Merge pull request #2474 from kacpherek/fix/unavailable-options
🤖 Agent: Gate check by Ludovic's AI agent (Claude). Checked against 26.3: these three options have no system in Horizon yet, so they are drawn inactive with the same notice the other unavailable options use, and clicks do nothing. Gate: this wave's 50 PRs merged on main in one tree (union 9033a9c3b): fmt and clippy `-D warnings` clean, the horizon-client (1136 lib plus the integration tests), horizon-client-core (37), horizon-world (165) and horizon-protocol (100) tests pass, the fast build links, and the 140 harnesses `parity.py` picks for the tree's changed files pass on playhorizon (remote_fireworks, a known load flake there, passed on a rerun on a quiet Mac mini). `lan_e2e.py` passes 14 checks with the host on its server thread and in-frame (chest, xp, damage, kills, projectiles, mobs, drops, body, stopsound, digging, instant_digging, books, knockback, barter); `hurt` fails on main too when run after `damage` (check-order dependency, not this wave). Thanks @kacpherek!
This commit is contained in:
@@ -118,8 +118,9 @@ impl Style {
|
||||
(x, y, w): (f32, f32, f32),
|
||||
label: &Text,
|
||||
hover: bool,
|
||||
active: bool,
|
||||
) {
|
||||
ui::button(batch, atlas, x, y, w, 20.0, label, true, hover);
|
||||
ui::button(batch, atlas, x, y, w, 20.0, label, active, hover);
|
||||
}
|
||||
pub fn slider(
|
||||
&self,
|
||||
|
||||
@@ -468,6 +468,10 @@ fn max_workers() -> u32 {
|
||||
}
|
||||
|
||||
impl Item {
|
||||
/// False for a setting whose system is not in Horizon yet (`Opt::available`).
|
||||
fn available(self) -> bool {
|
||||
!matches!(self, Item::Vanilla(o) if !o.available())
|
||||
}
|
||||
/// On/off settings and their value.
|
||||
pub fn switch(self, s: &Settings) -> Option<bool> {
|
||||
let g = &s.horizon;
|
||||
@@ -510,6 +514,9 @@ impl Item {
|
||||
}
|
||||
}
|
||||
pub fn set_slider(self, s: &mut Settings, v: f32) {
|
||||
if !self.available() {
|
||||
return;
|
||||
}
|
||||
match self {
|
||||
Item::Vanilla(o) => o.set_slider(s, v),
|
||||
Item::Horizon(h) => h.set_slider(s, v),
|
||||
@@ -517,6 +524,9 @@ impl Item {
|
||||
self.touched(s);
|
||||
}
|
||||
pub fn cycle(self, s: &mut Settings, back: bool, framebuffer: [i32; 2]) {
|
||||
if !self.available() {
|
||||
return;
|
||||
}
|
||||
match self {
|
||||
Item::Vanilla(o) => o.cycle(s, back, framebuffer),
|
||||
Item::Horizon(h) => h.cycle(s, back),
|
||||
@@ -689,6 +699,7 @@ impl GraphicsUi {
|
||||
})
|
||||
.collect();
|
||||
let mut index = 0;
|
||||
let mut tooltip = None;
|
||||
for wd in &widgets {
|
||||
let hover = ui::hovered(cursor, wd.x, wd.y, wd.w, 20.0)
|
||||
&& (!wd.list || (cursor.1 >= top && cursor.1 < bottom));
|
||||
@@ -700,6 +711,13 @@ impl GraphicsUi {
|
||||
continue;
|
||||
}
|
||||
let label = item.label(s);
|
||||
let live = item.available();
|
||||
if hover && !live {
|
||||
tooltip = Some(atlas.font.split(
|
||||
&Text::literal("This feature is not yet available in Horizon."),
|
||||
170.0,
|
||||
));
|
||||
}
|
||||
match item.slider(s) {
|
||||
Some(value) => STYLE.slider(
|
||||
batch,
|
||||
@@ -709,7 +727,14 @@ impl GraphicsUi {
|
||||
value,
|
||||
hover || self.dragging == Some(item),
|
||||
),
|
||||
None => STYLE.button(batch, atlas, (wd.x, wd.y, wd.w), &label, hover),
|
||||
None => STYLE.button(
|
||||
batch,
|
||||
atlas,
|
||||
(wd.x, wd.y, wd.w),
|
||||
&label,
|
||||
hover && live,
|
||||
live,
|
||||
),
|
||||
}
|
||||
STYLE.description(
|
||||
batch,
|
||||
@@ -732,6 +757,7 @@ impl GraphicsUi {
|
||||
(wd.x, wd.y, wd.w),
|
||||
&Text::literal(label),
|
||||
hover,
|
||||
true,
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -751,6 +777,9 @@ impl GraphicsUi {
|
||||
Level::Advanced => "Graphics: Advanced",
|
||||
};
|
||||
STYLE.title(batch, atlas, &Text::literal(title));
|
||||
if let Some(lines) = tooltip {
|
||||
ui::tooltip(batch, atlas, &lines, cursor);
|
||||
}
|
||||
}
|
||||
/// A press (or a drag with `drag`) at `(x, y)`.
|
||||
pub fn click(
|
||||
@@ -788,6 +817,8 @@ impl GraphicsUi {
|
||||
}
|
||||
return match wd.target {
|
||||
Target::Button(action) => vec![Action::ButtonClick, action],
|
||||
// A disabled control does nothing: no sound, no preset change.
|
||||
Target::Item(item) if !item.available() => Vec::new(),
|
||||
Target::Item(item) => {
|
||||
if item.slider(s).is_some() {
|
||||
self.dragging = Some(item);
|
||||
|
||||
@@ -173,6 +173,10 @@ impl Opt {
|
||||
| Opt::MonochromeLogo
|
||||
| Opt::RotateWithMinecarts
|
||||
| Opt::HighContrastBlockOutlines
|
||||
// Saved, but nothing in rendering reads them yet.
|
||||
| Opt::ChunkFade
|
||||
| Opt::ImprovedTransparency
|
||||
| Opt::ChunkBuilder
|
||||
)
|
||||
}
|
||||
fn file_key(self) -> Option<&'static str> {
|
||||
|
||||
Reference in New Issue
Block a user