Ticket #1778: 0ad-adding-RecordLastMPServerAndPlayer.diff

File 0ad-adding-RecordLastMPServerAndPlayer.diff, 2.4 KB (added by Aurélio A. Heckert, 11 years ago)

The last 50% to close the ticket.

  • source/gui/scripting/ScriptFunctions.cpp

     
    185185    return server;
    186186}
    187187
     188void 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
    188195void StartNetworkGame(void* UNUSED(cbdata))
    189196{
    190197    ENSURE(g_NetServer);
     
    641648    scriptInterface.RegisterFunction<int, &GetPlayerID>("GetPlayerID");
    642649    scriptInterface.RegisterFunction<std::wstring, &GetDefaultPlayerName>("GetDefaultPlayerName");
    643650    scriptInterface.RegisterFunction<std::wstring, &GetDefaultMPServer>("GetDefaultMPServer");
     651    scriptInterface.RegisterFunction<void, std::wstring, std::wstring, &SaveMPConfig>("SaveMPConfig");
    644652    scriptInterface.RegisterFunction<void, std::string, &OpenURL>("OpenURL");
    645653    scriptInterface.RegisterFunction<void, &RestartInAtlas>("RestartInAtlas");
    646654    scriptInterface.RegisterFunction<bool, &AtlasIsAvailable>("AtlasIsAvailable");
  • binaries/data/mods/public/gui/gamesetup/gamesetup_mp.xml

     
    3939                Server Hostname or IP:
    4040            </object>
    4141
    42             <object name="joinIP" type="input" size="210 80 100%-32 104" style="StoneInput">
     42            <object name="joinServer" type="input" size="210 80 100%-32 104" style="StoneInput">
    4343                <action on="Load"><![CDATA[
    4444                    this.caption = Engine.GetDefaultMPServer();
    4545                ]]></action>
     
    4848            <object type="button" size="50%-144 100%-60 50%-16 100%-32" style="StoneButton">
    4949                Continue
    5050                <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))
    5455                    {
    5556                        switchSetupPage("pageJoin", "pageConnecting");
    5657                    }