editor.h

Go to the documentation of this file.
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    editor.h
00012  * \author  Philip Vorsilak, gorzuate@allacrost.org
00013  * \brief   Header file for editor's main window and user interface.
00014  *****************************************************************************/
00015          
00016 #ifndef __EDITOR_HEADER__
00017 #define __EDITOR_HEADER__
00018 
00019 #include "grid.h"
00020 #include "tileset.h"
00021 
00022 #include <QApplication>
00023 #include <QCheckBox>
00024 #include <QComboBox>
00025 #include <QDialog>
00026 #include <Q3FileDialog>
00027 #include <QGLWidget>
00028 #include <Q3IconView>
00029 #include <QLabel>
00030 #include <QLayout>
00031 #include <QLineEdit>
00032 #include <Q3ListView>
00033 #include <Q3MainWindow>
00034 #include <QMenuBar>
00035 #include <QMessageBox>
00036 #include <Q3PopupMenu>
00037 #include <QPushButton>
00038 #include <Q3ScrollView>
00039 #include <QSpinBox>
00040 #include <QStatusBar>
00041 #include <QStringList>
00042 #include <Q3TabDialog>
00043 #include <QTabWidget>
00044 #include <QContextMenuEvent>
00045 #include <QCloseEvent>
00046 #include <Q3GridLayout>
00047 #include <QMouseEvent>
00048 #include <Q3VBoxLayout>
00049 #include <Q3VButtonGroup>
00050 
00051 #include <map>
00052 
00054 namespace hoa_editor
00055 {
00056 
00058 enum TILE_MODE_TYPE
00059 {
00060   INVALID_TILE = -1,
00061   PAINT_TILE   = 0,
00062   MOVE_TILE    = 1,
00063   DELETE_TILE  = 2,
00064   TOTAL_TILE   = 3
00065 };
00066 
00067 class EditorScrollView;
00068 
00069 class Editor: public Q3MainWindow
00070 {
00072   Q_OBJECT
00073   
00074   public:
00075     Editor();                       // constructor
00076     ~Editor();                      // destructor
00077 
00079     friend class EditorScrollView;
00080 
00081   protected:
00085     void closeEvent(QCloseEvent*);
00086     //void resizeEvent(QResizeEvent*); FIXME: do I need this?
00087   
00088   private slots:
00090     void _FileMenuSetup();
00091 
00094     //{@
00095     void _FileNew();
00096     void _FileOpen();
00097     void _FileSaveAs();
00098     void _FileSave();
00099     void _FileResize();
00100     void _FileQuit();
00102 
00105     //{@
00106     void _ViewToggleGrid();
00107     void _ViewToggleLL();
00108     void _ViewToggleML();
00109     void _ViewToggleUL();
00111 
00114     //{@
00115     void _TileLayerFill();
00116     void _TileLayerClear();
00117     void _TileModePaint();
00118     void _TileModeMove();
00119     void _TileModeDelete();
00120     void _TileEditLL();
00121     void _TileEditML();
00122     void _TileEditUL();
00124 
00127     //{@
00128     void _MapSelectMusic();
00130 
00133     //{@
00134     void _HelpHelp();
00135     void _HelpAbout();
00136     void _HelpAboutQt();
00138     
00139   private:
00141     bool _EraseOK();
00143     void _SetEditMode(TILE_MODE_TYPE new_mode);
00145     void _SetEditLayer(LAYER_TYPE new_layer);   
00146 
00148     Q3PopupMenu* _file_menu;
00150     Q3PopupMenu* _view_menu;
00152     Q3PopupMenu* _tiles_menu;
00154     Q3PopupMenu* _map_menu;
00156     Q3PopupMenu* _help_menu;
00157 
00159     QStatusBar*       _stat_bar;
00161     QTabWidget*       _ed_tabs;
00163     EditorScrollView* _ed_scrollview;
00165     Q3BoxLayout*       _ed_layout;
00167     QWidget*          _ed_widget;
00168 
00170     int  _grid_id;
00172     int  _ll_id;
00174     int  _ml_id;
00176     int  _ul_id;
00178     bool _grid_on;
00180     bool _ll_on;
00182     bool _ml_on;
00184     bool _ul_on;
00185 
00187     std::map<LAYER_TYPE, int> _layer_ids;
00189     std::map<TILE_MODE_TYPE, int> _mode_ids;
00190 }; // class Editor
00191 
00192 class NewMapDialog: public QDialog
00193 {
00194   public:
00195     NewMapDialog(QWidget* parent, const QString& name);   // constructor
00196     ~NewMapDialog();                                      // destructor
00197 
00199     int GetHeight() const { return _height_sbox->value(); }
00201     int GetWidth()  const { return  _width_sbox->value(); }
00203     Q3ListView* GetTilesetListView() const { return _tileset_lview; }
00204 
00205   private:
00207     Q3ListView* _tileset_lview;
00209     QSpinBox* _height_sbox;
00211     QSpinBox* _width_sbox;
00213     QLabel* _height_label;
00215     QLabel* _width_label;
00217     QPushButton* _cancel_pbut;
00219     QPushButton* _ok_pbut;
00221     Q3GridLayout* _dia_layout;
00222 }; // class NewMapDialog
00223 
00224 class MusicDialog: public QDialog
00225 {
00226 public:
00227   MusicDialog(QWidget* parent, const QString& name, const QString& selected_music);
00228   ~MusicDialog();
00229 
00230   QString GetSelectedFile();
00231 private:
00233   QPushButton* _cancel_pbut;
00235   QPushButton* _ok_pbut;
00237   QLabel* _select_label;
00239   Q3GridLayout* _dia_layout;
00241   Q3ListView* _music_list;
00242 
00245   void _PopulateMusicList(const QString& selected_str);
00246 }; // class MusicDialog
00247 
00248 class EditorScrollView: public Q3ScrollView
00249 {
00251   Q_OBJECT 
00252   
00253   public:
00254     EditorScrollView(QWidget* parent, const QString& name, int width, int height);
00255     ~EditorScrollView();
00256 
00260     void Resize(int width, int height); 
00261 
00263     std::vector<int32>& GetCurrentLayer();    
00264 
00266     friend class Editor;
00267 
00268   protected:
00273     //{@
00274     void contentsMousePressEvent(QMouseEvent *evt);
00275     void contentsMouseMoveEvent(QMouseEvent *evt);
00276     void contentsMouseReleaseEvent(QMouseEvent *evt);
00277 //    void contentsContextMenuEvent(QContextMenuEvent *evt);
00279 
00280   private slots:
00281 /*    //! \name Context Menu Slots
00284     //{@
00285     void _ContextMenuSetup();
00286     void _ContextMenuEvaluate();
00288 */
00289   private:
00291     Grid *_map;
00293     TILE_MODE_TYPE _tile_mode;
00295     LAYER_TYPE _layer_edit;
00297     int _tile_index;
00299     //Q3PopupMenu *_context_menu;
00300 
00302     int _move_source_index;
00303 }; // class EditorScrollView
00304 
00305 } // namespace hoa_editor
00306 
00307 #endif
00308 // __EDITOR_HEADER__

Generated on Fri Jul 6 23:11:13 2007 for Hero of Allacrost by  doxygen 1.5.1