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

Client: add some shortcuts for spectator mode

Following mode only work when client is started in spectator mode:
F5 - Pause / resume game by locking of pim
F6 - Toggle spectate-ignore-hero
F7 - Toggle spectate-skip-battle
F8 - Toggle spectate-skip-battle-result
F9 - Skip current battle
This commit is contained in:
Arseniy Shestakov 2017-06-05 18:43:02 +03:00
parent 18161d3688
commit 3f7cb9f893
3 changed files with 43 additions and 1 deletions

View File

@ -96,7 +96,7 @@
#define BATTLE_INTERFACE_CALL_IF_PRESENT_FOR_BOTH_SIDES(function,...) \
CALL_ONLY_THAT_BATTLE_INTERFACE(GS(cl)->curB->sides[0].color, function, __VA_ARGS__) \
CALL_ONLY_THAT_BATTLE_INTERFACE(GS(cl)->curB->sides[1].color, function, __VA_ARGS__) \
if(settings["session"]["spectate"].Bool() && !settings["session"]["spectate-skip-battle"].Bool()) \
if(settings["session"]["spectate"].Bool() && !settings["session"]["spectate-skip-battle"].Bool() && LOCPLINT->battleInt) \
{ \
CALL_ONLY_THAT_BATTLE_INTERFACE(PlayerColor::SPECTATOR, function, __VA_ARGS__) \
} \

View File

@ -453,6 +453,7 @@ CBattleInterface::~CBattleInterface()
int terrain = LOCPLINT->cb->getTile(adventureInt->selection->visitablePos())->terType;
CCS->musich->playMusicFromSet("terrain", terrain, true);
}
animsAreDisplayed.setn(false);
}
void CBattleInterface::setPrintCellBorders(bool set)

View File

@ -12,6 +12,7 @@
#include "../../lib/CConfigHandler.h"
#include "../CMT.h"
#include "../CPlayerInterface.h"
#include "../battle/CBattleInterface.h"
extern std::queue<SDL_Event> events;
extern boost::mutex eventsM;
@ -191,6 +192,46 @@ void CGuiHandler::handleEvent(SDL_Event *sEvent)
if (sEvent->type==SDL_KEYDOWN || sEvent->type==SDL_KEYUP)
{
SDL_KeyboardEvent key = sEvent->key;
if(sEvent->type == SDL_KEYDOWN && key.keysym.sym >= SDLK_F1 && key.keysym.sym <= SDLK_F15 && settings["session"]["spectate"].Bool())
{
//TODO: we need some central place for all interface-independent hotkeys
Settings s = settings.write["session"];
switch(key.keysym.sym)
{
case SDLK_F5:
if(settings["session"]["spectate-locked-pim"].Bool())
LOCPLINT->pim->unlock();
else
LOCPLINT->pim->lock();
s["spectate-locked-pim"].Bool() = !settings["session"]["spectate-locked-pim"].Bool();
break;
case SDLK_F6:
s["spectate-ignore-hero"].Bool() = !settings["session"]["spectate-ignore-hero"].Bool();
break;
case SDLK_F7:
s["spectate-skip-battle"].Bool() = !settings["session"]["spectate-skip-battle"].Bool();
break;
case SDLK_F8:
s["spectate-skip-battle-result"].Bool() = !settings["session"]["spectate-skip-battle-result"].Bool();
break;
case SDLK_F9:
//not working yet since CClient::run remain locked after CBattleInterface removal
if(LOCPLINT->battleInt)
{
GH.popIntTotally(GH.topInt());
vstd::clear_pointer(LOCPLINT->battleInt);
}
break;
default:
break;
}
return;
}
//translate numpad keys
if(key.keysym.sym == SDLK_KP_ENTER)