Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3eacd43837 | ||
|
|
523d5ffe29 | ||
|
|
e18623edb4 | ||
|
|
1812edcbe9 | ||
|
|
df06c8f9c6 | ||
|
|
ae6a24f82c | ||
|
|
0066a05e13 | ||
|
|
3d8143c4d1 | ||
|
|
a3ef4b39d0 | ||
|
|
f48ab50633 | ||
|
|
b86486d5aa | ||
|
|
1f1a331cc2 | ||
|
|
27b93c4a9d | ||
|
|
c95514036f |
No files matched your search
@@ -0,0 +1,11 @@
|
|||||||
|
# Contributing to Rusty Path Of Building
|
||||||
|
|
||||||
|
## Reporting bugs
|
||||||
|
- Ensure the bug was not already reported by searching through existing [issues](https://github.com/meehl/rusty-path-of-building/issues).
|
||||||
|
- If the bug can also be reproduced with the official runtime (e.g. by running through wine), please open an issue in the [PoB1](https://github.com/PathOfBuildingCommunity/PathOfBuilding) or [PoB2](https://github.com/PathOfBuildingCommunity/PathOfBuilding-PoE2) repo instead. If you're unsure, feel free to just open it here.
|
||||||
|
- If possible, use the bug report template to create the issue and provide as much information as possible.
|
||||||
|
|
||||||
|
## Contributing code
|
||||||
|
- Get familiar with the code base before you start. I'll try to add more documentation providing a high-level overview of the architecture in the future. Until then, feel free to reach out through [Discussions](https://github.com/meehl/rusty-path-of-building/discussions) if you have any questions.
|
||||||
|
- If you intend to work on the API functions, also check out the [SimpleGraphic](https://github.com/PathOfBuildingCommunity/PathOfBuilding-SimpleGraphic) code base. A great place to ask questions about it is the PoB dev discord server. [Here](https://github.com/PathOfBuildingCommunity/PathOfBuilding-SimpleGraphic) is more info on how to join.
|
||||||
|
- Ensure the PR description clearly describes the problem and solution. Include the relevant issue number if applicable.
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
---
|
||||||
|
name: Bug report
|
||||||
|
about: Create a report to help us improve
|
||||||
|
title: ''
|
||||||
|
labels: ''
|
||||||
|
assignees: ''
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
**Describe the bug**
|
||||||
|
A description of what the bug is.
|
||||||
|
|
||||||
|
**To Reproduce**
|
||||||
|
Steps to reproduce the behavior:
|
||||||
|
1. Go to '...'
|
||||||
|
2. Click on '....'
|
||||||
|
3. Scroll down to '....'
|
||||||
|
4. See error
|
||||||
|
|
||||||
|
**Expected behavior**
|
||||||
|
A description of what you expected to happen.
|
||||||
|
|
||||||
|
**System information:**
|
||||||
|
- OS: [e.g. Linux, Windows, macOS]
|
||||||
|
- Desktop Environment/Compositor: [e.g. KDE, Gnome, sway, etc.] (only on Linux)
|
||||||
|
- Rusty Path of Building Version: [e.g. v0.2.8]
|
||||||
|
- Path of Building Version: [e.g. PoB1 v2.59.0 or PoB2 v0.12.2]
|
||||||
|
|
||||||
|
**Additional context**
|
||||||
|
Add any other context about the problem here. Feel free to add screenshots or any other info like PoB build codes if relevant.
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
blank_issues_enabled: yes
|
||||||
|
contact_links:
|
||||||
|
- name: GitHub Discussions
|
||||||
|
url: https://github.com/meehl/rusty-path-of-building/discussions
|
||||||
|
about: Please ask questions unrelated to actual bugs/issues here.
|
||||||
+17
-1
@@ -2,6 +2,21 @@
|
|||||||
|
|
||||||
## [Unreleased] - ReleaseDate
|
## [Unreleased] - ReleaseDate
|
||||||
|
|
||||||
|
## [0.2.9] - 2025-12-03
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- Implement UI scale overriding
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- Reduce CPU usage while window is unfocused and not hovered over
|
||||||
|
- Download highest compatible PoB version instead of latest version
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- Register `AbortSubscript` function under right name
|
||||||
|
|
||||||
## [0.2.8] - 2025-11-07
|
## [0.2.8] - 2025-11-07
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
@@ -118,8 +133,9 @@
|
|||||||
- First release
|
- First release
|
||||||
|
|
||||||
<!-- next-url -->
|
<!-- next-url -->
|
||||||
[Unreleased]: https://github.com/meehl/rusty-path-of-building/compare/v0.2.8...HEAD
|
[Unreleased]: https://github.com/meehl/rusty-path-of-building/compare/v0.2.9...HEAD
|
||||||
|
|
||||||
|
[0.2.9]: https://github.com/meehl/rusty-path-of-building/compare/v0.2.8...v0.2.9
|
||||||
[0.2.8]: https://github.com/meehl/rusty-path-of-building/compare/v0.2.7...v0.2.8
|
[0.2.8]: https://github.com/meehl/rusty-path-of-building/compare/v0.2.7...v0.2.8
|
||||||
[0.2.7]: https://github.com/meehl/rusty-path-of-building/compare/v0.2.6...v0.2.7
|
[0.2.7]: https://github.com/meehl/rusty-path-of-building/compare/v0.2.6...v0.2.7
|
||||||
[0.2.6]: https://github.com/meehl/rusty-path-of-building/compare/v0.2.5...v0.2.6
|
[0.2.6]: https://github.com/meehl/rusty-path-of-building/compare/v0.2.5...v0.2.6
|
||||||
|
|||||||
Generated
+1
-1
@@ -2506,7 +2506,7 @@ checksum = "b39cdef0fa800fc44525c84ccb54a029961a8215f9619753635a9c0d2538d46d"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rusty-path-of-building"
|
name = "rusty-path-of-building"
|
||||||
version = "0.2.8"
|
version = "0.2.9"
|
||||||
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.8"
|
version = "0.2.9"
|
||||||
edition = "2024"
|
edition = "2024"
|
||||||
publish = false
|
publish = false
|
||||||
|
|
||||||
|
|||||||
@@ -43,5 +43,4 @@ Please refer to the [Lua documentation](https://www.lua.org/manual/5.1/manual.ht
|
|||||||
|
|
||||||
## Known Issues
|
## Known Issues
|
||||||
|
|
||||||
- Overriding UI scaling through the options is currently not implemented.
|
|
||||||
- If automatic updates fail, navigate to `~/.local/share/RustyPathOfBuilding{1,2}/` and delete both the `rpob.version` file and the `Update` directory. This will force a complete re-download of PoB's latest assets and Lua code on the next startup. (Note: Third-party backends, like this project, face challenges supporting PoB's update mechanism. To make it work, fragile workarounds had to be implemented that can break unexpectedly)
|
- If automatic updates fail, navigate to `~/.local/share/RustyPathOfBuilding{1,2}/` and delete both the `rpob.version` file and the `Update` directory. This will force a complete re-download of PoB's latest assets and Lua code on the next startup. (Note: Third-party backends, like this project, face challenges supporting PoB's update mechanism. To make it work, fragile workarounds had to be implemented that can break unexpectedly)
|
||||||
@@ -646,7 +646,7 @@ static int l_zipFile_Read(lua_State* L)
|
|||||||
if (n < 1) {
|
if (n < 1) {
|
||||||
luaL_error(L, "Usage: zipFile:Read(count) or zipFile:read(\"*a\")");
|
luaL_error(L, "Usage: zipFile:Read(count) or zipFile:read(\"*a\")");
|
||||||
}
|
}
|
||||||
int count;
|
int count = 0;
|
||||||
if (lua_isnumber(L, 1)) {
|
if (lua_isnumber(L, 1)) {
|
||||||
count = lua_tointeger(L, 1);
|
count = lua_tointeger(L, 1);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -390,9 +390,8 @@ unsafe extern "C-unwind" fn draw_string(state: *mut ffi::lua_State) -> c_int {
|
|||||||
ctx.layers().set_draw_color(last_segment.color);
|
ctx.layers().set_draw_color(last_segment.color);
|
||||||
}
|
}
|
||||||
|
|
||||||
let layout = ctx.fonts().layout(job, ctx.window().scale_factor);
|
let layout = ctx.fonts().layout(job, ctx.window().scale_factor());
|
||||||
ctx
|
ctx.layers()
|
||||||
.layers()
|
|
||||||
.draw_text(position, layout, is_absolute_position);
|
.draw_text(position, layout, is_absolute_position);
|
||||||
|
|
||||||
0
|
0
|
||||||
@@ -415,9 +414,7 @@ unsafe extern "C-unwind" fn get_string_width(state: *mut ffi::lua_State) -> c_in
|
|||||||
};
|
};
|
||||||
|
|
||||||
let job = build_layout_job(text, Srgba::WHITE, font_type, line_height, None);
|
let job = build_layout_job(text, Srgba::WHITE, font_type, line_height, None);
|
||||||
let width = ctx
|
let width = ctx.fonts().get_text_width(job, ctx.window().scale_factor());
|
||||||
.fonts()
|
|
||||||
.get_text_width(job, ctx.window().scale_factor);
|
|
||||||
|
|
||||||
unsafe { ffi::lua_pushnumber(state, width as f64) };
|
unsafe { ffi::lua_pushnumber(state, width as f64) };
|
||||||
1
|
1
|
||||||
@@ -436,7 +433,7 @@ fn get_index_at_cur(
|
|||||||
let index = ctx.fonts().get_text_index_at_cursor(
|
let index = ctx.fonts().get_text_index_at_cursor(
|
||||||
job,
|
job,
|
||||||
Point::new(cur_x, cur_y),
|
Point::new(cur_x, cur_y),
|
||||||
ctx.window().scale_factor,
|
ctx.window().scale_factor(),
|
||||||
);
|
);
|
||||||
|
|
||||||
// convert to lua's 1-based indexing
|
// convert to lua's 1-based indexing
|
||||||
|
|||||||
+14
-6
@@ -18,7 +18,7 @@ pub fn get_screen_size(l: &Lua, _: ()) -> LuaResult<(u32, u32)> {
|
|||||||
|
|
||||||
pub fn get_screen_scale(l: &Lua, _: ()) -> LuaResult<f32> {
|
pub fn get_screen_scale(l: &Lua, _: ()) -> LuaResult<f32> {
|
||||||
let ctx = l.app_data_ref::<&'static Context>().unwrap();
|
let ctx = l.app_data_ref::<&'static Context>().unwrap();
|
||||||
let scale_factor = ctx.window().scale_factor;
|
let scale_factor = ctx.window().scale_factor();
|
||||||
Ok(scale_factor)
|
Ok(scale_factor)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -34,12 +34,20 @@ pub fn set_foreground(l: &Lua, _: ()) -> LuaResult<()> {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn set_dpi_scale_override(_: &Lua, _percent: i32) -> LuaResult<()> {
|
pub fn set_dpi_scale_override(l: &Lua, percent: i32) -> LuaResult<()> {
|
||||||
// TODO:
|
let socket = l.app_data_ref::<&'static Context>().unwrap();
|
||||||
|
match percent {
|
||||||
|
0 => socket.window().scale_factor_override = None,
|
||||||
|
p if p > 0 => socket.window().scale_factor_override = Some(p as f32 / 100.0),
|
||||||
|
_ => {}
|
||||||
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_dpi_scale_override(_: &Lua, _: ()) -> LuaResult<i32> {
|
pub fn get_dpi_scale_override(l: &Lua, _: ()) -> LuaResult<i32> {
|
||||||
// TODO:
|
let socket = l.app_data_ref::<&'static Context>().unwrap();
|
||||||
Ok(0)
|
match socket.window().scale_factor_override {
|
||||||
|
Some(scale_factor) => Ok((scale_factor * 100.0) as i32),
|
||||||
|
None => Ok(0),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
+66
-29
@@ -19,6 +19,7 @@ use winit::{
|
|||||||
|
|
||||||
struct FrameOutput {
|
struct FrameOutput {
|
||||||
pub render_job: RenderJob,
|
pub render_job: RenderJob,
|
||||||
|
pub should_continue: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct AppState {
|
pub struct AppState {
|
||||||
@@ -31,7 +32,7 @@ pub struct AppState {
|
|||||||
impl AppState {
|
impl AppState {
|
||||||
fn set_mouse_pos(&mut self, pos: PhysicalPoint<f32>) {
|
fn set_mouse_pos(&mut self, pos: PhysicalPoint<f32>) {
|
||||||
self.input
|
self.input
|
||||||
.set_mouse_pos(pos.to_logical(self.window.scale_factor));
|
.set_mouse_pos(pos.to_logical(self.window.scale_factor()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -39,6 +40,7 @@ pub struct App {
|
|||||||
gfx_context: Option<GraphicsContext>,
|
gfx_context: Option<GraphicsContext>,
|
||||||
state: AppState,
|
state: AppState,
|
||||||
tessellator: Tessellator,
|
tessellator: Tessellator,
|
||||||
|
needs_reconfigure: bool,
|
||||||
force_render: bool,
|
force_render: bool,
|
||||||
current_mode: AppMode,
|
current_mode: AppMode,
|
||||||
}
|
}
|
||||||
@@ -54,7 +56,8 @@ impl App {
|
|||||||
texture_manager: WrappedTextureManager::new(),
|
texture_manager: WrappedTextureManager::new(),
|
||||||
},
|
},
|
||||||
tessellator: Tessellator::default(),
|
tessellator: Tessellator::default(),
|
||||||
force_render: false,
|
needs_reconfigure: true,
|
||||||
|
force_render: true,
|
||||||
current_mode: AppMode::Install(InstallMode::new()),
|
current_mode: AppMode::Install(InstallMode::new()),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -92,12 +95,10 @@ impl App {
|
|||||||
{
|
{
|
||||||
RenderJob::Skip
|
RenderJob::Skip
|
||||||
} else {
|
} else {
|
||||||
self.force_render = false;
|
|
||||||
|
|
||||||
let meshes = self.tessellator.convert_clipped_primitives(
|
let meshes = self.tessellator.convert_clipped_primitives(
|
||||||
mode_output.primitives,
|
mode_output.primitives,
|
||||||
font_atlas_size,
|
font_atlas_size,
|
||||||
self.state.window.scale_factor,
|
self.state.window.scale_factor(),
|
||||||
);
|
);
|
||||||
|
|
||||||
RenderJob::Render {
|
RenderJob::Render {
|
||||||
@@ -106,7 +107,10 @@ impl App {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
Ok(FrameOutput { render_job })
|
Ok(FrameOutput {
|
||||||
|
render_job,
|
||||||
|
should_continue: mode_output.should_continue,
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
fn handle_event(&mut self, event: AppEvent) {
|
fn handle_event(&mut self, event: AppEvent) {
|
||||||
@@ -154,7 +158,6 @@ impl ApplicationHandler<GraphicsContext> for App {
|
|||||||
if let Err(err) = self.create_window(event_loop) {
|
if let Err(err) = self.create_window(event_loop) {
|
||||||
log::error!("{err}");
|
log::error!("{err}");
|
||||||
event_loop.exit();
|
event_loop.exit();
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -178,26 +181,50 @@ impl ApplicationHandler<GraphicsContext> for App {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let render_job = match self.frame() {
|
if self.needs_reconfigure {
|
||||||
Ok(FrameOutput { render_job }) => render_job,
|
if let Some(ref mut gfx) = self.gfx_context {
|
||||||
Err(err) => {
|
let size = gfx.window.inner_size();
|
||||||
log::error!("{err}");
|
gfx.resize(size.width, size.height);
|
||||||
event_loop.exit();
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
};
|
self.needs_reconfigure = false;
|
||||||
|
// Render at least one frame after reconfigure
|
||||||
|
self.force_render = true;
|
||||||
|
}
|
||||||
|
|
||||||
if let Some(ref mut gfx) = self.gfx_context {
|
let is_focused = self.state.window.is_focused;
|
||||||
match gfx.render(render_job) {
|
let is_hovered = self.state.window.is_hovered;
|
||||||
Ok(_) => {}
|
let should_render = is_focused || is_hovered || self.force_render;
|
||||||
// Reconfigure the surface if it's lost or outdated
|
|
||||||
Err(wgpu::SurfaceError::Lost | wgpu::SurfaceError::Outdated) => {
|
if should_render {
|
||||||
let size = gfx.window.inner_size();
|
let FrameOutput {
|
||||||
gfx.resize(size.width, size.height);
|
render_job,
|
||||||
self.force_render = true;
|
should_continue,
|
||||||
}
|
} = match self.frame() {
|
||||||
|
Ok(frame_output) => frame_output,
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
log::error!("Unable to render: {err}");
|
log::error!("{err}");
|
||||||
|
event_loop.exit();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
if let Some(ref mut gfx) = self.gfx_context {
|
||||||
|
match gfx.render(render_job, self.state.window.scale_factor()) {
|
||||||
|
Ok(_) => {
|
||||||
|
self.force_render = should_continue;
|
||||||
|
|
||||||
|
if is_focused || is_hovered || should_continue {
|
||||||
|
self.state.window.request_redraw();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Reconfigure the surface if it's lost or outdated
|
||||||
|
Err(wgpu::SurfaceError::Lost | wgpu::SurfaceError::Outdated) => {
|
||||||
|
self.needs_reconfigure = true;
|
||||||
|
self.state.window.request_redraw();
|
||||||
|
}
|
||||||
|
Err(err) => {
|
||||||
|
log::error!("Unable to render: {err}");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -205,14 +232,17 @@ impl ApplicationHandler<GraphicsContext> for App {
|
|||||||
profiling::finish_frame!();
|
profiling::finish_frame!();
|
||||||
}
|
}
|
||||||
WindowEvent::Resized(size) => {
|
WindowEvent::Resized(size) => {
|
||||||
if let Some(ref mut gfx) = self.gfx_context {
|
|
||||||
gfx.resize(size.width, size.height);
|
|
||||||
self.force_render = true;
|
|
||||||
}
|
|
||||||
self.state.window.size = PhysicalSize::new(size.width, size.height);
|
self.state.window.size = PhysicalSize::new(size.width, size.height);
|
||||||
|
self.needs_reconfigure = true;
|
||||||
|
}
|
||||||
|
WindowEvent::Focused(focused) => {
|
||||||
|
self.state.window.is_focused = focused;
|
||||||
|
if focused {
|
||||||
|
self.state.window.request_redraw();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
WindowEvent::ScaleFactorChanged { scale_factor, .. } => {
|
WindowEvent::ScaleFactorChanged { scale_factor, .. } => {
|
||||||
self.state.window.scale_factor = scale_factor as f32;
|
self.state.window.set_scale_factor(scale_factor as f32);
|
||||||
}
|
}
|
||||||
WindowEvent::KeyboardInput {
|
WindowEvent::KeyboardInput {
|
||||||
event:
|
event:
|
||||||
@@ -265,6 +295,13 @@ impl ApplicationHandler<GraphicsContext> for App {
|
|||||||
let pos = PhysicalPoint::new(position.x as f32, position.y as f32);
|
let pos = PhysicalPoint::new(position.x as f32, position.y as f32);
|
||||||
self.state.set_mouse_pos(pos);
|
self.state.set_mouse_pos(pos);
|
||||||
}
|
}
|
||||||
|
WindowEvent::CursorEntered { .. } => {
|
||||||
|
self.state.window.is_hovered = true;
|
||||||
|
self.state.window.request_redraw();
|
||||||
|
}
|
||||||
|
WindowEvent::CursorLeft { .. } => {
|
||||||
|
self.state.window.is_hovered = false;
|
||||||
|
}
|
||||||
WindowEvent::MouseWheel { delta, .. } => {
|
WindowEvent::MouseWheel { delta, .. } => {
|
||||||
let delta = match delta {
|
let delta = match delta {
|
||||||
MouseScrollDelta::LineDelta(_, y) => y,
|
MouseScrollDelta::LineDelta(_, y) => y,
|
||||||
|
|||||||
+4
-1
@@ -9,7 +9,10 @@ pub struct Args {
|
|||||||
#[arg(value_enum)]
|
#[arg(value_enum)]
|
||||||
pub game: Game,
|
pub game: Game,
|
||||||
|
|
||||||
pub build_path: Option<String>,
|
#[arg(
|
||||||
|
help = "URL of build to import on startup. Needs to use custom protocol schema, e.g. `pob://pobbin/<id>`"
|
||||||
|
)]
|
||||||
|
pub import_url: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, ValueEnum)]
|
#[derive(Debug, Clone, ValueEnum)]
|
||||||
|
|||||||
+8
-7
@@ -144,11 +144,13 @@ impl GraphicsContext {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn render(&mut self, render_job: RenderJob) -> Result<(), wgpu::SurfaceError> {
|
pub fn render(
|
||||||
|
&mut self,
|
||||||
|
render_job: RenderJob,
|
||||||
|
scale_factor: f32,
|
||||||
|
) -> Result<(), wgpu::SurfaceError> {
|
||||||
profiling::scope!("render");
|
profiling::scope!("render");
|
||||||
|
|
||||||
self.window.request_redraw();
|
|
||||||
|
|
||||||
if !self.is_surface_configured {
|
if !self.is_surface_configured {
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
@@ -174,7 +176,6 @@ impl GraphicsContext {
|
|||||||
} = render_job
|
} = render_job
|
||||||
{
|
{
|
||||||
let screen_size = PhysicalSize::new(self.config.width, self.config.height);
|
let screen_size = PhysicalSize::new(self.config.width, self.config.height);
|
||||||
let pixels_per_point = self.window.as_ref().scale_factor() as f32;
|
|
||||||
|
|
||||||
// upload new textures
|
// upload new textures
|
||||||
self.renderer
|
self.renderer
|
||||||
@@ -186,7 +187,7 @@ impl GraphicsContext {
|
|||||||
&self.queue,
|
&self.queue,
|
||||||
&meshes,
|
&meshes,
|
||||||
screen_size,
|
screen_size,
|
||||||
pixels_per_point,
|
scale_factor,
|
||||||
);
|
);
|
||||||
|
|
||||||
let rpass = encoder.begin_render_pass(&wgpu::RenderPassDescriptor {
|
let rpass = encoder.begin_render_pass(&wgpu::RenderPassDescriptor {
|
||||||
@@ -214,10 +215,10 @@ impl GraphicsContext {
|
|||||||
&mut rpass.forget_lifetime(),
|
&mut rpass.forget_lifetime(),
|
||||||
&meshes,
|
&meshes,
|
||||||
screen_size,
|
screen_size,
|
||||||
pixels_per_point,
|
scale_factor,
|
||||||
);
|
);
|
||||||
|
|
||||||
self.renderer.free_textures(&textures_delta)
|
self.renderer.free_textures(&textures_delta);
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|||||||
+214
-8
@@ -7,7 +7,6 @@ use crate::{
|
|||||||
mode::{AppEvent, ModeFrameOutput, ModeTransition},
|
mode::{AppEvent, ModeFrameOutput, ModeTransition},
|
||||||
renderer::primitives::{ClippedPrimitive, DrawPrimitive, TextPrimitive},
|
renderer::primitives::{ClippedPrimitive, DrawPrimitive, TextPrimitive},
|
||||||
};
|
};
|
||||||
use anyhow::bail;
|
|
||||||
use flate2::read::GzDecoder;
|
use flate2::read::GzDecoder;
|
||||||
use parley::{FontFamily, GenericFamily};
|
use parley::{FontFamily, GenericFamily};
|
||||||
use regex::Regex;
|
use regex::Regex;
|
||||||
@@ -73,6 +72,7 @@ impl InstallMode {
|
|||||||
Ok(ModeFrameOutput {
|
Ok(ModeFrameOutput {
|
||||||
primitives,
|
primitives,
|
||||||
can_elide: false,
|
can_elide: false,
|
||||||
|
should_continue: true,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -137,7 +137,7 @@ impl InstallMode {
|
|||||||
};
|
};
|
||||||
job.append(&progress_text, Srgba::WHITE);
|
job.append(&progress_text, Srgba::WHITE);
|
||||||
|
|
||||||
let layout = app_state.fonts.layout(job, app_state.window.scale_factor);
|
let layout = app_state.fonts.layout(job, app_state.window.scale_factor());
|
||||||
|
|
||||||
// center text vertically and horizontally
|
// center text vertically and horizontally
|
||||||
let screen_size = app_state.window.logical_size().cast::<f32>();
|
let screen_size = app_state.window.logical_size().cast::<f32>();
|
||||||
@@ -160,10 +160,10 @@ fn install<P: AsRef<Path>>(
|
|||||||
progress_tx: &mpsc::Sender<Progress>,
|
progress_tx: &mpsc::Sender<Progress>,
|
||||||
) -> anyhow::Result<()> {
|
) -> anyhow::Result<()> {
|
||||||
// Skip installation if version file exists
|
// Skip installation if version file exists
|
||||||
|
let current_version = env!("CARGO_PKG_VERSION");
|
||||||
let version_file_path = target_dir.as_ref().join("rpob.version");
|
let version_file_path = target_dir.as_ref().join("rpob.version");
|
||||||
if version_file_path.exists() {
|
if version_file_path.exists() {
|
||||||
let old_version = fs::read_to_string(&version_file_path).unwrap();
|
let old_version = fs::read_to_string(&version_file_path).unwrap();
|
||||||
let current_version = env!("CARGO_PKG_VERSION");
|
|
||||||
|
|
||||||
if old_version != current_version {
|
if old_version != current_version {
|
||||||
log::info!("New version detected: {old_version} -> {current_version}");
|
log::info!("New version detected: {old_version} -> {current_version}");
|
||||||
@@ -173,7 +173,11 @@ fn install<P: AsRef<Path>>(
|
|||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
|
|
||||||
download_path_of_building(&target_dir, progress_tx)?;
|
let compatibility_info = fetch_compatibility_info()?;
|
||||||
|
let needed_pob_version = highest_supported_pob_version(&compatibility_info, current_version)
|
||||||
|
.ok_or_else(|| anyhow::anyhow!("Unable to determine supported PoB version"))?;
|
||||||
|
|
||||||
|
download_path_of_building(&target_dir, needed_pob_version, progress_tx)?;
|
||||||
replace_updatecheck(&target_dir)?;
|
replace_updatecheck(&target_dir)?;
|
||||||
set_branch_and_platform(&target_dir)?;
|
set_branch_and_platform(&target_dir)?;
|
||||||
|
|
||||||
@@ -183,9 +187,73 @@ fn install<P: AsRef<Path>>(
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Downloads latest release of Path of Building
|
#[derive(Debug)]
|
||||||
|
struct VersionReq {
|
||||||
|
pob_ver: String,
|
||||||
|
min_rpob_ver: String,
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Fetches and evaluates compatibility table
|
||||||
|
fn fetch_compatibility_info() -> anyhow::Result<Vec<VersionReq>> {
|
||||||
|
let compatibility_info_file_name = match Game::current() {
|
||||||
|
Game::Poe1 => "Compatibility_pob1.lua",
|
||||||
|
Game::Poe2 => "Compatibility_pob2.lua",
|
||||||
|
};
|
||||||
|
|
||||||
|
let compatibility_info_file_url = &format!(
|
||||||
|
"https://raw.githubusercontent.com/{REPO_NAME}/main/{}",
|
||||||
|
compatibility_info_file_name
|
||||||
|
);
|
||||||
|
|
||||||
|
let compatibility_info_file = download_file_contents(compatibility_info_file_url)?;
|
||||||
|
|
||||||
|
// Load and evaluate compatibility file contents as Lua code
|
||||||
|
let lua = mlua::Lua::new();
|
||||||
|
let compatibility_table = lua.load(compatibility_info_file).eval::<mlua::Table>()?;
|
||||||
|
|
||||||
|
// Compatibility table maps PoB version to minimum required Rusty PoB version
|
||||||
|
Ok(compatibility_table
|
||||||
|
.pairs::<String, String>()
|
||||||
|
.filter_map(|p| p.ok())
|
||||||
|
.map(|(pob_version, min_req_rpob_ver)| VersionReq {
|
||||||
|
pob_ver: pob_version,
|
||||||
|
min_rpob_ver: min_req_rpob_ver,
|
||||||
|
})
|
||||||
|
.collect())
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Determines highest PoB version supported by given Rusty PoB version
|
||||||
|
fn highest_supported_pob_version<'a>(
|
||||||
|
compatibility_info: &'a Vec<VersionReq>,
|
||||||
|
rpob_version: &str,
|
||||||
|
) -> Option<&'a str> {
|
||||||
|
let mut highest_pob_version = None;
|
||||||
|
for VersionReq {
|
||||||
|
pob_ver,
|
||||||
|
min_rpob_ver,
|
||||||
|
} in compatibility_info
|
||||||
|
{
|
||||||
|
if is_higher_version(min_rpob_ver, rpob_version).unwrap_or(false) {
|
||||||
|
// found PoB version that meets our minimum requirements
|
||||||
|
match highest_pob_version {
|
||||||
|
// make sure it is the highest PoB version possible
|
||||||
|
Some(h_pob_version) => {
|
||||||
|
if is_higher_version(h_pob_version, pob_ver).unwrap_or(false) {
|
||||||
|
highest_pob_version = Some(pob_ver.as_str());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
None => highest_pob_version = Some(pob_ver.as_str()),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
highest_pob_version
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Downloads specified version of Path of Building
|
||||||
fn download_path_of_building<P: AsRef<Path>>(
|
fn download_path_of_building<P: AsRef<Path>>(
|
||||||
target_dir: P,
|
target_dir: P,
|
||||||
|
pob_version: &str,
|
||||||
progress_tx: &mpsc::Sender<Progress>,
|
progress_tx: &mpsc::Sender<Progress>,
|
||||||
) -> anyhow::Result<()> {
|
) -> anyhow::Result<()> {
|
||||||
log::info!("Downloading Path of Building assets...");
|
log::info!("Downloading Path of Building assets...");
|
||||||
@@ -195,8 +263,8 @@ fn download_path_of_building<P: AsRef<Path>>(
|
|||||||
Game::Poe2 => "PathOfBuildingCommunity/PathOfBuilding-PoE2",
|
Game::Poe2 => "PathOfBuildingCommunity/PathOfBuilding-PoE2",
|
||||||
};
|
};
|
||||||
let url = format!(
|
let url = format!(
|
||||||
"https://github.com/{}/archive/refs/heads/master.tar.gz",
|
"https://github.com/{}/archive/refs/tags/v{}.tar.gz",
|
||||||
repo
|
repo, pob_version
|
||||||
);
|
);
|
||||||
|
|
||||||
let mut response = http_get_with_backoff(&url)?;
|
let mut response = http_get_with_backoff(&url)?;
|
||||||
@@ -302,6 +370,7 @@ fn set_branch_and_platform<P: AsRef<Path>>(target_dir: P) -> anyhow::Result<()>
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Downloads file and saves it to given path
|
||||||
fn download_file<P: AsRef<Path>>(url: &str, file_path: P) -> anyhow::Result<()> {
|
fn download_file<P: AsRef<Path>>(url: &str, file_path: P) -> anyhow::Result<()> {
|
||||||
let mut response = http_get_with_backoff(url)?;
|
let mut response = http_get_with_backoff(url)?;
|
||||||
|
|
||||||
@@ -311,7 +380,19 @@ fn download_file<P: AsRef<Path>>(url: &str, file_path: P) -> anyhow::Result<()>
|
|||||||
copy(&mut body.as_reader(), &mut file)?;
|
copy(&mut body.as_reader(), &mut file)?;
|
||||||
Ok(())
|
Ok(())
|
||||||
} else {
|
} else {
|
||||||
bail!("Unable to download: {}", url);
|
anyhow::bail!("Unable to download: {}", url);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Downloads file and returns contents as string
|
||||||
|
fn download_file_contents(url: &str) -> anyhow::Result<String> {
|
||||||
|
let mut response = http_get_with_backoff(url)?;
|
||||||
|
|
||||||
|
if response.status().is_success() {
|
||||||
|
let body = response.body_mut();
|
||||||
|
Ok(body.read_to_string()?)
|
||||||
|
} else {
|
||||||
|
anyhow::bail!("Unable to download: {}", url);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -432,3 +513,128 @@ fn http_get_with_backoff(url: &str) -> anyhow::Result<Response<ureq::Body>> {
|
|||||||
return Ok(resp);
|
return Ok(resp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// 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> {
|
||||||
|
let re = Regex::new(r"^(\d+)\.(\d+)\.(\d+)$").unwrap();
|
||||||
|
|
||||||
|
let parse_version = |v: &str| -> anyhow::Result<(u32, u32, u32)> {
|
||||||
|
let caps = re
|
||||||
|
.captures(v)
|
||||||
|
.ok_or_else(|| anyhow::anyhow!("Invalid semver format: {}", v))?;
|
||||||
|
|
||||||
|
let major = caps[1].parse::<u32>().unwrap();
|
||||||
|
let minor = caps[2].parse::<u32>().unwrap();
|
||||||
|
let patch = caps[3].parse::<u32>().unwrap();
|
||||||
|
|
||||||
|
Ok((major, minor, patch))
|
||||||
|
};
|
||||||
|
|
||||||
|
let (major1, minor1, patch1) = parse_version(v1)?;
|
||||||
|
let (major2, minor2, patch2) = parse_version(v2)?;
|
||||||
|
|
||||||
|
Ok(major2 > major1
|
||||||
|
|| (major2 == major1 && minor2 > minor1)
|
||||||
|
|| (major2 == major1 && minor2 == minor1 && patch2 >= patch1))
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use super::*;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_major_version() {
|
||||||
|
assert_eq!(is_higher_version("1.0.0", "2.0.0").unwrap(), true);
|
||||||
|
assert_eq!(is_higher_version("2.0.0", "1.0.0").unwrap(), false);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_minor_version() {
|
||||||
|
assert_eq!(is_higher_version("1.5.0", "1.6.0").unwrap(), true);
|
||||||
|
assert_eq!(is_higher_version("1.10.0", "1.9.0").unwrap(), false);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_patch_version() {
|
||||||
|
assert_eq!(is_higher_version("1.0.3", "1.0.4").unwrap(), true);
|
||||||
|
assert_eq!(is_higher_version("1.0.10", "1.0.9").unwrap(), false);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_same_version() {
|
||||||
|
assert_eq!(is_higher_version("1.5.3", "1.5.3").unwrap(), true);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_invalid_semver_format() {
|
||||||
|
assert!(is_higher_version("1.0", "2.0.0").is_err());
|
||||||
|
assert!(is_higher_version("1.0.0", "2.0").is_err());
|
||||||
|
assert!(is_higher_version("invalid", "2.0.0").is_err());
|
||||||
|
assert!(is_higher_version("1.0.0", "a.bb.ccc").is_err());
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_highest_supported_pob_ver() {
|
||||||
|
let compat_info = vec![
|
||||||
|
VersionReq {
|
||||||
|
pob_ver: String::from("2.56.0"),
|
||||||
|
min_rpob_ver: String::from("0.1.0"),
|
||||||
|
},
|
||||||
|
// compat info might not be sorted by pob_version
|
||||||
|
VersionReq {
|
||||||
|
pob_ver: String::from("2.58.0"),
|
||||||
|
min_rpob_ver: String::from("0.2.6"),
|
||||||
|
},
|
||||||
|
VersionReq {
|
||||||
|
pob_ver: String::from("2.57.0"),
|
||||||
|
min_rpob_ver: String::from("0.2.6"),
|
||||||
|
},
|
||||||
|
VersionReq {
|
||||||
|
pob_ver: String::from("2.58.1"),
|
||||||
|
min_rpob_ver: String::from("0.2.8"),
|
||||||
|
},
|
||||||
|
VersionReq {
|
||||||
|
pob_ver: String::from("2.59.0"),
|
||||||
|
min_rpob_ver: String::from("0.2.9"),
|
||||||
|
},
|
||||||
|
VersionReq {
|
||||||
|
pob_ver: String::from("2.59.1"),
|
||||||
|
min_rpob_ver: String::from("0.2.10"),
|
||||||
|
},
|
||||||
|
VersionReq {
|
||||||
|
pob_ver: String::from("2.59.2"),
|
||||||
|
min_rpob_ver: String::from("0.2.10"),
|
||||||
|
},
|
||||||
|
];
|
||||||
|
assert_eq!(highest_supported_pob_version(&compat_info, "0.0.2"), None);
|
||||||
|
assert_eq!(highest_supported_pob_version(&compat_info, "a.b.c"), None);
|
||||||
|
assert_eq!(
|
||||||
|
highest_supported_pob_version(&compat_info, "0.1.0"),
|
||||||
|
Some("2.56.0")
|
||||||
|
);
|
||||||
|
assert_eq!(
|
||||||
|
highest_supported_pob_version(&compat_info, "0.2.0"),
|
||||||
|
Some("2.56.0")
|
||||||
|
);
|
||||||
|
assert_eq!(
|
||||||
|
highest_supported_pob_version(&compat_info, "0.2.6"),
|
||||||
|
Some("2.58.0")
|
||||||
|
);
|
||||||
|
assert_eq!(
|
||||||
|
highest_supported_pob_version(&compat_info, "0.2.7"),
|
||||||
|
Some("2.58.0")
|
||||||
|
);
|
||||||
|
assert_eq!(
|
||||||
|
highest_supported_pob_version(&compat_info, "0.2.8"),
|
||||||
|
Some("2.58.1")
|
||||||
|
);
|
||||||
|
assert_eq!(
|
||||||
|
highest_supported_pob_version(&compat_info, "0.2.9"),
|
||||||
|
Some("2.59.0")
|
||||||
|
);
|
||||||
|
assert_eq!(
|
||||||
|
highest_supported_pob_version(&compat_info, "0.2.10"),
|
||||||
|
Some("2.59.2")
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
+26
-3
@@ -13,7 +13,7 @@ use crate::{
|
|||||||
window::WindowState,
|
window::WindowState,
|
||||||
};
|
};
|
||||||
use clap::Parser;
|
use clap::Parser;
|
||||||
use mlua::{Lua, Result as LuaResult, Table};
|
use mlua::{Function, Lua, Result as LuaResult, Table, ThreadStatus};
|
||||||
use std::{
|
use std::{
|
||||||
cell::{Cell, RefCell},
|
cell::{Cell, RefCell},
|
||||||
path::PathBuf,
|
path::PathBuf,
|
||||||
@@ -170,9 +170,9 @@ impl LuaInstance {
|
|||||||
// SAFETY: use `unsafe_new` to allow loading of C modules
|
// SAFETY: use `unsafe_new` to allow loading of C modules
|
||||||
let lua = unsafe { Lua::unsafe_new() };
|
let lua = unsafe { Lua::unsafe_new() };
|
||||||
|
|
||||||
// expose build arg to lua
|
// expose import url to lua
|
||||||
let args = Args::parse();
|
let args = Args::parse();
|
||||||
let args_table = lua.create_sequence_from(std::iter::once(args.build_path))?;
|
let args_table = lua.create_sequence_from(std::iter::once(args.import_url))?;
|
||||||
lua.globals().set("arg", args_table)?;
|
lua.globals().set("arg", args_table)?;
|
||||||
|
|
||||||
Self::register_package_paths(&lua)?;
|
Self::register_package_paths(&lua)?;
|
||||||
@@ -228,6 +228,29 @@ impl LuaInstance {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn has_running_subscripts(&self) -> bool {
|
||||||
|
self.subscript_manager.borrow().has_running_subscripts()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn has_active_coroutine(&self) -> bool {
|
||||||
|
self.get_coroutines().is_ok_and(|coroutines| {
|
||||||
|
coroutines.pairs::<mlua::Thread, bool>().any(|pair| {
|
||||||
|
pair.is_ok_and(|(thread, _)| {
|
||||||
|
matches!(
|
||||||
|
thread.status(),
|
||||||
|
ThreadStatus::Resumable | ThreadStatus::Running
|
||||||
|
)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
fn get_coroutines(&self) -> LuaResult<Table> {
|
||||||
|
let coroutine_module: Table = self.lua.globals().get("coroutine")?;
|
||||||
|
let list_func: Function = coroutine_module.get("_list")?;
|
||||||
|
list_func.call::<Table>(())
|
||||||
|
}
|
||||||
|
|
||||||
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));
|
||||||
|
|
||||||
|
|||||||
@@ -34,6 +34,9 @@ pub enum ModeTransition {
|
|||||||
pub struct ModeFrameOutput {
|
pub struct ModeFrameOutput {
|
||||||
pub primitives: Box<dyn Iterator<Item = ClippedPrimitive>>,
|
pub primitives: Box<dyn Iterator<Item = ClippedPrimitive>>,
|
||||||
pub can_elide: bool,
|
pub can_elide: bool,
|
||||||
|
/// Indicates that this should be redrawn again next frame even if user is not interacting with
|
||||||
|
/// window
|
||||||
|
pub should_continue: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub enum AppMode {
|
pub enum AppMode {
|
||||||
|
|||||||
@@ -68,9 +68,14 @@ impl PoBMode {
|
|||||||
let identical = layers_hash == self.previous_layers_hash;
|
let identical = layers_hash == self.previous_layers_hash;
|
||||||
self.previous_layers_hash = layers_hash;
|
self.previous_layers_hash = layers_hash;
|
||||||
|
|
||||||
|
let has_active_subscript = self.lua_instance.has_running_subscripts();
|
||||||
|
let has_active_coroutine = self.lua_instance.has_active_coroutine();
|
||||||
|
let should_continue = has_active_subscript || has_active_coroutine;
|
||||||
|
|
||||||
Ok(ModeFrameOutput {
|
Ok(ModeFrameOutput {
|
||||||
primitives: self.state.layers.consume_layers(),
|
primitives: self.state.layers.consume_layers(),
|
||||||
can_elide: identical,
|
can_elide: identical,
|
||||||
|
should_continue,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+5
-1
@@ -74,6 +74,10 @@ impl SubscriptManager {
|
|||||||
|
|
||||||
results
|
results
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn has_running_subscripts(&self) -> bool {
|
||||||
|
!self.scripts.is_empty()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
enum SubscriptCall {
|
enum SubscriptCall {
|
||||||
@@ -305,7 +309,7 @@ pub fn register_subscript_globals(
|
|||||||
"IsSubScriptRunning",
|
"IsSubScriptRunning",
|
||||||
lua.create_function(is_subscript_running)?,
|
lua.create_function(is_subscript_running)?,
|
||||||
)?;
|
)?;
|
||||||
globals.set("IsSubScriptRunning", lua.create_function(abort_subscript)?)?;
|
globals.set("AbortSubScript", lua.create_function(abort_subscript)?)?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+22
-2
@@ -11,8 +11,11 @@ pub struct WindowState {
|
|||||||
clipboard: Option<Clipboard>,
|
clipboard: Option<Clipboard>,
|
||||||
pub window: Option<Arc<Window>>,
|
pub window: Option<Arc<Window>>,
|
||||||
pub size: PhysicalSize<u32>,
|
pub size: PhysicalSize<u32>,
|
||||||
pub scale_factor: f32,
|
scale_factor: f32,
|
||||||
|
pub scale_factor_override: Option<f32>,
|
||||||
pending_window_title: std::cell::Cell<Option<String>>,
|
pending_window_title: std::cell::Cell<Option<String>>,
|
||||||
|
pub is_hovered: bool,
|
||||||
|
pub is_focused: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for WindowState {
|
impl Default for WindowState {
|
||||||
@@ -21,8 +24,11 @@ impl Default for WindowState {
|
|||||||
window: None,
|
window: None,
|
||||||
size: Default::default(),
|
size: Default::default(),
|
||||||
scale_factor: 1.0,
|
scale_factor: 1.0,
|
||||||
|
scale_factor_override: None,
|
||||||
pending_window_title: std::cell::Cell::new(None),
|
pending_window_title: std::cell::Cell::new(None),
|
||||||
clipboard: None,
|
clipboard: None,
|
||||||
|
is_hovered: true,
|
||||||
|
is_focused: true,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -51,7 +57,15 @@ impl WindowState {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn logical_size(&self) -> LogicalSize<u32> {
|
pub fn logical_size(&self) -> LogicalSize<u32> {
|
||||||
self.size.to_logical(self.scale_factor)
|
self.size.to_logical(self.scale_factor())
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn scale_factor(&self) -> f32 {
|
||||||
|
self.scale_factor_override.unwrap_or(self.scale_factor)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn set_scale_factor(&mut self, scale_factor: f32) {
|
||||||
|
self.scale_factor = scale_factor;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn focus(&self) {
|
pub fn focus(&self) {
|
||||||
@@ -73,4 +87,10 @@ impl WindowState {
|
|||||||
None
|
None
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn request_redraw(&self) {
|
||||||
|
if let Some(ref window) = self.window {
|
||||||
|
window.request_redraw();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user