Add ready button icons
This commit is contained in:
parent
212684fd34
commit
5c91b4e779
@ -3,8 +3,12 @@
|
||||
[ext_resource type="PackedScene" uid="uid://ccd0wj2usx5os" path="res://scenes/ui/lobby_player_listing.tscn" id="1_o1atq"]
|
||||
[ext_resource type="PackedScene" uid="uid://ffh5txda3j1" path="res://scenes/ui/chat_box.tscn" id="2_5gu6x"]
|
||||
[ext_resource type="Theme" uid="uid://drydbnrcdv4pk" path="res://default_theme.tres" id="3_dfnwm"]
|
||||
[ext_resource type="Texture2D" uid="uid://djyx3jrutbube" path="res://raw_assets/icons/PNG/White/1x/forward.png" id="3_oipnb"]
|
||||
[ext_resource type="PackedScene" uid="uid://bbmc2gmy7g8ag" path="res://scenes/player/menu_player.tscn" id="3_q60fs"]
|
||||
[ext_resource type="PackedScene" uid="uid://n3u0jr4wiib1" path="res://scenes/ui/settings.tscn" id="4_iulku"]
|
||||
[ext_resource type="Texture2D" uid="uid://bs5jp73lrqmoe" path="res://raw_assets/icons/PNG/White/1x/checkmark.png" id="4_yad6j"]
|
||||
[ext_resource type="Texture2D" uid="uid://cm4dcnb3i0ybq" path="res://raw_assets/icons/PNG/White/1x/cross.png" id="5_ncsg4"]
|
||||
[ext_resource type="Texture2D" uid="uid://di82vf1k8xr1d" path="res://raw_assets/icons/PNG/White/1x/wrench.png" id="5_omrgh"]
|
||||
[ext_resource type="PackedScene" uid="uid://dpqqe7hjktit8" path="res://maps/two_towers/two_towers_static.scn" id="6_apkv3"]
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_7j863"]
|
||||
@ -27,6 +31,9 @@ ready_button = NodePath("v_box_container3/ready_button")
|
||||
map_selection = NodePath("v_box_container2/option_button")
|
||||
options_panel = NodePath("options_panel")
|
||||
options_grid = NodePath("options_panel/h_box_container/options_grid")
|
||||
start_game_icon = ExtResource("3_oipnb")
|
||||
ready_icon = ExtResource("4_yad6j")
|
||||
not_ready_icon = ExtResource("5_ncsg4")
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
@ -161,10 +168,12 @@ offset_right = 198.0
|
||||
offset_bottom = 604.0
|
||||
|
||||
[node name="ready_button" type="Button" parent="lobby/v_box_container3" unique_id=311553419]
|
||||
custom_minimum_size = Vector2(100, 0)
|
||||
custom_maximum_size = Vector2(100, -1)
|
||||
custom_minimum_size = Vector2(150, 50)
|
||||
custom_maximum_size = Vector2(150, -1)
|
||||
layout_mode = 2
|
||||
text = "Not Ready"
|
||||
icon = ExtResource("5_ncsg4")
|
||||
expand_icon = true
|
||||
metadata/_edit_lock_ = true
|
||||
|
||||
[node name="h_box_container" type="HBoxContainer" parent="lobby/v_box_container3" unique_id=1165099293]
|
||||
@ -177,13 +186,19 @@ text = "Exit"
|
||||
metadata/_edit_lock_ = true
|
||||
|
||||
[node name="options_button" type="Button" parent="lobby/v_box_container3/h_box_container" unique_id=2109111628]
|
||||
custom_minimum_size = Vector2(100, 0)
|
||||
layout_mode = 2
|
||||
text = "Options"
|
||||
icon = ExtResource("5_omrgh")
|
||||
expand_icon = true
|
||||
metadata/_edit_lock_ = true
|
||||
|
||||
[node name="settings_button" type="Button" parent="lobby/v_box_container3/h_box_container" unique_id=2096226308]
|
||||
custom_minimum_size = Vector2(100, 0)
|
||||
layout_mode = 2
|
||||
text = "Settings"
|
||||
icon = ExtResource("5_omrgh")
|
||||
expand_icon = true
|
||||
metadata/_edit_lock_ = true
|
||||
|
||||
[node name="settings" parent="lobby" unique_id=999912383 instance=ExtResource("4_iulku")]
|
||||
|
||||
@ -2,8 +2,8 @@ use std::collections::HashMap;
|
||||
|
||||
use godot::{
|
||||
classes::{
|
||||
Button, CheckBox, Control, GridContainer, IPanel, Label, LineEdit, OptionButton, Panel,
|
||||
SpinBox, VBoxContainer,
|
||||
Button, CheckBox, CompressedTexture2D, Control, GridContainer, IPanel, Label, LineEdit,
|
||||
OptionButton, Panel, SpinBox, VBoxContainer,
|
||||
},
|
||||
prelude::*,
|
||||
};
|
||||
@ -38,6 +38,13 @@ pub struct LobbyPanel {
|
||||
|
||||
option_nodes: HashMap<GameOption, Gd<Control>>,
|
||||
|
||||
#[export]
|
||||
start_game_icon: Option<Gd<CompressedTexture2D>>,
|
||||
#[export]
|
||||
ready_icon: Option<Gd<CompressedTexture2D>>,
|
||||
#[export]
|
||||
not_ready_icon: Option<Gd<CompressedTexture2D>>,
|
||||
|
||||
is_ready: bool,
|
||||
|
||||
base: Base<Panel>,
|
||||
@ -163,14 +170,6 @@ impl IPanel for LobbyPanel {
|
||||
|
||||
self.update_players(true);
|
||||
|
||||
if let Some(peer) = &NetworkManager::singleton().bind().peer
|
||||
&& peer.is_host()
|
||||
{
|
||||
if let Some(button) = &mut self.ready_button {
|
||||
button.set_text("Start Game");
|
||||
button.set_disabled(true);
|
||||
}
|
||||
}
|
||||
self.update_ready_button();
|
||||
|
||||
let mut nodes = Vec::new();
|
||||
@ -296,7 +295,25 @@ impl LobbyPanel {
|
||||
&& let Some(button) = &mut self.ready_button
|
||||
{
|
||||
let all_ready = game.bind().players.iter().all(|p| p.data.ready);
|
||||
button.set_text("Start Game");
|
||||
if let Some(icon) = &self.start_game_icon {
|
||||
button.set_button_icon(icon);
|
||||
}
|
||||
button.set_disabled(!all_ready);
|
||||
} else {
|
||||
if let Some(button) = &mut self.ready_button {
|
||||
if let Some(icon) = &self.ready_icon
|
||||
&& self.is_ready
|
||||
{
|
||||
button.set_button_icon(icon);
|
||||
button.set_text("Ready");
|
||||
} else if let Some(icon) = &self.not_ready_icon
|
||||
&& !self.is_ready
|
||||
{
|
||||
button.set_button_icon(icon);
|
||||
button.set_text("Not Ready");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -351,13 +368,7 @@ impl LobbyPanel {
|
||||
};
|
||||
if !is_host {
|
||||
self.is_ready = !self.is_ready;
|
||||
if let Some(button) = &mut self.ready_button {
|
||||
if self.is_ready {
|
||||
button.set_text("Ready");
|
||||
} else {
|
||||
button.set_text("Not Ready");
|
||||
}
|
||||
}
|
||||
self.update_ready_button();
|
||||
|
||||
if let Some(peer) = &mut NetworkManager::singleton().bind_mut().peer {
|
||||
if let PeerKind::Client(peer, socket_addr) = peer {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user