• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdegames API Reference
  • KDE Home
  • Contact Us
 

kgoldrunner

  • sources
  • kde-4.14
  • kdegames
  • kgoldrunner
  • src
kgreditor.h
Go to the documentation of this file.
1 /****************************************************************************
2  * Copyright 2009 Ian Wadham <iandw.au@gmail.com> *
3  * *
4  * This program is free software; you can redistribute it and/or *
5  * modify it under the terms of the GNU General Public License as *
6  * published by the Free Software Foundation; either version 2 of *
7  * the License, or (at your option) any later version. *
8  * *
9  * This program is distributed in the hope that it will be useful, *
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12  * GNU General Public License for more details. *
13  * *
14  * You should have received a copy of the GNU General Public License *
15  * along with this program. If not, see <http://www.gnu.org/licenses/>. *
16  ****************************************************************************/
17 
18 #ifndef KGREDITOR_H
19 #define KGREDITOR_H
20 
21 #include "kgrglobals.h"
22 
23 #include <QObject>
24 
25 class KGrView;
26 class KGrScene;
27 class KGrGameIO;
28 class QTimer;
29 
42 class KGrEditor : public QObject
43 {
44  Q_OBJECT
45 public:
62  KGrEditor (KGrView * theView, const QString &theSystemDir,
63  const QString &theUserDir,
64  QList<KGrGameData *> & pGameList);
65  ~KGrEditor();
66 
77  bool saveOK();
78 
87  bool createLevel (int pGameIndex);
88 
100  bool updateLevel (int pGameIndex, int pLevel);
101 
112  bool saveLevelFile(); // Save the edited level in a text file (.grl).
113 
126  bool moveLevelFile (int pGameIndex, int pLevel);
127 
138  bool deleteLevelFile (int pGameIndex, int pLevel);
139 
150  bool editGame (int pGameIndex);
151 
152 public slots:
156  void editNameAndHint();
157 
158 public:
164  void setEditObj (char newEditObj);
165 
166  inline void getGameAndLevel (int & game, int & lev) {
167  game = gameIndex; lev = editLevel; }
168 
169 signals:
176  void getMousePos (int & i, int & j);
177 
178 private:
179  KGrView * view; // The canvas on which the editor paints.
180  KGrScene * scene;
181  KGrGameIO * io; // I/O object for reading level-data.
182  QString systemDataDir;
183  QString userDataDir;
184 
185  // Will REFERENCE the main list in KGrGame, allowing KGrEditor to add games.
186  QList<KGrGameData *> & gameList;
187 
188  bool mouseMode; // Flag to set up keyboard OR mouse control.
189  bool editMode; // Flag to change keyboard and mouse functions.
190  char editObj; // Type of object to be painted by the mouse.
191  bool paintEditObj; // Sets painting on/off (toggled by clicking).
192  bool paintAltObj; // Sets painting for the alternate object on/off
193  int oldI, oldJ; // Last mouse position painted.
194  int editLevel; // Level to be edited (= 0 for new level).
195  int heroCount; // Can enter at most one hero.
196  bool shouldSave; // True if name or hint was edited.
197 
198  // The list-index of the game (collection of levels) being composed/edited.
199  int gameIndex;
200 
201  // The data, including the layout, for the level being composed or edited.
202  KGrLevelData levelData;
203  KGrLevelData savedLevelData;
204  QString levelName; // Level name during editing (optional).
205  QString levelHint; // Level hint during editing (optional).
206 
221  int selectLevel (int action, int requestedLevel, int & requestedGame);
222 
223  void loadEditLevel (int); // Load and display an existing level for edit.
224  void initEdit();
225  void insertEditObj (int, int, char object);
226  char editableCell (int i, int j);
227  void setEditableCell (int, int, char);
228  void showEditLevel();
229  bool reNumberLevels (int, int, int, int);
230  bool ownerOK (Owner o);
231  bool saveGameData (Owner o);
232 
233  QString getTitle();
234  QString getLevelFilePath (KGrGameData * gameData, int lev);
235 
236  QTimer * timer; // The time-signal for the game-editor.
237 
238  bool mouseDisabled;
239 
240 private slots:
247  void doEdit (int button);
248 
253  void tick ();
254 
261  void endEdit (int button);
262 };
263 
264 #endif // KGREDITOR_H
KGrEditor::editNameAndHint
void editNameAndHint()
Run a dialog in which the name and hint of a level can be edited.
Definition: kgreditor.cpp:200
KGrGameIO
The KGrGameIO class handles I/O for text-files containing KGoldrunner games and levels.
Definition: kgrgameio.h:58
KGrGameData
KGrGameData structure: contains attributes of a KGoldrunner game.
Definition: kgrglobals.h:88
KGrEditor::deleteLevelFile
bool deleteLevelFile(int pGameIndex, int pLevel)
Delete a level from a game.
Definition: kgreditor.cpp:425
KGrEditor::setEditObj
void setEditObj(char newEditObj)
Set the next object for the editor to paint, e.g.
Definition: kgreditor.cpp:67
KGrEditor::getMousePos
void getMousePos(int &i, int &j)
Get the next grid-position at which to paint an object in the layout.
KGrEditor::editGame
bool editGame(int pGameIndex)
Create a new game (a collection point for levels) or load the details of an existing game...
Definition: kgreditor.cpp:496
KGrEditor::KGrEditor
KGrEditor(KGrView *theView, const QString &theSystemDir, const QString &theUserDir, QList< KGrGameData * > &pGameList)
The constructor of KGrEditor.
Definition: kgreditor.cpp:32
KGrEditor::getGameAndLevel
void getGameAndLevel(int &game, int &lev)
Definition: kgreditor.h:166
KGrEditor::moveLevelFile
bool moveLevelFile(int pGameIndex, int pLevel)
Move a level to another game or level number.
Definition: kgreditor.cpp:326
QTimer
QObject
KGrEditor::~KGrEditor
~KGrEditor()
Definition: kgreditor.cpp:63
KGrLevelData
KGrLevelData structure: contains attributes of a KGoldrunner level.
Definition: kgrglobals.h:103
QString
QList< KGrGameData * >
KGrEditor
This class is the game-editor for KGoldrunner.
Definition: kgreditor.h:42
KGrEditor::createLevel
bool createLevel(int pGameIndex)
Set up a blank level-layout, ready for editing.
Definition: kgreditor.cpp:72
kgrglobals.h
KGrEditor::saveLevelFile
bool saveLevelFile()
Save an edited level in a text file (*.grl) in the user's area.
Definition: kgreditor.cpp:214
KGrView
Definition: kgrview.h:27
KGrEditor::updateLevel
bool updateLevel(int pGameIndex, int pLevel)
Load and display an existing level, ready for editing.
Definition: kgreditor.cpp:120
KGrEditor::saveOK
bool saveOK()
Check if there are any unsaved edits and, if so, ask the user what to do.
Definition: kgreditor.cpp:646
KGrScene
The QGraphicsScene that represents KGoldrunner on the screen.
Definition: kgrscene.h:75
Owner
Owner
Definition: kgrglobals.h:26
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:18:24 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

kgoldrunner

Skip menu "kgoldrunner"
  • Main Page
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members

kdegames API Reference

Skip menu "kdegames API Reference"
  • granatier
  • kapman
  • kblackbox
  • kgoldrunner
  • kigo
  • kmahjongg
  • KShisen
  • ksquares
  • libkdegames
  •   highscore
  •   libkdegamesprivate
  •     kgame
  • libkmahjongg
  • palapeli
  •   libpala

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal