Implemented .WAgame import support
This commit is contained in:
@@ -2,11 +2,13 @@
|
||||
|
||||
ArmageDec (short for Armageddon Decoder) is a GUI scheme editor (written in Tcl/Tk 8.6) for Worms: Armageddon game scheme file format from version 1 to version 3. It was developed based on [this format description page](https://worms2d.info/Game_scheme_file) and supports all fields readable as of W:A v3.8.1, including those not present in some other external scheme editors.
|
||||
|
||||
Additionally, ArmageDec now supports importing schemes from Worms: Armageddon replay (.WAgame) files.
|
||||
|
||||
## Usage
|
||||
|
||||
ArmageDec is a fully GUI-based application, although you can pass the .wsc scheme file to open as the first command-line parameter to the script. You can modify all supported parameters, including the format version itself. If you supply an invalid version value, the program will assume and save version 3.
|
||||
ArmageDec is a fully GUI-based application, although you can pass a .wsc scheme file (or a .WAgame replay file) to open as the first command-line parameter to the script. You can modify all supported parameters, including the format version itself. If you supply an invalid version value, the program will assume and save version 3.
|
||||
|
||||
Note that you can't create a fully new scheme as of now. You need to open an existing .wsc file and start by editing it.
|
||||
Note that you can't create a fully new scheme as of now. You need to open an existing .wsc file or .WAgame and start by editing it. You can import schemes from .WAgame files but you can only save to .wsc files.
|
||||
|
||||
### How to use Mines & Barrels Calculator section
|
||||
|
||||
|
||||
+30
-7
@@ -375,13 +375,34 @@ proc fullscanscheme {version} {
|
||||
# load a scheme file into the internal structure
|
||||
proc loadscheme {fname} {
|
||||
global rawschemedata wsc_data
|
||||
set fp [open $fname r]
|
||||
fconfigure $fp -translation binary
|
||||
set rawschemedata [read $fp]
|
||||
close $fp
|
||||
if [string match *.wagame [string tolower $fname]] { # extract from the replay file
|
||||
set fp [open $fname r]
|
||||
fconfigure $fp -translation binary
|
||||
set replaydata [read $fp]
|
||||
close $fp
|
||||
set schemestart [string first "SCHM" $replaydata]
|
||||
if {$schemestart < 0} {
|
||||
tk_messageBox -type ok -title "Scheme loading error" -icon error -message "No scheme found in the replay file!"
|
||||
return
|
||||
}
|
||||
# read the version
|
||||
set offs [expr {$schemestart + 4}]
|
||||
set scanval [string index $replaydata $offs]
|
||||
binary scan $scanval cu scmver
|
||||
# set the target size based on the version
|
||||
set datasize 221
|
||||
if {$scmver eq 2} {set datasize 297}
|
||||
if {$scmver eq 3} {set datasize 407}
|
||||
set rawschemedata [string range $replaydata $schemestart [expr {$schemestart + $datasize - 1}]]
|
||||
} else { # read raw scheme data directly
|
||||
set fp [open $fname r]
|
||||
fconfigure $fp -translation binary
|
||||
set rawschemedata [read $fp]
|
||||
close $fp
|
||||
}
|
||||
set hdr ""
|
||||
set ver ""
|
||||
binary scan $rawschemedata a4c hdr ver
|
||||
binary scan $rawschemedata a4cu hdr ver
|
||||
if {$hdr eq {SCHM} && ($ver eq 1 || $ver eq 2 || $ver eq 3)} {
|
||||
# proceed with full scanning
|
||||
fullscanscheme $ver
|
||||
@@ -406,7 +427,7 @@ proc savescheme {fname} {
|
||||
if {$diffbytes > 0} { # expand with nulls
|
||||
set rawschemedata [string cat $rawschemedata [binary format x$diffbytes]]
|
||||
} else { # truncate
|
||||
set rawschemedata [string range 0 [expr {$datasize - 1}]
|
||||
set rawschemedata [string range $rawschemedata 0 [expr {$datasize - 1}]
|
||||
}
|
||||
# write the version itself
|
||||
set binval [binary format cu $wsc_data(version)]
|
||||
@@ -471,14 +492,16 @@ proc savescheme {fname} {
|
||||
}
|
||||
|
||||
# open a .wsc scheme file (get the target name)
|
||||
# or a .WAgame replay file
|
||||
proc openwsc {} {
|
||||
global wscfile appdir
|
||||
set startdir $appdir
|
||||
if {$wscfile ne ""} {set startdir [file dirname $wscfile]}
|
||||
set types {
|
||||
{{Worms: Armageddon game scheme} {.wsc} BINA}
|
||||
{{Worms: Armageddon replay} {.WAgame} BINA}
|
||||
}
|
||||
return [tk_getOpenFile -filetypes $types -initialdir $startdir -title {Open a Worms scheme file}]
|
||||
return [tk_getOpenFile -filetypes $types -initialdir $startdir -title {Open a Worms scheme or replay file}]
|
||||
}
|
||||
|
||||
# save a .wsc scheme file (get the target name)
|
||||
|
||||
Reference in New Issue
Block a user