samegame demo: fix qmllint warnings

Fix the qmllint unqualified warnings and custom parsed
property changes.

Pick-to: 6.8
Task-number: QTBUG-100100
Change-Id: I3a8e310738d1521bae4e233c5610af833fcb697f
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
This commit is contained in:
Sami Shalayel 2024-09-02 16:11:53 +02:00
parent 0c02d0545a
commit a841c45fee
12 changed files with 92 additions and 82 deletions

View File

@ -53,7 +53,7 @@ Rectangle {
system: gameCanvas.ps
}
onPuzzleLost: acc--;//So that nextPuzzle() reloads the current one
onPuzzleLost: root.acc--;//So that nextPuzzle() reloads the current one
}
@ -172,7 +172,7 @@ Rectangle {
interval: Settings.menuDelay
running : false
repeat : false
onTriggered: loadPuzzle();
onTriggered: root.loadPuzzle();
}
system: gameCanvas.ps
}
@ -290,7 +290,7 @@ Rectangle {
visible: (root.state == "in-game") && gameCanvas.mode == "puzzle" && gameCanvas.puzzleWon
opacity: gameCanvas.puzzleWon ? 1 : 0
Behavior on opacity{ NumberAnimation {} }
onClicked: {if (gameCanvas.puzzleWon) nextPuzzle();}
onClicked: {if (gameCanvas.puzzleWon) root.nextPuzzle();}
anchors { right: parent.right; verticalCenter: parent.verticalCenter; rightMargin: 11 }
}
}
@ -317,9 +317,10 @@ Rectangle {
State {
name: "in-game"
PropertyChanges {
target: menu
opacity: 0
visible: false
menu {
opacity: 0
visible: false
}
}
}
]

View File

