コード例 #1
0
ファイル: JournalBox.cpp プロジェクト: Rincevent/lbanet
/***********************************************************
handle event when list is selected
***********************************************************/
bool JournalBox::HandleQuestTreeSelected (const CEGUI::EventArgs& e)
{
	CEGUI::Tree * tree = static_cast<CEGUI::Tree *> (
		CEGUI::WindowManager::getSingleton().getWindow("Root/JournalWin/tab/questtab/Tree"));

	const MyTreeItem * it = static_cast<const MyTreeItem *>(tree->getFirstSelectedItem());
	if(it)
		DisplayDescription (it->Description, false);

	return true;
}
コード例 #2
0
void EntityCreatorTypeHelper::buildWidget(CEGUI::Tree& typeTree, CEGUI::PushButton& pushButton, CEGUI::Window& modelPreview)
{

	typeTree.setItemTooltipsEnabled(true);
	typeTree.setSortingEnabled(true);

	typeTree.subscribeEvent(CEGUI::Tree::EventSelectionChanged, CEGUI::Event::Subscriber(&EntityCreatorTypeHelper::typeTree_SelectionChanged, this));
	mCreateButton = &pushButton;
	mCreateButton->subscribeEvent(CEGUI::PushButton::EventClicked, CEGUI::Event::Subscriber(&EntityCreatorTypeHelper::createButton_Click, this));

	mRuleTreeAdapter = new Adapters::Eris::RuleTreeAdapter(mConnection, typeTree);
	mRuleTreeAdapter->refresh("game_entity");

	mModelPreviewRenderer = new ModelRenderer(&modelPreview, "modelPreview");
	mModelPreviewManipulator = new CameraEntityTextureManipulator(modelPreview, mModelPreviewRenderer->getEntityTexture());


	mConnection.getTypeService()->BoundType.connect(sigc::mem_fun(*this, &EntityCreatorTypeHelper::typeService_BoundType));

}
コード例 #3
0
void luaPopulateEntityList(CEGUI::Window* entityListWindow)
{
    CEGUI::Tree* theTree = (CEGUI::Tree*)entityListWindow->getChildRecursive("Editing/EntityList/Tree");
//    theTree->initialise();
    theTree->resetList();

    // Create classes, top-level
    readClasses();

    stringTreeItemMap classTreeItems;

    for (unsigned int i = 0; i < classes.size(); i++)
    {
        std::string name = classes[i];

        CEGUI::TreeItem* item = new CEGUI::TreeItem( name );
        item->setAutoDeleted(true);
        item->setTextColours(CEGUI::colour(0.0, 0.0, 0.0));
        theTree->addItem(item);

        classTreeItems.insert( stringTreeItemMap::value_type(name, item) );
    }

    // Insert entities at second level
    for(LogicSystem::LogicEntityMap::iterator iter = LogicSystem::logicEntities.begin();
        iter != LogicSystem::logicEntities.end();
        iter++)
    {
        int uniqueId = iter->first;
        ScriptValuePtr scriptEntity = iter->second.get()->scriptEntity;
        std::string className = scriptEntity->getPropertyString("_class");

        CEGUI::TreeItem* item = new CEGUI::TreeItem( Utility::toString(uniqueId) );
        item->setAutoDeleted(true);
        item->setTextColours(CEGUI::colour(0.0, 0.0, 0.0));
        classTreeItems[className]->addItem(item);
    }

    // Prune classes with 0 entities
    for (unsigned int i = 0; i < classes.size(); i++)
    {
        CEGUI::TreeItem *item = classTreeItems[classes[i]];
        if (item->getItemCount() == 0)
        {
            theTree->removeItem(item);
            // Note: No need to remove from classTreeItems
        }
    }

    // Create tags

    CEGUI::TreeItem* tagsItem = new CEGUI::TreeItem( "__tags__" );
    tagsItem->setAutoDeleted(true);
    tagsItem->setTextColours(CEGUI::colour(0.0, 0.333, 0.0));
    theTree->addItem(tagsItem);

    stringTreeItemMap tagTreeItems;

    for(LogicSystem::LogicEntityMap::iterator iter = LogicSystem::logicEntities.begin();
        iter != LogicSystem::logicEntities.end();
        iter++)
    {
        int uniqueId = iter->first;
        ScriptValuePtr scriptEntity = iter->second.get()->scriptEntity;
        ScriptValuePtr tags = scriptEntity->getProperty("tags");
        int numTags = tags->getPropertyInt("length");

        // Add item under each of its tags, creating the tag category if necessary
        for (int i = 0; i < numTags; i++)
        {
            std::string currTag = tags->getPropertyString( Utility::toString(i) );

            // Add the tag category if needed
            if (tagTreeItems.find(currTag) == tagTreeItems.end())
            {
                CEGUI::TreeItem* item = new CEGUI::TreeItem( currTag );
                item->setAutoDeleted(true);
                item->setTextColours(CEGUI::colour(0.0, 0.0, 0.0));
                tagsItem->addItem(item);

                tagTreeItems.insert( stringTreeItemMap::value_type(currTag, item) );
            }

            // Add the entity to the tag
            CEGUI::TreeItem* item = new CEGUI::TreeItem( Utility::toString(uniqueId) );
            item->setAutoDeleted(true);
            item->setTextColours(CEGUI::colour(0.0, 0.0, 0.0));
            tagTreeItems[currTag]->addItem(item);
        }
    }
}
コード例 #4
0
ファイル: JournalBox.cpp プロジェクト: Rincevent/lbanet
/***********************************************************
call to regenerate the quest book display
***********************************************************/
void JournalBox::RebuildBook(bool reset)
{
	CEGUI::Tree * tree = static_cast<CEGUI::Tree *> (
		CEGUI::WindowManager::getSingleton().getWindow("Root/JournalWin/tab/questtab/Tree"));

	CEGUI::Tree * tree2 = static_cast<CEGUI::Tree *> (
		CEGUI::WindowManager::getSingleton().getWindow("Root/JournalWin/tab/questdonetab/Tree"));

	if(reset)
	{
		tree->resetList();
		tree2->resetList();
		_mapquestarea.clear();
		_mapquestdonearea.clear();
		CEGUI::WindowManager::getSingleton().getWindow("Root/JournalWin/tab/questtab/Description")->setText("");
		CEGUI::WindowManager::getSingleton().getWindow("Root/JournalWin/tab/questdonetab/Description")->setText("");
		_first_book_init = true;
	}


	// rebuild quests
	{
		// remove extra quests
		std::map<std::string, CEGUI::TreeItem *>::iterator itmap = _mapquestarea.begin();
		while(itmap != _mapquestarea.end())
		{
			bool remove = false;
			std::vector<CEGUI::TreeItem*> items = itmap->second->getItemList();
			for(size_t i=0; i<items.size(); ++i)
			{
				if(_QuestsStarted.find(static_cast<MyTreeItem *> (items[i])->QuestId) == _QuestsStarted.end())
				{	
					itmap->second->removeItem(items[i]);
					if(itmap->second->getItemCount() == 0)
						remove = true;
				}
			}

			if(remove)
			{
				tree->removeItem(itmap->second);
				_mapquestarea.erase(itmap++);
			}
			else
				++itmap;
		}

		// add missing quests
		LbaNet::QuestsMap::const_iterator itstarted = _QuestsStarted.begin();
		LbaNet::QuestsMap::const_iterator endstarted = _QuestsStarted.end();
		for(; itstarted != endstarted; ++itstarted)
		{
			const LbaNet::QuestInfo &qi = itstarted->second;
			if(qi.Visible)
			{
				std::string Tittle = Localizer::getInstance()->GetText(Localizer::Quest, (long)qi.TittleTextId);
				std::string Description = Localizer::getInstance()->GetText(Localizer::Quest, (long)qi.DescriptionTextId);
				std::string QuestArea = Localizer::getInstance()->GetText(Localizer::Quest, (long)qi.QuestAreaTextId);

				if(QuestArea == "")
					QuestArea = "General";

				std::vector<CEGUI::String> listt;
				CreateTextList(Description, listt);



				std::map<std::string, CEGUI::TreeItem *>::iterator itm = _mapquestarea.find(QuestArea);
				if(itm != _mapquestarea.end())
				{
					bool found = false;
					std::vector<CEGUI::TreeItem*> items = itm->second->getItemList();
					for(size_t i=0; i<items.size(); ++i)
					{
						if(static_cast<MyTreeItem *> (items[i])->QuestId == qi.Id)
						{	
							found = true;
							break;
						}
					}

					if(!found)
					{
						MyTreeItem * titm = new MyTreeItem((const unsigned char *)Tittle.c_str(), listt, (long)qi.Id);
						itm->second->addItem(titm);

						if(_first_book_init)
						{
							if(_selected_tree_quests == Tittle)
							{
								titm->setSelected(true);
								DisplayDescription (titm->Description, false);
							}
						}
					}
				}
				else
				{
					MyTreeItem * titm = new MyTreeItem((const unsigned char *)Tittle.c_str(), listt, (long)qi.Id);
					std::vector<CEGUI::String> empty;
					CEGUI::TreeItem * root = new MyTreeItem((const unsigned char *)QuestArea.c_str(), empty);
					tree->addItem(root);
					root->addItem(titm);
					_mapquestarea[QuestArea] = root;

					if(_first_book_init)
					{
						if(_selected_tree_quests == Tittle)
						{
							titm->setSelected(true);
							DisplayDescription (titm->Description, false);
						}
					}
				}
			}
		}
	}


	// rebuild quests done
	{
		// remove extra quests
		std::map<std::string, CEGUI::TreeItem *>::iterator itmap = _mapquestdonearea.begin();
		while(itmap != _mapquestdonearea.end())
		{
			bool remove = false;
			std::vector<CEGUI::TreeItem*> items = itmap->second->getItemList();
			for(size_t i=0; i<items.size(); ++i)
			{
				if(_QuestsFinished.find(static_cast<MyTreeItem *> (items[i])->QuestId) == _QuestsFinished.end())
				{	
					itmap->second->removeItem(items[i]);
					if(itmap->second->getItemCount() == 0)
						remove = true;
				}
			}

			if(remove)
			{
				tree->removeItem(itmap->second);
				_mapquestdonearea.erase(itmap++);
			}
			else
				++itmap;
		}

		// add missing quests
		LbaNet::QuestsMap::const_iterator itfinished = _QuestsFinished.begin();
		LbaNet::QuestsMap::const_iterator endfinished = _QuestsFinished.end();
		for(; itfinished != endfinished; ++itfinished)
		{
			const LbaNet::QuestInfo &qi = itfinished->second;
			if(qi.Visible)
			{
				std::string Tittle = Localizer::getInstance()->GetText(Localizer::Quest, (long)qi.TittleTextId);
				std::string Description = Localizer::getInstance()->GetText(Localizer::Quest, (long)qi.DescriptionTextId);
				std::string QuestArea = Localizer::getInstance()->GetText(Localizer::Quest, (long)qi.QuestAreaTextId);

				if(QuestArea == "")
					QuestArea = Localizer::getInstance()->GetText(Localizer::GUI, 84);

				std::vector<CEGUI::String> listt;
				CreateTextList(Description, listt);



				std::map<std::string, CEGUI::TreeItem *>::iterator itm = _mapquestdonearea.find(QuestArea);
				if(itm != _mapquestdonearea.end())
				{
					bool found = false;
					std::vector<CEGUI::TreeItem*> items = itm->second->getItemList();
					for(size_t i=0; i<items.size(); ++i)
					{
						if(static_cast<MyTreeItem *> (items[i])->QuestId == qi.Id)
						{	
							found = true;
							break;
						}
					}

					if(!found)
					{
						MyTreeItem * titm = new MyTreeItem((const unsigned char *)Tittle.c_str(), listt, (long)qi.Id);
						itm->second->addItem(titm);

						if(_first_book_init)
						{
							if(_selected_tree_done_quests == Tittle)
							{
								titm->setSelected(true);
								DisplayDescription (titm->Description, true);
							}
						}
					}
				}
				else
				{
					MyTreeItem * titm = new MyTreeItem((const unsigned char *)Tittle.c_str(), listt, (long)qi.Id);
					std::vector<CEGUI::String> empty;
					CEGUI::TreeItem * root = new MyTreeItem((const unsigned char *)QuestArea.c_str(), empty);
					tree2->addItem(root);
					root->addItem(titm);
					_mapquestdonearea[QuestArea] = root;

					if(_first_book_init)
					{
						if(_selected_tree_done_quests == Tittle)
						{
							titm->setSelected(true);
							DisplayDescription (titm->Description, true);
						}
					}
				}
			}
		}
	}


	if(!_first_book_init)
	{
		if(tree->getFirstSelectedItem() == NULL)
			CEGUI::WindowManager::getSingleton().getWindow("Root/JournalWin/tab/questtab/Description")->setText("");
		
		if(tree2->getFirstSelectedItem() == NULL)
			CEGUI::WindowManager::getSingleton().getWindow("Root/JournalWin/tab/questdonetab/Description")->setText("");
	}

	if(_first_book_init)
	{
		_first_book_init = false;

		{
			std::map<std::string, CEGUI::TreeItem *>::iterator itm =	_mapquestarea.begin();
			std::map<std::string, CEGUI::TreeItem *>::iterator endm =	_mapquestarea.end();
			for(; itm != endm; ++itm)
			{
				if(std::find(_open_tree_quests.begin(), _open_tree_quests.end(), itm->first) != _open_tree_quests.end())
					itm->second->toggleIsOpen();
			}

		}

		{
			std::map<std::string, CEGUI::TreeItem *>::iterator itm =	_mapquestdonearea.begin();
			std::map<std::string, CEGUI::TreeItem *>::iterator endm =	_mapquestdonearea.end();
			for(; itm != endm; ++itm)
			{
				if(std::find(_open_tree_done_quests.begin(), _open_tree_done_quests.end(), itm->first) != _open_tree_done_quests.end())
					itm->second->toggleIsOpen();
			}
		}
	}

}
コード例 #5
0
ファイル: JournalBox.cpp プロジェクト: Rincevent/lbanet
/***********************************************************
initalize the box
***********************************************************/
void JournalBox::Initialize(CEGUI::Window* Root)
{
	try
	{
		_myBox = CEGUI::WindowManager::getSingleton().loadWindowLayout( "questbook.layout",
								"", "", &MyPropertyCallback);
		Root->addChildWindow(_myBox);


		CEGUI::FrameWindow * frw = static_cast<CEGUI::FrameWindow *> (
			CEGUI::WindowManager::getSingleton().getWindow("JournalFrame"));
		frw->subscribeEvent (
			CEGUI::FrameWindow::EventCloseClicked,
			CEGUI::Event::Subscriber (&JournalBox::HandleClose, this));

		CEGUI::Tree * tree = static_cast<CEGUI::Tree *> (
			CEGUI::WindowManager::getSingleton().getWindow("Root/JournalWin/tab/questtab/Tree"));

		tree->subscribeEvent(CEGUI::Listbox::EventSelectionChanged,
							CEGUI::Event::Subscriber (&JournalBox::HandleQuestTreeSelected, this));


		CEGUI::Tree * tree2 = static_cast<CEGUI::Tree *> (
			CEGUI::WindowManager::getSingleton().getWindow("Root/JournalWin/tab/questdonetab/Tree"));

		tree2->subscribeEvent(CEGUI::Listbox::EventSelectionChanged,
							CEGUI::Event::Subscriber (&JournalBox::HandleQuestDoneTreeSelected, this));


		float PosX = ConfigurationManager::GetInstance()->GetValue("Gui.JournalBox.PosX", 0.65f);
		float PosY = ConfigurationManager::GetInstance()->GetValue("Gui.JournalBox.PosY", 0.56f);
		float SizeX = ConfigurationManager::GetInstance()->GetValue("Gui.JournalBox.SizeX", 0.35f);
		float SizeY = ConfigurationManager::GetInstance()->GetValue("Gui.JournalBox.SizeY", 0.34f);
		bool Visible = ConfigurationManager::GetInstance()->GetValue("Gui.JournalBox.Visible", false);
		frw->setPosition(CEGUI::UVector2(CEGUI::UDim(PosX, 0), CEGUI::UDim(PosY, 0)));
		frw->setWidth(CEGUI::UDim(SizeX, 0));
		frw->setHeight(CEGUI::UDim(SizeY, 0));

		if(Visible)
			frw->show();
		else
			frw->hide();


		// get quest topic tree which should be opened
		std::string treeqopen = ConfigurationManager::GetInstance()->GetValue<std::string>("Gui.JournalBox.QuestTreeOpen", "");
		std::string treedqopen = ConfigurationManager::GetInstance()->GetValue<std::string>("Gui.JournalBox.QuestDoneTreeOpen", "");

		_selected_tree_quests = ConfigurationManager::GetInstance()->GetValue<std::string>("Gui.JournalBox.QuestTreeSelected", "");
		_selected_tree_done_quests = ConfigurationManager::GetInstance()->GetValue<std::string>("Gui.JournalBox.QuestDoneTreeSelected", "");

		StringHelper::Tokenize(treeqopen, _open_tree_quests, "##");
		StringHelper::Tokenize(treedqopen, _open_tree_done_quests, "##");


		static_cast<CEGUI::TabControl *> (
			CEGUI::WindowManager::getSingleton().getWindow("Root/JournalWin/tab"))->setSelectedTab("Root/JournalWin/tab/questtab");
	}
	catch(CEGUI::Exception &ex)
	{
		LogHandler::getInstance()->LogToFile(std::string("Exception init InventoryBox: ") + ex.getMessage().c_str());
	}
}