mirror of
https://github.com/overte-org/overte.git
synced 2025-07-16 00:56:48 +02:00
Beginning of stack stuff
This commit is contained in:
parent
45424f0cfe
commit
1493a310af
2 changed files with 56 additions and 4 deletions
|
@ -240,7 +240,9 @@ Rectangle {
|
||||||
anchors.leftMargin: 20;
|
anchors.leftMargin: 20;
|
||||||
width: parent.width/2 - anchors.leftMargin*2;
|
width: parent.width/2 - anchors.leftMargin*2;
|
||||||
text: "Cancel"
|
text: "Cancel"
|
||||||
//onClicked: deleteAttachment(root.attachment);
|
onClicked: {
|
||||||
|
sendToScript({method: 'checkout_cancelClicked'});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// "Buy" button
|
// "Buy" button
|
||||||
|
@ -255,7 +257,9 @@ Rectangle {
|
||||||
anchors.rightMargin: 20;
|
anchors.rightMargin: 20;
|
||||||
width: parent.width/2 - anchors.rightMargin*2;
|
width: parent.width/2 - anchors.rightMargin*2;
|
||||||
text: "Buy"
|
text: "Buy"
|
||||||
//onClicked: deleteAttachment(root.attachment);
|
onClicked: {
|
||||||
|
sendToScript({method: 'checkout_buyClicked'});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
|
@ -281,7 +285,6 @@ Rectangle {
|
||||||
function fromScript(message) {
|
function fromScript(message) {
|
||||||
switch (message.method) {
|
switch (message.method) {
|
||||||
case 'updateCheckoutQML':
|
case 'updateCheckoutQML':
|
||||||
console.log("ZRF:", JSON.stringify(message));
|
|
||||||
itemNameText.text = message.params.itemName;
|
itemNameText.text = message.params.itemName;
|
||||||
itemAuthorText.text = message.params.itemAuthor;
|
itemAuthorText.text = message.params.itemAuthor;
|
||||||
itemPriceText.text = message.params.itemPrice;
|
itemPriceText.text = message.params.itemPrice;
|
||||||
|
|
|
@ -131,7 +131,8 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
function onScreenChanged(type, url) {
|
function onScreenChanged(type, url) {
|
||||||
onMarketplaceScreen = type === "Web" && url === MARKETPLACE_URL_INITIAL
|
onMarketplaceScreen = type === "Web" && url === MARKETPLACE_URL_INITIAL;
|
||||||
|
wireEventBridge(type === "QML" && url === MARKETPLACE_CHECKOUT_QML_PATH);
|
||||||
// for toolbar mode: change button to active when window is first openend, false otherwise.
|
// for toolbar mode: change button to active when window is first openend, false otherwise.
|
||||||
marketplaceButton.editProperties({ isActive: onMarketplaceScreen });
|
marketplaceButton.editProperties({ isActive: onMarketplaceScreen });
|
||||||
if (type === "Web" && url.indexOf(MARKETPLACE_URL) !== -1) {
|
if (type === "Web" && url.indexOf(MARKETPLACE_URL) !== -1) {
|
||||||
|
@ -154,4 +155,52 @@
|
||||||
Entities.canWriteAssetsChanged.disconnect(onCanWriteAssetsChanged);
|
Entities.canWriteAssetsChanged.disconnect(onCanWriteAssetsChanged);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// Function Name: wireEventBridge()
|
||||||
|
//
|
||||||
|
// Description:
|
||||||
|
// -Used to connect/disconnect the script's response to the tablet's "fromQml" signal. Set the "on" argument to enable or
|
||||||
|
// disable to event bridge.
|
||||||
|
//
|
||||||
|
// Relevant Variables:
|
||||||
|
// -hasEventBridge: true/false depending on whether we've already connected the event bridge.
|
||||||
|
var hasEventBridge = false;
|
||||||
|
function wireEventBridge(on) {
|
||||||
|
if (!tablet) {
|
||||||
|
print("Warning in wireEventBridge(): 'tablet' undefined!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (on) {
|
||||||
|
if (!hasEventBridge) {
|
||||||
|
tablet.fromQml.connect(fromQml);
|
||||||
|
hasEventBridge = true;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (hasEventBridge) {
|
||||||
|
tablet.fromQml.disconnect(fromQml);
|
||||||
|
hasEventBridge = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Function Name: fromQml()
|
||||||
|
//
|
||||||
|
// Description:
|
||||||
|
// -Called when a message is received from Checkout.qml. The "message" argument is what is sent from the Checkout QML
|
||||||
|
// in the format "{method, params}", like json-rpc.
|
||||||
|
function fromQml(message) {
|
||||||
|
switch (message.method) {
|
||||||
|
case 'checkout_cancelClicked':
|
||||||
|
print('fromQml: ' + JSON.stringify(message));
|
||||||
|
tablet.popFromStack();
|
||||||
|
break;
|
||||||
|
case 'checkout_buyClicked':
|
||||||
|
tablet.popFromStack();
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
print('Unrecognized message from Checkout.qml: ' + JSON.stringify(message));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}()); // END LOCAL_SCOPE
|
}()); // END LOCAL_SCOPE
|
||||||
|
|
Loading…
Reference in a new issue