Skip to content

Commit

Permalink
KOTOR2: Add GUI to implement KotOR2 specific scaling
Browse files Browse the repository at this point in the history
  • Loading branch information
Nostritius authored and DrMcCoy committed Nov 3, 2018
1 parent 4830f8f commit b690a24
Show file tree
Hide file tree
Showing 3 changed files with 77 additions and 1 deletion.
69 changes: 69 additions & 0 deletions src/engines/kotor2/gui/gui.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
/* xoreos - A reimplementation of BioWare's Aurora engine
*
* xoreos is the legal property of its developers, whose names
* can be found in the AUTHORS file distributed with this source
* distribution.
*
* xoreos is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 3
* of the License, or (at your option) any later version.
*
* xoreos is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with xoreos. If not, see <http://www.gnu.org/licenses/>.
*/

/** @file
* A KotOR2 GUI.
*/

#include "src/graphics/windowman.h"

#include "src/engines/aurora/kotorjadegui/kotorjadewidget.h"
#include "src/engines/kotor2/gui/gui.h"

namespace Engines {

namespace KotOR2 {

GUI::GUI(::Engines::Console *console) : Engines::KotOR::GUI(console) {
}

void GUI::initWidget(Widget &widget) {
KotORJadeWidget &kotorWidget = static_cast<KotORJadeWidget &>(widget);

float wWidth = WindowMan.getWindowWidth();
float wHeight = WindowMan.getWindowHeight();

if (widget.getTag() == "TGuiPanel") {
kotorWidget.setWidth(wWidth);
kotorWidget.setHeight(wHeight);
} else {
float x, y, z;
kotorWidget.getPosition(x, y, z);

x *= ((wWidth / 2.0f) / 400.0f);
y *= ((wHeight / 2.0f) / 300.0f);

kotorWidget.setPosition(x, y, z);

float w, h;
w = kotorWidget.getWidth();
h = kotorWidget.getHeight();

w *= (wWidth / 800.0f);
h *= (wHeight / 600.0f);

kotorWidget.setWidth(w);
kotorWidget.setHeight(h);
}
}

} // End of namespace KotOR2

} // End of namespace Engines
8 changes: 7 additions & 1 deletion src/engines/kotor2/gui/gui.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,13 @@ namespace Engines {

namespace KotOR2 {

using ::Engines::KotOR::GUI;
class GUI : public Engines::KotOR::GUI {
public:
GUI(::Engines::Console *console);

protected:
virtual void initWidget(Widget &widget);
};

} // End of namespace KotOR2

Expand Down
1 change: 1 addition & 0 deletions src/engines/kotor2/gui/rules.mk
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ src_engines_kotor2_libkotor2_la_SOURCES += \
$(EMPTY)

src_engines_kotor2_libkotor2_la_SOURCES += \
src/engines/kotor2/gui/gui.cpp \
src/engines/kotor2/gui/dialog.cpp \
$(EMPTY)

Expand Down

0 comments on commit b690a24

Please sign in to comment.