# HG changeset patch # User John Tsiombikas # Date 1396158813 -10800 # Node ID 0c35763254806ff55bdfc29af3aa8e1d327ae45f # Parent b0bf3786bd5be87272f1953d62ef215f4db33898 moving the exporter along slowly diff -r b0bf3786bd5b -r 0c3576325480 exporters/maxgoat/maxgoat.vcxproj --- a/exporters/maxgoat/maxgoat.vcxproj Tue Mar 25 04:37:41 2014 +0200 +++ b/exporters/maxgoat/maxgoat.vcxproj Sun Mar 30 08:53:33 2014 +0300 @@ -156,6 +156,10 @@ + + + + diff -r b0bf3786bd5b -r 0c3576325480 exporters/maxgoat/maxgoat.vcxproj.filters --- a/exporters/maxgoat/maxgoat.vcxproj.filters Tue Mar 25 04:37:41 2014 +0200 +++ b/exporters/maxgoat/maxgoat.vcxproj.filters Sun Mar 30 08:53:33 2014 +0300 @@ -3,12 +3,20 @@ {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx;h src + + src + + + + + src + \ No newline at end of file diff -r b0bf3786bd5b -r 0c3576325480 exporters/maxgoat/src/maxgoat.cc --- a/exporters/maxgoat/src/maxgoat.cc Tue Mar 25 04:37:41 2014 +0200 +++ b/exporters/maxgoat/src/maxgoat.cc Sun Mar 30 08:53:33 2014 +0300 @@ -13,6 +13,7 @@ #include "IGameExport.h" #include "IConversionmanager.h" #include "goat3d.h" +#include "minwin.h" #include "config.h" @@ -118,6 +119,8 @@ int GoatExporter::DoExport(const MCHAR *name, ExpInterface *eiface, Interface *iface, BOOL non_interactive, DWORD opt) { + mw_test(); + mtlmap.clear(); nodemap.clear(); diff -r b0bf3786bd5b -r 0c3576325480 exporters/maxgoat/src/minwin.cc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/exporters/maxgoat/src/minwin.cc Sun Mar 30 08:53:33 2014 +0300 @@ -0,0 +1,93 @@ +#include +#include +#include "minwin.h" + +#define GOATSCE_WCLASS "goatsce-window" + +struct MinWidget { + HWND win; + + MWCallback cbfunc; + void *cbcls; + + MinWidget() { win = 0; cbfunc = 0; cbcls = 0; } +}; + +static void init(); +static LRESULT CALLBACK handle_msg(HWND win, unsigned int msg, WPARAM wparam, LPARAM lparam); + +void mw_set_callback(MinWidget *w, MWCallback func, void *cls) +{ + w->cbfunc = func; + w->cbcls = cls; +} + +MinWidget *mw_create_window(MinWidget *parent, const char *name) +{ + MinWidget *w = new MinWidget; + HINSTANCE inst = GetModuleHandle(0); + + w->win = CreateWindowA(GOATSCE_WCLASS, "Goat3D Scene export options ...", WS_OVERLAPPED, + CW_USEDEFAULT, CW_USEDEFAULT, 512, 400, parent ? parent->win : 0, 0, inst, 0); + ShowWindow(w->win, 1); + + return w; +} + +MinWidget *mw_create_button(MinWidget *parent, const char *text, int x, int y, int xsz, int ysz) +{ + MinWidget *bn = new MinWidget; + HINSTANCE inst = GetModuleHandle(0); + + bn->win = CreateWindowA("BUTTON", text, BS_PUSHBUTTON | BS_TEXT, + x, y, xsz, ysz, parent ? parent->win : 0, 0, inst, 0); + ShowWindow(bn->win, 1); + + return bn; +} + +MinWidget *mw_create_checkbox(MinWidget *parent, const char *text, int x, int y, int w, int h, bool checked) +{ + return 0; +} + + +void mw_test() +{ + MinWidget *win = mw_create_window(0, "test window!"); + MinWidget *bn = mw_create_button(win, "button!", 100, 100, 300, 80); +} + +static void init() +{ + static bool done_init; + if(done_init) { + return; + } + done_init = true; + + HINSTANCE hinst = GetModuleHandle(0); + + WNDCLASSA wc; + memset(&wc, 0, sizeof wc); + wc.lpszClassName = GOATSCE_WCLASS; + wc.hInstance = hinst; + wc.lpfnWndProc = handle_msg; + wc.style = CS_HREDRAW | CS_VREDRAW; + + RegisterClassA(&wc); +} + +static LRESULT CALLBACK handle_msg(HWND win, unsigned int msg, WPARAM wparam, LPARAM lparam) +{ + switch(msg) { + case WM_CLOSE: + DestroyWindow(win); + break; + + default: + return DefWindowProc(win, msg, wparam, lparam); + } + + return 0; +} \ No newline at end of file diff -r b0bf3786bd5b -r 0c3576325480 exporters/maxgoat/src/minwin.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/exporters/maxgoat/src/minwin.h Sun Mar 30 08:53:33 2014 +0300 @@ -0,0 +1,15 @@ +#ifndef MINWIN_H_ +#define MINWIN_H_ + +struct MinWidget; +typedef void (*MWCallback)(MinWidget*, void*); + +void mw_set_callback(MinWidget *w, MWCallback func, void *cls); + +MinWidget *mw_create_window(MinWidget *parent, const char *name); +MinWidget *mw_create_button(MinWidget *parent, const char *text, int x, int y, int w, int h); +MinWidget *mw_create_checkbox(MinWidget *parent, const char *text, int x, int y, int w, int h, bool checked); + +void mw_test(); + +#endif // MINWIN_H_ \ No newline at end of file diff -r b0bf3786bd5b -r 0c3576325480 exporters/maxgoat_stub/src/stub.cc --- a/exporters/maxgoat_stub/src/stub.cc Tue Mar 25 04:37:41 2014 +0200 +++ b/exporters/maxgoat_stub/src/stub.cc Sun Mar 30 08:53:33 2014 +0300 @@ -37,77 +37,43 @@ static FILE *logfile; static HINSTANCE hinst; +static const wchar_t *copyright_str = L"Copyright 2013 (C) John Tsiombikas - GNU General Public License v3, see COPYING for details."; class GoatExporterStub : public SceneExport { -private: - public: IGameScene *igame; - int ExtCount(); - const TCHAR *Ext(int n); - const TCHAR *LongDesc(); - const TCHAR *ShortDesc(); - const TCHAR *AuthorName(); - const TCHAR *CopyrightMessage(); - const TCHAR *OtherMessage1(); - const TCHAR *OtherMessage2(); - unsigned int Version(); - void ShowAbout(HWND win); + int ExtCount() { return 1; } + const TCHAR *Ext(int n) { return L"goatsce"; } + const TCHAR *LongDesc() { return L"Goat3D Scene file"; } + const TCHAR *ShortDesc() { return L"Goat3D Scene"; } + const TCHAR *AuthorName() { return L"John Tsiombikas"; } + const TCHAR *CopyrightMessage() { return copyright_str; } + const TCHAR *OtherMessage1() { return L"foo1"; } + const TCHAR *OtherMessage2() { return L"foo2"; } + unsigned int Version() { return VERSION(VER_MAJOR, VER_MINOR); } + void ShowAbout(HWND win) { MessageBoxA(win, "Goat3D exporter", "About this plugin", 0); } int DoExport(const MCHAR *name, ExpInterface *eiface, Interface *iface, BOOL silent = FALSE, DWORD opt = 0); }; +class GoatAnimExporterStub : public SceneExport { +public: + IGameScene *igame; -int GoatExporterStub::ExtCount() -{ - return 1; -} + int ExtCount() { return 1; } + const TCHAR *Ext(int n) { return L"goatanm"; } + const TCHAR *LongDesc() { return L"Goat3D Animation file"; } + const TCHAR *ShortDesc() { return L"Goat3D Animation"; } + const TCHAR *AuthorName() { return L"John Tsiombikas"; } + const TCHAR *CopyrightMessage() { return copyright_str; } + const TCHAR *OtherMessage1() { return L"bar1"; } + const TCHAR *OtherMessage2() { return L"bar2"; } + unsigned int Version() { return VERSION(VER_MAJOR, VER_MINOR); } + void ShowAbout(HWND win) { MessageBoxA(win, "Goat3D anim exporter", "About this plugin", 0); } -const TCHAR *GoatExporterStub::Ext(int n) -{ - return L"xml"; -} - -const TCHAR *GoatExporterStub::LongDesc() -{ - return L"Goat3D scene file"; -} - -const TCHAR *GoatExporterStub::ShortDesc() -{ - return L"Goat3D"; -} - -const TCHAR *GoatExporterStub::AuthorName() -{ - return L"John Tsiombikas"; -} - -const TCHAR *GoatExporterStub::CopyrightMessage() -{ - return L"Copyright 2013 (C) John Tsiombikas - GNU General Public License v3, see COPYING for details."; -} - -const TCHAR *GoatExporterStub::OtherMessage1() -{ - return L"other1"; -} - -const TCHAR *GoatExporterStub::OtherMessage2() -{ - return L"other2"; -} - -unsigned int GoatExporterStub::Version() -{ - return VERSION(VER_MAJOR, VER_MINOR); -} - -void GoatExporterStub::ShowAbout(HWND win) -{ - MessageBoxA(win, "Goat3D exporter stub", "About this plugin", 0); -} + int DoExport(const MCHAR *name, ExpInterface *eiface, Interface *iface, BOOL silent = FALSE, DWORD opt = 0); +}; static const char *find_dll_dir() { @@ -128,10 +94,7 @@ return path; } -/* TODO: open a dialog, let the user select goat3d or goat3danim, then load the correct dll - */ -int GoatExporterStub::DoExport(const MCHAR *name, ExpInterface *eiface, Interface *iface, - BOOL non_interactive, DWORD opt) +static int do_export(int which, const MCHAR *name, ExpInterface *eiface, Interface *iface, BOOL non_int, DWORD opt) { const char *dll_fname = "maxgoat.dll"; char *dll_path; @@ -170,8 +133,7 @@ } } - // TODO: pass 1 for anim - if(!(desc = get_class_desc(0))) { + if(!(desc = get_class_desc(which))) { fprintf(logfile, "failed to get the class descriptor\n"); goto done; } @@ -196,6 +158,18 @@ return result; } +int GoatExporterStub::DoExport(const MCHAR *name, ExpInterface *eiface, Interface *iface, + BOOL non_interactive, DWORD opt) +{ + return do_export(0, name, eiface, iface, non_interactive, opt); +} + + +int GoatAnimExporterStub::DoExport(const MCHAR *name, ExpInterface *eiface, Interface *iface, + BOOL non_interactive, DWORD opt) +{ + return do_export(1, name, eiface, iface, non_interactive, opt); +} // ------------------------------------------ @@ -212,7 +186,22 @@ HINSTANCE HInstance() { return hinst; } }; +class GoatAnimClassDesc : public ClassDesc2 { +public: + int IsPublic() { return TRUE; } + void *Create(BOOL loading = FALSE) { return new GoatAnimExporterStub; } + const TCHAR *ClassName() { return L"GoatAnimExporterStub"; } + SClass_ID SuperClassID() { return SCENE_EXPORT_CLASS_ID; } + Class_ID ClassID() { return Class_ID(0x75054666, 0x45487285); } + const TCHAR *Category() { return L"Mutant Stargoat"; } + + const TCHAR *InternalName() { return L"GoatAnimExporterStub"; } + HINSTANCE HInstance() { return hinst; } +}; + + static GoatClassDesc class_desc; +static GoatAnimClassDesc anim_class_desc; BOOL WINAPI DllMain(HINSTANCE inst_handle, ULONG reason, void *reserved) { @@ -232,12 +221,20 @@ __declspec(dllexport) int LibNumberClasses() { - return 1; + return 2; } __declspec(dllexport) ClassDesc *LibClassDesc(int i) { - return i == 0 ? &class_desc : 0; + switch(i) { + case 0: + return &class_desc; + case 1: + return &anim_class_desc; + default: + break; + } + return 0; } __declspec(dllexport) ULONG LibVersion()