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); | this.miniMap = Engine.GetGUIObjectByName("minimap"); | ||||
Engine.GetGUIObjectByName("minimap").onMouseEnter = this.onMouseEnter.bind(this); | this.miniMap.onWorldClick = this.onWorldClick.bind(this); | ||||
Engine.GetGUIObjectByName("minimap").onMouseLeave = this.onMouseLeave.bind(this); | this.miniMap.onMouseEnter = this.onMouseEnter.bind(this); | ||||
this.miniMap.onMouseLeave = this.onMouseLeave.bind(this); | |||||
this.mouseIsOverMiniMap = false; | this.mouseIsOverMiniMap = false; | ||||
} | } | ||||
onWorldClick(target, button) | onWorldClick(target, button) | ||||
{ | { | ||||
// 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 (inputState == INPUT_NORMAL && controlsPlayer(g_ViewedPlayer) && Engine.HotkeyIsPressed("session.flare")) | |||||
{ | |||||
triggerFlareAction(target); | |||||
return true; | |||||
} | |||||
if (button == SDL_BUTTON_LEFT) | if (button == SDL_BUTTON_LEFT) | ||||
{ | { | ||||
if (inputState != INPUT_PRESELECTEDACTION || preSelectedAction == ACTION_NONE) | if (inputState != INPUT_FLARE && (inputState != INPUT_PRESELECTEDACTION || preSelectedAction == ACTION_NONE)) | ||||
return false; | return false; | ||||
} | } | ||||
else if (button == SDL_BUTTON_RIGHT) | else if (button == SDL_BUTTON_RIGHT) | ||||
{ | { | ||||
if (inputState == INPUT_PRESELECTEDACTION) | if (inputState == INPUT_PRESELECTEDACTION) | ||||
{ | { | ||||
preSelectedAction = ACTION_NONE; | preSelectedAction = ACTION_NONE; | ||||
inputState = INPUT_NORMAL; | inputState = INPUT_NORMAL; | ||||
return true; | return true; | ||||
} | } | ||||
else if (inputState == INPUT_FLARE) | |||||
{ | |||||
inputState = INPUT_NORMAL; | |||||
return true; | |||||
} | |||||
else if (inputState != INPUT_NORMAL) | else if (inputState != INPUT_NORMAL) | ||||
return false; | return false; | ||||
} | } | ||||
else | else | ||||
return false; | return false; | ||||
if (!controlsPlayer(g_ViewedPlayer)) | if (!controlsPlayer(g_ViewedPlayer)) | ||||
return false; | return false; | ||||
if (inputState == INPUT_FLARE && button == SDL_BUTTON_LEFT) | |||||
{ | |||||
triggerFlareAction(target); | |||||
inputState = INPUT_NORMAL; | |||||
return true; | |||||
} | |||||
let action = determineAction(undefined, undefined, true); | let action = determineAction(undefined, undefined, true); | ||||
if (!action) | if (!action) | ||||
return false; | return false; | ||||
if (button == SDL_BUTTON_LEFT && !Engine.HotkeyIsPressed("session.queue") && !Engine.HotkeyIsPressed("session.orderone")) | if (button == SDL_BUTTON_LEFT && !Engine.HotkeyIsPressed("session.queue") && !Engine.HotkeyIsPressed("session.orderone")) | ||||
{ | { | ||||
preSelectedAction = ACTION_NONE; | preSelectedAction = ACTION_NONE; | ||||
inputState = INPUT_NORMAL; | inputState = INPUT_NORMAL; | ||||
} | } | ||||
Show All 9 Lines | class MiniMap | ||||
{ | { | ||||
this.mouseIsOverMiniMap = false; | this.mouseIsOverMiniMap = false; | ||||
} | } | ||||
isMouseOverMiniMap() | isMouseOverMiniMap() | ||||
{ | { | ||||
return this.mouseIsOverMiniMap; | return this.mouseIsOverMiniMap; | ||||
} | } | ||||
flare(target, playerID) | |||||
{ | |||||
return this.miniMap.flare({ "x": target.x, "y": target.z }, g_DiplomacyColors.getPlayerColor(playerID)); | |||||
} | |||||
} | } |
Wildfire Games · Phabricator