コード例 #1
0
// This method is called before first OnUpdate
int32 BSWeaponTimerBomb::OnStart(void)
{
	BSWeapon::OnStart();

	if(m_pWeaponGameObject)
	{
		// Get child explosion sprite game object
		m_pSpriteExplosion = GetGameObject()->FindChild<GameObjectSprite>(CTEXT("explosion"));
		if(NULL == m_pSpriteExplosion)
			GTLogManager::Inst()->LogError(CTEXT("BSWeaponTimerBomb::OnStart: Failed to find explosion sprite game object !"));
		else
		{
			ResetExplosion();			
			m_pSpriteExplosion->SetVisible(false, true);			
			//m_pWeaponParentGameObject->PlayAnimationByIndex(0, GSpriteAnimation::PlayMode_Loop);
		}
	}

	/*
	const int16 nDirection = GetPropertyDefaultDirection();
	if(nDirection == 0)
		m_pGameObjectSprite->PlayAnimationByName(BSCharacter::AnimationName_MoveRight, GSpriteAnimation::PlayMode_Loop);
	else if(nDirection == 1)
		m_pGameObjectSprite->PlayAnimationByName(BSCharacter::AnimationName_MoveLeft, GSpriteAnimation::PlayMode_Loop);
	else
		m_pGameObjectSprite->PlayAnimationByIndex(0, GSpriteAnimation::PlayMode_Loop);
		*/
	
	return 1;
}
コード例 #2
0
int CMessageEditorDlg::find_event()
{
	char *str;
	int i, formula, node;
	CComboBox *box;

	for (i=0; i<Num_mission_events; i++) {
		node = Mission_events[i].formula;
		if (find_operator(CTEXT(node)) == OP_WHEN) {
			node = CDR(node);
			formula = CAR(node);  // bool conditional
			if (CDR(CDR(node)) == -1) {  // only 1 action
				node = CADR(node);
				if ((find_operator(CTEXT(node)) == OP_SEND_MESSAGE) && !stricmp(CTEXT(CDR(CDR(CDR(node)))), m_message_name)) {
					box = (CComboBox *) GetDlgItem(IDC_SENDER);
					str = CTEXT(CDR(node));
					m_sender = box->FindStringExact(-1, str);
					if (m_sender == CB_ERR)
						m_sender = 0;

					box = (CComboBox *) GetDlgItem(IDC_PRIORITY);
					str = CTEXT(CDR(CDR(node)));
					m_priority = box->FindStringExact(-1, str);
					if (m_priority == CB_ERR)
						m_priority = 0;

					return i;
				}
			}
		}
	}

	m_sender = m_priority = 0;
	return -1;
}
コード例 #3
0
// This method is called before first OnUpdate
int32 BSWinlineLoader::OnStart(void)
{
	GTBehaviour::OnStart();
	
	bool res = false;
	GTString errorCode("");

	GTString winlineSpriteKey = PROPERTY_TAG_WINLINE_SPRITE_KEY;
	GTGameObject * childGO = m_pGameObject->FindChild(winlineSpriteKey.ToCharString(), true);
	if(childGO != NULL)
	{	
		m_winlineSprite = (BSSprite*)(childGO->GetBehaviour(CTEXT("BSSprite")));
		if(m_winlineSprite == NULL)
		{
			res = false;
			errorCode = winlineSpriteKey;
		}
		else
			res = true;
	}

	if(!res)
		GTLogManager::SLogFormatError(CTEXT("Error!!! BSWinlineLoader can not find BSSprite: %s "), errorCode.ToCharString());

	m_winlineSprite->SetZOrder(UI_ZOrder::WINLINE);
	return 1;
}
コード例 #4
0
void TestStringUtil()
{
	/*
	GTString sint16 = GTString::ToString((int16)1);
	GTString suint16 = GTString::ToString((uint16)2);
	GTString sint32 = GTString::ToString((int32)2111);
	GTString suint32 = GTString::ToString((uint32)2333);
	GTString sfloat = GTString::ToString((float)78.12f);
	*/

	/*
	GTString source = CTEXT("   123abc") + GTString(CTEXT('\r'));
	GTString source2 = CTEXT("123abc");
	GTString right = source.TrimRight();
	GTString left = source2.TrimLeft();
	GTString both = source.TrimRight().TrimLeft();
	*/

	/*
	// Doulbe slashes
	GTString source1 = CTEXT("  // This is a comment 1");
	GTString source2 = CTEXT(" Value = 10  // This is a comment 2");
	GTString source3 = CTEXT("// This is a comment 1");
	GTString result1 = GTStringUtil::StripDoubleSlashComments(source1);
	GTString result2 = GTStringUtil::StripDoubleSlashComments(source2);
	GTString result3 = GTStringUtil::StripDoubleSlashComments(source3);
	int32 length3 = result3.Length();
	*/

	// Block comments
	//GTString source1 = CTEXT("  /* This is a comment 1 */");
	//GTString source2 = CTEXT(" Value = 10  /* This is a comment 2 */");
	//GTString source3 = CTEXT("/* This is a comment 1 */");
	//GTString result1 = GTStringUtil::StripBlockComments(source1);
	//GTString result2 = GTStringUtil::StripBlockComments(source2);
	//GTString result3 = GTStringUtil::StripBlockComments(source3);

	/*
	GTString source1 = CTEXT("123=abc==xyz");
	GTArray<GTString> result1;
	GTStringUtil::Split(source1, CTEXT('='), result1, GTStringUtil::RemoveEmptyEntries);
	*/

	/*
	GTString test = CTEXT("ABC123xyZ");
	test.ToLower();
	test.ToUpper();
	*/

	GTString src1 = GTString(CTEXT("1,2,4,0,10"));
	GTString src2 = GTString(CTEXT("1, 2,4 ,0, 10"));
	GTArray<int32> gtai1;
	GTUtil::StringToArrayInt(gtai1, src1);
	GTArray<int32> gtai2;
	GTUtil::StringToArrayInt(gtai2, src2);

	GTString sFormatFloat = GTString::Format(CTEXT("Vector2=(%f,%f)"), 2.4f, 67.89f);
	GTString sFormatInt = GTString::Format(CTEXT("Vector2=(%d,%d)"), 24, 6789);
}
コード例 #5
0
// Load all config files
bool ConfigManager::Load(void)
{
	// Load config\GameObjectConfig.property
	m_pGameObjectConfig = Load(CTEXT("config/GameObjectConfig.property"));
	// Load
	m_pGlobalConfig = Load(CTEXT("config/GlobalConfig.property"));

	return true;
}
コード例 #6
0
// When the object is initialized, this method is called.
int32 WeaponCacheManager::OnInitialize(void)
{
	// Load weapon list from property file
	GTTreeNode *pTreeNode = GTPropertyFile::Load(CTEXT("game/weapon-list.property"));
	if(pTreeNode)
	{
		const int32 nChildCount = pTreeNode->GetChildCount();
		if(nChildCount)
		{
			m_pWeaponItemList = new WeaponItemProperty[nChildCount];
			if(m_pWeaponItemList)
			{
				for(int32 i=0; i<nChildCount; i++)
				{
					GTTreeNode *pChildNode = pTreeNode->GetChild(i);
					if(pChildNode)
					{
						// Weapon item id
						m_pWeaponItemList[i].nItemId = pChildNode->GetTag().ToInt();
						// Weapon item property url
						m_pWeaponItemList[i].sUrl = pChildNode->GetValue();

						// Add this weapon item to the dictionary
						m_DicItemList.Add(m_pWeaponItemList[i].nItemId, &m_pWeaponItemList[i]);
					}
				}
			}
		}
	}
	else
	{
		GTLogManager::SLogError(CTEXT("WeaponCacheManager::OnInitialize: Failed to load (game/weapon-list.property) !"));
	}

	// Release
	if(pTreeNode)
	{
		pTreeNode->Release();
		pTreeNode = NULL;
	}

	// Clean m_WeaponFiredList
	WeaponItemSlot wis;
	wis.nItemId = -1;
	wis.pGameObject = NULL;
	wis.lTimeElapsed = 0;
	for(int32 i=0; i<WeaponCacheManager::m_nWeaponFiredListCount; i++)
	{
		wis.nSlotId = i;
		m_WeaponFiredList.Add(wis);
	}

	return 1;
}
コード例 #7
0
void GTLogTextFile::LogOutout(const tchar* szMes, const tchar* szType)
{
	if(szMes && szType)
	{
		FILE* fp = tfopen(GTLogTextFile::g_szLogFileName, CTEXT("a+"));
		if(fp)
		{
			tfprintf(fp, CTEXT("[%s]: %s\n"), szType, szMes);
			tfclose(fp);
			fp = NULL;
		}
	}
}
コード例 #8
0
// Override this method to serialize specific properties
bool UIAnimation::OnSerializeFrom(GTTreeNode* pTreeNode)
{
	if(NULL == pTreeNode)
		return false;

	UIWidgetSprite::OnSerializeFrom(pTreeNode);
	
	// Read sprite node
	GTTreeNode* pSpriteNode = pTreeNode->FindChild(GTPropertyFile::TagSprite);
	// Read animation nodes
	GTTreeNode* pDefaultAnimationNode = pTreeNode->FindChild(GTPropertyFile::TagDefaultAnimation);
	GTTreeNode* pDefaultAnimationNodePlayMode = pTreeNode->FindChild(GTPropertyFile::TagDefaultAnimationPlayMode);
		
	// Create sprite object
	if(NULL == pSpriteNode)
		return false;
	m_pSprite = GameObjectCreation::CreateAnimatedSprite(
		pSpriteNode->GetValue().ToCharString(), // sprite file name
		GetParent()->GetZOrder() // User parent's z-order
		);
	if(NULL == m_pSprite)
		return false;
	
	// Setup position
	m_pSprite->SetPosition(UIWidget::GetPosition());
	// Setup ZOrder
	m_pSprite->SetZOrder(UIWidget::GetZOrder());
	// Setup Visible
	m_pSprite->SetVisible(UIWidget::GetVisible());

	// Setup animation to see if this sprite has animations
	int32 nPlayMode = GSpriteAnimation::PlayMode_Once;	
	if(pDefaultAnimationNodePlayMode)
	{
		if(pDefaultAnimationNodePlayMode->GetValue() == CTEXT("None"))
			nPlayMode = GSpriteAnimation::PlayMode_None;
		else if(pDefaultAnimationNodePlayMode->GetValue() == CTEXT("Loop"))
			nPlayMode = GSpriteAnimation::PlayMode_Loop;
		else if(pDefaultAnimationNodePlayMode->GetValue() == CTEXT("Once"))
			nPlayMode = GSpriteAnimation::PlayMode_Once;
	}
	if(pDefaultAnimationNode)
	{
		// NOTE: I think playing animation might be in OnStart
		m_pSprite->PlayAnimationByIndex(pDefaultAnimationNode->GetValue().ToInt(), nPlayMode);
		//m_pSprite->StopAnimation();
	}

	return true;
}
コード例 #9
0
// Create a game object from specified .property path
GTGameObject* AssetManager::CreateGameObject(const tchar *szPropPath, const tchar *szName, GTGameObject *pParent)
{
	if(NULL == szPropPath)
		return NULL;

	GTGameObject *pGameObjectNew = NULL;
	// Check if the game object is cached
	AssetItem assetItem;
	if(m_AssetCachedList.GetValueByKey(std::string(szPropPath), assetItem))
	{
		// The game object is already cached so clone a new game object
		pGameObjectNew = assetItem.pGameObject->Clone(szName, pParent);
	}
	else
	{
		// Not cached yet. Load the game object first and cache it.
		GTGameObject* pGameObjectCached = GTGameObjectManager::Inst()->CreateGameObject(pParent, szName, szPropPath);
		if(NULL == pGameObjectCached)
		{
			GTLogManager::SLogFormatError(CTEXT("AssetManager::CreateGameObject: Failed to create game object (%s) !"), szPropPath);
			return NULL;
		}
		// Because this game object is cached, detache this game object from its parent.
		// Otherwise it will be released automatically by game object manager when the game exits.
		if(pGameObjectCached->GetParent())
		{
			pGameObjectCached->GetParent()->RemoveChild(pGameObjectCached);
			pGameObjectCached->SetParent(NULL);
		}
		// Setup name
		pGameObjectCached->SetName(GTString::Format(CTEXT("%s-cached"), szName));
		// Set a position that is not in visible screen
		pGameObjectCached->SetPosition(-10000.0f, -10000.0f);
		// Disable this cached game object
		pGameObjectCached->SetEnable(false);
		pGameObjectCached->SetVisible(false, true);
		pGameObjectCached->SetZOrder(GameGeneral::Inst()->GetZOrderCacheObject());
		// Add it to cache list
		AssetItem ai;
		ai.sUrl = szPropPath;
		ai.pGameObject = pGameObjectCached;
		m_AssetCachedList.Add(ai.sUrl, ai);
		// Clone
		pGameObjectNew = pGameObjectCached->Clone(szName, pParent);
	}
	
	return pGameObjectNew;
}
コード例 #10
0
// Register an event
bool InputManager::RegisterEvent(
	const EventType eventType,
	const tchar* szName,
	const InputEventDelegate pCallback,
	void* pParam
	)
{
	if(eventType >= EventType_Count || NULL == szName || NULL == pCallback)
	{
		return false;
	}
	if(0 == StringLength(szName))
	{
		return false;
	}

	// Get the event list according to event type
	GTEventContainer *pEventList = GetEventList(eventType);
	if(NULL == pEventList)
	{
		return false;
	}
	// Create a new EventContainer object
	EventContainer* pEventContainer = new EventContainer(pCallback, pParam);
	if(NULL == pEventContainer)
	{
		GTLogManager::GetInstance()->LogFormatError(CTEXT("Failed to new EventContainer object with the name = %s"), szName);
		return false;
	}
	// Add this event into the event list
	pEventList->AddToTail(pEventContainer);

	return true;
}
コード例 #11
0
void ResourceManager::OnDestroy(void)
{
	GTLogManager::SLogTrace(CTEXT("ResourceManager----------------"));
	GTLogManager::SLogFormatTrace(CTEXT("Resource Unfreed Count = %d"), m_ResAnimationList.Count());

	GSpriteAnimationCocos2dx* pAnim = NULL;
	for(GTDictionary<std::string, GSpriteAnimationCocos2dx*>::ObjectTypeIterator it = m_ResAnimationList.Begin();
		it != m_ResAnimationList.End();
		it++)
	{
		pAnim = GTDictionaryGetValue((*it));
		GTLogManager::SLogFormatTrace(CTEXT("Key name = %s"), pAnim->m_strKey.ToCharString());
	}

	GTLogManager::SLogTrace(CTEXT("ResourceManager----------------"));
}
コード例 #12
0
ファイル: UIFont.cpp プロジェクト: BGCX261/zjh-dev-svn-to-git
tchar *_get_line(tchar *file, tchar *line)
{
	int32 i=0;

	if(!file[i]) return 0;

	while(file[i] && file[i]!=CTEXT('\n') && file[i]!=CTEXT('\r'))
	{
		line[i]=file[i];
		i++;
	}
	line[i]=0;

	while(file[i] && (file[i]==CTEXT('\n') || file[i]==CTEXT('\r'))) i++;

	return file + i;
}
コード例 #13
0
void stuff_link_with_formula(int *link_idx, int formula, int mission_num)
{
	int j, node, node2, node3;
	if (formula >= 0) {
		if (!stricmp(CTEXT(formula), "cond")) {
			// sexp is valid

			node = CDR(formula);
			free_one_sexp(formula);
			while (node != -1) {
				node2 = CAR(node);
				Links[*link_idx].from = mission_num;
				Links[*link_idx].sexp = CAR(node2);
				Links[*link_idx].mission_loop_txt = NULL;
				Links[*link_idx].mission_loop_brief_anim = NULL;
				Links[*link_idx].mission_loop_brief_sound = NULL;
				sexp_mark_persistent(CAR(node2));
				free_one_sexp(node2);
				node3 = CADR(node2);
				if ( !stricmp( CTEXT(node3), "next-mission") ) {
					node3 = CDR(node3);
					for (j=0; j<Campaign.num_missions; j++)
						if (!stricmp(CTEXT(node3), Campaign.missions[j].name))
							break;

					if (j < Campaign.num_missions) {  // mission is in campaign (you never know..)
						Links[(*link_idx)++].to = j;
						Elements[mission_num].from_links++;
						Elements[j].to_links++;
					}

				} else if ( !stricmp( CTEXT(node3), "end-of-campaign") ) {
					Links[(*link_idx)++].to = -1;
					Elements[mission_num].from_links++;

				} else
					Int3();			// bogus operator in campaign file

				free_sexp(CDR(node2));
				free_one_sexp(node);
				node = CDR(node);
			}
		}
	}
}
コード例 #14
0
// Initialize Log object
void GTLogTextFile::Initialize(void)
{
	FILE* fp = tfopen(GTLogTextFile::g_szLogFileName, CTEXT("w"));
	if(fp)
	{
		OutTimestamp(fp);
		fprintf(fp, "\n");
		tfclose(fp);
		fp = NULL;
	}
}
コード例 #15
0
// Override this method to serialize specific properties
bool UILabelSmoothChange::OnSerializeFrom(GTTreeNode* pTreeNode)
{
	UILabel::OnSerializeFrom(pTreeNode);

	if(NULL == pTreeNode)
	{
		return true;
	}

	GTTreeNode* pCustomizedValueNode = pTreeNode->FindChild(GTPropertyFile::TagCustomizedValue);
	if(pCustomizedValueNode)
	{
		const int32 nChildCount = pCustomizedValueNode->GetChildCount();
		for(int32 i=0; i<nChildCount; i++)
		{
			GTTreeNode* pChildNode = pCustomizedValueNode->GetChild(i);
			if(pChildNode)
			{
				if(pChildNode->GetTag() == GTPropertyFile::TagPairValue)
				{
					GTPairValue pv = pChildNode->ValueToPairValue();
					if(pv.m_sName == CTEXT("MinValue"))				
						SetPropertyMinValue(pv.m_sValue.ToInt());
					else if(pv.m_sName == CTEXT("MaxValue"))
						SetPropertyMaxValue(pv.m_sValue.ToInt());
					else if(pv.m_sName == CTEXT("Interval"))
						SetPropertyTimerInterval(pv.m_sValue.ToFloat());
					else if(pv.m_sName == CTEXT("StepValue"))
						SetPropertyStepValue(pv.m_sValue.ToInt());
				}
			}
		}
	}

	return true;
}
コード例 #16
0
void TestFileUtil()
{
	unsigned long size = 0;
	char* pContent = (char*)GTFileUtil::ReadTextFileData(CTEXT("sprites/JiaXuRun.property"), &size);
	if(pContent)
	{
		GTTreeNode* tn = GTTreeNode::FromString(pContent);
		if(tn)
		{
			tn->Release();
		}

		delete[] pContent;
		pContent = NULL;
	}
}
コード例 #17
0
// Create a weapon game object from item id defined in staticWeaponItemList
// If the weapon game object specified by nItemId is not loaded yet, load it from file. Then clone and return it.
// If the weapon game object is already loaded, clone and return it.
GameObjectSprite* WeaponCacheManager::CreateWeaponGameObject(const int32 nItemId)
{
	// Check if the item id is available in existing list
	WeaponItemProperty *pWIP = NULL;
	if(false == m_DicItemList.GetValueByKey(nItemId, pWIP))
		return NULL; // Key not found

	WeaponItemSlot *pWIS = FindAvailableSlot(nItemId);
	if(NULL == pWIS)
	{
		GTLogManager::Inst()->LogFormatError(CTEXT("WeaponCacheManager::CreateWeaponGameObject: Failed to find available slot (item id = %d)"), nItemId);
		return NULL;
	}
	
	return pWIS->pGameObject;
}
コード例 #18
0
GTTreeNode *ConfigManager::Load(const tchar *szName)
{
	if(NULL == szName)
	{
		return NULL;
	}

	GTTreeNode *pNode = PropertyFile::Load(szName);
	if(NULL == pNode)
	{
		GTLogManager::GetInstance()->LogFormatError(CTEXT("Failed to load '%s'"), szName);
		return NULL;
	}

	return pNode;
}
コード例 #19
0
// OnChangePosition is called when the the object is set with new position.
void GameObjectSprite::OnChangePosition(const GTPoint2 position)
{
	GTGameObject::OnChangePosition(position);

	if(GTString::IsEqual(m_strName.ToCharString(), CTEXT("explosion")))
	{
		int32 k = 0;
	}
	if(m_pSprite)
	{
		// If the object has parent, apply Parent position + position.
		const GTVector2 posParent = m_pParent ? m_pParent->GetPosition() : GTVector2::Zero;
		const GTVector2 posObject = GetPosition();
		m_pSprite->SetPosition(posParent + posObject);
		//m_pSprite->SetPosition(m_pParent ? (m_pParent->GetPosition() + position) : position);
	}
}
コード例 #20
0
// This method is called when GTBehaviour object is initialized.
int32 UIBSLabelSmoothValueChange::OnInitialize(GTBehaviourInit* param)
{
	GTBehaviour::OnInitialize(param);

	if(param->pParam2)
	{
		GTTreeNode* pParam = (GTTreeNode*)(param->pParam2);
		const int32 nChildCount = pParam->GetChildCount();
		for(int32 i=0; i<nChildCount; i++)
		{
			GTTreeNode* pChildNode = pParam->GetChild(i);
			if(pChildNode->GetTag() == CTEXT("Interval"))
				m_fTimerInterval = pChildNode->GetValue().ToFloat();
		}
	}	
	
	return 1;
}
コード例 #21
0
// This method is called before first OnUpdate
int32 BSSlotsContainer::OnStart(void)
{
	GTBehaviour::OnStart();
	
	bool res = false;
	GTString errorCode("");

	for(int id = 0; id < m_reelColumnCount; id++)
	{
		GTString reelColumName = PROPERTY_TAG_REELCOLUMN_KEY;
		reelColumName.Append(GTString::From(id));// + GTString::FormatFrom(id);
		//reelColumName += GTString::FormatFrom(id);

		GTGameObject * childGO = m_pGameObject->FindChild(reelColumName.ToCharString(), true);
		if(childGO != NULL)
		{			
			BSReelColumn* reelColum = dynamic_cast<BSReelColumn* >(childGO->GetComponent("BSReelColumn"));
			if(reelColum)
			{
				res = true;
				m_reelColumns.AddToTail(reelColum);
				//m_reelColumnsStatus.AddToTail(reelColum->GetStatus());
			}
			else
			{
				res = false;
				errorCode = reelColumName;
				break;
			}
		}		
		else
		{
			res = false;
			errorCode = reelColumName;
			break;
		}
	}

	if(!res)
		GTLogManager::SLogFormatError(CTEXT("Error!!! BSSlotsContainer can not find BSReelColumn: %s "), errorCode.ToCharString());
	
	return 1;
}
コード例 #22
0
int32 SceneGameObjectManager::OnInitialize()
{
	GTTreeNode* pGlobalConfig = ConfigManager::GetInstance()->GetGlobalConfig();
	if(pGlobalConfig)
	{
		GTTreeNode* pRootNode = pGlobalConfig->FindChild(CTEXT("SceneGameObjectTree"));
		if(pRootNode)
		{
			// Setup root game object
			m_pRootGameObject = new GTGameObject(NULL);
			if(m_pRootGameObject)
			{
				m_pRootGameObject->OnInitialize();
				// Setup the name
				m_pRootGameObject->SetName(pRootNode->Value().ToCharString());
				// Setup the parent
				m_pRootGameObject->SetParent(NULL);
				// Initialize behaviour classes
				GTTreeNode *pBehaviour = pRootNode->GetChild(PropertyFile::TagBehaviour);
				if(pBehaviour)
				{
					PropertyFile::ApplyBehaviourForGameObject(pBehaviour, m_pRootGameObject, NULL);
				}

				// Initialize the children
				const int32 nChildCount = pRootNode->GetChildCount();
				for(int32 i=0; i<nChildCount; i++)
				{
					GTTreeNode *pChild = pRootNode->GetChild(i);
					if(pChild->GetTag() == PropertyFile::TagBehaviour)
					{
						// Skip behaviour section
						continue;
					}
					InitializeTree(pChild, m_pRootGameObject);
				}
			}
			DBG_ASSERT(m_pRootGameObject);
		}
	}

	return 1;
}
コード例 #23
0
// Before the system is shut down, this method is called.
int32 AssetManager::OnDestroy(void)
{
	// Release all cached game objects
	for(GTDictionary<std::string, AssetItem>::ObjectTypeIterator it = m_AssetCachedList.Begin();
		it != m_AssetCachedList.End();
		it++)
	{
		if(it->second.pGameObject)
		{
			it->second.pGameObject->Release();
			it->second.pGameObject = NULL;
			it->second.sUrl = CTEXT("");
		}
	}
	// Clear the dictionary
	m_AssetCachedList.Clear();

	return 1;
}
コード例 #24
0
int32 GOS::GetFileSize(const tchar* szFileName)
{
	if(NULL == szFileName)
	{
		return -1;
	}

	FILE* fp = tfopen(szFileName, CTEXT("rb"));
	if(NULL == fp)
	{
		// The file doesn't exist.
		return -2;
	}
	// Set fp to the end of the file
	tfseek(fp, 0, SEEK_END);
	// Get the current fp position to get the size
	const int32 nFileSize = tftell(fp);
	// Close the file
	tfclose(fp);
	fp = NULL;

	return nFileSize;
}
コード例 #25
0
// Apply all behaviour scripts under TagBehaviour to a game object
bool GTPropertyFile::ApplyBehaviourForGameObject(
	 GTTreeNode *pBehaviourNode,
	 GTGameObject *pGameObject,
	 void* param
	)
{
	if(NULL == pBehaviourNode || NULL == pGameObject)
	{
		return false;
	}

	GTBehaviourInit initParam;
	// Get the count of behaviour scripts attached to this object
	const int32 nNodeCount = pBehaviourNode->GetChildCount();
	for(int count=0; count<nNodeCount; count++)
	{
		// Get a node of behaviour script
		GTTreeNode* pChild = pBehaviourNode->GetChild(count);
		if(pChild)
		{
			if(pChild->Tag() == GTPropertyFile::TagScript)
			{
				// Prepare the paramters for behaviour initialization
				initParam.pParam1 = param;
				initParam.pParam2 = pChild;

				GTBehaviour *pBehaviour = pGameObject->AddComponent(pChild->GetValue().ToCharString(), &initParam);
				if(NULL == pBehaviour)
				{
					GTLogManager::GetInstance()->LogFormatError(CTEXT("Failed to AddComponent '%s' for the game object '%s'"), pChild->GetValue().ToCharString(), pGameObject->GetName());
				}
			}
		}
	}

	return true;
}
コード例 #26
0
// Derived widget class must implement this method in order to
// return correct class name
const tchar* UIWidget::GetClassName(void) const
{
	return CTEXT("NoClassName");
}
コード例 #27
0
void UIWidget::SetTextFromFloat(const float fValue)
{
	tsprintf(g_szUIWidgetTempBuffer, CTEXT("%f"), fValue);
	SetText(g_szUIWidgetTempBuffer);
}
コード例 #28
0
void UIWidget::SetTextFromUINT32(const uint32 nValue)
{
	tsprintf(g_szUIWidgetTempBuffer, CTEXT("%u"), nValue);
	SetText(g_szUIWidgetTempBuffer);
}
コード例 #29
0
void UIWidget::SetTextFromINT16(const int16 nValue)
{
	tsprintf(g_szUIWidgetTempBuffer, CTEXT("%d"), nValue);
	SetText(g_szUIWidgetTempBuffer);
}
コード例 #30
0
#include "UIWidget.h"
#include "UIManager.h"
#include <GTPropertyFile.h>
#include "Sprite/GSprite.h"
#include <GameObjectCreation.h>
#include "UILabelBMFont.h"
#include "UIWidgetScript.h"

#ifdef GT_DEBUG
#include <GTNew.h>
#endif // GT_DEBUG

const tchar* UIWidget::m_szEventTypeNone = CTEXT("None");
const tchar* UIWidget::m_szEventTypeChildren = CTEXT("Children");
const tchar* UIWidget::m_szEventTypeAll = CTEXT("All");
// Global working variable for UIWidget
tchar g_szUIWidgetTempBuffer[32];

// Get event id from the string
int32 UIWidget::GetEventTypeIdFromString(const tchar* szTypeString)
{
	if(NULL == szTypeString)
	{
		return UIWidget::EventType_None;
	}

	if(GTString::IsEqual(szTypeString, UIWidget::m_szEventTypeNone))
	{
		return UIWidget::EventType_None;
	}
	else if(GTString::IsEqual(szTypeString, UIWidget::m_szEventTypeChildren))