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
GitLab 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
3 months ago
by
Ulysse Durand
Browse files
Options
Downloads
Patches
Plain Diff
ÇA MARCHE
parent
9a2f731f
Branches
Branches containing commit
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 {
...
@@ -10,41 +10,38 @@ Item {
color
:
"
#ffffff
"
color
:
"
#ffffff
"
anchors.fill
:
parent
anchors.fill
:
parent
Clavier
{
id
:
clavier
x
:
225
y
:
594
}
Grid
{
Grid
{
id
:
g
rid
id
:
letterG
rid
columns
:
8
columns
:
8
rows
:
5
rows
:
5
spacing
:
5
spacing
:
4
width
:
columns
*
50
+
(
columns
-
1
)
*
spacing
anchors.centerIn
:
parent
height
:
rows
*
50
+
(
rows
-
1
)
*
spacing
width
:
600
height
:
400
anchors.horizontalCenter
:
parent
.
horizontalCenter
anchors.bottom
:
clavier
.
top
anchors.bottomMargin
:
100
// un petit espace entre la grille et le clavier
Repeater
{
Repeater
{
model
:
grid
.
columns
*
grid
.
rows
model
:
letterModel
// <-- C++ ListModel exposé ici
delegate
:
Rectangle
{
Rectangle
{
width
:
60
width
:
50
height
:
60
height
:
50
color
:
"
#dddddd
"
color
:
"
lightgray
"
border.color
:
"
#888
"
border.color
:
"
black
"
radius
:
5
objectName
:
"
cell_
"
+
index
%
grid
.
columns
+
"
_
"
+
Math
.
floor
(
index
/
grid
.
columns
)
Text
{
Text
{
anchors.centerIn
:
parent
anchors.centerIn
:
parent
text
:
"
_
"
// ou lettre dynamique
text
:
model
.
letter
font.pixelSize
:
24
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 @@
...
@@ -3,7 +3,7 @@
#include
<QString>
#include
<QString>
Jeu
::
Jeu
(
QObject
*
parent
)
:
QObject
(
parent
)
{
Jeu
::
Jeu
(
QObject
*
rootObject
,
QObject
*
parent
)
:
QObject
(
parent
)
,
rootObject
(
rootObject
)
{
brain
=
new
Brain
(
"./"
);
brain
=
new
Brain
(
"./"
);
}
}
...
@@ -25,16 +25,28 @@ void Jeu::onClavierClick(QString lettre) {
...
@@ -25,16 +25,28 @@ void Jeu::onClavierClick(QString lettre) {
if
(
!
m_letterModel
)
if
(
!
m_letterModel
)
return
;
return
;
//
if (currentIndex < 40) { // on évite de dépasser la grille
if
(
currentIndex
<
40
)
{
// on évite de dépasser la grille
//
m_letterModel->setLetter(currentIndex, lettre);
m_letterModel
->
setLetter
(
currentIndex
,
lettre
);
//
currentIndex++;
currentIndex
++
;
//
}
}
brain
->
entreLettre
(
lettre
.
toStdString
()[
0
]);
brain
->
entreLettre
(
lettre
.
toStdString
()[
0
]);
for
(
int
index
=
0
;
index
<
40
;
index
++
)
{
for
(
int
index
=
0
;
index
<
40
;
index
++
)
{
m_letterModel
->
setLetter
(
index
,
QString
::
fromLatin1
(
&
brain
->
getGrid
()[
index
],
1
));
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() {
...
@@ -46,8 +58,8 @@ void Jeu::initGame() {
void
Jeu
::
startGame
()
{
void
Jeu
::
startGame
()
{
brain
->
setFichierDico
(
"words_alpha.txt"
);
brain
->
setFichierDico
(
"words_alpha.txt"
);
brain
->
setNombreEssais
(
8
);
brain
->
setNombreEssais
(
5
);
brain
->
setTailleMots
(
5
);
brain
->
setTailleMots
(
8
);
brain
->
initGame
();
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 {
...
@@ -13,7 +13,7 @@ class Jeu : public QObject {
Q_PROPERTY
(
QQuickItem
*
gameWindow
READ
getGameWindow
NOTIFY
gameWindowChanged
)
Q_PROPERTY
(
QQuickItem
*
gameWindow
READ
getGameWindow
NOTIFY
gameWindowChanged
)
public:
public:
explicit
Jeu
(
QObject
*
parent
=
nullptr
);
explicit
Jeu
(
QObject
*
rootObject
,
QObject
*
parent
=
nullptr
);
QString
getMotAffiche
();
QString
getMotAffiche
();
Q_INVOKABLE
void
onClavierClick
(
QString
lettre
);
Q_INVOKABLE
void
onClavierClick
(
QString
lettre
);
Q_INVOKABLE
void
initGame
();
Q_INVOKABLE
void
initGame
();
...
@@ -28,6 +28,7 @@ signals:
...
@@ -28,6 +28,7 @@ signals:
private
:
private
:
Brain
*
brain
;
Brain
*
brain
;
QObject
*
rootObject
;
QString
mot
;
QString
mot
;
QQuickItem
*
gameWindow
;
// Pointer to the QQuickItem of the GameWindow
QQuickItem
*
gameWindow
;
// Pointer to the QQuickItem of the GameWindow
LetterModel
*
m_letterModel
=
nullptr
;
// Modèle QML
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