Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
I
ingame
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Vladislav
ingame
Commits
7a41473b
Commit
7a41473b
authored
May 07, 2024
by
Georgiy Yankovskiy
Browse files
Options
Browse Files
Download
Plain Diff
Merge conflicts solved
parents
57718f8b
eb599f83
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
189 additions
and
92 deletions
+189
-92
App.py
ingame/models/App.py
+5
-1
Gamepad.py
ingame/models/Gamepad.py
+15
-0
Button.qml
qml/components/Button.qml
+23
-23
Tabs.qml
qml/components/Tabs.qml
+0
-0
TextButton.qml
qml/components/TextButton.qml
+37
-21
Game.qml
qml/delegates/Game.qml
+59
-32
qml.qml
qml/qml.qml
+3
-3
GameInfoScene.qml
qml/scenes/GameInfoScene.qml
+44
-11
HomeScene.qml
qml/scenes/HomeScene.qml
+3
-1
No files found.
ingame/models/App.py
View file @
7a41473b
...
@@ -29,6 +29,7 @@ class App(QtCore.QObject):
...
@@ -29,6 +29,7 @@ class App(QtCore.QObject):
gamepad_clicked_LB
=
Signal
(
bool
,
name
=
"gamepadClickedLB"
)
gamepad_clicked_LB
=
Signal
(
bool
,
name
=
"gamepadClickedLB"
)
gamepad_clicked_RB
=
Signal
(
bool
,
name
=
"gamepadClickedRB"
)
gamepad_clicked_RB
=
Signal
(
bool
,
name
=
"gamepadClickedRB"
)
gamepad_clicked_apply
=
Signal
(
bool
,
name
=
"gamepadClickedApply"
)
gamepad_clicked_apply
=
Signal
(
bool
,
name
=
"gamepadClickedApply"
)
gamepad_clicked_back
=
Signal
(
bool
,
name
=
"gamepadClickedBack"
)
gamepad_axis_left
=
Signal
(
bool
,
name
=
"gamepadAxisLeft"
)
gamepad_axis_left
=
Signal
(
bool
,
name
=
"gamepadAxisLeft"
)
gamepad_axis_right
=
Signal
(
bool
,
name
=
"gamepadAxisRight"
)
gamepad_axis_right
=
Signal
(
bool
,
name
=
"gamepadAxisRight"
)
...
@@ -46,6 +47,7 @@ class App(QtCore.QObject):
...
@@ -46,6 +47,7 @@ class App(QtCore.QObject):
self
.
gamepad
.
apply_clicked
=
lambda
:
self
.
gamepad_clicked_apply
.
emit
(
True
)
self
.
gamepad
.
apply_clicked
=
lambda
:
self
.
gamepad_clicked_apply
.
emit
(
True
)
self
.
gamepad
.
l_clicked
=
lambda
:
self
.
gamepad_axis_left
.
emit
(
True
)
self
.
gamepad
.
l_clicked
=
lambda
:
self
.
gamepad_axis_left
.
emit
(
True
)
self
.
gamepad
.
r_clicked
=
lambda
:
self
.
gamepad_axis_right
.
emit
(
True
)
self
.
gamepad
.
r_clicked
=
lambda
:
self
.
gamepad_axis_right
.
emit
(
True
)
self
.
gamepad
.
back_clicked
=
lambda
:
self
.
gamepad_clicked_back
.
emit
(
True
)
self
.
setup
()
self
.
setup
()
...
@@ -86,6 +88,9 @@ class App(QtCore.QObject):
...
@@ -86,6 +88,9 @@ class App(QtCore.QObject):
# Автозапуск игры:
# Автозапуск игры:
# PW_GUI_DISABLED_CS=1
# PW_GUI_DISABLED_CS=1
# START_FROM_STEAM=1
# START_FROM_STEAM=1
# Remove extra env in the beginning
_exec
=
_exec
[
4
:
len
(
_exec
)]
_exec
=
f
"env START_FROM_STEAM=1 {_exec}"
_exec
=
f
"env START_FROM_STEAM=1 {_exec}"
self
.
games_model
.
add_game
(
Game
(
name
=
_name
,
icon
=
_icon
,
exec
=
_exec
))
self
.
games_model
.
add_game
(
Game
(
name
=
_name
,
icon
=
_icon
,
exec
=
_exec
))
...
@@ -113,7 +118,6 @@ class App(QtCore.QObject):
...
@@ -113,7 +118,6 @@ class App(QtCore.QObject):
@Slot
(
str
)
@Slot
(
str
)
def
start_game
(
self
,
exec
):
def
start_game
(
self
,
exec
):
self
.
game_started
.
emit
(
True
)
self
.
game_started
.
emit
(
True
)
def
run_in_thread
(
t
,
_exec
):
def
run_in_thread
(
t
,
_exec
):
t
.
running_game_process
=
subprocess
.
Popen
(
t
.
running_game_process
=
subprocess
.
Popen
(
_exec
,
_exec
,
...
...
ingame/models/Gamepad.py
View file @
7a41473b
...
@@ -12,20 +12,26 @@ class Gamepad:
...
@@ -12,20 +12,26 @@ class Gamepad:
LEFT_RIGHT_AXIS
=
0
LEFT_RIGHT_AXIS
=
0
LEFT_RIGHT_AXIS_SENSITIVITY
=
0.7
LEFT_RIGHT_AXIS_SENSITIVITY
=
0.7
APPLY_BUTTON
=
0
APPLY_BUTTON
=
0
BACK_BUTTON
=
1
def
__init__
(
self
):
def
__init__
(
self
):
self
.
joystick
:
Union
[
Joystick
,
None
]
=
None
self
.
joystick
:
Union
[
Joystick
,
None
]
=
None
self
.
terminated
:
bool
=
False
self
.
terminated
:
bool
=
False
self
.
last_rb_clicked
:
bool
=
False
self
.
last_rb_clicked
:
bool
=
False
self
.
last_lb_clicked
:
bool
=
False
self
.
last_lb_clicked
:
bool
=
False
self
.
last_apply_clicked
:
bool
=
False
self
.
last_apply_clicked
:
bool
=
False
self
.
last_left_clicked
:
bool
=
False
self
.
last_left_clicked
:
bool
=
False
self
.
last_right_clicked
:
bool
=
False
self
.
last_right_clicked
:
bool
=
False
self
.
last_back_clicked
:
bool
=
False
self
.
lb_clicked
:
()
=
lambda
:
None
self
.
lb_clicked
:
()
=
lambda
:
None
self
.
rb_clicked
:
()
=
lambda
:
None
self
.
rb_clicked
:
()
=
lambda
:
None
self
.
l_clicked
:
()
=
lambda
:
None
self
.
l_clicked
:
()
=
lambda
:
None
self
.
r_clicked
:
()
=
lambda
:
None
self
.
r_clicked
:
()
=
lambda
:
None
self
.
back_clicked
:
()
=
lambda
:
None
self
.
apply_clicked
:
()
=
lambda
:
None
self
.
apply_clicked
:
()
=
lambda
:
None
self
.
thread
:
Union
[
threading
.
Thread
,
None
]
=
None
self
.
thread
:
Union
[
threading
.
Thread
,
None
]
=
None
pygame
.
init
()
pygame
.
init
()
...
@@ -58,6 +64,7 @@ class Gamepad:
...
@@ -58,6 +64,7 @@ class Gamepad:
rb_button
=
self
.
joystick
.
get_button
(
self
.
RB_BUTTON
)
rb_button
=
self
.
joystick
.
get_button
(
self
.
RB_BUTTON
)
apply_button
=
self
.
joystick
.
get_button
(
self
.
APPLY_BUTTON
)
apply_button
=
self
.
joystick
.
get_button
(
self
.
APPLY_BUTTON
)
left_right_axis
=
self
.
joystick
.
get_axis
(
self
.
LEFT_RIGHT_AXIS
)
left_right_axis
=
self
.
joystick
.
get_axis
(
self
.
LEFT_RIGHT_AXIS
)
back_button
=
self
.
joystick
.
get_button
(
self
.
BACK_BUTTON
)
# LB
# LB
...
@@ -103,6 +110,14 @@ class Gamepad:
...
@@ -103,6 +110,14 @@ class Gamepad:
if
(
not
left_right_axis
>=
self
.
LEFT_RIGHT_AXIS_SENSITIVITY
)
and
self
.
last_right_clicked
:
if
(
not
left_right_axis
>=
self
.
LEFT_RIGHT_AXIS_SENSITIVITY
)
and
self
.
last_right_clicked
:
self
.
last_right_clicked
=
not
self
.
last_right_clicked
self
.
last_right_clicked
=
not
self
.
last_right_clicked
# BACK
if
back_button
and
not
self
.
last_back_clicked
:
self
.
last_back_clicked
=
not
self
.
last_back_clicked
self
.
back_clicked
()
if
not
back_button
and
self
.
last_back_clicked
:
self
.
last_back_clicked
=
not
self
.
last_back_clicked
# print(f"Button {self.LB_BUTTON}: {lb_button}")
# print(f"Button {self.LB_BUTTON}: {lb_button}")
# print(f"Button {self.RB_BUTTON}: {rb_button}")
# print(f"Button {self.RB_BUTTON}: {rb_button}")
...
...
qml/components/Button.qml
View file @
7a41473b
...
@@ -7,32 +7,32 @@ C.Button {
...
@@ -7,32 +7,32 @@ C.Button {
font.bold
:
true
font.bold
:
true
//font.letterSpacing: font.pixelSize / 100 * 30
//font.letterSpacing: font.pixelSize / 100 * 30
//
font.pointSize: Math.max(parent.width / 100,10)
font.pointSize
:
Math
.
max
(
parent
.
width
/
100
,
10
)
//
contentItem: Text {
contentItem
:
Text
{
//
text: control.text
text
:
control
.
text
//
font: control.font
font
:
control
.
font
//
//fontSizeMode: Text.Fit; minimumPixelSize: 10;
//fontSizeMode: Text.Fit; minimumPixelSize: 10;
//
opacity: enabled ? 1.0 : 0.3
opacity
:
enabled
?
1.0
:
0.3
// color: control.down ? "Black
" : (control.activeFocus ? "#333333" : "#ffffff")
color
:
control
.
down
?
"#000000
"
:
(
control
.
activeFocus
?
"#333333"
:
"#ffffff"
)
//
horizontalAlignment: Text.AlignHCenter
horizontalAlignment
:
Text
.
AlignHCenter
//
verticalAlignment: Text.AlignVCenter
verticalAlignment
:
Text
.
AlignVCenter
//
elide: Text.ElideRight
elide
:
Text
.
ElideRight
//
leftPadding: font.pointSize / 100 * 20
leftPadding
:
font
.
pointSize
/
100
*
20
//
rightPadding: font.pointSize / 100 * 20
rightPadding
:
font
.
pointSize
/
100
*
20
//
topPadding: font.pointSize / 100 * 0
topPadding
:
font
.
pointSize
/
100
*
0
//
bottomPadding: font.pointSize / 100 * 0
bottomPadding
:
font
.
pointSize
/
100
*
0
//
}
}
//
background: Rectangle {
background
:
Rectangle
{
//
//implicitWidth: 100
//implicitWidth: 100
//
//implicitHeight: 40
//implicitHeight: 40
//
opacity: enabled ? 1 : 0.3
opacity
:
enabled
?
1
:
0.3
// color: control.down ? "#000000" : (control.activeFocus ? "#ffffff" : "#00
000000")
color
:
control
.
down
?
"#aaaaaa"
:
(
control
.
activeFocus
?
"#aaaaaa"
:
"#
000000"
)
//
border.width: 0
border.width
:
0
//
radius: 16
radius
:
16
//
}
}
}
}
qml/components/Tabs.qml
View file @
7a41473b
This diff is collapsed.
Click to expand it.
qml/components/TextButton.qml
View file @
7a41473b
...
@@ -8,9 +8,9 @@ C.Button {
...
@@ -8,9 +8,9 @@ C.Button {
property
bool
isActive
:
false
property
bool
isActive
:
false
hoverEnabled
:
true
hoverEnabled
:
true
//width: parent.width / 100 * 1.5
//
width: parent.width / 100 * 1.5
//height: 200
//
height: 200
//text: "Size me!"
//
text: "Size me!"
contentItem
:
Text
{
contentItem
:
Text
{
id
:
text
id
:
text
...
@@ -21,7 +21,7 @@ C.Button {
...
@@ -21,7 +21,7 @@ C.Button {
horizontalAlignment
:
Text
.
AlignHCenter
horizontalAlignment
:
Text
.
AlignHCenter
verticalAlignment
:
Text
.
AlignVCenter
verticalAlignment
:
Text
.
AlignVCenter
//fontSizeMode: Text.Fit
//
fontSizeMode: Text.Fit
color
:
'white'
color
:
'white'
opacity
:
0.8
opacity
:
0.8
}
}
...
@@ -34,7 +34,7 @@ C.Button {
...
@@ -34,7 +34,7 @@ C.Button {
width
:
0
width
:
0
anchors.horizontalCenter
:
root
.
horizontalCenter
anchors.horizontalCenter
:
root
.
horizontalCenter
anchors.top
:
root
.
top
anchors.top
:
root
.
top
//
anchors.bottom:root.bottom
// anchors.bottom:root.bottom
}
}
...
@@ -43,15 +43,23 @@ C.Button {
...
@@ -43,15 +43,23 @@ C.Button {
// Карточка в фокуске
// Карточка в фокуске
State
{
State
{
name
:
"active"
;
when
:
isActive
name
:
"active"
;
when
:
isActive
PropertyChanges
{
target
:
line
;
width
:
parent
.
width
;}
PropertyChanges
{
PropertyChanges
{
target
:
text
;
opacity
:
1
}
target
:
line
;
width
:
parent
.
width
;
}
PropertyChanges
{
target
:
text
;
opacity
:
1
;
}
},
},
// На карточку навели курсор мыши
// На карточку навели курсор мыши
State
{
State
{
name
:
"hover"
;
when
:
hovered
&&
!
isActive
name
:
"hover"
;
when
:
hovered
&&
!
isActive
//PropertyChanges { target: line; width: parent.width;}
//PropertyChanges { target: line; width: parent.width;}
PropertyChanges
{
target
:
text
;
opacity
:
1
}
PropertyChanges
{
target
:
text
;
opacity
:
1
;
}
}
}
]
]
...
@@ -61,13 +69,17 @@ C.Button {
...
@@ -61,13 +69,17 @@ C.Button {
to
:
"active"
to
:
"active"
reversible
:
true
reversible
:
true
id
:
activeAnim
id
:
activeAnim
ParallelAnimation
{
ParallelAnimation
{
NumberAnimation
{
NumberAnimation
{
target
:
line
;
property
:
"width"
target
:
line
;
property
:
"width"
duration
:
200
duration
:
200
easing.type
:
Easing
.
InOutQuad
easing.type
:
Easing
.
InOutQuad
}
}
NumberAnimation
{
target
:
text
;
property
:
"opacity"
;
duration
:
100
}
NumberAnimation
{
target
:
text
;
property
:
"opacity"
;
duration
:
100
}
}
}
},
},
...
@@ -76,11 +88,15 @@ C.Button {
...
@@ -76,11 +88,15 @@ C.Button {
reversible
:
true
reversible
:
true
ParallelAnimation
{
ParallelAnimation
{
NumberAnimation
{
NumberAnimation
{
target
:
line
;
property
:
"width"
target
:
line
;
property
:
"width"
duration
:
200
duration
:
200
easing.type
:
Easing
.
InOutQuad
easing.type
:
Easing
.
InOutQuad
}
}
NumberAnimation
{
target
:
text
;
property
:
"opacity"
;
duration
:
100
}
NumberAnimation
{
target
:
text
;
property
:
"opacity"
;
duration
:
100
}
}
}
}
}
]
]
...
...
qml/delegates/Game.qml
View file @
7a41473b
...
@@ -3,8 +3,9 @@ import "../constants/scene.js" as SceneConstants
...
@@ -3,8 +3,9 @@ import "../constants/scene.js" as SceneConstants
//import "../components/" as C
//import "../components/" as C
import
QtQuick
.
Controls
as
C
import
QtQuick
.
Controls
as
C
// Подключить для работы с типом объекта LinearGradient
// Карточка игры
C.Button
{
C.Button
{
property
string
gameTitle
:
"Generic title"
property
string
gameTitle
:
"Generic title"
property
string
gameIcon
:
""
property
string
gameIcon
:
""
...
@@ -17,18 +18,23 @@ C.Button {
...
@@ -17,18 +18,23 @@ C.Button {
id
:
hoverArea
id
:
hoverArea
anchors.fill
:
parent
anchors.fill
:
parent
hoverEnabled
:
true
hoverEnabled
:
true
acceptedButtons
:
"AllButtons"
onClicked
:
function
(){
onClicked
:
function
(){
// console.log(game.title)
if
(
!
game
.
visible
)
return
;
game
InfoScene
.
title
=
game
.
gameTitle
;
game
.
press
()
;
gameInfoScene
.
icon
=
game
.
gameIcon
;
}
gameInfoScene
.
exec
=
game
.
gameExec
;
}
function
press
(){
if
(
!
visible
)
return
;
gameInfoScene
.
title
=
game
.
gameTitle
;
gameInfoScene
.
icon
=
game
.
gameIcon
;
gameInfoScene
.
exec
=
game
.
gameExec
;
window
.
scene
=
SceneConstants
.
gameInfoScene
;
}
window
.
scene
=
SceneConstants
.
gameInfoScene
;
}
}
//
//
background
:
Rectangle
{
background
:
Rectangle
{
id
:
rect
id
:
rect
...
@@ -64,40 +70,51 @@ C.Button {
...
@@ -64,40 +70,51 @@ C.Button {
// Анимации при изменениях состояний
// Анимации при изменениях состояний
transitions
:
[
transitions
:
[
Transition
{
Transition
{
from
:
""
;
to
:
"focus"
from
:
""
;
reversible
:
false
to
:
"focus"
;
reversible
:
false
;
SequentialAnimation
{
SequentialAnimation
{
NumberAnimation
{
NumberAnimation
{
target
:
rect
;
property
:
"border.width"
target
:
rect
;
duration
:
100
property
:
"border.width"
to
:
Math
.
max
(
game
.
width
/
100
*
4
,
4
)
// пока x не будет равно 250
duration
:
100
easing.type
:
Easing
.
InOutQuad
to
:
Math
.
max
(
game
.
width
/
100
*
4
,
4
)
// пока x не будет равно 250
}
easing.type
:
Easing
.
InOutQuad
NumberAnimation
{
target
:
rect
;
property
:
"border.width"
;
duration
:
100
}
}
NumberAnimation
{
target
:
rect
;
property
:
"border.width"
;
duration
:
100
;
}
}
}
},
},
Transition
{
Transition
{
from
:
""
;
to
:
"hover"
from
:
""
;
to
:
"hover"
;
reversible
:
true
reversible
:
true
NumberAnimation
{
target
:
game
;
property
:
"scale"
;
duration
:
100
}
NumberAnimation
{
target
:
game
;
property
:
"scale"
;
duration
:
100
;
}
}
}
]
]
// вообще должно быть в Transition focus но оно там не рнаботает :(
// вообще должно быть в Transition focus но оно там не рнаботает :(
SequentialAnimation
{
SequentialAnimation
{
id
:
anim
id
:
anim
running
:
game
.
activeFocus
?
true
:
false
running
:
game
.
activeFocus
?
true
:
false
loops
:
Animation
.
Infinite
loops
:
Animation
.
Infinite
OpacityAnimator
{
OpacityAnimator
{
target
:
rect
;
target
:
rect
;
from
:
1
;
from
:
1
;
to
:
0.4
;
to
:
0.4
;
duration
:
1000
duration
:
1000
;
}
}
OpacityAnimator
{
OpacityAnimator
{
target
:
rect
;
target
:
rect
;
from
:
0.4
;
from
:
0.4
;
to
:
1
;
to
:
1
;
duration
:
1000
duration
:
1000
;
}
}
}
}
...
@@ -113,15 +130,25 @@ C.Button {
...
@@ -113,15 +130,25 @@ C.Button {
// Градиент + название игры
// Градиент + название игры
Rectangle
{
Rectangle
{
id
:
bgNameGrad
id
:
bgNameGrad
opacity
:
0
opacity
:
0
anchors.fill
:
parent
anchors.fill
:
parent
gradient
:
Gradient
{
gradient
:
Gradient
{
GradientStop
{
position
:
0.6
;
color
:
"#00000000"
}
GradientStop
{
GradientStop
{
position
:
1.0
;
color
:
"#a0000000"
}
position
:
0.6
;
}
color
:
"#00000000"
;
Behavior
on
opacity
{
}
NumberAnimation
{
target
:
bgNameGrad
;
property
:
"opacity"
;
duration
:
200
}
GradientStop
{
position
:
1.0
;
color
:
"#a0000000"
;
}
}
Behavior
on
opacity
{
NumberAnimation
{
target
:
bgNameGrad
;
property
:
"opacity"
;
duration
:
200
;
}
}
}
// Название игры
// Название игры
Text
{
Text
{
...
@@ -140,5 +167,5 @@ C.Button {
...
@@ -140,5 +167,5 @@ C.Button {
}
}
}
}
}
}
}
}
qml/qml.qml
View file @
7a41473b
...
@@ -53,7 +53,7 @@ Window {
...
@@ -53,7 +53,7 @@ Window {
// Решение бага с изменением положений кнопок вкладок через opacity и enabled - ЭТО КОСТЫЛЬ!!!
// Решение бага с изменением положений кнопок вкладок через opacity и enabled - ЭТО КОСТЫЛЬ!!!
HomeScene
{
HomeScene
{
//visible: scene == SceneConstants.homeScene
//
visible: scene == SceneConstants.homeScene
opacity
:
scene
==
SceneConstants
.
homeScene
opacity
:
scene
==
SceneConstants
.
homeScene
enabled
:
scene
==
SceneConstants
.
homeScene
enabled
:
scene
==
SceneConstants
.
homeScene
...
@@ -62,7 +62,7 @@ Window {
...
@@ -62,7 +62,7 @@ Window {
}
}
GameInfoScene
{
GameInfoScene
{
//visible: scene == SceneConstants.gameInfoScene
//
visible: scene == SceneConstants.gameInfoScene
opacity
:
scene
==
SceneConstants
.
gameInfoScene
opacity
:
scene
==
SceneConstants
.
gameInfoScene
enabled
:
scene
==
SceneConstants
.
gameInfoScene
enabled
:
scene
==
SceneConstants
.
gameInfoScene
...
@@ -71,7 +71,7 @@ Window {
...
@@ -71,7 +71,7 @@ Window {
}
}
RunningScene
{
RunningScene
{
//visible: scene == SceneConstants.runningScene
//
visible: scene == SceneConstants.runningScene
opacity
:
scene
==
SceneConstants
.
runningScene
opacity
:
scene
==
SceneConstants
.
runningScene
enabled
:
scene
==
SceneConstants
.
runningScene
enabled
:
scene
==
SceneConstants
.
runningScene
...
...
qml/scenes/GameInfoScene.qml
View file @
7a41473b
...
@@ -9,6 +9,18 @@ Rectangle {
...
@@ -9,6 +9,18 @@ Rectangle {
property
string
icon
:
""
property
string
icon
:
""
property
string
exec
:
""
property
string
exec
:
""
onVisibleChanged
:
function
(){
// if(visible){
if
(
window
.
scene
!==
S
.
gameInfoScene
)
return
;
container
.
setItemsFocus
(
0
);
// }
}
Keys.onEscapePressed
:
function
(){
if
(
window
.
scene
!==
S
.
gameInfoScene
)
return
;
back
.
clicked
();
}
id
:
container
id
:
container
x
:
0
x
:
0
y
:
0
y
:
0
...
@@ -65,6 +77,7 @@ Rectangle {
...
@@ -65,6 +77,7 @@ Rectangle {
}
}
Button
{
Button
{
id
:
runGameButton
anchors.left
:
parent
.
left
anchors.left
:
parent
.
left
anchors.top
:
parent
.
top
anchors.top
:
parent
.
top
anchors.leftMargin
:
142
anchors.leftMargin
:
142
...
@@ -72,6 +85,7 @@ Rectangle {
...
@@ -72,6 +85,7 @@ Rectangle {
text
:
"Run game"
text
:
"Run game"
onClicked
:
function
(){
onClicked
:
function
(){
if
(
window
.
scene
!==
S
.
gameInfoScene
)
return
;
if
(
core_app
===
undefined
)
return
;
if
(
core_app
===
undefined
)
return
;
core_app
.
start_game
(
container
.
exec
);
core_app
.
start_game
(
container
.
exec
);
}
}
...
@@ -80,35 +94,54 @@ Rectangle {
...
@@ -80,35 +94,54 @@ Rectangle {
// LOGIC
// LOGIC
property
int
focusedItems
:
0
;
property
int
focusedItems
:
0
;
function
focusElements
(){
return
[
runGameButton
,
back
];
}
function
applyItemsFocus
(
inc
){
function
applyItemsFocus
(
inc
){
let
c
=
children
;
let
c
=
focusElements
();
let
i
=
focusedItems
;
focusedItems
+=
inc
;
i
+=
inc
;
if
(
focusedItems
>=
c
.
length
)
if
(
i
>=
c
.
length
)
focusedItems
=
0
;
i
=
0
;
if
(
focusedItems
<
0
)
if
(
i
<
0
)
focusedItems
=
c
.
length
-
1
;
i
=
c
.
length
-
1
;
c
[
focusedItems
].
forceActiveFocus
(
);
setItemsFocus
(
i
);
// c[focusedItems].clicked();
// c[focusedItems].clicked();
}
}
function
setItemsFocus
(
i
){
let
c
=
focusElements
();
focusedItems
=
i
;
c
[
i
].
forceActiveFocus
();
}
Connections
{
Connections
{
target
:
core_app
target
:
core_app
function
onGamepadAxisLeft
(
done
){
function
onGamepadAxisLeft
(
done
){
if
(
!
visibl
e
)
return
;
if
(
window
.
scene
!==
S
.
gameInfoScen
e
)
return
;
container
.
applyItemsFocus
(
-
1
)
container
.
applyItemsFocus
(
-
1
)
}
}
function
onGamepadAxisRight
(
done
){
function
onGamepadAxisRight
(
done
){
if
(
!
visibl
e
)
return
;
if
(
window
.
scene
!==
S
.
gameInfoScen
e
)
return
;
container
.
applyItemsFocus
(
1
)
container
.
applyItemsFocus
(
1
)
}
}
function
onGamepadClickedApply
(
done
){
function
onGamepadClickedApply
(
done
){
if
(
!
visibl
e
)
return
;
if
(
window
.
scene
!==
S
.
gameInfoScen
e
)
return
;
let
c
=
container
.
children
;
let
c
=
focusElements
()
;
c
[
container
.
focusedItems
].
clicked
();
c
[
container
.
focusedItems
].
clicked
();
}
}
function
onGamepadClickedBack
(
done
){
if
(
window
.
scene
!==
S
.
gameInfoScene
)
return
;
back
.
clicked
();
}
}
}
}
}
qml/scenes/HomeScene.qml
View file @
7a41473b
...
@@ -10,7 +10,9 @@ Rectangle {
...
@@ -10,7 +10,9 @@ Rectangle {
width
:
640
width
:
640
height
:
480
height
:
480
onVisibleChanged
:
{
tabs
.
visible
=
container
.
visible
}
onVisibleChanged
:
{
tabs
.
visible
=
container
.
visible
;
}
// Rectangle {
// Rectangle {
// id: rectangle
// id: rectangle
...
...
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