Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <array.au3>
- #Include <String.au3>
- #include <ButtonConstants.au3>
- #include <EditConstants.au3>
- #include <GUIConstantsEx.au3>
- #include <WindowsConstants.au3>
- #Region ### START Koda GUI section ### Form=C:\Users\Sascha\Desktop\ROSEonline bot\NewRosy\LoadSaveWPE.kxf
- $Form1 = GUICreate("Simple SPT Editor v0.1 for WPE PRO", 587, 624, 192, 124)
- $Edit = GUICtrlCreateEdit("", 0, 0, 585, 537, BitOR($ES_AUTOVSCROLL,$ES_AUTOHSCROLL,$ES_WANTRETURN,$WS_VSCROLL), 0)
- GUICtrlSetData($Edit, StringFormat("Name of Entry | 00 00 00 00 00 01 FF 00 "))
- GUICtrlSetFont($Edit, 11, 400, 0, "Times New Roman")
- GUICtrlSetResizing(-1, $GUI_DOCKAUTO+$GUI_DOCKLEFT+$GUI_DOCKRIGHT+$GUI_DOCKTOP+$GUI_DOCKBOTTOM+$GUI_DOCKWIDTH+$GUI_DOCKHEIGHT)
- $Load = GUICtrlCreateButton("Load", 0, 536, 585, 41, BitOR($WS_BORDER,$WS_CLIPSIBLINGS))
- $Save = GUICtrlCreateButton("save", 0, 576, 585, 41, BitOR($WS_BORDER,$WS_CLIPSIBLINGS))
- GUISetState(@SW_SHOW)
- #EndRegion ### END Koda GUI section ###
- Func open()
- $open = FileOpenDialog("select a File",@WorkingDir& "\", "SPT (*.SPT)")
- $file = FileOpen($open, 16)
- ; Check if file opened for reading OK
- If $file = -1 Then
- MsgBox(0, "Error", "Unable to open file.")
- Exit
- EndIf
- ; Read in 1 character at a time until the EOF is reached
- $chars = Hex(FileRead($file))
- FileClose($file)
- if($chars == "") Then
- $chars = "010000000B0000004E616D656F66456E74727908000000000000000001FF00"
- EndIf
- $entries = StripZero(StringLeft($chars,8))
- $length = StringLen($chars)
- Dim $Content[Dec($entries)][2]
- $chars = StringTrimLeft($chars,8)
- $output = ""
- $length -= 8
- for $i = 0 To Dec($entries)-1
- for $j = 0 to 1
- $next = Dec(StripZero(StringLeft($chars,8)))
- $chars = StringTrimLeft($chars,8)
- $length -= 8
- $valHex = StringLeft($chars,$next*2)
- $chars = StringTrimLeft($chars,$next*2)
- $length -= $next*2
- if($j == 0) Then
- $Content[$i][$j] = _HexToString($valHex)
- $output = $output & $Content[$i][$j] & " | "
- Else
- $Content[$i][$j] = $valHex
- for $k = 1 to StringLen($Content[$i][$j]) Step 2
- $output = $output & StringLeft($valHex,2) & " "
- $valHex = StringTrimLeft($valHex,2)
- Next
- if $i <> Dec($entries)-1 Then
- $output = $output & "\r\n"
- EndIf
- EndIf
- Next
- Next
- GUICtrlSetData($Edit, StringFormat($output))
- EndFunc
- Func StripZero($string)
- for $charnum = 7 to 0 Step -1
- if StringRight($string,1) == 0 Then
- $string = StringLeft($string, $charnum)
- Else
- ExitLoop
- EndIf
- Next
- Return $string
- EndFunc
- Func save()
- $data = GUICtrlRead($Edit)
- if $data <> "" then
- $splitLines = StringSplit($data,@CR)
- $saveto = FileSaveDialog("select a File",@WorkingDir& "\", "SPT (*.SPT)")
- $write = ""
- $h = Hex($splitLines[0])
- for $pos = 1 to 3
- if StringLeft($h,2) == "00" Then
- $h = StringTrimLeft($h,2) & "00"
- Else
- ExitLoop
- EndIf
- Next
- $write = $h
- for $i = 1 to $splitLines[0]
- $splitLines[$i] = StringStripWS($splitLines[$i],8)
- ConsoleWrite( $splitLines[$i]&@CRLF)
- $split = StringSplit($splitLines[$i],"|")
- if $split[0] == 2 then
- $namehex = _StringToHex($split[1])
- $h = Hex(StringLen($split[2])/2)
- for $pos = 1 to 3
- if StringLeft($h,2) == "00" Then
- $h = StringTrimLeft($h,2) & "00"
- Else
- ExitLoop
- EndIf
- Next
- $len2hex = $h
- $h = Hex(StringLen($namehex)/2)
- for $pos = 1 to 3
- if StringLeft($h,2) == "00" Then
- $h = StringTrimLeft($h,2) & "00"
- Else
- ExitLoop
- EndIf
- Next
- $lenhex = $h
- $namehexlen = StringLen($lenhex)
- $hexhexlen = StringLen($len2hex)
- $write &= $lenhex & $namehex & $len2hex & $split[2]
- EndIf
- Next
- $bstring = $write
- $file = FileOpen($saveto, BitOR(16, 2))
- ; Check if file opened for writing OK
- If $file = -1 Then
- MsgBox(0, "Error", "Unable to open file.")
- Exit
- EndIf
- for $k = 1 to StringLen($bstring) Step 2
- FileWrite($file, Binary("0x"&StringLeft($bstring,2)))
- $bstring = StringTrimLeft($bstring,2)
- Next
- FileClose($file)
- EndIf
- EndFunc
- While 1
- $nMsg = GUIGetMsg()
- Switch $nMsg
- Case $GUI_EVENT_CLOSE
- Exit
- Case $Save
- save()
- Case $Load
- open()
- EndSwitch
- WEnd
Advertisement
Add Comment
Please, Sign In to add comment