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