Skip to content
This repository was archived by the owner on Nov 22, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
e820c78
Extract initial signal viz code from #600
alice-i-cecile Mar 24, 2023
0707db9
Move tile selection code into infoviz module
alice-i-cecile Mar 24, 2023
1c7ccba
Store an Option for visualized signal type
alice-i-cecile Mar 24, 2023
f4a017b
Use a single resource to store overlay info
alice-i-cecile Mar 24, 2023
bae4c74
Refactor material fetching into a method
alice-i-cecile Mar 24, 2023
dbd8af9
Log error, don't panic
alice-i-cecile Mar 24, 2023
9a42115
Reparameterize color ramp scaling for clarity
alice-i-cecile Mar 24, 2023
fd10821
Fix math
alice-i-cecile Mar 24, 2023
c0a8f75
Tweak max signal strength for better visualization
alice-i-cecile Mar 24, 2023
3d74aaf
Use N_COLORS consistently
alice-i-cecile Mar 24, 2023
bcfd5ec
Display color ramp in legend
alice-i-cecile Mar 24, 2023
670d939
Organize color palette constants
alice-i-cecile Mar 24, 2023
e46d6be
Don't screw up the base color
alice-i-cecile Mar 24, 2023
9c73c48
Get tile interactions and signal viz to play nice together
alice-i-cecile Mar 24, 2023
99e2bcd
Create color ramp via HSLA color interpolation
alice-i-cecile Mar 24, 2023
0e3467a
Store the legend in the right orientation
alice-i-cecile Mar 24, 2023
d46c3f5
Tweak overlay colors for now
alice-i-cecile Mar 24, 2023
3264554
Fix math for normalizing signal strength
alice-i-cecile Mar 24, 2023
89d0e15
Attempt to do UI layout
alice-i-cecile Mar 24, 2023
4db7aa8
Display currently visualized signal
alice-i-cecile Mar 24, 2023
20ae1a4
Cycle signal types randomly
alice-i-cecile Mar 24, 2023
539e7e8
Clippy
alice-i-cecile Mar 24, 2023
6c338ef
Fix broken doc link
alice-i-cecile Mar 24, 2023
8534b24
Another doc link...
alice-i-cecile Mar 24, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
219 changes: 119 additions & 100 deletions emergence_lib/src/asset_management/palette.rs
Original file line number Diff line number Diff line change
@@ -1,105 +1,124 @@
//! A central source of truth for the game and UI's color palettes.

use bevy::prelude::Color;

/// The alpha value used for selection/hovering/other UI overlay
const OVERLAY_ALPHA: f32 = 0.5;

/// The hue of selected objects
pub(crate) const SELECTION_HUE: f32 = 100.;
/// The saturation of selected objects
pub(crate) const SELECTION_SATURATION: f32 = 0.5;
/// The lightness of selected objects
pub(crate) const SELECTION_LIGHTNESS: f32 = 0.6;
/// The color used to tint selected objects.
pub(crate) const SELECTION_COLOR: Color = Color::hsla(
SELECTION_HUE,
SELECTION_SATURATION,
SELECTION_LIGHTNESS,
OVERLAY_ALPHA,
);

/// The hue used to indicate that an action is forbidden.
pub(crate) const FORBIDDEN_HUE: f32 = 0.;

/// The hue of selected objects
pub(crate) const HOVER_HUE: f32 = 55.;
/// The saturation of selected objects
pub(crate) const HOVER_SATURATION: f32 = 0.5;
/// The lightness of selected objects
pub(crate) const HOVER_LIGHTNESS: f32 = 0.6;

/// The color used to tint hovered objects.
pub(crate) const HOVER_COLOR: Color =
Color::hsla(HOVER_HUE, HOVER_SATURATION, HOVER_LIGHTNESS, OVERLAY_ALPHA);

/// The hue value of ghost-like materials.
pub(crate) const GHOST_HUE: f32 = 0.0;
/// The saturation value of ghost-like materials.
pub(crate) const GHOST_SATURATION: f32 = 0.;
/// The lightness value of ghost-like materials.
pub(crate) const GHOST_LIGHTNESS: f32 = 0.9;
/// The alpha value of ghost-like materials.
pub(crate) const GHOST_ALPHA: f32 = 0.7;
/// The color used to tint ghosts
pub(crate) const GHOST_COLOR: Color =
Color::hsla(GHOST_HUE, GHOST_SATURATION, GHOST_LIGHTNESS, GHOST_ALPHA);
/// The color used to tint selected ghosts
pub(crate) const SELECTED_GHOST_COLOR: Color = Color::hsla(
SELECTION_HUE,
SELECTION_SATURATION,
SELECTION_LIGHTNESS,
GHOST_ALPHA,
);

/// The color used to tint previews
pub(crate) const PREVIEW_COLOR: Color =
Color::hsla(HOVER_HUE, HOVER_SATURATION, HOVER_LIGHTNESS, GHOST_ALPHA);
/// The color used to tint previews that cannot be built
pub(crate) const FORBIDDEN_PREVIEW_COLOR: Color = Color::hsla(
FORBIDDEN_HUE,
HOVER_SATURATION,
HOVER_LIGHTNESS,
GHOST_ALPHA,
);

/// The color used to tint objects that are both selected and hovered.
pub(crate) const SELECTION_AND_HOVER_COLOR: Color = Color::hsla(
(SELECTION_HUE + HOVER_HUE) / 2.,
(SELECTION_SATURATION + HOVER_SATURATION) / 2.,
(SELECTION_LIGHTNESS + HOVER_LIGHTNESS) / 2.,
OVERLAY_ALPHA,
);

/// The color used for columns of dirt underneath tiles
pub(crate) const COLUMN_COLOR: Color = Color::hsl(21., 0.6, 0.15);

/// The color of daylight
pub(crate) const LIGHT_SUN: Color = Color::Hsla {
hue: 30.,
saturation: 1.0,
lightness: 1.,
alpha: 1.,
};

/// The color of moonlight
pub(crate) const LIGHT_MOON: Color = Color::Hsla {
hue: 198.,
saturation: 1.0,
lightness: 1.,
alpha: 1.,
};

/// The color of a clear and sunny sky.
pub(crate) const SKY_SUNNY: Color = Color::Hsla {
hue: 202.,
saturation: 0.8,
lightness: 0.8,
alpha: 1.0,
};

/// The color of starlight
pub(crate) const LIGHT_STARS: Color = Color::WHITE;
/// Colors used for visualizing information about the world.
pub(crate) mod infovis {
use bevy::prelude::Color;

/// The alpha value used for selection/hovering/other UI overlay
const OVERLAY_ALPHA: f32 = 0.5;

/// The hue of selected objects
pub(crate) const SELECTION_HUE: f32 = 100.;
/// The saturation of selected objects
pub(crate) const SELECTION_SATURATION: f32 = 0.5;
/// The lightness of selected objects
pub(crate) const SELECTION_LIGHTNESS: f32 = 0.6;
/// The color used to tint selected objects.
pub(crate) const SELECTION_COLOR: Color = Color::hsla(
SELECTION_HUE,
SELECTION_SATURATION,
SELECTION_LIGHTNESS,
OVERLAY_ALPHA,
);

/// The hue used to indicate that an action is forbidden.
pub(crate) const FORBIDDEN_HUE: f32 = 0.;

/// The hue of selected objects
pub(crate) const HOVER_HUE: f32 = 55.;
/// The saturation of selected objects
pub(crate) const HOVER_SATURATION: f32 = 0.5;
/// The lightness of selected objects
pub(crate) const HOVER_LIGHTNESS: f32 = 0.6;

/// The color used to tint hovered objects.
pub(crate) const HOVER_COLOR: Color =
Color::hsla(HOVER_HUE, HOVER_SATURATION, HOVER_LIGHTNESS, OVERLAY_ALPHA);

/// The hue value of ghost-like materials.
pub(crate) const GHOST_HUE: f32 = 0.0;
/// The saturation value of ghost-like materials.
pub(crate) const GHOST_SATURATION: f32 = 0.;
/// The lightness value of ghost-like materials.
pub(crate) const GHOST_LIGHTNESS: f32 = 0.9;
/// The alpha value of ghost-like materials.
pub(crate) const GHOST_ALPHA: f32 = 0.7;
/// The color used to tint ghosts
pub(crate) const GHOST_COLOR: Color =
Color::hsla(GHOST_HUE, GHOST_SATURATION, GHOST_LIGHTNESS, GHOST_ALPHA);
/// The color used to tint selected ghosts
pub(crate) const SELECTED_GHOST_COLOR: Color = Color::hsla(
SELECTION_HUE,
SELECTION_SATURATION,
SELECTION_LIGHTNESS,
GHOST_ALPHA,
);

/// The color used to tint previews
pub(crate) const PREVIEW_COLOR: Color =
Color::hsla(HOVER_HUE, HOVER_SATURATION, HOVER_LIGHTNESS, GHOST_ALPHA);
/// The color used to tint previews that cannot be built
pub(crate) const FORBIDDEN_PREVIEW_COLOR: Color = Color::hsla(
FORBIDDEN_HUE,
HOVER_SATURATION,
HOVER_LIGHTNESS,
GHOST_ALPHA,
);

/// The color used to tint objects that are both selected and hovered.
pub(crate) const SELECTION_AND_HOVER_COLOR: Color = Color::hsla(
(SELECTION_HUE + HOVER_HUE) / 2.,
(SELECTION_SATURATION + HOVER_SATURATION) / 2.,
(SELECTION_LIGHTNESS + HOVER_LIGHTNESS) / 2.,
OVERLAY_ALPHA,
);

/// The color used to indicate that the signal strength is low.
///
/// Beginning at a low lightness means that the effect will be very translucent when the signal strength is low.
pub(crate) const SIGNAL_OVERLAY_LOW: Color = Color::hsla(300., 0.0, 0., OVERLAY_ALPHA);
/// The color used to indicate that the signal strength is high.
pub(crate) const SIGNAL_OVERLAY_HIGH: Color = Color::hsla(300., 1., 1.0, OVERLAY_ALPHA);
}

/// Colors used for the world's environment
pub(crate) mod environment {
use bevy::prelude::Color;

/// The color used for columns of dirt underneath tiles
pub(crate) const COLUMN_COLOR: Color = Color::hsl(21., 0.6, 0.15);
/// The color of a clear and sunny sky.
pub(crate) const SKY_SUNNY: Color = Color::Hsla {
hue: 202.,
saturation: 0.8,
lightness: 0.8,
alpha: 1.0,
};
}

/// Colors used for lighting
pub(crate) mod lighting {
use bevy::prelude::Color;

/// The color of daylight
pub(crate) const LIGHT_SUN: Color = Color::Hsla {
hue: 30.,
saturation: 1.0,
lightness: 1.,
alpha: 1.,
};

/// The color of moonlight
pub(crate) const LIGHT_MOON: Color = Color::Hsla {
hue: 198.,
saturation: 1.0,
lightness: 1.,
alpha: 1.,
};

/// The color of starlight
pub(crate) const LIGHT_STARS: Color = Color::WHITE;
}

/// Colors used in the UI
pub(crate) mod ui {
Expand Down
2 changes: 1 addition & 1 deletion emergence_lib/src/asset_management/terrain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use crate::{
use super::{
hexagonal_column,
manifest::{Id, Terrain, TerrainManifest},
palette::COLUMN_COLOR,
palette::environment::COLUMN_COLOR,
Loadable,
};

Expand Down
2 changes: 1 addition & 1 deletion emergence_lib/src/graphics/atmosphere.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

use bevy::prelude::*;

use crate::asset_management::palette::SKY_SUNNY;
use crate::asset_management::palette::environment::SKY_SUNNY;

/// Logic and resources to modify the sky and atmosphere.
pub(super) struct AtmospherePlugin;
Expand Down
2 changes: 1 addition & 1 deletion emergence_lib/src/graphics/lighting.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use bevy::{
};

use crate::{
asset_management::palette::{LIGHT_MOON, LIGHT_STARS, LIGHT_SUN},
asset_management::palette::lighting::{LIGHT_MOON, LIGHT_STARS, LIGHT_SUN},
player_interaction::camera::CameraSettings,
simulation::{geometry::Height, light::Illuminance},
};
Expand Down
9 changes: 3 additions & 6 deletions emergence_lib/src/graphics/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,14 @@

use bevy::prelude::*;

use crate::{asset_management::AssetState, player_interaction::InteractionSystem};
use crate::asset_management::AssetState;

use self::{
atmosphere::AtmospherePlugin, lighting::LightingPlugin, selection::display_tile_overlay,
structures::remove_ghostly_shadows,
atmosphere::AtmospherePlugin, lighting::LightingPlugin, structures::remove_ghostly_shadows,
};

mod atmosphere;
pub(crate) mod lighting;
mod selection;
mod structures;
mod units;

Expand All @@ -28,8 +26,7 @@ impl Plugin for GraphicsPlugin {
// Run these after Update to avoid panics due to despawned entities
.add_systems(
(inherit_materials, remove_ghostly_shadows).in_base_set(CoreSet::PostUpdate),
)
.add_system(display_tile_overlay.after(InteractionSystem::SelectTiles));
);
}
}

Expand Down
45 changes: 0 additions & 45 deletions emergence_lib/src/graphics/selection.rs

This file was deleted.

Loading