1
0
forked from 0ad/0ad

Atlas: Simple (and ugly and unreliable) interface to rmgen

This was SVN commit r2735.
This commit is contained in:
Ykkrosh 2005-09-16 05:29:40 +00:00
parent 599452af85
commit f0885bde69
2 changed files with 29 additions and 7 deletions

View File

@ -1,25 +1,27 @@
class ActionButton : public wxButton
{
typedef void (*actionFun)();
typedef void (*actionFun)(void* data);
public:
ActionButton(wxWindow *parent,
const wxString& label,
actionFun fun,
void* data,
const wxSize& size = wxDefaultSize,
long style = 0)
: wxButton(parent, wxID_ANY, label, wxDefaultPosition, size, style),
m_Fun(fun)
m_Fun(fun), m_Data(data)
{
}
protected:
virtual void OnClick(wxCommandEvent&)
{
m_Fun();
m_Fun(m_Data);
}
private:
actionFun m_Fun;
void* m_Data;
DECLARE_EVENT_TABLE();
};

View File

@ -7,12 +7,13 @@
#include "GameInterface/Messages.h"
static void LoadMap()
static void LoadMap(void*)
{
wxFileDialog dlg (NULL, wxFileSelectorPromptStr, Datafile::GetDataDirectory()+_T("/mods/official/maps/scenarios"),
_T(""), _T("PMP files (*.pmp)|*.pmp|All files (*.*)|*.*"), wxOPEN);
if (dlg.ShowModal() == wxID_OK)
{
// TODO: Work when the map is not in .../maps/scenarios/
std::wstring map = dlg.GetFilename().c_str();
POST_COMMAND(LoadMap(map));
}
@ -20,17 +21,36 @@ static void LoadMap()
// TODO: Make this a non-undoable command
}
static void GenerateMap()
static void GenerateMap(void*)
{
POST_COMMAND(GenerateMap(9));
}
static void GenerateRMS(void* data)
{
wxChar* argv[] = { _T("rmgen.exe"), 0, _T("_atlasrm"), 0 };
wxString scriptName = ((wxTextCtrl*)data)->GetValue();
argv[1] = const_cast<wxChar*>(scriptName.c_str());
wxExecute(argv, wxEXEC_SYNC);
POST_COMMAND(LoadMap(L"_atlasrm.pmp"));
}
//////////////////////////////////////////////////////////////////////////
MapSidebar::MapSidebar(wxWindow* parent)
: Sidebar(parent)
{
// TODO: Less ugliness
// TODO: Intercept arrow keys and send them to the GL window
m_MainSizer->Add(new ActionButton(this, _T("Load existing map"), &LoadMap));
m_MainSizer->Add(new ActionButton(this, _T("Generate empty map"), &GenerateMap));
m_MainSizer->Add(new ActionButton(this, _T("Load existing map"), &LoadMap, NULL));
m_MainSizer->Add(new ActionButton(this, _T("Generate empty map"), &GenerateMap, NULL));
{
wxSizer* sizer = new wxBoxSizer(wxHORIZONTAL);
m_MainSizer->Add(sizer);
wxTextCtrl* text = new wxTextCtrl(this, wxID_ANY, _T("cantabrian_highlands"));
sizer->Add(text);
sizer->Add(new ActionButton(this, _T("Generate RMS"), &GenerateRMS, text));
}
}