missing-content panel scroll fix
This commit is contained in:
@@ -23,7 +23,7 @@ GUI::GUI() {
|
|||||||
|
|
||||||
menu = std::make_shared<PagesControl>();
|
menu = std::make_shared<PagesControl>();
|
||||||
container->add(menu);
|
container->add(menu);
|
||||||
container->scrollable(false);
|
container->setScrollable(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
GUI::~GUI() {
|
GUI::~GUI() {
|
||||||
|
|||||||
@@ -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],
|
setSize(content->getSize()+vec2(padding[0]+padding[2]+margin[0]+margin[2],
|
||||||
padding[1]+padding[3]+margin[1]+margin[3]));
|
padding[1]+padding[3]+margin[1]+margin[3]));
|
||||||
add(content);
|
add(content);
|
||||||
scrollable(false);
|
setScrollable(false);
|
||||||
setHoverColor(glm::vec4(0.05f, 0.1f, 0.15f, 0.75f));
|
setHoverColor(glm::vec4(0.05f, 0.1f, 0.15f, 0.75f));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -117,7 +117,7 @@ Button::Button(
|
|||||||
if (action) {
|
if (action) {
|
||||||
listenAction(action);
|
listenAction(action);
|
||||||
}
|
}
|
||||||
scrollable(false);
|
setScrollable(false);
|
||||||
|
|
||||||
label = std::make_shared<Label>(text);
|
label = std::make_shared<Label>(text);
|
||||||
label->setAlign(Align::center);
|
label->setAlign(Align::center);
|
||||||
@@ -253,7 +253,7 @@ void TextBox::drawBackground(const GfxContext* pctx, Assets* assets) {
|
|||||||
label->setColor(vec4(1.0f));
|
label->setColor(vec4(1.0f));
|
||||||
label->setText(input);
|
label->setText(input);
|
||||||
}
|
}
|
||||||
scrollable(false);
|
setScrollable(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextBox::typed(unsigned int codepoint) {
|
void TextBox::typed(unsigned int codepoint) {
|
||||||
@@ -343,7 +343,7 @@ InputBindBox::InputBindBox(Binding& binding, vec4 padding)
|
|||||||
binding(binding) {
|
binding(binding) {
|
||||||
label = std::make_shared<Label>(L"");
|
label = std::make_shared<Label>(L"");
|
||||||
add(label);
|
add(label);
|
||||||
scrollable(false);
|
setScrollable(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void InputBindBox::drawBackground(const GfxContext* pctx, Assets* assets) {
|
void InputBindBox::drawBackground(const GfxContext* pctx, Assets* assets) {
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ void Container::act(float delta) {
|
|||||||
|
|
||||||
void Container::scrolled(int value) {
|
void Container::scrolled(int value) {
|
||||||
int diff = (actualLength-getSize().y);
|
int diff = (actualLength-getSize().y);
|
||||||
if (diff > 0 && scrollable_) {
|
if (diff > 0 && scrollable) {
|
||||||
scroll += value * 40;
|
scroll += value * 40;
|
||||||
if (scroll > 0)
|
if (scroll > 0)
|
||||||
scroll = 0;
|
scroll = 0;
|
||||||
@@ -74,8 +74,8 @@ void Container::scrolled(int value) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Container::scrollable(bool flag) {
|
void Container::setScrollable(bool flag) {
|
||||||
scrollable_ = flag;
|
scrollable = flag;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Container::draw(const GfxContext* pctx, Assets* assets) {
|
void Container::draw(const GfxContext* pctx, Assets* assets) {
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ namespace gui {
|
|||||||
std::vector<IntervalEvent> intervalEvents;
|
std::vector<IntervalEvent> intervalEvents;
|
||||||
int scroll = 0;
|
int scroll = 0;
|
||||||
int actualLength = 0;
|
int actualLength = 0;
|
||||||
bool scrollable_ = true;
|
bool scrollable = true;
|
||||||
public:
|
public:
|
||||||
Container(glm::vec2 coord, glm::vec2 size);
|
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 add(std::shared_ptr<UINode> node, glm::vec2 coord);
|
||||||
virtual void remove(std::shared_ptr<UINode> node);
|
virtual void remove(std::shared_ptr<UINode> node);
|
||||||
virtual void scrolled(int value) override;
|
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);
|
void listenInterval(float interval, ontimeout callback, int repeat=-1);
|
||||||
virtual glm::vec2 contentOffset() override {return glm::vec2(0.0f, scroll);};
|
virtual glm::vec2 contentOffset() override {return glm::vec2(0.0f, scroll);};
|
||||||
virtual void setSize(glm::vec2 size);
|
virtual void setSize(glm::vec2 size);
|
||||||
|
|||||||
@@ -276,7 +276,7 @@ HudRenderer::HudRenderer(Engine* engine, LevelFrontend* frontend)
|
|||||||
);
|
);
|
||||||
contentAccessPanel->setColor(glm::vec4());
|
contentAccessPanel->setColor(glm::vec4());
|
||||||
contentAccessPanel->add(contentAccess);
|
contentAccessPanel->add(contentAccess);
|
||||||
contentAccessPanel->scrollable(true);
|
contentAccessPanel->setScrollable(true);
|
||||||
|
|
||||||
hotbarView = createHotbar();
|
hotbarView = createHotbar();
|
||||||
inventoryView = createInventory();
|
inventoryView = createInventory();
|
||||||
|
|||||||
@@ -96,6 +96,9 @@ static void show_content_missing(
|
|||||||
|
|
||||||
auto subpanel = std::make_shared<Panel>(vec2(500, 100));
|
auto subpanel = std::make_shared<Panel>(vec2(500, 100));
|
||||||
subpanel->setColor(vec4(0.0f, 0.0f, 0.0f, 0.5f));
|
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()) {
|
for (auto& entry : lut->getMissingContent()) {
|
||||||
auto hpanel = std::make_shared<Panel>(vec2(500, 30));
|
auto hpanel = std::make_shared<Panel>(vec2(500, 30));
|
||||||
@@ -112,8 +115,7 @@ static void show_content_missing(
|
|||||||
hpanel->add(namelabel);
|
hpanel->add(namelabel);
|
||||||
subpanel->add(hpanel);
|
subpanel->add(hpanel);
|
||||||
}
|
}
|
||||||
subpanel->setMaxLength(400);
|
|
||||||
panel->add(subpanel);
|
|
||||||
|
|
||||||
panel->add(std::make_shared<Button>(
|
panel->add(std::make_shared<Button>(
|
||||||
langs::get(L"Back to Main Menu", L"menu"), vec4(8.0f), [=](GUI*){
|
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) {
|
void create_languages_panel(Engine* engine) {
|
||||||
auto menu = engine->getGUI()->getMenu();
|
auto menu = engine->getGUI()->getMenu();
|
||||||
auto panel = create_page(engine, "languages", 400, 0.5f, 1);
|
auto panel = create_page(engine, "languages", 400, 0.5f, 1);
|
||||||
panel->scrollable(true);
|
panel->setScrollable(true);
|
||||||
|
|
||||||
std::vector<std::string> locales;
|
std::vector<std::string> locales;
|
||||||
for (auto& entry : langs::locales_info) {
|
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) {
|
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->setColor(vec4(1.0f, 1.0f, 1.0f, 0.07f));
|
||||||
panel->setMaxLength(400);
|
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));
|
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->setColor(vec4(1.0f, 1.0f, 1.0f, 0.07f));
|
||||||
panel->setMaxLength(400);
|
panel->setMaxLength(400);
|
||||||
panel->scrollable(true);
|
panel->setScrollable(true);
|
||||||
|
|
||||||
for (auto& pack : packs) {
|
for (auto& pack : packs) {
|
||||||
auto packpanel = std::make_shared<RichButton>(vec2(390, 80));
|
auto packpanel = std::make_shared<RichButton>(vec2(390, 80));
|
||||||
|
|||||||
Reference in New Issue
Block a user