mirror of
https://github.com/HarmonyHoney/tiny_crate.git
synced 2026-08-03 13:04:10 +00:00
developer console in effect
This commit is contained in:
parent
c0d8ab4011
commit
0cb5e0be5a
5 changed files with 227 additions and 21 deletions
105
Scene/DevConsole.tscn
Normal file
105
Scene/DevConsole.tscn
Normal file
|
|
@ -0,0 +1,105 @@
|
|||
[gd_scene load_steps=8 format=2]
|
||||
|
||||
[ext_resource path="res://Font/m3x6.tres" type="DynamicFont" id=1]
|
||||
[ext_resource path="res://Script/DevConsole.gd" type="Script" id=2]
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id=3]
|
||||
bg_color = Color( 0.247059, 0.247059, 0.247059, 0.247059 )
|
||||
border_width_left = 4
|
||||
border_width_top = 4
|
||||
border_width_right = 4
|
||||
border_width_bottom = 4
|
||||
border_color = Color( 0.619608, 0.52549, 0.784314, 1 )
|
||||
corner_radius_top_left = 8
|
||||
corner_radius_top_right = 8
|
||||
corner_radius_bottom_right = 8
|
||||
corner_radius_bottom_left = 8
|
||||
anti_aliasing = false
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id=1]
|
||||
draw_center = false
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id=2]
|
||||
draw_center = false
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id=4]
|
||||
draw_center = false
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id=5]
|
||||
draw_center = false
|
||||
|
||||
[node name="DevConsole" type="CanvasLayer"]
|
||||
script = ExtResource( 2 )
|
||||
|
||||
[node name="Control" type="Control" parent="."]
|
||||
margin_right = 320.0
|
||||
margin_bottom = 180.0
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="Panel" type="Panel" parent="Control"]
|
||||
margin_left = 2.0
|
||||
margin_top = 2.0
|
||||
margin_right = 318.0
|
||||
margin_bottom = 156.0
|
||||
custom_styles/panel = SubResource( 3 )
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="Log" type="RichTextLabel" parent="Control"]
|
||||
margin_left = 8.0
|
||||
margin_top = 8.0
|
||||
margin_right = 312.0
|
||||
margin_bottom = 150.0
|
||||
focus_mode = 2
|
||||
custom_styles/focus = SubResource( 1 )
|
||||
custom_styles/normal = SubResource( 2 )
|
||||
custom_fonts/normal_font = ExtResource( 1 )
|
||||
custom_colors/default_color = Color( 0.705882, 0.823529, 0.45098, 1 )
|
||||
custom_colors/selection_color = Color( 1, 1, 1, 0.247059 )
|
||||
custom_colors/font_color_selected = Color( 1, 1, 1, 1 )
|
||||
custom_colors/font_color_shadow = Color( 0.180392, 0.180392, 0.180392, 1 )
|
||||
custom_constants/line_separation = -4
|
||||
text = "Apartments simplicity or understood do it we. Song such eyes had and off. Removed winding ask explain delight out few behaved lasting. Letters old hastily ham sending not sex chamber because present. Oh is indeed twenty entire figure. Occasional diminution announcing new now literature terminated. Really regard excuse off ten pulled. Lady am room head so lady four or eyes an. He do of consulted sometimes concluded mr. An household behaviour if pretended.
|
||||
|
||||
His having within saw become ask passed misery giving. Recommend questions get too fulfilled. He fact in we case miss sake. Entrance be throwing he do blessing up. Hearts warmth in genius do garden advice mr it garret. Collected preserved are middleton dependent residence but him how. Handsome weddings yet mrs you has carriage packages. Preferred joy agreement put continual elsewhere delivered now. Mrs exercise felicity had men speaking met. Rich deal mrs part led pure will but.
|
||||
|
||||
Apartments simplicity or understood do it we. Song such eyes had and off. Removed winding ask explain delight out few behaved lasting. Letters old hastily ham sending not sex chamber because present. Oh is indeed twenty entire figure. Occasional diminution announcing new now literature terminated. Really regard excuse off ten pulled. Lady am room head so lady four or eyes an. He do of consulted sometimes concluded mr. An household behaviour if pretended.
|
||||
|
||||
His having within saw become ask passed misery giving. Recommend questions get too fulfilled. He fact in we case miss sake. Entrance be throwing he do blessing up. Hearts warmth in genius do garden advice mr it garret. Collected preserved are middleton dependent residence but him how. Handsome weddings yet mrs you has carriage packages. Preferred joy agreement put continual elsewhere delivered now. Mrs exercise felicity had men speaking met. Rich deal mrs part led pure will but. "
|
||||
scroll_following = true
|
||||
selection_enabled = true
|
||||
override_selected_font_color = true
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="Panel2" type="Panel" parent="Control"]
|
||||
margin_left = 2.0
|
||||
margin_top = 158.0
|
||||
margin_right = 318.0
|
||||
margin_bottom = 178.0
|
||||
custom_styles/panel = SubResource( 3 )
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="Input" type="LineEdit" parent="Control"]
|
||||
margin_left = 8.0
|
||||
margin_top = 155.0
|
||||
margin_right = 320.0
|
||||
margin_bottom = 178.0
|
||||
custom_styles/focus = SubResource( 4 )
|
||||
custom_styles/normal = SubResource( 5 )
|
||||
custom_fonts/font = ExtResource( 1 )
|
||||
custom_colors/cursor_color = Color( 1, 1, 1, 1 )
|
||||
custom_colors/font_color = Color( 0.909804, 0.490196, 0.243137, 1 )
|
||||
context_menu_enabled = false
|
||||
placeholder_text = "developer console"
|
||||
caret_blink = true
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
[connection signal="text_entered" from="Control/Input" to="." method="_on_Input_text_entered"]
|
||||
93
Script/DevConsole.gd
Normal file
93
Script/DevConsole.gd
Normal file
|
|
@ -0,0 +1,93 @@
|
|||
extends CanvasLayer
|
||||
|
||||
var node_control : Control
|
||||
var node_log : RichTextLabel
|
||||
var node_input : LineEdit
|
||||
|
||||
var is_open := false
|
||||
|
||||
func _ready():
|
||||
node_control= $Control
|
||||
node_log = $Control/Log
|
||||
node_log.clear()
|
||||
node_input = $Control/Input
|
||||
|
||||
node_control.visible = is_open
|
||||
out("untitled project by Harmony Monroe")
|
||||
out("developer console initialized")
|
||||
|
||||
func _process(delta):
|
||||
if btn.p("dev_console"):
|
||||
close() if is_open else open()
|
||||
|
||||
if btn.p("ui_cancel"):
|
||||
close()
|
||||
|
||||
func open():
|
||||
is_open = true
|
||||
node_control.visible = true
|
||||
node_input.grab_focus()
|
||||
|
||||
func close():
|
||||
is_open = false
|
||||
node_control.visible = false
|
||||
node_input.clear()
|
||||
|
||||
# always grab focus when typing
|
||||
func _input(event):
|
||||
if event is InputEventKey and event.pressed:
|
||||
node_input.grab_focus()
|
||||
|
||||
# signal when pressing enter
|
||||
func _on_Input_text_entered(new_text):
|
||||
if not is_open:
|
||||
return
|
||||
|
||||
var method = new_text.split(" ")[0]
|
||||
var args = ""
|
||||
if new_text.split(" ").size() > 1:
|
||||
args = new_text.split(" ")[1]
|
||||
if has_method(method):
|
||||
if args:
|
||||
call(method, args)
|
||||
else:
|
||||
call(method)
|
||||
else:
|
||||
out("can't find: " + method)
|
||||
|
||||
node_input.clear()
|
||||
|
||||
func out(arg = ""):
|
||||
node_log.text += arg + "\n"
|
||||
print("dev.out: ", arg)
|
||||
|
||||
func clear():
|
||||
node_log.clear()
|
||||
|
||||
func quit():
|
||||
out("bye bye")
|
||||
get_tree().quit()
|
||||
|
||||
func reset():
|
||||
out("reset scene")
|
||||
get_tree().reload_current_scene()
|
||||
|
||||
func map(arg = "map0"):
|
||||
if get_tree().change_scene("res://Map/" + arg + ".tscn"):
|
||||
out("error loading map: " + "res://Map/" + arg + ".tscn")
|
||||
else:
|
||||
out("loading map: " + "res://Map/" + arg + ".tscn")
|
||||
|
||||
func box():
|
||||
for i in get_tree().get_nodes_in_group("player"):
|
||||
i.debug_box()
|
||||
|
||||
func winscale(arg = 0):
|
||||
if int(arg) == 0:
|
||||
Shared.set_window_scale()
|
||||
else:
|
||||
Shared.set_window_scale(int(arg))
|
||||
|
||||
func kill():
|
||||
for i in get_tree().get_nodes_in_group("player"):
|
||||
i.death()
|
||||
|
|
@ -64,13 +64,6 @@ func _process(delta):
|
|||
if Engine.editor_hint:
|
||||
return
|
||||
|
||||
# spawn box
|
||||
if btn.p("debug_spawn_box"):
|
||||
var box = scene_box.instance()
|
||||
box.position = Vector2(position.x, position.y - 8)
|
||||
get_parent().add_child(box)
|
||||
|
||||
|
||||
# joystick axis
|
||||
var btnx = btn.d("right") - btn.d("left")
|
||||
var btny = btn.d("down") - btn.d("up")
|
||||
|
|
@ -100,14 +93,14 @@ func _process(delta):
|
|||
|
||||
# hit exit
|
||||
for a in check_area_actors("exit"):
|
||||
print("hit exit")
|
||||
dev.out(name + " hit exit")
|
||||
win()
|
||||
return
|
||||
|
||||
# hit spike
|
||||
if speed_y > -1:
|
||||
for a in check_area_actors("spike"):
|
||||
print("hit spike")
|
||||
dev.out(name + " hit spike")
|
||||
death()
|
||||
return
|
||||
|
||||
|
|
@ -247,6 +240,7 @@ func death():
|
|||
# reset scene
|
||||
Shared.start_reset()
|
||||
queue_free()
|
||||
dev.out(name + " died")
|
||||
|
||||
func win():
|
||||
Shared.map_num += 1
|
||||
|
|
@ -264,6 +258,7 @@ func win():
|
|||
# reset scene
|
||||
Shared.start_reset()
|
||||
queue_free()
|
||||
dev.out("map complete")
|
||||
|
||||
func try_anim(arg : String):
|
||||
if node_anim.current_animation != arg:
|
||||
|
|
@ -271,4 +266,9 @@ func try_anim(arg : String):
|
|||
# update the animationPlayer immediately
|
||||
node_anim.advance(0)
|
||||
|
||||
|
||||
# spawn box
|
||||
func debug_box():
|
||||
var box = scene_box.instance()
|
||||
box.position = Vector2(position.x, position.y - 8)
|
||||
get_parent().add_child(box)
|
||||
dev.out("box spawned")
|
||||
|
|
|
|||
|
|
@ -30,7 +30,8 @@ func set_window_scale(arg := _window_scale):
|
|||
# center window
|
||||
OS.set_window_position(OS.get_screen_size() * 0.5 - OS.get_window_size() * 0.5)
|
||||
|
||||
print("_window_scale: ", _window_scale, " - ", OS.get_window_size())
|
||||
#print("_window_scale: ", _window_scale, " - ", OS.get_window_size())
|
||||
dev.out("_window_scale: " + str(_window_scale) + " - " + str(OS.get_window_size()))
|
||||
|
||||
func _process(delta):
|
||||
# reset timer
|
||||
|
|
@ -38,6 +39,7 @@ func _process(delta):
|
|||
reset_clock -= delta
|
||||
if reset_clock < 0:
|
||||
is_reset = false
|
||||
dev.out("loading scene: " + "res://Map/map" + String(map_num) + ".tscn")
|
||||
get_tree().change_scene("res://Map/map" + String(map_num) + ".tscn")
|
||||
#get_tree().reload_current_scene()
|
||||
|
||||
|
|
@ -48,16 +50,16 @@ func _process(delta):
|
|||
set_window_scale(_window_scale + 1)
|
||||
|
||||
# quit
|
||||
if btn.p("ui_cancel"):
|
||||
if map_num == 0:
|
||||
get_tree().quit()
|
||||
else:
|
||||
map_num = 0
|
||||
get_tree().change_scene("res://Map/map" + String(map_num) + ".tscn")
|
||||
|
||||
# reset
|
||||
if btn.p("reset"):
|
||||
get_tree().reload_current_scene()
|
||||
# if btn.p("ui_cancel"):
|
||||
# if map_num == 0:
|
||||
# get_tree().quit()
|
||||
# else:
|
||||
# map_num = 0
|
||||
# get_tree().change_scene("res://Map/map" + String(map_num) + ".tscn")
|
||||
#
|
||||
# # reset
|
||||
# if btn.p("reset"):
|
||||
# get_tree().reload_current_scene()
|
||||
|
||||
|
||||
func start_reset():
|
||||
|
|
|
|||
|
|
@ -75,6 +75,7 @@ config/icon="res://icon.png"
|
|||
[autoload]
|
||||
|
||||
btn="*res://Script/btn.gd"
|
||||
dev="*res://Scene/DevConsole.tscn"
|
||||
Shared="*res://Script/Shared.gd"
|
||||
|
||||
[display]
|
||||
|
|
@ -178,6 +179,11 @@ window_expand={
|
|||
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":61,"unicode":0,"echo":false,"script":null)
|
||||
]
|
||||
}
|
||||
dev_console={
|
||||
"deadzone": 0.5,
|
||||
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":96,"unicode":0,"echo":false,"script":null)
|
||||
]
|
||||
}
|
||||
|
||||
[rendering]
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue