Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members  

theme.h

00001 /*
00002  *   EasySok --- A(nother) sokoban game for KDE.
00003  *
00004  *   Copyright (C) 2001 by Ralf Schmelter (ralfs@pc2a.chemie.uni-dortmund.de).
00005  *
00006  *   This program is free software; you can redistribute it and/or modify
00007  *   it under the terms of the GNU General Public License version 2 as
00008  *   published by the Free Software Foundation.
00009  *
00010  *   This program is distributed in the hope that it will be useful,
00011  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  *   GNU General Public License for more details.
00014  *
00015  *   You should have received a copy of the GNU General Public License
00016  *   along with this program; if not, write to the Free Software
00017  *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00018  */
00019 
00020 
00021 #ifndef EASYSOK_THEME_INC_GUARD_H
00022 #define EASYSOK_THEME_INC_GUARD_H
00023 
00024 
00025 #include <vector>
00026 
00027 #include <qcolor.h>
00028 #include <qstring.h>
00029 
00030 #include "piece_image.h"
00031 
00032 
00033 class Map;
00034 class QDomElement;
00035 class QPoint;
00036 
00037 
00038 
00039 
00047 class Theme
00048 {
00049 
00050 public:
00051 
00058     Theme(QDomElement const & dom_element);
00059 
00060 
00065     bool hideGems() const;
00066 
00067 
00074     void setHideGems(bool hide);
00075 
00076 
00081     bool hideGoals() const;
00082 
00083 
00090     void setHideGoals(bool hide);
00091 
00092 
00097     bool outsideAsWall() const;
00098 
00099 
00106     void setOutsideAsWall(bool outside_as_wall);
00107 
00108 
00113     QString const & name() const;
00114 
00115 
00120     QString const & backgroundImage() const;
00121 
00122 
00128     QColor backgroundColor() const;
00129 
00130 
00135     enum ImageType
00136     {
00141         LEFT_KEEPER_ON_FLOOR,
00142 
00143 
00148         RIGHT_KEEPER_ON_FLOOR,
00149 
00150 
00155         UP_KEEPER_ON_FLOOR,
00156 
00157 
00162         DOWN_KEEPER_ON_FLOOR,
00163 
00164 
00169         LEFT_KEPPER_ON_DEAD_FLOOR,
00170 
00171 
00176         RIGHT_KEPPER_ON_DEAD_FLOOR,
00177 
00178 
00183         UP_KEPPER_ON_DEAD_FLOOR,
00184 
00185 
00190         DOWN_KEPPER_ON_DEAD_FLOOR,
00191 
00192 
00197         LEFT_KEEPER_ON_GOAL,
00198 
00199 
00204         RIGHT_KEEPER_ON_GOAL,
00205 
00206 
00211         UP_KEEPER_ON_GOAL,
00212 
00213 
00218         DOWN_KEEPER_ON_GOAL,
00219 
00220 
00225         LEFT_MOVING_KEEPER,
00226 
00227 
00232         RIGHT_MOVING_KEEPER,
00233 
00234 
00239         DOWN_MOVING_KEEPER,
00240 
00241 
00246         UP_MOVING_KEEPER,
00247 
00248 
00253         LEFT_VIRTUAL_KEEPER,
00254 
00255 
00260         RIGHT_VIRTUAL_KEEPER,
00261 
00262 
00267         UP_VIRTUAL_KEEPER,
00268 
00269 
00274         DOWN_VIRTUAL_KEEPER,
00275 
00276 
00281         GEM_ON_FLOOR,
00282 
00283 
00288         GEM_ON_DEAD_FLOOR,
00289 
00290 
00295         GEM_ON_GOAL,
00296 
00297 
00302         MOVING_GEM,
00303 
00304 
00309         EMPTY_FLOOR,
00310 
00311 
00316         EMPTY_DEAD_FLOOR,
00317 
00318 
00323         EMPTY_GOAL,
00324 
00325 
00330         LEFT_ARROW,
00331 
00332 
00337         RIGHT_ARROW,
00338 
00339 
00344         UP_ARROW,
00345 
00346 
00351         DOWN_ARROW,
00352 
00353 
00358         WALL,
00359 
00360 
00365         OUTSIDE
00366     };
00367 
00376     std::vector<int> const & imageIndices(ImageType type, QPoint const & position, Map const & map) const;
00377 
00378 
00387     std::vector<int> const & imageIndicesFromPosition(int direction, QPoint const & position,
00388                                                       Map const & map) const;
00389 
00390 
00397     PieceImage const & pieceImage(int index) const;
00398 
00399 
00404     int nrOfPieceImages() const;
00405 
00406 
00411     double upperBorder() const;
00412 
00413 
00418     double lowerBorder() const;
00419 
00420 
00425     double leftBorder() const;
00426 
00427 
00432     double rightBorder() const;
00433 
00434 
00435 private:
00436 
00443     void addAlternates(QDomElement const & dom_element);
00444 
00445 
00452     void addPieceImageAlternates(QDomElement const & dom_element);
00453 
00454 
00461     void addWallPieceAlternates(QDomElement const & dom_element);
00462 
00463 
00470     void addAlternatesImages(QDomElement const & dom_element);
00471 
00472 
00480     int patternForPieceImage(QDomElement const & dom_element, QString const & name);
00481 
00482 
00490     int patternForWallPiece(QDomElement const & dom_element, QString const & name);
00491 
00492 
00500     int getNonWallPattern(QPoint const & position, Map const & map) const;
00501 
00502 
00510     int getWallPattern(QPoint const & position, Map const & map) const;
00511 
00512 
00517     QString m_name;
00518 
00519 
00524     double m_upper_border;
00525 
00526 
00531     double m_lower_border;
00532 
00533 
00538     double m_left_border;
00539 
00540 
00545     double m_right_border;
00546 
00547 
00552     QColor m_background_color;
00553 
00554 
00559     QString m_background_image;
00560 
00561 
00566     std::vector<int> m_alternate_starts;
00567 
00568 
00573     std::vector<int> m_alternate_sizes;
00574 
00575 
00580     std::vector<int> m_alternative_piece_image_starts;
00581 
00582 
00587     std::vector<int> m_alternative_piece_image_nr;
00588 
00589 
00594     std::vector<int> m_patterns;
00595 
00596 
00601     std::vector<int> m_piece_image_indices;
00602 
00603 
00608     std::vector<PieceImage> m_piece_images;
00609 
00610 
00615     bool m_hide_gems;
00616 
00617 
00622     bool m_hide_goals;
00623 
00624 
00629     bool m_outside_as_wall;
00630 
00631 
00636     static char const * s_elements[33];
00637 
00638 
00643     static char const * s_short_elements[33];
00644 
00645 
00650     static int const s_types_for_hidden_gems[33];
00651 
00652 
00657     static int const s_types_for_hidden_goals[33];
00658 };
00659 
00660 
00661 #endif

Generated at Sun Jan 6 18:49:09 2002 for EasySok by doxygen1.2.9.1 written by Dimitri van Heesch, © 1997-2001