@@ -2991,22 +2991,16 @@ pub fn main() !void {
29912991 const world = sacred_worlds .getWorldByBlock (wi );
29922992 const title_slice = world .name [0.. world .name_len ];
29932993
2994- // Find existing sacred_world panel with this world_id
2995- var found = false ;
2994+ // Close all other sacred_world panels first (one world at a time)
29962995 for (0.. panels .count ) | pi | {
2997- if (panels .panels [pi ].panel_type == .sacred_world and
2998- panels .panels [pi ].world_id == @as (u8 , @intCast (wi )))
2999- {
3000- // Focus existing — fullscreen
3001- panels .panels [pi ].jarvisFocus ();
3002- panels .active_panel = pi ;
3003- found = true ;
3004- break ;
2996+ if (panels .panels [pi ].panel_type == .sacred_world ) {
2997+ panels .panels [pi ].close ();
2998+ panels .panels [pi ].is_focused = false ;
30052999 }
30063000 }
30073001
3008- if ( ! found and panels . count < MAX_PANELS ) {
3009- // Spawn new fullscreen sacred world panel
3002+ // Spawn fullscreen sacred world panel (reuse slot or add new)
3003+ if ( panels . count < MAX_PANELS ) {
30103004 panels .panels [panels .count ] = GlassPanel .init (
30113005 0 , 0 , screen_w , screen_h ,
30123006 .sacred_world , title_slice ,
@@ -3023,6 +3017,36 @@ pub fn main() !void {
30233017 // ESC unfocuses all panels
30243018 if (rl .IsKeyPressed (rl .KEY_ESCAPE )) {
30253019 panels .unfocusAll ();
3020+ // Close all sacred world panels
3021+ for (0.. panels .count ) | pi | {
3022+ if (panels .panels [pi ].panel_type == .sacred_world ) {
3023+ panels .panels [pi ].close ();
3024+ }
3025+ }
3026+ }
3027+
3028+ // Click outside any panel = close all panels (return to logo menu)
3029+ if (rl .IsMouseButtonPressed (rl .MOUSE_BUTTON_LEFT ) and ! shift_held and ! ctrl_held and ! cmd_held ) {
3030+ var clicked_on_panel = false ;
3031+ for (0.. panels .count ) | pi | {
3032+ const p = & panels .panels [pi ];
3033+ if (p .state == .open or p .state == .opening ) {
3034+ if (mx >= p .x and mx <= p .x + p .width and my >= p .y and my <= p .y + p .height ) {
3035+ clicked_on_panel = true ;
3036+ break ;
3037+ }
3038+ }
3039+ }
3040+ // Also check if click is on the logo (don't close if clicking logo)
3041+ const on_logo = logo_anim .hovered_block >= 0 ;
3042+ if (! clicked_on_panel and ! on_logo ) {
3043+ // Close all panels — return to main logo menu
3044+ for (0.. panels .count ) | pi | {
3045+ panels .panels [pi ].close ();
3046+ panels .panels [pi ].is_focused = false ;
3047+ }
3048+ panels .unfocusAll ();
3049+ }
30263050 }
30273051
30283052 // === DIRECT CHAT PANEL INPUT ===
@@ -3224,25 +3248,16 @@ pub fn main() !void {
32243248 const block_idx = @as (usize , @intCast (logo_anim .clicked_block ));
32253249 const world = sacred_worlds .getWorldByBlock (block_idx );
32263250
3227- // Check if world panel already exists
3228- var found = false ;
3229- var found_idx : usize = 0 ;
3251+ // Close all other sacred_world panels (one at a time)
32303252 for (0.. panels .count ) | pi | {
3231- if (panels .panels [pi ].panel_type == .sacred_world and
3232- panels .panels [pi ].world_id == @as (u8 , @intCast (block_idx )))
3233- {
3234- found = true ;
3235- found_idx = pi ;
3236- break ;
3253+ if (panels .panels [pi ].panel_type == .sacred_world ) {
3254+ panels .panels [pi ].close ();
3255+ panels .panels [pi ].is_focused = false ;
32373256 }
32383257 }
32393258
3240- if (found ) {
3241- // Focus existing panel — fullscreen
3242- panels .panels [found_idx ].jarvisFocus ();
3243- panels .active_panel = found_idx ;
3244- } else if (panels .count < MAX_PANELS ) {
3245- // Spawn new fullscreen sacred world panel
3259+ // Spawn new fullscreen sacred world panel
3260+ if (panels .count < MAX_PANELS ) {
32463261 const title_slice = world .name [0.. world .name_len ];
32473262 panels .panels [panels .count ] = GlassPanel .init (
32483263 0 , 0 , screen_w , screen_h ,
@@ -3288,7 +3303,7 @@ pub fn main() !void {
32883303 panels .draw (time , font );
32893304
32903305 // Keyboard hint (minimal, top-left)
3291- rl .DrawTextEx (font_small , "Click Logo = World | Shift +1-8 = Panel | ESC = Close " , .{ .x = 10 , .y = 10 }, 13 , 1 , withAlpha (TEXT_DIM , 180 ));
3306+ rl .DrawTextEx (font_small , "Shift+1-9 RAZUM | Ctrl+1-9 MATERIYA | Cmd +1-9 DUKH | ESC" , .{ .x = 10 , .y = 10 }, 13 , 1 , withAlpha (TEXT_DIM , 180 ));
32923307
32933308 // === STATUS BAR (Hyper terminal style, bottom) ===
32943309 const status_bar_h : f32 = 24 ;
0 commit comments