Exemplo n.º 1
0
bool 
IntroState::apply(const CEGUI::EventArgs &e){
  
  CEGUI::Slider* slider = static_cast<CEGUI::Slider*>(static_cast<const CEGUI::WindowEventArgs&>(e).window->getRootWindow()->getChild("background_options")->getChild("SliderSpeed"));
  float aux=slider->getCurrentValue();
  
  CEGUI::ToggleButton* cb = static_cast<CEGUI::ToggleButton*>(static_cast<const CEGUI::WindowEventArgs&>(e).window->getRootWindow()->getChild("background_options")->getChild("CBAutoReload"));

  ofstream archivo;  // objeto de la clase ofstream
  archivo.open("data/Config.txt");
  archivo<<"MouseSpeed = "+Ogre::StringConverter::toString((int)aux)<< endl;
  archivo<<"AutoReaload = "+Ogre::StringConverter::toString(cb->isSelected())<< endl;
  archivo.close();

  //Cambio de resolucion-----------
  if(_fullscreen){
    _root->getAutoCreatedWindow()->resize(1920,1200);
    renderer->setDisplaySize(CEGUI::Sizef(1920,1200));
    _root->getAutoCreatedWindow()->setFullscreen(true,1920,1200);
  }else{
    _root->getAutoCreatedWindow()->resize(_resWidth,_resHeigt);
    renderer->setDisplaySize(CEGUI::Sizef(_resWidth,_resHeigt));
    _root->getAutoCreatedWindow()->setFullscreen(false,_resWidth,_resHeigt);
  }
  
  //-------------------------------
  return true;
}
Exemplo n.º 2
0
bool 
IntroState::onSliderValueChanged(const CEGUI::EventArgs &e){

  CEGUI::Slider* slider = static_cast<CEGUI::Slider*>(static_cast<const CEGUI::WindowEventArgs&>(e).window->getRootWindow()->getChild("background_options")->getChild("SliderSpeed"));
  float aux=slider->getCurrentValue();
  CEGUI::Window* sbText =static_cast<CEGUI::Slider*>(static_cast<const CEGUI::WindowEventArgs&>(e).window->getRootWindow()->getChild("background_options")->getChild("textSliderSpeed"));
  if(aux<5.0){
    aux=5.0;
  }
  sbText->setText("[font='DickVanDyke']"+Ogre::StringConverter::toString( (int)aux ));
  return true;
}
void luaPopulateSettings(CEGUI::Window* settingsWindow)
{
    CEGUI::Slider* slider;

    slider = (CEGUI::Slider*)settingsWindow->getChildRecursive("Settings/Main/Volume");
    int soundvol = getvar("soundvol");
    slider->setCurrentValue(float(soundvol)/255);

    slider = (CEGUI::Slider*)settingsWindow->getChildRecursive("Settings/Main/MusicVolume");
    int musicvol = getvar("musicvol");
    slider->setCurrentValue(float(musicvol)/255);

//printf("luaPopulateSettings: %d,%d\r\n", soundvol, musicvol);
}
Exemplo n.º 4
0
  void SettingSlider::initialiseComponents()
  {
    CEGUI::Slider* slider = getSliderW();

    // Hack, Init max value because else the
    // sliderthumb doesn't get positioned correctly later.
    slider->setMaxValue(100000.0f);

    // internal event wiring
    slider->subscribeEvent(CEGUI::Slider::EventValueChanged, CEGUI::Event::Subscriber(&SettingSlider::onSliderChanged, this));

    // put components in their initial positions
    performChildWindowLayout();
  }
