From 67bf14bbbbbdcbb6b6f995a54603d1695766ea6e Mon Sep 17 00:00:00 2001 From: Nathan Warden Date: Sun, 10 May 2015 17:39:38 -0500 Subject: Removed redundant code in the kinematic 3D demo. --- demos/3d/kinematic_char/cubio.gd | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'demos') diff --git a/demos/3d/kinematic_char/cubio.gd b/demos/3d/kinematic_char/cubio.gd index a1baa78a0c..058b919d05 100644 --- a/demos/3d/kinematic_char/cubio.gd +++ b/demos/3d/kinematic_char/cubio.gd @@ -46,9 +46,8 @@ func _fixed_process(delta): vel.x=hvel.x; vel.z=hvel.z - - var motion = vel*delta - motion=move(vel*delta) + + var motion = move(vel*delta) var on_floor = false var original_vel = vel -- cgit v1.2.3 From 17ccd8d9b7c82ee4e3448c4923f9c1c8da4be1be Mon Sep 17 00:00:00 2001 From: Juan Linietsky Date: Mon, 11 May 2015 21:39:42 -0300 Subject: fixs particles on 3d platformer demo, closes #1588 --- demos/3d/platformer/bullet.scn | Bin 6156 -> 6157 bytes 1 file changed, 0 insertions(+), 0 deletions(-) (limited to 'demos') diff --git a/demos/3d/platformer/bullet.scn b/demos/3d/platformer/bullet.scn index 4f1623b7d9..da90dba1a5 100644 Binary files a/demos/3d/platformer/bullet.scn and b/demos/3d/platformer/bullet.scn differ -- cgit v1.2.3 From dc3d0bdf3809c8107db1d47b938edbfaa5aa332b Mon Sep 17 00:00:00 2001 From: Juan Linietsky Date: Mon, 11 May 2015 22:34:29 -0300 Subject: Translation Demo --- demos/gui/translation/controls.scn | Bin 0 -> 1857 bytes demos/gui/translation/engine.cfg | 8 +++++ demos/gui/translation/main.gd | 42 ++++++++++++++++++++++++++ demos/gui/translation/main.scn | Bin 0 -> 2051 bytes demos/gui/translation/noto.fnt | Bin 0 -> 9171 bytes demos/gui/translation/notosans.otf | Bin 0 -> 16426032 bytes demos/gui/translation/text.csv | 3 ++ demos/gui/translation/translations/text.en.xl | Bin 0 -> 575 bytes demos/gui/translation/translations/text.es.xl | Bin 0 -> 579 bytes demos/gui/translation/translations/text.ja.xl | Bin 0 -> 595 bytes 10 files changed, 53 insertions(+) create mode 100644 demos/gui/translation/controls.scn create mode 100644 demos/gui/translation/engine.cfg create mode 100644 demos/gui/translation/main.gd create mode 100644 demos/gui/translation/main.scn create mode 100644 demos/gui/translation/noto.fnt create mode 100644 demos/gui/translation/notosans.otf create mode 100644 demos/gui/translation/text.csv create mode 100644 demos/gui/translation/translations/text.en.xl create mode 100644 demos/gui/translation/translations/text.es.xl create mode 100644 demos/gui/translation/translations/text.ja.xl (limited to 'demos') diff --git a/demos/gui/translation/controls.scn b/demos/gui/translation/controls.scn new file mode 100644 index 0000000000..23e2413bc3 Binary files /dev/null and b/demos/gui/translation/controls.scn differ diff --git a/demos/gui/translation/engine.cfg b/demos/gui/translation/engine.cfg new file mode 100644 index 0000000000..4f01f200c6 --- /dev/null +++ b/demos/gui/translation/engine.cfg @@ -0,0 +1,8 @@ +[application] + +name="Translation Demo" +main_scene="res://main.scn" + +[locale] + +translations=["res://translations/text.en.xl", "res://translations/text.es.xl", "res://translations/text.ja.xl"] diff --git a/demos/gui/translation/main.gd b/demos/gui/translation/main.gd new file mode 100644 index 0000000000..bf3c0c0840 --- /dev/null +++ b/demos/gui/translation/main.gd @@ -0,0 +1,42 @@ + +extends Panel + +# member variables here, example: +# var a=2 +# var b="textvar" + +func _ready(): + # Initialization here + pass + + + +func _goto_scene(): + var s = load("res://controls.scn") + var si = s.instance() + get_parent().add_child(si) + queue_free() + pass + + +func _on_system_pressed(): + #will autodetect based on system, then fall back + #to english if not found + _goto_scene() + +#NOTE: Changling locale will not change the text in the controls, +# The scene must be reloaded for changes to take effect. + +func _on_english_pressed(): + TranslationServer.set_locale("en") + _goto_scene() + + +func _on_spanish_pressed(): + TranslationServer.set_locale("es") + _goto_scene() + + +func _on_japanese_pressed(): + TranslationServer.set_locale("ja") + _goto_scene() diff --git a/demos/gui/translation/main.scn b/demos/gui/translation/main.scn new file mode 100644 index 0000000000..1e1bd0141e Binary files /dev/null and b/demos/gui/translation/main.scn differ diff --git a/demos/gui/translation/noto.fnt b/demos/gui/translation/noto.fnt new file mode 100644 index 0000000000..e019615f41 Binary files /dev/null and b/demos/gui/translation/noto.fnt differ diff --git a/demos/gui/translation/notosans.otf b/demos/gui/translation/notosans.otf new file mode 100644 index 0000000000..6443f9023e Binary files /dev/null and b/demos/gui/translation/notosans.otf differ diff --git a/demos/gui/translation/text.csv b/demos/gui/translation/text.csv new file mode 100644 index 0000000000..0f4c148b95 --- /dev/null +++ b/demos/gui/translation/text.csv @@ -0,0 +1,3 @@ +,en,es,ja +KEY_HELLO,Hello!,Hola!,こんにちは +KEY_PUSH,Push Me!,Aprétame!,私をプッシュ \ No newline at end of file diff --git a/demos/gui/translation/translations/text.en.xl b/demos/gui/translation/translations/text.en.xl new file mode 100644 index 0000000000..7bcba63e71 Binary files /dev/null and b/demos/gui/translation/translations/text.en.xl differ diff --git a/demos/gui/translation/translations/text.es.xl b/demos/gui/translation/translations/text.es.xl new file mode 100644 index 0000000000..4474d955d5 Binary files /dev/null and b/demos/gui/translation/translations/text.es.xl differ diff --git a/demos/gui/translation/translations/text.ja.xl b/demos/gui/translation/translations/text.ja.xl new file mode 100644 index 0000000000..b3d1f0bf60 Binary files /dev/null and b/demos/gui/translation/translations/text.ja.xl differ -- cgit v1.2.3 From 436379860855fe2d1b073a74f4bfa4e7acc96c5b Mon Sep 17 00:00:00 2001 From: Juan Linietsky Date: Tue, 12 May 2015 07:31:15 -0300 Subject: -Fixed bug in translation remaps, also added proper demo, maybe fixes #1729 --- demos/gui/translation/controls.gd | 20 ++++++++++++++++++++ demos/gui/translation/controls.scn | Bin 1857 -> 2349 bytes demos/gui/translation/engine.cfg | 1 + demos/gui/translation/flag_japan.png | Bin 0 -> 1473 bytes demos/gui/translation/flag_spain.png | Bin 0 -> 3048 bytes demos/gui/translation/flag_uk.png | Bin 0 -> 6544 bytes demos/gui/translation/main.scn | Bin 2051 -> 2671 bytes 7 files changed, 21 insertions(+) create mode 100644 demos/gui/translation/controls.gd create mode 100644 demos/gui/translation/flag_japan.png create mode 100644 demos/gui/translation/flag_spain.png create mode 100644 demos/gui/translation/flag_uk.png (limited to 'demos') diff --git a/demos/gui/translation/controls.gd b/demos/gui/translation/controls.gd new file mode 100644 index 0000000000..f8403f49a7 --- /dev/null +++ b/demos/gui/translation/controls.gd @@ -0,0 +1,20 @@ + +extends Panel + +# member variables here, example: +# var a=2 +# var b="textvar" + +func _ready(): + # Initialization here + pass + + + + +func _on_back_pressed(): + var s = load("res://main.scn") + var si = s.instance() + get_parent().add_child(si) + queue_free() + pass # replace with function body diff --git a/demos/gui/translation/controls.scn b/demos/gui/translation/controls.scn index 23e2413bc3..66e6d47702 100644 Binary files a/demos/gui/translation/controls.scn and b/demos/gui/translation/controls.scn differ diff --git a/demos/gui/translation/engine.cfg b/demos/gui/translation/engine.cfg index 4f01f200c6..169b65e154 100644 --- a/demos/gui/translation/engine.cfg +++ b/demos/gui/translation/engine.cfg @@ -6,3 +6,4 @@ main_scene="res://main.scn" [locale] translations=["res://translations/text.en.xl", "res://translations/text.es.xl", "res://translations/text.ja.xl"] +translation_remaps={"res://flag_uk.png":["res://flag_spain.png:es", "res://flag_japan.png:ja"]} diff --git a/demos/gui/translation/flag_japan.png b/demos/gui/translation/flag_japan.png new file mode 100644 index 0000000000..4cc8267a5c Binary files /dev/null and b/demos/gui/translation/flag_japan.png differ diff --git a/demos/gui/translation/flag_spain.png b/demos/gui/translation/flag_spain.png new file mode 100644 index 0000000000..4d00f93593 Binary files /dev/null and b/demos/gui/translation/flag_spain.png differ diff --git a/demos/gui/translation/flag_uk.png b/demos/gui/translation/flag_uk.png new file mode 100644 index 0000000000..53fbef3d67 Binary files /dev/null and b/demos/gui/translation/flag_uk.png differ diff --git a/demos/gui/translation/main.scn b/demos/gui/translation/main.scn index 1e1bd0141e..76c9ba7b45 100644 Binary files a/demos/gui/translation/main.scn and b/demos/gui/translation/main.scn differ -- cgit v1.2.3 From 3936ed882c6f39c74a3b124a95d5adc5e61ab3c5 Mon Sep 17 00:00:00 2001 From: Juan Linietsky Date: Tue, 12 May 2015 08:17:09 -0300 Subject: -Added lookat/get_angle_to functions in 2D, and a demo, closes #1843 -Added get_viewport().get_mouse_pos() to replace Input.get_mouse_pos(), closes #1838 --- demos/2d/lookat/arrow.png | Bin 0 -> 2528 bytes demos/2d/lookat/engine.cfg | 4 ++++ demos/2d/lookat/lookat.gd | 43 +++++++++++++++++++++++++++++++++++++++++++ demos/2d/lookat/lookat.scn | Bin 0 -> 1622 bytes 4 files changed, 47 insertions(+) create mode 100644 demos/2d/lookat/arrow.png create mode 100644 demos/2d/lookat/engine.cfg create mode 100644 demos/2d/lookat/lookat.gd create mode 100644 demos/2d/lookat/lookat.scn (limited to 'demos') diff --git a/demos/2d/lookat/arrow.png b/demos/2d/lookat/arrow.png new file mode 100644 index 0000000000..25db91e8d1 Binary files /dev/null and b/demos/2d/lookat/arrow.png differ diff --git a/demos/2d/lookat/engine.cfg b/demos/2d/lookat/engine.cfg new file mode 100644 index 0000000000..56917a39ec --- /dev/null +++ b/demos/2d/lookat/engine.cfg @@ -0,0 +1,4 @@ +[application] + +name="Look At Pointer" +main_scene="res://lookat.scn" diff --git a/demos/2d/lookat/lookat.gd b/demos/2d/lookat/lookat.gd new file mode 100644 index 0000000000..742c5b0671 --- /dev/null +++ b/demos/2d/lookat/lookat.gd @@ -0,0 +1,43 @@ + +extends Sprite + +# member variables here, example: +# var a=2 +# var b="textvar" + +const MODE_DIRECT=0 +const MODE_CONSTANT=1 +const MODE_SMOOTH=2 + +const ROTATION_SPEED = 1 +const SMOOTH_SPEED = 2.0 + +export(int,"Direct","Constant","Smooth") var mode=MODE_DIRECT + +func _process(delta): + var mpos = get_viewport().get_mouse_pos() + + if (mode==MODE_DIRECT): + + look_at(mpos) + + elif (mode==MODE_CONSTANT): + + var ang = get_angle_to(mpos) + var s = sign(ang) + ang=abs(ang) + + rotate( min(ang,ROTATION_SPEED*delta)*s ) + + elif (mode==MODE_SMOOTH): + + var ang = get_angle_to(mpos) + + rotate( ang*delta*SMOOTH_SPEED ) + +func _ready(): + # Initialization here + set_process(true) + pass + + diff --git a/demos/2d/lookat/lookat.scn b/demos/2d/lookat/lookat.scn new file mode 100644 index 0000000000..880070b4c7 Binary files /dev/null and b/demos/2d/lookat/lookat.scn differ -- cgit v1.2.3 From 1e382dbb1835d0509630ee9e6a61501e3839239b Mon Sep 17 00:00:00 2001 From: Juan Linietsky Date: Sat, 16 May 2015 17:05:56 -0300 Subject: -small motion demo, to better troubleshoot --- demos/2d/motion/car.png | Bin 0 -> 2086 bytes demos/2d/motion/engine.cfg | 4 ++++ demos/2d/motion/motion.gd | 38 ++++++++++++++++++++++++++++++++++++++ demos/2d/motion/motion.scn | Bin 0 -> 2845 bytes 4 files changed, 42 insertions(+) create mode 100644 demos/2d/motion/car.png create mode 100644 demos/2d/motion/engine.cfg create mode 100644 demos/2d/motion/motion.gd create mode 100644 demos/2d/motion/motion.scn (limited to 'demos') diff --git a/demos/2d/motion/car.png b/demos/2d/motion/car.png new file mode 100644 index 0000000000..7ea973ceeb Binary files /dev/null and b/demos/2d/motion/car.png differ diff --git a/demos/2d/motion/engine.cfg b/demos/2d/motion/engine.cfg new file mode 100644 index 0000000000..064de6b331 --- /dev/null +++ b/demos/2d/motion/engine.cfg @@ -0,0 +1,4 @@ +[application] + +name="Motion Test" +main_scene="res://motion.scn" diff --git a/demos/2d/motion/motion.gd b/demos/2d/motion/motion.gd new file mode 100644 index 0000000000..8f8f56a889 --- /dev/null +++ b/demos/2d/motion/motion.gd @@ -0,0 +1,38 @@ + +extends Sprite + + +export var use_idle=true + +# member variables here, example: +# var a=2 +# var b="textvar" +const BEGIN = -113 +const END = 907 +const TIME = 5.0 # seconds +const SPEED = (END-BEGIN)/TIME + +func _process(delta): + var ofs = get_pos() + ofs.x+=delta*SPEED + if (ofs.x>END): + ofs.x=BEGIN + set_pos(ofs) + +func _fixed_process(delta): + var ofs = get_pos() + ofs.x+=delta*SPEED + if (ofs.x>END): + ofs.x=BEGIN + set_pos(ofs) + + +func _ready(): + # Initialization here + if (use_idle): + set_process(true) + else: + set_fixed_process(true) + pass + + diff --git a/demos/2d/motion/motion.scn b/demos/2d/motion/motion.scn new file mode 100644 index 0000000000..6c5b5307ac Binary files /dev/null and b/demos/2d/motion/motion.scn differ -- cgit v1.2.3 From b6b346e8aeaa4b31f4a89b0711e48a08fa802cf5 Mon Sep 17 00:00:00 2001 From: Juan Linietsky Date: Sun, 17 May 2015 16:33:35 -0300 Subject: added a built-in scene changer API, closes #1928 --- demos/misc/scene_changer/engine.cfg | 4 ++++ demos/misc/scene_changer/scene_a.gd | 17 +++++++++++++++++ demos/misc/scene_changer/scene_a.scn | Bin 0 -> 1459 bytes demos/misc/scene_changer/scene_b.gd | 17 +++++++++++++++++ demos/misc/scene_changer/scene_b.scn | Bin 0 -> 1448 bytes 5 files changed, 38 insertions(+) create mode 100644 demos/misc/scene_changer/engine.cfg create mode 100644 demos/misc/scene_changer/scene_a.gd create mode 100644 demos/misc/scene_changer/scene_a.scn create mode 100644 demos/misc/scene_changer/scene_b.gd create mode 100644 demos/misc/scene_changer/scene_b.scn (limited to 'demos') diff --git a/demos/misc/scene_changer/engine.cfg b/demos/misc/scene_changer/engine.cfg new file mode 100644 index 0000000000..1ba1a41167 --- /dev/null +++ b/demos/misc/scene_changer/engine.cfg @@ -0,0 +1,4 @@ +[application] + +name="Scene Changer" +main_scene="res://scene_a.scn" diff --git a/demos/misc/scene_changer/scene_a.gd b/demos/misc/scene_changer/scene_a.gd new file mode 100644 index 0000000000..956878b0f7 --- /dev/null +++ b/demos/misc/scene_changer/scene_a.gd @@ -0,0 +1,17 @@ + +extends Panel + +# member variables here, example: +# var a=2 +# var b="textvar" + +func _ready(): + # Initalization here + pass + + + + +func _on_goto_scene_pressed(): + get_tree().change_scene("res://scene_b.scn") + pass # replace with function body diff --git a/demos/misc/scene_changer/scene_a.scn b/demos/misc/scene_changer/scene_a.scn new file mode 100644 index 0000000000..61727a57ba Binary files /dev/null and b/demos/misc/scene_changer/scene_a.scn differ diff --git a/demos/misc/scene_changer/scene_b.gd b/demos/misc/scene_changer/scene_b.gd new file mode 100644 index 0000000000..4f94d6bb8f --- /dev/null +++ b/demos/misc/scene_changer/scene_b.gd @@ -0,0 +1,17 @@ + +extends Panel + +# member variables here, example: +# var a=2 +# var b="textvar" + +func _ready(): + # Initalization here + pass + + + + +func _on_goto_scene_pressed(): + get_tree().change_scene("res://scene_a.scn") + pass # replace with function body diff --git a/demos/misc/scene_changer/scene_b.scn b/demos/misc/scene_changer/scene_b.scn new file mode 100644 index 0000000000..ae09eeff88 Binary files /dev/null and b/demos/misc/scene_changer/scene_b.scn differ -- cgit v1.2.3 From 221443c5a2d174e52d391d15d5f1c6b5c9496d57 Mon Sep 17 00:00:00 2001 From: Juan Linietsky Date: Tue, 19 May 2015 21:36:35 -0300 Subject: more fixes -only refuse to load an older file if version major is different, fixes #1944 -fix drive letter default value, fixes #1939 --- demos/2d/kinematic_char/engine.cfg | 7 +++++++ demos/2d/lights_shadows/engine.cfg | 3 +++ demos/2d/navpoly/engine.cfg | 7 +++++++ demos/2d/normalmaps/engine.cfg | 7 +++++++ demos/2d/screen_space_shaders/engine.cfg | 6 ++++++ demos/2d/screen_space_shaders/screen_shaders.scn | Bin 5896 -> 5936 bytes demos/2d/texscreen/bubbles.scn | Bin 1456 -> 1551 bytes demos/2d/texscreen/engine.cfg | 7 +++++++ 8 files changed, 37 insertions(+) (limited to 'demos') diff --git a/demos/2d/kinematic_char/engine.cfg b/demos/2d/kinematic_char/engine.cfg index 0132442c18..4ce8f836ae 100644 --- a/demos/2d/kinematic_char/engine.cfg +++ b/demos/2d/kinematic_char/engine.cfg @@ -4,6 +4,13 @@ name="Kinematic Collision" main_scene="res://colworld.scn" icon="res://icon.png" +[display] + +width=800 +height=600 +stretch_mode="2d" +stretch_aspect="keep" + [input] move_up=[key(Up)] diff --git a/demos/2d/lights_shadows/engine.cfg b/demos/2d/lights_shadows/engine.cfg index 7e028c3556..771288c209 100644 --- a/demos/2d/lights_shadows/engine.cfg +++ b/demos/2d/lights_shadows/engine.cfg @@ -6,6 +6,9 @@ main_scene="res://light_shadows.scn" [display] stretch_mode="2d" +width=800 +height=600 +stretch_aspect="keep" [rasterizer] diff --git a/demos/2d/navpoly/engine.cfg b/demos/2d/navpoly/engine.cfg index 51eefd7b77..40515dd3d2 100644 --- a/demos/2d/navpoly/engine.cfg +++ b/demos/2d/navpoly/engine.cfg @@ -2,3 +2,10 @@ name="Navigation Polygon (2D)" main_scene="res://navigation.scn" + +[display] + +width=800 +height=600 +stretch_mode="2d" +stretch_aspect="keep" diff --git a/demos/2d/normalmaps/engine.cfg b/demos/2d/normalmaps/engine.cfg index 3fc2048716..f0002dc2b8 100644 --- a/demos/2d/normalmaps/engine.cfg +++ b/demos/2d/normalmaps/engine.cfg @@ -2,3 +2,10 @@ name="2D Normal Mapping" main_scene="res://normalmap.scn" + +[display] + +stretch_mode="2d" +width=800 +height=600 +stretch_aspect="ignore" diff --git a/demos/2d/screen_space_shaders/engine.cfg b/demos/2d/screen_space_shaders/engine.cfg index 108fdeba34..527e2f8f0a 100644 --- a/demos/2d/screen_space_shaders/engine.cfg +++ b/demos/2d/screen_space_shaders/engine.cfg @@ -3,3 +3,9 @@ name="Screen-Space Shaders" main_scene="res://screen_shaders.scn" +[display] + +width=780 +height=600 +stretch_mode="2d" +stretch_aspect="keep" diff --git a/demos/2d/screen_space_shaders/screen_shaders.scn b/demos/2d/screen_space_shaders/screen_shaders.scn index cc62ac8203..fc2be96fc9 100644 Binary files a/demos/2d/screen_space_shaders/screen_shaders.scn and b/demos/2d/screen_space_shaders/screen_shaders.scn differ diff --git a/demos/2d/texscreen/bubbles.scn b/demos/2d/texscreen/bubbles.scn index 779cba6930..41026aceed 100644 Binary files a/demos/2d/texscreen/bubbles.scn and b/demos/2d/texscreen/bubbles.scn differ diff --git a/demos/2d/texscreen/engine.cfg b/demos/2d/texscreen/engine.cfg index 58193c8c4a..fb683dfc1d 100644 --- a/demos/2d/texscreen/engine.cfg +++ b/demos/2d/texscreen/engine.cfg @@ -2,3 +2,10 @@ name="Glass Bubbles (Texscreen)" main_scene="res://bubbles.scn" + +[display] + +width=800 +height=600 +stretch_mode="2d" +stretch_aspect="keep" -- cgit v1.2.3 From d9e8cd4dde1d27a423fc192d0adf8dd8c1fcab35 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Verschelde?= Date: Wed, 20 May 2015 17:38:41 +0200 Subject: Add input mapping GUI demo --- demos/gui/input_mapping/controls.gd | 49 +++++++++++++++++++++++++++++++++++ demos/gui/input_mapping/controls.scn | Bin 0 -> 2686 bytes demos/gui/input_mapping/engine.cfg | 18 +++++++++++++ 3 files changed, 67 insertions(+) create mode 100644 demos/gui/input_mapping/controls.gd create mode 100644 demos/gui/input_mapping/controls.scn create mode 100644 demos/gui/input_mapping/engine.cfg (limited to 'demos') diff --git a/demos/gui/input_mapping/controls.gd b/demos/gui/input_mapping/controls.gd new file mode 100644 index 0000000000..6ca059c812 --- /dev/null +++ b/demos/gui/input_mapping/controls.gd @@ -0,0 +1,49 @@ +# Note for the reader: +# +# This demo conveniently uses the same names for actions and for the container nodes +# that hold each remapping button. This allow to get back to the button based simply +# on the name of the corresponding action, but it might not be so simple in your project. +# +# A better approach for large-scale input remapping might be to do the connections between +# buttons and wait_for_input through the code, passing as arguments both the name of the +# action and the node, e.g.: +# button.connect("pressed", self, "wait_for_input", [ button, action ]) + +extends Control + +var player_actions = [ "move_up", "move_down", "move_left", "move_right", "jump" ] +var action # To register the action the UI is currently handling +var button # Button node corresponding to the above action + +func wait_for_input(action_bind): + action = action_bind + # See note at the beginning of the script + button = get_node("bindings").get_node(action).get_node("Button") + get_node("contextual_help").set_text("Press a key to assign to the '" + action + "' action.") + set_process_input(true) + +func _input(event): + # Handle the first pressed key + if (event.type == InputEvent.KEY): + # Register the event as handled and stop polling + get_tree().set_input_as_handled() + set_process_input(false) + # Reinitialise the contextual help label + get_node("contextual_help").set_text("Click a key binding to reassign it, or press the Cancel action.") + if (not event.is_action("ui_cancel")): + # Display the string corresponding to the pressed key + button.set_text(OS.get_scancode_string(event.scancode)) + # Start by removing previously key binding(s) + for old_event in InputMap.get_action_list(action): + InputMap.action_erase_event(action, old_event) + # Add the new key binding + InputMap.action_add_event(action, event) + +func _ready(): + # Initialise each button with the default key binding from InputMap + var input_event + for action in player_actions: + # We assume that the key binding that we want is the first one (0), if there are several + input_event = InputMap.get_action_list(action)[0] + # See note at the beginning of the script + get_node("bindings").get_node(action).get_node("Button").set_text(OS.get_scancode_string(input_event.scancode)) diff --git a/demos/gui/input_mapping/controls.scn b/demos/gui/input_mapping/controls.scn new file mode 100644 index 0000000000..276712ba22 Binary files /dev/null and b/demos/gui/input_mapping/controls.scn differ diff --git a/demos/gui/input_mapping/engine.cfg b/demos/gui/input_mapping/engine.cfg new file mode 100644 index 0000000000..959c0ac7d5 --- /dev/null +++ b/demos/gui/input_mapping/engine.cfg @@ -0,0 +1,18 @@ +[application] + +name="Input Mapping GUI" +main_scene="res://controls.scn" +icon="icon.png" + +[display] + +width=640 +height=480 + +[input] + +move_up=[key(Up)] +move_down=[key(Down)] +move_left=[key(Left)] +move_right=[key(Right)] +jump=[key(Space)] -- cgit v1.2.3