Пример #1
0
    NewMapDialog(wxWindow* parent, int game, int port, vector<Archive::mapdesc_t>& maps, Archive* archive)
        : wxDialog(parent, -1, "New Map")
    {
        // Setup dialog
        wxBoxSizer* msizer = new wxBoxSizer(wxVERTICAL);
        SetSizer(msizer);
        wxGridBagSizer* sizer = new wxGridBagSizer(4, 4);
        msizer->Add(sizer, 1, wxEXPAND|wxALL, 10);

        // Open selected game configuration if no map names are currently loaded
        if (theGameConfiguration->nMapNames() == 0)
        {
            string gname = theGameConfiguration->gameConfig(game).name;
            string pname = theGameConfiguration->portConfig(port).name;
            theGameConfiguration->openConfig(gname, pname);
        }

        // Check if the game configuration allows any map name
        int flags = 0;
        if (!theGameConfiguration->anyMapName())
            flags = wxCB_READONLY;

        // Create map name combo box
        cbo_mapname = new wxComboBox(this, -1, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0, NULL, flags);
        sizer->Add(new wxStaticText(this, -1, "Map Name:"), wxGBPosition(0, 0), wxDefaultSpan, wxALIGN_CENTER_VERTICAL);
        sizer->Add(cbo_mapname, wxGBPosition(0, 1), wxDefaultSpan, wxEXPAND);

        // Limit map name length if necessary
        if (theGameConfiguration->anyMapName() &&
                (!theGameConfiguration->allowLongNames() ||
                 (archive && archive->getType() != ARCHIVE_ZIP &&
                  archive->getType() != ARCHIVE_7Z &&
                  archive->getType() != ARCHIVE_FOLDER)))
            cbo_mapname->SetMaxLength(8);

        // Add possible map names to the combo box
        for (unsigned a = 0; a < theGameConfiguration->nMapNames(); a++)
        {
            // Check if map already exists
            string mapname = theGameConfiguration->mapName(a);
            bool exists = false;
            for (unsigned m = 0; m < maps.size(); m++)
            {
                if (S_CMPNOCASE(maps[m].name, mapname))
                {
                    exists = true;
                    break;
                }
            }

            if (!exists)
                cbo_mapname->Append(mapname);
        }

        // Set inital map name selection
        if (theGameConfiguration->nMapNames() > 0)
            cbo_mapname->SetSelection(0);

        // Create map format combo box
        choice_mapformat = new wxChoice(this, -1);
        sizer->Add(new wxStaticText(this, -1, "Map Format:"), wxGBPosition(1, 0), wxDefaultSpan, wxALIGN_CENTER_VERTICAL);
        sizer->Add(choice_mapformat, wxGBPosition(1, 1), wxDefaultSpan, wxEXPAND);

        // Add possible map formats to the combo box
        uint8_t default_format = MAP_UNKNOWN;
        if (! maps.empty())
            default_format = maps[0].format;
        for (uint8_t map_type = 0; map_type < MAP_UNKNOWN; map_type++)
        {
            if (theGameConfiguration->mapFormatSupported(map_type, game, port))
            {
                choice_mapformat->Append(MAP_TYPE_NAMES[map_type]);
                if (map_type == default_format)
                    choice_mapformat->SetSelection(choice_mapformat->GetCount() - 1);
            }
        }
        // Default to the "best" supported format, the last one in the list
        if (choice_mapformat->GetSelection() == wxNOT_FOUND)
            choice_mapformat->SetSelection(choice_mapformat->GetCount() - 1);

        // Add dialog buttons
        wxBoxSizer* hbox = new wxBoxSizer(wxHORIZONTAL);
        msizer->Add(hbox, 0, wxEXPAND | wxLEFT | wxRIGHT | wxBOTTOM, 10);
        hbox->AddStretchSpacer();
        btn_ok = new wxButton(this, -1, "OK");
        hbox->Add(btn_ok, 0, wxEXPAND | wxRIGHT, 4);
        btn_cancel = new wxButton(this, -1, "Cancel");
        hbox->Add(btn_cancel, 0, wxEXPAND);
        sizer->AddGrowableCol(1);

        // Bind events
        btn_ok->Bind(wxEVT_BUTTON, &NewMapDialog::onBtnOk, this);
        btn_cancel->Bind(wxEVT_BUTTON, &NewMapDialog::onBtnCancel, this);

        Layout();
        msizer->Fit(this);
        CenterOnParent();
    }
