Files
rusty-path-of-building/src/main.rs
T
meehl cc6de120f2 Refactor context handling and redraw requests
Remove unsafe pointer shenanigans and give Lua instance ownership over
`Context`. Event handlers now directly mutate Context instead of using a
shared app state which is then hooked up to Context via unsafe pointers.
The removal of a shared state means stages (previously called "modes")
are now responsible for keeping their own internal state.

Additionally, clean up draw request handling and module hierarchy.
2026-08-23 23:55:43 +02:00

69 lines
1.6 KiB
Rust

use crate::{app::App, args::Args};
use clap::Parser;
use std::path::{Path, PathBuf};
use winit::event_loop::EventLoop;
mod app;
mod args;
mod batcher;
mod clipboard;
mod color;
mod dpi;
mod draw_commands;
mod fonts;
mod gfx;
mod input;
mod installer;
mod math;
mod pob;
mod renderer;
mod stage;
mod util;
mod window;
mod worker_pool;
fn main() -> anyhow::Result<()> {
profiling::register_thread!("Main Thread");
env_logger::init();
#[cfg(feature = "profile-with-puffin")]
let _puffin_server = {
let server_addr = format!("127.0.0.1:{}", puffin_http::DEFAULT_PORT);
let server = puffin_http::Server::new(&server_addr).unwrap();
eprintln!("Serving profiling data on {server_addr}. Run `puffin_viewer` to view it.");
profiling::puffin::set_scopes_on(true);
server
};
let args = Args::parse();
let script_dir = find_nearby_launch_script();
let mut app = App::new(args.game, script_dir)?;
let event_loop = EventLoop::with_user_event().build()?;
event_loop.run_app(&mut app)?;
Ok(())
}
/// Search for the Launch.lua file in nearby locations
fn find_nearby_launch_script() -> Option<PathBuf> {
let mut candidates = vec![Path::new("Launch.lua"), Path::new("src/Launch.lua")];
if let Ok(cwd) = std::env::current_dir()
&& cwd.ends_with("runtime")
{
candidates.push(Path::new("../src/Launch.lua"));
}
for candidate in candidates {
if candidate.try_exists().is_ok_and(|exists| exists)
&& let Some(Ok(candidate)) = candidate.parent().map(Path::canonicalize)
{
return Some(candidate);
}
}
None
}