Compare commits

...

2 Commits

Author SHA1 Message Date
40c119d1c8 Add possibility for alternate team colors 2026-08-03 20:33:40 +03:00
a7fcaeb2ff Add setting for alt team colors 2026-08-03 20:19:33 +03:00
21 changed files with 101 additions and 27 deletions

View File

@ -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")

View File

@ -7,11 +7,9 @@
[sub_resource type="TeamResource" id="TeamResource_w4gl8"]
name = "Copper Team"
color = Color(0.41, 0.82, 0.54666674, 1)
[sub_resource type="TeamResource" id="TeamResource_iftcq"]
name = "Silver Team"
color = Color(0.74, 0.7876666, 1, 1)
[resource]
name = "Precipice"

View File

@ -2,4 +2,3 @@
[resource]
name = "Blue Team"
color = Color(0, 0.7411765, 1, 1)

View File

@ -2,4 +2,3 @@
[resource]
name = "Red Team"
color = Color(1, 0.35686275, 0.3647059, 1)

View File

@ -8,11 +8,13 @@
[sub_resource type="TeamResource" id="TeamResource_64qm8"]
name = "Shadow Team"
color = Color(0.5380128, 0.5138385, 1, 1)
primary_color = Color(0.05000019, 0, 1, 1)
alt_color = Color(0, 1, 0.0666666, 1)
[sub_resource type="TeamResource" id="TeamResource_47vax"]
name = "Sunshine Team"
color = Color(0.99999994, 0.83743095, 0.5094259, 1)
primary_color = Color(1, 0, 0, 1)
alt_color = Color(0.9333333, 1, 0, 1)
[resource]
name = "Two Towers"

View File

@ -20,10 +20,11 @@ font_size = 32
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_jbm04"]
bg_color = Color(0.30692267, 0.3069227, 0.30692264, 1)
[node name="lobby_world" type="LobbyWorld" unique_id=129662054]
[node name="lobby_world" type="LobbyWorld" unique_id=129662054 node_paths=PackedStringArray("lobby")]
menu_player_scene = ExtResource("3_q60fs")
lobby = NodePath("lobby")
[node name="lobby" type="LobbyPanel" parent="." unique_id=915192272 node_paths=PackedStringArray("players_list", "name_field", "ready_button", "map_selection", "options_panel", "options_grid")]
[node name="lobby" type="LobbyPanel" parent="." unique_id=915192272 node_paths=PackedStringArray("players_list", "name_field", "ready_button", "map_selection", "options_panel", "options_grid", "alt_colors")]
players_list = NodePath("v_box_container/players_list")
name_field = NodePath("v_box_container/h_box_container/text_edit")
player_listing_prefab = ExtResource("1_o1atq")
@ -31,6 +32,7 @@ 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")
alt_colors = NodePath("v_box_container/h_box_container/check_box")
start_game_icon = ExtResource("3_oipnb")
ready_icon = ExtResource("4_yad6j")
not_ready_icon = ExtResource("5_ncsg4")
@ -74,6 +76,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:"

View File

@ -105,7 +105,7 @@ impl ChatMessage {
if idx > 0 {
label.add_text(" and ");
}
label.push_color(team.bind().color);
label.push_color(team.bind().color());
label.add_text(&team.bind().name);
label.pop();
}
@ -120,7 +120,7 @@ fn add_player(label: &mut Gd<RichTextLabel>, player: &Player) {
if let Some(game) = Game::singleton()
&& let Some(team) = game.bind().get_team(player.data.team)
{
label.push_color(team.bind().color);
label.push_color(team.bind().color());
label.add_text(&player.data.name);
label.pop();
}

View File

@ -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,
@ -1184,7 +1185,7 @@ impl Game {
{
chat.bind_mut().new_message(ChatMessage::ChatMessage(
player.data.name.clone(),
team.bind().color,
team.bind().color(),
message.clone(),
));
}

View File

@ -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>,

View File

@ -44,7 +44,7 @@ impl Goal {
if let Some(game) = Game::singleton()
&& let Some(team) = game.bind().get_team(self.team)
{
mat.set_shader_parameter("goal_color", &team.bind().color.to_variant());
mat.set_shader_parameter("goal_color", &team.bind().color().to_variant());
} else if let Some(playback) = &StandaloneReplayManager::singleton().bind().playback
&& let Some(team) = playback.bind().replay.teams.get(self.team as usize)
{

View File

@ -2,13 +2,15 @@ use std::{collections::HashMap, f32::consts::PI};
use godot::{classes::RandomNumberGenerator, prelude::*};
use crate::{game::Game, player::menu_player::MenuPlayer};
use crate::{game::Game, player::menu_player::MenuPlayer, ui::lobby::LobbyPanel};
#[derive(GodotClass)]
#[class(base=Node3D, init)]
pub struct LobbyWorld {
#[export]
menu_player_scene: Option<Gd<PackedScene>>,
#[export]
lobby: Option<Gd<LobbyPanel>>,
rng: Gd<RandomNumberGenerator>,
@ -35,6 +37,13 @@ impl INode3D for LobbyWorld {
.on_players_updated()
.connect_other(self, Self::update_players);
}
if let Some(lobby) = &self.lobby {
lobby
.signals()
.on_alt_colors_changed()
.connect_other(self, |s| s.update_players());
}
}
}

View File

@ -87,7 +87,7 @@ impl Map {
&& let Some(team) = game.bind().get_team(player.data.team)
{
node_clone.bind_mut().player_name = player.data.name.clone();
node_clone.bind_mut().player_color = team.bind().color.clone();
node_clone.bind_mut().player_color = team.bind().color().clone();
}
});
}

View File

@ -459,7 +459,7 @@ impl ICharacterBody3D for LocalPlayer {
&& let Some(team) = game.bind().get_team(player.data.team)
{
if let Some(mesh) = &mut s.soldier_mesh {
mesh.bind_mut().set_color(team.bind().color);
mesh.bind_mut().set_color(team.bind().color());
}
}
});

View File

@ -42,10 +42,10 @@ impl MenuPlayer {
{
if let Some(name_label) = &mut self.name_label {
name_label.set_text(&player.data.name);
name_label.set_modulate(team.bind().color);
name_label.set_modulate(team.bind().color());
}
if let Some(mesh) = &mut self.mesh {
mesh.bind_mut().set_color(team.bind().color);
mesh.bind_mut().set_color(team.bind().color());
}
}
}

View File

@ -525,7 +525,7 @@ impl INode for ReplayRecorder {
ReplayPlayer {
id: player.id(),
name: player.data.name.clone(),
color: team.bind().color.into(),
color: team.bind().color().into(),
team: player.data.team,
stats: Default::default(),
},
@ -539,7 +539,7 @@ impl INode for ReplayRecorder {
.iter_shared()
.map(|t| ReplayTeam {
name: t.bind().name.to_string(),
color: t.bind().color.into(),
color: t.bind().color().into(),
})
.collect();
}

View File

@ -1,15 +1,37 @@
use godot::prelude::*;
use crate::game::{Game, opts::PrivateGameOptions};
#[derive(GodotClass)]
#[class(base=Resource, init, tool)]
pub struct TeamResource {
#[export]
pub name: GString,
#[export]
pub color: Color,
pub primary_color: Color,
#[export]
pub alt_color: Color,
base: Base<Resource>,
}
#[godot_api]
impl IResource for TeamResource {}
impl TeamResource {
pub fn color_from(&self, opts: &PrivateGameOptions) -> Color {
match opts.use_alternate_team_colors {
true => self.alt_color,
false => self.primary_color,
}
}
pub fn color(&self) -> Color {
godot_print!("Fetching color");
if let Some(game) = Game::singleton() {
self.color_from(&game.bind().private_opts)
} else {
self.primary_color
}
}
}

View File

@ -101,7 +101,7 @@ impl GameFinishedScreen {
for (idx, team) in winning_teams.iter().enumerate() {
let mut label = Label::new_alloc();
label.set_text(&team.bind().name);
label.set_modulate(team.bind().color);
label.set_modulate(team.bind().color());
if idx > 0 {
let mut and_label = Label::new_alloc();
and_label.set_text(" and ");

View File

@ -14,6 +14,7 @@ use crate::{
Game, GameManager,
opts::{GameOption, GameOptionValue, GameOptions},
},
lobby_world::LobbyWorld,
net::network_manager::{NetworkManager, Package, PeerKind},
ui::lobby_player_listing::LobbyPlayerListing,
};
@ -35,6 +36,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 +91,17 @@ 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());
}
s.update_players(false);
s.signals().on_alt_colors_changed().emit();
});
}
game.signals().options_changed().connect_other(self, |s| {
s.run_deferred(|s| {
if let Some(game) = Game::singleton() {
@ -234,6 +248,9 @@ impl IPanel for LobbyPanel {
#[godot_api]
impl LobbyPanel {
#[signal]
pub fn on_alt_colors_changed();
#[func]
fn open_options(&mut self) {
if let Some(panel) = &mut self.options_panel {
@ -254,6 +271,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);

View File

@ -91,7 +91,7 @@ impl LobbyPlayerListing {
));
if let Some(team) = game.bind().get_team(player.data.team) {
player_label.add_theme_color_override("font_color", team.bind().color);
player_label.add_theme_color_override("font_color", team.bind().color());
}
}
@ -133,7 +133,7 @@ impl LobbyPlayerListing {
&& let Some(player_label) = &mut self.name_label
&& let Some(team) = game.bind().get_team(player.data.team)
{
player_label.add_theme_color_override("font_color", team.bind().color);
player_label.add_theme_color_override("font_color", team.bind().color());
}
}
}
@ -148,7 +148,7 @@ impl LobbyPlayerListing {
&& let Some(player_label) = &mut self.name_label
&& let Some(team) = game.bind().get_team(player.data.team)
{
player_label.add_theme_color_override("font_color", team.bind().color);
player_label.add_theme_color_override("font_color", team.bind().color());
}
}
}

View File

@ -52,7 +52,7 @@ impl PlayerListings {
vbox.set_custom_minimum_size(Vector2::new(300., 0.));
let mut team_label = Label::new_alloc();
team_label.set_modulate(team.bind().color);
team_label.set_modulate(team.bind().color());
team_label.set_text(&team.bind().name);
team_label.set_horizontal_alignment(HorizontalAlignment::CENTER);
vbox.add_child(&team_label);

View File

@ -21,7 +21,7 @@ impl IHBoxContainer for SimpleScoreView {
if let Some(game) = Game::singleton() {
for (id, team) in game.bind().get_teams().iter_shared().enumerate() {
let mut goals_label = Label::new_alloc();
goals_label.set_modulate(team.bind().color);
goals_label.set_modulate(team.bind().color());
goals_label.set_text("0");
if !s.team_goals.is_empty() {
let mut dash = Label::new_alloc();