void OptionsDialog::_buildFrameNetwork()
{
	Input* i;
	Checkbox* c;
	int y = 0;
	
	mFrameNetwork->mSortable = false;

/*
	new Label(mFrameNetwork, "", rect(0,y), "Reconnect");
	i = new Input(mFrameNetwork, "reconnect", rect(95, y, 150, 20), "0123456789", 0, true, NULL);
		i->SetText( "0" ); //game->mConfig.GetParamString("connection", "delay") );
		i->mHoverText = "Delay (in minutes) between reconnect attempts. 0 to disable.";
	y += 25;
*/
	
	c = new Checkbox(mFrameNetwork, "joinparts", rect(0,y), "Show Joins/Parts", 0);
		c->SetState( game->mShowJoinParts );
	y += 25;
	
	c = new Checkbox(mFrameNetwork, "addr", rect(0,y), "Show Addresses In Joins/Parts", 0);
		c->SetState( game->mShowAddresses );
	y += 25;
	
	c = new Checkbox(mFrameNetwork, "privmsg", rect(0,y), "Accept Private Messages", 0);
		c->SetState( sti(game->mUserData.GetValue("MapSettings", "PrivMsg")) );
	y += 25;

}
Exemple #2
0
void CEGUICheckbox::Init (const string& widgetName)
{
    ScrollWidget::Init(widgetName);

    const string& windowName = m_manager->GetWindowName ();
    // Get the root window
    Window *rootWindow = CEGUI::System::getSingleton().getGUISheet();
    // Get the parent window. No point in searching all windows.
    Window *window = rootWindow->getChild(windowName);
    // Get recursively the widget, this will handle tabs.
    Window *widget = window->getChildRecursive(widgetName);
    orxASSERT(widget != NULL);

    /*
     * Static cast is now safe as it is guarded by assert. This will be active
     * only in debug build so -fno-rtti can be used for release build
     */
    orxASSERT( typeid(*widget) == typeid(CEGUI::Checkbox) );
    Checkbox *checkbox = static_cast<Checkbox *> (widget);

    // Subscribe to check state change event
    checkbox->subscribeEvent (Checkbox::EventCheckStateChanged,
	Event::Subscriber (&CEGUICheckbox::OnCheckStateChanged, this));

    //! @todo Handle mouse events

    m_ceCheckbox = checkbox;
}
Exemple #3
0
/** \brief Test if a checkbox is checked.
 *  \returns true if the Checkbox is checked.
 */
int UI_Lua::IsChecked(lua_State *L){
	int n = lua_gettop(L);  // Number of arguments
	if (n != 1)
		return luaL_error(L, "Got %d arguments expected 1 (self)", n);

	Checkbox *box = (Checkbox*)checkWidget(L,1);
	luaL_argcheck(L, box->GetMask() & WIDGET_CHECKBOX, 1, "`Checkbox' expected.");

	lua_pushboolean(L, (int) box->IsChecked() );

	return 1;
}
Exemple #4
0
/** \brief Check or Uncheck a checkbox
 */
