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
......
......@@ -25,15 +25,15 @@ Rectangle {
property double imgHight: 0
function startAnimation(){
startPos.x = startX
startPos.y = startY
gameRect.anchors.left = startPos.left
gameRect.anchors.top = startPos.top
runGameButton.focus = true
root.state = "completed"
startPos.x = startX
startPos.y = startY
gameRect.anchors.left = startPos.left
gameRect.anchors.top = startPos.top
runGameButton.focus = true
root.state = "completed"
}
states:[
states: [
State {
name: "finish"
AnchorChanges {
......@@ -46,7 +46,6 @@ Rectangle {
width: imgWight
height: imgHight
}
},
State {
name: "completed"
......@@ -60,14 +59,14 @@ Rectangle {
width: finishPos.width
height: finishPos.height
}
}
]
transitions: Transition {
AnchorAnimation { duration: 300 }
}
}
]
transitions: Transition {
AnchorAnimation {
duration: 300
}
}
onVisibleChanged: function(){
// if(visible){
......@@ -86,11 +85,9 @@ Rectangle {
// anchors.fill:parent
anchors.left: parent.left
anchors.top: parent.top
anchors.fill:parent
anchors.fill: parent
id: content
anchors.leftMargin: parent.width / 100 * 3
anchors.rightMargin: parent.width / 100 * 3
anchors.topMargin: parent.height / 100 * 3
......@@ -98,18 +95,17 @@ Rectangle {
spacing: 6
ItemGroup{
id: topPanel
Button {
id: back
background.opacity: 0.0
opacity: 0.8
text:"Back"
text: "Back"
width: text.contentWidth + backImg.width + 5
hoverEnabled: true
contentItem: Text {
id: text
text: back.text
font.pixelSize:Math.max(19,root.height / 100 * 3.2)
font.pixelSize: Math.max(19, root.height / 100 * 3.2)
font.family: globalFont.font
font.weight: 500
......@@ -135,7 +131,8 @@ Rectangle {
states: [
// Карточка в фокуске
State {
name: "focus"; when: back.activeFocus
name: "focus";
when: back.activeFocus
PropertyChanges {
target: back;
opacity: 1;
......@@ -147,7 +144,8 @@ Rectangle {
},
// На карточку навели курсор мыши
State {
name: "hover"; when: back.hovered
name: "hover";
when: back.hovered
PropertyChanges {
target: back;
opacity: 1;
......@@ -159,7 +157,7 @@ Rectangle {
//to: "focus"
reversible: true
NumberAnimation {
//target: back;
// target: back;
property: "opacity";
duration: 100
}
......@@ -186,16 +184,16 @@ Rectangle {
anchors.top: gameRect.parent.top
anchors.leftMargin: root.width / 100 * 3
anchors.topMargin: root.width / 100 * 3
width: height /3 * 2 //root.width / 100 * 20
width: height / 3 * 2 //root.width / 100 * 20
height: root.height / 2 //width / 2 * 3
color:"#00000000"
color: "#00000000"
}
Rectangle{
id:gameRect
Rectangle {
id: gameRect
width: imgWight
height: imgHight
color:"#000000"
color: "#000000"
Image {
id: gameImage
anchors.fill: parent
......@@ -219,36 +217,28 @@ Rectangle {
}
}
RowLayout{
id:info
RowLayout {
id: info
width: parent.width - finishPos.width - root.width / 100 * 6
anchors.left: finishPos.right
anchors.top: finishPos.top
anchors.leftMargin: root.width / 100 * 3
ColumnLayout{
ColumnLayout {
Layout.alignment: Qt.AlignLeft | Qt.AlignTop
Layout.fillWidth: true
Layout.fillHeight: true
spacing: 40
Text {
id: title
Layout.maximumWidth: root.width / 100 * 30
font.weight: 600
wrapMode: Text.Wrap
text: root.title
font.pixelSize:Math.max(19,root.height / 100 * 4.2)
font.pixelSize: Math.max(19, root.height / 100 * 4.2)
color: "white"
}
Button {
id: runGameButton
focus: true
......@@ -256,17 +246,17 @@ Rectangle {
//background.opacity: 0.2
leftPadding: textGame.font.pixelSize * 3
rightPadding: leftPadding
topPadding: leftPadding/ 8
bottomPadding: leftPadding/8
topPadding: leftPadding / 8
bottomPadding: leftPadding / 8
//opacity: 0.8
text:"Play"
text: "Play"
width: textGame.contentWidth + 5
hoverEnabled: true
contentItem: Text {
id: textGame
text: runGameButton.text
font.pixelSize:Math.max(19,root.height / 100 * 3)
font.pixelSize: Math.max(19, root.height / 100 * 3)
font.family: globalFont.font
font.weight: 800
......@@ -275,16 +265,13 @@ Rectangle {
verticalAlignment: Text.AlignVCenter
horizontalAlignment: Text.AlignHCenter
}
padding:10
padding: 10
background: Rectangle {
id:runGameBg
id: runGameBg
color: "white" //control.down ? "#aaaaaa" : (control.activeFocus ? "#aaaaaa" : "#000000")
opacity: 0.1
radius: runGameButton.width * 0.3
}
onClicked: function(){
......@@ -296,7 +283,8 @@ Rectangle {
states: [
// Карточка в фокуске
State {
name: "focus"; when: runGameButton.activeFocus
name: "focus";
when: runGameButton.activeFocus
PropertyChanges {
target: runGameBg;
opacity: 1;
......@@ -304,19 +292,20 @@ Rectangle {
PropertyChanges {
target: textGame;
font.weight: 800;
color:"black"
color: "black"
}
},
// На карточку навели курсор мыши
State {
name: "hover"; when: runGameButton.hovered
name: "hover";
when: runGameButton.hovered
PropertyChanges {
target: runGameBg;
opacity: 1;
}
PropertyChanges {
target: textGame;
color:"black"
color: "black"
}
}
]
......@@ -327,27 +316,32 @@ Rectangle {
property: "opacity";
duration: 300
}
}
}
}
Text {
horizontalAlignment: Text.AlignJustif
Layout.alignment:Qt.AlignRight| Qt.AlignTop
Layout.alignment: Qt.AlignRight | Qt.AlignTop
id: title2
Layout.maximumWidth: root.width / 100 * 30
Layout.maximumHeight: root.height / 100 * 70
elide: Text.ElideRight
wrapMode: Text.Wrap
text: "SD ferwf f wqefewf wekj fn wfaksljf dskvjblds vdfkjvb dvlkdfsj vd vjdfk vkldfjv dfkl vd vfkjlbdf kdfljb fkdjn kdjf vd kdfjv vdfkvjdv dfvjkf vdfv SD ferwf f wqefewf wekj fn wfaksljf dskvjblds vdfkjvb dvlkdfsj vd vjdfk vkldfjv dfkl vd vfkjlbdf kdfljb fkdjn kdjf vd kdfjv vdfkvjdv dfvjkf vdfv SD ferwf f wqefewf wekj fn wfaksljf dskvjblds vdfkjvb dvlkdfsj vd vjdfk vkldfjv dfkl vd vfkjlbdf kdfljb fkdjn kdjf vd kdfjv vdfkvjdv dfvjkf vdfv SD ferwf f wqefewf wekj fn wfaksljf dskvjblds vdfkjvb dvlkdfsj vd vjdfk vkldfjv dfkl vd vfkjlbdf kdfljb fkdjn kdjf vd kdfjv vdfkvjdv dfvjkf vdfvSD ferwf f wqefewf wekj fn wfaksljf dskvjblds vdfkjvb dvlkdfsj vd vjdfk vkldfjv dfkl vd vfkjlbdf kdfljb fkdjn kdjf vd kdfjv vdfkvjdv dfvjkf vdfv SD ferwf f wqefewf wekj fn wfaksljf dskvjblds vdfkjvb dvlkdfsj vd vjdfk vkldfjv dfkl vd vfkjlbdf kdfljb fkdjn kdjf vd kdfjv vdfkvjdv dfvjkf vdfvSD ferwf f wqefewf wekj fn wfaksljf dskvjblds vdfkjvb dvlkdfsj vd vjdfk vkldfjv dfkl vd vfkjlbdf kdfljb fkdjn kdjf vd kdfjv vdfkvjdv dfvjkf vdfv SD ferwf f wqefewf wekj fn wfaksljf dskvjblds vdfkjvb dvlkdfsj vd vjdfk vkldfjv dfkl vd vfkjlbdf kdfljb fkdjn kdjf vd kdfjv vdfkvjdv dfvjkf vdfv "
font.pixelSize:Math.max(13,root.height / 100 * 2.2)
text:
"Lorem ipsum dolor sit amet, consectetur adipiscing elit. " +
"Sed a ligula dolor. Cras eu sapien felis. Praesent placerat " +
"interdum mi at commodo. Nulla leo lacus, semper sed neque a, " +
"viverra convallis enim. Maecenas eget ligula eu augue posuere " +
"tincidunt sit amet et orci. In hac habitasse platea dictumst. " +
"Donec rutrum pharetra scelerisque. Sed quam mi, accumsan eget " +
"bibendum non, varius a nisi. Vivamus commodo turpis vitae " +
"vulputate tempus. Pellentesque efficitur risus nibh, sit amet " +
"interdum ante pulvinar sit amet. Ut hendrerit diam eu felis " +
"ornare, a sollicitudin lacus auctor. In hac habitasse platea dictumst. " +
"Vivamus sodales, purus at fermentum mattis, nulla libero porttitor " +
"orci, vitae scelerisque quam elit sit amet eros."
font.pixelSize: Math.max(13, root.height / 100 * 2.2)
color: "white"
}
......@@ -357,22 +351,6 @@ Rectangle {
}
// LOGIC
property int focusedItems: 0;
......@@ -405,25 +383,23 @@ Rectangle {
c[i].forceActiveFocus();
}
Connections {
target: core_app
function onGamepadAxisLeft(done){
if(window.scene !== S.gameInfoScene) return;
root.applyItemsFocus(-1)
}
function onGamepadAxisRight(done){
if(window.scene !== S.gameInfoScene) return;
root.applyItemsFocus(1)
}
function onGamepadClickedApply(done){
if(window.scene !== S.gameInfoScene) return;
let c = focusElements();
c[root.focusedItems].clicked();
}
function onGamepadClickedBack(done){
if(window.scene !== S.gameInfoScene) return;
back.clicked();
}
function onGamepadAxisLeft(done){
if(window.scene !== S.gameInfoScene) return;
root.applyItemsFocus(-1)
}
function onGamepadAxisRight(done){
if(window.scene !== S.gameInfoScene) return;
root.applyItemsFocus(1)
}
function onGamepadClickedApply(done){
if(window.scene !== S.gameInfoScene) return;
let c = focusElements();
c[root.focusedItems].clicked();
}
function onGamepadClickedBack(done){
if(window.scene !== S.gameInfoScene) return;
back.clicked();
}
......
......@@ -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