Ticket #3355: t3355_move_maptypes_v1.patch
File t3355_move_maptypes_v1.patch, 11.0 KB (added by , 9 years ago) |
---|
-
binaries/data/mods/public/gui/common/settings.js
30 30 function loadSettingsValues() 31 31 { 32 32 var settings = { 33 33 "Ceasefire": loadCeasefire(), 34 34 "GameSpeeds": loadSettingValuesFile("game_speeds.json"), 35 "MapTypes": loadMapTypes(), 35 36 "PopulationCapacities": loadPopulationCapacities(), 36 37 "StartingResources": loadSettingValuesFile("starting_resources.json"), 37 38 "VictoryConditions": loadVictoryConditions() 38 39 }; 39 40 … … 88 89 sprintf(translatePluralWithContext("ceasefire", "%(minutes)s minute", "%(minutes)s minutes", timeout), { "minutes": timeout }) 89 90 })); 90 91 } 91 92 92 93 /** 94 * Hardcoded, as modding is not supported without major changes. 95 * 96 * @returns {Array} 97 */ 98 function loadMapTypes() 99 { 100 return [ 101 { 102 "Name": "skirmish", 103 "Title": translateWithContext("map", "Skirmish"), 104 "Default": true 105 }, 106 { 107 "Name": "random", 108 "Title": translateWithContext("map", "Random") 109 }, 110 { 111 "Name": "scenario", 112 "Title": translate("Scenario") // TODO: update the translation (but not shortly before a release) 113 } 114 ]; 115 } 116 117 /** 93 118 * Loads available gametypes. 94 119 * 95 120 * @returns {Array|undefined} 96 121 */ 97 122 function loadVictoryConditions() -
binaries/data/mods/public/gui/gamesetup/gamesetup.js
3 3 const DEFAULT_NETWORKED_MAP = "Acropolis 01"; 4 4 const DEFAULT_OFFLINE_MAP = "Acropolis 01"; 5 5 6 6 const g_Ceasefire = prepareForDropdown(g_Settings ? g_Settings.Ceasefire : undefined); 7 7 const g_GameSpeeds = prepareForDropdown(g_Settings ? g_Settings.GameSpeeds.filter(speed => !speed.ReplayOnly) : undefined); 8 const g_ VictoryConditions = prepareForDropdown(g_Settings ? g_Settings.VictoryConditions : undefined);8 const g_MapTypes = prepareForDropdown(g_Settings ? g_Settings.MapTypes : undefined); 9 9 const g_PopulationCapacities = prepareForDropdown(g_Settings ? g_Settings.PopulationCapacities : undefined); 10 10 const g_StartingResources = prepareForDropdown(g_Settings ? g_Settings.StartingResources : undefined); 11 const g_VictoryConditions = prepareForDropdown(g_Settings ? g_Settings.VictoryConditions : undefined); 11 12 12 13 //////////////////////////////////////////////////////////////////////////////////////////////// 13 14 14 15 // Is this is a networked game, or offline 15 16 var g_IsNetworked; … … 126 127 // Init civs 127 128 initCivNameList(); 128 129 129 130 // Init map types 130 131 var mapTypes = Engine.GetGUIObjectByName("mapTypeSelection"); 131 mapTypes.list = [translateWithContext("map", "Skirmish"), translateWithContext("map", "Random"), translate("Scenario")];132 mapTypes.list_data = ["skirmish","random","scenario"];132 mapTypes.list = g_MapTypes.Title; 133 mapTypes.list_data = g_MapTypes.Name; 133 134 134 135 // Setup map filters - will appear in order they are added 135 136 addFilter("default", translate("Default"), function(settings) { return settings && (settings.Keywords === undefined || !keywordTestOR(settings.Keywords, ["naval", "demo", "hidden"])); }); 136 137 addFilter("naval", translate("Naval Maps"), function(settings) { return settings && settings.Keywords !== undefined && keywordTestAND(settings.Keywords, ["naval"]); }); 137 138 addFilter("demo", translate("Demo Maps"), function(settings) { return settings && settings.Keywords !== undefined && keywordTestAND(settings.Keywords, ["demo"]); }); … … 158 159 } 159 160 160 161 // Setup controls for host only 161 162 if (g_IsController) 162 163 { 163 mapTypes.selected = 0;164 mapTypes.selected = g_MapTypes.Default; 164 165 mapFilters.selected = 0; 165 166 166 167 // Create a unique ID for this match, to be used for identifying the same game reports 167 168 // for the lobby. 168 169 g_GameAttributes.matchID = Engine.GetMatchID(); … … 738 739 } 739 740 740 741 var mapFilterSelection = Engine.GetGUIObjectByName("mapFilterSelection"); 741 742 mapFilterSelection.selected = mapFilterSelection.list_data.indexOf(attrs.mapFilter); 742 743 743 var mapTypeSelection = Engine.GetGUIObjectByName("mapTypeSelection"); 744 mapTypeSelection.selected = mapTypeSelection.list_data.indexOf(attrs.mapType); 744 Engine.GetGUIObjectByName("mapTypeSelection").selected = g_MapTypes.Name.indexOf(attrs.mapType); 745 745 746 746 initMapNameList(); 747 747 748 748 var mapSelectionBox = Engine.GetGUIObjectByName("mapSelection"); 749 749 mapSelectionBox.selected = mapSelectionBox.list_data.indexOf(mapName); … … 1164 1164 if (!g_IsController) 1165 1165 { 1166 1166 var mapFilterSelection = Engine.GetGUIObjectByName("mapFilterSelection"); 1167 1167 var mapFilterId = mapFilterSelection.list_data.indexOf(g_GameAttributes.mapFilter); 1168 1168 Engine.GetGUIObjectByName("mapFilterText").caption = mapFilterSelection.list[mapFilterId]; 1169 var mapTypeSelection = Engine.GetGUIObjectByName("mapTypeSelection"); 1170 var idx = mapTypeSelection.list_data.indexOf(g_GameAttributes.mapType); 1171 Engine.GetGUIObjectByName("mapTypeText").caption = mapTypeSelection.list[idx]; 1169 Engine.GetGUIObjectByName("mapTypeText").caption = g_MapTypes.Title[g_MapTypes.Name.indexOf(g_GameAttributes.mapType)]; 1172 1170 var mapSelectionBox = Engine.GetGUIObjectByName("mapSelection"); 1173 1171 mapSelectionBox.selected = mapSelectionBox.list_data.indexOf(mapName); 1174 1172 Engine.GetGUIObjectByName("mapSelectionText").caption = translate(getMapDisplayName(mapName)); 1175 1173 if (mapSettings.PopulationCap) 1176 1174 { -
binaries/data/mods/public/gui/lobby/lobby.js
1 const g_MapTypes = prepareForDropdown(g_Settings ? g_Settings.MapTypes : undefined); 2 1 3 var g_ChatMessages = []; 2 4 var g_Name = "unknown"; 3 5 var g_GameList = {} 4 6 var g_GameListSortBy = "name"; 5 7 var g_PlayerListSortBy = "name"; … … 8 10 var g_specialKey = Math.random(); 9 11 // This object looks like {"name":[numMessagesSinceReset, lastReset, timeBlocked]} when in use. 10 12 var g_spamMonitor = {}; 11 13 var g_timestamp = Engine.ConfigDB_GetValue("user", "lobby.chattimestamp") == "true"; 12 14 var g_mapSizes = {}; 13 const g_mapTypesText = [translateWithContext("map", "Skirmish"), translateWithContext("map", "Random"), translate("Scenario")];14 const g_mapTypes = ["skirmish", "random", "scenario"];15 15 var g_userRating = ""; // Rating of user, defaults to Unrated 16 16 var g_modPrefix = "@"; 17 17 // Block spammers for 30 seconds. 18 18 var SPAM_BLOCK_LENGTH = 30; 19 19 20 20 //////////////////////////////////////////////////////////////////////////////////////////////// 21 21 22 22 function init(attribs) 23 23 { 24 if (!g_Settings) 25 { 26 returnToMainMenu(); 27 return; 28 } 29 24 30 // Play menu music 25 31 initMusic(); 26 32 global.music.setState(global.music.states.MENU); 27 33 28 34 g_Name = Engine.LobbyGetNick(); … … 40 46 var playersNumberFilter = Engine.GetGUIObjectByName("playersNumberFilter"); 41 47 playersNumberFilter.list = [translateWithContext("player number", "Any")].concat(playersArray); 42 48 playersNumberFilter.list_data = [""].concat(playersArray); 43 49 44 50 var mapTypeFilter = Engine.GetGUIObjectByName("mapTypeFilter"); 45 mapTypeFilter.list = [translateWithContext("map", "Any")].concat(g_ mapTypesText);46 mapTypeFilter.list_data = [""].concat(g_ mapTypes);51 mapTypeFilter.list = [translateWithContext("map", "Any")].concat(g_MapTypes.Title); 52 mapTypeFilter.list_data = [""].concat(g_MapTypes.Name); 47 53 48 54 Engine.LobbySetPlayerPresence("available"); 49 55 Engine.SendGetGameList(); 50 56 Engine.SendGetBoardList(); 51 57 … … 56 62 updateSubject(Engine.LobbyGetRoomSubject()); 57 63 58 64 resetFilters(); 59 65 } 60 66 67 function returnToMainMenu() 68 { 69 lobbyStop(); 70 Engine.SwitchGuiPage("page_pregame.xml"); 71 } 72 61 73 //////////////////////////////////////////////////////////////////////////////////////////////// 62 74 // Xmpp client connection management 63 75 //////////////////////////////////////////////////////////////////////////////////////////////// 64 76 65 77 … … 101 113 function resetFilters() 102 114 { 103 115 // Reset states of gui objects 104 116 Engine.GetGUIObjectByName("mapSizeFilter").selected = 0 105 117 Engine.GetGUIObjectByName("playersNumberFilter").selected = 0; 106 Engine.GetGUIObjectByName("mapTypeFilter").selected = 0;118 Engine.GetGUIObjectByName("mapTypeFilter").selected = g_MapTypes.Default; 107 119 Engine.GetGUIObjectByName("showFullFilter").checked = false; 108 120 109 121 applyFilters(); 110 122 } 111 123 … … 472 484 name = '[color="255 0 0"]' + name + '[/color]'; 473 485 list_name.push(name); 474 486 list_ip.push(g.ip); 475 487 list_mapName.push(translate(g.niceMapName)); 476 488 list_mapSize.push(translatedMapSize(g.mapSize)); 477 let idx = g_mapTypes.indexOf(g.mapType);478 list_mapType.push( idx != -1 ? g_mapTypesText[idx] : "");489 let mapTypeIdx = g_MapTypes.Name.indexOf(g.mapType); 490 list_mapType.push(mapTypeIdx != -1 ? g_MapTypes.Title[mapTypeIdx] : ""); 479 491 list_nPlayers.push(g.nbp + "/" +g.tnbp); 480 492 list.push(name); 481 493 list_data.push(c); 482 494 } 483 495 c++; … … 599 611 // Display the map name, number of players, the names of the players, the map size and the map type. 600 612 Engine.GetGUIObjectByName("sgMapName").caption = translate(g_GameList[g].niceMapName); 601 613 Engine.GetGUIObjectByName("sgNbPlayers").caption = g_GameList[g].nbp + "/" + g_GameList[g].tnbp; 602 614 Engine.GetGUIObjectByName("sgPlayersNames").caption = g_GameList[g].players; 603 615 Engine.GetGUIObjectByName("sgMapSize").caption = translatedMapSize(g_GameList[g].mapSize); 604 let idx = g_mapTypes.indexOf(g_GameList[g].mapType);605 Engine.GetGUIObjectByName("sgMapType").caption = idx != -1 ? g_mapTypesText[idx] : "";616 let mapTypeIdx = g_MapTypes.indexOf(g_GameList[g].mapType); 617 Engine.GetGUIObjectByName("sgMapType").caption = mapTypeIdx != -1 ? g_MapTypes.Title[mapTypeIdx] : ""; 606 618 607 619 // Display map description if it exists, otherwise display a placeholder. 608 620 if (mapData && mapData.settings.Description) 609 621 var mapDescription = translate(mapData.settings.Description); 610 622 else … … 810 822 break; 811 823 case "ban": // TODO: Split reason from nick and pass it too, for now just support "/ban nick" 812 824 Engine.LobbyBan(nick, ""); 813 825 break; 814 826 case "quit": 815 lobbyStop(); 816 Engine.SwitchGuiPage("page_pregame.xml"); 827 returnToMainMenu(); 817 828 break; 818 829 case "say": 819 830 case "me": 820 831 return false; 821 832 default: -
binaries/data/mods/public/gui/lobby/lobby.xml
162 162 </action> 163 163 </object> 164 164 165 165 <object type="button" style="ModernButtonRed" size="0 100%-25 100% 100%"> 166 166 <translatableAttribute id="caption">Main Menu</translatableAttribute> 167 <action on="Press"> 168 lobbyStop(); 169 Engine.SwitchGuiPage("page_pregame.xml"); 170 </action> 167 <action on="Press">returnToMainMenu();</action> 171 168 </object> 172 169 </object> 173 170 174 171 <!-- Middle panel: Filters, game list, chat box. --> 175 172 <object name="middlePanel" size="20%+5 5% 100%-255 97.2%">