diff options
| author | Daniel Weipert <code@drogueronin.de> | 2021-02-08 15:05:09 +0100 | 
|---|---|---|
| committer | Daniel Weipert <code@drogueronin.de> | 2021-02-08 15:05:09 +0100 | 
| commit | cc278651a6aee0de5f928b4bc423e3b705a6b006 (patch) | |
| tree | 89ea325d3c116de691c95bf202330985d437159b | |
| parent | 8224cb660460f6af7b6cae8b7882bd036bab46ea (diff) | |
Highlights Characters on select
| -rw-r--r-- | UI/CharacterSelect.gd | 14 | ||||
| -rw-r--r-- | UI/CharacterSelect.tscn | 116 | 
2 files changed, 105 insertions, 25 deletions
| diff --git a/UI/CharacterSelect.gd b/UI/CharacterSelect.gd index fc84a35..bc6dab1 100644 --- a/UI/CharacterSelect.gd +++ b/UI/CharacterSelect.gd @@ -3,8 +3,14 @@ extends Panel  var players_selected = {} +var bg_color_selected = '#fffba5' +var style_selected = StyleBoxFlat.new() +var style_deselected = StyleBoxFlat.new() +  func _ready(): +	self.style_selected.set_bg_color(self.bg_color_selected) +	self.style_deselected.set_bg_color(Color(0, 0, 0, 0))  	self.set_Wait_text() @@ -12,10 +18,18 @@ func set_Wait_text():  	$Wait.text = "Waiting for " + str(Network.get_player_count() - self.players_selected.size()) + " players to choose" +func set_bg_color_selected(character, previous_character = null): +	if previous_character: +		get_node(previous_character + "Panel").set("custom_styles/panel", self.style_deselected) +	 +	get_node(character + "Panel").set("custom_styles/panel", self.style_selected) + +  func _button_pressed(event, character):  	if event is InputEventMouseButton or event is InputEventKey:  		if event.pressed:  			rpc("_character_selected", character) +			self.set_bg_color_selected(character, Network.player.character)  			Network.player.character = character diff --git a/UI/CharacterSelect.tscn b/UI/CharacterSelect.tscn index 9834648..4493549 100644 --- a/UI/CharacterSelect.tscn +++ b/UI/CharacterSelect.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=10 format=2] +[gd_scene load_steps=11 format=2]  [ext_resource path="res://Assets/Characters/Tux/Front.png" type="Texture" id=1]  [ext_resource path="res://Assets/Characters/Duck/Front.png" type="Texture" id=2] @@ -13,6 +13,9 @@  size = 52  font_data = ExtResource( 3 ) +[sub_resource type="StyleBoxFlat" id=2] +bg_color = Color( 1, 0.984314, 0.647059, 0 ) +  [node name="CharacterSelect" type="Panel"]  anchor_right = 1.0  anchor_bottom = 1.0 @@ -46,71 +49,134 @@ __meta__ = {  "_edit_use_anchors_": false  } -[node name="Tux" type="TextureRect" parent="."] +[node name="TuxPanel" type="Panel" parent="."]  margin_left = 96.0  margin_top = 168.0 -margin_right = 128.0 -margin_bottom = 200.0 +margin_right = 176.0 +margin_bottom = 248.0 +custom_styles/panel = SubResource( 2 ) +__meta__ = { +"_edit_use_anchors_": false +} + +[node name="Tux" type="TextureRect" parent="TuxPanel"] +margin_left = 8.0 +margin_top = 8.0 +margin_right = 40.0 +margin_bottom = 40.0  rect_scale = Vector2( 2, 2 )  texture = ExtResource( 1 ) +__meta__ = { +"_edit_use_anchors_": false +} -[node name="Duck" type="TextureRect" parent="."] +[node name="DuckPanel" type="Panel" parent="."]  margin_left = 288.0  margin_top = 168.0 -margin_right = 320.0 -margin_bottom = 200.0 +margin_right = 368.0 +margin_bottom = 248.0 +custom_styles/panel = SubResource( 2 ) +__meta__ = { +"_edit_use_anchors_": false +} + +[node name="Duck" type="TextureRect" parent="DuckPanel"] +margin_left = 8.0 +margin_top = 8.0 +margin_right = 40.0 +margin_bottom = 40.0  rect_scale = Vector2( 2, 2 )  texture = ExtResource( 2 )  __meta__ = {  "_edit_use_anchors_": false  } -[node name="Dove" type="TextureRect" parent="."] +[node name="DovePanel" type="Panel" parent="."]  margin_left = 480.0  margin_top = 168.0 -margin_right = 512.0 -margin_bottom = 200.0 +margin_right = 560.0 +margin_bottom = 248.0 +custom_styles/panel = SubResource( 2 ) +__meta__ = { +"_edit_use_anchors_": false +} + +[node name="Dove" type="TextureRect" parent="DovePanel"] +margin_left = 8.0 +margin_top = 8.0 +margin_right = 40.0 +margin_bottom = 40.0  rect_scale = Vector2( 2, 2 )  texture = ExtResource( 5 )  __meta__ = {  "_edit_use_anchors_": false  } -[node name="Pidgin" type="TextureRect" parent="."] +[node name="PidginPanel" type="Panel" parent="."]  margin_left = 672.0  margin_top = 168.0 -margin_right = 704.0 -margin_bottom = 200.0 +margin_right = 752.0 +margin_bottom = 248.0 +custom_styles/panel = SubResource( 2 ) +__meta__ = { +"_edit_use_anchors_": false +} + +[node name="Pidgin" type="TextureRect" parent="PidginPanel"] +margin_left = 8.0 +margin_top = 8.0 +margin_right = 40.0 +margin_bottom = 40.0  rect_scale = Vector2( 2, 2 )  texture = ExtResource( 7 )  __meta__ = {  "_edit_use_anchors_": false  } -[node name="Monkey" type="TextureRect" parent="."] +[node name="MonkeyPanel" type="Panel" parent="."]  margin_left = 96.0  margin_top = 296.0 -margin_right = 128.0 -margin_bottom = 328.0 +margin_right = 176.0 +margin_bottom = 376.0 +custom_styles/panel = SubResource( 2 ) +__meta__ = { +"_edit_use_anchors_": false +} + +[node name="Monkey" type="TextureRect" parent="MonkeyPanel"] +margin_left = 8.0 +margin_top = 8.0 +margin_right = 40.0 +margin_bottom = 40.0  rect_scale = Vector2( 2, 2 )  texture = ExtResource( 6 )  __meta__ = {  "_edit_use_anchors_": false  } -[node name="Elephant" type="TextureRect" parent="."] +[node name="ElephantPanel" type="Panel" parent="."]  margin_left = 288.0  margin_top = 296.0 -margin_right = 320.0 -margin_bottom = 328.0 +margin_right = 368.0 +margin_bottom = 376.0 +custom_styles/panel = SubResource( 2 ) +__meta__ = { +"_edit_use_anchors_": false +} + +[node name="Elephant" type="TextureRect" parent="ElephantPanel"] +margin_left = 8.0 +margin_top = 8.0 +margin_right = 40.0 +margin_bottom = 40.0  rect_scale = Vector2( 2, 2 )  texture = ExtResource( 8 )  __meta__ = {  "_edit_use_anchors_": false  } -[connection signal="gui_input" from="Tux" to="." method="_button_pressed" binds= [ "Tux" ]] -[connection signal="gui_input" from="Duck" to="." method="_button_pressed" binds= [ "Duck" ]] -[connection signal="gui_input" from="Dove" to="." method="_button_pressed" binds= [ "Dove" ]] -[connection signal="gui_input" from="Pidgin" to="." method="_button_pressed" binds= [ "Pidgin" ]] -[connection signal="gui_input" from="Monkey" to="." method="_button_pressed" binds= [ "Monkey" ]] -[connection signal="gui_input" from="Elephant" to="." method="_button_pressed" binds= [ "Elephant" ]] +[connection signal="gui_input" from="TuxPanel/Tux" to="." method="_button_pressed" binds= [ "Tux" ]] +[connection signal="gui_input" from="DuckPanel/Duck" to="." method="_button_pressed" binds= [ "Duck" ]] +[connection signal="gui_input" from="DovePanel/Dove" to="." method="_button_pressed" binds= [ "Dove" ]] +[connection signal="gui_input" from="PidginPanel/Pidgin" to="." method="_button_pressed" binds= [ "Pidgin" ]] +[connection signal="gui_input" from="MonkeyPanel/Monkey" to="." method="_button_pressed" binds= [ "Monkey" ]] +[connection signal="gui_input" from="ElephantPanel/Elephant" to="." method="_button_pressed" binds= [ "Elephant" ]] | 
