diff options
Diffstat (limited to 'demos/gui')
37 files changed, 285 insertions, 0 deletions
diff --git a/demos/gui/drag_and_drop/drag_and_drop.scn b/demos/gui/drag_and_drop/drag_and_drop.scn Binary files differnew file mode 100644 index 0000000000..94a25cc53e --- /dev/null +++ b/demos/gui/drag_and_drop/drag_and_drop.scn diff --git a/demos/gui/drag_and_drop/drag_drop_script.gd b/demos/gui/drag_and_drop/drag_drop_script.gd new file mode 100644 index 0000000000..21a737ce1a --- /dev/null +++ b/demos/gui/drag_and_drop/drag_drop_script.gd @@ -0,0 +1,24 @@ + +extends ColorPickerButton + + +#virtual function +func get_drag_data(pos): + + #use another colorpicker as drag preview + var cpb = ColorPickerButton.new() + cpb.set_color( get_color() ) + cpb.set_size(Vector2(50,50)) + set_drag_preview(cpb) + #return color as drag data + return get_color() + +#virtual function +func can_drop_data(pos, data): + return typeof(data)==TYPE_COLOR + +#virtual function +func drop_data(pos, data): + set_color(data) + + diff --git a/demos/gui/drag_and_drop/engine.cfg b/demos/gui/drag_and_drop/engine.cfg new file mode 100644 index 0000000000..49b9b93512 --- /dev/null +++ b/demos/gui/drag_and_drop/engine.cfg @@ -0,0 +1,5 @@ +[application] + +name="Drag & Drop (GUI)" +main_scene="res://drag_and_drop.scn" +icon="res://icon.png" diff --git a/demos/gui/drag_and_drop/icon.png b/demos/gui/drag_and_drop/icon.png Binary files differnew file mode 100644 index 0000000000..f900d8d4a3 --- /dev/null +++ b/demos/gui/drag_and_drop/icon.png 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 Binary files differnew file mode 100644 index 0000000000..276712ba22 --- /dev/null +++ b/demos/gui/input_mapping/controls.scn diff --git a/demos/gui/input_mapping/engine.cfg b/demos/gui/input_mapping/engine.cfg new file mode 100644 index 0000000000..811635ce25 --- /dev/null +++ b/demos/gui/input_mapping/engine.cfg @@ -0,0 +1,18 @@ +[application] + +name="Input Mapping GUI" +main_scene="res://controls.scn" +icon="res://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)] diff --git a/demos/gui/input_mapping/icon.png b/demos/gui/input_mapping/icon.png Binary files differnew file mode 100644 index 0000000000..5a1abf4f58 --- /dev/null +++ b/demos/gui/input_mapping/icon.png diff --git a/demos/gui/rich_text_bbcode/OFL.txt b/demos/gui/rich_text_bbcode/OFL.txt new file mode 100644 index 0000000000..723d4560b9 --- /dev/null +++ b/demos/gui/rich_text_bbcode/OFL.txt @@ -0,0 +1,92 @@ +Copyright (c) 2009-2011 by Accademia di Belle Arti di Urbino and students of MA course of Visual design. Some rights reserved.
+This Font Software is licensed under the SIL Open Font License, Version 1.1.
+This license is copied below, and is also available with a FAQ at:
+http://scripts.sil.org/OFL
+
+
+-----------------------------------------------------------
+SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
+-----------------------------------------------------------
+
+PREAMBLE
+The goals of the Open Font License (OFL) are to stimulate worldwide
+development of collaborative font projects, to support the font creation
+efforts of academic and linguistic communities, and to provide a free and
+open framework in which fonts may be shared and improved in partnership
+with others.
+
+The OFL allows the licensed fonts to be used, studied, modified and
+redistributed freely as long as they are not sold by themselves. The
+fonts, including any derivative works, can be bundled, embedded,
+redistributed and/or sold with any software provided that any reserved
+names are not used by derivative works. The fonts and derivatives,
+however, cannot be released under any other type of license. The
+requirement for fonts to remain under this license does not apply
+to any document created using the fonts or their derivatives.
+
+DEFINITIONS
+"Font Software" refers to the set of files released by the Copyright
+Holder(s) under this license and clearly marked as such. This may
+include source files, build scripts and documentation.
+
+"Reserved Font Name" refers to any names specified as such after the
+copyright statement(s).
+
+"Original Version" refers to the collection of Font Software components as
+distributed by the Copyright Holder(s).
+
+"Modified Version" refers to any derivative made by adding to, deleting,
+or substituting -- in part or in whole -- any of the components of the
+Original Version, by changing formats or by porting the Font Software to a
+new environment.
+
+"Author" refers to any designer, engineer, programmer, technical
+writer or other person who contributed to the Font Software.
+
+PERMISSION & CONDITIONS
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of the Font Software, to use, study, copy, merge, embed, modify,
+redistribute, and sell modified and unmodified copies of the Font
+Software, subject to the following conditions:
+
+1) Neither the Font Software nor any of its individual components,
+in Original or Modified Versions, may be sold by itself.
+
+2) Original or Modified Versions of the Font Software may be bundled,
+redistributed and/or sold with any software, provided that each copy
+contains the above copyright notice and this license. These can be
+included either as stand-alone text files, human-readable headers or
+in the appropriate machine-readable metadata fields within text or
+binary files as long as those fields can be easily viewed by the user.
+
+3) No Modified Version of the Font Software may use the Reserved Font
+Name(s) unless explicit written permission is granted by the corresponding
+Copyright Holder. This restriction only applies to the primary font name as
+presented to the users.
+
+4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
+Software shall not be used to promote, endorse or advertise any
+Modified Version, except to acknowledge the contribution(s) of the
+Copyright Holder(s) and the Author(s) or with their explicit written
+permission.
+
+5) The Font Software, modified or unmodified, in part or in whole,
+must be distributed entirely under this license, and must not be
+distributed under any other license. The requirement for fonts to
+remain under this license does not apply to any document created
+using the Font Software.
+
+TERMINATION
+This license becomes null and void if any of the above conditions are
+not met.
+
+DISCLAIMER
+THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
+OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
+COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
+DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
+OTHER DEALINGS IN THE FONT SOFTWARE.
diff --git a/demos/gui/rich_text_bbcode/TitilliumWeb-Bold.ttf b/demos/gui/rich_text_bbcode/TitilliumWeb-Bold.ttf Binary files differnew file mode 100644 index 0000000000..0af0fe7d27 --- /dev/null +++ b/demos/gui/rich_text_bbcode/TitilliumWeb-Bold.ttf diff --git a/demos/gui/rich_text_bbcode/TitilliumWeb-BoldItalic.ttf b/demos/gui/rich_text_bbcode/TitilliumWeb-BoldItalic.ttf Binary files differnew file mode 100644 index 0000000000..77425eaab6 --- /dev/null +++ b/demos/gui/rich_text_bbcode/TitilliumWeb-BoldItalic.ttf diff --git a/demos/gui/rich_text_bbcode/TitilliumWeb-Italic.ttf b/demos/gui/rich_text_bbcode/TitilliumWeb-Italic.ttf Binary files differnew file mode 100644 index 0000000000..42f2c10f18 --- /dev/null +++ b/demos/gui/rich_text_bbcode/TitilliumWeb-Italic.ttf diff --git a/demos/gui/rich_text_bbcode/TitilliumWeb-Regular.ttf b/demos/gui/rich_text_bbcode/TitilliumWeb-Regular.ttf Binary files differnew file mode 100644 index 0000000000..6da821935d --- /dev/null +++ b/demos/gui/rich_text_bbcode/TitilliumWeb-Regular.ttf diff --git a/demos/gui/rich_text_bbcode/engine.cfg b/demos/gui/rich_text_bbcode/engine.cfg new file mode 100644 index 0000000000..5f68b6a0e6 --- /dev/null +++ b/demos/gui/rich_text_bbcode/engine.cfg @@ -0,0 +1,5 @@ +[application] + +name="Rich Text Label (BBCode)" +main_scene="res://rich_text_bbcode.scn" +icon="res://icon.png" diff --git a/demos/gui/rich_text_bbcode/icon.png b/demos/gui/rich_text_bbcode/icon.png Binary files differnew file mode 100644 index 0000000000..6db48a3a9b --- /dev/null +++ b/demos/gui/rich_text_bbcode/icon.png diff --git a/demos/gui/rich_text_bbcode/rich_text_bbcode.gd b/demos/gui/rich_text_bbcode/rich_text_bbcode.gd new file mode 100644 index 0000000000..30fac1f729 --- /dev/null +++ b/demos/gui/rich_text_bbcode/rich_text_bbcode.gd @@ -0,0 +1,17 @@ + +extends Panel + +# member variables here, example: +# var a=2 +# var b="textvar" + +func _ready(): + # Initialization here + pass + + + + +func _on_RichTextLabel_meta_clicked( meta ): + OS.shell_open(meta) + pass # replace with function body diff --git a/demos/gui/rich_text_bbcode/rich_text_bbcode.scn b/demos/gui/rich_text_bbcode/rich_text_bbcode.scn Binary files differnew file mode 100644 index 0000000000..ca02044bb8 --- /dev/null +++ b/demos/gui/rich_text_bbcode/rich_text_bbcode.scn diff --git a/demos/gui/rich_text_bbcode/titilium-bold.fnt b/demos/gui/rich_text_bbcode/titilium-bold.fnt Binary files differnew file mode 100644 index 0000000000..7920ca743d --- /dev/null +++ b/demos/gui/rich_text_bbcode/titilium-bold.fnt diff --git a/demos/gui/rich_text_bbcode/titilium-bolditalic.fnt b/demos/gui/rich_text_bbcode/titilium-bolditalic.fnt Binary files differnew file mode 100644 index 0000000000..cc2d650d08 --- /dev/null +++ b/demos/gui/rich_text_bbcode/titilium-bolditalic.fnt diff --git a/demos/gui/rich_text_bbcode/titilium-italic.fnt b/demos/gui/rich_text_bbcode/titilium-italic.fnt Binary files differnew file mode 100644 index 0000000000..f2e8edf2c2 --- /dev/null +++ b/demos/gui/rich_text_bbcode/titilium-italic.fnt diff --git a/demos/gui/rich_text_bbcode/titilium-regular.fnt b/demos/gui/rich_text_bbcode/titilium-regular.fnt Binary files differnew file mode 100644 index 0000000000..fc3b789e11 --- /dev/null +++ b/demos/gui/rich_text_bbcode/titilium-regular.fnt diff --git a/demos/gui/rich_text_bbcode/unicorn_icon.png b/demos/gui/rich_text_bbcode/unicorn_icon.png Binary files differnew file mode 100644 index 0000000000..a14517e12b --- /dev/null +++ b/demos/gui/rich_text_bbcode/unicorn_icon.png 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 Binary files differnew file mode 100644 index 0000000000..66e6d47702 --- /dev/null +++ b/demos/gui/translation/controls.scn diff --git a/demos/gui/translation/engine.cfg b/demos/gui/translation/engine.cfg new file mode 100644 index 0000000000..dcd3d1983d --- /dev/null +++ b/demos/gui/translation/engine.cfg @@ -0,0 +1,10 @@ +[application] + +name="Translation Demo" +main_scene="res://main.scn" +icon="res://icon.png" + +[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 Binary files differnew file mode 100644 index 0000000000..4cc8267a5c --- /dev/null +++ b/demos/gui/translation/flag_japan.png diff --git a/demos/gui/translation/flag_spain.png b/demos/gui/translation/flag_spain.png Binary files differnew file mode 100644 index 0000000000..4d00f93593 --- /dev/null +++ b/demos/gui/translation/flag_spain.png diff --git a/demos/gui/translation/flag_uk.png b/demos/gui/translation/flag_uk.png Binary files differnew file mode 100644 index 0000000000..53fbef3d67 --- /dev/null +++ b/demos/gui/translation/flag_uk.png diff --git a/demos/gui/translation/icon.png b/demos/gui/translation/icon.png Binary files differnew file mode 100644 index 0000000000..4be5ac1127 --- /dev/null +++ b/demos/gui/translation/icon.png 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 Binary files differnew file mode 100644 index 0000000000..76c9ba7b45 --- /dev/null +++ b/demos/gui/translation/main.scn diff --git a/demos/gui/translation/noto.fnt b/demos/gui/translation/noto.fnt Binary files differnew file mode 100644 index 0000000000..e019615f41 --- /dev/null +++ b/demos/gui/translation/noto.fnt diff --git a/demos/gui/translation/notosans.otf b/demos/gui/translation/notosans.otf Binary files differnew file mode 100644 index 0000000000..6443f9023e --- /dev/null +++ b/demos/gui/translation/notosans.otf 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 Binary files differnew file mode 100644 index 0000000000..7bcba63e71 --- /dev/null +++ b/demos/gui/translation/translations/text.en.xl diff --git a/demos/gui/translation/translations/text.es.xl b/demos/gui/translation/translations/text.es.xl Binary files differnew file mode 100644 index 0000000000..4474d955d5 --- /dev/null +++ b/demos/gui/translation/translations/text.es.xl diff --git a/demos/gui/translation/translations/text.ja.xl b/demos/gui/translation/translations/text.ja.xl Binary files differnew file mode 100644 index 0000000000..b3d1f0bf60 --- /dev/null +++ b/demos/gui/translation/translations/text.ja.xl |