[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [gcompris/gsoc_pulkit_digital_electricity] src/activities/digital_electricity: digital_electricity: 
From:       Rudra Nil Basu <null () kde ! org>
Date:       2017-08-18 15:38:02
Message-ID: E1dijLW-0005or-G6 () code ! kde ! org
[Download RAW message or body]

Git commit 559b539b82e7011ca29b7da4f1959b7e5d11044c by Rudra Nil Basu.
Committed on 18/08/2017 at 15:16.
Pushed by rudranilbasu into branch 'gsoc_pulkit_digital_electricity'.

digital_electricity: Free mode: Add component from dataset

The components to be loaded on the availablePieces for the free mode was
being done by appending each of the componenets individually, which is
now changed to a much more generalised manner, by listing all the
components in the Dataset under the componentList variable.

It is loaded in the js by running through the array one at a time and
appending them in the availablePieces:

        items.availablePieces.model.append( {
            "imgName": componentList[i].imageName,
            "componentSrc": componentList[i].componentSource,
            "imgWidth": sizeMultiplier * componentList[i].width,
            "imgHeight": sizeMultiplier * componentList[i].height,
            "toolTipText": componentList[i].toolTipText
        })

level 2: it's -> its
level 22: made the intromessage more descriptive by detailing on the bcd
counter and it's output.

Signed-off-by: Rudra Nil Basu <rudra.nil.basu.1996@gmail.com>

M  +5    -2    src/activities/digital_electricity/Dataset.qml
M  +1    -1    src/activities/digital_electricity/Wire.qml
M  +10   -105  src/activities/digital_electricity/digital_electricity.js

https://commits.kde.org/gcompris/559b539b82e7011ca29b7da4f1959b7e5d11044c

diff --git a/src/activities/digital_electricity/Dataset.qml \
b/src/activities/digital_electricity/Dataset.qml index 821daeb4..c4f04ee2 100644
--- a/src/activities/digital_electricity/Dataset.qml
+++ b/src/activities/digital_electricity/Dataset.qml
@@ -127,6 +127,8 @@ QtObject {
         'height': 0.4,
         'toolTipText': qsTr("BCD Counter")
     }
+    // List of all components
+    property var componentList: [zero, one, digitalLight, andGate, orGate, notGate, \
xorGate, nandGate, norGate, switchKey, comparator, bcdToSevenSegment, \
sevenSegmentDisplay, signalGenerator, bcdCounter]  // tutorial levels
     property var tutorialLevels: [
         // level 1
@@ -151,7 +153,7 @@ QtObject {
             playAreaComponentPositionX: [0.4, 0.6],
             playAreaComponentPositionY: [0.3, 0.3],
             introMessage: [
-                qsTr("The AND Gate produces an output of one when both of it's input \
terminal are of value 1"), +                qsTr("The AND Gate produces an output of \
                one when both of its input terminal are of value 1"),
                 qsTr("Turn the Digital light on using an AND gate and the inputs \
provided")  ]
         },
@@ -407,7 +409,8 @@ QtObject {
             playAreaComponentPositionY: [0.2, 0.5, 0.2, 0.4, 0.6, 0.8],
             introMessage: [
                 qsTr("The signal generator on the left is used to generate \
alternating signals between 0 and 1 in a given time period take as input. The time \
                period by default is 1 second, but it can be changed between 0.25 and \
                2s"),
-                qsTr("The BCD counter placed next to it is a special type of counter \
which can count to ten on application of a clock signal."), +                \
qsTr("The BCD counter placed next to it is a special type of counter which can count \
from 0 to 10 and back to 0 on application of a clock signal."), +                \
qsTr("The value of the counter is in the form a BCD number in the output of the BCD \
                counter, with 'A' representing the least significant bit."),
                 qsTr("Connect the components to make sure that the count of 0 to 10 \
is visible in the digital lights provided.")  ]
         }
diff --git a/src/activities/digital_electricity/Wire.qml \
b/src/activities/digital_electricity/Wire.qml index 5a3fc88e..57fe7864 100644
--- a/src/activities/digital_electricity/Wire.qml
+++ b/src/activities/digital_electricity/Wire.qml
@@ -38,7 +38,7 @@ Rectangle {
 
     MouseArea {
         id: mouseArea
-        visible: destructible
+        enabled: destructible
         width: parent.width
         height: parent.height * 3
         anchors.centerIn: parent
diff --git a/src/activities/digital_electricity/digital_electricity.js \
b/src/activities/digital_electricity/digital_electricity.js index f882b77d..29b2b1f8 \
                100644
--- a/src/activities/digital_electricity/digital_electricity.js
+++ b/src/activities/digital_electricity/digital_electricity.js
@@ -137,111 +137,16 @@ function initLevel() {
 }
 
 function loadFreeMode(sizeMultiplier) {
-    items.availablePieces.model.append( {
-        "imgName": "zero.svg",
-        "componentSrc": "Zero.qml",
-        "imgWidth": sizeMultiplier * 0.12,
-        "imgHeight": sizeMultiplier * 0.2,
-        "toolTipText": qsTr("Zero input")
-    })
-    items.availablePieces.model.append( {
-        "imgName": "one.svg",
-        "componentSrc": "One.qml",
-        "imgWidth": sizeMultiplier * 0.12,
-        "imgHeight": sizeMultiplier * 0.2,
-        "toolTipText": qsTr("One input")
-    })
-    items.availablePieces.model.append( {
-        "imgName": "DigitalLightOff.svg",
-        "componentSrc": "DigitalLight.qml",
-        "imgWidth": sizeMultiplier * 0.12,
-        "imgHeight": sizeMultiplier * 0.12,
-        "toolTipText": qsTr("Digital Light")
-    })
-    items.availablePieces.model.append( {
-        "imgName": "gateAnd.svg",
-        "componentSrc": "AndGate.qml",
-        "imgWidth": sizeMultiplier * 0.15,
-        "imgHeight": sizeMultiplier * 0.12,
-        "toolTipText": qsTr("AND gate")
-    })
-    items.availablePieces.model.append( {
-        "imgName": "gateNand.svg",
-        "componentSrc": "NandGate.qml",
-        "imgWidth": sizeMultiplier * 0.15,
-        "imgHeight": sizeMultiplier * 0.12,
-        "toolTipText": qsTr("NAND gate")
-    })
-    items.availablePieces.model.append( {
-        "imgName": "gateNor.svg",
-        "componentSrc": "NorGate.qml",
-        "imgWidth": sizeMultiplier * 0.15,
-        "imgHeight": sizeMultiplier * 0.12,
-        "toolTipText": qsTr("NOR gate")
-    })
-    items.availablePieces.model.append( {
-        "imgName": "gateNot.svg",
-        "componentSrc": "NotGate.qml",
-        "imgWidth": sizeMultiplier * 0.15,
-        "imgHeight": sizeMultiplier * 0.12,
-        "toolTipText": qsTr("NOT gate")
-    })
-    items.availablePieces.model.append( {
-        "imgName": "gateOr.svg",
-        "componentSrc": "OrGate.qml",
-        "imgWidth": sizeMultiplier * 0.15,
-        "imgHeight": sizeMultiplier * 0.12,
-        "toolTipText": qsTr("OR gate")
-    })
-    items.availablePieces.model.append( {
-        "imgName": "gateXor.svg",
-        "componentSrc": "XorGate.qml",
-        "imgWidth": sizeMultiplier * 0.15,
-        "imgHeight": sizeMultiplier * 0.12,
-        "toolTipText": qsTr("XOR gate")
-    })
-    items.availablePieces.model.append( {
-        "imgName": "comparator.svg",
-        "componentSrc": "Comparator.qml",
-        "imgWidth": sizeMultiplier * 0.3,
-        "imgHeight": sizeMultiplier * 0.25,
-        "toolTipText": qsTr("Comparator")
-    })
-    items.availablePieces.model.append( {
-        "imgName": "BCDTo7Segment.svg",
-        "componentSrc": "BCDToSevenSegment.qml",
-        "imgWidth": sizeMultiplier * 0.3,
-        "imgHeight": sizeMultiplier * 0.4,
-        "toolTipText": qsTr("BCD To 7 Segment")
-    })
-    items.availablePieces.model.append( {
-        "imgName": "sevenSegmentDisplay.svgz",
-        "componentSrc": "SevenSegment.qml",
-        "imgWidth": sizeMultiplier * 0.18,
-        "imgHeight": sizeMultiplier * 0.4,
-        "toolTipText": qsTr("7 Segment Display")
-    })
-    items.availablePieces.model.append( {
-        "imgName": "switchOff.svg",
-        "componentSrc": "Switch.qml",
-        "imgWidth": sizeMultiplier * 0.18,
-        "imgHeight": sizeMultiplier * 0.15,
-        "toolTipText": qsTr("Switch")
-    })
-    items.availablePieces.model.append( {
-        "imgName": "signalGenerator.svg",
-        "componentSrc": "SignalGenerator.qml",
-        "imgWidth": sizeMultiplier * 0.25,
-        "imgHeight": sizeMultiplier * 0.18,
-        "toolTipText": qsTr("Signal Generator")
-    })
-    items.availablePieces.model.append( {
-        "imgName": "bcdCounter.svg",
-        "componentSrc": "BcdCounter.qml",
-        "imgWidth": sizeMultiplier * 0.3,
-        "imgHeight": sizeMultiplier * 0.4,
-        "toolTipText": qsTr("BCD Counter")
-    })
+    var componentList = items.tutorialDataset.componentList
+    for (var i = 0; i < componentList.length; i++) {
+        items.availablePieces.model.append( {
+            "imgName": componentList[i].imageName,
+            "componentSrc": componentList[i].componentSource,
+            "imgWidth": sizeMultiplier * componentList[i].width,
+            "imgHeight": sizeMultiplier * componentList[i].height,
+            "toolTipText": componentList[i].toolTipText
+        })
+    }
 }
 
 function isTutorialMode() {


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic