ist ein einfaches und simples tool enstanden.
Ziel war für mich ein kleines projekt fertig zustellen
und der Zweck, es soll die Cachedateien von dem Spiel UnrealTournamen 2004
in die Standartordner vom Spiel Kopieren und richtig umbenennen.
Beim ersten Start wird der Installationsordner abgefragt und in der path.txt geschrieben.
Dazu wird auch immer eine log.txt erstellt in der das Datum und über den erfolg oder nichterfolg
der Kopieraktion steht.
Das Tool ist ansich sehr speziel, aber vieleicht spielt der eine oder andere auch noch UT2K4.
Hier hätte ich auch mit Proceduren arbeiten können,
dann wäre der Select abschnitt etwas kürzer, aber soll ja auch ne übung für sein

Code: Alles auswählen
; PB UT2K4 Cachemanager
EnableExplicit
Global inipath.s
Global Cachename.s
Global Filename.s
Global NewList inilist.s()
Global UT_Path.s
Global result.i
Global endung.s
Global lang.w
Global pos.w
Global OK.w
#maps = "Maps\" ;.ut2
#utsystems = "System\" ;.u
#animation = "Animations\" ;.ukx
#cache_ini = "Cache\cache.ini"
#cache = "Cache\"
#sounds = "Sounds\" ;uax
#staticmeshes= "StaticMeshes\" ;.usx
#textures = "Textures\" ;.utx
; Info: In der path.txt wird die Pfandangabe von dem Cacheordner gespeichert
;ansonsten müsste man jedesmal den pfad nachfragen.
If OpenConsole()
If FileSize("path.txt") > 0 ;Überprüfung ob Datei vorhanden ist. Alternative ?????
; -1 = keine datei
; -2 = Ordner
; hier wird > 0 verwendet. Die Datei muss vorhanden sein und nicht leer.
ReadFile(1,"path.txt") ; Datei öffnen und auslesen
; inipath = ReadString(1)
UT_Path = ReadString(1)
CloseFile(1) ;
inipath = UT_Path+#cache_ini
If FileSize(inipath) < 0 ; Überprüfung ob der pfad noch stimmt ansonsten neu anlegen
UT_Path = PathRequester("Installationsordner von UT2004 angeben",GetCurrentDirectory())
If CreateFile(1,"path.txt")
; WriteStringN(1,UT_Path+#cache_ini) ; ini pfad eintragen
WriteStringN(1,UT_Path) ; installationspfad
CloseFile(1)
Else
If MessageRequester("Information","path.txt konnte nicht erstellt werden!",#PB_MessageRequester_Ok ) = #PB_MessageRequester_Ok
CloseFile(1)
End
EndIf
EndIf
EndIf
Else ; falls path.txt nicht vorhanden ist oder "0" leer ist
; pfadangabe der cache.ini
UT_Path = PathRequester("Installationsordner von UT2004 angeben",GetCurrentDirectory())
If CreateFile(1,"path.txt")
; WriteStringN(1,UT_Path+#cache_ini) ; ini pfad eintragen
WriteStringN(1,UT_Path) ; installationspfad
CloseFile(1)
Else
If MessageRequester("Information","path.txt konnte nicht erstellt werden!",#PB_MessageRequester_Ok ) = #PB_MessageRequester_Ok
CloseFile(1)
End
EndIf
EndIf
inipath = UT_Path+#cache_ini
EndIf
EndIf
;Ini Datei öffnen und inhalt in der inilist() speichern.
If ReadFile(0,inipath)
While Eof(0) = 0
AddElement(inilist())
inilist() = ReadString(0)
Wend
CloseFile(0)
Else
result = MessageRequester("Information","cache.ini nicht vorhanden",#PB_MessageRequester_Ok )
If result = #PB_MessageRequester_Ok
CloseFile(0)
End
EndIf
EndIf
;logdatei erstellen
OK = CreateFile(0,"log.txt")
If OK : WriteStringN(0,FormatDate("%mm/%dd/%yyyy", Date())) : EndIf
ForEach inilist()
If ListIndex(inilist()) = 0 ; Das [Cache] in der ini überspringen
Continue
EndIf
Cachename = inilist() ; eintrag aus der ini übergeben
lang = Len(Cachename) ; gesamtlänge des strings
endung = GetExtensionPart(Cachename) ; endung auslesen
pos = FindString(Cachename,"-1=",1) ; position der Trennung heraus finden
; hier 3 zeichen lag, da "=" eventuel auch im Dateinamen stehen kann.
Filename = Mid(Cachename,pos+3) ; Original Name der datei mit endung
Cachename = Left(Cachename,pos+1) ; Name der Cache datei ohne endung
Cachename + ".uxx" ; .uxx endung anhängen
endung = GetExtensionPart(Filename)
If FileSize(UT_Path + #cache + Cachename ) > 0 ; nur gefüllte dateien
PrintN( UT_Path+ #cache + Cachename )
PrintN(UT_Path +"test\"+filename)
Select endung
Case "ut2"
If OK
WriteString(0, UT_Path+ #cache + Cachename+" copy "+UT_Path +#maps+filename)
EndIf
If CopyFile(UT_Path+ #cache + Cachename , UT_Path +#maps+filename)
ConsoleColor(15,2)
PrintN("OK!")
If OK : WriteStringN(0," OK!") : EndIf
ConsoleColor(7, 0)
Else
ConsoleColor(15, 4)
PrintN("FAIL!")
If OK : WriteStringN(0," >>>---FAIL!---<<<") : EndIf
ConsoleColor(7, 0)
;Delay(300)
EndIf
Case "u"
If OK
WriteString(0, UT_Path+ #cache + Cachename+" copy "+UT_Path +#utsystems+filename)
EndIf
If CopyFile(UT_Path+ #cache + Cachename , UT_Path +#utsystems+filename)
ConsoleColor(15,2)
PrintN("OK!")
If OK : WriteStringN(0," OK!") : EndIf
ConsoleColor(7, 0)
Else
ConsoleColor(15, 4)
PrintN("FAIL!")
If OK : WriteStringN(0," >>>---FAIL!---<<<") : EndIf
ConsoleColor(7, 0)
;Delay(300)
EndIf
Case "ukx"
If OK
WriteString(0, UT_Path+ #cache + Cachename+" copy "+UT_Path +#animation+filename)
EndIf
If CopyFile(UT_Path+ #cache + Cachename , UT_Path +#animation+filename)
ConsoleColor(15,2)
PrintN("OK!")
If OK : WriteStringN(0," OK!") : EndIf
ConsoleColor(7, 0)
Else
ConsoleColor(15, 4)
PrintN("FAIL!")
If OK : WriteStringN(0," >>>---FAIL!---<<<") : EndIf
ConsoleColor(7, 0)
;Delay(300)
EndIf
Case "uax"
If OK
WriteString(0, UT_Path+ #cache + Cachename+" copy "+UT_Path +#sounds+filename)
EndIf
If CopyFile(UT_Path+ #cache + Cachename , UT_Path +#sounds+filename)
ConsoleColor(15,2)
PrintN("OK!")
If OK : WriteStringN(0," OK!") : EndIf
ConsoleColor(7, 0)
Else
ConsoleColor(15, 4)
PrintN("FAIL!")
If OK : WriteStringN(0," >>>---FAIL!---<<<") : EndIf
ConsoleColor(7, 0)
;Delay(300)
EndIf
Case "usx"
If OK
WriteString(0, UT_Path+ #cache + Cachename+" copy "+UT_Path +#staticmeshes+filename)
EndIf
If CopyFile(UT_Path+ #cache + Cachename , UT_Path +#staticmeshes+filename)
ConsoleColor(15,2)
PrintN("OK!")
If OK : WriteStringN(0," OK!") : EndIf
ConsoleColor(7, 0)
Else
ConsoleColor(15, 4)
PrintN("FAIL!")
If OK : WriteStringN(0," >>>---FAIL!---<<<") : EndIf
ConsoleColor(7, 0)
;Delay(300)
EndIf
Case "utx"
If OK
WriteString(0, UT_Path+ #cache + Cachename+" copy "+UT_Path +#textures+filename)
EndIf
If CopyFile(UT_Path+ #cache + Cachename , UT_Path +#textures+filename)
ConsoleColor(15,2)
PrintN("OK!")
If OK : WriteStringN(0," OK!") : EndIf
ConsoleColor(7, 0)
Else
ConsoleColor(15, 4)
PrintN("FAIL!")
If OK : WriteStringN(0," >>>---FAIL!---<<<") : EndIf
ConsoleColor(7, 0)
;Delay(300)
EndIf
EndSelect
EndIf
Next
CloseFile(0)
CloseConsole()
End