1
0
mirror of https://github.com/k4zmu2a/SpaceCadetPinball.git synced 2024-11-22 02:32:39 +01:00

Options refactor part 2.1: fixed control option labels.

This commit is contained in:
Muzychenko Andrey 2023-02-10 08:46:09 +03:00
parent d99fbb092e
commit 8df996f452
3 changed files with 44 additions and 45 deletions

View File

@ -23,36 +23,42 @@ optionsStruct options::Options
{
{
"Left Flipper key",
Msg::KEYMAPPER_FlipperL,
{InputTypes::Keyboard, SDLK_z},
{InputTypes::Mouse, SDL_BUTTON_LEFT},
{InputTypes::GameController, SDL_CONTROLLER_BUTTON_LEFTSHOULDER}
},
{
"Right Flipper key",
Msg::KEYMAPPER_FlipperR,
{InputTypes::Keyboard, SDLK_SLASH},
{InputTypes::Mouse,SDL_BUTTON_RIGHT},
{InputTypes::GameController, SDL_CONTROLLER_BUTTON_RIGHTSHOULDER}
},
{
"Plunger key",
Msg::KEYMAPPER_Plunger,
{InputTypes::Keyboard, SDLK_SPACE},
{InputTypes::Mouse,SDL_BUTTON_MIDDLE},
{InputTypes::GameController, SDL_CONTROLLER_BUTTON_A}
},
{
"Left Table Bump key",
Msg::KEYMAPPER_BumpLeft,
{InputTypes::Keyboard, SDLK_x},
{InputTypes::Mouse,SDL_BUTTON_X1},
{InputTypes::GameController, SDL_CONTROLLER_BUTTON_DPAD_LEFT}
},
{
"Right Table Bump key",
Msg::KEYMAPPER_BumpRight,
{InputTypes::Keyboard, SDLK_PERIOD},
{InputTypes::Mouse,SDL_BUTTON_X2},
{InputTypes::GameController, SDL_CONTROLLER_BUTTON_DPAD_RIGHT}
},
{
"Bottom Table Bump key",
Msg::KEYMAPPER_BumpBottom,
{InputTypes::Keyboard, SDLK_UP},
{InputTypes::Mouse,SDL_BUTTON_X2 + 1},
{InputTypes::GameController, SDL_CONTROLLER_BUTTON_DPAD_UP}
@ -299,16 +305,6 @@ void options::ShowControlDialog()
void options::RenderControlDialog()
{
static const Msg controlDescriptions[6]
{
Msg::KEYMAPPER_FlipperL,
Msg::KEYMAPPER_FlipperR,
Msg::KEYMAPPER_BumpLeft,
Msg::KEYMAPPER_BumpRight,
Msg::KEYMAPPER_BumpBottom,
Msg::KEYMAPPER_Plunger,
};
if (!ShowDialog)
return;
@ -325,7 +321,9 @@ void options::RenderControlDialog()
ImGui::TextUnformatted(pb::get_rc_string(Msg::KEYMAPPER_Groupbox1));
ImGui::PushStyleVar(ImGuiStyleVar_CellPadding, ImVec2{5, 10});
if (ImGui::BeginTable("Controls", 4, ImGuiTableFlags_NoSavedSettings | ImGuiTableFlags_Borders| ImGuiTableFlags_SizingStretchSame))
if (ImGui::BeginTable("Controls", 4,
ImGuiTableFlags_NoSavedSettings | ImGuiTableFlags_Borders |
ImGuiTableFlags_SizingStretchSame))
{
ImGui::TableSetupColumn("Control");
ImGui::TableSetupColumn("Binding 1");
@ -334,13 +332,11 @@ void options::RenderControlDialog()
ImGui::TableHeadersRow();
int rowHash = 0;
for (auto inputId = GameBindings::Min; inputId < GameBindings::Max; inputId++)
for (auto& option : Options.Key)
{
auto& option = Options.Key[~inputId];
ImGui::TableNextColumn();
ImGui::PushStyleColor(ImGuiCol_Button, ImVec4{0.5, 0, 0, 1});
if (ImGui::Button(pb::get_rc_string(controlDescriptions[~inputId])))
if (ImGui::Button(pb::get_rc_string(option.Description), ImVec2(-1, 0)))
{
for (auto& input : option.Inputs)
input = {};

View File

@ -191,11 +191,14 @@ struct BoolOption : OptionBaseT<bool>
struct ControlOption : OptionBase
{
const Msg Description;
GameInput Defaults[3];
GameInput Inputs[3];
ControlOption(LPCSTR name, GameInput defaultKeyboard, GameInput defaultMouse, GameInput defaultController) :
ControlOption(LPCSTR name, Msg description, GameInput defaultKeyboard, GameInput defaultMouse,
GameInput defaultController) :
OptionBase(name),
Description(description),
Defaults{defaultKeyboard, defaultMouse, defaultController},
Inputs{
{InputTypes::Keyboard, -1},