From 77f173461a8f2e708fd20299f3109dbbf907a883 Mon Sep 17 00:00:00 2001 From: Luna Date: Sun, 18 Feb 2018 21:12:56 -0500 Subject: [PATCH] Add hero descriptions to UI --- scenes/HeroSelect.tscn | 72 ----------------------------- scenes/hero_select.tscn | 102 ++++++++++++++++++++++++++++++++++++++++++ scripts/hero_select.gd | 9 ++++ scripts/hero_select_screen.gd | 10 +++++ scripts/lobby.gd | 30 ++++++------- 5 files changed, 135 insertions(+), 88 deletions(-) delete mode 100644 scenes/HeroSelect.tscn create mode 100644 scenes/hero_select.tscn create mode 100644 scripts/hero_select_screen.gd diff --git a/scenes/HeroSelect.tscn b/scenes/HeroSelect.tscn deleted file mode 100644 index d8e103c..0000000 --- a/scenes/HeroSelect.tscn +++ /dev/null @@ -1,72 +0,0 @@ -[gd_scene load_steps=2 format=2] - -[ext_resource path="res://scripts/hero_select.gd" type="Script" id=1] - -[node name="HeroSelect" type="ColorRect" index="0"] - -pause_mode = 2 -anchor_left = 0.0 -anchor_top = 0.0 -anchor_right = 1.0 -anchor_bottom = 1.0 -rect_pivot_offset = Vector2( 0, 0 ) -mouse_filter = 0 -mouse_default_cursor_shape = 0 -size_flags_horizontal = 1 -size_flags_vertical = 1 -color = Color( 0.097229, 0.104696, 0.105469, 1 ) -_sections_unfolded = [ "Anchor", "Margin", "Material", "Pause", "Visibility" ] - -[node name="Hero" type="OptionButton" parent="." index="0"] - -anchor_left = 0.5 -anchor_top = 0.5 -anchor_right = 0.5 -anchor_bottom = 0.5 -margin_left = -192.0 -margin_top = -103.0 -margin_right = 191.0 -margin_bottom = -6.0 -rect_rotation = -0.0115615 -rect_pivot_offset = Vector2( 0, 0 ) -focus_mode = 2 -mouse_filter = 0 -mouse_default_cursor_shape = 0 -size_flags_horizontal = 1 -size_flags_vertical = 1 -toggle_mode = false -action_mode = 0 -enabled_focus_mode = 2 -shortcut = null -group = null -flat = false -align = 0 -selected = -1 -items = [ ] -script = ExtResource( 1 ) - -[node name="Confirm" type="Button" parent="." index="1"] - -anchor_left = 0.5 -anchor_top = 0.5 -anchor_right = 0.5 -anchor_bottom = 0.5 -margin_left = -163.0 -margin_top = 21.0 -margin_right = 163.0 -margin_bottom = 79.0 -rect_pivot_offset = Vector2( 0, 0 ) -focus_mode = 2 -mouse_filter = 0 -mouse_default_cursor_shape = 0 -size_flags_horizontal = 1 -size_flags_vertical = 1 -toggle_mode = false -enabled_focus_mode = 2 -shortcut = null -group = null -text = "Select Hero" -flat = false -align = 1 - - diff --git a/scenes/hero_select.tscn b/scenes/hero_select.tscn new file mode 100644 index 0000000..c3e0e9b --- /dev/null +++ b/scenes/hero_select.tscn @@ -0,0 +1,102 @@ +[gd_scene load_steps=3 format=2] + +[ext_resource path="res://scripts/hero_select_screen.gd" type="Script" id=1] +[ext_resource path="res://scripts/hero_select.gd" type="Script" id=2] + +[node name="HeroSelect" type="ColorRect" index="0"] + +pause_mode = 2 +anchor_left = 0.0 +anchor_top = 0.0 +anchor_right = 1.0 +anchor_bottom = 1.0 +rect_pivot_offset = Vector2( 0, 0 ) +mouse_filter = 0 +mouse_default_cursor_shape = 0 +size_flags_horizontal = 1 +size_flags_vertical = 1 +color = Color( 0.097229, 0.104696, 0.105469, 1 ) +script = ExtResource( 1 ) +_sections_unfolded = [ "Anchor", "Margin", "Material", "Pause", "Visibility" ] + +[node name="Hero" type="OptionButton" parent="." index="0"] + +anchor_left = 0.5 +anchor_top = 0.5 +anchor_right = 0.5 +anchor_bottom = 0.5 +margin_left = -192.0 +margin_top = -103.0 +margin_right = 191.0 +margin_bottom = -6.0 +rect_rotation = -0.0115615 +rect_pivot_offset = Vector2( 0, 0 ) +focus_mode = 2 +mouse_filter = 0 +mouse_default_cursor_shape = 0 +size_flags_horizontal = 1 +size_flags_vertical = 1 +toggle_mode = false +action_mode = 0 +enabled_focus_mode = 2 +shortcut = null +group = null +flat = false +align = 0 +selected = -1 +items = [ ] +script = ExtResource( 2 ) + +[node name="Confirm" type="Button" parent="." index="1"] + +anchor_left = 0.5 +anchor_top = 0.5 +anchor_right = 0.5 +anchor_bottom = 0.5 +margin_left = -163.0 +margin_top = 21.0 +margin_right = 163.0 +margin_bottom = 79.0 +rect_pivot_offset = Vector2( 0, 0 ) +focus_mode = 2 +mouse_filter = 0 +mouse_default_cursor_shape = 0 +size_flags_horizontal = 1 +size_flags_vertical = 1 +toggle_mode = false +enabled_focus_mode = 2 +shortcut = null +group = null +text = "Select Hero" +flat = false +align = 1 + +[node name="HeroDescription" type="RichTextLabel" parent="." index="2"] + +anchor_left = 0.5 +anchor_top = 0.5 +anchor_right = 0.5 +anchor_bottom = 0.5 +margin_left = -198.0 +margin_top = 105.0 +margin_right = 197.0 +margin_bottom = 240.0 +rect_pivot_offset = Vector2( 0, 0 ) +rect_clip_content = true +mouse_filter = 0 +mouse_default_cursor_shape = 0 +size_flags_horizontal = 1 +size_flags_vertical = 1 +bbcode_enabled = false +bbcode_text = "" +visible_characters = -1 +percent_visible = 1.0 +meta_underlined = true +tab_size = 4 +text = "" +scroll_active = true +scroll_following = false +selection_enabled = false +override_selected_font_color = false + + diff --git a/scripts/hero_select.gd b/scripts/hero_select.gd index afd8fea..7624ee5 100644 --- a/scripts/hero_select.gd +++ b/scripts/hero_select.gd @@ -8,6 +8,15 @@ const hero_names = [ "PAZIENZA", ] +const hero_text = [ + "DILIGENCE.\n\nWallride by jumping on walls.\n\nYour speed builds immensely as your Switch Charge increases.", + "WRATH.\n\nPress E and click (or just click) to build a wall.\n\nRight click to destroy one.", + "LUST.\n\nYou attract nearby heroes.\n\nPress E to switch to repelling them.", + "GENEROSITY.\n\nMake contact with a friend to boost their speed.\n\nPress E to separate.", + "PATIENCE.\n\nHold left mouse button on an enemy to slow them down.", +] + func _ready(): for hero_index in range(hero_names.size()): add_item(hero_names[hero_index], hero_index) + diff --git a/scripts/hero_select_screen.gd b/scripts/hero_select_screen.gd new file mode 100644 index 0000000..61ba122 --- /dev/null +++ b/scripts/hero_select_screen.gd @@ -0,0 +1,10 @@ +extends ColorRect + +func _ready(): + get_node("Hero").connect("item_selected", self, "update_description") + update_description(0) + +func update_description(hero): + var description = get_node("Hero").hero_text[hero] + get_node("HeroDescription").set_text(description) + diff --git a/scripts/lobby.gd b/scripts/lobby.gd index 860fbd8..6d12735 100644 --- a/scripts/lobby.gd +++ b/scripts/lobby.gd @@ -36,15 +36,24 @@ func option_sel(button_name, option): func _ready(): + randomize() + + get_node("Server").connect("pressed", self, "_server_init") + get_node("ServerStart").connect("pressed", self, "start_game") + get_node("Client").connect("pressed", self, "_client_init") + get_node("Singleplayer").connect("pressed", self, "_singleplayer_init") + get_node("HeroSelect").connect("item_selected", self, "select_hero") + var o = setup_options() o.parse() - - randomize() if o.get_value("-silent-server"): SERVER_PLAYING = false # TODO: Uncaps :( if o.get_value("-hero"): - option_sel("HeroSelect", o.get_value("-hero")) + var hero = o.get_value("-hero") + option_sel("HeroSelect", hero) + # For some reason, calling option_sel doesn't trigger the actual selection + select_hero(get_node("HeroSelect").get_selected_id()) if o.get_value("-level"): option_sel("ServerStart/LevelSelect", o.get_value("-level")) if o.get_value("-server"): @@ -64,18 +73,9 @@ func _ready(): o.print_help() quit() - # Called every time the node is added to the scene. - # Initialization here - get_node("Server").connect("pressed", self, "_server_init") - get_node("ServerStart").connect("pressed", self, "start_game") - get_node("Client").connect("pressed", self, "_client_init") - get_node("Singleplayer").connect("pressed", self, "_singleplayer_init") - get_tree().connect("network_peer_connected", self, "_player_connected") get_tree().connect("network_peer_disconnected", self, "_player_disconnected") get_tree().connect("connected_to_server", self, "_connected_ok") - - get_node("HeroSelect").connect("item_selected", self, "select_hero") func _client_init(): collect_info() @@ -157,6 +157,8 @@ sync func unregister_player(peer): get_node("/root/Level/Players/%d" % peer).queue_free() func select_hero(hero): + var description = get_node("HeroSelect").hero_text[hero] + get_node("HeroDescription").set_text(description) rpc("set_hero", get_tree().get_network_unique_id(), hero) sync func set_hero(peer, hero): @@ -228,7 +230,3 @@ sync func post_configure_game(): for p in player_info: get_node("/root/Level/Players/%d" % p).begin() -#func _process(delta): -# # Called every frame. Delta is time since last frame. -# # Update game logic here. -# pass