Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions rts/Game/UI/GuiHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1851,16 +1851,18 @@ int CGuiHandler::GetIconPosCommand(int slot) const // only called by SetActiveCo
}


void CGuiHandler::CancelActiveCommand()
{
activeMousePress = false;
SetActiveCommandIndex(-1);
}


bool CGuiHandler::KeyPressed(int keyCode, int scanCode, bool isRepeat)
{
RECOIL_DETAILED_TRACY_ZONE;
if (keyCode == SDLK_ESCAPE && activeMousePress) {
activeMousePress = false;
SetActiveCommandIndex(-1);
return true;
}
if (keyCode == SDLK_ESCAPE && inCommand >= 0) {
SetActiveCommandIndex(-1);
if (keyCode == SDLK_ESCAPE && (activeMousePress || inCommand >= 0)) {
CancelActiveCommand();
return true;
}

Expand Down
1 change: 1 addition & 0 deletions rts/Game/UI/GuiHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ class CGuiHandler : public CInputReceiver {
bool SetActiveCommand(int cmdIndex, bool rightMouseButton);
bool SetActiveCommand(int cmdIndex, int button, bool leftMouseButton, bool rightMouseButton, bool alt, bool ctrl, bool meta, bool shift);
bool SetActiveCommand(const Action& action, const CKeySet& ks, int actionIndex);
void CancelActiveCommand();

void SetDrawSelectionInfo(bool dsi) { drawSelectionInfo = dsi; }
bool GetDrawSelectionInfo() const { return drawSelectionInfo; }
Expand Down
17 changes: 17 additions & 0 deletions rts/Game/UnsyncedGameCommands.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,22 @@ class DeselectActionExecutor : public IUnsyncedActionExecutor {



class CancelCommandActionExecutor : public IUnsyncedActionExecutor {
public:
CancelCommandActionExecutor() : IUnsyncedActionExecutor("CancelCommand", "Cancels the active command (build/order mode)") {
}

bool Execute(const UnsyncedAction& action) const final {
if (guihandler == nullptr)
return false;

guihandler->CancelActiveCommand();
return true;
}
};



class MapMeshDrawerActionExecutor : public IUnsyncedActionExecutor {
public:
MapMeshDrawerActionExecutor() : IUnsyncedActionExecutor("mapmeshdrawer", "Switch map-mesh rendering modes: 0=GCM, 1=HLOD, 2=ROAM") {
Expand Down Expand Up @@ -4038,6 +4054,7 @@ void UnsyncedGameCommands::AddDefaultActionExecutors()
AddActionExecutor(AllocActionExecutor<SelectUnitsActionExecutor>());
AddActionExecutor(AllocActionExecutor<SelectCycleActionExecutor>());
AddActionExecutor(AllocActionExecutor<DeselectActionExecutor>());
AddActionExecutor(AllocActionExecutor<CancelCommandActionExecutor>());
AddActionExecutor(AllocActionExecutor<ShadowsActionExecutor>());
AddActionExecutor(AllocActionExecutor<DumpShadowsActionExecutor>());
AddActionExecutor(AllocActionExecutor<MapShadowPolyOffsetActionExecutor>());
Expand Down