reworked buying mechanism

This commit is contained in:
Manuel Simon Hirsig
2016-01-24 00:25:28 +01:00
parent c104881f46
commit 3258e60214
6 changed files with 90 additions and 218 deletions
+1
View File
@@ -99,6 +99,7 @@ function Aux_OnLoad()
Aux.item_search_frame.on_load()
Aux.filter_search_frame.on_load()
Aux.post_frame.on_load()
end
function Aux_OnEvent()
+27 -17
View File
@@ -9,8 +9,8 @@ m.config = {
content_border_color = {0, 0, 0, 0},
content_font = [[Fonts\ARIALN.TTF]],
normal_font_size = 15,
text_color = { enabled = { 255, 254, 250, 1 }, disabled = { 147, 151, 139, 1 } },
label_color = { enabled = { 216, 225, 211, 1 }, disabled = { 150, 148, 140, 1 } },
text_color = { enabled = { 255/255, 254/255, 250/255, 1 }, disabled = { 147/255, 151/255, 139/255, 1 } },
label_color = { enabled = { 216/255, 225/255, 211/255, 1 }, disabled = { 150/255, 148/255, 140/255, 1 } },
}
@@ -24,17 +24,27 @@ function m.button(parent, text_height, name)
highlight:SetTexture(1, 1, 1, .2)
highlight:SetBlendMode('BLEND')
button.highlight = highlight
button:Show()
local label = button:CreateFontString()
label:SetFont(m.config.content_font, text_height)
label:SetPoint('CENTER', 0, 0)
label:SetJustifyH('CENTER')
label:SetJustifyV('CENTER')
label:SetHeight(text_height)
label:SetTextColor(255/255, 254/255, 250/255)
-- TSM:Hook(button, "Enable", function() TSMAPI.Design:SetWidgetTextColor(label) end, true)
-- TSM:Hook(button, "Disable", function() TSMAPI.Design:SetWidgetTextColor(label, true) end, true)
button:SetFontString(label)
do
local label = button:CreateFontString()
label:SetFont(m.config.content_font, text_height)
label:SetPoint('CENTER', 0, 0)
label:SetJustifyH('CENTER')
label:SetJustifyV('CENTER')
label:SetHeight(text_height)
label:SetTextColor(unpack(m.config.text_color.enabled))
button:SetFontString(label)
end
button.default_Enable = button.Enable
function button:Enable()
self:GetFontString():SetTextColor(unpack(m.config.text_color.enabled))
return self:default_Enable()
end
button.default_Disable = button.Disable
function button:Disable()
self:GetFontString():SetTextColor(unpack(m.config.text_color.disabled))
return self:default_Disable()
end
return button
end
@@ -238,7 +248,7 @@ function m.editbox(parent, name)
return editbox
end
function m.status_bar(parent, base_name)
function m.status_bar(parent)
local self = CreateFrame('Frame', nil, parent)
local level = parent:GetFrameLevel()
@@ -247,11 +257,11 @@ function m.status_bar(parent, base_name)
do
-- minor status bar (gray one)
local status_bar = CreateFrame('STATUSBAR', base_name..'_minor', self, 'TextStatusBar')
local status_bar = CreateFrame('STATUSBAR', nil, self, 'TextStatusBar')
status_bar:SetOrientation('HORIZONTAL')
status_bar:SetMinMaxValues(0, 100)
status_bar:SetAllPoints()
status_bar:SetStatusBarTexture('[[Interface\Buttons\WHITE8X8]]')
status_bar:SetStatusBarTexture([[Interface\Buttons\WHITE8X8]])
status_bar:SetStatusBarColor(.42, .42, .42, .7)
status_bar:SetFrameLevel(level + 2)
-- local ag = status_bar:CreateAnimationGroup()
@@ -265,7 +275,7 @@ function m.status_bar(parent, base_name)
do
-- major status bar (main blue one)
local status_bar = CreateFrame('STATUSBAR', base_name..'_major', self, 'TextStatusBar')
local status_bar = CreateFrame('STATUSBAR', nil, self, 'TextStatusBar')
status_bar:SetOrientation('HORIZONTAL')
status_bar:SetMinMaxValues(0, 100)
status_bar:SetAllPoints()
+41 -59
View File
@@ -85,7 +85,10 @@ public.views = {
Aux.info.set_tooltip(sheet.rows[row_index].itemstring, sheet.rows[row_index].EnhTooltip_info, this, 'ANCHOR_RIGHT', 0, 0)
end,
on_row_leave = function (sheet, row_index)
sheet.rows[row_index].highlight:SetAlpha(0)
local data_index = row_index + FauxScrollFrame_GetOffset(sheet.scroll_frame)
if sheet.data[data_index][1].signature ~= Aux.util.safe_index{private.selected, 'signature'} then
sheet.rows[row_index].highlight:SetAlpha(0)
end
AuxTooltip:Hide()
ResetCursor()
end,
@@ -101,6 +104,11 @@ public.views = {
row_setter = function(row, group)
row.itemstring = Aux.info.itemstring(group[1].item_id, group[1].suffix_id, nil, group[1].enchant_id)
row.EnhTooltip_info = group[1].EnhTooltip_info
if group[1].signature == Aux.util.safe_index{private.selected, 'signature'} then
row.highlight:SetAlpha(.5)
else
row.highlight:SetAlpha(0)
end
end,
columns = {
{
@@ -456,26 +464,23 @@ public.views = {
}
function public.on_close()
if AuxItemSearchFrameAuctionsConfirmation:IsVisible() then
public.dialog_cancel()
end
current_page = nil
end
function public.on_open()
public.update_item()
private.update_recently_searched()
update_listing()
if not private.item_id then
AuxItemSearchFrameItemRefreshButton:Disable()
end
private.tab_group:set_tab(aux_view)
end
function public.on_load()
do
local btn = Aux.gui.button(AuxItemSearchFrameItem, 15, '$parentRefreshButton')
btn:SetPoint('BOTTOMLEFT', 8, 15)
btn:SetWidth(75)
btn:SetWidth(80)
btn:SetHeight(24)
btn:SetText('Refresh')
btn:SetScript('OnClick', Aux.item_search_frame.start_search)
@@ -483,7 +488,7 @@ function public.on_load()
do
local btn = Aux.gui.button(AuxItemSearchFrameItem, 15, '$parentStopButton')
btn:SetPoint('BOTTOMLEFT', 8, 15)
btn:SetWidth(75)
btn:SetWidth(80)
btn:SetHeight(24)
btn:SetText('Stop')
btn:SetScript('OnClick', Aux.item_search_frame.stop_search)
@@ -495,7 +500,7 @@ function public.on_load()
tab_group:create_tab('Bid')
tab_group:create_tab('Full')
tab_group.on_select = Aux.item_search_frame.set_view
tab_group:set_tab(aux_view)
private.tab_group = tab_group
end
do
local editbox = Aux.gui.editbox(AuxItemSearchFrameItem, '$parentItemInputBox')
@@ -534,7 +539,7 @@ function public.on_load()
end)
end
do
local status_bar = Aux.gui.status_bar(AuxItemSearchFrame, 15, 'kekbar')
local status_bar = Aux.gui.status_bar(AuxItemSearchFrame)
status_bar:SetWidth(265)
status_bar:SetHeight(30)
status_bar:SetPoint('BOTTOMLEFT', AuxItemSearchFrame, 'BOTTOMLEFT', 6, 6)
@@ -542,13 +547,15 @@ function public.on_load()
status_bar:set_text('')
private.status_bar = status_bar
end
end
function public.dialog_cancel()
Aux.scan.abort()
AuxItemSearchFrameAuctionsConfirmation:Hide()
update_listing()
AuxItemSearchFrameItemRefreshButton:Enable()
do
local btn = Aux.gui.button(AuxItemSearchFrameItem, 15)
btn:SetPoint('TOPLEFT', private.status_bar, 'TOPRIGHT', 5, 0)
btn:SetWidth(80)
btn:SetHeight(24)
btn:SetText('Buyout')
btn:Disable()
private.buyout_button = btn
end
end
function public.stop_search()
@@ -557,6 +564,8 @@ end
function update_listing()
private.buyout_button:Disable()
if not AuxItemSearchFrame:IsVisible() then
return
end
@@ -678,7 +687,7 @@ function public.start_search()
current_page = nil
end,
on_page_loaded = function(page, total_pages)
private.status_bar:update_status(100 * (page + 1) / total_pages, 0)
private.status_bar:update_status(100 * (page + 1) / total_pages, 100 * (page + 1) / total_pages) -- TODO
private.status_bar:set_text(string.format('Scanning (Page %d / %d)', page + 1, total_pages))
-- Aux.log('Scanning page '..(page+1)..' out of '..total_pages..' ...')
current_page = page
@@ -720,36 +729,6 @@ function public.start_search()
end)
end
function show_dialog(buyout_mode, entry, amount)
AuxItemSearchFrameAuctionsConfirmationContentItem.itemstring = Aux.info.itemstring(entry.item_id, entry.suffix_id, entry.unique_id, entry.enchant_id)
AuxItemSearchFrameAuctionsConfirmationContentItem.EnhTooltip_info = entry.EnhTooltip_info
AuxItemSearchFrameAuctionsConfirmationContentActionButton:Disable()
AuxItemSearchFrameAuctionsConfirmationContentItemIconTexture:SetTexture(Aux.info.item(entry.item_id).texture)
AuxItemSearchFrameAuctionsConfirmationContentItemName:SetText(entry.name)
local color = ITEM_QUALITY_COLORS[entry.quality]
AuxItemSearchFrameAuctionsConfirmationContentItemName:SetTextColor(color.r, color.g, color.b)
if entry.aux_quantity > 1 then
AuxItemSearchFrameAuctionsConfirmationContentItemCount:SetText(entry.aux_quantity);
AuxItemSearchFrameAuctionsConfirmationContentItemCount:Show()
else
AuxItemSearchFrameAuctionsConfirmationContentItemCount:Hide()
end
if buyout_mode then
AuxItemSearchFrameAuctionsConfirmationContentActionButton:SetText('Buy')
MoneyFrame_Update('AuxItemSearchFrameAuctionsConfirmationContentBuyoutPrice', amount)
AuxItemSearchFrameAuctionsConfirmationContentBid:Hide()
AuxItemSearchFrameAuctionsConfirmationContentBuyoutPrice:Show()
else
AuxItemSearchFrameAuctionsConfirmationContentActionButton:SetText('Bid')
MoneyInputFrame_SetCopper(AuxItemSearchFrameAuctionsConfirmationContentBid, amount)
AuxItemSearchFrameAuctionsConfirmationContentBuyoutPrice:Hide()
AuxItemSearchFrameAuctionsConfirmationContentBid:Show()
end
AuxItemSearchFrameAuctionsConfirmation:Show()
end
function find_auction(entry, buyout_mode, express_mode)
if entry.gone then
@@ -769,12 +748,12 @@ function find_auction(entry, buyout_mode, express_mode)
amount = entry.bid
end
Aux.log('Searching auction ...')
AuxItemSearchFrameItemRefreshButton:Disable()
private.status_bar:update_status(0, 0)
private.status_bar:set_text('Searching auction...')
if not express_mode then
show_dialog(buyout_mode, entry, amount)
end
-- if not express_mode then
-- show_dialog(buyout_mode, entry, amount)
-- end
PlaySound('igMainMenuOptionCheckBoxOn')
@@ -794,7 +773,8 @@ function find_auction(entry, buyout_mode, express_mode)
if entry.signature == auction_record.signature then
ctrl.suspend()
found = true
Aux.log('Matching auction found.')
private.status_bar:update_status(100, 100)
private.status_bar:set_text('Auction found')
if express_mode then
if GetMoney() >= amount then
@@ -807,10 +787,10 @@ function find_auction(entry, buyout_mode, express_mode)
end
Aux.scan.abort()
else
public.dialog_action = function()
private.buyout_button:SetScript('OnClick', function()
if create_auction_record(Aux.info.auction(auction_info.index)).signature == entry.signature then
if GetMoney() >= amount then
PlaceAuctionBid('list', auction_info.index, buyout_mode and amount or MoneyInputFrame_GetCopper(AuxItemSearchFrameAuctionsConfirmationContentBid))
PlaceAuctionBid('list', auction_info.index, amount)
Aux.log((buyout_mode and 'Purchased ' or 'Bid on ')..auction_record.hyperlink..' ('..auction_record.aux_quantity..').')
entry.gone = true
refresh = true
@@ -818,12 +798,11 @@ function find_auction(entry, buyout_mode, express_mode)
Aux.log('Not enough money.')
end
Aux.scan.abort()
AuxItemSearchFrameItemRefreshButton:Enable()
AuxItemSearchFrameAuctionsConfirmation:Hide()
update_listing()
end
end
AuxItemSearchFrameAuctionsConfirmationContentActionButton:Enable()
private.buyout_button:Disable()
end)
private.buyout_button:Enable()
end
end
end,
@@ -853,6 +832,9 @@ end
function public.on_row_click(entry)
private.selected = entry
update_listing()
local express_mode = IsAltKeyDown()
local buyout_mode = arg1 == 'LeftButton'
-123
View File
@@ -35,65 +35,6 @@
</OnClick>
</scripts>
</Button>
<!--<EditBox name="$parentItemInputBox" autoFocus="false" inherits="AuxInputBoxTemplate">-->
<!--<Anchors><Anchor point="TOP"><Offset><AbsDimension x="2" y="-28"/></Offset></Anchor></Anchors>-->
<!--<Scripts>-->
<!--<OnLoad>-->
<!--this.selector = Aux.completion.selector(this)-->
<!--this:SetWidth(185)-->
<!--</OnLoad>-->
<!--<OnTextChanged>-->
<!--this.selector.suggest()-->
<!--</OnTextChanged>-->
<!--<OnTabPressed>-->
<!--if IsShiftKeyDown() then-->
<!--this.selector.previous()-->
<!--else-->
<!--this.selector.next()-->
<!--end-->
<!--</OnTabPressed>-->
<!--<OnEnterPressed>-->
<!--if this.selector.selected_value() then-->
<!--this:ClearFocus()-->
<!--end-->
<!--</OnEnterPressed>-->
<!--<OnEditFocusLost>-->
<!--this.selector.close()-->
<!--if this.selector.selected_value() then-->
<!--Aux.item_search_frame.set_item(this.selector.selected_value())-->
<!--end-->
<!--if Aux.item_search_frame.item_set() then-->
<!--this:Hide()-->
<!--this.selector.clear()-->
<!--Aux.item_search_frame.update_item()-->
<!--end-->
<!--</OnEditFocusLost>-->
<!--<OnEscapePressed>-->
<!--this.selector.clear()-->
<!--this:ClearFocus()-->
<!--</OnEscapePressed>-->
<!--</Scripts>-->
<!--</EditBox>-->
<!--<Button name="$parentRefreshButton" inherits="UIPanelButtonTemplate" text="Refresh" disabled="true">-->
<!--<Size><AbsDimension x="90" y="26"/></Size>-->
<!--<Anchors><Anchor point="BOTTOMLEFT" ><Offset><AbsDimension x="8" y="15"/></Offset></Anchor></Anchors>-->
<!--<Scripts>-->
<!--<OnClick>-->
<!--Aux.item_search_frame.start_search()-->
<!--</OnClick>-->
<!--</Scripts>-->
<!--</Button>-->
<!--<Button name="$parentStopButton" inherits="UIPanelButtonTemplate" text="Stop" hidden="true">-->
<!--<Size><AbsDimension x="90" y="26"/></Size>-->
<!--<Anchors><Anchor point="BOTTOMLEFT" ><Offset><AbsDimension x="8" y="15"/></Offset></Anchor></Anchors>-->
<!--<Scripts>-->
<!--<OnClick>-->
<!--Aux.item_search_frame.stop_search()-->
<!--</OnClick>-->
<!--</Scripts>-->
<!--</Button>-->
<EditBox name="$parentPageEditBox" numeric="true" autoFocus="false" inherits="AuxInputBoxTemplate">
<Anchors><Anchor point="BOTTOMLEFT" ><Offset><AbsDimension x="111" y="15"/></Offset></Anchor></Anchors>
<Scripts>
@@ -237,70 +178,6 @@
</OnLoad>
</Scripts>
</Frame>
<Frame name="$parentConfirmation" frameStrata="FULLSCREEN_DIALOG" inherits="OptionFrameBoxTemplate" enableMouse="true" enableMouseWheel="true" hidden="true">
<Anchors>
<Anchor point="TOPLEFT"><Offset><AbsDimension x="0" y="0"/></Offset></Anchor>
<Anchor point="BOTTOMRIGHT"><Offset><AbsDimension x="0" y="0"/></Offset></Anchor>
</Anchors>
<Scripts>
<OnMouseWheel></OnMouseWheel>
</Scripts>
<Frames>
<Frame name="$parentContent">
<Anchors><Anchor point="CENTER"><Offset><AbsDimension x="0" y="5"/></Offset></Anchor></Anchors>
<Size><AbsDimension x="193" y="120"/></Size>
<Frames>
<Frame name="$parentItem" inherits="AuxItemTemplate">
<Anchors><Anchor point="TOP"><Offset><AbsDimension x="0" y="0"/></Offset></Anchor></Anchors>
</Frame>
<Frame name="$parentBid" inherits="MoneyInputFrameTemplate">
<Anchors><Anchor point="BOTTOM"><Offset><AbsDimension x="30" y="43"/></Offset></Anchor></Anchors>
<Layers>
<Layer level="OVERLAY">
<FontString inherits="GameFontNormal" text="Price:" justifyH="RIGHT">
<Anchors><Anchor point="RIGHT" relativePoint="LEFT"><Offset><AbsDimension x="-10" y="0"/></Offset></Anchor></Anchors>
</FontString>
</Layer>
</Layers>
</Frame>
<Frame name="$parentBuyoutPrice" inherits="SmallMoneyFrameTemplate">
<Anchors><Anchor point="BOTTOM"><Offset><AbsDimension x="30" y="45"/></Offset></Anchor></Anchors>
<Scripts>
<OnLoad>
SmallMoneyFrame_OnLoad()
MoneyFrame_SetType("STATIC")
</OnLoad>
</Scripts>
<Layers>
<Layer level="OVERLAY">
<FontString inherits="GameFontNormal" text="Price:" justifyH="RIGHT">
<Anchors><Anchor point="RIGHT" relativePoint="LEFT"><Offset><AbsDimension x="-5" y="0"/></Offset></Anchor></Anchors>
</FontString>
</Layer>
</Layers>
</Frame>
<Button name="$parentActionButton" inherits="UIPanelButtonTemplate" text="Buy" disabled="true">
<Size><AbsDimension x="90" y="26"/> </Size>
<Anchors><Anchor point="BOTTOMLEFT"><Offset><AbsDimension x="0" y="0"/></Offset></Anchor></Anchors>
<Scripts>
<OnClick>
Aux.item_search_frame.dialog_action()
</OnClick>
</Scripts>
</Button>
<Button name="$parentCancelButton" inherits="UIPanelButtonTemplate" text="Cancel">
<Size><AbsDimension x="90" y="26"/></Size>
<Anchors><Anchor point="BOTTOMRIGHT"><Offset><AbsDimension x="0" y="0"/></Offset></Anchor></Anchors>
<Scripts>
<OnClick>
Aux.item_search_frame.dialog_cancel()
</OnClick>
</Scripts>
</Button>
</Frames>
</Frame>
</Frames>
</Frame>
</Frames>
</Frame>
</Frames>
+21 -1
View File
@@ -1,5 +1,6 @@
local private, public = {}, {}
Aux.sell = public
Aux.post_frame = public
local existing_auctions = {}
@@ -222,6 +223,25 @@ function Aux.sell.on_close()
end
function public.on_load()
do
local btn = Aux.gui.button(AuxSellParameters, 15, '$parentPostButton')
btn:SetPoint('BOTTOMLEFT', 8, 15)
btn:SetWidth(75)
btn:SetHeight(24)
btn:SetText('Post')
btn:SetScript('OnClick', private.post_auctions)
end
do
local btn = Aux.gui.button(AuxSellParameters, 15, '$parentRefreshButton')
btn:SetPoint('LEFT', AuxSellParametersPostButton,'RIGHT', 5, 0)
btn:SetWidth(75)
btn:SetHeight(24)
btn:SetText('Refresh')
btn:SetScript('OnClick', private.refresh)
end
end
function Aux.sell.duration_radio_button_on_click(index)
AuxSellParametersShortDurationRadio:SetChecked(false)
AuxSellParametersMediumDurationRadio:SetChecked(false)
@@ -618,7 +638,7 @@ function AuxSellEntry_OnClick(entry)
PlaySound('igMainMenuOptionCheckBoxOn')
end
function AuxSellParametersRefreshButton_OnClick()
function private.refresh()
Aux.scan.abort(function()
refresh_entries()
select_entry()
-18
View File
@@ -242,24 +242,6 @@
</OnLoad>
</Scripts>
</Frame>
<Button name="$parentPostButton" inherits="UIPanelButtonTemplate" text="Post">
<Size><AbsDimension x="90" y="26"/></Size>
<Anchors><Anchor point="BOTTOMLEFT" ><Offset><AbsDimension x="8" y="15"/></Offset></Anchor></Anchors>
<Scripts>
<OnClick>
Aux.sell.post_auctions()
</OnClick>
</Scripts>
</Button>
<Button name="$parentRefreshButton" inherits="UIPanelButtonTemplate" text="Refresh">
<Size><AbsDimension x="90" y="26"/></Size>
<Anchors><Anchor point="LEFT" relativePoint="RIGHT" relativeTo="$parentPostButton"><Offset><AbsDimension x="5" y="0"/></Offset></Anchor></Anchors>
<Scripts>
<OnClick>
AuxSellParametersRefreshButton_OnClick()
</OnClick>
</Scripts>
</Button>
</frames>
</frame>
<Frame name="AuxSellAuctions" inherits="AuxFrameBoxTemplate">