Holiday switch in the debug menu; darker wood for the treasury chests
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
8f670554c7
commit
4175ca7f97
24 files changed
+112
-8
No files matched your search
+17
-2
@@ -53,12 +53,27 @@ pub fn holiday_on(y: i64, m: i64, d: i64) -> u8 {
|
||||
}
|
||||
}
|
||||
|
||||
// today's holiday (worked out once); on the desktop DUNGEONCRAFT_HOLIDAY=halloween / christmas /
|
||||
// easter / none shows one at any time
|
||||
thread_local! {
|
||||
// the debug menu's choice: 0 by the date, else the holiday + 1
|
||||
static OVERRIDE: std::cell::Cell<u8> = const { std::cell::Cell::new(0) };
|
||||
}
|
||||
|
||||
// the debug menu's holiday setting (Settings::debug_holiday: 0 by the date, 1 none, 2 Halloween,
|
||||
// 3 Christmas, 4 Easter)
|
||||
pub fn set_override(v: u8) {
|
||||
OVERRIDE.with(|o| o.set(v.min(4)));
|
||||
}
|
||||
|
||||
// today's holiday (worked out once) unless the debug menu picks one; on the desktop
|
||||
// DUNGEONCRAFT_HOLIDAY=halloween / christmas / easter / none shows one at any time
|
||||
pub fn current() -> u8 {
|
||||
thread_local! {
|
||||
static HOLIDAY: std::cell::Cell<u8> = const { std::cell::Cell::new(255) };
|
||||
}
|
||||
let forced = OVERRIDE.with(|o| o.get());
|
||||
if forced > 0 {
|
||||
return forced - 1;
|
||||
}
|
||||
HOLIDAY.with(|h| {
|
||||
if h.get() == 255 {
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
|
||||
@@ -480,6 +480,7 @@ fn apply_settings(s: &Settings, r3d: &mut R3d) {
|
||||
r3d.set_wall_detail(s.wall_subdivisions());
|
||||
r3d.max_lights = s.max_lights as usize;
|
||||
r3d.pixel_rows = settings::pixel_rows(s.pixel_rows);
|
||||
holiday::set_override(s.debug_holiday);
|
||||
audio::set_volumes(s.music_volume, s.volume, s.muted);
|
||||
}
|
||||
|
||||
|
||||
+11
-1
@@ -62,6 +62,7 @@ pub enum Item {
|
||||
DebugTriggerZones,
|
||||
DebugCommandMarkers,
|
||||
DebugPathLines,
|
||||
DebugHoliday,
|
||||
GameSpeed,
|
||||
Hints,
|
||||
Events,
|
||||
@@ -77,7 +78,7 @@ fn tab_items(tab: usize) -> &'static [Item] {
|
||||
1 => &[RotateSpeed, PanSpeed, ZoomSpeed, EdgeScroll, InvertMouse],
|
||||
2 => &[Outlines, WallDetail, Lights, UiScale, RenderScale],
|
||||
3 => &[GameSpeed, Hints, Events, TouchUi],
|
||||
4 => &[DebugFps, DebugFrameTime, DebugPing, DebugTriggerZones, DebugCommandMarkers, DebugPathLines],
|
||||
4 => &[DebugFps, DebugFrameTime, DebugPing, DebugTriggerZones, DebugCommandMarkers, DebugPathLines, DebugHoliday],
|
||||
_ => &[],
|
||||
}
|
||||
}
|
||||
@@ -104,6 +105,7 @@ fn item_label(it: Item) -> String {
|
||||
Item::DebugTriggerZones => "set.debug_trigger_zones",
|
||||
Item::DebugCommandMarkers => "set.debug_command_markers",
|
||||
Item::DebugPathLines => "set.debug_path_lines",
|
||||
Item::DebugHoliday => "set.debug_holiday",
|
||||
Item::GameSpeed => "set.game_speed",
|
||||
Item::Hints => "set.hints",
|
||||
Item::Events => "set.events",
|
||||
@@ -151,6 +153,13 @@ fn item_value(it: Item, s: &Settings) -> String {
|
||||
Item::DebugTriggerZones => onoff(s.debug_trigger_zones),
|
||||
Item::DebugCommandMarkers => onoff(s.debug_command_markers),
|
||||
Item::DebugPathLines => onoff(s.debug_path_lines),
|
||||
Item::DebugHoliday => tr(match s.debug_holiday {
|
||||
1 => "val.off",
|
||||
2 => "val.halloween",
|
||||
3 => "val.christmas",
|
||||
4 => "val.easter",
|
||||
_ => "val.auto_plain",
|
||||
}),
|
||||
Item::RenderScale => tr(if crate::settings::pixel_rows(s.pixel_rows) == crate::settings::HIGH_RES_ROWS as u32 { "set.style_highres" } else { "set.style_pixel" }),
|
||||
Item::GameSpeed => format!("{}x", s.game_speed as i32),
|
||||
Item::Hints => onoff(s.hints),
|
||||
@@ -207,6 +216,7 @@ fn item_change(it: Item, s: &mut Settings, d: i32) {
|
||||
Item::DebugTriggerZones => s.debug_trigger_zones = !s.debug_trigger_zones,
|
||||
Item::DebugCommandMarkers => s.debug_command_markers = !s.debug_command_markers,
|
||||
Item::DebugPathLines => s.debug_path_lines = !s.debug_path_lines,
|
||||
Item::DebugHoliday => s.debug_holiday = cycle(&[0u8, 1, 2, 3, 4], s.debug_holiday.min(4), d),
|
||||
Item::GameSpeed => s.game_speed = cycle(&[1.0f32, 2.0], s.game_speed, d),
|
||||
Item::Hints => s.hints = !s.hints,
|
||||
Item::Events => s.events = !s.events,
|
||||
|
||||
+2
-2
@@ -430,8 +430,8 @@ fn chest(c: Vec3, h: u32, l: f32, fill: f32, res: u8) {
|
||||
let at = |dx: f32, dz: f32, y: f32| c + vec3(dx * ca - dz * sa, y, dx * sa + dz * ca);
|
||||
let cube = |p: Vec3, s: Vec3, col: Color| cube(p, if q % 2 == 1 { vec3(s.z, s.y, s.x) } else { s }, col);
|
||||
let mcube = |m: Mat, p: Vec3, s: Vec3, col: Color| mc(m, p, if q % 2 == 1 { vec3(s.z, s.y, s.x) } else { s }, col);
|
||||
let wood = rgb(110, 70, 36, l);
|
||||
let band = rgb(170, 140, 70, l);
|
||||
let wood = rgb(66, 40, 22, l);
|
||||
let band = rgb(150, 122, 60, l);
|
||||
mcube(Mat::Wood, at(0.0, 0.0, 0.16), vec3(0.56, 0.32, 0.4), wood);
|
||||
mcube(Mat::Iron, at(0.0, 0.0, 0.16), vec3(0.58, 0.05, 0.42), band);
|
||||
mcube(Mat::Iron, at(0.0, 0.21, 0.18), vec3(0.08, 0.1, 0.02), band);
|
||||
|
||||
+7
-3
@@ -1255,6 +1255,7 @@ pub struct R3d {
|
||||
target: Option<(RenderTarget, u32, u32)>, // low resolution render target
|
||||
lava: Vec<f32>, // lava light per tile (see lava_field)
|
||||
chunks_hd: bool, // the chunks were built with the high-res atlas
|
||||
chunks_holiday: u8, // ... and with this holiday's decorations
|
||||
}
|
||||
|
||||
// The 3D resolution setting refers to a window 1080 device pixels high: smaller windows use a
|
||||
@@ -1305,7 +1306,7 @@ fn chunk_sig(map: &Map, cx: i32, cz: i32) -> u64 {
|
||||
|
||||
impl R3d {
|
||||
pub fn new() -> R3d {
|
||||
R3d { lit: lit_material(), glow: glow_material(), opaque: opaque_material(), chunks: Vec::new(), ncx: 0, ncz: 0, outlines: true, wall_sub: 3, max_lights: MAX_LIGHTS, pixel_rows: crate::settings::PIXEL_ART_ROWS as u32, target: None, lava: Vec::new(), chunks_hd: false }
|
||||
R3d { lit: lit_material(), glow: glow_material(), opaque: opaque_material(), chunks: Vec::new(), ncx: 0, ncz: 0, outlines: true, wall_sub: 3, max_lights: MAX_LIGHTS, pixel_rows: crate::settings::PIXEL_ART_ROWS as u32, target: None, lava: Vec::new(), chunks_hd: false, chunks_holiday: 0 }
|
||||
}
|
||||
|
||||
// Changing the wall detail rebuilds all chunks
|
||||
@@ -1345,10 +1346,13 @@ impl R3d {
|
||||
ch.sig = 0;
|
||||
}
|
||||
}
|
||||
// the graphics style changed: the chunks are built again with the other atlas
|
||||
// the graphics style or the holiday changed: the chunks are built again (other atlas,
|
||||
// other decorations)
|
||||
let hd = self.pixel_rows >= crate::settings::HIGH_RES_ROWS as u32;
|
||||
if hd != self.chunks_hd {
|
||||
let holiday = crate::holiday::current();
|
||||
if hd != self.chunks_hd || holiday != self.chunks_holiday {
|
||||
self.chunks_hd = hd;
|
||||
self.chunks_holiday = holiday;
|
||||
for ch in self.chunks.iter_mut() {
|
||||
ch.sig = 0;
|
||||
}
|
||||
|
||||
@@ -159,6 +159,7 @@ pub struct Settings {
|
||||
pub debug_trigger_zones: bool, // draw mission trigger zones
|
||||
pub debug_command_markers: bool, // draw extra command markers (guard/attack/gather stay fixed)
|
||||
pub debug_path_lines: bool, // draw creature path lines
|
||||
pub debug_holiday: u8, // holiday: 0 by the date, 1 none, 2 Halloween, 3 Christmas, 4 Easter
|
||||
// game
|
||||
pub game_speed: f32, // 1 or 2
|
||||
pub hints: bool,
|
||||
@@ -200,6 +201,7 @@ impl Default for Settings {
|
||||
debug_trigger_zones: false,
|
||||
debug_command_markers: false,
|
||||
debug_path_lines: false,
|
||||
debug_holiday: 0,
|
||||
game_speed: 1.0,
|
||||
hints: true,
|
||||
difficulty: 1,
|
||||
|
||||
Reference in new issue
Block a user