[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: branches/work/kreversi_rewrite
From: Dmitry Suzdalev <dimsuz () gmail ! com>
Date: 2006-09-05 21:20:23
Message-ID: 1157491223.677855.28522.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 581275 by dimsuz:
Now black&white chips may be used instead of colored ones.
You can even change this on the fly! ;)
Few crash fixes also.
You know what? It's getting near the end.
(Just joking - there's no end in software development ;) )
I'm in the mood of writing an overview of what to be done:
- Add number of chips statistics to status bar
- Add the moves history widget.
- Nice messagebox with stats at the end of the game
- HighScores
M +4 -0 kreversi.kcfg
M +35 -3 kreversiscene.cpp
M +3 -0 kreversiscene.h
M +1 -0 kreversiui.rc
M +14 -0 mainwindow.cpp
M +3 -0 mainwindow.h
M +1 -1 preferences.kcfgc
--- branches/work/kreversi_rewrite/kreversi.kcfg #581274:581275
@@ -32,5 +32,9 @@
<label>Background image name</label>
<default>Light_Wood</default>
</entry>
+ <entry name="UseColoredChips" type="Bool">
+ <label>Whether to use colored chips instead of black and white ones.</label>
+ <default>true</default>
+ </entry>
</group>
</kcfg>
--- branches/work/kreversi_rewrite/kreversiscene.cpp #581274:581275
@@ -14,8 +14,8 @@
const int CHIP_SIZE = 36;
KReversiScene::KReversiScene( KReversiGame* game , const QPixmap& chipsPixmap )
- : m_hintChip(0), m_lastMoveChip(0), m_timerDelay(25), m_showingHint(false), \
m_demoMode(false),
- m_showLastMove(false), m_showPossibleMoves(false)
+ : m_game(0), m_frameSet(0), m_hintChip(0), m_lastMoveChip(0), m_timerDelay(25),
+ m_showingHint(false), m_demoMode(false), m_showLastMove(false), \
m_showPossibleMoves(false) {
setBackgroundBrush( Qt::lightGray );
@@ -27,13 +27,37 @@
setSceneRect( 0, 0, m_boardRect.width()+2*fontHeight, \
m_boardRect.height()+2*fontHeight);
- m_frameSet = new KReversiChipFrameSet( chipsPixmap, CHIP_SIZE );
+ setChipsPixmap(chipsPixmap);
+
m_animTimer = new QTimer(this);
connect(m_animTimer, SIGNAL(timeout()), SLOT(slotAnimationStep()));
setGame(game);
}
+KReversiScene::~KReversiScene()
+{
+ delete m_frameSet;
+}
+
+void KReversiScene::setChipsPixmap( const QPixmap& chipsPixmap )
+{
+ delete m_frameSet;
+ m_frameSet = new KReversiChipFrameSet( chipsPixmap, CHIP_SIZE );
+ if(m_game)
+ {
+ QList<QGraphicsItem*> allItems = items( m_boardRect );
+ KReversiChip *chip = 0;
+ foreach( QGraphicsItem* item, allItems )
+ {
+ // FIXME dimsuz: use qgraphicsitem_cast?
+ chip = dynamic_cast<KReversiChip*>(item);
+ if( chip )
+ chip->setColor( chip->color() ); // this will reread pixmap
+ }
+ }
+}
+
void KReversiScene::setGame( KReversiGame* game )
{
m_game = game;
@@ -48,6 +72,14 @@
delete chip;
}
+ m_possibleMovesItems.clear();
+
+ m_animTimer->stop();
+ m_hintChip = 0; // it was deleted above if it was shown
+ m_showingHint = false;
+ m_lastMoveChip = 0;
+ m_demoMode = false;
+
updateBoard();
}
--- branches/work/kreversi_rewrite/kreversiscene.h #581274:581275
@@ -30,8 +30,11 @@
* @param chipsPixmap the pixmap with animation frames
*/
KReversiScene( KReversiGame* game, const QPixmap& chipsPixmap );
+ ~KReversiScene();
+
void setGame( KReversiGame* game );
void setBackgroundPixmap( const QPixmap& pix );
+ void setChipsPixmap( const QPixmap& chipsPixmap );
/**
* This function will tell you if the scene is currently performing
* some kind of "better-don't-interrupt-me" operation.
--- branches/work/kreversi_rewrite/kreversiui.rc #581274:581275
@@ -15,6 +15,7 @@
<Action name="choose_bkgnd" />
<Action name="anim_speed" />
<Action name="skill" />
+ <Action name="use_colored_chips" />
</Menu>
</MenuBar>
--- branches/work/kreversi_rewrite/mainwindow.cpp #581274:581275
@@ -84,6 +84,9 @@
m_skillAct->setItems(acts);
connect(m_skillAct, SIGNAL(triggered(int)), SLOT(slotSkillChanged(int)) );
+ m_coloredChipsAct = new KToggleAction( i18n("Use colored chips"), \
actionCollection(), "use_colored_chips" ); + connect( m_coloredChipsAct, \
SIGNAL(triggered(bool)), SLOT(slotUseColoredChips(bool)) ); +
addAction(newGameAct);
addAction(quitAct);
addAction(m_undoAct);
@@ -102,6 +105,9 @@
m_animSpeedAct->setCurrentItem( Preferences::animationSpeed() );
slotAnimSpeedChanged( Preferences::animationSpeed() );
+
+ m_coloredChipsAct->setChecked( Preferences::useColoredChips() );
+ slotUseColoredChips( Preferences::useColoredChips() );
}
void KReversiMainWindow::slotBackgroundChanged( const QString& text )
@@ -137,6 +143,14 @@
Preferences::writeConfig();
}
+void KReversiMainWindow::slotUseColoredChips(bool toggled)
+{
+ QString chipsPngPath = m_coloredChipsAct->isChecked() ? "pics/chips.png" : \
"pics/chips_mono.png"; + m_scene->setChipsPixmap( KStandardDirs::locate("appdata", \
chipsPngPath) ); + Preferences::setUseColoredChips(toggled);
+ Preferences::writeConfig();
+}
+
void KReversiMainWindow::slotDemoMode(bool toggled)
{
kDebug() << k_funcinfo << endl;
--- branches/work/kreversi_rewrite/mainwindow.h #581274:581275
@@ -8,6 +8,7 @@
class KReversiView;
class KAction;
class KSelectAction;
+class KToggleAction;
class KReversiMainWindow : public KMainWindow
{
@@ -23,6 +24,7 @@
void slotMoveFinished();
void slotGameOver();
void slotDemoMode(bool);
+ void slotUseColoredChips(bool);
private:
void setupActions();
void loadSettings();
@@ -37,5 +39,6 @@
KSelectAction* m_animSpeedAct;
KSelectAction* m_bkgndAct;
KSelectAction* m_skillAct;
+ KToggleAction* m_coloredChipsAct;
};
#endif
--- branches/work/kreversi_rewrite/preferences.kcfgc #581274:581275
@@ -4,4 +4,4 @@
ClassName=Preferences
Singleton=true
CustomAdditions=false
-Mutators=Skill,BackgroundImageName,AnimationSpeed
+Mutators=Skill,BackgroundImageName,AnimationSpeed,UseColoredChips
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic