import QtGraphicalEffects 1.0 import QtQuick 2.7 import QtQuick.Controls 2.4 import QtQuick.Controls 1.4 import QtQuick.Controls.Material 2.0 import QtQuick.Layouts 1.3 import "../widgets" import "../widgets/controls" as Awesome import "../fonts/Twemoji.js" as T import "../utils.js" as Utils ColumnLayout { Layout.fillWidth: true width:parent.width anchors.horizontalCenter: parent.horizontalCenter id: puzzleGame Connections { target: gcd onClearMessages: function() { } onAppendMessage: function(handle, from, displayName, message, image, mid, fromMe, ts) { var msg try { msg = JSON.parse(message) } catch (e) { return } if (msg.o != 3) return if (msg.p != undefined && msg.s != undefined) { var points = JSON.stringify(msg.s) var path = JSON.stringify(msg.p) var remove = -1 for(var i=0;i -1) { solutions.remove(remove) //console.log("Better solution found for Puzzle " + "Puzzle " + JSON.stringify(msg.s)) } solutions.insert(0,{ "text": "Puzzle " + JSON.stringify(msg.s), "points":points, "path": path, "from": from, "displayName": displayName, "timestamp": ts }) } } } ListModel { id: solutions } RowLayout { anchors.right: parent.right anchors.rightMargin: 2 ComboBox { width: 200 textRole: "text" model: solutions onActivated: { //console.log("Loading puzzle " + index) var solution = solutions.get(index) //console.log("Loading puzzle " + JSON.parse(solution.path)) canvas.points = JSON.parse(solution.points) canvas.path = JSON.parse(solution.path) gameScore.text = Utils.scorePath(canvas.path) canvas.requestPaint() } } Slider { id: gameDifficulty value: 5 stepSize: 1.0 minimumValue: 4.0 maximumValue: 16.0 anchors.rightMargin: 2 } SimpleButton { // New Game id: btnNewGame icon: "regular/paper-plane" text: "new game" anchors.rightMargin: 2 property int nextMessageID: 1 onClicked: { canvas.points = [] canvas.path = [] gameScore.text = 0 for(var i=0;i