Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e2c0f2fffc | ||
|
|
a6be413190 | ||
|
|
8034eef8c7 | ||
|
|
3b0d5295d3 | ||
|
|
ff46a570fc | ||
|
|
7db64e337d | ||
|
|
522ab489cd | ||
|
|
8217aca6f2 | ||
|
|
249116af52 | ||
|
|
c47bf48556 | ||
|
|
1f89e31f30 | ||
|
|
913d2127d8 |
No files matched your search
+28
-1
@@ -2,6 +2,30 @@
|
|||||||
|
|
||||||
## [Unreleased] - ReleaseDate
|
## [Unreleased] - ReleaseDate
|
||||||
|
|
||||||
|
## [0.2.14] - 2026-03-14
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- Fix deletion of character build directories
|
||||||
|
- Prevent installer from downloading beta versions
|
||||||
|
|
||||||
|
## [0.2.13] - 2026-03-09
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- Fix size of ascendancy flavour texts
|
||||||
|
|
||||||
|
## [0.2.12] - 2026-03-09
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- Add better logging and UI feedback for initial install
|
||||||
|
- Set global timeout for network requests
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- Fix confirmation dialog not showing on close with unsaved changes
|
||||||
|
|
||||||
## [0.2.11] - 2026-03-05
|
## [0.2.11] - 2026-03-05
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
@@ -150,8 +174,11 @@
|
|||||||
- First release
|
- First release
|
||||||
|
|
||||||
<!-- next-url -->
|
<!-- next-url -->
|
||||||
[Unreleased]: https://github.com/meehl/rusty-path-of-building/compare/v0.2.11...HEAD
|
[Unreleased]: https://github.com/meehl/rusty-path-of-building/compare/v0.2.14...HEAD
|
||||||
|
|
||||||
|
[0.2.14]: https://github.com/meehl/rusty-path-of-building/compare/v0.2.13...v0.2.14
|
||||||
|
[0.2.13]: https://github.com/meehl/rusty-path-of-building/compare/v0.2.12...v0.2.13
|
||||||
|
[0.2.12]: https://github.com/meehl/rusty-path-of-building/compare/v0.2.11...v0.2.12
|
||||||
[0.2.11]: https://github.com/meehl/rusty-path-of-building/compare/v0.2.10...v0.2.11
|
[0.2.11]: https://github.com/meehl/rusty-path-of-building/compare/v0.2.10...v0.2.11
|
||||||
[0.2.10]: https://github.com/meehl/rusty-path-of-building/compare/v0.2.9...v0.2.10
|
[0.2.10]: https://github.com/meehl/rusty-path-of-building/compare/v0.2.9...v0.2.10
|
||||||
[0.2.9]: https://github.com/meehl/rusty-path-of-building/compare/v0.2.8...v0.2.9
|
[0.2.9]: https://github.com/meehl/rusty-path-of-building/compare/v0.2.8...v0.2.9
|
||||||
|
|||||||
Generated
+1
-1
@@ -2506,7 +2506,7 @@ checksum = "b39cdef0fa800fc44525c84ccb54a029961a8215f9619753635a9c0d2538d46d"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rusty-path-of-building"
|
name = "rusty-path-of-building"
|
||||||
version = "0.2.11"
|
version = "0.2.14"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"ahash",
|
"ahash",
|
||||||
"anyhow",
|
"anyhow",
|
||||||
|
|||||||
+1
-1
@@ -4,7 +4,7 @@ authors = ["meehl"]
|
|||||||
description = "Cross-platform runtime for Path of Building"
|
description = "Cross-platform runtime for Path of Building"
|
||||||
repository = "https://github.com/meehl/rusty-path-of-building"
|
repository = "https://github.com/meehl/rusty-path-of-building"
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
version = "0.2.11"
|
version = "0.2.14"
|
||||||
edition = "2024"
|
edition = "2024"
|
||||||
publish = false
|
publish = false
|
||||||
|
|
||||||
|
|||||||
+13
-1
@@ -9,7 +9,8 @@ use crate::{
|
|||||||
input::{get_cursor_pos, is_key_down},
|
input::{get_cursor_pos, is_key_down},
|
||||||
lua::{load_module, protected_call, protected_load_module},
|
lua::{load_module, protected_call, protected_load_module},
|
||||||
paths::{
|
paths::{
|
||||||
get_runtime_path, get_script_path, get_user_path, get_work_dir, make_dir, set_work_dir,
|
get_runtime_path, get_script_path, get_user_path, get_work_dir, make_dir, remove_dir,
|
||||||
|
set_work_dir,
|
||||||
},
|
},
|
||||||
rendering::PoBString,
|
rendering::PoBString,
|
||||||
search_handle::new_search_handle,
|
search_handle::new_search_handle,
|
||||||
@@ -51,6 +52,7 @@ pub fn register_globals(lua: &Lua) -> LuaResult<()> {
|
|||||||
globals.set("GetWorkDir", lua.create_function(get_work_dir)?)?;
|
globals.set("GetWorkDir", lua.create_function(get_work_dir)?)?;
|
||||||
globals.set("SetWorkDir", lua.create_function(set_work_dir)?)?;
|
globals.set("SetWorkDir", lua.create_function(set_work_dir)?)?;
|
||||||
globals.set("MakeDir", lua.create_function(make_dir)?)?;
|
globals.set("MakeDir", lua.create_function(make_dir)?)?;
|
||||||
|
globals.set("RemoveDir", lua.create_function(remove_dir)?)?;
|
||||||
|
|
||||||
// console
|
// console
|
||||||
globals.set("ConPrintf", lua.create_function(console_printf)?)?;
|
globals.set("ConPrintf", lua.create_function(console_printf)?)?;
|
||||||
@@ -61,6 +63,7 @@ pub fn register_globals(lua: &Lua) -> LuaResult<()> {
|
|||||||
// general
|
// general
|
||||||
globals.set("GetTime", lua.create_function(get_time)?)?;
|
globals.set("GetTime", lua.create_function(get_time)?)?;
|
||||||
globals.set("StripEscapes", lua.create_function(strip_escapes)?)?;
|
globals.set("StripEscapes", lua.create_function(strip_escapes)?)?;
|
||||||
|
globals.set("Exit", lua.create_function(exit)?)?;
|
||||||
globals.set("Restart", lua.create_function(restart)?)?;
|
globals.set("Restart", lua.create_function(restart)?)?;
|
||||||
globals.set("OpenURL", lua.create_function(open_url)?)?;
|
globals.set("OpenURL", lua.create_function(open_url)?)?;
|
||||||
globals.set("RenderInit", lua.create_function(render_init)?)?;
|
globals.set("RenderInit", lua.create_function(render_init)?)?;
|
||||||
@@ -128,6 +131,15 @@ fn strip_escapes(_: &Lua, text: String) -> LuaResult<String> {
|
|||||||
Ok(PoBString(&text).strip_escapes())
|
Ok(PoBString(&text).strip_escapes())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn exit(l: &Lua, exit_msg: Option<String>) -> LuaResult<()> {
|
||||||
|
if let Some(exit_msg) = exit_msg {
|
||||||
|
println!("{exit_msg}");
|
||||||
|
}
|
||||||
|
let ctx = l.app_data_ref::<&'static Context>().unwrap();
|
||||||
|
*ctx.should_exit() = true;
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
fn restart(l: &Lua, _: ()) -> LuaResult<()> {
|
fn restart(l: &Lua, _: ()) -> LuaResult<()> {
|
||||||
let ctx = l.app_data_ref::<&'static Context>().unwrap();
|
let ctx = l.app_data_ref::<&'static Context>().unwrap();
|
||||||
*ctx.needs_restart() = true;
|
*ctx.needs_restart() = true;
|
||||||
|
|||||||
@@ -47,3 +47,15 @@ pub fn make_dir(l: &Lua, path: String) -> LuaResult<MultiValue> {
|
|||||||
Err(err) => Ok((Value::Nil, err.to_string()).into_lua_multi(l)?),
|
Err(err) => Ok((Value::Nil, err.to_string()).into_lua_multi(l)?),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn remove_dir(l: &Lua, (path, recursive): (String, Option<bool>)) -> LuaResult<MultiValue> {
|
||||||
|
let result = if recursive.unwrap_or(false) {
|
||||||
|
fs::remove_dir_all(&path)
|
||||||
|
} else {
|
||||||
|
fs::remove_dir(&path)
|
||||||
|
};
|
||||||
|
match result {
|
||||||
|
Ok(_) => Ok(Value::Boolean(true).into_lua_multi(l)?),
|
||||||
|
Err(err) => Ok((Value::Nil, err.to_string()).into_lua_multi(l)?),
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -484,8 +484,15 @@ fn build_layout_job<'a>(
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// TODO: check how PoB determines font size
|
// NOTE: This is just an approximation and was chosen based on how it looks.
|
||||||
let font_size = (line_height - 2).clamp(11, 32) as f32;
|
//
|
||||||
|
// PoB uses pre-rendered font atlases of discrete sizes and selects the appropriate
|
||||||
|
// atlas based on the provided height. Rusty-PoB dynamically renders fonts to a
|
||||||
|
// cached font atlas to support the selection of arbitrary sizes.
|
||||||
|
//
|
||||||
|
// TODO: font size in some dropdowns is too small, e.g. socket group selection in
|
||||||
|
// 'Calcs' tab
|
||||||
|
let font_size = (line_height - 2).max(1) as f32;
|
||||||
|
|
||||||
let mut job = LayoutJob::new(
|
let mut job = LayoutJob::new(
|
||||||
font_family,
|
font_family,
|
||||||
|
|||||||
+12
-2
@@ -29,6 +29,7 @@ pub struct AppState {
|
|||||||
pub fonts: Fonts,
|
pub fonts: Fonts,
|
||||||
pub texture_manager: WrappedTextureManager,
|
pub texture_manager: WrappedTextureManager,
|
||||||
pub script_dir: PathBuf,
|
pub script_dir: PathBuf,
|
||||||
|
pub should_exit: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl AppState {
|
impl AppState {
|
||||||
@@ -59,6 +60,7 @@ impl App {
|
|||||||
fonts: Fonts::new(pob_font_definitions()),
|
fonts: Fonts::new(pob_font_definitions()),
|
||||||
texture_manager: WrappedTextureManager::new(),
|
texture_manager: WrappedTextureManager::new(),
|
||||||
script_dir,
|
script_dir,
|
||||||
|
should_exit: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
let current_mode = if uses_custom_script_dir {
|
let current_mode = if uses_custom_script_dir {
|
||||||
@@ -188,8 +190,10 @@ impl ApplicationHandler<GraphicsContext> for App {
|
|||||||
) {
|
) {
|
||||||
match event {
|
match event {
|
||||||
WindowEvent::CloseRequested => {
|
WindowEvent::CloseRequested => {
|
||||||
self.handle_event(AppEvent::Exit);
|
self.state.should_exit = self.current_mode.can_exit(&mut self.state);
|
||||||
event_loop.exit();
|
if !self.state.should_exit {
|
||||||
|
self.state.window.request_redraw();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
WindowEvent::RedrawRequested => {
|
WindowEvent::RedrawRequested => {
|
||||||
profiling::scope!("RedrawRequested");
|
profiling::scope!("RedrawRequested");
|
||||||
@@ -200,6 +204,12 @@ impl ApplicationHandler<GraphicsContext> for App {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if self.state.should_exit {
|
||||||
|
self.handle_event(AppEvent::Exit);
|
||||||
|
event_loop.exit();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if self.needs_reconfigure {
|
if self.needs_reconfigure {
|
||||||
if let Some(ref mut gfx) = self.gfx_context {
|
if let Some(ref mut gfx) = self.gfx_context {
|
||||||
let size = gfx.window.inner_size();
|
let size = gfx.window.inner_size();
|
||||||
|
|||||||
+39
-9
@@ -11,7 +11,6 @@ use crate::{
|
|||||||
use flate2::read::GzDecoder;
|
use flate2::read::GzDecoder;
|
||||||
use parley::{FontFamily, GenericFamily};
|
use parley::{FontFamily, GenericFamily};
|
||||||
use regex::Regex;
|
use regex::Regex;
|
||||||
use std::time::{Duration, SystemTime, UNIX_EPOCH};
|
|
||||||
use std::{
|
use std::{
|
||||||
fs::{self},
|
fs::{self},
|
||||||
io::copy,
|
io::copy,
|
||||||
@@ -19,9 +18,15 @@ use std::{
|
|||||||
sync::mpsc::{self, Receiver, TryRecvError},
|
sync::mpsc::{self, Receiver, TryRecvError},
|
||||||
thread,
|
thread,
|
||||||
};
|
};
|
||||||
use ureq::http::Response;
|
use std::{
|
||||||
|
sync::LazyLock,
|
||||||
|
time::{Duration, SystemTime, UNIX_EPOCH},
|
||||||
|
};
|
||||||
|
use ureq::{Agent, http::Response};
|
||||||
|
|
||||||
const REPO_NAME: &str = "meehl/rusty-pob-manifest";
|
const REPO_NAME: &str = "meehl/rusty-pob-manifest";
|
||||||
|
static VERSION_RE: LazyLock<Regex> =
|
||||||
|
LazyLock::new(|| Regex::new(r"^(\d+)\.(\d+)\.(\d+)$").unwrap());
|
||||||
|
|
||||||
enum DownloadProgress {
|
enum DownloadProgress {
|
||||||
Percentage(f32), // percentage of total size (between 0 and 1)
|
Percentage(f32), // percentage of total size (between 0 and 1)
|
||||||
@@ -29,6 +34,7 @@ enum DownloadProgress {
|
|||||||
}
|
}
|
||||||
|
|
||||||
enum Progress {
|
enum Progress {
|
||||||
|
Status(String),
|
||||||
Download(DownloadProgress),
|
Download(DownloadProgress),
|
||||||
Complete,
|
Complete,
|
||||||
Error(anyhow::Error),
|
Error(anyhow::Error),
|
||||||
@@ -36,6 +42,7 @@ enum Progress {
|
|||||||
|
|
||||||
enum CurrentProgress {
|
enum CurrentProgress {
|
||||||
Starting,
|
Starting,
|
||||||
|
Status(String),
|
||||||
Download(DownloadProgress),
|
Download(DownloadProgress),
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -84,6 +91,9 @@ impl InstallMode {
|
|||||||
Ok(Progress::Download(progress)) => {
|
Ok(Progress::Download(progress)) => {
|
||||||
self.current_progress = CurrentProgress::Download(progress);
|
self.current_progress = CurrentProgress::Download(progress);
|
||||||
}
|
}
|
||||||
|
Ok(Progress::Status(msg)) => {
|
||||||
|
self.current_progress = CurrentProgress::Status(msg);
|
||||||
|
}
|
||||||
Ok(Progress::Complete) => {
|
Ok(Progress::Complete) => {
|
||||||
return Ok(Some(ModeTransition::PoB));
|
return Ok(Some(ModeTransition::PoB));
|
||||||
}
|
}
|
||||||
@@ -126,6 +136,7 @@ impl InstallMode {
|
|||||||
|
|
||||||
let progress_text = match &self.current_progress {
|
let progress_text = match &self.current_progress {
|
||||||
CurrentProgress::Starting => String::from("Starting download..."),
|
CurrentProgress::Starting => String::from("Starting download..."),
|
||||||
|
CurrentProgress::Status(msg) => msg.clone(),
|
||||||
CurrentProgress::Download(progress) => match progress {
|
CurrentProgress::Download(progress) => match progress {
|
||||||
DownloadProgress::Percentage(progress) => {
|
DownloadProgress::Percentage(progress) => {
|
||||||
let percent = (progress * 100.0) as u32;
|
let percent = (progress * 100.0) as u32;
|
||||||
@@ -175,16 +186,29 @@ fn install<P: AsRef<Path>>(
|
|||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
progress_tx.send(Progress::Status("Fetching compatibility info...".into()))?;
|
||||||
|
log::info!("Fetching compatibility info...");
|
||||||
let compatibility_info = fetch_compatibility_info(game)?;
|
let compatibility_info = fetch_compatibility_info(game)?;
|
||||||
|
|
||||||
|
progress_tx.send(Progress::Status("Resolving PoB version...".into()))?;
|
||||||
|
log::info!("Resolving supported PoB version...");
|
||||||
let needed_pob_version = highest_supported_pob_version(&compatibility_info, current_version)
|
let needed_pob_version = highest_supported_pob_version(&compatibility_info, current_version)
|
||||||
.ok_or_else(|| anyhow::anyhow!("Unable to determine supported PoB version"))?;
|
.ok_or_else(|| anyhow::anyhow!("Unable to determine supported PoB version"))?;
|
||||||
|
log::info!("Using PoB version: {needed_pob_version}");
|
||||||
|
|
||||||
|
progress_tx.send(Progress::Status("Downloading assets...".into()))?;
|
||||||
download_path_of_building(&target_dir, game, needed_pob_version, progress_tx)?;
|
download_path_of_building(&target_dir, game, needed_pob_version, progress_tx)?;
|
||||||
|
|
||||||
|
progress_tx.send(Progress::Status("Patching UpdateCheck...".into()))?;
|
||||||
|
log::info!("Patching UpdateCheck...");
|
||||||
replace_updatecheck(&target_dir)?;
|
replace_updatecheck(&target_dir)?;
|
||||||
|
|
||||||
|
progress_tx.send(Progress::Status("Finalizing installation...".into()))?;
|
||||||
|
log::info!("Finalizing installation...");
|
||||||
set_branch_and_platform(&target_dir)?;
|
set_branch_and_platform(&target_dir)?;
|
||||||
|
|
||||||
// write version file
|
|
||||||
fs::write(&version_file_path, env!("CARGO_PKG_VERSION")).unwrap();
|
fs::write(&version_file_path, env!("CARGO_PKG_VERSION")).unwrap();
|
||||||
|
log::info!("Installation complete.");
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
@@ -217,6 +241,9 @@ fn fetch_compatibility_info(game: Game) -> anyhow::Result<Vec<VersionReq>> {
|
|||||||
Ok(compatibility_table
|
Ok(compatibility_table
|
||||||
.pairs::<String, String>()
|
.pairs::<String, String>()
|
||||||
.filter_map(|p| p.ok())
|
.filter_map(|p| p.ok())
|
||||||
|
// filter out beta versions. beta version adds a suffix to the version string which is not
|
||||||
|
// matched by the version regex resulting in them being filtered out
|
||||||
|
.filter(|(pob_version, _)| VERSION_RE.is_match(pob_version))
|
||||||
.map(|(pob_version, min_req_rpob_ver)| VersionReq {
|
.map(|(pob_version, min_req_rpob_ver)| VersionReq {
|
||||||
pob_ver: pob_version,
|
pob_ver: pob_version,
|
||||||
min_rpob_ver: min_req_rpob_ver,
|
min_rpob_ver: min_req_rpob_ver,
|
||||||
@@ -340,8 +367,6 @@ fn download_path_of_building<P: AsRef<Path>>(
|
|||||||
|
|
||||||
/// Replaces UpdateCheck with rusty-path-of-building's modified version
|
/// Replaces UpdateCheck with rusty-path-of-building's modified version
|
||||||
fn replace_updatecheck<P: AsRef<Path>>(target_dir: P) -> anyhow::Result<()> {
|
fn replace_updatecheck<P: AsRef<Path>>(target_dir: P) -> anyhow::Result<()> {
|
||||||
log::info!("Downloading modified UpdateCheck.lua script...");
|
|
||||||
|
|
||||||
download_file(
|
download_file(
|
||||||
&format!(
|
&format!(
|
||||||
"https://raw.githubusercontent.com/{REPO_NAME}/main/{}",
|
"https://raw.githubusercontent.com/{REPO_NAME}/main/{}",
|
||||||
@@ -486,9 +511,16 @@ fn http_get_with_backoff(url: &str) -> anyhow::Result<Response<ureq::Body>> {
|
|||||||
let mut attempt = 0;
|
let mut attempt = 0;
|
||||||
let mut backoff_secs: u64 = 2;
|
let mut backoff_secs: u64 = 2;
|
||||||
|
|
||||||
|
let config = Agent::config_builder()
|
||||||
|
.timeout_global(Some(Duration::from_secs(10)))
|
||||||
|
.build();
|
||||||
|
|
||||||
|
let agent: Agent = config.into();
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
attempt += 1;
|
attempt += 1;
|
||||||
let resp_result = ureq::get(url)
|
let resp_result = agent
|
||||||
|
.get(url)
|
||||||
.header("User-Agent", "rusty-path-of-building")
|
.header("User-Agent", "rusty-path-of-building")
|
||||||
.call();
|
.call();
|
||||||
|
|
||||||
@@ -544,10 +576,8 @@ fn http_get_with_backoff(url: &str) -> anyhow::Result<Response<ureq::Body>> {
|
|||||||
|
|
||||||
/// Compares two SemVer versions and returns true if v2 is higher or equal than v1
|
/// Compares two SemVer versions and returns true if v2 is higher or equal than v1
|
||||||
fn is_higher_version(v1: &str, v2: &str) -> anyhow::Result<bool> {
|
fn is_higher_version(v1: &str, v2: &str) -> anyhow::Result<bool> {
|
||||||
let re = Regex::new(r"^(\d+)\.(\d+)\.(\d+)$").unwrap();
|
|
||||||
|
|
||||||
let parse_version = |v: &str| -> anyhow::Result<(u32, u32, u32)> {
|
let parse_version = |v: &str| -> anyhow::Result<(u32, u32, u32)> {
|
||||||
let caps = re
|
let caps = VERSION_RE
|
||||||
.captures(v)
|
.captures(v)
|
||||||
.ok_or_else(|| anyhow::anyhow!("Invalid semver format: {}", v))?;
|
.ok_or_else(|| anyhow::anyhow!("Invalid semver format: {}", v))?;
|
||||||
|
|
||||||
|
|||||||
+17
@@ -52,6 +52,7 @@ pub struct Context {
|
|||||||
current_working_dir: Cell<*mut PathBuf>,
|
current_working_dir: Cell<*mut PathBuf>,
|
||||||
layers: Cell<*mut Layers>,
|
layers: Cell<*mut Layers>,
|
||||||
needs_restart: Cell<*mut bool>,
|
needs_restart: Cell<*mut bool>,
|
||||||
|
should_exit: Cell<*mut bool>,
|
||||||
is_dpi_aware: Cell<*mut bool>,
|
is_dpi_aware: Cell<*mut bool>,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -66,6 +67,7 @@ impl Context {
|
|||||||
current_working_dir: Cell::new(std::ptr::null_mut()),
|
current_working_dir: Cell::new(std::ptr::null_mut()),
|
||||||
layers: Cell::new(std::ptr::null_mut()),
|
layers: Cell::new(std::ptr::null_mut()),
|
||||||
needs_restart: Cell::new(std::ptr::null_mut()),
|
needs_restart: Cell::new(std::ptr::null_mut()),
|
||||||
|
should_exit: Cell::new(std::ptr::null_mut()),
|
||||||
is_dpi_aware: Cell::new(std::ptr::null_mut()),
|
is_dpi_aware: Cell::new(std::ptr::null_mut()),
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
@@ -80,6 +82,7 @@ impl Context {
|
|||||||
.set(&mut ctx.pob.current_working_dir);
|
.set(&mut ctx.pob.current_working_dir);
|
||||||
self.layers.set(&mut ctx.pob.layers);
|
self.layers.set(&mut ctx.pob.layers);
|
||||||
self.needs_restart.set(&mut ctx.pob.needs_restart);
|
self.needs_restart.set(&mut ctx.pob.needs_restart);
|
||||||
|
self.should_exit.set(&mut ctx.app.should_exit);
|
||||||
self.is_dpi_aware.set(&mut ctx.pob.is_dpi_aware);
|
self.is_dpi_aware.set(&mut ctx.pob.is_dpi_aware);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -92,6 +95,7 @@ impl Context {
|
|||||||
self.current_working_dir.set(std::ptr::null_mut());
|
self.current_working_dir.set(std::ptr::null_mut());
|
||||||
self.layers.set(std::ptr::null_mut());
|
self.layers.set(std::ptr::null_mut());
|
||||||
self.needs_restart.set(std::ptr::null_mut());
|
self.needs_restart.set(std::ptr::null_mut());
|
||||||
|
self.should_exit.set(std::ptr::null_mut());
|
||||||
self.is_dpi_aware.set(std::ptr::null_mut());
|
self.is_dpi_aware.set(std::ptr::null_mut());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -103,6 +107,7 @@ impl Context {
|
|||||||
ctx_accessor!(current_working_dir: &mut PathBuf);
|
ctx_accessor!(current_working_dir: &mut PathBuf);
|
||||||
ctx_accessor!(layers: &mut Layers);
|
ctx_accessor!(layers: &mut Layers);
|
||||||
ctx_accessor!(needs_restart: &mut bool);
|
ctx_accessor!(needs_restart: &mut bool);
|
||||||
|
ctx_accessor!(should_exit: &mut bool);
|
||||||
ctx_accessor!(is_dpi_aware: &mut bool);
|
ctx_accessor!(is_dpi_aware: &mut bool);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -259,6 +264,18 @@ impl LuaInstance {
|
|||||||
list_func.call::<Table>(())
|
list_func.call::<Table>(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn can_exit(&self, pob_ctx: &mut PoBContext) -> bool {
|
||||||
|
let ctx = self.lua.app_data_ref::<&'static Context>().unwrap();
|
||||||
|
ctx.set(pob_ctx);
|
||||||
|
|
||||||
|
let can_exit = get_callback(&self.lua, "CanExit")
|
||||||
|
.and_then(|f| f.call(()))
|
||||||
|
.unwrap_or(true);
|
||||||
|
|
||||||
|
ctx.clear();
|
||||||
|
can_exit
|
||||||
|
}
|
||||||
|
|
||||||
pub fn handle_event(&self, event: PoBEvent, pob_ctx: &mut PoBContext) -> LuaResult<()> {
|
pub fn handle_event(&self, event: PoBEvent, pob_ctx: &mut PoBContext) -> LuaResult<()> {
|
||||||
profiling::scope!("handle_event", format!("{}", event));
|
profiling::scope!("handle_event", format!("{}", event));
|
||||||
|
|
||||||
|
|||||||
@@ -65,4 +65,11 @@ impl AppMode {
|
|||||||
AppMode::PoB(mode) => mode.handle_event(state, event),
|
AppMode::PoB(mode) => mode.handle_event(state, event),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn can_exit(&mut self, state: &mut AppState) -> bool {
|
||||||
|
match self {
|
||||||
|
AppMode::Install(_) => true,
|
||||||
|
AppMode::PoB(mode) => mode.can_exit(state),
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -147,6 +147,11 @@ impl PoBMode {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn can_exit(&mut self, app_state: &mut AppState) -> bool {
|
||||||
|
let mut ctx = PoBContext::new(app_state, &mut self.state);
|
||||||
|
self.lua_instance.can_exit(&mut ctx)
|
||||||
|
}
|
||||||
|
|
||||||
fn reset_viewport(&mut self, size: LogicalSize<u32>) {
|
fn reset_viewport(&mut self, size: LogicalSize<u32>) {
|
||||||
self.state
|
self.state
|
||||||
.layers
|
.layers
|
||||||
|
|||||||
Reference in new issue
Block a user