jak-project/game/settings/settings.h
Tyler Wilding d819d6da05
Some checks failed
Lint / 📝 Optional Checks (push) Has been cancelled
Build / 🖥️ Windows (push) Has been cancelled
Build / 🐧 Linux (push) Has been cancelled
Build / 🍎 MacOS (push) Has been cancelled
Inform Pages Repo / Generate Documentation (push) Has been cancelled
Lint / 📝 Formatting (push) Has been cancelled
Lint / 📝 Required Checks (push) Has been cancelled
game: cleanup some display settings related code, forbid invalid game-size resolutions (#3601)
Fixes https://github.com/open-goal/jak-project/issues/3563

These users have the following spamming in logs:
> OpenGL error 0x502 S8246 T824C: GL_INVALID_OPERATION error generated.
Source and destination dimensions must be identical with the current
filtering modes.

And the solution is to correctly set their game-size. The way this
change accomplishes that is by confirming whether or not the set
`game-size` is a valid resolution informed by SDL, if not, it defaults
to the monitor's currently set display mode's resolution.

This also moves the selected display id, and the display mode into the
C++ settings -- closer to where it's actually managed and used. I'm
tempted to do this eventually for the resolutions as well but that stuff
is much more burdensome. This hopefully simplifies debugging, reduces
startup flickering, and removes back-and-forth complexity. Hopefully
this makes debugging display related problems easier. It also adds a
bunch more logging to the related code.
2024-07-27 22:29:14 -04:00

79 lines
2 KiB
C++

#pragma once
#include "common/util/FileUtil.h"
#include "common/util/json_util.h"
#include "game/system/hid/input_bindings.h"
#include "game/system/hid/sdl_util.h"
#include "game/tools/filter_menu/filter_menu.h"
namespace game_settings {
struct DebugSettings {
DebugSettings();
std::string current_version = "1.2";
std::string version = current_version;
bool show_imgui = false;
int imgui_font_size = 16;
bool monospaced_font = true;
bool alternate_style = false;
bool ignore_hide_imgui = false;
bool treat_pad0_as_pad1 = false;
std::vector<DebugTextFilter> text_filters = {};
bool text_check_range = false;
float text_max_range = 0;
u32 hide_imgui_key = SDLK_LALT;
void load_settings();
void save_settings();
};
void to_json(json& j, const DebugSettings& obj);
void from_json(const json& j, DebugSettings& obj);
struct DisplaySettings {
enum class DisplayMode { Windowed = 0, Fullscreen = 1, Borderless = 2 };
DisplaySettings();
std::string current_version = "1.2";
std::string version = current_version;
int window_xpos = 50;
int window_ypos = 50;
int display_id = 0;
DisplayMode display_mode = DisplayMode::Borderless;
void load_settings();
void save_settings();
};
void to_json(json& j, const DisplaySettings& obj);
void from_json(const json& j, DisplaySettings& obj);
struct InputSettings {
InputSettings();
std::string current_version = "1.0";
std::string version = current_version;
// NOTE - assumes only port 0
std::string last_selected_controller_guid = "";
std::unordered_map<std::string, int> controller_port_mapping;
std::unordered_map<std::string, InputBindingGroups> controller_binds;
InputBindingGroups keyboard_binds;
InputBindingGroups mouse_binds;
bool keyboard_enabled = false;
bool keyboard_temp_enabled =
false; // not saved or restored, flips on if no controllers are detected
void load_settings();
void save_settings();
};
void to_json(json& j, const InputSettings& obj);
void from_json(const json& j, InputSettings& obj);
} // namespace game_settings