Merge pull request #1089 from ludovic111/fix/video-cost-labels
🤖 Agent: merged after integration C: the desktop ran 322/325 harnesses on main + #1088–#1093, and its 3 failures were the known dedicated_server flake plus the two display harnesses; world_reopen and save_roundtrip pass on the Mac mini (main + the six branches).
This commit is contained in:
@@ -14,6 +14,8 @@ pub enum Cost {
|
||||
Low,
|
||||
Medium,
|
||||
High,
|
||||
/// Turning it on makes frames faster (culling).
|
||||
Saves,
|
||||
}
|
||||
impl Cost {
|
||||
pub fn label(self) -> &'static str {
|
||||
@@ -22,6 +24,7 @@ impl Cost {
|
||||
Cost::Low => "Low cost",
|
||||
Cost::Medium => "Medium cost",
|
||||
Cost::High => "High cost",
|
||||
Cost::Saves => "Saves time",
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -42,7 +45,7 @@ pub struct Style {
|
||||
pub header_color: u32,
|
||||
pub description_color: u32,
|
||||
/// Colour of each `Cost`, in its order.
|
||||
pub cost_colors: [u32; 4],
|
||||
pub cost_colors: [u32; 5],
|
||||
}
|
||||
|
||||
/// `hud::rgba` with full alpha, usable in constants.
|
||||
@@ -65,6 +68,7 @@ pub const STYLE: Style = Style {
|
||||
opaque(170, 220, 120),
|
||||
opaque(240, 200, 90),
|
||||
opaque(240, 110, 90),
|
||||
opaque(85, 255, 85),
|
||||
],
|
||||
};
|
||||
|
||||
@@ -179,3 +183,18 @@ fn wrap(atlas: &HudAtlas, text: &str, width: f32, indent: f32) -> Vec<String> {
|
||||
}
|
||||
lines
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn every_cost_has_a_label_and_a_colour() {
|
||||
let all = [Cost::None, Cost::Low, Cost::Medium, Cost::High, Cost::Saves];
|
||||
assert_eq!(all.len(), STYLE.cost_colors.len());
|
||||
for (i, cost) in all.into_iter().enumerate() {
|
||||
assert_eq!(cost as usize, i);
|
||||
assert!(!cost.label().is_empty());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -124,7 +124,7 @@ pub fn rows(level: Level) -> Vec<Row> {
|
||||
),
|
||||
h(
|
||||
H::CaveCulling,
|
||||
None,
|
||||
Saves,
|
||||
"Skips terrain hidden behind closed sections. Off costs a lot.",
|
||||
),
|
||||
h(
|
||||
@@ -150,7 +150,7 @@ pub fn rows(level: Level) -> Vec<Row> {
|
||||
),
|
||||
v(
|
||||
Opt::Mipmaps,
|
||||
Low,
|
||||
None,
|
||||
"Smaller copies of block textures for distant terrain: less shimmer.",
|
||||
),
|
||||
v(
|
||||
@@ -160,7 +160,7 @@ pub fn rows(level: Level) -> Vec<Row> {
|
||||
),
|
||||
v(
|
||||
Opt::Clouds,
|
||||
Medium,
|
||||
Low,
|
||||
"Cloud layer: off, flat (fast) or 3D (fancy).",
|
||||
),
|
||||
v(Opt::CloudRange, Low, "How far clouds reach, in chunks."),
|
||||
@@ -170,10 +170,10 @@ pub fn rows(level: Level) -> Vec<Row> {
|
||||
None,
|
||||
"Distance fog. Off shows the edge of the loaded world.",
|
||||
),
|
||||
h(H::Weather, Low, "Draws rain and snow."),
|
||||
h(H::Weather, High, "Draws rain and snow."),
|
||||
v(
|
||||
Opt::WeatherRadius,
|
||||
Low,
|
||||
Medium,
|
||||
"How far rain and snow fall around you.",
|
||||
),
|
||||
v(Opt::Particles, Medium, "How many particles effects spawn."),
|
||||
@@ -213,7 +213,7 @@ pub fn rows(level: Level) -> Vec<Row> {
|
||||
),
|
||||
h(
|
||||
H::Antialiasing,
|
||||
Low,
|
||||
Medium,
|
||||
"FXAA smooths jagged edges of the world; slightly softer image.",
|
||||
),
|
||||
h(
|
||||
|
||||
@@ -1247,7 +1247,8 @@ impl<'a> Ui<'a> {
|
||||
}
|
||||
/// A settings row with, under its label, a one-line description led by
|
||||
/// the setting's frame-time cost (`cost` 0 none .. 3 high, coloured from
|
||||
/// the muted colour to the danger colour). Same height as [`Ui::row`].
|
||||
/// the muted colour to the danger colour; 4 saves time, in the success
|
||||
/// colour). Same height as [`Ui::row`].
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
pub fn described_row(
|
||||
&mut self,
|
||||
@@ -1276,8 +1277,14 @@ impl<'a> Ui<'a> {
|
||||
&value,
|
||||
);
|
||||
let dy = top + (BODY * 1.45).round();
|
||||
let tint = [0.0, 0.2, 0.55, 1.0][usize::from(cost.0.min(3))];
|
||||
let cost_color = color::mix(color::FAINT, color::DANGER, tint);
|
||||
let cost_color = match cost.0 {
|
||||
4 => color::SUCCESS,
|
||||
n => color::mix(
|
||||
color::FAINT,
|
||||
color::DANGER,
|
||||
[0.0, 0.2, 0.55, 1.0][usize::from(n.min(3))],
|
||||
),
|
||||
};
|
||||
self.text(Face::Medium, SMALL, x, dy, cost_color, cost.1);
|
||||
// No cost label: the description starts at the row's edge.
|
||||
let used = if cost.1.is_empty() {
|
||||
|
||||
+1
-1
@@ -9,7 +9,7 @@ In the Horizon menu style, the Options screen's **Video** section holds the grap
|
||||
|
||||
In the Classic style, Video Settings starts with two buttons opening the same settings as vanilla-looking screens.
|
||||
|
||||
Every row has a one-line description and its cost in frame time (none, low, medium, high), and applies at once, except worker threads, which apply at the next start. A preset sets the quality settings together; changing one of them turns it into Custom. Display preferences (FOV, framerate, VSync, GUI scale, fullscreen, present mode, pacing) leave the preset as it is.
|
||||
Every row has a one-line description and its cost in frame time (none, low, medium, high, or saves time for culling that makes frames faster), and applies at once, except worker threads, which apply at the next start. A preset sets the quality settings together; changing one of them turns it into Custom. Display preferences (FOV, framerate, VSync, GUI scale, fullscreen, present mode, pacing) leave the preset as it is.
|
||||
|
||||

|
||||

|
||||
|
||||
Reference in New Issue
Block a user