gcsx_spawnedit.h 3.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. /* GCSx
  2. ** SPAWNEDIT.H
  3. **
  4. ** Spawn-point editor-only functionality
  5. */
  6. /*****************************************************************************
  7. ** Copyright (C) 2003-2006 Janson
  8. **
  9. ** This program is free software; you can redistribute it and/or modify
  10. ** it under the terms of the GNU General Public License as published by
  11. ** the Free Software Foundation; either version 2 of the License, or
  12. ** (at your option) any later version.
  13. **
  14. ** This program is distributed in the hope that it will be useful,
  15. ** but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. ** GNU General Public License for more details.
  18. **
  19. ** You should have received a copy of the GNU General Public License
  20. ** along with this program; if not, write to the Free Software
  21. ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
  22. *****************************************************************************/
  23. #ifndef __GCSx_SPAWNEDIT_H_
  24. #define __GCSx_SPAWNEDIT_H_
  25. class SpawnEdit : public Spawn {
  26. protected:
  27. // Who owns us
  28. class WorldEdit* world;
  29. class LayerEdit* layer; // If NULL, then no sprite in properties dialog
  30. // Are we associated with a world/layer now- i.e. store undo?
  31. // Set on load or when requested
  32. int undoReady;
  33. // Can be locked by layer/etc
  34. int lockCount;
  35. // We only display spawns in the editor, so we only need
  36. // display-related data there
  37. int displayX; // modified for any offset
  38. int displayY;
  39. int displayW;
  40. int displayH;
  41. void calculateDisplayCoords();
  42. // Tell our owner we're modified
  43. void setModified();
  44. public:
  45. // ID of zero if loading or clipboard
  46. SpawnEdit(class WorldEdit* myWorld, class LayerEdit* myLayer, int newId = 0);
  47. // (since a new spawnedit isn't locked, won't lock anything it copies)
  48. SpawnEdit(const class SpawnEdit* copy, class LayerEdit* myLayer, int newId = 0);
  49. virtual ~SpawnEdit();
  50. // (doesn't mark old/new layer as modified; no Undo here)
  51. void setLayer(class LayerEdit* newLayer);
  52. void setUndoReady();
  53. class LayerEdit* getLayer() { return layer; }
  54. int getW() const { return displayW; }
  55. int getH() const { return displayH; }
  56. // So we lock our anim/image (not script)
  57. int markLock() throw_File;
  58. int markUnlock();
  59. int isLocked() const;
  60. void load(class FileRead* file, const class World* world) throw_File;
  61. // Change properties
  62. void setName(const std::string& newName, Window* srcWin = NULL, Window* exWin = NULL) throw_Undo;
  63. void setPos(int nX, int nY, int skipUndo = 0, Window* srcWin = NULL, Window* exWin = NULL) throw_Undo;
  64. void setSprite(class AnimGroup* newAnimgroup, class TileSet* newTileset, int newId, Window* srcWin = NULL, Window* exWin = NULL) throw_File throw_Undo;
  65. void setScript(class Script* newScript, Window* srcWin = NULL, Window* exWin = NULL) throw_Undo;
  66. // Display in editor
  67. // dim 1 = half dim (for dimmed sprite layers)
  68. // dim 2 = 75% dim (for sprite placement hover)
  69. void blit(int offsetX, int offsetY, SDL_Surface* dest, int clipX, int clipY, int clipW, int clipH, int dim = 0, int selection = 0);
  70. // Returns true if OK pressed
  71. int propertiesDialog(Window* srcWin = NULL, Window* exWin = NULL);
  72. // Save data to file
  73. void save(class FileWrite* file) throw_File;
  74. };
  75. #endif