Example #1
0
void Game::notifyComboChange(MyGUI::ComboBox* _sender, size_t _index){
	int st = static_cast<int>(Ogre::SHADOWTYPE_NONE);

	if( mUI.IsWidget(_sender,"shadow") ){
		st = static_cast<int>(getShadowTechnique( _index ));
		if( st != static_cast<int>(Ogre::SHADOWTYPE_NONE) ){
			try{
				MyGUI::ComboBox* pcombo = mUI["lighting"]->castType<MyGUI::ComboBox>(false);
				size_t index = pcombo->getIndexSelected();
				st |= static_cast<int>(getShadowMode( index ));
			}catch( out_of_range& e ){
				WARNING_LOG(e.what());
			}
		}
	}else if( mUI.IsWidget(_sender,"lighting") ){
		try{
			MyGUI::ComboBox* pcombo = mUI["shadow"]->castType<   MyGUI::ComboBox>(false);
			int sel = pcombo->getIndexSelected();
			st = static_cast<int>(getShadowTechnique( sel ));
		}catch( out_of_range& e ){
			WARNING_LOG(e.what());
			return;
		}
		if( st != static_cast<int>(Ogre::SHADOWTYPE_NONE) )
			st |= static_cast<int>(getShadowMode( _index ));
	}
setShadowTechnique( static_cast<Ogre::ShadowTechnique>(st) );
}
Example #2
0
//-------------------------------------------------------------------------------
void MainMenu::onClickLoadUserLevel(MyGUI::WidgetPtr)
{
    unsigned int worldNum = GlbVar.firstLevel - 1;
    Level *userLevel = dynamic_cast<Level*>(GlbVar.woMgr->getWorld(worldNum));

    MyGUI::ComboBox *list = GlbVar.gui->findWidget<MyGUI::ComboBox>("cmb_userLevel");
    Ogre::String ngf = list->getItemNameAt(list->getIndexSelected());
    userLevel->setNgfName(ngf);
    userLevel->setCaption(ngf);

    GlbVar.woMgr->gotoWorld(worldNum);
}
Example #3
0
void Game::showOptionsDialog(){
	if( !mUI ){
		mUI.load("Options.layout","Game");
		try{
			if( mUI ){
				SimpleDataUI sdu(mUI["OgreView"],MyGUI::newDelegate(this,&Game::simpleDataChange));
				
				assert(mRoot && mRoot->getRenderSystem());

				mNeedReset = false;

				Ogre::ConfigOptionMap& mp = mRoot->getRenderSystem()->getConfigOptions();
				
				for( Ogre::ConfigOptionMap::iterator i=mp.begin();i!=mp.end();++i ){
					vector<MyGUI::UString> v(i->second.possibleValues.size());
					copy(i->second.possibleValues.begin(),i->second.possibleValues.end(),v.begin());
					sdu.add( i->first,SimpleData(i->first,i->second.currentValue,v) );
				}
				sdu.reLayout(2,5);

				mUI["Cancel"]->eventMouseButtonClick += newDelegate(this, &Game::notifyButtonClick);
				mUI["Apply"]->eventMouseButtonClick += newDelegate(this, &Game::notifyButtonClick);

				MyGUI::ComboBox* pcombo = mUI["shadow"]->castType<MyGUI::ComboBox>(false);
				pcombo->addItem( "None" );
				pcombo->addItem( "Stencil" );
				pcombo->addItem( "Texture" );
				Ogre::ShadowTechnique st = getSceneManager()->getShadowTechnique();
				if( st & Ogre::SHADOWDETAILTYPE_STENCIL )
					pcombo->setIndexSelected(1);
				else if( st & Ogre::SHADOWDETAILTYPE_TEXTURE )
					pcombo->setIndexSelected(2);
				else
					pcombo->setIndexSelected(0);
				pcombo->eventComboChangePosition += newDelegate(this,&Game::notifyComboChange);
				pcombo = mUI["lighting"]->castType<MyGUI::ComboBox>(false);
				pcombo->addItem( "Modulative" );
				pcombo->addItem( "Additive" );
				if( st & Ogre::SHADOWDETAILTYPE_ADDITIVE )
					pcombo->setIndexSelected( 1 );
				else if( st & Ogre::SHADOWDETAILTYPE_MODULATIVE )
					pcombo->setIndexSelected( 0 );
				pcombo->eventComboChangePosition += newDelegate(this,&Game::notifyComboChange);

				mUI->eventWindowButtonPressed += newDelegate(this, &Game::notifyWindowButtonPressed);
			}
		}catch( out_of_range& e ){
			WARNING_LOG(e.what());
		}
	}
}
Example #4
0
/////////////////// <SELECTION FROM STRING VECTOR CONTROL>
    void PropertyGridManager::buildStringVectorSelectionControl(MyGUI::Widget *const control, PropertyGridProperty *const property)
    {
        int left = insertPropertyIdLabel(control, property) + WIDGET_SPACING;

        int width = control->getWidth() - left - WIDGET_SPACING;
        MyGUI::IntCoord coord(left, 0, width, control->getHeight());
        MyGUI::ComboBox *cbBox = (MyGUI::ComboBox *)control->createWidget<MyGUI::ComboBox>("ComboBox", coord, MyGUI::Align::Left | MyGUI::Align::Top, "ComboBox");
        cbBox->setEnabled(!property->isReadOnly());

        cbBox->setEditReadOnly(true);
        cbBox->setComboModeDrop(true); //a position change also acts as a submit (aka accept) (both events are raised in this order).
        cbBox->setUserData(property);
        cbBox->eventComboAccept += MyGUI::newDelegate(this, &PropertyGridManager::onMyGUIComboAccept);
    }
