Пример #1
0
	int GameLoop::loadStates(LoadXML* loader)
	{
		int status = -1;
		if(loader != NULL &&
		   loader->getDocument() != NULL)
		{
			XMLCh nodeName[100];
			XMLString::copyString(nodeName, newString("state").c_str());
			DOMNodeList* nodeList = loader->getDocument()->getElementsByTagName(nodeName);
			if(nodeList != NULL &&
				nodeList->getLength() > 0)
			{
				for(int i = 0; i < nodeList->getLength(); i++)
				{
					String type = loader->getTagContent(newString("type"), (DOMElement*)nodeList->item(i));
					String name = loader->getTagContent(newString("name"), (DOMElement*)nodeList->item(i));
					BaseState* state = this->newState(name, type);
					String camera = loader->getTagContent(newString("camera"), (DOMElement*)nodeList->item(i));
					String resources = loader->getTagContent(newString("resources"), (DOMElement*)nodeList->item(i));
					if(state != NULL)
					{
						state->setName(name);
						state->setResourceXML(resources);
						state->setCamera(camera);
					}
				}
			}
		}
		return status;
	}
Пример #2
0
BaseState* StateMachine::PopState()
{
	BaseState* lastState = stateStack.back();
	stateStack.pop_back();
	lastState->Destroy();
	return lastState;
}
void StateManager::CreateState(const StateType& l_type){
	auto newState = m_stateFactory.find(l_type);
	if (newState == m_stateFactory.end()){ return; }
	BaseState* state = newState->second();
	state->m_view = m_shared->m_wind->GetRenderWindow()->getDefaultView();
	m_states.emplace_back(l_type, state);
	state->OnCreate();
}
Пример #4
0
BaseState * StateWidget::getState()
{
    BaseState * toInsertState = StateWidgets[tmpWidget]->getStateObject();
    if(toInsertState==NULL)return NULL;
    toInsertState->setName(this->stateNameEdit->text());
    int chosen = getStateTypeTable().indexOf(stateTypeCombo->currentText());
    toInsertState->setType((StateType)chosen);
    toInsertState->setParameters(paramEdit->text());
    return toInsertState;
}
Пример #5
0
BaseState* StateMachine::SwitchState(BaseState* a_gameState)
{
	BaseState* lastState = stateStack.back();
	lastState->Destroy();

	stateStack.pop_back();
	stateStack.push_back(a_gameState);
	a_gameState->Initialize();

	return lastState;
}
Пример #6
0
void StateManager::createState(const StateType& type)
{
	auto newState = m_stateFactory.find(type);
	if (newState == m_stateFactory.end()) { return; }

	BaseState* state = newState->second();
	state->m_view = m_context->window->getRenderWindow().getView();
	
	m_states.emplace_back(type, state);
	state->onCreate();
}
Пример #7
0
void StateWidget::AcceptState()
{
    if(edited==NULL)
    {
        emit reportError(QString("Please, select a state to edit, edit it and then press OK."));
        return;
    }
    if ( !StateNameOK())
    {
        return;
    }
    BaseState * toInsertState = StateWidgets[tmpWidget]->getStateObject();
    if(toInsertState==NULL)
        return;
    toInsertState->setName(this->stateNameEdit->text());
    toInsertState->setType(StateType(stateTypeCombo->currentIndex()));
    toInsertState->setParameters(paramEdit->text());
    OKButton->setDisabled(true);
    BaseState * tmp = edited;
    edited = NULL;
    emit ReplaceState(tmp, toInsertState);
}
Пример #8
0
	// вытаскивание состояния из стека
	BaseState* StateManager::Pop(){
		BaseState* st = states.top();
		st->Stop();
		states.pop();
		return st;
	};