Exemple #1
0
/***********************************************************
resize inventory
***********************************************************/
void ContainerBox::ResizeInventory(int newsize)
{
	if(_inventory_size == newsize)
		return;

	_inventory_size = newsize;
	for(size_t i=0; i<_inv_boxes.size(); ++i)
		_inv_boxes[i]->destroy();

	_inv_boxes.clear();


	CEGUI::Window*	pane = CEGUI::WindowManager::getSingleton().getWindow("ContainerFrame/InvScrollable");
	CEGUI::Window*	tmpwindow;
	for(int i=0; i<_inventory_size; ++i)
	{
		int x = i / 4;
		int y = i % 4;

		tmpwindow = CEGUI::WindowManager::getSingleton().createWindow("TaharezLook/StaticText");
		tmpwindow->setArea(CEGUI::UDim(0,5+((float)_boxsize+2)*y), CEGUI::UDim(0,5+((float)_boxsize+2.0f)*x),
							CEGUI::UDim(0, (float)_boxsize), CEGUI::UDim(0, (float)_boxsize));
		pane->addChildWindow(tmpwindow);

        tmpwindow->subscribeEvent(
					CEGUI::Window::EventDragDropItemDropped,
					CEGUI::Event::Subscriber(&ContainerBox::handle_ItemDroppedInInventory, this));

		tmpwindow->setID(i);
		_inv_boxes.push_back(tmpwindow);
	}

	CleanInventory();
}
Exemple #2
0
void MessageBox::SetButtons(const MessageBoxButtons& buttons)
{
	float32 sumWidth = 0;
	for (MessageBoxButtons::const_iterator it = buttons.begin(); it != buttons.end(); ++it)
	{
		CEGUI::Window* button = GetButton(*it);
		OC_DASSERT(button != 0);
		float32 width = button->getWidth().d_offset;
		sumWidth += width;
	}

	float32 totalWidth = sumWidth + BUTTON_MARGIN * (buttons.size() - 1);

	float32 left = 0;
	for (MessageBoxButtons::const_iterator it = buttons.begin(); it != buttons.end(); ++it)
	{
		CEGUI::Window* button = GetButton(*it);
		OC_DASSERT(button != 0);
		float32 width = button->getWidth().d_offset;

		button->setPosition(CEGUI::UVector2(CEGUI::UDim(0.5f, -0.5f * totalWidth + left), button->getPosition().d_y));
		button->setWidth(CEGUI::UDim(0, width));
		button->setVisible(true);
		button->setID((CEGUI::uint)*it);
		button->subscribeEvent(CEGUI::PushButton::EventClicked, CEGUI::Event::Subscriber(&GUISystem::MessageBox::OnButtonClicked, this));
		
		left += width + BUTTON_MARGIN;
	}

	mMinWidth = totalWidth + 2.0f * BUTTON_MARGIN;
}
Exemple #3
0
PromptBox::PromptBox(int32 tag): mTag(tag), mPromptBox(0), mMinWidth(0)
{
	CEGUI::String windowName;
	static int i = 0;
	do
	{
		i++;
		windowName = "PromptBox" + StringConverter::ToString(i);
	}
	while (gGUIMgr.WindowExists(windowName.c_str()));
	mPromptBox = gGUIMgr.LoadSystemLayout("PromptBox.layout", windowName);
	mPromptBox->setModalState(true);

	CEGUI::Window* btnOK = mPromptBox->getChild(mPromptBox->getName() + "/ButtonOK");
	btnOK->setID(0);
	btnOK->subscribeEvent(CEGUI::PushButton::EventClicked, CEGUI::Event::Subscriber(&GUISystem::PromptBox::OnButtonClicked, this));
	CEGUI::Window* btnCancel = mPromptBox->getChild(mPromptBox->getName() + "/ButtonCancel");
	btnCancel->setID(1);
	btnCancel->subscribeEvent(CEGUI::PushButton::EventClicked, CEGUI::Event::Subscriber(&GUISystem::PromptBox::OnButtonClicked, this));
}
Exemple #4
0
//双击推荐列表,打开购买页面
bool OnShopCityTwitterMouseDoubleClicked(const CEGUI::EventArgs& e)
{
    CEGUI::Listbox* twitterList = WListBox(WEArgs(e).window);
    CEGUI::ListboxItem* lbi = twitterList->getFirstSelectedItem();
    if(lbi)
    {
        uint index = lbi->getID();//获取索引,索引关联物品索引
        CEGUI::Window* buyPage = GetWindow(SHOPCITY_BUY_PAGE_NAME);
        buyPage->setID(index);//购买界面ID与物品索引关联
        //打开购买界面
        FireUIEvent(SHOPCITY_BUY_PAGE_NAME,EVENT_OPEN);
    }
    return true;
}
/************************************************************************
Handle click on a mine button (any mouse button)
************************************************************************/
bool MinesweeperSample::handleMineButtonDown(const CEGUI::EventArgs& event)
{
    const CEGUI::MouseEventArgs& me = static_cast<const CEGUI::MouseEventArgs&>(event);
    if (me.button == CEGUI::RightButton)
    {
        CEGUI::Window* button = me.window;
        if (!button->isDisabled())
        {
            if (button->getID() == 0)
            {
                button->setID(1);
                button->setText("F");
            }
            else
            {
                button->setID(0);
                button->setText("");
            }
            return true;
        }
    }
    return false;
}
Exemple #6
0
/***********************************************************
initalize the box
***********************************************************/
void ContainerBox::Initialize(CEGUI::Window* Root)
{
	try
	{
		_myBox = CEGUI::WindowManager::getSingleton().loadWindowLayout( "container.layout" );
		Root->addChildWindow(_myBox);


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


		static_cast<CEGUI::PushButton *> (
			CEGUI::WindowManager::getSingleton().getWindow("ContainerFrame/OK"))->subscribeEvent (
			CEGUI::PushButton::EventClicked,
			CEGUI::Event::Subscriber (&ContainerBox::HandleOk, this));

		static_cast<CEGUI::PushButton *> (
			CEGUI::WindowManager::getSingleton().getWindow("ContainerFrame/TakeAll"))->subscribeEvent (
			CEGUI::PushButton::EventClicked,
			CEGUI::Event::Subscriber (&ContainerBox::HandleTakeAll, this));

		static_cast<CEGUI::PushButton *> (
			CEGUI::WindowManager::getSingleton().getWindow("ContainerFrame/Cancel"))->subscribeEvent (
			CEGUI::PushButton::EventClicked,
			CEGUI::Event::Subscriber (&ContainerBox::HandleCancel, this));


		CEGUI::Window*	pane = CEGUI::WindowManager::getSingleton().getWindow("ContainerFrame/ConScrollable");
		CEGUI::Window*	tmpwindow;
		for(int i=0; i<_NB_BOX_CONTAINER_; ++i)
		{
			int x = i / 3;
			int y = i % 3;

			tmpwindow = CEGUI::WindowManager::getSingleton().createWindow("TaharezLook/StaticText");
			tmpwindow->setArea(CEGUI::UDim(0,5+((float)_boxsize+2)*y), CEGUI::UDim(0,5+((float)_boxsize+2)*x), 
								CEGUI::UDim(0, (float)_boxsize), CEGUI::UDim(0, (float)_boxsize));
			pane->addChildWindow(tmpwindow);

			tmpwindow->subscribeEvent(
						CEGUI::Window::EventDragDropItemDropped,
						CEGUI::Event::Subscriber(&ContainerBox::handle_ItemDroppedInContainer, this));

			tmpwindow->setID(i);
			_cont_boxes.push_back(tmpwindow);
		}



		frw->show();
		_myBox->hide();

		frw->subscribeEvent(CEGUI::Window::EventKeyDown,
			CEGUI::Event::Subscriber (&ContainerBox::HandleEnterKey, this));
	}
	catch(CEGUI::Exception &ex)
	{
		LogHandler::getInstance()->LogToFile(std::string("Exception init ContainerBox: ") + ex.getMessage().c_str());
	}
}
Exemple #7
0
/***********************************************************
add an item inside the container
***********************************************************/
std::pair<CEGUI::Window*, CEGUI::Window*> ContainerBox::AddInventoryItem(long Id, int number, 
																		 CEGUI::Window* parent, 
																		bool tocontainer)
{
	CEGUI::Window*	tmp = CEGUI::WindowManager::getSingleton().createWindow("DragContainer");
	tmp->setArea(CEGUI::UDim(0,0), CEGUI::UDim(0,0), CEGUI::UDim(1, 0), CEGUI::UDim(1, 0));
	tmp->setID(Id);

	CEGUI::Window*	tmp2 = CEGUI::WindowManager::getSingleton().createWindow("TaharezLook/StaticImage");
	tmp2->setArea(CEGUI::UDim(0,5.0f), CEGUI::UDim(0,12.0f), CEGUI::UDim(0, (float)_boxsize-10.0f), CEGUI::UDim(0, (float)_boxsize-20.0f));

	std::string imagesetname = ImageSetHandler::GetInstance()->GetInventoryImage(Id);
	tmp2->setProperty("Image", "set:" + imagesetname + " image:full_image");
	tmp2->setProperty("MousePassThroughEnabled", "True");



	CEGUI::Window*	tmp3 = CEGUI::WindowManager::getSingleton().createWindow("TaharezLook/StaticText");
	tmp3->setArea(CEGUI::UDim(0,2), CEGUI::UDim(0,4), CEGUI::UDim(1, -1), CEGUI::UDim(0, 14));
	tmp3->setProperty("FrameEnabled", "False");
	tmp3->setProperty("BackgroundEnabled", "False");
	tmp3->setProperty("MousePassThroughEnabled", "True");
	tmp3->setAlwaysOnTop(true);
	tmp3->setProperty("Font" , "contourfont");

	std::stringstream strs;
	strs<<number;
	tmp3->setText(strs.str().c_str());
	if(tocontainer)
		tmp3->setID(3);
	else
		tmp3->setID(2);


	CEGUI::String tmpstr((const unsigned char *)InventoryHandler::getInstance()->GetItemDescription(Id).c_str());
	tmp->setProperty("Tooltip", tmpstr);
	tmp->addChildWindow(tmp2);
	tmp->addChildWindow(tmp3);
	parent->addChildWindow(tmp);


    tmp->subscribeEvent(
		CEGUI::Window::EventMouseEnters,
				CEGUI::Event::Subscriber(&ContainerBox::HandleInventoryEnter, this));


	if(tocontainer)
	{
		tmp->subscribeEvent(
					CEGUI::Window::EventDragDropItemDropped,
					CEGUI::Event::Subscriber(&ContainerBox::handle_ItemDroppedInContainerItem, this));
	
		tmp->subscribeEvent (CEGUI::Window::EventMouseClick,
								CEGUI::Event::Subscriber (&ContainerBox::HandleContainerItemClicked, this));
	}
	else
	{
		tmp->subscribeEvent(
					CEGUI::Window::EventDragDropItemDropped,
					CEGUI::Event::Subscriber(&ContainerBox::handle_ItemDroppedInInventoryItem, this));
	
		tmp->subscribeEvent (CEGUI::Window::EventMouseClick,
								CEGUI::Event::Subscriber (&ContainerBox::HandleInventoryItemClicked, this));
	}


	return std::make_pair<CEGUI::Window*, CEGUI::Window*>(tmp, tmp3);
}