@ -12,7 +12,7 @@ Item {
property ParticleSystem particleSystem
Behavior on x {
enabled: spawned;
enabled: block.spawned;
SpringAnimation{ spring: 2; damping: 0.2 }
}
Behavior on y {
@ -22,11 +22,11 @@ Item {
Image {
id: img
source: {
if (type == 0){
if (block.type == 0){
"gfx/red.png";
} else if (type == 1) {
} else if (block.type == 1) {
"gfx/blue.png";
} else if (type == 2) {
} else if (block.type == 2) {
"gfx/green.png";
} else {
"gfx/yellow.png";
@ -40,13 +40,13 @@ Item {
//Foreground particles
BlockEmitter {
id: particles
system: particleSystem
system: block.particleSystem
group: {
if (type == 0){
if (block.type == 0){
"red";
} else if (type == 1) {
} else if (block.type == 1) {
"blue";
} else if (type == 2) {
} else if (block.type == 2) {
"green";
} else {
"yellow";
@ -58,19 +58,19 @@ Item {
//Paint particles on the background
PaintEmitter {
id: particles2
system: particleSystem
system: block.particleSystem
}
states: [
State {
name: "AliveState"; when: spawned == true && dying == false
PropertyChanges { target: img; opacity: 1 }
name: "AliveState"; when: block.spawned == true && block.dying == false
PropertyChanges { img.opacity: 1 }
},
State {
name: "DeathState"; when: dying == true
StateChangeScript { script: {particleSystem.paused = false; particles.pulse(100); particles2.pulse(100);} }
PropertyChanges { target: img; opacity: 0 }
name: "DeathState"; when: block.dying == true
StateChangeScript { script: {block.particleSystem.paused = false; particles.pulse(100); particles2.pulse(100);} }
PropertyChanges { img.opacity: 0 }
StateChangeScript { script: block.destroy(1000); }
}
]

View File

@ -3,13 +3,21 @@
import QtQuick
import QtQuick.Particles
// Needed for singletons QTBUG-34418
import "."
Emitter {
id: emitter
property Item block: parent
velocity: TargetDirection{targetX: block.width/2; targetY: block.height/2; magnitude: -40; magnitudeVariation: 40}
acceleration: TargetDirection{targetX: block.width/2; targetY: block.height/2; magnitude: -100;}
velocity: TargetDirection {
targetX: emitter.block.width/2
targetY: emitter.block.height/2
magnitude: -40
magnitudeVariation: 40
}
acceleration: TargetDirection {
targetX: emitter.block.width/2
targetY: emitter.block.height/2
magnitude: -100
}
shape: EllipseShape{fill:true}
enabled: false;
lifeSpan: 700; lifeSpanVariation: 100

View File

@ -5,6 +5,7 @@ import QtQuick
import QtQuick.Particles
Item {
id: button
property alias imgSrc: image.source
property alias system: emitter.system
property alias group: emitter.group
@ -19,7 +20,7 @@ Item {
width: height/sourceSize.height * sourceSize.width
anchors.horizontalCenter: parent.horizontalCenter
rotation: rotatedButton ? ((Math.random() * 3 + 2) * (Math.random() <= 0.5 ? -1 : 1)) : 0
rotation: button.rotatedButton ? ((Math.random() * 3 + 2) * (Math.random() <= 0.5 ? -1 : 1)) : 0
MenuEmitter {
id: emitter
anchors.fill: parent

View File

@ -4,7 +4,6 @@
import QtQuick
import QtQuick.Particles
import "samegame.js" as Logic
import "."
Item {
id: gameCanvas
@ -50,7 +49,7 @@ Item {
id: bg
z: -1
anchors.fill: parent
source: background;
source: gameCanvas.background;
fillMode: Image.PreserveAspectCrop
}
@ -60,7 +59,7 @@ Item {
if (puzzleTextBubble.opacity == 1) {
puzzleTextBubble.opacity = 0;
Logic.finishLoadingMap();
} else if (!swapping) {
} else if (!gameCanvas.swapping) {
Logic.handleClick(mouse.x,mouse.y);
}
}
@ -68,7 +67,7 @@ Item {
Image {
id: highScoreTextBubble
opacity: mode == "arcade" && gameOver && gameCanvas.score == gameCanvas.highScore ? 1 : 0
opacity: gameCanvas.mode == "arcade" && gameCanvas.gameOver && gameCanvas.score == gameCanvas.highScore ? 1 : 0
Behavior on opacity { NumberAnimation {} }
anchors.centerIn: parent
z: 10

View File

@ -1,6 +1,8 @@
// Copyright (C) 2017 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
pragma ComponentBehavior: Bound
import QtQuick
import QtQuick.Particles
@ -30,7 +32,7 @@ Item {
id: emitter
anchors.fill: parent
group: "red"
system: particleSystem
system: container.particleSystem
Connections {
target: container
function onBoomTime() {
@ -49,19 +51,19 @@ Item {
PropertyAction { target: g1; property: "opacity"; value: 1}
PropertyAction { target: s1; property: "y"; value: 0}
PropertyAction { target: s1; property: "opacity"; value: 1}
NumberAnimation { target: g1; property: "y"; from: -96; to: -48; duration: dur}
NumberAnimation { target: g1; property: "y"; from: -96; to: -48; duration: container.dur}
ParallelAnimation {
NumberAnimation { target: g1; property: "y"; from: -48; to: 0; duration: dur}
NumberAnimation { target: s1; property: "y"; from: 0; to: 48; duration: dur }
NumberAnimation { target: g1; property: "y"; from: -48; to: 0; duration: container.dur}
NumberAnimation { target: s1; property: "y"; from: 0; to: 48; duration: container.dur }
}
PauseAnimation { duration: dur }
PauseAnimation { duration: container.dur }
ScriptAction { script: container.boomTime(); }
ParallelAnimation {
NumberAnimation { target: g1; property: "opacity"; to: 0; duration: dur }
NumberAnimation { target: s1; property: "opacity"; to: 0; duration: dur }
NumberAnimation { target: g1; property: "opacity"; to: 0; duration: container.dur }
NumberAnimation { target: s1; property: "opacity"; to: 0; duration: container.dur }
}
PropertyAction { target: s1; property: "y"; value: -128}
PropertyAction { target: s1; property: "opacity"; value: 1}
NumberAnimation { target: s1; property: "y"; from: -96; to: 0; duration: dur * 2}
NumberAnimation { target: s1; property: "y"; from: -96; to: 0; duration: container.dur * 2}
}
}

View File

@ -3,18 +3,17 @@
import QtQuick
import QtQuick.Particles
import "."
Emitter {
property Item block: parent
property int blockType: (parent as Block).type
anchors.fill: parent
shape: EllipseShape { fill: true }
group: {
if (block.type == 0){
if (blockType == 0){
"redspots";
} else if (block.type == 1) {
} else if (blockType == 1) {
"bluespots";
} else if (block.type == 2) {
} else if (blockType == 2) {
"greenspots";
} else {
"yellowspots";
@ -34,19 +33,19 @@ Emitter {
onEmitParticles: {//One group, many colors, for better stacking
for (var i=0; i<particles.length; i++) {
var particle = particles[i];
if (block.type == 0) {
if (blockType == 0) {
particle.red = mainIntensity + (Math.random() * colorVariation * 2 - colorVariation);
particle.green = subIntensity + (Math.random() * colorVariation * 2 - colorVariation);
particle.blue = subIntensity + (Math.random() * colorVariation * 2 - colorVariation);
} else if (block.type == 1) {
} else if (blockType == 1) {
particle.red = subIntensity + (Math.random() * colorVariation * 2 - colorVariation);
particle.green = subIntensity + (Math.random() * colorVariation * 2 - colorVariation);
particle.blue = mainIntensity + (Math.random() * colorVariation * 2 - colorVariation);
} else if (block.type == 2) {
} else if (blockType == 2) {
particle.red = subIntensity + (Math.random() * colorVariation * 2 - colorVariation);
particle.green = mainIntensity + (Math.random() * colorVariation * 2 - colorVariation);
particle.blue = subIntensity + (Math.random() * colorVariation * 2 - colorVariation);
} else if (block.type == 3) {
} else if (blockType == 3) {
particle.red = mainIntensity + (Math.random() * colorVariation * 2 - colorVariation);
particle.green = mainIntensity + (Math.random() * colorVariation * 2 - colorVariation);
particle.blue = subIntensity + (Math.random() * colorVariation * 2 - colorVariation);

View File

@ -16,7 +16,7 @@ Item {
ImageParticle {
groups: ["yellowspots"]
color: Qt.darker("yellow");//Actually want desaturated...
system: particleSystem
system: container.particleSystem
source: "gfx/particle-paint.png"
colorVariation: 0.2
alpha: 0.2
@ -24,7 +24,7 @@ Item {
}
ImageParticle {
groups: ["redspots"]
system: particleSystem
system: container.particleSystem
color: Qt.darker("red");//Actually want desaturated...
source: "gfx/particle-paint.png"
colorVariation: 0.2
@ -33,7 +33,7 @@ Item {
}
ImageParticle {
groups: ["greenspots"]
system: particleSystem
system: container.particleSystem
color: Qt.darker("green");//Actually want desaturated...
source: "gfx/particle-paint.png"
colorVariation: 0.2
@ -42,7 +42,7 @@ Item {
}
ImageParticle {
groups: ["bluespots"]
system: particleSystem
system: container.particleSystem
color: Qt.darker("blue");//Actually want desaturated...
source: "gfx/particle-paint.png"
colorVariation: 0.2
@ -52,7 +52,7 @@ Item {
}
ImageParticle {
groups: ["yellow"]
system: particleSystem
system: container.particleSystem
color: Qt.darker("yellow");//Actually want desaturated...
source: "gfx/particle-brick.png"
colorVariation: 0.4
@ -60,7 +60,7 @@ Item {
}
ImageParticle {
groups: ["red"]
system: particleSystem
system: container.particleSystem
color: Qt.darker("red");//Actually want desaturated...
source: "gfx/particle-brick.png"
colorVariation: 0.4
@ -68,7 +68,7 @@ Item {
}
ImageParticle {
groups: ["green"]
system: particleSystem
system: container.particleSystem
color: Qt.darker("green");//Actually want desaturated...
source: "gfx/particle-brick.png"
colorVariation: 0.4
@ -76,7 +76,7 @@ Item {
}
ImageParticle {
groups: ["blue"]
system: particleSystem
system: container.particleSystem
color: Qt.darker("blue");//Actually want desaturated...
source: "gfx/particle-brick.png"
colorVariation: 0.4

View File

@ -12,7 +12,7 @@ Item {
property ParticleSystem particleSystem
Behavior on x {
enabled: spawned;
enabled: block.spawned;
NumberAnimation{ easing.type: Easing.OutBounce }
}
Behavior on y {
@ -22,11 +22,11 @@ Item {
Image {
id: img
source: {
if (type == 0){
if (block.type == 0){
"gfx/red-puzzle.png";
} else if (type == 1) {
} else if (block.type == 1) {
"gfx/blue-puzzle.png";
} else if (type == 2) {
} else if (block.type == 2) {
"gfx/green-puzzle.png";
} else {
"gfx/yellow-puzzle.png";
@ -42,13 +42,13 @@ Item {
//Foreground particles
BlockEmitter {
id: particles
system: particleSystem
system: block.particleSystem
group: {
if (type == 0){
if (block.type == 0){
"red";
} else if (type == 1) {
} else if (block.type == 1) {
"blue";
} else if (type == 2) {
} else if (block.type == 2) {
"green";
} else {
"yellow";
@ -59,15 +59,15 @@ Item {
states: [
State {
name: "AliveState"; when: spawned == true && dying == false
PropertyChanges { target: img; opacity: 1 }
name: "AliveState"; when: block.spawned == true && block.dying == false
PropertyChanges { img.opacity: 1 }
},
State {
name: "DeathState"; when: dying == true
PropertyChanges { target: img; scale: 2 }
name: "DeathState"; when: block.dying == true
PropertyChanges { img.scale: 2 }
StateChangeScript { script: particles.pulse(200); }
PropertyChanges { target: img; opacity: 0 }
PropertyChanges { img.opacity: 0 }
StateChangeScript { script: block.destroy(1000); }
}
]

View File

@ -2,7 +2,6 @@
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
import QtQuick
import "."
Text {
font.pixelSize: Settings.fontPixelSize;

View File

@ -12,7 +12,7 @@ Item {
property ParticleSystem particleSystem
Behavior on x {
enabled: spawned;
enabled: block.spawned;
SpringAnimation{ spring: 2; damping: 0.2 }
}
Behavior on y {
@ -22,11 +22,11 @@ Item {
Image {
id: img
source: {
if (type == 0){
if (block.type == 0){
"gfx/red.png";
} else if (type == 1) {
} else if (block.type == 1) {
"gfx/blue.png";
} else if (type == 2) {
} else if (block.type == 2) {
"gfx/green.png";
} else {
"gfx/yellow.png";
@ -40,13 +40,13 @@ Item {
//Foreground particles
BlockEmitter {
id: particles
system: particleSystem
system: block.particleSystem
group: {
if (type == 0){
if (block.type == 0){
"red";
} else if (type == 1) {
} else if (block.type == 1) {
"blue";
} else if (type == 2) {
} else if (block.type == 2) {
"green";
} else {
"yellow";
@ -57,14 +57,14 @@ Item {
states: [
State {
name: "AliveState"; when: spawned == true && dying == false
PropertyChanges { target: img; opacity: 1 }
name: "AliveState"; when: block.spawned == true && block.dying == false
PropertyChanges { img.opacity: 1 }
},
State {
name: "DeathState"; when: dying == true
StateChangeScript { script: {particleSystem.paused = false; particles.pulse(100); } }
PropertyChanges { target: img; opacity: 0 }
name: "DeathState"; when: block.dying == true
StateChangeScript { script: {block.particleSystem.paused = false; particles.pulse(100); } }
PropertyChanges { img.opacity: 0 }
StateChangeScript { script: block.destroy(1000); }
}
]

View File

@ -5,6 +5,7 @@ import QtQuick
import QtQuick.Particles
Item {
id: smokeText
z: 10
property alias source: img.source
property alias system: emitter.system
@ -17,7 +18,7 @@ Item {
opacity: 0
id: img
anchors.centerIn: parent
rotation: playerNum == 1 ? -8 : -5
rotation: smokeText.playerNum == 1 ? -8 : -5
Emitter {
id: emitter
group: "smoke"