Focus for Qt5 is fewer, better demos.
Change-Id: Ia2b74ce4768034d8f225547ffbbc85ac5cb72845
Reviewed-by: Alan Alpert <alan.alpert@nokia.com>
+++ /dev/null
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtQml module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-
-Item {
- id: container
-
- signal clicked
-
- property string text
-
- BorderImage {
- id: buttonImage
- source: "images/toolbutton.sci"
- width: container.width; height: container.height
- }
- BorderImage {
- id: pressed
- opacity: 0
- source: "images/toolbutton.sci"
- width: container.width; height: container.height
- }
- MouseArea {
- id: mouseRegion
- anchors.fill: buttonImage
- onClicked: { container.clicked(); }
- }
- Text {
- color: "white"
- anchors.centerIn: buttonImage; font.bold: true; font.pixelSize: 15
- text: container.text; style: Text.Raised; styleColor: "black"
- }
- states: [
- State {
- name: "Pressed"
- when: mouseRegion.pressed == true
- PropertyChanges { target: pressed; opacity: 1 }
- }
- ]
-}
+++ /dev/null
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtQml module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-
-Item {
- id: wrapper; width: GridView.view.cellWidth; height: GridView.view.cellHeight
-
- function photoClicked() {
- imageDetails.photoTitle = title;
- imageDetails.photoTags = tags;
- imageDetails.photoWidth = photoWidth;
- imageDetails.photoHeight = photoHeight;
- imageDetails.photoType = photoType;
- imageDetails.photoAuthor = photoAuthor;
- imageDetails.photoDate = photoDate;
- imageDetails.photoUrl = url;
- imageDetails.rating = 0;
- scaleMe.state = "Details";
- }
-
- Item {
- anchors.centerIn: parent
- scale: 0.0
- Behavior on scale { NumberAnimation { easing.type: Easing.InOutQuad} }
- id: scaleMe
-
- Item {
- width: 77; height: 77; anchors.centerIn: parent
- Rectangle {
- id: whiteRect; width: 77; height: 77; color: "#dddddd"; smooth: true
- Image { id: thumb; source: imagePath; x: 1; y: 1; smooth: true }
- Image { source: "images/gloss.png" }
- }
- }
-
- Connections {
- target: toolBar
- onButton2Clicked: if (scaleMe.state == 'Details' ) scaleMe.state = 'Show'
- }
-
- states: [
- State {
- name: "Show"; when: thumb.status == Image.Ready
- PropertyChanges { target: scaleMe; scale: 1 }
- },
- State {
- name: "Details"
- PropertyChanges { target: scaleMe; scale: 1 }
- ParentChange { target: whiteRect; x: 10; y: 20; parent: imageDetails.frontContainer }
- PropertyChanges { target: background; state: "DetailedView" }
- }
- ]
- transitions: [
- Transition {
- from: "Show"; to: "Details"
- ParentAnimation {
- via: foreground
- NumberAnimation { properties: "x,y"; duration: 500; easing.type: Easing.InOutQuad }
- }
- },
- Transition {
- from: "Details"; to: "Show"
- ParentAnimation {
- via: foreground
- NumberAnimation { properties: "x,y"; duration: 500; easing.type: Easing.InOutQuad }
- }
- }
- ]
- }
- MouseArea { anchors.fill: wrapper; onClicked: photoClicked() }
-}
-
+++ /dev/null
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtQml module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-import QtQuick.Particles 2.0
-
-Flipable {
- id: container
-
- property alias frontContainer: containerFront
- property string photoTitle: ""
- property string photoTags: ""
- property int photoWidth
- property int photoHeight
- property string photoType
- property string photoAuthor
- property string photoDate
- property string photoUrl
- property int rating: 2
- property variant prevScale: 1.0
-
- property int flipDuration: 1600
-
- signal closed
-
- transform: Rotation {
- id: itemRotation
- origin.x: container.width / 2;
- axis.y: 1; axis.z: 0
- }
-
- front: Item {
- id: containerFront; anchors.fill: container
-
- Rectangle {
- anchors.fill: parent
- color: "black"; opacity: 0.4
- }
-
- Column {
- spacing: 10
- anchors {
- left: parent.left; leftMargin: 10
- right: parent.right; rightMargin: 10
- top: parent.top; topMargin: 120
- }
- Text { font.bold: true; color: "white"; elide: Text.ElideRight; text: container.photoTitle; width: parent.width }
- Text { color: "white"; elide: Text.ElideRight; text: "Size: " + container.photoWidth + 'x' + container.photoHeight; width: parent.width }
- Text { color: "white"; elide: Text.ElideRight; text: "Type: " + container.photoType; width: parent.width }
- Text { color: "white"; elide: Text.ElideRight; text: "Author: " + container.photoAuthor; width: parent.width }
- Text { color: "white"; elide: Text.ElideRight; text: "Published: " + container.photoDate; width: parent.width }
- Text { color: "white"; elide: Text.ElideRight; text: container.photoTags == "" ? "" : "Tags: "; width: parent.width }
- Text { color: "white"; elide: Text.ElideRight; text: container.photoTags; width: parent.width }
- }
- }
-
- back: Item {
- anchors.fill: container
-
- Rectangle { anchors.fill: parent; color: "black"; opacity: 0.4 }
-
- Progress {
- anchors.centerIn: parent; width: 200; height: 22
- progress: bigImage.progress; visible: bigImage.status != Image.Ready
- }
-
- Flickable {
- id: flickable; anchors.fill: parent; clip: true
- contentWidth: imageContainer.width; contentHeight: imageContainer.height
-
- function updateMinimumScale() {
- if (bigImage.status == Image.Ready && bigImage.width != 0) {
- slider.minimum = Math.min(flickable.width / bigImage.width, flickable.height / bigImage.height);
- if (bigImage.width * slider.value > flickable.width) {
- var xoff = (flickable.width/2 + flickable.contentX) * slider.value / prevScale;
- flickable.contentX = xoff - flickable.width/2;
- }
- if (bigImage.height * slider.value > flickable.height) {
- var yoff = (flickable.height/2 + flickable.contentY) * slider.value / prevScale;
- flickable.contentY = yoff - flickable.height/2;
- }
- prevScale = slider.value;
- }
- }
-
- onWidthChanged: updateMinimumScale()
- onHeightChanged: updateMinimumScale()
-
- Item {
- id: imageContainer
- width: Math.max(bigImage.width * bigImage.scale, flickable.width);
- height: Math.max(bigImage.height * bigImage.scale, flickable.height);
- Image {
- id: bigImage; source: container.photoUrl; scale: slider.value
- anchors.centerIn: parent; smooth: !flickable.movingVertically
- onStatusChanged : {
- // Default scale shows the entire image.
- if (bigImage.status == Image.Ready && bigImage.width != 0) {
- slider.minimum = Math.min(flickable.width / bigImage.width, flickable.height / bigImage.height);
- prevScale = Math.min(slider.minimum, 1);
- slider.value = prevScale;
- }
- if (inBackState && bigImage.status == Image.Ready)
- effectBox.imageInAnim();
- }
- property bool inBackState: false
- onInBackStateChanged:{
- if(inBackState && bigImage.status == Image.Ready)
- effectBox.imageInAnim();
- else if (!inBackState && bigImage.status == Image.Ready)
- effectBox.imageOutAnim();
- }
- }
- ShaderEffectSource{
- id: pictureSource
- sourceItem: bigImage
- smooth: true
- //Workaround: Doesn't work below lines
- width: bigImage.width
- height: bigImage.width
- visible: false
- }
- Turbulence{//only fill visible rect
- id: turbulence
- system: imageSystem
- anchors.fill: parent
- strength: 240
- enabled: false
- }
-
- Item{
- id: effectBox
- width: bigImage.width * bigImage.scale
- height: bigImage.height * bigImage.scale
- anchors.centerIn: parent
- function imageInAnim(){
- bigImage.visible = false;
- noiseIn.visible = true;
- endEffectTimer.start();
- }
- function imageOutAnim(){
- bigImage.visible = false;
- noiseIn.visible = false;
- turbulence.enabled = true;
- endEffectTimer.start();
- pixelEmitter.burst(2048);
- }
- Timer{
- id: endEffectTimer
- interval: flipDuration
- repeat: false
- running: false
- onTriggered:{
- turbulence.enabled = false;
- noiseIn.visible = false;
- bigImage.visible = true;
- }
- }
- ShaderEffect{
- id: noiseIn
- anchors.fill: parent
- property real t: 0
- visible: false
- onVisibleChanged: tAnim.start()
- NumberAnimation{
- id: tAnim
- target: noiseIn
- property: "t"
- from: 0.0
- to: 1.0
- duration: flipDuration
- }
- property variant source: pictureSource
- property variant noise: ShaderEffectSource{
- sourceItem:Image{
- source: "images/noise.png"
- }
- hideSource: true
- smooth: false
- }
- fragmentShader:"
- uniform sampler2D noise;
- uniform sampler2D source;
- uniform highp float t;
- uniform lowp float qt_Opacity;
- varying highp vec2 qt_TexCoord0;
- void main(){
- //Want to use noise2, but it always returns (0,0)?
- if(texture2D(noise, qt_TexCoord0).w <= t)
- gl_FragColor = texture2D(source, qt_TexCoord0) * qt_Opacity;
- else
- gl_FragColor = vec4(0.,0.,0.,0.);
- }
- "
- }
- ParticleSystem{
- id: imageSystem
- }
- Emitter{
- id: pixelEmitter
- system: imageSystem
- //anchors.fill: parent
- width: Math.min(bigImage.width * bigImage.scale, flickable.width);
- height: Math.min(bigImage.height * bigImage.scale, flickable.height);
- anchors.centerIn: parent
- size: 4
- lifeSpan: flipDuration
- emitRate: 2048
- enabled: false
- }
- CustomParticle{
- id: blowOut
- system: imageSystem
- property real maxWidth: effectBox.width
- property real maxHeight: effectBox.height
- vertexShader:"
- uniform highp float maxWidth;
- uniform highp float maxHeight;
-
- varying highp vec2 fTex2;
-
- void main() {
- defaultMain();
- fTex2 = vec2(qt_ParticlePos.x / maxWidth, qt_ParticlePos.y / maxHeight);
- }
- "
- property variant pictureTexture: pictureSource
- fragmentShader: "
- uniform lowp float qt_Opacity;
- uniform sampler2D pictureTexture;
- varying highp vec2 fTex2;
- void main() {
- gl_FragColor = texture2D(pictureTexture, fTex2) * qt_Opacity;
- }"
- }
-
-
-
- }
- }
- }
-
- Text {
- text: "Image Unavailable"
- visible: bigImage.status == Image.Error
- anchors.centerIn: parent; color: "white"; font.bold: true
- }
-
- Slider {
- id: slider; visible: { bigImage.status == Image.Ready && maximum > minimum }
- anchors {
- bottom: parent.bottom; bottomMargin: 65
- left: parent.left; leftMargin: 25
- right: parent.right; rightMargin: 25
- }
- onValueChanged: {
- if (bigImage.width * value > flickable.width) {
- var xoff = (flickable.width/2 + flickable.contentX) * value / prevScale;
- flickable.contentX = xoff - flickable.width/2;
- }
- if (bigImage.height * value > flickable.height) {
- var yoff = (flickable.height/2 + flickable.contentY) * value / prevScale;
- flickable.contentY = yoff - flickable.height/2;
- }
- prevScale = value;
- }
- }
- }
-
- states: State {
- name: "Back"
- PropertyChanges { target: itemRotation; angle: 180 }
- PropertyChanges { target: toolBar; button2Visible: false }
- PropertyChanges { target: toolBar; button1Label: "Back" }
- PropertyChanges { target: bigImage; inBackState: true }
- }
-
- transitions: Transition {
- SequentialAnimation {
- PropertyAction { target: bigImage; property: "smooth"; value: false }
- NumberAnimation { easing.type: Easing.InOutQuad; properties: "angle"; duration: flipDuration }
- PropertyAction { target: bigImage; property: "smooth"; value: !flickable.movingVertically }
- }
- }
-}
+++ /dev/null
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtQml module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-
-Component {
- Item {
- id: wrapper; width: wrapper.ListView.view.width; height: 86
- Item {
- id: moveMe
- Rectangle { color: "black"; opacity: index % 2 ? 0.2 : 0.4; height: 84; width: wrapper.width; y: 1 }
- Rectangle {
- x: 6; y: 4; width: 77; height: 77; color: "white"; smooth: true
-
- Image { source: imagePath; x: 1; y: 1 }
- Image { source: "images/gloss.png" }
- }
- Column {
- x: 92; width: wrapper.ListView.view.width - 95; y: 15; spacing: 2
- Text { text: title; color: "white"; width: parent.width; font.pixelSize: 14; font.bold: true; elide: Text.ElideRight; style: Text.Raised; styleColor: "black" }
- Text { text: photoAuthor; width: parent.width; font.pixelSize: 14; elide: Text.ElideLeft; color: "#cccccc"; style: Text.Raised; styleColor: "black" }
- Text { text: photoDate; width: parent.width; font.pixelSize: 14; elide: Text.ElideRight; color: "#cccccc"; style: Text.Raised; styleColor: "black" }
- }
- }
- }
-}
+++ /dev/null
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtQml module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-import QtQuick.Particles 2.0
-
-Item{
- id: container
- property variant progress: 0
-
- Rectangle {
- anchors.fill: parent; smooth: true
- border.color: "white"; border.width: 0; radius: height/2 - 2
- gradient: Gradient {
- GradientStop { position: 0; color: "#66343434" }
- GradientStop { position: 1.0; color: "#66000000" }
- }
- }
-
- ParticleSystem{
- running: container.visible
- id: barSys
- }
- ImageParticle{
- color: "lightsteelblue"
- alpha: 0.1
- colorVariation: 0.05
- source: "images/particle.png"
- system: barSys
- }
- Emitter{
- y: 2; height: parent.height-4;
- x: 2; width: Math.max(parent.width * progress - 4, 0);
- speed: AngleDirection{ angleVariation: 180; magnitudeVariation: 12 }
- system: barSys
- emitRate: width;
- lifeSpan: 1000
- size: 20
- sizeVariation: 4
- endSize: 12
- maximumEmitted: parent.width;
- }
-
- Text {
- text: Math.round(progress * 100) + "%"
- anchors.horizontalCenter: parent.horizontalCenter
- anchors.verticalCenter: parent.verticalCenter
- color: Qt.rgba(1.0, 1.0 - progress, 1.0 - progress,0.9); font.bold: true; font.pixelSize: 15
- }
-}
+++ /dev/null
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtQml module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-import QtQuick.XmlListModel 2.0
-
-XmlListModel {
- property string tags : ""
-
- function encodeTags(x) { return encodeURIComponent(x.replace(' ',',')); }
-
- source: "http://api.flickr.com/services/feeds/photos_public.gne?"+(tags ? "tags="+encodeTags(tags)+"&" : "")+"format=rss2"
- query: "/rss/channel/item"
- namespaceDeclarations: "declare namespace media=\"http://search.yahoo.com/mrss/\";"
-
- XmlRole { name: "title"; query: "title/string()" }
- XmlRole { name: "imagePath"; query: "media:thumbnail/@url/string()" }
- XmlRole { name: "url"; query: "media:content/@url/string()" }
- XmlRole { name: "description"; query: "description/string()" }
- XmlRole { name: "tags"; query: "media:category/string()" }
- XmlRole { name: "photoWidth"; query: "media:content/@width/string()" }
- XmlRole { name: "photoHeight"; query: "media:content/@height/string()" }
- XmlRole { name: "photoType"; query: "media:content/@type/string()" }
- XmlRole { name: "photoAuthor"; query: "author/string()" }
- XmlRole { name: "photoDate"; query: "pubDate/string()" }
-}
+++ /dev/null
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtQml module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-
-Item {
- id: container
-
- property variant flickableArea
-
- Rectangle {
- radius: 5
- color: "black"
- opacity: 0.3
- border.color: "white"
- border.width: 2
- x: 0
- y: flickableArea.visibleArea.yPosition * container.height
- width: parent.width
- height: flickableArea.visibleArea.heightRatio * container.height
- }
- states: [
- State {
- name: "show"
- when: flickableArea.movingVertically
- PropertyChanges {
- target: container
- opacity: 1
- }
- }
- ]
- transitions: [
- Transition {
- from: "*"
- to: "*"
- NumberAnimation {
- target: container
- properties: "opacity"
- duration: 400
- }
- }
- ]
-}
+++ /dev/null
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtQml module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-
-Item {
- id: slider; width: 400; height: 16
-
- // value is read/write.
- property real value: 1
- onValueChanged: updatePos();
- property real maximum: 1
- property real minimum: 1
- property int xMax: width - handle.width - 4
- onXMaxChanged: updatePos();
- onMinimumChanged: updatePos();
-
- function updatePos() {
- if (maximum > minimum) {
- var pos = 2 + (value - minimum) * slider.xMax / (maximum - minimum);
- pos = Math.min(pos, width - handle.width - 2);
- pos = Math.max(pos, 2);
- handle.x = pos;
- } else {
- handle.x = 2;
- }
- }
-
- Rectangle {
- anchors.fill: parent
- border.color: "white"; border.width: 0; radius: 8
- gradient: Gradient {
- GradientStop { position: 0.0; color: "#66343434" }
- GradientStop { position: 1.0; color: "#66000000" }
- }
- }
-
- Rectangle {
- id: handle; smooth: true
- y: 2; width: 30; height: slider.height-4; radius: 6
- gradient: Gradient {
- GradientStop { position: 0.0; color: "lightgray" }
- GradientStop { position: 1.0; color: "gray" }
- }
-
- MouseArea {
- id: mouse
- anchors.fill: parent; drag.target: parent
- drag.axis: Drag.XAxis; drag.minimumX: 2; drag.maximumX: slider.xMax+2
- onPositionChanged: { value = (maximum - minimum) * (handle.x-2) / slider.xMax + minimum; }
- }
- }
-}
+++ /dev/null
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtQml module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-
-Item {
- id: titleBar
- property string untaggedString: "Uploads from everyone"
- property string taggedString: "Recent uploads tagged "
-
- BorderImage { source: "images/titlebar.sci"; width: parent.width; height: parent.height + 14; y: -7 }
-
- Item {
- id: container
- width: (parent.width * 2) - 55 ; height: parent.height
-
- function accept() {
- imageDetails.closed()
- titleBar.state = ""
- background.state = ""
- rssModel.tags = editor.text
- }
-
- Image {
- id: quitButton
- anchors.left: parent.left//; anchors.leftMargin: 0
- anchors.verticalCenter: parent.verticalCenter
- source: "images/quit.png"
- MouseArea {
- anchors.fill: parent
- onClicked: Qt.quit()
- }
- }
-
- Text {
- id: categoryText
- anchors {
- left: quitButton.right; right: tagButton.left; leftMargin: 10; rightMargin: 10
- verticalCenter: parent.verticalCenter
- }
- elide: Text.ElideLeft
- text: (rssModel.tags=="" ? untaggedString : taggedString + rssModel.tags)
- font.bold: true; font.pixelSize: 15; color: "White"; style: Text.Raised; styleColor: "Black"
- }
-
- Button {
- id: tagButton; x: titleBar.width - 50; width: 45; height: 32; text: "..."
- onClicked: if (titleBar.state == "Tags") container.accept(); else titleBar.state = "Tags"
- anchors.verticalCenter: parent.verticalCenter
- }
-
- Item {
- id: lineEdit
- y: 4; height: parent.height - 9
- anchors { left: tagButton.right; leftMargin: 5; right: parent.right; rightMargin: 5 }
-
- BorderImage { source: "images/lineedit.sci"; anchors.fill: parent }
-
- TextInput {
- id: editor
- anchors {
- left: parent.left; right: parent.right; leftMargin: 10; rightMargin: 10
- verticalCenter: parent.verticalCenter
- }
- cursorVisible: true; font.bold: true
- color: "#151515"; selectionColor: "Green"
- }
-
- Keys.forwardTo: [ (returnKey), (editor)]
-
- Item {
- id: returnKey
- Keys.onReturnPressed: container.accept()
- Keys.onEnterPressed: container.accept()
- Keys.onEscapePressed: titleBar.state = ""
- }
- }
- }
-
- states: State {
- name: "Tags"
- PropertyChanges { target: container; x: -tagButton.x + 5 }
- PropertyChanges { target: tagButton; text: "OK" }
- PropertyChanges { target: editor; focus: true }
- }
-
- transitions: Transition {
- NumberAnimation { properties: "x"; easing.type: Easing.InOutQuad }
- }
-}
+++ /dev/null
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtQml module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-
-Item {
- id: toolbar
-
- property alias button1Label: button1.text
- property alias button2Label: button2.text
- property alias button2Visible: button2.visible
-
- signal button1Clicked
- signal button2Clicked
-
- BorderImage { source: "images/titlebar.sci"; width: parent.width; height: parent.height + 14; y: -7 }
-
- Row {
- anchors.right: parent.right; anchors.rightMargin: 5; y: 3; height: 32; spacing: 30
- Button {
- id: button1
- width: 140; height: 32
- onClicked: toolbar.button1Clicked()
- }
-
- Button {
- id: button2; width: 140; height: 32
- onClicked: toolbar.button2Clicked()
- }
- }
-}
+++ /dev/null
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtQml module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-import QtQuick.Particles 2.0
-
-Package {
- function photoClicked() {
- imageDetails.photoTitle = title;
- imageDetails.photoTags = tags;
- imageDetails.photoWidth = photoWidth;
- imageDetails.photoHeight = photoHeight;
- imageDetails.photoType = photoType;
- imageDetails.photoAuthor = photoAuthor;
- imageDetails.photoDate = photoDate;
- imageDetails.photoUrl = url;
- imageDetails.rating = 0;
- scaleMe.state = "Details";
- }
-
- Item {
- id: gridwrapper;
- width: GridView.view.cellWidth; height: GridView.view.cellHeight
- Package.name: "grid"
- }
- Item {
- id: streamwrapper;
- width: 80; height: 80
- Package.name: "stream"
- }
- Item {
- //anchors.centerIn: parent//Doesn't animate :(
- width: 80; height: 80
- scale: 0.0
- Behavior on scale { NumberAnimation { easing.type: Easing.InOutQuad} }
- id: scaleMe
-
- Item {
- id: whiteRectContainer
- width: 77; height: 77; anchors.centerIn: parent
- Rectangle {
- id: whiteRect; width: 77; height: 77; color: "#dddddd"; smooth: true
- x:0; y:0
- Image { id: thumb; source: imagePath; x: 1; y: 1; smooth: true }
- Image { source: "images/gloss.png" }
- MouseArea { anchors.fill: parent; onClicked: photoClicked() }
- }
- }
-
- Connections {
- target: toolBar
- onButton2Clicked: if (scaleMe.state == 'Details' ) scaleMe.state = 'Show'
- }
-
- state: 'inStream'
- states: [
- State {
- name: "Show"; when: thumb.status == Image.Ready
- PropertyChanges { target: scaleMe; scale: 1; }
- },
- State {
- name: "Details"
- PropertyChanges { target: scaleMe; scale: 1 }
- ParentChange { target: whiteRect; x: 10; y: 20; parent: imageDetails.frontContainer }
- PropertyChanges { target: background; state: "DetailedView" }
- }
- ]
- transitions: [
- Transition {
- from: "Show"; to: "Details"
- ParentAnimation {
- via: foreground
- NumberAnimation { properties: "x,y"; duration: 500; easing.type: Easing.InOutQuad }
- }
- },
- Transition {
- from: "Details"; to: "Show"
- SequentialAnimation{
- ParentAnimation {
- via: foreground
- NumberAnimation { properties: "x,y"; duration: 500; easing.type: Easing.InOutQuad }
- }
- }
- }
- ]
- Item{
- id: stateContainer
- states: [
- State {
- name: 'inStream'
- when: screen.inGridView == false
- ParentChange {
- target: scaleMe; parent: streamwrapper
- x: 0; y: 0;
- }
- },
- State {
- name: 'inGrid'
- when: screen.inGridView == true
- ParentChange {
- target: scaleMe; parent: gridwrapper
- x: 0; y: 0;
- }
- }
- ]
-
- transitions: [
- Transition {
- ParentAnimation {
- NumberAnimation { target: scaleMe; properties: 'x,y,width,height'; duration: 300 }
- }
- }
- ]
- }
- }
-}
+++ /dev/null
-border.left: 10
-border.top: 10
-border.bottom: 10
-border.right: 10
-source: lineedit.png
+++ /dev/null
-border.left: 10
-border.top: 12
-border.bottom: 12
-border.right: 10
-source: titlebar.png
+++ /dev/null
-border.left: 15
-border.top: 4
-border.bottom: 4
-border.right: 15
-source: toolbutton.png
+++ /dev/null
-ImageDetails ImageDetails.qml
-LikeOMeter LikeOMeter.qml
-Loading Loading.qml
-MediaButton MediaButton.qml
-MediaLineEdit MediaLineEdit.qml
-Progress Progress.qml
-RssModel RssModel.qml
-ScrollBar ScrollBar.qml
-Slider Slider.qml
-Star Star.qml
+++ /dev/null
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtQml module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-
-Item {
- width: 480; height: 320
-
- Loader {
- y: 320; rotation: -90
- transformOrigin: Item.TopLeft
- source: "flickr.qml"
- }
-}
+++ /dev/null
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtQml module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-import QtQuick.Particles 2.0
-import "content"
-
-Item {
- id: screen; width: 320; height: 480
- property bool inGridView : true
-
- Rectangle {
- id: background
- anchors.fill: parent; color: "#343434";
-
- Image { source: "content/images/stripes.png"; fillMode: Image.Tile; anchors.fill: parent; opacity: 0.3 }
- ParticleSystem {
- id: bgParticles
- anchors.fill: parent
- ImageParticle {
- groups: ["trail"]
- source: "content/images/particle.png"
- color: "#1A1A6F"
- alpha: 0.1
- colorVariation: 0.01
- blueVariation: 0.8
- }
- Emitter {
- group: "drops"
- width: parent.width
- emitRate: 0.5
- lifeSpan: 20000
- startTime: 16000
- speed: PointDirection{
- y: {screen.height/18}
- }
- }
- TrailEmitter {
- follow: "drops"
- group: "trail"
- emitRatePerParticle: 18
- size: 32
- endSize: 0
- sizeVariation: 4
- lifeSpan: 1200
- anchors.fill: parent
- emitWidth: 16
- emitHeight: 16
- emitShape: EllipseShape{}
- }
- }
-
- VisualDataModel{
- id: vdm
- delegate: UnifiedDelegate{}
- model: RssModel { id: rssModel }
- }
-
- Item {
- id: views
- width: parent.width
- anchors.top: titleBar.bottom; anchors.bottom: toolBar.top
-
- GridView {
- id: photoGridView; model: vdm.parts.grid
- cacheBuffer: 1000
- cellWidth: (parent.width-2)/4; cellHeight: cellWidth; width: parent.width; height: parent.height
- }
-
- states: State {
- name: "GridView"; when: state.inGridView == true
- }
-
- transitions: Transition {
- NumberAnimation { properties: "x"; duration: 500; easing.type: Easing.InOutQuad }
- }
-
- ImageDetails { id: imageDetails; width: parent.width; anchors.left: views.right; height: parent.height }
-
- Item { id: foreground; anchors.fill: parent }
- }
-
- TitleBar { id: titleBar; width: parent.width; height: 40; opacity: 0.9 }
-
- ToolBar {
- id: toolBar
- height: 40; anchors.bottom: parent.bottom; width: parent.width; opacity: 0.9
- button1Label: "Update"; button2Label: "View mode"
- onButton1Clicked: rssModel.reload()
- onButton2Clicked: if (screen.inGridView == true) screen.inGridView = false; else screen.inGridView = true
- }
-
- Connections {
- target: imageDetails
- onClosed: {
- if (background.state == "DetailedView") {
- background.state = '';
- imageDetails.photoUrl = "";
- }
- }
- }
-
- states: State {
- name: "DetailedView"
- PropertyChanges { target: views; x: -parent.width }
- PropertyChanges { target: toolBar; button1Label: "View..." }
- PropertyChanges {
- target: toolBar
- onButton1Clicked: if (imageDetails.state=='') imageDetails.state='Back'; else imageDetails.state=''
- }
- PropertyChanges { target: toolBar; button2Label: "Back" }
- PropertyChanges { target: toolBar; onButton2Clicked: imageDetails.closed() }
- }
-
- transitions: Transition {
- NumberAnimation { properties: "x"; duration: 500; easing.type: Easing.InOutQuad }
- }
-
- }
-}
+++ /dev/null
-import QmlProject 1.1
-
-Project {
- mainFile: "flickr.qml"
- //mainFile: "flickr-90.qml"
-
- /* Include .qml, .js, and image files from current directory and subdirectories */
- QmlFiles {
- directory: "."
- }
- JavaScriptFiles {
- directory: "."
- }
- ImageFiles {
- directory: "."
- }
-}
+++ /dev/null
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtQml module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-import QtQuick.Particles 2.0
-
-Item {
- property bool explode : false
- ParticleSystem {
- width: 40
- height: 40
- ImageParticle {
- groups: ["star"]
- source: "file:MinehuntCore/pics/star.png" // TODO: Use qrc path once QTBUG-21129 is fixed
- }
- Emitter {
- id: particles
- enabled: false
- anchors.centerIn: parent
- group: "star"
- speed: AngleDirection { angleVariation: 360; magnitude: 150; magnitudeVariation: 50 }
- emitRate: 200
- z: 100
- lifeSpan: 1000
- }
- }
- states: State { name: "exploding"; when: explode
- StateChangeScript { script: particles.burst(200); }
- }
-
-}
+++ /dev/null
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtQml module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-
-Flipable {
- id: flipable
- property int angle: 0
-
- width: 40; height: 40
- transform: Rotation { origin.x: 20; origin.y: 20; axis.x: 1; axis.z: 0; angle: flipable.angle }
-
- front: Image {
- source: "pics/front.png"; width: 40; height: 40
-
- Image {
- anchors.centerIn: parent
- source: "pics/flag.png"; opacity: modelData.hasFlag
-
- Behavior on opacity { NumberAnimation {} }
- }
- }
-
- back: Image {
- source: "pics/back.png"
- width: 40; height: 40
-
- Text {
- anchors.centerIn: parent
- text: modelData.hint; color: "white"; font.bold: true
- opacity: !modelData.hasMine && modelData.hint > 0
- }
-
- Image {
- anchors.centerIn: parent
- source: "pics/bomb.png"; opacity: modelData.hasMine
- }
-
- Explosion { id: expl }
- }
-
- states: State {
- name: "back"; when: modelData.flipped
- PropertyChanges { target: flipable; angle: 180 }
- }
-
- property real pauseDur: 250
- transitions: Transition {
- SequentialAnimation {
- ScriptAction {
- script: {
- var ret = Math.abs(flipable.x - field.clickx)
- + Math.abs(flipable.y - field.clicky);
- if (modelData.hasMine && modelData.flipped)
- pauseDur = ret * 3
- else
- pauseDur = ret
- }
- }
- PauseAnimation {
- duration: pauseDur
- }
- RotationAnimation { easing.type: Easing.InOutQuad }
- ScriptAction { script: if (modelData.hasMine && modelData.flipped) { expl.explode = true } }
- }
- }
-
- MouseArea {
- anchors.fill: parent
- acceptedButtons: Qt.LeftButton | Qt.RightButton
- onClicked: {
- field.clickx = flipable.x
- field.clicky = flipable.y
- var row = Math.floor(index / 9)
- var col = index - (Math.floor(index / 9) * 9)
- if (mouse.button == undefined || mouse.button == Qt.RightButton) {
- flag(row, col)
- } else {
- flip(row, col)
- }
- }
- onPressAndHold: {
- field.clickx = flipable.x
- field.clicky = flipable.y
- var row = Math.floor(index / 9)
- var col = index - (Math.floor(index / 9) * 9)
- flag(row, col)
- }
- }
-}
+++ /dev/null
-Explosion 2.0 Explosion.qml
-Tile 2.0 Tile.qml
+++ /dev/null
-Minehunt has to be compiled to run.
-
-To compile the C++ part, do 'qmake && make'.
-To run, simply run the executable.
-To deploy on a device, do 'make sis'.
-
+++ /dev/null
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the demonstration applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QtGui/QGuiApplication>
-#include <QtQuick/qquickview.h>
-#include <QtQml/QQmlContext>
-#include <QtQml/QQmlEngine>
-
-#include "minehunt.h"
-
-int main(int argc, char *argv[])
-{
- QGuiApplication app(argc, argv);
- QQuickView canvas;
-
- qmlRegisterType<TileData>();
- MinehuntGame* game = new MinehuntGame();
-
- canvas.setResizeMode(QQuickView::SizeRootObjectToView);
- canvas.engine()->rootContext()->setContextObject(game);
- canvas.setSource(QString("qrc:///minehunt.qml"));
- QObject::connect(canvas.engine(), SIGNAL(quit()), &app, SLOT(quit()));
-
- canvas.show();
- return app.exec();
-}
+++ /dev/null
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the demonstration applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <stdlib.h>
-#include <QTime>
-#include <QTimer>
-
-#include "minehunt.h"
-
-void tilesPropAppend(QQmlListProperty<TileData>* prop, TileData* value)
-{
- Q_UNUSED(prop);
- Q_UNUSED(value);
- return; //Append not supported
-}
-
-int tilesPropCount(QQmlListProperty<TileData>* prop)
-{
- return static_cast<QList<TileData*>*>(prop->data)->count();
-}
-
-TileData* tilesPropAt(QQmlListProperty<TileData>* prop, int index)
-{
- return static_cast<QList<TileData*>*>(prop->data)->at(index);
-}
-
-QQmlListProperty<TileData> MinehuntGame::tiles(){
- return QQmlListProperty<TileData>(this, &_tiles, &tilesPropAppend,
- &tilesPropCount, &tilesPropAt, 0);
-}
-
-MinehuntGame::MinehuntGame()
-: numCols(9), numRows(9), playing(true), won(false)
-{
- setObjectName("mainObject");
- srand(QTime(0,0,0).secsTo(QTime::currentTime()));
-
- //initialize array
- for(int ii = 0; ii < numRows * numCols; ++ii) {
- _tiles << new TileData;
- }
- reset();
-
-}
-
-void MinehuntGame::setBoard()
-{
- foreach(TileData* t, _tiles){
- t->setHasMine(false);
- t->setHint(-1);
- }
- //place mines
- int mines = nMines;
- remaining = numRows*numCols-mines;
- while ( mines ) {
- int col = int((double(rand()) / double(RAND_MAX)) * numCols);
- int row = int((double(rand()) / double(RAND_MAX)) * numRows);
-
- TileData* t = tile( row, col );
-
- if (t && !t->hasMine()) {
- t->setHasMine( true );
- mines--;
- }
- }
-
- //set hints
- for (int r = 0; r < numRows; r++)
- for (int c = 0; c < numCols; c++) {
- TileData* t = tile(r, c);
- if (t && !t->hasMine()) {
- int hint = getHint(r,c);
- t->setHint(hint);
- }
- }
-
- setPlaying(true);
-}
-
-void MinehuntGame::reset()
-{
- foreach(TileData* t, _tiles){
- t->unflip();
- t->setHasFlag(false);
- }
- nMines = 12;
- nFlags = 0;
- emit numMinesChanged();
- emit numFlagsChanged();
- setPlaying(false);
- QTimer::singleShot(600,this, SLOT(setBoard()));
-}
-
-int MinehuntGame::getHint(int row, int col)
-{
- int hint = 0;
- for (int c = col-1; c <= col+1; c++)
- for (int r = row-1; r <= row+1; r++) {
- TileData* t = tile(r, c);
- if (t && t->hasMine())
- hint++;
- }
- return hint;
-}
-
-bool MinehuntGame::flip(int row, int col)
-{
- if(!playing)
- return false;
-
- TileData *t = tile(row, col);
- if (!t || t->hasFlag())
- return false;
-
- if(t->flipped()){
- int flags = 0;
- for (int c = col-1; c <= col+1; c++)
- for (int r = row-1; r <= row+1; r++) {
- TileData *nearT = tile(r, c);
- if(!nearT || nearT == t)
- continue;
- if(nearT->hasFlag())
- flags++;
- }
- if(!t->hint() || t->hint() != flags)
- return false;
- for (int c = col-1; c <= col+1; c++)
- for (int r = row-1; r <= row+1; r++) {
- TileData *nearT = tile(r, c);
- if (nearT && !nearT->flipped() && !nearT->hasFlag()) {
- flip( r, c );
- }
- }
- return true;
- }
-
- t->flip();
-
- if (t->hint() == 0) {
- for (int c = col-1; c <= col+1; c++)
- for (int r = row-1; r <= row+1; r++) {
- TileData* t = tile(r, c);
- if (t && !t->flipped()) {
- flip( r, c );
- }
- }
- }
-
- if(t->hasMine()){
- for (int r = 0; r < numRows; r++)//Flip all other mines
- for (int c = 0; c < numCols; c++) {
- TileData* t = tile(r, c);
- if (t && t->hasMine()) {
- flip(r, c);
- }
- }
- won = false;
- hasWonChanged();
- setPlaying(false);
- return true;
- }
-
- remaining--;
- if(!remaining){
- won = true;
- hasWonChanged();
- setPlaying(false);
- return true;
- }
- return true;
-}
-
-bool MinehuntGame::flag(int row, int col)
-{
- TileData *t = tile(row, col);
- if(!t || !playing || t->flipped())
- return false;
-
- t->setHasFlag(!t->hasFlag());
- nFlags += (t->hasFlag()?1:-1);
- emit numFlagsChanged();
- return true;
-}
+++ /dev/null
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the demonstration applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-
-#include <qqml.h>
-
-class TileData : public QObject
-{
- Q_OBJECT
-public:
- TileData() : _hasFlag(false), _hasMine(false), _hint(-1), _flipped(false) {}
-
- Q_PROPERTY(bool hasFlag READ hasFlag WRITE setHasFlag NOTIFY hasFlagChanged)
- bool hasFlag() const { return _hasFlag; }
-
- Q_PROPERTY(bool hasMine READ hasMine NOTIFY hasMineChanged)
- bool hasMine() const { return _hasMine; }
-
- Q_PROPERTY(int hint READ hint NOTIFY hintChanged)
- int hint() const { return _hint; }
-
- Q_PROPERTY(bool flipped READ flipped NOTIFY flippedChanged())
- bool flipped() const { return _flipped; }
-
- void setHasFlag(bool flag) {if(flag==_hasFlag) return; _hasFlag = flag; emit hasFlagChanged();}
- void setHasMine(bool mine) {if(mine==_hasMine) return; _hasMine = mine; emit hasMineChanged();}
- void setHint(int hint) { if(hint == _hint) return; _hint = hint; emit hintChanged(); }
- void flip() { if (_flipped) return; _flipped = true; emit flippedChanged(); }
- void unflip() { if(!_flipped) return; _flipped = false; emit flippedChanged(); }
-
-signals:
- void flippedChanged();
- void hasFlagChanged();
- void hintChanged();
- void hasMineChanged();
-
-private:
- bool _hasFlag;
- bool _hasMine;
- int _hint;
- bool _flipped;
-};
-
-class MinehuntGame : public QObject
-{
- Q_OBJECT
-public:
- MinehuntGame();
-
- Q_PROPERTY(QQmlListProperty<TileData> tiles READ tiles CONSTANT)
- QQmlListProperty<TileData> tiles();
-
- Q_PROPERTY(bool isPlaying READ isPlaying NOTIFY isPlayingChanged)
- bool isPlaying() {return playing;}
-
- Q_PROPERTY(bool hasWon READ hasWon NOTIFY hasWonChanged)
- bool hasWon() {return won;}
-
- Q_PROPERTY(int numMines READ numMines NOTIFY numMinesChanged)
- int numMines() const{return nMines;}
-
- Q_PROPERTY(int numFlags READ numFlags NOTIFY numFlagsChanged)
- int numFlags() const{return nFlags;}
-
-public slots:
- Q_INVOKABLE bool flip(int row, int col);
- Q_INVOKABLE bool flag(int row, int col);
- void setBoard();
- void reset();
-
-signals:
- void isPlayingChanged();
- void hasWonChanged();
- void numMinesChanged();
- void numFlagsChanged();
-
-private:
- bool onBoard( int r, int c ) const { return r >= 0 && r < numRows && c >= 0 && c < numCols; }
- TileData *tile( int row, int col ) { return onBoard(row, col) ? _tiles[col+numRows*row] : 0; }
- int getHint(int row, int col);
- void setPlaying(bool b){if(b==playing) return; playing=b; emit isPlayingChanged();}
-
- QList<TileData *> _tiles;
- int numCols;
- int numRows;
- bool playing;
- bool won;
- int remaining;
- int nMines;
- int nFlags;
-};
+++ /dev/null
-QT += qml quick
-
-HEADERS += minehunt.h
-SOURCES += main.cpp minehunt.cpp
-RESOURCES = minehunt.qrc
+++ /dev/null
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtQml module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-import "MinehuntCore" 2.0
-
-Item {
- id: field
- property int clickx: 0
- property int clicky: 0
-
- width: 450; height: 450
-
- Image { source: "MinehuntCore/pics/background.png"; anchors.fill: parent; fillMode: Image.Tile }
-
- Grid {
- anchors.horizontalCenter: parent.horizontalCenter
- columns: 9; spacing: 1
-
- Repeater {
- id: repeater
- model: tiles
- delegate: Tile {}
- }
- }
-
- Row {
- id: gamedata
- x: 20; spacing: 20
- anchors.bottom: field.bottom; anchors.bottomMargin: 15
-
- Image {
- source: "MinehuntCore/pics/quit.png"
- scale: quitMouse.pressed ? 0.8 : 1.0
- smooth: quitMouse.pressed
- y: 10
- MouseArea {
- id: quitMouse
- anchors.fill: parent
- anchors.margins: -20
- onClicked: Qt.quit()
- }
- }
- Column {
- spacing: 2
- Image { source: "MinehuntCore/pics/bomb-color.png" }
- Text { anchors.horizontalCenter: parent.horizontalCenter; color: "white"; text: numMines }
- }
-
- Column {
- spacing: 2
- Image { source: "MinehuntCore/pics/flag-color.png" }
- Text { anchors.horizontalCenter: parent.horizontalCenter; color: "white"; text: numFlags }
- }
- }
-
- Image {
- anchors.bottom: field.bottom; anchors.bottomMargin: 15
- anchors.right: field.right; anchors.rightMargin: 20
- source: isPlaying ? 'MinehuntCore/pics/face-smile.png' :
- hasWon ? 'MinehuntCore/pics/face-smile-big.png': 'MinehuntCore/pics/face-sad.png'
-
- MouseArea { anchors.fill: parent; onPressed: reset() }
- }
- Text {
- anchors.centerIn: parent; width: parent.width - 20
- horizontalAlignment: Text.AlignHCenter
- wrapMode: Text.WordWrap
- text: "Minehunt demo has to be compiled to run.\n\nPlease see README."
- color: "white"; font.bold: true; font.pixelSize: 14
- visible: tiles == undefined
- }
-
-}
+++ /dev/null
-import QmlProject 1.1
-
-Project {
- mainFile: "minehunt.qml"
-
- /* Include .qml, .js, and image files from current directory and subdirectories */
- QmlFiles {
- directory: "."
- }
- JavaScriptFiles {
- directory: "."
- }
- ImageFiles {
- directory: "."
- }
-}
+++ /dev/null
-<!DOCTYPE RCC><RCC version="1.0">
-<qresource>
- <file>minehunt.qml</file>
- <file>MinehuntCore/Explosion.qml</file>
- <file>MinehuntCore/Tile.qml</file>
- <file>MinehuntCore/qmldir</file>
- <file>MinehuntCore/pics/background.png</file>
- <file>MinehuntCore/pics/back.png</file>
- <file>MinehuntCore/pics/bomb-color.png</file>
- <file>MinehuntCore/pics/bomb.png</file>
- <file>MinehuntCore/pics/face-sad.png</file>
- <file>MinehuntCore/pics/face-smile-big.png</file>
- <file>MinehuntCore/pics/face-smile.png</file>
- <file>MinehuntCore/pics/flag-color.png</file>
- <file>MinehuntCore/pics/flag.png</file>
- <file>MinehuntCore/pics/front.png</file>
- <file>MinehuntCore/pics/quit.png</file>
- <file>MinehuntCore/pics/star.png</file>
-</qresource>
-</RCC>
+++ /dev/null
-import QmlProject 1.1
-
-Project {
- mainFile: "plasmapatrol.qml"
-
- /* Include .qml, .js, and image files from current directory and subdirectories */
- QmlFiles {
- directory: "."
- }
- JavaScriptFiles {
- directory: "."
- }
- ImageFiles {
- directory: "."
- }
- Files {
- paths: ["TODO"]
- }
-}
+++ /dev/null
-Realistic Tasks:
-Particle explosions on ship death.
-Better help text (both content and styled a little nicer).
-Hardpoint help showing them firing across the screen.
-Endless Demo Mode
-
-Nice-but-i-doubt-it-will-get-done Tasks:
-Particle Text for the winner.
-Particle-based buttons.
-Single player mode that is challenges (known opponents) to master the game with and earn achievements (in addition to 'skirmish').
+++ /dev/null
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtQml module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-import QtQuick 2.0
-import QtQuick.Particles 2.0
-
-Item {
- id: container
- property variant target: {"y": -90, "x":12}
- property Item targetObj: container
- property Item hardpoint: container
- property ParticleSystem system
- property int blasts: 16
- property int bonusBlasts: 12
- property bool show: true
-
- width: 24
- height: 24
- Emitter {
- id: visualization
- group: "blaster"
- system: container.system
- enabled: show
- anchors.fill: parent
- shape: EllipseShape {}
- speed: TargetDirection { targetX: width/2; targetY: width/2; magnitude: -1; proportionalMagnitude: true}
- lifeSpan: 1000
- emitRate: 64
-
- size: 24
- sizeVariation: 24
- endSize: 0
- }
-
- property int blastsLeft: 0
- function fireAt(targetArg, container) {
- target = container.mapFromItem(targetArg, targetArg.width/2, targetArg.height/2);
- targetObj = targetArg;
- hardpoint = container;
- blastsLeft = blasts;
- rofTimer.repeat = true;
- rofTimer.start();
- }
- Timer {
- id: rofTimer
- interval: 30;//Has to be greater than 1 frame or they stack up
- running: false
- repeat: false
- onTriggered: {
- if (targetObj.hp <= 0)
- return;
- //TODO: calculate hit and damage at target, which must be a Ship
- var hit;
- if (blastsLeft >= bonusBlasts)
- hit = Math.random() > targetObj.dodge;
- else
- hit = false; //purely aesthetic shots, because the damage isn't that fine grained
- if (hit == true) {
- switch (targetObj.shipType) {
- case 1: hardpoint.damageDealt += 4; break;
- case 2: hardpoint.damageDealt += 5; break;
- case 3: hardpoint.damageDealt += 1; break;
- default: hardpoint.damageDealt += 100;
- }
- }
- blastVector.targetX = target.x;
- blastVector.targetY = target.y;
- if (!hit) {//TODO: Actual targetVariation
- blastVector.targetX += (128 * Math.random() - 64);
- blastVector.targetY += (128 * Math.random() - 64);
- }
- emitter.burst(1);
- blastsLeft--;
- if (!blastsLeft)
- rofTimer.repeat = false;
- }
- }
- Emitter {
- id: emitter
- group: "blaster"
- enabled: false
- system: container.system
- anchors.centerIn: parent
-
- lifeSpan: 1000
- emitRate: 16
- maximumEmitted: blasts
- size: 24
- endSize:16
- sizeVariation: 8
- speed: TargetDirection {
- id: blastVector
- targetX: target.x; targetY: target.y; magnitude: 1.1; proportionalMagnitude: true
- }
- }
-}
+++ /dev/null
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtQml module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-import QtQuick 2.0
-
-//TODO: Add particles to this component too
-Rectangle {
- id: container
- property alias text: txt.text
- signal clicked
- //color: "lightsteelblue"
- gradient: Gradient {
- GradientStop { position: 0.0; color: "lightsteelblue" }
- GradientStop { position: 1.0; color: "steelblue" }
- }
- height: 64
- radius: 16
- width: 128
- Text {
- id: txt
- anchors.centerIn: parent
- font.pixelSize: 24
- color: "white"
- }
- MouseArea {
- anchors.fill: parent
- onClicked: container.clicked()
- }
-}
+++ /dev/null
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtQml module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-import QtQuick 2.0
-import QtQuick.Particles 2.0
-
-Item {
- id: container
- property variant target: {"y": -90, "x":12}
- property ParticleSystem system
- property bool show: true
-
- width: 24
- height: 24
- Emitter {
- id: visualization
- group: "cannon"
- enabled: container.show
- system: container.system
- anchors.centerIn: parent
- lifeSpan: 2000
- emitRate: 1
-
- size: 4
- endSize: 0
- }
-
- function fireAt(targetArg, hardpoint) {
- target = container.mapFromItem(targetArg, targetArg.width/2, targetArg.height/2);
- if (container.hp <= 0 || targetArg.hp <= 0)
- return;
- //TODO: calculate hit and damage at target, which must be a Ship
- var hit = Math.random() > targetArg.dodge
- if (hit) {
- switch (targetArg.shipType) {
- case 1: hardpoint.damageDealt += 8; break;
- case 2: hardpoint.damageDealt += 10; break;
- case 3: hardpoint.damageDealt += 16; break;
- default: hardpoint.damageDealt += 1000;
- }
- }
- emitter.burst(1);
- }
- Emitter {
- id: emitter
- group: "cannon"
- enabled: false
- system: container.system
- anchors.centerIn: parent
-
- lifeSpan: 1000
- emitRate: 1
- size: 8
- endSize: 4
- speed: TargetDirection {
- id: blastVector
- targetX: target.x; targetY: target.y; magnitude: 1.1; proportionalMagnitude: true
- }
- }
-}
+++ /dev/null
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtQml module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-import QtQuick 2.0
-import QtQuick.Particles 2.0
-
-Item {
- id: container
- width: 360
- height: 160
- property ParticleSystem system
- Ship {
- id: nully
- system: system
- }
- property Item target: nully
- /*
- Component.onCompleted: {
- container.target.shipType = 1
- container.target.gunType = 1
- }
- */
- Row {
- anchors.horizontalCenter: parent.horizontalCenter
- height: parent.height
- spacing: 8
- Button {
- width: 80
- height: 80
- anchors.verticalCenter: parent.verticalCenter
- text: "Cycle\nShip"
- onClicked: {
- var nextVal = container.target.shipType;
- if(nextVal == 3)
- nextVal = 1;
- else
- nextVal++;
- container.target.shipType = nextVal;
- }
- }
- Item {
- width: 128
- height: 128
- anchors.verticalCenter: parent.verticalCenter
- Ship {
- hp: 20
- anchors.centerIn: parent
- shipType: container.target.shipType
- gunType: container.target.gunType
- system: container.system
- }
- }
- Button {
- width: 80
- height: 80
- anchors.verticalCenter: parent.verticalCenter
- text: "Cycle\nGun"
- onClicked: {
- var nextVal = container.target.gunType;
- if(nextVal == 3)
- nextVal = 1;
- else
- nextVal++;
- container.target.gunType = nextVal;
- }
- }
- }
-}
+++ /dev/null
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtQml module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-import QtQuick 2.0
-import QtQuick.Particles 2.0
-
-Item {
- id: container
- property int maxHP: 100
- property int hp: maxHP
- property real initialDodge: 0.01
- property real dodge: initialDodge
- onHpChanged: if(hp <= 0) target = container;
- property ParticleSystem system//TODO: Ship abstraction
- property Item target: container
- property string shipParticle: "default"//Per team colors?
- property int gunType: 0
- width: 128
- height: 128
- Emitter {
- //TODO: Cooler would be an 'orbiting' affector
- //TODO: On the subject, opacity and size should be grouped type 'overLife' if we can cram that in the particles
- system: container.system
- group: container.shipParticle
- anchors.centerIn: parent
- width: 64
- height: 64
- shape: EllipseShape {}
-
- emitRate: hp > 0 ? hp * 1 + 20 : 0
- lifeSpan: 2400
- maximumEmitted: (maxHP * 1 + 20)*2.4
-
- size: 48
- sizeVariation: 16
- endSize: 16
-
- speed: AngleDirection {angleVariation:360; magnitudeVariation: 32}
- }
- Emitter {
- system: container.system
- group: "cruiserArmor"
- anchors.fill: parent
- shape: EllipseShape { fill: false }
- enabled: hp>0
-
- emitRate: 16
- lifeSpan: 2000
-
- size: 48
- sizeVariation: 24
-
- SpriteGoal {
- id: destructor
- system: container.system
- enabled: container.hp <=0
- anchors.fill: parent
- groups: ["cruiserArmor"]
- goalState: "death"
-// jump: true
- once: true
- }
- }
-
- Timer {
- id: fireControl
- property int next: Math.floor(Math.random() * 3) + 1
- interval: 800
- running: root.readySetGo
- repeat: true
- onTriggered: {
- if (next == 1) {
- gun1.fireAt(container.target);
- next = Math.floor(Math.random() * 3) + 1;
- } else if (next == 2) {
- gun2.fireAt(container.target);
- next = Math.floor(Math.random() * 3) + 1;
- } else if (next == 3) {
- gun3.fireAt(container.target);
- next = Math.floor(Math.random() * 3) + 1;
- }
- }
- }
-
- Hardpoint {//TODO: Hardpoint abstraction
- x: 112 - 12 - 8*2
- y: 128 - 12 - 12*2
- id: gun1
- system: container.system
- show: hp > 0
- hardpointType: gunType
- }
- Hardpoint {
- x: 64 - 12
- y: 0 - 12 + 12*2
- id: gun2
- system: container.system
- show: hp > 0
- hardpointType: gunType
- }
- Hardpoint {
- x: 16 - 12 + 8*2
- y: 128 - 12 - 12*2
- id: gun3
- system: container.system
- show: hp > 0
- hardpointType: gunType
- }
-}
+++ /dev/null
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtQml module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-import QtQuick 2.0
-import QtQuick.Particles 2.0
-
-Item {
- id: container
- property int maxHP: 100
- property int hp: maxHP
- property real initialDodge: 0.2
- property real dodge: initialDodge
- onHpChanged: if(hp <= 0) target = container;
- property ParticleSystem system//TODO: Ship abstraction
- property Item target: container
- property string shipParticle: "default"//Per team colors?
- property int gunType: 0
- width: 128
- height: 128
- Emitter {
- system: container.system
- group: "frigateShield"
- anchors.centerIn: parent
- size: 92
- emitRate: 1
- lifeSpan: 4800
- enabled: hp > 0
- }
- Emitter {
- system: container.system
- group: container.shipParticle
- anchors.centerIn: parent
- width: 64
- height: 16
- shape: EllipseShape {}
-
- size: 16
- sizeVariation: 8
- endSize: 8
- emitRate: hp > 0 ? hp * 1 + 20 : 0
- lifeSpan: 1200
- maximumEmitted: (maxHP * 1 + 20)*2
- }
- Timer {
- id: fireControl
- property int next: Math.floor(Math.random() * 2) + 1
- interval: 800
- running: root.readySetGo
- repeat: true
- onTriggered: {
- if (next == 1) {
- gun1.fireAt(container.target);
- next = Math.floor(Math.random() * 2) + 1;
- } else if (next == 2) {
- gun2.fireAt(container.target);
- next = Math.floor(Math.random() * 2) + 1;
- }
- }
- }
-
- Hardpoint {
- x: 128 - 32 - 12
- y: 64 - 12
- id: gun1
- system: container.system
- show: hp > 0
- hardpointType: gunType
- }
- Hardpoint {
- x: 0 + 32 - 12
- y: 64 - 12
- id: gun2
- system: container.system
- show: hp > 0
- hardpointType: gunType
- }
-}
+++ /dev/null
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtQml module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-import QtQuick 2.0
-import QtQuick.Particles 2.0
-
-Item {
- id: container
- //ReflectiveProperties
- //TransferredProperties
- property variant target: {"y": -90, "x":12}
- property ParticleSystem system
- property bool show: true
- property int hardpointType: 0 //default is pea shooter - always bad.
-
- property Item targetObj: null
- property int damageDealt: 0
- onDamageDealtChanged: dealDamageTimer.start();
- Timer {
- id: dealDamageTimer
- interval: 16
- running: false
- repeat: false
- onTriggered: {targetObj.hp -= damageDealt; damageDealt = 0;}
- }
- width: 24
- height: 24
- function fireAt(targetArg) {//Each implement own
- if (targetArg != null) {
- hardpointLoader.item.fireAt(targetArg, container);
- targetObj = targetArg;
- }
- }
- Loader {
- id: hardpointLoader
- sourceComponent: {
- switch (hardpointType) {
- case 1: laserComponent; break;
- case 2: blasterComponent; break;
- case 3: cannonComponent; break;
- default: emptyComponent;
- }
- }
- }
- Component {
- id: laserComponent
- LaserHardpoint {
- target: container.target
- system: container.system
- show: container.show
- }
- }
- Component {
- id: blasterComponent
- BlasterHardpoint {
- target: container.target
- system: container.system
- show: container.show
- }
- }
- Component {
- id: cannonComponent
- CannonHardpoint {
- target: container.target
- system: container.system
- show: container.show
- }
- }
- Component {
- id: emptyComponent
- Item {
- function fireAt(obj) {
- console.log("Firing null weapon. It hurts.");
- }
- }
- }
-}
+++ /dev/null
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtQml module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-import QtQuick 2.0
-import QtQuick.Particles 2.0
-
-SequentialLoader {
- id: hLdr
- signal exitDesired
- Component.onCompleted: advance();
- ParticleSystem { id: helpSystem }
- PlasmaPatrolParticles { sys: helpSystem }
- pages: [
- Component {Item {
- id: story
- Text {
- color: "white"
- text: "Story"
- font.pixelSize: 48
- }
- /*
- Flickable {
- y: 60
- width: 360
- height: 500
- contentHeight: txt1.height
- contentWidth: 360//TODO: Less magic numbers?
- */
- Text {
- id: txt1
- color: "white"
- y: 60
- font.pixelSize: 18
- text: "
-In a remote nebula, a race of energy beings formed and lived prosperous lives for millenia. Until the schism - when they became constantly at each other's energy-throats. War soon followed, crippling both sides, until a truce was formed. But while governments knew the desparate need for peace, the soldiers in the ion-field were still filled with rampant bloodlust. On the border, patrols are constantly engaging in minor skirmishes whenever they cross paths.
-
-You must select one such patrol unit for the border, heading into an inevitable skirmish, in Plasma Patrol: the game of energy being spaceship combat!
- "
- width: 360
- wrapMode: Text.WordWrap
- }
- // }
- Button {
- x: 20
- y: 560
- height: 40
- width: 120
- text: "Next"
- onClicked: hLdr.advance();
- }
- Button {
- x: 220
- y: 560
- height: 40
- width: 120
- text: "Menu"
- onClicked: hLdr.exitDesired();
- }
- }},
- Component {Item {
- id: ships
- Text {
- color: "white"
- text: "Vessels"
- font.pixelSize: 48
- }
- Column {
- spacing: 16
- y: 60
- Row {
- height: 128
- Sloop {
- system: helpSystem
- }
- Text {
- text: "The nimble sloop"
- color: "white"
- font.pixelSize: 18
- }
- }
- Row {
- height: 128
- Frigate {
- system: helpSystem
- }
- Text {
- text: "The versitile shield frigate"
- color: "white"
- font.pixelSize: 18
- }
- }
- Row {
- height: 128
- Cruiser {
- system: helpSystem
- }
- Text {
- text: "The armored cruiser"
- color: "white"
- font.pixelSize: 18
- }
- }
- }
- Button {
- x: 20
- y: 560
- height: 40
- width: 120
- text: "Next"
- onClicked: hLdr.advance();
- }
- Button {
- x: 220
- y: 560
- height: 40
- width: 120
- text: "Menu"
- onClicked: hLdr.exitDesired();
- }
- }},
- Component {Item {
- id: guns
- Text {
- color: "white"
- text: "Hardpoints"
- font.pixelSize: 48
- }
- Column {
- spacing: 16
- y: 60
- Row {
- height: 128
- LaserHardpoint {
- system: helpSystem
- }
- Text {
- text: "The laser hardpoint almost always hits the target, even the nimble sloop, but loses much of its potency against the frigate's shields"
- width: 332
- wrapMode: Text.WordWrap
- color: "white"
- font.pixelSize: 18
- }
- }
- Row {
- height: 128
- BlasterHardpoint {
- system: helpSystem
- }
- Text {
- text: "The blaster passes right through the frigate's shields but loses much of its impact against the armor of the cruiser"
- width: 332
- wrapMode: Text.WordWrap
- color: "white"
- font.pixelSize: 18
- }
- }
- Row {
- height: 128
- CannonHardpoint {
- system: helpSystem
- }
- Text {
- text: "The cannon has poor accuracy, often missing the nimble sloop, but can punch right through the armor of the cruiser"
- width: 332
- wrapMode: Text.WordWrap
- color: "white"
- font.pixelSize: 18
- }
- }
- }
- Button {
- x: 20
- y: 560
- height: 40
- width: 120
- text: "Next"
- onClicked: hLdr.advance();
- }
- Button {
- x: 220
- y: 560
- height: 40
- width: 120
- text: "Menu"
- onClicked: hLdr.exitDesired();
- }
- }},
- Component {Item {
- id: strategy
- Text {
- color: "white"
- text: "Strategy"
- font.pixelSize: 48
- }
- Flickable {
- y: 60
- width: 360
- height: 500
- contentHeight: txt1.height
- contentWidth: 360//TODO: Less magic numbers?
- Text {
- id: txt1
- color: "white"
- font.pixelSize: 18
- text: "
-Basic Strategy: Good luck, have fun - don't die.
-More to come after thorough playtesting.
- "
- width: 360
- wrapMode: Text.WordWrap
- }
- }
- Button {
- x: 20
- y: 560
- height: 40
- width: 120
- text: "Story"
- onClicked: {hLdr.at=0; hLdr.advance();}
- }
- Button {
- x: 220
- y: 560
- height: 40
- width: 120
- text: "Menu"
- onClicked: hLdr.exitDesired();
- }
- }}
- ]
-}
+++ /dev/null
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtQml module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-import QtQuick 2.0
-import QtQuick.Particles 2.0
-
-Item {
- id: container
- property variant target: {"y": -90, "x":12}
- property ParticleSystem system
- property bool show: true
-
- width: 24
- height: 24
- Emitter {
- id: visualization
- group: "laser"
- system: container.system
- anchors.fill: parent
- enabled: container.show
- shape: EllipseShape {}
- speed: TargetDirection { targetX: width/2; targetY: width/2; magnitude: -1; proportionalMagnitude: true }
- lifeSpan: 1000
- emitRate: 64
-
- size: 24
- sizeVariation: 8
- endSize: 8
- }
-
- function fireAt(targetArg, hardpoint) {
- if (targetArg.hp <= 0)
- return;
- //TODO: calculate hit and damage at target, which must be a Ship
- var offset = 0;
- if (Math.random() < 0.99) {
- switch (targetArg.shipType) {
- case 1: hardpoint.damageDealt += 16; break;
- case 2: hardpoint.damageDealt += 4; break;
- case 3: hardpoint.damageDealt += 8; break;
- default: hardpoint.damageDealt += 500; //Really effective against unregistered vessels
- }
- } else {//Misses with Lasers are really rare
- offset = Math.random() * 100;
- }
- target = container.mapFromItem(targetArg, offset + targetArg.width/2, offset + targetArg.height/2);
- emitter.pulse(100);
- // console.log("Fire box: " + Math.min(container.width/2, target.x) + "," + Math.min(container.height/2, target.y) + " " + (Math.max(container.width/2, target.x) - Math.min(container.width/2, target.x)) + "," + (Math.max(container.height/2, target.y) - Math.min(container.height/2, target.y)));
- }
- Emitter {
- id: emitter
- group: "laser"
- enabled: false
- system: container.system
- x: Math.min(container.width/2, target.x);
- width: Math.max(container.width/2, target.x) - x;
- y: Math.min(container.height/2, target.y);
- height: Math.max(container.height/2, target.y) - y;
- shape: LineShape {
- mirrored: (emitter.y < 0 || emitter.x < 0) && !(emitter.y < 0 && emitter.x < 0 )//I just want XOR
- }
-
- lifeSpan: 1000
- emitRate: 8000
- maximumEmitted: 800
- size: 16
- endSize: 0
-
- speed: PointDirection {xVariation: 4; yVariation: 4}
- }
-}
+++ /dev/null
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtQml module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-import QtQuick 2.0
-import QtQuick.Particles 2.0
-
-Item {
- property ParticleSystem sys
- ImageParticle {
- system: sys
- groups: ["default"]
- source: "pics/blur-circle3.png"
- color: "#003A3A3A"
- colorVariation: 0.1
- z: 0
- }
- ImageParticle {
- system: sys
- groups: ["redTeam"]
- source: "pics/blur-circle3.png"
- color: "#0028060A"
- colorVariation: 0.1
- z: 0
- }
- ImageParticle {
- system: sys
- groups: ["greenTeam"]
- source: "pics/blur-circle3.png"
- color: "#0006280A"
- colorVariation: 0.1
- z: 0
- }
- ImageParticle {
- system: sys
- groups: ["blaster"]
- source: "pics/star2.png"
- //color: "#0F282406"
- color: "#0F484416"
- colorVariation: 0.2
- z: 2
- }
- ImageParticle {
- system: sys
- groups: ["laser"]
- source: "pics/star3.png"
- //color: "#00123F68"
- color: "#00428FF8"
- colorVariation: 0.2
- z: 2
- }
- ImageParticle {
- system: sys
- groups: ["cannon"]
- source: "pics/particle.png"
- color: "#80FFAAFF"
- colorVariation: 0.1
- z: 2
- }
- ImageParticle {
- system: sys
- groups: ["cannonCore"]
- source: "pics/particle.png"
- color: "#00666666"
- colorVariation: 0.8
- z: 1
- }
- ImageParticle {
- system: sys
- groups: ["cannonWake"]
- source: "pics/star.png"
- color: "#00CCCCCC"
- colorVariation: 0.2
- z: 1
- }
- ImageParticle {
- system: sys
- groups: ["frigateShield"]
- source: "pics/blur-circle2.png"
- color: "#00000000"
- colorVariation: 0.05
- blueVariation: 0.5
- greenVariation: 0.1
- z: 3
- }
- ImageParticle {
- system: sys
- groups: ["cruiserArmor"]
- z: 1
- sprites:[Sprite {
- id: spinState
- name: "spinning"
- source: "pics/meteor.png"
- frameCount: 35
- frameDuration: 40
- to: {"death":0, "spinning":1}
- },Sprite {
- name: "death"
- source: "pics/meteor_explo.png"
- frameCount: 22
- frameDuration: 40
- to: {"null":1}
- }, Sprite {
- name: "null"
- source: "pics/nullRock.png"
- frameCount: 1
- frameDuration: 1000
- }
- ]
- }
- TrailEmitter {
- system: sys
- group: "cannonWake"
- follow: "cannon"
- emitRatePerParticle: 64
- lifeSpan: 600
- speed: AngleDirection { angleVariation: 360; magnitude: 48}
- size: 16
- endSize: 8
- sizeVariation: 2
- enabled: true
- width: 1000//XXX: Terrible hack
- height: 1000
- }
- TrailEmitter {
- system: sys
- group: "cannonCore"
- follow: "cannon"
- emitRatePerParticle: 256
- lifeSpan: 128
- size: 24
- endSize: 8
- enabled: true
- width: 1000//XXX: Terrible hack
- height: 1000
- }
-}
+++ /dev/null
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtQml module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-import QtQuick 2.0
-
-Item {
- id: container
- //TODO: Somehow get particles into this?
- property list<Component> pages
- property Item cur: null
- property int at: 0
- function advance() {
- if(cur != null)
- cur.destroy();
- cur = pages[at++].createObject(container);
- }
-}
+++ /dev/null
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtQml module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-import QtQuick 2.0
-import QtQuick.Particles 2.0
-
-Item {
- id: me
- //Reflective Properties
- width: shipLoader.width
- height: shipLoader.height
- //Transfered Properties
- property int hp: 100//shipLoader.item.maxHP
- property real dodge: shipLoader.item.initialDodge
- property ParticleSystem system
- property int targetIdx: 0
- property Item target: targets[targetIdx] == undefined?null:targets[targetIdx]
- Connections {
- target: me.target
- onHpChanged: if (me.target.hp<=0) me.targetIdx++;
- }
- property list<Item> targets
- property string shipParticle: "default"//Per team colors?
- property int gunType: 0
- property int shipType: 0
- Component {
- id: sloopComp
- Sloop {
- system: me.system
- target: me.target
- shipParticle: me.shipParticle
- gunType: me.gunType
- hp: me.hp
- dodge: me.dodge
- }
- }
- Component {
- id: frigateComp
- Frigate {
- system: me.system
- target: me.target
- shipParticle: me.shipParticle
- gunType: me.gunType
- hp: me.hp
- dodge: me.dodge
- }
- }
- Component {
- id: cruiserComp
- Cruiser {
- system: me.system
- target: me.target
- shipParticle: me.shipParticle
- gunType: me.gunType
- hp: me.hp
- dodge: me.dodge
- }
- }
- Component {
- id: dumbComp
- Item {
- property int maxHP: 0
- property int initialDodge: 0
- }
- }
- Loader {
- id: shipLoader
- sourceComponent: {
- switch (shipType) {
- case 1: sloopComp; break;
- case 2: frigateComp; break;
- case 3: cruiserComp; break;
- default: dumbComp;
- }
- }
- }
-}
+++ /dev/null
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtQml module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-import QtQuick 2.0
-import QtQuick.Particles 2.0
-
-Item {
- id: container
- property int maxHP: 100
- property int hp: maxHP
- property real initialDodge: 0.5
- property real dodge: initialDodge
- property int blinkInterval: 800
- onHpChanged: if(hp <= 0) target = container;
- property ParticleSystem system//TODO: Ship abstraction
- property Item target: container
- property string shipParticle: "default"//Per team colors?
- property int gunType: 0
- width: 128
- height: 128
- Emitter {
- id: emitter
- //TODO: Cooler would be an 'orbiting' affector
- //TODO: On the subject, opacity and size should be grouped type 'overLife' if we can cram that in the particles
- system: container.system
- group: container.shipParticle
- shape: EllipseShape {}
-
- emitRate: hp > 0 ? hp + 20 : 0
- lifeSpan: blinkInterval
- maximumEmitted: (maxHP + 20)
-
- acceleration: AngleDirection {angleVariation: 360; magnitude: 8}
-
- size: 24
- endSize: 4
- sizeVariation: 8
- width: 16
- height: 16
- x: 64
- y: 64
- Behavior on x {NumberAnimation {duration:blinkInterval}}
- Behavior on y {NumberAnimation {duration:blinkInterval}}
- Timer {
- interval: blinkInterval
- running: true
- repeat: true
- onTriggered: {
- emitter.x = Math.random() * 48 + 32
- emitter.y = Math.random() * 48 + 32
- }
- }
- }
- Hardpoint {
- anchors.centerIn: parent
- id: gun2
- system: container.system
- show: container.hp > 0
- hardpointType: gunType
- }
- Timer {
- id: fireControl
- interval: 800
- running: root.readySetGo
- repeat: true
- onTriggered: {
- gun2.fireAt(container.target);
- }
- }
-
-}
+++ /dev/null
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtQml module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-import QtQuick 2.0
-import QtQuick.Particles 2.0
-import "content"
-
-Rectangle {
- id: root
- property bool readySetGo: false
- //Debugging
- property int hits: 0
- property int misses: 0
- property real ratio: hits/(misses?misses:1)
- //Move to JS file?
- property Ship redVar1: Ship {shipType: 1; gunType: 1}
- property Ship redVar2: Ship {shipType: 1; gunType: 2}
- property Ship redVar3: Ship {shipType: 1; gunType: 3}
- property Ship greenVar1: Ship {shipType: 3; gunType: 1}
- property Ship greenVar2: Ship {shipType: 2; gunType: 2}
- property Ship greenVar3: Ship {shipType: 1; gunType: 3}
- property string winner: "0"
- property int players: 0
- function aiSet(ship) {
- ship.gunType = Math.floor(Math.random() * 3) + 1
- ship.shipType = Math.floor(Math.random() * 3) + 1
- }
-
- width: 360
- height: 600
- color: "black"
- SequentialLoader {
- anchors.fill: parent
- //General Children
- Image {
- anchors.centerIn: parent
- source: "../images/finalfrontier.png"
- }
- ParticleSystem {
- id: particles
- }
- PlasmaPatrolParticles { sys: particles; z: 100 }//Renders all particles on the one plane
- //Component parts
- id: pageControl
- Component.onCompleted: advance();
- pages:[
- Component {Item {
- id: menu
- width: root.width
- height: root.height
- Column {
- anchors.verticalCenter: parent.verticalCenter
- width: parent.width
- spacing: 8
- Item {
- id: title
- width: root.width
- height: 240
- Emitter {
- anchors.fill: parent
- system: particles
- enabled: true
- group: "default"
- emitRate: 1200
- lifeSpan: 1200
- shape: MaskShape {source:"content/pics/TitleText.png"}
- size: 16
- endSize: 0
- sizeVariation: 8
- speed: AngleDirection {angleVariation:360; magnitudeVariation: 6}
- }
- }
- Button {
- text: "1P"
- onClicked: {root.players = 1; pageControl.advance();}
- anchors.horizontalCenter: parent.horizontalCenter
- }
- Button {
- text: "2P"
- onClicked: {root.players = 2; pageControl.advance();}
- anchors.horizontalCenter: parent.horizontalCenter
- }
- Button {
- text: "Demo"
- anchors.horizontalCenter: parent.horizontalCenter
- onClicked: {root.players = 0;
- aiSet(redVar1);
- aiSet(redVar2);
- aiSet(redVar3);
- aiSet(greenVar1);
- aiSet(greenVar2);
- aiSet(greenVar3);
- pageControl.at = 5;//TODO: Not a magic number
- pageControl.advance();}
- }
- Button {
- text: "Help"
- anchors.horizontalCenter: parent.horizontalCenter
- onClicked: {
- pageControl.at = 7;//TODO: Not a magic number
- pageControl.advance();
- }
- }
- Button {
- text: "Quit"
- anchors.horizontalCenter: parent.horizontalCenter
- onClicked: Qt.quit();
- }
- }
- }},
- Component {Item {
- id: p1Screen
- z: 101
- width: root.width
- height: root.height
- Rectangle {
- anchors.fill: parent
- color: "red"
- }
- Text {
- anchors.centerIn: parent
- color: "white"
- font.pixelSize: 64
- font.bold: true
- text: "Player\n 1"
- horizontalAlignment: Text.AlignHCenter
- }
- MouseArea {
- anchors.fill: parent
- onClicked: pageControl.advance()
- }
- }},
- Component {Item {
- id: p1Choices
- z: 3
- width: root.width
- height: root.height
- Rectangle {
- color: "black"
- anchors.fill: parent
- }
- Column {
- spacing: 16
- width: root.width
- anchors.horizontalCenter: parent.horizontalCenter
- ChoiceBox {
- target: redVar1
- system: particles
- }
- ChoiceBox {
- target: redVar2
- system: particles
- }
- ChoiceBox {
- target: redVar3
- system: particles
- }
- Button {
- anchors.horizontalCenter: parent.horizontalCenter
- text: "Next"
- onClicked: {
- if (root.players < 2) {
- aiSet(greenVar1);
- aiSet(greenVar2);
- aiSet(greenVar3);
- pageControl.at = 5;//TODO: Not a magic number
- }
- pageControl.advance();
- }
- }
- }
- }},
- Component {Item {
- id: p2Screen
- z: 101
- width: root.width
- height: root.height
- Rectangle {
- anchors.fill: parent
- color: "green"
- }
- Text {
- anchors.centerIn: parent
- color: "white"
- font.pixelSize: 64
- font.bold: true
- text: "Player\n 2"
- horizontalAlignment: Text.AlignHCenter
- }
- MouseArea {
- anchors.fill: parent
- onClicked: pageControl.advance()
- }
- }},
- Component {Item {
- id: p2Choices
- z: 1
- width: root.width
- height: root.height
- Rectangle {
- color: "black"
- anchors.fill: parent
- }
- Column {
- spacing: 16
- width: root.width
- anchors.horizontalCenter: parent.horizontalCenter
- ChoiceBox {
- target: greenVar1
- system: particles
- }
- ChoiceBox {
- target: greenVar2
- system: particles
- }
- ChoiceBox {
- target: greenVar3
- system: particles
- }
- Button {
- anchors.horizontalCenter: parent.horizontalCenter
- text: "Next"
- onClicked: pageControl.advance()
- }
- }
- }},
- Component {Item {
- id: arena
- width: root.width
- height: root.height
- z: 0
- Component.onCompleted: root.readySetGo = true
- Component.onDestruction: root.readySetGo = false
- property bool victory: redShip3.hp <= 0 || greenShip3.hp <=0
- onVictoryChanged: {
- if (redShip3.hp <= 0) {
- if (greenShip3.hp <= 0) {
- root.winner = "1&2"
- }else {
- root.winner = "2"
- }
- } else {
- root.winner = "1"
- }
- winTimer.start()
- }
- Timer {
- id: winTimer
- interval: 1200
- repeat: false
- running: false
- onTriggered: pageControl.advance();
- }
- Ship {
- id: redShip1
- shipParticle: "redTeam"
- system: particles
- x: 180-64
- y: 128
- shipType: redVar1.shipType
- gunType: redVar1.gunType
- targets: [greenShip1, greenShip2, greenShip3]
- }
- Ship {
- id: redShip2
- shipParticle: "redTeam"
- system: particles
- x: 0
- y: 0
- shipType: redVar2.shipType
- gunType: redVar2.gunType
- targets: [greenShip1, greenShip2, greenShip3]
- }
- Ship {
- id: redShip3
- shipParticle: "redTeam"
- system: particles
- x: 360-128
- y: 0
- shipType: redVar3.shipType
- gunType: redVar3.gunType
- targets: [greenShip1, greenShip2, greenShip3]
- }
-
- Ship {
- id: greenShip1
- shipParticle: "greenTeam"
- system: particles
- x: 180-64
- y: 600 - 128 - 128
- shipType: greenVar1.shipType
- gunType: greenVar1.gunType
- targets: [redShip1, redShip2, redShip3]
- }
- Ship {
- id: greenShip2
- shipParticle: "greenTeam"
- system: particles
- x: 0
- y: 600-128
- shipType: greenVar2.shipType
- gunType: greenVar2.gunType
- targets: [redShip1, redShip2, redShip3]
- }
- Ship {
- id: greenShip3
- shipParticle: "greenTeam"
- system: particles
- x: 360 - 128
- y: 600 - 128
- shipType: greenVar3.shipType
- gunType: greenVar3.gunType
- targets: [redShip1, redShip2, redShip3]
- }
- }},
- Component {Item {
- id: winScreen
- z: 101
- width: root.width
- height: root.height
- /*
- Rectangle {
- anchors.fill: parent
- color: "black"
- }
- */
- Text {//TODO: Particle Text?
- anchors.fill: parent
- color: "white"
- font.pixelSize: 64
- font.bold: true
- text: "Player " + root.winner + " wins!"
- wrapMode: Text.WordWrap
- horizontalAlignment: Text.AlignHCenter
- verticalAlignment: Text.AlignVCenter
- }
- MouseArea {
- anchors.fill: parent
- onClicked: {pageControl.at = 0; pageControl.advance();}
- }
- }},
- Component {
- HelpScreens {
- onExitDesired: {pageControl.at = 0; pageControl.advance();}
- }
- }
- ]
- }
-}
+++ /dev/null
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtQml module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-
-Rectangle {
- id: container
-
- signal clicked
- property string text: "Button"
-
- color: activePalette.button; smooth: true
- width: txtItem.width + 20; height: txtItem.height + 6
- border.width: 1; border.color: Qt.darker(activePalette.button); radius: 8;
-
- gradient: Gradient {
- GradientStop {
- id: topGrad; position: 0.0
- color: if (mr.pressed) { activePalette.dark } else { activePalette.light } }
- GradientStop { position: 1.0; color: activePalette.button }
- }
-
- MouseArea { id: mr; anchors.fill: parent; onClicked: container.clicked() }
-
- Text {
- id: txtItem; text: container.text; anchors.centerIn: container; color: activePalette.buttonText
- }
-}
+++ /dev/null
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtQml module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-import QtQuick.Particles 2.0
-
-Item {
- id: root
- property bool dying: false
- property int row;
- property int column;
- x: margin + column * gridSize
- y: margin + row * gridSize
-
- width: gridSize
- height: gridSize
- property int value : 1;
-
- Image {
- id: img
- anchors.fill: parent
- source: "pics/cookie.png"
- opacity: 0
- Text {
- font.bold: true
- anchors.verticalCenter: parent.verticalCenter
- anchors.horizontalCenter: parent.horizontalCenter
- text: value
- }
- }
-
-
- ParticleSystem {
- width:1; height:1; anchors.centerIn: parent;
- ImageParticle {
- groups: ["star"]
- source: "pics/yellowStar.png"
- }
- Emitter {
- id: particles
- anchors.fill: parent
- group: "star"
- emitRate: 50
- enabled: false
- lifeSpan: 700
- acceleration: AngleDirection { angleVariation: 360; magnitude: 200 }
- }
- }
-
- states: [
- State{ name: "AliveState"; when: dying == false
- PropertyChanges { target: img; opacity: 1 }
- },
- State{ name: "DeathState"; when: dying == true
- StateChangeScript { script: particles.burst(50); }
- PropertyChanges { target: img; opacity: 0 }
- }
- ]
- transitions: [
- Transition {
- NumberAnimation { target: img; property: "opacity"; duration: 100 }
- }
- ]
-}
+++ /dev/null
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtQml module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-import QtQuick.LocalStorage 2.0 as Sql
-
-// Models a high score table.
-//
-// Use this component like this:
-//
-// HighScoreModel {
-// id: highScores
-// game: "MyCoolGame"
-// }
-//
-// Then use either use the top-score properties:
-//
-// Text { text: "HI: " + highScores.topScore }
-//
-// or, use the model in a view:
-//
-// ListView {
-// model: highScore
-// delegate: Component {
-// ... player ... score ...
-// }
-// }
-//
-// Add new scores via:
-//
-// saveScore(newScore)
-//
-// or:
-//
-// savePlayerScore(playerName,newScore)
-//
-// The best maxScore scores added by this method will be retained in an SQL database,
-// and presented in the model and in the topScore/topPlayer properties.
-//
-
-ListModel {
- id: model
- property string game: ""
- property int topScore: 0
- property string topPlayer: ""
- property int maxScores: 10
-
- function __db()
- {
- return Sql.openDatabaseSync("HighScoreModel", "1.0", "Generic High Score Functionality for QML", 1000000);
- }
- function __ensureTables(tx)
- {
- tx.executeSql('CREATE TABLE IF NOT EXISTS HighScores(game TEXT, score INT, player TEXT)', []);
- }
-
- function fillModel() {
- __db().transaction(
- function(tx) {
- __ensureTables(tx);
- var rs = tx.executeSql("SELECT score,player FROM HighScores WHERE game=? ORDER BY score DESC", [game]);
- model.clear();
- if (rs.rows.length > 0) {
- topScore = rs.rows.item(0).score
- topPlayer = rs.rows.item(0).player
- for (var i=0; i<rs.rows.length; ++i) {
- if (i < maxScores)
- model.append(rs.rows.item(i))
- }
- if (rs.rows.length > maxScores)
- tx.executeSql("DELETE FROM HighScores WHERE game=? AND score <= ?",
- [game, rs.rows.item(maxScores).score]);
- }
- }
- )
- }
-
- function savePlayerScore(player,score) {
- __db().transaction(
- function(tx) {
- __ensureTables(tx);
- tx.executeSql("INSERT INTO HighScores VALUES(?,?,?)", [game,score,player]);
- fillModel();
- }
- )
- }
-
- function saveScore(score) {
- savePlayerScore("player",score);
- }
-
- function clearScores() {
- __db().transaction(
- function(tx) {
- tx.executeSql("DELETE FROM HighScores WHERE game=?", [game]);
- fillModel();
- }
- )
- }
-
- Component.onCompleted: { fillModel() }
-}
+++ /dev/null
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtQml module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-import QtQuick.Particles 2.0
-
-Item { id:link
- property bool dying: false
- property bool spawned: false
- property int type: 0
- property int row: 0
- property int column: 0
- property int rotation;
-
- width: 40;
- height: 40
-
- x: margin - 3 + gridSize * column
- y: margin - 3 + gridSize * row
- Behavior on x { NumberAnimation { duration: spawned ? heartbeatInterval : 0} }
- Behavior on y { NumberAnimation { duration: spawned ? heartbeatInterval : 0 } }
-
-
- Item {
- id: img
- anchors.fill: parent
- Image {
- source: {
- if(type == 1) {
- "pics/blueStone.png";
- } else if (type == 2) {
- "pics/head.png";
- } else {
- "pics/redStone.png";
- }
- }
-
- transform: Rotation {
- id: actualImageRotation
- origin.x: width/2; origin.y: height/2;
- angle: rotation * 90
- Behavior on angle {
- RotationAnimation{
- direction: RotationAnimation.Shortest
- duration: spawned ? 200 : 0
- }
- }
- }
- }
-
- Image {
- source: "pics/stoneShadow.png"
- }
-
- opacity: 0
- }
-
- ParticleSystem {
- width:1; height:1; anchors.centerIn: parent;
- ImageParticle {
- groups: ["star"]
- source: type == 1 ? "pics/blueStar.png" : "pics/redStar.png"
- }
- Emitter {
- id: particles
- anchors.fill: parent
- group: "star"
- emitRate: 50
- enabled: false
- lifeSpan: 700
- acceleration: AngleDirection { angleVariation: 360; magnitude: 200 }
- }
- }
-
- states: [
- State{ name: "AliveState"; when: spawned == true && dying == false
- PropertyChanges { target: img; opacity: 1 }
- },
- State{ name: "DeathState"; when: dying == true
- StateChangeScript { script: particles.burst(50); }
- PropertyChanges { target: img; opacity: 0 }
- }
- ]
-
- transitions: [
- Transition {
- NumberAnimation { target: img; property: "opacity"; duration: 200 }
- }
- ]
-
-}
+++ /dev/null
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtQml module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-
-Image {
- property bool spawned: false
- property int row;
- property int column;
- property int verticalMovement;
- property int horizontalMovement;
-
- x: screen.margin + column * screen.gridSize + 2
- y: screen.margin + row * screen.gridSize - 3
- Behavior on x { NumberAnimation { duration: spawned ? screen.halfbeatInterval : 0} }
- Behavior on y { NumberAnimation { duration: spawned ? screen.halfbeatInterval : 0 } }
-
- opacity: spawned ? 1 : 0
- Behavior on opacity { NumberAnimation { duration: 200 } }
-
- source: "pics/skull.png"
- width: 24
- height: 40
-}
+++ /dev/null
-snake.jpg: This image is based on the picture "Eastern Green Mamba.jpg" from the free media databse Wikimedia Commons and is published under the terms of the GNU Free Documentation License. The original picture was taken by Danleo.
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<!-- Created with Inkscape (http://www.inkscape.org/) -->
-<svg
- xmlns:dc="http://purl.org/dc/elements/1.1/"
- xmlns:cc="http://creativecommons.org/ns#"
- xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
- xmlns:svg="http://www.w3.org/2000/svg"
- xmlns="http://www.w3.org/2000/svg"
- xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
- xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
- id="svg2"
- sodipodi:version="0.32"
- inkscape:version="0.46"
- width="40"
- height="40"
- version="1.0"
- sodipodi:docname="eyes.svg"
- inkscape:output_extension="org.inkscape.output.svg.inkscape"
- inkscape:export-filename="/home/ettrich/dev/research/qml-validate/snake/pics/eyes.png"
- inkscape:export-xdpi="90"
- inkscape:export-ydpi="90">
- <metadata
- id="metadata7">
- <rdf:RDF>
- <cc:Work
- rdf:about="">
- <dc:format>image/svg+xml</dc:format>
- <dc:type
- rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
- </cc:Work>
- </rdf:RDF>
- </metadata>
- <defs
- id="defs5">
- <inkscape:perspective
- sodipodi:type="inkscape:persp3d"
- inkscape:vp_x="0 : 526.18109 : 1"
- inkscape:vp_y="0 : 1000 : 0"
- inkscape:vp_z="744.09448 : 526.18109 : 1"
- inkscape:persp3d-origin="372.04724 : 350.78739 : 1"
- id="perspective9" />
- </defs>
- <sodipodi:namedview
- inkscape:window-height="838"
- inkscape:window-width="907"
- inkscape:pageshadow="2"
- inkscape:pageopacity="0.0"
- guidetolerance="10.0"
- gridtolerance="10.0"
- objecttolerance="10.0"
- borderopacity="1.0"
- bordercolor="#666666"
- pagecolor="#ffffff"
- id="base"
- showgrid="false"
- inkscape:zoom="12.35"
- inkscape:cx="20"
- inkscape:cy="20"
- inkscape:window-x="117"
- inkscape:window-y="45"
- inkscape:current-layer="svg2" />
- <path
- sodipodi:type="arc"
- style="fill:#ffffff;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
- id="path2384"
- sodipodi:cx="18.056681"
- sodipodi:cy="9.5141697"
- sodipodi:rx="7.1255059"
- sodipodi:ry="11.295547"
- d="M 25.182187,9.5141697 A 7.1255059,11.295547 0 1 1 10.931175,9.5141697 A 7.1255059,11.295547 0 1 1 25.182187,9.5141697 z"
- transform="matrix(1.0089865,0,0,0.5462656,-4.9233835,3.3301401)" />
- <path
- sodipodi:type="arc"
- style="fill:#ffffff;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
- id="path3158"
- sodipodi:cx="18.056681"
- sodipodi:cy="9.5141697"
- sodipodi:rx="7.1255059"
- sodipodi:ry="11.295547"
- d="M 25.182187,9.5141697 A 7.1255059,11.295547 0 1 1 10.931175,9.5141697 A 7.1255059,11.295547 0 1 1 25.182187,9.5141697 z"
- transform="matrix(1.0089865,0,0,0.5462656,9.6190931,3.3522563)" />
- <path
- sodipodi:type="arc"
- style="fill:#000000;fill-opacity:1"
- id="path3182"
- sodipodi:cx="16.275303"
- sodipodi:cy="12.307693"
- sodipodi:rx="2.2672064"
- sodipodi:ry="3.4008098"
- d="M 18.542509,12.307693 A 2.2672064,3.4008098 0 0 1 14.008446,12.367372"
- sodipodi:start="0"
- sodipodi:end="3.1240432"
- transform="translate(11.65992,-9.740891)"
- sodipodi:open="true" />
- <rect
- style="fill:#000000;fill-opacity:0"
- id="rect2382"
- width="40"
- height="40"
- x="0"
- y="-7.1054274e-15"
- inkscape:export-filename="/home/ettrich/dev/research/qml-validate/snake/pics/eyes.png"
- inkscape:export-xdpi="90"
- inkscape:export-ydpi="90" />
- <path
- sodipodi:type="arc"
- style="fill:#000000;fill-opacity:1"
- id="path2383"
- sodipodi:cx="16.275303"
- sodipodi:cy="12.307693"
- sodipodi:rx="2.2672064"
- sodipodi:ry="3.4008098"
- d="M 18.542509,12.307693 A 2.2672064,3.4008098 0 0 1 14.008446,12.367372"
- sodipodi:start="0"
- sodipodi:end="3.1240432"
- transform="translate(-3.3200119,-9.821862)"
- sodipodi:open="true" />
-</svg>
+++ /dev/null
-
-var snake = new Array;
-var board = new Array;
-var links = new Array;
-var scheduledDirections = new Array;
-var numRows = 1;
-var numColumns = 1;
-var linkComponent = Qt.createComponent("Link.qml");
-var cookieComponent = Qt.createComponent("Cookie.qml");
-var cookie;
-var linksToGrow = 0;
-var linksToDie = 0;
-var waitForCookie = 0;
-var growType = 0;
-var skullMovementsBeforeDirectionChange = 0;
-
-
-function rand(n)
-{
- return (Math.floor(Math.random() * n));
-}
-
-function scheduleDirection(dir)
-{
- if (state == "starting") {
- direction = dir;
- headDirection = direction;
- head.rotation = headDirection;
- } else if (state == "running"){
- direction = dir;
- if(scheduledDirections[scheduledDirections.length-1]!=direction)
- scheduledDirections.push(direction);
- }
-}
-
-function startNewGame()
-{
- if (state == "starting") {
- return;
- }
-
- if (activeGame) {
- endGame();
- startNewGameTimer.running = true;
- return;
- }
-
- state = "starting";
-
- numRows = numRowsAvailable;
- numColumns = numColumnsAvailable;
- board = new Array(numRows * numColumns);
- snake = new Array;
- scheduledDirections = new Array;
- growType = 0;
-
- skull.z = numRows * numColumns + 1;
-
- for (var i = 0; i < numRows * numColumns; ++i) {
- if (i < links.length) {
- var link = links[i];
- link.spawned = false;
- link.dying = false;
- } else {
- if(linkComponent.status != Component.Ready) {
- if(linkComponent.status == Component.Error)
- console.log(linkComponent.errorString());
- else
- console.log("Still loading linkComponent");
- continue;//TODO: Better error handling?
- }
- var link = linkComponent.createObject(playfield);
- link.z = numRows * numColumns + 1 - i;
- link.type = i == 0 ? 2 : 0;
- link.spawned = false;
- link.dying = false;
- links.push(link);
- }
- }
-
- head = links[0];
- snake.push(head);
- head.row = numRows/2 -1;
- head.column = numColumns/2 -1;
- head.spawned = true;
-
- linksToGrow = 5;
- linksToDie = 0;
- waitForCookie = 5;
- score = 0;
- startHeartbeatTimer.running = true;
-}
-
-function endGame()
-{
- activeGame = false;
- for(var i in snake)
- snake[i].dying = true;
- if (cookie) {
- cookie.dying = true;
- cookie = 0;
- }
- lastScore = score;
- highScores.saveScore(lastScore);
- state = "";
-}
-
-function move() {
-
- if (!head)
- return;
-
- var dir = direction;
-
- if (scheduledDirections.length) {
- dir = scheduledDirections.shift();
- }
-
- if (state == "starting") {
- var turn = (dir - headDirection);
- head.rotation += turn == -3 ? 1 : (turn == 3 ? -1 : turn );
- headDirection = dir;
- return;
- }
-
- var row = head.row;
- var column = head.column;
-
- if (dir == 0) {
- row = row - 1;
- } else if (dir == 1) {
- column = column + 1
- } else if (dir == 2) {
- row = row + 1;
- } else if (dir == 3) {
- column = column - 1;
- }
-
- //validate the new position
- if (row < 0 || row >= numRows
- || column < 0 || column >= numColumns
- || (row == skull.row && column == skull.column)
- || !isFree(row, column)) {
- var turn = (dir - headDirection);
- head.rotation += turn == -3 ? 1 : (turn == 3 ? -1 : turn );
- headDirection = dir;
- endGame();
- return;
- }
-
- var newLink;
- if (linksToGrow > 0) {
- --linksToGrow;
- newLink = links[snake.length];
- newLink.spawned = false;
- newLink.rotation = snake[snake.length-1].rotation;
- newLink.type = growType;
- newLink.dying = false;
- snake.push(newLink);
- } else {
- var lastLink = snake[snake.length-1];
- board[lastLink.row * numColumns + lastLink.column] = undefined;
- }
-
- if (waitForCookie > 0) {
- if (--waitForCookie == 0)
- createCookie(cookie? (cookie.value+1) : 1);
- }
-
- for (var i = snake.length-1; i > 0; --i) {
- snake[i].row = snake[i-1].row;
- snake[i].column = snake[i-1].column;
- snake[i].rotation = snake[i-1].rotation;
- }
-
- if (newLink) {
- newLink.spawned = true;
- }
-
- // move the head
- head.row = row;
- head.column = column;
- board[row * numColumns + column] = head;
-
- var turn = (dir - headDirection);
- head.rotation += turn == -3 ? 1 : (turn == 3 ? -1 : turn );
- headDirection = dir;
-
- var value = testCookie(row, column);
- if (value > 0) {
- linksToGrow += value;
- score += value;
- }
-}
-
-function isFree(row, column)
-{
- return board[row * numColumns + column] == undefined;
-}
-
-function isHead(row, column)
-{
- return head.column == column && head.row == row;
-}
-
-function testCookie(row, column)
-{
- if (cookie && !cookie.dying && cookie.row == row && cookie.column == column) {
- var value = cookie.value;
- waitForCookie = value;
- growType = snake[snake.length-1].type == 1 ? 0 : 1;
- cookie.dying = true;
- cookie.z = numRows * numColumns + 2;
- return value;
- }
- return 0;
-}
-
-function moveSkull()
-{
-
- if (linksToDie > 0) {
- --linksToDie;
- var link = snake.pop();
- link.dying = true;
- board[link.row * numColumns + link.column] = undefined;
- if (score > 0)
- --score;
- if (snake.length == 0) {
- endGame();
- return;
- }
- }
-
- var row = skull.row;
- var column = skull.column;
- if (isHead(row, column)) {
- endGame();
- return;
- }
- row += skull.verticalMovement;
- column += skull.horizontalMovement;
-
- var attempts = 4;
-
- while (skullMovementsBeforeDirectionChange == 0 || row < 0 || row >= numRows
- || column < 0 || column >= numColumns
- || (!isFree(row, column) && !isHead(row, column))) {
- var d = rand(8);
- skull.verticalMovement = 0;
- skull.horizontalMovement = 0;
- skullMovementsBeforeDirectionChange = rand(20)+1;
- if (d == 0) {
- skull.verticalMovement = -1
- } else if (d == 1) {
- skull.horizontalMovement = -1;
- } else if (d == 2) {
- skull.verticalMovement = 1
- } else if (d == 3){
- skull.horizontalMovement = 1;
- } else if (cookie) {
- var rd = cookie.row - skull.row;
- var rc = cookie.column - skull.column;
- if (Math.abs(rd) > Math.abs(rc)) {
- skull.verticalMovement = rd > 0 ? 1 : -1;
- skullMovementsBeforeDirectionChange = Math.abs(rd);
- } else {
- skull.horizontalMovement= rc > 0 ? 1 : -1;
- skullMovementsBeforeDirectionChange = Math.abs(rc);
- }
- }
- row = skull.row + skull.verticalMovement;
- column = skull.column + skull.horizontalMovement;
- if (--attempts == 0)
- return;
- }
-
- skull.row = row;
- skull.column = column;
- --skullMovementsBeforeDirectionChange;
- var value = testCookie(row, column);
- if (value > 0)
- linksToDie += value/2;
-
- if (isHead(row, column))
- endGame();
-}
-
-function createCookie(value) {
- if (numRows * numColumns - snake.length < 10)
- return;
-
- var column = rand(numColumns);
- var row = rand(numRows);
- while (!isFree(row, column)) {
- column++;
- if (column == numColumns) {
- column = 0;
- row++;
- if (row == numRows)
- row = 0;
- }
- }
-
- if(cookieComponent.status != Component.Ready) {
- if(cookieComponent.status == Component.Error)
- console.log(cookieComponent.errorString());
- else
- console.log("Still loading cookieComponent");
- return;//TODO: Better error handling?
- }
- cookie = cookieComponent.createObject(head.parent);
- cookie.value = value;
- cookie.row = row;
- cookie.column = column;
-}
+++ /dev/null
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the QtQml module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-import "content" as Content
-import "content/snake.js" as Logic
-
-Rectangle {
- id: screen;
- SystemPalette { id: activePalette }
- color: activePalette.window
- property bool activeGame: false
-
- property int gridSize : 34
- property int margin: 4
- property int numRowsAvailable: Math.floor((height-32-2*margin)/gridSize)
- property int numColumnsAvailable: Math.floor((width-2*margin)/gridSize)
-
- property int lastScore : 0
-
- property int score: 0;
- property int heartbeatInterval: 200
- property int halfbeatInterval: 160
-
- width: 480
- height: 750
-
- property int direction
- property int headDirection
-
- property variant head;
-
- Content.HighScoreModel {
- id: highScores
- game: "Snake"
- }
-
- Timer {
- id: heartbeat;
- interval: screen.heartbeatInterval;
- running: screen.activeGame
- repeat: true
- onTriggered: { Logic.move() }
- }
- Timer {
- id: halfbeat;
- interval: screen.halfbeatInterval;
- repeat: true
- running: heartbeat.running
- onTriggered: { Logic.moveSkull() }
- }
- Timer {
- id: startNewGameTimer;
- interval: 700;
- onTriggered: { Logic.startNewGame(); }
- }
-
- Timer {
- id: startHeartbeatTimer;
- interval: 1000 ;
- onTriggered: { screen.state = "running"; screen.activeGame = true; }
- }
-
- Image{
- id: pauseDialog
- z: 1
- source: "content/pics/pause.png"
- anchors.centerIn: parent;
- //opacity is deliberately not animated
- opacity: 0 //Was !Qt.application.active && activeGame, but application doesn't work (QTBUG-23331)
- }
-
- Image {
-
- Image {
- id: title
- source: "content/pics/snake.jpg"
- fillMode: Image.PreserveAspectCrop
- anchors.fill: parent
- anchors.horizontalCenter: parent.horizontalCenter
- anchors.verticalCenter: parent.verticalCenter
-
- Column {
- spacing: 140
- anchors.verticalCenter: parent.verticalCenter;
- anchors.left: parent.left;
- anchors.right: parent.right;
-
- Text {
- color: "white"
- font.pointSize: 48
- font.italic: true;
- font.bold: true;
- text: "Snake"
- anchors.horizontalCenter: parent.horizontalCenter;
- }
-
- Text {
- color: "white"
- font.pointSize: 24
- anchors.horizontalCenter: parent.horizontalCenter;
- //horizontalAlignment: Text.AlignHCenter
- text: "Last Score:\t" + screen.lastScore + "\nHighscore:\t" + highScores.topScore;
- }
- }
- }
-
- source: "content/pics/background.png"
- fillMode: Image.PreserveAspectCrop
-
- anchors.left: parent.left
- anchors.right: parent.right
- anchors.top: parent.top
- anchors.bottom: toolbar.top
-
- Rectangle {
- id: playfield
- border.width: 1
- border.color: "white"
- color: "transparent"
- anchors.horizontalCenter: parent.horizontalCenter
- y: (screen.height - 32 - height)/2;
- width: screen.numColumnsAvailable * screen.gridSize + 2*screen.margin
- height: screen.numRowsAvailable * screen.gridSize + 2*screen.margin
-
-
- Content.Skull {
- id: skull
- }
-
- MouseArea {
- anchors.fill: parent
- onPressed: {
- if (screen.state == "") {
- Logic.startNewGame();
- return;
- }
- if (direction == 0 || direction == 2)
- Logic.scheduleDirection((mouseX > (head.x + head.width/2)) ? 1 : 3);
- else
- Logic.scheduleDirection((mouseY > (head.y + head.height/2)) ? 2 : 0);
- }
- }
- }
-
- }
-
- Rectangle {
- id: progressBar
- opacity: 0
- Behavior on opacity { NumberAnimation { duration: 200 } }
- color: "transparent"
- border.width: 2
- border.color: "#221edd"
- x: 50
- y: 50
- width: 200
- height: 30
- anchors.horizontalCenter: parent.horizontalCenter
- anchors.verticalCenter: parent.verticalCenter
- anchors.verticalCenterOffset: 40
-
- Rectangle {
- id: progressIndicator
- color: "#221edd";
- width: 0;
- height: 30;
- }
- }
-
- Rectangle {
- id: toolbar
- color: activePalette.window
- height: 32; width: parent.width
- anchors.bottom: screen.bottom
-
- Content.Button {
- id: btnA; text: "New Game"; onClicked: Logic.startNewGame();
- anchors.left: parent.left; anchors.leftMargin: 3
- anchors.verticalCenter: parent.verticalCenter
- }
-
- Content.Button {
- text: "Quit"
- anchors { left: btnA.right; leftMargin: 3; verticalCenter: parent.verticalCenter }
- onClicked: Qt.quit();
- }
-
- Text {
- color: activePalette.text
- text: "Score: " + screen.score; font.bold: true
- anchors.right: parent.right; anchors.rightMargin: 3
- anchors.verticalCenter: parent.verticalCenter
- }
- }
-
- focus: true
- Keys.onSpacePressed: Logic.startNewGame();
- Keys.onLeftPressed: if (state == "starting" || direction != 1) Logic.scheduleDirection(3);
- Keys.onRightPressed: if (state == "starting" || direction != 3) Logic.scheduleDirection(1);
- Keys.onUpPressed: if (state == "starting" || direction != 2) Logic.scheduleDirection(0);
- Keys.onDownPressed: if (state == "starting" || direction != 0) Logic.scheduleDirection(2);
-
- states: [
- State {
- name: "starting"
- PropertyChanges {target: progressIndicator; width: 200}
- PropertyChanges {target: title; opacity: 0}
- PropertyChanges {target: progressBar; opacity: 1}
- },
- State {
- name: "running"
- PropertyChanges {target: progressIndicator; width: 200}
- PropertyChanges {target: title; opacity: 0}
- PropertyChanges {target: skull; row: 0; column: 0; }
- PropertyChanges {target: skull; spawned: 1}
- }
- ]
-
- transitions: [
- Transition {
- from: "*"
- to: "starting"
- NumberAnimation { target: progressIndicator; property: "width"; duration: 1000 }
- NumberAnimation { property: "opacity"; duration: 200 }
- },
- Transition {
- to: "starting"
- NumberAnimation { target: progressIndicator; property: "width"; duration: 1000 }
- NumberAnimation { property: "opacity"; duration: 200 }
- }
- ]
-
-}
+++ /dev/null
-import QmlProject 1.1
-
-Project {
- mainFile: "snake.qml"
-
- /* Include .qml, .js, and image files from current directory and subdirectories */
- QmlFiles {
- directory: "."
- }
- JavaScriptFiles {
- directory: "."
- }
- ImageFiles {
- directory: "."
- }
-}
+++ /dev/null
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** You may use this file under the terms of the BSD license as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
-** the names of its contributors may be used to endorse or promote
-** products derived from this software without specific prior written
-** permission.
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-
-Rectangle {
- id: container
-
- property string text
- property bool pressed: false
-
- signal clicked
-
- width: buttonLabel.width + 20; height: buttonLabel.height + 6
- border { width: 1; color: Qt.darker(container.color) }
- radius: 8
- color: "lightgray"
- smooth: true
-
- gradient: Gradient {
- GradientStop {
- position: 0.0
- color: container.pressed ? "darkgray" : "white"
- }
- GradientStop {
- position: 1.0
- color: container.color
- }
- }
-
- MouseArea {
- anchors.fill: parent
- onClicked: container.clicked()
- }
-
- Text {
- id: buttonLabel
- anchors.centerIn: container
- text: container.text
- font.pixelSize: 14
- }
-}
+++ /dev/null
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** You may use this file under the terms of the BSD license as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
-** the names of its contributors may be used to endorse or promote
-** products derived from this software without specific prior written
-** permission.
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-
-Item {
- signal clicked
-
- states: [
- State { name: "X"; PropertyChanges { target: image; source: "pics/x.png" } },
- State { name: "O"; PropertyChanges { target: image; source: "pics/o.png" } }
- ]
-
- Image {
- id: image
- anchors.centerIn: parent
- }
-
- MouseArea {
- anchors.fill: parent
- onClicked: parent.clicked()
- }
-}
+++ /dev/null
-function winner(board)
-{
- for (var i=0; i<3; ++i) {
- if (board.children[i].state != ""
- && board.children[i].state == board.children[i+3].state
- && board.children[i].state == board.children[i+6].state)
- return true
-
- if (board.children[i*3].state != ""
- && board.children[i*3].state == board.children[i*3+1].state
- && board.children[i*3].state == board.children[i*3+2].state)
- return true
- }
-
- if (board.children[0].state != ""
- && board.children[0].state == board.children[4].state != ""
- && board.children[0].state == board.children[8].state != "")
- return true
-
- if (board.children[2].state != ""
- && board.children[2].state == board.children[4].state != ""
- && board.children[2].state == board.children[6].state != "")
- return true
-
- return false
-}
-
-function restartGame()
-{
- game.running = true
-
- for (var i=0; i<9; ++i)
- board.children[i].state = ""
-}
-
-function makeMove(pos, player)
-{
- board.children[pos].state = player
- if (winner(board)) {
- gameFinished(player + " wins")
- return true
- } else {
- return false
- }
-}
-
-function canPlayAtPos(pos)
-{
- return board.children[pos].state == ""
-}
-
-function computerTurn()
-{
- var r = Math.random();
- if (r < game.difficulty)
- smartAI();
- else
- randomAI();
-}
-
-function smartAI()
-{
- function boardCopy(a) {
- var ret = new Object;
- ret.children = new Array(9);
- for (var i = 0; i<9; i++) {
- ret.children[i] = new Object;
- ret.children[i].state = a.children[i].state;
- }
- return ret;
- }
-
- for (var i=0; i<9; i++) {
- var simpleBoard = boardCopy(board);
- if (canPlayAtPos(i)) {
- simpleBoard.children[i].state = "O";
- if (winner(simpleBoard)) {
- makeMove(i, "O")
- return
- }
- }
- }
- for (var i=0; i<9; i++) {
- var simpleBoard = boardCopy(board);
- if (canPlayAtPos(i)) {
- simpleBoard.children[i].state = "X";
- if (winner(simpleBoard)) {
- makeMove(i, "O")
- return
- }
- }
- }
-
- function thwart(a,b,c) { //If they are at a, try b or c
- if (board.children[a].state == "X") {
- if (canPlayAtPos(b)) {
- makeMove(b, "O")
- return true
- } else if (canPlayAtPos(c)) {
- makeMove(c, "O")
- return true
- }
- }
- return false;
- }
-
- if (thwart(4,0,2)) return;
- if (thwart(0,4,3)) return;
- if (thwart(2,4,1)) return;
- if (thwart(6,4,7)) return;
- if (thwart(8,4,5)) return;
- if (thwart(1,4,2)) return;
- if (thwart(3,4,0)) return;
- if (thwart(5,4,8)) return;
- if (thwart(7,4,6)) return;
-
- for (var i =0; i<9; i++) {
- if (canPlayAtPos(i)) {
- makeMove(i, "O")
- return
- }
- }
- restartGame();
-}
-
-function randomAI()
-{
- var unfilledPosns = new Array();
-
- for (var i=0; i<9; ++i) {
- if (canPlayAtPos(i))
- unfilledPosns.push(i);
- }
-
- if (unfilledPosns.length == 0) {
- restartGame();
- } else {
- var choice = unfilledPosns[Math.floor(Math.random() * unfilledPosns.length)];
- makeMove(choice, "O");
- }
-}
-
-function gameFinished(message)
-{
- messageDisplay.text = message
- messageDisplay.visible = true
- game.running = false
-}
-
+++ /dev/null
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** You may use this file under the terms of the BSD license as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
-** the names of its contributors may be used to endorse or promote
-** products derived from this software without specific prior written
-** permission.
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-import "content"
-import "content/tic-tac-toe.js" as Logic
-
-Rectangle {
- id: game
-
- property bool running: true
- property real difficulty: 1.0 //chance it will actually think
-
- width: display.width; height: display.height + 10
-
- Image {
- id: boardImage
- source: "content/pics/board.png"
- }
-
-
- Column {
- id: display
-
- Grid {
- id: board
- width: boardImage.width; height: boardImage.height
- columns: 3
-
- Repeater {
- model: 9
-
- TicTac {
- width: board.width/3
- height: board.height/3
-
- onClicked: {
- if (game.running && Logic.canPlayAtPos(index)) {
- if (!Logic.makeMove(index, "X"))
- Logic.computerTurn();
- }
- }
- }
- }
- }
-
- Row {
- spacing: 4
- anchors.horizontalCenter: parent.horizontalCenter
-
- Button {
- text: "Hard"
- pressed: game.difficulty == 1.0
- onClicked: { game.difficulty = 1.0 }
- }
- Button {
- text: "Moderate"
- pressed: game.difficulty == 0.8
- onClicked: { game.difficulty = 0.8 }
- }
- Button {
- text: "Easy"
- pressed: game.difficulty == 0.2
- onClicked: { game.difficulty = 0.2 }
- }
- }
- }
-
-
- Text {
- id: messageDisplay
- anchors.centerIn: parent
- color: "blue"
- style: Text.Outline; styleColor: "white"
- font.pixelSize: 50; font.bold: true
- visible: false
-
- Timer {
- running: messageDisplay.visible
- onTriggered: {
- messageDisplay.visible = false;
- Logic.restartGame();
- }
- }
- }
-}
+++ /dev/null
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** You may use this file under the terms of the BSD license as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
-** the names of its contributors may be used to endorse or promote
-** products derived from this software without specific prior written
-** permission.
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-
-Item {
- id:twitterUser
- property variant friends : [];
- property string name : "";
- property string twitterId : "";
- property string image : "";
- property string url : "";
- property string desc : "";
- width : 0;
- height : 0;
- property int posX:0;
- property int posY:0;
- property bool hasFocus : false;
- property variant canvas;
- property variant manager;
- property variant linkColor;
- property bool selected : false;
-
- Rectangle {
- id:twitterStatus
- x:twitterUser.width
- y:twitterUser.height
- width:250
- height:60
- opacity: 0
- border.color:"steelblue"
- border.width:3
- Column {
- spacing:2
- Text {color:"steelblue"; font.pointSize:15; width:250; height:30; text:twitterUser.name; wrapMode: Text.WrapAnywhere}
- Text {color:"steelblue"; font.pointSize:8; width:250; height:30; text:twitterUser.url; wrapMode: Text.WrapAnywhere}
- }
- }
-
- function moved() {
- twitterUser.posX = twitterUser.x;
- twitterUser.posY = twitterUser.y;
- twitterUser.canvas.requestPaint();
- }
-
- onXChanged: moved();
- onYChanged: moved();
-
- MouseArea {
- anchors.fill:parent
- drag.target : twitterUser
- drag.axis : Drag.XandYAxis
-
- onClicked: {
- if (!twitterUser.selected) {
- twitterUser.selected = true;
- twitterStatus.opacity = 1;
- twitterStatus.visible = true;
- } else {
- twitterUser.selected = false;
- twitterStatus.opacity = 0;
- }
- }
-
- onDoubleClicked : {
- twitterStatus.opacity = 0;
- twitterUser.selected = false;
- twitterUser.hasFocus = true;
- twitterUser.canvas.twitterName = twitterUser.name;
- twitterUser.canvas.twitterId = twitterUser.twitterId;
- twitterUser.canvas.loading = true;
- twitterUser.createFriends();
- }
- }
-
- function show(ctx, layoutChanged) {
- var w = canvas.width;
- var h = canvas.height;
- if (twitterUser.hasFocus) {
- twitterUser.width = 60
- twitterUser.height = 60
- twitterUser.posX = w/2;
- twitterUser.posY = h/2;
- } else {
- twitterUser.width = 40
- twitterUser.height = 40
- }
-
-
- if (twitterUser.hasFocus) {
- if (layoutChanged)
- twitterUser.layoutFriends();
- twitterUser.linkFriends(ctx);
- twitterUser.showFriends(ctx);
- ctx.shadowOffsetX = 5;
- ctx.shadowOffsetY = 5;
- ctx.shadowBlur = 7;
- ctx.shadowColor = "blue";
- ctx.globalAlpha = 1;
- } else {
- ctx.shadowOffsetX = 5;
- ctx.shadowOffsetY = 5;
- ctx.shadowBlur = 7;
- ctx.shadowColor = twitterUser.linkColor;
- ctx.globalAlpha = 0.6;
- }
-
- if (twitterUser.canvas.isImageLoaded(twitterUser.image)) {
- ctx.drawImage(twitterUser.image, twitterUser.posX, twitterUser.posY, twitterUser.width, twitterUser.height);
- }
-// ctx.font = "15px";
-// var nameSize = ctx.measureText(twitterUser.name).width;
-// ctx.fillText(twitterUser.name, twitterUser.posX + nameSize/2 - twitterUser.width/2, twitterUser.posY + twitterUser.height/2 + 10);
- }
- function dump() {
- console.log("name:" + twitterUser.name
- + " x:" + twitterUser.posX
- + " y:" + twitterUser.posY
- + " width:" + twitterUser.width
- + " height:" + twitterUser.height
- + " id:" + twitterUser.twitterId
- + " image:" + twitterUser.image
- + " url:" + twitterUser.url + "\n" + twitterUser.desc);
- }
-
- function layoutFriends() {
- var w = canvas.width;
- var h = canvas.height;
- for (var i=0; i < twitterUser.friends.length; i++) {
- var friend = manager.getById(twitterUser.friends[i]);
- if (friend) {
- friend.x = Math.random() *w;
- friend.y = Math.random() *h;
- }
- }
- }
-
- function showFriends(ctx) {
- var w = canvas.width;
- var h = canvas.height;
- for (var i=0; i < twitterUser.friends.length && i < 15; i++) {
- var friend = manager.getById(twitterUser.friends[i]);
- if (friend && twitterUser.canvas.isImageLoaded(friend.image)) {
- friend.hasFocus = false;
- friend.show(ctx, false);
- }
- }
- }
-
- function linkFriends(ctx) {
- var w = canvas.width;
- var h = canvas.height;
- for (var i=0; i < twitterUser.friends.length && i < 15; i++) {
- var friend = manager.getById(twitterUser.friends[i]);
- if (friend && twitterUser.canvas.isImageLoaded(friend.image)) {
- if (!friend.linkColor)
- friend.linkColor = Qt.rgba( ((Math.random() * 200) +55)/255
- , ((Math.random() * 200) +55)/255
- , ((Math.random() * 200) +55)/255, 0.8);
- ctx.strokeStyle = friend.linkColor;
- ctx.lineWidth = 8;
- ctx.beginPath();
- ctx.moveTo(twitterUser.posX + twitterUser.width/2, twitterUser.posY + twitterUser.height/2);
- ctx.lineTo(friend.x + friend.width/2, friend.y + friend.height/2);
- ctx.stroke();
- }
- }
- }
-
-
- function create(url) {
- var x = new XMLHttpRequest;
- x.open("GET", url);
-
- x.onreadystatechange = function() {
- if (x.readyState == XMLHttpRequest.DONE) {
- var user = eval('(' + x.responseText +')')[0];
- twitterUser.name = user.name;
- twitterUser.twitterId = user.id;
- twitterUser.image = user.profile_image_url;
- twitterUser.canvas.loadImage(twitterUser.image);
- twitterUser.url = user.url;
- twitterUser.desc = user.description;
- twitterUser.createFriends();
- }
- }
- x.send();
- }
-
- function createByName(name) {
- if (twitterUser.name === "" && twitterUser.twitterId === "") {
- twitterUser.name = name;
- var userUrl = "http://api.twitter.com/1/users/lookup.json?stringify_ids=true&screen_name=" + name;
- twitterUser.create(userUrl);
- }
- }
-
- function createById(id) {
- if (twitterUser.name === "" && twitterUser.twitterId === "") {
- twitterUser.twitterId = id;
- var userUrl = "http://api.twitter.com/1/users/lookup.json?stringify_ids=true&user_id=" + id;
- twitterUser.create(userUrl);
- }
- }
-
- function createFriends() {
- if (twitterUser.friends.length === 0) {
- var x = new XMLHttpRequest;
- var friendsUrl = "https://api.twitter.com/1/friends/ids.json?cursor=-1&stringify_ids=true&user_id=" + twitterUser.twitterId;
- x.open("GET", friendsUrl);
-
- x.onreadystatechange = function() {
- if (x.readyState == XMLHttpRequest.DONE) {
- twitterUser.friends = eval('(' + x.responseText +')').ids;
- var doRequest = false;
- var userUrl = "http://api.twitter.com/1/users/lookup.json?stringify_ids=true&user_id=";
-
- for (var i=0; i<twitterUser.friends.length && i < 100; i++) {
- var friend = manager.getById(twitterUser.friends[i]);
- if (!friend) {
- userUrl += "," + twitterUser.friends[i];
- doRequest = true;
- }
- }
-
- if (!doRequest) return;
-
- var xx = new XMLHttpRequest;
- xx.open("GET", userUrl);
- xx.onreadystatechange = function() {
- if (xx.readyState == XMLHttpRequest.DONE) {
- var friendUsers = eval('(' + xx.responseText +')');
- for(var i=0; i<friendUsers.length; i++) {
- var friend = manager.createTwitterUser(twitterUser.canvas);
- friend.name = friendUsers[i].name;
- friend.twitterId = friendUsers[i].id;
- friend.image = friendUsers[i].profile_image_url ? friendUsers[i].profile_image_url : "";
- friend.url = friendUsers[i].url ? friendUsers[i].url : "";
- friend.desc = friendUsers[i].description ? friendUsers[i].description : "";
- friend.manager = twitterUser.manager;
- twitterUser.canvas.loadImage(friend.image);
- }
-
- if (twitterUser.hasFocus && twitterUser.canvas) {
- twitterUser.canvas.layoutChanged = true;
- twitterUser.canvas.loading = false;
- twitterUser.canvas.requestPaint();
- }
- }
- }
- xx.send();
- }
- }
- x.send();
- }
- }
-}
\ No newline at end of file
+++ /dev/null
-var UserCache = function() {
- this._users = [];
-}
-
-
-UserCache.prototype.getById = function(id){
- for (var i=0; i < this._users.length; i++){
- var user = this._users[i];
- if (user.twitterId == id) {
- return user;
- }
- }
-}
-UserCache.prototype.getByName = function(name){
- for (var i=0; i < this._users.length; i++){
- var user = this._users[i];
- if (user.name == name)
- return user;
- }
-}
-
-UserCache.prototype.add = function(user){
- this._users[this._users.length] = user;
-}
-
-
-var cache = new UserCache;
-
-function getById(id) {
- return cache.getById(id);
-}
-
-function getByName(name) {
- return cache.getByName(name);
-}
-
-function createTwitterUser(canvas) {
- var user = Qt.createQmlObject("import QtQuick 2.0; TwitterUser{}", canvas);
- user.canvas = canvas;
- cache.add(user);
- return user;
-}
+++ /dev/null
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** You may use this file under the terms of the BSD license as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
-** the names of its contributors may be used to endorse or promote
-** products derived from this software without specific prior written
-** permission.
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-import "cache.js" as TwitterUserCache
-Rectangle {
- width:360
- height:600
- color:"black"
- QtObject {
- id:twitterManager
- function getById(id) {
- return TwitterUserCache.cache.getById(id);
- }
-
- function getByName(name) {
- return TwitterUserCache.cache.getByName(name);
- }
-
- function createTwitterUser(canvas) {
- return TwitterUserCache.createTwitterUser(canvas);
- }
- }
- Rectangle {
- id:inputContainer
- width:parent.width-4
- height:40
- anchors.top:parent.top
- anchors.topMargin:4
- anchors.horizontalCenter:parent.horizontalCenter
- radius:8
- border.color:"steelblue"
- Text {
- text:inputName.text == "" ? "Enter your twitter name..." : ""
- id:inputLabel
- anchors.centerIn:parent
- font.pointSize:12
- opacity:.5
- color:"steelblue"
- }
- TextInput {
- id:inputName
- anchors.centerIn:parent
- font.pointSize : 20
- opacity:1
- color:"steelblue"
- width:parent.width-6
- height:parent.height-6
- text:""
- autoScroll:true
- focus:true
- selectByMouse:true
- onAccepted : {canvas.twitterName = text; canvas.requestPaint();}
- }
- }
- Canvas {
- id:canvas
- width:parent.width
- anchors.top :inputContainer.bottom
- anchors.bottom : parent.bottom
- smooth:true
- renderTarget:Canvas.Image
- renderStrategy: Canvas.Immediate
-
- property bool layoutChanged:true
- property string twitterName:""
- property string twitterId:""
- property bool loading:false
-
- onLoadingChanged: requestPaint();
- onWidthChanged: { layoutChanged = true; requestPaint();}
- onHeightChanged: { layoutChanged = true; requestPaint();}
- onTwitterNameChanged: inputName.text = twitterName;
- onImageLoaded:requestPaint();
- onPaint: {
- var ctx = canvas.getContext('2d');
- ctx.save();
- ctx.fillStyle="black";
- ctx.fillRect(0, 0, canvas.width, canvas.height);
-
- if (canvas.twitterName != "" || canvas.twitterId != "") {
- var user = canvas.twitterId ? TwitterUserCache.getById(canvas.twitterId) : TwitterUserCache.getByName(canvas.twitterName);
- if (!user) {
- user = TwitterUserCache.createTwitterUser(canvas);
- user.hasFocus = true;
- user.manager = twitterManager;
- user.createByName(canvas.twitterName);
- canvas.loading = true;
- }
-
- if (canvas.loading) {
- ctx.font = "40px";
- ctx.fillStyle = "steelblue";
- ctx.fillText("Loading...", canvas.width/2 - 80, canvas.height/2);
- } else {
- user.show(ctx, layoutChanged);
- }
- layoutChanged = false;
- }
- ctx.restore();
- }
- }
-}
+++ /dev/null
-import QmlProject 1.1
-
-Project {
- mainFile: "friends.qml"
-
- /* Include .qml, .js, and image files from current directory and subdirectories */
- QmlFiles {
- directory: "."
- }
- JavaScriptFiles {
- directory: "."
- }
- ImageFiles {
- directory: "."
- }
-}
\ No newline at end of file