Skip to content

Commit

Permalink
Added optional accountname to results tooltip
Browse files Browse the repository at this point in the history
  • Loading branch information
Eruyome committed Oct 5, 2016
1 parent 19b8fd1 commit 1490f53
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 3 deletions.
2 changes: 2 additions & 0 deletions trade_config.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
26 changes: 23 additions & 3 deletions trade_data/TradeMacro.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -282,18 +282,38 @@ FunctionParseHtml(html, payload)
; Text .= StrX( html, "<tbody id=""item-container-0", N,0, "<tr class=""first-line"">",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, "<tbody id=""item-container-" . %A_Index%, N,0, "<tr class=""first-line"">", 1,23, N )
, AccountName := StrX( TBody, "data-seller=""", 1,13, """" , 1,1, T )
, Buyout := StrX( TBody, "data-buyout=""", T,13, """" , 1,1, T )
, 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
; ------------------------------------------------------------------------------------------------------------------ ;
Expand Down
2 changes: 2 additions & 0 deletions trade_data/TradeMacroInit.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -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 ;

Expand Down Expand Up @@ -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)
Expand Down
2 changes: 2 additions & 0 deletions trade_data/trade_defaults.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 1490f53

Please sign in to comment.