Changeset View
Changeset View
Standalone View
Standalone View
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); | ||||
} | } | ||||
onWorldClick(target) | onWorldClick(data) | ||||
{ | |||||
switch (data.type) | |||||
{ | |||||
case "mouserightrelease": | |||||
case "mouserightdoubleclick": | |||||
{ | { | ||||
if (!controlsPlayer(g_ViewedPlayer)) | |||||
return; | |||||
// 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) | if (inputState != INPUT_NORMAL) | ||||
return false; | return false; | ||||
let action = determineAction(undefined, undefined, true); | let action = determineAction(undefined, undefined, true); | ||||
return action && handleUnitAction(target, action); | return action && handleUnitAction(data.target, action); | ||||
} | |||||
case "mousemiddlerelease": | |||||
case "mousemiddledoubleclick": | |||||
{ | |||||
let now = Date.now(); | |||||
if (!g_LastMapPingTime || now > g_LastMapPingTime + 1000) { | |||||
g_LastMapPingTime = now; | |||||
displayMapPing(data.target, Engine.GetPlayerID()); | |||||
Engine.PostNetworkCommand({ | |||||
"type": "map-ping", | |||||
"target": data.target | |||||
}); | |||||
return true; | |||||
} | |||||
break; | |||||
} | |||||
} | |||||
return false; | |||||
} | } | ||||
} | } |
Wildfire Games · Phabricator