~starkingdoms/starkingdoms

12afe29331c55dc3f02ab1c71e62688eb371cf6c — ghostly_zsh 5 months ago 05fbfec
ui start (merge again)
A crates/unified/src/client/colors.rs => crates/unified/src/client/colors.rs +33 -0
@@ 0,0 1,33 @@
macro_rules! color {
    ($n:ident,rgb($r:expr, $g:expr, $b:expr)) => {
        #[allow(dead_code)]
        pub const $n: ::bevy::prelude::Color = ::bevy::prelude::Color::srgb($r as f32 / 256.0, $g as f32 / 256.0, $b as f32 / 256.0);
    };
}

color!(ROSEWATER, rgb(245, 224, 220));
color!(FLAMINGO, rgb(242, 205, 205));
color!(PINK, rgb(245, 194, 231));
color!(MAUVE, rgb(203, 166, 247));
color!(RED, rgb(243, 139, 168));
color!(MAROON, rgb(235, 160, 172));
color!(PEACH, rgb(250, 179, 135));
color!(YELLOW, rgb(249, 226, 175));
color!(GREEN, rgb(166, 227, 161));
color!(TEAL, rgb(148, 226, 213));
color!(SKY, rgb(137, 220, 235));
color!(SAPPHIRE, rgb(116, 199, 236));
color!(BLUE, rgb(137, 180, 250));
color!(LAVENDER, rgb(180, 190, 254));
color!(TEXT, rgb(205, 214, 244));
color!(SUBTEXT_1, rgb(186, 194, 222));
color!(SUBTEXT_0, rgb(166, 173, 200));
color!(OVERLAY_2, rgb(147, 153, 178));
color!(OVERLAY_1, rgb(127, 132, 156));
color!(OVERLAY_0, rgb(108, 112, 132));
color!(SURFACE_2, rgb(88, 91, 112));
color!(SURFACE_1, rgb(69, 71, 90));
color!(SURFACE_0, rgb(49, 50, 68));
color!(BASE, rgb(30, 30, 46));
color!(MANTLE, rgb(24, 24, 37));
color!(CRUST, rgb(17, 17, 27));

M crates/unified/src/client/mod.rs => crates/unified/src/client/mod.rs +5 -1
@@ 3,6 3,8 @@ mod incoming_planets;
mod key_input;
mod starfield;
mod net;
mod ui;
mod colors;

use aeronet_websocket::client::WebSocketClient;
use crate::client::incoming_parts::incoming_parts_plugin;


@@ 16,6 18,7 @@ use bevy::window::PrimaryWindow;
use bevy_replicon::prelude::RepliconChannels;
use bevy_replicon::shared::server_entity_map::ServerEntityMap;
use web_time::SystemTime;
use crate::client::ui::ui_plugin;

pub struct ClientPlugin {
    pub server: String


@@ 41,7 44,8 @@ impl Plugin for ClientPlugin {
            .add_plugins(incoming_planets_plugin)
            .add_plugins(incoming_parts_plugin)
            .add_plugins(key_input_plugin)
            .add_plugins(starfield_plugin);
            .add_plugins(starfield_plugin)
            .add_plugins(ui_plugin);
    }
}


A crates/unified/src/client/ui.rs => crates/unified/src/client/ui.rs +43 -0
@@ 0,0 1,43 @@
use bevy::prelude::*;

use crate::client::colors;

pub fn ui_plugin(app: &mut App) {
    app
        .add_systems(Startup, setup_ui);
}

fn setup_ui(
    mut commands: Commands,
) {
    commands.spawn((
        Node {
            width: Val::Percent(100.0),
            height: Val::Percent(100.0),
            ..Default::default()
        },
        children![(
            Node {
                display: Display::Flex,
                position_type: PositionType::Absolute,
                width: Val::Px(200.0),
                height: Val::Px(150.0),
                top: Val::Px(5.0),
                right: Val::Px(5.0),
                ..Default::default()
            },
            BorderRadius::all(Val::Px(5.0)),
            BackgroundColor(colors::MANTLE),
            children![(
                Node {
                    width: Val::Percent(100.0),
                    height: Val::Px(20.0),
                    margin: UiRect::all(Val::Px(5.0)),
                    ..Default::default()
                },
                BorderRadius::all(Val::Px(5.0)),
                BackgroundColor(colors::CRUST),
            )],
        )],
    ));
}