mirror of
https://github.com/lihop/godot-xterm.git
synced 2024-11-24 10:20:24 +01:00
Update import plugins
This commit is contained in:
parent
4490296d4d
commit
6b47d35835
3 changed files with 22 additions and 18 deletions
|
@ -24,17 +24,21 @@ func _get_resource_type():
|
||||||
return "Animation"
|
return "Animation"
|
||||||
|
|
||||||
|
|
||||||
func _get_import_options(preset):
|
func _get_import_options(preset, _i):
|
||||||
return []
|
return []
|
||||||
|
|
||||||
|
|
||||||
|
func _get_import_order():
|
||||||
|
return 0
|
||||||
|
|
||||||
|
|
||||||
func _get_preset_count():
|
func _get_preset_count():
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
|
|
||||||
func import(source_file, save_path, options, r_platform_variant, r_gen_files):
|
func _import(source_file, save_path, options, r_platform_variant, r_gen_files):
|
||||||
var file = File.new()
|
var file = FileAccess.open(source_file, FileAccess.READ)
|
||||||
var err = file.open(source_file, File.READ)
|
var err = FileAccess.get_open_error()
|
||||||
if err != OK:
|
if err != OK:
|
||||||
return err
|
return err
|
||||||
|
|
||||||
|
@ -55,17 +59,17 @@ func import(source_file, save_path, options, r_platform_variant, r_gen_files):
|
||||||
var test_json_conv = JSON.new()
|
var test_json_conv = JSON.new()
|
||||||
test_json_conv.parse(line)
|
test_json_conv.parse(line)
|
||||||
var p = test_json_conv.get_data()
|
var p = test_json_conv.get_data()
|
||||||
if typeof(p.result) != TYPE_ARRAY:
|
if typeof(p) != TYPE_ARRAY:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
var event_type: String = p.result[1]
|
var event_type: String = p[1]
|
||||||
var event_data: PackedByteArray = p.result[2].to_utf8_buffer()
|
var event_data: PackedByteArray = p[2].to_utf8_buffer()
|
||||||
|
|
||||||
# Asciicast recordings have a resolution of 0.000001, however animation
|
# Asciicast recordings have a resolution of 0.000001, however animation
|
||||||
# track keys only have a resolution of 0.01, therefore we must combine
|
# track keys only have a resolution of 0.01, therefore we must combine
|
||||||
# events that would occur in the same keyframe, otherwise only the last
|
# events that would occur in the same keyframe, otherwise only the last
|
||||||
# event is inserted and the previous events are overwritten.
|
# event is inserted and the previous events are overwritten.
|
||||||
var time = snapped(p.result[0], 0.01)
|
var time = snapped(p[0], 0.01)
|
||||||
|
|
||||||
if event_type == "o":
|
if event_type == "o":
|
||||||
if time == frame.time:
|
if time == frame.time:
|
||||||
|
@ -79,4 +83,4 @@ func import(source_file, save_path, options, r_platform_variant, r_gen_files):
|
||||||
|
|
||||||
asciicast.length = frame.time
|
asciicast.length = frame.time
|
||||||
|
|
||||||
return ResourceSaver.save("%s.%s" % [save_path, _get_save_extension()], asciicast)
|
return ResourceSaver.save(asciicast, "%s.%s" % [save_path, _get_save_extension()])
|
||||||
|
|
|
@ -24,7 +24,7 @@ func _get_resource_type():
|
||||||
return "Theme"
|
return "Theme"
|
||||||
|
|
||||||
|
|
||||||
func _get_import_options(preset):
|
func _get_import_options(preset, _i):
|
||||||
return []
|
return []
|
||||||
|
|
||||||
|
|
||||||
|
@ -32,9 +32,9 @@ func _get_preset_count():
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
|
|
||||||
func import(source_file, save_path, options, r_platform_variant, r_gen_files):
|
func _import(source_file, save_path, options, r_platform_variant, r_gen_files):
|
||||||
var file = File.new()
|
var file = FileAccess.open(source_file, FileAccess.READ)
|
||||||
var err = file.open(source_file, File.READ)
|
var err = FileAccess.get_open_error()
|
||||||
if err != OK:
|
if err != OK:
|
||||||
return err
|
return err
|
||||||
|
|
||||||
|
@ -72,7 +72,7 @@ func import(source_file, save_path, options, r_platform_variant, r_gen_files):
|
||||||
name = words[1].get_string().to_lower()
|
name = words[1].get_string().to_lower()
|
||||||
color = Color(words[2].get_string())
|
color = Color(words[2].get_string())
|
||||||
|
|
||||||
if not name or not color:
|
if name == null or color == null:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
match name:
|
match name:
|
||||||
|
@ -121,4 +121,4 @@ func import(source_file, save_path, options, r_platform_variant, r_gen_files):
|
||||||
"cursor_text_color":
|
"cursor_text_color":
|
||||||
theme.set_color("cursor_text", "Terminal", color)
|
theme.set_color("cursor_text", "Terminal", color)
|
||||||
|
|
||||||
return ResourceSaver.save("%s.%s" % [save_path, _get_save_extension()], theme)
|
return ResourceSaver.save(theme, "%s.%s" % [save_path, _get_save_extension()])
|
||||||
|
|
|
@ -3,11 +3,11 @@ extends Animation
|
||||||
signal data_written(data)
|
signal data_written(data)
|
||||||
signal data_read(data)
|
signal data_read(data)
|
||||||
|
|
||||||
@export var version: int: int = 2
|
@export var version: int = 2
|
||||||
# Initial terminal width (number of columns).
|
# Initial terminal width (number of columns).
|
||||||
@export var width: int: int
|
@export var width: int
|
||||||
# Initial terminal height (number of rows).
|
# Initial terminal height (number of rows).
|
||||||
@export var height: int: int
|
@export var height: int
|
||||||
|
|
||||||
|
|
||||||
func get_class() -> String:
|
func get_class() -> String:
|
||||||
|
|
Loading…
Reference in a new issue