Branding: remove fancy/ and samegame/ examples

The examples of branding have moved to the calamares-branding repo.
This commit is contained in:
Adriaan de Groot 2018-03-09 08:44:20 -05:00
parent 3610634883
commit 25b9663a40
28 changed files with 0 additions and 836 deletions

View File

@ -1,32 +0,0 @@
---
componentName: fancy
welcomeStyleCalamares: false
strings:
productName: Fancy GNU/Linux
shortProductName: Fancy
version: 2018.3 LTS
shortVersion: 2018.3
versionedName: Fancy GNU/Linux 2018.3 LTS "Terrible Tubas"
shortVersionedName: Fancy 2018.3
bootloaderEntryName: Fancy
productUrl: https://calamares.io/
supportUrl: https://github.com/calamares/calamares/issues
knownIssuesUrl: https://calamares.io/about/
releaseNotesUrl: https://calamares.io/about/
welcomeExpandingLogo: true
images:
productLogo: "squid.png"
productIcon: "squid.png"
productWelcome: "languages.png"
slideshow: "show.qml"
style:
sidebarBackground: "#392F34"
sidebarText: "#eFFFFF"
sidebarTextSelect: "#392F34"
sidebarTextHighlight: "#c35400"

Binary file not shown.

Binary file not shown.

View File

@ -1,42 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<TS version="2.1" language="en">
<context>
<name>show</name>
<message>
<location filename="../src/branding/fancy/show.qml" line="59"/>
<location filename="../src/branding/fancy/show.qml" line="108"/>
<source>This is a customizable QML slideshow.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/branding/fancy/show.qml" line="71"/>
<location filename="../src/branding/fancy/show.qml" line="107"/>
<source>Welcome to Fancy GNU/Linux.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/branding/fancy/show.qml" line="72"/>
<location filename="../src/branding/fancy/show.qml" line="99"/>
<source>This is example branding for your GNU/Linux distribution. Long texts in the slideshow are translated and word-wrapped appropriately. Calamares is a distribution-independent installer framework. </source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/branding/fancy/show.qml" line="78"/>
<location filename="../src/branding/fancy/show.qml" line="109"/>
<source>This is a third Slide element.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/branding/fancy/show.qml" line="94"/>
<source>This is a fourth Slide element.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/branding/fancy/show.qml" line="98"/>
<location filename="../src/branding/fancy/show.qml" line="105"/>
<source>Slide number five</source>
<translation type="unfinished"></translation>
</message>
</context>
</TS>

View File

@ -1,42 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<TS version="2.1" language="en">
<context>
<name>show</name>
<message>
<location filename="../src/branding/fancy/show.qml" line="59"/>
<location filename="../src/branding/fancy/show.qml" line="108"/>
<source>This is a customizable QML slideshow.</source>
<translation>Dit is een zelf-aan-te-passen QML presentatie.</translation>
</message>
<message>
<location filename="../src/branding/fancy/show.qml" line="71"/>
<location filename="../src/branding/fancy/show.qml" line="107"/>
<source>Welcome to Fancy GNU/Linux.</source>
<translation>Welkom bij Fancy GNU/Linux.</translation>
</message>
<message>
<location filename="../src/branding/fancy/show.qml" line="72"/>
<location filename="../src/branding/fancy/show.qml" line="99"/>
<source>This is example branding for your GNU/Linux distribution. Long texts in the slideshow are translated and word-wrapped appropriately. Calamares is a distribution-independent installer framework. </source>
<translation>Dit is voorbeeld merk-materiaal voor uw GNU/Linux distributie. Lange teksten in de presentatie kunnen automatisch worden ge-layout. Calamares is een distributie-onafhankelijke installatie raamwerk.</translation>
</message>
<message>
<location filename="../src/branding/fancy/show.qml" line="78"/>
<location filename="../src/branding/fancy/show.qml" line="109"/>
<source>This is a third Slide element.</source>
<translation>Dit is de derde slide.</translation>
</message>
<message>
<location filename="../src/branding/fancy/show.qml" line="94"/>
<source>This is a fourth Slide element.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/branding/fancy/show.qml" line="98"/>
<location filename="../src/branding/fancy/show.qml" line="105"/>
<source>Slide number five</source>
<translation>Slide nummer vijf</translation>
</message>
</context>
</TS>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 84 KiB

View File