void luaApplySoundSettings(CEGUI::Window* settingsWindow)
{
    CEGUI::Slider* slider;
    std::string command;

    slider = (CEGUI::Slider*)settingsWindow->getChildRecursive("Settings/Main/Volume");
    int soundvol = int(slider->getCurrentValue()*255);
    command = "soundvol " + Utility::toString(soundvol);
    execute(command.c_str());

    slider = (CEGUI::Slider*)settingsWindow->getChildRecursive("Settings/Main/MusicVolume");
    int musicvol = int(slider->getCurrentValue()*255);
    command = "musicvol " + Utility::toString(musicvol);
    execute(command.c_str());

//printf("luaApplySoundSettings: %d,%d\r\n", soundvol, musicvol);
}
Exemplo n.º 6
0
bool OgreSample13App::handleSliders(const CEGUI::EventArgs & args)
{
	CEGUI::Slider * cb = static_cast<CEGUI::Slider *>(static_cast<const CEGUI::WindowEventArgs&>(args).window);
	if (cb->getName() == CEGUI::String("OgreSample13/slider1"))
	{
		destroyCurrentGeomOpt();
		mNumMeshes = cb->getCurrentValue() * 1000.0f;
		CEGUI::WindowManager::getSingleton().getWindow("OgreSample13/num1")->setText(CEGUI::PropertyHelper::intToString(mNumMeshes));
		createCurrentGeomOpt();
	}
	else
	{
		mBurnAmount = cb->getCurrentValue() * 16.67;
		CEGUI::WindowManager::getSingleton().getWindow("OgreSample13/num2")->setText(CEGUI::PropertyHelper::floatToString(mBurnAmount));
	}

	return true;
}
Exemplo n.º 7
0
  bool SettingSlider::onSliderChanged(const CEGUI::EventArgs& e)
  {
    CEGUI::Slider* slider = getSliderW();
    float val = slider->getCurrentValue();
    val = ScaleMinMax(val, getMinimumValue(), slider->getMaxValue());
    CEGUI::Window* value = getValueW();   

    for (size_t i = 0; i < settings.GetSize(); i++)
    {
      csRef<Setting> setting = settings.Get(i);
      if (setting->IsValid())
      {
        setting->SetFromOther(val);
        value->setText(setting->GetAsString());
      }
    }

    return true;
  }
