ASF_import.cpp 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280
  1. /*
  2. ** Command & Conquer Renegade(tm)
  3. ** Copyright 2025 Electronic Arts Inc.
  4. **
  5. ** This program is free software: you can redistribute it and/or modify
  6. ** it under the terms of the GNU General Public License as published by
  7. ** the Free Software Foundation, either version 3 of the License, or
  8. ** (at your option) any later version.
  9. **
  10. ** This program is distributed in the hope that it will be useful,
  11. ** but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. ** GNU General Public License for more details.
  14. **
  15. ** You should have received a copy of the GNU General Public License
  16. ** along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. //----------------------------------------------------------------------------
  19. // asf_import.cpp
  20. //
  21. // Acclaim Skeleton File import module
  22. //
  23. // James McNeill
  24. //
  25. // Created October 1996
  26. //
  27. // Copyright (c) 1996 Westwood Studios
  28. //----------------------------------------------------------------------------
  29. #include <Max.h>
  30. #include <istdplug.h>
  31. #include <splshape.h>
  32. #include <dummy.h>
  33. #include "asf_resource.h"
  34. #include "asf_data.h"
  35. #include "read_asf.h"
  36. #include "exception.h"
  37. static HINSTANCE hInstance;
  38. static TCHAR * GetString ( int id )
  39. {
  40. static TCHAR buf[256];
  41. if (hInstance)
  42. return LoadString(hInstance, id, buf, sizeof(buf)) ? buf : NULL;
  43. return NULL;
  44. }
  45. static int MessageBox ( int s1, int s2, int option = MB_OK )
  46. {
  47. TSTR str1(GetString(s1));
  48. TSTR str2(GetString(s2));
  49. return MessageBox(GetActiveWindow(), str1, str2, option);
  50. }
  51. static int Alert ( int s1, int s2 = IDS_LIB_SHORT_DESC, int option = MB_OK )
  52. {
  53. return MessageBox(s1, s2, option);
  54. }
  55. //----------------------------------------------------------------------------
  56. // ASF_Import
  57. //----------------------------------------------------------------------------
  58. class ASF_Import : public SceneImport
  59. {
  60. public:
  61. ASF_Import();
  62. ~ASF_Import();
  63. int ExtCount(); // Number of extensions supported
  64. const TCHAR * Ext(int n); // Extension #n
  65. const TCHAR * LongDesc(); // Long ASCII description
  66. const TCHAR * ShortDesc(); // Short ASCII description
  67. const TCHAR * AuthorName(); // ASCII Author name
  68. const TCHAR * CopyrightMessage(); // ASCII Copyright message
  69. const TCHAR * OtherMessage1(); // Other message #1
  70. const TCHAR * OtherMessage2(); // Other message #2
  71. unsigned int Version(); // Version number * 100
  72. void ShowAbout(HWND); // Show DLL's "About..." box
  73. int DoImport
  74. (
  75. const TCHAR * name,
  76. ImpInterface * i,
  77. Interface * gi,
  78. BOOL suppressPrompts=FALSE
  79. );
  80. };
  81. //----------------------------------------------------------------------------
  82. // DllMain
  83. //----------------------------------------------------------------------------
  84. static int controlsInit = FALSE;
  85. BOOL WINAPI DllMain
  86. (
  87. HINSTANCE hinstDLL,
  88. ULONG fdwReason,
  89. LPVOID lpvReserved
  90. )
  91. {
  92. hInstance = hinstDLL;
  93. if ( !controlsInit )
  94. {
  95. controlsInit = TRUE;
  96. InitCustomControls(hInstance);
  97. InitCommonControls();
  98. }
  99. switch(fdwReason)
  100. {
  101. case DLL_PROCESS_ATTACH: break;
  102. case DLL_THREAD_ATTACH: break;
  103. case DLL_THREAD_DETACH: break;
  104. case DLL_PROCESS_DETACH: break;
  105. }
  106. return TRUE;
  107. }
  108. //----------------------------------------------------------------------------
  109. // ASF_ClassDesc
  110. //----------------------------------------------------------------------------
  111. class ASF_ClassDesc : public ClassDesc
  112. {
  113. public:
  114. int IsPublic() { return 1; }
  115. void * Create(BOOL loading = FALSE) { return new ASF_Import; }
  116. const TCHAR * ClassName() { return GetString(IDS_SHORT_DESC); }
  117. SClass_ID SuperClassID() { return SCENE_IMPORT_CLASS_ID; }
  118. Class_ID ClassID() { return Class_ID(0x74975aa6, 0x1810323f); }
  119. const TCHAR* Category() { return GetString(IDS_CATEGORY); }
  120. };
  121. static ASF_ClassDesc ASF_desc;
  122. //----------------------------------------------------------------------------
  123. // This is the interface to Jaguar:
  124. //----------------------------------------------------------------------------
  125. __declspec( dllexport ) const TCHAR * LibDescription()
  126. {
  127. return GetString(IDS_LIB_LONG_DESC);
  128. }
  129. __declspec( dllexport ) int LibNumberClasses()
  130. {
  131. return 1;
  132. }
  133. __declspec( dllexport ) ClassDesc * LibClassDesc(int i)
  134. {
  135. switch(i)
  136. {
  137. case 0: return & ASF_desc; break;
  138. default: return 0; break;
  139. }
  140. }
  141. // Return version so can detect obsolete DLLs
  142. __declspec( dllexport ) ULONG LibVersion()
  143. {
  144. return VERSION_3DSMAX;
  145. }
  146. //
  147. // ASF import module functions follow:
  148. //
  149. ASF_Import::ASF_Import() {}
  150. ASF_Import::~ASF_Import() {}
  151. int ASF_Import::ExtCount()
  152. {
  153. return 1;
  154. }
  155. // Extensions supported for import/export modules
  156. const TCHAR * ASF_Import::Ext(int n)
  157. {
  158. if ( n == 0 ) return _T("ASF");
  159. else return _T("");
  160. }
  161. const TCHAR * ASF_Import::LongDesc()
  162. {
  163. return GetString(IDS_LONG_DESC);
  164. }
  165. const TCHAR * ASF_Import::ShortDesc()
  166. {
  167. return GetString(IDS_SHORT_DESC);
  168. }
  169. const TCHAR * ASF_Import::AuthorName()
  170. {
  171. return GetString(IDS_AUTHOR_NAME);
  172. }
  173. const TCHAR * ASF_Import::CopyrightMessage()
  174. {
  175. return GetString(IDS_COPYRIGHT);
  176. }
  177. const TCHAR * ASF_Import::OtherMessage1()
  178. {
  179. return _T("");
  180. }
  181. const TCHAR * ASF_Import::OtherMessage2()
  182. {
  183. return _T("");
  184. }
  185. unsigned int ASF_Import::Version()
  186. {
  187. return 100;
  188. }
  189. void ASF_Import::ShowAbout(HWND hWnd)
  190. {
  191. }
  192. //----------------------------------------------------------------------------
  193. // asf_load
  194. //----------------------------------------------------------------------------
  195. static int asf_load
  196. (
  197. const TCHAR * filename,
  198. ImpInterface * iface,
  199. Interface * gi
  200. )
  201. {
  202. // Load the skeleton definition file.
  203. try
  204. {
  205. Skeleton_Class skeleton ( filename, iface, gi );
  206. }
  207. catch ( const Parse_Error & error )
  208. {
  209. MessageBox ( GetActiveWindow (), error.message (), "Parse error",
  210. MB_OK );
  211. return -1;
  212. }
  213. // Create a matching skeleton in 3DS Max.
  214. return 1;
  215. }
  216. //----------------------------------------------------------------------------
  217. // ASF_Import::DoImport
  218. //----------------------------------------------------------------------------
  219. int ASF_Import::DoImport
  220. (
  221. const TCHAR * filename,
  222. ImpInterface * iface,
  223. Interface * gi,
  224. BOOL
  225. )
  226. {
  227. int status;
  228. status = asf_load ( filename, iface, gi );
  229. if(status == 0)
  230. status = IMPEXP_CANCEL;
  231. return (status <= 0) ? IMPEXP_FAIL : status;
  232. }