Actor Editor: Most-recently-used files list. 'New' menu item. Shuffled some header inclusions around.
This was SVN commit r2069.
This commit is contained in:
parent
36cd555ba7
commit
71705b5aa4
@ -3,12 +3,8 @@
|
||||
#include "ActorEditor.h"
|
||||
|
||||
#include "ActorEditorListCtrl.h"
|
||||
|
||||
#include "AtlasObject/AtlasObject.h"
|
||||
|
||||
#include "wx/panel.h"
|
||||
#include "wx/sizer.h"
|
||||
|
||||
ActorEditor::ActorEditor(wxWindow* parent)
|
||||
: AtlasWindow(parent, _("Actor Editor"), wxSize(1024, 450))
|
||||
{
|
||||
@ -67,6 +63,14 @@ ActorEditor::ActorEditor(wxWindow* parent)
|
||||
|
||||
void ActorEditor::Import(AtObj& in)
|
||||
{
|
||||
if (! in.defined())
|
||||
{
|
||||
// 'Importing' a new blank file. Fill it in with default values:
|
||||
AtObj actor;
|
||||
actor.add("@version", L"1");
|
||||
in.add("actor", actor);
|
||||
}
|
||||
|
||||
// Determine the file format version
|
||||
long version;
|
||||
|
||||
|
@ -2,7 +2,6 @@
|
||||
#define EDITABLELISTCTRL_H__
|
||||
|
||||
#include "wx/listctrl.h"
|
||||
#include "wx/arrstr.h"
|
||||
|
||||
#include "IAtlasExporter.h"
|
||||
|
||||
|
@ -36,8 +36,7 @@ void FieldEditCtrl_List::StartEdit(wxWindow* parent, wxRect rect, long row, int
|
||||
wxArrayString choices;
|
||||
|
||||
AtObj list (Datafile::ReadList(m_ListType));
|
||||
AtIter items (list["item"]);
|
||||
for (AtIter it = items; it.defined(); ++it)
|
||||
for (AtIter it = list["item"]; it.defined(); ++it)
|
||||
choices.Add(it);
|
||||
|
||||
new QuickComboBox(parent, rect, choices, ListCtrlValidator((EditableListCtrl*)parent, row, col));
|
||||
|
@ -1,6 +1,3 @@
|
||||
#include "wx/validate.h"
|
||||
#include "wx/listctrl.h"
|
||||
|
||||
class EditableListCtrl;
|
||||
|
||||
class ListCtrlValidator : public wxValidator
|
||||
|
@ -1,5 +1,3 @@
|
||||
#include "wx/combobox.h"
|
||||
|
||||
class QuickComboBox : public wxComboBox
|
||||
{
|
||||
public:
|
||||
|
@ -1,6 +1,7 @@
|
||||
#include "stdafx.h"
|
||||
|
||||
#include "QuickFileCtrl.h"
|
||||
|
||||
#include "wx/filename.h"
|
||||
|
||||
const int verticalPadding = 2;
|
||||
|
@ -1,3 +1,5 @@
|
||||
#include "wx/panel.h"
|
||||
|
||||
class QuickFileCtrl : public wxPanel
|
||||
{
|
||||
DECLARE_DYNAMIC_CLASS(QuickFileCtrl);
|
||||
|
@ -1,5 +1,3 @@
|
||||
#include "wx/textctrl.h"
|
||||
|
||||
class QuickTextCtrl : public wxTextCtrl
|
||||
{
|
||||
public:
|
||||
|
@ -4,9 +4,8 @@
|
||||
|
||||
#include "AtlasObject/AtlasObject.h"
|
||||
|
||||
#include "wx/intl.h"
|
||||
#include "wx/menu.h"
|
||||
#include "wx/artprov.h"
|
||||
#include "wx/config.h"
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@ -57,6 +56,7 @@ IMPLEMENT_CLASS(AtlasWindow, wxFrame);
|
||||
enum
|
||||
{
|
||||
ID_Quit = 1,
|
||||
ID_New,
|
||||
// ID_Import,
|
||||
// ID_Export,
|
||||
ID_Open,
|
||||
@ -65,20 +65,24 @@ enum
|
||||
};
|
||||
|
||||
BEGIN_EVENT_TABLE(AtlasWindow, wxFrame)
|
||||
EVT_MENU(ID_Quit, AtlasWindow::OnQuit)
|
||||
EVT_MENU(ID_New, AtlasWindow::OnNew)
|
||||
// EVT_MENU(ID_Import, AtlasWindow::OnImport)
|
||||
// EVT_MENU(ID_Export, AtlasWindow::OnExport)
|
||||
EVT_MENU(ID_Open, AtlasWindow::OnOpen)
|
||||
EVT_MENU(ID_Save, AtlasWindow::OnSave)
|
||||
EVT_MENU(ID_SaveAs, AtlasWindow::OnSaveAs)
|
||||
EVT_MENU_RANGE(wxID_FILE1, wxID_FILE9, AtlasWindow::OnMRUFile)
|
||||
EVT_MENU(ID_Quit, AtlasWindow::OnQuit)
|
||||
|
||||
EVT_MENU(wxID_UNDO, AtlasWindow::OnUndo)
|
||||
EVT_MENU(wxID_REDO, AtlasWindow::OnRedo)
|
||||
|
||||
EVT_CLOSE(AtlasWindow::OnClose)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
AtlasWindow::AtlasWindow(wxWindow* parent, const wxString& title, const wxSize& size)
|
||||
: wxFrame(parent, wxID_ANY, _T(""), wxDefaultPosition, size)
|
||||
, m_WindowTitle(title)
|
||||
: wxFrame(parent, wxID_ANY, _T(""), wxDefaultPosition, size),
|
||||
m_WindowTitle(title), m_FileHistory(9)
|
||||
{
|
||||
|
||||
wxMenuBar *menuBar = new wxMenuBar;
|
||||
@ -87,6 +91,7 @@ AtlasWindow::AtlasWindow(wxWindow* parent, const wxString& title, const wxSize&
|
||||
wxMenu *menuFile = new wxMenu;
|
||||
menuBar->Append(menuFile, _("&File"));
|
||||
{
|
||||
menuFile->Append(ID_New, _("&New"));
|
||||
// menuFile->Append(ID_Import, _("&Import..."));
|
||||
// menuFile->Append(ID_Export, _("&Export..."));
|
||||
menuFile->Append(ID_Open, _("&Open..."));
|
||||
@ -94,6 +99,8 @@ AtlasWindow::AtlasWindow(wxWindow* parent, const wxString& title, const wxSize&
|
||||
menuFile->Append(ID_SaveAs, _("Save &As..."));
|
||||
menuFile->AppendSeparator();//-----------
|
||||
menuFile->Append(ID_Quit, _("E&xit"));
|
||||
m_FileHistory.UseMenu(menuFile);//-------
|
||||
m_FileHistory.AddFilesToMenu();
|
||||
}
|
||||
|
||||
m_menuItem_Save = menuFile->FindItem(ID_Save); // to let it be greyed out
|
||||
@ -109,6 +116,8 @@ AtlasWindow::AtlasWindow(wxWindow* parent, const wxString& title, const wxSize&
|
||||
m_CommandProc.SetEditMenu(menuEdit);
|
||||
m_CommandProc.Initialize();
|
||||
|
||||
m_FileHistory.Load(*wxConfigBase::Get());
|
||||
|
||||
CreateStatusBar();
|
||||
//SetStatusText(_("Welcome to wxWidgets!"));
|
||||
|
||||
@ -142,6 +151,9 @@ void AtlasWindow::OnClose(wxCloseEvent& event)
|
||||
assert(ret == wxID_CANCEL);
|
||||
event.Veto();
|
||||
}
|
||||
|
||||
if (event.GetSkipped())
|
||||
m_FileHistory.Save(*wxConfigBase::Get());
|
||||
}
|
||||
|
||||
void AtlasWindow::OnUndo(wxCommandEvent& WXUNUSED(event))
|
||||
@ -165,6 +177,12 @@ void AtlasWindow::OnRedo(wxCommandEvent& WXUNUSED(event))
|
||||
// ...
|
||||
//}
|
||||
|
||||
void AtlasWindow::OnNew(wxCommandEvent& WXUNUSED(event))
|
||||
{
|
||||
AtObj blank;
|
||||
Import(blank);
|
||||
SetCurrentFilename();
|
||||
}
|
||||
|
||||
void AtlasWindow::OnOpen(wxCommandEvent& WXUNUSED(event))
|
||||
{
|
||||
@ -186,6 +204,14 @@ void AtlasWindow::OnSaveAs(wxCommandEvent& WXUNUSED(event))
|
||||
SaveChanges(true);
|
||||
}
|
||||
|
||||
void AtlasWindow::OnMRUFile(wxCommandEvent& event)
|
||||
{
|
||||
wxString file (m_FileHistory.GetHistoryFile(event.GetId() - wxID_FILE1));
|
||||
if (file.Length())
|
||||
OpenFile(file);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void AtlasWindow::SetCurrentFilename(wxFileName filename)
|
||||
{
|
||||
@ -213,7 +239,10 @@ bool AtlasWindow::SaveChanges(bool forceSaveAs)
|
||||
if (dlg.ShowModal() != wxID_OK)
|
||||
return false;
|
||||
|
||||
SetCurrentFilename(dlg.GetPath());
|
||||
wxString filename(dlg.GetPath());
|
||||
|
||||
m_FileHistory.AddFileToHistory(filename);
|
||||
SetCurrentFilename(filename);
|
||||
}
|
||||
|
||||
if (! GetCurrentFilename().IsOk())
|
||||
@ -237,6 +266,7 @@ bool AtlasWindow::OpenFile(wxString filename)
|
||||
|
||||
Import(file);
|
||||
|
||||
m_FileHistory.AddFileToHistory(filename);
|
||||
SetCurrentFilename(filename);
|
||||
|
||||
return true;
|
||||
|
@ -2,8 +2,8 @@
|
||||
|
||||
#include "IAtlasExporter.h"
|
||||
|
||||
#include "wx/frame.h"
|
||||
#include "wx/filename.h"
|
||||
#include "wx/docview.h"
|
||||
|
||||
class AtObj;
|
||||
|
||||
@ -16,22 +16,23 @@ class AtlasWindow : public wxFrame, public IAtlasExporter
|
||||
public:
|
||||
AtlasWindow(wxWindow* parent, const wxString& title, const wxSize& size);
|
||||
|
||||
void OnQuit(wxCommandEvent& event);
|
||||
|
||||
void OnNew(wxCommandEvent& event);
|
||||
// void OnImport(wxCommandEvent& event);
|
||||
// void OnExport(wxCommandEvent& event);
|
||||
|
||||
// TODO: import/export vs open/save/saveas - how should it decide which to do?
|
||||
void OnOpen(wxCommandEvent& event);
|
||||
void OnSave(wxCommandEvent& event);
|
||||
void OnSaveAs(wxCommandEvent& event);
|
||||
|
||||
void OnQuit(wxCommandEvent& event);
|
||||
|
||||
void OnMRUFile(wxCommandEvent& event);
|
||||
|
||||
void OnUndo(wxCommandEvent& event);
|
||||
void OnRedo(wxCommandEvent& event);
|
||||
|
||||
void OnClose(wxCloseEvent& event);
|
||||
|
||||
|
||||
protected:
|
||||
void SetCurrentFilename(wxFileName filename = wxString());
|
||||
wxFileName GetCurrentFilename() { return m_CurrentFilename; }
|
||||
@ -48,5 +49,7 @@ private:
|
||||
wxFileName m_CurrentFilename;
|
||||
wxString m_WindowTitle;
|
||||
|
||||
wxFileHistory m_FileHistory;
|
||||
|
||||
DECLARE_EVENT_TABLE();
|
||||
};
|
||||
|
@ -1,5 +1,7 @@
|
||||
#include "stdafx.h"
|
||||
|
||||
#include "AtlasWindowCommandProc.h"
|
||||
|
||||
#include "AtlasWindow.h"
|
||||
#include "AtlasWindowCommand.h"
|
||||
#include "AtlasDialog.h"
|
||||
|
@ -2,7 +2,6 @@
|
||||
#define ATLASWINDOWCOMMANDPROC_H__
|
||||
|
||||
#include "wx/cmdproc.h"
|
||||
#include "wx/window.h"
|
||||
|
||||
class AtlasWindowCommandProc : public wxCommandProcessor
|
||||
{
|
||||
|
@ -1,6 +1,7 @@
|
||||
#include "stdafx.h"
|
||||
|
||||
#include "Datafile.h"
|
||||
|
||||
#include "wx/filename.h"
|
||||
|
||||
AtObj Datafile::ReadList(const char* section)
|
||||
|
@ -5,13 +5,16 @@
|
||||
#include "ActorEditor/ActorEditor.h"
|
||||
#include "Datafile.h"
|
||||
|
||||
#include "wx/app.h"
|
||||
#include "wx/file.h"
|
||||
#include "wx/config.h"
|
||||
|
||||
class MyApp: public wxApp
|
||||
{
|
||||
bool OnInit()
|
||||
{
|
||||
// Initialise the global config file
|
||||
wxConfigBase::Set(new wxConfig(_T("Atlas Editor"), _T("Wildfire Games")));
|
||||
|
||||
// Display the Actor Editor window
|
||||
AtlasWindow *frame = new ActorEditor(NULL);
|
||||
frame->Show();
|
||||
@ -35,6 +38,7 @@ class MyApp: public wxApp
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
IMPLEMENT_APP(MyApp)
|
||||
|
@ -12,8 +12,14 @@
|
||||
// Include useful wx headers
|
||||
#include "wx/wxprec.h"
|
||||
#include "wx/listctrl.h"
|
||||
#include "wx/docview.h"
|
||||
#include "wx/cmdproc.h"
|
||||
#include "wx/dialog.h"
|
||||
#include "wx/filename.h"
|
||||
#include "wx/artprov.h"
|
||||
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
// Nicer memory-leak detection:
|
||||
#ifdef _DEBUG
|
||||
@ -22,3 +28,8 @@
|
||||
#endif
|
||||
|
||||
#endif // HAVE_PCH
|
||||
|
||||
#ifndef HAVE_PCH
|
||||
// If no PCH, just include a load of common headers anyway
|
||||
# include "wx/wx.h"
|
||||
#endif
|
||||
|
@ -1,5 +1,7 @@
|
||||
* Open from prop-actor selection
|
||||
|
||||
* Make import undo work with multi-control windows, and update the title bar
|
||||
|
||||
===
|
||||
|
||||
* 'Create entity' button (take name, parent)
|
||||
@ -16,14 +18,16 @@
|
||||
|
||||
* Better colouring in test_dude.xml, where some variants have no data
|
||||
|
||||
* Tab to move between fields
|
||||
|
||||
===
|
||||
|
||||
* Correct undo menu entry when selecting 'New' (so it's not 'Import')
|
||||
|
||||
* Save on exit: don't ask if no changes
|
||||
|
||||
* Browse for meshes/actors/etc, in a more nice/correct/unbuggy way
|
||||
|
||||
* Make import undo work with multi-control windows, and update the title bar
|
||||
|
||||
* Window size memory
|
||||
|
||||
* Column width memory
|
||||
@ -36,8 +40,6 @@
|
||||
|
||||
* Customised AtObj->string conversion
|
||||
|
||||
* Import/export filter, for validation(?) and for handling attributes
|
||||
|
||||
* Undo in text-editing boxes
|
||||
|
||||
* AtlasObjectXML error handling
|
||||
@ -46,13 +48,23 @@
|
||||
|
||||
* Fix Escape in combo boxes inside dialogs
|
||||
|
||||
===
|
||||
* Make wxFileHistory work when not at the very end of a menu
|
||||
|
||||
===
|
||||
|
||||
* Document lots
|
||||
|
||||
* wxListItemAttr* OnGetItemAttr(long item) >>>const<<< - wx documentation??
|
||||
* wxListItemAttr* OnGetItemAttr(long item) >>>const<<< - wx documentation wrong?
|
||||
|
||||
* Better column widths / window sizes
|
||||
|
||||
* Don't create a row when editing a blank one then removing focus without typing anything
|
||||
|
||||
|
||||
======
|
||||
|
||||
Done:
|
||||
|
||||
* MRU file list
|
||||
* 'New' menu item
|
||||
* Import/export filter, for validation(?) and for handling attributes
|
||||
|
Loading…
Reference in New Issue
Block a user