Fix warnings

This commit is contained in:
Sebastian Morr 2020-10-26 19:56:52 +01:00
parent 2dc04b1682
commit 8f70770107
9 changed files with 19 additions and 52 deletions

View file

@ -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:

View file

@ -126,37 +126,14 @@ 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])

View file

@ -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($"..")

View file

@ -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/"

View file

@ -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):

View file

@ -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.

View file

@ -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)

View file

@ -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:

View file

@ -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":