Switches part 1
This commit is contained in:
parent
d33c4607e5
commit
05ec5bf38f
3 changed files with 811 additions and 744 deletions
|
|
@ -6,5 +6,9 @@
|
|||
{
|
||||
"label": "Build debug",
|
||||
"command": "odin build . -debug",
|
||||
}
|
||||
},
|
||||
{
|
||||
"label": "Test run (gojo)",
|
||||
"command": "odin run . -- ../Satoru-Gojo-Needle/Satoru-Gojo-Needle.yyp ../Satoru-Gojo-Needle/rooms/rSatoru/rSatoru.yy jmap.jmap jmap_config.json5"
|
||||
},
|
||||
]
|
||||
|
|
|
|||
69
main.odin
69
main.odin
|
|
@ -295,6 +295,61 @@ HELP_MESSAGE :: """
|
|||
Usage: <program> <yyp_resource_path> <room_resource_path> <jmap_path> <jmap_config_path> [other flags...]
|
||||
"""
|
||||
|
||||
ProgramArguments :: struct {
|
||||
x, y: int,
|
||||
clear_area: bool,
|
||||
}
|
||||
|
||||
switch_definitions := []SwitchDefinition {
|
||||
{
|
||||
name = "x",
|
||||
fullname = "x",
|
||||
shortname = "x",
|
||||
description = "set x at which to place the jmap contents at (default: 0)",
|
||||
no_argument = false,
|
||||
usage = "-x <value>",
|
||||
callback = proc(value: string, args: ^byte) -> (ok: bool) {
|
||||
args := cast(^ProgramArguments)args
|
||||
x, x_ok := strconv.parse_int(value, 10)
|
||||
if !x_ok {
|
||||
fmt.eprintln("Invalid argument passed to switch 'x'")
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
},
|
||||
{
|
||||
name = "y",
|
||||
fullname = "y",
|
||||
shortname = "y",
|
||||
description = "set y at which to place the jmap contents at (default: 0)",
|
||||
no_argument = false,
|
||||
usage = "-y <value>",
|
||||
callback = proc(value: string, args: ^byte) -> (ok: bool) {
|
||||
args := cast(^ProgramArguments)args
|
||||
y, y_ok := strconv.parse_int(value, 10)
|
||||
if !y_ok {
|
||||
fmt.eprintln("Invalid argument passed to switch 'y'")
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
},
|
||||
{
|
||||
name = "clear_area",
|
||||
fullname = "clear_area",
|
||||
shortname = "clear_area",
|
||||
description = "clear area where jmap contents are placed",
|
||||
no_argument = true,
|
||||
usage = "-clear_area",
|
||||
callback = proc(value: string, args: ^byte) -> (ok: bool) {
|
||||
args := cast(^ProgramArguments)args
|
||||
args.clear_area = true
|
||||
return true
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
main :: proc() {
|
||||
args := os.args
|
||||
switch len(args) {
|
||||
|
|
@ -439,7 +494,14 @@ program :: proc(yyp_project_path, room_resource_path, jmap_path, jmap_config_pat
|
|||
room_layer_instances := &((&room_layer["instances"]).(json.Array))
|
||||
|
||||
for jmap_instance in jmap_instance_list {
|
||||
binding := jmap_instance_to_gamemaker_binding_map[jmap_instance.object_index]
|
||||
binding := &jmap_instance_to_gamemaker_binding_map[jmap_instance.object_index]
|
||||
if len(binding.path) == 0 {
|
||||
if !binding.warned {
|
||||
fmt.eprintln("Jmap used '", binding.jmap_object_name, "' but no binding was set, or object wasn't found in project '", binding.object_name, sep = "")
|
||||
binding.warned = true
|
||||
}
|
||||
continue
|
||||
}
|
||||
instance := resource_room_layer_create_instance("v4", "2.0", binding.object_name, 32, 32, binding.path, context.allocator)
|
||||
append(room_layer_instances, instance)
|
||||
}
|
||||
|
|
@ -449,7 +511,7 @@ program :: proc(yyp_project_path, room_resource_path, jmap_path, jmap_config_pat
|
|||
return program_error_create(room_resource_after_marshal_error, "Failed to convert marshal room data to resource")
|
||||
}
|
||||
|
||||
room_resource_after_write_error := os.write_entire_file_from_bytes("output.yy", room_resource_after)
|
||||
room_resource_after_write_error := os.write_entire_file_from_bytes(room_resource_path, room_resource_after)
|
||||
if room_resource_after_write_error != nil {
|
||||
return program_error_create(room_resource_after_write_error, "Failed to write modified room data to resource")
|
||||
}
|
||||
|
|
@ -535,9 +597,10 @@ jmap_config_get_from_json :: proc(root: json.Value) -> (_config: JmapImportConfi
|
|||
jmap_object_map_reverse: map[string]int
|
||||
|
||||
GameMakerInstanceDefinition :: struct {
|
||||
changed: bool,
|
||||
object_name: string,
|
||||
jmap_object_name: string,
|
||||
changed: bool,
|
||||
warned: bool,
|
||||
path: string,
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue