1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-24 22:14:36 +02:00

Add separate shortcuts for saving and loading of artifact costumes

This commit is contained in:
Ivan Savenko 2024-05-18 16:27:42 +00:00
parent 1f1e693a5b
commit 947d07faa4
6 changed files with 99 additions and 81 deletions

View File

@ -158,9 +158,6 @@ void CInGameConsole::keyPressed (EShortcut key)
break;
case EShortcut::GAME_ACTIVATE_CONSOLE:
if(GH.isKeyboardAltDown())
return; //QoL for alt-tab operating system shortcut
if(!enteredText.empty())
endEnteringText(false);
else

View File

@ -173,16 +173,27 @@ enum class EShortcut
HERO_TIGHT_FORMATION,
HERO_TOGGLE_TACTICS, // b
HERO_BACKPACK,
HERO_COSTUME_0,
HERO_COSTUME_1,
HERO_COSTUME_2,
HERO_COSTUME_3,
HERO_COSTUME_4,
HERO_COSTUME_5,
HERO_COSTUME_6,
HERO_COSTUME_7,
HERO_COSTUME_8,
HERO_COSTUME_9,
HERO_COSTUME_SAVE_0,
HERO_COSTUME_SAVE_1,
HERO_COSTUME_SAVE_2,
HERO_COSTUME_SAVE_3,
HERO_COSTUME_SAVE_4,
HERO_COSTUME_SAVE_5,
HERO_COSTUME_SAVE_6,
HERO_COSTUME_SAVE_7,
HERO_COSTUME_SAVE_8,
HERO_COSTUME_SAVE_9,
HERO_COSTUME_LOAD_0,
HERO_COSTUME_LOAD_1,
HERO_COSTUME_LOAD_2,
HERO_COSTUME_LOAD_3,
HERO_COSTUME_LOAD_4,
HERO_COSTUME_LOAD_5,
HERO_COSTUME_LOAD_6,
HERO_COSTUME_LOAD_7,
HERO_COSTUME_LOAD_8,
HERO_COSTUME_LOAD_9,
// Spellbook screen
SPELLBOOK_TAB_ADVENTURE,

View File

@ -218,16 +218,26 @@ EShortcut ShortcutHandler::findShortcut(const std::string & identifier ) const
{"heroLooseFormation", EShortcut::HERO_LOOSE_FORMATION },
{"heroTightFormation", EShortcut::HERO_TIGHT_FORMATION },
{"heroToggleTactics", EShortcut::HERO_TOGGLE_TACTICS },
{"heroCostume0", EShortcut::HERO_COSTUME_0 },
{"heroCostume1", EShortcut::HERO_COSTUME_1 },
{"heroCostume2", EShortcut::HERO_COSTUME_2 },
{"heroCostume3", EShortcut::HERO_COSTUME_3 },
{"heroCostume4", EShortcut::HERO_COSTUME_4 },
{"heroCostume5", EShortcut::HERO_COSTUME_5 },
{"heroCostume6", EShortcut::HERO_COSTUME_6 },
{"heroCostume7", EShortcut::HERO_COSTUME_7 },
{"heroCostume8", EShortcut::HERO_COSTUME_8 },
{"heroCostume9", EShortcut::HERO_COSTUME_9 },
{"heroCostumeSave0", EShortcut::HERO_COSTUME_SAVE_0 },
{"heroCostumeSave1", EShortcut::HERO_COSTUME_SAVE_1 },
{"heroCostumeSave2", EShortcut::HERO_COSTUME_SAVE_2 },
{"heroCostumeSave3", EShortcut::HERO_COSTUME_SAVE_3 },
{"heroCostumeSave4", EShortcut::HERO_COSTUME_SAVE_4 },
{"heroCostumeSave5", EShortcut::HERO_COSTUME_SAVE_5 },
{"heroCostumeSave6", EShortcut::HERO_COSTUME_SAVE_6 },
{"heroCostumeSave7", EShortcut::HERO_COSTUME_SAVE_7 },
{"heroCostumeSave8", EShortcut::HERO_COSTUME_SAVE_8 },
{"heroCostumeSave9", EShortcut::HERO_COSTUME_SAVE_9 },
{"heroCostumeLoad0", EShortcut::HERO_COSTUME_LOAD_0 },
{"heroCostumeLoad1", EShortcut::HERO_COSTUME_LOAD_1 },
{"heroCostumeLoad2", EShortcut::HERO_COSTUME_LOAD_2 },
{"heroCostumeLoad3", EShortcut::HERO_COSTUME_LOAD_3 },
{"heroCostumeLoad4", EShortcut::HERO_COSTUME_LOAD_4 },
{"heroCostumeLoad5", EShortcut::HERO_COSTUME_LOAD_5 },
{"heroCostumeLoad6", EShortcut::HERO_COSTUME_LOAD_6 },
{"heroCostumeLoad7", EShortcut::HERO_COSTUME_LOAD_7 },
{"heroCostumeLoad8", EShortcut::HERO_COSTUME_LOAD_8 },
{"heroCostumeLoad9", EShortcut::HERO_COSTUME_LOAD_9 },
{"spellbookTabAdventure", EShortcut::SPELLBOOK_TAB_ADVENTURE },
{"spellbookTabCombat", EShortcut::SPELLBOOK_TAB_COMBAT }
};

View File

