コード例 #1
0
bool pawsCharacterPickerWindow::OnButtonPressed(int /*mouseButton*/, int /*keyModifer*/, pawsWidget* widget)
{
    if(!widget)
        return false;

    switch ( widget->GetID() )
    {
        case CHARACTER_DELETE_BUTTON:
        {
            csString name;
            name.Format("SelectCharacter%i", selectedCharacter);
            csString confirm;
            // Catch empty selection.
            if(selectedCharacter < 0)
            {
                confirm.Format( "You must select a character to delete!" );
                PawsManager::GetSingleton().CreateWarningBox( confirm, this );
                return false;
            }
            csString charName(((pawsButton*)FindWidget(name))->GetText());
            // Catch invalid selection.
            if(charName == "New Character")
                return false;

            csString msg("Warning! this will PERMANENTLY DELETE your character.  Are you sure you want to continue?");
            pawsYesNoBox::Create(this, msg, YES_DELETE_CHARACTER, NO_DELETE_CHARACTER);

            return true;
        }

        case BACK_BUTTON:
        {
            ReturnToLoginWindow();
            return true;
        }

        case CHARACTER_BUTTON_0:
        case CHARACTER_BUTTON_1:
        case CHARACTER_BUTTON_2:
        case CHARACTER_BUTTON_3:
        {
            if(!connecting)
            {
                SelectCharacter(widget->GetID(),widget);
            }
            break;    
        }
        
        case CHARACTER_ACTION_BUTTON:
        {
            // if we have a character then we play as that one.
            if ( selectedCharacter != -1 && !connecting )
            {
                // Disable the button so that we don't send 2 picker message
                connecting = true;

                csString name;
                name.Format("SelectCharacter%i", selectedCharacter);
                
                // Send the name of the character to the server. 
                csString charname( ((pawsButton*)FindWidget(name))->GetText() );
                                
                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;
        }
        
        case QUIT_BUTTON:
        {
            psengine->QuitClient();
            return true;
        }
       
    }
    return false;
}
コード例 #2
0
ファイル: pawscharpick.cpp プロジェクト: garinh/planeshift
bool pawsCharacterPickerWindow::OnButtonPressed( int mouseButton, int keyModifer, pawsWidget* widget )
{
    if(!widget)
        return false;

    switch ( widget->GetID() )
    {
        case YES_DELETE_CHARACTER:
        {
            PawsManager::GetSingleton().SetModalWidget(NULL);
            widget->GetParent()->Hide();

            pawsStringPromptWindow::Create("Please enter your account password to confirm:", csString(""),false, 220, 20, this, "DeletionConfirm", 0, true); 
            pawsEditTextBox* passbox =  dynamic_cast<pawsEditTextBox*>
                                        (PawsManager::GetSingleton().FindWidget("stringPromptEntry"));

            if (passbox)
            {
               passbox->SetPassword(true);
            }
            return true;
        }

        case NO_DELETE_CHARACTER:
        {
            return true;
        }

        case CHARACTER_DELETE_BUTTON:
        {
            csString name;
            name.Format("SelectCharacter%i", selectedCharacter);
            csString confirm;
            // Catch empty selection.
            if(selectedCharacter < 0)
            {
                confirm.Format( "You must select a character to delete!" );
                PawsManager::GetSingleton().CreateWarningBox( confirm, this );
                return false;
            }
            csString charName(((pawsButton*)FindWidget(name))->GetText());
            // Catch invalid selection.
            if(charName == "New Character")
                return false;

            csString msg("Warning! this will PERMANENTLY DELETE your character.  Are you sure you want to continue?");
            pawsYesNoBox::Create(this, msg, YES_DELETE_CHARACTER, NO_DELETE_CHARACTER);

            return true;
        }

        case BACK_BUTTON:
        {
            ReturnToLoginWindow();
            return true;
        }

        case CONFIRM_YES:
        {
            //Delete the selected character
            csString name;
            name.Format("SelectCharacter%i", selectedCharacter);

            // Get Full name.
            psString charFullName( ((pawsButton*)FindWidget(name))->GetText() );
            psString charFirstName;
            charFullName.GetWord( 0, charFirstName );

            psCharDeleteMessage msg(charFirstName, 0);
            msg.SendMessage();

            return true;
        }

        case CONFIRM_NO:
        {
            PawsManager::GetSingleton().SetModalWidget(NULL);
            widget->GetParent()->Hide();
            return true;
        }

        case CHARACTER_BUTTON_0:
        case CHARACTER_BUTTON_1:
        case CHARACTER_BUTTON_2:
        case CHARACTER_BUTTON_3:
        {
            if(!connecting)
            {
                SelectCharacter(widget->GetID(),widget);
            }
            break;    
        }
        
        case CHARACTER_ACTION_BUTTON:
        {
            // if we have a character then we play as that one.
            if ( selectedCharacter != -1 && !connecting )
            {
                // Disable the button so that we don't send 2 picker message
                connecting = true;

                csString name;
                name.Format("SelectCharacter%i", selectedCharacter);
                
                // Send the name of the character to the server. 
                csString charname( ((pawsButton*)FindWidget(name))->GetText() );
                                
                psCharacterPickerMessage msg(charname);
                msg.SendMessage();
            }
            
            return true;
        }
        
        case QUIT_BUTTON:
        {
            psengine->QuitClient();
            return true;
        }
       
    }
    return false;
}
コード例 #3
0
void pawsCharacterPickerWindow::HandleMessage( MsgEntry* me )
{
    switch( me->GetType() )
    {
        // Incomming character description.  At the moment it is just the
//         // character name and the factory of the mesh.
        case MSGTYPE_AUTHAPPROVED:
        {
            if(charactersFound != 0)
                return;

            //get a requested autoconnect charname
            csRef<iConfigManager> cfg =  csQueryRegistry<iConfigManager> (PawsManager::GetSingleton().GetObjectRegistry());
            //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);            

            for (int i=0; i < (msg.msgNumOfChars); i++)
             
            {
                csString name,race,factName,traits,equipment;

                msg.GetCharacter(me,name,race,factName, traits,equipment);

                // Set the name of the character in the right button.
                csString buff;
                buff.Format("SelectCharacter%i", charactersFound);
                pawsButton* button = (pawsButton*)FindWidget( buff );
                button->SetText( name );
                button->Show();
                buff.Format("ImgCharacter%i", charactersFound);
                pawsWidget* radio = FindWidget(buff);
                radio->Show();
                
                // Store the character data.
                models[charactersFound].factName = factName;
                models[charactersFound].race = race;
                models[charactersFound].traits = traits;
                models[charactersFound].equipment = equipment;                                   
                charactersFound++;

                //if this is the name we have requested for autologin
                //choose it immediately
                if(!connecting && ( requestedAutoPickId == i ||
                                    (requestedAutoPickId == -1 && name == lastCharName) ||
                                    name == requestedAutoPickName))
                {
                    connecting = true;
                    psCharacterPickerMessage msg(name);
                    msg.SendMessage();
                }

                //save the character id we have found
                if(lastCharName == name)
                    selectedCharacter = i;
            }

            // If we have all the chars we have then turn on the rest of the 
            // buttons as new character ones.                            
            // Allow player to join only after all messages have been received
            // to prevent user thinking chars have been 'lost'.
            if ( charactersFound == psengine->GetNumChars() )
            {
                pawsWidget* widget = FindWidget("login");
                if ( widget )
                    widget->Show();           
                if ( charactersFound == 1 )
                {
                   /* csString buff;
                    buff.Format("SelectCharacter%i", charactersFound);
                    pawsWidget* widget = FindWidget( buff );
                    widget->Show();
                    buff.Format("ImgCharacter%i", charactersFound);
                    pawsWidget* radio = FindWidget(buff);
                    radio->Show();*/
                    pawsWidget* deleteCharBut = FindWidget("delete");
                    if (deleteCharBut)
                        deleteCharBut->Show();                
                }  
                if ( charactersFound == 0 )
                {
                    csString buff;
                    buff.Format("SelectCharacter%i", charactersFound);
                    pawsWidget* widget = FindWidget( buff );
                    widget->Show();
                    buff.Format("ImgCharacter%i", charactersFound);
                    pawsWidget* radio = FindWidget(buff);
                    radio->Show();
                    pawsWidget* deleteCharBut = FindWidget("delete");
                    if (deleteCharBut)
                        deleteCharBut->Hide();                
                }                       

                // If there's some char created then show delete option
                /*pawsWidget* deleteCharBut = FindWidget("delete");
                if (deleteCharBut)
                    deleteCharBut->Show();*/
            }
            return;
        }
        case MSGTYPE_CHAR_DELETE:
        {
            ReturnToLoginWindow();
            break;
        }
    }
    
}