Exemplo n.º 8
0
bool
IntroState::options(const CEGUI::EventArgs &e)
{
  CEGUI::Window* sheet=CEGUI::System::getSingleton().getDefaultGUIContext().getRootWindow();
  _credits=false;
  _options=true;
  _info=false;

  //Sheet Records
  Window* sheetBG =  WindowManager::getSingleton().createWindow("TaharezLook/StaticImage","background_options");
  sheetBG->setPosition( UVector2(cegui_reldim(0),cegui_reldim(0)));
  sheetBG->setSize( USize(cegui_reldim(1),cegui_reldim(1)));
  sheetBG->setProperty("Image","BackgroundImageOptions");
  sheetBG->setProperty("FrameEnabled","False");
  sheetBG->setProperty("BackgroundEnabled", "False");

  CEGUI::Window* backButton = CEGUI::WindowManager::getSingleton().createWindow("OgreTray/Button","back");
  backButton->setText("[font='DickVanDyke'] Back ");
  backButton->setSize(CEGUI::USize(CEGUI::UDim(0.23,0),CEGUI::UDim(0.07,0)));
  backButton->setXPosition(UDim(0.66f, 0.0f));
  backButton->setYPosition(UDim(0.85f, 0.0f));
  backButton->subscribeEvent(CEGUI::PushButton::EventClicked,CEGUI::Event::Subscriber(&IntroState::back,this));
  
  CEGUI::Window* applyButton = CEGUI::WindowManager::getSingleton().createWindow("OgreTray/Button","apply");
  applyButton->setText("[font='DickVanDyke'] apply ");
  applyButton->setSize(CEGUI::USize(CEGUI::UDim(0.23,0),CEGUI::UDim(0.07,0)));
  applyButton->setXPosition(UDim(0.66f, 0.0f));
  applyButton->setYPosition(UDim(0.77f, 0.0f));
  applyButton->subscribeEvent(CEGUI::PushButton::EventClicked,CEGUI::Event::Subscriber(&IntroState::apply,this));

  CEGUI::Window* text = CEGUI::WindowManager::getSingleton().createWindow("TaharezLook/StaticText","text");
  text->setText("[font='DickVanDyke'] Mouse Speed");
  text->setSize(CEGUI::USize(CEGUI::UDim(0.15,0),CEGUI::UDim(0.1,0)));
  text->setPosition(CEGUI::UVector2(CEGUI::UDim(0.12,0),CEGUI::UDim(0.32,0)));
  text->setProperty("FrameEnabled","False");
  text->setProperty("BackgroundEnabled", "False");
  text->setProperty("HorzFormatting", "RightAligned");

  CEGUI::Slider* sb = static_cast<CEGUI::Slider*> (CEGUI::WindowManager::getSingleton().createWindow("OgreTray/Slider","SliderSpeed"));
  sb->setPosition(CEGUI::UVector2(CEGUI::UDim(0.15,0),CEGUI::UDim(0.4,0)));
  sb->setMaxValue(40.0f);
  sb->setClickStep(1.0f);
  sb->setCurrentValue(20.0f); 
  sb->subscribeEvent(Slider::EventValueChanged, Event::Subscriber(&IntroState::onSliderValueChanged, this));

  CEGUI::Window* sbText = CEGUI::WindowManager::getSingleton().createWindow("TaharezLook/StaticText","textSliderSpeed");
  sbText->setText("[font='DickVanDyke']20");
  sbText->setSize(CEGUI::USize(CEGUI::UDim(0.05,0),CEGUI::UDim(0.08,0)));
  sbText->setPosition(CEGUI::UVector2(CEGUI::UDim(0.36,0),CEGUI::UDim(0.38,0)));
  sbText->setProperty("FrameEnabled","False");
  sbText->setProperty("BackgroundEnabled", "False");
  sbText->setProperty("HorzFormatting", "RightAligned");

  CEGUI::Window* text2 = CEGUI::WindowManager::getSingleton().createWindow("TaharezLook/StaticText","text2");
  text2->setText("[font='DickVanDyke'] Auto-Reload Arrows");
  text2->setSize(CEGUI::USize(CEGUI::UDim(0.25,0),CEGUI::UDim(0.06,0)));
  text2->setPosition(CEGUI::UVector2(CEGUI::UDim(0.15,0),CEGUI::UDim(0.46,0)));
  text2->setProperty("FrameEnabled","False");
  text2->setProperty("BackgroundEnabled", "False");
  text2->setProperty("HorzFormatting", "LeftAligned");

  CEGUI::ToggleButton* cb = static_cast<CEGUI::ToggleButton*> (CEGUI::WindowManager::getSingleton().createWindow("OgreTray/Checkbox","CBAutoReload"));
  cb->setPosition(CEGUI::UVector2(CEGUI::UDim(0.08,0),CEGUI::UDim(0.52,0)));

  CEGUI::Window* resetButton = CEGUI::WindowManager::getSingleton().createWindow("OgreTray/Button","resetButton");
  resetButton->setText("[font='DickVanDyke'] Reset Records ");
  resetButton->setSize(CEGUI::USize(CEGUI::UDim(0.23,0),CEGUI::UDim(0.07,0)));
  resetButton->setXPosition(UDim(0.40f, 0.0f));
  resetButton->setYPosition(UDim(0.85f, 0.0f));
  resetButton->subscribeEvent(CEGUI::PushButton::EventClicked,CEGUI::Event::Subscriber(&IntroState::resetRecords,this));

  CEGUI::Window* configButton = CEGUI::WindowManager::getSingleton().createWindow("OgreTray/Button","configButton");
  configButton->setText("[font='DickVanDyke'] Restore Config ");
  configButton->setSize(CEGUI::USize(CEGUI::UDim(0.23,0),CEGUI::UDim(0.07,0)));
  configButton->setXPosition(UDim(0.40f, 0.0f));
  configButton->setYPosition(UDim(0.77f, 0.0f));
  configButton->subscribeEvent(CEGUI::PushButton::EventClicked,CEGUI::Event::Subscriber(&IntroState::resetConfig,this));

  CEGUI::Window* text3 = CEGUI::WindowManager::getSingleton().createWindow("TaharezLook/StaticText","FullscreenText");
  text3->setText("[font='DickVanDyke'] Fullscreen");
  text3->setSize(CEGUI::USize(CEGUI::UDim(0.25,0),CEGUI::UDim(0.06,0)));
  text3->setPosition(CEGUI::UVector2(CEGUI::UDim(0.15,0),CEGUI::UDim(0.57,0)));
  text3->setProperty("FrameEnabled","False");
  text3->setProperty("BackgroundEnabled", "False");
  text3->setProperty("HorzFormatting", "LeftAligned");

  CEGUI::ToggleButton* cbFullscreen = static_cast<CEGUI::ToggleButton*> (CEGUI::WindowManager::getSingleton().createWindow("OgreTray/Checkbox","CBFullscreen"));
  cbFullscreen->setPosition(CEGUI::UVector2(CEGUI::UDim(0.08,0),CEGUI::UDim(0.62,0)));
  cbFullscreen->subscribeEvent(CEGUI::ToggleButton::EventSelectStateChanged,CEGUI::Event::Subscriber(&IntroState::tbFullscreenChanged,this));

  CEGUI::Window* text4 = CEGUI::WindowManager::getSingleton().createWindow("TaharezLook/StaticText","ResolutionText");
  text4->setText("[font='DickVanDyke'] Resolution");
  text4->setSize(CEGUI::USize(CEGUI::UDim(0.25,0),CEGUI::UDim(0.06,0)));
  text4->setPosition(CEGUI::UVector2(CEGUI::UDim(0.5,0),CEGUI::UDim(0.35,0)));
  text4->setProperty("FrameEnabled","False");
  text4->setProperty("BackgroundEnabled", "False");
  text4->setProperty("HorzFormatting", "LeftAligned");

  


  CEGUI::Listbox* lbRes = static_cast<CEGUI::Listbox*> (CEGUI::WindowManager::getSingleton().createWindow("OgreTray/Listbox","lbRes"));
  lbRes->setSize(CEGUI::USize(CEGUI::UDim(0.3,0),CEGUI::UDim(0.3,0)));
  lbRes->setPosition(CEGUI::UVector2(CEGUI::UDim(0.5, 0),CEGUI::UDim(0.40, 0)));
  lbRes->subscribeEvent(Listbox::EventSelectionChanged,CEGUI::Event::Subscriber(&IntroState::changeResolution,this));
  
  const CEGUI::Image* sel_img = &CEGUI::ImageManager::getSingleton().get("TaharezLook/MultiListSelectionBrush");
  
  CEGUI::ListboxTextItem* itm;
  itm = new CEGUI::ListboxTextItem("800x600",0);
  itm->setFont("DickVanDyke-28");
  itm->setTextColours(CEGUI::Colour(0.0,0.8,0.5));
  itm->setSelectionBrushImage(sel_img);
  lbRes->addItem(itm);
  
  CEGUI::ListboxTextItem* itm2;
  itm2 = new CEGUI::ListboxTextItem("1200x800",1);
  itm2->setFont("DickVanDyke-28");
  itm2->setTextColours(CEGUI::Colour(0.0,0.8,0.5));
  itm2->setSelectionBrushImage(sel_img);
  lbRes->addItem(itm2);

  CEGUI::ListboxTextItem* itm3;
  itm3 = new CEGUI::ListboxTextItem("1920x1020",2);
  itm3->setFont("DickVanDyke-28");
  itm3->setTextColours(CEGUI::Colour(0.0,0.8,0.5));
  itm3->setSelectionBrushImage(sel_img);
  lbRes->addItem(itm3);
    
  

  sheetBG->addChild(text4);
  sheetBG->addChild(lbRes);
  sheetBG->addChild(cb);
  sheetBG->addChild(text2);
  sheetBG->addChild(cbFullscreen);
  sheetBG->addChild(text3);
  sheetBG->addChild(sbText);
  sheetBG->addChild(sb);
  sheetBG->addChild(applyButton);
  sheetBG->addChild(backButton);
  sheetBG->addChild(resetButton);
  sheetBG->addChild(configButton);
  sheetBG->addChild(text);
  sheet->addChild(sheetBG);
    

  if(_fullscreen){
    cbFullscreen->setSelected(true);
  }else{
    cbFullscreen->setSelected(false);
  }

  return true;
}