Skip to content

Commit

Permalink
Merge branch 'ShadowMario:experimental' into experimental
Browse files Browse the repository at this point in the history
  • Loading branch information
PartnerCapPikachu authored Oct 12, 2024
2 parents 030c22a + 6e7c936 commit d85466e
Show file tree
Hide file tree
Showing 7 changed files with 108 additions and 48 deletions.
43 changes: 21 additions & 22 deletions source/objects/NoteSplash.hx
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class NoteSplash extends FlxSprite
loadSplash(splash);
}

function loadSplash(?splash:String)
public function loadSplash(?splash:String)
{
config = null; // Reset config to the default so when reloaded it can be set properly
skin = null;
Expand Down Expand Up @@ -103,7 +103,7 @@ class NoteSplash extends FlxSprite
}
}

public function spawnSplashNote(note:Note, ?noteData:Int, ?randomize:Bool = true)
public function spawnSplashNote(note:Note, ?noteData:Null<Int>, ?randomize:Bool = true)
{
if (note != null && note.noteSplashData.texture != null)
loadSplash(note.noteSplashData.texture);
Expand All @@ -114,7 +114,6 @@ class NoteSplash extends FlxSprite
if (babyArrow != null)
setPosition(babyArrow.x, babyArrow.y); // To prevent it from being misplaced for one game tick

var noteData:Null<Int> = noteData;
if (noteData == null)
noteData = note != null ? note.noteData : 0;

Expand All @@ -126,7 +125,7 @@ class NoteSplash extends FlxSprite

while (true)
{
var data:Int = noteData % 4 + (datas * 4);
var data:Int = noteData % Note.colArray.length + (datas * Note.colArray.length);
if (!noteDataMap.exists(data) || !animation.exists(noteDataMap[data]))
break;

Expand All @@ -138,7 +137,7 @@ class NoteSplash extends FlxSprite
{
for (i in 0...anims)
{
var data = noteData % 4 + (i * 4);
var data = noteData % Note.colArray.length + (i * Note.colArray.length);
if (!animArray.contains(data))
animArray.push(data);
}
Expand All @@ -148,30 +147,19 @@ class NoteSplash extends FlxSprite
noteData = animArray[FlxG.random.bool() ? 0 : 1];
}

var anim:String = null;
function playDefaultAnim()
{
var animation:String = noteDataMap.get(noteData);
if (animation != null && this.animation.exists(animation))
{
this.animation.play(animation);
anim = animation;
}
else visible = false;
}

playDefaultAnim();
this.noteData = noteData;
var anim:String = playDefaultAnim();

var tempShader:RGBPalette = null;
if (config.allowRGB)
{
if (note == null)
note = new Note(0, noteData);

Note.initializeGlobalRGBShader(noteData % 4);
Note.initializeGlobalRGBShader(noteData % Note.colArray.length);
function useDefault()
{
tempShader = Note.globalRgbShaders[noteData % 4];
tempShader = Note.globalRgbShaders[noteData % Note.colArray.length];
}

if(((cast FlxG.state) is NoteSplashEditorState) ||
Expand All @@ -188,8 +176,8 @@ class NoteSplash extends FlxSprite
{
if (i > 2) break;

var arr:Array<FlxColor> = ClientPrefs.data.arrowRGB[noteData % 4];
if(PlayState.isPixelStage) arr = ClientPrefs.data.arrowRGBPixel[noteData % 4];
var arr:Array<FlxColor> = ClientPrefs.data.arrowRGB[noteData % Note.colArray.length];
if(PlayState.isPixelStage) arr = ClientPrefs.data.arrowRGBPixel[noteData % Note.colArray.length];

var rgb = colors[i];
if (rgb == null)
Expand Down Expand Up @@ -257,6 +245,17 @@ class NoteSplash extends FlxSprite
animation.curAnim.frameRate = FlxG.random.int(minFps, maxFps);
}
}

public var noteData:Int = 0;
public function playDefaultAnim()
{
var animation:String = noteDataMap.get(noteData);
if (animation != null && this.animation.exists(animation))
this.animation.play(animation, true);
else
visible = false;
return animation;
}

override function update(elapsed:Float)
{
Expand Down
2 changes: 1 addition & 1 deletion source/options/Option.hx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class Option
public var type:OptionType = BOOL;

public var scrollSpeed:Float = 50; //Only works on int/float, defines how fast it scrolls per second while holding left/right
private var variable:String = null; //Variable from ClientPrefs.hx
public var variable(default, null):String = null; //Variable from ClientPrefs.hx
public var defaultValue:Dynamic = null;

public var curOption:Int = 0; //Don't change this
Expand Down
85 changes: 73 additions & 12 deletions source/options/VisualsSettingsSubState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,45 @@ package options;

import objects.Note;
import objects.StrumNote;
import objects.NoteSplash;
import objects.Alphabet;

class VisualsSettingsSubState extends BaseOptionsMenu
{
var noteOptionID:Int = -1;
var notes:FlxTypedGroup<StrumNote>;
var notesTween:Array<FlxTween> = [];
var splashes:FlxTypedGroup<NoteSplash>;
var noteY:Float = 90;
public function new()
{
title = Language.getPhrase('visuals_menu', 'Visuals Settings');
rpcTitle = 'Visuals Settings Menu'; //for Discord Rich Presence

// for note skins
// for note skins and splash skins
notes = new FlxTypedGroup<StrumNote>();
splashes = new FlxTypedGroup<NoteSplash>();
for (i in 0...Note.colArray.length)
{
var note:StrumNote = new StrumNote(370 + (560 / Note.colArray.length) * i, -200, i, 0);
note.centerOffsets();
note.centerOrigin();
note.playAnim('static');
notes.add(note);

var splash:NoteSplash = new NoteSplash();
splash.noteData = i;
splash.setPosition(note.x, noteY);
splash.loadSplash();
splash.visible = false;
splash.alpha = ClientPrefs.data.splashAlpha;
splash.animation.finishCallback = function(name:String) splash.visible = false;
splashes.add(splash);

Note.initializeGlobalRGBShader(i % Note.colArray.length);
splash.rgbShader.copyValues(Note.globalRgbShaders[i % Note.colArray.length]);
}

// options

var noteSkins:Array<String> = Mods.mergeAllTextsNamed('images/noteSkins/list.txt');
if(noteSkins.length > 0)
{
Expand Down Expand Up @@ -58,6 +71,7 @@ class VisualsSettingsSubState extends BaseOptionsMenu
STRING,
noteSplashes);
addOption(option);
option.onChange = onChangeSplashSkin;
}

var option:Option = new Option('Note Splash Opacity',
Expand All @@ -70,6 +84,7 @@ class VisualsSettingsSubState extends BaseOptionsMenu
option.changeValue = 0.1;
option.decimals = 1;
addOption(option);
option.onChange = playNoteSplashes;

var option:Option = new Option('Hide HUD',
'If checked, hides most HUD elements.',
Expand Down Expand Up @@ -154,22 +169,38 @@ class VisualsSettingsSubState extends BaseOptionsMenu

super();
add(notes);
add(splashes);
}

var notesShown:Bool = false;
override function changeSelection(change:Int = 0)
{
super.changeSelection(change);

if(noteOptionID < 0) return;

for (i in 0...Note.colArray.length)
switch(curOption.variable)
{
var note:StrumNote = notes.members[i];
if(notesTween[i] != null) notesTween[i].cancel();
if(curSelected == noteOptionID)
notesTween[i] = FlxTween.tween(note, {y: noteY}, Math.abs(note.y / (200 + noteY)) / 3, {ease: FlxEase.quadInOut});
else
notesTween[i] = FlxTween.tween(note, {y: -200}, Math.abs(note.y / (200 + noteY)) / 3, {ease: FlxEase.quadInOut});
case 'noteSkin', 'splashSkin', 'splashAlpha':
if(!notesShown)
{
for (note in notes.members)
{
FlxTween.cancelTweensOf(note);
FlxTween.tween(note, {y: noteY}, Math.abs(note.y / (200 + noteY)) / 3, {ease: FlxEase.quadInOut});
}
}
notesShown = true;
if(curOption.variable.startsWith('splash') && Math.abs(notes.members[0].y - noteY) < 25) playNoteSplashes();

default:
if(notesShown)
{
for (note in notes.members)
{
FlxTween.cancelTweensOf(note);
FlxTween.tween(note, {y: -200}, Math.abs(note.y / (200 + noteY)) / 3, {ease: FlxEase.quadInOut});
}
}
notesShown = false;
}
}

Expand Down Expand Up @@ -204,6 +235,36 @@ class VisualsSettingsSubState extends BaseOptionsMenu
note.playAnim('static');
}

function onChangeSplashSkin()
{
for (splash in splashes)
splash.loadSplash();

playNoteSplashes();
}

function playNoteSplashes()
{
for (splash in splashes)
{
var anim:String = splash.playDefaultAnim();
splash.visible = true;
splash.alpha = ClientPrefs.data.splashAlpha;

var conf = splash.config.animations.get(anim);
var offsets:Array<Float> = [0, 0];

if (conf != null)
offsets = conf.offsets;

if (offsets != null)
{
splash.centerOffsets();
splash.offset.set(offsets[0], offsets[1]);
}
}
}

override function destroy()
{
if(changedMusic && !OptionsState.onPlayState) FlxG.sound.playMusic(Paths.music('freakyMenu'), 1, true);
Expand Down
16 changes: 8 additions & 8 deletions source/states/FreeplayState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,14 @@ class FreeplayState extends MusicBeatState
#end

if(WeekData.weeksList.length < 1)
{
FlxTransitionableState.skipNextTransIn = true;
persistentUpdate = false;
MusicBeatState.switchState(new states.ErrorState("NO WEEKS ADDED FOR FREEPLAY\n\nPress ACCEPT to go to the Week Editor Menu.\nPress BACK to return to Main Menu.",
function() MusicBeatState.switchState(new states.editors.WeekEditorState()),
function() MusicBeatState.switchState(new states.MainMenuState())));
return;
}
{
FlxTransitionableState.skipNextTransIn = true;
persistentUpdate = false;
MusicBeatState.switchState(new states.ErrorState("NO WEEKS ADDED FOR FREEPLAY\n\nPress ACCEPT to go to the Week Editor Menu.\nPress BACK to return to Main Menu.",
function() MusicBeatState.switchState(new states.editors.WeekEditorState()),
function() MusicBeatState.switchState(new states.MainMenuState())));
return;
}

for (i in 0...WeekData.weeksList.length)
{
Expand Down
4 changes: 2 additions & 2 deletions source/states/PlayState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -3090,11 +3090,11 @@ class PlayState extends MusicBeatState
if(note != null) {
var strum:StrumNote = playerStrums.members[note.noteData];
if(strum != null)
spawnNoteSplash(strum.x, strum.y, note.noteData, note, strum);
spawnNoteSplash(note, strum);
}
}

public function spawnNoteSplash(x:Float, y:Float, data:Int, note:Note, strum:StrumNote) {
public function spawnNoteSplash(note:Note, strum:StrumNote) {
var splash:NoteSplash = new NoteSplash();
splash.babyArrow = strum;
splash.spawnSplashNote(note);
Expand Down
2 changes: 1 addition & 1 deletion source/states/StoryMenuState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ class StoryMenuState extends MusicBeatState

override function update(elapsed:Float)
{
if(grpWeekText.length < 1)
if(WeekData.weeksList.length < 1)
{
if (controls.BACK && !movedBack && !selectedWeek)
{
Expand Down
4 changes: 2 additions & 2 deletions source/states/editors/ChartingState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -864,7 +864,7 @@ class ChartingState extends MusicBeatState implements PsychUIEventHandler.PsychU
if(shiftAdd > 0)
{
loadSection(curSec - shiftAdd);
Conductor.songPosition = FlxG.sound.music.time = cachedSectionTimes[curSec] + 0.000001;
Conductor.songPosition = FlxG.sound.music.time = cachedSectionTimes[curSec] - Conductor.offset + 0.000001;
}
}
else if(FlxG.keys.justPressed.D)
Expand All @@ -874,7 +874,7 @@ class ChartingState extends MusicBeatState implements PsychUIEventHandler.PsychU
if(shiftAdd > 0)
{
loadSection(curSec + shiftAdd);
Conductor.songPosition = FlxG.sound.music.time = cachedSectionTimes[curSec] + 0.000001;
Conductor.songPosition = FlxG.sound.music.time = cachedSectionTimes[curSec] - Conductor.offset + 0.000001;
}
}
}
Expand Down

0 comments on commit d85466e

Please sign in to comment.