From: <wel...@us...> - 2010-10-16 21:06:55
|
Revision: 6301 http://planeshift.svn.sourceforge.net/planeshift/?rev=6301&view=rev Author: weltall2 Date: 2010-10-16 21:06:49 +0000 (Sat, 16 Oct 2010) Log Message: ----------- Now the last character chosen for each server is saved and selected automatically by default, additionally it's possible to define the name of the char for autologin, the id of the char (from 0 to 3) or -1 if you want the last choice to be automatically done Modified Paths: -------------- trunk/src/client/gui/pawscharpick.cpp trunk/src/client/gui/pawscharpick.h trunk/src/client/gui/pawsloginwindow.cpp Modified: trunk/src/client/gui/pawscharpick.cpp =================================================================== --- trunk/src/client/gui/pawscharpick.cpp 2010-10-16 20:17:25 UTC (rev 6300) +++ trunk/src/client/gui/pawscharpick.cpp 2010-10-16 21:06:49 UTC (rev 6301) @@ -55,7 +55,9 @@ #define YES_DELETE_CHARACTER 300 #define NO_DELETE_CHARACTER 302 -#define CNF_AUTOPICK_CHAR "PlaneShift.Connection.AutoPickChar" +#define CNF_AUTOPICK_CHAR_NAME "PlaneShift.Connection.AutoPickChar.Name" +#define CNF_AUTOPICK_CHAR "PlaneShift.Connection.AutoPickChar.Id" +#define CNF_LAST_CHAR "PlaneShift.Connection.%s.LastChar" pawsCharacterPickerWindow::pawsCharacterPickerWindow() @@ -109,7 +111,13 @@ //get a requested autoconnect charname csRef<iConfigManager> cfg = csQueryRegistry<iConfigManager> (PawsManager::GetSingleton().GetObjectRegistry()); - csString requestedAutoPickName = cfg->GetStr(CNF_AUTOPICK_CHAR, ""); + //gets the autopick choice + csString requestedAutoPickName = cfg->GetStr(CNF_AUTOPICK_CHAR_NAME, ""); + int requestedAutoPickId = cfg->GetInt(CNF_AUTOPICK_CHAR, -2); + //gets the last used name to select it + csString cnf_name; + cnf_name.Format(CNF_LAST_CHAR,serverName.GetData()); + csString lastCharName = cfg->GetStr(cnf_name,""); psAuthApprovedMessage msg(me); @@ -138,14 +146,20 @@ //if this is the name we have requested for autologin //choose it immediately - if(!connecting && name == requestedAutoPickName) + if(!connecting && ( requestedAutoPickId == i || + (requestedAutoPickId == -1 && name == lastCharName) || + name == requestedAutoPickName)) { connecting = true; psCharacterPickerMessage msg(name); msg.SendMessage(); } - - SelectCharacter(0,FindWidget("SelectCharacter0")); + + //only select 0 the first time in case we don't have an hit with the last selected char + if(lastCharName == name) + SelectCharacter(i, button); + else if(i==0) + SelectCharacter(0,FindWidget("SelectCharacter0")); } // If we have all the chars we have then turn on the rest of the @@ -321,6 +335,12 @@ psCharacterPickerMessage msg(charname); msg.SendMessage(); + + //save the selected charname to the configuration file + csString cnf_name; + cnf_name.Format(CNF_LAST_CHAR,serverName.GetData()); + csRef<iConfigManager> cfg = csQueryRegistry<iConfigManager> (PawsManager::GetSingleton().GetObjectRegistry()); + cfg->SetStr(cnf_name, charname); } return true; Modified: trunk/src/client/gui/pawscharpick.h =================================================================== --- trunk/src/client/gui/pawscharpick.h 2010-10-16 20:17:25 UTC (rev 6300) +++ trunk/src/client/gui/pawscharpick.h 2010-10-16 21:06:49 UTC (rev 6301) @@ -42,12 +42,13 @@ void SelectCharacter(int character, pawsWidget* widget); void SelectCharacter(int character); - // This is used ONLY by psClientDR to let the user join if we got the MsgStrings we need + /// This is used ONLY by psClientDR to let the user join if we got the MsgStrings we need void ReceivedStrings(); void Draw(); void StoreHashedPassword(csString passwordHash) {passHash = passwordHash;} + void StoreServerName(csString servName) {serverName = servName;} bool CheckLoadStatus(); private: @@ -74,6 +75,7 @@ Model models[MAX_CHARS]; csString passHash; + csString serverName; psCharAppearance* charApp; bool loaded; }; Modified: trunk/src/client/gui/pawsloginwindow.cpp =================================================================== --- trunk/src/client/gui/pawsloginwindow.cpp 2010-10-16 20:17:25 UTC (rev 6300) +++ trunk/src/client/gui/pawsloginwindow.cpp 2010-10-16 21:06:49 UTC (rev 6301) @@ -378,6 +378,9 @@ psengine->GetNetManager()->Authenticate( login->GetText(), storedPasswd ); } + //allow the server name to be known from the charpicker to autochose the last server chosen. + static_cast<pawsCharacterPickerWindow*>(PawsManager::GetSingleton().FindWidget("CharPickerWindow"))->StoreServerName(servers[listBox->GetSelectedRowNum()]->GetName().GetData()); + SaveLoginInformation(); connecting = true; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |