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
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
279 additions
and
130 deletions
+279
-130
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
+108
-56
TextButton.qml
qml/components/TextButton.qml
+27
-11
Game.qml
qml/delegates/Game.qml
+51
-24
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):
gamepad_clicked_LB
=
Signal
(
bool
,
name
=
"gamepadClickedLB"
)
gamepad_clicked_RB
=
Signal
(
bool
,
name
=
"gamepadClickedRB"
)
gamepad_clicked_apply
=
Signal
(
bool
,
name
=
"gamepadClickedApply"
)
gamepad_clicked_back
=
Signal
(
bool
,
name
=
"gamepadClickedBack"
)
gamepad_axis_left
=
Signal
(
bool
,
name
=
"gamepadAxisLeft"
)
gamepad_axis_right
=
Signal
(
bool
,
name
=
"gamepadAxisRight"
)
...
...
@@ -46,6 +47,7 @@ class App(QtCore.QObject):
self
.
gamepad
.
apply_clicked
=
lambda
:
self
.
gamepad_clicked_apply
.
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
.
back_clicked
=
lambda
:
self
.
gamepad_clicked_back
.
emit
(
True
)
self
.
setup
()
...
...
@@ -86,6 +88,9 @@ class App(QtCore.QObject):
# Автозапуск игры:
# PW_GUI_DISABLED_CS=1
# START_FROM_STEAM=1
# Remove extra env in the beginning
_exec
=
_exec
[
4
:
len
(
_exec
)]
_exec
=
f
"env START_FROM_STEAM=1 {_exec}"
self
.
games_model
.
add_game
(
Game
(
name
=
_name
,
icon
=
_icon
,
exec
=
_exec
))
...
...
@@ -113,7 +118,6 @@ class App(QtCore.QObject):
@Slot
(
str
)
def
start_game
(
self
,
exec
):
self
.
game_started
.
emit
(
True
)
def
run_in_thread
(
t
,
_exec
):
t
.
running_game_process
=
subprocess
.
Popen
(
_exec
,
...
...
ingame/models/Gamepad.py
View file @
7a41473b
...
...
@@ -12,20 +12,26 @@ class Gamepad:
LEFT_RIGHT_AXIS
=
0
LEFT_RIGHT_AXIS_SENSITIVITY
=
0.7
APPLY_BUTTON
=
0
BACK_BUTTON
=
1
def
__init__
(
self
):
self
.
joystick
:
Union
[
Joystick
,
None
]
=
None
self
.
terminated
:
bool
=
False
self
.
last_rb_clicked
:
bool
=
False
self
.
last_lb_clicked
:
bool
=
False
self
.
last_apply_clicked
:
bool
=
False
self
.
last_left_clicked
:
bool
=
False
self
.
last_right_clicked
:
bool
=
False
self
.
last_back_clicked
:
bool
=
False
self
.
lb_clicked
:
()
=
lambda
:
None
self
.
rb_clicked
:
()
=
lambda
:
None
self
.
l_clicked
:
()
=
lambda
:
None
self
.
r_clicked
:
()
=
lambda
:
None
self
.
back_clicked
:
()
=
lambda
:
None
self
.
apply_clicked
:
()
=
lambda
:
None
self
.
thread
:
Union
[
threading
.
Thread
,
None
]
=
None
pygame
.
init
()
...
...
@@ -58,6 +64,7 @@ class Gamepad:
rb_button
=
self
.
joystick
.
get_button
(
self
.
RB_BUTTON
)
apply_button
=
self
.
joystick
.
get_button
(
self
.
APPLY_BUTTON
)
left_right_axis
=
self
.
joystick
.
get_axis
(
self
.
LEFT_RIGHT_AXIS
)
back_button
=
self
.
joystick
.
get_button
(
self
.
BACK_BUTTON
)
# LB
...
...
@@ -103,6 +110,14 @@ class Gamepad:
if
(
not
left_right_axis
>=
self
.
LEFT_RIGHT_AXIS_SENSITIVITY
)
and
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.RB_BUTTON}: {rb_button}")
...
...
qml/components/Button.qml
View file @
7a41473b
...
...
@@ -7,32 +7,32 @@ C.Button {
font.bold
:
true
//font.letterSpacing: font.pixelSize / 100 * 30
//
font.pointSize: Math.max(parent.width / 100,10)
//
contentItem: Text {
//
text: control.text
//
font: control.font
//
//fontSizeMode: Text.Fit; minimumPixelSize: 10;
//
opacity: enabled ? 1.0 : 0.3
// color: control.down ? "Black
" : (control.activeFocus ? "#333333" : "#ffffff")
//
horizontalAlignment: Text.AlignHCenter
//
verticalAlignment: Text.AlignVCenter
//
elide: Text.ElideRight
//
leftPadding: font.pointSize / 100 * 20
//
rightPadding: font.pointSize / 100 * 20
//
topPadding: font.pointSize / 100 * 0
//
bottomPadding: font.pointSize / 100 * 0
font.pointSize
:
Math
.
max
(
parent
.
width
/
100
,
10
)
contentItem
:
Text
{
text
:
control
.
text
font
:
control
.
font
//fontSizeMode: Text.Fit; minimumPixelSize: 10;
opacity
:
enabled
?
1.0
:
0.3
color
:
control
.
down
?
"#000000
"
:
(
control
.
activeFocus
?
"#333333"
:
"#ffffff"
)
horizontalAlignment
:
Text
.
AlignHCenter
verticalAlignment
:
Text
.
AlignVCenter
elide
:
Text
.
ElideRight
leftPadding
:
font
.
pointSize
/
100
*
20
rightPadding
:
font
.
pointSize
/
100
*
20
topPadding
:
font
.
pointSize
/
100
*
0
bottomPadding
:
font
.
pointSize
/
100
*
0
//
}
}
//
background: Rectangle {
//
//implicitWidth: 100
//
//implicitHeight: 40
//
opacity: enabled ? 1 : 0.3
// color: control.down ? "#000000" : (control.activeFocus ? "#ffffff" : "#00
000000")
//
border.width: 0
//
radius: 16
background
:
Rectangle
{
//implicitWidth: 100
//implicitHeight: 40
opacity
:
enabled
?
1
:
0.3
color
:
control
.
down
?
"#aaaaaa"
:
(
control
.
activeFocus
?
"#aaaaaa"
:
"#
000000"
)
border.width
:
0
radius
:
16
//
}
}
}
qml/components/Tabs.qml
View file @
7a41473b
...
...
@@ -5,26 +5,38 @@ import "../delegates"
import
"../constants/tabs.js"
as
TabConstants
import
"../constants/style.js"
as
Style
import
"../components"
as
TopMenuBut
import
"../constants/scene.js"
as
S
// TODO: code refactor
Rectangle
{
property
string
currentTab
:
TabConstants
.
gamesTab
property
var
activeButtonTab
:
buttonGames
id
:
tabs
x
:
100
y
:
0
width
:
640
height
:
480
color
:
Style
.
backgroundColor
onVisibleChanged
:
{
tabButtons
.
changeButtonActiveTab
(
tabs
.
activeButtonTab
);
tabButtons
.
x
=
tabButtons
.
tempX
;
console
.
log
(
"tabButtons.x = "
+
tabButtons
.
x
);}
onVisibleChanged
:
{
tabButtons
.
changeButtonActiveTab
(
tabs
.
activeButtonTab
);
tabButtons
.
x
=
tabButtons
.
tempX
;
console
.
log
(
"tabButtons.x = "
+
tabButtons
.
x
);
}
Component
.
onCompleted
:{
tabButtons
.
changeButtonActiveTab
(
tabs
.
activeButtonTab
);
tabButtons
.
x
=
tabButtons
.
tempX
;
console
.
log
(
"Tabs completed!"
);}
onWidthChanged
:
function
(){
tabButtons
.
changeButtonActiveTab
(
tabs
.
activeButtonTab
);
tabButtons
.
x
=
tabButtons
.
tempX
;}
onHeightChanged
:
function
(){
tabButtons
.
changeButtonActiveTab
(
tabs
.
activeButtonTab
);
tabButtons
.
x
=
tabButtons
.
tempX
;}
Component
.
onCompleted
:
{
tabButtons
.
changeButtonActiveTab
(
tabs
.
activeButtonTab
);
tabButtons
.
x
=
tabButtons
.
tempX
;
console
.
log
(
"Tabs completed!"
);
}
onWidthChanged
:
function
(){
tabButtons
.
changeButtonActiveTab
(
tabs
.
activeButtonTab
);
tabButtons
.
x
=
tabButtons
.
tempX
;
}
onHeightChanged
:
function
(){
tabButtons
.
changeButtonActiveTab
(
tabs
.
activeButtonTab
);
tabButtons
.
x
=
tabButtons
.
tempX
;
}
Image
{
id
:
bg
...
...
@@ -44,51 +56,73 @@ Rectangle {
//anchors.leftMargin: parent.width / 10
//anchors.rightMargin: parent.width / 10
Component.onCompleted
:{
tabButtons
.
changeButtonActiveTab
(
tabs
.
activeButtonTab
);
tabButtons
.
x
=
tabButtons
.
tempX
;
console
.
log
(
"tabButtons completed!"
);}
Component.onCompleted
:
{
tabButtons
.
changeButtonActiveTab
(
tabs
.
activeButtonTab
);
tabButtons
.
x
=
tabButtons
.
tempX
;
console
.
log
(
"tabButtons completed!"
);
}
Layout
.
bottomMargin
:
buttonSystemManagement
.
height
/
2
Layout
.
topMargin
:
buttonSystemManagement
.
height
/
3
x
:
100
// Состояния
states
:
[
State
{
name
:
"ClickTabButton"
;
when
:
tabButtons
.
toggle
;
PropertyChanges
{
target
:
tabButtons
;
x
:
tempX
}},
State
{
name
:
""
;
when
:
1
==
1
}
State
{
name
:
"ClickTabButton"
;
when
:
tabButtons
.
toggle
;
PropertyChanges
{
target
:
tabButtons
;
x
:
tempX
}
},
State
{
name
:
""
;
when
:
1
==
1
}
]
// Анимации при изменениях состояний
transitions
:
Transition
{
from
:
""
;
to
:
"ClickTabButton"
PropertyAnimation
{
id
:
clickTabButtonAnimation
//from: tempX
from
:
""
;
to
:
"ClickTabButton"
;
PropertyAnimation
{
id
:
clickTabButtonAnimation
// from: tempX
duration
:
200
property
:
"x"
//
анимацию
ю можно будет поменять в любое время
property
:
"x"
//
анимаци
ю можно будет поменять в любое время
easing.type
:
Easing
.
InOutCirc
}
}
// Функция перемещения кнопок
// TODO: OPTIMIZE (REDUCE EXTRA FOR LOOP)
function
changeButtonActiveTab
(
ButtonId
){
let
index
=
0
let
left_distance
=
0
for
(
var
i
=
0
;
i
<
tabButtons
.
children
.
length
;
++
i
)
if
(
children
[
i
]
===
ButtonId
){
let
index
=
0
;
let
left_distance
=
0
;
let
i
=
0
;
for
(
i
=
0
;
i
<
tabButtons
.
children
.
length
;
++
i
)
{
if
(
children
[
i
]
===
ButtonId
)
{
index
=
i
break
}
for
(
i
=
0
;
i
<
index
;
++
i
)
left_distance
+=
spacing
+
children
[
i
].
width
tempX
=
topNavigation
.
width
/
2
-
tabButtons
.
children
[
index
].
width
/
2
-
left_distance
tabs
.
activeButtonTab
.
isActive
=
false
tabs
.
activeButtonTab
=
ButtonId
tabs
.
activeButtonTab
.
isActive
=
true
}
for
(
i
=
0
;
i
<
index
;
++
i
)
{
left_distance
+=
spacing
+
children
[
i
].
width
;
}
tempX
=
topNavigation
.
width
/
2
-
tabButtons
.
children
[
index
].
width
/
2
-
left_distance
;
tabs
.
activeButtonTab
.
isActive
=
false
;
tabs
.
activeButtonTab
=
ButtonId
;
tabs
.
activeButtonTab
.
isActive
=
true
;
}
TopMenuBut.TextButton
{
id
:
buttonSystemManagement
text
:
TabConstants
.
systemManagementTab
width
:
400
id
:
buttonSystemManagement
;
text
:
TabConstants
.
systemManagementTab
;
width
:
400
;
onClicked
:
function
(){
tabButtons
.
x
=
tabButtons
.
tempX
tabButtons
.
changeButtonActiveTab
(
this
)
...
...
@@ -191,10 +225,18 @@ Rectangle {
scrolV
.
fromAnim
=
scrolV
.
position
scrolV
.
position
=
(
1.0
-
scrolV
.
size
)
*
y
/
gamesScroller
.
height
scrolV
.
toAnim
=
(
1.0
-
scrolV
.
size
)
*
y
/
gamesScroller
.
height
if
(
scrolV
.
toAnim
!=
scrolV
.
fromAnim
)
scrollAnimation
.
start
()
if
(
scrolV
.
toAnim
!=
scrolV
.
fromAnim
)
scrollAnimation
.
start
()
}
// Анимация авто скролла
PropertyAnimation
{
to
:
scrolV
.
toAnim
;
from
:
scrolV
.
fromAnim
;
target
:
scrolV
;
id
:
scrollAnimation
;
property
:
"position"
;
duration
:
200
}
PropertyAnimation
{
to
:
scrolV
.
toAnim
;
from
:
scrolV
.
fromAnim
;
target
:
scrolV
;
id
:
scrollAnimation
;
property
:
"position"
;
duration
:
200
;
}
GridLayout
{
id
:
gamesGrid
...
...
@@ -209,7 +251,7 @@ Rectangle {
anchors.leftMargin
:
rowSpacing
*
2
anchors.bottomMargin
:
90
anchors.topMargin
:
Math
.
floor
(
gamesScroller
.
width
/
100
*
1.5
)
rowSpacing
:
Math
.
floor
(
gamesScroller
.
width
/
100
*
1.5
)
rowSpacing
:
Math
.
floor
(
gamesScroller
.
width
/
100
*
1.5
)
columnSpacing
:
rowSpacing
// Повторитель
...
...
@@ -220,9 +262,16 @@ Rectangle {
gameTitle
:
model
.
name
gameExec
:
model
.
exec
gameIcon
:
model
.
icon
Layout.bottomMargin
:
(
index
-
index
%
gamesGrid
.
columns
)
/
gamesGrid
.
columns
===
gamesGrid
.
rows
-
1
?
gamesGrid
.
rowSpacing
*
2
:
0
onFocusChanged
:
if
(
focus
)
{
gamesScroller
.
scrollToY
(
y
);
}
Layout.preferredWidth
:
(
gamesScroller
.
width
-
(
gamesGrid
.
columns
-
1
)
*
gamesGrid
.
rowSpacing
-
gamesGrid
.
anchors
.
rightMargin
-
gamesGrid
.
anchors
.
leftMargin
)
/
gamesGrid
.
columns
Layout.bottomMargin
:
(
index
-
index
%
gamesGrid
.
columns
)
/
gamesGrid
.
columns
===
gamesGrid
.
rows
-
1
?
gamesGrid
.
rowSpacing
*
2
:
0
onFocusChanged
:
if
(
focus
)
{
gamesScroller
.
scrollToY
(
y
);
}
Layout.preferredWidth
:
(
gamesScroller
.
width
-
(
gamesGrid
.
columns
-
1
)
*
gamesGrid
.
rowSpacing
-
gamesGrid
.
anchors
.
rightMargin
-
gamesGrid
.
anchors
.
leftMargin
)
/
gamesGrid
.
columns
Layout.preferredHeight
:
Layout
.
preferredWidth
/
2
*
3
}
}
...
...
@@ -234,14 +283,22 @@ Rectangle {
// LOGIC
property
int
focusedTabs
:
0
;
property
int
focusedItems
:
0
;
property
int
focusedTabs
:
0
;
function
getTabs
(){
return
[
buttonSystemManagement
,
buttonGames
,
testbut1
,
testbut2
];
}
function
applyTabsFocus
(
inc
){
if
(
!
visible
)
return
;
if
(
window
.
scene
!==
S
.
homeScene
)
return
;
let
c
=
row
.
children
;
let
c
=
tabs
.
getTabs
()
;
tabs
.
focusedTabs
+=
inc
;
if
(
tabs
.
focusedTabs
>=
c
.
length
)
...
...
@@ -250,19 +307,14 @@ Rectangle {
if
(
tabs
.
focusedTabs
<
0
)
tabs
.
focusedTabs
=
c
.
length
-
1
;
c
[
tabs
.
focusedTabs
].
forceActiveFocus
();
c
[
tabs
.
focusedTabs
].
clicked
();
/* if (c[i].focus) {
console.log("focus found");
c[i].nextItemInFocusChain().forceActiveFocus()
break
} */
let
item
=
c
[
tabs
.
focusedTabs
];
item
.
released
();
item
.
clicked
();
// tabButtons.changeButtonActiveTab(item);
}
function
applyItemsFocus
(
inc
){
if
(
!
gamesScroller
.
visible
)
return
;
if
(
window
.
scene
!==
S
.
homeScene
)
return
;
let
c
=
gamesGrid
.
children
;
...
...
@@ -281,25 +333,25 @@ Rectangle {
Connections
{
target
:
core_app
function
onGamepadClickedLB
(
done
){
if
(
!
visibl
e
)
return
;
if
(
window
.
scene
!==
S
.
homeScen
e
)
return
;
tabs
.
applyTabsFocus
(
-
1
)
}
function
onGamepadClickedRB
(
done
){
if
(
!
visibl
e
)
return
;
if
(
window
.
scene
!==
S
.
homeScen
e
)
return
;
tabs
.
applyTabsFocus
(
1
)
}
function
onGamepadAxisLeft
(
done
){
if
(
!
visibl
e
)
return
;
if
(
window
.
scene
!==
S
.
homeScen
e
)
return
;
tabs
.
applyItemsFocus
(
-
1
)
}
function
onGamepadAxisRight
(
done
){
if
(
!
visibl
e
)
return
;
if
(
window
.
scene
!==
S
.
homeScen
e
)
return
;
tabs
.
applyItemsFocus
(
1
)
}
function
onGamepadClickedApply
(
done
){
if
(
!
visibl
e
)
return
;
if
(
window
.
scene
!==
S
.
homeScen
e
)
return
;
let
c
=
gamesGrid
.
children
;
c
[
tabs
.
focusedItems
].
clicked
();
c
[
tabs
.
focusedItems
].
press
();
}
}
...
...
qml/components/TextButton.qml
View file @
7a41473b
...
...
@@ -8,9 +8,9 @@ C.Button {
property
bool
isActive
:
false
hoverEnabled
:
true
//width: parent.width / 100 * 1.5
//height: 200
//text: "Size me!"
//
width: parent.width / 100 * 1.5
//
height: 200
//
text: "Size me!"
contentItem
:
Text
{
id
:
text
...
...
@@ -21,7 +21,7 @@ C.Button {
horizontalAlignment
:
Text
.
AlignHCenter
verticalAlignment
:
Text
.
AlignVCenter
//fontSizeMode: Text.Fit
//
fontSizeMode: Text.Fit
color
:
'white'
opacity
:
0.8
}
...
...
@@ -43,15 +43,23 @@ C.Button {
// Карточка в фокуске
State
{
name
:
"active"
;
when
:
isActive
PropertyChanges
{
target
:
line
;
width
:
parent
.
width
;}
PropertyChanges
{
target
:
text
;
opacity
:
1
}
PropertyChanges
{
target
:
line
;
width
:
parent
.
width
;
}
PropertyChanges
{
target
:
text
;
opacity
:
1
;
}
},
// На карточку навели курсор мыши
State
{
name
:
"hover"
;
when
:
hovered
&&
!
isActive
//PropertyChanges { target: line; width: parent.width;}
PropertyChanges
{
target
:
text
;
opacity
:
1
}
PropertyChanges
{
target
:
text
;
opacity
:
1
;
}
}
]
...
...
@@ -62,12 +70,16 @@ C.Button {
reversible
:
true
id
:
activeAnim
ParallelAnimation
{
NumberAnimation
{
NumberAnimation
{
target
:
line
;
property
:
"width"
duration
:
200
easing.type
:
Easing
.
InOutQuad
}
NumberAnimation
{
target
:
text
;
property
:
"opacity"
;
duration
:
100
}
NumberAnimation
{
target
:
text
;
property
:
"opacity"
;
duration
:
100
}
}
},
...
...
@@ -80,7 +92,11 @@ C.Button {
duration
:
200
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
//import "../components/" as C
import
QtQuick
.
Controls
as
C
// Подключить для работы с типом объекта LinearGradient
// Карточка игры
C.Button
{
property
string
gameTitle
:
"Generic title"
property
string
gameIcon
:
""
...
...
@@ -17,18 +18,23 @@ C.Button {
id
:
hoverArea
anchors.fill
:
parent
hoverEnabled
:
true
acceptedButtons
:
"AllButtons"
onClicked
:
function
(){
// console.log(game.title)
if
(
!
game
.
visible
)
return
;
game
.
press
();
}
}
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
{
id
:
rect
...
...
@@ -64,40 +70,51 @@ C.Button {
// Анимации при изменениях состояний
transitions
:
[
Transition
{
from
:
""
;
to
:
"focus"
reversible
:
false
from
:
""
;
to
:
"focus"
;
reversible
:
false
;
SequentialAnimation
{
NumberAnimation
{
target
:
rect
;
property
:
"border.width"
target
:
rect
;
property
:
"border.width"
duration
:
100
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
{
from
:
""
;
to
:
"hover"
from
:
""
;
to
:
"hover"
;
reversible
:
true
NumberAnimation
{
target
:
game
;
property
:
"scale"
;
duration
:
100
}
NumberAnimation
{
target
:
game
;
property
:
"scale"
;
duration
:
100
;
}
}
]
// вообще должно быть в Transition focus но оно там не рнаботает :(
SequentialAnimation
{
id
:
anim
running
:
game
.
activeFocus
?
true
:
false
SequentialAnimation
{
id
:
anim
running
:
game
.
activeFocus
?
true
:
false
loops
:
Animation
.
Infinite
OpacityAnimator
{
target
:
rect
;
target
:
rect
;
from
:
1
;
to
:
0.4
;
duration
:
1000
duration
:
1000
;
}
OpacityAnimator
{
target
:
rect
;
from
:
0.4
;
to
:
1
;
duration
:
1000
duration
:
1000
;
}
}
...
...
@@ -113,15 +130,25 @@ C.Button {
// Градиент + название игры
Rectangle
{
id
:
bgNameGrad
id
:
bgNameGrad
opacity
:
0
anchors.fill
:
parent
gradient
:
Gradient
{
GradientStop
{
position
:
0.6
;
color
:
"#00000000"
}
GradientStop
{
position
:
1.0
;
color
:
"#a0000000"
}
gradient
:
Gradient
{
GradientStop
{
position
:
0.6
;
color
:
"#00000000"
;
}
GradientStop
{
position
:
1.0
;
color
:
"#a0000000"
;
}
}
Behavior
on
opacity
{
NumberAnimation
{
target
:
bgNameGrad
;
property
:
"opacity"
;
duration
:
200
;
}
Behavior
on
opacity
{
NumberAnimation
{
target
:
bgNameGrad
;
property
:
"opacity"
;
duration
:
200
}
}
// Название игры
Text
{
...
...
qml/qml.qml
View file @
7a41473b
...
...
@@ -53,7 +53,7 @@ Window {
// Решение бага с изменением положений кнопок вкладок через opacity и enabled - ЭТО КОСТЫЛЬ!!!
HomeScene
{
//visible: scene == SceneConstants.homeScene
//
visible: scene == SceneConstants.homeScene
opacity
:
scene
==
SceneConstants
.
homeScene
enabled
:
scene
==
SceneConstants
.
homeScene
...
...
@@ -62,7 +62,7 @@ Window {
}
GameInfoScene
{
//visible: scene == SceneConstants.gameInfoScene
//
visible: scene == SceneConstants.gameInfoScene
opacity
:
scene
==
SceneConstants
.
gameInfoScene
enabled
:
scene
==
SceneConstants
.
gameInfoScene
...
...
@@ -71,7 +71,7 @@ Window {
}
RunningScene
{
//visible: scene == SceneConstants.runningScene
//
visible: scene == SceneConstants.runningScene
opacity
:
scene
==
SceneConstants
.
runningScene
enabled
:
scene
==
SceneConstants
.
runningScene
...
...
qml/scenes/GameInfoScene.qml
View file @
7a41473b
...
...
@@ -9,6 +9,18 @@ Rectangle {
property
string
icon
:
""
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
x
:
0
y
:
0
...
...
@@ -65,6 +77,7 @@ Rectangle {
}
Button
{
id
:
runGameButton
anchors.left
:
parent
.
left
anchors.top
:
parent
.
top
anchors.leftMargin
:
142
...
...
@@ -72,6 +85,7 @@ Rectangle {
text
:
"Run game"
onClicked
:
function
(){
if
(
window
.
scene
!==
S
.
gameInfoScene
)
return
;
if
(
core_app
===
undefined
)
return
;
core_app
.
start_game
(
container
.
exec
);
}
...
...
@@ -80,35 +94,54 @@ Rectangle {
// LOGIC
property
int
focusedItems
:
0
;
function
focusElements
(){
return
[
runGameButton
,
back
];
}
function
applyItemsFocus
(
inc
){
let
c
=
children
;
let
c
=
focusElements
();
let
i
=
focusedItems
;
focusedItems
+=
inc
;
if
(
focusedItems
>=
c
.
length
)
focusedItems
=
0
;
i
+=
inc
;
if
(
i
>=
c
.
length
)
i
=
0
;
if
(
focusedItems
<
0
)
focusedItems
=
c
.
length
-
1
;
if
(
i
<
0
)
i
=
c
.
length
-
1
;
c
[
focusedItems
].
forceActiveFocus
(
);
setItemsFocus
(
i
);
// c[focusedItems].clicked();
}
function
setItemsFocus
(
i
){
let
c
=
focusElements
();
focusedItems
=
i
;
c
[
i
].
forceActiveFocus
();
}
Connections
{
target
:
core_app
function
onGamepadAxisLeft
(
done
){
if
(
!
visibl
e
)
return
;
if
(
window
.
scene
!==
S
.
gameInfoScen
e
)
return
;
container
.
applyItemsFocus
(
-
1
)
}
function
onGamepadAxisRight
(
done
){
if
(
!
visibl
e
)
return
;
if
(
window
.
scene
!==
S
.
gameInfoScen
e
)
return
;
container
.
applyItemsFocus
(
1
)
}
function
onGamepadClickedApply
(
done
){
if
(
!
visibl
e
)
return
;
let
c
=
container
.
children
;
if
(
window
.
scene
!==
S
.
gameInfoScen
e
)
return
;
let
c
=
focusElements
()
;
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 {
width
:
640
height
:
480
onVisibleChanged
:
{
tabs
.
visible
=
container
.
visible
}
onVisibleChanged
:
{
tabs
.
visible
=
container
.
visible
;
}
// 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