Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/gui/session/menu.js
Show First 20 Lines • Show All 60 Lines • ▼ Show 20 Lines | |||||
/** | /** | ||||
* Remember last viewed summary panel and charts. | * Remember last viewed summary panel and charts. | ||||
*/ | */ | ||||
var g_SummarySelectedData; | var g_SummarySelectedData; | ||||
// Redefined every time someone makes a tribute (so we can save some data in a closure). Called in input.js handleInputBeforeGui. | // Redefined every time someone makes a tribute (so we can save some data in a closure). Called in input.js handleInputBeforeGui. | ||||
var g_FlushTributing = function() {}; | var g_FlushTributing = function() {}; | ||||
/** | |||||
ffffffff: jsdocs missing
/**
* Setting menu buttons tooltips and hotkey descriptions plus enable or… | |||||
* Setting tooltips and hotkey descriptions for buttons plus enable or disable them. | |||||
Not Done Inline ActionsMaybe "Toggle the in-game menu"? Imarok: Maybe "Toggle **the** in-game menu"? | |||||
Not Done Inline Actionsclaro! ffffffff: claro! | |||||
*/ | |||||
var g_GuiButtons = { | |||||
"menuButton": { "description": "Toggle the in-game menu." }, | |||||
"manualButton": { "description": "Show the game manual." }, | |||||
Not Done Inline Actionshotkey property is redundant and should be received by Engine.GetGUIObjectByName("name").hotkey elexis: hotkey property is redundant and should be received by Engine.GetGUIObjectByName("name").hotkey | |||||
Not Done Inline Actionsnice!! ffffffff: nice!! | |||||
Not Done Inline Actionsnot just "enabled": Engine.HasXmppClient ? Imarok: not just `"enabled": Engine.HasXmppClient` ? | |||||
"saveGameButton": { "description": "Save the current game." }, | |||||
"summaryButton": { "description": "Show the summary dialog." }, | |||||
"lobbyButton": { "description": "Show the multiplayer lobby in a dialog.", "enabled": Engine.HasXmppClient }, | |||||
"chatButton": { "hotkey": [ | |||||
{ "hotkey": "chat", "description": translate("Chat"), "showOnlyWhenUsed": true }, | |||||
{ "hotkey": "teamchat", "description": translate("Team chat"), "showOnlyWhenUsed": true }, | |||||
{ "hotkey": "privatechat", "description": translate("Private chat"), "showOnlyWhenUsed": true } | |||||
] }, | |||||
"optionsButton": { "description": "Show the options dialog." }, | |||||
"pauseButton": { "description": "Toggle pause the game.", "enabled": () => !g_IsObserver || !g_IsNetworked || g_IsController }, | |||||
"menuResignButton": { "description": "Resign from the current game.", "enabled": () => !g_IsObserver }, | |||||
"menuExitButton": { "description": "Exit from the current game." }, | |||||
"tradeButton1": { "description": "Barter & Trade" } | |||||
}; | |||||
function initSessionMenuButtons() | function initSessionMenuButtons() | ||||
{ | { | ||||
initMenuPosition(); | initMenuPosition(); | ||||
updateGameSpeedControl(); | updateGameSpeedControl(); | ||||
resizeDiplomacyDialog(); | resizeDiplomacyDialog(); | ||||
resizeTradeDialog(); | resizeTradeDialog(); | ||||
} | } | ||||
function updateMenuButtons() | |||||
Not Done Inline ActionsMaybe name updateMenuButtons. ffffffff: Maybe name updateMenuButtons. | |||||
{ | |||||
let colorizedHotkey = name => { | |||||
let hotkey = Engine.ConfigDB_GetValue("user", "hotkey." + name); | |||||
return !hotkey || hotkey == "unused" ? "" : setStringTags("\\[" + hotkey + "]", g_HotkeyTags); | |||||
Not Done Inline ActionsIs this actually what we want compared to colorizeHotkey() in color,js? Dont like this "Unassigned hotkey: %(hotkeyName)s" String from it. ffffffff: Is this actually what we want compared to colorizeHotkey() in color,js?
Dont like this… | |||||
} | |||||
let getTooltip = (hotkey, description) => | |||||
colorizedHotkey(hotkey) == "" ? description : translate(description) != "" ? sprintf(translate("%(hotkey)s: " + description), { | |||||
"hotkey": colorizedHotkey(hotkey) | |||||
}) : colorizedHotkey(hotkey); | |||||
for (let name in g_GuiButtons) | |||||
{ | |||||
let button = g_GuiButtons[name]; | |||||
let enabled = !button.enabled || button.enabled(); | |||||
let guiObj = Engine.GetGUIObjectByName(name); | |||||
guiObj.enabled = enabled; | |||||
let hotkey = button.hotkey || guiObj.hotkey || ""; | |||||
if ((!hotkey && !button.description) || !enabled) | |||||
continue; | |||||
if (hotkey && Array.isArray(hotkey)) | |||||
guiObj.tooltip = hotkey.map(tooltip => | |||||
!!tooltip.showOnlyWhenUsed && colorizedHotkey(tooltip.hotkey) == "" ? "" : | |||||
getTooltip(tooltip.hotkey, tooltip.description)).join("\n"); | |||||
else | |||||
if (!hotkey || typeof(hotkey) == 'string') | |||||
guiObj.tooltip = getTooltip(hotkey, button.description || ""); | |||||
} | |||||
} | |||||
function initMenuPosition() | function initMenuPosition() | ||||
{ | { | ||||
Engine.GetGUIObjectByName("menu").size = "100%-164 " + MENU_TOP + " 100% " + MENU_BOTTOM; | Engine.GetGUIObjectByName("menu").size = "100%-164 " + MENU_TOP + " 100% " + MENU_BOTTOM; | ||||
} | } | ||||
function updateMenuPosition(dt) | function updateMenuPosition(dt) | ||||
{ | { | ||||
let menu = Engine.GetGUIObjectByName("menu"); | let menu = Engine.GetGUIObjectByName("menu"); | ||||
Show All 40 Lines | |||||
{ | { | ||||
if (!Engine.HasXmppClient()) | if (!Engine.HasXmppClient()) | ||||
return; | return; | ||||
closeOpenDialogs(); | closeOpenDialogs(); | ||||
Engine.PushGuiPage("page_lobby.xml", { "dialog": true }); | Engine.PushGuiPage("page_lobby.xml", { "dialog": true }); | ||||
} | } | ||||
function chatMenuButton() | |||||
{ | |||||
closeOpenDialogs(); | |||||
openChat(); | |||||
} | |||||
function diplomacyMenuButton() | function diplomacyMenuButton() | ||||
{ | { | ||||
closeOpenDialogs(); | closeOpenDialogs(); | ||||
openDiplomacy(); | openDiplomacy(); | ||||
} | } | ||||
function pauseMenuButton() | function pauseMenuButton() | ||||
{ | { | ||||
▲ Show 20 Lines • Show All 1,110 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator
jsdocs missing
/**