@ -1,112 +0,0 @@
/* === This file is part of Calamares - <https://github.com/calamares> ===
*
* Copyright 2015, Teo Mrnjavac <teo@kde.org>
* Copyright 2018, Adriaan de Groot <groot@kde.org>
*
* Calamares is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Calamares is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Calamares. If not, see <http://www.gnu.org/licenses/>.
*/
import QtQuick 2.5;
import calamares.slideshow 1.0;
Presentation
{
id: presentation
mouseNavigation: false /* Only the fwd/back buttons */
loopSlides: false
BackButton {
width: 60
height: 60
source: "go-previous.svgz"
}
ForwardButton {
width: 60
height: 60
source: "go-next.svgz"
}
SlideCounter {}
Slide {
/* This first slide ignores the "normal" slide layout and places
* an image and text by itself. The anchors need to be connected
* to place the items properly.
*/
Image {
id: background1 // Must be unique
source: "squid.png"
width: 200; height: 200
fillMode: Image.PreserveAspectFit
anchors.centerIn: parent
}
Text {
anchors.horizontalCenter: background1.horizontalCenter
anchors.top: background1.bottom
text: qsTr("This is a customizable QML slideshow.")
wrapMode: Text.WordWrap
width: presentation.width
horizontalAlignment: Text.Center
}
}
Slide {
/* Make this one narrower to prevent overlap of wide text with nav buttons */
width: parent.width * 0.9 - 120
x: parent.width * 0.05 + 60
/* For just a slide with text, things can be simplified using properties */
title: qsTr("Welcome to Fancy GNU/Linux.")
centeredText: qsTr("This is example branding for your GNU/Linux distribution. " +
"Long texts in the slideshow are translated and word-wrapped appropriately. " +
"Calamares is a distribution-independent installer framework. ")
}
Slide {
centeredText: qsTr("This is a third Slide element.")
}
Slide {
/* Note that these overlap because both are centered. The z-order puts the background
* in back. While you can use the properties of the Slide, it's not easy to get at
* the anchors of the items.
*/
Image {
id: background4
source: "squid4.png"
width: 200; height: 200
fillMode: Image.PreserveAspectFit
anchors.centerIn: parent
z: -1
}
centeredText: qsTr("This is a fourth Slide element.")
}
Slide {
title: qsTr("Slide number five")
writeInText: qsTr("This is example branding for your GNU/Linux distribution. " +
"Long texts in the slideshow are translated and word-wrapped appropriately. " +
"Calamares is a distribution-independent installer framework. ")
}
Slide {
title: qsTr("Slide number five")
content: [
qsTr("Welcome to Fancy GNU/Linux."),
qsTr("This is a customizable QML slideshow."),
qsTr("This is a third Slide element.")
]
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.1 KiB

View File

@ -1,73 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2017 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the examples of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** BSD License Usage
** Alternatively, 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 The Qt Company Ltd 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$
**
****************************************************************************/
//![0]
import QtQuick 2.0
Item {
id: block
property int type: 0
Image {
id: img
anchors.fill: parent
source: {
if (type == 0)
return "redStone.png";
else if (type == 1)
return "blueStone.png";
else
return "greenStone.png";
}
}
}
//![0]

View File

@ -1,91 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2017 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the examples of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** BSD License Usage
** Alternatively, 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 The Qt Company Ltd 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: "Button"
signal clicked
width: buttonLabel.width + 20; height: buttonLabel.height + 5
border { width: 1; color: Qt.darker(activePalette.button) }
antialiasing: true
radius: 8
// color the button with a gradient
gradient: Gradient {
GradientStop {
position: 0.0
color: {
if (mouseArea.pressed)
return activePalette.dark
else
return activePalette.light
}
}
GradientStop { position: 1.0; color: activePalette.button }
}
MouseArea {
id: mouseArea
anchors.fill: parent
onClicked: container.clicked();
}
Text {
id: buttonLabel
anchors.centerIn: container
color: activePalette.buttonText
text: container.text
}
}

View File

@ -1,81 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2017 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the examples of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** BSD License Usage
** Alternatively, 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 The Qt Company Ltd 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$
**
****************************************************************************/
//![0]
import QtQuick 2.0
Rectangle {
id: container
function show(text) {
dialogText.text = text;
container.opacity = 1;
}
function hide() {
container.opacity = 0;
}
width: dialogText.width + 20
height: dialogText.height + 20
opacity: 0
Text {
id: dialogText
anchors.centerIn: parent
text: ""
}
MouseArea {
anchors.fill: parent
onClicked: hide();
}
}
//![0]

Binary file not shown.

Before

Width:  |  Height:  |  Size: 36 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 149 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.0 KiB

View File

@ -1,76 +0,0 @@
---
componentName: samegame
# This selects between different welcome texts. When false, uses
# the traditional "Welcome to the %1 installer.", and when true,
# uses "Welcome to the Calamares installer for %1." This allows
# to distinguish this installer from other installers for the
# same distribution.
welcomeStyleCalamares: false
# These are strings shown to the user in the user interface.
# There is no provision for translating them -- since they
# are names, the string is included as-is.
#
# The four Url strings are the Urls used by the buttons in
# the welcome screen, and are not shown to the user. Clicking
# on the "Support" button, for instance, opens the link supportUrl.
# If a Url is empty, the corresponding button is not shown.
#
# bootloaderEntryName is how this installation / distro is named
# in the boot loader (e.g. in the GRUB menu).
strings:
productName: Generic GNU/Linux
shortProductName: Generic
version: 2018.1 LTS
shortVersion: 2018.1
versionedName: Generic GNU/Linux 2018.1 LTS "Tasseled Tambourine"
shortVersionedName: Generic 2018.1
bootloaderEntryName: Generic
productUrl: https://calamares.io/
supportUrl: https://github.com/calamares/calamares/issues
knownIssuesUrl: https://calamares.io/about/
releaseNotesUrl: https://calamares.io/about/
# Should the welcome image (productWelcome, below) be scaled
# up beyond its natural size? If false, the image does not grow
# with the window but remains the same size throughout (this
# may have surprising effects on HiDPI monitors).
welcomeExpandingLogo: true
# These images are loaded from the branding module directory.
#
# productIcon is used as the window icon, and will (usually) be used
# by the window manager to represent the application. This image
# should be square, and may be displayed by the window manager
# as small as 16x16 (but possibly larger).
# productLogo is used as the logo at the top of the left-hand column
# which shows the steps to be taken. The image should be square,
# and is displayed at 80x80 pixels (also on HiDPI).
# productWelcome is shown on the welcome page of the application in
# the middle of the window, below the welcome text. It can be
# any size and proportion, and will be scaled to fit inside
# the window. Use `welcomeExpandingLogo` to make it non-scaled.
# Recommended size is 320x150.
images:
productLogo: "squidball.png"
productIcon: "squidball.png"
productWelcome: "languages.png"
# The slideshow is displayed during execution steps (e.g. when the
# installer is actually writing to disk and doing other slow things).
slideshow: "samegame.qml"
# Colors for text and background components.
#
# - sidebarBackground is the background of the sidebar
# - sidebarText is the (foreground) text color
# - sidebarTextHighlight sets the background of the selected (current) step.
# Optional, and defaults to the application palette.
# - sidebarSelect is the text color of the selected step.
#
style:
sidebarBackground: "#292F34"
sidebarText: "#FFFFFF"
sidebarTextSelect: "#292F34"
sidebarTextHighlight: "#D35400"

Binary file not shown.

Before

Width:  |  Height:  |  Size: 149 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 84 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 148 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.8 KiB

View File

@ -1,174 +0,0 @@
/* This script file handles the game logic */
var maxColumn = 10;
var maxRow = 15;
var maxIndex = maxColumn * maxRow;
var board = new Array(maxIndex);
var component;
//Index function used instead of a 2D array
function index(column, row) {
return column + (row * maxColumn);
}
function startNewGame() {
//Calculate board size
maxColumn = Math.floor(gameCanvas.width / gameCanvas.blockSize);
maxRow = Math.floor(gameCanvas.height / gameCanvas.blockSize);
maxIndex = maxRow * maxColumn;
//Close dialogs
dialog.hide();
//Initialize Board
board = new Array(maxIndex);
gameCanvas.score = 0;
for (var column = 0; column < maxColumn; column++) {
for (var row = 0; row < maxRow; row++) {
board[index(column, row)] = null;
createBlock(column, row);
}
}
}
function createBlock(column, row) {
if (component == null)
component = Qt.createComponent("Block.qml");
// Note that if Block.qml was not a local file, component.status would be
// Loading and we should wait for the component's statusChanged() signal to
// know when the file is downloaded and ready before calling createObject().
if (component.status == Component.Ready) {
var dynamicObject = component.createObject(gameCanvas);
if (dynamicObject == null) {
console.log("error creating block");
console.log(component.errorString());
return false;
}
dynamicObject.type = Math.floor(Math.random() * 3);
dynamicObject.x = column * gameCanvas.blockSize;
dynamicObject.y = row * gameCanvas.blockSize;
dynamicObject.width = gameCanvas.blockSize;
dynamicObject.height = gameCanvas.blockSize;
board[index(column, row)] = dynamicObject;
} else {
console.log("error loading block component");
console.log(component.errorString());
return false;
}
return true;
}
var fillFound; //Set after a floodFill call to the number of blocks found
var floodBoard; //Set to 1 if the floodFill reaches off that node
//![1]
function handleClick(xPos, yPos) {
var column = Math.floor(xPos / gameCanvas.blockSize);
var row = Math.floor(yPos / gameCanvas.blockSize);
if (column >= maxColumn || column < 0 || row >= maxRow || row < 0)
return;
if (board[index(column, row)] == null)
return;
//If it's a valid block, remove it and all connected (does nothing if it's not connected)
floodFill(column, row, -1);
if (fillFound <= 0)
return;
gameCanvas.score += (fillFound - 1) * (fillFound - 1);
shuffleDown();
victoryCheck();
}
//![1]
function floodFill(column, row, type) {
if (board[index(column, row)] == null)
return;
var first = false;
if (type == -1) {
first = true;
type = board[index(column, row)].type;
//Flood fill initialization
fillFound = 0;
floodBoard = new Array(maxIndex);
}
if (column >= maxColumn || column < 0 || row >= maxRow || row < 0)
return;
if (floodBoard[index(column, row)] == 1 || (!first && type != board[index(column, row)].type))
return;
floodBoard[index(column, row)] = 1;
floodFill(column + 1, row, type);
floodFill(column - 1, row, type);
floodFill(column, row + 1, type);
floodFill(column, row - 1, type);
if (first == true && fillFound == 0)
return; //Can't remove single blocks
board[index(column, row)].opacity = 0;
board[index(column, row)] = null;
fillFound += 1;
}
function shuffleDown() {
//Fall down
for (var column = 0; column < maxColumn; column++) {
var fallDist = 0;
for (var row = maxRow - 1; row >= 0; row--) {
if (board[index(column, row)] == null) {
fallDist += 1;
} else {
if (fallDist > 0) {
var obj = board[index(column, row)];
obj.y += fallDist * gameCanvas.blockSize;
board[index(column, row + fallDist)] = obj;
board[index(column, row)] = null;
}
}
}
}
//Fall to the left
var fallDist = 0;
for (var column = 0; column < maxColumn; column++) {
if (board[index(column, maxRow - 1)] == null) {
fallDist += 1;
} else {
if (fallDist > 0) {
for (var row = 0; row < maxRow; row++) {
var obj = board[index(column, row)];
if (obj == null)
continue;
obj.x -= fallDist * gameCanvas.blockSize;
board[index(column - fallDist, row)] = obj;
board[index(column, row)] = null;
}
}
}
}
}
//![2]
function victoryCheck() {
//Award bonus points if no blocks left
var deservesBonus = true;
for (var column = maxColumn - 1; column >= 0; column--)
if (board[index(column, maxRow - 1)] != null)
deservesBonus = false;
if (deservesBonus)
gameCanvas.score += 500;
//Check whether game has finished
if (deservesBonus || !(floodMoveCheck(0, maxRow - 1, -1)))
dialog.show("Game Over. Your score is " + gameCanvas.score);
}
//![2]
//only floods up and right, to see if it can find adjacent same-typed blocks
function floodMoveCheck(column, row, type) {
if (column >= maxColumn || column < 0 || row >= maxRow || row < 0)
return false;
if (board[index(column, row)] == null)
return false;
var myType = board[index(column, row)].type;
if (type == myType)
return true;
return floodMoveCheck(column + 1, row, myType) || floodMoveCheck(column, row - 1, board[index(column, row)].type);
}

View File

@ -1,113 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2017 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the examples of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** BSD License Usage
** Alternatively, 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 The Qt Company Ltd 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$
**
****************************************************************************/
//![0]
import QtQuick 2.0
import "samegame.js" as SameGame
Rectangle {
id: screen
width: 490; height: 720
SystemPalette { id: activePalette }
Item {
width: parent.width
anchors { top: parent.top; bottom: toolBar.top }
Image {
id: background
anchors.fill: parent
source: "background.jpg"
fillMode: Image.PreserveAspectCrop
}
//![1]
Item {
id: gameCanvas
property int score: 0
property int blockSize: 40
width: parent.width - (parent.width % blockSize)
height: parent.height - (parent.height % blockSize)
anchors.centerIn: parent
MouseArea {
anchors.fill: parent
onClicked: SameGame.handleClick(mouse.x, mouse.y)
}
}
//![1]
}
//![2]
Dialog {
id: dialog
anchors.centerIn: parent
z: 100
}
//![2]
Rectangle {
id: toolBar
width: parent.width; height: 30
color: activePalette.window
anchors.bottom: screen.bottom
Button {
anchors { left: parent.left; verticalCenter: parent.verticalCenter }
text: "New Game"
onClicked: SameGame.startNewGame()
}
}
}
//![0]

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 262 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.0 KiB