Skip to content

Commit

Permalink
JADE: Improve GUI to better handle child guis
Browse files Browse the repository at this point in the history
  • Loading branch information
Nostritius committed Jul 21, 2019
1 parent cb0d82a commit 28eaf57
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions src/engines/jade/gui/gui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ GUI::WidgetContext::WidgetContext(const Aurora::GFF3Struct &s, Widget *p) {
}


GUI::GUI(::Engines::Console *console) : ::Engines::GUI(console), _widgetZ(0), _guiHeight(0.0f), _guiWidth(0.0f) {
GUI::GUI(::Engines::Console *console) : ::Engines::GUI(console), _widgetZ(0), _guiHeight(480.0f), _guiWidth(640.0f) {
}

GUI::~GUI() {
Expand All @@ -85,7 +85,7 @@ void GUI::convertToXoreos(float &x, float &y, const float widgetHeight) const {

void GUI::convertToGUI(float &x, float &y, const float widgetHeight) const {
x = x + (_guiWidth / 2.0f);
y = widgetHeight + (-1.0f * (y - (_guiHeight / 2.0f)));
y = widgetHeight + (y - (_guiHeight / 2.0f));
}

Common::UString GUI::getName() const {
Expand Down Expand Up @@ -123,17 +123,22 @@ void GUI::loadWidget(const Aurora::GFF3Struct &strct, Widget *parent) {

createWidget(ctx);

if (_guiWidth <= 0.0f)
_guiWidth = ctx.widget->getWidth();
if (_guiHeight <= 0.0f)
_guiHeight = ctx.widget->getHeight();

float wX, wY, wZ;
ctx.widget->getPosition(wX, wY, wZ);

convertToXoreos(wX, wY, ctx.widget->getHeight());
wZ = _widgetZ + wZ;

if (parent) {
float pX, pY, pZ;
parent->getPosition(pX, pY, pZ);

convertToGUI(pX, pY, parent->getHeight());

wX += pX;
wY += pY;
}

ctx.widget->setPosition(wX, wY, wZ);

_widgetZ -= 1.0f;
Expand Down

0 comments on commit 28eaf57

Please sign in to comment.