Пример #2
0
	NewMapDialog(wxWindow* parent, int game, int port, vector<Archive::mapdesc_t>& maps) : wxDialog(parent, -1, "New Map")
	{
		// Setup dialog
		wxBoxSizer* msizer = new wxBoxSizer(wxVERTICAL);
		SetSizer(msizer);
		wxGridBagSizer* sizer = new wxGridBagSizer(4, 4);
		msizer->Add(sizer, 1, wxEXPAND|wxALL, 10);

		// Open selected game configuration if no map names are currently loaded
		if (theGameConfiguration->nMapNames() == 0)
		{
			string gname = theGameConfiguration->gameConfig(game).name;
			string pname = theGameConfiguration->portConfig(port).name;
			theGameConfiguration->openConfig(gname, pname);
		}

		// Check if the game configuration allows any map name
		int flags = 0;
		if (!theGameConfiguration->anyMapName())
			flags = wxCB_READONLY;

		// Create map name combo box
		cbo_mapname = new wxComboBox(this, -1, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0, NULL, flags);
		if (theGameConfiguration->anyMapName()) cbo_mapname->SetMaxLength(8);
		sizer->Add(new wxStaticText(this, -1, "Map Name:"), wxGBPosition(0, 0), wxDefaultSpan, wxALIGN_CENTER_VERTICAL);
		sizer->Add(cbo_mapname, wxGBPosition(0, 1), wxDefaultSpan, wxEXPAND);

		// Add possible map names to the combo box
		for (unsigned a = 0; a < theGameConfiguration->nMapNames(); a++)
		{
			// Check if map already exists
			string mapname = theGameConfiguration->mapName(a);
			bool exists = false;
			for (unsigned m = 0; m < maps.size(); m++)
			{
				if (S_CMPNOCASE(maps[m].name, mapname))
				{
					exists = true;
					break;
				}
			}

			if (!exists)
				cbo_mapname->Append(mapname);
		}

		// Set inital map name selection
		if (theGameConfiguration->nMapNames() > 0)
			cbo_mapname->SetSelection(0);

		// Create map format combo box
		choice_mapformat = new wxChoice(this, -1);
		sizer->Add(new wxStaticText(this, -1, "Map Format:"), wxGBPosition(1, 0), wxDefaultSpan, wxALIGN_CENTER_VERTICAL);
		sizer->Add(choice_mapformat, wxGBPosition(1, 1), wxDefaultSpan, wxEXPAND);

		// Add possible map formats to the combo box
		if (theGameConfiguration->mapFormatSupported(MAP_DOOM, game, port))
			choice_mapformat->Append("Doom");
		if (theGameConfiguration->mapFormatSupported(MAP_HEXEN, game, port))
			choice_mapformat->Append("Hexen");
		if (theGameConfiguration->mapFormatSupported(MAP_UDMF, game, port))
			choice_mapformat->Append("UDMF");
		if (theGameConfiguration->mapFormatSupported(MAP_DOOM64, game, port))
			choice_mapformat->Append("Doom64");
		choice_mapformat->SetSelection(0);

		// Add dialog buttons
		sizer->Add(CreateButtonSizer(wxOK|wxCANCEL), wxGBPosition(2, 0), wxGBSpan(1, 2), wxEXPAND);
		sizer->AddGrowableCol(1, 1);

		Layout();
		sizer->Fit(this);
		CenterOnParent();
	}
