Skip to content

Commit

Permalink
new splash screen; error handling improvements (#912)
Browse files Browse the repository at this point in the history
* new splash screen WIP

* splash screen improvements

* merge script splash screen

* darker splash border

* fixed shaper/elder state being forced by adv search even if not selected

* splash screen improvements

* added better comments for merged files

* runtime error handling improvements

* runtime error parsing improvements

* splashui border image fix; ie test call closes ielowutil.exe if it caused it to exist

* splash screen text overlap fix

* settings UI fix (WIP)

* added more gui names for the settings ui

* reversed IEComObjectTestcall changes

* caught errors for a failed json parsing of all data files at script start

* fixes

* more UI fixes

* updated notes/version
  • Loading branch information
Eruyome authored Jan 22, 2019
1 parent d965dda commit bee152f
Show file tree
Hide file tree
Showing 15 changed files with 699 additions and 338 deletions.
3 changes: 3 additions & 0 deletions Run_TradeMacro.ahk
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
; #####################################################################################################################
; # This script checks if the right AHK version is installed and runs the TradeMacro merge script.
; #####################################################################################################################
#SingleInstance, Force
#NoEnv
SetWorkingDir, %A_ScriptDir%

versionFilePath := A_ScriptDir "\resources\VersionTrade.txt"
FileRead, versionFile, %versionFilePath%
Expand Down
117 changes: 117 additions & 0 deletions lib/Class_SplashUI.ahk
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
class SplashUI
{
__New(params*)
{
c := params.MaxIndex()
If (c > 6) {
throw "Too many parameters passed to SplashUI.New()"
}

; set defaults
this.state := (params[1] = "" or not params[1]) ? "on" : params[1]
this.title := (params[2] = "" or not params[2]) ? "Splash Screen" : params[2]
this.message := (params[3] = "" or not params[3]) ? "Initializing script" : params[3]
this.submessage := (params[4] = "" or not params[4]) ? "" : params[4]
this.scriptVersion := (params[5] = "" or not params[5]) ? "" : params[5]
this.borderImage := (params[6] = "" or not params[6]) ? "" : params[6]

; initialize
this.CreateUI()
}

CreateUI() {
Global SplashMessage, SplashSubMessage

;Destroy GUIs in case they still exist
Gui, SplashUI:Destroy

Gui, SplashUI:New, +Border -resize -SysMenu -Caption +HwndSplashHwnd
Gui, SplashUI:Margin, 10, 2
Gui, SplashUI:Color, FFFFFF, 000000

Gui, SplashUI:Add, Progress, w900 h28 x0 y0 c505256 Background505256

Gui, SplashUI:Font, s12 cFFFFFF bold, Verdana
Gui, SplashUI:Add, Text, x10 y5 h20 w450 +Center BackgroundTrans, % this.title
Gui, SplashUI:Font, s7 cFFFFFF norm, Verdana
Gui, SplashUI:Add, Text, x+-90 yp+6 h20 w90 +Right BackgroundTrans, % this.scriptVersion

Gui, SplashUI:Font, s10 c000000, Verdana
Gui, SplashUI:Add, Text, x10 y+5 w450 +Center BackgroundTrans vSplashMessage, % this.message

Gui, SplashUI:Font, s8 c000000, Consolas
Gui, SplashUI:Add, Text, x10 y+10 w450 r4 +Left BackgroundTrans vSplashSubMessage, % StrLen(this.submessage) ? "- " this.submessage : this.submessage

Gui, SplashUI:Font, s7 c000000, Verdana
Gui, SplashUI:Add, Text, x10 y+5 h20 w450 +Right BackgroundTrans, % "AHK v" . A_AHKVersion

Gui, SplashUI:+LastFound
Gui, SplashUI:Show, Center w470 NA, % this.title

WinGetPos, _TTX, _TTY, _TTW, _TTH, ahk_id %SplashHwnd%
image := this.borderImage
If (FileExist(image)) {
WinGetPos, _TTX, _TTY, _TTW, _TTH, ahk_id %SplashHwnd%

Gui, SplashUI:Add, Picture, w1000 h1 x0 y0, %image%
Gui, SplashUI:Add, Picture, w1000 h1 x0 y0, %image%

Gui, SplashUI:Add, Picture, w1 h1000 x0 y0, %image%
Gui, SplashUI:Add, Picture, w1 h1000 x0 y0, %image%

_TTH := _TTH -1
_TTW := _TTW -1
Gui, SplashUI:Add, Picture, w1000 h1 x0 y%_TTH%, %image%
Gui, SplashUI:Add, Picture, w1000 h1 x0 y%_TTH%, %image%

Gui, SplashUI:Add, Picture, w1 h1000 x%_TTW% y1, %image%
Gui, SplashUI:Add, Picture, w1 h1000 x%_TTW% y1, %image%
}

If (state = "off") {
Gui, SplashUI:Show, Hide
}
}

ShowUI() {
this.state := "on"
If (this.state = "dead") {
this.CreateUI()
} Else {
Gui, SplashUI:Show
}
}

HideUI() {
Gui, SplashUI:Show, Hide
this.state := "off"
}

DestroyUI() {
Gui, SplashUI:Destroy
this.state := "dead"
}

SetMessage(message) {
this.message := message
GuiControl,,SplashMessage, % this.message
Sleep, 1 ; add a small sleep to prevent text field overlapping caused by too fast updates
}
SetSubMessage(message) {
If (StrLen(message)) {
this.submessage := StrLen(this.submessage) ? this.submessage "`n" : ""
this.submessage .= "- " message
} Else {
this.submessage := this.submessage "`n" ""
}

arr := StrSplit(this.submessage, "`n")
mI := arr.MaxIndex()
If (mI > 3) {
this.submessage := Trim(arr[mI - 2] "`n" arr[mI - 1] "`n" arr[mI])
}

GuiControl,,SplashSubMessage, % this.submessage
Sleep, 1 ; add a small sleep to prevent text field overlapping caused by too fast updates
}
}
36 changes: 34 additions & 2 deletions lib/IEComObjectTestCall.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ If (FileExist(userFolderPath "\IEComObjectCall.txt")) {
}

url := "https://poe-trademacro.github.io/userCount/index.html"
Try {
killIElowutil := false
Try {
;killIElowutil := CheckForRunningIElowutil()
wb1 := ComObjCreate("InternetExplorer.Application")
wb1.Visible := False
wb1.Navigate(url)
Expand All @@ -30,6 +32,18 @@ Try {
}
}

If (killIElowutil) {
DetectHiddenWindows, On
SetTitleMatchMode, 2

Process, Exist, ielowutil.exe ; Sets errorlevel to process PID
pid := ErrorLevel
Process, Close, %pid%
Process, Close, ielowutil.ex
WinClose, % "ahk_pid " pid
WinKill, % "ahk_pid " pid
}

CleanIE() {
Try {
wb1.Quit
Expand All @@ -38,7 +52,25 @@ CleanIE() {

}
ExitApp
}
}

CheckForRunningIElowutil() {
DetectHiddenWindows, On
SetTitleMatchMode, 2
Loop
{
Process, Exist, ielowutil.exe ; Sets errorlevel to process PID
pid := ErrorLevel
IfWinNotExist, % "ahk_pid " pid ; Expression for ahk_pid
{
Return 0
}
IfWinExist, % "ahk_pid " pid ; Expression for ahk_pid
{
Return 1
}
}
}

IELoad(wb, ByRef loaded = false, path = "", visible = false) ;You need to send the IE handle to the function unless you define it as global.
{
Expand Down
1 change: 1 addition & 0 deletions lib/PoEScripts_CheckInvalidScriptFolder.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
Msgbox, 0x1030, %project% Problematic Installation Path, % msg
} Else {
SplashTextOff
SplashUI.DestroyUI()
msg .= "`n`n" "Do not report this, it is intended behaviour! Move your script folder to somewhere else!"
Msgbox, 0x1010, %project% Invalid Installation Path, % msg
}
Expand Down
1 change: 1 addition & 0 deletions lib/PoEScripts_CompareUserFolderWithScriptFolder.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
msg .= exit ? "`n`nScript will be closed." : ""

SplashTextOff
SplashUI.DestroyUI()
If (exit) {
MsgBox, 16, Invalid %project% Script Location, % msg
ExitApp
Expand Down
1 change: 1 addition & 0 deletions lib/PoEScripts_CreateTempFolder.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
MsgBox, 5, %project%, % msg
IfMsgBox, Cancel
{
SplashUI.DestroyUI()
SplashTextOn, , 20, %project%, Exiting script...
Sleep, 2000
SplashTextOff
Expand Down
6 changes: 6 additions & 0 deletions resources/Updates_Trade.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
The following is a list of what has been updated, starting with 1.1.0

2.13.1
================================================================================================
* Added a new splash screen.
* Further improved handling of various (runtime) errors.
* Various small improvements/fixes.

2.12.5
================================================================================================
* Improved feedback for issues with poe.trade http requests.
Expand Down
2 changes: 1 addition & 1 deletion resources/VersionTrade.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
TradeReleaseVersion := "v2.12.5"
TradeReleaseVersion := "v2.13.1"
TradeAHKVersionRequired := "1.1.26.00"
12 changes: 7 additions & 5 deletions resources/ahk/Merge_ItemInfo.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ PoEScripts_CompareUserFolderWithScriptFolder(userDirectory, scriptDir, projectNa
/*
merge all scripts into `_ItemInfoMain.ahk` and execute it.
*/
info := ReadFileToMerge(scriptDir "\resources\ahk\POE-ItemInfo.ahk")
addMacros := ReadFileToMerge(scriptDir "\resources\ahk\AdditionalMacros.ahk")
info := ReadFileToMerge(file01 := scriptDir "\resources\ahk\POE-ItemInfo.ahk")
addMacros := ReadFileToMerge(file02 := scriptDir "\resources\ahk\AdditionalMacros.ahk")

info := info . "`n`r`n`r"
addMacros := "`n`r#IfWinActive ahk_group PoEWindowGrp" . "`n`r`n`r" . addMacros
Expand All @@ -57,6 +57,8 @@ CloseScript("ItemInfoMain.ahk")
FileDelete, %scriptDir%\_ItemInfoMain.ahk
FileCopy, %scriptDir%\resources\ahk\POE-ItemInfo.ahk, %scriptDir%\_ItemInfoMain.ahk

; additional macros
FileAppend, % "`r`n`r`n/* ###--- Merged File: " file02 " ---### `r`n*/`r`n", %scriptDir%\_TradeMacroMain.ahk
FileAppend, %addMacros% , %scriptDir%\_ItemInfoMain.ahk

; set script hidden
Expand Down Expand Up @@ -103,7 +105,7 @@ RunAsAdmin()

AppendCustomMacros(userDirectory)
{
If(!InStr(FileExist(userDirectory "\CustomMacros"), "D")) {
If (!InStr(FileExist(userDirectory "\CustomMacros"), "D")) {
FileCreateDir, %userDirectory%\CustomMacros\
}

Expand All @@ -113,8 +115,8 @@ AppendCustomMacros(userDirectory)
{
If A_LoopFileExt in %extensions%
{
FileRead, tmp, %A_LoopFileFullPath%
appendedMacros .= "; appended custom macro file: " A_LoopFileName " ---------------------------------------------------"
FileRead, tmp, %A_LoopFileFullPath%
appendedMacros .= "`r`n`r`n/* ###--- Merged File: " A_LoopFileFullPath " ---### `r`n*/`r`n"
appendedMacros .= "`n" tmp "`n`n"
}
}
Expand Down
Loading

0 comments on commit bee152f

Please sign in to comment.