significantly changed the buying mechanism

This commit is contained in:
Manuel Simon Hirsig
2015-10-01 02:22:36 +02:00
parent 6d0ccf3eb4
commit 69f334cedc
4 changed files with 156 additions and 63 deletions
+95 -53
View File
@@ -6,6 +6,14 @@ local selectedEntries = {}
local search_query
local tooltip_patterns = {}
local current_page
local refresh
function Aux.buy.exit()
Aux.buy.buyout_dialog_cancel()
current_page = nil
end
-----------------------------------------
@@ -18,6 +26,14 @@ end
-----------------------------------------
function Aux.buy.buyout_dialog_cancel()
Aux.scan.abort()
AuxBuyBuyoutDialog:Hide()
AuxBuySearchButton:Enable()
end
-----------------------------------------
function Aux.buy.StopButton_onclick()
Aux.scan.abort()
end
@@ -32,7 +48,7 @@ function Aux.buy.SearchButton_onclick()
entries = nil
selectedEntries = {}
Aux_Buy_ScrollbarUpdate()
refresh = true
local category = UIDropDownMenu_GetSelectedValue(AuxBuyCategoryDropDown)
local tooltip_patterns = Aux.util.set_to_array(tooltip_patterns)
@@ -77,13 +93,13 @@ function Aux.buy.SearchButton_onclick()
entries = entries or {}
AuxBuyStopButton:Hide()
AuxBuySearchButton:Show()
Aux_Buy_ScrollbarUpdate()
refresh = true
end,
on_abort = function()
entries = entries or {}
AuxBuyStopButton:Hide()
AuxBuySearchButton:Show()
Aux_Buy_ScrollbarUpdate()
refresh = true
end,
next_page = function(page, auctions)
if auctions == Aux.scan.MAX_AUCTIONS_PER_PAGE then
@@ -103,10 +119,38 @@ end
-----------------------------------------
function AuxBuyEntry_OnClick()
local express_mode = IsControlKeyDown()
AuxBuySearchButton:Disable()
local i = this:GetID()
local entry = entries[i]
local entry_index = this:GetID()
local entry = entries[entry_index]
if not express_mode then
AuxBuyBuyoutDialogBuyButton:Disable()
AuxBuyBuyoutDialogHTML:SetText(string.format(
[[
<html>
<body>
<h1>%s</h1>
<br/>
<p>
Stack Size: %i
<br/><br/>
Buyout Price: %s
<br/><br/>
Unit Price: %s
</p>
</body>
</html>
]],
entry.name,
entry.stack_size,
Aux.util.format_money(entry.buyout_price),
Aux.util.format_money(entry.item_price)
))
AuxBuyBuyoutDialog:Show()
end
PlaySound("igMainMenuOptionCheckBoxOn")
@@ -132,25 +176,47 @@ function AuxBuyEntry_OnClick()
local key = Aux.auction_key(auction_item.tooltip, stack_size, auction_item.buyout_price)
if key == order_key then
found = true
if GetMoney() >= auction_item.buyout_price then
PlaceAuctionBid("list", i, auction_item.buyout_price)
tremove(entries,i)
if express_mode then
if GetMoney() >= auction_item.buyout_price then
tremove(entries, entry_index)
refresh = true
end
PlaceAuctionBid("list", i, auction_item.buyout_price)
Aux.scan.abort()
else
Aux.buy.buyout_dialog_buy = function()
if GetMoney() >= auction_item.buyout_price then
tremove(entries, entry_index)
refresh = true
end
PlaceAuctionBid("list", i, auction_item.buyout_price)
Aux.scan.abort()
AuxBuySearchButton:Enable()
AuxBuyBuyoutDialog:Hide()
end
AuxBuyBuyoutDialogBuyButton:Enable()
end
end
end,
on_complete = function()
if not found then
tremove(entries,i)
tremove(entries, entry_index)
refresh = true
Aux.buy.buyout_dialog_cancel()
end
if express_mode then
AuxBuySearchButton:Enable()
end
AuxBuySearchButton:Enable()
Aux_Buy_ScrollbarUpdate()
end,
on_abort = function()
AuxBuySearchButton:Enable()
Aux_Buy_ScrollbarUpdate()
if express_mode then
AuxBuySearchButton:Enable()
end
end,
}
end
@@ -173,13 +239,13 @@ function record_auction(name, tooltip, stack_size, buyout_price, quality, owner,
if buyout_price > 0 and owner ~= UnitName("player") then
tinsert(entries, {
name = name,
tooltip = tooltip,
stack_size = stack_size,
buyout_price = buyout_price,
item_price = buyout_price / stack_size,
quality = quality,
hyperlink = hyperlink,
name = name,
tooltip = tooltip,
stack_size = stack_size,
buyout_price = buyout_price,
item_price = buyout_price / stack_size,
quality = quality,
hyperlink = hyperlink,
itemstring = itemstring,
page = current_page,
})
@@ -190,6 +256,15 @@ end
-----------------------------------------
function Aux.buy.onupdate()
if refresh then
refresh = false
Aux_Buy_ScrollbarUpdate()
end
end
-----------------------------------------
function Aux_Buy_ScrollbarUpdate()
if entries and getn(entries) == 0 then
set_message("No auctions were found")
@@ -265,39 +340,6 @@ end
-----------------------------------------
function report(completed, item_name, ordered_count, progress)
AuxBuyReportHTML:SetText(string.format(
[[
<html>
<body>
<h1>Aux Buy Report%s</h1>
<br/>
<p>
%i out of %i ordered auctions of %s purchased
<br/><br/>
Total units purchased: %i
<br/>
Total expense: %s
</p>
</body>
</html>
]],
completed and '' or ' (Aborted)',
progress.auctions,
ordered_count,
item_name,
progress.units,
Aux.util.format_money(progress.expense)
))
AuxBuyReportHTML:SetSpacing(3)
AuxBuyReport:Show()
end
-----------------------------------------
function AuxBuyCategoryDropDown_Initialize(arg1)
local level = arg1 or 1
+56 -3
View File
@@ -2,6 +2,14 @@
<Script file="buy.lua"/>
<Frame>
<Scripts>
<OnUpdate>
Aux.buy.onupdate()
</OnUpdate>
</Scripts>
</Frame>
<Button name="AuxBuyEntryTemplate" virtual="true" hidden="true">
<Size><AbsDimension y="16"/></Size>
<Frames>
@@ -128,7 +136,7 @@
</Layers>
<Frames>
<Frame name="AuxBuyList" inherits="ListTemplate">
<!-- <Frame name="AuxBuyList" inherits="ListTemplate">
<Size><AbsDimension x="610" y="334"/></Size>
<Anchors><Anchor point="TOPLEFT"><Offset><AbsDimension x="187" y="-77"/></Offset></Anchor></Anchors>
<Scripts>
@@ -136,7 +144,7 @@
Aux.list.initialize(this, {{ width=50, logicalColumns={1,2,3} }, { width=50, logicalColumns={1,2,3} }})
</OnLoad>
</Scripts>
</Frame>
</Frame> -->
<Frame name="AuxBuyFilters">
<Size><AbsDimension x="1" y="1"/></Size>
<Anchors><Anchor point="TOPLEFT"><Offset><AbsDimension x="80" y="-46"/></Offset></Anchor></Anchors>
@@ -357,7 +365,52 @@
<Button name="AuxBuyEntry16" inherits="AuxBuyEntryTemplate"><Anchors><Anchor point="TOPLEFT" relativeTo="AuxBuyEntry15" relativePoint="BOTTOMLEFT"/></Anchors></Button>
<Button name="AuxBuyEntry17" inherits="AuxBuyEntryTemplate"><Anchors><Anchor point="TOPLEFT" relativeTo="AuxBuyEntry16" relativePoint="BOTTOMLEFT"/></Anchors></Button>
<Button name="AuxBuyEntry18" inherits="AuxBuyEntryTemplate"><Anchors><Anchor point="TOPLEFT" relativeTo="AuxBuyEntry17" relativePoint="BOTTOMLEFT"/></Anchors></Button>
<Button name="AuxBuyEntry19" inherits="AuxBuyEntryTemplate"><Anchors><Anchor point="TOPLEFT" relativeTo="AuxBuyEntry18" relativePoint="BOTTOMLEFT"/></Anchors></Button>
<Button name="AuxBuyEntry19" inherits="AuxBuyEntryTemplate"><Anchors><Anchor point="TOPLEFT" relativeTo="AuxBuyEntry18" relativePoint="BOTTOMLEFT"/></Anchors></Button>
<Frame name="AuxBuyBuyoutDialog" frameStrata="FULLSCREEN_DIALOG" toplevel="true" enableMouse="true" hidden="true" movable="true">
<Size><AbsDimension x="260" y="160" /></Size>
<Anchors><Anchor point="TOPLEFT"><Offset><AbsDimension x="300" y="-150"/></Offset></Anchor></Anchors>
<Scripts>
<OnLoad>this:RegisterForDrag("LeftButton")</OnLoad>
<OnDragStart>this:StartMoving()</OnDragStart>
<OnDragStop>this:StopMovingOrSizing()</OnDragStop>
</Scripts>
<Backdrop bgFile="Interface\CharacterFrame\UI-Party-Background" edgeFile="Interface\DialogFrame\UI-DialogBox-Border" tile="true">
<BackgroundInsets><AbsInset left="11" right="12" top="12" bottom="11"/></BackgroundInsets>
<TileSize><AbsValue val="32"/></TileSize>
<EdgeSize><AbsValue val="32"/></EdgeSize>
</Backdrop>
<Frames>
<SimpleHTML name="$parentHTML">
<Size><AbsDimension x="420" y="420" /></Size>
<Anchors>
<Anchor point="TOPLEFT"><Offset><AbsDimension x="30" y="-30"/></Offset></Anchor>
</Anchors>
<FontString inherits="GameFontHighlightSmall"/>
<FontStringHeader1 inherits="GameFontNormal"/>
</SimpleHTML>
<Button name="$parentBuyButton" inherits="UIPanelButtonTemplate" text="Buy" disabled="true">
<Size><AbsDimension x="100" y="22"/> </Size>
<Anchors><Anchor point="BOTTOMLEFT"><Offset><AbsDimension x="20" y="15"/></Offset></Anchor></Anchors>
<Scripts>
<OnClick>
Aux.buy.buyout_dialog_buy()
</OnClick>
</Scripts>
</Button>
<Button name="$parentCancelButton" inherits="UIPanelButtonTemplate" text="Cancel">
<Size><AbsDimension x="100" y="22"/> </Size>
<Anchors><Anchor point="BOTTOMRIGHT"><Offset><AbsDimension x="-20" y="15"/></Offset></Anchor></Anchors>
<Scripts>
<OnClick>
Aux.buy.buyout_dialog_cancel()
</OnClick>
</Scripts>
</Button>
</Frames>
</Frame>
</Frames>
</Frame>
+5 -6
View File
@@ -196,9 +196,8 @@ function Aux_OnAuctionHouseClosed()
Aux.post.stop()
Aux.stack.stop()
if not Aux.scan.idle() then
Aux.scan.abort()
end
Aux.buy.exit()
Aux.scan.abort()
AuxOptionsButtonPanel:Hide()
AuxOptionsFrame:Hide()
@@ -218,9 +217,9 @@ function Aux_AuctionFrameTab_OnClick(index)
Aux.post.stop()
Aux.stack.stop()
if not Aux.scan.idle() then
Aux.scan.abort()
end
Aux.buy.exit()
Aux.scan.abort()
AuxSellPanel:Hide()
AuxBuyPanel:Hide()
-1
View File
@@ -2,7 +2,6 @@
<Script file="core.lua"/>
<!-- Frame to handle all core events -->
<Frame>
<Scripts>
<OnLoad>