This commit is contained in:
Yoshman29
2023-01-22 14:37:26 +01:00
15 changed files with 369 additions and 353 deletions
+1 -1
View File
@@ -1 +1 @@
2143
2148
+24 -6
View File
@@ -18,17 +18,17 @@ class Stage extends FlxBasic implements IBeatReceiver {
public var stagePath:String;
public var stageSprites:Map<String, FlxSprite> = [];
public var stageScript:Script;
public function getSprite(name:String) {
return stageSprites[name];
}
public function new(stage:String, ?state:FlxState) {
super();
if (state == null) state = PlayState.instance;
if (state == null) state = FlxG.state;
stagePath = Paths.xml('stages/$stage');
try {
if (Assets.exists(stagePath)) stageXML = new Access(Xml.parse(Assets.getText(stagePath)).firstElement());
@@ -49,7 +49,7 @@ class Stage extends FlxBasic implements IBeatReceiver {
spritesParentFolder = stageXML.att.folder;
if (spritesParentFolder.charAt(spritesParentFolder.length-1) != "/") spritesParentFolder = spritesParentFolder + "/";
}
for(node in stageXML.elements) {
var sprite:Dynamic = switch(node.name) {
case "sprite" | "spr" | "sparrow":
@@ -59,10 +59,28 @@ class Stage extends FlxBasic implements IBeatReceiver {
if (!node.has.zoomfactor && PlayState.instance != null)
spr.initialZoom = PlayState.instance.defaultCamZoom;
stageSprites.set(spr.name, spr);
state.add(spr);
spr;
case "box":
trace('HOLY FUCK BOX DETECTED'); // TODO: someone help this aint doing shit!! >:(
if ( !node.has.name || !node.has.width || !node.has.height) continue;
var spr = new FlxSprite(
(node.has.x) ? Std.parseFloat(node.att.x) : 0,
(node.has.y) ? Std.parseFloat(node.att.y) : 0
).makeGraphic(
Std.parseInt(node.att.width),
Std.parseInt(node.att.height),
(node.has.color) ? Std.parseInt(node.att.color) : 0xFFFFFFFF
);
trace(node.att.name, node.att.width, node.att.height);
stageSprites.set(node.getAtt("name"), spr);
state.add(spr);
spr;
case "boyfriend" | "bf":
if (PlayState.instance == null || PlayState.instance.boyfriend == null) continue;
doCharNodeShit(PlayState.instance.boyfriend, node);
@@ -102,7 +120,7 @@ class Stage extends FlxBasic implements IBeatReceiver {
}
PlayState.instance.scripts.add(stageScript);
}
private static function doCharNodeShit(char:Character, node:Access) {
if (node.has.x) {
+1 -1
View File
@@ -39,7 +39,7 @@ class BetaWarningState extends MusicBeatState {
if (controls.ACCEPT && !transitioning) {
transitioning = true;
CoolUtil.playMenuSFX(1);
CoolUtil.playMenuSFX(CONFIRM);
FlxG.camera.flash(FlxColor.WHITE, 1, function() {
FlxG.camera.fade(FlxColor.BLACK, 2.5, false, function() {
FlxTransitionableState.skipNextTransIn = FlxTransitionableState.skipNextTransOut = true;
+4 -7
View File
@@ -167,7 +167,6 @@ class FreeplayState extends MusicBeatState
super.create();
}
#if PRELOAD_ALL
/**
@@ -231,7 +230,7 @@ class FreeplayState extends MusicBeatState
if (controls.BACK)
{
CoolUtil.playMenuSFX(2, 0.7);
CoolUtil.playMenuSFX(CANCEL, 0.7);
FlxG.switchState(new MainMenuState());
}
@@ -282,7 +281,6 @@ class FreeplayState extends MusicBeatState
intendedScore = Highscore.getScore(curSong.songName, curSong.difficulties[curDifficulty]).score;
#end
if (curSong.difficulties.length > 1)
diffText.text = '< ${curSong.difficulties[curDifficulty]} >';
else
@@ -332,15 +330,14 @@ class FreeplayState extends MusicBeatState
{
if (change == 0 && !force) return;
var bothEnabled = songs[curSelected].coopAllowed && songs[curSelected].opponentModeAllowed;
var event = event("onChangeSelection", EventManager.get(MenuChangeEvent).recycle(curSelected, FlxMath.wrap(curSelected + change, 0, songs.length-1), change));
if (event.cancelled) return;
if (event.playMenuSFX) CoolUtil.playMenuSFX(0, 0.7);
if (event.playMenuSFX) CoolUtil.playMenuSFX(SCROLL, 0.7);
changeDiff(0, true);
#if PRELOAD_ALL
autoplayElapsed = 0;
songInstPlaying = false;
@@ -391,7 +388,7 @@ class FreeplaySonglist {
var meta = new SongMetadata(e.name,
e.icon.getDefault("bf"),
CoolUtil.getColorFromDynamic(e.color).getDefault(FreeplayState.defaultColor), e.difficulties, source);
meta.coopAllowed = e.coopAllowed;
meta.opponentModeAllowed = e.opponentModeAllowed;
this.songs.push(meta);
+6 -7
View File
@@ -43,7 +43,7 @@ class MainMenuState extends MusicBeatState
override function create()
{
super.create();
DiscordUtil.changePresence("In the Menus", null);
CoolUtil.playMenuSong();
@@ -66,7 +66,7 @@ class MainMenuState extends MusicBeatState
bg.screenCenter();
bg.antialiasing = true;
}
menuItems = new FlxTypedGroup<FlxSprite>();
add(menuItems);
@@ -99,14 +99,14 @@ class MainMenuState extends MusicBeatState
override function update(elapsed:Float)
{
if (FlxG.sound.music.volume < 0.8)
FlxG.sound.music.volume += 0.5 * FlxG.elapsed;
FlxG.sound.music.volume += 0.5 * elapsed;
if (!selectedSomethin)
{
if (canAccessDebugMenus) {
if (FlxG.keys.justPressed.SEVEN)
FlxG.switchState(new funkin.desktop.DesktopMain());
if (FlxG.keys.justPressed.F1)
funkin.multitasking.MultiTaskingHandler.openWindow("FreeplayState", new FreeplayState());
}
@@ -143,7 +143,6 @@ class MainMenuState extends MusicBeatState
});
}
public override function switchTo(nextState:FlxState):Bool {
try {
menuItems.forEach(function(spr:FlxSprite) {
@@ -155,7 +154,7 @@ class MainMenuState extends MusicBeatState
function selectItem() {
selectedSomethin = true;
CoolUtil.playMenuSFX(1);
CoolUtil.playMenuSFX(CONFIRM);
if (Options.flashingMenu) FlxFlicker.flicker(magenta, 1.1, 0.15, false);
@@ -192,7 +191,7 @@ class MainMenuState extends MusicBeatState
curSelected = event.value;
if (event.playMenuSFX)
CoolUtil.playMenuSFX(0, 0.7);
CoolUtil.playMenuSFX(SCROLL, 0.7);
menuItems.forEach(function(spr:FlxSprite)
{
+2 -2
View File
@@ -19,7 +19,7 @@ class ModSwitchMenu extends MusicBeatSubstate {
public override function create() {
super.create();
var bg = new FlxSprite(0, 0).makeGraphic(1, 1, 0xFF000000);
bg.scale.set(FlxG.width, FlxG.height);
bg.updateHitbox();
@@ -69,7 +69,7 @@ class ModSwitchMenu extends MusicBeatSubstate {
curSelected = FlxMath.wrap(curSelected + change, 0, alphabets.length-1);
CoolUtil.playMenuSFX(0, 0.7);
CoolUtil.playMenuSFX(SCROLL, 0.7);
for(k=>alphabet in alphabets.members) {
alphabet.alpha = 0.6;
+292 -296
View File
@@ -17,42 +17,42 @@ import flixel.FlxSprite;
import flixel.text.FlxText;
class StoryMenuState extends MusicBeatState {
public var characters:Map<String, MenuCharacter> = [];
public var weeks:Array<WeekData> = [];
public var characters:Map<String, MenuCharacter> = [];
public var weeks:Array<WeekData> = [];
public var scoreText:FlxText;
public var tracklist:FlxText;
public var weekTitle:FlxText;
public var scoreText:FlxText;
public var tracklist:FlxText;
public var weekTitle:FlxText;
public var curDifficulty:Int = 0;
public var curWeek:Int = 0;
public var curDifficulty:Int = 0;
public var curWeek:Int = 0;
public var difficultySprites:Map<String, FlxSprite> = [];
public var weekBG:FlxSprite;
public var leftArrow:FlxSprite;
public var rightArrow:FlxSprite;
public var blackBar:FlxSprite;
public var difficultySprites:Map<String, FlxSprite> = [];
public var weekBG:FlxSprite;
public var leftArrow:FlxSprite;
public var rightArrow:FlxSprite;
public var blackBar:FlxSprite;
public var lerpScore:Float = 0;
public var intendedScore:Int = 0;
public var lerpScore:Float = 0;
public var intendedScore:Int = 0;
public var canSelect:Bool = true;
public var canSelect:Bool = true;
public var weekSprites:FlxTypedGroup<MenuItem>;
public var characterSprites:FlxTypedGroup<MenuCharacterSprite>;
public var weekSprites:FlxTypedGroup<MenuItem>;
public var characterSprites:FlxTypedGroup<MenuCharacterSprite>;
public var charFrames:Map<String, FlxFramesCollection> = [];
public override function create() {
super.create();
loadXMLs();
persistentUpdate = persistentDraw = true;
// WEEK INFO
blackBar = new FlxSprite(0, 0).makeGraphic(1, 1, 0xFFFFFFFF);
blackBar.color = 0xFF000000;
blackBar.setGraphicSize(FlxG.width, 56);
blackBar.updateHitbox();
public var charFrames:Map<String, FlxFramesCollection> = [];
public override function create() {
super.create();
loadXMLs();
persistentUpdate = persistentDraw = true;
// WEEK INFO
blackBar = new FlxSprite(0, 0).makeGraphic(1, 1, 0xFFFFFFFF);
blackBar.color = 0xFF000000;
blackBar.setGraphicSize(FlxG.width, 56);
blackBar.updateHitbox();
scoreText = new FunkinText(10, 10, 0, "SCORE: -", 36);
scoreText.setFormat(Paths.font("vcr.ttf"), 32);
@@ -61,322 +61,318 @@ class StoryMenuState extends MusicBeatState {
weekTitle.setFormat(Paths.font("vcr.ttf"), 32, FlxColor.WHITE, RIGHT);
weekTitle.alpha = 0.7;
weekBG = new FlxSprite(0, 56).makeGraphic(1, 1, 0xFFFFFFFF);
weekBG.color = 0xFFF9CF51;
weekBG.setGraphicSize(FlxG.width, 400);
weekBG.updateHitbox();
weekBG = new FlxSprite(0, 56).makeGraphic(1, 1, 0xFFFFFFFF);
weekBG.color = 0xFFF9CF51;
weekBG.setGraphicSize(FlxG.width, 400);
weekBG.updateHitbox();
weekSprites = new FlxTypedGroup<MenuItem>();
weekSprites = new FlxTypedGroup<MenuItem>();
// DUMBASS ARROWS
// DUMBASS ARROWS
var assets = Paths.getFrames('menus/storymenu/assets');
var directions = ["left", "right"];
var directions = ["left", "right"];
leftArrow = new FlxSprite((FlxG.width + 400) / 2, weekBG.y + weekBG.height + 10 + 10);
rightArrow = new FlxSprite(FlxG.width - 10, weekBG.y + weekBG.height + 10 + 10);
for(k=>arrow in [leftArrow, rightArrow]) {
var dir = directions[k];
leftArrow = new FlxSprite((FlxG.width + 400) / 2, weekBG.y + weekBG.height + 10 + 10);
rightArrow = new FlxSprite(FlxG.width - 10, weekBG.y + weekBG.height + 10 + 10);
for(k=>arrow in [leftArrow, rightArrow]) {
var dir = directions[k];
arrow.frames = assets;
arrow.animation.addByPrefix('idle', 'arrow $dir');
arrow.animation.addByPrefix('press', 'arrow push $dir', 24, false);
arrow.animation.play('idle');
add(arrow);
}
rightArrow.x -= rightArrow.width;
arrow.frames = assets;
arrow.animation.addByPrefix('idle', 'arrow $dir');
arrow.animation.addByPrefix('press', 'arrow push $dir', 24, false);
arrow.animation.play('idle');
add(arrow);
}
rightArrow.x -= rightArrow.width;
tracklist = new FunkinText(16, weekBG.y + weekBG.height + 44, Std.int(((FlxG.width - 400) / 2) - 80), "TRACKS", 32);
tracklist.alignment = CENTER;
tracklist.color = 0xFFE55777;
tracklist = new FunkinText(16, weekBG.y + weekBG.height + 44, Std.int(((FlxG.width - 400) / 2) - 80), "TRACKS", 32);
tracklist.alignment = CENTER;
tracklist.color = 0xFFE55777;
add(weekSprites);
for(e in [blackBar, scoreText, weekTitle, weekBG, tracklist]) {
e.scrollFactor.set();
add(e);
}
add(weekSprites);
for(e in [blackBar, scoreText, weekTitle, weekBG, tracklist]) {
e.scrollFactor.set();
add(e);
}
characterSprites = new FlxTypedGroup<MenuCharacterSprite>();
for(i in 0...3) {
characterSprites.add(new MenuCharacterSprite(i));
}
add(characterSprites);
characterSprites = new FlxTypedGroup<MenuCharacterSprite>();
for(i in 0...3) {
characterSprites.add(new MenuCharacterSprite(i));
}
add(characterSprites);
for(i=>week in weeks) {
var spr:MenuItem = new MenuItem(0, (i * 120) + 480, 'menus/storymenu/weeks/${week.sprite}');
weekSprites.add(spr);
for(i=>week in weeks) {
var spr:MenuItem = new MenuItem(0, (i * 120) + 480, 'menus/storymenu/weeks/${week.sprite}');
weekSprites.add(spr);
for(e in week.difficulties) {
var le = e.toLowerCase();
if (difficultySprites[le] == null) {
var diffSprite = new FlxSprite(leftArrow.x + leftArrow.width, leftArrow.y);
diffSprite.loadAnimatedGraphic(Paths.image('menus/storymenu/difficulties/${le}'));
diffSprite.setUnstretchedGraphicSize(Std.int(rightArrow.x - leftArrow.x - leftArrow.width), Std.int(leftArrow.height), false, 1);
diffSprite.antialiasing = true;
diffSprite.scrollFactor.set();
add(diffSprite);
for(e in week.difficulties) {
var le = e.toLowerCase();
if (difficultySprites[le] == null) {
var diffSprite = new FlxSprite(leftArrow.x + leftArrow.width, leftArrow.y);
diffSprite.loadAnimatedGraphic(Paths.image('menus/storymenu/difficulties/${le}'));
diffSprite.setUnstretchedGraphicSize(Std.int(rightArrow.x - leftArrow.x - leftArrow.width), Std.int(leftArrow.height), false, 1);
diffSprite.antialiasing = true;
diffSprite.scrollFactor.set();
add(diffSprite);
difficultySprites[le] = diffSprite;
}
}
}
difficultySprites[le] = diffSprite;
}
}
}
changeWeek(0, true);
changeWeek(0, true);
DiscordUtil.changePresence("In the Menus", null);
}
}
var __lastDifficultyTween:FlxTween;
public override function update(elapsed:Float) {
super.update(elapsed);
var __lastDifficultyTween:FlxTween;
public override function update(elapsed:Float) {
super.update(elapsed);
lerpScore = lerp(lerpScore, intendedScore, 0.5);
scoreText.text = 'WEEK SCORE:${Math.round(lerpScore)}';
if (canSelect) {
if (leftArrow != null && leftArrow.exists) leftArrow.animation.play(controls.LEFT ? 'press' : 'idle');
if (rightArrow != null && rightArrow.exists) rightArrow.animation.play(controls.RIGHT ? 'press' : 'idle');
lerpScore = lerp(lerpScore, intendedScore, 0.5);
scoreText.text = 'WEEK SCORE:${Math.round(lerpScore)}';
if (controls.BACK) {
goBack();
}
if (canSelect) {
if (leftArrow != null && leftArrow.exists) leftArrow.animation.play(controls.LEFT ? 'press' : 'idle');
if (rightArrow != null && rightArrow.exists) rightArrow.animation.play(controls.RIGHT ? 'press' : 'idle');
changeDifficulty((controls.LEFT_P ? -1 : 0) + (controls.RIGHT_P ? 1 : 0));
changeWeek((controls.UP_P ? -1 : 0) + (controls.DOWN_P ? 1 : 0));
if (controls.BACK) {
goBack();
}
if (controls.ACCEPT)
selectWeek();
} else {
for(e in [leftArrow, rightArrow])
if (e != null && e.exists)
e.animation.play('idle');
}
}
changeDifficulty((controls.LEFT_P ? -1 : 0) + (controls.RIGHT_P ? 1 : 0));
changeWeek((controls.UP_P ? -1 : 0) + (controls.DOWN_P ? 1 : 0));
public function goBack() {
var event = event("onGoBack", new CancellableEvent());
if (!event.cancelled)
FlxG.switchState(new MainMenuState());
}
if (controls.ACCEPT)
selectWeek();
} else {
for(e in [leftArrow, rightArrow])
if (e != null && e.exists)
e.animation.play('idle');
}
}
public function changeWeek(change:Int, force:Bool = false) {
if (change == 0 && !force) return;
public function goBack() {
var event = event("onGoBack", new CancellableEvent());
if (!event.cancelled)
FlxG.switchState(new MainMenuState());
}
var event = event("onChangeWeek", EventManager.get(MenuChangeEvent).recycle(curWeek, FlxMath.wrap(curWeek + change, 0, weeks.length-1), change));
if (event.cancelled) return;
curWeek = event.value;
if (!force) CoolUtil.playMenuSFX();
for(k=>e in weekSprites.members) {
e.targetY = k - curWeek;
}
tracklist.text = 'TRACKS\n\n${[for(e in weeks[curWeek].songs) if (!e.hide) e.name.toUpperCase()].join('\n')}';
public function changeWeek(change:Int, force:Bool = false) {
if (change == 0 && !force) return;
for(i in 0...3)
characterSprites.members[i].changeCharacter(characters[weeks[curWeek].chars[i]]);
var event = event("onChangeWeek", EventManager.get(MenuChangeEvent).recycle(curWeek, FlxMath.wrap(curWeek + change, 0, weeks.length-1), change));
if (event.cancelled) return;
curWeek = event.value;
changeDifficulty(0, true);
}
if (!force) CoolUtil.playMenuSFX();
for(k=>e in weekSprites.members) {
e.targetY = k - curWeek;
}
tracklist.text = 'TRACKS\n\n${[for(e in weeks[curWeek].songs) if (!e.hide) e.name.toUpperCase()].join('\n')}';
var __oldDiffName = null;
public function changeDifficulty(change:Int, force:Bool = false) {
if (change == 0 && !force) return;
for(i in 0...3)
characterSprites.members[i].changeCharacter(characters[weeks[curWeek].chars[i]]);
var event = event("onChangeDifficulty", EventManager.get(MenuChangeEvent).recycle(curDifficulty, FlxMath.wrap(curDifficulty + change, 0, weeks[curWeek].difficulties.length-1), change));
if (event.cancelled) return;
curDifficulty = event.value;
changeDifficulty(0, true);
}
if (__oldDiffName != (__oldDiffName = weeks[curWeek].difficulties[curDifficulty].toLowerCase())) {
for(e in difficultySprites) e.visible = false;
var __oldDiffName = null;
public function changeDifficulty(change:Int, force:Bool = false) {
if (change == 0 && !force) return;
var diffSprite = difficultySprites[__oldDiffName];
if (diffSprite != null) {
diffSprite.visible = true;
if (__lastDifficultyTween != null)
__lastDifficultyTween.cancel();
diffSprite.alpha = 0;
diffSprite.y = leftArrow.y - 15;
var event = event("onChangeDifficulty", EventManager.get(MenuChangeEvent).recycle(curDifficulty, FlxMath.wrap(curDifficulty + change, 0, weeks[curWeek].difficulties.length-1), change));
if (event.cancelled) return;
curDifficulty = event.value;
FlxTween.tween(diffSprite, {y: leftArrow.y, alpha: 1}, 0.07);
}
}
intendedScore = Highscore.getWeekScore(weeks[curWeek].name, weeks[curWeek].difficulties[curDifficulty]).score;
}
if (__oldDiffName != (__oldDiffName = weeks[curWeek].difficulties[curDifficulty].toLowerCase())) {
for(e in difficultySprites) e.visible = false;
public function loadXMLs() {
loadXML(Paths.xml('weeks'));
}
var diffSprite = difficultySprites[__oldDiffName];
if (diffSprite != null) {
diffSprite.visible = true;
public override function destroy() {
super.destroy();
for(e in characters)
if (e != null && e.offset != null)
e.offset.put();
}
if (__lastDifficultyTween != null)
__lastDifficultyTween.cancel();
diffSprite.alpha = 0;
diffSprite.y = leftArrow.y - 15;
public function selectWeek() {
__lastDifficultyTween = FlxTween.tween(diffSprite, {y: leftArrow.y, alpha: 1}, 0.07);
}
}
var event = event("onWeekSelect", EventManager.get(WeekSelectEvent).recycle(weeks[curWeek], weeks[curWeek].difficulties[curDifficulty], curWeek, curDifficulty));
if (event.cancelled) return;
intendedScore = Highscore.getWeekScore(weeks[curWeek].name, weeks[curWeek].difficulties[curDifficulty]).score;
}
canSelect = false;
CoolUtil.playMenuSFX(1);
public function loadXMLs() {
loadXML(Paths.xml('weeks'));
}
for(char in characterSprites)
if (char.animation.exists("confirm"))
char.animation.play("confirm");
public override function destroy() {
super.destroy();
for(e in characters)
if (e != null && e.offset != null)
e.offset.put();
}
CoolUtil.loadWeek(weeks[curWeek], weeks[curWeek].difficulties[curDifficulty]);
public function selectWeek() {
var event = event("onWeekSelect", EventManager.get(WeekSelectEvent).recycle(weeks[curWeek], weeks[curWeek].difficulties[curDifficulty], curWeek, curDifficulty));
if (event.cancelled) return;
canSelect = false;
CoolUtil.playMenuSFX(CONFIRM);
new FlxTimer().start(1, function(tmr:FlxTimer)
{
FlxG.switchState(new PlayState());
});
weekSprites.members[curWeek].startFlashing();
}
for(char in characterSprites)
if (char.animation.exists("confirm"))
char.animation.play("confirm");
public function loadXML(xmlPath:String) {
try {
var xml = new Access(Xml.parse(Assets.getText(xmlPath)).firstElement());
CoolUtil.loadWeek(weeks[curWeek], weeks[curWeek].difficulties[curDifficulty]);
for(el in xml.elements) {
switch(el.name) {
case 'characters':
for(k=>char in el.nodes.char) {
if (!char.has.name) {
Logs.trace('weeks.xml: Character at index ${k} has no name. Skipping...', WARNING);
continue;
}
if (characters[char.att.name] != null) continue;
var charObj:MenuCharacter = {
spritePath: Paths.image(char.getAtt('sprite').getDefault('menus/storymenu/characters/${char.att.name}')),
scale: Std.parseFloat(char.getAtt('scale')).getDefault(1),
xml: char,
offset: FlxPoint.get(
Std.parseFloat(char.getAtt('x')).getDefault(0),
Std.parseFloat(char.getAtt('y')).getDefault(0)
)
};
characters[char.att.name] = charObj;
}
case 'weeks':
for(k=>week in el.nodes.week) {
if (!week.has.name) {
Logs.trace('weeks.xml: Week at index ${k} has no name. Skipping...', WARNING);
continue;
}
var weekObj:WeekData = {
name: week.att.name,
sprite: week.getAtt('sprite').getDefault('week${k}'),
chars: [null, null, null],
songs: [],
difficulties: ['easy', 'normal', 'hard']
};
new FlxTimer().start(1, function(tmr:FlxTimer)
{
FlxG.switchState(new PlayState());
});
weekSprites.members[curWeek].startFlashing();
}
var diffNodes = week.nodes.difficulty;
if (diffNodes.length > 0) {
var diffs:Array<String> = [];
for(e in diffNodes) {
if (e.has.name) diffs.push(e.att.name);
}
if (diffs.length > 0)
weekObj.difficulties = diffs;
}
public function loadXML(xmlPath:String) {
try {
var xml = new Access(Xml.parse(Assets.getText(xmlPath)).firstElement());
if (week.has.chars) {
for(k=>e in week.att.chars.split(",")) {
if (e.trim() == "" || e == "none" || e == "null")
weekObj.chars[k] = null;
else
weekObj.chars[k] = e.trim();
}
}
for(k2=>song in week.nodes.song) {
if (!song.has.name) {
Logs.trace('weeks.xml: Song at index ${k2} in week ${weekObj.name} has no name. Skipping...', WARNING);
continue;
}
weekObj.songs.push({
name: song.att.name,
hide: song.getAtt('hide').getDefault('false') == "true"
});
}
if (weekObj.songs.length <= 0) {
Logs.trace('weeks.xml: Week ${weekObj.name} has no songs. Skipping...', WARNING);
continue;
}
weeks.push(weekObj);
}
}
}
} catch(e) {
Logs.trace('Failed to parse data/weeks.xml: $e', ERROR);
}
}
for(el in xml.elements) {
switch(el.name) {
case 'characters':
for(k=>char in el.nodes.char) {
if (!char.has.name) {
Logs.trace('weeks.xml: Character at index ${k} has no name. Skipping...', WARNING);
continue;
}
if (characters[char.att.name] != null) continue;
var charObj:MenuCharacter = {
spritePath: Paths.image(char.getAtt('sprite').getDefault('menus/storymenu/characters/${char.att.name}')),
scale: Std.parseFloat(char.getAtt('scale')).getDefault(1),
xml: char,
offset: FlxPoint.get(
Std.parseFloat(char.getAtt('x')).getDefault(0),
Std.parseFloat(char.getAtt('y')).getDefault(0)
)
};
characters[char.att.name] = charObj;
}
case 'weeks':
for(k=>week in el.nodes.week) {
if (!week.has.name) {
Logs.trace('weeks.xml: Week at index ${k} has no name. Skipping...', WARNING);
continue;
}
var weekObj:WeekData = {
name: week.att.name,
sprite: week.getAtt('sprite').getDefault('week${k}'),
chars: [null, null, null],
songs: [],
difficulties: ['easy', 'normal', 'hard']
};
var diffNodes = week.nodes.difficulty;
if (diffNodes.length > 0) {
var diffs:Array<String> = [];
for(e in diffNodes) {
if (e.has.name) diffs.push(e.att.name);
}
if (diffs.length > 0)
weekObj.difficulties = diffs;
}
if (week.has.chars) {
for(k=>e in week.att.chars.split(",")) {
if (e.trim() == "" || e == "none" || e == "null")
weekObj.chars[k] = null;
else
weekObj.chars[k] = e.trim();
}
}
for(k2=>song in week.nodes.song) {
if (!song.has.name) {
Logs.trace('weeks.xml: Song at index ${k2} in week ${weekObj.name} has no name. Skipping...', WARNING);
continue;
}
weekObj.songs.push({
name: song.att.name,
hide: song.getAtt('hide').getDefault('false') == "true"
});
}
if (weekObj.songs.length <= 0) {
Logs.trace('weeks.xml: Week ${weekObj.name} has no songs. Skipping...', WARNING);
continue;
}
weeks.push(weekObj);
}
}
}
} catch(e) {
Logs.trace('Failed to parse data/weeks.xml: $e', ERROR);
}
}
}
typedef WeekData = {
var name:String;
var sprite:String;
var chars:Array<String>;
var songs:Array<WeekSong>;
var difficulties:Array<String>;
var name:String;
var sprite:String;
var chars:Array<String>;
var songs:Array<WeekSong>;
var difficulties:Array<String>;
}
typedef WeekSong = {
var name:String;
var hide:Bool;
var name:String;
var hide:Bool;
}
typedef MenuCharacter = {
var spritePath:String;
var xml:Access;
var scale:Float;
var offset:FlxPoint;
// var frames:FlxFramesCollection;
var spritePath:String;
var xml:Access;
var scale:Float;
var offset:FlxPoint;
// var frames:FlxFramesCollection;
}
class MenuCharacterSprite extends FlxSprite
{
public var character:String;
public var character:String;
var pos:Int;
var pos:Int;
public function new(pos:Int) {
super(0, 70);
this.pos = pos;
visible = false;
antialiasing = true;
}
public function new(pos:Int) {
super(0, 70);
this.pos = pos;
visible = false;
antialiasing = true;
}
public var oldChar:MenuCharacter = null;
public var oldChar:MenuCharacter = null;
public function changeCharacter(data:MenuCharacter) {
visible = (data != null);
if (!visible)
return;
public function changeCharacter(data:MenuCharacter) {
visible = (data != null);
if (!visible)
return;
if (oldChar != (oldChar = data)) {
CoolUtil.loadAnimatedGraphic(this, data.spritePath);
for(e in data.xml.nodes.anim) {
if (e.getAtt("name") == "idle")
animation.remove("idle");
XMLUtil.addXMLAnimation(this, e);
}
animation.play("idle");
scale.set(data.scale, data.scale);
updateHitbox();
offset.x += data.offset.x;
offset.y += data.offset.y;
x = (FlxG.width * 0.25) * (1 + pos) - 150;
}
}
if (oldChar != (oldChar = data)) {
CoolUtil.loadAnimatedGraphic(this, data.spritePath);
for(e in data.xml.nodes.anim) {
if (e.getAtt("name") == "idle")
animation.remove("idle");
XMLUtil.addXMLAnimation(this, e);
}
animation.play("idle");
scale.set(data.scale, data.scale);
updateHitbox();
offset.x += data.offset.x;
offset.y += data.offset.y;
x = (FlxG.width * 0.25) * (1 + pos) - 150;
}
}
}
class MenuItem extends FlxSprite
{
@@ -386,8 +382,8 @@ class MenuItem extends FlxSprite
{
super(x, y);
CoolUtil.loadAnimatedGraphic(this, Paths.image(path, null, true));
screenCenter(X);
antialiasing = true;
screenCenter(X);
antialiasing = true;
}
private var isFlashing:Bool = false;
@@ -403,19 +399,19 @@ class MenuItem extends FlxSprite
// I'm still learning how math works thanks whoever is reading this lol
// var fakeFramerate:Int = Math.round((1 / FlxG.elapsed) / 10);
// hi ninja muffin
// i have found a more efficient way
// dw, judging by how week 7 looked you prob know how to do maths
// goodbye
var time:Float = 0;
// hi ninja muffin
// i have found a more efficient way
// dw, judging by how week 7 looked you prob know how to do maths
// goodbye
var time:Float = 0;
override function update(elapsed:Float)
{
super.update(elapsed);
time += elapsed;
time += elapsed;
y = CoolUtil.fpsLerp(y, (targetY * 120) + 480, 0.17);
if (isFlashing)
color = (time % 0.1 > 0.05) ? FlxColor.WHITE : 0xFF33ffff;
if (isFlashing)
color = (time % 0.1 > 0.05) ? FlxColor.WHITE : 0xFF33ffff;
}
}
+2 -2
View File
@@ -50,7 +50,7 @@ class TitleState extends MusicBeatState
curWacky = FlxG.random.getObject(getIntroTextShit());
FlxTransitionableState.skipNextTransIn = true;
super.create();
startIntro();
@@ -173,7 +173,7 @@ class TitleState extends MusicBeatState
titleText.animation.play('press');
FlxG.camera.flash(FlxColor.WHITE, 1);
CoolUtil.playMenuSFX(1, 0.7);
CoolUtil.playMenuSFX(CONFIRM, 0.7);
transitioning = true;
// FlxG.sound.music.stop();
@@ -47,7 +47,7 @@ class CreditsCodename extends MusicBeatState {
public override function update(elapsed:Float) {
super.update(elapsed);
if (controls.BACK) {
CoolUtil.playMenuSFX(2);
CoolUtil.playMenuSFX(CANCEL);
FlxTransitionableState.skipNextTransIn = FlxTransitionableState.skipNextTransOut = true;
FlxG.switchState(new MainMenuState());
}
+4 -4
View File
@@ -83,14 +83,14 @@ class OptionsMenu extends MusicBeatState {
if (!canSelect) return;
changeSelection((controls.UP_P ? -1 : 0) + (controls.DOWN_P ? 1 : 0));
if (controls.ACCEPT && alphabets.members[curSelected] != null) {
CoolUtil.playMenuSFX(1);
CoolUtil.playMenuSFX(CONFIRM);
canSelect = false;
FlxFlicker.flicker(alphabets.members[curSelected], 1, Options.flashingMenu ? 0.06 : 0.15, false, false, function(flick:FlxFlicker)
{
FlxTransitionableState.skipNextTransOut = true;
if (options[curSelected].state is FlxState)
FlxG.switchState(options[curSelected].state);
else
else
FlxG.switchState(Type.createInstance(options[curSelected].state, []));
});
} else if (controls.BACK) {
@@ -100,10 +100,10 @@ class OptionsMenu extends MusicBeatState {
FlxG.switchState(new MainMenuState());
}
}
public function changeSelection(change:Int) {
if (change == 0) return;
CoolUtil.playMenuSFX(0, 0.7);
CoolUtil.playMenuSFX(CANCEL, 0.7);
curSelected = FlxMath.wrap(curSelected + change, 0, options.length-1);
alphabets.forEach(function(e) {
e.alpha = 0.6;
+1 -2
View File
@@ -99,7 +99,6 @@ class OptionsScreen extends MusicBeatState {
}
public function exit() {
FlxTransitionableState.skipNextTransOut = true;
FlxTransitionableState.skipNextTransIn = true;
FlxG.switchState(new OptionsMenu());
@@ -107,7 +106,7 @@ class OptionsScreen extends MusicBeatState {
public function changeSelection(change:Int) {
if (change == 0 && curSelected != -1) return;
CoolUtil.playMenuSFX(0, 0.7);
CoolUtil.playMenuSFX(SCROLL, 0.7);
if (curSelected != (curSelected = FlxMath.wrap(curSelected + change, 0, options.length - 1))) {
for(e in options)
e.selected = false;
@@ -18,7 +18,7 @@ class MiscOptions extends OptionsScreen {
if (report.newUpdate) {
FlxG.switchState(new funkin.updating.UpdateAvailableScreen(report));
} else {
CoolUtil.playMenuSFX(2);
CoolUtil.playMenuSFX(CANCEL);
updateDescText("No update found.");
}
}),
@@ -146,7 +146,7 @@ class KeybindsOptions extends MusicBeatSubstate {
var title = new Alphabet(0, k * 75, category.name, true);
title.screenCenter(X);
add(title);
k++;
for(e in category.settings) {
var sparrowIcon:String = null;
@@ -165,7 +165,7 @@ class KeybindsOptions extends MusicBeatSubstate {
};
e.name = e.name.substring(5, e.name.length - 1);
}
var text = new KeybindSetting(100, k * 75, e.name, e.control, sparrowIcon, sparrowAnim);
if (!isSubState)
text.bind1.color = text.bind2.color = FlxColor.BLACK;
@@ -199,18 +199,17 @@ class KeybindsOptions extends MusicBeatSubstate {
coloredBG.color = noteColors[curSelected];
else
coloredBG.color = CoolUtil.lerpColor(coloredBG.color, noteColors[curSelected], 0.0625);
coloredBG.alpha = lerp(coloredBG.alpha, 1, 0.0625);
} else
coloredBG.alpha = lerp(coloredBG.alpha, 0, 0.0625);
}
if (canSelect) {
changeSelection((controls.UP_P ? -1 : 0) + (controls.DOWN_P ? 1 : 0));
if (controls.BACK) {
FlxTransitionableState.skipNextTransIn = true;
if (isSubState)
if (isSubState)
close();
else
FlxG.switchState(new OptionsMenu());
@@ -222,7 +221,7 @@ class KeybindsOptions extends MusicBeatSubstate {
if (controls.ACCEPT && !skipThisFrame) {
if (alphabets.members[curSelected] != null) {
canSelect = false;
CoolUtil.playMenuSFX(1);
CoolUtil.playMenuSFX(CONFIRM);
alphabets.members[curSelected].changeKeybind(function() {
canSelect = true;
}, function() {
@@ -231,10 +230,10 @@ class KeybindsOptions extends MusicBeatSubstate {
}
return;
}
if (controls.LEFT_P || controls.RIGHT_P) {
if (alphabets.members[curSelected] != null) {
CoolUtil.playMenuSFX(0, 0.7);
CoolUtil.playMenuSFX(SCROLL, 0.7);
alphabets.members[curSelected].p2Selected = (p2Selected = !p2Selected);
}
}
@@ -243,10 +242,10 @@ class KeybindsOptions extends MusicBeatSubstate {
skipThisFrame = false;
}
public function changeSelection(change:Int) {
if (change == 0) return;
CoolUtil.playMenuSFX(0, 0.4);
CoolUtil.playMenuSFX(SCROLL, 0.4);
curSelected = FlxMath.wrap(curSelected + change, 0, alphabets.length-1);
alphabets.forEach(function(e) {
e.alpha = 0.55;
@@ -16,7 +16,7 @@ import flixel.FlxG;
class UpdateAvailableScreen extends MusicBeatState {
public var bg:FlxSprite;
public var versionCheckBG:FlxSprite;
public var title:Alphabet;
public var versionDifferenceLabel:FunkinText;
@@ -38,7 +38,7 @@ class UpdateAvailableScreen extends MusicBeatState {
super.create();
FlxTransitionableState.skipNextTransIn = true;
FlxG.mouse.visible = true;
FlxG.camera.flash(0xFF000000, 0.25);
bg = new FlxSprite().loadAnimatedGraphic(Paths.image("menus/menuDesat"));
@@ -85,7 +85,7 @@ class UpdateAvailableScreen extends MusicBeatState {
installButton.scrollFactor.set();
skipButton.scrollFactor.set();
optionsBG.scrollFactor.set();
add(changeLogText);
add(versionCheckBG);
@@ -129,17 +129,17 @@ class UpdateAvailableScreen extends MusicBeatState {
public function select() {
if (installSelected) {
CoolUtil.playMenuSFX(1);
CoolUtil.playMenuSFX(CONFIRM);
FlxG.switchState(new UpdateScreen(check));
} else {
CoolUtil.playMenuSFX(2);
CoolUtil.playMenuSFX(CANCEL);
FlxG.switchState(new MainMenuState());
}
}
public function changeSelection() {
CoolUtil.playMenuSFX(0, 0.7);
CoolUtil.playMenuSFX(SCROLL, 0.7);
if (installSelected) {
installButton.text = "> INSTALL <";
skipButton.text = "SKIP";
+15 -7
View File
@@ -174,16 +174,18 @@ class CoolUtil
} else
Conductor.changeBPM(DefaultBPM);
}
/**
* Plays a specified Menu SFX.
* @param menuSFX Menu SFX to play
* @param volume At which volume it should play
*/
public static function playMenuSFX(menuSFX:Int = 0, volume:Float = 1) {
public static function playMenuSFX(menuSFX:CoolSfx = SCROLL, volume:Float = 1) {
FlxG.sound.play(Paths.sound(switch(menuSFX) {
case 1: 'menu/confirm';
case 2: 'menu/cancel';
default: 'menu/scroll';
case CONFIRM: 'menu/confirm';
case CANCEL: 'menu/cancel';
case SCROLL: 'menu/scroll';
default: 'menu/scroll';
}), volume);
}
@@ -192,7 +194,7 @@ class CoolUtil
return [for(e in Assets.getText(path).trim().split('\n')) e.trim()];
}
public static inline function numberArray(max:Int, ?min = 0):Array<Int>
public static inline function numberArray(max:Int, ?min:Int = 0):Array<Int>
{
return [for (i in min...max) i];
}
@@ -258,7 +260,7 @@ class CoolUtil
case Y:
obj.y = (cam.height - obj.height) / 2;
case NONE:
}
}
@@ -301,7 +303,7 @@ class CoolUtil
var frames = FlxAtlasFrames.findFrame(graphic);
if (frames != null)
return frames;
trace("no frames yet for multiple atlases!!");
var spritesheets = [];
var cur = 1;
@@ -386,4 +388,10 @@ class CoolUtil
array.push(a);
return array;
}
}
enum abstract CoolSfx(Int) from Int {
var SCROLL = 0;
var CONFIRM = 1;
var CANCEL = 2;
}