Allow dropping files onto the window to load them.
This commit is contained in:
parent
038ab69a54
commit
a7fc07c726
|
@ -111,26 +111,28 @@ func update_view():
|
|||
for entry in files:
|
||||
itemlist.add_item(entry[0], entry[1])
|
||||
|
||||
func load_file(entry: String):
|
||||
var filename := dir.get_current_dir() + '/' + entry
|
||||
var ext = entry.rsplit('.', true, 1)[1].to_lower()
|
||||
func load_file(filename: String, full_path: bool = false):
|
||||
var full_filename := filename
|
||||
if not full_path:
|
||||
full_filename = dir.get_current_dir() + '/' + filename
|
||||
var ext := full_filename.rsplit('/', true, 1)[1].rsplit('.', true, 1)[1].to_lower()
|
||||
match ext:
|
||||
'sfc', 'smc':
|
||||
if current_mode == SELECT_ROM:
|
||||
splash_filter.visible = true
|
||||
splash_label.text = 'Loading ROM: %s'%filename
|
||||
splash_label.text = 'Loading ROM: %s'%full_filename
|
||||
yield(get_tree(), 'idle_frame')
|
||||
RomLoader.load_snes_rom(filename)
|
||||
RomLoader.load_snes_rom(full_filename)
|
||||
'srm':
|
||||
if current_mode == SELECT_ROM:
|
||||
return
|
||||
var file := File.new()
|
||||
match file.open(filename, File.READ):
|
||||
match file.open(full_filename, File.READ):
|
||||
OK:
|
||||
emit_signal('savefile_loaded', SaveLoader.load_save_dicts_from_file(file))
|
||||
_set_mode(COMPLETE)
|
||||
var err:
|
||||
print_debug('Error loading savefile: %s - %d'%[filename, err])
|
||||
print_debug('Error loading savefile: %s - %d'%[full_filename, err])
|
||||
|
||||
func activate_entry(entry: String, _index: int = -1):
|
||||
var curr_dir := dir.get_current_dir()
|
||||
|
@ -228,6 +230,12 @@ func _ready() -> void:
|
|||
RomLoader.connect('loading_stage_updated', self, '_on_loading_stage_updated')
|
||||
print(ProjectSettings.globalize_path('user://'))
|
||||
print(ProjectSettings.globalize_path(dir.get_current_dir()))
|
||||
get_tree().connect('files_dropped', self, '_files_dropped')
|
||||
|
||||
func _files_dropped(filenames: PoolStringArray, screen_idx: int) -> void:
|
||||
print('Files Dropped signal: screen=%d, files='%screen_idx, filenames)
|
||||
for filename in filenames:
|
||||
load_file(filename, true)
|
||||
|
||||
func _update_config() -> void:
|
||||
var d = self.dir.get_current_dir()
|
||||
|
|
Loading…
Reference in New Issue