int UI_Lua::setChecked(lua_State *L){
	int n = lua_gettop(L);  // Number of arguments
	if (n != 2)
		return luaL_error(L, "Got %d arguments expected 2 (self, value)", n);

	Checkbox *box = (Checkbox*)checkWidget(L,1);
	luaL_argcheck(L, box->GetMask() & WIDGET_CHECKBOX, 1, "`Checkbox' expected.");

	bool checked = lua_toboolean(L, 2) != 0;

	box->Set(checked);

	return 0;
}
void OptionsDialog::_buildFrameAudio()
{
#ifdef _SOUNDMANAGER_H_
	Scrollbar* sc;
	Checkbox* c;
	int y = 0;
	
	mFrameAudio->mSortable = false;
	
	new Label(mFrameAudio, "", rect(0,y), "Volume");
	sc = new Scrollbar(mFrameAudio, "vol", rect(95, y, 150, 20), HORIZONTAL, MAX_VOLUME, 10, 0, NULL);
		sc->SetValue( config.GetParamInt("sound", "volume") );
	y += 25;
	
	c = new Checkbox(mFrameAudio, "", rect(0,y), "Enable Voice Chat", 0);
		c->SetState( 0 );
		c->mHoverText = "Haha, you wish";
	y += 25;
#endif
}
Exemple #6
0
bool GuiConfig::HandleConfigOK(const CEGUI::EventArgs& e)
{
	Editbox* playerName = static_cast<Editbox*>(winMgr.getWindow("CONFIGPLAYERNAME"));
/*
	if (_stricmp(GConfig->GetPlayerName(), playerName->getText().c_str()))
	{
		if (GClientGame)
		{
			GClientGame->SendMessageNick(playerName->getText().c_str());
		}

	}
	*/
	bool bScreenConfigHasChanged = false;

	{
		Checkbox *pcb = (Checkbox*)winMgr.getWindow("CHKBFS");
		bScreenConfigHasChanged |= GConfig->IsEnable("CHKBFS") != pcb->isSelected();
		GConfig->SetEnable("CHKBFS", (int)pcb->isSelected() );
	}
	{
		Checkbox *pcb = (Checkbox*)winMgr.getWindow("CHKBVSYNC");
		bScreenConfigHasChanged |= GConfig->IsEnable("CHKBVSYNC") != pcb->isSelected();
		GConfig->SetEnable("CHKBVSYNC", (int)pcb->isSelected() );
	}


	GConfig->SetPlayerName(playerName->getText().c_str());


	// Resolution
	Combobox* resCB = static_cast<Combobox*>(winMgr.getWindow("RESOLUTION"));
	ListboxItem *resib = resCB->getSelectedItem();
	if (resib)
	{
		int selres = resCB->getItemIndex(resib);

		bScreenConfigHasChanged |= (GConfig->GetQuality("Width") != mResolutions[selres].width);
		bScreenConfigHasChanged |= (GConfig->GetQuality("Height") != mResolutions[selres].height);

		GConfig->SetQuality("Width", mResolutions[selres].width);
		GConfig->SetQuality("Height", mResolutions[selres].height);
	}


	if (bScreenConfigHasChanged)
	{
		tstring onoksschanged = ".00 ";
		onoksschanged += GLoc->GetString("OK");
		((ZProtoGUI*)GProtoGui)->mMessageboxGui.Show(GLoc->GetString("SCREENCHANGED"), onoksschanged.c_str(), mOnOK);

		Hide();
	}
	else
	{
		mOnOK();
		Hide();
	}
	return true;
}
void OptionsDialog::_buildFrameGraphics()
{
	Input* i;
	Checkbox* c;
	int y = 0;

	mFrameGraphics->mSortable = false;
	
	new Label(mFrameGraphics, "", rect(0,y), "FPS Cap");
	i = new Input(mFrameGraphics, "fps", rect(95, y, 150, 20), "0123456789", 0, true, NULL);
		i->SetText( its(gui->mFpsCap) );
	y += 25;

	c = new Checkbox(mFrameGraphics, "lowcpu", rect(0,y), "Use Lower Cpu When Inactive", 0);
		c->SetState( gui->mUseLowCpu );
	y += 25;
		
	c = new Checkbox(mFrameGraphics, "nolimit", rect(0,y), "Max Speed (Not Recommended)", 0);
		c->SetState( gui->mNoFpsLimit );
		c->mHoverText = "Seriously, this is a 2D chat room. Why have 4000 FPS?";
	y += 25;	
}
void OptionsDialog::_buildFrameUser()
{
	Input* i;
	SmallSelect* ss;
	Checkbox* c;
	int y = 0;

	mFrameUser->mSortable = false;

	new Label(mFrameUser, "", rect(0,y), "Nickname");
	i = new Input(mFrameUser, "nick", rect(95, y, 150, 20), 
					"0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ\\_-^`[]{}|", 
					32, true, NULL);
		i->SetText( game->mPlayer->GetName() );
	y += 25;
	
	new Label(mFrameUser, "", rect(0,y), "Alerts");
	ss = new SmallSelect(mFrameUser, "alerts", rect(95, y, 150, 20), NULL);
		ss->AddItem("Off");
		ss->AddItem("Always");
		ss->AddItem("Only When Inactive");
		ss->mSelectedIndex = gui->mSystemAlertType;
		ss->mHoverText = "Controls when to flash the title bar for a new message";
	y += 25;
	
/*	c = new Checkbox(mFrameUser, "names", rect(0,y), "Show Player Names", 0);
		c->SetState( game->mPlayerData.GetParamInt("map", "shownames") );
	y += 25;
		
	c = new Checkbox(mFrameUser, "trading", rect(0,y), "Allow Trade Requests", 0);
		c->SetState( game->mPlayerData.GetParamInt("map", "trading") );
	y += 25;
*/

	c = new Checkbox(mFrameUser, "stamps", rect(0,y), "Show Timestamps", 0);
		c->SetState( sti(game->mUserData.GetValue("MapSettings", "Timestamps")) );
	y += 25;
}
Exemple #9
0
void DemoState::createAnimationWindow() {
	detachChild("animationWindow");

	Window* animWindow = new Window("animationWindow", Vector2(-500, 2), Vector2(368, 358), "images/WINDOW.tga");
	animWindow->setResizable(true);

	// Attaching the subtitle as a child of title gives weird results... strange
	animWindow->attachChild(new Label("aw_Title", "Animation", 14, Vector2(15, 165)));
	animWindow->attachChild(new Label("aw_Subtitle", "Configure the DOOM guy!", 9, Vector2(15, 150)));

	GUIImage* transArea = new GUIImage("transArea", "images/SCROLL_AREA.tga", Vector2(148, 148));
	transArea->setLocalTranslation(Vector2(110, 100));
	animWindow->attachChild(transArea);

	// Create the Doom guy amimation
	doomGuy = new Animation("DOOMGUY!", "demo/doomguy.tga", 64, new int[6]{ 3, 3, 3, 3, 3, 6 });
	doomGuy->setLocalTranslation(Vector2(10, 10));
	doomGuy->resize(128.0f, 128.0f);
	doomGuy->setUnordered(true);
	transArea->attachChild(doomGuy);

	// Unordered checkbox
	Checkbox* checkUnordered = new Checkbox("animation_checkUnordered", Vector2(60, 40), true, TICK);
	checkUnordered->setToolTip("If ticked, the animation plays in a random order.");
	checkUnordered->attachChild(new Label("unordered_label", "Unordered", 10, Vector2(15, 9)));
	animWindow->attachChild(checkUnordered);

	// Looping checkbox
	Checkbox* checkLooping = new Checkbox("animation_checkLoops", Vector2(60, 70), true, CROSS);
	checkUnordered->setToolTip("If ticked, plays in a random order.");
	checkLooping->attachChild(new Label("loop_label", "Loops", 10, Vector2(15, 9)));
	animWindow->attachChild(checkLooping);

	// Animation slider
	Slider* animationSlider = new Slider("animSlider", Vector2(180, 130), 230, VERTICAL);
	animationSlider->setStepCount(5);
	animWindow->attachChild(animationSlider);

	// Speed slider
	Slider* animationSpeedSlider = new Slider("animSpeed", Vector2(215, 130), 230, VERTICAL);
	animationSpeedSlider->setIndex(50); // 500ms by default
	animWindow->attachChild(animationSpeedSlider);

	// Attach the window
	attachChild(animWindow);
}
Exemple #10
0
void CreateSetting()
{
	renderScene = eScene::SETTING;

	GUIManager& guiManager = GUIManager::instance();
	guiManager.init();
	guiManager.getRootControl()->setEventListener( &listener );

	Checkbox* cbGore = new Checkbox();
	cbGore->init( "gore", Vector2( 50.f, 50.f ), "data/gui/CheckBox_disabled.png", "data/gui/CheckBox_enabled.png", "", font, "Modo gore" );
	cbGore->setEventListener( &listener );
	cbGore->setParent( guiManager.getRootControl() );

	Checkbox* cbParticles = new Checkbox();
	cbParticles->init( "particles", Vector2( 50.f, 150.f ), "data/gui/CheckBox_disabled.png", "data/gui/CheckBox_enabled.png", "", font, "Particulas" );
	cbParticles->setEventListener( &listener );
	cbParticles->setParent( guiManager.getRootControl() );

	Checkbox* cbAutoSave = new Checkbox();
	cbAutoSave->init( "autosave", Vector2( 50.f, 250.f ), "data/gui/CheckBox_disabled.png", "data/gui/CheckBox_enabled.png", "", font, "Auto guardado" );
	cbAutoSave->setEventListener( &listener );
	cbAutoSave->setParent( guiManager.getRootControl() );

	Slider* slVolume = new Slider();
	slVolume->init( "volume", Vector2( 50.f, 350.f ), "data/gui/Slider_bar.png", "data/gui/Slider_ball.png", 0, 100.0, 1.0 );
	slVolume->setEventListener( &listener );
	slVolume->setParent( guiManager.getRootControl() );
}
Exemple #11
0
/*************************************************************************
    Sample specific initialisation goes here.
*************************************************************************/
bool Demo4Sample::initialiseSample()
{
    using namespace CEGUI;

    // we will make extensive use of the WindowManager.
    WindowManager& winMgr = WindowManager::getSingleton();

    // load scheme and set up defaults
    SchemeManager::getSingleton().loadScheme("TaharezLook.scheme");
    System::getSingleton().setDefaultMouseCursor("TaharezLook", "MouseArrow");
    //FontManager::getSingleton().createFont("Commonwealth-10.font");

    // load an image to use as a background
    ImagesetManager::getSingleton().createImagesetFromImageFile("BackgroundImage", "GPN-2000-001437.tga");

    // here we will use a StaticImage as the root, then we can use it to place a background image
    Window* background = winMgr.createWindow("TaharezLook/StaticImage", "background_wnd");
    // set position and size
    background->setPosition(UVector2(cegui_reldim(0), cegui_reldim( 0)));
    background->setSize(UVector2(cegui_reldim(1), cegui_reldim( 1)));
    // disable frame and standard background
    background->setProperty("FrameEnabled", "false");
    background->setProperty("BackgroundEnabled", "false");
    // set the background image
    background->setProperty("Image", "set:BackgroundImage image:full_image");
    // install this as the root GUI sheet
    System::getSingleton().setGUISheet(background);

    // now we create a DefaultWindow which we will attach all the widgets to.  We could
    // have attached them to the background StaticImage, though we want to be a bit tricky
    // since we do not wish the background to be faded by the slider - so we create this
    // container window so we can affect all the other widgets, but leave the background
    // unchanged.
    Window* sheet = winMgr.createWindow("DefaultWindow", "root_wnd");
    // attach this to the 'real' root
    background->addChildWindow(sheet);

    //
    // widget initialisation
    //
    // quit button
    PushButton* btn = static_cast<PushButton*>(winMgr.createWindow("TaharezLook/Button", "QuitButton"));
    sheet->addChildWindow(btn);
    btn->setText("Quit!");
    btn->setPosition(UVector2(cegui_reldim(0.035f), cegui_reldim( 0.0f)));
    btn->setSize(UVector2(cegui_reldim(0.1f), cegui_reldim( 0.036f)));
    btn->subscribeEvent(PushButton::EventClicked, Event::Subscriber(&Demo4Sample::handleQuit, this));
    btn->setAlwaysOnTop(true);

    // Alpha-slider
    Slider* slider = static_cast<Slider*>(winMgr.createWindow("TaharezLook/Slider", "my slider"));
    sheet->addChildWindow(slider);
    slider->setPosition(UVector2(cegui_reldim(0.136f), cegui_reldim( 0.0f)));
    slider->setSize(UVector2(cegui_reldim(0.02f), cegui_reldim( 0.075f)));
    slider->setAlwaysOnTop(true);
    // here we disable inherited alpha so that we will always be able to see the slider
    slider->setInheritsAlpha(false);
    // set up slider config
    slider->setCurrentValue(1.0f);
    slider->setClickStep(0.1f);
    // subscribe handler that will process slider position changes.
    slider->subscribeEvent(Slider::EventValueChanged, &sliderHandler);

    // big scroll bar
    Scrollbar* vscb = static_cast<Scrollbar*>(winMgr.createWindow("TaharezLook/LargeVerticalScrollbar", "Vert Scroll 1"));
    sheet->addChildWindow(vscb);
    vscb->setPosition(UVector2(cegui_reldim(0.0f), cegui_reldim( 0.0f)));
    vscb->setMinSize(UVector2(cegui_reldim(0.01f), cegui_reldim( 0.01f)));
    vscb->setMaxSize(UVector2(cegui_reldim(1.0f), cegui_reldim( 1.0f)));
    vscb->setSize(UVector2(cegui_reldim(0.035f), cegui_reldim( 0.83f)));
    vscb->setDocumentSize(100);
    vscb->setPageSize(5);
    vscb->setStepSize(1);
    vscb->setAlwaysOnTop(true);

    // mini vert scroll bar
    Scrollbar* mvsb = static_cast<Scrollbar*>(winMgr.createWindow("TaharezLook/VerticalScrollbar", "MiniVertScroll 1"));
    sheet->addChildWindow(mvsb);
    mvsb->setPosition(UVector2(cegui_reldim(0.99f), cegui_reldim( 0.015f)));
    mvsb->setMinSize(UVector2(cegui_reldim(0.01f), cegui_reldim( 0.01f)));
    mvsb->setMaxSize(UVector2(cegui_reldim(1.0f), cegui_reldim( 1.0f)));
    mvsb->setSize(UVector2(cegui_reldim(0.01f), cegui_reldim( 0.5f)));
    mvsb->setDocumentSize(360);
    mvsb->setPageSize(45);
    mvsb->setStepSize(1);
    mvsb->setAlwaysOnTop(true);

    // mini horz scroll bar
    Scrollbar* mhsb = static_cast<Scrollbar*>(winMgr.createWindow("TaharezLook/HorizontalScrollbar", "MiniHorzScroll 1"));
    sheet->addChildWindow(mhsb);
    mhsb->setPosition(UVector2(cegui_reldim(0.485f), cegui_reldim( 0.0f)));
    mhsb->setMinSize(UVector2(cegui_reldim(0.01f), cegui_reldim( 0.01f)));
    mhsb->setMaxSize(UVector2(cegui_reldim(1.0f), cegui_reldim( 1.0f)));
    mhsb->setSize(UVector2(cegui_reldim(0.5f), cegui_reldim( 0.015f)));
    mhsb->setDocumentSize(360);
    mhsb->setPageSize(45);
    mhsb->setStepSize(1);
    mhsb->setAlwaysOnTop(true);

    //
    // Build a window with some text and formatting options via radio buttons etc
    //
    FrameWindow* textwnd = static_cast<FrameWindow*>(winMgr.createWindow("TaharezLook/FrameWindow", "TextWindow"));
    sheet->addChildWindow(textwnd);
    textwnd->setPosition(UVector2(cegui_reldim(0.2f), cegui_reldim( 0.2f)));
    textwnd->setMaxSize(UVector2(cegui_reldim(0.75f), cegui_reldim( 0.75f)));
    textwnd->setMinSize(UVector2(cegui_reldim(0.1f), cegui_reldim( 0.1f)));
    textwnd->setSize(UVector2(cegui_reldim(0.5f), cegui_reldim( 0.5f)));
    textwnd->setCloseButtonEnabled(false);
    textwnd->setText("Crazy Eddie's GUI - Demo 4");

    Window* st = winMgr.createWindow("TaharezLook/StaticText", "TextWindow/Static");
    textwnd->addChildWindow(st);
    st->setPosition(UVector2(cegui_reldim(0.1f), cegui_reldim( 0.22f)));
    st->setSize(UVector2(cegui_reldim(0.5f), cegui_reldim( 0.6f)));

    st = winMgr.createWindow("TaharezLook/StaticText", "TextWindow/Group label 1");
    textwnd->addChildWindow(st);
    st->setPosition(UVector2(cegui_reldim(0.65f), cegui_reldim( 0.23f)));
    st->setSize(UVector2(cegui_reldim(0.35f), cegui_reldim( 0.05f)));
    st->setText("Horz. Formatting");
    // disable frame and background on static control
    st->setProperty("FrameEnabled", "false");
    st->setProperty("BackgroundEnabled", "false");

    st = winMgr.createWindow("TaharezLook/StaticText", "TextWindow/Group label 2");
    textwnd->addChildWindow(st);
    st->setPosition(UVector2(cegui_reldim(0.65f), cegui_reldim( 0.53f)));
    st->setSize(UVector2(cegui_reldim(0.35f), cegui_reldim( 0.05f)));
    st->setText("Vert. Formatting");
    // disable frame and background on static control
    st->setProperty("FrameEnabled", "false");
    st->setProperty("BackgroundEnabled", "false");

    st = winMgr.createWindow("TaharezLook/StaticText", "TextWindow/Box label");
    textwnd->addChildWindow(st);
    st->setPosition(UVector2(cegui_reldim(0.12f), cegui_reldim( 0.15f)));
    st->setSize(UVector2(cegui_reldim(0.35f), cegui_reldim( 0.05f)));
    st->setText("Formatted Output");
    // disable frame and background on static control
    st->setProperty("FrameEnabled", "false");
    st->setProperty("BackgroundEnabled", "false");

	// groupbox
	st = winMgr.createWindow("TaharezLook/GroupBox", "TextWindow/GroupBox1");
	textwnd->addChildWindow(st);
	st->setPosition(UVector2(cegui_reldim(0.03f), cegui_reldim(0.08f)));
	st->setSize(UVector2(cegui_reldim(0.94f), cegui_reldim(0.90f)));
	st->setText("Text samples");

    // word-wrap checkbox
    Checkbox* cb = static_cast<Checkbox*>(winMgr.createWindow("TaharezLook/Checkbox", "TextWindow/CB1"));
    textwnd->addChildWindow(cb);
    cb->setPosition(UVector2(cegui_reldim(0.65f), cegui_reldim( 0.13f)));
    cb->setSize(UVector2(cegui_reldim(0.35f), cegui_reldim( 0.05f)));
    cb->setText("Word Wrap");
    // subscribe a handler to listen for when the check-box button select state changes
    cb->subscribeEvent(Checkbox::EventCheckStateChanged, &formatChangedHandler);

    // horizontal formatting radio group
    RadioButton* rb = static_cast<RadioButton*>(winMgr.createWindow("TaharezLook/RadioButton", "TextWindow/RB1"));
    textwnd->addChildWindow(rb);
    rb->setPosition(UVector2(cegui_reldim(0.65f), cegui_reldim( 0.3f)));
    rb->setSize(UVector2(cegui_reldim(0.35f), cegui_reldim( 0.05f)));
    rb->setGroupID(1);
    rb->setText("Left Aligned");
    // subscribe a handler to listen for when the radio button select state changes
    rb->subscribeEvent(RadioButton::EventSelectStateChanged, &formatChangedHandler);

    rb = static_cast<RadioButton*>(winMgr.createWindow("TaharezLook/RadioButton", "TextWindow/RB2"));
    textwnd->addChildWindow(rb);
    rb->setPosition(UVector2(cegui_reldim(0.65f), cegui_reldim( 0.35f)));
    rb->setSize(UVector2(cegui_reldim(0.35f), cegui_reldim( 0.05f)));
    rb->setGroupID(1);
    rb->setText("Right Aligned");
    // subscribe a handler to listen for when the radio button select state changes
    rb->subscribeEvent(RadioButton::EventSelectStateChanged, &formatChangedHandler);

    rb = static_cast<RadioButton*>(winMgr.createWindow("TaharezLook/RadioButton", "TextWindow/RB3"));
    textwnd->addChildWindow(rb);
    rb->setPosition(UVector2(cegui_reldim(0.65f), cegui_reldim( 0.4f)));
    rb->setSize(UVector2(cegui_reldim(0.35f), cegui_reldim( 0.05f)));
    rb->setGroupID(1);
    rb->setText("Centred");
    // subscribe a handler to listen for when the radio button select state changes
    rb->subscribeEvent(RadioButton::EventSelectStateChanged, &formatChangedHandler);

    // vertical formatting radio group
    rb = static_cast<RadioButton*>(winMgr.createWindow("TaharezLook/RadioButton", "TextWindow/RB4"));
    textwnd->addChildWindow(rb);
    rb->setPosition(UVector2(cegui_reldim(0.65f), cegui_reldim( 0.6f)));
    rb->setSize(UVector2(cegui_reldim(0.35f), cegui_reldim( 0.05f)));
    rb->setGroupID(2);
    rb->setText("Top Aligned");
    // subscribe a handler to listen for when the radio button select state changes
    rb->subscribeEvent(RadioButton::EventSelectStateChanged, &formatChangedHandler);

    rb = static_cast<RadioButton*>(winMgr.createWindow("TaharezLook/RadioButton", "TextWindow/RB5"));
    textwnd->addChildWindow(rb);
    rb->setPosition(UVector2(cegui_reldim(0.65f), cegui_reldim( 0.65f)));
    rb->setSize(UVector2(cegui_reldim(0.35f), cegui_reldim( 0.05f)));
    rb->setGroupID(2);
    rb->setText("Bottom Aligned");
    // subscribe a handler to listen for when the radio button select state changes
    rb->subscribeEvent(RadioButton::EventSelectStateChanged, &formatChangedHandler);

    rb = static_cast<RadioButton*>(winMgr.createWindow("TaharezLook/RadioButton", "TextWindow/RB6"));
    textwnd->addChildWindow(rb);
    rb->setPosition(UVector2(cegui_reldim(0.65f), cegui_reldim( 0.7f)));
    rb->setSize(UVector2(cegui_reldim(0.35f), cegui_reldim( 0.05f)));
    rb->setGroupID(2);
    rb->setText("Centred");
    // subscribe a handler to listen for when the radio button select state changes
    rb->subscribeEvent(RadioButton::EventSelectStateChanged, &formatChangedHandler);

    // Edit box for text entry
    Editbox* eb = static_cast<Editbox*>(winMgr.createWindow("TaharezLook/Editbox", "TextWindow/Editbox1"));
    textwnd->addChildWindow(eb);
    eb->setPosition(UVector2(cegui_reldim(0.05f), cegui_reldim( 0.85f)));
    eb->setMaxSize(UVector2(cegui_reldim(1.0f), cegui_reldim( 0.04f)));
    eb->setSize(UVector2(cegui_reldim(0.90f), cegui_reldim( 0.08f)));
    // subscribe a handler to listen for when the text changes
    eb->subscribeEvent(Window::EventTextChanged, &textChangedHandler);

    //
    // Controls are set up.  Install initial settings
    //
    static_cast<Checkbox*>(winMgr.getWindow("TextWindow/CB1"))->setSelected(true);
    static_cast<RadioButton*>(winMgr.getWindow("TextWindow/RB1"))->setSelected(true);
    static_cast<RadioButton*>(winMgr.getWindow("TextWindow/RB4"))->setSelected(true);
    winMgr.getWindow("TextWindow/Editbox1")->setText("Come on then, edit me!");

    // success!
    return true;
}
Exemple #12
0
bool GuiConfig::handleChkMusicChanged(const CEGUI::EventArgs& e)
{
	Checkbox *pcb = (Checkbox*)winMgr.getWindow("CHKMUSIC");
	GConfig->SetEnable("CHKMUSIC", (int)pcb->isSelected() );
	return true;
}
Exemple #13
0
void GuiConfig::Build(ZProtoGUI *pGUI)
{
	mGUI = (ZProtoGUI*)pGUI;
	root = mGUI->root;
	mFontArial8 = mGUI->mFontArial8;
	mFontArial24 = mGUI->mFontArial24;


	// Create a FrameWindow in the TaharezLook style, and name it 'Demo Window'
	mCondigWindow = (FrameWindow*)winMgr.createWindow("TaharezLook/FrameWindow", "Config Window");
	mCondigWindow->setTitleBarEnabled(false);
	mCondigWindow->setCloseButtonEnabled(false);
	mCondigWindow->setSizingEnabled(false);
	root->addChildWindow(mCondigWindow);
	mCondigWindow->setAlpha(0.6f);
	mCondigWindow ->hide();
	mCondigWindow->setSizingEnabled(false);


	FrameWindow* wnd1 = (FrameWindow*)winMgr.createWindow("TaharezLook/FrameWindow", "tabPage0");
	wnd1->setTitleBarEnabled(false);
	wnd1->setFrameEnabled(false);//>setTitleBarEnabled(false);
	wnd1->setCloseButtonEnabled(false);
	wnd1->setText(GLoc->GetString("PLAYER").c_str());


	FrameWindow* wnd2 = (FrameWindow*)winMgr.createWindow("TaharezLook/FrameWindow", "tabPage1");
	wnd2->setTitleBarEnabled(false);
	wnd2->setFrameEnabled(false);//>setTitleBarEnabled(false);
	wnd2->setCloseButtonEnabled(false);
	wnd2->setText(GLoc->GetString("Controls").c_str());


	FrameWindow* wnd3 = (FrameWindow*)winMgr.createWindow("TaharezLook/FrameWindow", "tabPage2");
	wnd3->setTitleBarEnabled(false);
	wnd3->setCloseButtonEnabled(false);
	wnd3->setText(GLoc->GetString("Graphics").c_str());
	wnd3->setFrameEnabled(false);//

	FrameWindow* wnd4 = (FrameWindow*)winMgr.createWindow("TaharezLook/FrameWindow", "tabPage3");
	wnd4->setTitleBarEnabled(false);
	wnd4->setFrameEnabled(false);//>setTitleBarEnabled(false);
	wnd4->setCloseButtonEnabled(false);
	wnd4->setText(GLoc->GetString("SOUND").c_str());
	//wnd->addChildWindow (winMgr.loadWindowLayout ("TabControlDemo.layout", "TabControlDemo/"));

	TabControl *tc = (TabControl *)winMgr.createWindow("TaharezLook/TabControl", "Config/Tabs");

	mCondigWindow->setPosition(UVector2(cegui_reldim(0.f), cegui_reldim( 0.f)));
	mCondigWindow->setSize(UVector2(cegui_reldim(1.f), cegui_reldim( 0.9f)));
	tc->setArea(UVector2(cegui_reldim(0.1f), cegui_reldim( 0.05f)), UVector2(cegui_reldim(0.9f), cegui_reldim( 0.85f)) );



	// Add some pages to tab control
	tc->addTab (wnd1);
	tc->addTab (wnd2);
	tc->addTab (wnd3);
	tc->addTab (wnd4);

	tc->setTabHeight(UDim (0.06f, 0.13f));
	tc->setTabTextPadding(UDim (0.06f, 0.1f));


	mCondigWindow->addChildWindow(tc);

	mCondigWindow->setPosition(UVector2(cegui_reldim(0), cegui_reldim( 0.15f)));
	mCondigWindow->setSize(UVector2(cegui_reldim(1.1f), cegui_reldim( 0.70f)));
	mCondigWindow->setAlpha(0.88f);


	wnd1->setPosition(UVector2(cegui_reldim(0.0f), cegui_reldim( 0.0f)));
	wnd1->setSize(UVector2(cegui_reldim(1.f), cegui_reldim( 1.f)));

	wnd2->setPosition(UVector2(cegui_reldim(0.0f), cegui_reldim( 0.0f)));
	wnd2->setSize(UVector2(cegui_reldim(1.f), cegui_reldim( 1.f)));

	wnd3->setPosition(UVector2(cegui_reldim(0.0f), cegui_reldim( 0.0f)));
	wnd3->setSize(UVector2(cegui_reldim(1.f), cegui_reldim( 1.f)));

	wnd4->setPosition(UVector2(cegui_reldim(0.0f), cegui_reldim( 0.0f)));
	wnd4->setSize(UVector2(cegui_reldim(1.f), cegui_reldim( 1.f)));

	// controls


	for (int allCtrl = 0;allCtrl<sizeof(aCtrlList)/sizeof(CTRLEntry); allCtrl++)
	{
		static const float interligne = 0.06f*1.6f;
		static const float intersize = 0.05f*1.4f;
		tstring numb;
		numb.Printf("%d", allCtrl);

		Window* txtlib = winMgr.createWindow("TaharezLook/StaticText", String(aCtrlList[allCtrl].mName)+String("CtrlLib")+String(numb.c_str()));

		txtlib->setText(GLoc->GetString(aCtrlList[allCtrl].mName).c_str());
		txtlib->setProperty("FrameEnabled", "false");
		txtlib->setProperty("BackgroundEnabled", "false");
		//txtlib->setHorizontalAlignment(HA_CENTRE);
		txtlib->setPosition(UVector2(cegui_reldim(0.05f), cegui_reldim( 0.01f + interligne*allCtrl)));
		txtlib->setSize(UVector2(cegui_reldim(0.19f), cegui_reldim( intersize )));

		wnd2->addChildWindow(txtlib);



		PushButton* txtBut = (PushButton*)winMgr.createWindow("TaharezLook/Button", String(aCtrlList[allCtrl].mName)+String("CtrlBut")+String(numb.c_str()));
		txtBut->setPosition(UVector2(cegui_reldim(0.2f), cegui_reldim( 0.01f + interligne*allCtrl)));
		txtBut->setSize(UVector2(cegui_reldim(0.50f), cegui_reldim( intersize )));

		SetBindedControlString(allCtrl, txtBut);


		//txtBut->setText("A or PAD Button 1");
		txtBut->setHorizontalAlignment(HA_CENTRE);

		wnd2->addChildWindow(txtBut);

		txtBut->subscribeEvent ( PushButton::EventClicked,
			Event::Subscriber (&GuiConfig::handleConfigControlsBut, this));

		txtBut->setID(allCtrl);
		aCtrlList[allCtrl].mWindow = (Window*)txtBut;

	}
	// -- PLAYER

	Editbox* playerName = static_cast<Editbox*>(winMgr.createWindow("TaharezLook/Editbox", "CONFIGPLAYERNAME"));
	wnd1->addChildWindow(playerName);
	playerName->setPosition(UVector2(cegui_reldim(0.3f), cegui_reldim( 0.05f)));
	playerName->setSize(UVector2(cegui_reldim(0.3f), cegui_reldim( 0.08f)));
	//playerName->setValidationString("*");
	playerName->setText(GConfig->GetPlayerName());

	Window* txtlib = winMgr.createWindow("TaharezLook/StaticText", "CONFIGPLAYERNAMESTATIC");

	txtlib->setText(GLoc->GetString("PLAYERNAME").c_str());
	txtlib->setProperty("FrameEnabled", "false");
	txtlib->setProperty("BackgroundEnabled", "false");
	txtlib->setPosition(UVector2(cegui_reldim(0.05f), cegui_reldim( 0.05f)));
	txtlib->setSize(UVector2(cegui_reldim(0.24f), cegui_reldim( 0.08f )));

	wnd1->addChildWindow(txtlib);



	// --

	// -- SOUND

	Scrollbar* sfxslider = static_cast<Scrollbar*>(winMgr.createWindow("TaharezLook/HorizontalScrollbar", "SFXVOLUME"));
	sfxslider->setPosition(UVector2(cegui_reldim(0.3f), cegui_reldim( 0.05f)));
	sfxslider->setSize(UVector2(cegui_reldim(0.6f), cegui_reldim( 0.08f)));
	sfxslider->setDocumentSize (100);
	sfxslider->subscribeEvent ( Scrollbar::EventScrollPositionChanged, Event::Subscriber (&GuiConfig::handleSFXVolChanged, this));
	sfxslider->setScrollPosition(float(GConfig->GetQuality("SFXVOLUME")));
	wnd4->addChildWindow(sfxslider);


	Window* txtlibsfx = winMgr.createWindow("TaharezLook/StaticText", "SFXVOLUMESTATIC");
	txtlibsfx->setText(GLoc->GetString("SFXVOLUME").c_str());
	txtlibsfx->setProperty("FrameEnabled", "false");
	txtlibsfx->setProperty("BackgroundEnabled", "false");
	txtlibsfx->setPosition(UVector2(cegui_reldim(0.05f), cegui_reldim( 0.05f)));
	txtlibsfx->setSize(UVector2(cegui_reldim(0.24f), cegui_reldim( 0.08f )));
	wnd4->addChildWindow(txtlibsfx);



	Scrollbar* musicslider = static_cast<Scrollbar*>(winMgr.createWindow("TaharezLook/HorizontalScrollbar", "MUSICVOLUME"));
	musicslider->setPosition(UVector2(cegui_reldim(0.3f), cegui_reldim( 0.15f)));
	musicslider->setSize(UVector2(cegui_reldim(0.6f), cegui_reldim( 0.08f)));
	musicslider->setDocumentSize (100);
	musicslider->subscribeEvent ( Scrollbar::EventScrollPositionChanged, Event::Subscriber (&GuiConfig::handleMusicVolChanged, this));
	musicslider->setScrollPosition(float(GConfig->GetQuality("MUSICVOLUME")));
	wnd4->addChildWindow(musicslider);


	Window* txtlibmusic = winMgr.createWindow("TaharezLook/StaticText", "MUSICVOLUMESTATIC");
	txtlibmusic->setText(GLoc->GetString("MUSICVOLUME").c_str());
	txtlibmusic->setProperty("FrameEnabled", "false");
	txtlibmusic->setProperty("BackgroundEnabled", "false");
	txtlibmusic->setPosition(UVector2(cegui_reldim(0.05f), cegui_reldim( 0.15f)));
	txtlibmusic->setSize(UVector2(cegui_reldim(0.24f), cegui_reldim( 0.08f )));
	wnd4->addChildWindow(txtlibmusic);


    Checkbox* checkMusic = static_cast<Checkbox*>(winMgr.createWindow("TaharezLook/Checkbox", "CHKMUSIC"));
    wnd4->addChildWindow(checkMusic);
	checkMusic->setPosition(UVector2(cegui_reldim(0.05f), cegui_reldim( 0.25f)));
	checkMusic->setSize(UVector2(cegui_reldim(0.24f), cegui_reldim( 0.08f )));
	checkMusic->setText(GLoc->GetString("CHKMUSIC").c_str());
	checkMusic->subscribeEvent ( Checkbox::EventCheckStateChanged, Event::Subscriber (&GuiConfig::handleChkMusicChanged, this));
	checkMusic->setSelected (GConfig->IsEnable("CHKMUSIC"));

	// --

	// -- VIDEO


    Combobox* cbresolution = static_cast<Combobox*>(winMgr.createWindow("TaharezLook/Combobox", "RESOLUTION"));
    wnd3->addChildWindow(cbresolution);
    cbresolution->setPosition(UVector2(cegui_reldim(0.3f), cegui_reldim( 0.05f)));
    cbresolution->setSize(UVector2(cegui_reldim(0.24f), cegui_reldim( 0.75f)));
	cbresolution->setReadOnly(true);

	Window* txtres = winMgr.createWindow("TaharezLook/StaticText", "RESOLUTIONTXT");
	txtres->setText(GLoc->GetString("RESOLUTION").c_str());
	txtres->setProperty("FrameEnabled", "false");
	txtres->setProperty("BackgroundEnabled", "false");
	txtres->setPosition(UVector2(cegui_reldim(0.05f), cegui_reldim( 0.05f)));
	txtres->setSize(UVector2(cegui_reldim(0.24f), cegui_reldim( 0.08f )));
	wnd3->addChildWindow(txtres);


	int optWidth = GConfig->GetQuality("Width");
	int optHeight = GConfig->GetQuality("Height");

	int awidth = -1, aheight = -1;
	int avresolutions = 0;
	for (unsigned int rs = 0;rs<GDD->GetNbPossibleResolutions(); rs++)
	{
		char tmps[512];
		int width, height;
		GDD->GetResolution(rs, width, height);
		if ((awidth != width) || (aheight != height))
		{
			awidth = width;
			aheight = height;

			mResolutions.push_back(resval_t(width, height));
			snprintf(tmps, 512, "%d x %d", width, height);
			cbresolution->addItem (new ListboxTextItem(tmps));

			if ((width == optWidth)&&(height == optHeight))
				CEGUICBSel(cbresolution, avresolutions);

			avresolutions++;
		}
	}



	// --

    Checkbox* checkFS = static_cast<Checkbox*>(winMgr.createWindow("TaharezLook/Checkbox", "CHKBFS"));
    wnd3->addChildWindow(checkFS);
	checkFS->setPosition(UVector2(cegui_reldim(0.05f), cegui_reldim( 0.15f)));
	checkFS->setSize(UVector2(cegui_reldim(0.24f), cegui_reldim( 0.08f )));
	checkFS->setText(GLoc->GetString("FULLSCREEN").c_str());
	//checkFS->subscribeEvent ( Checkbox::EventCheckStateChanged, Event::Subscriber (&GuiConfig::handleFSChanged, this));
	checkFS->setSelected (GConfig->IsEnable("CHKBFS"));


    Checkbox* checkVSync = static_cast<Checkbox*>(winMgr.createWindow("TaharezLook/Checkbox", "CHKBVSYNC"));
    wnd3->addChildWindow(checkVSync);
	checkVSync->setPosition(UVector2(cegui_reldim(0.05f), cegui_reldim( 0.75f)));
	checkVSync->setSize(UVector2(cegui_reldim(0.24f), cegui_reldim( 0.08f )));
	checkVSync->setText(GLoc->GetString("VSYNC").c_str());
	//checkVSync->subscribeEvent ( Checkbox::EventCheckStateChanged, Event::Subscriber (&GuiConfig::handleVSYNCChanged, this));
	checkVSync->setSelected (GConfig->IsEnable("CHKBVSYNC"));

	// --

    Combobox* cbshad = static_cast<Combobox*>(winMgr.createWindow("TaharezLook/Combobox", "SHADOWQUALITY"));
    wnd3->addChildWindow(cbshad);
    cbshad->setPosition(UVector2(cegui_reldim(0.3f), cegui_reldim( 0.25f)));
    cbshad->setSize(UVector2(cegui_reldim(0.24f), cegui_reldim( 0.33f)));
	cbshad->setReadOnly(true);

	Window* txtshad = winMgr.createWindow("TaharezLook/StaticText", "SHADOWQUALITYTXT");
	txtshad->setText(GLoc->GetString("SHADOWQUALITY").c_str());
	txtshad->setProperty("FrameEnabled", "false");
	txtshad->setProperty("BackgroundEnabled", "false");
	txtshad->setPosition(UVector2(cegui_reldim(0.05f), cegui_reldim( 0.25f)));
	txtshad->setSize(UVector2(cegui_reldim(0.24f), cegui_reldim( 0.08f )));
	wnd3->addChildWindow(txtshad);

	cbshad->addItem (new ListboxTextItem(GLoc->GetString("DISABLED").c_str()));
	cbshad->addItem (new ListboxTextItem(GLoc->GetString("MEDIUM").c_str()));
	cbshad->addItem (new ListboxTextItem(GLoc->GetString("HIGH").c_str()));
	cbshad->addItem (new ListboxTextItem(GLoc->GetString("VERYHIGH").c_str()));

	cbshad->subscribeEvent ( Combobox::EventListSelectionAccepted, Event::Subscriber (&GuiConfig::handleShadowQualityChanged, this));
	CEGUICBSel(cbshad, GConfig->GetQuality("SHADOWQUALITY"));
	// --

    Combobox* cbrefl = static_cast<Combobox*>(winMgr.createWindow("TaharezLook/Combobox", "REFLECTIONQUALITY"));
    wnd3->addChildWindow(cbrefl);
    cbrefl->setPosition(UVector2(cegui_reldim(0.3f), cegui_reldim( 0.35f)));
    cbrefl->setSize(UVector2(cegui_reldim(0.24f), cegui_reldim( 0.33f)));
	cbrefl->setReadOnly(true);

	Window* txtrefl = winMgr.createWindow("TaharezLook/StaticText", "REFLECTIONQUALITYTXT");
	txtrefl->setText(GLoc->GetString("REFLECTIONQUALITY").c_str());
	txtrefl->setProperty("FrameEnabled", "false");
	txtrefl->setProperty("BackgroundEnabled", "false");
	txtrefl->setPosition(UVector2(cegui_reldim(0.05f), cegui_reldim( 0.35f)));
	txtrefl->setSize(UVector2(cegui_reldim(0.24f), cegui_reldim( 0.08f )));
	wnd3->addChildWindow(txtrefl);

	cbrefl->addItem (new ListboxTextItem(GLoc->GetString("DISABLED").c_str()));
	cbrefl->addItem (new ListboxTextItem(GLoc->GetString("MEDIUM").c_str()));
	cbrefl->addItem (new ListboxTextItem(GLoc->GetString("HIGH").c_str()));
	cbrefl->addItem (new ListboxTextItem(GLoc->GetString("VERYHIGH").c_str()));
	cbrefl->subscribeEvent ( Combobox::EventListSelectionAccepted, Event::Subscriber (&GuiConfig::handleReflectionQualityChanged, this));
	CEGUICBSel(cbrefl, GConfig->GetQuality("REFLECTIONQUALITY"));
	// --
    Combobox* cbwater = static_cast<Combobox*>(winMgr.createWindow("TaharezLook/Combobox", "WATERQUALITY"));
    wnd3->addChildWindow(cbwater);
    cbwater->setPosition(UVector2(cegui_reldim(0.3f), cegui_reldim( 0.45f)));
    cbwater->setSize(UVector2(cegui_reldim(0.24f), cegui_reldim( 0.33f)));
	cbwater->setReadOnly(true);

	Window* txtwater = winMgr.createWindow("TaharezLook/StaticText", "WATERQUALITYTXT");
	txtwater->setText(GLoc->GetString("WATERQUALITY").c_str());
	txtwater->setProperty("FrameEnabled", "false");
	txtwater->setProperty("BackgroundEnabled", "false");
	txtwater->setPosition(UVector2(cegui_reldim(0.05f), cegui_reldim( 0.45f)));
	txtwater->setSize(UVector2(cegui_reldim(0.24f), cegui_reldim( 0.08f )));
	wnd3->addChildWindow(txtwater);

	cbwater->addItem (new ListboxTextItem(GLoc->GetString("LOW").c_str()));
	cbwater->addItem (new ListboxTextItem(GLoc->GetString("MEDIUM").c_str()));
	cbwater->addItem (new ListboxTextItem(GLoc->GetString("HIGH").c_str()));
	cbwater->addItem (new ListboxTextItem(GLoc->GetString("VERYHIGH").c_str()));
	cbwater->subscribeEvent ( Combobox::EventListSelectionAccepted, Event::Subscriber (&GuiConfig::handleWaterQualityChanged, this));
	CEGUICBSel(cbwater, GConfig->GetQuality("WATERQUALITY"));
	// --

    Checkbox* checkDOF = static_cast<Checkbox*>(winMgr.createWindow("TaharezLook/Checkbox", "CHKDOF"));
    wnd3->addChildWindow(checkDOF);
	checkDOF->setPosition(UVector2(cegui_reldim(0.05f), cegui_reldim( 0.55f)));
	checkDOF->setSize(UVector2(cegui_reldim(0.24f), cegui_reldim( 0.08f )));
	checkDOF->setText(GLoc->GetString("DEPTHOFFIELD").c_str());
	checkDOF->subscribeEvent ( Checkbox::EventCheckStateChanged, Event::Subscriber (&GuiConfig::handleDOFChanged, this));
	checkDOF->setSelected (GConfig->IsEnable("CHKDOF"));

    Checkbox* checkMBLUR = static_cast<Checkbox*>(winMgr.createWindow("TaharezLook/Checkbox", "CHKMBLUR"));
    wnd3->addChildWindow(checkMBLUR);
	checkMBLUR->setPosition(UVector2(cegui_reldim(0.05f), cegui_reldim( 0.65f)));
	checkMBLUR->setSize(UVector2(cegui_reldim(0.24f), cegui_reldim( 0.08f )));
	checkMBLUR->setText(GLoc->GetString("MOTIONBLUR").c_str());
	checkMBLUR->subscribeEvent ( Checkbox::EventCheckStateChanged, Event::Subscriber (&GuiConfig::handleMBLURChanged, this));
	checkMBLUR->setSelected (GConfig->IsEnable("CHKMBLUR"));
/*
	Resolution

	Enable FullScreen

	shadows quality (disabled, medium, high, ultrahigh)
	0, 1024, 2048, 4096
	reflection quality (disabled, low, medium, high)
	0, 256, 512, 1024
	water quality (low, medium, high, ultra high)

	enable Depth of field
	enable motion blur

	*/

	// --
	PushButton* btn = static_cast<PushButton*>(winMgr.createWindow("TaharezLook/Button", "configOK"));
	mCondigWindow->addChildWindow(btn);
	btn->setPosition(UVector2(cegui_reldim(0.77f), cegui_reldim( 0.90f)));
	btn->setSize(UVector2(cegui_reldim(0.20f), cegui_reldim( 0.065f)));
	btn->setText("OK");
	btn->subscribeEvent(PushButton::EventClicked, Event::Subscriber(&GuiConfig::HandleConfigOK, this));

}
UIElement *UserInterface::createElement(SlotType *iter, UIElement* parent) {
    UIElement *el = nullptr;
    //  ----------- КНОПКА
    if (iter->choiceValue.button != nullptr) {
        Button *b = new Button(iter);
        el = b;
        buttonIndex[b->getName()] = b;
    } else if (iter->choiceValue.image != nullptr) {
        el = new Image(iter);
    } else if (iter->choiceValue.text != nullptr) {
        el = new TextLabel(iter);
    } else if (iter->choiceValue.tableContainer != nullptr) {
        TableContainer *tabCont = new TableContainer(iter);
        for (auto subIter : iter->choiceValue.tableContainer->slot) {
            tabCont->add(createElement(subIter, tabCont));
        }
        tabCont->pack();
        el = tabCont;
        tableIndex[tabCont->getName()] = tabCont;
    } else if (iter->choiceValue.input != nullptr) {
        InputField *ipf = new InputField(iter);
        el = ipf;
        inputIndex[ipf->getName()] = ipf;
    } else if (iter->choiceValue.ddlb != nullptr) {
        DropDownListBox *lb = new DropDownListBox(iter);
        ddlbIndex[lb->getName()] = lb;
        el = lb;
    } else if (iter->choiceValue.context != nullptr) {
        ButtonContextMenu *b = new ButtonContextMenu(iter);
        el = b;
        if (b->getName().size() > 0) {
            if (contextMenuIndex.find(el->getName()) != contextMenuIndex.end()) {
                logger.warn("Context Menu with name %s already exists!", el->getName().c_str());
            }
            contextMenuIndex[el->getName()] = b;
        }
    } else if (iter->choiceValue.dialog != nullptr) {
        Dialog *d = new Dialog(iter);
        for (auto subIter : iter->choiceValue.dialog->slot) {
            d->add(createElement(subIter));
        }
        el = d;
    } else if (iter->choiceValue.imagePicker != nullptr) {
        ImagePicker *ip = new ImagePicker(iter);
        imagePickerIndex[ip->getName()] = ip;
        el = ip;
    } else if (iter->choiceValue.rgb != nullptr) {
        RGBSlider *s = new RGBSlider(iter);
        el = s;
        rgbSliderIndex[s->getName()] = s;
    } else if (iter->choiceValue.healthbar != nullptr) {
        el = new Healthbar(iter);
    } else if (iter->choiceValue.slider != nullptr) {
        Slider *s = new Slider(iter);
        el = s;
        sliderIndex[s->getName()] = s;
    } else if (iter->choiceValue.checkbox != nullptr) {
        Checkbox *lb = new Checkbox(iter);
        checkboxIndex[lb->getName()] = lb;
        el = lb;
    } else if (iter->choiceValue.radio != nullptr) {
        RadioButton *r = new RadioButton(iter);
        checkboxIndex[r->getName()] = r;
        el = r;
    } else if (iter->choiceValue.labelsList!=nullptr){
        LabelsList* ll = new LabelsList(iter);
        el = ll;
    } else if (iter->choiceValue.lineContainer!=nullptr){
        el = new LineContainer(iter);
    } else if(iter->choiceValue.containerSelector!=nullptr){
        ContainerSelector* cs;
        if(parent==nullptr) {
            cs = new ContainerSelector(iter,nullptr);
        }else{
            TableContainer *contParent = dynamic_cast<TableContainer *>(parent);
            if(contParent==nullptr){
                logger.error("ContainerSelector [%s] parent can be only TableContainer", iter->name.c_str());
                return nullptr;
            }
            cs = new ContainerSelector(iter,contParent);
        }
        containerSelectorIndex[cs->getName()]=cs;
        el=cs;
    }

    //common atrs
    if (el != nullptr) {
        el->setVisible(iter->visible);
        el->setEnabled(iter->enabled);
    }

    return el;
}
Exemple #15
0
void CheckOption( void* checkbox, void*option )
{
	Checkbox *box = (Checkbox *)checkbox;
	SETOPTION( (char*)option, box->IsChecked() );
}
void OptionsDialog::Save()
{
	//save settings to xml, set shit, etc. blah blah
	Checkbox* c;
	Input* i;
	SmallSelect* ss;
	Scrollbar* sc;
	string s;
	uShort u;
	
	i = (Input*)mFrameUser->Get("nick");
	if (i)
	{
		s = i->GetText();
		if (s.find(" ", 0) != string::npos)
			s.erase(s.find(" ", 0));
	
		// nope!
		replace(&s, "\\n", "");
		replace(&s, "\\t", "");
		replace(&s, "\n", "");
		replace(&s, "\t", "");

		if (!stripCodes(s).empty())
		{
			if (game->mNet->IsConnected())
			{
				game->mNet->ChangeNick(s);
			}
			else
			{
				if (userlist)
					userlist->ChangeNick(game->mPlayer->GetName(), s);
				game->mPlayer->SetName(s);

				game->mUserData.SetValue("MapSettings", "Nick", s);
			}
		}
		else
		{
			game->GetChat()->AddMessage("\\c900 * Invalid nickname, ignoring.");
		}
	}

	c = (Checkbox*)mFrameUser->Get("stamps");
	if (c)
	{
		game->mUserData.SetValue("MapSettings", "Timestamps", its(c->GetState()));
		if (game->GetChat())
			game->GetChat()->mShowTimestamps = c->GetState();
	}
			
	c = (Checkbox*)mFrameUser->Get("names");
	if (c) 
	{
		game->mUserData.SetValue("MapSettings", "ShowNames", its(c->GetState()));
		if (game->mMap)
			game->mMap->mShowPlayerNames = c->GetState();
	}
/*
	c = (Checkbox*)mFrameUser->Get("trading");
	if (c) 
	{
		game->mPlayerData.SetParamInt("map", "trading", c->GetState());
	}	
*/
	ss = (SmallSelect*)mFrameUser->Get("alerts");
	if (ss) 
	{
		game->mUserData.SetValue("System", "Alerts", its(ss->mSelectedIndex));
		gui->mSystemAlertType = ss->mSelectedIndex;
	}
	
	c = (Checkbox*)mFrameNetwork->Get("joinparts");
	if (c)
	{
		game->mUserData.SetValue("MapSettings", "JoinParts", its(c->GetState()));
		game->mShowJoinParts = c->GetState();
	}
	
	c = (Checkbox*)mFrameNetwork->Get("addr");
	if (c)
	{
		game->mUserData.SetValue("MapSettings", "ShowAddresses", its(c->GetState()));
		game->mShowAddresses = c->GetState();
	}

/*
	i = (Input*)mFrameNetwork->Get("reconnect");
	if (i)
	{
		game->mConfig.SetParamInt("connection", "delay", sti(i->GetText()));
		//TODO: this
	}
*/				
	c = (Checkbox*)mFrameNetwork->Get("privmsg");
	if (c)
	{
		game->mUserData.SetValue("MapSettings", "PrivMsg", its(c->GetState()));
	}
	
#ifdef _SOUNDMANAGER_H_		
	sc = (Scrollbar*)mFrameAudio->Get("vol");
	if (sc) 
	{
		config.SetParamInt("sound", "volume", sc->GetValue());

		if (sound)
			sound->SetVolume( sc->GetValue() );

	}
#endif	
	c = (Checkbox*)mFrameGraphics->Get("nolimit");
	if (c)
	{
		game->mUserData.SetValue("System", "NoLimit", its(c->GetState()));
		gui->mNoFpsLimit = c->GetState();
	}
	
	c = (Checkbox*)mFrameGraphics->Get("lowcpu");
	if (c)
	{
		game->mUserData.SetValue("System", "LowCpu", its(c->GetState()));
		gui->mUseLowCpu = c->GetState();
	}

	i = (Input*)mFrameGraphics->Get("fps");
	if (i)
	{
		u = sti(i->GetText());
		if (u < 5)
			u = 5;
		game->mUserData.SetValue("System", "FPS", its(u));
		gui->mFpsCap = u;
	}
}