mirror of
https://github.com/Armored-Dragon/overte.git
synced 2025-03-11 16:13:16 +01:00
Big progress!
This commit is contained in:
parent
080c6da71a
commit
a21ff75a49
4 changed files with 187 additions and 6 deletions
|
@ -26,6 +26,8 @@ Rectangle {
|
||||||
id: checkoutRoot;
|
id: checkoutRoot;
|
||||||
property string itemId;
|
property string itemId;
|
||||||
property string itemHref;
|
property string itemHref;
|
||||||
|
property int balanceAfterPurchase: commerce.balance() - parseInt(itemPriceText.text, 10);
|
||||||
|
property bool alreadyOwned: checkAlreadyOwned(itemId);
|
||||||
// Style
|
// Style
|
||||||
color: hifi.colors.baseGray;
|
color: hifi.colors.baseGray;
|
||||||
Hifi.QmlCommerce {
|
Hifi.QmlCommerce {
|
||||||
|
@ -172,11 +174,56 @@ Rectangle {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// HFC Balance text
|
||||||
|
Item {
|
||||||
|
id: hfcBalanceContainer;
|
||||||
|
// Anchors
|
||||||
|
anchors.top: itemAuthorContainer.bottom;
|
||||||
|
anchors.topMargin: 16;
|
||||||
|
anchors.left: parent.left;
|
||||||
|
anchors.leftMargin: 16;
|
||||||
|
anchors.right: parent.right;
|
||||||
|
anchors.rightMargin: 16;
|
||||||
|
height: childrenRect.height;
|
||||||
|
|
||||||
|
RalewaySemiBold {
|
||||||
|
id: hfcBalanceTextLabel;
|
||||||
|
text: "HFC Balance:";
|
||||||
|
// Anchors
|
||||||
|
anchors.top: parent.top;
|
||||||
|
anchors.left: parent.left;
|
||||||
|
width: paintedWidth;
|
||||||
|
// Text size
|
||||||
|
size: 20;
|
||||||
|
// Style
|
||||||
|
color: hifi.colors.lightGrayText;
|
||||||
|
// Alignment
|
||||||
|
horizontalAlignment: Text.AlignHLeft;
|
||||||
|
verticalAlignment: Text.AlignVCenter;
|
||||||
|
}
|
||||||
|
RalewayRegular {
|
||||||
|
id: hfcBalanceText;
|
||||||
|
text: commerce.balance();
|
||||||
|
// Text size
|
||||||
|
size: hfcBalanceTextLabel.size;
|
||||||
|
// Anchors
|
||||||
|
anchors.top: parent.top;
|
||||||
|
anchors.left: hfcBalanceTextLabel.right;
|
||||||
|
anchors.leftMargin: 16;
|
||||||
|
width: paintedWidth;
|
||||||
|
// Style
|
||||||
|
color: hifi.colors.lightGrayText;
|
||||||
|
// Alignment
|
||||||
|
horizontalAlignment: Text.AlignHLeft;
|
||||||
|
verticalAlignment: Text.AlignVCenter;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Item Price text
|
// Item Price text
|
||||||
Item {
|
Item {
|
||||||
id: itemPriceContainer;
|
id: itemPriceContainer;
|
||||||
// Anchors
|
// Anchors
|
||||||
anchors.top: itemAuthorContainer.bottom;
|
anchors.top: hfcBalanceContainer.bottom;
|
||||||
anchors.topMargin: 4;
|
anchors.topMargin: 4;
|
||||||
anchors.left: parent.left;
|
anchors.left: parent.left;
|
||||||
anchors.leftMargin: 16;
|
anchors.leftMargin: 16;
|
||||||
|
@ -215,6 +262,51 @@ Rectangle {
|
||||||
verticalAlignment: Text.AlignVCenter;
|
verticalAlignment: Text.AlignVCenter;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// HFC "Balance After Purchase" text
|
||||||
|
Item {
|
||||||
|
id: hfcBalanceAfterPurchaseContainer;
|
||||||
|
// Anchors
|
||||||
|
anchors.top: itemPriceContainer.bottom;
|
||||||
|
anchors.topMargin: 4;
|
||||||
|
anchors.left: parent.left;
|
||||||
|
anchors.leftMargin: 16;
|
||||||
|
anchors.right: parent.right;
|
||||||
|
anchors.rightMargin: 16;
|
||||||
|
height: childrenRect.height;
|
||||||
|
|
||||||
|
RalewaySemiBold {
|
||||||
|
id: hfcBalanceAfterPurchaseTextLabel;
|
||||||
|
text: "HFC Balance After Purchase:";
|
||||||
|
// Anchors
|
||||||
|
anchors.top: parent.top;
|
||||||
|
anchors.left: parent.left;
|
||||||
|
width: paintedWidth;
|
||||||
|
// Text size
|
||||||
|
size: 20;
|
||||||
|
// Style
|
||||||
|
color: hifi.colors.lightGrayText;
|
||||||
|
// Alignment
|
||||||
|
horizontalAlignment: Text.AlignHLeft;
|
||||||
|
verticalAlignment: Text.AlignVCenter;
|
||||||
|
}
|
||||||
|
RalewayRegular {
|
||||||
|
id: hfcBalanceAfterPurchaseText;
|
||||||
|
text: balanceAfterPurchase;
|
||||||
|
// Text size
|
||||||
|
size: hfcBalanceAfterPurchaseTextLabel.size;
|
||||||
|
// Anchors
|
||||||
|
anchors.top: parent.top;
|
||||||
|
anchors.left: hfcBalanceAfterPurchaseTextLabel.right;
|
||||||
|
anchors.leftMargin: 16;
|
||||||
|
width: paintedWidth;
|
||||||
|
// Style
|
||||||
|
color: (balanceAfterPurchase >= 0) ? hifi.colors.lightGrayText : hifi.colors.redHighlight;
|
||||||
|
// Alignment
|
||||||
|
horizontalAlignment: Text.AlignHLeft;
|
||||||
|
verticalAlignment: Text.AlignVCenter;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
// ITEM DESCRIPTION END
|
// ITEM DESCRIPTION END
|
||||||
|
@ -231,7 +323,8 @@ Rectangle {
|
||||||
height: 40;
|
height: 40;
|
||||||
// Anchors
|
// Anchors
|
||||||
anchors.left: parent.left;
|
anchors.left: parent.left;
|
||||||
anchors.top: itemDescriptionContainer.bottom;
|
anchors.bottom: parent.bottom;
|
||||||
|
anchors.bottomMargin: 8;
|
||||||
|
|
||||||
// "Cancel" button
|
// "Cancel" button
|
||||||
HifiControlsUit.Button {
|
HifiControlsUit.Button {
|
||||||
|
@ -255,6 +348,7 @@ Rectangle {
|
||||||
HifiControlsUit.Button {
|
HifiControlsUit.Button {
|
||||||
property bool buyFailed: false;
|
property bool buyFailed: false;
|
||||||
id: buyButton;
|
id: buyButton;
|
||||||
|
enabled: balanceAfterPurchase >= 0 && !alreadyOwned;
|
||||||
color: hifi.buttons.black;
|
color: hifi.buttons.black;
|
||||||
colorScheme: hifi.colorSchemes.dark;
|
colorScheme: hifi.colorSchemes.dark;
|
||||||
anchors.top: parent.top;
|
anchors.top: parent.top;
|
||||||
|
@ -264,7 +358,7 @@ Rectangle {
|
||||||
anchors.right: parent.right;
|
anchors.right: parent.right;
|
||||||
anchors.rightMargin: 20;
|
anchors.rightMargin: 20;
|
||||||
width: parent.width/2 - anchors.rightMargin*2;
|
width: parent.width/2 - anchors.rightMargin*2;
|
||||||
text: "Buy"
|
text: alreadyOwned ? "Already Owned" : "Buy";
|
||||||
onClicked: {
|
onClicked: {
|
||||||
if (buyFailed) {
|
if (buyFailed) {
|
||||||
sendToScript({method: 'checkout_cancelClicked', params: itemId});
|
sendToScript({method: 'checkout_cancelClicked', params: itemId});
|
||||||
|
@ -287,6 +381,16 @@ Rectangle {
|
||||||
//
|
//
|
||||||
// FUNCTION DEFINITIONS START
|
// FUNCTION DEFINITIONS START
|
||||||
//
|
//
|
||||||
|
|
||||||
|
function checkAlreadyOwned(idToCheck) {
|
||||||
|
var inventory = commerce.inventory();
|
||||||
|
if (inventory.indexOf(idToCheck) !== -1) {
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Function Name: fromScript()
|
// Function Name: fromScript()
|
||||||
//
|
//
|
||||||
|
@ -308,7 +412,6 @@ Rectangle {
|
||||||
itemAuthorText.text = message.params.itemAuthor;
|
itemAuthorText.text = message.params.itemAuthor;
|
||||||
itemPriceText.text = message.params.itemPrice;
|
itemPriceText.text = message.params.itemPrice;
|
||||||
itemHref = message.params.itemHref;
|
itemHref = message.params.itemHref;
|
||||||
buyButton.text = "Buy";
|
|
||||||
buyButton.buyFailed = false;
|
buyButton.buyFailed = false;
|
||||||
break;
|
break;
|
||||||
case 'buyFailed':
|
case 'buyFailed':
|
||||||
|
|
|
@ -120,6 +120,77 @@ Rectangle {
|
||||||
// HFC BALANCE END
|
// HFC BALANCE END
|
||||||
//
|
//
|
||||||
|
|
||||||
|
//
|
||||||
|
// INVENTORY CONTENTS START
|
||||||
|
//
|
||||||
|
Item {
|
||||||
|
id: inventoryContentsContainer;
|
||||||
|
// Anchors
|
||||||
|
anchors.left: parent.left;
|
||||||
|
anchors.leftMargin: 16;
|
||||||
|
anchors.right: parent.right;
|
||||||
|
anchors.rightMargin: 16;
|
||||||
|
anchors.top: hfcBalanceContainer.bottom;
|
||||||
|
anchors.topMargin: 8;
|
||||||
|
anchors.bottom: actionButtonsContainer.top;
|
||||||
|
anchors.bottomMargin: 8;
|
||||||
|
|
||||||
|
RalewaySemiBold {
|
||||||
|
id: inventoryContentsLabel;
|
||||||
|
text: "Inventory:";
|
||||||
|
// Anchors
|
||||||
|
anchors.top: parent.top;
|
||||||
|
anchors.left: parent.left;
|
||||||
|
width: paintedWidth;
|
||||||
|
// Text size
|
||||||
|
size: 24;
|
||||||
|
// Style
|
||||||
|
color: hifi.colors.lightGrayText;
|
||||||
|
// Alignment
|
||||||
|
horizontalAlignment: Text.AlignHLeft;
|
||||||
|
verticalAlignment: Text.AlignVCenter;
|
||||||
|
}
|
||||||
|
ListView {
|
||||||
|
id: inventoryContentsList;
|
||||||
|
// Anchors
|
||||||
|
anchors.top: inventoryContentsLabel.bottom;
|
||||||
|
anchors.topMargin: 8;
|
||||||
|
anchors.left: parent.left;
|
||||||
|
anchors.bottom: parent.bottom;
|
||||||
|
width: parent.width;
|
||||||
|
model: commerce.inventory();
|
||||||
|
delegate: Item {
|
||||||
|
width: parent.width;
|
||||||
|
height: 30;
|
||||||
|
RalewayRegular {
|
||||||
|
id: thisItemId;
|
||||||
|
// Text size
|
||||||
|
size: 20;
|
||||||
|
// Style
|
||||||
|
color: hifi.colors.blueAccent;
|
||||||
|
text: modelData;
|
||||||
|
// Alignment
|
||||||
|
horizontalAlignment: Text.AlignHLeft;
|
||||||
|
}
|
||||||
|
MouseArea {
|
||||||
|
anchors.fill: parent;
|
||||||
|
hoverEnabled: enabled;
|
||||||
|
onClicked: {
|
||||||
|
sendToScript({method: 'inventory_itemClicked', itemId: thisItemId.text});
|
||||||
|
}
|
||||||
|
onEntered: {
|
||||||
|
thisItemId.color = hifi.colors.blueHighlight;
|
||||||
|
}
|
||||||
|
onExited: {
|
||||||
|
thisItemId.color = hifi.colors.blueAccent;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//
|
||||||
|
// INVENTORY CONTENTS END
|
||||||
|
//
|
||||||
|
|
||||||
//
|
//
|
||||||
// ACTION BUTTONS START
|
// ACTION BUTTONS START
|
||||||
|
@ -131,7 +202,8 @@ Rectangle {
|
||||||
height: 40;
|
height: 40;
|
||||||
// Anchors
|
// Anchors
|
||||||
anchors.left: parent.left;
|
anchors.left: parent.left;
|
||||||
anchors.top: hfcBalanceContainer.bottom;
|
anchors.bottom: parent.bottom;
|
||||||
|
anchors.bottomMargin: 8;
|
||||||
|
|
||||||
// "Back" button
|
// "Back" button
|
||||||
HifiControlsUit.Button {
|
HifiControlsUit.Button {
|
||||||
|
|
|
@ -114,7 +114,7 @@
|
||||||
itemId: id,
|
itemId: id,
|
||||||
itemName: name,
|
itemName: name,
|
||||||
itemAuthor: author,
|
itemAuthor: author,
|
||||||
itemPrice: price,
|
itemPrice: Math.round(Math.random() * 50),
|
||||||
itemHref: href
|
itemHref: href
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
|
@ -212,6 +212,12 @@
|
||||||
}
|
}
|
||||||
//tablet.popFromStack();
|
//tablet.popFromStack();
|
||||||
break;
|
break;
|
||||||
|
case 'inventory_itemClicked':
|
||||||
|
var itemId = message.itemId;
|
||||||
|
if (itemId && itemId !== "") {
|
||||||
|
tablet.gotoWebScreen(MARKETPLACE_URL + '/items/' + itemId, MARKETPLACES_INJECT_SCRIPT_URL);
|
||||||
|
}
|
||||||
|
break;
|
||||||
case 'inventory_backClicked':
|
case 'inventory_backClicked':
|
||||||
tablet.gotoWebScreen(message.referrerURL, MARKETPLACES_INJECT_SCRIPT_URL);
|
tablet.gotoWebScreen(message.referrerURL, MARKETPLACES_INJECT_SCRIPT_URL);
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in a new issue