Skip to content

Commit

Permalink
lmao
Browse files Browse the repository at this point in the history
  • Loading branch information
Hackx2 committed Aug 27, 2024
1 parent 577e985 commit d6f6944
Show file tree
Hide file tree
Showing 9 changed files with 212 additions and 200 deletions.
4 changes: 3 additions & 1 deletion source/funkin/backend/Song.hx
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,9 @@ class Song
switch(convertTo)
{
case 'astro_v0.3':
if(!fmt.toLowerCase().startsWith('astro_v0.3')) //Convert to Psych 1.0 format
// psych support :3
final fmt = fmt.toLowerCase();
if(!fmt.startsWith('astro_v0.3') && !fmt.startsWith('psych_v1')) //Convert to Psych 1.0 format
{
trace('converting chart $nameForError with format $fmt to astro_v0.3 format...');
songJson.format = 'astro_v0.3_convert';
Expand Down
78 changes: 21 additions & 57 deletions source/funkin/backend/system/ui/FunkinSoundTray.hx
Original file line number Diff line number Diff line change
@@ -1,24 +1,14 @@
package funkin.backend.system.ui;
import haxe.io.Bytes;
import openfl.utils.AssetType;

import flixel.system.ui.FlxSoundTray;
import flixel.tweens.FlxTween;
import flixel.system.FlxAssets;
import flixel.tweens.FlxEase;
import openfl.display.Bitmap;
import openfl.display.BitmapData;
import openfl.utils.Assets;
#if sys
import sys.io.File;
import sys.FileSystem;
#end

/**
* Extends the default flixel soundtray, but with some art
* and lil polish!
*
* Gets added to the game in Main.hx, right after FlxGame is new'd
* since it's a Sprite rather than Flixel related object
* V-Slice SoundTray
* Wouldnt say this is the best way of implemeting this, but it works.
* Also Supports The Mods Folders
*/
class FunkinSoundTray extends FlxSoundTray
{
Expand All @@ -30,37 +20,31 @@ class FunkinSoundTray extends FlxSoundTray

public function new()
{
// calls super, then removes all children to add our own
// graphics
super();

removeChildren();

var bg:Bitmap = new Bitmap(getPath("images/soundtray/volumebox", IMAGE));
var bg:Bitmap = new Bitmap(getPathImage("soundtray/volumebox"));
bg.scaleX = graphicScale;
bg.scaleY = graphicScale;
addChild(bg);

y = -height;
visible = false;

// makes an alpha'd version of all the bars (bar_10.png)
var backingBar:Bitmap = new Bitmap(getPath('images/soundtray/bars_10', IMAGE));
var backingBar:Bitmap = new Bitmap(getPathImage('soundtray/bars_10'));
backingBar.x = 9;
backingBar.y = 5;
backingBar.scaleX = graphicScale;
backingBar.scaleY = graphicScale;
addChild(backingBar);
backingBar.alpha = 0.4;

// clear the bars array entirely, it was initialized
// in the super class
_bars = [];

// 1...11 due to how block named the assets,
// we are trying to get assets bars_1-10
for (i in 1...11)
{
var bar:Bitmap = new Bitmap(getPath('images/soundtray/bars_$i', IMAGE), false);
var bar:Bitmap = new Bitmap(getPathImage('soundtray/bars_$i'), false);
bar.x = 9;
bar.y = 5;
bar.scaleX = graphicScale;
Expand All @@ -77,37 +61,22 @@ class FunkinSoundTray extends FlxSoundTray
volumeMaxSound = 'VolMAX';
}

function getPath(path:String, ?TYPE:AssetType = IMAGE):Dynamic
function getPathImage(path:String):Dynamic
{
var ext = '';
switch (TYPE)
{
case IMAGE:
ext = 'png';
var file = Paths.getPath('$path.$ext', IMAGE);
#if MODS_ALLOWED
return BitmapData.fromFile(file);
#end
return Assets.getBitmapData(file);
case SOUND:
ext = Paths.SOUND_EXT;
var uhh = Paths.getPath('$path.$ext', TYPE);
#if MODS_ALLOWED
return uhh;
#end
default:
ext = '';
};
final ext = 'png';
final file = Paths.getPath('images/$path.$ext');

return null;
#if MODS_ALLOWED
return BitmapData.fromFile(file);
#end
return Assets.getBitmapData(file);
}

override public function update(MS:Float):Void
{
y = CoolUtil.coolLerp(y, lerpYPos, 0.1);
alpha = CoolUtil.coolLerp(alpha, alphaTarget, 0.25);

// Animate sound tray thing
if (_timer > 0)
{
_timer -= (MS / 1000);
Expand All @@ -125,7 +94,6 @@ class FunkinSoundTray extends FlxSoundTray
active = false;

#if FLX_SAVE
// Save sound preferences
if (FlxG.save.isBound)
{
FlxG.save.data.mute = FlxG.sound.muted;
Expand All @@ -136,11 +104,6 @@ class FunkinSoundTray extends FlxSoundTray
}
}

/**
* Makes the little volume tray slide out.
*
* @param up Whether the volume is increasing.
*/
override public function show(up:Bool = false):Void
{
_timer = 1;
Expand All @@ -160,11 +123,16 @@ class FunkinSoundTray extends FlxSoundTray
#if MODS_ALLOWED
sound = Paths.returnSound('sounds/soundtray/${up ? volumeUpSound : volumeDownSound}');
#else
sound = FlxAssets.getSound(up ? volumeUpSound : volumeDownSound);
final path = 'assets/shared/sounds/soundtray/';
sound = FlxAssets.getSound(path + (up ? volumeUpSound : volumeDownSound));
#end

if (globalVolume == 10)
#if MODS_ALLOWED
sound = Paths.returnSound('sounds/soundtray/$volumeMaxSound');
#else
sound = FlxAssets.getSound('assets/shared/sounds/soundtray/$volumeMaxSound');
#end

if (sound != null)
FlxG.sound.load(sound).play();
Expand All @@ -173,13 +141,9 @@ class FunkinSoundTray extends FlxSoundTray
for (i in 0..._bars.length)
{
if (i < globalVolume)
{
_bars[i].visible = true;
}
else
{
_bars[i].visible = false;
}
}
}
}
7 changes: 0 additions & 7 deletions source/funkin/game/Main.hx
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,6 @@ class Main extends Sprite

public function new()
{
#if CRISP_VISUALS
@:functionCode("
#include <windows.h>
setProcessDPIAware()
")
#end

super();

if (stage != null)
Expand Down
7 changes: 4 additions & 3 deletions source/funkin/game/editors/ChartingState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -1832,10 +1832,11 @@ class ChartingState extends MusicBeatState implements FlxUIEventHandler.FlxUIEve
catch (e:Dynamic) {}
}

#if DISCORD_ALLOWED
DiscordClient.changePresence('Chart Editor', 'Song: ' + PlayState.SONG.song);
WindowUtil.setTitle('Chart Editor - ${PlayState.SONG.song} (${Difficulty.list[PlayState.storyDifficulty]})');
#if DISCORD_ALLOWED
DiscordClient.changePresence('Chart Editor', 'Song: ' + PlayState.SONG.song);
#end
WindowUtil.setTitle('Chart Editor - ${PlayState.SONG.song} (${Difficulty.list[PlayState.storyDifficulty]})');


updateAudioVolume();
setPitch();
Expand Down
32 changes: 14 additions & 18 deletions source/funkin/game/objects/MenuItem.hx
Original file line number Diff line number Diff line change
Expand Up @@ -10,40 +10,36 @@ import flixel.util.FlxColor;
class MenuItem extends FlxSprite
{
public var targetY:Float = 0;
public var flashingInt:Int = 0;

public function new(x:Float, y:Float, weekName:String = '')
{
super(x, y);
loadGraphic(Paths.image('storymenu/' + weekName));
antialiasing = ClientPrefs.data.antialiasing;
//trace('Test added: ' + WeekData.getWeekNumber(weekNum) + ' (' + weekNum + ')');
antialiasing = funkin.backend.utils.ClientPrefs.data.globalAntialiasing;
}

private var isFlashing:Bool = false;
public var isFlashing(default, set):Bool = false;
private var _flashingElapsed:Float = 0;
final _flashColor = 0xFF33FFFF;
final flashes_ps:Int = 6;

public function startFlashing():Void
public function set_isFlashing(value:Bool = true):Bool
{
isFlashing = true;
isFlashing = value;
_flashingElapsed = 0;
color = (isFlashing) ? _flashColor : FlxColor.WHITE;
return isFlashing;
}

// if it runs at 60fps, fake framerate will be 6
// if it runs at 144 fps, fake framerate will be like 14, and will update the graphic every 0.016666 * 3 seconds still???
// so it runs basically every so many seconds, not dependant on framerate??
// I'm still learning how math works thanks whoever is reading this lol
var fakeFramerate:Int = Math.round((1 / FlxG.elapsed) / 10);

override function update(elapsed:Float)
{
super.update(elapsed);
y = FlxMath.lerp(y, (targetY * 120) + 480, CoolUtil.boundTo(elapsed * 10.2, 0, 1));

if (isFlashing)
flashingInt += 1;

if (flashingInt % fakeFramerate >= Math.floor(fakeFramerate / 2))
color = 0xFF33ffff;
else
color = FlxColor.WHITE;
{
_flashingElapsed += elapsed;
color = (Math.floor(_flashingElapsed * FlxG.updateFramerate * flashes_ps) % 2 == 0) ? _flashColor : FlxColor.WHITE;
}
}
}
6 changes: 5 additions & 1 deletion source/funkin/game/objects/characters/Character.hx
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ class Character extends FlxSprite
this.isPlayer = isPlayer;
changeCharacter(character);


#if BASE_GAME_FILES
switch(curCharacter)
{
case 'pico-speaker':
Expand All @@ -99,6 +101,7 @@ class Character extends FlxSprite
case 'pico-blazin', 'darnell-blazin':
skipDance = true;
}
#end
}

public function changeCharacter(character:String)
Expand Down Expand Up @@ -284,7 +287,7 @@ class Character extends FlxSprite
dance();
finishAnimation();
}

#if BASE_GAME_FILES
switch(curCharacter)
{
case 'pico-speaker':
Expand All @@ -299,6 +302,7 @@ class Character extends FlxSprite
}
if(isAnimationFinished()) playAnim(getAnimationName(), false, false, animation.curAnim.frames.length - 3);
}
#end

if (getAnimationName().startsWith('sing')) holdTimer += elapsed;
else if(isPlayer) holdTimer = 0;
Expand Down
49 changes: 49 additions & 0 deletions source/funkin/game/states/ErrorState.hx
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package funkin.game.states;

class ErrorState extends MusicBeatState
{
public var acceptCallback:Void->Void;
public var backCallback:Void->Void;
public var errorMsg:String;

public function new(error:String, accept:Void->Void = null, back:Void->Void = null)
{
this.errorMsg = error;
this.acceptCallback = accept;
this.backCallback = back;

super();
}

public var errorSine:Float = 0;
public var errorText:FlxText;
override function create()
{
var bg = new FlxSprite().loadGraphic(Paths.image('menuDesat'));
bg.color = FlxColor.GRAY;
bg.antialiasing = ClientPrefs.data.antialiasing;
add(bg);
bg.screenCenter();

errorText = new FlxText(0, 0, FlxG.width - 300, errorMsg, 32);
errorText.setFormat(Paths.font("vcr.ttf"), 32, FlxColor.WHITE, CENTER, FlxTextBorderStyle.OUTLINE, FlxColor.BLACK);
errorText.scrollFactor.set();
errorText.borderSize = 2;
errorText.screenCenter();
add(errorText);
super.create();
}

override function update(elapsed:Float)
{
errorSine += 180 * elapsed;
errorText.alpha = 1 - Math.sin((Math.PI * errorSine) / 180);

if(controls.ACCEPT && acceptCallback != null)
acceptCallback();
else if(controls.BACK && backCallback != null)
backCallback();

super.update(elapsed);
}
}
2 changes: 2 additions & 0 deletions source/funkin/game/states/PlayState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -450,6 +450,7 @@ class PlayState extends MusicBeatState
switch (curStage)
{
case 'stage': new Stage(); //Week 1
#if BASE_GAME_FILES
case 'spooky': new Spooky(); //Week 2
case 'philly': new Philly(); //Week 3
case 'limo': new Limo(); //Week 4
Expand All @@ -460,6 +461,7 @@ class PlayState extends MusicBeatState
case 'tank': new Tank(); //Week 7 - Ugh, Guns, Stress
case 'phillyStreets': new PhillyStreets(); //Weekend 1 - Darnell, Lit Up, 2Hot
case 'phillyBlazin': new PhillyBlazin(); //Weekend 1 - Blazin
#end
}

add(gfGroup); //Needed for blammed lights
Expand Down
Loading

0 comments on commit d6f6944

Please sign in to comment.