Changeset View
Changeset View
Standalone View
Standalone View
ps/trunk/binaries/data/mods/public/gui/session/minimap/MiniMap.js
/** | /** | ||||
* This class is concerned with handling events occurring when the interacts with the minimap, | * This class is concerned with handling events occurring when the interacts with the minimap, | ||||
* except for changing the camera position on leftclick. | * except for changing the camera position on leftclick. | ||||
*/ | */ | ||||
class MiniMap | class MiniMap | ||||
{ | { | ||||
constructor() | constructor() | ||||
{ | { | ||||
Engine.GetGUIObjectByName("minimap").onWorldClick = this.onWorldClick.bind(this); | Engine.GetGUIObjectByName("minimap").onWorldClick = this.onWorldClick.bind(this); | ||||
Engine.GetGUIObjectByName("minimap").onMouseEnter = this.onMouseEnter.bind(this); | Engine.GetGUIObjectByName("minimap").onMouseEnter = this.onMouseEnter.bind(this); | ||||
Engine.GetGUIObjectByName("minimap").onMouseLeave = this.onMouseLeave.bind(this); | Engine.GetGUIObjectByName("minimap").onMouseLeave = this.onMouseLeave.bind(this); | ||||
this.mouseIsOverMiniMap = false; | this.mouseIsOverMiniMap = false; | ||||
} | } | ||||
onWorldClick(target) | onWorldClick(target, button) | ||||
{ | { | ||||
if (!controlsPlayer(g_ViewedPlayer)) | |||||
return false; | |||||
// Partly duplicated from handleInputAfterGui(), but with the input being | // Partly duplicated from handleInputAfterGui(), but with the input being | ||||
// world coordinates instead of screen coordinates. | // world coordinates instead of screen coordinates. | ||||
if (button == SDL_BUTTON_LEFT) | |||||
{ | |||||
if (inputState != INPUT_PRESELECTEDACTION || preSelectedAction == ACTION_NONE) | |||||
return false; | |||||
} | |||||
else if (button == SDL_BUTTON_RIGHT) | |||||
{ | |||||
if (inputState == INPUT_PRESELECTEDACTION) | |||||
{ | |||||
preSelectedAction = ACTION_NONE; | |||||
inputState = INPUT_NORMAL; | |||||
return true; | |||||
} | |||||
else if (inputState != INPUT_NORMAL) | |||||
return false; | |||||
} | |||||
else | |||||
return false; | |||||
if (inputState != INPUT_NORMAL) | if (!controlsPlayer(g_ViewedPlayer)) | ||||
return false; | return false; | ||||
let action = determineAction(undefined, undefined, true); | let action = determineAction(undefined, undefined, true); | ||||
return action && handleUnitAction(target, action); | if (!action) | ||||
return false; | |||||
if (button == SDL_BUTTON_LEFT && !Engine.HotkeyIsPressed("session.queue") && !Engine.HotkeyIsPressed("session.orderone")) | |||||
{ | |||||
preSelectedAction = ACTION_NONE; | |||||
inputState = INPUT_NORMAL; | |||||
} | |||||
return handleUnitAction(target, action); | |||||
} | } | ||||
onMouseEnter() | onMouseEnter() | ||||
{ | { | ||||
this.mouseIsOverMiniMap = true; | this.mouseIsOverMiniMap = true; | ||||
} | } | ||||
onMouseLeave() | onMouseLeave() | ||||
Show All 9 Lines |
Wildfire Games · Phabricator