Commit e968fb03 authored by Georgiy Yankovskiy's avatar Georgiy Yankovskiy

Gamepad double click A/B fixes

parent 7456e9a5
...@@ -83,7 +83,7 @@ class App(QtCore.QObject): ...@@ -83,7 +83,7 @@ class App(QtCore.QObject):
# TODO parse product name # TODO parse product name
_icon = (os.path.isfile(_icon) and _icon _icon = (os.path.isfile(_icon) and _icon
or os.path.realpath(f"{Path(__file__).resolve().parent}../../../qml/images/PUBG.png")) or os.path.realpath(f"{Path(__file__).resolve().parent}../../../qml/images/PUBG.png"))
# Автозапуск игры: # Автозапуск игры:
# PW_GUI_DISABLED_CS=1 # PW_GUI_DISABLED_CS=1
...@@ -118,6 +118,7 @@ class App(QtCore.QObject): ...@@ -118,6 +118,7 @@ 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,
......
...@@ -21,13 +21,13 @@ Rectangle { ...@@ -21,13 +21,13 @@ Rectangle {
onVisibleChanged: { onVisibleChanged: {
tabButtons.changeButtonActiveTab(tabs.activeButtonTab); tabButtons.changeButtonActiveTab(tabs.activeButtonTab);
tabButtons.x = tabButtons.tempX; tabButtons.x = tabButtons.tempX;
console.log("tabButtons.x = " + tabButtons.x); // console.log("tabButtons.x = " + tabButtons.x);
} }
Component.onCompleted: { Component.onCompleted: {
tabButtons.changeButtonActiveTab(tabs.activeButtonTab); tabButtons.changeButtonActiveTab(tabs.activeButtonTab);
tabButtons.x = tabButtons.tempX; tabButtons.x = tabButtons.tempX;
console.log("Tabs completed!"); // console.log("Tabs completed!");
} }
onWidthChanged: function(){ onWidthChanged: function(){
tabButtons.changeButtonActiveTab(tabs.activeButtonTab); tabButtons.changeButtonActiveTab(tabs.activeButtonTab);
...@@ -39,13 +39,14 @@ Rectangle { ...@@ -39,13 +39,14 @@ Rectangle {
} }
// Кнопки навигации // Кнопки навигации
ColumnLayout{ ColumnLayout {
id:topNavigation id: topNavigation
width: parent.width width: parent.width
Rectangle{
Rectangle {
width: parent.width width: parent.width
height: buttonSystemManagement.height height: buttonSystemManagement.height
color:"#00000000" color: "#00000000"
Layout.bottomMargin: buttonSystemManagement.height / 2 Layout.bottomMargin: buttonSystemManagement.height / 2
Layout.topMargin: buttonSystemManagement.height / 3 Layout.topMargin: buttonSystemManagement.height / 3
...@@ -70,11 +71,11 @@ Rectangle { ...@@ -70,11 +71,11 @@ Rectangle {
Component.onCompleted: { Component.onCompleted: {
tabButtons.changeButtonActiveTab(tabs.activeButtonTab); tabButtons.changeButtonActiveTab(tabs.activeButtonTab);
tabButtons.x = tabButtons.tempX; tabButtons.x = tabButtons.tempX;
console.log("tabButtons completed!"); // console.log("tabButtons completed!");
} }
x: 0
x:0
// Состояния // Состояния
states: [ states: [
State { State {
...@@ -82,7 +83,7 @@ Rectangle { ...@@ -82,7 +83,7 @@ Rectangle {
when: tabButtons.toggle; when: tabButtons.toggle;
PropertyChanges { PropertyChanges {
target: tabButtons; target: tabButtons;
x:tempX x: tempX
} }
}, },
State { State {
...@@ -104,6 +105,7 @@ Rectangle { ...@@ -104,6 +105,7 @@ Rectangle {
easing.type: Easing.InOutCirc easing.type: Easing.InOutCirc
} }
} }
// Функция перемещения кнопок // Функция перемещения кнопок
// TODO: OPTIMIZE (REDUCE EXTRA FOR LOOP) // TODO: OPTIMIZE (REDUCE EXTRA FOR LOOP)
function changeButtonActiveTab(ButtonId){ function changeButtonActiveTab(ButtonId){
...@@ -213,11 +215,31 @@ Rectangle { ...@@ -213,11 +215,31 @@ Rectangle {
anchors.leftMargin: 0 anchors.leftMargin: 0
anchors.bottomMargin: 90 anchors.bottomMargin: 90
Rectangle { color: "red"; width: 50; height: 50 } Rectangle {
Rectangle { color: "green"; width: 20; height: 50 } color: "red";
Rectangle { color: "blue"; width: 50; height: 20 } width: 50;
Rectangle { color: "cyan"; width: 50; height: 50 } height: 50;
Rectangle { color: "magenta"; width: 10; height: 10 } }
Rectangle {
color: "green";
width: 20;
height: 50;
}
Rectangle {
color: "blue";
width: 50;
height: 20;
}
Rectangle {
color: "cyan";
width: 50;
height: 50;
}
Rectangle {
color: "magenta";
width: 10;
height: 10;
}
} }
// Сетка игр // Сетка игр
...@@ -229,8 +251,8 @@ Rectangle { ...@@ -229,8 +251,8 @@ Rectangle {
ScrollBar.vertical: ScrollBar { ScrollBar.vertical: ScrollBar {
id: scrolV; id: scrolV;
height: parent.height height: parent.height
opacity:0 opacity: 0
position:0 position: 0
property double fromAnim: 0.0 property double fromAnim: 0.0
property double toAnim: 0.0 property double toAnim: 0.0
...@@ -238,8 +260,8 @@ Rectangle { ...@@ -238,8 +260,8 @@ Rectangle {
function scrollToY(y,HItem) { function scrollToY(y,HItem) {
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) if(scrolV.toAnim != scrolV.fromAnim)
scrollAnimation.start() scrollAnimation.start()
} }
...@@ -290,13 +312,8 @@ Rectangle { ...@@ -290,13 +312,8 @@ Rectangle {
/ gamesGrid.columns / gamesGrid.columns
Layout.preferredHeight: Layout.preferredWidth / 2 * 3 Layout.preferredHeight: Layout.preferredWidth / 2 * 3
// Component.onCompleted: {a3.start()} // Component.onCompleted: {a3.start()}
// SequentialAnimation { // SequentialAnimation {
// id:a3 // id:a3
...@@ -317,11 +334,7 @@ Rectangle { ...@@ -317,11 +334,7 @@ Rectangle {
// loops: Animation.Infinite // loops: Animation.Infinite
// } // }
// Layout.topMargin: Layout.preferredHeight
//Layout.topMargin: Layout.preferredHeight
} }
} }
...@@ -340,7 +353,7 @@ Rectangle { ...@@ -340,7 +353,7 @@ Rectangle {
return [ return [
buttonSystemManagement, buttonSystemManagement,
buttonGames, buttonGames,
testbut1, // testbut1,
testbut2 testbut2
]; ];
} }
...@@ -380,29 +393,27 @@ Rectangle { ...@@ -380,29 +393,27 @@ Rectangle {
// c[tabs.focusedItems].clicked(); // c[tabs.focusedItems].clicked();
} }
Connections { function onGamepadClickedLB(done){
target: core_app if(window.scene !== S.homeScene) return;
function onGamepadClickedLB(done){ tabs.applyTabsFocus(-1)
if(window.scene !== S.homeScene) return; }
tabs.applyTabsFocus(-1) function onGamepadClickedRB(done){
} if(window.scene !== S.homeScene) return;
function onGamepadClickedRB(done){ tabs.applyTabsFocus(1)
if(window.scene !== S.homeScene) return; }
tabs.applyTabsFocus(1) function onGamepadAxisLeft(done){
} if(window.scene !== S.homeScene) return;
function onGamepadAxisLeft(done){ tabs.applyItemsFocus(-1)
if(window.scene !== S.homeScene) return; }
tabs.applyItemsFocus(-1) function onGamepadAxisRight(done){
} if(window.scene !== S.homeScene) return;
function onGamepadAxisRight(done){ tabs.applyItemsFocus(1)
if(window.scene !== S.homeScene) return; }
tabs.applyItemsFocus(1) function onGamepadClickedApply(done){
} if(window.scene !== S.homeScene) return;
function onGamepadClickedApply(done){ // console.log("onGamepadClickedApply");
if(window.scene !== S.homeScene) return; let c = gamesGrid.children;
let c = gamesGrid.children; c[tabs.focusedItems].press();
c[tabs.focusedItems].press();
}
} }
} }
......
import QtQuick import QtQuick
import QtQuick.Controls as C import QtQuick.Controls as C
C.Button { C.Button {
id: root id: root
property bool isActive: false property bool isActive: false
...@@ -28,9 +26,11 @@ C.Button { ...@@ -28,9 +26,11 @@ C.Button {
color: 'white' color: 'white'
opacity: 0.8 opacity: 0.8
} }
background.opacity: 0.0 background.opacity: 0.0
background.anchors.margins: 0 background.anchors.margins: 0
Rectangle{
Rectangle {
id: line id: line
color: 'white' color: 'white'
height: 2 height: 2
...@@ -38,14 +38,14 @@ C.Button { ...@@ -38,14 +38,14 @@ C.Button {
anchors.horizontalCenter: root.horizontalCenter anchors.horizontalCenter: root.horizontalCenter
anchors.top: root.top anchors.top: root.top
// anchors.bottom:root.bottom // anchors.bottom:root.bottom
} }
// Состояния // Состояния
states: [ states: [
// Карточка в фокуске // Карточка в фокуске
State { State {
name: "active"; when: isActive name: "active";
when: isActive
PropertyChanges { PropertyChanges {
target: line; target: line;
width: parent.width; width: parent.width;
...@@ -61,7 +61,8 @@ C.Button { ...@@ -61,7 +61,8 @@ C.Button {
}, },
// На карточку навели курсор мыши // На карточку навели курсор мыши
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 { PropertyChanges {
target: text; target: text;
...@@ -78,7 +79,8 @@ C.Button { ...@@ -78,7 +79,8 @@ C.Button {
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
} }
...@@ -91,11 +93,13 @@ C.Button { ...@@ -91,11 +93,13 @@ C.Button {
}, },
Transition { Transition {
from: ""; to: "hover" from: "";
to: "hover"
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
} }
......
...@@ -19,23 +19,28 @@ C.Button { ...@@ -19,23 +19,28 @@ C.Button {
anchors.fill: parent anchors.fill: parent
hoverEnabled: true hoverEnabled: true
acceptedButtons: "AllButtons" acceptedButtons: "AllButtons"
onClicked: function(){ onClicked: function() {
if(!game.visible) return;
game.press(); game.press();
} }
} }
function press(){ function press(){
if(!visible) return; if(!game.visible) return;
if(window.scene !== SceneConstants.homeScene) return;
// console.log("GAME CLICKED " + game.gameTitle);
gameInfoScene.title = game.gameTitle; gameInfoScene.title = game.gameTitle;
gameInfoScene.icon = game.gameIcon; gameInfoScene.icon = game.gameIcon;
gameInfoScene.exec = game.gameExec; gameInfoScene.exec = game.gameExec;
var globalCoordinates = mapToItem(null,0,0)
console.log("game coord - X: " + globalCoordinates.x + " y: " + globalCoordinates.y) let globalCoordinates = mapToItem(null, 0, 0)
// console.log("game coord - X: " + globalCoordinates.x + " y: " + globalCoordinates.y)
gameInfoScene.startX = globalCoordinates.x gameInfoScene.startX = globalCoordinates.x
gameInfoScene.startY = globalCoordinates.y gameInfoScene.startY = globalCoordinates.y
gameInfoScene.imgWight = game.width*1.05 gameInfoScene.imgWight = game.width * 1.05
gameInfoScene.imgHight = game.height*1.05 gameInfoScene.imgHight = game.height * 1.05
window.scene = SceneConstants.gameInfoScene; window.scene = SceneConstants.gameInfoScene;
gameInfoScene.startAnimation() gameInfoScene.startAnimation()
...@@ -46,8 +51,8 @@ C.Button { ...@@ -46,8 +51,8 @@ C.Button {
// //
background: Rectangle { background: Rectangle {
id: rect id: rect
width:game.width + border.width *2 width: game.width + border.width * 2
height:game.height + border.width*2 height: game.height + border.width * 2
opacity: 1.0 opacity: 1.0
color: "#000000" color: "#000000"
...@@ -61,16 +66,33 @@ C.Button { ...@@ -61,16 +66,33 @@ C.Button {
states: [ states: [
// Карточка в фокуске // Карточка в фокуске
State { State {
name: "focus"; when: game.activeFocus name: "focus";
PropertyChanges { target: rect; border.width: Math.max(game.width / 100 * 2 ,2);} when: game.activeFocus
PropertyChanges { target: game; scale:1.05 } PropertyChanges {
PropertyChanges { target: bgNameGrad; opacity:1 } target: rect;
border.width: Math.max(game.width / 100 * 2, 2);
}
PropertyChanges {
target: game;
scale: 1.05;
}
PropertyChanges {
target: bgNameGrad;
opacity: 1;
}
}, },
// На карточку навели курсор мыши // На карточку навели курсор мыши
State { State {
name: "hover"; when: hoverArea.containsMouse name: "hover";
PropertyChanges { target: game; scale:1.05 } when: hoverArea.containsMouse
PropertyChanges { target: bgNameGrad; opacity:1 } PropertyChanges {
target: game;
scale: 1.05;
}
PropertyChanges {
target: bgNameGrad;
opacity: 1;
}
} }
] ]
...@@ -81,12 +103,12 @@ C.Button { ...@@ -81,12 +103,12 @@ C.Button {
from: ""; from: "";
to: "focus"; to: "focus";
reversible: false; reversible: false;
SequentialAnimation { SequentialAnimation {
NumberAnimation{ NumberAnimation {
target: rect; target: rect;
property: "border.width" 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 { NumberAnimation {
...@@ -183,7 +205,7 @@ C.Button { ...@@ -183,7 +205,7 @@ C.Button {
Rectangle { Rectangle {
id: rectangleMask id: rectangleMask
anchors.fill: parent anchors.fill: parent
radius: 1.5*height radius: 1.5 * height
visible: false visible: false
} }
} }
...@@ -8,42 +8,60 @@ import "constants/scene.js" as SceneConstants ...@@ -8,42 +8,60 @@ import "constants/scene.js" as SceneConstants
Window { Window {
property string scene: SceneConstants.homeScene property string scene: SceneConstants.homeScene
Loader{ Loader {
id : ld id: ld
anchors.fill: parent; anchors.fill: parent;
}
FontLoader {
id: globalFont;
source: "./fonts/OpenSans-VariableFont_wdth.ttf"
} }
FontLoader { id: globalFont; source: "./fonts/OpenSans-VariableFont_wdth.ttf" }
Connections { Connections {
target: core_app target: core_app
function onGameStarted(done) { function onGameStarted(done) {
console.log("core_app: gameStarted"); // console.log("core_app: gameStarted");
window.scene = SceneConstants.runningScene; window.scene = SceneConstants.runningScene;
} }
function onGameEnded(done) { function onGameEnded(done) {
console.log("core_app: gameEnded"); // console.log("core_app: gameEnded");
window.scene = SceneConstants.gameInfoScene; window.scene = SceneConstants.gameInfoScene;
} }
function onGamepadClickedLB(done){ function onGamepadClickedLB(done){
// console.log("core_app: onGamepadClickedLB"); window._trigger("onGamepadClickedLB", done);
} }
function onGamepadClickedRB(done){ function onGamepadClickedRB(done){
// console.log("core_app: onGamepadClickedRB"); window._trigger("onGamepadClickedRB", done);
} }
function onGamepadAxisLeft(done){ function onGamepadAxisLeft(done){
// console.log("core_app: onGamepadAxisLeft"); window._trigger("onGamepadAxisLeft", done);
} }
function onGamepadAxisRight(done){ function onGamepadAxisRight(done){
// console.log("core_app: onGamepadAxisRight"); window._trigger("onGamepadAxisRight", done);
} }
function onGamepadClickedApply(done){ function onGamepadClickedApply(done){
// console.log("core_app: onGamepadClickedApply"); window._trigger("onGamepadClickedApply", done);
}
function onGamepadClickedBack(done){
window._trigger("onGamepadClickedBack", done);
} }
} }
function _trigger(_method, ...args){
let scenes = {};
scenes[SceneConstants.homeScene] = homeScene;
scenes[SceneConstants.gameInfoScene] = gameInfoScene;
scenes[SceneConstants.runningScene] = runningScene;
let d = scenes[scene];
if(d !== null && d[_method] !== undefined && d[_method] !== null)
d[_method](args);
}
Component.onDestruction: { Component.onDestruction: {
console.log("Desctructing window"); // console.log("Desctructing window");
} }
id: window id: window
......
...@@ -41,4 +41,21 @@ Rectangle { ...@@ -41,4 +41,21 @@ Rectangle {
anchors.leftMargin: 0 anchors.leftMargin: 0
anchors.rightMargin: 0 anchors.rightMargin: 0
} }
function onGamepadClickedLB(done){
tabs.onGamepadClickedLB(done)
}
function onGamepadClickedRB(done){
tabs.onGamepadClickedRB(done)
}
function onGamepadAxisLeft(done){
tabs.onGamepadAxisLeft(done)
}
function onGamepadAxisRight(done){
tabs.onGamepadAxisRight(done)
}
function onGamepadClickedApply(done){
tabs.onGamepadClickedApply(done)
}
} }
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