missing-content panel scroll fix

This commit is contained in:
MihailRis 2024-02-04 03:31:11 +03:00
parent 01df957859
commit e9efdb0e7b
6 changed files with 18 additions and 16 deletions

View File

@ -23,7 +23,7 @@ GUI::GUI() {
menu = std::make_shared<PagesControl>();
container->add(menu);
container->scrollable(false);
container->setScrollable(false);
}
GUI::~GUI() {

View File

@ -95,7 +95,7 @@ Button::Button(std::shared_ptr<UINode> content, glm::vec4 padding)
setSize(content->getSize()+vec2(padding[0]+padding[2]+margin[0]+margin[2],
padding[1]+padding[3]+margin[1]+margin[3]));
add(content);
scrollable(false);
setScrollable(false);
setHoverColor(glm::vec4(0.05f, 0.1f, 0.15f, 0.75f));
}
@ -117,7 +117,7 @@ Button::Button(
if (action) {
listenAction(action);
}
scrollable(false);
setScrollable(false);
label = std::make_shared<Label>(text);
label->setAlign(Align::center);
@ -253,7 +253,7 @@ void TextBox::drawBackground(const GfxContext* pctx, Assets* assets) {
label->setColor(vec4(1.0f));
label->setText(input);
}
scrollable(false);
setScrollable(false);
}
void TextBox::typed(unsigned int codepoint) {
@ -343,7 +343,7 @@ InputBindBox::InputBindBox(Binding& binding, vec4 padding)
binding(binding) {
label = std::make_shared<Label>(L"");
add(label);
scrollable(false);
setScrollable(false);
}
void InputBindBox::drawBackground(const GfxContext* pctx, Assets* assets) {

View File

@ -62,7 +62,7 @@ void Container::act(float delta) {
void Container::scrolled(int value) {
int diff = (actualLength-getSize().y);
if (diff > 0 && scrollable_) {
if (diff > 0 && scrollable) {
scroll += value * 40;
if (scroll > 0)
scroll = 0;
@ -74,8 +74,8 @@ void Container::scrolled(int value) {
}
}
void Container::scrollable(bool flag) {
scrollable_ = flag;
void Container::setScrollable(bool flag) {
scrollable = flag;
}
void Container::draw(const GfxContext* pctx, Assets* assets) {

View File

@ -30,7 +30,7 @@ namespace gui {
std::vector<IntervalEvent> intervalEvents;
int scroll = 0;
int actualLength = 0;
bool scrollable_ = true;
bool scrollable = true;
public:
Container(glm::vec2 coord, glm::vec2 size);
@ -43,7 +43,7 @@ namespace gui {
virtual void add(std::shared_ptr<UINode> node, glm::vec2 coord);
virtual void remove(std::shared_ptr<UINode> node);
virtual void scrolled(int value) override;
virtual void scrollable(bool flag);
virtual void setScrollable(bool flag);
void listenInterval(float interval, ontimeout callback, int repeat=-1);
virtual glm::vec2 contentOffset() override {return glm::vec2(0.0f, scroll);};
virtual void setSize(glm::vec2 size);

View File

@ -276,7 +276,7 @@ HudRenderer::HudRenderer(Engine* engine, LevelFrontend* frontend)
);
contentAccessPanel->setColor(glm::vec4());
contentAccessPanel->add(contentAccess);
contentAccessPanel->scrollable(true);
contentAccessPanel->setScrollable(true);
hotbarView = createHotbar();
inventoryView = createInventory();

View File

@ -96,6 +96,9 @@ static void show_content_missing(
auto subpanel = std::make_shared<Panel>(vec2(500, 100));
subpanel->setColor(vec4(0.0f, 0.0f, 0.0f, 0.5f));
subpanel->setScrollable(true);
subpanel->setMaxLength(400);
panel->add(subpanel);
for (auto& entry : lut->getMissingContent()) {
auto hpanel = std::make_shared<Panel>(vec2(500, 30));
@ -112,8 +115,7 @@ static void show_content_missing(
hpanel->add(namelabel);
subpanel->add(hpanel);
}
subpanel->setMaxLength(400);
panel->add(subpanel);
panel->add(std::make_shared<Button>(
langs::get(L"Back to Main Menu", L"menu"), vec4(8.0f), [=](GUI*){
@ -143,7 +145,7 @@ void show_convert_request(
void create_languages_panel(Engine* engine) {
auto menu = engine->getGUI()->getMenu();
auto panel = create_page(engine, "languages", 400, 0.5f, 1);
panel->scrollable(true);
panel->setScrollable(true);
std::vector<std::string> locales;
for (auto& entry : langs::locales_info) {
@ -211,7 +213,7 @@ void open_world(std::string name, Engine* engine) {
}
std::shared_ptr<Panel> create_worlds_panel(Engine* engine) {
auto panel = std::make_shared<Panel>(vec2(390, 200), vec4(5.0f));
auto panel = std::make_shared<Panel>(vec2(390, 0), vec4(5.0f));
panel->setColor(vec4(1.0f, 1.0f, 1.0f, 0.07f));
panel->setMaxLength(400);
@ -278,7 +280,7 @@ std::shared_ptr<Panel> create_packs_panel(
auto panel = std::make_shared<Panel>(vec2(PACKS_PANEL_WIDTH, 200), vec4(5.0f));
panel->setColor(vec4(1.0f, 1.0f, 1.0f, 0.07f));
panel->setMaxLength(400);
panel->scrollable(true);
panel->setScrollable(true);
for (auto& pack : packs) {
auto packpanel = std::make_shared<RichButton>(vec2(390, 80));