diff options
author | Rémi Verschelde <rverschelde@gmail.com> | 2015-12-09 08:38:23 +0100 |
---|---|---|
committer | Rémi Verschelde <rverschelde@gmail.com> | 2015-12-09 08:38:23 +0100 |
commit | 8639cecf4cedd56452b47503be19c44b304cd02f (patch) | |
tree | e2a795da15e40c7d9d5b82e33378f8dbf0eaf67a /demos/gui | |
parent | efbb834936fdc9da9789ad37c9cc61e0b90cda95 (diff) |
Improve code formatting and update to 2.0
The scripts were streamlined using more or less the following conventions:
- space after a comma in lists of arguments
- space around weak operators (+, -), no space around strong operators (*, /)
- space after a comment start (#)
- removed trailing spaces or tabs, apart from those that delimit the function indentation level (those could be removed too but since they are added automatically by the editor when typing code, keeping them for now)
- function blocks separate by two newlines
The scene files were resaved with the (current) 2.0 format, and some scenes that were in XML format were converted to SCN, to be consistent across all demos.
Diffstat (limited to 'demos/gui')
-rw-r--r-- | demos/gui/drag_and_drop/drag_and_drop.scn | bin | 2594 -> 2947 bytes | |||
-rw-r--r-- | demos/gui/drag_and_drop/drag_drop_script.gd | 18 | ||||
-rw-r--r-- | demos/gui/input_mapping/controls.gd | 4 | ||||
-rw-r--r-- | demos/gui/input_mapping/controls.scn | bin | 2852 -> 2698 bytes | |||
-rw-r--r-- | demos/gui/rich_text_bbcode/rich_text_bbcode.gd | 13 | ||||
-rw-r--r-- | demos/gui/rich_text_bbcode/rich_text_bbcode.scn | bin | 3288 -> 3217 bytes | |||
-rw-r--r-- | demos/gui/translation/controls.gd | 11 | ||||
-rw-r--r-- | demos/gui/translation/controls.scn | bin | 2349 -> 2272 bytes | |||
-rw-r--r-- | demos/gui/translation/main.gd | 18 | ||||
-rw-r--r-- | demos/gui/translation/main.scn | bin | 2671 -> 2939 bytes |
10 files changed, 16 insertions, 48 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 differindex 94a25cc53e..9dec254ef7 100644 --- a/demos/gui/drag_and_drop/drag_and_drop.scn +++ 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 index 21a737ce1a..7bcaf1a35e 100644 --- a/demos/gui/drag_and_drop/drag_drop_script.gd +++ b/demos/gui/drag_and_drop/drag_drop_script.gd @@ -2,23 +2,19 @@ extends ColorPickerButton -#virtual function func get_drag_data(pos): - - #use another colorpicker as drag preview + # use another colorpicker as drag preview var cpb = ColorPickerButton.new() - cpb.set_color( get_color() ) - cpb.set_size(Vector2(50,50)) + cpb.set_color(get_color()) + cpb.set_size(Vector2(50, 50)) set_drag_preview(cpb) - #return color as drag data + # return color as drag data return get_color() -#virtual function + func can_drop_data(pos, data): - return typeof(data)==TYPE_COLOR + return typeof(data) == TYPE_COLOR + -#virtual function func drop_data(pos, data): set_color(data) - - diff --git a/demos/gui/input_mapping/controls.gd b/demos/gui/input_mapping/controls.gd index 6ca059c812..7420053ef1 100644 --- a/demos/gui/input_mapping/controls.gd +++ b/demos/gui/input_mapping/controls.gd @@ -11,10 +11,12 @@ extends Control +# member variables 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 @@ -22,6 +24,7 @@ func wait_for_input(action_bind): 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): @@ -39,6 +42,7 @@ func _input(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 diff --git a/demos/gui/input_mapping/controls.scn b/demos/gui/input_mapping/controls.scn Binary files differindex 03567fb691..98cbbca464 100644 --- a/demos/gui/input_mapping/controls.scn +++ b/demos/gui/input_mapping/controls.scn diff --git a/demos/gui/rich_text_bbcode/rich_text_bbcode.gd b/demos/gui/rich_text_bbcode/rich_text_bbcode.gd index 30fac1f729..79a08c1303 100644 --- a/demos/gui/rich_text_bbcode/rich_text_bbcode.gd +++ b/demos/gui/rich_text_bbcode/rich_text_bbcode.gd @@ -1,17 +1,6 @@ extends Panel -# member variables here, example: -# var a=2 -# var b="textvar" -func _ready(): - # Initialization here - pass - - - - -func _on_RichTextLabel_meta_clicked( meta ): +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 differindex 081338fd91..c908d44dc3 100644 --- a/demos/gui/rich_text_bbcode/rich_text_bbcode.scn +++ b/demos/gui/rich_text_bbcode/rich_text_bbcode.scn diff --git a/demos/gui/translation/controls.gd b/demos/gui/translation/controls.gd index f8403f49a7..ae2e26362b 100644 --- a/demos/gui/translation/controls.gd +++ b/demos/gui/translation/controls.gd @@ -1,20 +1,9 @@ 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 differindex 66e6d47702..055ac90b9b 100644 --- a/demos/gui/translation/controls.scn +++ b/demos/gui/translation/controls.scn diff --git a/demos/gui/translation/main.gd b/demos/gui/translation/main.gd index bf3c0c0840..9b188cd588 100644 --- a/demos/gui/translation/main.gd +++ b/demos/gui/translation/main.gd @@ -1,31 +1,21 @@ 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 + # 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. +# NOTE: Changing 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") diff --git a/demos/gui/translation/main.scn b/demos/gui/translation/main.scn Binary files differindex 76c9ba7b45..8fc0b4ffb2 100644 --- a/demos/gui/translation/main.scn +++ b/demos/gui/translation/main.scn |