Fixes Atlas toolbar in wxOSX (only Realize() it after creation).

Fixes terrain preview not displaying first page in wxOSX.
Formats terrain page labels more nicely.
Adds a bunch of tooltips.

This was SVN commit r10131.
This commit is contained in:
historic_bruno 2011-08-29 03:50:29 +00:00
parent ded514644e
commit 6366ad728f
5 changed files with 98 additions and 41 deletions

View File

@ -452,7 +452,7 @@ ScenarioEditor::ScenarioEditor(wxWindow* parent, ScriptInterface& scriptInterfac
// wxOSX/Cocoa 2.9 doesn't seem to like SetToolBar, so we use CreateToolBar which implicitly associates
// the toolbar with the frame, and use OnCreateToolBar to construct our custom toolbar
// (this should be equivalent behavior on all platforms)
CreateToolBar(wxNO_BORDER|wxTB_FLAT|wxTB_HORIZONTAL, ID_Toolbar);
CreateToolBar(wxNO_BORDER|wxTB_FLAT|wxTB_HORIZONTAL, ID_Toolbar)->Realize();
// Set the default tool to be selected
m_ToolManager.SetCurrentTool(_T(""));
@ -539,8 +539,6 @@ wxToolBar* ScenarioEditor::OnCreateToolBar(long style, wxWindowID id, const wxSt
toolbar->AddToolButton(_("Flatten"), _("Flatten terrain elevation"), _T("flattenelevation.png"), _T("FlattenElevation"), _T("")/*_T("TerrainSidebar")*/);
toolbar->AddToolButton(_("Paint Terrain"), _("Paint terrain texture"), _T("paintterrain.png"), _T("PaintTerrain"), _T("")/*_T("TerrainSidebar")*/);
toolbar->Realize();
return toolbar;
}

View File

@ -147,11 +147,14 @@ void MapSettingsControl::CreateWidgets()
wxFlexGridSizer* gridSizer = new wxFlexGridSizer(2, 5, 5);
gridSizer->AddGrowableCol(1);
gridSizer->Add(new wxStaticText(this, wxID_ANY, _("Reveal map")), wxSizerFlags().Align(wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT));
gridSizer->Add(new wxCheckBox(this, ID_MapReveal, wxEmptyString));
gridSizer->Add(Tooltipped(new wxCheckBox(this, ID_MapReveal, wxEmptyString),
_("If checked, players won't need to explore")));
gridSizer->Add(new wxStaticText(this, wxID_ANY, _("Game type")), wxSizerFlags().Align(wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT));
gridSizer->Add(new wxChoice(this, ID_MapType, wxDefaultPosition, wxDefaultSize, gameTypes), wxSizerFlags().Expand());
gridSizer->Add(Tooltipped(new wxChoice(this, ID_MapType, wxDefaultPosition, wxDefaultSize, gameTypes),
_("Select the game type (or victory condition)")), wxSizerFlags().Expand());
gridSizer->Add(new wxStaticText(this, wxID_ANY, _("Lock teams")), wxSizerFlags().Align(wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT));
gridSizer->Add(new wxCheckBox(this, ID_MapTeams, wxEmptyString));
gridSizer->Add(Tooltipped(new wxCheckBox(this, ID_MapTeams, wxEmptyString),
_("NOT IMPLEMENTED")));
sizer->Add(gridSizer, wxSizerFlags().Expand());
sizer->AddSpacer(5);
@ -159,9 +162,11 @@ void MapSettingsControl::CreateWidgets()
wxStaticBoxSizer* keywordsSizer = new wxStaticBoxSizer(wxVERTICAL, this, _("Keywords"));
wxFlexGridSizer* kwGridSizer = new wxFlexGridSizer(2, 5, 5);
kwGridSizer->Add(new wxStaticText(this, wxID_ANY, _("Demo")), wxSizerFlags().Align(wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT));
kwGridSizer->Add(new wxCheckBox(this, ID_MapKW_Demo, wxEmptyString));
kwGridSizer->Add(Tooltipped(new wxCheckBox(this, ID_MapKW_Demo, wxEmptyString),
_("If checked, map will only be visible using filters in game setup")));
kwGridSizer->Add(new wxStaticText(this, wxID_ANY, _("Hidden")), wxSizerFlags().Align(wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT));
kwGridSizer->Add(new wxCheckBox(this, ID_MapKW_Hidden, wxEmptyString));
kwGridSizer->Add(Tooltipped(new wxCheckBox(this, ID_MapKW_Hidden, wxEmptyString),
_("If checked, map will only be visible using filters in game setup")));
keywordsSizer->Add(kwGridSizer);
sizer->Add(keywordsSizer, wxSizerFlags().Expand());
}
@ -262,8 +267,6 @@ MapSidebar::MapSidebar(ScenarioEditor& scenarioEditor, wxWindow* sidebarContaine
m_MapSettingsCtrl = new MapSettingsControl(this, m_ScenarioEditor);
m_MainSizer->Add(m_MapSettingsCtrl, wxSizerFlags().Expand());
m_MainSizer->Add(new wxButton(this, ID_OpenPlayerPanel, _T("Player settings")), wxSizerFlags().Expand().Border(wxTOP, 16));
{
/////////////////////////////////////////////////////////////////////////
// Random map settings
@ -273,6 +276,10 @@ MapSidebar::MapSidebar(ScenarioEditor& scenarioEditor, wxWindow* sidebarContaine
sizer->AddSpacer(5);
sizer->Add(new wxButton(this, ID_OpenPlayerPanel, _T("Change players")), wxSizerFlags().Expand());
sizer->AddSpacer(5);
wxFlexGridSizer* gridSizer = new wxFlexGridSizer(2, 5, 5);
gridSizer->AddGrowableCol(1);
@ -282,17 +289,20 @@ MapSidebar::MapSidebar(ScenarioEditor& scenarioEditor, wxWindow* sidebarContaine
gridSizer->Add(new wxStaticText(this, wxID_ANY, _("Random seed")), wxSizerFlags().Align(wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT));
wxBoxSizer* seedSizer = new wxBoxSizer(wxHORIZONTAL);
seedSizer->Add(Tooltipped(new wxTextCtrl(this, ID_RandomSeed, _T("0"), wxDefaultPosition, wxDefaultSize, 0, wxTextValidator(wxFILTER_NUMERIC)), _("Seed value for random map")), wxSizerFlags(1).Expand());
seedSizer->Add(Tooltipped(new wxButton(this, ID_RandomReseed, _("R"), wxDefaultPosition, wxSize(24, -1)), _("New random seed")));
seedSizer->Add(Tooltipped(new wxTextCtrl(this, ID_RandomSeed, _T("0"), wxDefaultPosition, wxDefaultSize, 0, wxTextValidator(wxFILTER_NUMERIC)),
_("Seed value for random map")), wxSizerFlags(1).Expand());
seedSizer->Add(Tooltipped(new wxButton(this, ID_RandomReseed, _("R"), wxDefaultPosition, wxSize(24, -1)),
_("New random seed")));
gridSizer->Add(seedSizer, wxSizerFlags().Expand());
sizer->Add(gridSizer, wxSizerFlags().Expand());
sizer->AddSpacer(5);
sizer->Add(new wxButton(this, ID_RandomGenerate, _("Generate map")), wxSizerFlags().Expand());
sizer->Add(Tooltipped(new wxButton(this, ID_RandomGenerate, _("Generate map")),
_("Run selected random map script")), wxSizerFlags().Expand());
m_MainSizer->Add(sizer, wxSizerFlags().Expand().Border(wxTOP, 16));
m_MainSizer->Add(sizer, wxSizerFlags().Expand().Border(wxTOP, 10));
}
{
@ -300,14 +310,19 @@ MapSidebar::MapSidebar(ScenarioEditor& scenarioEditor, wxWindow* sidebarContaine
// Simulation buttons
wxStaticBoxSizer* sizer = new wxStaticBoxSizer(wxVERTICAL, this, _("Simulation test"));
wxGridSizer* gridSizer = new wxGridSizer(5);
gridSizer->Add(new wxButton(this, ID_SimPlay, _("Play")), wxSizerFlags().Expand());
gridSizer->Add(new wxButton(this, ID_SimFast, _("Fast")), wxSizerFlags().Expand());
gridSizer->Add(new wxButton(this, ID_SimSlow, _("Slow")), wxSizerFlags().Expand());
gridSizer->Add(new wxButton(this, ID_SimPause, _("Pause")), wxSizerFlags().Expand());
gridSizer->Add(new wxButton(this, ID_SimReset, _("Reset")), wxSizerFlags().Expand());
gridSizer->Add(Tooltipped(new wxButton(this, ID_SimPlay, _("Play")),
_("Run the simulation at normal speed")), wxSizerFlags().Expand());
gridSizer->Add(Tooltipped(new wxButton(this, ID_SimFast, _("Fast")),
_("Run the simulation at 8x speed")), wxSizerFlags().Expand());
gridSizer->Add(Tooltipped(new wxButton(this, ID_SimSlow, _("Slow")),
_("Run the simulation at 1/8x speed")), wxSizerFlags().Expand());
gridSizer->Add(Tooltipped(new wxButton(this, ID_SimPause, _("Pause")),
_("Pause the simulation")), wxSizerFlags().Expand());
gridSizer->Add(Tooltipped(new wxButton(this, ID_SimReset, _("Reset")),
_("Reset the editor to initial state")), wxSizerFlags().Expand());
sizer->Add(gridSizer, wxSizerFlags().Expand());
UpdateSimButtons();
m_MainSizer->Add(sizer, wxSizerFlags().Expand().Border(wxTOP, 16));
m_MainSizer->Add(sizer, wxSizerFlags().Expand().Border(wxTOP, 10));
}
}

View File

@ -113,8 +113,8 @@ ObjectSidebar::ObjectSidebar(ScenarioEditor& scenarioEditor, wxWindow* sidebarCo
{
wxBoxSizer* sizer = new wxBoxSizer(wxHORIZONTAL);
sizer->Add(new wxStaticText(this, wxID_ANY, _("Filter")), wxSizerFlags().Align(wxALIGN_CENTER));
wxTextCtrl* objectFilter = new wxTextCtrl(this, ID_ObjectFilter);
sizer->Add(objectFilter, wxSizerFlags().Expand().Proportion(1));
sizer->Add(Tooltipped(new wxTextCtrl(this, ID_ObjectFilter),
_("Enter text to filter object list")), wxSizerFlags().Expand().Proportion(1));
m_MainSizer->Add(sizer, wxSizerFlags().Expand());
wxArrayString strings;
@ -193,10 +193,17 @@ void ObjectSidebar::FilterObjects()
void ObjectSidebar::ToggleViewer(wxCommandEvent& WXUNUSED(evt))
{
// Change name of button
if (p->m_ActorViewerActive)
{
wxDynamicCast(FindWindow(ID_ToggleViewer), wxButton)->SetLabel(_("Switch to actor viewer"));
m_ScenarioEditor.GetToolManager().SetCurrentTool(_T(""), NULL);
}
else
{
wxDynamicCast(FindWindow(ID_ToggleViewer), wxButton)->SetLabel(_("Return to game view"));
m_ScenarioEditor.GetToolManager().SetCurrentTool(_T("ActorViewerTool"), NULL);
}
}
void ObjectSidebar::OnSelectType(wxCommandEvent& WXUNUSED(evt))

View File

@ -85,11 +85,13 @@ public:
m_Controls.civ = civChoice;
gridSizer->Add(new wxStaticText(this, wxID_ANY, _("Colour")), wxSizerFlags().Align(wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT));
wxButton* colourButton = new wxButton(this, ID_PlayerColour);
gridSizer->Add(Tooltipped(colourButton, _("Set player colour")), wxSizerFlags(1).Expand().Align(wxALIGN_RIGHT));
gridSizer->Add(Tooltipped(colourButton,
_("Set player colour")), wxSizerFlags(1).Expand().Align(wxALIGN_RIGHT));
m_Controls.colour = colourButton;
gridSizer->Add(new wxStaticText(this, wxID_ANY, _("Default AI")), wxSizerFlags().Align(wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT));
wxChoice* aiChoice = new wxChoice(this, wxID_ANY);
gridSizer->Add(Tooltipped(aiChoice, _("Select default AI")), wxSizerFlags(1).Expand().Align(wxALIGN_RIGHT));
gridSizer->Add(Tooltipped(aiChoice,
_("Select default AI")), wxSizerFlags(1).Expand().Align(wxALIGN_RIGHT));
m_Controls.ai = aiChoice;
playerInfoSizer->Add(gridSizer, wxSizerFlags(1).Expand());
@ -104,23 +106,28 @@ public:
gridSizer->AddGrowableCol(1);
gridSizer->Add(new wxStaticText(this, wxID_ANY, _("Food")), wxSizerFlags().Align(wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT));
wxSpinCtrl* foodCtrl = new wxSpinCtrl(this, ID_PlayerFood, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, 0, INT_MAX);
gridSizer->Add(Tooltipped(foodCtrl, _("Initial value of food resource")), wxSizerFlags().Expand());
gridSizer->Add(Tooltipped(foodCtrl,
_("Initial value of food resource")), wxSizerFlags().Expand());
m_Controls.food = foodCtrl;
gridSizer->Add(new wxStaticText(this, wxID_ANY, _("Wood")), wxSizerFlags().Align(wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT));
wxSpinCtrl* woodCtrl = new wxSpinCtrl(this, ID_PlayerWood, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, 0, INT_MAX);
gridSizer->Add(Tooltipped(woodCtrl, _("Initial value of wood resource")), wxSizerFlags().Expand());
gridSizer->Add(Tooltipped(woodCtrl,
_("Initial value of wood resource")), wxSizerFlags().Expand());
m_Controls.wood = woodCtrl;
gridSizer->Add(new wxStaticText(this, wxID_ANY, _("Metal")), wxSizerFlags().Align(wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT));
wxSpinCtrl* metalCtrl = new wxSpinCtrl(this, ID_PlayerMetal, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, 0, INT_MAX);
gridSizer->Add(Tooltipped(metalCtrl, _("Initial value of metal resource")), wxSizerFlags().Expand());
gridSizer->Add(Tooltipped(metalCtrl,
_("Initial value of metal resource")), wxSizerFlags().Expand());
m_Controls.metal = metalCtrl;
gridSizer->Add(new wxStaticText(this, wxID_ANY, _("Stone")), wxSizerFlags().Align(wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT));
wxSpinCtrl* stoneCtrl = new wxSpinCtrl(this, ID_PlayerStone, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, 0, INT_MAX);
gridSizer->Add(Tooltipped(stoneCtrl, _("Initial value of stone resource")), wxSizerFlags().Expand());
gridSizer->Add(Tooltipped(stoneCtrl,
_("Initial value of stone resource")), wxSizerFlags().Expand());
m_Controls.stone = stoneCtrl;
gridSizer->Add(new wxStaticText(this, wxID_ANY, _("Pop limit")), wxSizerFlags().Align(wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT));
wxSpinCtrl* popCtrl = new wxSpinCtrl(this, ID_PlayerPop, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, 0, INT_MAX);
gridSizer->Add(Tooltipped(popCtrl, _("Population limit for this player")), wxSizerFlags().Expand());
gridSizer->Add(Tooltipped(popCtrl,
_("Population limit for this player")), wxSizerFlags().Expand());
m_Controls.pop = popCtrl;
resourceSizer->Add(gridSizer, wxSizerFlags(1).Expand());
@ -157,13 +164,16 @@ public:
wxStaticBoxSizer* cameraSizer = new wxStaticBoxSizer(wxVERTICAL, this, _("Starting Camera"));
wxGridSizer* gridSizer = new wxGridSizer(3);
wxButton* cameraSet = new wxButton(this, ID_CameraSet, _("Set"));
gridSizer->Add(Tooltipped(cameraSet, _("Set player camera to this view")), wxSizerFlags().Expand());
gridSizer->Add(Tooltipped(cameraSet,
_("Set player camera to this view")), wxSizerFlags().Expand());
wxButton* cameraView = new wxButton(this, ID_CameraView, _("View"));
cameraView->Enable(false);
gridSizer->Add(Tooltipped(cameraView, _("View the player camera")), wxSizerFlags().Expand());
gridSizer->Add(Tooltipped(cameraView,
_("View the player camera")), wxSizerFlags().Expand());
wxButton* cameraClear = new wxButton(this, ID_CameraClear, _("Clear"));
cameraClear->Enable(false);
gridSizer->Add(Tooltipped(cameraClear, _("Clear player camera")), wxSizerFlags().Expand());
gridSizer->Add(Tooltipped(cameraClear,
_("Clear player camera")), wxSizerFlags().Expand());
cameraSizer->Add(gridSizer, wxSizerFlags().Expand());
sizer->Add(cameraSizer, wxSizerFlags().Expand().Border(wxTOP, 10));

View File

@ -53,6 +53,13 @@ enum
ID_ResizeMap
};
// Helper function for adding tooltips
static wxWindow* Tooltipped(wxWindow* window, const wxString& tip)
{
window->SetToolTip(tip);
return window;
}
TerrainSidebar::TerrainSidebar(ScenarioEditor& scenarioEditor, wxWindow* sidebarContainer, wxWindow* bottomBarContainer) :
Sidebar(scenarioEditor, sidebarContainer, bottomBarContainer)
{
@ -61,9 +68,12 @@ TerrainSidebar::TerrainSidebar(ScenarioEditor& scenarioEditor, wxWindow* sidebar
// Terrain elevation
wxSizer* sizer = new wxStaticBoxSizer(wxVERTICAL, this, _("Elevation tools"));
wxSizer* gridSizer = new wxGridSizer(3);
gridSizer->Add(new ToolButton(scenarioEditor.GetToolManager(), this, _("Modify"), _T("AlterElevation")), wxSizerFlags().Expand());
gridSizer->Add(new ToolButton(scenarioEditor.GetToolManager(), this, _("Smooth"), _T("SmoothElevation")), wxSizerFlags().Expand());
gridSizer->Add(new ToolButton(scenarioEditor.GetToolManager(), this, _("Flatten"), _T("FlattenElevation")), wxSizerFlags().Expand());
gridSizer->Add(Tooltipped(new ToolButton(scenarioEditor.GetToolManager(), this, _("Modify"), _T("AlterElevation")),
_("Brush with left mouse buttons to raise terrain,\nright mouse button to lower it")), wxSizerFlags().Expand());
gridSizer->Add(Tooltipped(new ToolButton(scenarioEditor.GetToolManager(), this, _("Smooth"), _T("SmoothElevation")),
_("Brush with left mouse button to smooth terrain,\nright mouse button to roughen it")), wxSizerFlags().Expand());
gridSizer->Add(Tooltipped(new ToolButton(scenarioEditor.GetToolManager(), this, _("Flatten"), _T("FlattenElevation")),
_("Brush with left mouse button to flatten terrain")), wxSizerFlags().Expand());
sizer->Add(gridSizer, wxSizerFlags().Expand());
m_MainSizer->Add(sizer, wxSizerFlags().Expand().Border(wxTOP, 10));
}
@ -73,9 +83,12 @@ TerrainSidebar::TerrainSidebar(ScenarioEditor& scenarioEditor, wxWindow* sidebar
// Terrain texture
wxSizer* sizer = new wxStaticBoxSizer(wxVERTICAL, this, _("Texture tools"));
wxSizer* gridSizer = new wxGridSizer(3);
gridSizer->Add(new ToolButton(scenarioEditor.GetToolManager(), this, _("Paint"), _T("PaintTerrain")), wxSizerFlags().Expand());
gridSizer->Add(new ToolButton(scenarioEditor.GetToolManager(), this, _("Replace"), _T("ReplaceTerrain")), wxSizerFlags().Expand());
gridSizer->Add(new ToolButton(scenarioEditor.GetToolManager(), this, _("Fill"), _T("FillTerrain")), wxSizerFlags().Expand());
gridSizer->Add(Tooltipped(new ToolButton(scenarioEditor.GetToolManager(), this, _("Paint"), _T("PaintTerrain")),
_("Brush with left mouse button to paint texture dominantly,\nright mouse button to paint submissively")), wxSizerFlags().Expand());
gridSizer->Add(Tooltipped(new ToolButton(scenarioEditor.GetToolManager(), this, _("Replace"), _T("ReplaceTerrain")),
_("Replace all of a terrain texture with a new one")), wxSizerFlags().Expand());
gridSizer->Add(Tooltipped(new ToolButton(scenarioEditor.GetToolManager(), this, _("Fill"), _T("FillTerrain")),
_T("Bucket fill a patch of terrain texture with a new one")), wxSizerFlags().Expand());
sizer->Add(gridSizer, wxSizerFlags().Expand());
m_MainSizer->Add(sizer, wxSizerFlags().Expand().Border(wxTOP, 10));
}
@ -104,10 +117,12 @@ TerrainSidebar::TerrainSidebar(ScenarioEditor& scenarioEditor, wxWindow* sidebar
m_PassabilityChoice->SetSelection(0);
visSizer->Add(new wxStaticText(this, wxID_ANY, _("Passability")), wxSizerFlags().Align(wxALIGN_CENTER|wxALIGN_RIGHT));
visSizer->Add(m_PassabilityChoice, wxSizerFlags().Expand());
visSizer->Add(Tooltipped(m_PassabilityChoice,
_("View passability classes")), wxSizerFlags().Expand());
visSizer->Add(new wxStaticText(this, wxID_ANY, _("Priorities")), wxSizerFlags().Align(wxALIGN_CENTER|wxALIGN_RIGHT));
visSizer->Add(new wxCheckBox(this, ID_ShowPriorities, _("")));
visSizer->Add(Tooltipped(new wxCheckBox(this, ID_ShowPriorities, _("")),
_("Show terrain texture priorities")));
}
{
@ -164,7 +179,7 @@ void TerrainSidebar::OnResizeMap(wxCommandEvent& WXUNUSED(evt))
// TODO: set default based on current map size
wxSingleChoiceDialog dlg(this, _("Select new map size. WARNING: This probably only works reliably on blank maps, and cannot be undone."),
wxSingleChoiceDialog dlg(this, _("Select new map size. WARNING: This probably only works reliably on blank maps."),
_("Resize map"), sizeNames);
if (dlg.ShowModal() != wxID_OK)
@ -244,6 +259,8 @@ public:
// Add spaces into the displayed name so there are more wrapping opportunities
wxString labelText = name;
if (labelText.Len())
labelText[0] = wxToupper(labelText[0]);
labelText.Replace(_T("_"), _T(" "));
wxStaticText* label = new wxStaticText(m_ScrolledPanel, wxID_ANY, labelText, wxDefaultPosition, wxDefaultSize, wxALIGN_CENTER);
label->Wrap(imageWidth);
@ -357,10 +374,20 @@ public:
for (size_t i = 0; i < m_TerrainGroups.GetCount(); ++i)
{
wxString visibleName = m_TerrainGroups[i];
// Format name slightly
if (visibleName.Len())
visibleName[0] = wxToupper(visibleName[0]);
visibleName.Replace(_T("_"), _T(" "));
AddPage(new TextureNotebookPage(m_ScenarioEditor, this, m_TerrainGroups[i]), visibleName);
}
// On some platforms (wxOSX) there is no initial OnPageChanged event, so it loads with a blank page
// and setting selection to 0 won't trigger it either, so just force first page to display
// (this is safe because the sidebar has already been displayed)
if (GetPageCount() > 0)
{
static_cast<TextureNotebookPage*>(GetPage(0))->OnDisplay();
}
}
protected: