Example #1
0
void YOGLoginScreen::onAction(Widget *source, Action action, int par1, int par2)
{
	if ((action==BUTTON_RELEASED) || (action==BUTTON_SHORTCUT))
	{
		if (par1==CANCEL)
		{
			endExecute(Cancelled);
		}
		else if (par1==LOGIN)
		{
			//Update the gui
			animation->show();
			globalContainer->gfx->cursorManager.setNextType(CursorManager::CURSOR_WAIT);
			statusText->setText(Toolkit::getStringTable()->getString("[YESTS_CONNECTING]"));
			
			client->connect(YOG_SERVER_IP);
			wasConnecting = true;
		}
		else if (par1==REGISTER)
		{
			client->removeEventListener(this);
			YOGRegisterScreen screen(client);
			int rc = screen.execute(globalContainer->gfx, 40);
			client->addEventListener(this);
			if(rc == -1)
			{
				endExecute(-1);
			}
			else if(rc == YOGRegisterScreen::Connected)
			{
				runLobby();
			}
		}
	}
	if (action==TEXT_ACTIVATED)
	{
		if (source==login)
			password->deactivate();
		else if (source==password)
			login->deactivate();
	}
	if (action==TEXT_TABBED)
	{
		if (login->isActivated() && changeTabAgain)
		{
			login->deactivate();
			password->activate();
			changeTabAgain=false;
		}
		else if (password->isActivated() && changeTabAgain)
		{
			password->deactivate();
			login->activate();
			changeTabAgain=false;
		}
	}
}
void CustomGameOtherOptions::onAction(Widget *source, Action action, int par1, int par2)
{
	if ((action == BUTTON_RELEASED) || (action == BUTTON_SHORTCUT))
	{
		if(par1 == OK)
		{
			endExecute(Finished);
		}
		if(par1 == CANCEL)
		{
			gameHeader = oldGameHeader;
			endExecute(Canceled);
		}
	}
	else if (action==BUTTON_STATE_CHANGED)
	{
		if(par1>=200 && par1<300)
		{
			int team = -1;
			int nth = 0;
			int n = 0;
			///Find which team number this widget is for
			for(int i=0; i<gameHeader.getNumberOfPlayers(); ++i)
			{
				if(allyTeamNumbers[i] == source)
				{
					team = gameHeader.getBasePlayer(i).teamNumber;
					nth = allyTeamNumbers[i]->getIndex();
					n = nth+1;
					break;
				}
			}
			///Adjust all widgets that have this team number
			for(int i=0; i<gameHeader.getNumberOfPlayers(); ++i)
			{
				if(gameHeader.getBasePlayer(i).teamNumber == team)
				{
					allyTeamNumbers[i]->setIndex(nth);
				}
			}
			gameHeader.setAllyTeamNumber(team, n);
		}
		else if(par1 == TEAMSFIXED)
		{
			gameHeader.setAllyTeamsFixed(teamsFixed->getState());
		}
		else if(par1 == PRESTIGEWINENABLED)
		{
			updateGameHeaderWinningConditions();
		}
		else if(par1 == MAPDISCOVERED)
		{
			gameHeader.setMapDiscovered(mapDiscovered->getState());
		}
	}
}
Example #3
0
void YOGLoginScreen::runLobby()
{
	Glob2TabScreen screen(true);
	YOGClientLobbyScreen lobby(&screen, client);
	YOGClientOptionsScreen options(&screen, client);
	YOGClientMapDownloadScreen maps(&screen, client);
	int rc = screen.execute(globalContainer->gfx, 40);
	if(rc == YOGClientLobbyScreen::ConnectionLost)
		endExecute(ConnectionLost);
	else if(rc == -1)
		endExecute(-1);
	else
		endExecute(LoggedIn);
}
void CampaignMenuScreen::onAction(Widget *source, Action action, int par1, int par2)
{
	if ((action==BUTTON_RELEASED) || (action==BUTTON_SHORTCUT))
	{
		if ((par1==EXIT))
		{
			campaign.save(true);
			endExecute(par1);
		}
		else if((par1==START))
		{
			if (availableMissions->getSelectionIndex() >= 0)
			{
				Engine engine;
				int rc_e = engine.initCampaign(getMissionName(), campaign, availableMissions->get());
				if (rc_e == Engine::EE_NO_ERROR)
				{
	    			int rcr = engine.run();
	    			if(rcr == -1)
	    			    endExecute(-1);
				}
				else if(rc_e == -1)
				{
					endExecute(-1);
				}
				availableMissions->clear();
				for(unsigned i=0; i<campaign.getMapCount(); ++i)
				{
					if(campaign.getMap(i).isUnlocked())
						availableMissions->addItem(campaign.getMap(i).getMapName(), campaign.getMap(i).isCompleted());
				}
				campaign.save(true);
			}
		}
	}
	else if((action==TEXT_MODIFIED))
	{
		if(source==playerName)
		{
			campaign.setPlayerName(playerName->getText());
		}
	}
	else if (action == LIST_ELEMENT_SELECTED)
	{
		std::string mapFileName = campaign.getMap(availableMissions->getSelectionIndex()).getMapFileName();
		mapPreview->setMapThumbnail(mapFileName.c_str());
		description->setText(Toolkit::getStringTable()->getString(campaign.getMap(availableMissions->getSelectionIndex()).getDescription()));
	}
}
Example #5
0
int SSIEngine::resumeExecute(HttpSession *pSession)
{
    SSIRuntime *pRuntime = pSession->getReq()->getSSIRuntime();
    int ret = 0;
    if (!pRuntime)
        return LS_FAIL;
    SSIComponent *pComponent;
    while (!pRuntime->done())
    {
        SSIScript *pScript = pRuntime->getCurrentScript();
        pRuntime->clearFlag();
        pComponent = pScript->nextComponent();
        if (!pComponent)
        {
            pRuntime->pop();
            if (!pRuntime->done())
                pSession->getReq()->restorePathInfo();
            continue;
        }
        ret = executeComponent(pSession, pComponent);
        if (ret == -2)
            return 0;
    }
    endExecute(pSession);
    return pSession->endResponse(1);

}
Example #6
0
void CampaignMapEntryEditor::onAction(Widget *source, Action action, int par1, int par2)
{
	if ((action == BUTTON_RELEASED) || (action == BUTTON_SHORTCUT))
	{
		if (source == ok)
		{
			///If the maps name was changes, make sure to change it in all of the other map entries
			for(unsigned i=0; i<campaign.getMapCount(); ++i)
			{
				std::vector<std::string>::iterator iter=std::find(campaign.getMap(i).getUnlockedByMaps().begin(), campaign.getMap(i).getUnlockedByMaps().end(), entry.getMapName());
				if(iter!=campaign.getMap(i).getUnlockedByMaps().end())
				{
					(*iter)=nameEditor->getText();
				}
			}
			entry.setMapName(nameEditor->getText());
			entry.setDescription(descriptionEditor->getText());
			entry.getUnlockedByMaps().clear();
			for(unsigned i=0; i<mapsUnlockedBy->getCount(); ++i)
			{
				if(mapsUnlockedBy->isChecked(i))
				{
					entry.getUnlockedByMaps().push_back(mapsUnlockedBy->getText(i));
				}
			}
			
			if(!isUnlocked->getState())
				entry.lockMap();
			else
				entry.unlockMap();
			endExecute(OK);
		}
		else if (source == cancel)
		{
			endExecute(CANCEL);
		}
	}
	else if(action == TEXT_ACTIVATED)
	{
		if(source == nameEditor)
			descriptionEditor->deactivate();
		else if(source == descriptionEditor)
			nameEditor->deactivate();
	}
}
void AIDescriptionScreen::onAction(Widget *source, Action action, int par1, int par2)
{
	if ((action == BUTTON_RELEASED) || (action == BUTTON_SHORTCUT))
	{
		if(par1 == OK)
		{
			endExecute(OK);
		}
	}
	if (action == LIST_ELEMENT_SELECTED)
	{
		if(ailist->getSelectionIndex() != -1)
		{
			description->setText(AINames::getAIDescription(ailist->getSelectionIndex()).c_str());
		}
	}
}
Example #8
0
void CampaignEditor::onAction(Widget *source, Action action, int par1, int par2)
{
	if ((action == BUTTON_RELEASED) || (action == BUTTON_SHORTCUT))
	{
		if (source == ok)
		{
			campaign.save();
			endExecute(OK);
		}
		else if (source == cancel)
		{
			endExecute(CANCEL);
		}
		else if (source == addMap)
		{
			ChooseMapScreen cms("campaigns", "map", false);
			int rcms=cms.execute(gfx, 40);
			if(rcms==ChooseMapScreen::OK)
			{
				MapHeader& mapHeader = cms.getMapHeader();
				CampaignMapEntry cme(mapHeader.getMapName(), glob2NameToFilename("campaigns", mapHeader.getMapName(), "map"));
				CampaignMapEntryEditor cmee(campaign, cme);
				int rcmee = cmee.execute(gfx, 40);
				if(rcmee==CampaignMapEntryEditor::OK)
				{
					campaign.appendMap(cme);
					mapList->addText(mapHeader.getMapName());
				}
				else if(rcmee==CampaignMapEntryEditor::CANCEL)
				{

				}
				else if(rcmee == -1)
				{
					endExecute(-1);
				}
			}
			else if(rcms==ChooseMapScreen::CANCEL)
			{
			}
			else if(rcms==-1)
			{
				endExecute(-1);
			}
		}
		else if (source == editMap)
		{
			for(unsigned i=0; i<campaign.getMapCount(); ++i)
			{
				if(mapList->getSelectionIndex()!=-1 && campaign.getMap(i).getMapName()==mapList->get())
				{
					CampaignMapEntryEditor cmee(campaign, campaign.getMap(i));
					int rcmee = cmee.execute(gfx, 40);
					if(rcmee==CampaignMapEntryEditor::OK)
					{
						mapList->setText(mapList->getSelectionIndex(), campaign.getMap(i).getMapName());
					}
					else if(rcmee==CampaignMapEntryEditor::CANCEL)
					{
					}
				}
			}
		}
		else if (source == removeMap)
		{
			if(mapList->getSelectionIndex()!=-1)
			{
				for(unsigned i=0; i<campaign.getMapCount(); ++i)
				{
					std::vector<std::string>::iterator iter=std::find(campaign.getMap(i).getUnlockedByMaps().begin(), campaign.getMap(i).getUnlockedByMaps().end(), mapList->get());
					if(iter!=campaign.getMap(i).getUnlockedByMaps().end())
					{
						campaign.getMap(i).getUnlockedByMaps().erase(iter);
					}
				}
				campaign.removeMap(mapList->getSelectionIndex());
				mapList->removeText(mapList->getSelectionIndex());
			}
		}
	}
	else if (action == TEXT_MODIFIED)
	{
		if(source==nameEditor)
		{
			campaign.setName(nameEditor->getText());
		}
		if(source==description)
		{
			campaign.setDescription(description->getText());
		}
	}
}