Compare commits

..

No commits in common. "0125e2ca3ef25f9764ece3eb35e3fc31dd857b46" and "89c750842647448986ac3ea75727ef6ca391fb06" have entirely different histories.

2 changed files with 4 additions and 28 deletions

View file

@ -670,8 +670,7 @@ pub const Context = struct {
const border_color: ?Style.Color = blk: {
if (config.base_color) |base| {
const derived = Style.derivePanelFrameColors(base);
const bc = if (config.has_focus) derived.border_focus else derived.border_unfocus;
break :blk bc;
break :blk if (config.has_focus) derived.border_focus else derived.border_unfocus;
}
break :blk config.border_color;
};

View file

@ -32,18 +32,12 @@
//!
//! ## Personalización
//! Los tiempos son configurables mediante constantes en State:
//! - IDLE_MIN_MS: Tiempo MÍNIMO de inactividad para aparecer (45s)
//! - IDLE_RANDOM_MAX_MS: Tiempo adicional aleatorio (0-135s, total 45s-3min)
//! - IDLE_THRESHOLD_MS: Tiempo de inactividad para aparecer (15s)
//! - PEEK_DURATION_MS: Duración del asomarse (4s)
//! - WATCH_DURATION_MS: Duración mirando alrededor (3s)
//! - HIDE_DURATION_MS: Duración al esconderse (1s)
//! - PANIC_HIDE_DURATION_MS: Duración del salto de pánico (0.2s)
//! - RELOCATE_DELAY_MS: Pausa antes de reaparecer (5s)
//!
//! ## Comportamiento de sorpresa
//! El gatito aparece de forma impredecible entre 45 segundos y 3 minutos
//! de inactividad. Cada aparición genera un nuevo tiempo aleatorio para
//! la siguiente, manteniendo el efecto sorpresa.
const std = @import("std");
const Context = @import("../core/context.zig").Context;
@ -102,18 +96,11 @@ pub const State = struct {
/// Semilla para números pseudo-aleatorios (LCG simple)
random_seed: u32 = 12345,
/// Tiempo de inactividad necesario para la próxima aparición (aleatorio)
next_appear_threshold: i64 = 45_000,
// =========================================================================
// Constantes de tiempo (personalizables)
// =========================================================================
/// Tiempo MÍNIMO de inactividad para aparecer (ms)
pub const IDLE_MIN_MS: i64 = 45_000; // 45 segundos
/// Tiempo MÁXIMO adicional aleatorio (ms)
pub const IDLE_RANDOM_MAX_MS: i64 = 135_000; // +0 a 135s = total 45s-3min
/// Tiempo de inactividad para aparecer (ms) - LEGACY, ahora aleatorio
/// Tiempo de inactividad para aparecer (ms)
pub const IDLE_THRESHOLD_MS: i64 = 15_000;
/// Duración del estado peeking (ms)
pub const PEEK_DURATION_MS: i64 = 4_000;
@ -137,13 +124,6 @@ pub const State = struct {
return @as(f32, @floatFromInt(self.nextRandom() % 10000)) / 10000.0;
}
/// Genera el próximo tiempo de inactividad necesario para aparecer
/// Resultado: entre IDLE_MIN_MS y IDLE_MIN_MS + IDLE_RANDOM_MAX_MS
fn generateNextAppearThreshold(self: *State) void {
const random_extra = self.nextRandom() % @as(u32, @intCast(IDLE_RANDOM_MAX_MS));
self.next_appear_threshold = IDLE_MIN_MS + @as(i64, random_extra);
}
/// Elige un panel y posición aleatorios
fn pickRandomLocation(self: *State, num_panels: usize) void {
if (num_panels == 0) return;
@ -184,8 +164,7 @@ pub const State = struct {
// Máquina de estados
switch (self.anim_state) {
.hidden => {
// Aparición aleatoria: usa threshold variable (45s - 3min)
if (idle_time >= self.next_appear_threshold and num_panels > 0) {
if (idle_time >= IDLE_THRESHOLD_MS and num_panels > 0) {
self.pickRandomLocation(num_panels);
self.anim_state = .peeking;
self.state_start_time = now;
@ -252,8 +231,6 @@ pub const State = struct {
self.state_start_time = now + RELOCATE_DELAY_MS;
self.appear_progress = 0;
self.panic_jump = false;
// Generar nuevo tiempo aleatorio para próxima aparición
self.generateNextAppearThreshold();
}
},
}