gameedit.h 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  1. ////////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright 2016 RWS Inc, All Rights Reserved
  4. //
  5. // This program is free software; you can redistribute it and/or modify
  6. // it under the terms of version 2 of the GNU General Public License as published by
  7. // the Free Software Foundation
  8. //
  9. // This program is distributed in the hope that it will be useful,
  10. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. // GNU General Public License for more details.
  13. //
  14. // You should have received a copy of the GNU General Public License along
  15. // with this program; if not, write to the Free Software Foundation, Inc.,
  16. // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  17. //
  18. // GameEdit.h
  19. // Project: Nostril (aka Postal)
  20. //
  21. // History:
  22. // 12/18/96 MJR Started.
  23. //
  24. // 02/07/97 JMI Added CGameEditThing to store editor settings and, perhaps,
  25. // later it could do more things that only a CThing derived
  26. // class can do for the Editor.
  27. //
  28. // 02/07/97 JMI Needed include of idBank.h.
  29. //
  30. // 03/13/97 JMI Load now takes a version number.
  31. //
  32. // 04/18/97 JMI Added Edit_Menu_Continue() and Edit_Menu_ExitEditor().
  33. //
  34. ////////////////////////////////////////////////////////////////////////////////
  35. #ifndef GAMEEDIT_H
  36. #define GAMEEDIT_H
  37. ////////////////////////////////////////////////////////////////////////////////
  38. // Includes.
  39. ////////////////////////////////////////////////////////////////////////////////
  40. #include "thing.h"
  41. #include "IdBank.h"
  42. extern void NavNetListPressedCall(RGuiItem* pgui);
  43. ////////////////////////////////////////////////////////////////////////////////
  44. // Typedefs.
  45. ////////////////////////////////////////////////////////////////////////////////
  46. // One of these classes is created by the editor for each Realm. This class can
  47. // then store and retrieve the editor settings for a Realm on Load and Save.
  48. class CGameEditThing : public CThing
  49. {
  50. //---------------------------------------------------------------------------
  51. // Types, enums, etc.
  52. //---------------------------------------------------------------------------
  53. protected:
  54. //---------------------------------------------------------------------------
  55. // Variables
  56. //---------------------------------------------------------------------------
  57. public:
  58. // Settings //////////////////////////////////////////////////////////////
  59. U16 m_u16CameraTrackId; // ID of object for grip to track.
  60. short m_sViewPosX; // View position.
  61. short m_sViewPosY; // View position.
  62. RListBox* m_plbNavNetList; // Pointer to Nav Net List Box
  63. //---------------------------------------------------------------------------
  64. // Constructor(s) / destructor
  65. //---------------------------------------------------------------------------
  66. protected:
  67. // Constructor
  68. CGameEditThing(CRealm* pRealm)
  69. : CThing(pRealm, CGameEditThingID)
  70. {
  71. // Set defaults.
  72. m_u16CameraTrackId = CIdBank::IdNil;
  73. m_sViewPosX = 0;
  74. m_sViewPosY = 0;
  75. }
  76. public:
  77. // Destructor
  78. ~CGameEditThing()
  79. {
  80. }
  81. //---------------------------------------------------------------------------
  82. // Required static functions
  83. //---------------------------------------------------------------------------
  84. public:
  85. // Construct object
  86. static short Construct( // Returns 0 if successfull, non-zero otherwise
  87. CRealm* pRealm, // In: Pointer to realm this object belongs to
  88. CThing** ppNew) // Out: Pointer to new object
  89. {
  90. short sResult = 0;
  91. *ppNew = new CGameEditThing(pRealm);
  92. if (*ppNew == 0)
  93. {
  94. sResult = -1;
  95. TRACE("CGameEditThing::Construct(): Couldn't construct CGameEditThing!\n");
  96. }
  97. return sResult;
  98. }
  99. //---------------------------------------------------------------------------
  100. // Required virtual functions (implementing them as inlines doesn't pay!
  101. // (unless you really, really don't want them in your CPP!)).
  102. //---------------------------------------------------------------------------
  103. public:
  104. // Load object (should call base class version!)
  105. short Load( // Returns 0 if successfull, non-zero otherwise
  106. RFile* pFile, // In: File to load from
  107. bool bEditMode, // In: True for edit mode, false otherwise
  108. short sFileCount, // In: File count (unique per file, never 0)
  109. ULONG ulFileVersion) // In: Version of file format to load.
  110. {
  111. // Call base class.
  112. short sResult = CThing::Load(pFile, bEditMode, sFileCount, ulFileVersion);
  113. if (sResult == 0)
  114. {
  115. // Read settings.
  116. switch (ulFileVersion)
  117. {
  118. default:
  119. case 1:
  120. pFile->Read(&m_u16CameraTrackId);
  121. pFile->Read(&m_sViewPosX);
  122. pFile->Read(&m_sViewPosY);
  123. break;
  124. }
  125. // Make sure there were no format errors . . .
  126. if (sResult == 0)
  127. {
  128. // File status indicates our success, or lack thereof.
  129. sResult = pFile->Error();
  130. }
  131. }
  132. else
  133. {
  134. TRACE("CGameEditThing::Load(): Base class Load() failed.\n");
  135. }
  136. return sResult;
  137. }
  138. // Save object (should call base class version!)
  139. short Save( // Returns 0 if successfull, non-zero otherwise
  140. RFile* pFile, // In: File to save to
  141. short sFileCount) // In: File count (unique per file, never 0)
  142. {
  143. // Call base class.
  144. short sResult = CThing::Save(pFile, sFileCount);
  145. if (sResult == 0)
  146. {
  147. // Write settings.
  148. pFile->Write(m_u16CameraTrackId);
  149. pFile->Write(m_sViewPosX);
  150. pFile->Write(m_sViewPosY);
  151. // File status indicates our success, or lack thereof.
  152. sResult = pFile->Error();
  153. }
  154. else
  155. {
  156. TRACE("CGameEditThing::Save(): Base class Save() failed.\n");
  157. }
  158. return sResult;
  159. }
  160. //---------------------------------------------------------------------------
  161. // Internal functions
  162. //---------------------------------------------------------------------------
  163. protected:
  164. };
  165. ////////////////////////////////////////////////////////////////////////////////
  166. // Protos.
  167. ////////////////////////////////////////////////////////////////////////////////
  168. extern void GameEdit(
  169. void);
  170. // Called by the menu callback when it wants to tell the editor to continue
  171. // editting (end the menu).
  172. extern void Edit_Menu_Continue(void);
  173. // Called by the menu callback when it wants to tell the editor to quit the
  174. // editor.
  175. extern void Edit_Menu_ExitEditor(void);
  176. #endif //GAMEEDIT_H
  177. ////////////////////////////////////////////////////////////////////////////////
  178. // EOF
  179. ////////////////////////////////////////////////////////////////////////////////