Skip to content

Commit 8ef5e08

Browse files
authored
Merge pull request #478 from fhscey/main
feat: multitouch & fullscreen for windows
2 parents a30ff5c + cfa260b commit 8ef5e08

4 files changed

Lines changed: 37 additions & 9 deletions

File tree

phira/src/lib.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,9 @@ async fn the_main() -> Result<()> {
284284
info!("FPS {}", (1. / (t - frame_start)) as u32);
285285
}
286286

287+
#[cfg(target_os = "windows")]
288+
macroquad::window::set_fullscreen(get_data().config.fullscreen_mode);
289+
287290
next_frame().await;
288291
}
289292
Ok(())

phira/src/page/settings.rs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,10 @@ struct GeneralList {
271271
icon_lang: SafeTexture,
272272

273273
lang_btn: ChooseButton,
274+
275+
#[cfg(target_os = "windows")]
276+
fullscreen_btn: DRectButton,
277+
274278
cache_btn: DRectButton,
275279
offline_btn: DRectButton,
276280
server_status_btn: DRectButton,
@@ -300,6 +304,10 @@ impl GeneralList {
300304
.and_then(|ident| LANG_IDENTS.iter().position(|it| *it == ident))
301305
.unwrap_or_default(),
302306
),
307+
308+
#[cfg(target_os = "windows")]
309+
fullscreen_btn: DRectButton::new(),
310+
303311
cache_btn: DRectButton::new(),
304312
offline_btn: DRectButton::new(),
305313
server_status_btn: DRectButton::new(),
@@ -353,6 +361,13 @@ impl GeneralList {
353361
if self.lang_btn.touch(touch, t) {
354362
return Ok(Some(false));
355363
}
364+
365+
#[cfg(target_os = "windows")]
366+
if self.fullscreen_btn.touch(touch, t) {
367+
config.fullscreen_mode ^= true;
368+
return Ok(Some(true));
369+
}
370+
356371
if self.cache_btn.touch(touch, t) {
357372
fs::remove_dir_all(dir::cache()?)?;
358373
self.update_cache_size()?;
@@ -453,6 +468,13 @@ impl GeneralList {
453468
ui.fill_rect(r, (*self.icon_lang, r));
454469
self.lang_btn.render(ui, rr, t);
455470
}
471+
472+
#[cfg(target_os = "windows")]
473+
item! {
474+
render_title(ui, tl!("item-fullscreen"), Some(tl!("item-fullscreen-sub")));
475+
render_switch(ui, rr, t, &mut self.fullscreen_btn, config.fullscreen_mode);
476+
}
477+
456478
item! {
457479
render_title(ui, tl!("item-offline"), Some(tl!("item-offline-sub")));
458480
render_switch(ui, rr, t, &mut self.offline_btn, config.offline_mode);

prpr/src/config.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ pub struct Config {
3838
pub mp_enabled: bool,
3939
pub mp_address: String,
4040
pub offline_mode: bool,
41+
pub fullscreen_mode: bool,
4142
pub offset: f32,
4243
pub particle: bool,
4344
pub player_name: String,
@@ -74,6 +75,7 @@ impl Default for Config {
7475
mp_enabled: false,
7576
note_scale: 1.0,
7677
offline_mode: false,
78+
fullscreen_mode: false,
7779
offset: 0.,
7880
particle: true,
7981
player_name: "Mivik".to_string(),

prpr/src/judge.rs

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,15 @@ fn get_uptime() -> f64 {
8585
}
8686
}
8787

88+
#[cfg(target_os = "windows")]
89+
fn get_uptime() -> f64 {
90+
use std::time::SystemTime;
91+
let start = SystemTime::UNIX_EPOCH;
92+
let now = SystemTime::now();
93+
let duration = now.duration_since(start).expect("Time went backwards");
94+
duration.as_secs() as f64 + duration.subsec_nanos() as f64 * 1e-9
95+
}
96+
8897
pub struct FlickTracker {
8998
threshold: f32,
9099
last_point: Point,
@@ -366,7 +375,6 @@ impl Judge {
366375
const X_DIFF_MAX: f32 = 0.21 / (16. / 9.) * 2.;
367376
let spd = res.config.speed;
368377

369-
#[cfg(not(target_os = "windows"))]
370378
let uptime = get_uptime();
371379

372380
let t = res.time;
@@ -460,14 +468,7 @@ impl Judge {
460468
it.time = if it.time.is_infinite() {
461469
f64::NEG_INFINITY
462470
} else {
463-
#[cfg(target_os = "windows")]
464-
{
465-
it.time
466-
}
467-
#[cfg(not(target_os = "windows"))]
468-
{
469-
t as f64 - (uptime - it.time) * spd as f64
470-
}
471+
t as f64 - (uptime - it.time) * spd as f64
471472
};
472473
it
473474
})

0 commit comments

Comments
 (0)