|
Source listing: echo $file; ?>. Return to
the main page
/* -*- C++ -*-
*******************************************************************
*
*
* Shisen-Sho for Windows
*
* board.h - Declaration of the Board class
*
*
*******************************************************************
*
* A japanese game similar to mahjongg
*
*******************************************************************
*
* Created 2000-12-28 by Jim Mason <jmason@sirius.com>
*
* Game engine ported from Mario Weilguni's <mweilguni@sime.com>
* original game for KDE, KSHISEN. If you are interested in the
* KDE version of the game, see http://www.kde.org/kdegames/
*
*******************************************************************
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; see the file COPYING. If not, write to
* the Free Software Foundation, 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*
*******************************************************************
*/
#ifndef _BOARD_H_
#define _BOARD_H_
#include "wndcore.h"
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#define WM_END_OF_GAME (WM_USER+1)
typedef struct {
int x, y;
} History;
class Move {
public:
Move() {};
Move(int _x1, int _y1, int _x2, int _y2, int _tile) {
x1 = _x1;
y1 = _y1;
x2 = _x2;
y2 = _y2;
tile = _tile;
}
int x1, x2, y1, y2;
int tile;
};
/////////////////////////////////////////////////////////////////////////////
// Board window
class Board : public Window
{
// Construction
public:
Board();
// Implementation
protected:
BOOL OnEraseBkgnd(HDC hDC);
void OnPaint();
void OnLButtonDown(UINT nFlags, POINT point);
void OnRButtonDown(UINT nFlags, POINT point);
void OnTimer(UINT nIDEvent);
// Operations
public:
SIZE sizeHint();
void setDelay(int);
int getDelay();
BOOL canUndo();
BOOL canRedo();
void redo();
void undo();
void setSize(int x, int y);
void newGame();
void setShuffle(int);
int getShuffle();
void getHint();
BOOL getHint_I(int &, int &, int &, int &, History h[4]);
int tilesLeft();
int getCurrentTime();
int getTimeForGame();
BOOL solvable(BOOL norestore = FALSE);
BOOL getSolvableFlag();
void setSolvableFlag(BOOL);
BOOL gravityFlag();
void setGravityFlag(BOOL);
int x_tiles();
int y_tiles();
BOOL isPaused() { return paused; }
void setNoEvents(BOOL bNoEvents=TRUE) { m_bNoEvents = bNoEvents; }
void markError();
void markMatched();
void changed();
void sizeChange();
void endOfGame();
BOOL pause();
#ifdef _DEBUG
void finish();
#endif // _DEBUG
private: // functions
void marked(int, int);
void undrawArrow();
void madeMove(int, int, int, int);
void gravity(int, BOOL);
void initBoard();
void setField(int x, int y, int value);
int getField(int x, int y);
int random(int max);
void updateField(int, int, BOOL bErase = FALSE);
public:
void loadMahjonggTileset(LPCSTR szTileset);
void loadDefaultTileset();
void initCacheDC();
void releaseTileset();
void loadBackground(LPCSTR szBackground);
void loadDefaultBackground();
void releaseBackground();
private:
void eraseBackground(HDC hDC, RECT& rcUpdate);
void drawTile(HDC hDC, int iTile, int xpos, int ypos, BOOL bLighten=FALSE);
BOOL canMakePath(int x1, int y1, int x2, int y2);
BOOL findPath(int x1, int y1, int x2, int y2);
BOOL findSimplePath(int x1, int y1, int x2, int y2);
void drawArrow(int, int, int, int);
POINT midCoord(int, int);
void clearHistory();
// Overrides
protected:
BOOL PreCreateWindow(CREATESTRUCT& cs);
LRESULT WndProc(UINT uMsg, WPARAM wParam, LPARAM lParam);
int OnCreate(LPCREATESTRUCT lpCreateStruct);
void OnDestroy();
private:
time_t starttime;
time_t time_for_game;
HBITMAP m_hBmpPaused;
std::list<Move> _undo;
std::list<Move> _redo;
int mark_x;
int mark_y;
History history[4];
int *field;
int _x_tiles;
int _y_tiles;
int _delay;
int _shuffle;
BOOL paused;
time_t pause_start;
BOOL trying;
BOOL _solvable_flag;
BOOL gravity_flag;
int grav_col_1, grav_col_2;
int highlighted_tile;
private:
HBITMAP m_bmpBkgnd;
SIZE m_sizeBkgnd;
HBITMAP m_bmpTiles, m_bmpTilesSel;
HGDIOBJ m_hOldTiles;
int m_tileWidth, m_tileHeight;
BOOL m_bUniqueSeasons;
// This is the cached tile DC for fast blitting
HDC m_dcTiles;
SHORT m_nTimer;
BOOL m_bNoEvents;
};
/////////////////////////////////////////////////////////////////////////////
#endif // ndef _BOARD_H_
<< Back to Shisen-Sho
|
|