Code: Select all
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn ; Enable warnings to assist with detecting common errors.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
#SingleInstance Force
version := 0.1
product := "Fiesta Online Price Checker"
UrlDownloadToFile, https://raw.githubusercontent.com/SkrillexAkaCraft/FiestaOnline/master/version.ini, version.ini
; FileRead, new_version, version.ini, https://raw.githubusercontent.com/SkrillexAkaCraft/FiestaOnline/master/version.ini, version, new_version
INIRead, newVersion,% "version.ini", version, new_version ; if it's an INI-file why using FileRead instead??
if (newVersion > version){
Gui, Update:Add, Text, x10 y10 wp400 h25 ,% "A new version of " product "has arrived!`n`n"
Gui, Update:Add, Text, xp y40 wp-40 hp ,% "Current version:`t" Version "`n"
Gui, Update:Add, Text, xp y55 wp hp ,% "New version:`t" newVersion "`n"
Gui, Update:Add, Text, xp y85 wp hp ,% "Would you like to update?"
Gui, Update:Add, Button, xp+170yp-6 w30 hp gYes ,% "Yes"
Gui, Update:Add, Button, xp+50 yp wp hp gUpdateGuiClose ,% "No"
Gui, Update:Show, w290 h130 ,% "Update?"
return
} Else {
gosub Home
}
Home:
IfExist, %A_Workingdir%\Items\Firstrun.txt
{
gui, Update:Destroy
UrlDownloadToFile, https://raw.githubusercontent.com/SkrillexAkaCraft/FiestaOnline/master/Items.ini, %A_Workingdir%\Items\Items.ini
FileRead, Data, %A_WorkingDir%\Items\Items.ini
Data := Jxon_Load(Data)
Gui, Home:Add, DropDownList, x10 y35 w120 h21 R5 AltSubmit +HScroll vCategory gCategoryC, % DDL(Data)
Gui, Home:Add, Text, x10 y20 w120 h15, Category:
Gui, Home:Add, DropDownList, x10 y75 w120 h21 R5 AltSubmit +HScroll vCategoryC gItemC,
Gui, Home:Add, Text, x10 y60 w21 h13, Item:
Gui, Home:Add, Text, x10 y100 w21 h13, Tier:
Gui, Home:Add, DropDownList, x10 y115 w120 h21 R5 AltSubmit +HScroll vItemC gTierC,
Gui, Home:Add, Text, x310 y40 w75 h25, Price Range:
Gui, Home:Add, Edit, x265 y55 w65 h20 vItem1,
Gui, Home:Add, Edit, x265 y75 w65 h20 vItem2,
Gui, Home:Add, Edit, x265 y95 w65 h20 vItem3,
Gui, Home:Add, Edit, x265 y115 w65 h20 vItem4,
Gui, Home:Add, Edit, x350 y55 w65 h20 vItem5,
Gui, Home:Add, Edit, x350 y75 w65 h20 vItem6,
Gui, Home:Add, Edit, x350 y95 w65 h20 vItem7,
Gui, Home:Add, Edit, x350 y115 w65 h20 vItem8,
Gui, Home:Add, Button, x285 y185 w80 h20 gReport, Report Bug
Gui, Home:Add, Text, x332 y59 w15 h15, <->
Gui, Home:Add, Text, x332 y80 w15 h15, <->
Gui, Home:Add, Text, x332 y100 w15 h15, <->
Gui, Home:Add, Text, x332 y120 w15 h15, <->
Gui, Home:Add, Text, x235 y60 w30 h15, Gem:
Gui, Home:Add, Text, x235 y80 w25 h15, Gold:
Gui, Home:Add, Text, x230 y100 w30 h15, Silver:
Gui, Home:Add, Text, x225 y120 w40 h15, Copper:
Gui, Home:Add, Text, x370 y190 w65 h20, Version:%version%
Gui, Home:Show, w432 h204, Fiesta Online Price Checker
GoSub, CategoryC ; Act like the user picked an item to initialize the menus
}
IfNotExist, %A_Workingdir%\Items\Firstrun.txt
{
Gui, UpdateLog:Add, Edit, x0 y10 w240 h210 +VScroll +ReadOnly, Version 2:`nFixed updater`nAdded Enhance Stones Tier 1 - Tier 5`nAdded item Karis`nAdded Price range Copper till Gems`nAdded prices for Enhance Stones & Karis`nFixed Karis showing tiers`nAdded report function
Gui, UpdateLog:Add, Button, x190 y245 w43 h23 gCreate, Done
Gui, UpdateLog:Show, w241 h271, Update Log
}
return
UpdateGuiClose:
ExitApp
HomeGuiClose:
ExitApp
Report:
Run, https://github.com/SkrillexAkaCraft/FiestaOnline/issues
return
CategoryC:
Gui, Home:Submit, NoHide
SubList := Data[Category-1][2]
GuiControl,,CategoryC, % "|" DDL(Sublist)
GoSub, ItemC
return
ItemC:
Gui, Home:Submit, NoHide
SubList := Data[Category-1][2][CategoryC-1][2]
GuiControl,,ItemC, % "|" DDL(Sublist)
GoSub, TierC
return
TierC:
Gui, Home:Submit, NoHide
SubList := Data[Category-1][2][CategoryC-1][2][ItemC-1][2]
GuiControl,,Item1, % SubList[1]
GuiControl,,Item2, % SubList[2]
GuiControl,,Item3, % SubList[3]
GuiControl,,Item4, % SubList[4]
GuiControl,,Item5, % SubList[5]
GuiControl,,Item6, % SubList[6]
GuiControl,,Item7, % SubList[7]
GuiControl,,Item8, % SubList[8]
return
DDL(Obj)
{
Out := "Pick An Item|"
for Key, Value in Obj
Out .= "|" Value[1]
return Out
}
Jxon_Load(ByRef src, args*)
{
static q := Chr(34)
key := "", is_key := false
stack := [ tree := [] ]
is_arr := { (tree): 1 }
next := q . "{[01234567890-tfn"
pos := 0
while ( (ch := SubStr(src, ++pos, 1)) != "" )
{
if InStr(" `t`n`r", ch)
continue
if !InStr(next, ch, true)
{
ln := ObjLength(StrSplit(SubStr(src, 1, pos), "`n"))
col := pos - InStr(src, "`n",, -(StrLen(src)-pos+1))
msg := Format("{}: line {} col {} (char {})"
, (next == "") ? ["Extra data", ch := SubStr(src, pos)][1]
: (next == "'") ? "Unterminated string starting at"
: (next == "\") ? "Invalid \escape"
: (next == ":") ? "Expecting ':' delimiter"
: (next == q) ? "Expecting object key enclosed in double quotes"
: (next == q . "}") ? "Expecting object key enclosed in double quotes or object closing '}'"
: (next == ",}") ? "Expecting ',' delimiter or object closing '}'"
: (next == ",]") ? "Expecting ',' delimiter or array closing ']'"
: [ "Expecting JSON value(string, number, [true, false, null], object or array)"
, ch := SubStr(src, pos, (SubStr(src, pos)~="[\]\},\s]|$")-1) ][1]
, ln, col, pos)
throw Exception(msg, -1, ch)
}
is_array := is_arr[obj := stack[1]]
if i := InStr("{[", ch)
{
val := (proto := args[i]) ? new proto : {}
is_array? ObjPush(obj, val) : obj[key] := val
ObjInsertAt(stack, 1, val)
is_arr[val] := !(is_key := ch == "{")
next := q . (is_key ? "}" : "{[]0123456789-tfn")
}
else if InStr("}]", ch)
{
ObjRemoveAt(stack, 1)
next := stack[1]==tree ? "" : is_arr[stack[1]] ? ",]" : ",}"
}
else if InStr(",:", ch)
{
is_key := (!is_array && ch == ",")
next := is_key ? q : q . "{[0123456789-tfn"
}
else ; string | number | true | false | null
{
if (ch == q) ; string
{
i := pos
while i := InStr(src, q,, i+1)
{
val := StrReplace(SubStr(src, pos+1, i-pos-1), "\\", "\u005C")
static end := A_AhkVersion<"2" ? 0 : -1
if (SubStr(val, end) != "\")
break
}
if !i ? (pos--, next := "'") : 0
continue
pos := i ; update pos
val := StrReplace(val, "\/", "/")
, val := StrReplace(val, "\" . q, q)
, val := StrReplace(val, "\b", "`b")
, val := StrReplace(val, "\f", "`f")
, val := StrReplace(val, "\n", "`n")
, val := StrReplace(val, "\r", "`r")
, val := StrReplace(val, "\t", "`t")
i := 0
while i := InStr(val, "\",, i+1)
{
if (SubStr(val, i+1, 1) != "u") ? (pos -= StrLen(SubStr(val, i)), next := "\") : 0
continue 2
; \uXXXX - JSON unicode escape sequence
xxxx := Abs("0x" . SubStr(val, i+2, 4))
if (A_IsUnicode || xxxx < 0x100)
val := SubStr(val, 1, i-1) . Chr(xxxx) . SubStr(val, i+6)
}
if is_key
{
key := val, next := ":"
continue
}
}
else ; number | true | false | null
{
val := SubStr(src, pos, i := RegExMatch(src, "[\]\},\s]|$",, pos)-pos)
; For numerical values, numerify integers and keep floats as is.
; I'm not yet sure if I should numerify floats in v2.0-a ...
static number := "number", integer := "integer"
if val is %number%
{
if val is %integer%
val += 0
}
; in v1.1, true,false,A_PtrSize,A_IsUnicode,A_Index,A_EventInfo,
; SOMETIMES return strings due to certain optimizations. Since it
; is just 'SOMETIMES', numerify to be consistent w/ v2.0-a
else if (val == "true" || val == "false")
val := %value% + 0
; AHK_H has built-in null, can't do 'val := %value%' where value == "null"
; as it would raise an exception in AHK_H(overriding built-in var)
else if (val == "null")
val := ""
; any other values are invalid, continue to trigger error
else if (pos--, next := "#")
continue
pos += i-1
}
is_array? ObjPush(obj, val) : obj[key] := val
next := obj==tree ? "" : is_array ? ",]" : ",}"
}
}
return tree[1]
}
Create:
Gui, UpdateLog:Destroy
FileAppend, Another line.`n, %A_Workingdir%\Items\Firstrun.txt
gosub Home
return
Yes:
UrlDownloadToFile, https://github.com/SkrillexAkaCraft/FiestaOnline/raw/master/price_check.exe, %A_Workingdir%\Fiesta Online Price Checker.exe
gosub Run
return
Run:
FileDelete, %A_Workingdir%\Items\Firstrun.txt
FileDelete, %A_Workingdir%\Items\Items.ini
sleep 1000
Run, %A_Workingdir%\Fiesta Online Price Checker.exe
ExitApp