Пример #1
0
void TextInputJournal::Init()
{
	//TODO: Turn creation of menus into a template function?

	InterfaceManager* intfc = InterfaceManager::GetSingleton();

	// Is BookMenu already open?
	BookMenu* bookMenu = (BookMenu*)GetMenuByType(kMenuType_Book);
	if (bookMenu)	// open, so get rid of it first
		bookMenu->Destructor(1);

	// create new book menu
	Tile* tile = intfc->menuRoot->ReadXML("data\\menus\\book_menu.xml");
	if (tile)
	{
		Tile* bookRoot = tile->GetRoot();
		if (bookRoot)
		{
			TileMenu* bookMenuTile = tile_cast <TileMenu>(bookRoot);
			if (bookMenuTile)
			{
				BookMenu* bookMenu = (BookMenu*)(bookMenuTile->menu);
				if (bookMenu)
				{
					bookMenu->book = m_dummyBook;
					bookMenu->bookRef = NULL;

					ToggleMenuShortcutKeys(false, bookMenu);

					bookMenu->RegisterTile(bookMenuTile);
					
					// update depth
					Tile* backgroundTile = NULL;
					if (m_dummyBook->IsScroll())
						backgroundTile = bookMenu->tile->GetChildByName("book_background_scroll");
					else
						backgroundTile = bookMenu->tile->GetChildByName("book_background");

					Tile::Value* depthVal = backgroundTile->GetValueByType(kTileValue_depth);
					if (depthVal)
					{
						backgroundTile->UpdateFloat(kTileValue_depth, depthVal->num + intfc->GetDepth());
						depthVal->num += intfc->GetDepth();
					}

					if (!m_dummyBook->IsScroll())
						bookMenu->tile->UpdateFloat(BookMenu::kBookValue_IsBook, 2.0);	
					
					bookMenu->EnableMenu(false);
					bookMenu->UpdateText(m_inputText.c_str());
				}
			}
		}
	}
}
Пример #2
0
Tile::Value * Tile::GetValueByName(char* name)
{
	char* strtokContext = NULL;
	char * childName = strtok_s(name, "\\/", &strtokContext);
	char* nextName = NULL;
	Tile * parentTile = this;

	while (childName && parentTile)
	{
		nextName = strtok_s(NULL, "\\/", &strtokContext);
		if (!nextName)
			break;
	
		parentTile = parentTile->GetChildByName(childName);
		childName = nextName;
	}

	if (childName && !nextName && parentTile)	// childName is now name of value to retrieve
		return parentTile->GetValueByType(StrToStrID(childName));

	return NULL;
}