@ -42,49 +42,27 @@ void CArtifactsOfHeroMain::keyPressed(EShortcut key)
{
if(!shortcutPressed)
{
uint32_t costumeIdx;
switch(key)
int saveIdx = vstd::find_pos(costumeSaveShortcuts, key);
int loadIdx = vstd::find_pos(costumeLoadShortcuts, key);
if (saveIdx != -1)
{
case EShortcut::HERO_COSTUME_0:
costumeIdx = 0;
break;
case EShortcut::HERO_COSTUME_1:
costumeIdx = 1;
break;
case EShortcut::HERO_COSTUME_2:
costumeIdx = 2;
break;
case EShortcut::HERO_COSTUME_3:
costumeIdx = 3;
break;
case EShortcut::HERO_COSTUME_4:
costumeIdx = 4;
break;
case EShortcut::HERO_COSTUME_5:
costumeIdx = 5;
break;
case EShortcut::HERO_COSTUME_6:
costumeIdx = 6;
break;
case EShortcut::HERO_COSTUME_7:
costumeIdx = 7;
break;
case EShortcut::HERO_COSTUME_8:
costumeIdx = 8;
break;
case EShortcut::HERO_COSTUME_9:
costumeIdx = 9;
break;
default:
shortcutPressed = true;
LOCPLINT->cb->manageHeroCostume(getHero()->id, saveIdx, true);
return;
}
if (loadIdx != -1)
{
shortcutPressed = true;
LOCPLINT->cb->manageHeroCostume(getHero()->id, loadIdx, false);
return;
}
shortcutPressed = true;
LOCPLINT->cb->manageHeroCostume(getHero()->id, costumeIdx, GH.isKeyboardCtrlDown());
}
}
void CArtifactsOfHeroMain::keyReleased(EShortcut key)
{
if(vstd::contains(costumesSwitcherHotkeys, key))
if(vstd::contains(costumeSaveShortcuts, key) || vstd::contains(costumeLoadShortcuts, key))
shortcutPressed = false;
}

View File

@ -23,17 +23,29 @@ public:
void keyReleased(EShortcut key) override;
private:
const std::vector<EShortcut> costumesSwitcherHotkeys =
{
EShortcut::HERO_COSTUME_0,
EShortcut::HERO_COSTUME_1,
EShortcut::HERO_COSTUME_2,
EShortcut::HERO_COSTUME_3,
EShortcut::HERO_COSTUME_4,
EShortcut::HERO_COSTUME_5,
EShortcut::HERO_COSTUME_6,
EShortcut::HERO_COSTUME_7,
EShortcut::HERO_COSTUME_8,
EShortcut::HERO_COSTUME_9
static constexpr std::array costumeSaveShortcuts = {
EShortcut::HERO_COSTUME_SAVE_0,
EShortcut::HERO_COSTUME_SAVE_1,
EShortcut::HERO_COSTUME_SAVE_2,
EShortcut::HERO_COSTUME_SAVE_3,
EShortcut::HERO_COSTUME_SAVE_4,
EShortcut::HERO_COSTUME_SAVE_5,
EShortcut::HERO_COSTUME_SAVE_6,
EShortcut::HERO_COSTUME_SAVE_7,
EShortcut::HERO_COSTUME_SAVE_8,
EShortcut::HERO_COSTUME_SAVE_9
};
static constexpr std::array costumeLoadShortcuts = {
EShortcut::HERO_COSTUME_LOAD_0,
EShortcut::HERO_COSTUME_LOAD_1,
EShortcut::HERO_COSTUME_LOAD_2,
EShortcut::HERO_COSTUME_LOAD_3,
EShortcut::HERO_COSTUME_LOAD_4,
EShortcut::HERO_COSTUME_LOAD_5,
EShortcut::HERO_COSTUME_LOAD_6,
EShortcut::HERO_COSTUME_LOAD_7,
EShortcut::HERO_COSTUME_LOAD_8,
EShortcut::HERO_COSTUME_LOAD_9
};
};

View File

@ -132,16 +132,26 @@
"heroToggleTactics": "B",
"spellbookTabAdventure": "A",
"spellbookTabCombat": "C",
"heroCostume0": "0",
"heroCostume1": "1",
"heroCostume2": "2",
"heroCostume3": "3",
"heroCostume4": "4",
"heroCostume5": "5",
"heroCostume6": "6",
"heroCostume7": "7",
"heroCostume8": "8",
"heroCostume9": "9"
"heroCostumeLoad0": "0",
"heroCostumeLoad1": "1",
"heroCostumeLoad2": "2",
"heroCostumeLoad3": "3",
"heroCostumeLoad4": "4",
"heroCostumeLoad5": "5",
"heroCostumeLoad6": "6",
"heroCostumeLoad7": "7",
"heroCostumeLoad8": "8",
"heroCostumeLoad9": "9",
"heroCostumeSave0": "Ctrl+0",
"heroCostumeSave1": "Ctrl+1",
"heroCostumeSave2": "Ctrl+2",
"heroCostumeSave3": "Ctrl+3",
"heroCostumeSave4": "Ctrl+4",
"heroCostumeSave5": "Ctrl+5",
"heroCostumeSave6": "Ctrl+6",
"heroCostumeSave7": "Ctrl+7",
"heroCostumeSave8": "Ctrl+8",
"heroCostumeSave9": "Ctrl+9"
},
"joystickAxes":