Example #5
0
    void PropertyGridManager::onMyGUIComboAccept(MyGUI::ComboBox *sender, size_t index)
    {
        MyGUI::ComboBox *cbBox = sender->castType<MyGUI::ComboBox>();

        PropertyGridProperty *const property = *(cbBox->getUserData<PropertyGridProperty *>());

        if(nullptr == property)
        {
            Debug::error(STEEL_METH_INTRO, "no property linked to control ", cbBox->getParent()).endl().breakHere();
            return;
        }

        if(PropertyGridPropertyValueType::StringVectorSelection == property->valueType())
            property->write((u32)index);
        else
            Debug::error(STEEL_METH_INTRO, "got a combobox event for property ", *property, ". Skipping event.").endl();
    }
Example #6
0
void SimpleUI::removeAllItem( const string& name )
{
	try
	{
		MyGUI::ComboBox * c = operator [](name)->castType<MyGUI::ComboBox>(false);
		if( c )
			c->removeAllItems();
		else
		{
			MyGUI::ListBox * c = operator [](name)->castType<MyGUI::ListBox>(false);
			if( c )
				c->removeAllItems();
		}
	}
	catch( std::out_of_range& e )
	{
		WARNING_LOG(e.what());
	}
}
Example #7
0
void SimpleUI::selectItem( const string& name,int index )
{
	try
	{
		MyGUI::ComboBox * c = operator [](name)->castType<MyGUI::ComboBox>(false);
		if( c )
			c->setIndexSelected( index );
		else
		{
			MyGUI::ListBox * c = operator [](name)->castType<MyGUI::ListBox>(false);
			if( c )
				c->setIndexSelected( index );
		}
	}
	catch( std::out_of_range& e )
	{
		WARNING_LOG(e.what());
	}
}
Example #8
0
/*向界面中加入数据相
*/
void SimpleDataUI::add( const MyGUI::UString& caption,SimpleData sd ){

	MyGUI::TextBox* pt = mParent->createWidget<MyGUI::TextBox>(
		"TextBox",MyGUI::IntCoord(),
		MyGUI::Align::Left|MyGUI::Align::Top);
	
	pt->setTextAlign( MyGUI::Align::Right );
	pt->setCaption( caption );
	pt->setUserData( MyGUI::Any(string("@")) ); //打一个标记为删除做准备

	if( sd.type==SimpleData::BOOL ){
		MyGUI::Button* pe = mParent->createWidget<MyGUI::Button>(
		"CheckBox",MyGUI::IntCoord(),
		MyGUI::Align::Left|MyGUI::Align::Top);
		pe->setStateSelected(sd.b);
		sd.change = mep;
		pe->setUserData(MyGUI::Any(sd));
		pe->eventMouseButtonClick += newDelegate(_simpleDataCheckChange);
	}else if( sd.sv.empty() ){//编辑
		MyGUI::EditBox* pe = mParent->createWidget<MyGUI::EditBox>(
		"EditBox",MyGUI::IntCoord(),
		MyGUI::Align::Left|MyGUI::Align::Top);
		if( sd.type== SimpleData::STRING )
			pe->setCaption( sd.str );
		else if( sd.type== SimpleData::REAL)
		{
			pe->setCaption( (boost::format("%.2f")%sd.real).str() );
		}

		sd.change = mep;
		pe->setUserData(MyGUI::Any(sd));
		//数据改变
		pe->eventEditTextChange += newDelegate(_simpleDataEditTextChange);
	}else{//有可选数据
		MyGUI::ComboBox* pc = mParent->createWidget<MyGUI::ComboBox>(
		"ComboBox",MyGUI::IntCoord(),
		MyGUI::Align::Left|MyGUI::Align::Top);
		if( sd.type== SimpleData::STRING )
			pc->setCaption( sd.str );
		else if( sd.type== SimpleData::REAL )
			pc->setCaption( boost::lexical_cast<string>(sd.real) );
		for( vector<MyGUI::UString>::const_iterator i = sd.sv.begin();
			i!=sd.sv.end();++i){
			pc->addItem(*i);
			if( *i == sd.str ){
				if( sd.type== SimpleData::STRING )
					pc->setEditStatic(true);
				pc->setIndexSelected(i-sd.sv.begin());
			}
		}

		sd.change = mep;
		pc->setUserData(MyGUI::Any(sd));
		//数据改变
		pc->eventComboChangePosition += newDelegate(_simpleDataChange);
	}
}
Example #9
0
    void PropertyGridManager::updateStringVectorSelectionControlValue(MyGUI::Widget *const control, PropertyGridProperty *const property)
    {
        MyGUI::ComboBox *cbBox = (MyGUI::ComboBox *)control->findWidget("ComboBox");

        if(nullptr == cbBox)
        {
            Debug::error(STEEL_METH_INTRO, "could not find comboBox in stringVectorSelection propertyControl. Control: ", control, " property: ", *property, ". Aborting.").endl();
            return;
        }

        PropertyGridProperty::StringVectorSelection readItem;
        property->read(readItem);

        cbBox->removeAllItems();

        for(Ogre::String const & value : readItem.selectableValues)
            cbBox->addItem(value);

        cbBox->setIndexSelected(readItem.selectedIndex);
    }
