From 1490f5339612b2a535f1200c357cbfc65e5cc2e6 Mon Sep 17 00:00:00 2001 From: Manuel Schermuly Date: Wed, 5 Oct 2016 13:19:53 +0200 Subject: [PATCH] Added optional accountname to results tooltip --- trade_config.ini | 2 ++ trade_data/TradeMacro.ahk | 26 +++++++++++++++++++++++--- trade_data/TradeMacroInit.ahk | 2 ++ trade_data/trade_defaults.ini | 2 ++ 4 files changed, 29 insertions(+), 3 deletions(-) diff --git a/trade_config.ini b/trade_config.ini index b44fea25..9716bdca 100644 --- a/trade_config.ini +++ b/trade_config.ini @@ -5,6 +5,8 @@ ShowUpdateNotifications = 1 ; Defaults to 1 (show) if not set. 0 = hide OpenWithDefaultWin10Fix := 0 ; If your PC asks you what program to use to open the wiki-link, set this to 1 to let ahk find your default program from registry +ShowAccountName = 1 +; Show also sellers account name in the results window, 1 = show; 0 = hide [Debug] Debug = 0 diff --git a/trade_data/TradeMacro.ahk b/trade_data/TradeMacro.ahk index 04dbafbd..9e9b7dc2 100644 --- a/trade_data/TradeMacro.ahk +++ b/trade_data/TradeMacro.ahk @@ -237,13 +237,13 @@ FunctionGetMeanMedianPrice(html, payload){ If (prices.MaxIndex() > 0) { average := average / itemCount + Title .= "Average price in chaos: " average " (" itemCount " results) `n" If (prices.MaxIndex()&1) { median := prices[prices.MaxIndex()/2] } Else { median := (prices[Floor(prices.MaxIndex()/2)] + prices[Ceil(prices.MaxIndex()/2)]) / 2 - } - Title .= "Average price in chaos: " average " (" itemCount " results) `n" + } Title .= "Median price in chaos: " median " (" itemCount " results) `n`n" } return Title @@ -282,6 +282,8 @@ FunctionParseHtml(html, payload) ; Text .= StrX( html, "",1,28, N ) NoOfItemsToShow := TradeOpts.ShowItemResults + Title .= FunctionShowAcc(StrPad("Account",10), "|") StrPad("IGN",20) StrPad("Price",20,"left")"`n" + Title .= FunctionShowAcc(StrPad("----------",10), "-") StrPad("--------------------",20) StrPad("--------------------",20,"left")"`n" While A_Index < NoOfItemsToShow TBody := StrX( html, "", 1,23, N ) , AccountName := StrX( TBody, "data-seller=""", 1,13, """" , 1,1, T ) @@ -289,11 +291,29 @@ FunctionParseHtml(html, payload) , IGN := StrX( TBody, "data-ign=""", T,10, """" , 1,1 ) ;, Text .= StrPad(IGN, 30) StrPad(AccountName, 30) StrPad(Buyout,30) "`n" ;, Text .= StrPad(IGN,20) StrPad(Buyout,20,"left") "`n" - , Title .= StrPad(IGN,20) StrPad(Buyout,20,"left")"`n" + , subAcc := FunctionTrimNames(AccountName, 10, true) + , subIGN := FunctionTrimNames(IGN, 20, true) + , Title .= FunctionShowAcc(StrPad(subAcc,10), "|") StrPad(subIGN,20) StrPad(Buyout,20,"left")"`n" Return, Title } +FunctionTrimNames(name, length, addDots) { + s := SubStr(name, 1 , length) + if (StrLen(name) > length + 3 && addDots) { + StringTrimRight, s, s, 3 + s .= "..." + } + return s +} + +FunctionShowAcc(s, addString) { + if (TradeOpts.ShowAccountName = 1) { + s .= addString + return s + } +} + ; ------------------------------------------------------------------------------------------------------------------ ; ; StrX function for parsing html, see simple example usage at https://gist.github.com/thirdy/9cac93ec7fd947971721c7bdde079f94 ; ------------------------------------------------------------------------------------------------------------------ ; diff --git a/trade_data/TradeMacroInit.ahk b/trade_data/TradeMacroInit.ahk index 58c85a62..71496e94 100644 --- a/trade_data/TradeMacroInit.ahk +++ b/trade_data/TradeMacroInit.ahk @@ -34,6 +34,7 @@ class TradeUserOptions { ShowItemResults := 15 ; Number of Items shown as search result; defaults to 15 if not set. ShowUpdateNotifications := 1 ; 1 = show, 0 = don't show OpenWithDefaultWin10Fix := 0 ; If your PC asks you what programm to use to open the wiki-link, set this to 1 + ShowAccountName := 1 ; Show also sellers account name in the results window Debug := 0 ; @@ -89,6 +90,7 @@ ReadTradeConfig(TradeConfigPath="trade_config.ini") TradeOpts.ShowItemResults := ReadIniValue(TradeConfigPath, "General", "ShowItemResults", TradeOpts.ShowItemResults) TradeOpts.ShowUpdateNotifications := ReadIniValue(TradeConfigPath, "General", "ShowUpdateNotifications", TradeOpts.ShowUpdateNotifications) TradeOpts.OpenWithDefaultWin10Fix := ReadIniValue(TradeConfigPath, "General", "OpenWithDefaultWin10Fix", TradeOpts.OpenWithDefaultWin10Fix) + TradeOpts.ShowAccountName := ReadIniValue(TradeConfigPath, "General", "ShowAccountName", TradeOpts.ShowAccountName) ; Debug TradeOpts.Debug := ReadIniValue(TradeConfigPath, "Debug", "Debug", 0) diff --git a/trade_data/trade_defaults.ini b/trade_data/trade_defaults.ini index b44fea25..9716bdca 100644 --- a/trade_data/trade_defaults.ini +++ b/trade_data/trade_defaults.ini @@ -5,6 +5,8 @@ ShowUpdateNotifications = 1 ; Defaults to 1 (show) if not set. 0 = hide OpenWithDefaultWin10Fix := 0 ; If your PC asks you what program to use to open the wiki-link, set this to 1 to let ahk find your default program from registry +ShowAccountName = 1 +; Show also sellers account name in the results window, 1 = show; 0 = hide [Debug] Debug = 0