Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/gui/session/messages.js
Show All 35 Lines | |||||
/** | /** | ||||
* All tutorial messages received so far. | * All tutorial messages received so far. | ||||
*/ | */ | ||||
var g_TutorialMessages = []; | var g_TutorialMessages = []; | ||||
/** | /** | ||||
* GUI tags applied to the most recent tutorial message. | * GUI tags applied to the most recent tutorial message. | ||||
*/ | */ | ||||
var g_TutorialNewMessageTags = { "color": "yellow" }; | var g_TutorialNewMessageTag = { "color": "yellow" }; | ||||
/** | /** | ||||
* Handle all netmessage types that can occur. | * Handle all netmessage types that can occur. | ||||
*/ | */ | ||||
var g_NetMessageTypes = { | var g_NetMessageTypes = { | ||||
"netstatus": msg => { | "netstatus": msg => { | ||||
handleNetStatusMessage(msg); | handleNetStatusMessage(msg); | ||||
}, | }, | ||||
▲ Show 20 Lines • Show All 509 Lines • ▼ Show 20 Lines | |||||
*/ | */ | ||||
function updateTutorial(notification) | function updateTutorial(notification) | ||||
{ | { | ||||
// Show the tutorial panel if not yet done | // Show the tutorial panel if not yet done | ||||
Engine.GetGUIObjectByName("tutorialPanel").hidden = false; | Engine.GetGUIObjectByName("tutorialPanel").hidden = false; | ||||
if (notification.warning) | if (notification.warning) | ||||
{ | { | ||||
Engine.GetGUIObjectByName("tutorialWarning").caption = coloredText(translate(notification.warning), "orange"); | Engine.GetGUIObjectByName("tutorialWarning").caption = setStringTags(translate(notification.warning), g_TooltipTextFormats.warning); | ||||
elexis: Is it a tooltip?
Does every modder who wants to change the tooltip color from orange to red… | |||||
return; | return; | ||||
} | } | ||||
let notificationText = | let notificationText = | ||||
notification.instructions.reduce((instructions, item) => | notification.instructions.reduce((instructions, item) => | ||||
instructions + (typeof item == "string" ? translate(item) : colorizeHotkey(translate(item.text), item.hotkey)), | instructions + (typeof item == "string" ? translate(item) : colorizeHotkey(translate(item.text), item.hotkey)), | ||||
""); | ""); | ||||
Engine.GetGUIObjectByName("tutorialText").caption = g_TutorialMessages.concat(setStringTags(notificationText, g_TutorialNewMessageTags)).join("\n"); | Engine.GetGUIObjectByName("tutorialText").caption = g_TutorialMessages.concat(setStringTags(notificationText, g_TutorialNewMessageTag)).join("\n"); | ||||
g_TutorialMessages.push(notificationText); | g_TutorialMessages.push(notificationText); | ||||
if (notification.readyButton) | if (notification.readyButton) | ||||
{ | { | ||||
Engine.GetGUIObjectByName("tutorialReady").hidden = false; | Engine.GetGUIObjectByName("tutorialReady").hidden = false; | ||||
if (notification.leave) | if (notification.leave) | ||||
{ | { | ||||
Engine.GetGUIObjectByName("tutorialWarning").caption = translate("Click to quit this tutorial."); | Engine.GetGUIObjectByName("tutorialWarning").caption = translate("Click to quit this tutorial."); | ||||
▲ Show 20 Lines • Show All 389 Lines • ▼ Show 20 Lines | function colorizePlayernameByGUID(guid) | ||||
let username = g_PlayerAssignments[guid] ? g_PlayerAssignments[guid].name : ""; | let username = g_PlayerAssignments[guid] ? g_PlayerAssignments[guid].name : ""; | ||||
let playerID = g_PlayerAssignments[guid] ? g_PlayerAssignments[guid].player : -1; | let playerID = g_PlayerAssignments[guid] ? g_PlayerAssignments[guid].player : -1; | ||||
return colorizePlayernameHelper(username, playerID); | return colorizePlayernameHelper(username, playerID); | ||||
} | } | ||||
function colorizePlayernameHelper(username, playerID) | function colorizePlayernameHelper(username, playerID) | ||||
{ | { | ||||
let playerColor = playerID > -1 ? rgbToGuiColor(g_DisplayedPlayerColors[playerID]) : "white"; | let playerColor = playerID > -1 ? rgbToGuiColor(g_DisplayedPlayerColors[playerID]) : "white"; | ||||
return coloredText(username || translate("Unknown Player"), playerColor); | return coloredText(username || translate("Unknown Player"), playerColor); | ||||
Done Inline ActionsSame, as below; what is the benefit to using this function? Thered only be one if we want to remove the text function, but if we'd remove that, then we'd be forced to create an unused object here every call. (In rmgen there is enough recursion and nested calls to have one unneeded object become created half a million times during mapgen) elexis: Same, as below; what is the benefit to using this function? Thered only be one if we want to… | |||||
} | } | ||||
/** | /** | ||||
* Insert the colorized playername to chat messages sent by the AI and time notifications. | * Insert the colorized playername to chat messages sent by the AI and time notifications. | ||||
*/ | */ | ||||
function colorizePlayernameParameters(parameters) | function colorizePlayernameParameters(parameters) | ||||
{ | { | ||||
for (let param in parameters) | for (let param in parameters) | ||||
▲ Show 20 Lines • Show All 313 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator
Is it a tooltip?
Does every modder who wants to change the tooltip color from orange to red also want to change this one to red (because its displayed in the same place in the same way) or is it coincidental that its orange in both cases? If all warnings shown in text are orange, would TooltipWarning not constraint the meaining to tooltips when its also used for regular text?