Skip to content

Commit

Permalink
MenuConfig: Base visibility of some keybinds on menu configs
Browse files Browse the repository at this point in the history
- Bar1 through Bar0 based on menus/actionbar.txt config
- Next/Previous Equip Set based on menus/inventory.txt config
  • Loading branch information
dorkster committed Jan 24, 2025
1 parent 420487e commit 4e5183f
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 1 deletion.
53 changes: 53 additions & 0 deletions src/MenuConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,8 @@ MenuConfig::MenuConfig (bool _is_game_state)
: is_game_state(_is_game_state)
, enable_gamestate_buttons(false)
, hero(NULL)
, keybinds_visible_equipswap(false)
, keybinds_visible_actionbar(10, false)
, child_widget()
, tab_control(new WidgetTabControl())
, ok_button(new WidgetButton(WidgetButton::DEFAULT_FILE))
Expand Down Expand Up @@ -476,6 +478,12 @@ void MenuConfig::init() {

for (size_t i = 0; i < keybinds_lstb.size(); ++i) {
cfg_tabs[KEYBINDS_TAB].setOptionWidgets(static_cast<int>(i), keybinds_lb[i], keybinds_lstb[i], inpt->binding_name[i]);
if (i >= Input::BAR_1 && i <= Input::BAR_0 && !keybinds_visible_actionbar[i - Input::BAR_1]) {
cfg_tabs[KEYBINDS_TAB].setOptionEnabled(static_cast<int>(i), false);
}
else if ((i == Input::EQUIPMENT_SWAP || i == Input::EQUIPMENT_SWAP_PREV) && !keybinds_visible_equipswap) {
cfg_tabs[KEYBINDS_TAB].setOptionEnabled(static_cast<int>(i), false);
}
}

// disable some options
Expand Down Expand Up @@ -591,6 +599,51 @@ void MenuConfig::readConfig() {
mouse_move_attack_cb->tooltip = msg->get("When 'Move hero using mouse' is enabled, this setting controls if the Power assigned to the movement button can be used by targeting an enemy. If this setting is disabled, it is required to use 'Shift' to access the Power assigned to the movement button.");
mouse_aim_cb->tooltip = msg->get("The player's attacks will be aimed in the direction of the mouse cursor when this is enabled.");
touch_controls_cb->tooltip = msg->get("When enabled, a virtual gamepad will be added in-game. Other interactions, such as drag-and-drop behavior, are also altered to better suit touch input.");

// some keybinds are hidden based on other configuration files
if (infile.open("menus/actionbar.txt", FileParser::MOD_FILE, FileParser::ERROR_NONE)) {
while (infile.next()) {
if (infile.key == "slot") {
unsigned index = Parse::popFirstInt(infile.val);
if (index > 0 && index <= 10) {
keybinds_visible_actionbar[index-1] = true;
}
}
}
infile.close();
}
else {
// no actionbar config; show all associated keybinds
for (size_t i = 0; i < keybinds_visible_actionbar.size(); ++i) {
keybinds_visible_actionbar[i] = true;
}
}

if (infile.open("menus/inventory.txt", FileParser::MOD_FILE, FileParser::ERROR_NONE)) {
while (infile.next()) {
if (infile.key == "set_button" || infile.key == "set_previous" || infile.key == "set_next" || infile.key == "label_equipment_set") {
keybinds_visible_equipswap = true;
break;
}
else if (infile.key == "equipment_slot") {
Parse::popFirstInt(infile.val);
Parse::popFirstInt(infile.val);
Parse::popFirstString(infile.val);
int equip_set = Parse::popFirstInt(infile.val);
if (equip_set > 0) {
keybinds_visible_equipswap = true;
break;
}
}
}
infile.close();
}
else {
// no inventory config; show all associated keybinds
keybinds_visible_equipswap = true;
}


}

bool MenuConfig::parseKeyButtons(FileParser &infile) {
Expand Down
3 changes: 3 additions & 0 deletions src/MenuConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,9 @@ class MenuConfig {
std::vector<unsigned short> frame_limits;
std::vector<unsigned short> virtual_heights;

bool keybinds_visible_equipswap;
std::vector<bool> keybinds_visible_actionbar;

public:
static const bool IS_GAME_STATE = true;
static const bool ENABLE_SAVE_GAME = true;
Expand Down
2 changes: 1 addition & 1 deletion src/Version.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ FLARE. If not, see http://www.gnu.org/licenses/

#include <SDL.h>

Version VersionInfo::ENGINE(1, 14, 95);
Version VersionInfo::ENGINE(1, 14, 96);
Version VersionInfo::MIN(0, 0, 0);
Version VersionInfo::MAX(USHRT_MAX, USHRT_MAX, USHRT_MAX);

Expand Down

0 comments on commit 4e5183f

Please sign in to comment.