steveR Posted January 20, 2005 Share Posted January 20, 2005 This is my first "real" program so please let me know how the script logic looks. It just simply switches out some graphics for an online game I play. It writes to the registry so the changes can be undone and it allows you to pick a directory. expandcollapse popup; ; AutoIt Version: 3.0.103 ; Language: English ; Platform: Win9x/NT ; Author: Steve Renolds ; Date: Wednesday, January 19, 2005 ; ; Script Function: ; SubSpace Graphics Mod v1.0 ; #include <GUIConstants.au3> ; global $shrapFlag global $bulletFlag global $radarFlag global $mainGui global $picCtrl global $labelText global $labelCtrl global $bulletChkBox global $shrapChkBox global $radarChkBox global $okBtn global $exitBtn global $aboutBtn global $inputCtrl global $browseBtn global $gfxFolder = "C:\Program Files\Continuum\graphics" ; ;Opt("TrayIconHide",1) Opt("guiCoordMode",0) Opt("mustDeclareVars",1) ; ; Read reg keys readRegKey() ; ; Create main GUI createMainGui() ; ; ; Main event loop dim $mainGuiEvent while 1 $mainGuiEvent = GuiGetMsg() if $mainGuiEvent = $GUI_EVENT_CLOSE Then exit if $mainGuiEvent = $exitBtn Then exit if $mainGuiEvent = $aboutBtn Then aboutBox() if $mainGuiEvent = $okBtn then ok() if $mainGuiEvent = $bulletChkBox Then bulletChkBox() if $mainGuiEvent = $shrapChkBox Then shrapChkBox() if $mainGuiEvent = $radarChkBox Then radarChkBox() if $mainGuiEvent = $browseBtn then browseBtn() sleep(100) wend ; ; ; Procedures ; ; Create main GUI func createMainGui() $mainGui = GuiCreate("SubSpace Graphics Mod",310,160,-1,-1) if $mainGui = 0 then error() ; ; Create label $labelText = "This program will allow you to modify your SubSpace graphics." $labelCtrl = GuiCtrlCreateLabel($labelText,10,10,300,20) ; ; Create SS pic $picCtrl = GuiCtrlCreatePic("res\ssshield.gif",0,25,38,50,-1,$WS_EX_TRANSPARENT) ; ; Create checkboxes $bulletChkBox = GuiCtrlCreateCheckbox("Bigger bullets",55,-5) $shrapChkBox = GuiCtrlCreateCheckbox("Bigger shrapnel",0,20) $radarChkBox = GuiCtrlCreateCheckbox("Enemy appears red on radar",0,20) setChkBoxStates() ; ; Create buttons $okBtn = GuiCtrlCreateButton("OK",-30,30,50) $exitBtn = GuiCtrlCreateButton("Exit",50,0,50) $aboutBtn = GuiCtrlCreateButton("About",50,0,50) ; ; Create folder browser $inputCtrl = guiCtrlCreateInput($gfxFolder, -120,35,200,20) $browseBtn = guiCtrlCreateButton("...",200,0,20,20) ; Show GUI GuiSetState() endFunc ; ; Bullet chkbox event func bulletChkBox() $bulletFlag = guiCtrlRead($bulletChkBox) if $bulletFlag = $GUI_CHECKED then $bulletflag = 1 else $bulletFlag = 0 endIf endFunc ; ; Shrap chkbox event func shrapChkBox() $shrapFlag = guiCtrlRead($shrapChkBox) if $shrapFlag = $GUI_CHECKED then $shrapFlag = 1 else $shrapFlag = 0 endIf endFunc ; ; Radar chkbox event func radarChkBox() $radarFlag = guiCtrlRead($radarChkBox) if $radarFlag = $GUI_CHECKED then $radarFlag = 1 else $radarFlag = 0 endIf endFunc ; ; OK btn event func ok() ; Write reg keys writeRegKey("BulletFlag",$bulletFlag) writeRegKey("ShrapFlag",$shrapFlag) writeRegkey("RadarFlag",$radarFlag) handleGfx() msgBox(0,"","All done.") endFunc ; func browseBtn() $gfxFolder = fileSelectFolder("Browse for 'Continuum\graphics' folder",@ProgramFilesDir) if @error <> 1 then guiCtrlSetData($inputCtrl, $gfxFolder) endFunc ; ; Error handler func error() endFunc ; ; Create and show the about box func aboutBox() ; Set label text local $aboutText = "This program will backup your original graphics files and replace them with " $aboutText = $aboutText & "the modified graphics files." & @CRLF & "You can select a different directory " $aboutText = $aboutText & "if you installed your Continuum folder somewhere else." & @CRLF $aboutText = $aboutText & "You are able to revert back to the original files by " $aboutText = $aboutText & "unchecking all the boxes." & @CRLF & @CRLF $aboutText = $aboutText & "Please send comments, suggestions and bug reports to:" & @CRLF $aboutText = $aboutText & "steverenolds@hotmail.com" & @CRLF & @CRLF & @CRLF $aboutText = $aboutText & "Created with AutoIt3" & @CRLF $aboutText = $aboutText & "http://www.hiddensoft.com/autoit3/"& @CRLF & @CRLF & @CRLF $aboutText = $aboutText & "SubSpace Graphics Mod" & @CRLF & "Version 1.0" ; Create the about box local $aboutBox = GuiCreate("",300,300,-1,-1,$WS_DLGFRAME,-1,$mainGui) guiCtrlCreateLabel($aboutText,10,10,290,220) local $aboutBtn = guiCtrlCreateButton("OK",120,230,30) GuiSetState() ; Wait for btn press local $aboutBtnEvent do $aboutBtnEvent = guiGetMsg() sleep(100) until $aboutBtnEvent = $aboutBtn ; Destroy about box GuiDelete($aboutBox) endfunc ; ; Write registry keys func writeRegKey($flag,$value) regWrite("HKEY_CURRENT_USER\SOFTWARE\SubSpace GFX Mod",$flag,"REG_DWORD",$value) endFunc ; ; Read registry keys func readRegKey() $bulletFlag = regRead("HKEY_CURRENT_USER\SOFTWARE\SubSpace GFX Mod", "BulletFlag") $shrapFlag = regRead("HKEY_CURRENT_USER\SOFTWARE\SubSpace GFX Mod", "ShrapFlag") $radarFlag = regRead("HKEY_CURRENT_USER\SOFTWARE\SubSpace GFX Mod", "RadarFlag") endFunc ; ; Set check box states func setChkBoxStates() guiCtrlSetState($bulletChkbox, $bulletFlag) guiCtrlSetState($shrapChkBox, $shrapFlag) guiCtrlSetState($radarChkBox, $radarFlag) endFunc ; ; Switch out the gfx files func handleGfx() $gfxFolder = guiCtrlRead($inputCtrl) fileChangeDir($gfxFolder) ; Handle bullets.bm2 if $bulletFlag = 1 then ; Only replace if mod doesn't already exist if NOT fileExists("bullets.bm2.ssgfxorig") then fileCopy("bullets.bm2","bullets.bm2.ssgfxorig") fileCopy(@ScriptDir & "\res\bullets.bm2", $gfxFolder & "\bullets.bm2",1) endIf else ; Revert to original fileCopy("bullets.bm2.ssgfxorig", "bullets.bm2", 1) fileDelete("bullets.bm2.ssgfxorig") endIf ; Handle shrapnel.bm2 if $shrapFlag =1 then ; Only replace if mod doesn't already exist if NOT fileExists("shrapnel.bm2.ssgfxorig") then fileCopy("shrapnel.bm2","shrapnel.bm2.ssgfxorig") fileCopy(@ScriptDir & "\res\shrapnel.bm2", $gfxFolder & "\shrapnel.bm2",1) endIf else ; Revert to original fileCopy("shrapnel.bm2.ssgfxorig", "shrapnel.bm2", 1) fileDelete("shrapnel.bm2.ssgfxorig") endIf ; Handle colors.bm2 if $radarFlag =1 then ; Only replace if mod doesn't already exist if NOT fileExists("colors.bm2.ssgfxorig") then fileCopy("colors.bm2","colors.bm2.ssgfxorig") fileCopy(@ScriptDir & "\res\colors.bm2", $gfxFolder & "\colors.bm2",1) endIf else ; Revert to original fileCopy("colors.bm2.ssgfxorig", "colors.bm2", 1) fileDelete("colors.bm2.ssgfxorig") endIf endFunc ; ; AutoIt3 online docs Use it... Know it... Live it...MSDN libraryglobal Help and SupportWindows: Just another pane in the glass. Link to comment Share on other sites More sharing options...
DirtyBanditos Posted January 20, 2005 Share Posted January 20, 2005 This is my first "real" program so please let me know how the script logic looks. It just simply switches out some graphics for an online game I play. It writes to the registry so the changes can be undone and it allows you to pick a directory. Link to comment Share on other sites More sharing options...
steveR Posted January 20, 2005 Author Share Posted January 20, 2005 Thanks DB, I hope to add more useful scripts AutoIt3 online docs Use it... Know it... Live it...MSDN libraryglobal Help and SupportWindows: Just another pane in the glass. Link to comment Share on other sites More sharing options...
killaz219 Posted January 20, 2005 Share Posted January 20, 2005 Thanks DB, I hope to add more useful scripts <{POST_SNAPBACK}>[sarcasm] ya because it is VERY useful to change the graphics of SSHQ [/sarcasm]Pretty good for being yourfirst"real" program. Link to comment Share on other sites More sharing options...
psreauk Posted June 12, 2007 Share Posted June 12, 2007 sır what ıs thıs and how can ı use for...? Link to comment Share on other sites More sharing options...
Sn0opy Posted June 12, 2007 Share Posted June 12, 2007 It's for a game i thinkhttp://en.wikipedia.org/wiki/SubSpace_(computer_game) Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now