Files
Bullosseum/ui/orientation_guard.gd
T
richard 7b6a141767 Reorganize the codebase into role-based folders (snake_case)
Move the 40-odd root-level scripts and scenes into a tree that groups by role,
per the approved roadmap (WS2/WS3): actors/{player,matador,bear}, systems/{combat,
fx,input,debug,render,crowd,config}, ui/, props/ (was tscn_s/). Rename the shell
scene.tscn -> levels/game_shell.tscn and every PascalCase scene to snake_case
(Player.tscn -> player.tscn, MainMenu.tscn -> main_menu.tscn, etc.) so the
case-insensitive web/macOS filesystems can't alias two files together.

Done as a scripted move: each file travels with its .uid; every quoted res:// path
across scenes, scripts, .tres, and project.godot's 9 autoloads is rewritten; the
.godot uid/class cache is rebuilt from scratch. Scenes still resolve by uid, so the
rewrite is belt-and-suspenders. Lint globs (run_tests.sh + both CI workflows) now
walk the new dirs; an orphan animation_tree.gd.uid and 7 pre-existing trailing-
whitespace lints (barrel/torch, never covered by the old root-only glob) are cleaned.

Full suite green on both sides. Asset consolidation (Assets/Animations/fonts ->
art/) is deferred — moving imported .glb/.png/.ttf is safer done in the editor.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017KoYBYQgRyY1zDHXMsXY3V
2026-09-06 00:04:41 +03:00

64 lines
2.2 KiB
GDScript

extends CanvasLayer
## Universal "rotate to landscape" prompt (autoload `OrientationGuard`). The cross-device
## half of landscape enforcement: screen.orientation.lock (controls_manager.gd) handles
## Android, but iOS Safari has no lock API, and some browsers only lock in fullscreen — so
## wherever the device ends up portrait, we simply ask the player to turn it. No canvas
## rotation or input remapping (those break touch coordinates), so it works on every phone
## and browser cleanly. Only ever shows on touch-primary devices, only while portrait.
var _panel: ColorRect
func _ready() -> void:
layer = 128 # above HUD, touch UI, everything
process_mode = Node.PROCESS_MODE_ALWAYS
_panel = ColorRect.new()
_panel.color = Color(0.05, 0.03, 0.02, 0.97)
_panel.set_anchors_preset(Control.PRESET_FULL_RECT)
_panel.mouse_filter = Control.MOUSE_FILTER_STOP # swallow taps to the game behind it
_panel.visible = false
add_child(_panel)
var center := CenterContainer.new()
center.set_anchors_preset(Control.PRESET_FULL_RECT)
center.mouse_filter = Control.MOUSE_FILTER_IGNORE
_panel.add_child(center)
var box := VBoxContainer.new()
box.alignment = BoxContainer.ALIGNMENT_CENTER
box.add_theme_constant_override("separation", 14)
center.add_child(box)
var title := Label.new()
title.text = "Rotate your device"
title.horizontal_alignment = HORIZONTAL_ALIGNMENT_CENTER
title.add_theme_font_size_override("font_size", 44)
title.add_theme_color_override("font_color", Color(1.0, 0.78, 0.22))
box.add_child(title)
var sub := Label.new()
sub.text = "Turn it sideways to play in landscape"
sub.horizontal_alignment = HORIZONTAL_ALIGNMENT_CENTER
sub.add_theme_font_size_override("font_size", 22)
sub.add_theme_color_override("font_color", Color(0.85, 0.85, 0.85))
box.add_child(sub)
get_viewport().size_changed.connect(_update)
_update.call_deferred()
func _update() -> void:
_panel.visible = _should_guard() and _is_portrait()
func _is_portrait() -> bool:
var s := get_viewport().get_visible_rect().size
return s.y > s.x
# Touch-primary devices only — never a desktop browser with a tall window (they can't rotate
# a monitor). Reuses the same conservative detection the touch UI uses.
func _should_guard() -> bool:
return Controls.use_touch_ui()