gcsx_importimg.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. /* GCSx
  2. ** IMPORTIMG.H
  3. **
  4. ** Import image (creating tileset/fontset) dialog
  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_IMPORTIMG_H_
  24. #define __GCSx_IMPORTIMG_H_
  25. class ImportImgDialog : private Dialog {
  26. private:
  27. int initialized;
  28. int isFont;
  29. std::string filename;
  30. int width;
  31. int height;
  32. int left;
  33. int top;
  34. int horiz;
  35. int vert;
  36. int skipBlank;
  37. int skipDupe;
  38. int importScene;
  39. color bkColor;
  40. SDL_Surface* image;
  41. enum {
  42. ID_LABEL = 1,
  43. ID_FILE,
  44. ID_FILECHOOSE,
  45. ID_TRANSPARENCY,
  46. ID_PREVIEW,
  47. ID_WIDTH,
  48. ID_HEIGHT,
  49. ID_LEFT,
  50. ID_TOP,
  51. ID_HORIZ,
  52. ID_VERT,
  53. ID_SKIPBLANK,
  54. ID_SKIPDUPE,
  55. ID_IMPORTSCENE,
  56. ID_OK,
  57. ID_CANCEL,
  58. };
  59. static class ImportImgDialog* dialogTileSet;
  60. static class ImportImgDialog* dialogFontSet;
  61. // (sl NULL to not import a scene)
  62. int doImport(TileSetEdit* ts, SceneEdit* sc, LayerEdit* sl, WorldEdit* world);
  63. public:
  64. ImportImgDialog(int font);
  65. ~ImportImgDialog();
  66. static class ImportImgDialog* createFontSet();
  67. static class ImportImgDialog* createTileSet();
  68. static void destroy();
  69. void run(class WorldEdit* world, Window* srcWin = NULL);
  70. void childModified(Window* modified);
  71. Dialog::ButtonAction verifyEntry(int buttonId, Dialog::ButtonAction buttonType);
  72. };
  73. // Shows a preview of splitting an image into tiles
  74. // Call load() when the image updates
  75. class WSplitPreview : public Widget {
  76. private:
  77. enum {
  78. PREVIEW_BORDER_SIZE = 1,
  79. TILE_SPACING = 1,
  80. };
  81. SDL_Surface* const* source;
  82. SDL_Surface* split; // Version to display (split/etc)
  83. int displayW;
  84. int displayH;
  85. int topPad;
  86. int leftPad;
  87. int horizSplit;
  88. int vertSplit;
  89. int tileWidth;
  90. int tileHeight;
  91. color bkColor;
  92. enum {
  93. WSPLITPREVIEW_DRAG_NONE = 0,
  94. WSPLITPREVIEW_DRAG_BK,
  95. } dragMode;
  96. void setBk(int x, int y);
  97. public:
  98. // Width doesn't include border
  99. // A width or height <= 0 hides the control
  100. // Doesn't update display until you call changeStats
  101. WSplitPreview(int pId, color* pSetting, SDL_Surface* const* src, int myWidth, int myHeight);
  102. ~WSplitPreview();
  103. // Width doesn't include border
  104. // A width or height <= 0 hides the control
  105. // Call load() after this to update image/size/position (not auto)
  106. void changeSize(int newWidth, int newHeight);
  107. // Automatically updates image
  108. void changeStats(int width, int height, int top, int left, int horiz, int vert);
  109. int event(int hasFocus, const SDL_Event* event);
  110. void load();
  111. void apply();
  112. void display(SDL_Surface* destSurface, Rect& toDisplay, const Rect& clipArea, int xOffset, int yOffset);
  113. };
  114. #endif