Skip to content

Commit

Permalink
JADE: Add background to main menu
Browse files Browse the repository at this point in the history
  • Loading branch information
farmboy0 committed Dec 22, 2017
1 parent 02b66c6 commit 30da7f8
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 4 deletions.
39 changes: 35 additions & 4 deletions src/engines/jade/gui/main/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,15 @@
* The Jade Empire main menu.
*/

#include "src/common/util.h"
#include "src/common/configman.h"
#include "src/common/error.h"
#include "src/common/ustring.h"

#include "src/aurora/2dareg.h"
#include "src/aurora/2dafile.h"
#include "src/aurora/talkman.h"

#include "src/graphics/windowman.h"

#include "src/engines/jade/arealayout.h"
#include "src/engines/jade/module.h"

#include "src/engines/jade/gui/main/main.h"
Expand All @@ -41,7 +44,7 @@ namespace Engines {
namespace Jade {

MainMenu::MainMenu(Module &module, ::Engines::Console *console) : ::Engines::KotOR::GUI(console),
_module(&module) {
_module(&module), _background(0) {

load("maingame");

Expand Down Expand Up @@ -75,9 +78,25 @@ MainMenu::MainMenu(Module &module, ::Engines::Console *console) : ::Engines::Kot
float tX, tY, tZ;
getLabel("TitleLabel")->getPosition(tX, tY, tZ);
getLabel("TitleLabel")->setPosition(tX-80, tY+52, tZ);

addBackground();
}

MainMenu::~MainMenu() {
delete _background;
_background = NULL;
}

void MainMenu::show() {
if (_background)
_background->show();
::Engines::KotOR::GUI::show();
}

void MainMenu::hide() {
if (_background)
_background->hide();
::Engines::KotOR::GUI::hide();
}

void MainMenu::callbackActive(Widget &widget) {
Expand All @@ -93,6 +112,18 @@ void MainMenu::callbackActive(Widget &widget) {
}
}

void MainMenu::addBackground() {
const Aurora::TwoDAFile &startrooms = TwoDAReg.get2DA("startrooms");

Common::UString currentChapter = ConfigMan.getString("chapter", "1");
if (startrooms.getRow("chapter", currentChapter).empty("room"))
currentChapter = "1";

const Common::UString &room = startrooms.getRow("chapter", currentChapter).getString("room");

_background = new AreaLayout(room);
}

} // End of namespace Jade

} // End of namespace Engines
7 changes: 7 additions & 0 deletions src/engines/jade/gui/main/main.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,25 @@ namespace Engines {

namespace Jade {

class AreaLayout;
class Module;

class MainMenu : public ::Engines::KotOR::GUI {
public:
MainMenu(Module &module, ::Engines::Console *console = 0);
~MainMenu();

void show(); ///< Show the GUI.
void hide(); ///< Hide the GUI.

protected:
void callbackActive(Widget &widget);
void addBackground();

private:
Module *_module;

AreaLayout *_background;
};

} // End of namespace Jade
Expand Down

0 comments on commit 30da7f8

Please sign in to comment.