SetWorkingDir, %A_ScriptDir%
IfNotExist, config.ini
{
MsgBox, 4, Cannot find config.ini, Cannot find the config.ini file, create?
IfMsgBox, No
ExitApp
IfMsgBox, Yes
{
Random, Result, 1000, 9999
NewClient := MakeConfig("NoName" . Result,800,600,10,0,0,0,5)
FileAppend, %NewClient%, config.ini
}
}
IniRead, NickName, config.ini, client, name
IniRead, XRes, config.ini, client, xres
IniRead, YRes, config.ini, client, yres
IniRead, Volume, config.ini, client, vol
IniRead, Invert, config.ini, client, inverty
IniRead, Windowed, config.ini, client, windowed
IniRead, Mouse, config.ini, client, mouse_sensitivity
Invert := Invert ? "Checked" : ""
Windowed := Windowed ? "Checked" : ""
Gui, Add, Text, x12 y10 h20 , Nickname:
Gui, Add, Text, x12 y40 h20, XResolution:
Gui, Add, Text, x12 y70 h20, YResolution:
Gui, Add, Text, x12 y100 h20 , Volume:
Gui, Add, Text, x12 y130 h20 , Mouse Sensitivity:
Gui, Add, Edit, x112 y10 w350 h20 vNickName, %NickName%
Gui, Add, Edit, x112 y40 w350 h20 vXRes Number, %XRes%
Gui, Add, Edit, x112 y70 w350 h20 vYRes Number, %YRes%
Gui, Add, Edit, x112 y100 w350 h20 Number
Gui, Add, UpDown, vVolume Range0-10, %Volume%
Gui, Add, Edit, x112 y130 w350 h20 Number
Gui, Add, UpDown, vMouse Range0-10, %Mouse%
Gui, Add, CheckBox, x12 y160 w90 h20 vInvert %Invert%, Invert Y Axis
Gui, Add, CheckBox, x232 y160 w80 h20 vWindowed %Windowed%, Windowed
Gui, Add, Button, x182 y190 w100 h30 gUpdate, Update config.ini
Gui, Show, h234 w479, AoS Configurator
Return
Update:
Gui, Submit, NoHide
IniRead, Language, config.ini, client, language
If (Language = "ERROR")
Language = 0
If (Volume < 0)
Volume = 0
If (Volume > 10)
Volume = 10
If (Mouse < 0)
Mouse = 0
If (Mouse > 10)
Mouse = 10
GuiControl,, Volume, %Volume%
GuiControl,, Mouse, %Mouse%
IfExist, config.ini
FileRead, BKConfig, config.ini
FileDelete, config.ini
IfExist, config.ini
{
MsgBox, 0, Failure!, Could not remove existing config.ini
Return
}
AppendConfig := MakeConfig(NickName,XRes,YRes,Volume,Invert,Windowed,Language,Mouse)
FileAppend, %AppendConfig%, config.ini
IfNotExist, config.ini
{
MsgBox, 0, Failure!, Could not write to config.ini
Return
}
FileRead, NewConfig, config.ini
If (AppendConfig != NewConfig)
{
MsgBox, 4, Failure!, New config.ini didn't write correctly, Restore old one?
IfMsgBox, Yes
{
FileDelete, config.ini
IfExist, config.ini
{
MsgBox, 0, Failure!, Could not remove existing config.ini
Return
}
FileAppend, %BKConfig%, config.ini
IfNotExist, config.ini
{
MsgBox, 0, Failure!, Could not write to config.ini
Return
}
FileRead, NewConfig, config.ini
If (BKConfig != NewConfig)
{
MsgBox, 0, Failure!, Could not restore old config.ini
Return
}
Else
{
MsgBox, 0, Success!, Restored old config.ini
Return
}
}
IfMsgBox, No
Return
}
MsgBox, 0, Success!, New config.ini written
Return
D(N)
{
Loop,%N%
W.=" "
Return W
}
MakeConfig(Name,XRes,YRes,Vol,Invert,Win,Lang,Mouse)
{
Config := "`r`n[client]`r`nname" . D(27) . "= " . Name . "`r`nxres" . D(27) . "= " . Xres . "`r`nyres" . D(27) . "= " . YRes . "`r`nvol" . D(28) . "= " . Vol . "`r`ninverty" . D(24) . "= " . Invert . "`r`nwindowed" . D(23) . "= " . Win . "`r`nlanguage" . D(23) . "= " . Lang . "`r`nmouse_sensitivity" . D(14) . "= " . Mouse . "`r`n"
Return Config
}
GuiClose:
ExitApp