Пример #3
0
wxPanel* SjViewSettingsPage::CreateFontPage(wxWindow* parent)
{
	// init dialog
	wxPanel* page = new wxPanel(parent, -1);
	wxSizer* sizer1 = new wxBoxSizer(wxVERTICAL);
	page->SetSizer(sizer1);

	sizer1->Add(SJ_DLG_SPACE, SJ_DLG_SPACE); // some space

	wxStaticText* staticText = new wxStaticText(page, -1,
	        _("You can set independent font and cover sizes to use in the main window. The sizes\nrefer to a zoom of 100%. If you zoom in or out (eg. by using the \"+\" or \"-\" keys), both\nsizes will grow or shrink proportionally."));
	sizer1->Add(staticText,
	            0, wxALL, SJ_DLG_SPACE);

	m_orgFace           = g_mainFrame->GetBaseFontFace();
	m_orgSize           = g_mainFrame->GetBaseFontSize();
	m_orgColumnWidth    = g_mainFrame->GetBaseColumnWidth();
	m_orgCoverHeight    = g_mainFrame->GetBaseCoverHeight();

	wxFlexGridSizer* sizer3 = new wxFlexGridSizer(2, SJ_DLG_SPACE/2, SJ_DLG_SPACE);
	sizer1->Add(sizer3, 0, wxGROW|wxALL, SJ_DLG_SPACE);

	#define SLIDER_W 240

	// font face
	sizer3->Add(new wxStaticText(page, -1, _("Font:")), 0, wxALIGN_CENTER_VERTICAL);

	m_fontFaceChoice = new wxChoice(page, IDC_FONTFACECHOICE/*, wxDefaultPosition, wxSize(FONTFACE_W, -1)*/);

	const wxArrayString& fontFaces = g_tools->GetFacenames();

	wxString currFace;
	int facesIndex, facesCount = fontFaces.GetCount();
	for( facesIndex = 0; facesIndex < facesCount; facesIndex++ )
	{
		currFace = fontFaces.Item(facesIndex);
		if( currFace[0] != '?' && currFace[0] != '#' ) // ignore funny font names as "?234" eg. on os x/wx2.6.3
		{
			m_fontFaceChoice->Append(currFace);
			if( currFace.CmpNoCase(m_orgFace)==0 )
			{
				m_fontFaceChoice->SetSelection(m_fontFaceChoice->GetCount()-1);
			}
		}
	}

	SjDialog::SetCbWidth(m_fontFaceChoice);
	sizer3->Add(m_fontFaceChoice, 0, wxALIGN_CENTER_VERTICAL);

	// font size
	sizer3->Add(new wxStaticText(page, -1, _("Font size:")), 0, wxALIGN_CENTER_VERTICAL);

	wxBoxSizer* sizer4 = new wxBoxSizer(wxHORIZONTAL);
	sizer3->Add(sizer4);

	m_fontPtSlider = new wxSlider(page, IDC_FONTPTSLIDER, m_orgSize, SJ_MIN_FONT_SIZE, SJ_MAX_FONT_SIZE, wxDefaultPosition, wxSize(SLIDER_W, -1), wxSL_HORIZONTAL);
	sizer4->Add(m_fontPtSlider, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT, SJ_DLG_SPACE);

	m_fontPtText = new wxStaticText(page, -1, wxEmptyString);
	UpdateFontPtText(TRUE);
	sizer4->Add(m_fontPtText, 0, wxALIGN_CENTER_VERTICAL, 0);


	// use font in dialogs?
	sizer3->Add(SJ_DLG_SPACE, SJ_DLG_SPACE);

	m_useViewFontInDlgCheckBox = new wxCheckBox(page, -1, _("Use this font for dialogs, too"));
	m_useViewFontInDlgCheckBox->SetValue((g_accelModule->m_flags&SJ_ACCEL_USE_VIEW_FONT_IN_DLG)!=0);
	sizer3->Add(m_useViewFontInDlgCheckBox, 0, wxALIGN_CENTER_VERTICAL|wxBOTTOM, SJ_DLG_SPACE);

	// column width
	sizer3->Add(new wxStaticText(page, -1, _("Column width:")), 0, wxALIGN_CENTER_VERTICAL);

	sizer4 = new wxBoxSizer(wxHORIZONTAL);
	sizer3->Add(sizer4);

	m_columnWidthSlider = new wxSlider(page, IDC_COLUMNWIDTHSLIDER, m_orgColumnWidth/COLUMNWIDTH_DIVISOR, SJ_MIN_COLUMN_WIDTH/COLUMNWIDTH_DIVISOR, SJ_MAX_COLUMN_WIDTH/COLUMNWIDTH_DIVISOR, wxDefaultPosition, wxSize(SLIDER_W, -1), wxSL_HORIZONTAL);
	sizer4->Add(m_columnWidthSlider, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT, SJ_DLG_SPACE);

	m_columnWidthText = new wxStaticText(page, -1, wxEmptyString);
	UpdateColumnWidthText();
	sizer4->Add(m_columnWidthText, 0, wxALIGN_CENTER_VERTICAL);


	// cover height (= width = size)
	sizer3->Add(new wxStaticText(page, -1, _("Cover size:")), 0, wxALIGN_CENTER_VERTICAL);

	sizer4 = new wxBoxSizer(wxHORIZONTAL);
	sizer3->Add(sizer4);

	m_coverHeightSlider = new wxSlider(page, IDC_COVERHEIGHTSLIDER, m_orgCoverHeight, 1, 100, wxDefaultPosition, wxSize(SLIDER_W, -1), wxSL_HORIZONTAL);
	sizer4->Add(m_coverHeightSlider, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT, SJ_DLG_SPACE);

	m_coverHeightText = new wxStaticText(page, -1, wxEmptyString);
	UpdateCoverHeightText();
	sizer4->Add(m_coverHeightText, 0, wxALIGN_CENTER_VERTICAL);

	wxButton* button = new wxButton(page, IDC_FONTDEFAULT, _("Reset to default values"), wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT);
	sizer1->Add(button, 0, wxALL, SJ_DLG_SPACE);

	return page;
}