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
DMMaster636 authored Jul 18, 2024
2 parents 43fc2d1 + cba599d commit 307853b
Show file tree
Hide file tree
Showing 5 changed files with 83 additions and 37 deletions.
24 changes: 24 additions & 0 deletions assets/base_game/shared/stages/phillyStreets.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"directory": "weekend1",
"defaultZoom": 0.77,
"stageUI": "",

"boyfriend": [1930, 450],
"girlfriend": [1175, 200],
"opponent": [620, 445],
"hide_girlfriend": false,

"camera_boyfriend": [-180, 25],
"camera_opponent": [450, -110],
"camera_girlfriend": [0, 0],
"camera_speed": 1,

"preload": {
},

"_editorMeta": {
"dad": "darnell",
"boyfriend": "pico-playable",
"gf": "nene"
}
}
3 changes: 3 additions & 0 deletions source/backend/BaseStage.hx
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,9 @@ class BaseStage extends FlxBasic
}
}

public function getStageObject(name:String) //Objects can only be accessed *after* create(), use createPost() if you want to mess with them on init
return game.variables.get(name);

//start/end callback functions
public function setStartCallback(myfn:Void->Void)
{
Expand Down
24 changes: 14 additions & 10 deletions source/states/PlayState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -324,11 +324,8 @@ class PlayState extends MusicBeatState
stageUI = "normal";
if (stageData.stageUI != null && stageData.stageUI.trim().length > 0)
stageUI = stageData.stageUI;
else //Backward compatibility
{
if (stageData.isPixelStage == true)
stageUI = "pixel";
}
else if (stageData.isPixelStage == true) //Backward compatibility
stageUI = "pixel";

BF_X = stageData.boyfriend[0];
BF_Y = stageData.boyfriend[1];
Expand Down Expand Up @@ -1923,7 +1920,8 @@ class PlayState extends MusicBeatState
if (((skipHealthCheck && instakillOnMiss) || health <= 0) && !practiceMode && !isDead)
{
var ret:Dynamic = callOnScripts('onGameOver', null, true);
if(ret != LuaUtils.Function_Stop) {
if(ret != LuaUtils.Function_Stop)
{
FlxG.animationTimeScale = 1;
boyfriend.stunned = true;
deathCounter++;
Expand All @@ -1938,6 +1936,7 @@ class PlayState extends MusicBeatState
persistentDraw = false;
FlxTimer.globalManager.clear();
FlxTween.globalManager.clear();
FlxG.camera.setFilters([]);

#if VIDEOS_ALLOWED
for(vid in VideoSprite._videos)
Expand Down Expand Up @@ -3050,7 +3049,7 @@ class PlayState extends MusicBeatState
lua.call('onDestroy', []);
lua.stop();
}
luaArray = [];
luaArray = null;
FunkinLua.customFunctions.clear();
#end

Expand All @@ -3062,16 +3061,21 @@ class PlayState extends MusicBeatState
script.destroy();
}

while (hscriptArray.length > 0)
hscriptArray.pop();
hscriptArray = null;
#end
stagesFunc(function(stage:BaseStage) stage.destroy());

FlxG.stage.removeEventListener(KeyboardEvent.KEY_DOWN, onKeyPress);
FlxG.stage.removeEventListener(KeyboardEvent.KEY_UP, onKeyRelease);
FlxG.animationTimeScale = 1;

FlxG.camera.setFilters([]);

#if FLX_PITCH FlxG.sound.music.pitch = 1; #end
FlxG.animationTimeScale = 1;

Note.globalRgbShaders = [];
backend.NoteTypesConfig.clearNoteTypesData();

instance = null;
super.destroy();
}
Expand Down
49 changes: 27 additions & 22 deletions source/states/editors/ChartingState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,7 @@ class ChartingState extends MusicBeatState implements PsychUIEventHandler.PsychU
bg.scrollFactor.set();
add(bg);

if(chartEditorSave.data.theme != null)
changeTheme(chartEditorSave.data.theme, false);
changeTheme(chartEditorSave.data.theme != null ? chartEditorSave.data.theme : DEFAULT, false);

var tipText:FlxText = new FlxText(FlxG.width - 210, FlxG.height - 30, 200, 'Press F1 for Help', 20);
tipText.cameras = [camUI];
Expand Down Expand Up @@ -639,7 +638,7 @@ class ChartingState extends MusicBeatState implements PsychUIEventHandler.PsychU
}
positionNoteYOnTime(event, secNum);
}
loadSection();
loadSection(null, false);
showOutput('Zoom: ${Math.round(curZoom * 100)}%');
scrollY = (Conductor.songPosition / Conductor.crochet * GRID_SIZE * 4) * curZoom - FlxG.height/2;
}
Expand Down Expand Up @@ -856,7 +855,7 @@ class ChartingState extends MusicBeatState implements PsychUIEventHandler.PsychU
var hitSoundOpp:Bool = (hitsoundOpponentStepper.value > 0);
for (note in curRenderedNotes)
{
if(note == null) continue;
if(note == null || note.isEvent) continue;

note.alpha = (note.strumTime >= Conductor.songPosition) ? 1 : 0.6;
if(canPlayHitSound && Conductor.songPosition > note.strumTime && lastTime <= note.strumTime)
Expand Down Expand Up @@ -898,7 +897,7 @@ class ChartingState extends MusicBeatState implements PsychUIEventHandler.PsychU
{
if(qPress != ePress)
{
note.setSustainLength(note.sustainLength + addSus, Conductor.stepCrochet);
note.setSustainLength(note.sustainLength + addSus, Conductor.stepCrochet, curZoom);
if(selectedNotes.length == 1)
susLengthStepper.value = note.sustainLength;
}
Expand Down Expand Up @@ -1239,7 +1238,7 @@ class ChartingState extends MusicBeatState implements PsychUIEventHandler.PsychU

var swagNote:MetaNote = new MetaNote(daStrumTime, daNoteData, note);
swagNote.mustPress = gottaHitNote;
swagNote.setSustainLength(note[2], cachedSectionCrochets[secNum] / 4);
swagNote.setSustainLength(note[2], cachedSectionCrochets[secNum] / 4, curZoom);
swagNote.gfNote = (section.gfSection && gottaHitNote == section.mustHitSection);
swagNote.noteType = note[3];
swagNote.scrollFactor.x = 0;
Expand Down Expand Up @@ -1322,21 +1321,25 @@ class ChartingState extends MusicBeatState implements PsychUIEventHandler.PsychU
else if(secNum < PlayState.SONG.notes.length && note[0] >= time - 0.000001) note[0] = time - 0.000001;
}

if(FlxG.sound.music != null && time >= FlxG.sound.music.length && secNum < PlayState.SONG.notes.length-1) //Delete extra sections
if(FlxG.sound.music != null && time >= FlxG.sound.music.length)
{
while(PlayState.SONG.notes.length-1 > secNum)
var lastSectionNum:Int = PlayState.SONG.notes.length - 1;
if(secNum < lastSectionNum) //Delete extra sections
{
PlayState.SONG.notes.pop();
while(PlayState.SONG.notes.length - 1 > secNum)
{
PlayState.SONG.notes.pop();
}

trace('breaking at section $secNum');
reachedLimit = true;
break;
}
else if(secNum == lastSectionNum)
{
trace('reached limit at section $secNum');
reachedLimit = true;
}

trace('breaking at section $secNum');
reachedLimit = true;
break;
}
else if(secNum == PlayState.SONG.notes.length - 1)
{
//trace('breaking at section $secNum');
reachedLimit = true;
}
}

