@@ -0,0 +1,168 @@
|
||||
import funkin.game.HudCamera;
|
||||
import funkin.scripting.events.NoteHitEvent;
|
||||
|
||||
public var pixelNotesForBF = true;
|
||||
public var pixelNotesForDad = true;
|
||||
public var enablePixelUI = true;
|
||||
public var enablePixelGameOver = true;
|
||||
public var enableCameraHacks = Options.week6PixelPerfect;
|
||||
public var enablePauseMenu = true;
|
||||
public var isSpooky = false;
|
||||
|
||||
var oldStageQuality = FlxG.game.stage.quality;
|
||||
static var daPixelZoom = 6;
|
||||
|
||||
/**
|
||||
* UI
|
||||
*/
|
||||
function onNoteCreation(event) {
|
||||
if (event.note.strumLine == playerStrums && !pixelNotesForBF) return;
|
||||
if (event.note.strumLine == cpuStrums && !pixelNotesForDad) return;
|
||||
|
||||
event.cancel();
|
||||
|
||||
var note = event.note;
|
||||
if (event.note.isSustainNote) {
|
||||
note.loadGraphic(Paths.image('stages/school/ui/arrowEnds'), true, 7, 6);
|
||||
note.animation.add("hold", [event.strumID]);
|
||||
note.animation.add("holdend", [4 + event.strumID]);
|
||||
} else {
|
||||
note.loadGraphic(Paths.image('stages/school/ui/arrows-pixels'), true, 17, 17);
|
||||
note.animation.add("scroll", [4 + event.strumID]);
|
||||
}
|
||||
note.scale.set(daPixelZoom, daPixelZoom);
|
||||
note.updateHitbox();
|
||||
}
|
||||
|
||||
function onStrumCreation(event) {
|
||||
if (event.player == 1 && !pixelNotesForBF) return;
|
||||
if (event.player == 0 && !pixelNotesForDad) return;
|
||||
|
||||
event.cancel();
|
||||
|
||||
var strum = event.strum;
|
||||
strum.loadGraphic(Paths.image('stages/school/ui/arrows-pixels'), true, 17, 17);
|
||||
strum.animation.add("static", [event.strumID]);
|
||||
strum.animation.add("pressed", [4 + event.strumID, 8 + event.strumID], 12, false);
|
||||
strum.animation.add("confirm", [12 + event.strumID, 16 + event.strumID], 24, false);
|
||||
|
||||
strum.scale.set(daPixelZoom, daPixelZoom);
|
||||
strum.updateHitbox();
|
||||
}
|
||||
|
||||
function onCountdown(event) {
|
||||
if (!enablePixelUI) return;
|
||||
|
||||
if (event.soundPath != null) event.soundPath = 'pixel/' + event.soundPath;
|
||||
event.antialiasing = false;
|
||||
event.scale = daPixelZoom;
|
||||
event.spritePath = switch(event.swagCounter) {
|
||||
case 0: null;
|
||||
case 1: 'stages/school/ui/ready';
|
||||
case 2: 'stages/school/ui/set';
|
||||
case 3: 'stages/school/ui/go';
|
||||
};
|
||||
}
|
||||
|
||||
function onPlayerHit(event:NoteHitEvent) {
|
||||
if (!enablePixelUI) return;
|
||||
event.ratingPrefix = "stages/school/ui/";
|
||||
event.ratingScale = daPixelZoom * 0.7;
|
||||
event.ratingAntialiasing = false;
|
||||
|
||||
event.numScale = daPixelZoom;
|
||||
event.numAntialiasing = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* CAMERA HACKS!!
|
||||
*/
|
||||
function postCreate() {
|
||||
if (enablePauseMenu) {
|
||||
PauseSubState.script = 'data/scripts/week6-pause';
|
||||
}
|
||||
if (enableCameraHacks) {
|
||||
FlxG.camera.antialiasing = false;
|
||||
FlxG.camera.pixelPerfectRender = true;
|
||||
|
||||
|
||||
iconP1.antialiasing = false;
|
||||
iconP2.antialiasing = false;
|
||||
|
||||
makeCameraPixely(camGame);
|
||||
defaultCamZoom /= daPixelZoom;
|
||||
}
|
||||
if (enablePixelGameOver) {
|
||||
gameOverSong = "pixel/gameOver";
|
||||
lossSFX = "pixel/gameOverSFX";
|
||||
retrySFX = "pixel/gameOverEnd";
|
||||
}
|
||||
}
|
||||
|
||||
function onStartCountdown() {
|
||||
var newNoteCamera = new HudCamera();
|
||||
newNoteCamera.bgColor = 0; // transparent
|
||||
FlxG.cameras.add(newNoteCamera, false);
|
||||
|
||||
var pixelSwagWidth = Note.swagWidth + (daPixelZoom - (Note.swagWidth % daPixelZoom));
|
||||
|
||||
for(p in strumLines) {
|
||||
var i = 0;
|
||||
for(str in p.members) {
|
||||
str.x = (FlxG.width * strumOffset) + (pixelSwagWidth * (i - 2));
|
||||
str.x -= str.x % daPixelZoom;
|
||||
i++;
|
||||
}
|
||||
}
|
||||
makeCameraPixely(newNoteCamera);
|
||||
}
|
||||
|
||||
/**
|
||||
* Use this to make any camera pixelly (you wont be able to zoom with it anymore!)
|
||||
*/
|
||||
public function makeCameraPixely(cam) {
|
||||
cam.pixelPerfectRender = true;
|
||||
cam.zoom /= Math.min(FlxG.scaleMode.scale.x, FlxG.scaleMode.scale.y) * daPixelZoom;
|
||||
|
||||
var shad = new CustomShader('pixelZoomShader');
|
||||
cam.addShader(shad);
|
||||
|
||||
pixellyCameras.push(cam);
|
||||
pixellyShaders.push(shad);
|
||||
|
||||
FlxG.game.stage.quality = 2;
|
||||
}
|
||||
|
||||
function destroy() {
|
||||
// resets the stage quality
|
||||
FlxG.game.stage.quality = oldStageQuality;
|
||||
}
|
||||
|
||||
function pixelCam(cam) {
|
||||
makeCameraPixely(cam);
|
||||
}
|
||||
|
||||
var pixellyCameras = [];
|
||||
var pixellyShaders = [];
|
||||
|
||||
function postUpdate(elapsed) {
|
||||
for(e in pixellyCameras) {
|
||||
if (Std.isOfType(e, HudCamera))
|
||||
e.downscroll = camHUD.downscroll;
|
||||
}
|
||||
if (enableCameraHacks) {
|
||||
for(p in strumLines)
|
||||
p.notes.forEach(function(n) {
|
||||
n.y -= n.y % daPixelZoom;
|
||||
n.x -= n.x % daPixelZoom;
|
||||
});
|
||||
}
|
||||
|
||||
for(e in pixellyCameras) {
|
||||
if (!e.exists) continue;
|
||||
e.zoom = 1 / daPixelZoom / Math.min(FlxG.scaleMode.scale.x, FlxG.scaleMode.scale.y);
|
||||
}
|
||||
for(e in pixellyShaders) {
|
||||
e.pixelZoom = 1 / daPixelZoom / Math.min(FlxG.scaleMode.scale.x, FlxG.scaleMode.scale.y);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,127 @@
|
||||
import funkin.ui.FunkinText;
|
||||
import flixel.text.FlxText;
|
||||
import flixel.text.FlxTextBorderStyle;
|
||||
import flixel.util.FlxAxes;
|
||||
|
||||
var pixelScript:Script;
|
||||
var pauseCam = new FlxCamera();
|
||||
|
||||
var bg:FlxSprite;
|
||||
var hand:FlxSprite;
|
||||
|
||||
var texts:Array<FlxText> = [];
|
||||
|
||||
var isThorns = PlayState.SONG.meta.name.toLowerCase() == "thorns";
|
||||
|
||||
function create(event) {
|
||||
// cancel default pause menu!!
|
||||
event.cancel();
|
||||
|
||||
event.music = isThorns ? "pixel/LunchboxScary" : "pixel/Lunchbox";
|
||||
|
||||
cameras = [];
|
||||
|
||||
pixelScript = game.scripts.getByName("pixel.hx");
|
||||
pixelScript.call("pixelCam", [pauseCam]);
|
||||
|
||||
FlxG.cameras.add(pauseCam, false);
|
||||
|
||||
pauseCam.bgColor = isThorns ? 0x88000000 : 0x88FF99CC;
|
||||
pauseCam.alpha = 0;
|
||||
|
||||
bg = new FlxSprite(44 * 6, 14 * 6);
|
||||
bg.loadGraphic(Paths.image('stages/school/pause/bg'));
|
||||
if (isThorns)
|
||||
bg.color = 0xFF000000;
|
||||
bg.scale.set(6, 6);
|
||||
bg.updateHitbox();
|
||||
bg.scale.y = 4;
|
||||
bg.cameras = [pauseCam];
|
||||
add(bg);
|
||||
|
||||
songText = new FlxText(0, 22 * 6, 0, "Pause", 8, false);
|
||||
confText(songText);
|
||||
add(songText);
|
||||
|
||||
var i = 2;
|
||||
for(e in menuItems) {
|
||||
text = new FlxText(0, (22 * 6) + (i * 9 * 6), 0, e, 8, false);
|
||||
confText(text);
|
||||
add(text);
|
||||
texts.push(text);
|
||||
i++;
|
||||
}
|
||||
|
||||
hand = new FlxSprite().loadGraphic(Paths.image('stages/school/ui/hand_textbox'));
|
||||
hand.scale.set(6, 6);
|
||||
hand.updateHitbox();
|
||||
add(hand);
|
||||
|
||||
FlxTween.tween(bg, {"scale.y": 6}, 0.75, {ease: FlxEase.elasticOut});
|
||||
|
||||
cameras = [pauseCam];
|
||||
|
||||
FlxG.sound.play(Paths.sound(isThorns ? 'pixel/ANGRY' : 'pixel/clickText'));
|
||||
}
|
||||
|
||||
function confText(text) {
|
||||
text.scale.set(6, 6);
|
||||
text.updateHitbox();
|
||||
text.screenCenter(FlxAxes.X);
|
||||
text.borderStyle = FlxTextBorderStyle.OUTLINE;
|
||||
if (!isThorns) text.borderColor = 0xFF953E3E;
|
||||
}
|
||||
|
||||
function destroy() {
|
||||
FlxG.cameras.remove(pauseCam);
|
||||
}
|
||||
|
||||
var canDoShit = true;
|
||||
var time:Float = 0;
|
||||
function update(elapsed) {
|
||||
pixelScript.call("postUpdate", [elapsed]);
|
||||
|
||||
pauseCam.alpha = lerp(pauseCam.alpha, 1, 0.25);
|
||||
time += elapsed;
|
||||
|
||||
var curText = texts[curSelected];
|
||||
hand.setPosition(curText.x - hand.width - 18 + (Math.sin(time * Math.PI * 2) * 12), curText.y + (text.height - hand.height) - 6);
|
||||
hand.x -= hand.x % 6;
|
||||
hand.y -= hand.y % 6;
|
||||
|
||||
if (!canDoShit) return;
|
||||
var oldSec = curSelected;
|
||||
if (controls.DOWN_P)
|
||||
changeSelection(1, false);
|
||||
if (controls.UP_P)
|
||||
changeSelection(-1);
|
||||
|
||||
if (oldSec != curSelected) {
|
||||
FlxG.sound.play(Paths.sound(isThorns ? 'pixel/type' : 'pixel/pixelText'));
|
||||
}
|
||||
|
||||
|
||||
if (controls.ACCEPT) {
|
||||
FlxG.sound.play(Paths.sound(isThorns ? 'pixel/ANGRY' : 'pixel/clickText'));
|
||||
var option = menuItems[curSelected];
|
||||
if (option == "Resume" || option == "Exit to menu") {
|
||||
canDoShit = false;
|
||||
for(t in texts) t.visible = false;
|
||||
hand.visible = songText.visible = false;
|
||||
FlxTween.tween(bg, {"scale.y": 0}, 0.125, {ease: FlxEase.cubeOut, onComplete: function() {
|
||||
selectOption();
|
||||
}});
|
||||
} else {
|
||||
selectOption();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function changeSelection(change) {
|
||||
curSelected += change;
|
||||
|
||||
if (curSelected < 0)
|
||||
curSelected = menuItems.length - 1;
|
||||
if (curSelected >= menuItems.length)
|
||||
curSelected = 0;
|
||||
}
|
||||
Reference in New Issue
Block a user