code
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
package funkin.menus;
|
||||
|
||||
import funkin.scripting.events.PauseCreationEvent;
|
||||
import funkin.scripting.events.PauseSelectOptionEvent;
|
||||
import funkin.scripting.events.NameEvent;
|
||||
import funkin.scripting.Script;
|
||||
import flixel.FlxG;
|
||||
import flixel.FlxSprite;
|
||||
@@ -124,7 +124,7 @@ class PauseSubState extends MusicBeatSubstate
|
||||
}
|
||||
|
||||
public function selectOption() {
|
||||
var event = new PauseSelectOptionEvent(menuItems[curSelected]);
|
||||
var event = new NameEvent(menuItems[curSelected]);
|
||||
pauseScript.call("onSelectOption", [event]);
|
||||
|
||||
if (event.cancelled) return;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package funkin.menus;
|
||||
|
||||
import funkin.scripting.events.*;
|
||||
import flixel.util.FlxTimer;
|
||||
import flixel.math.FlxPoint;
|
||||
import funkin.system.XMLUtil;
|
||||
@@ -132,11 +133,12 @@ class StoryMenuState extends MusicBeatState {
|
||||
scoreText.text = 'WEEK SCORE:${Math.round(lerpScore)}';
|
||||
|
||||
if (canSelect) {
|
||||
leftArrow.animation.play(controls.LEFT ? 'press' : 'idle');
|
||||
rightArrow.animation.play(controls.RIGHT ? 'press' : 'idle');
|
||||
if (leftArrow != null && leftArrow.exists) leftArrow.animation.play(controls.LEFT ? 'press' : 'idle');
|
||||
if (rightArrow != null && rightArrow.exists) rightArrow.animation.play(controls.RIGHT ? 'press' : 'idle');
|
||||
|
||||
if (controls.BACK)
|
||||
FlxG.switchState(new MainMenuState());
|
||||
if (controls.BACK) {
|
||||
goBack();
|
||||
}
|
||||
|
||||
|
||||
changeDifficulty((controls.LEFT_P ? -1 : 0) + (controls.RIGHT_P ? 1 : 0));
|
||||
@@ -146,14 +148,23 @@ class StoryMenuState extends MusicBeatState {
|
||||
selectWeek();
|
||||
} else {
|
||||
for(e in [leftArrow, rightArrow])
|
||||
e.animation.play('idle');
|
||||
if (e != null && e.exists)
|
||||
e.animation.play('idle');
|
||||
}
|
||||
}
|
||||
|
||||
public function goBack() {
|
||||
var event = event("onGoBack", new CancellableEvent());
|
||||
if (!event.cancelled)
|
||||
FlxG.switchState(new MainMenuState());
|
||||
}
|
||||
|
||||
public function changeWeek(change:Int, force:Bool = false) {
|
||||
if (change == 0 && !force) return;
|
||||
|
||||
curWeek = FlxMath.wrap(curWeek + change, 0, weeks.length-1);
|
||||
var event = event("onChangeWeek", new MenuChangeEvent(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) {
|
||||
@@ -171,7 +182,9 @@ class StoryMenuState extends MusicBeatState {
|
||||
public function changeDifficulty(change:Int, force:Bool = false) {
|
||||
if (change == 0 && !force) return;
|
||||
|
||||
curDifficulty = FlxMath.wrap(curDifficulty + change, 0, weeks[curWeek].difficulties.length-1);
|
||||
var event = event("onChangeDifficulty", new MenuChangeEvent(curDifficulty, FlxMath.wrap(curDifficulty + change, 0, weeks[curWeek].difficulties.length-1), change));
|
||||
if (event.cancelled) return;
|
||||
curDifficulty = event.value;
|
||||
|
||||
if (__oldDiffName != (__oldDiffName = weeks[curWeek].difficulties[curDifficulty].toLowerCase())) {
|
||||
for(e in difficultySprites) e.visible = false;
|
||||
@@ -204,6 +217,11 @@ class StoryMenuState extends MusicBeatState {
|
||||
}
|
||||
|
||||
public function selectWeek() {
|
||||
|
||||
|
||||
var event = event("onWeekSelect", new WeekSelectEvent(weeks[curWeek], weeks[curWeek].difficulties[curDifficulty], curWeek, curDifficulty));
|
||||
if (event.cancelled) return;
|
||||
|
||||
canSelect = false;
|
||||
CoolUtil.playMenuSFX(1);
|
||||
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
package funkin.scripting.events;
|
||||
|
||||
class MenuChangeEvent extends CancellableEvent {
|
||||
/**
|
||||
* Value after the change
|
||||
*/
|
||||
public var value:Int;
|
||||
|
||||
/**
|
||||
* Value before the change
|
||||
*/
|
||||
public var oldValue:Int;
|
||||
|
||||
/**
|
||||
* Amount of change
|
||||
*/
|
||||
public var change:Int;
|
||||
|
||||
/**
|
||||
* Whenever the menu SFX should be played.
|
||||
*/
|
||||
public var playMenuSFX:Bool = true;
|
||||
|
||||
public function new(oldValue:Int, value:Int, change:Int) {
|
||||
super();
|
||||
this.value = value;
|
||||
this.oldValue = value;
|
||||
this.change = change;
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -1,8 +1,8 @@
|
||||
package funkin.scripting.events;
|
||||
|
||||
class PauseSelectOptionEvent extends CancellableEvent {
|
||||
class NameEvent extends CancellableEvent {
|
||||
/**
|
||||
* Option name thats going to be selected
|
||||
* Name
|
||||
*/
|
||||
public var name:String;
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
package funkin.scripting.events;
|
||||
|
||||
import funkin.menus.StoryMenuState.WeekData;
|
||||
|
||||
class WeekSelectEvent extends CancellableEvent {
|
||||
/**
|
||||
* Week that is going to be selected
|
||||
*/
|
||||
public var week:WeekData;
|
||||
|
||||
/**
|
||||
* The difficulty that has been selected
|
||||
*/
|
||||
public var difficulty:String;
|
||||
|
||||
/**
|
||||
* At which emplacement the week is. Goes from 0 to the number of weeks - 1.
|
||||
*/
|
||||
public var weekID:Int;
|
||||
|
||||
/**
|
||||
* At which emplacement the difficulty is. Goes from 0 to the number of weeks - 1.
|
||||
*/
|
||||
public var difficultyID:Int;
|
||||
|
||||
public override function new(week:WeekData, difficulty:String, weekID:Int, difficultyID:Int) {
|
||||
super();
|
||||
|
||||
this.week = week;
|
||||
this.difficulty = difficulty;
|
||||
this.weekID = weekID;
|
||||
this.difficultyID = difficultyID;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user