/// @file CommandOper.cpp
#include "GameCore.h"
/**
	@brief 스크립트 명령처리를 위한 함수셋

	스크립트의 명령을 처리할 수 있는 함수들입니다.\n
	map형태의 자료구조에 함수포인터 형태로 담겨있으며 GameCore 생성자에서 등록됩니다.
*/
void GameCore::operShow_(TiXmlElement* _pCommandElement){
	int robject;
	if(_pCommandElement->Attribute("robject", &robject)){
		(*pCurrentRObjectPocket_)[robject]->bShow = true;
	}else{
		MessageBox(NULL, "Error in XML (command show)", "Error Message", MB_OK | MB_ICONERROR);
		exit(1);
	}
}

void GameCore::operRotate_(TiXmlElement* _pCommandElement){
	int robject;
	if(_pCommandElement->Attribute("robject", &robject)){
		Indicator* pIndicator = (Indicator*)(*pCurrentRObjectPocket_)[robject];
		pIndicator->bRotation = true;
	}else{
		MessageBox(NULL, "Error in XML (command show)", "Error Message", MB_OK | MB_ICONERROR);
		exit(1);
	}
}

void GameCore::operPrint_(TiXmlElement* _pCommandElement){
	int robject;
	string strContent;
	const char* pStr;
	TiXmlElement* pPrintElement;
	if(_pCommandElement->Attribute("robject", &robject)){
		PrintBoard* pPrintBoard = (PrintBoard*)(*pCurrentRObjectPocket_)[robject];
		pPrintElement = _pCommandElement->FirstChildElement("print");
		int line = 1;
		while(pPrintElement){
			if(pStr = pPrintElement->GetText()){
				strContent = pStr;
			}else{
				strContent = "";
			}
			pPrintBoard->aStringPocket.push_back(strContent);
			if(pPrintElement->FirstChildElement("wait")){
				pPrintBoard->aWaitPoint.push_back(line);
				pPrintBoard->setWait();
				aControlTable_.controlType = PROCESS;
			}
			pPrintElement = pPrintElement->NextSiblingElement("print");
			line++;
		}
		pPrintBoard->aWaitPoint.push_back(line);
	}else{
		MessageBox(NULL, "Error in XML (command print)", "Error Message", MB_OK | MB_ICONERROR);
		exit(1);
	}
}