gcsx_sceneedit.h 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. /* GCSx
  2. ** SCENEEDIT.H
  3. **
  4. ** Scene support
  5. ** Expands basic Scene to include editor functionality
  6. */
  7. /*****************************************************************************
  8. ** Copyright (C) 2003-2006 Janson
  9. **
  10. ** This program is free software; you can redistribute it and/or modify
  11. ** it under the terms of the GNU General Public License as published by
  12. ** the Free Software Foundation; either version 2 of the License, or
  13. ** (at your option) any later version.
  14. **
  15. ** This program is distributed in the hope that it will be useful,
  16. ** but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. ** GNU General Public License for more details.
  19. **
  20. ** You should have received a copy of the GNU General Public License
  21. ** along with this program; if not, write to the Free Software
  22. ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
  23. *****************************************************************************/
  24. #ifndef __GCSx_SCENEEDIT_H_
  25. #define __GCSx_SCENEEDIT_H_
  26. class SceneEdit : public Scene, virtual public SaveLoad {
  27. protected:
  28. // Has the scene been modified from initial state (from empty if new)
  29. int headerModified;
  30. int contentModified;
  31. int disassociated;
  32. class LayerEdit* layerEdits[MAX_LAYERS]; // CACHEABLE
  33. // Our node on the world browser
  34. TreeView* browserNode;
  35. const static std::string tileButton;
  36. const static std::string imageButton;
  37. const static std::string fontButton;
  38. const static std::string addLayerButton;
  39. public:
  40. // Id of 0 = we're going to load immediately
  41. // Any other id = we start out modified
  42. // World and ID may be NULL/0 if in process of creating
  43. SceneEdit(class WorldEdit* myWorld, int myId = 0); // Starts with default settings
  44. virtual ~SceneEdit();
  45. // Intended only for use after creating/importing- not in general usage
  46. void setInfo(class WorldEdit* myWorld, int newId);
  47. class WorldEdit* getWorldEdit() { return dynamic_cast<WorldEdit*>(world); }
  48. // (asserts pos is valid)
  49. // markLock() this scene as long as you're using the layer for nontrivial purposes
  50. class LayerEdit* getLayerEdit(int pos);
  51. // Layers
  52. // Asserts that position is valid and we aren't full on layers yet
  53. // Inserts at position- 0 is top layer; takes ownership of pointer
  54. // Locks layer to match our lock count
  55. // Returns >0 if successfully inserted
  56. // Returns <0 if successfully inserted without undo (you should delete if you cancel)
  57. // Returns 0 if not inserted and you should delete the layer
  58. int insertLayer(class LayerEdit* newLayer, int pos, Window* srcWin = NULL, Window* exWin = NULL, int readd = 0) throw_File;
  59. // Unlocks layer if locked; returns true if successfully deleted
  60. int deleteLayer(int pos, Window* srcWin = NULL, Window* exWin = NULL) throw_File;
  61. // Just swaps position of two layers
  62. void swapLayer(int pos1, int pos2, Window* srcWin = NULL, Window* exWin = NULL) throw_Undo;
  63. // Inserts an entirely new layer; calls properties dialog; returns true if one was inserted
  64. int newLayer(Window* srcWin = NULL, Window* exWin = NULL) throw_File;
  65. // Change properties; handles undo
  66. void setName(const std::string& newName, Window* srcWin = NULL, Window* exWin = NULL) throw_Undo;
  67. // Returns true if OK pressed
  68. int propertiesDialog(Window* srcWin = NULL, Window* exWin = NULL);
  69. // Edit window (editor) Adds a layer if none
  70. void openEditWindow();
  71. // Tells scene to add itself to the world browser node
  72. void addToBrowser(TreeView* node, int makeCurrent = 1);
  73. void dropBrowser(); // Called if scene gets dropped from browser
  74. // Tells us to disassociate ourselves from anything, we've been "deleted"
  75. // or that we've been "readded" again
  76. // FileException means couldn't decache, and nothing was done
  77. void disassociate() throw_File;
  78. // Node is world browser node that we readd to
  79. void reassociate(TreeView* node);
  80. // Treeview event handling
  81. int treeviewEvent(int code, int command, int check);
  82. static int treeviewEventWrap(void* ptr, int code, int command, int check);
  83. // Set us as modified; public so layers can access this
  84. // Setting content modified also loads from cache if needed
  85. // Call these before actually making any modifications
  86. // (if header changes affect content, call both modifieds first)
  87. void setHeaderModified();
  88. void setContentModified();
  89. // File access (recurses to layers)
  90. void loadHeader(FileRead* file) throw_File;
  91. int isHeaderModified() const;
  92. int isContentModified() const;
  93. Uint32 saveHeader(FileWrite* file) throw_File;
  94. void saveContent(FileWrite* file) throw_File;
  95. void saveSuccess();
  96. void cachedContent(FileRead* file, int oldData);
  97. };
  98. #endif