goat3d
diff exporters/maxgoat_stub/src/stub.cc @ 60:0c3576325480
moving the exporter along slowly
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Sun, 30 Mar 2014 08:53:33 +0300 |
parents | d317eb4f83da |
children | 3751aabbc5b3 |
line diff
1.1 --- a/exporters/maxgoat_stub/src/stub.cc Tue Mar 25 04:37:41 2014 +0200 1.2 +++ b/exporters/maxgoat_stub/src/stub.cc Sun Mar 30 08:53:33 2014 +0300 1.3 @@ -37,77 +37,43 @@ 1.4 1.5 static FILE *logfile; 1.6 static HINSTANCE hinst; 1.7 +static const wchar_t *copyright_str = L"Copyright 2013 (C) John Tsiombikas - GNU General Public License v3, see COPYING for details."; 1.8 1.9 class GoatExporterStub : public SceneExport { 1.10 -private: 1.11 - 1.12 public: 1.13 IGameScene *igame; 1.14 1.15 - int ExtCount(); 1.16 - const TCHAR *Ext(int n); 1.17 - const TCHAR *LongDesc(); 1.18 - const TCHAR *ShortDesc(); 1.19 - const TCHAR *AuthorName(); 1.20 - const TCHAR *CopyrightMessage(); 1.21 - const TCHAR *OtherMessage1(); 1.22 - const TCHAR *OtherMessage2(); 1.23 - unsigned int Version(); 1.24 - void ShowAbout(HWND win); 1.25 + int ExtCount() { return 1; } 1.26 + const TCHAR *Ext(int n) { return L"goatsce"; } 1.27 + const TCHAR *LongDesc() { return L"Goat3D Scene file"; } 1.28 + const TCHAR *ShortDesc() { return L"Goat3D Scene"; } 1.29 + const TCHAR *AuthorName() { return L"John Tsiombikas"; } 1.30 + const TCHAR *CopyrightMessage() { return copyright_str; } 1.31 + const TCHAR *OtherMessage1() { return L"foo1"; } 1.32 + const TCHAR *OtherMessage2() { return L"foo2"; } 1.33 + unsigned int Version() { return VERSION(VER_MAJOR, VER_MINOR); } 1.34 + void ShowAbout(HWND win) { MessageBoxA(win, "Goat3D exporter", "About this plugin", 0); } 1.35 1.36 int DoExport(const MCHAR *name, ExpInterface *eiface, Interface *iface, BOOL silent = FALSE, DWORD opt = 0); 1.37 }; 1.38 1.39 +class GoatAnimExporterStub : public SceneExport { 1.40 +public: 1.41 + IGameScene *igame; 1.42 1.43 -int GoatExporterStub::ExtCount() 1.44 -{ 1.45 - return 1; 1.46 -} 1.47 + int ExtCount() { return 1; } 1.48 + const TCHAR *Ext(int n) { return L"goatanm"; } 1.49 + const TCHAR *LongDesc() { return L"Goat3D Animation file"; } 1.50 + const TCHAR *ShortDesc() { return L"Goat3D Animation"; } 1.51 + const TCHAR *AuthorName() { return L"John Tsiombikas"; } 1.52 + const TCHAR *CopyrightMessage() { return copyright_str; } 1.53 + const TCHAR *OtherMessage1() { return L"bar1"; } 1.54 + const TCHAR *OtherMessage2() { return L"bar2"; } 1.55 + unsigned int Version() { return VERSION(VER_MAJOR, VER_MINOR); } 1.56 + void ShowAbout(HWND win) { MessageBoxA(win, "Goat3D anim exporter", "About this plugin", 0); } 1.57 1.58 -const TCHAR *GoatExporterStub::Ext(int n) 1.59 -{ 1.60 - return L"xml"; 1.61 -} 1.62 - 1.63 -const TCHAR *GoatExporterStub::LongDesc() 1.64 -{ 1.65 - return L"Goat3D scene file"; 1.66 -} 1.67 - 1.68 -const TCHAR *GoatExporterStub::ShortDesc() 1.69 -{ 1.70 - return L"Goat3D"; 1.71 -} 1.72 - 1.73 -const TCHAR *GoatExporterStub::AuthorName() 1.74 -{ 1.75 - return L"John Tsiombikas"; 1.76 -} 1.77 - 1.78 -const TCHAR *GoatExporterStub::CopyrightMessage() 1.79 -{ 1.80 - return L"Copyright 2013 (C) John Tsiombikas - GNU General Public License v3, see COPYING for details."; 1.81 -} 1.82 - 1.83 -const TCHAR *GoatExporterStub::OtherMessage1() 1.84 -{ 1.85 - return L"other1"; 1.86 -} 1.87 - 1.88 -const TCHAR *GoatExporterStub::OtherMessage2() 1.89 -{ 1.90 - return L"other2"; 1.91 -} 1.92 - 1.93 -unsigned int GoatExporterStub::Version() 1.94 -{ 1.95 - return VERSION(VER_MAJOR, VER_MINOR); 1.96 -} 1.97 - 1.98 -void GoatExporterStub::ShowAbout(HWND win) 1.99 -{ 1.100 - MessageBoxA(win, "Goat3D exporter stub", "About this plugin", 0); 1.101 -} 1.102 + int DoExport(const MCHAR *name, ExpInterface *eiface, Interface *iface, BOOL silent = FALSE, DWORD opt = 0); 1.103 +}; 1.104 1.105 static const char *find_dll_dir() 1.106 { 1.107 @@ -128,10 +94,7 @@ 1.108 return path; 1.109 } 1.110 1.111 -/* TODO: open a dialog, let the user select goat3d or goat3danim, then load the correct dll 1.112 - */ 1.113 -int GoatExporterStub::DoExport(const MCHAR *name, ExpInterface *eiface, Interface *iface, 1.114 - BOOL non_interactive, DWORD opt) 1.115 +static int do_export(int which, const MCHAR *name, ExpInterface *eiface, Interface *iface, BOOL non_int, DWORD opt) 1.116 { 1.117 const char *dll_fname = "maxgoat.dll"; 1.118 char *dll_path; 1.119 @@ -170,8 +133,7 @@ 1.120 } 1.121 } 1.122 1.123 - // TODO: pass 1 for anim 1.124 - if(!(desc = get_class_desc(0))) { 1.125 + if(!(desc = get_class_desc(which))) { 1.126 fprintf(logfile, "failed to get the class descriptor\n"); 1.127 goto done; 1.128 } 1.129 @@ -196,6 +158,18 @@ 1.130 return result; 1.131 } 1.132 1.133 +int GoatExporterStub::DoExport(const MCHAR *name, ExpInterface *eiface, Interface *iface, 1.134 + BOOL non_interactive, DWORD opt) 1.135 +{ 1.136 + return do_export(0, name, eiface, iface, non_interactive, opt); 1.137 +} 1.138 + 1.139 + 1.140 +int GoatAnimExporterStub::DoExport(const MCHAR *name, ExpInterface *eiface, Interface *iface, 1.141 + BOOL non_interactive, DWORD opt) 1.142 +{ 1.143 + return do_export(1, name, eiface, iface, non_interactive, opt); 1.144 +} 1.145 1.146 // ------------------------------------------ 1.147 1.148 @@ -212,7 +186,22 @@ 1.149 HINSTANCE HInstance() { return hinst; } 1.150 }; 1.151 1.152 +class GoatAnimClassDesc : public ClassDesc2 { 1.153 +public: 1.154 + int IsPublic() { return TRUE; } 1.155 + void *Create(BOOL loading = FALSE) { return new GoatAnimExporterStub; } 1.156 + const TCHAR *ClassName() { return L"GoatAnimExporterStub"; } 1.157 + SClass_ID SuperClassID() { return SCENE_EXPORT_CLASS_ID; } 1.158 + Class_ID ClassID() { return Class_ID(0x75054666, 0x45487285); } 1.159 + const TCHAR *Category() { return L"Mutant Stargoat"; } 1.160 + 1.161 + const TCHAR *InternalName() { return L"GoatAnimExporterStub"; } 1.162 + HINSTANCE HInstance() { return hinst; } 1.163 +}; 1.164 + 1.165 + 1.166 static GoatClassDesc class_desc; 1.167 +static GoatAnimClassDesc anim_class_desc; 1.168 1.169 BOOL WINAPI DllMain(HINSTANCE inst_handle, ULONG reason, void *reserved) 1.170 { 1.171 @@ -232,12 +221,20 @@ 1.172 1.173 __declspec(dllexport) int LibNumberClasses() 1.174 { 1.175 - return 1; 1.176 + return 2; 1.177 } 1.178 1.179 __declspec(dllexport) ClassDesc *LibClassDesc(int i) 1.180 { 1.181 - return i == 0 ? &class_desc : 0; 1.182 + switch(i) { 1.183 + case 0: 1.184 + return &class_desc; 1.185 + case 1: 1.186 + return &anim_class_desc; 1.187 + default: 1.188 + break; 1.189 + } 1.190 + return 0; 1.191 } 1.192 1.193 __declspec(dllexport) ULONG LibVersion()