From 8f70770107d2657c5fb07159a4f8a6f5cd16b3b3 Mon Sep 17 00:00:00 2001 From: Sebastian Morr Date: Mon, 26 Oct 2020 19:56:52 +0100 Subject: [PATCH] Fix warnings --- scenes/card.gd | 6 ++---- scenes/cardgame.gd | 27 ++------------------------- scenes/drop_area.gd | 1 - scenes/game.gd | 21 +++++++-------------- scenes/helpers.gd | 2 +- scenes/level.gd | 2 +- scenes/sandbox.gd | 2 +- scenes/shell.gd | 4 ++-- scenes/text_editor.gd | 6 +++--- 9 files changed, 19 insertions(+), 52 deletions(-) diff --git a/scenes/card.gd b/scenes/card.gd index 98161d5..7e32ce6 100644 --- a/scenes/card.gd +++ b/scenes/card.gd @@ -35,8 +35,6 @@ func _process(delta): if hovered and not dragged: target_scale = 1.5 - var speed = 5 - scale = lerp(scale, Vector2(target_scale, target_scale), 10*delta) func _unhandled_input(event): @@ -107,13 +105,13 @@ func dropped_on(other): # else: # _first_argument = other.id -func try_play(command): +func try_play(full_command): if game.energy >= energy: $PlaySound.play() var particles = preload("res://scenes/card_particles.tscn").instance() particles.position = position get_parent().add_child(particles) - $"../../..".terminal.send_command(command) + $"../../..".terminal.send_command(full_command) buuurn() game.energy -= energy else: diff --git a/scenes/cardgame.gd b/scenes/cardgame.gd index 88e0618..0da2fef 100644 --- a/scenes/cardgame.gd +++ b/scenes/cardgame.gd @@ -126,36 +126,13 @@ var cards = [ ] func _ready(): -# var path = game.tmp_prefix_inside+"/repos/sandbox/" -# helpers.careful_delete(path) -# -# game.global_shell.run("mkdir " + path) -# game.global_shell.cd(path) -# game.global_shell.run("git init") -# game.global_shell.run("git remote add origin ../remote") -# $Repository.path = path -# $Terminal.repository = $Repository -# -# var path2 = game.tmp_prefix_inside+"/repos/remote/" -# helpers.careful_delete(path2) -# -# game.global_shell.run("mkdir " + path2) -# game.global_shell.cd(path2) -# game.global_shell.run("git init") -# game.global_shell.run("git config receive.denyCurrentBranch ignore") -# $RepositoryRemote.path = path2 - redraw_all_cards() arrange_cards() pass -func _process(delta): +func _process(_delta): if $Energy: $Energy.text = str(game.energy) - -#func _update_repo(): -# $Repository.update_everything() -# $RepositoryRemote.update_everything() func draw_rand_card(): var deck = [] @@ -164,7 +141,7 @@ func draw_rand_card(): deck.push_back(card) # We want a lot of commit and checkout cards! - for i in range(5): + for _i in range(5): deck.push_back(cards[0]) deck.push_back(cards[1]) diff --git a/scenes/drop_area.gd b/scenes/drop_area.gd index 5fb5376..ae86a5f 100644 --- a/scenes/drop_area.gd +++ b/scenes/drop_area.gd @@ -15,5 +15,4 @@ func _input(event): if event is InputEventMouseButton: if event.button_index == BUTTON_LEFT and !event.pressed and hovered: if game.dragged_object: - print(game.dragged_object) game.dragged_object.dropped_on($"..") diff --git a/scenes/game.gd b/scenes/game.gd index e084e9b..b14c3be 100644 --- a/scenes/game.gd +++ b/scenes/game.gd @@ -1,7 +1,6 @@ extends Node -var tmp_prefix_outside = _tmp_prefix_outside() -var tmp_prefix_inside = _tmp_prefix_inside() +var tmp_prefix = OS.get_user_data_dir() + "/tmp/" var global_shell var fake_editor @@ -13,11 +12,11 @@ var state = {} func _ready(): var dir = Directory.new() - var repo_dir = tmp_prefix_outside+"repos/" - if not dir.dir_exists(tmp_prefix_outside): - var err = dir.make_dir(tmp_prefix_outside) + var repo_dir = tmp_prefix+"repos/" + if not dir.dir_exists(tmp_prefix): + var err = dir.make_dir(tmp_prefix) if err != OK: - helpers.crash("Could not create temporary directory %s." % tmp_prefix_outside) + helpers.crash("Could not create temporary directory %s." % tmp_prefix) if not dir.dir_exists(repo_dir): var err = dir.make_dir(repo_dir) if err != OK: @@ -53,15 +52,9 @@ func load_state(): func copy_file_to_game_env(filename): # Copy fake-editor to tmp directory (because the original might be in a .pck file). - var file_outside = tmp_prefix_outside + filename - var file_inside = tmp_prefix_inside + filename + var file_outside = tmp_prefix + filename + var file_inside = tmp_prefix + filename var content = helpers.read_file("res://scripts/"+filename) helpers.write_file(file_outside, content) global_shell.run("chmod u+x " + '"'+file_inside+'"') return file_inside - -func _tmp_prefix_inside(): - return OS.get_user_data_dir() + "/tmp/" - -func _tmp_prefix_outside(): - return "user://tmp/" diff --git a/scenes/helpers.gd b/scenes/helpers.gd index a0f339f..8912a35 100644 --- a/scenes/helpers.gd +++ b/scenes/helpers.gd @@ -84,7 +84,7 @@ func careful_delete(path_inside): if path_inside.substr(0,expected_prefix.length()) != expected_prefix: helpers.crash("Refusing to delete directory %s that does not start with %s" % [path_inside, expected_prefix]) else: - game.global_shell.cd(game.tmp_prefix_inside) + game.global_shell.cd(game.tmp_prefix) game.global_shell.run("rm -rf '%s'" % path_inside) func parse(file): diff --git a/scenes/level.gd b/scenes/level.gd index 601557a..2db71ec 100644 --- a/scenes/level.gd +++ b/scenes/level.gd @@ -63,7 +63,7 @@ func load(path): helpers.crash("Level %s does not exist." % path) for repo in repos: - repos[repo].path = game.tmp_prefix_inside+"repos/%s/" % repo + repos[repo].path = game.tmp_prefix+"repos/%s/" % repo repos[repo].slug = repo # Surround all lines indented with four spaces with [code] tags. diff --git a/scenes/sandbox.gd b/scenes/sandbox.gd index 069489e..a2f98b6 100644 --- a/scenes/sandbox.gd +++ b/scenes/sandbox.gd @@ -15,7 +15,7 @@ func _ready(): helpers.crash("Directory %s does not exist" % args["sandbox"]) if path == null: - path = game.tmp_prefix_inside+"/repos/sandbox/" + path = game.tmp_prefix+"/repos/sandbox/" helpers.careful_delete(path) game.global_shell.run("mkdir " + path) diff --git a/scenes/shell.gd b/scenes/shell.gd index 2635de8..a64fdf5 100644 --- a/scenes/shell.gd +++ b/scenes/shell.gd @@ -7,7 +7,7 @@ var _cwd var _os = OS.get_name() func _init(): - _cwd = game.tmp_prefix_inside + _cwd = game.tmp_prefix func cd(dir): _cwd = dir @@ -58,7 +58,7 @@ func run(command, crash_on_fail=true): # On Windows, if the command contains a newline (even if inside a string), # execution will end. To avoid that, we first write the command to a file, # and run that file with bash. - var script_path = game.tmp_prefix_inside + "command" + str(randi()) + var script_path = game.tmp_prefix + "command" + str(randi()) helpers.write_file(script_path, hacky_command) result = helpers.exec(_shell_binary(), [script_path], crash_on_fail) else: diff --git a/scenes/text_editor.gd b/scenes/text_editor.gd index 2fb9633..350e7e4 100644 --- a/scenes/text_editor.gd +++ b/scenes/text_editor.gd @@ -17,7 +17,7 @@ func _process(_delta): _client_connection = _server.take_connection() var length = _client_connection.get_u8() var filename = _client_connection.get_string(length) - filename = filename.replace("%srepos/" % game.tmp_prefix_inside, "") + filename = filename.replace("%srepos/" % game.tmp_prefix, "") open(filename) func _input(event): @@ -27,7 +27,7 @@ func _input(event): func open(filename): path = filename - var fixme_path = game.tmp_prefix_outside+"repos/" + var fixme_path = game.tmp_prefix+"repos/" var content = helpers.read_file(fixme_path+filename) text = content @@ -36,7 +36,7 @@ func open(filename): func save(): if visible: - var fixme_path = game.tmp_prefix_outside+"repos/" + var fixme_path = game.tmp_prefix+"repos/" # Add a newline to the end of the file if there is none. if text.length() > 0 and text.substr(text.length()-1, 1) != "\n":