Commit f94062b4 authored by Frederik Schwarzer's avatar Frederik Schwarzer

tabs -> spaces

svn path=/trunk/KDE/kdegames/kshisen/; revision=915468
parent 312a26ae
This diff is collapsed.
......@@ -52,77 +52,77 @@ class QLabel;
struct HighScore
{
QString name;
int seconds;
int x, y;
time_t date;
int gravity;
QString name;
int seconds;
int x, y;
time_t date;
int gravity;
};
const signed HIGHSCORE_MAX = 10;
class App : public KXmlGuiWindow
{
Q_OBJECT
public:
explicit App(QWidget *parent = 0);
private slots:
void slotEndOfGame();
void enableItems();
void updateScore();
void showSettings();
void notifyTilesDontMatch();
void notifyInvalidMove();
void notifySelectATile();
void notifySelectAMatchingTile();
void notifySelectAMove();
void newGame();
void restartGame();
void isSolvable();
void pause();
void undo();
void redo();
void hint();
void hallOfFame();
void keyBindings();
private:
void lockMenus(bool);
QString getPlayerName();
/**
* Read the old (pre- @ref KHighscore) highscore table.
*
* This reads the config file first, then saves it in the new format and
* re-reads it again as a KHighscore table.
**/
void readOldHighscore();
void readHighscore();
void writeHighscore();
int insertHighscore(const HighScore &);
int getScore(const HighScore &);
bool isBetter(const HighScore &, const HighScore &);
void showHighscore(int focusitem = -1);
void setupStatusBar();
void setupActions();
void setCheatMode();
void resetCheatMode();
private:
QString lastPlayerName;
QLabel *gameTipLabel;
QLabel *gameTimerLabel;
QLabel *gameTilesLabel;
QLabel *gameCheatLabel;
Board *board;
QVector<HighScore> highscore;
KHighscore* highscoreTable;
bool cheat;
Q_OBJECT
public:
explicit App(QWidget *parent = 0);
private slots:
void slotEndOfGame();
void enableItems();
void updateScore();
void showSettings();
void notifyTilesDontMatch();
void notifyInvalidMove();
void notifySelectATile();
void notifySelectAMatchingTile();
void notifySelectAMove();
void newGame();
void restartGame();
void isSolvable();
void pause();
void undo();
void redo();
void hint();
void hallOfFame();
void keyBindings();
private:
void lockMenus(bool);
QString getPlayerName();
/**
* Read the old (pre- @ref KHighscore) highscore table.
*
* This reads the config file first, then saves it in the new format and
* re-reads it again as a KHighscore table.
**/
void readOldHighscore();
void readHighscore();
void writeHighscore();
int insertHighscore(const HighScore &);
int getScore(const HighScore &);
bool isBetter(const HighScore &, const HighScore &);
void showHighscore(int focusitem = -1);
void setupStatusBar();
void setupActions();
void setCheatMode();
void resetCheatMode();
private:
QString lastPlayerName;
QLabel *gameTipLabel;
QLabel *gameTimerLabel;
QLabel *gameTilesLabel;
QLabel *gameCheatLabel;
Board *board;
QVector<HighScore> highscore;
KHighscore* highscoreTable;
bool cheat;
};
#endif
This diff is collapsed.
......@@ -59,10 +59,10 @@
*/
struct Position
{
Position() : x(0), y(0) { }
Position(int _x, int _y) : x(_x), y(_y) { }
int x;
int y;
Position() : x(0), y(0) { }
Position(int _x, int _y) : x(_x), y(_y) { }
int x;
int y;
};
/*
......@@ -78,32 +78,32 @@ typedef QList<Position> Path;
*/
class PossibleMove
{
public:
PossibleMove(Path& p) :
path(p), hasSlide(false) { }
PossibleMove(Path& p, Path& s) :
path(p), hasSlide(true), slide(s) { }
bool isInPath(int x, int y) const;
void Debug() const
{
kDebug() << "PossibleMove";
QList<Position>::const_iterator i;
for (i = path.begin(); i != path.end(); ++i)
kDebug() << " Path:" << (*i).x << "," << (*i).y;
if (hasSlide)
{
kDebug() << " hasSlide";
for (i = slide.begin(); i != slide.end(); ++i)
kDebug() << " Slide:" << (*i).x << "," << (*i).y;
}
}
Path path; // path used to connect the two tiles
bool hasSlide; // flag set if the move requires a slide
Path slide; // path representing the movement of the last sliding tile
public:
PossibleMove(Path& p) :
path(p), hasSlide(false) { }
PossibleMove(Path& p, Path& s) :
path(p), hasSlide(true), slide(s) { }
bool isInPath(int x, int y) const;
void Debug() const
{
kDebug() << "PossibleMove";
QList<Position>::const_iterator i;
for (i = path.begin(); i != path.end(); ++i)
kDebug() << " Path:" << (*i).x << "," << (*i).y;
if (hasSlide)
{
kDebug() << " hasSlide";
for (i = slide.begin(); i != slide.end(); ++i)
kDebug() << " Slide:" << (*i).x << "," << (*i).y;
}
}
Path path; // path used to connect the two tiles
bool hasSlide; // flag set if the move requires a slide
Path slide; // path representing the movement of the last sliding tile
};
/*
......@@ -118,175 +118,175 @@ typedef QList<PossibleMove> PossibleMoves;
*/
class Move
{
public:
Move(int _x1, int _y1, int _x2, int _y2, int _tile) :
x1(_x1), y1(_y1), x2(_x2), y2(_y2), tile1(_tile), tile2(_tile), hasSlide(false), slide_x1(-1), slide_y1(-1), slide_x2(-1), slide_y2(-1) { }
Move(int _x1, int _y1, int _x2, int _y2, int _tile1, int _tile2) :
x1(_x1), y1(_y1), x2(_x2), y2(_y2), tile1(_tile1), tile2(_tile2), hasSlide(false), slide_x1(-1), slide_y1(-1), slide_x2(-1), slide_y2(-1) { }
Move(int _x1, int _y1, int _x2, int _y2, int _tile1, int _tile2, int _slide_x1, int _slide_y1, int _slide_x2, int _slide_y2) :
x1(_x1), y1(_y1), x2(_x2), y2(_y2), tile1(_tile1), tile2(_tile2), hasSlide(true), slide_x1(_slide_x1), slide_y1(_slide_y1), slide_x2(_slide_x2), slide_y2(_slide_y2) { }
int x1, y1, x2, y2; // coordinates of the two tiles that matched
int tile1; // type of tile at first set of coordinates
int tile2; // type of tile at second set of coordinates
bool hasSlide; // if we performed a slide during the move
int slide_x1, slide_y1; // original coordinates of the last slided tile
int slide_x2, slide_y2; // final coordinates of the last slided tile
public:
Move(int _x1, int _y1, int _x2, int _y2, int _tile) :
x1(_x1), y1(_y1), x2(_x2), y2(_y2), tile1(_tile), tile2(_tile), hasSlide(false), slide_x1(-1), slide_y1(-1), slide_x2(-1), slide_y2(-1) { }
Move(int _x1, int _y1, int _x2, int _y2, int _tile1, int _tile2) :
x1(_x1), y1(_y1), x2(_x2), y2(_y2), tile1(_tile1), tile2(_tile2), hasSlide(false), slide_x1(-1), slide_y1(-1), slide_x2(-1), slide_y2(-1) { }
Move(int _x1, int _y1, int _x2, int _y2, int _tile1, int _tile2, int _slide_x1, int _slide_y1, int _slide_x2, int _slide_y2) :
x1(_x1), y1(_y1), x2(_x2), y2(_y2), tile1(_tile1), tile2(_tile2), hasSlide(true), slide_x1(_slide_x1), slide_y1(_slide_y1), slide_x2(_slide_x2), slide_y2(_slide_y2) { }
int x1, y1, x2, y2; // coordinates of the two tiles that matched
int tile1; // type of tile at first set of coordinates
int tile2; // type of tile at second set of coordinates
bool hasSlide; // if we performed a slide during the move
int slide_x1, slide_y1; // original coordinates of the last slided tile
int slide_x2, slide_y2; // final coordinates of the last slided tile
};
class Board : public QWidget
{
Q_OBJECT
Q_OBJECT
public:
Board(QWidget *parent = 0);
~Board();
public:
Board(QWidget *parent = 0);
~Board();
static const int nTiles = 42;
static const int nTiles = 42;
virtual void paintEvent(QPaintEvent *);
virtual void mousePressEvent(QMouseEvent *);
virtual void resizeEvent(QResizeEvent*);
virtual void paintEvent(QPaintEvent *);
virtual void mousePressEvent(QMouseEvent *);
virtual void resizeEvent(QResizeEvent*);
void setDelay(int);
int getDelay() const;
void setDelay(int);
int getDelay() const;
bool canUndo() const;
bool canRedo() const;
void redo();
void undo();
bool canUndo() const;
bool canRedo() const;
void redo();
void undo();
void setSize(int x, int y);
void resizeBoard();
QSize unscaledSize() ;
void newGame();
void setShuffle(int);
int getShuffle() const;
void setSize(int x, int y);
void resizeBoard();
QSize unscaledSize() ;
void newGame();
void setShuffle(int);
int getShuffle() const;
void showHint();
bool getHint_I(PossibleMoves& p) const;
void showHint();
bool getHint_I(PossibleMoves& p) const;
#ifdef DEBUGGING
void makeHintMove();
void finish();
void dumpBoard() const;
void dumpBoard(const int*) const;
void makeHintMove();
void finish();
void dumpBoard() const;
void dumpBoard(const int*) const;
#endif
int tilesLeft() const;
int getCurrentTime() const;
int getTimeForGame() const;
bool solvable(bool norestore = false);
bool getSolvableFlag() const;
void setSolvableFlag(bool);
bool gravityFlag() const;
void setGravityFlag(bool);
void setChineseStyleFlag(bool);
void setTilesCanSlideFlag(bool);
int x_tiles() const;
int y_tiles() const;
bool isPaused() const { return paused; }
void resetTimer();
void resetUndo();
void resetRedo();
signals:
void markMatched();
void changed();
void endOfGame();
void resized();
void invalidMove();
void tilesDontMatch();
void selectATile();
void selectAMove();
void selectAMatchingTile();
public slots:
bool pause();
void loadSettings();
bool loadTileset ( const QString & );
bool loadBackground ( const QString & );
private slots:
void undrawConnection();
bool gravity(int, bool);
protected:
virtual QSize sizeHint() const;
private: // functions
void initBoard();
int xOffset() ;
int yOffset() ;
int lineWidth();
void setField(int x, int y, int value);
int getField(int x, int y) const;
void updateField(int, int);
void clearHighlight();
bool tilesMatch(int tile1, int tile2) const;
bool canMakePath(int x1, int y1, int x2, int y2) const;
bool canSlideTiles(int x1, int y1, int x2, int y2, Path& p) const;
int findPath(int x1, int y1, int x2, int y2, PossibleMoves& p) const;
int findSimplePath(int x1, int y1, int x2, int y2, PossibleMoves& p) const;
void performMove(PossibleMove& p);
void performSlide(int x, int y, Path& s);
void reverseSlide(int x, int y, int s_x1, int s_y1, int s_x2, int s_y2);
bool isTileHighlighted(int x, int y) const;
void drawConnection(int timeout);
void drawPossibleMoves();
void undrawPossibleMoves();
QPoint midCoord(int x, int y);
void marked(int x, int y);
void madeMove(int x1, int y1, int x2, int y2);
void madeMoveWithSlide(int x1, int y1, int x2, int y2, Path& s);
void gravity(bool);
private:
time_t starttime;
time_t time_for_game;
KMahjonggTileset tiles;
KMahjonggBackground background;
KRandomSequence random;
QList<Move*> _undo;
QList<Move*> _redo;
int undraw_timer_id;
int mark_x;
int mark_y;
Path connection;
PossibleMoves possibleMoves;
int *field;
int _x_tiles;
int _y_tiles;
int _delay;
int _shuffle;
bool paused;
time_t pause_start;
bool gravity_flag;
bool _solvable_flag;
bool _chineseStyle_flag;
bool _tilesCanSlide_flag;
QList<int> grav_cols;
//int grav_col_1, grav_col_2;
int highlighted_tile;
int _connectionTimeout;
bool _paintConnection;
bool _paintPossibleMoves;
QPair<int, int> tileRemove1, tileRemove2;
int tilesLeft() const;
int getCurrentTime() const;
int getTimeForGame() const;
bool solvable(bool norestore = false);
bool getSolvableFlag() const;
void setSolvableFlag(bool);
bool gravityFlag() const;
void setGravityFlag(bool);
void setChineseStyleFlag(bool);
void setTilesCanSlideFlag(bool);
int x_tiles() const;
int y_tiles() const;
bool isPaused() const { return paused; }
void resetTimer();
void resetUndo();
void resetRedo();
signals:
void markMatched();
void changed();
void endOfGame();
void resized();
void invalidMove();
void tilesDontMatch();
void selectATile();
void selectAMove();
void selectAMatchingTile();
public slots:
bool pause();
void loadSettings();
bool loadTileset ( const QString & );
bool loadBackground ( const QString & );
private slots:
void undrawConnection();
bool gravity(int, bool);
protected:
virtual QSize sizeHint() const;
private: // functions
void initBoard();
int xOffset() ;
int yOffset() ;
int lineWidth();
void setField(int x, int y, int value);
int getField(int x, int y) const;
void updateField(int, int);
void clearHighlight();
bool tilesMatch(int tile1, int tile2) const;
bool canMakePath(int x1, int y1, int x2, int y2) const;
bool canSlideTiles(int x1, int y1, int x2, int y2, Path& p) const;
int findPath(int x1, int y1, int x2, int y2, PossibleMoves& p) const;
int findSimplePath(int x1, int y1, int x2, int y2, PossibleMoves& p) const;
void performMove(PossibleMove& p);
void performSlide(int x, int y, Path& s);
void reverseSlide(int x, int y, int s_x1, int s_y1, int s_x2, int s_y2);
bool isTileHighlighted(int x, int y) const;
void drawConnection(int timeout);
void drawPossibleMoves();
void undrawPossibleMoves();
QPoint midCoord(int x, int y);
void marked(int x, int y);
void madeMove(int x1, int y1, int x2, int y2);
void madeMoveWithSlide(int x1, int y1, int x2, int y2, Path& s);
void gravity(bool);
private:
time_t starttime;
time_t time_for_game;
KMahjonggTileset tiles;
KMahjonggBackground background;
KRandomSequence random;
QList<Move*> _undo;
QList<Move*> _redo;
int undraw_timer_id;
int mark_x;
int mark_y;
Path connection;
PossibleMoves possibleMoves;
int *field;
int _x_tiles;
int _y_tiles;
int _delay;
int _shuffle;
bool paused;
time_t pause_start;
bool gravity_flag;
bool _solvable_flag;
bool _chineseStyle_flag;
bool _tilesCanSlide_flag;
QList<int> grav_cols;
//int grav_col_1, grav_col_2;
int highlighted_tile;
int _connectionTimeout;
bool _paintConnection;
bool _paintPossibleMoves;
QPair<int, int> tileRemove1, tileRemove2;
};
#endif
......@@ -56,22 +56,22 @@ static const char dummy[] = I18N_NOOP2("Menu title", "&Move");
int main(int argc, char **argv)
{
KAboutData aboutData( "kshisen", 0, ki18n("Shisen-Sho"),
KSHISEN_VERSION, ki18n(description), KAboutData::License_GPL,
ki18n("(c) 1997, Mario Weilguni"), KLocalizedString(), "http://games.kde.org/kshisen" );
aboutData.addAuthor(ki18n("Dave Corrie"), ki18n("Current Maintainer"), "kde@davecorrie.com");
aboutData.addAuthor(ki18n("Mario Weilguni"), ki18n("Original Author"), "mweilguni@sime.com");
aboutData.addCredit(ki18n("Mauricio Piacentini"), ki18n("KMahjonggLib integration for KDE4"), "mauricio@tabuleiro.com");
aboutData.addCredit(ki18n("Jason Lane"), ki18n("Added 'tiles removed' counter\nTile smooth-scaling and window resizing"), "jglane@btopenworld.com");
aboutData.addCredit(ki18n("Thanks also to everyone who should be listed here but is not!"));
KCmdLineArgs::init( argc, argv, &aboutData );
KAboutData aboutData( "kshisen", 0, ki18n("Shisen-Sho"),
KSHISEN_VERSION, ki18n(description), KAboutData::License_GPL,
ki18n("(c) 1997, Mario Weilguni"), KLocalizedString(), "http://games.kde.org/kshisen" );
aboutData.addAuthor(ki18n("Dave Corrie"), ki18n("Current Maintainer"), "kde@davecorrie.com");
aboutData.addAuthor(ki18n("Mario Weilguni"), ki18n("Original Author"), "mweilguni@sime.com");
aboutData.addCredit(ki18n("Mauricio Piacentini"), ki18n("KMahjonggLib integration for KDE4"), "mauricio@tabuleiro.com");
aboutData.addCredit(ki18n("Jason Lane"), ki18n("Added 'tiles removed' counter\nTile smooth-scaling and window resizing"), "jglane@btopenworld.com");
aboutData.addCredit(ki18n("Thanks also to everyone who should be listed here but is not!"));
KCmdLineArgs::init( argc, argv, &aboutData );
KApplication a;
KGlobal::locale()->insertCatalog("libkdegames");
KGlobal::locale()->insertCatalog("libkmahjongg");
KApplication a;
KGlobal::locale()->insertCatalog("libkdegames");
KGlobal::locale()->insertCatalog("libkmahjongg");
App *app = new App();
app->show();
return a.exec();
App *app = new App();
app->show();
return a.exec();
}
/*
/*
* KSHISEN
*
*
......@@ -47,5 +47,5 @@
// MICRO numbers >= 90 are used for development milestones in HEAD.
#ifndef KSHISEN_VERSION
#define KSHISEN_VERSION "1.6.1"
#define KSHISEN_VERSION "1.6.1"
#endif // KSHISEN_VERSION
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment