Add setting for alt team colors
This commit is contained in:
parent
55d6d236f9
commit
a7fcaeb2ff
@ -3,6 +3,7 @@
|
||||
[ext_resource type="FontFile" uid="uid://hptdnjg4ec58" path="res://font/static/SpaceGrotesk-Medium.ttf" id="1_e7bfs"]
|
||||
[ext_resource type="Texture2D" uid="uid://dvrcbukia04ae" path="res://raw_assets/ui_pack/PNG/Extra/Default/panel_glass.png" id="2_50bnw"]
|
||||
[ext_resource type="Texture2D" uid="uid://bkn85nst4nats" path="res://raw_assets/ui_pack/Vector/Extra/panel_square.svg" id="2_cefca"]
|
||||
[ext_resource type="Texture2D" uid="uid://cv612ig20ptq" path="res://raw_assets/ui_pack/PNG/Extra/Default/panel_square.png" id="2_ed8xq"]
|
||||
|
||||
[sub_resource type="StyleBoxTexture" id="StyleBoxTexture_meo00"]
|
||||
texture = ExtResource("2_cefca")
|
||||
@ -44,6 +45,14 @@ texture_margin_right = 5.0
|
||||
texture_margin_bottom = 5.0
|
||||
modulate_color = Color(0.28118682, 0.28118688, 0.2811868, 1)
|
||||
|
||||
[sub_resource type="StyleBoxTexture" id="StyleBoxTexture_5qcgm"]
|
||||
texture = ExtResource("2_ed8xq")
|
||||
texture_margin_left = 5.0
|
||||
texture_margin_top = 5.0
|
||||
texture_margin_right = 5.0
|
||||
texture_margin_bottom = 5.0
|
||||
modulate_color = Color(0.40069774, 0.40069774, 0.40069768, 1)
|
||||
|
||||
[sub_resource type="StyleBoxTexture" id="StyleBoxTexture_4dgt1"]
|
||||
texture = ExtResource("2_cefca")
|
||||
texture_margin_left = 6.0
|
||||
@ -99,6 +108,7 @@ Button/styles/focus = SubResource("StyleBoxTexture_ed8xq")
|
||||
Button/styles/hover = SubResource("StyleBoxTexture_yehm5")
|
||||
Button/styles/normal = SubResource("StyleBoxTexture_lh46g")
|
||||
Button/styles/pressed = SubResource("StyleBoxTexture_rwh25")
|
||||
CheckBox/styles/hover_pressed = SubResource("StyleBoxTexture_5qcgm")
|
||||
LineEdit/styles/focus = SubResource("StyleBoxTexture_4dgt1")
|
||||
LineEdit/styles/normal = SubResource("StyleBoxTexture_u7cj8")
|
||||
LineEdit/styles/read_only = SubResource("StyleBoxTexture_v0r2u")
|
||||
|
||||
@ -74,6 +74,10 @@ custom_minimum_size = Vector2(150, 0)
|
||||
layout_mode = 2
|
||||
max_length = 20
|
||||
|
||||
[node name="check_box" type="CheckBox" parent="lobby/v_box_container/h_box_container" unique_id=21168819]
|
||||
layout_mode = 2
|
||||
text = "Use alternate team colors"
|
||||
|
||||
[node name="players_label" type="Label" parent="lobby/v_box_container" unique_id=1537542117]
|
||||
layout_mode = 2
|
||||
text = "Players:"
|
||||
|
||||
@ -12,7 +12,7 @@ use crate::{
|
||||
chat::{Chat, ChatMessage},
|
||||
game::{
|
||||
commands::{register_commands, unregister_commands},
|
||||
opts::{GameOption, GameOptionValue, GameOptions},
|
||||
opts::{GameOption, GameOptionValue, GameOptions, PrivateGameOptions},
|
||||
},
|
||||
map::Map,
|
||||
map_resource::MapResource,
|
||||
@ -173,6 +173,7 @@ pub struct Game {
|
||||
pub maps: Array<Gd<MapResource>>,
|
||||
|
||||
pub opts: GameOptions,
|
||||
pub private_opts: PrivateGameOptions,
|
||||
|
||||
is_host: bool,
|
||||
player_counter: u16,
|
||||
|
||||
@ -2,6 +2,11 @@ use std::collections::HashMap;
|
||||
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Debug, Default)]
|
||||
pub struct PrivateGameOptions {
|
||||
pub use_alternate_team_colors: bool,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
pub struct GameOptions {
|
||||
pub values: HashMap<GameOption, GameOptionValue>,
|
||||
|
||||
@ -35,6 +35,8 @@ pub struct LobbyPanel {
|
||||
options_panel: Option<Gd<Panel>>,
|
||||
#[export]
|
||||
options_grid: Option<Gd<GridContainer>>,
|
||||
#[export]
|
||||
alt_colors: Option<Gd<CheckBox>>,
|
||||
|
||||
option_nodes: HashMap<GameOption, Gd<Control>>,
|
||||
|
||||
@ -88,6 +90,15 @@ impl IPanel for LobbyPanel {
|
||||
}
|
||||
|
||||
if let Some(game) = Game::singleton() {
|
||||
if let Some(mut alt_colors) = self.alt_colors.clone() {
|
||||
alt_colors.set_pressed(game.bind().private_opts.use_alternate_team_colors);
|
||||
alt_colors.signals().pressed().connect_other(self, |s| {
|
||||
if let Some(alt_colors) = &s.alt_colors {
|
||||
s.use_alt_colors_changed(alt_colors.is_pressed());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
game.signals().options_changed().connect_other(self, |s| {
|
||||
s.run_deferred(|s| {
|
||||
if let Some(game) = Game::singleton() {
|
||||
@ -254,6 +265,12 @@ impl LobbyPanel {
|
||||
NetworkManager::singleton().bind_mut().disconnect();
|
||||
}
|
||||
|
||||
fn use_alt_colors_changed(&mut self, value: bool) {
|
||||
if let Some(game) = &mut Game::singleton() {
|
||||
game.bind_mut().private_opts.use_alternate_team_colors = value;
|
||||
}
|
||||
}
|
||||
|
||||
fn option_changed(&mut self, key: GameOption, value: GameOptionValue) {
|
||||
if let Some(game) = &mut Game::singleton() {
|
||||
game.bind_mut().change_option(key, value);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user