1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127
|
//
// This file is part of the Marble Virtual Globe.
//
// This program is free software licensed under the GNU LGPL. You can
// find a copy of this license in LICENSE.txt in the top directory of
// the source code.
//
// Copyright 2014 Abhinav Gangwar <abhgang@gmail.com>
//
import QtQuick 2.0
import QtQuick.Controls 1.2
import QtQuick.Controls.Styles 1.2
Rectangle {
id: gamesDisplayPanel
objectName: "gamesDisplayPanel"
signal quitGame(int score)
signal requestNextQuestion()
signal requestAnswerDisplay()
property int gamesDisplayWidth: 200
property int gamesDisplayHeight: 600
property alias currentIndex: gameView.currentIndex
width: gamesDisplayWidth
height: gamesDisplayHeight
/*
* The Model contains data for
* UI for different types of available
* games. Whenever user opts for a
* particular game we switch the view
* to that game. View is controlled by
* ListView element defined below
*/
VisualItemModel {
id: gamesModel
CountryByShape {
id: countryByShapeGame
panelWidth: gamesDisplayPanel.width
panelHeight: gamesDisplayPanel.height
onGameQuitRequested: {
quitGame(score);
}
onNextQuestionRequested: {
requestNextQuestion();
}
}
CountryByFlag {
id: countryByFlagGame
panelWidth: gamesDisplayPanel.width
panelHeight: gamesDisplayPanel.height
onGameQuitRequested: {
quitGame(score);
}
onNextQuestionRequested: {
requestNextQuestion();
}
}
ClickOnThat {
id: clickOnThat
panelWidth: gamesDisplayPanel.width
panelHeight: gamesDisplayPanel.height
onGameQuitRequested: {
quitGame(score);
}
onNextQuestionRequested: {
requestNextQuestion();
}
onAnswerDisplayRequested: {
requestAnswerDisplay();
}
}
}
/*
* View to display game model
*/
ListView {
id: gameView
objectName: "gameView"
width: gamesDisplayPanel.width
height: gamesDisplayPanel.height
anchors.centerIn: parent
model: gamesModel
highlightMoveDuration: 250
highlightRangeMode: ListView.StrictlyEnforceRange
orientation: ListView.Vertical
}
/*
* These are functions which tell a
* particular type of game to display
* the question data
*/
function postCountryShapeQuestion( answerOptions, correctAnswer ) {
gameView.currentItem.setQuestion( answerOptions, correctAnswer );
}
function postCountryFlagQuestion( answerOptions, imageSource, correctAnswer ) {
gameView.currentItem.setQuestion( answerOptions, imageSource, correctAnswer );
}
function postClickOnThatQuestion( countryName ) {
gameView.currentItem.setQuestion( countryName );
}
function initGame() {
gameView.currentItem.initGame()
}
function displayResult( result ) {
gameView.currentItem.displayResult( result )
}
function setMaximumQuestionsCounts( questionsCount ) {
gameView.currentItem.setMaximumQuestions( questionsCount );
}
}
|