diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 756c29d..bf96b9f 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -2,16 +2,11 @@ - - - - - @@ -77,8 +72,8 @@ - - + + @@ -87,8 +82,8 @@ - - + + @@ -97,18 +92,18 @@ - - + + - + - - + + @@ -124,11 +119,11 @@ - + - - + + @@ -137,8 +132,8 @@ - - + + @@ -178,14 +173,14 @@ @@ -375,7 +370,7 @@ - + @@ -431,10 +426,26 @@ + + + + + + + + + + + + + + + + - - + + @@ -449,48 +460,32 @@ - - - - - - - - - - + + - - - - - - - - - - - - - - - - - - + + - - + + + + + + + + + + diff --git a/buy.lua b/buy.lua index 7ee3ac4..81ef1e1 100644 --- a/buy.lua +++ b/buy.lua @@ -468,7 +468,9 @@ function Aux.buy.exit() current_page = nil end ------------------------------------------ +function Aux.buy.on_open() + +end function Aux_AuctionFrameBid_Update() Aux.orig.AuctionFrameBid_Update() @@ -497,7 +499,7 @@ function show_sheet() AuxBuyBidList:Hide() AuxBuyFullList:Hide() - local mode = AuxBuyModeDropDown:GetValue() + local mode = UIDropDownMenu_GetSelectedValue(AuxBuyModeDropDown) if mode == BUY then AuxBuyBuyList:Show() elseif mode == BID then @@ -807,6 +809,7 @@ end ----------------------------------------- function Aux_Buy_ScrollbarUpdate() + local mode = UIDropDownMenu_GetSelectedValue(AuxBuyModeDropDown) if mode == BUY then Aux.list.populate(AuxBuyBuyList.sheet, auctions or {}) elseif mode == BID then @@ -894,7 +897,7 @@ function AuxBuyQualityDropDown_Initialize() UIDropDownMenu_AddButton{ text = getglobal("ITEM_QUALITY"..i.."_DESC"), value = i, - func = function AuxBuyQualityDropDown_OnClick() + func = function() UIDropDownMenu_SetSelectedValue(AuxBuyQualityDropDown, this.value) end, } @@ -938,7 +941,7 @@ function AuxBuyModeDropDown_Initialize() UIDropDownMenu_AddButton{ text = mode.name, value = i, - func = function AuxBuyQualityDropDown_OnClick() + func = function() UIDropDownMenu_SetSelectedValue(AuxBuyModeDropDown, this.value) end, } diff --git a/buy.xml b/buy.xml index 3a86630..2ab1a30 100644 --- a/buy.xml +++ b/buy.xml @@ -75,7 +75,7 @@ - + @@ -103,6 +103,7 @@ UIDropDownMenu_Initialize(this, AuxBuyModeDropDown_Initialize) + UIDropDownMenu_SetSelectedValue(this, 1) UIDropDownMenu_Initialize(this, AuxBuyModeDropDown_Initialize) diff --git a/core.lua b/core.lua index 3a95d41..9b5f5e3 100644 --- a/core.lua +++ b/core.lua @@ -54,6 +54,10 @@ function Aux_OnAddonLoaded() Aux_SetupHookFunctions() Aux.tabs.sell.hiddenElements = { + AuctionsPriceText, + StartPrice, + AuctionsBuyoutText, + BuyoutPrice, AuctionsDurationText, AuctionsShortAuctionButton, AuctionsMediumAuctionButton, diff --git a/sell.lua b/sell.lua index 1e8e29c..f1166ee 100644 --- a/sell.lua +++ b/sell.lua @@ -10,9 +10,7 @@ local current_auction ----------------------------------------- -local record_auction, undercut, item_class_index, item_subclass_index, set_message, report, select_entry, update_recommendation, refresh_entries, availability, charge_classes - ------------------------------------------ +local record_auction, undercut, item_class_index, item_subclass_index, set_message, report, select_entry, update_recommendation, refresh_entries, availability, charge_classes, get_stack_size_slider_value function Aux.sell.on_open() AuxSellStackSizeSlider:SetValueStep(1) @@ -20,9 +18,29 @@ function Aux.sell.on_open() AuxSellStackCountSlider:SetValueStep(1) AuxSellStackCountSliderText:SetText('Stack Count') + + Aux.sell.validate_parameters() end ------------------------------------------ +function Aux.sell.duration_radio_button_on_click(index) + AuxSellParametersShortDurationRadio:SetChecked(false) + AuxSellParametersMediumDurationRadio:SetChecked(false) + AuxSellParametersLongDurationRadio:SetChecked(false) + if index == 1 then + AuxSellParametersShortDurationRadio:SetChecked(true) + AuctionFrameAuctions.duration = 120 + AUX_AUCTION_DURATION = 'short' + elseif index == 2 then + AuxSellParametersMediumDurationRadio:SetChecked(true) + AuctionFrameAuctions.duration = 480 + AUX_AUCTION_DURATION = 'medium' + else + AuxSellParametersLongDurationRadio:SetChecked(true) + AuctionFrameAuctions.duration = 1440 + AUX_AUCTION_DURATION = 'long' + end + update_recommendation() +end function Aux_Sell_AuctionFrameAuctions_OnShow() Aux.orig.AuctionFrameAuctions_OnShow() @@ -33,31 +51,16 @@ end function Aux_Sell_SetAuctionDuration(duration) if duration == 'short' then - Aux_Sell_AuctionsRadioButton_OnClick(1) + Aux.sell.duration_radio_button_on_click(1) elseif duration == 'medium' then - Aux_Sell_AuctionsRadioButton_OnClick(2) + Aux.sell.duration_radio_button_on_click(2) elseif duration == 'long' then - Aux_Sell_AuctionsRadioButton_OnClick(3) + Aux.sell.duration_radio_button_on_click(3) end end ----------------------------------------- -function Aux_Sell_AuctionsRadioButton_OnClick(index) - if index == 1 then - AUX_AUCTION_DURATION = 'short' - elseif index == 2 then - AUX_AUCTION_DURATION = 'medium' - elseif index == 3 then - AUX_AUCTION_DURATION = 'long' - end - - Aux.orig.AuctionsRadioButton_OnClick(index) - update_recommendation() -end - ------------------------------------------ - function Aux_AuctionFrameAuctions_Update() Aux.orig.AuctionFrameAuctions_Update() if PanelTemplates_GetSelectedTab(AuctionFrame) == Aux.tabs.sell.index and AuctionFrame:IsShown() then @@ -69,7 +72,7 @@ end function Aux.sell.post_auctions() if current_auction and PanelTemplates_GetSelectedTab(AuctionFrame) == Aux.tabs.sell.index then - local name, stack_size, buyout_price, stack_count = current_auction.name, AuxSellStackSize:GetNumber(), MoneyInputFrame_GetCopper(BuyoutPrice), AuxSellStackCount:GetNumber() + local name, stack_size, buyout_price, stack_count = current_auction.name, get_stack_size_slider_value(), MoneyInputFrame_GetCopper(AuxSellParametersBuyoutPrice), AuxSellStackCountSlider:GetValue() local duration if AuctionFrameAuctions.duration == 120 then duration = 2 @@ -83,7 +86,7 @@ function Aux.sell.post_auctions() name, stack_size, AuctionFrameAuctions.duration, - MoneyInputFrame_GetCopper(StartPrice), + MoneyInputFrame_GetCopper(AuxSellParametersStartPrice), buyout_price, stack_count, function(posted) @@ -142,15 +145,43 @@ function select_entry() auxSellEntries[current_auction.name].selected = absoluteBest - if bestPrice[AuxSellStackSize:GetNumber()] then - auxSellEntries[current_auction.name].selected = bestPrice[AuxSellStackSize:GetNumber()] - bestPriceOurStackSize = bestPrice[AuxSellStackSize:GetNumber()] + if bestPrice[get_stack_size_slider_value()] then + auxSellEntries[current_auction.name].selected = bestPrice[get_stack_size_slider_value()] + bestPriceOurStackSize = bestPrice[get_stack_size_slider_value()] end end end ----------------------------------------- +function get_stack_size_slider_value() + if current_auction.has_charges then + return AuxSellStackSizeSlider.charge_classes[AuxSellStackSizeSlider:GetValue()] + else + return AuxSellStackSizeSlider:GetValue() + end +end + +function Aux.sell.validate_parameters() + AuxSellPostButton:Disable() + AuxSellParametersBuyoutPriceErrorText:Hide() + + if not current_auction then + return + end + + if MoneyInputFrame_GetCopper(AuxSellParametersBuyoutPrice) > 0 and MoneyInputFrame_GetCopper(AuxSellParametersStartPrice) > MoneyInputFrame_GetCopper(AuxSellParametersBuyoutPrice) then + AuxSellParametersBuyoutPriceErrorText:Show() + return + end + + if MoneyInputFrame_GetCopper(AuxSellParametersStartPrice) < 1 then + return + end + + AuxSellPostButton:Enable() +end + function update_recommendation() AuxRecommendStaleText:Hide() @@ -161,8 +192,8 @@ function update_recommendation() AuxSellItemName:SetText() AuxSellItemCount:SetText() - MoneyInputFrame_SetCopper(BuyoutPrice, 0) - MoneyInputFrame_SetCopper(StartPrice, 0) + MoneyInputFrame_SetCopper(AuxSellParametersBuyoutPrice, 0) + MoneyInputFrame_SetCopper(AuxSellParametersStartPrice, 0) AuxSellStackSizeSlider:SetMinMaxValues(0,0) AuxSellStackSize:SetNumber(0) @@ -176,8 +207,8 @@ function update_recommendation() AuxSellItem:SetNormalTexture(current_auction.texture) AuxSellItemName:SetText(current_auction.name) - if AuxSellStackSize:GetNumber() > 1 then - AuxSellItemCount:SetText(AuxSellStackSize:GetNumber()) + if get_stack_size_slider_value() > 1 then + AuxSellItemCount:SetText(get_stack_size_slider_value()) AuxSellItemCount:Show() else AuxSellItemCount:Hide() @@ -185,7 +216,7 @@ function update_recommendation() AuxSellRefreshButton:Enable() - MoneyFrame_Update("AuctionsDepositMoneyFrame", current_auction.base_deposit * AuxSellStackCount:GetNumber() * (current_auction.has_charges and 1 or AuxSellStackSize:GetNumber()) * AuctionFrameAuctions.duration / 120) + MoneyFrame_Update("AuctionsDepositMoneyFrame", current_auction.base_deposit * AuxSellStackCountSlider:GetValue() * (current_auction.has_charges and 1 or get_stack_size_slider_value()) * AuctionFrameAuctions.duration / 120) if auxSellEntries[current_auction.name] and auxSellEntries[current_auction.name].selected then if not auxSellEntries[current_auction.name].created or GetTime() - auxSellEntries[current_auction.name].created > 1800 then @@ -193,7 +224,7 @@ function update_recommendation() AuxRecommendStaleText:Show() end - local newBuyoutPrice = auxSellEntries[current_auction.name].selected.itemPrice * AuxSellStackSize:GetNumber() + local newBuyoutPrice = auxSellEntries[current_auction.name].selected.itemPrice * get_stack_size_slider_value() if auxSellEntries[current_auction.name].selected.numYours == 0 then newBuyoutPrice = undercut(newBuyoutPrice) @@ -205,22 +236,22 @@ function update_recommendation() Aux_ShowElems(Aux.tabs.sell.recommendationElements) AuxRecommendText:SetText("Recommended Buyout Price") - AuxRecommendPerStackText:SetText("for a stack of "..AuxSellStackSize:GetNumber()) + AuxRecommendPerStackText:SetText("for a stack of "..get_stack_size_slider_value()) AuxRecommendItemTex:SetNormalTexture(current_auction.texture) if AuxSellStackSize:GetNumber() > 1 then - AuxRecommendItemTexCount:SetText(AuxSellStackSize:GetNumber()) + AuxRecommendItemTexCount:SetText(get_stack_size_slider_value()) AuxRecommendItemTexCount:Show() else AuxRecommendItemTexCount:Hide() end - MoneyFrame_Update("AuxRecommendPerItemPrice", Aux_Round(AuxSellStackSize:GetNumber() > 0 and newBuyoutPrice / AuxSellStackSize:GetNumber() or 0)) + MoneyFrame_Update("AuxRecommendPerItemPrice", Aux_Round(get_stack_size_slider_value() > 0 and newBuyoutPrice / get_stack_size_slider_value() or 0)) MoneyFrame_Update("AuxRecommendPerStackPrice", Aux_Round(newBuyoutPrice)) - MoneyInputFrame_SetCopper(BuyoutPrice, Aux_Round(newBuyoutPrice)) - MoneyInputFrame_SetCopper(StartPrice, Aux_Round(newStartPrice)) + MoneyInputFrame_SetCopper(AuxSellParametersBuyoutPrice, Aux_Round(newBuyoutPrice)) + MoneyInputFrame_SetCopper(AuxSellParametersStartPrice, Aux_Round(newStartPrice)) if auxSellEntries[current_auction.name].selected.stackSize == auxSellEntries[current_auction.name][1].stackSize and auxSellEntries[current_auction.name].selected.buyoutPrice == auxSellEntries[current_auction.name][1].buyoutPrice then AuxRecommendBasisText:SetText("(based on cheapest)") @@ -242,7 +273,7 @@ end function Aux.sell.quantity_update() if current_auction then - AuxSellStackCountSlider:SetMinMaxValues(1, current_auction.has_charges and current_auction.availability[AuxSellStackSizeSlider.charge_classes[AuxSellStackSizeSlider.GetValue()]] or floor(current_auction.availability[0] / AuxSellStackSize:GetNumber())) + AuxSellStackCountSlider:SetMinMaxValues(1, current_auction.has_charges and current_auction.availability[AuxSellStackSizeSlider.charge_classes[AuxSellStackSizeSlider.GetValue()]] or floor(current_auction.availability[0] / get_stack_size_slider_value())) end select_entry() update_recommendation() @@ -287,7 +318,7 @@ function Aux.sell.set_auction(bag, slot) } AuxSellStackSizeSlider.charge_classes = charge_classes(current_auction.availability) - AuxSellStackSizeSlider:SetMinMaxValues(1, current_auction.has_charges and getn(charge_classes(current_auction.availability)) or min(current_auction.max_stack, current_auction.availability[0])) + AuxSellStackSizeSlider:SetMinMaxValues(1, current_auction.has_charges and getn(charge_classes(current_auction.availability)) or min(container_item.max_stack, current_auction.availability[0])) AuxSellStackSizeSlider:SetValue(current_auction.has_charges and Aux.util.index_of(container_item.charges, charge_classes(current_auction.availability)) or container_item.count) AuxSellStackCountSlider:SetValue(1) Aux.sell.quantity_update() @@ -425,7 +456,7 @@ function Aux.sell.scrollbar_update() lineEntry_time:SetText("Very Long") end - if entry.stackSize == AuxSellStackSize:GetNumber() then + if entry.stackSize == get_stack_size_slider_value() then lineEntry_stacks:SetTextColor(0.2, 0.9, 0.2) else lineEntry_stacks:SetTextColor(1.0, 1.0, 1.0) diff --git a/sell.xml b/sell.xml index 4ee1013..2131f2d 100644 --- a/sell.xml +++ b/sell.xml @@ -358,12 +358,12 @@ - + - + @@ -373,7 +373,7 @@ - + @@ -381,45 +381,6 @@ - - - - - - - - - - getglobal(this:GetName().."Text"):SetText("2h"); - - - - - - - - - - - - - getglobal(this:GetName().."Text"):SetText("8h"); - - - - - - - - - - - - - getglobal(this:GetName().."Text"):SetText("24h"); - - - @@ -429,7 +390,7 @@ - + Aux.sell.quantity_update() @@ -459,7 +420,7 @@ - + @@ -489,6 +450,78 @@ + + + + + + + + + + getglobal(this:GetName().."Text"):SetText("2h"); + Aux.sell.duration_radio_button_on_click(1) + + + + + + + + + + + + getglobal(this:GetName().."Text"):SetText("8h"); + Aux.sell.duration_radio_button_on_click(2) + + + + + + + + + + + + getglobal(this:GetName().."Text"):SetText("24h"); + Aux.sell.duration_radio_button_on_click(3) + + + + + + + + + + + + + + MoneyInputFrame_SetOnvalueChangedFunc(this, Aux.sell.validate_parameters) + + + + + + + + + + + + + + + + + + MoneyInputFrame_SetOnvalueChangedFunc(this, Aux.sell.validate_parameters) + + +