diff --git a/src/game/gui/mainmenu.cpp b/src/game/gui/mainmenu.cpp index 11af4b9b..cc59b29c 100644 --- a/src/game/gui/mainmenu.cpp +++ b/src/game/gui/mainmenu.cpp @@ -51,8 +51,6 @@ static const char kBlueprintResRefBastila[] = "p_bastilla"; static const char kBlueprintResRefAtton[] = "p_atton"; static const char kBlueprintResRefKreia[] = "p_kreia"; -static bool g_warpEnabled = true; - MainMenu::MainMenu(Game *game) : GameGUI(game->gameId(), game->options().graphics), _game(game) { @@ -84,27 +82,13 @@ void MainMenu::load() { setControlDisabled("BTN_MOVIES", true); setControlDisabled("BTN_OPTIONS", true); - if (!g_warpEnabled) { + // Hide warp button in developer mode + if (!_game->options().developer) { hideControl("BTN_WARP"); } + + setup3DView(); configureButtons(); - - if (_gameId == GameID::KotOR) { - Control &control = getControl("LBL_3DVIEW"); - const Control::Extent &extent = control.extent(); - float aspect = extent.width / static_cast(extent.height); - - unique_ptr scene(SceneBuilder(_gfxOpts) - .aspect(aspect) - .depth(0.1f, 10.0f) - .modelSupplier(bind(&MainMenu::getKotorModel, this, _1)) - .modelScale(kKotorModelSize) - .cameraFromModelNode("camerahook") - .ambientLightColor(glm::vec3(0.1f)) - .build()); - - control.setScene3D(move(scene)); - } } void MainMenu::configureButtons() { @@ -121,14 +105,27 @@ void MainMenu::configureButtons() { void MainMenu::setButtonColors(const string &tag) { Control &control = getControl(tag); + control.setTextColor(getBaseColor(_gameId)); + control.setHilightColor(getHilightColor(_gameId)); +} - Control::Text text(control.text()); - text.color = getBaseColor(_gameId); - control.setText(move(text)); +void MainMenu::setup3DView() { + if (_gameId != GameID::KotOR) return; - Control::Border hilight(control.hilight()); - hilight.color = getHilightColor(_gameId); - control.setHilight(move(hilight)); + Control &control = getControl("LBL_3DVIEW"); + const Control::Extent &extent = control.extent(); + float aspect = extent.width / static_cast(extent.height); + + unique_ptr scene(SceneBuilder(_gfxOpts) + .aspect(aspect) + .depth(0.1f, 10.0f) + .modelSupplier(bind(&MainMenu::getKotorModel, this, _1)) + .modelScale(kKotorModelSize) + .cameraFromModelNode("camerahook") + .ambientLightColor(glm::vec3(0.1f)) + .build()); + + control.setScene3D(move(scene)); } shared_ptr MainMenu::getKotorModel(SceneGraph &sceneGraph) { @@ -136,7 +133,6 @@ shared_ptr MainMenu::getKotorModel(SceneGraph &sceneGraph) { model->setDefaultAnimation("default"); model->playDefaultAnimation(); model->setLightingEnabled(true); - return move(model); } @@ -167,16 +163,23 @@ void MainMenu::startModuleSelection() { hideControl("LBL_GAMELOGO"); hideControl("LBL_MENUBG"); - ListBox &modules = static_cast(getControl("LB_MODULES")); + loadModuleNames(); +} + +void MainMenu::loadModuleNames() { + auto &modules = getControl("LB_MODULES"); for (auto &module : Resources::instance().moduleNames()) { - modules.addItem({ module, module }); + ListBox::Item item; + item.tag = module; + item.text = module; + modules.addItem(move(item)); } } void MainMenu::onListBoxItemClick(const string &control, const string &item) { - if (control != "LB_MODULES") return; - - onModuleSelected(item); + if (control == "LB_MODULES") { + onModuleSelected(item); + } } void MainMenu::onModuleSelected(const string &name) { diff --git a/src/game/gui/mainmenu.h b/src/game/gui/mainmenu.h index f86049ee..2e036e17 100644 --- a/src/game/gui/mainmenu.h +++ b/src/game/gui/mainmenu.h @@ -36,7 +36,6 @@ public: MainMenu(Game *game); void load() override; - void onClick(const std::string &control) override; void onModuleSelected(const std::string &name); @@ -47,9 +46,12 @@ private: void onListBoxItemClick(const std::string &control, const std::string &item) override; void configureButtons(); + void setup3DView(); void setButtonColors(const std::string &tag); - std::shared_ptr getKotorModel(scene::SceneGraph &sceneGraph); void startModuleSelection(); + void loadModuleNames(); + + std::shared_ptr getKotorModel(scene::SceneGraph &sceneGraph); }; } // namespace game diff --git a/src/game/options.h b/src/game/options.h index d6ee5259..c0ec5742 100644 --- a/src/game/options.h +++ b/src/game/options.h @@ -28,6 +28,7 @@ namespace reone { namespace game { struct Options { + bool developer { false }; std::string module; render::GraphicsOptions graphics; audio::AudioOptions audio; diff --git a/src/program.cpp b/src/program.cpp index 3cb432bb..f7ca8071 100644 --- a/src/program.cpp +++ b/src/program.cpp @@ -64,6 +64,7 @@ int Program::run() { void Program::initOptions() { _commonOpts.add_options() ("game", po::value(), "path to game directory") + ("dev", po::value()->default_value(false), "enable developer mode") ("module", po::value(), "name of a module to load") ("width", po::value()->default_value(800), "window width") ("height", po::value()->default_value(600), "window height") @@ -96,6 +97,7 @@ void Program::loadOptions() { _showHelp = vars.count("help") > 0; _gamePath = vars.count("game") > 0 ? vars["game"].as() : fs::current_path(); + _gameOpts.developer = vars["dev"].as(); _gameOpts.module = vars.count("module") > 0 ? vars["module"].as() : ""; _gameOpts.graphics.width = vars["width"].as(); _gameOpts.graphics.height = vars["height"].as();