Commit c7055d65 authored by Dmitry Suzdalev's avatar Dmitry Suzdalev

Let the rewrite start :).

Added a mainwindow and board class.
Just a skeletons by now.

svn path=/branches/work/kreversi_rewrite/; revision=571698
parent e8d8efd3
......@@ -3,41 +3,24 @@ add_subdirectory( pics )
add_subdirectory( sounds )
add_subdirectory( icons )
include_directories( ${CMAKE_SOURCE_DIR}/libkdegames ${CMAKE_SOURCE_DIR}/libkdegames/highscore )
########### next target ###############
set(kreversi_SRCS
Score.cpp
Move.cpp
Position.cpp
Game.cpp
qreversigame.cpp
qreversigameview.cpp
SuperEngine.cpp
Engine.cpp
board.cpp
highscores.cpp
kreversi.cpp
main.cpp )
kreversiboard.cpp
mainwindow.cpp
main.cpp )
kde4_automoc(${kreversi_SRCS})
kde4_add_ui_files(kreversi_SRCS settings.ui )
kde4_add_kcfg_files(kreversi_SRCS prefs.kcfgc )
kde4_add_executable(kreversi ${kreversi_SRCS})
target_link_libraries(kreversi ${KDE4_KIO_LIBS} kdegames knotifyconfig)
target_link_libraries(kreversi ${KDE4_KDEUI_LIBS})
install(TARGETS kreversi DESTINATION ${BIN_INSTALL_DIR} )
########### install files ###############
install( FILES kreversi.desktop DESTINATION ${XDG_APPS_DIR} )
install( FILES kreversi.kcfg DESTINATION ${KCFG_INSTALL_DIR} )
install( FILES kreversiui.rc DESTINATION ${DATA_INSTALL_DIR}/kreversi )
#install( FILES kreversi.kcfg DESTINATION ${KCFG_INSTALL_DIR} )
#install( FILES kreversiui.rc DESTINATION ${DATA_INSTALL_DIR}/kreversi )
#include "kreversiboard.h"
KReversiBoard::KReversiBoard(int boardSize)
: m_boardSize(boardSize)
{
resetBoard();
}
void KReversiBoard::resetBoard()
{
m_cells.resize( m_boardSize * m_boardSize );
m_cells.fill( emptyCell );
}
#ifndef KREVERSI_BOARD_H
#define KREVERSI_BOARD_H
#include <QVector>
/**
* This class represents a reversi board.
* It only holds a current state of the game,
* i.e. what type of chip the cells contain - nothing more.
* So this is just a plain QVector with some nice additions.
*/
class KReversiBoard
{
public:
enum CellType { emptyCell, playerCell, computerCell };
KReversiBoard(int boardSize=10);
/**
* Resets board to initial (start-of-new-game) state
*/
void resetBoard();
private:
QVector<CellType> m_cells;
int m_boardSize;
};
#endif
/* Yo Emacs, this -*- C++ -*-
*******************************************************************
*******************************************************************
*
*
* KREVERSI
*
*
*******************************************************************
*
* A Reversi (or sometimes called Othello) game
/*******************************************************************
*
*******************************************************************
*
* created 1997 by Mario Weilguni <mweilguni@sime.com>
*
*******************************************************************
* Copyright 2006 Dmitry Suzdalev <dimsuz@gmail.com>
*
* This file is part of the KDE project "KREVERSI"
*
......@@ -38,27 +24,20 @@
#include <kapplication.h>
#include <kimageio.h>
#include <kcmdlineargs.h>
#include <kaboutdata.h>
#include <khighscore.h>
#include <klocale.h>
#include <kglobal.h>
#include "mainwindow.h"
#include "version.h"
#include "kreversi.h"
#include "highscores.h"
static const char description[] = I18N_NOOP("KDE Board Game");
static const char description[] = I18N_NOOP("KDE Reversi Board Game");
int main(int argc, char **argv)
{
KHighscore::init("kreversi");
KAboutData aboutData( "kreversi", I18N_NOOP("KReversi"),
KREVERSI_VERSION, description, KAboutData::License_GPL,
"(c) 1997-2000, Mario Weilguni");
"(c) 1997-2000, Mario Weilguni\n(c) 2006, Dmitry Suzdalev");
aboutData.addAuthor("Mario Weilguni",0, "mweilguni@sime.com");
aboutData.addAuthor("Benjamin Meyer",0, "ben+kreversi@meyerhome.net");
aboutData.addCredit("Mats Luthman", I18N_NOOP("Game engine, ported from his JAVA applet."), 0);
......@@ -69,18 +48,14 @@ int main(int argc, char **argv)
KCmdLineArgs::init( argc, argv, &aboutData );
KApplication application;
KGlobal::locale()->insertCatalog("libkdegames");
// used for loading background pixmaps
KExtHighscore::ExtManager highscores;
if (application.isSessionRestored()){
RESTORE(KReversi)
if( application.isSessionRestored() )
{
RESTORE(KReversiMainWindow)
}
else {
KReversi *kreversi = new KReversi;
kreversi->show();
else
{
KReversiMainWindow *mainWin = new KReversiMainWindow;
mainWin->show();
}
return application.exec();
......
#include "mainwindow.h"
#include <kstdaction.h>
KReversiMainWindow::KReversiMainWindow(QWidget* parent)
: KMainWindow(parent)
{
setupActions();
setupGUI();
}
void KReversiMainWindow::setupActions()
{
KStdAction::quit(this, SLOT(close()), actionCollection());
}
#ifndef KREVERSI_MAIN_WINDOW_H
#define KREVERSI_MAIN_WINDOW_H
#include <kmainwindow.h>
class KReversiMainWindow : public KMainWindow
{
public:
KReversiMainWindow(QWidget* parent=0);
private:
void setupActions();
};
#endif
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