Expand Down Expand Up @@ -1387,7 +1390,7 @@ class ChartingState extends MusicBeatState implements PsychUIEventHandler.PsychU
var showNextSection:Bool = true;
var showNoteTypeLabels:Bool = true;
var forceDataUpdate:Bool = true;
function loadSection(?sec:Null<Int> = null)
function loadSection(?sec:Null<Int> = null, ?clearSelection:Bool = true)
{
if(sec != null) curSec = sec;
curSec = Std.int(FlxMath.bound(curSec, 0, PlayState.SONG.notes.length-1));
Expand Down Expand Up @@ -1421,7 +1424,7 @@ class ChartingState extends MusicBeatState implements PsychUIEventHandler.PsychU
eventLockOverlay.scale.y = hei;
eventLockOverlay.updateHitbox();

resetSelectedNotes();
if(clearSelection) resetSelectedNotes();
softReloadNotes();
updateHeads();

Expand Down Expand Up @@ -1466,6 +1469,7 @@ class ChartingState extends MusicBeatState implements PsychUIEventHandler.PsychU
if(!firstNote) sectionFirstNoteID = num;
curRenderedNotes.add(note);
note.alpha = (note.strumTime >= Conductor.songPosition) ? 1 : 0.6;
if(note.hasSustain) note.updateSustainToZoom(cachedSectionCrochets[curSec] / 4, curZoom);
}
}

