Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
projetcppqt
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Durand Ulysse
projetcppqt
Commits
358b142a
Commit
358b142a
authored
2 months ago
by
Ulysse Durand
Browse files
Options
Downloads
Patches
Plain Diff
ÇA MARCHE
parent
9a2f731f
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
motus/GameWindow.qml
+20
-23
20 additions, 23 deletions
motus/GameWindow.qml
motus/jeu.cpp
+19
-7
19 additions, 7 deletions
motus/jeu.cpp
motus/jeu.h
+2
-1
2 additions, 1 deletion
motus/jeu.h
with
41 additions
and
31 deletions
motus/GameWindow.qml
+
20
−
23
View file @
358b142a
...
...
@@ -10,41 +10,38 @@ Item {
color
:
"
#ffffff
"
anchors.fill
:
parent
Clavier
{
id
:
clavier
x
:
225
y
:
594
}
Grid
{
id
:
g
rid
id
:
letterG
rid
columns
:
8
rows
:
5
spacing
:
5
width
:
columns
*
50
+
(
columns
-
1
)
*
spacing
height
:
rows
*
50
+
(
rows
-
1
)
*
spacing
anchors.horizontalCenter
:
parent
.
horizontalCenter
anchors.bottom
:
clavier
.
top
anchors.bottomMargin
:
100
// un petit espace entre la grille et le clavier
spacing
:
4
anchors.centerIn
:
parent
width
:
600
height
:
400
Repeater
{
model
:
grid
.
columns
*
grid
.
rows
Rectangle
{
width
:
50
height
:
50
color
:
"
lightgray
"
border.color
:
"
black
"
objectName
:
"
cell_
"
+
index
%
grid
.
columns
+
"
_
"
+
Math
.
floor
(
index
/
grid
.
columns
)
model
:
letterModel
// <-- C++ ListModel exposé ici
delegate
:
Rectangle
{
width
:
60
height
:
60
color
:
"
#dddddd
"
border.color
:
"
#888
"
radius
:
5
Text
{
anchors.centerIn
:
parent
text
:
"
_
"
// ou lettre dynamique
text
:
model
.
letter
font.pixelSize
:
24
}
}
}
}
Clavier
{
id
:
clavier
x
:
225
y
:
594
}
}
}
This diff is collapsed.
Click to expand it.
motus/jeu.cpp
+
19
−
7
View file @
358b142a
...
...
@@ -3,7 +3,7 @@
#include
<QString>
Jeu
::
Jeu
(
QObject
*
parent
)
:
QObject
(
parent
)
{
Jeu
::
Jeu
(
QObject
*
rootObject
,
QObject
*
parent
)
:
QObject
(
parent
)
,
rootObject
(
rootObject
)
{
brain
=
new
Brain
(
"./"
);
}
...
...
@@ -25,16 +25,28 @@ void Jeu::onClavierClick(QString lettre) {
if
(
!
m_letterModel
)
return
;
//
if (currentIndex < 40) { // on évite de dépasser la grille
//
m_letterModel->setLetter(currentIndex, lettre);
//
currentIndex++;
//
}
if
(
currentIndex
<
40
)
{
// on évite de dépasser la grille
m_letterModel
->
setLetter
(
currentIndex
,
lettre
);
currentIndex
++
;
}
brain
->
entreLettre
(
lettre
.
toStdString
()[
0
]);
for
(
int
index
=
0
;
index
<
40
;
index
++
)
{
m_letterModel
->
setLetter
(
index
,
QString
::
fromLatin1
(
&
brain
->
getGrid
()[
index
],
1
));
}
// string lagrille = brain->getGrid();
// for (int index = 0; index < 40; index ++) {
// string nomCell = "cell_"+to_string(index/8)+"_"+to_string(index%8);
// QObject *cell = rootObject->findChild<QObject*>(nomCell);
// if (cell) {
// cell->setProperty("color", "red");
// }
// }
}
...
...
@@ -46,8 +58,8 @@ void Jeu::initGame() {
void
Jeu
::
startGame
()
{
brain
->
setFichierDico
(
"words_alpha.txt"
);
brain
->
setNombreEssais
(
8
);
brain
->
setTailleMots
(
5
);
brain
->
setNombreEssais
(
5
);
brain
->
setTailleMots
(
8
);
brain
->
initGame
();
...
...
This diff is collapsed.
Click to expand it.
motus/jeu.h
+
2
−
1
View file @
358b142a
...
...
@@ -13,7 +13,7 @@ class Jeu : public QObject {
Q_PROPERTY
(
QQuickItem
*
gameWindow
READ
getGameWindow
NOTIFY
gameWindowChanged
)
public:
explicit
Jeu
(
QObject
*
parent
=
nullptr
);
explicit
Jeu
(
QObject
*
rootObject
,
QObject
*
parent
=
nullptr
);
QString
getMotAffiche
();
Q_INVOKABLE
void
onClavierClick
(
QString
lettre
);
Q_INVOKABLE
void
initGame
();
...
...
@@ -28,6 +28,7 @@ signals:
private
:
Brain
*
brain
;
QObject
*
rootObject
;
QString
mot
;
QQuickItem
*
gameWindow
;
// Pointer to the QQuickItem of the GameWindow
LetterModel
*
m_letterModel
=
nullptr
;
// Modèle QML
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment