void CGameConfig::Enter() {
	Winsys.ShowCursor (!param.ice_cursor);
	Winsys.KeyRepeat (true);

	for (int i=0; i<NUM_RESOLUTIONS; i++) res_names[i] = Winsys.GetResName (i);

	int framewidth = 550 * Winsys.scale;
	area = AutoAreaN (30, 80, framewidth);
	FT.AutoSizeN (4);
	dd = FT.AutoDistanceN (3);
	if (dd < 36) dd = 36;
	int rightpos = area.right -48;

	ResetGUI ();
#ifndef PANDORA
	fullscreen = AddCheckbox (area.left, area.top, framewidth-16, Trans.Text(31));
	fullscreen->checked = param.fullscreen;

	resolution = AddUpDown(rightpos, area.top+dd*1, 0, NUM_RESOLUTIONS-1, (int)param.res_type);
#endif
	mus_vol = AddUpDown(rightpos, area.top+dd*2, 0, 120, param.music_volume);
	sound_vol = AddUpDown(rightpos, area.top+dd*3, 0, 120, param.sound_volume);
	detail_level = AddUpDown(rightpos, area.top+dd*4, 1, 4, param.perf_level);
	language = AddUpDown(rightpos, area.top+dd*5, 0, (int)Trans.languages.size() - 1, (int)param.language);

	int siz = FT.AutoSizeN (5);
	textbuttons[0] = AddTextButton (Trans.Text(28), area.left+50, AutoYPosN (80), siz);
	ETR_DOUBLE len = FT.GetTextWidth (Trans.Text(8));
	textbuttons[1] = AddTextButton (Trans.Text(15), area.right-len-50, AutoYPosN (80), siz);

	Music.Play (param.config_music, -1);
}
Ejemplo n.º 2
0
void MainWindow::Load()
{
    font = new FontLoader();
    if (!font->Load("Calibri.fnt")) std::cout << "No font D:" << std::endl;
    AddCheckbox(32, 32);
    AddTextbox(32, 70);
    AddTextbox(32, 110);
}
Ejemplo n.º 3
0
void GameConfigInit (void) {
	Winsys.ShowCursor (!param.ice_cursor);    
	Winsys.KeyRepeat (true);
	init_ui_snow (); 

	LangList = Trans.languages;
	lastLang = Trans.numLanguages - 1;

	SDL_Surface *surf = 0;
	surf = SDL_GetVideoSurface ();

	for (int i=0; i<NUM_RESOLUTIONS; i++) res_names[i] = Winsys.GetResName (i);
 
	paramchanged = false;

	// read the start params:
	curr_res = param.res_type;
	prev_res = param.res_type;
	curr_fullscreen = param.fullscreen;
	prev_fullscreen = param.fullscreen;
	curr_mus_vol = param.music_volume;
	curr_sound_vol = param.sound_volume;
	curr_detail_level = param.perf_level;
	curr_language = param.language;
	if (curr_language > lastLang) curr_language = lastLang;

	framewidth = 550 * param.scale;
	frameheight = 50 * param.scale;
	area = AutoAreaN (30, 80, framewidth);
	FT.AutoSizeN (4);
	dd = FT.AutoDistanceN (3);
	if (dd < 36) dd = 36;
	rightpos = area.right -48;

	ResetWidgets ();
	AddCheckbox (area.left, area.top, 0, framewidth-16, Trans.Text(31));
	AddArrow (rightpos, area.top+dd*1, 0, 1);
	AddArrow (rightpos, area.top+dd*1+18, 1, 1);
	AddArrow (rightpos, area.top+dd*2, 0, 2);
	AddArrow (rightpos, area.top+dd*2+18, 1, 2);
	AddArrow (rightpos, area.top+dd*3, 0, 3);
	AddArrow (rightpos, area.top+dd*3+18, 1, 3);
	AddArrow (rightpos, area.top+dd*4, 0, 4);
	AddArrow (rightpos, area.top+dd*4+18, 1, 4);
	AddArrow (rightpos, area.top+dd*5, 0, 5);
	AddArrow (rightpos, area.top+dd*5+18, 1, 5);	

	int siz = FT.AutoSizeN (5);
	AddTextButton (Trans.Text(28), area.left+50, AutoYPosN (80), 6, siz);
	double len = FT.GetTextWidth (Trans.Text(8));
	AddTextButton (Trans.Text(15), area.right-len-50, AutoYPosN (80), 7, siz);

	curr_focus = 0;
	Music.Play (param.config_music, -1);
}
Ejemplo n.º 4
0
    DebugSettingsWindow(TBWidget *root)
    {
        SetText("Debug settings");
        g_widgets_reader->LoadData(this,
                                   "TBLayout: axis: y, distribution: available, position: left\n"
                                   "	TBLayout: id: 'container', axis: y, size: available\n"
                                   "	TBTextField: text: 'Event output:'\n"
                                   "	TBEditField: id: 'output', gravity: all, multiline: 1, wrap: 0\n"
                                   "		lp: pref-height: 100dp");

        AddCheckbox(TBDebugInfo::LAYOUT_BOUNDS, "Layout bounds");
        AddCheckbox(TBDebugInfo::LAYOUT_CLIPPING, "Layout clipping");
        AddCheckbox(TBDebugInfo::LAYOUT_PS_DEBUGGING, "Layout size calculation");
        AddCheckbox(TBDebugInfo::RENDER_BATCHES, "Render batches");
        AddCheckbox(TBDebugInfo::RENDER_SKIN_BITMAP_FRAGMENTS, "Render skin bitmap fragments");
        AddCheckbox(TBDebugInfo::RENDER_FONT_BITMAP_FRAGMENTS, "Render font bitmap fragments");

        output = GetWidgetByIDAndType<TBEditField>(TBIDC("output"));

        TBRect bounds(0, 0, root->GetRect().w, root->GetRect().h);
        SetRect(GetResizeToFitContentRect().CenterIn(bounds).MoveIn(bounds).Clip(bounds));

        root->AddChild(this);

        TBWidgetListener::AddGlobalListener(this);
    }
Ejemplo n.º 5
0
/*******************************************************************************
 *	Slot function. Translates command object recevied from the parser thread
 * 	to appropriate function call.
 * ****************************************************************************/
void DialogBox::ExecuteCommand(DialogCommand command)
{
	QWidget* widget=NULL;

	if(empty)
		{
			ClearDialog();
			empty=false;
		}
	switch(command.command & DialogCommand::command_mask)
		{
			case DialogCommand::add:

				if(command.command & DialogCommand::option_space & DialogCommand::option_mask)
					{
						// Seems sscanf %d in some versions of standard C library has a bug
						// returning 32k on sero-size strings
						if(command.GetText()[0])
							{
								int size;
								sscanf(command.GetText(), "%d", &size);
								AddSpace(size);
							}
						else AddSpace();
						break;
					}

				if(command.command & DialogCommand::option_stretch & DialogCommand::option_mask)
					{
						AddStretch();
						break;
					}

				switch(command.control & ~DialogCommand::property_mask)
					{
						case DialogCommand::label:
							AddLabel(command.GetTitle(), command.GetName(),
								command.control & DialogCommand::property_picture & DialogCommand::property_mask ? DialogBox::pixmap :
										command.control & DialogCommand::property_animation & DialogCommand::property_mask ? DialogBox::movie :
										DialogBox::text);
							break;
						case DialogCommand::groupbox:
							AddGroupbox(command.GetTitle(), command.GetName(),
								command.control & DialogCommand::property_vertical & DialogCommand::property_mask,
								command.control & DialogCommand::property_checkable & DialogCommand::property_mask,
								command.control & DialogCommand::property_checked & DialogCommand::property_mask);
							break;
						case DialogCommand::frame:
							AddFrame(command.GetTitle(),
								command.control & DialogCommand::property_vertical & DialogCommand::property_mask,
								command.control);
							break;
						case DialogCommand::pushbutton:
							AddPushbutton(command.GetTitle(), command.GetName(),
								command.control & DialogCommand::property_apply & DialogCommand::property_mask,
								command.control & DialogCommand::property_exit & DialogCommand::property_mask,
								command.control & DialogCommand::property_default & DialogCommand::property_mask);
							break;
						case DialogCommand::checkbox:
							AddCheckbox(command.GetTitle(), command.GetName(),
								command.control & DialogCommand::property_checked & DialogCommand::property_mask);
							break;
						case DialogCommand::radiobutton:
							AddRadiobutton(command.GetTitle(), command.GetName(),
								command.control & DialogCommand::property_checked & DialogCommand::property_mask);
							break;
						case DialogCommand::textbox:
							AddTextbox(command.GetTitle(), command.GetName(),
								command.GetText(),
								command.GetAuxText(),
								command.control & DialogCommand::property_password & DialogCommand::property_mask);
							break;
						case DialogCommand::listbox:
							AddListbox(command.GetTitle(), command.GetName(),
							command.control & DialogCommand::property_activation & DialogCommand::property_mask,
							command.control & DialogCommand::property_selection & DialogCommand::property_mask);
							break;
						case DialogCommand::combobox:
							AddCombobox(command.GetTitle(), command.GetName(),
							command.control & DialogCommand::property_editable & DialogCommand::property_mask,
							command.control & DialogCommand::property_selection & DialogCommand::property_mask);
							break;
						case DialogCommand::item:
							AddItem(command.GetTitle(), command.GetName(),
							command.control & DialogCommand::property_current & DialogCommand::property_mask);
							break;
						case DialogCommand::separator:
							AddSeparator(command.GetTitle(),
								command.control & DialogCommand::property_vertical & DialogCommand::property_mask,
								command.control);
							break;
						case DialogCommand::progressbar:
							AddProgressbar(command.GetTitle(),
								command.control & DialogCommand::property_vertical & DialogCommand::property_mask,
								command.control & DialogCommand::property_busy & DialogCommand::property_mask);
							break;
						case DialogCommand::slider:
							{
								int min(0), max(100);
								if(command.GetName()[0]) sscanf(command.GetName(), "%d", &min);
								if(command.GetText()[0]) sscanf(command.GetText(), "%d", &max);
								AddSlider(command.GetTitle(),
									command.control & DialogCommand::property_vertical & DialogCommand::property_mask,
									min, max);
							}
							break;
						case DialogCommand::textview:
							AddTextview(command.GetTitle(), command.GetName());
							break;
						case DialogCommand::tabs:
							AddTabs(command.GetTitle(), command.control);
							break;
						case DialogCommand::page:
							AddPage(command.GetTitle(), command.GetName(), command.GetText(),
							command.control & DialogCommand::property_current & DialogCommand::property_mask);
							break;
					}
				break;
			case DialogCommand::clear:
				Clear(command.GetName());
				break;
			case DialogCommand::end:
				switch(command.control & ~DialogCommand::property_mask)
					{
						case DialogCommand::groupbox:
						case DialogCommand::frame:
							EndGroup();
							break;
						case DialogCommand::listbox:
						case DialogCommand::combobox:
							EndList();
							break;
						case DialogCommand::tabs:
							EndTabs();
							break;
						case DialogCommand::page:
							EndPage();
							break;
						case DialogCommand::widget_mask:	// none type mentioned
							if(current_view) EndList();
							else if(group_layout) EndGroup();
							else if(current_tab_widget)
								{
									if(current_tab_widget->indexOf(current_layout->parentWidget())==-1) EndTabs();
									else EndPage();
								}
							break;
					}
				break;
			case DialogCommand::step:
				if(command.command & DialogCommand::option_vertical & DialogCommand::option_mask) StepVertical();
				else StepHorizontal();
				break;
			case DialogCommand::set:
				if(command.GetName()[0])
					{
						if(!(widget=FindWidget(command.GetName()))) break;
					}
				else widget=this;

				if(command.command & DialogCommand::option_enabled & DialogCommand::option_mask)
					SetEnabled(widget, true);

				if(command.command & DialogCommand::option_focus & DialogCommand::option_mask)
					{
						QTimer::singleShot(0, widget, SLOT(setFocus()));

						// select text for QLineEdit objects
						// selectedText property is not writable and this must be done in the class specific way
						if(QWidget* proxywidget=widget->focusProxy())
							{
								switch(WidgetType(proxywidget))
									{
										case DialogCommand::combobox:
											proxywidget=((QComboBox*)proxywidget)->lineEdit();
											break;
										case DialogCommand::textbox:
											break;
										default:
											proxywidget=NULL;
											break;
									}
								if(proxywidget) ((QLineEdit*)proxywidget)->selectAll();
							}
					}

				// see http://doc.qt.io/qt-4.8/stylesheet.html for reference
				if(command.command & DialogCommand::option_stylesheet & DialogCommand::option_mask)
					{
						widget->setStyleSheet(command.GetText());
						if(QWidget* proxywidget=widget->focusProxy())
							proxywidget->setStyleSheet(command.GetText());
					}

				if(command.command & DialogCommand::option_visible & DialogCommand::option_mask)
					{
						widget->show();
						if(QWidget* proxywidget=widget->focusProxy()) proxywidget->show();
					}

				if(command.control) SetOptions(widget, command.control, command.control, command.GetText());

				// setting of some properties (calls like show and hide) generates events which are optimised next
				// or sets widget attributes which might impact next calls
				// to avoid races and to ensure the command is executed as expected we process all events that
				// have been generated:
				QCoreApplication::processEvents(QEventLoop::ExcludeUserInputEvents | QEventLoop::ExcludeSocketNotifiers);
				break;
			case DialogCommand::unset:
				if(command.GetName()[0])
					{
						if(!(widget=FindWidget(command.GetName()))) break;
					}
				else widget=this;

				if(command.command & DialogCommand::option_enabled & DialogCommand::option_mask)
					SetEnabled(widget, false);

				// see http://doc.qt.io/qt-4.8/stylesheet.html for reference
				if(command.command & DialogCommand::option_stylesheet & DialogCommand::option_mask)
					{
						// rarely it was seen this fails (unset stylesheet or set it to empty string)
						// hopefully this was caused by the race which is now fixed
						// (queued signaling between threads and optimisation of queued GUI events)
						widget->setStyleSheet(QString());
						if(QWidget* proxywidget=widget->focusProxy())
							proxywidget->setStyleSheet(QString());
					}

				if(command.command & DialogCommand::option_visible & DialogCommand::option_mask)
					{
						widget->hide();
						if(QWidget* proxywidget=widget->focusProxy()) proxywidget->hide();
					}

				if(command.control) SetOptions(widget, 0, command.control, NULL);

				// setting of some properties (calls like show and hide) generates events which are optimised next
				// or sets widget attributes which might impact next calls
				// to avoid races and to ensure the command is executed as expected we process all events that
				// have been generated:
				QCoreApplication::processEvents(QEventLoop::ExcludeUserInputEvents | QEventLoop::ExcludeSocketNotifiers);
				break;
			case DialogCommand::remove:
				RemoveWidget(command.GetName());
				break;
			case DialogCommand::position:
				Position(command.GetText(),
							command.command & DialogCommand::option_behind & DialogCommand::option_mask,
							command.command & DialogCommand::option_onto & DialogCommand::option_mask);
				break;
			case DialogCommand::query:
				Report();
				break;
			case DialogCommand::noop:
			default:
				;
		}
	// clean up after possible FindWidget call
	chosen_view=NULL;
	chosen_row_flag=false;
}
Ejemplo n.º 6
0
/*********************************************************************\
	Function name    : CCustomSubDialog::CreateLayout
	Description      :
	Created at       : 27.03.02, @ 12:04:28
	Created by       : Thomas Kunert
	Modified by      :
\*********************************************************************/
Bool CCustomSubDialog::CreateLayout(void)
{
    Int32 i;
    GroupBegin(100, BFH_SCALEFIT | BFV_SCALEFIT, 2, 0, "", 0);
    Int32 lID = FIRST_CUSTOM_ELEMENT_ID;

    if (!m_pProp || m_pProp[0].type == CUSTOMTYPE_END)
    {
        GroupBegin(100, BFH_SCALEFIT, 1, 0, "", 0);
    }

    AddCheckbox(IDC_CUSTOM_OPEN_CLOSE, BFH_LEFT, 0, 0, "Open");
    Bool b = false;
    if (m_pElement)
    {
        CCustomElements* pElement = g_pCustomElements->GetItem(m_pElement->m_lElement);
        if (pElement)
        {
            BasePlugin *bs = (BasePlugin*)FindPlugin(pElement->m_lID, PLUGINTYPE_CUSTOMGUI);
            if (bs)
            {
                b = true;
                if (!(bs->GetInfo() & CUSTOMGUI_SUPPORT_LAYOUTSWITCH))
                    Enable(IDC_CUSTOM_OPEN_CLOSE, false);
                else
                    Enable(IDC_CUSTOM_OPEN_CLOSE, true);
            }
        }
    }
    if (!b)
        Enable(IDC_CUSTOM_OPEN_CLOSE, true);

    if (!m_pProp || m_pProp[0].type == CUSTOMTYPE_END)
    {
        AddStaticText(100, BFH_LEFT | BFV_CENTER, 0, 0, GeLoadString(IDS_CUSTOM_NO_PROPS), 0);
        GroupEnd();
    }

    AddStaticText(100, 0, 0, 0, "", 0);

    for (i = 0; m_pProp && m_pProp[i].type != CUSTOMTYPE_END; i++, lID++)
    {
        AddStaticText(100, BFH_LEFT | BFV_CENTER, 0, 0, m_pProp[i].ident, 0);
        switch (m_pProp[i].type)
        {
        case CUSTOMTYPE_FLAG:
            AddCheckbox(lID, BFH_LEFT | BFV_CENTER, 0, 0, "");
            break;
        case CUSTOMTYPE_LONG:
            AddEditNumber(lID, BFH_LEFT | BFV_CENTER);
            break;
        case CUSTOMTYPE_REAL:
            AddEditNumber(lID, BFH_LEFT | BFV_CENTER);
            break;
        case CUSTOMTYPE_STRING:
            AddEditText(lID, BFH_SCALEFIT | BFV_CENTER);
            break;
        case CUSTOMTYPE_VECTOR:
            AddEditNumber(lID++, BFH_LEFT | BFV_CENTER);
            AddEditNumber(lID++, BFH_LEFT | BFV_CENTER);
            AddEditNumber(lID, BFH_LEFT | BFV_CENTER);
            break;

        default:
            AddStaticText(lID, BFH_LEFT | BFV_CENTER, 0, 0, "wird auch noch ;-)", 0);
            break;
        }
    }
    /*if (!m_pProp || i == 0)
    	AddStaticText(100, BFH_LEFT | BFV_CENTER, 0, 0, GeLoadString(IDS_CUSTOM_NO_PROPS), 0);*/
    return true;
}
Ejemplo n.º 7
0
DialogItemEx *DialogBuilder::AddCheckbox(lng TextMessageId, BoolOption& Value)
{
	return AddCheckbox(GetLangString(TextMessageId), Value);
}
Ejemplo n.º 8
0
void PaletteSubDialog::PaletteLayout()
{
    if(m_rowArea != NULL){
        GetInt32(m_rowArea, m_rows);
    }
    if(m_layoutArea != NULL){
        GetInt32(m_layoutArea, m_layout);
    }
    if(m_labelCheckArea != NULL){
        GetBool(m_labelCheckArea,m_showLabel);
    }
    if(m_searchText != NULL){
        GetString(m_searchText, m_searchString);
    }
    if(m_showControls && !m_controlsShown){
        LayoutFlushGroup(1);
        GroupBegin(51, BFV_SCALEFIT, 1, 0, String(), 0);
            m_nameArea = AddEditText(IDC_NAME, BFH_SCALEFIT);
            SetString(IDC_NAME, m_palette.m_name);
            
            GroupBegin(123,BFH_SCALEFIT,0,1,String(),0);
            String rowText("Rows");
            if(m_layout == 1){
                rowText = String("Columns");
            }
            AddStaticText(9, BFH_LEFT, 0, 0, rowText, 0);
            
            m_rowArea = AddEditNumberArrows(IDC_ROWS, BFH_RIGHT);
            GroupEnd();
            SetInt32(m_rowArea, m_rows,1,99);
            
            m_layoutArea = AddComboBox(IDC_LAYOUT_DIRECTION,BFH_LEFT);
            AddChild(m_layoutArea, 0, String("Horizontal"));
            AddChild(m_layoutArea, 1, String("Vertical"));
            SetInt32(m_layoutArea, m_layout);
            
            m_labelCheckArea = AddCheckbox(IDC_LABELCHECKBOX,BFH_LEFT,0,0,String("Show Labels"));
            SetBool(m_labelCheckArea, m_showLabel);
        
            AddStaticText(IDC_FILTERLABEL, BFH_CENTER, 0, 0, String("Filter:"), 0);
            m_searchText = AddEditText(IDC_SEARCHTEXT, BFH_SCALEFIT);
            SetString(m_searchText, m_searchString);
        
            m_controlsShown = TRUE;
        
			GroupBegin(142,BFV_SCALEFIT,1,0,String(),0);
				GroupBorderNoTitle(BORDER_THIN_IN);
				AddButton(IDC_CREATEMATERIAL, BFH_CENTER, 0, 0, String("Create Materials"));
				m_linkColor = AddCheckbox(IDC_LINKMATERIALS,BFH_LEFT,0,0,String("Link colors"));
			GroupEnd();
        
            AddButton(IDC_HIDE, BFH_CENTER, 0, 0, String("Hide Controls"));
        GroupEnd();
        
        GroupBegin(3,BFV_SCALEFIT,1,0,String(),0);
            m_actionPopup = AddPopupButton(3,BFH_LEFT);
            m_trashArea = AddUserArea(4, BFH_CENTER);
            AttachUserArea(m_trash, m_trashArea);
        GroupEnd();
        LayoutChanged(1);
    }
    if(!m_showControls && m_controlsShown){
        LayoutFlushGroup(1);
            GroupBegin(3,BFV_SCALEFIT,1,0,String(),0);
                m_actionPopup = AddPopupButton(3,BFH_LEFT);
                m_trashArea = AddUserArea(4, BFH_CENTER);
                AttachUserArea(m_trash, m_trashArea);
            GroupEnd();
        LayoutChanged(1);
        m_rowArea = NULL;
        m_layoutArea = NULL;
        m_labelCheckArea = NULL;
        m_searchText = NULL;
        m_controlsShown = FALSE;
    }
    
	LayoutFlushGroup(6);
    LayoutPalette();
	LayoutChanged(6);
}