Ticket #1778: 0ad-adding-RecordLastMPServerAndPlayer.diff
File 0ad-adding-RecordLastMPServerAndPlayer.diff, 2.4 KB (added by , 11 years ago) |
---|
-
source/gui/scripting/ScriptFunctions.cpp
185 185 return server; 186 186 } 187 187 188 void SaveMPConfig(void* UNUSED(cbdata), std::wstring playerName, std::wstring server) 189 { 190 g_ConfigDB.CreateValue(CFG_USER, "playername")->m_String = CStrW(playerName).ToUTF8(); 191 g_ConfigDB.CreateValue(CFG_USER, "multiplayerserver")->m_String = CStrW(server).ToUTF8(); 192 g_ConfigDB.WriteFile(CFG_USER); 193 } 194 188 195 void StartNetworkGame(void* UNUSED(cbdata)) 189 196 { 190 197 ENSURE(g_NetServer); … … 641 648 scriptInterface.RegisterFunction<int, &GetPlayerID>("GetPlayerID"); 642 649 scriptInterface.RegisterFunction<std::wstring, &GetDefaultPlayerName>("GetDefaultPlayerName"); 643 650 scriptInterface.RegisterFunction<std::wstring, &GetDefaultMPServer>("GetDefaultMPServer"); 651 scriptInterface.RegisterFunction<void, std::wstring, std::wstring, &SaveMPConfig>("SaveMPConfig"); 644 652 scriptInterface.RegisterFunction<void, std::string, &OpenURL>("OpenURL"); 645 653 scriptInterface.RegisterFunction<void, &RestartInAtlas>("RestartInAtlas"); 646 654 scriptInterface.RegisterFunction<bool, &AtlasIsAvailable>("AtlasIsAvailable"); -
binaries/data/mods/public/gui/gamesetup/gamesetup_mp.xml
39 39 Server Hostname or IP: 40 40 </object> 41 41 42 <object name="join IP" type="input" size="210 80 100%-32 104" style="StoneInput">42 <object name="joinServer" type="input" size="210 80 100%-32 104" style="StoneInput"> 43 43 <action on="Load"><![CDATA[ 44 44 this.caption = Engine.GetDefaultMPServer(); 45 45 ]]></action> … … 48 48 <object type="button" size="50%-144 100%-60 50%-16 100%-32" style="StoneButton"> 49 49 Continue 50 50 <action on="Press"><![CDATA[ 51 if (startJoin( 52 getGUIObjectByName("joinPlayerName").caption, 53 getGUIObjectByName("joinIP").caption)) 51 var joinPlayerName = getGUIObjectByName("joinPlayerName").caption; 52 var joinServer = getGUIObjectByName("joinServer").caption; 53 Engine.SaveMPConfig(joinPlayerName, joinServer); 54 if (startJoin(joinPlayerName, joinServer)) 54 55 { 55 56 switchSetupPage("pageJoin", "pageConnecting"); 56 57 }