mirror of
https://gitea.wildfiregames.com/0ad/0ad
synced 2026-08-15 14:43:32 -07:00
add game name to the game setup screen
This commit is contained in:
parent
b9c23b511a
commit
2fa849a1fc
5 changed files with 32 additions and 5 deletions
|
|
@ -0,0 +1,19 @@
|
|||
GameSettings.prototype.Attributes.GameName = class GameName extends GameSetting
|
||||
{
|
||||
init()
|
||||
{
|
||||
this.value = "";
|
||||
}
|
||||
|
||||
toInitAttributes(attribs)
|
||||
{
|
||||
if (this.value)
|
||||
attribs.gameName = this.value;
|
||||
}
|
||||
|
||||
fromInitAttributes(attribs)
|
||||
{
|
||||
if (attribs.gameName !== undefined)
|
||||
this.value = attribs.gameName;
|
||||
}
|
||||
};
|
||||
|
|
@ -184,10 +184,12 @@ function formatPlayerInfo(playerDataArray, playerStates)
|
|||
function getGameDescription(initAttributes, mapCache)
|
||||
{
|
||||
const titles = [];
|
||||
const gameDescription = initAttributes.gameName ?
|
||||
coloredText(translate("Game:"), g_DescriptionHighlight) + " " +
|
||||
escapeText(initAttributes.gameName) : "";
|
||||
const hostDescription = initAttributes.hostName ?
|
||||
sprintf(translate("Host: %(playername)s"), {
|
||||
"playername": escapeText(initAttributes.hostName)
|
||||
}) : "";
|
||||
coloredText(translate("Host:"), g_DescriptionHighlight) + " " +
|
||||
escapeText(initAttributes.hostName) : "";
|
||||
|
||||
if (!initAttributes.settings.VictoryConditions.length)
|
||||
titles.push({
|
||||
|
|
@ -439,7 +441,8 @@ function getGameDescription(initAttributes, mapCache)
|
|||
title.value || translateWithContext("game setup option", "disabled")
|
||||
})).join("\n");
|
||||
|
||||
return hostDescription + (hostDescription && settingsDescription ? "\n" : "") + settingsDescription;
|
||||
const descriptions = [gameDescription, hostDescription, settingsDescription].filter(description => description);
|
||||
return descriptions.join("\n");
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -31,6 +31,8 @@ class SetupWindow
|
|||
const mapCache = new MapCache();
|
||||
g_GameSettings = new GameSettings();
|
||||
g_GameSettings.init(mapCache, g_IsController ? savedGame : undefined);
|
||||
if (initData?.gameName)
|
||||
g_GameSettings.gameName.value = initData.gameName;
|
||||
if (initData?.hostName)
|
||||
g_GameSettings.hostName.value = initData.hostName;
|
||||
|
||||
|
|
|
|||
|
|
@ -100,7 +100,7 @@ async function init(attribs)
|
|||
}
|
||||
if (attribs.hasPassword)
|
||||
{
|
||||
g_ServerName = attribs.name;
|
||||
g_ServerName = attribs.gameName || "";
|
||||
switchSetupPage("pagePassword");
|
||||
const passwordResult = await cancelOr(new Promise(resolve =>
|
||||
{
|
||||
|
|
@ -111,6 +111,7 @@ async function init(attribs)
|
|||
}
|
||||
try
|
||||
{
|
||||
g_ServerName = attribs.gameName || "";
|
||||
startJoinFromLobby(attribs.name, attribs.hostJID,
|
||||
attribs.hasPassword ? Engine.GetGUIObjectByName("clientPassword").caption : "");
|
||||
switchSetupPage("pageConnecting");
|
||||
|
|
@ -398,6 +399,7 @@ async function handleAuthenticated(message, loadSavedGame)
|
|||
"argument": {
|
||||
"savedGame": savegameID, // Undefined or the savegame ID
|
||||
"serverName": g_ServerName,
|
||||
"gameName": g_ServerName,
|
||||
"hasPassword": g_ServerHasPassword,
|
||||
"hostName": message.hostName
|
||||
}
|
||||
|
|
|
|||
|
|
@ -78,6 +78,7 @@ class JoinButton
|
|||
Engine.OpenChildPage("page_gamesetup_mp.xml", {
|
||||
"multiplayerGameType": "join",
|
||||
"name": g_Nickname,
|
||||
"gameName": stanza.name,
|
||||
"rating": this.getRejoinRating(stanza),
|
||||
"hasPassword": !!stanza.hasPassword,
|
||||
"hostJID": stanza.hostJID
|
||||
|
|
|
|||
Loading…
Reference in a new issue