Fix #2595 by validating cheats are disabled in rated games. Also forces locked teams in ranked games and adds a scrollbar to the lobby subject.

This was SVN commit r15405.
This commit is contained in:
JoshuaJB 2014-06-20 23:59:04 +00:00
parent 160a83b73f
commit b9a4af4cc6
5 changed files with 28 additions and 18 deletions

View File

@ -116,6 +116,8 @@
textcolor="white"
text_align="left"
text_valign="top"
scrollbar="true"
scrollbar_style="ModernScrollBar"
/>
<style name="ModernInput"
sprite="ModernDarkBoxWhite"

View File

@ -284,6 +284,8 @@ function initMain()
// Update attributes so other players can see change
g_GameAttributes.settings.RatingEnabled = this.checked;
Engine.SetRankedGame(this.checked);
Engine.GetGUIObjectByName("enableCheats").enabled = !this.checked;
Engine.GetGUIObjectByName("lockTeams").enabled = !this.checked;
if (!g_IsInGuiUpdate)
updateGameAttributes();
};
@ -291,7 +293,6 @@ function initMain()
else
{
// If we're a network client, disable all the map controls
// TODO: make them look visually disabled so it's obvious why they don't work
Engine.GetGUIObjectByName("mapTypeSelection").hidden = true;
Engine.GetGUIObjectByName("mapTypeText").hidden = false;
Engine.GetGUIObjectByName("mapFilterSelection").hidden = true;
@ -333,7 +334,10 @@ function initMain()
{
Engine.GetGUIObjectByName("optionRating").hidden = false;
Engine.GetGUIObjectByName("enableRating").checked = Engine.IsRankedGame();
g_GameAttributes.settings.RatingEnabled = true;
g_GameAttributes.settings.RatingEnabled = Engine.IsRankedGame();
// We force locked teams and disabled cheats in ranked games.
Engine.GetGUIObjectByName("enableCheats").enabled = !Engine.IsRankedGame();
Engine.GetGUIObjectByName("lockTeams").enabled = !Engine.IsRankedGame();
}
if (g_IsController)
{
@ -398,6 +402,9 @@ function initMain()
// to allow easy keyboard selection of maps
Engine.GetGUIObjectByName("mapSelection").focus();
}
// Sync g_GameAttributes to everyone.
if (g_IsController)
updateGameAttributes();
}
function handleNetMessage(message)
@ -426,8 +433,19 @@ function handleNetMessage(message)
case "gamesetup":
if (message.data) // (the host gets undefined data on first connect, so skip that)
{
g_GameAttributes = message.data;
// Validate some settings for rated games.
if (g_GameAttributes.settings.RatingEnabled)
{
// Cheats can never be on in rated games.
g_GameAttributes.settings.CheatsEnabled = false;
// Teams must be locked in rated games.
g_GameAttributes.settings.LockTeams = true;
}
}
onGameAttributesChange();
break;
@ -1040,14 +1058,15 @@ function onGameAttributesChange()
var startingResourcesText = Engine.GetGUIObjectByName("startingResourcesText");
var gameSpeedText = Engine.GetGUIObjectByName("gameSpeedText");
// Josh 20.6.2014: Not quite sure why we check for undefined on these properties, that shouldn't ever happen (?)
var sizeIdx = (mapSettings.Size !== undefined && g_MapSizes.tiles.indexOf(mapSettings.Size) != -1 ? g_MapSizes.tiles.indexOf(mapSettings.Size) : g_MapSizes["default"]);
var speedIdx = (g_GameAttributes.gameSpeed !== undefined && g_GameSpeeds.speeds.indexOf(g_GameAttributes.gameSpeed) != -1) ? g_GameSpeeds.speeds.indexOf(g_GameAttributes.gameSpeed) : g_GameSpeeds["default"];
var victoryIdx = (mapSettings.GameType !== undefined && VICTORY_DATA.indexOf(mapSettings.GameType) != -1 ? VICTORY_DATA.indexOf(mapSettings.GameType) : VICTORY_DEFAULTIDX);
enableCheats.checked = (g_GameAttributes.settings.CheatsEnabled === undefined || !g_GameAttributes.settings.CheatsEnabled ? false : true)
enableCheats.checked = (mapSettings.CheatsEnabled === undefined || !mapSettings.CheatsEnabled ? false : true)
enableCheatsText.caption = (enableCheats.checked ? "Yes" : "No");
if (g_GameAttributes.settings.RatingEnabled !== undefined)
if (mapSettings.RatingEnabled !== undefined)
{
enableRating.checked = g_GameAttributes.settings.RatingEnabled;
enableRating.checked = mapSettings.RatingEnabled;
Engine.SetRankedGame(enableRating.checked);
enableRatingText.caption = (enableRating.checked ? "Yes" : "No");
}

View File

@ -419,7 +419,7 @@ function joinSelectedGame()
}
// Open Multiplayer connection window with join option.
Engine.PushGuiPage("page_gamesetup_mp.xml", { multiplayerGameType: "join", name: sname, ip: sip, rating: g_userRating });
Engine.PushGuiPage("page_gamesetup_mp.xml", { multiplayerGameType: "join", name: sname, ip: "127.0.0.1", rating: g_userRating });
}
}

View File

@ -84,7 +84,7 @@
<!-- Map Description -->
<object type="image" sprite="ModernDarkBoxWhite" size="3% 290 97% 75%">
<object name="sgMapDescription" size="0 0 100% 100%" type="text" style="MapDescription"/>
<object name="sgMapDescription" size="0 0 100% 100%" type="text" style="ModernText" font="sans-12"/>
</object>
<object type="image" sprite="ModernDarkBoxWhite" size="3% 75%+5 97% 99%">

View File

@ -13,17 +13,6 @@
text_valign="center"
/>
<style name="MapDescription"
buffer_zone="8"
font="sans-12"
scrollbar="true"
scrollbar_style="ModernScrollBar"
scroll_bottom="true"
textcolor="white"
text_align="left"
text_valign="top"
/>
<style name="MapPlayerList"
buffer_zone="8"
font="sans-14"