Skip to content

Commit

Permalink
Deez nuts
Browse files Browse the repository at this point in the history
fixed char-based note colors crashing if the stage specified to hide gf
fixed double note ghosts crashing when triggered with gf notes if gf is hidden
added a little checkbox that hides the grid if turned off (off by default)
ADDED CHART EDITOR ANTI-CRASHING
  • Loading branch information
JordanSantiagoYT committed Nov 25, 2023
1 parent 9348c23 commit a9ada44
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 13 deletions.
2 changes: 1 addition & 1 deletion source/CoolUtil.hx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class CoolUtil
inline public static function quantize(f:Float, snap:Float){
// changed so this actually works lol
var m:Float = Math.fround(f * snap);
trace(snap);
//trace(snap); yo why does it trace the snap
return (m / snap);
}

Expand Down
2 changes: 1 addition & 1 deletion source/Note.hx
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ class Note extends FlxSprite
this.shader = new ColoredNoteShader(PlayState.instance.boyfriend.healthColorArray[0], PlayState.instance.boyfriend.healthColorArray[1], PlayState.instance.boyfriend.healthColorArray[2], false, 10);
}
if (gfNote) {
this.shader = new ColoredNoteShader(PlayState.instance.gf.healthColorArray[0], PlayState.instance.gf.healthColorArray[1], PlayState.instance.gf.healthColorArray[2], false, 10);
if (PlayState.instance.gf != null) this.shader = new ColoredNoteShader(PlayState.instance.gf.healthColorArray[0], PlayState.instance.gf.healthColorArray[1], PlayState.instance.gf.healthColorArray[2], false, 10);
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions source/PlayState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -7100,7 +7100,7 @@ if (ClientPrefs.showNPS) {
case 'gf':
if (gfGhostTween != null)
gfGhostTween.cancel();
ghost.color = FlxColor.fromRGB(gf.healthColorArray[0] + 50, gf.healthColorArray[1] + 50, gf.healthColorArray[2] + 50);
if (gf != null) ghost.color = FlxColor.fromRGB(gf.healthColorArray[0] + 50, gf.healthColorArray[1] + 50, gf.healthColorArray[2] + 50);
gfGhostTween = FlxTween.tween(gfGhost, {alpha: 0}, 0.75, {
ease: FlxEase.linear,
onComplete: function(twn:FlxTween)
Expand Down Expand Up @@ -8312,7 +8312,7 @@ if (!allSicks && ClientPrefs.colorRatingHit && ClientPrefs.hudType != 'Tails Get
final animToPlay:String = singAnimations[Std.int(Math.abs(daNote.noteData))] + altAnim;
if(daNote.gfNote && ClientPrefs.charsAndBG) {
char = gf;
if (ClientPrefs.doubleGhost)
if (ClientPrefs.doubleGhost && gf != null)
{
if (!daNote.isSustainNote && noteRows[daNote.mustPress?0:1][daNote.row].length > 1)
{
Expand Down Expand Up @@ -8513,7 +8513,7 @@ if (!allSicks && ClientPrefs.colorRatingHit && ClientPrefs.hudType != 'Tails Get
if (ClientPrefs.noteColorStyle == 'Char-Based')
{
if (!isDadNote) splashColor = FlxColor.fromRGB(boyfriend.healthColorArray[0], boyfriend.healthColorArray[1], boyfriend.healthColorArray[2]);
if (isGfNote) splashColor = FlxColor.fromRGB(gf.healthColorArray[0], gf.healthColorArray[1], gf.healthColorArray[2]);
if (isGfNote && gf != null) splashColor = FlxColor.fromRGB(gf.healthColorArray[0], gf.healthColorArray[1], gf.healthColorArray[2]);
}

var splash:NoteSplash = grpNoteSplashes.recycle(NoteSplash);
Expand Down
2 changes: 1 addition & 1 deletion source/Song.hx
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class Song
public var speed:Float = 1;
public var stage:String;
public var songCredit:String;
public var event7:String;
public var event7:String = 'None';
public var event7Value:String;
public var windowName:String;
public var validScore:Bool = true;
Expand Down
2 changes: 1 addition & 1 deletion source/StrumNote.hx
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ class StrumNote extends FlxSprite
rgbShaderEnabled = true;
}
public function enableRGBGF() {
if (Std.isOfType(this.shader, ColoredNoteShader))
if (Std.isOfType(this.shader, ColoredNoteShader) && PlayState.instance.gf != null)
cast(this.shader, ColoredNoteShader).setColors(PlayState.instance.gf.healthColorArray[0], PlayState.instance.gf.healthColorArray[1], PlayState.instance.gf.healthColorArray[2]);
cast(this.shader, ColoredNoteShader).enabled.value = [true];
rgbShaderEnabled = true;
Expand Down
45 changes: 39 additions & 6 deletions source/editors/ChartingState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ class ChartingState extends MusicBeatState
private var noteTypeIntMap:Map<Int, String> = new Map<Int, String>();
private var noteTypeMap:Map<String, Null<Int>> = new Map<String, Null<Int>>();
public var ignoreWarnings = false;
public var showTheGrid = false;
public var undos = [];
public var redos = [];
var eventStuff:Array<Dynamic> =
Expand Down Expand Up @@ -537,6 +538,7 @@ class ChartingState extends MusicBeatState

var check_mute_inst:FlxUICheckBox = null;
var check_vortex:FlxUICheckBox = null;
var check_showGrid:FlxUICheckBox = null;
var check_warnings:FlxUICheckBox = null;
var playSoundBf:FlxUICheckBox = null;
var playSoundDad:FlxUICheckBox = null;
Expand Down Expand Up @@ -575,7 +577,8 @@ class ChartingState extends MusicBeatState

var reloadSongJson:FlxButton = new FlxButton(reloadSong.x, saveButton.y + 30, "Reload JSON", function()
{
openSubState(new Prompt('This action will clear current progress.\n\nProceed?', 0, function(){loadJson(_song.song.toLowerCase()); }, null,ignoreWarnings));
openSubState(new Prompt('This action will clear current progress.\n\nProceed?', 0, function()
{loadJson(_song.song.toLowerCase()); }, null,ignoreWarnings));
});

var loadAutosaveBtn:FlxButton = new FlxButton(reloadSongJson.x, reloadSongJson.y + 30, 'Load Autosave', function()
Expand Down Expand Up @@ -793,6 +796,10 @@ class ChartingState extends MusicBeatState
FlxG.camera.follow(camPos);
}

function songJsonPopup() { //you tried reloading the json, but it doesn't exist
CoolUtil.coolError("The engine failed to load the JSON! \nEither it doesn't exist, or the name doesn't match with the one you're putting?", "JS Engine Anti-Crash Tool");
}

var creditInputText:FlxUIInputText;
var winNameInputText:FlxUIInputText;
function addSongDataUI():Void //therell be more added here later
Expand Down Expand Up @@ -1669,6 +1676,17 @@ class ChartingState extends MusicBeatState
reloadGridLayer();
};

check_showGrid = new FlxUICheckBox(10, 220, null, null, "Show Grid", 100);
if (FlxG.save.data.showGrid == null) FlxG.save.data.showGrid = false;
check_showGrid.checked = FlxG.save.data.showGrid;

check_showGrid.callback = function()
{
FlxG.save.data.showGrid = check_showGrid.checked;
showTheGrid = FlxG.save.data.showGrid;
reloadGridLayer();
};

check_warnings = new FlxUICheckBox(10, 120, null, null, "Ignore Progress Warnings", 100);
if (FlxG.save.data.ignoreWarnings == null) FlxG.save.data.ignoreWarnings = false;
check_warnings.checked = FlxG.save.data.ignoreWarnings;
Expand Down Expand Up @@ -1773,6 +1791,7 @@ class ChartingState extends MusicBeatState
tab_group_chart.add(check_vortex);
tab_group_chart.add(mouseScrollingQuant);
tab_group_chart.add(check_warnings);
tab_group_chart.add(check_showGrid);
tab_group_chart.add(playSoundBf);
tab_group_chart.add(playSoundDad);
UI_box.addGroup(tab_group_chart);
Expand Down Expand Up @@ -2721,7 +2740,9 @@ class ChartingState extends MusicBeatState
var lastSecBeatsNext:Float = 0;
function reloadGridLayer() {
gridLayer.clear();
gridBG = FlxGridOverlay.create(GRID_SIZE, GRID_SIZE, GRID_SIZE * 9, Std.int(GRID_SIZE * getSectionBeats() * 4 * zoomList[curZoom]));
if (showTheGrid)
gridBG = FlxGridOverlay.create(GRID_SIZE, GRID_SIZE, GRID_SIZE * 9, Std.int(GRID_SIZE * getSectionBeats() * 4 * zoomList[curZoom]));
else gridBG = new FlxSprite().makeGraphic(Std.int(GRID_SIZE * 9), Std.int(GRID_SIZE * getSectionBeats() * 4 * zoomList[curZoom]), 0xffe7e6e6);

#if desktop
if(FlxG.save.data.chart_waveformInst || FlxG.save.data.chart_waveformVoices) {
Expand All @@ -2733,11 +2754,15 @@ class ChartingState extends MusicBeatState
var foundNextSec:Bool = false;
if(sectionStartTime(1) <= FlxG.sound.music.length)
{
nextGridBG = FlxGridOverlay.create(GRID_SIZE, GRID_SIZE, GRID_SIZE * 9, Std.int(GRID_SIZE * getSectionBeats(curSec + 1) * 4 * zoomList[curZoom]));
leHeight = Std.int(gridBG.height + nextGridBG.height);
foundNextSec = true;
if (showTheGrid) {
// If showTheGrid is enabled, create a grid overlay for the next section
nextGridBG = FlxGridOverlay.create(GRID_SIZE, GRID_SIZE, GRID_SIZE * 9, Std.int(GRID_SIZE * getSectionBeats(curSec + 1) * 4 * zoomList[curZoom]));
leHeight = Std.int(gridBG.height + nextGridBG.height);
foundNextSec = true;
} else { // Else, make a simple gray graphic
nextGridBG = new FlxSprite().makeGraphic(1, 1, FlxColor.TRANSPARENT);
}
}
else nextGridBG = new FlxSprite().makeGraphic(1, 1, FlxColor.TRANSPARENT);
nextGridBG.y = gridBG.height;

gridLayer.add(nextGridBG);
Expand Down Expand Up @@ -3704,6 +3729,8 @@ class ChartingState extends MusicBeatState
{
//shitty null fix, i fucking hate it when this happens
//make it look sexier if possible
if(sys.FileSystem.exists(Paths.json(song + '/' + song)) || sys.FileSystem.exists(Paths.modsJson(song + '/' + song)))
{
if (CoolUtil.difficulties[PlayState.storyDifficulty] != CoolUtil.defaultDifficulty) {
if(CoolUtil.difficulties[PlayState.storyDifficulty] == null){
PlayState.SONG = Song.loadFromJson(song.toLowerCase(), song.toLowerCase());
Expand All @@ -3714,6 +3741,12 @@ class ChartingState extends MusicBeatState
PlayState.SONG = Song.loadFromJson(song.toLowerCase(), song.toLowerCase());
}
MusicBeatState.resetState();
}
else
{
trace (song + "'s JSON doesn't exist!");
songJsonPopup(); //HAH, IT AINT CRASHING NOW
}
}

public function autosaveSong():Void
Expand Down

1 comment on commit a9ada44

@StinkTheStinker
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

w anti crash

Please sign in to comment.