Expand Down Expand Up @@ -1501,6 +1505,7 @@ class ChartingState extends MusicBeatState implements PsychUIEventHandler.PsychU
{
behindRenderedNotes.add(note);
note.alpha = 0.4;
if(note.hasSustain) note.updateSustainToZoom(cachedSectionCrochets[curSec] / 4, curZoom);
}

if(SHOW_EVENT_COLUMN)
Expand Down Expand Up @@ -1974,10 +1979,10 @@ class ChartingState extends MusicBeatState implements PsychUIEventHandler.PsychU
for (note in selectedNotes)
{
if(note == null && !note.isEvent) continue;
note.setSustainLength(note.sustainLength + (susLengthStepper.value - susLengthLastVal), Conductor.stepCrochet);
note.setSustainLength(note.sustainLength + (susLengthStepper.value - susLengthLastVal), Conductor.stepCrochet, curZoom);
}
}
else if(selectedNotes.length == 1) selectedNotes[0].setSustainLength(susLengthStepper.value, Conductor.stepCrochet);
else if(selectedNotes.length == 1) selectedNotes[0].setSustainLength(susLengthStepper.value, Conductor.stepCrochet, curZoom);
susLengthLastVal = susLengthStepper.value;
}
};
Expand Down
20 changes: 15 additions & 5 deletions source/states/editors/content/MetaNote.hx
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,12 @@ class MetaNote extends Note
this.strumTime = v;
}

public function setSustainLength(v:Float, stepCrochet:Float)
var _lastZoom:Float = -1;
public function setSustainLength(v:Float, stepCrochet:Float, zoom:Float = 1)
{
_lastZoom = zoom;
v = Math.round(v / (stepCrochet / 2)) * (stepCrochet / 2);
sustainLength = Math.max(Math.min(v, stepCrochet * 128), 0);
songData[2] = v;
songData[2] = sustainLength = Math.max(Math.min(v, stepCrochet * 128), 0);

if(sustainLength > 0)
{
Expand All @@ -62,10 +63,19 @@ class MetaNote extends Note
sustainSprite = new FlxSprite().makeGraphic(1, 1, FlxColor.WHITE);
sustainSprite.scrollFactor.x = 0;
}
sustainSprite.setGraphicSize(8, Math.max(0, (v * ChartingState.GRID_SIZE / stepCrochet) + ChartingState.GRID_SIZE/2));
sustainSprite.setGraphicSize(8, Math.max(0, (v * ChartingState.GRID_SIZE / stepCrochet * zoom) + ChartingState.GRID_SIZE/2));
sustainSprite.updateHitbox();
}
}

public var hasSustain(get, never):Bool;
function get_hasSustain() return (!isEvent && sustainLength > 0);

public function updateSustainToZoom(stepCrochet:Float, zoom:Float = 1)
{
if(_lastZoom == zoom) return;
setSustainLength(sustainLength, stepCrochet, zoom);
}

var _noteTypeText:FlxText;
public function findNoteTypeText(num:Int)
Expand Down Expand Up @@ -147,7 +157,7 @@ class EventMetaNote extends MetaNote
super.draw();
}

override function setSustainLength(v:Float, stepCrochet:Float) {}
override function setSustainLength(v:Float, stepCrochet:Float, zoom:Float = 1) {}

public var events:Array<Array<String>>;
public function updateEventText()
Expand Down

0 comments on commit 307853b

Please sign in to comment.