00001 00002 // Copyright (C) 2004-2007 by The Allacrost Project 00003 // All Rights Reserved 00004 // 00005 // This code is licensed under the GNU GPL version 2. It is free software 00006 // and you may modify it and/or redistribute it under the terms of this license. 00007 // See http://www.gnu.org/copyleft/gpl.html for details. 00009 00010 /*!**************************************************************************** 00011 * \file grid.h 00012 * \author Philip Vorsilak, gorzuate@allacrost.org 00013 * \brief Header file for editor's grid, used for the OpenGL map portion 00014 * where tiles are painted, edited, etc. 00015 *****************************************************************************/ 00016 00017 #ifndef __GRID_HEADER__ 00018 #define __GRID_HEADER__ 00019 00020 #include "utils.h" 00021 #include "defs.h" 00022 #include "script.h" 00023 #include "video.h" 00024 00025 #include "tileset.h" 00026 00027 #include <QGLWidget> 00028 #include <QStringList> 00029 00031 namespace hoa_editor 00032 { 00033 00035 enum LAYER_TYPE 00036 { 00037 INVALID_LAYER = -1, 00038 LOWER_LAYER = 0, 00039 MIDDLE_LAYER = 1, 00040 UPPER_LAYER = 2, 00041 TOTAL_LAYER = 3 00042 }; 00043 00044 LAYER_TYPE& operator++(LAYER_TYPE& value, int dummy); 00045 00046 class Grid: public QGLWidget 00047 { 00048 Q_OBJECT // macro needed to use QT's slots and signals 00049 00050 public: 00051 Grid(QWidget *parent = 0, const QString &name = QString("Untitled"), 00052 int width = 0, int height = 0); // constructor 00053 ~Grid(); // destructor 00054 00056 bool GetChanged() const { return _changed; } 00058 void SetChanged(bool value); 00059 QString GetFileName() const { return _file_name; } 00060 void SetFileName(QString filename); // sets the map's file name 00061 int GetHeight() const { return _height; } 00062 int GetWidth() const {return _width; } 00063 void SetHeight(int height); // sets the map's height in tiles (rows) 00064 void SetWidth(int width); // sets the map's width in tiles (columns) 00065 void SetLLOn(bool value); // sets lower layer on/off 00066 void SetMLOn(bool value); // sets middle layer on/off 00067 void SetULOn(bool value); // sets upper layer on/off 00068 void SetGridOn(bool value); // sets grid on/off 00069 00070 std::vector<int32>& GetLayer(LAYER_TYPE layer); 00071 00076 void SetMusic(const QString& music_file); 00077 00082 const QString& GetMusic() const; 00083 00087 void LoadMap(); 00088 00093 void SaveMap(); 00094 00096 QStringList tileset_names; 00098 std::vector<Tileset*> tilesets; 00099 00100 protected: 00102 void initializeGL(); 00103 00105 void paintGL(); 00106 00108 void resizeGL(int w, int h); 00109 00110 private: 00112 QString _file_name; 00114 int _height; 00116 int _width; 00117 00119 bool _changed; 00121 bool _grid_on; 00123 bool _ll_on; 00125 bool _ml_on; 00127 bool _ul_on; 00128 00130 std::vector<int32> _lower_layer; 00132 std::vector<int32> _middle_layer; 00134 std::vector<int32> _upper_layer; 00135 00137 QString _music_file; 00138 }; // class Grid 00139 00140 } // namespace hoa_editor 00141 00142 #endif 00143 // __GRID_HEADER__
1.5.1