diff --git a/source/tools/atlas/Atlas.sln b/source/tools/atlas/Atlas.sln index 519fadf1df..4676956056 100644 --- a/source/tools/atlas/Atlas.sln +++ b/source/tools/atlas/Atlas.sln @@ -8,6 +8,16 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "AtlasObject", "AtlasObject\ ProjectSection(ProjectDependencies) = postProject EndProjectSection EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ActorEditor", "AtlasFrontends\ActorEditor.vcproj", "{E859DDC0-224A-41F6-B09F-E320EC8DDA35}" + ProjectSection(ProjectDependencies) = postProject + {E99BA969-D540-4F23-822E-37C499E8F704} = {E99BA969-D540-4F23-822E-37C499E8F704} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ColourTester", "AtlasFrontends\ColourTester.vcproj", "{C018BE85-EBFE-428E-8626-3CCB77052715}" + ProjectSection(ProjectDependencies) = postProject + {E99BA969-D540-4F23-822E-37C499E8F704} = {E99BA969-D540-4F23-822E-37C499E8F704} + EndProjectSection +EndProject Global GlobalSection(SolutionConfiguration) = preSolution Debug = Debug @@ -22,6 +32,14 @@ Global {228B468D-3C2E-45BF-9833-C626E1A35B04}.Debug.Build.0 = Debug|Win32 {228B468D-3C2E-45BF-9833-C626E1A35B04}.Release.ActiveCfg = Release|Win32 {228B468D-3C2E-45BF-9833-C626E1A35B04}.Release.Build.0 = Release|Win32 + {E859DDC0-224A-41F6-B09F-E320EC8DDA35}.Debug.ActiveCfg = Debug|Win32 + {E859DDC0-224A-41F6-B09F-E320EC8DDA35}.Debug.Build.0 = Debug|Win32 + {E859DDC0-224A-41F6-B09F-E320EC8DDA35}.Release.ActiveCfg = Release|Win32 + {E859DDC0-224A-41F6-B09F-E320EC8DDA35}.Release.Build.0 = Release|Win32 + {C018BE85-EBFE-428E-8626-3CCB77052715}.Debug.ActiveCfg = Debug|Win32 + {C018BE85-EBFE-428E-8626-3CCB77052715}.Debug.Build.0 = Debug|Win32 + {C018BE85-EBFE-428E-8626-3CCB77052715}.Release.ActiveCfg = Release|Win32 + {C018BE85-EBFE-428E-8626-3CCB77052715}.Release.Build.0 = Release|Win32 EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution EndGlobalSection diff --git a/source/tools/atlas/AtlasFrontends/ActorEditor.cpp b/source/tools/atlas/AtlasFrontends/ActorEditor.cpp new file mode 100644 index 0000000000..81845cca21 --- /dev/null +++ b/source/tools/atlas/AtlasFrontends/ActorEditor.cpp @@ -0,0 +1,11 @@ +#define WIN32_LEAN_AND_MEAN +#include + +#define ATLASDLLIMPEXP __declspec(dllimport) + +#include "AtlasUI/Misc/DLLInterface.h" + +int APIENTRY wWinMain(HINSTANCE, HINSTANCE, LPTSTR, int) { + StartWindow(L"ActorEditor"); + return 0; +} diff --git a/source/tools/atlas/AtlasFrontends/ActorEditor.vcproj b/source/tools/atlas/AtlasFrontends/ActorEditor.vcproj new file mode 100644 index 0000000000..5f8dce0223 --- /dev/null +++ b/source/tools/atlas/AtlasFrontends/ActorEditor.vcproj @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/source/tools/atlas/AtlasFrontends/ColourTester.cpp b/source/tools/atlas/AtlasFrontends/ColourTester.cpp new file mode 100644 index 0000000000..e399f01672 --- /dev/null +++ b/source/tools/atlas/AtlasFrontends/ColourTester.cpp @@ -0,0 +1,11 @@ +#define WIN32_LEAN_AND_MEAN +#include + +#define ATLASDLLIMPEXP __declspec(dllimport) + +#include "AtlasUI/Misc/DLLInterface.h" + +int APIENTRY wWinMain(HINSTANCE, HINSTANCE, LPTSTR, int) { + StartWindow(L"ColourTester"); + return 0; +} diff --git a/source/tools/atlas/AtlasFrontends/ColourTester.vcproj b/source/tools/atlas/AtlasFrontends/ColourTester.vcproj new file mode 100644 index 0000000000..c660648a1e --- /dev/null +++ b/source/tools/atlas/AtlasFrontends/ColourTester.vcproj @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/source/tools/atlas/AtlasFrontends/_template.cpp b/source/tools/atlas/AtlasFrontends/_template.cpp new file mode 100644 index 0000000000..fd3060d7b8 --- /dev/null +++ b/source/tools/atlas/AtlasFrontends/_template.cpp @@ -0,0 +1,11 @@ +#define WIN32_LEAN_AND_MEAN +#include + +#define ATLASDLLIMPEXP __declspec(dllimport) + +#include "AtlasUI/Misc/DLLInterface.h" + +int APIENTRY wWinMain(HINSTANCE, HINSTANCE, LPTSTR, int) { + StartWindow(L"$$WINDOW_NAME$$"); + return 0; +} diff --git a/source/tools/atlas/AtlasFrontends/_template.vcproj b/source/tools/atlas/AtlasFrontends/_template.vcproj new file mode 100644 index 0000000000..70aa69eb39 --- /dev/null +++ b/source/tools/atlas/AtlasFrontends/_template.vcproj @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/source/tools/atlas/AtlasFrontends/generate.pl b/source/tools/atlas/AtlasFrontends/generate.pl new file mode 100644 index 0000000000..d34da9203a --- /dev/null +++ b/source/tools/atlas/AtlasFrontends/generate.pl @@ -0,0 +1,31 @@ +use strict; +use warnings; + +my @files = qw( .cpp .vcproj ); + +my @progs = ( + { + PROJECT_NAME => "ActorEditor", + GUID => "", + EXE_NAME => "ActorEditor", + WINDOW_NAME => "ActorEditor", + }, + { + PROJECT_NAME => "ColourTester", + GUID => "", + EXE_NAME => "ColourTester", + WINDOW_NAME => "ColourTester", + }, + +); + +for my $p (@progs) { + for my $f (@files) { + open IN, "<", "_template$f" or die "Error opening _template$f: $!"; + open OUT, ">", "$p->{PROJECT_NAME}$f" or die "Error opening $p->{PROJECT_NAME}$f: $!"; + while () { + s/\$\$([A-Z_]+)\$\$/ $p->{$1} /eg; + print OUT; + } + } +} diff --git a/source/tools/atlas/AtlasObject/AtlasObject.vcproj b/source/tools/atlas/AtlasObject/AtlasObject.vcproj index 15a7bd99cf..4fbdbf75c8 100644 --- a/source/tools/atlas/AtlasObject/AtlasObject.vcproj +++ b/source/tools/atlas/AtlasObject/AtlasObject.vcproj @@ -12,8 +12,8 @@ + DebugInformationFormat="3"/> + OutputFile="$(OutDir)/AtlasObject_d.lib" + AdditionalLibraryDirectories=""/> @@ -74,7 +73,7 @@ + AdditionalLibraryDirectories=""/> - -#include #include - #define ATSMARTPTR_IMPL(T) \ template<> void AtSmartPtr::inc_ref() \ { \ diff --git a/source/tools/atlas/AtlasObject/AtlasObjectImpl.h b/source/tools/atlas/AtlasObject/AtlasObjectImpl.h index d10c63e974..8e75199ede 100644 --- a/source/tools/atlas/AtlasObject/AtlasObjectImpl.h +++ b/source/tools/atlas/AtlasObject/AtlasObjectImpl.h @@ -1,7 +1,17 @@ #include "AtlasObject.h" #include -#include + +#ifdef _MSC_VER + // Avoid complaints about unreachable code; the optimiser is realising + // that some code is incapable of throwing, then warning about the catch + // block that will never be executed. + #pragma warning(disable: 4702) + #include + #pragma warning(default: 4702) +#else + #include +#endif // AtNode is an immutable tree node, with a string and and multimap of children. class AtNode diff --git a/source/tools/atlas/AtlasObject/AtlasObjectText.h b/source/tools/atlas/AtlasObject/AtlasObjectText.h index 0f2ab4b77b..660f7a20bb 100644 --- a/source/tools/atlas/AtlasObject/AtlasObjectText.h +++ b/source/tools/atlas/AtlasObject/AtlasObjectText.h @@ -3,13 +3,13 @@ // (This is done in order to avoid forcing inclusion of all the // STL headers when they're not needed) -#ifdef new // HACK: to make the STL headers happy with a redefined 'new' -# undef new +//#ifdef new // HACK: to make the STL headers happy with a redefined 'new' +//# undef new +//# include +//# define new new(_NORMAL_BLOCK ,__FILE__, __LINE__) +//#else # include -# define new new(_NORMAL_BLOCK ,__FILE__, __LINE__) -#else -# include -#endif +//#endif class AtObj; diff --git a/source/tools/atlas/AtlasObject/AtlasObjectXML.cpp b/source/tools/atlas/AtlasObject/AtlasObjectXML.cpp index 5db2129757..fa2b4381cb 100644 --- a/source/tools/atlas/AtlasObject/AtlasObjectXML.cpp +++ b/source/tools/atlas/AtlasObject/AtlasObjectXML.cpp @@ -19,7 +19,6 @@ #include #include -#include #include #include #include @@ -46,6 +45,7 @@ private: char* systemId = XMLString::transcode(err.getSystemId()); char* message = XMLString::transcode(err.getMessage()); // TODO: do something + (void)severity; XMLString::release(&systemId); XMLString::release(&message); } diff --git a/source/tools/atlas/AtlasUI/ActorEditor/ActorEditor.cpp b/source/tools/atlas/AtlasUI/ActorEditor/ActorEditor.cpp index 14d5c293b8..8afd10efe8 100644 --- a/source/tools/atlas/AtlasUI/ActorEditor/ActorEditor.cpp +++ b/source/tools/atlas/AtlasUI/ActorEditor/ActorEditor.cpp @@ -65,7 +65,12 @@ ActorEditor::ActorEditor(wxWindow* parent) materialsPanel->SetSizer(materialsSizer); - m_Material = new wxTextCtrl(materialsPanel, wxID_ANY, _T("")); +// m_Material = new wxTextCtrl(materialsPanel, wxID_ANY, _T("")); + wxArrayString materials; + AtObj list (Datafile::ReadList("materials")); + for (AtIter it = list["material"]; it.defined(); ++it) + materials.Add(it); + m_Material = new wxComboBox(materialsPanel, wxID_ANY, _T(""), wxDefaultPosition, wxDefaultSize, materials); materialsSizer->Add(m_Material, wxSizerFlags().Border(wxALL, 2)); ////////////////////////////////////////////////////////////////////////// diff --git a/source/tools/atlas/AtlasUI/ActorEditor/ActorEditor.h b/source/tools/atlas/AtlasUI/ActorEditor/ActorEditor.h index 4c2cde9260..478d9dee90 100644 --- a/source/tools/atlas/AtlasUI/ActorEditor/ActorEditor.h +++ b/source/tools/atlas/AtlasUI/ActorEditor/ActorEditor.h @@ -21,7 +21,7 @@ private: ActorEditorListCtrl* m_ActorEditorListCtrl; wxCheckBox* m_CastShadows; - wxTextCtrl* m_Material; + wxComboBox* m_Material; DECLARE_EVENT_TABLE(); }; diff --git a/source/tools/atlas/AtlasUI/ActorEditor/ActorEditorListCtrl.cpp b/source/tools/atlas/AtlasUI/ActorEditor/ActorEditorListCtrl.cpp index 55c0989a0b..c15d1cb946 100644 --- a/source/tools/atlas/AtlasUI/ActorEditor/ActorEditorListCtrl.cpp +++ b/source/tools/atlas/AtlasUI/ActorEditor/ActorEditorListCtrl.cpp @@ -21,6 +21,7 @@ ActorEditorListCtrl::ActorEditorListCtrl(wxWindow* parent) COLOUR(Anim, (e,f,e), (c,f,c)); COLOUR(Prop, (e,e,f), (c,c,f)); COLOUR(Colour, (f,e,f), (f,c,f)); + COLOUR(None, (f,f,f), (f,f,f)); #undef COLOUR @@ -97,5 +98,5 @@ wxListItemAttr* ActorEditorListCtrl::OnGetItemAttr(long item) const return const_cast(&m_ListItemAttr_Colour[item%2]); } - return DraggableListCtrl::OnGetItemAttr(item); + return const_cast(&m_ListItemAttr_None[item%2]); } diff --git a/source/tools/atlas/AtlasUI/ActorEditor/ActorEditorListCtrl.h b/source/tools/atlas/AtlasUI/ActorEditor/ActorEditorListCtrl.h index 372f89180e..004d0334d4 100644 --- a/source/tools/atlas/AtlasUI/ActorEditor/ActorEditorListCtrl.h +++ b/source/tools/atlas/AtlasUI/ActorEditor/ActorEditorListCtrl.h @@ -22,4 +22,5 @@ private: wxListItemAttr m_ListItemAttr_Anim[2]; wxListItemAttr m_ListItemAttr_Prop[2]; wxListItemAttr m_ListItemAttr_Colour[2]; + wxListItemAttr m_ListItemAttr_None[2]; }; diff --git a/source/tools/atlas/AtlasUI/ActorEditor/AnimListEditor.cpp b/source/tools/atlas/AtlasUI/ActorEditor/AnimListEditor.cpp index 28a5474d03..3cfba10d91 100644 --- a/source/tools/atlas/AtlasUI/ActorEditor/AnimListEditor.cpp +++ b/source/tools/atlas/AtlasUI/ActorEditor/AnimListEditor.cpp @@ -50,6 +50,8 @@ AnimListEditorListCtrl::AnimListEditorListCtrl(wxWindow* parent) AddColumnType(_("Anim name"), 100, "@name", new FieldEditCtrl_List("animations")); AddColumnType(_("File"), 200, "@file", new FieldEditCtrl_File(_T("art/animation/"), _("Animation files (*.psa)|*.psa|All files (*.*)|*.*"))); AddColumnType(_("Speed"), 50, "@speed", new FieldEditCtrl_Text()); + AddColumnType(_("Load"), 30, "@load", new FieldEditCtrl_Text()); + AddColumnType(_("Event"), 30, "@event", new FieldEditCtrl_Text()); } void AnimListEditorListCtrl::DoImport(AtObj& in) diff --git a/source/tools/atlas/AtlasUI/AtlasUI.vcproj b/source/tools/atlas/AtlasUI/AtlasUI.vcproj index 6af38baaa6..26542dc7b3 100644 --- a/source/tools/atlas/AtlasUI/AtlasUI.vcproj +++ b/source/tools/atlas/AtlasUI/AtlasUI.vcproj @@ -13,8 +13,8 @@ - - - - - - + RelativePath=".\Misc\DLLInterface.cpp"> + RelativePath=".\Misc\DLLInterface.h"> diff --git a/source/tools/atlas/AtlasUI/ColourTester/ColourTester.cpp b/source/tools/atlas/AtlasUI/ColourTester/ColourTester.cpp index 1adb7699d4..f7ec1a82fc 100644 --- a/source/tools/atlas/AtlasUI/ColourTester/ColourTester.cpp +++ b/source/tools/atlas/AtlasUI/ColourTester/ColourTester.cpp @@ -6,15 +6,29 @@ #include "ColourTesterColourCtrl.h" #include "ColourTesterFileCtrl.h" -//#include "AtlasObject/AtlasObject.h" -//#include "Datafile.h" - -//#include "wx/file.h" +#include "wx/dnd.h" BEGIN_EVENT_TABLE(ColourTester, wxFrame) //EVT_MENU(ID_Custom1, OnCreateEntity) END_EVENT_TABLE() +class DropTarget : public wxFileDropTarget +{ +public: + DropTarget(ColourTesterImageCtrl* imgctrl) + : m_ImageCtrl(imgctrl) + {} + + bool OnDropFiles(wxCoord WXUNUSED(x), wxCoord WXUNUSED(y), const wxArrayString& filenames) + { + if (filenames.GetCount() >= 1) + m_ImageCtrl->SetImageFile(filenames[0]); + return true; + } +private: + ColourTesterImageCtrl* m_ImageCtrl; +}; + ColourTester::ColourTester(wxWindow* parent) : wxFrame(parent, wxID_ANY, _("Colour Tester"), wxDefaultPosition, wxSize(800, 700)) { @@ -47,4 +61,8 @@ ColourTester::ColourTester(wxWindow* parent) bottomSizer->Add((wxPanel*)new ColourTesterColourCtrl(mainPanel, m_ImageCtrl), wxSizerFlags().Border(wxALL, 10)); + + ////////////////////////////////////////////////////////////////////////// + + SetDropTarget(new DropTarget(m_ImageCtrl)); } diff --git a/source/tools/atlas/AtlasUI/Misc/DLLInterface.cpp b/source/tools/atlas/AtlasUI/Misc/DLLInterface.cpp new file mode 100644 index 0000000000..bb8d9e68c0 --- /dev/null +++ b/source/tools/atlas/AtlasUI/Misc/DLLInterface.cpp @@ -0,0 +1,91 @@ +#include "stdafx.h" + +#include "DLLInterface.h" + +#include "Datafile.h" +#include "ActorEditor/ActorEditor.h" +#include "ColourTester/ColourTester.h" + +#include "wx/config.h" + +// Global variables, to remember state between DllMain and StartWindow and OnInit +wxString g_InitialWindowType; +HINSTANCE g_Module; +bool g_IsLoaded = false; + + +BOOL APIENTRY DllMain(HINSTANCE hModule, DWORD fdwReason, LPVOID WXUNUSED(lpReserved)) +{ + switch (fdwReason) + { + case DLL_PROCESS_ATTACH: + g_Module = hModule; + return TRUE; + + case DLL_PROCESS_DETACH: + if (g_IsLoaded) + { + wxEntryCleanup(); + g_IsLoaded = false; + } + break; + } + + return TRUE; +} + + +ATLASDLLIMPEXP void StartWindow(wchar_t* type) +{ + g_InitialWindowType = type; + wxEntry(g_Module); +} + + +class wxDLLApp : public wxApp +{ +public: + virtual bool OnInit() + { + // Initialise the global config file + wxConfigBase::Set(new wxConfig(_T("Atlas Editor"), _T("Wildfire Games"))); + + // Assume that the .exe is located in .../binaries/system. (We can't + // just use the cwd, since that isn't correct when being executed by + // dragging-and-dropping onto the program in Explorer.) + Datafile::SetSystemDirectory(argv[0]); + + // Display the Actor Editor window + wxFrame* frame; + if (g_InitialWindowType == _T("ActorEditor")) + frame = new ActorEditor(NULL); + else if (g_InitialWindowType == _T("ColourTester")) + frame = new ColourTester(NULL); + else + { + wxFAIL_MSG(_("Internal error: invalid window type")); + return false; + } + + frame->Show(); + SetTopWindow(frame); + + // One argument => argv[1] is a filename to open + if (argc > 1) + { + wxChar* filename = argv[1]; + if (wxFile::Exists(filename)) + { + AtlasWindow* win = wxDynamicCast(frame, AtlasWindow); + if (win) + win->OpenFile(filename); + } + else + wxLogError(_("Cannot find file '%s'"), filename); + } + + return true; + } +}; + +IMPLEMENT_APP_NO_MAIN(wxDLLApp) diff --git a/source/tools/atlas/AtlasUI/Misc/DLLInterface.h b/source/tools/atlas/AtlasUI/Misc/DLLInterface.h new file mode 100644 index 0000000000..4500a17e59 --- /dev/null +++ b/source/tools/atlas/AtlasUI/Misc/DLLInterface.h @@ -0,0 +1,3 @@ +#include + +ATLASDLLIMPEXP void StartWindow(wchar_t* type); diff --git a/source/tools/atlas/AtlasUI/Misc/actored.cpp b/source/tools/atlas/AtlasUI/Misc/actored.cpp deleted file mode 100644 index 37f956477e..0000000000 --- a/source/tools/atlas/AtlasUI/Misc/actored.cpp +++ /dev/null @@ -1,43 +0,0 @@ -// Just a boring app that creates an ActorEditor window - -#include "stdafx.h" - -#include "ActorEditor/ActorEditor.h" -#include "Datafile.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"))); - - // Assume that the .exe is located in .../binaries/system. (We can't - // just use the cwd, since that isn't correct when being executed by - // dragging-and-dropping onto the program in Explorer.) - Datafile::SetSystemDirectory(argv[0]); - - // Display the Actor Editor window - AtlasWindow *frame = new ActorEditor(NULL); - frame->Show(); - SetTopWindow(frame); - - // One argument => argv[1] is a filename to open - if (argc > 1) - { - wxChar* filename = argv[1]; - if (wxFile::Exists(filename)) - frame->OpenFile(filename); - else - wxLogError(_("Cannot find file '%s'"), filename); - } - - return true; - } - -}; - -IMPLEMENT_APP(MyApp) diff --git a/source/tools/atlas/AtlasUI/Misc/colourtest.cpp b/source/tools/atlas/AtlasUI/Misc/colourtest.cpp deleted file mode 100644 index 61e79c58ec..0000000000 --- a/source/tools/atlas/AtlasUI/Misc/colourtest.cpp +++ /dev/null @@ -1,50 +0,0 @@ -// Just another boring app that creates a ColourTester window - -#include "stdafx.h" - -#include "ColourTester/ColourTester.h" -#include "Datafile.h" - -#include "wx/file.h" -#include "wx/config.h" - -#include "wx/generic/colrdlgg.h" -#include "wx/generic/filedlgg.h" -#include "wx/generic/dirctrlg.h" -#include "wx/generic/dirdlgg.h" - -class MyApp: public wxApp -{ - bool OnInit() - { - // Initialise the global config file - wxConfigBase::Set(new wxConfig(_T("Atlas Editor"), _T("Wildfire Games"))); - - // Assume that the .exe is located in .../binaries/system. (We can't - // just use the cwd, since that isn't correct when being executed by - // dragging-and-dropping onto the program in Explorer.) - Datafile::SetSystemDirectory(argv[0]); - - // Display the main program window - wxFrame *frame = new ColourTester(NULL); - frame->Show(); - SetTopWindow(frame); - -/* - // One argument => argv[1] is a filename to open - if (argc > 1) - { - wxChar* filename = argv[1]; - if (wxFile::Exists(filename)) - frame->OpenFile(filename); - else - wxLogError(_("Cannot find file '%s'"), filename); - } -*/ - - return true; - } - -}; - -IMPLEMENT_APP(MyApp) diff --git a/source/tools/atlas/AtlasUI/Misc/stdafx.h b/source/tools/atlas/AtlasUI/Misc/stdafx.h index 5d79d3de05..6deafe0e78 100644 --- a/source/tools/atlas/AtlasUI/Misc/stdafx.h +++ b/source/tools/atlas/AtlasUI/Misc/stdafx.h @@ -37,3 +37,6 @@ // If no PCH, just include a load of common headers anyway # include "wx/wx.h" #endif + + +#define ATLASDLLIMPEXP __declspec(dllexport) diff --git a/source/tools/atlas/AtlasUI/TODO.txt b/source/tools/atlas/AtlasUI/TODO.txt index 5b789480cd..46ff035186 100644 --- a/source/tools/atlas/AtlasUI/TODO.txt +++ b/source/tools/atlas/AtlasUI/TODO.txt @@ -1,3 +1,18 @@ +Colour tester: + +* Display DDS info (compression, size) + +============================== + +Actor editor: + +* Fix new actor fields + + +============================== + +General and/or unsorted miscellany: + * Regression testing * Open actors from prop-actor selection