Beispiel #1
0
bool GUIManager::handleDSActivation ( CEGUI::EventArgs const & e )
{
  CEGUI::Window *tab =
    static_cast<CEGUI::WindowEventArgs const &>(e).window->getParent();
  CEGUI::Listbox *lb = static_cast<CEGUI::Listbox *>(tab->getChild(0));
  ListboxItem *item = static_cast<ListboxItem *>(lb->getFirstSelectedItem());
  if (item != NULL) {
    DataManager *dm = static_cast<DataManager *>(item->getUserData());
    CEGUI::Scrollbar *sb = static_cast<CEGUI::Scrollbar *>(tab->getChild(2));
    std::vector<unsigned int> const & dims = dm->getDimensions();
    unsigned int dim = dims[int(sb->getScrollPosition()*(dims.size()-1))];
    float scrollPos = sb->getScrollPosition();
    dm->activate(dim);
    // Enable global scrollbar
    CEGUI::WindowManager & wm = CEGUI::WindowManager::getSingleton();
    sb = static_cast<CEGUI::Scrollbar *>(wm.getWindow("Sheet/DimensionSlider"));
    sb->enable();
    CEGUI::WindowEventArgs w(sb);
    sb->fireEvent(CEGUI::Scrollbar::EventScrollPositionChanged, w);
    // Set the global scrollbar to the right position.
    sb->setScrollPosition(scrollPos);
    CEGUI::Window *desc = wm.getWindow("Sheet/DimensionText");
    desc->show();
  }
  // TODO handle else-error
  return true;
}
Beispiel #2
0
/***********************************************************
handle event when add friend clicked
***********************************************************/
bool CommunityBox::HandleAddFriend(const CEGUI::EventArgs& e)
{
	CEGUI::Listbox * lb = static_cast<CEGUI::Listbox *> (
		CEGUI::WindowManager::getSingleton().getWindow("Community/friendlist"));

	// check if we accept pending friend
	const CEGUI::ListboxTextItem * it = static_cast<const CEGUI::ListboxTextItem *>(lb->getFirstSelectedItem());
	if(it)
	{
		long fid = (long)it->getID();
		T_friendmap::iterator itm = _friends.find(fid);
		if(itm != _friends.end())
		{
			if(itm->second.first.ToAccept)
			{
				ThreadSafeWorkpile::getInstance()->AcceptFriend(fid);
				return true;
			}
		}
	}

	// if not then we add a new friend
	_myChooseName->show();
	CEGUI::Editbox * bed = static_cast<CEGUI::Editbox *>
		(CEGUI::WindowManager::getSingleton().getWindow("Chat/choosePlayerName/edit"));
	bed->activate();
	return true;
}
Beispiel #3
0
/***********************************************************
handle world selected event
***********************************************************/
bool ChooseWorldGUI::HandleWorldSelected (const CEGUI::EventArgs& e)
{
	try
	{
		CEGUI::Listbox * lb = static_cast<CEGUI::Listbox *> (
				CEGUI::WindowManager::getSingleton().getWindow("ChooseWorldList"));
		if(lb)
		{
			size_t idx = lb->getItemIndex(lb->getFirstSelectedItem());
			if(idx < _wlist.size())
			{
				CEGUI::MultiLineEditbox * eb = static_cast<CEGUI::MultiLineEditbox *> (
					CEGUI::WindowManager::getSingleton().getWindow("ChooseWorldDescription"));
				if(eb)
				{
					eb->setText(_wlist[idx].Description);
				}

				_selectedworld = _wlist[idx].WorldName;
			}
		}
	}
	catch(CEGUI::Exception &ex)
	{
		LogHandler::getInstance()->LogToFile(std::string("Exception init the world list: ") + ex.getMessage().c_str());
		_root = NULL;
	}

	return true;
}
Beispiel #4
0
bool GUILobby::handleRoomClick( const CEGUI::EventArgs& args )
{
	CEGUI::Listbox* pListBox = static_cast<CEGUI::Listbox*>(d_root->getChild("RoomList"));

	if(pListBox->getFirstSelectedItem())
    {
        MyListItem* pItem = static_cast<MyListItem*>(pListBox->getFirstSelectedItem());
		
		SFProtobufPacket<SFPacketStore::EnterRoom> pktEnterRoom(CGSF::EnterRoom);

		pktEnterRoom.GetData().set_roomindex(pItem->roomIndex);
		pktEnterRoom.GetData().set_gamemode(3);
		g_pCasualGameManager->GetNetwork()->TCPSend(&pktEnterRoom);
	}

	return true;
}
Beispiel #5
0
bool 
IntroState::changeResolution(const CEGUI::EventArgs &e){
  CEGUI::Listbox* lb = static_cast<CEGUI::Listbox*>(static_cast<const CEGUI::WindowEventArgs&>(e).window->getRootWindow()->getChild("background_options")->getChild("lbRes"));
  string sel=lb->getFirstSelectedItem()->getText().c_str();
  _resWidth=Ogre::StringConverter::parseInt(Ogre::StringUtil::split(sel,"x")[0]);
  _resHeigt=Ogre::StringConverter::parseInt(Ogre::StringUtil::split(sel,"x")[1]);
  cout << _resWidth << endl;
  cout << _resHeigt << endl;
  return true;
}
Beispiel #6
0
/***********************************************************
handle GO button pressed
***********************************************************/
bool TeleportBox::HandleGoButton (const CEGUI::EventArgs& e)
{
    CEGUI::Listbox * lb = static_cast<CEGUI::Listbox *> (
        CEGUI::WindowManager::getSingleton().getWindow("TeleportList"));

	MyTeleListItem * it = static_cast<MyTeleListItem *> (lb->getFirstSelectedItem());
	if(it != NULL)
	{
		InternalWorkpile::getInstance()->AddEvent(new TeleportEvent(_tplist[it->getText().c_str()].NewMap, _tplist[it->getText().c_str()].Spawning));
		HandleClose(e);
	}

	return true;
}
Beispiel #7
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;
}
Beispiel #8
0
/***********************************************************
handle event when remove friend clicked
***********************************************************/
bool CommunityBox::HandleRemoveFriend(const CEGUI::EventArgs& e)
{
	CEGUI::Listbox * lb = static_cast<CEGUI::Listbox *> (
		CEGUI::WindowManager::getSingleton().getWindow("Community/friendlist"));

	const CEGUI::ListboxTextItem * it = static_cast<const CEGUI::ListboxTextItem *>(lb->getFirstSelectedItem());
	if(it)
	{
		long fid = (long)it->getID();
		//RemoveFriend(fid);
		ThreadSafeWorkpile::getInstance()->RemoveFriend(fid);
	}

	return true;
}
Beispiel #9
0
bool GUIManager::handleDSSelection ( CEGUI::EventArgs const & e )
{
  CEGUI::Window *tab =
    static_cast<CEGUI::WindowEventArgs const &>(e).window->getParent();
  CEGUI::Listbox *lb = static_cast<CEGUI::Listbox *>(tab->getChild(0));
  CEGUI::Scrollbar *sb = static_cast<CEGUI::Scrollbar *>(tab->getChild(2));
  DataManager *dm = static_cast<DataManager *>(
      lb->getFirstSelectedItem()->getUserData());
  _selectedDM = dm;
  std::vector<unsigned int> const & dim = dm->getDimensions();
  sb->setStepSize(1.0/float(dim.size()-1));
  sb->enable();
  CEGUI::WindowEventArgs w(sb);
  sb->fireEvent(CEGUI::Scrollbar::EventScrollPositionChanged, w);
  return true;
}
Beispiel #10
0
bool GUIManager::handleScrollbarChanged ( CEGUI::EventArgs const & e )
{
  CEGUI::Window *tab =
    static_cast<CEGUI::WindowEventArgs const &>(e).window->getParent();
  CEGUI::Scrollbar *scrollbar =
    static_cast<CEGUI::Scrollbar *>(tab->getChild(2));
  CEGUI::Listbox *lb = static_cast<CEGUI::Listbox *>(tab->getChild(0));
  CEGUI::Window *desc = tab->getChild(1);
  DataManager *dm = static_cast<DataManager *>(
      lb->getFirstSelectedItem()->getUserData());
  std::vector<unsigned int> const & dims = dm->getDimensions();
  float f = static_cast<CEGUI::Scrollbar *>(scrollbar)->getScrollPosition();
  unsigned int dim = dims[int(f*(dims.size()-1))];
  std::ostringstream ss; ss << "Dimension: " << dim;
  desc->setText(ss.str());
  return true;
}
Beispiel #11
0
bool
MenuState::playB(const CEGUI::EventArgs &e)
{
  //Recupero el nivel selecionado-----------------------------------------
  CEGUI::Listbox* slistbox = static_cast<CEGUI::Listbox*>(static_cast<const CEGUI::WindowEventArgs&>(e).window->getRootWindow()->getChild("backgroundMenu")->getChild("listbox"));
  string listboxText=slistbox->getFirstSelectedItem()->getText().c_str();
  listboxText+=".txt";
  cout << listboxText << endl;
  for(unsigned int i=0;i<_recorridos.size();i++){
    string aux=_recorridos[i];
    if(Ogre::StringUtil::endsWith(aux,listboxText)){
      GameManager::getSingletonPtr()->setLevel(aux);
      changeState(PlayState::getSingletonPtr());
    }
  }
  return true;
}
Beispiel #12
0
/***********************************************************
handle event when list is double clicked
***********************************************************/
bool CommunityBox::HandleConnecteddblClick (const CEGUI::EventArgs& e)
{
	CEGUI::Listbox * lb = static_cast<CEGUI::Listbox *> (
		CEGUI::WindowManager::getSingleton().getWindow("Community/onlinelist"));

	const CEGUI::ListboxTextItem * it = static_cast<const CEGUI::ListboxTextItem *>(lb->getFirstSelectedItem());
	if(it)
	{
		std::string name = it->getText().c_str();
		name = name.substr(name.find("]")+1);
		name = name.substr(0, name.find_last_of("(")-1);

		ThreadSafeWorkpile::getInstance()->AddWhisperChannel(name);
		ThreadSafeWorkpile::getInstance()->AddEvent(new FocusChatEvent());
	}

	return true;
}
Beispiel #13
0
bool GUIManager::handleDSDeactivation ( CEGUI::EventArgs const & e )
{
  CEGUI::Window *tab =
    static_cast<CEGUI::WindowEventArgs const &>(e).window->getParent();
  CEGUI::Listbox *lb = static_cast<CEGUI::Listbox *>(tab->getChild(0));
  ListboxItem *item = static_cast<ListboxItem *>(lb->getFirstSelectedItem());
  if (item != NULL) {
    DataManager *dm = static_cast<DataManager *>(item->getUserData());
    dm->deactivate();
    // Enable global scrollbar
    CEGUI::WindowManager & wm = CEGUI::WindowManager::getSingleton();
    CEGUI::Scrollbar *sb = static_cast<CEGUI::Scrollbar *>(tab->getChild(2));
    sb = static_cast<CEGUI::Scrollbar *>(wm.getWindow("Sheet/DimensionSlider"));
    sb->disable();
    CEGUI::Window *desc = wm.getWindow("Sheet/DimensionText");
    desc->hide();
  }
  // TODO handle else-error
  return true;
}
Beispiel #14
0
/***********************************************************
handle event when list is double clicked
***********************************************************/
bool CommunityBox::HandleListdblClick (const CEGUI::EventArgs& e)
{
	CEGUI::Listbox * lb = static_cast<CEGUI::Listbox *> (
		CEGUI::WindowManager::getSingleton().getWindow("Community/friendlist"));

	const CEGUI::ListboxTextItem * it = static_cast<const CEGUI::ListboxTextItem *>(lb->getFirstSelectedItem());
	if(it)
	{
		std::string name = it->getText().c_str();
		name = name.substr(name.find("]")+1);
	
		std::map<std::string, CEGUI::ListboxItem *>::iterator iton = _onlines.find(name);
		if(iton != _onlines.end())
		{
			ThreadSafeWorkpile::getInstance()->AddWhisperChannel(name);
			ThreadSafeWorkpile::getInstance()->AddEvent(new FocusChatEvent());
		}
	}

	return true;
}
Beispiel #15
0
/***********************************************************
handle world selected event
***********************************************************/
bool ChooseWorldGUI::HandleWorldSelected (const CEGUI::EventArgs& e)
{
	try
	{
		CEGUI::Listbox * lb = static_cast<CEGUI::Listbox *> (
				CEGUI::WindowManager::getSingleton().getWindow("ChooseWorldList"));
		if(lb)
		{
			size_t idx = lb->getItemIndex(lb->getFirstSelectedItem());
			if(idx < _wlist.size())
			{
				CEGUI::MultiLineEditbox * eb = static_cast<CEGUI::MultiLineEditbox *> (
					CEGUI::WindowManager::getSingleton().getWindow("ChooseWorldDescription"));
				if(eb)
				{
					std::string str = _wlist[idx].Description;
					int idxs = 0;
					bool firsttime=true;
					while((idxs = str.find(" @ ")) != std::string::npos)
					{
						std::string tmp = str.substr(0, idxs);
						if(tmp == "")
							tmp = "\n";

						if(firsttime)
						{
							firsttime = false;
							eb->setText((const unsigned char *)tmp.c_str());
						}
						else
							eb->appendText((const unsigned char *)tmp.c_str());

						while(((idxs+4) < (int)str.size()) && (str[idxs+3] == '@') && (str[idxs+4] == ' '))
						{
							eb->appendText("\n");
							idxs+= 2;
						}

						str = str.substr(idxs+3);
					}

					if(firsttime)
					{
						firsttime = false;
						eb->setText((const unsigned char *)str.c_str());
					}
					else
						eb->appendText((const unsigned char *)str.c_str());
				}

				 eb = static_cast<CEGUI::MultiLineEditbox *> (
					CEGUI::WindowManager::getSingleton().getWindow("ChooseWorldNews"));
				if(eb)
				{
					std::string str = _wlist[idx].News;
					int idxs = 0;
					bool firsttime=true;
					while((idxs = str.find(" @ ")) != std::string::npos)
					{
						std::string tmp = str.substr(0, idxs);
						if(tmp == "")
							tmp = "\n";

						if(firsttime)
						{
							firsttime = false;
							eb->setText((const unsigned char *)tmp.c_str());
						}
						else
							eb->appendText((const unsigned char *)tmp.c_str());

						while(((idxs+4) < (int)str.size()) && (str[idxs+3] == '@') && (str[idxs+4] == ' '))
						{
							eb->appendText("\n");
							idxs+= 2;
						}

						str = str.substr(idxs+3);
					}

					if(firsttime)
					{
						firsttime = false;
						eb->setText((const unsigned char *)str.c_str());
					}
					else
						eb->appendText((const unsigned char *)str.c_str());
				}

				_selectedworld = idx;
				ConfigurationManager::GetInstance()->SetValue("Options.General.SelectedWorld", _selectedworld);
			}
		}
	}
	catch(CEGUI::Exception &ex)
	{
		LogHandler::getInstance()->LogToFile(std::string("Exception init the world list: ") + ex.getMessage().c_str());
		_root = NULL;
	}

	return true;
}