Commit 7a41473b authored by Georgiy Yankovskiy's avatar Georgiy Yankovskiy

Merge conflicts solved

parents 57718f8b eb599f83
...@@ -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,
......
...@@ -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}")
......
...@@ -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" : "#00000000") color: control.down ? "#aaaaaa" : (control.activeFocus ? "#aaaaaa" : "#000000")
// border.width: 0 border.width: 0
// radius: 16 radius: 16
// } }
} }
...@@ -5,26 +5,38 @@ import "../delegates" ...@@ -5,26 +5,38 @@ import "../delegates"
import "../constants/tabs.js" as TabConstants import "../constants/tabs.js" as TabConstants
import "../constants/style.js" as Style import "../constants/style.js" as Style
import "../components" as TopMenuBut import "../components" as TopMenuBut
import "../constants/scene.js" as S
// TODO: code refactor
Rectangle { Rectangle {
property string currentTab: TabConstants.gamesTab property string currentTab: TabConstants.gamesTab
property var activeButtonTab: buttonGames property var activeButtonTab: buttonGames
id: tabs id: tabs
x: 100 x: 100
y: 0 y: 0
width: 640 width: 640
height: 480 height: 480
color: Style.backgroundColor 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!");} Component.onCompleted: {
onWidthChanged: function(){tabButtons.changeButtonActiveTab(tabs.activeButtonTab);tabButtons.x = tabButtons.tempX;} tabButtons.changeButtonActiveTab(tabs.activeButtonTab);
onHeightChanged: function(){tabButtons.changeButtonActiveTab(tabs.activeButtonTab);tabButtons.x = tabButtons.tempX;} 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 { Image {
id: bg id: bg
...@@ -44,51 +56,73 @@ Rectangle { ...@@ -44,51 +56,73 @@ Rectangle {
//anchors.leftMargin: parent.width / 10 //anchors.leftMargin: parent.width / 10
//anchors.rightMargin: 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.bottomMargin: buttonSystemManagement.height / 2
Layout.topMargin: buttonSystemManagement.height / 3 Layout.topMargin: buttonSystemManagement.height / 3
x:100 x:100
// Состояния // Состояния
states: [ states: [
State {name: "ClickTabButton";when:tabButtons.toggle;PropertyChanges {target: tabButtons;x:tempX}}, State {
State {name: "";when:1 == 1} name: "ClickTabButton";
when: tabButtons.toggle;
PropertyChanges {
target: tabButtons;
x:tempX
}
},
State {
name: "";
when: 1 == 1
}
] ]
// Анимации при изменениях состояний // Анимации при изменениях состояний
transitions: transitions:
Transition { Transition {
from: ""; to: "ClickTabButton" from: "";
PropertyAnimation{ to: "ClickTabButton";
id:clickTabButtonAnimation PropertyAnimation {
//from: tempX id: clickTabButtonAnimation
// from: tempX
duration: 200 duration: 200
property:"x" property: "x"
//анимациюю можно будет поменять в любое время // анимацию можно будет поменять в любое время
easing.type: Easing.InOutCirc easing.type: Easing.InOutCirc
} }
} }
// Функция перемещения кнопок // Функция перемещения кнопок
// TODO: OPTIMIZE (REDUCE EXTRA FOR LOOP)
function changeButtonActiveTab(ButtonId){ function changeButtonActiveTab(ButtonId){
let index = 0 let index = 0;
let left_distance = 0 let left_distance = 0;
for(var i = 0; i < tabButtons.children.length; ++i) let i = 0;
if(children[i]===ButtonId){
for(i = 0; i < tabButtons.children.length; ++i) {
if (children[i] === ButtonId) {
index = i index = i
break break
} }
for(i = 0; i < index; ++i) }
left_distance += spacing + children[i].width
tempX = topNavigation.width / 2 - tabButtons.children[index].width / 2 - left_distance for(i = 0; i < index; ++i) {
tabs.activeButtonTab.isActive = false left_distance += spacing + children[i].width;
tabs.activeButtonTab = ButtonId }
tabs.activeButtonTab.isActive = true
tempX = topNavigation.width / 2 - tabButtons.children[index].width / 2 - left_distance;
tabs.activeButtonTab.isActive = false;
tabs.activeButtonTab = ButtonId;
tabs.activeButtonTab.isActive = true;
} }
TopMenuBut.TextButton { TopMenuBut.TextButton {
id: buttonSystemManagement id: buttonSystemManagement;
text: TabConstants.systemManagementTab text: TabConstants.systemManagementTab;
width: 400 width: 400;
onClicked: function(){ onClicked: function(){
tabButtons.x = tabButtons.tempX tabButtons.x = tabButtons.tempX
tabButtons.changeButtonActiveTab(this) tabButtons.changeButtonActiveTab(this)
...@@ -191,10 +225,18 @@ Rectangle { ...@@ -191,10 +225,18 @@ Rectangle {
scrolV.fromAnim = scrolV.position scrolV.fromAnim = scrolV.position
scrolV.position = (1.0 - scrolV.size) * y/gamesScroller.height scrolV.position = (1.0 - scrolV.size) * y/gamesScroller.height
scrolV.toAnim = (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 { GridLayout {
id: gamesGrid id: gamesGrid
...@@ -209,7 +251,7 @@ Rectangle { ...@@ -209,7 +251,7 @@ Rectangle {
anchors.leftMargin: rowSpacing * 2 anchors.leftMargin: rowSpacing * 2
anchors.bottomMargin : 90 anchors.bottomMargin : 90
anchors.topMargin: Math.floor( gamesScroller.width / 100 * 1.5) 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 columnSpacing: rowSpacing
// Повторитель // Повторитель
...@@ -220,9 +262,16 @@ Rectangle { ...@@ -220,9 +262,16 @@ Rectangle {
gameTitle: model.name gameTitle: model.name
gameExec: model.exec gameExec: model.exec
gameIcon: model.icon gameIcon: model.icon
Layout.bottomMargin : (index - index % gamesGrid.columns)/ gamesGrid.columns === gamesGrid.rows-1 ? gamesGrid.rowSpacing*2 : 0 Layout.bottomMargin :
onFocusChanged: if(focus) { gamesScroller.scrollToY(y); } (index - index % gamesGrid.columns) /
Layout.preferredWidth: (gamesScroller.width - (gamesGrid.columns -1) * gamesGrid.rowSpacing - gamesGrid.anchors.rightMargin- gamesGrid.anchors.leftMargin) / 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 Layout.preferredHeight: Layout.preferredWidth / 2 * 3
} }
} }
...@@ -234,14 +283,22 @@ Rectangle { ...@@ -234,14 +283,22 @@ Rectangle {
// LOGIC // LOGIC
property int focusedTabs: 0;
property int focusedItems: 0; property int focusedItems: 0;
property int focusedTabs: 0;
function getTabs(){
return [
buttonSystemManagement,
buttonGames,
testbut1,
testbut2
];
}
function applyTabsFocus(inc){ function applyTabsFocus(inc){
if(!visible) if(window.scene !== S.homeScene) return;
return;
let c = row.children; let c = tabs.getTabs();
tabs.focusedTabs += inc; tabs.focusedTabs += inc;
if(tabs.focusedTabs >= c.length) if(tabs.focusedTabs >= c.length)
...@@ -250,19 +307,14 @@ Rectangle { ...@@ -250,19 +307,14 @@ Rectangle {
if(tabs.focusedTabs < 0) if(tabs.focusedTabs < 0)
tabs.focusedTabs = c.length - 1; tabs.focusedTabs = c.length - 1;
c[tabs.focusedTabs].forceActiveFocus(); let item = c[tabs.focusedTabs];
c[tabs.focusedTabs].clicked(); item.released();
item.clicked();
/* if (c[i].focus) { // tabButtons.changeButtonActiveTab(item);
console.log("focus found");
c[i].nextItemInFocusChain().forceActiveFocus()
break
} */
} }
function applyItemsFocus(inc){ function applyItemsFocus(inc){
if(!gamesScroller.visible) if(window.scene !== S.homeScene) return;
return;
let c = gamesGrid.children; let c = gamesGrid.children;
...@@ -281,25 +333,25 @@ Rectangle { ...@@ -281,25 +333,25 @@ Rectangle {
Connections { Connections {
target: core_app target: core_app
function onGamepadClickedLB(done){ function onGamepadClickedLB(done){
if(!visible) return; if(window.scene !== S.homeScene) return;
tabs.applyTabsFocus(-1) tabs.applyTabsFocus(-1)
} }
function onGamepadClickedRB(done){ function onGamepadClickedRB(done){
if(!visible) return; if(window.scene !== S.homeScene) return;
tabs.applyTabsFocus(1) tabs.applyTabsFocus(1)
} }
function onGamepadAxisLeft(done){ function onGamepadAxisLeft(done){
if(!visible) return; if(window.scene !== S.homeScene) return;
tabs.applyItemsFocus(-1) tabs.applyItemsFocus(-1)
} }
function onGamepadAxisRight(done){ function onGamepadAxisRight(done){
if(!visible) return; if(window.scene !== S.homeScene) return;
tabs.applyItemsFocus(1) tabs.applyItemsFocus(1)
} }
function onGamepadClickedApply(done){ function onGamepadClickedApply(done){
if(!visible) return; if(window.scene !== S.homeScene) return;
let c = gamesGrid.children; let c = gamesGrid.children;
c[tabs.focusedItems].clicked(); c[tabs.focusedItems].press();
} }
} }
......
...@@ -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
} }
...@@ -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;
}
} }
] ]
...@@ -62,12 +70,16 @@ C.Button { ...@@ -62,12 +70,16 @@ C.Button {
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
}
} }
}, },
...@@ -80,7 +92,11 @@ C.Button { ...@@ -80,7 +92,11 @@ C.Button {
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
}
} }
} }
] ]
......
...@@ -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.press();
}
}
function press(){
if(!visible) return;
gameInfoScene.title = game.gameTitle; gameInfoScene.title = game.gameTitle;
gameInfoScene.icon = game.gameIcon; gameInfoScene.icon = game.gameIcon;
gameInfoScene.exec = game.gameExec; 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;
property: "border.width"
duration: 100 duration: 100
to: Math.max(game.width / 100 * 4,4) // пока x не будет равно 250 to: Math.max(game.width / 100 * 4,4) // пока x не будет равно 250
easing.type: Easing.InOutQuad 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";
}
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 { Text {
......
...@@ -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
......
...@@ -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(!visible) return; if(window.scene !== S.gameInfoScene) return;
container.applyItemsFocus(-1) container.applyItemsFocus(-1)
} }
function onGamepadAxisRight(done){ function onGamepadAxisRight(done){
if(!visible) return; if(window.scene !== S.gameInfoScene) return;
container.applyItemsFocus(1) container.applyItemsFocus(1)
} }
function onGamepadClickedApply(done){ function onGamepadClickedApply(done){
if(!visible) return; if(window.scene !== S.gameInfoScene) 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();
}
} }
} }
...@@ -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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment