Skip to content
Open
Show file tree
Hide file tree
Changes from 3 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
8 changes: 7 additions & 1 deletion phira/locales/en-US/song.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,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 @@ -55,5 +55,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 @@ -101,8 +101,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 @@ -1198,7 +1198,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 @@ -1219,7 +1219,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
6 changes: 1 addition & 5 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 @@ -352,9 +351,6 @@ impl JudgeLine {
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
10 changes: 9 additions & 1 deletion 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},
judge::{HitSound, JudgeStatus, LIMIT_BAD},
config::Mods,
parse::RPE_HEIGHT,
};
use macroquad::prelude::*;
Expand Down Expand Up @@ -236,11 +237,17 @@ 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 @@ -264,6 +271,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
11 changes: 11 additions & 0 deletions prpr/src/scene/game.rs
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,17 @@ impl GameScene {
.push(Effect::new(0.0..f32::INFINITY, include_str!("fxaa.glsl"), Vec::new(), false).unwrap());
}

if config.has_mod(Mods::NIGHTCORE) {
config.speed = 1.5;
}

if config.has_mod(Mods::RAINBOW) {
chart
.extra
.effects
.push(Effect::new(0.0..f32::INFINITY, include_str!("rainbow.glsl"), Vec::new(), false).unwrap());
}

let info_offset = info.offset;
let mut res = Resource::new(
config,
Expand Down
37 changes: 37 additions & 0 deletions prpr/src/scene/rainbow.glsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#version 100
precision highp float;

varying lowp vec2 uv;
uniform sampler2D screenTexture;
uniform float time;

const float hueSpeed = 0.5;

vec3 rgb2hsv(vec3 c) {
vec4 K = vec4(0.0, -1.0/3.0, 2.0/3.0, -1.0);
vec4 p = mix(vec4(c.bg, K.wz), vec4(c.gb, K.xy), step(c.b, c.g));
vec4 q = mix(vec4(p.xyw, c.r), vec4(c.r, p.yzx), step(p.x, c.r));

float d = q.x - min(q.w, q.y);
float e = 1.0e-10;
return vec3(abs(q.z + (q.w - q.y) / (6.0 * d + e)),
d / (q.x + e),
q.x);
}

vec3 hsv2rgb(vec3 c) {
vec3 p = abs(fract(c.xxx + vec3(0.0, 2.0/3.0, 1.0/3.0)) * 6.0 - 3.0);
return c.z * mix(vec3(1.0), clamp(p - 1.0, 0.0, 1.0), c.y);
}

void main() {
vec4 color = texture2D(screenTexture, uv);

vec3 hsv = rgb2hsv(color.rgb);

hsv.x = fract(hsv.x + time * hueSpeed);

vec3 rgb = hsv2rgb(hsv);

gl_FragColor = vec4(rgb, color.a);
}