Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
Games
KShisen
Commits
b839346a
Commit
b839346a
authored
Dec 31, 2015
by
Frederik Schwarzer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add and apply clang-format file.
parent
fe1abcb8
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
217 additions
and
77 deletions
+217
-77
.clang-format
.clang-format
+85
-0
src/app.cpp
src/app.cpp
+15
-14
src/app.h
src/app.h
+6
-6
src/board.cpp
src/board.cpp
+44
-37
src/board.h
src/board.h
+63
-16
src/kshisen_debug.h
src/kshisen_debug.h
+1
-1
src/main.cpp
src/main.cpp
+3
-3
No files found.
.clang-format
0 → 100644
View file @
b839346a
---
Language: Cpp
# BasedOnStyle: WebKit
AccessModifierOffset: -4
AlignAfterOpenBracket: Align
AlignConsecutiveAssignments: false
AlignConsecutiveDeclarations: false
AlignEscapedNewlinesLeft: false
AlignOperands: false
AlignTrailingComments: false
AllowAllParametersOfDeclarationOnNextLine: true
AllowShortBlocksOnASingleLine: false
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: None
AllowShortIfStatementsOnASingleLine: false
AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakBeforeMultilineStrings: false
AlwaysBreakTemplateDeclarations: false
BinPackArguments: true
BinPackParameters: true
BraceWrapping:
AfterClass: true
AfterControlStatement: false
AfterEnum: false
AfterFunction: true
AfterNamespace: true
AfterStruct: true
AfterUnion: true
BeforeCatch: false
BeforeElse: false
IndentBraces: false
BreakBeforeBinaryOperators: All
BreakBeforeBraces: Custom
BreakBeforeTernaryOperators: true
BreakConstructorInitializersBeforeComma: true
ColumnLimit: 0
CommentPragmas: ''
ConstructorInitializerAllOnOneLineOrOnePerLine: false
ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 4
Cpp11BracedListStyle: true
DerivePointerAlignment: false
DisableFormat: false
ExperimentalAutoDetectBinPacking: false
ForEachMacros: [ foreach, Q_FOREACH ]
IncludeCategories:
- Regex: '^"'
Priority: 1
- Regex: '^<K'
Priority: 2
- Regex: '^<Q'
Priority: 3
IndentCaseLabels: true
IndentWidth: 4
IndentWrappedFunctionNames: false
KeepEmptyLinesAtTheStartOfBlocks: false
MacroBlockBegin: ''
MacroBlockEnd: ''
MaxEmptyLinesToKeep: 2
NamespaceIndentation: Inner
PenaltyBreakBeforeFirstCallParameter: 19
PenaltyBreakComment: 300
PenaltyBreakFirstLessLess: 120
PenaltyBreakString: 1000
PenaltyExcessCharacter: 1000000
PenaltyReturnTypeOnItsOwnLine: 60
SortIncludes: true
PointerAlignment: Middle
SpaceAfterCStyleCast: false
SpaceBeforeAssignmentOperators: true
SpaceBeforeParens: ControlStatements
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 1
SpacesInAngles: false
SpacesInContainerLiterals: true
SpacesInCStyleCastParentheses: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
Standard: Cpp11
TabWidth: 8
UseTab: Never
#ForceEmptyLineAtEOF: true
...
src/app.cpp
View file @
b839346a
...
...
@@ -32,7 +32,6 @@
#include <QTimer>
// KDE
#include <KStandardGameAction>
#include <KActionCollection>
#include <KConfig>
#include <KConfigDialog>
...
...
@@ -46,7 +45,8 @@
#include <KToggleAction>
// KDEGames
#include <highscore/kscoredialog.h>
#include <KScoreDialog>
#include <KStandardGameAction>
// Kmahjongg
#include <kmahjonggconfigdialog.h>
...
...
@@ -64,19 +64,20 @@
class
Settings
:
public
QWidget
,
public
Ui
::
Settings
{
public:
Settings
(
QWidget
*
parent
)
:
QWidget
(
parent
)
{
Settings
(
QWidget
*
parent
)
:
QWidget
(
parent
)
{
setupUi
(
this
);
}
};
App
::
App
(
QWidget
*
parent
)
:
KXmlGuiWindow
(
parent
)
,
m_gameTipLabel
(
nullptr
)
,
m_gameTimerLabel
(
nullptr
)
,
m_gameTilesLabel
(
nullptr
)
,
m_gameCheatLabel
(
nullptr
)
,
m_board
(
nullptr
)
App
::
App
(
QWidget
*
parent
)
:
KXmlGuiWindow
(
parent
)
,
m_gameTipLabel
(
nullptr
)
,
m_gameTimerLabel
(
nullptr
)
,
m_gameTilesLabel
(
nullptr
)
,
m_gameCheatLabel
(
nullptr
)
,
m_board
(
nullptr
)
{
m_board
=
new
Board
(
this
);
m_board
->
setObjectName
(
QStringLiteral
(
"board"
));
...
...
@@ -122,7 +123,7 @@ void App::setupActions()
KStandardGameAction
::
redo
(
this
,
SLOT
(
redo
()),
actionCollection
());
KStandardGameAction
::
hint
(
this
,
SLOT
(
hint
()),
actionCollection
());
KToggleAction
*
soundAction
=
new
KToggleAction
(
QIcon
::
fromTheme
(
QStringLiteral
(
"speaker"
)),
i18n
(
"Play Sounds"
),
this
);
KToggleAction
*
soundAction
=
new
KToggleAction
(
QIcon
::
fromTheme
(
QStringLiteral
(
"speaker"
)),
i18n
(
"Play Sounds"
),
this
);
soundAction
->
setChecked
(
Prefs
::
sounds
());
actionCollection
()
->
addAction
(
QStringLiteral
(
"sounds"
),
soundAction
);
connect
(
soundAction
,
&
KToggleAction
::
triggered
,
m_board
,
&
Board
::
setSoundsEnabled
);
...
...
@@ -138,7 +139,7 @@ void App::setupActions()
connect
(
m_board
,
&
Board
::
selectAMatchingTile
,
this
,
&
App
::
notifySelectAMatchingTile
);
connect
(
m_board
,
&
Board
::
selectAMove
,
this
,
&
App
::
notifySelectAMove
);
QTimer
*
timer
=
new
QTimer
(
this
);
QTimer
*
timer
=
new
QTimer
(
this
);
connect
(
timer
,
&
QTimer
::
timeout
,
this
,
&
App
::
updateTimeDisplay
);
timer
->
start
(
1000
);
...
...
@@ -380,7 +381,7 @@ void App::showSettingsDialog()
}
//Use the classes exposed by LibKmahjongg for our configuration dialog
KMahjonggConfigDialog
*
dialog
=
new
KMahjonggConfigDialog
(
this
,
QStringLiteral
(
"settings"
),
Prefs
::
self
());
KMahjonggConfigDialog
*
dialog
=
new
KMahjonggConfigDialog
(
this
,
QStringLiteral
(
"settings"
),
Prefs
::
self
());
dialog
->
addPage
(
new
Settings
(
0
),
i18n
(
"General"
),
QStringLiteral
(
"games-config-options"
));
dialog
->
addTilesetPage
();
dialog
->
addBackgroundPage
();
...
...
src/app.h
View file @
b839346a
...
...
@@ -39,7 +39,7 @@ class App : public KXmlGuiWindow
Q_OBJECT
public:
explicit
App
(
QWidget
*
parent
=
0
);
explicit
App
(
QWidget
*
parent
=
0
);
private
slots
:
void
slotEndOfGame
();
...
...
@@ -132,11 +132,11 @@ private:
void
setCheatModeEnabled
(
bool
enabled
);
private:
QLabel
*
m_gameTipLabel
;
///< Status bar area for game tips
QLabel
*
m_gameTimerLabel
;
///< Status bar area for the timer
QLabel
*
m_gameTilesLabel
;
///< Status bar area for the tile counter
QLabel
*
m_gameCheatLabel
;
///< Status bar area for the cheat mode
Board
*
m_board
;
///< Holds the game board
QLabel
*
m_gameTipLabel
;
///< Status bar area for game tips
QLabel
*
m_gameTimerLabel
;
///< Status bar area for the timer
QLabel
*
m_gameTilesLabel
;
///< Status bar area for the tile counter
QLabel
*
m_gameCheatLabel
;
///< Status bar area for the cheat mode
Board
*
m_board
;
///< Holds the game board
};
#endif // APP_H
...
...
src/board.cpp
View file @
b839346a
...
...
@@ -40,13 +40,13 @@
#include "prefs.h"
#define EMPTY
0
#define SEASONS_START
28
#define FLOWERS_START
39
#define EMPTY 0
#define SEASONS_START 28
#define FLOWERS_START 39
static
std
::
array
<
int
,
5
>
const
s_delay
=
{
1000
,
750
,
500
,
250
,
125
};
static
std
::
array
<
int
,
6
>
const
s_sizeX
=
{
14
,
16
,
18
,
24
,
26
,
30
};
static
std
::
array
<
int
,
6
>
const
s_sizeY
=
{
6
,
9
,
8
,
12
,
14
,
16
};
static
std
::
array
<
int
,
6
>
const
s_sizeY
=
{
6
,
9
,
8
,
12
,
14
,
16
};
bool
PossibleMove
::
isInPath
(
TilePos
const
&
tilePos
)
const
{
...
...
@@ -64,9 +64,9 @@ bool PossibleMove::isInPath(TilePos const & tilePos) const
for
(;
iter
!=
m_path
.
cend
();
++
iter
)
{
// to fix
if
((
tilePos
.
x
()
==
iter
->
x
()
&&
((
tilePos
.
y
()
>
pathY
&&
tilePos
.
y
()
<=
iter
->
y
())
||
(
tilePos
.
y
()
<
pathY
&&
tilePos
.
y
()
>=
iter
->
y
())))
||
(
tilePos
.
y
()
<
pathY
&&
tilePos
.
y
()
>=
iter
->
y
())))
||
(
tilePos
.
y
()
==
iter
->
y
()
&&
((
tilePos
.
x
()
>
pathX
&&
tilePos
.
x
()
<=
iter
->
x
())
||
(
tilePos
.
x
()
<
pathX
&&
tilePos
.
x
()
>=
iter
->
x
()))))
{
||
(
tilePos
.
x
()
<
pathX
&&
tilePos
.
x
()
>=
iter
->
x
()))))
{
qCDebug
(
KSHISEN_LOG
)
<<
"isInPath:"
<<
tilePos
.
x
()
<<
","
<<
tilePos
.
y
()
<<
"found in path"
<<
pathX
<<
","
<<
pathY
<<
" => "
<<
iter
->
x
()
<<
","
<<
iter
->
y
();
return
true
;
}
...
...
@@ -77,16 +77,26 @@ bool PossibleMove::isInPath(TilePos const & tilePos) const
}
Board
::
Board
(
QWidget
*
parent
)
:
QWidget
(
parent
),
m_markX
(
0
),
m_markY
(
0
),
m_xTiles
(
0
),
m_yTiles
(
0
),
m_delay
(
0
),
m_level
(
0
),
m_shuffle
(
0
),
m_gameState
(
GameState
::
Normal
),
m_cheat
(
false
),
m_gravityFlag
(
true
),
m_solvableFlag
(
false
),
m_chineseStyleFlag
(
false
),
m_tilesCanSlideFlag
(
false
),
m_highlightedTile
(
-
1
),
m_paintConnection
(
false
),
m_paintPossibleMoves
(
false
),
m_paintInProgress
(
false
),
m_soundPick
(
QStandardPaths
::
locate
(
QStandardPaths
::
GenericDataLocation
,
QStringLiteral
(
"sounds/kshisen/tile-touch.ogg"
))),
m_soundFall
(
QStandardPaths
::
locate
(
QStandardPaths
::
GenericDataLocation
,
QStringLiteral
(
"sounds/kshisen/tile-fall-tile.ogg"
)))
:
QWidget
(
parent
)
,
m_markX
(
0
)
,
m_markY
(
0
)
,
m_xTiles
(
0
)
,
m_yTiles
(
0
)
,
m_delay
(
0
)
,
m_level
(
0
)
,
m_shuffle
(
0
)
,
m_gameState
(
GameState
::
Normal
)
,
m_cheat
(
false
)
,
m_gravityFlag
(
true
)
,
m_solvableFlag
(
false
)
,
m_chineseStyleFlag
(
false
)
,
m_tilesCanSlideFlag
(
false
)
,
m_highlightedTile
(
-
1
)
,
m_paintConnection
(
false
)
,
m_paintPossibleMoves
(
false
)
,
m_paintInProgress
(
false
)
,
m_soundPick
(
QStandardPaths
::
locate
(
QStandardPaths
::
GenericDataLocation
,
QStringLiteral
(
"sounds/kshisen/tile-touch.ogg"
)))
,
m_soundFall
(
QStandardPaths
::
locate
(
QStandardPaths
::
GenericDataLocation
,
QStringLiteral
(
"sounds/kshisen/tile-fall-tile.ogg"
)))
{
m_tileRemove1
.
setX
(
-
1
);
...
...
@@ -310,8 +320,7 @@ void Board::mousePressEvent(QMouseEvent * e)
int
posX
=
(
e
->
pos
().
x
()
-
xOffset
())
/
(
m_tiles
.
qWidth
()
*
2
);
int
posY
=
(
e
->
pos
().
y
()
-
yOffset
())
/
(
m_tiles
.
qHeight
()
*
2
);
if
(
e
->
pos
().
x
()
<
xOffset
()
||
e
->
pos
().
y
()
<
yOffset
()
||
posX
>=
xTiles
()
||
posY
>=
yTiles
())
{
if
(
e
->
pos
().
x
()
<
xOffset
()
||
e
->
pos
().
y
()
<
yOffset
()
||
posX
>=
xTiles
()
||
posY
>=
yTiles
())
{
posX
=
-
1
;
posY
=
-
1
;
}
...
...
@@ -909,7 +918,7 @@ void Board::performMove(PossibleMove & possibleMoves)
void
Board
::
marked
(
TilePos
const
&
tilePos
)
{
if
(
field
(
tilePos
)
==
EMPTY
)
{
// click on empty space on the board
if
(
m_possibleMoves
.
size
()
>
1
)
{
// if the click is on any of the current possible moves, make that move
if
(
m_possibleMoves
.
size
()
>
1
)
{
// if the click is on any of the current possible moves, make that move
for
(
auto
move
:
m_possibleMoves
)
{
if
(
move
.
isInPath
(
tilePos
))
{
performMove
(
move
);
...
...
@@ -945,7 +954,7 @@ void Board::marked(TilePos const & tilePos)
updateField
(
tilePos
);
emit
selectAMatchingTile
();
return
;
}
else
if
(
m_possibleMoves
.
size
()
>
1
)
{
// if the click is on any of the current possible moves, make that move
}
else
if
(
m_possibleMoves
.
size
()
>
1
)
{
// if the click is on any of the current possible moves, make that move
for
(
auto
move
:
m_possibleMoves
)
{
if
(
move
.
isInPath
(
tilePos
))
{
...
...
@@ -1214,15 +1223,13 @@ int Board::findPath(TilePos const & tilePos1, TilePos const & tilePos2, Possible
}
// Find paths of 3 segments
std
::
array
<
int
,
4
>
const
dx
=
{
1
,
0
,
-
1
,
0
};
std
::
array
<
int
,
4
>
const
dy
=
{
0
,
1
,
0
,
-
1
};
std
::
array
<
int
,
4
>
const
dx
=
{
1
,
0
,
-
1
,
0
};
std
::
array
<
int
,
4
>
const
dy
=
{
0
,
1
,
0
,
-
1
};
for
(
int
i
=
0
;
i
<
4
;
++
i
)
{
int
newX
=
tilePos1
.
x
()
+
dx
.
at
(
i
);
int
newY
=
tilePos1
.
y
()
+
dy
.
at
(
i
);
while
(
newX
>=
-
1
&&
newX
<=
xTiles
()
&&
newY
>=
-
1
&&
newY
<=
yTiles
()
&&
field
(
TilePos
(
newX
,
newY
))
==
EMPTY
)
{
while
(
newX
>=
-
1
&&
newX
<=
xTiles
()
&&
newY
>=
-
1
&&
newY
<=
yTiles
()
&&
field
(
TilePos
(
newX
,
newY
))
==
EMPTY
)
{
if
((
simplePath
=
findSimplePath
(
TilePos
(
newX
,
newY
),
tilePos2
,
possibleMoves
))
>
0
)
{
possibleMoves
.
back
().
m_path
.
prepend
(
tilePos1
);
numberOfPaths
+=
simplePath
;
...
...
@@ -1424,7 +1431,7 @@ int Board::delay() const
void
Board
::
madeMove
(
TilePos
const
&
tilePos1
,
TilePos
const
&
tilePos2
,
Path
slide
)
{
Move
*
move
;
Move
*
move
;
if
(
slide
.
empty
())
{
move
=
new
Move
(
tilePos1
,
tilePos2
,
field
(
tilePos1
),
field
(
tilePos2
));
}
else
{
...
...
@@ -1456,7 +1463,7 @@ void Board::undo()
clearHighlight
();
undrawConnection
();
Move
*
move
=
m_undo
.
takeLast
();
Move
*
move
=
m_undo
.
takeLast
();
if
(
gravityFlag
())
{
// When both tiles reside in the same column, the order of undo is
// significant (we must undo the lower tile first).
...
...
@@ -1512,7 +1519,7 @@ void Board::undo()
// slided tiles may fall down after the slide
// so any tiles on top of the columns between
// slide_x2 -> slide_x2 +/- n (excluded) should go up to slide_y1
if
(
move
->
m_slideX2
>
move
->
m_slideX1
)
{
// slide to the right
if
(
move
->
m_slideX2
>
move
->
m_slideX1
)
{
// slide to the right
#ifdef DEBUGGING
qCDebug
(
KSHISEN_LOG
)
<<
"[undo] slide right"
;
#endif
...
...
@@ -1565,10 +1572,10 @@ void Board::undo()
updateField
(
TilePos
(
i
,
move
->
m_slideY1
));
}
}
// move tiles from the second column up
#ifdef DEBUGGING
qCDebug
(
KSHISEN_LOG
)
<<
"[undo] moving up column x2"
<<
move
->
m_x2
;
#endif
// move tiles from the second column up
for
(
int
y
=
0
;
y
<=
move
->
m_y2
;
++
y
)
{
#ifdef DEBUGGING
qCDebug
(
KSHISEN_LOG
)
<<
"[undo] moving up tile"
<<
y
+
1
;
...
...
@@ -1581,7 +1588,7 @@ void Board::undo()
// x1 -> x1+dx should go up one
// if their height > slide_y1
// because they have fallen after the slide
if
(
move
->
m_slideX2
>
move
->
m_slideX1
)
{
// slide to the right
if
(
move
->
m_slideX2
>
move
->
m_slideX1
)
{
// slide to the right
if
(
move
->
m_slideY1
>
0
)
{
for
(
int
i
=
move
->
m_x1
+
dx
;
i
>=
move
->
m_x1
;
--
i
)
{
#ifdef DEBUGGING
...
...
@@ -1623,19 +1630,19 @@ void Board::undo()
}
}
// then undo the slide to put the tiles back to their original location
#ifdef DEBUGGING
qCDebug
(
KSHISEN_LOG
)
<<
"[undo] reversing slide"
;
#endif
// then undo the slide to put the tiles back to their original location
reverseSlide
(
TilePos
(
move
->
m_x1
,
move
->
m_y1
),
move
->
m_slideX1
,
move
->
m_slideY1
,
move
->
m_slideX2
,
move
->
m_slideY2
);
}
else
{
// vertical slide, in fact nothing special is necessary
// the default implementation works because it only affects
// the two columns were tiles were taken
#ifdef DEBUGGING
qCDebug
(
KSHISEN_LOG
)
<<
"[undo] gravity from vertical slide"
;
#endif
// vertical slide, in fact nothing special is necessary
// the default implementation works because it only affects
// the two columns were tiles were taken
// move tiles from the first column up
for
(
int
y
=
0
;
y
<
move
->
m_y1
;
++
y
)
{
...
...
@@ -1673,7 +1680,7 @@ void Board::redo()
if
(
canRedo
())
{
clearHighlight
();
undrawConnection
();
Move
*
move
=
m_redo
.
takeFirst
();
Move
*
move
=
m_redo
.
takeFirst
();
// redo the slide if any
if
(
move
->
m_hasSlide
)
{
Path
s
;
...
...
@@ -1721,7 +1728,7 @@ void Board::dumpBoard() const
dumpBoard
(
m_field
);
}
void
Board
::
dumpBoard
(
const
std
::
vector
<
int
>&
board
)
const
void
Board
::
dumpBoard
(
const
std
::
vector
<
int
>
&
board
)
const
{
qCDebug
(
KSHISEN_LOG
)
<<
"Board contents:"
;
for
(
int
y
=
0
;
y
<
yTiles
();
++
y
)
{
...
...
@@ -1778,7 +1785,7 @@ bool Board::hint_I(PossibleMoves & possibleMoves) const
int
Board
::
tilesLeft
()
const
{
return
std
::
count_if
(
m_field
.
begin
(),
m_field
.
end
(),
[](
int
field
){
return
field
!=
EMPTY
;
});
return
std
::
count_if
(
m_field
.
begin
(),
m_field
.
end
(),
[](
int
field
)
{
return
field
!=
EMPTY
;
});
}
int
Board
::
currentTime
()
const
...
...
src/board.h
View file @
b839346a
...
...
@@ -36,8 +36,8 @@
#include <KRandomSequence>
// KDEGames
#include <KgSound>
#include <KGameClock>
#include <KgSound>
// KMahjongg
#include <kmahjonggbackground.h>
...
...
@@ -66,14 +66,22 @@ using Path = QList<TilePos>;
class
PossibleMove
{
public:
explicit
PossibleMove
(
Path
&
path
)
:
m_path
(
path
),
m_hasSlide
(
false
)
{
}
PossibleMove
(
Path
&
path
,
Path
&
slide
)
:
m_path
(
path
),
m_hasSlide
(
true
),
m_slide
(
slide
)
{
}
explicit
PossibleMove
(
Path
&
path
)
:
m_path
(
path
)
,
m_hasSlide
(
false
)
{
}
PossibleMove
(
Path
&
path
,
Path
&
slide
)
:
m_path
(
path
)
,
m_hasSlide
(
true
)
,
m_slide
(
slide
)
{
}
bool
isInPath
(
TilePos
const
&
tilePos
)
const
;
void
Debug
()
const
{
void
Debug
()
const
{
qCDebug
(
KSHISEN_LOG
)
<<
"PossibleMove"
;
for
(
auto
iter
=
m_path
.
cbegin
();
iter
!=
m_path
.
cend
();
++
iter
)
{
...
...
@@ -107,12 +115,48 @@ using PossibleMoves = QList<PossibleMove>;
class
Move
{
public:
Move
(
TilePos
const
&
tilePos1
,
TilePos
const
&
tilePos2
,
int
tile
)
:
m_x1
(
tilePos1
.
x
()),
m_y1
(
tilePos1
.
y
()),
m_x2
(
tilePos2
.
x
()),
m_y2
(
tilePos2
.
y
()),
m_tile1
(
tile
),
m_tile2
(
tile
),
m_hasSlide
(
false
),
m_slideX1
(
-
1
),
m_slideY1
(
-
1
),
m_slideX2
(
-
1
),
m_slideY2
(
-
1
)
{
}
Move
(
TilePos
const
&
tilePos1
,
TilePos
const
&
tilePos2
,
int
tile1
,
int
tile2
)
:
m_x1
(
tilePos1
.
x
()),
m_y1
(
tilePos1
.
y
()),
m_x2
(
tilePos2
.
x
()),
m_y2
(
tilePos2
.
y
()),
m_tile1
(
tile1
),
m_tile2
(
tile2
),
m_hasSlide
(
false
),
m_slideX1
(
-
1
),
m_slideY1
(
-
1
),
m_slideX2
(
-
1
),
m_slideY2
(
-
1
)
{
}
Move
(
TilePos
const
&
tilePos1
,
TilePos
const
&
tilePos2
,
int
tile1
,
int
tile2
,
int
slideX1
,
int
slideY1
,
int
slideX2
,
int
slideY2
)
:
m_x1
(
tilePos1
.
x
()),
m_y1
(
tilePos1
.
y
()),
m_x2
(
tilePos2
.
x
()),
m_y2
(
tilePos2
.
y
()),
m_tile1
(
tile1
),
m_tile2
(
tile2
),
m_hasSlide
(
true
),
m_slideX1
(
slideX1
),
m_slideY1
(
slideY1
),
m_slideX2
(
slideX2
),
m_slideY2
(
slideY2
)
{
}
Move
(
TilePos
const
&
tilePos1
,
TilePos
const
&
tilePos2
,
int
tile
)
:
m_x1
(
tilePos1
.
x
())
,
m_y1
(
tilePos1
.
y
())
,
m_x2
(
tilePos2
.
x
())
,
m_y2
(
tilePos2
.
y
())
,
m_tile1
(
tile
)
,
m_tile2
(
tile
)
,
m_hasSlide
(
false
)
,
m_slideX1
(
-
1
)
,
m_slideY1
(
-
1
)
,
m_slideX2
(
-
1
)
,
m_slideY2
(
-
1
)
{
}
Move
(
TilePos
const
&
tilePos1
,
TilePos
const
&
tilePos2
,
int
tile1
,
int
tile2
)
:
m_x1
(
tilePos1
.
x
())
,
m_y1
(
tilePos1
.
y
())
,
m_x2
(
tilePos2
.
x
())
,
m_y2
(
tilePos2
.
y
())
,
m_tile1
(
tile1
)
,
m_tile2
(
tile2
)
,
m_hasSlide
(
false
)
,
m_slideX1
(
-
1
)
,
m_slideY1
(
-
1
)
,
m_slideX2
(
-
1
)
,
m_slideY2
(
-
1
)
{
}
Move
(
TilePos
const
&
tilePos1
,
TilePos
const
&
tilePos2
,
int
tile1
,
int
tile2
,
int
slideX1
,
int
slideY1
,
int
slideX2
,
int
slideY2
)
:
m_x1
(
tilePos1
.
x
())
,
m_y1
(
tilePos1
.
y
())
,
m_x2
(
tilePos2
.
x
())
,
m_y2
(
tilePos2
.
y
())
,
m_tile1
(
tile1
)
,
m_tile2
(
tile2
)
,
m_hasSlide
(
true
)
,
m_slideX1
(
slideX1
)
,
m_slideY1
(
slideY1
)
,
m_slideX2
(
slideX2
)
,
m_slideY2
(
slideY2
)
{
}
int
m_x1
,
m_y1
,
m_x2
,
m_y2
;
///< coordinates of the two tiles that matched
int
m_tile1
;
///< type of tile at first set of coordinates
...
...
@@ -143,7 +187,7 @@ public:
virtual
void
resizeEvent
(
QResizeEvent
*
e
);
void
setDelay
(
int
);
int
delay
()
const
;
int
delay
()
const
;
/// Returns if undo step is available
bool
canUndo
()
const
;
...
...
@@ -351,8 +395,8 @@ private:
KRandomSequence
m_random
;
QList
<
Move
*>
m_undo
;
///< Undo history
QList
<
Move
*>
m_redo
;
///< Redo history
QList
<
Move
*>
m_undo
;
///< Undo history
QList
<
Move
*>
m_redo
;
///< Redo history
int
m_markX
;
int
m_markY
;
...
...
@@ -366,7 +410,10 @@ private:
int
m_shuffle
;
// The game can be in one of the following states.
enum
class
GameState
{
Normal
,
Paused
,
Stuck
,
Over
};
enum
class
GameState
{
Normal
,
Paused
,
Stuck
,
Over
};
GameState
m_gameState
;
bool
m_cheat
;
///< Whether the cheat mode is set
...
...
src/kshisen_debug.h
View file @
b839346a
...
...
@@ -26,4 +26,4 @@
Q_DECLARE_LOGGING_CATEGORY
(
KSHISEN_LOG
)
#endif
#endif
src/main.cpp
View file @
b839346a
...
...
@@ -25,8 +25,8 @@
// KDE
#include <KAboutData>
#include <KDBusService>
#include <Kdelibs4ConfigMigrator>
#include <KLocalizedString>
#include <Kdelibs4ConfigMigrator>
// KShisen
#include "app.h"
...
...
@@ -34,7 +34,7 @@
static
const
char
description
[]
=
I18N_NOOP
(
"A KDE game similar to Mahjongg"
);
int
main
(
int
argc
,
char
**
argv
)
int
main
(
int
argc
,
char
**
argv
)
{
QApplication
a
(
argc
,
argv
);
...
...
@@ -68,7 +68,7 @@ int main(int argc, char **argv)
KDBusService
service
;
App
*
app
=
new
App
();
App
*
app
=
new
App
();
app
->
show
();
return
a
.
exec
();
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment