chore: Show warp button in debug mode only

This commit is contained in:
Vsevolod Kremianskii 2020-08-08 11:42:27 +07:00
parent 92e9e170db
commit ee468c5d71
10 changed files with 32 additions and 26 deletions

View file

@ -75,7 +75,7 @@ void Game::configure() {
}
void Game::loadMainMenu() {
unique_ptr<MainMenu> mainMenu(new MainMenu(_opts.graphics));
unique_ptr<MainMenu> mainMenu(new MainMenu(_opts));
mainMenu->load(_version);
mainMenu->initGL();
mainMenu->setOnExit([this]() { _quit = true; });

View file

@ -54,8 +54,8 @@ void DebugGui::update(const DebugContext &ctx) {
float textWidth = _font->measure(object.text);
Control::Extent extent(
_opts.width * object.screenCoords.x - 0.5f * textWidth,
_opts.height * (1.0f - object.screenCoords.y),
_gfxOpts.width * object.screenCoords.x - 0.5f * textWidth,
_gfxOpts.height * (1.0f - object.screenCoords.y),
textWidth,
_font->height());

View file

@ -71,9 +71,9 @@ void DialogGui::addTopFrame() {
void DialogGui::addBottomFrame() {
int rootTop = _rootControl->extent().top;
int height = _opts.height - rootTop;
int height = _gfxOpts.height - rootTop;
addFrame(_opts.height - rootTop - height, height);
addFrame(_gfxOpts.height - rootTop - height, height);
}
void DialogGui::addFrame(int top, int height) {
@ -82,7 +82,7 @@ void DialogGui::addFrame(int top, int height) {
Control::Extent extent;
extent.left = -_rootControl->extent().left;
extent.top = top;
extent.width = _opts.width;
extent.width = _gfxOpts.width;
extent.height = height;
Control::Border border;

View file

@ -30,7 +30,7 @@ namespace reone {
namespace game {
MainMenu::MainMenu(const GraphicsOptions &opts) : GUI(opts) {
MainMenu::MainMenu(const Options &opts) : GUI(opts.graphics), _opts(opts) {
_resolutionX = 800;
_resolutionY = 600;
}
@ -42,6 +42,10 @@ void MainMenu::load(GameVersion version) {
hideControl("LBL_NEWCONTENT");
hideControl("LBL_BW");
hideControl("LBL_LUCAS");
if (!_opts.debug) {
hideControl("BTN_WARP");
}
}
string MainMenu::getResRef(GameVersion version) const {

View file

@ -20,13 +20,15 @@
#include "../../gui/gui.h"
#include "../../resources/types.h"
#include "../types.h"
namespace reone {
namespace game {
class MainMenu : public gui::GUI {
public:
MainMenu(const render::GraphicsOptions &opts);
MainMenu(const Options &opts);
void load(resources::GameVersion version);
void onClick(const std::string &control) override;
@ -36,6 +38,7 @@ public:
void setOnModuleSelected(const std::function<void(const std::string &)> &fn);
private:
Options _opts;
std::function<void()> _onNewGame;
std::function<void()> _onExit;
std::function<void(const std::string &)> _onModuleSelected;

View file

@ -103,6 +103,7 @@ struct Options {
render::GraphicsOptions graphics;
audio::AudioOptions audio;
net::NetworkOptions network;
bool debug { false };
};
struct UpdateContext {

View file

@ -36,9 +36,9 @@ namespace reone {
namespace gui {
GUI::GUI(const GraphicsOptions &opts) : _opts(opts) {
_screenCenter.x = 0.5f * _opts.width;
_screenCenter.y = 0.5f * _opts.height;
GUI::GUI(const GraphicsOptions &opts) : _gfxOpts(opts) {
_screenCenter.x = 0.5f * _gfxOpts.width;
_screenCenter.y = 0.5f * _gfxOpts.height;
}
void GUI::load(const string &resRef, BackgroundType background) {
@ -87,29 +87,29 @@ void GUI::load(const string &resRef, BackgroundType background) {
void GUI::positionRelativeToCenter(Control &control) {
Control::Extent extent(control.extent());
if (extent.left >= 0.5f * _resolutionX) {
extent.left = extent.left - _resolutionX + _opts.width;
extent.left = extent.left - _resolutionX + _gfxOpts.width;
}
if (extent.top >= 0.5f * _resolutionY) {
extent.top = extent.top - _resolutionY + _opts.height;
extent.top = extent.top - _resolutionY + _gfxOpts.height;
}
control.setExtent(move(extent));
}
void GUI::stretchControl(Control &control) {
float aspectX = _opts.width / static_cast<float>(_resolutionX);
float aspectY = _opts.height / static_cast<float>(_resolutionY);
float aspectX = _gfxOpts.width / static_cast<float>(_resolutionX);
float aspectY = _gfxOpts.height / static_cast<float>(_resolutionY);
control.stretch(aspectX, aspectY);
}
void GUI::loadBackground(BackgroundType type) {
string resRef;
if ((_opts.width == 1600 && _opts.height == 1200) ||
(_opts.width == 1280 && _opts.height == 960) ||
(_opts.width == 1024 && _opts.height == 768) ||
(_opts.width == 800 && _opts.height == 600)) {
if ((_gfxOpts.width == 1600 && _gfxOpts.height == 1200) ||
(_gfxOpts.width == 1280 && _gfxOpts.height == 960) ||
(_gfxOpts.width == 1024 && _gfxOpts.height == 768) ||
(_gfxOpts.width == 800 && _gfxOpts.height == 600)) {
resRef = str(boost::format("%dx%d") % _opts.width % _opts.height);
resRef = str(boost::format("%dx%d") % _gfxOpts.width % _gfxOpts.height);
} else {
resRef = "1600x1200";
}
@ -187,7 +187,7 @@ void GUI::render() const {
}
void GUI::renderBackground() const {
glm::mat4 transform(glm::scale(glm::mat4(1.0f), glm::vec3(_opts.width, _opts.height, 1.0f)));
glm::mat4 transform(glm::scale(glm::mat4(1.0f), glm::vec3(_gfxOpts.width, _gfxOpts.height, 1.0f)));
ShaderManager &shaders = ShaderManager::instance();
shaders.activate(ShaderProgram::BasicDiffuse);

View file

@ -50,7 +50,7 @@ protected:
Stretch
};
render::GraphicsOptions _opts;
render::GraphicsOptions _gfxOpts;
int _resolutionX { kDefaultResolutionX };
int _resolutionY { kDefaultResolutionY };
ScalingMode _scaling { ScalingMode::Center };

View file

@ -83,7 +83,6 @@ void Program::loadOptions() {
_help = _vars.count("help") > 0;
_gamePath = _vars.count("game") ? _vars["game"].as<string>() : fs::current_path();
_debug = _vars["debug"].as<bool>();
_gameOpts.graphics.width = _vars["width"].as<int>();
_gameOpts.graphics.height = _vars["height"].as<int>();
_gameOpts.graphics.fullscreen = _vars["fullscreen"].as<bool>();
@ -91,9 +90,9 @@ void Program::loadOptions() {
_gameOpts.audio.soundVolume = _vars["soundvol"].as<int>();
_gameOpts.network.host = _vars.count("join") ? _vars["join"].as<string>() : "";
_gameOpts.network.port = _vars["port"].as<int>();
_gameOpts.debug = _vars["debug"].as<bool>();
bool debug = _vars["debug"].as<bool>();
setDebugLogEnabled(debug);
setDebugLogEnabled(_gameOpts.debug);
initGameVersion();
initMultiplayerMode();

View file

@ -47,7 +47,6 @@ private:
boost::program_options::variables_map _vars;
bool _help { false };
boost::filesystem::path _gamePath;
bool _debug { false };
game::Options _gameOpts;
resources::GameVersion _version { resources::GameVersion::KotOR };
game::MultiplayerMode _multiplayer { game::MultiplayerMode::None };