Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added assets/mod/autoplay.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/mod/fade_in.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/mod/fade_out.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/mod/flip_x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/mod/nightcore.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/mod/rainbow.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 7 additions & 1 deletion phira/locales/en-US/song.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,17 @@ review-edit-tags-done = Tags updated.

mods = Mods
mods-autoplay = Autoplay
mods-autoplay-sub = Plays the chart without user input.
mods-autoplay-sub = Results will not be submitted when enabled.
mods-flip-x = Mirror
mods-flip-x-sub = Mirrors the chart by the X-axis.
mods-fade-in = Fade-In
mods-fade-in-sub = Makes notes fade in when they approach the judgeline.
mods-fade-out = Fade-Out
mods-fade-out-sub = Makes notes fade out when they approach the judgeline.
mods-nightcore = Nightcore
mods-nightcore-sub = Plays the chart at higher speed
mods-rainbow = Rainbow
mods-rainbow-sub = Makes your game a *little* more colorful

rate-failed = Rate failed.
rate-done = Rated successfully.
Expand Down
11 changes: 11 additions & 0 deletions phira/locales/ja-JP/song.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -54,5 +54,16 @@ ldb = リーダーボード
ldb-load-failed = リーダーボードの読み込みに失敗
ldb-no-rank = なし

mods = Mods
mods-autoplay = オートプレイ
mods-autoplay-sub = これを有効にすると、リザルトの記録が無効になります
mods-flip-x = ミラー
mods-flip-x-sub = X軸に沿って譜面を反転させます
mods-fade-in = フェードイン
mods-fade-in-sub = ノーツが判定線に近づくと現れるようにします
mods-fade-out = フェードアウト
mods-fade-out-sub = ノーツが判定線に近づくと消えるようにします
mods-nightcore = ナイトコア
mods-nightcore-sub = より高速で譜面をプレイします
mods-rainbow = レインボー
mods-rainbow-sub = ゲームを *少しだけ* カラフルにします
6 changes: 6 additions & 0 deletions phira/locales/zh-CN/song.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,14 @@ mods-autoplay = 自动游玩
mods-autoplay-sub = 启用后将无法上传成绩
mods-flip-x = X 轴反转
mods-flip-x-sub = 在 X 轴上反转谱面
mods-fade-in = 上隐
mods-fade-in-sub = 音符在靠近判定线时会显现
mods-fade-out = 下隐
mods-fade-out-sub = 音符在靠近判定线时会隐藏
mods-nightcore = 夜店
mods-nightcore-sub = 以高倍速游玩谱面
mods-rainbow = 彩虹
mods-rainbow-sub = 遇上彩虹,吃定彩虹

rate-failed = 评分失败
rate-done = 评分成功
Expand Down
5 changes: 4 additions & 1 deletion phira/src/scene/song.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1267,7 +1267,7 @@ impl SongScene {
let (btn, clicked) = &mut self.mod_btns[index];
if *clicked {
*clicked = false;
self.mods.toggle(flag);
self.mods.toggle_mod(flag);
}
let on = self.mods.contains(flag);
let oh = rr.h;
Expand All @@ -1288,7 +1288,10 @@ impl SongScene {
};
item(tl!("mods-autoplay"), Some(tl!("mods-autoplay-sub")), Mods::AUTOPLAY);
item(tl!("mods-flip-x"), Some(tl!("mods-flip-x-sub")), Mods::FLIP_X);
item(tl!("mods-fade-in"), Some(tl!("mods-fade-in-sub")), Mods::FADE_IN);
item(tl!("mods-fade-out"), Some(tl!("mods-fade-out-sub")), Mods::FADE_OUT);
item(tl!("mods-nightcore"), Some(tl!("mods-nightcore-sub")), Mods::NIGHTCORE);
item(tl!("mods-rainbow"), Some(tl!("mods-rainbow-sub")), Mods::RAINBOW);
(width, h)
});
}
Expand Down
23 changes: 23 additions & 0 deletions prpr/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,29 @@ bitflags! {
const AUTOPLAY = 1;
const FLIP_X = 2;
const FADE_OUT = 4;
const FADE_IN = 8;
const NIGHTCORE = 16;
const RAINBOW = 32;
}
}

impl Mods {
pub fn toggle_mod(&mut self, flag: Mods) {
if self.contains(flag) {
self.remove(flag);
} else {
for &conflict in Mods::conflicts(flag) {
self.remove(conflict);
}
self.insert(flag);
}
}
fn conflicts(flag: Mods) -> &'static [Mods] {
match flag {
Mods::FADE_IN => &[Mods::FADE_OUT],
Mods::FADE_OUT => &[Mods::FADE_IN],
_ => &[],
}
}
}

Expand Down
7 changes: 1 addition & 6 deletions prpr/src/core/line.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
use super::{chart::ChartSettings, object::CtrlObject, Anim, AnimFloat, BpmList, Matrix, Note, Object, Point, RenderConfig, Resource, Vector};
use crate::{
config::Mods,
ext::{get_viewport, NotNanExt, SafeTexture},
judge::{JudgeStatus, LIMIT_BAD},
judge::JudgeStatus,
ui::Ui,
};
use macroquad::prelude::*;
Expand Down Expand Up @@ -359,13 +358,9 @@ impl JudgeLine {
ctrl_obj: &mut self.ctrl_obj.borrow_mut(),
line_height: self.height.now(),
appear_before: f32::INFINITY,
invisible_time: f32::INFINITY,
draw_below: self.show_below,
incline_sin: self.incline.now_opt().map(|it| it.to_radians().sin()).unwrap_or_default(),
};
if res.config.has_mod(Mods::FADE_OUT) {
config.invisible_time = LIMIT_BAD;
}
if alpha < 0.0 {
if !settings.pe_alpha_extension {
return;
Expand Down
16 changes: 11 additions & 5 deletions prpr/src/core/note.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use super::{chart::ChartSettings, BpmList, CtrlObject, JudgeLine, Matrix, Object, Point, Resource};
pub use crate::{
judge::{HitSound, JudgeStatus},
config::Mods,
judge::{HitSound, JudgeStatus, LIMIT_BAD},
parse::RPE_HEIGHT,
};
use macroquad::prelude::*;
Expand Down Expand Up @@ -48,7 +49,6 @@ pub struct RenderConfig<'a> {
pub ctrl_obj: &'a mut CtrlObject,
pub line_height: f32,
pub appear_before: f32,
pub invisible_time: f32,
pub draw_below: bool,
pub incline_sin: f32,
}
Expand Down Expand Up @@ -198,9 +198,6 @@ impl Note {
return;
}
}
if config.invisible_time.is_finite() && self.time - config.invisible_time < res.time {
return;
}
let scale = (if res.config.double_hint && self.multiple_hint {
res.res_pack.note_style_mh.click.width() / res.res_pack.note_style.click.width()
} else {
Expand Down Expand Up @@ -240,11 +237,19 @@ impl Note {
} else {
&res.res_pack.note_style
};
let mod_alpha = if res.config.has_mod(Mods::FADE_OUT) {
((self.time - res.time - LIMIT_BAD) / LIMIT_BAD).clamp(0., 1.)
} else if res.config.has_mod(Mods::FADE_IN) {
(1. - (self.time - res.time - LIMIT_BAD) / LIMIT_BAD).clamp(0., 1.)
} else {
1.
};
let draw = |res: &mut Resource, tex: Texture2D| {
let mut color = color;
if !config.draw_below {
color.a *= (self.time - res.time).min(0.) / FADEOUT_TIME + 1.;
}
color.a *= mod_alpha;
res.with_model(self.now_transform(res, ctrl_obj, base, config.incline_sin), |res| {
draw_center(res, tex, order, scale, color);
});
Expand All @@ -268,6 +273,7 @@ impl Note {
return;
}
let end_height = end_height / res.aspect_ratio * spd;
color.a *= mod_alpha;

let h = if self.time <= res.time { line_height } else { height };
let bottom = h - line_height;
Expand Down
32 changes: 23 additions & 9 deletions prpr/src/core/resource.rs
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,7 @@ pub struct Resource {
pub background: SafeTexture,
pub illustration: SafeTexture,
pub icons: [SafeTexture; 8],
pub mod_icons: [SafeTexture; 6],
pub res_pack: ResourcePack,
pub player: SafeTexture,
pub icon_back: SafeTexture,
Expand All @@ -415,17 +416,18 @@ pub struct Resource {
pub model_stack: Vec<Matrix>,
}

macro_rules! loads {
($($path:literal),*) => {
[$(loads!(@detail $path)),*]
};

(@detail $path:literal) => {
Texture2D::from_image(&load_image($path).await?).into()
};
}

impl Resource {
pub async fn load_icons() -> Result<[SafeTexture; 8]> {
macro_rules! loads {
($($path:literal),*) => {
[$(loads!(@detail $path)),*]
};

(@detail $path:literal) => {
Texture2D::from_image(&load_image($path).await?).into()
};
}
Ok(loads![
"rank/F.png",
"rank/C.png",
Expand All @@ -437,6 +439,17 @@ impl Resource {
"rank/phi.png"
])
}
pub async fn load_mod_icons() -> Result<[SafeTexture; 6]> {
// FLIP_X, FADE_OUT, FADE_IN, NIGHTCORE, RAINBOW, AUTOPLAY
Ok(loads![
"mod/flip_x.png",
"mod/fade_out.png",
"mod/fade_in.png",
"mod/nightcore.png",
"mod/rainbow.png",
"mod/autoplay.png"
])
}

pub async fn new(
config: Config,
Expand Down Expand Up @@ -496,6 +509,7 @@ impl Resource {
background,
illustration,
icons: Self::load_icons().await?,
mod_icons: Self::load_mod_icons().await?,
res_pack,
player: if let Some(player) = player { player } else { load_tex!("player.jpg") },
icon_back: load_tex!("back.png"),
Expand Down
Loading
Loading