Example #10
0
void GUIManager::buttonGUIDelegate(MyGUI::Widget* _sender, int _left, int _top, MyGUI::MouseButton _id) 
{
   const string& _name = _sender->getName();
   string name = _name;

   render_manager->processGUIButton(name);

   GUIWidgetScript* widget_script = all_widgets->tableRetrieve(&name);
   if (widget_script)
   {
      string file_name = widget_script->getFileName();
      string script_name = widget_script->getScriptName();

      //obtain a reference to the combo box
      MyGUI::ComboBox* combo = MyGUI::Gui::getInstance().findWidget<MyGUI::ComboBox>("SelectMusic");
      int selected_index = combo->getIndexSelected();
      string object_name = combo->getItemNameAt(selected_index);

      render_manager->executeScript(file_name, script_name, object_name);
   }
}
Example #11
0
static bool getComboBoxSize( MyGUI::Widget* pw,MyGUI::IntSize& size ){
	MyGUI::ComboBox* p = pw->castType<MyGUI::ComboBox>(false);
	
	if( p ){
		MyGUI::IntSize s,ss;
		for( size_t i=0;i<p->getItemCount();++i ){
			s = CalcTextWidth(p->getItemNameAt(i),p->getFontName());
			ss.width = max(s.width,ss.width);
		}
		s = CalcTextWidth(p->getCaption(),p->getFontName());
		size.width = max(s.width,ss.width) + 26;
		size.height = max(s.height,ss.height)+4;
		return true;
	}
	return false;
}
Example #12
0
void GUIManager::addComboBoxes(TiXmlNode* combo_boxes_node, float* values, MyGUI::Window* w)
{
   for(TiXmlNode* combo_box_node = combo_boxes_node->FirstChild("combo_box"); combo_box_node; combo_box_node = combo_box_node->NextSibling())
   {
      std::string name_text = GameManager::textFromChildNode(combo_box_node, "name");
      std::string skin_text = GameManager::textFromChildNode(combo_box_node, "skin");
      std::string position_text = GameManager::textFromChildNode(combo_box_node, "position");
      GameManager::parseFloats(position_text, values);
      uint32 left = (uint32) values[0];
      uint32 top = (uint32) values[1];

      std::string size_text = GameManager::textFromChildNode(combo_box_node, "size");
      GameManager::parseFloats(size_text, values);
      uint32 width = (uint32) values[0];
      uint32 height = (uint32) values[1];

      std::string align_text = GameManager::textFromChildNode(combo_box_node, "align");
      std::string font_size_text = GameManager::textFromChildNode(combo_box_node, "font");
      uint32 font_size = (uint32) GameManager::parseFloat(font_size_text);

      std::string selected_index_text = GameManager::textFromChildNode(combo_box_node, "selected_index");
      int selected_index = (uint32) GameManager::parseFloat(selected_index_text);

      MyGUI::ComboBox* combo = w->createWidget<MyGUI::ComboBox>(skin_text, left, top, width, height, MyGUI::Align::Default, name_text);
      combo->setFontHeight(font_size);
      combo->setTextColour(MyGUI::Colour(0,0,0));

      TiXmlNode* selections_node = combo_box_node->FirstChild("selections");
      for(TiXmlNode* selection_node = selections_node->FirstChild("selection"); selection_node; selection_node = selection_node->NextSibling())
      {
         TiXmlElement* selection_element = (TiXmlElement*) selection_node->ToElement();
         std::string selection_text = selection_element->GetText();
         combo->addItem(selection_text);
      }

      combo->setIndexSelected(selected_index);
      combo->setComboModeDrop(true);
      combo->eventComboAccept += newDelegate(this, &GUIManager::comboGUIDelegate);
   }
}
Example #13
0
//-------------------------------------------------------------------------------
void MainMenu::init()
{
    int winHeight = GlbVar.ogreWindow->getHeight();
    int winWidth = GlbVar.ogreWindow->getWidth();
    GlbVar.fader->abortFade(0);

    //Gotta see where we click. :-)
    GlbVar.gui->setVisiblePointer(true);

    //Background, logo.
    mBackground = GlbVar.gui->createWidget<MyGUI::StaticImage>("StaticImage", MyGUI::IntCoord(0,0,winWidth,winHeight), MyGUI::Align::Default, "Back");
    mBackground->setImageTexture("MainMenuBgr.png");

    int logoX = winWidth - (LOGO_WIDTH + 5);
    int logoY = winHeight - (LOGO_HEIGHT + 5);
    mLogo = GlbVar.gui->createWidget<MyGUI::StaticImage>("StaticImage", MyGUI::IntCoord(logoX, logoY, LOGO_WIDTH, LOGO_HEIGHT), MyGUI::Align::Default, "Back");
    mLogo->setImageTexture("MainMenuLogo.png");

    //Get the Window.
    MyGUI::LayoutManager::getInstance().load("MainMenu.layout");
    mWindow = GlbVar.gui->findWidget<MyGUI::Window>("win_mainMenu");

    //Buttons, events.
    MyGUI::ButtonPtr button;
    button = GlbVar.gui->findWidget<MyGUI::Button>("but_newGame");
    button->eventMouseButtonClick = MyGUI::newDelegate(this, &MainMenu::onClickNewGame);

    button = GlbVar.gui->findWidget<MyGUI::Button>("but_continueGame");
    button->eventMouseButtonClick = MyGUI::newDelegate(this, &MainMenu::onClickContinueGame);
    if (GlbVar.records.firstTime)
        button->setEnabled(false);

    button = GlbVar.gui->findWidget<MyGUI::Button>("but_levelSelect");
    button->eventMouseButtonClick = MyGUI::newDelegate(this, &MainMenu::onClickLevelSelect);
    if (GlbVar.records.firstTime)
        button->setEnabled(false);

    button = GlbVar.gui->findWidget<MyGUI::Button>("but_userLevel");
    button->eventMouseButtonClick = MyGUI::newDelegate(this, &MainMenu::onClickUserLevel);
    if (GlbVar.userNgfNames.empty())
        button->setEnabled(false);

    button = GlbVar.gui->findWidget<MyGUI::Button>("but_options");
    button->eventMouseButtonClick = MyGUI::newDelegate(this, &MainMenu::onClickOptions);

    button = GlbVar.gui->findWidget<MyGUI::Button>("but_credits");
    button->eventMouseButtonClick = MyGUI::newDelegate(this, &MainMenu::onClickCredits);

    button = GlbVar.gui->findWidget<MyGUI::Button>("but_quit");
    button->eventMouseButtonClick = MyGUI::newDelegate(this, &MainMenu::onClickQuit);

    //Window properties.
    //Children don't inherit alpha.
    MyGUI::EnumeratorWidgetPtr iter = mWindow->getEnumerator();
    while (iter.next())
    {
        iter.current()->setInheritsAlpha(false);
    }

    mWindow->setAlpha(0);
    mWindow->setPosition(30,5);

    //Create child interfaces.

    //Level select.
    mLevelSelect = new LevelSelect();

    //Credits.
    MyGUI::LayoutManager::getInstance().load("Credits.layout");
    mCreditsWindow = GlbVar.gui->findWidget<MyGUI::Window>("win_credits");
    mCreditsWindow->setVisible(false);

    int height = mCreditsWindow->getHeight();
    int width = mCreditsWindow->getWidth();
    mCreditsWindow->setCoord(MyGUI::IntCoord((winWidth - width)*0.5, (winHeight - height)*0.5, width, height));

    button = GlbVar.gui->findWidget<MyGUI::Button>("but_cr_ok");
    button->eventMouseButtonClick = MyGUI::newDelegate(this, &MainMenu::onClickCloseCredits);

    MyGUI::EditPtr credits = GlbVar.gui->findWidget<MyGUI::Edit>("edt_cr_credits");
    credits->setOnlyText(creditsStr);
    credits->setTextAlign(MyGUI::Align::Left | MyGUI::Align::Top);

    //User level.
    MyGUI::LayoutManager::getInstance().load("LoadUserLevel.layout");
    mUserLevelWindow = GlbVar.gui->findWidget<MyGUI::Window>("win_userLevel");
    height = mUserLevelWindow->getHeight();
    width = mUserLevelWindow->getWidth();
    mUserLevelWindow->setCoord(MyGUI::IntCoord((winWidth - width)*0.5, (winHeight - height)*0.5, width, height));
    mUserLevelWindow->setVisible(false);

    //Tell the buttons to tell us.
    button = GlbVar.gui->findWidget<MyGUI::Button>("but_loadUserLevel");
    button->eventMouseButtonClick = MyGUI::newDelegate(this, &MainMenu::onClickLoadUserLevel);

    button = GlbVar.gui->findWidget<MyGUI::Button>("but_cancelUserLevel");
    button->eventMouseButtonClick = MyGUI::newDelegate(this, &MainMenu::onClickCancelUserLevel);

    //Populate the user level list.
    MyGUI::ComboBox *list = GlbVar.gui->findWidget<MyGUI::ComboBox>("cmb_userLevel");

    for (std::vector<Ogre::String>::iterator iter = GlbVar.userNgfNames.begin(); iter != GlbVar.userNgfNames.end(); ++iter)
        list->addItem(*iter);

    if (!(GlbVar.userNgfNames.empty()))
        list->setIndexSelected(0);
}