Skip to content

Commit

Permalink
borrowed stuff from denpa
Browse files Browse the repository at this point in the history
+ idk
  • Loading branch information
Joalor64GH authored Aug 5, 2023
1 parent a3ad40f commit 6578bc8
Show file tree
Hide file tree
Showing 6 changed files with 246 additions and 44 deletions.
4 changes: 2 additions & 2 deletions TODO
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
[HIGH PRIORITY]
- Extra Notes (Hardcoded)
- Add an option to make letters float like in Hypno's Lullaby (WIP)
- In-Game Crash Handler
- Note Color Presets
- Note Color Presets (Currently Working On)

[SOMEWHERE IN BETWEEN]
- Better Startup Screen
- In-Game Crash Handler
- Script Editor

[LOW PRIORITY]
Expand Down
File renamed without changes.
File renamed without changes.
18 changes: 17 additions & 1 deletion source/meta/data/options/NotesSubState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ class NotesSubState extends MusicBeatSubstate
var holdTime:Float = 0;
var nextAccept:Int = 5;

var angleTween:FlxTween;
var scaleTween:FlxTween;

var btn1:FlxButton;
var btn2:FlxButton;

Expand Down Expand Up @@ -127,7 +130,7 @@ class NotesSubState extends MusicBeatSubstate
btn2.updateHitbox();
add(btn2);

rgbText = new Alphabet(posX + 550, 0, "Red Green Blue", false);
rgbText = new Alphabet(posX + 720, 0, "Red Green Blue", false);
rgbText.scaleX = 0.6;
rgbText.scaleY = 0.6;
add(rgbText);
Expand Down Expand Up @@ -160,6 +163,19 @@ class NotesSubState extends MusicBeatSubstate
rgbText.y = item.y - 70;
blackBG.y = item.y - 20;
blackBG.x = item.x - 20;
if (lastSelected != curSelected) {
lastSelected = curSelected;
if (angleTween != null) angleTween.cancel();
angleTween = null;
if (scaleTween != null) scaleTween.cancel();
scaleTween = null;
item.scale.set(0.78,0.78);
angleTween = FlxTween.angle(item, -12, 12, 2, {ease: FlxEase.quadInOut, type: FlxTweenType.PINGPONG});
scaleTween = FlxTween.tween(item, {"scale.x": 0.92, "scale.y": 0.92}, 1, {ease: FlxEase.quadInOut, type: FlxTweenType.PINGPONG});
}
} else {
item.scale.set(0.6,0.6);
item.angle = 0;
}
}

Expand Down
172 changes: 172 additions & 0 deletions source/meta/state/GameExitState.hx
Original file line number Diff line number Diff line change
@@ -0,0 +1,172 @@
package meta.state;

import flixel.FlxG;
import flixel.FlxState;
import flixel.FlxSprite;
import flixel.group.FlxGroup.FlxTypedGroup;
import flixel.effects.FlxFlicker;
import flixel.util.FlxColor;
import flixel.text.FlxText;
import flixel.math.FlxMath;
import flixel.FlxCamera;
import flixel.FlxObject;

import meta.*;
import meta.data.*;
import meta.data.alphabet.*;

import meta.state.*;

using StringTools;

class GameExitState extends FlxState
{
var options:Array<String> = ['Yes', 'No'];

private var grpOptions:FlxTypedGroup<Alphabet>;
private static var curSelected:Int = 0;

function openSelectedSubstate(label:String) {
switch(label) {
case 'Yes':
quitGame();
case 'No':
FlxG.sound.playMusic(Paths.music('freakyMenu'));
MusicBeatState.switchState(new MainMenuState());
}
}

var accepted:Bool;
var allowInputs:Bool = false;

var selectorLeft:Alphabet;
var selectorRight:Alphabet;

var camFollow:FlxObject;
var camFollowPos:FlxObject;
var camMain:FlxCamera;

var bg:FlxSprite;

override function create()
{
camMain = new FlxCamera();
FlxG.cameras.reset(camMain);
FlxG.cameras.setDefaultDrawTarget(camMain, true);
camFollow = new FlxObject(0, 0, 1, 1);
camFollowPos = new FlxObject(0, 0, 1, 1);
add(camFollow);
add(camFollowPos);
FlxG.camera.follow(camFollowPos, null, 1);

var yScroll:Float = Math.max(0.25 - (0.05 * (options.length - 4)), 0.1);
bg = new FlxSprite().loadGraphic(Paths.image('menuDesat'));
bg.updateHitbox();
bg.screenCenter();
bg.scrollFactor.set(0, yScroll / 3);
bg.antialiasing = true;
add(bg);

var header:Alphabet = new Alphabet(0, -55, 'Exit the game?', true);
header.scrollFactor.set(0, Math.max(0.25 - (0.05 * (options.length - 4)), 0.1));
header.screenCenter(X);
add(header);

initOptions();

selectorLeft = new Alphabet(0, 0, '>', true);
selectorLeft.scrollFactor.set(0, yScroll);
add(selectorLeft);
selectorRight = new Alphabet(0, 0, '<', true);
selectorRight.scrollFactor.set(0, yScroll);
add(selectorRight);

changeSelection();

allowInputs = true;

super.create();
}

function initOptions() {
grpOptions = new FlxTypedGroup<Alphabet>();
add(grpOptions);

for (i in 0...options.length)
{
var optionText:Alphabet = new Alphabet(0, 0, options[i], true);
optionText.screenCenter();
optionText.y += (100 * (i - (options.length / 2))) + 50;
optionText.scrollFactor.set(0, Math.max(0.25 - (0.05 * (options.length - 4)), 0.1));
grpOptions.add(optionText);
}
}

override function update(elapsed:Float) {
super.update(elapsed);

var lerpVal:Float = CoolUtil.boundTo(elapsed * 7.5, 0, 1);
camFollowPos.setPosition(FlxMath.lerp(camFollowPos.x, camFollow.x, lerpVal), FlxMath.lerp(camFollowPos.y, camFollow.y, lerpVal));

var mult:Float = FlxMath.lerp(1.07, bg.scale.x, CoolUtil.boundTo(1 - (elapsed * 9), 0, 1));
bg.scale.set(mult, mult);
bg.updateHitbox();
bg.offset.set();

if (allowInputs)
{
if ((FlxG.keys.justPressed.UP || FlxG.keys.justPressed.DOWN) && !accepted) {
changeSelection(FlxG.keys.justPressed.UP ? -1 : 1);
}

if (FlxG.keys.justPressed.ENTER && !accepted) {
accepted = true; // locks inputs
FlxG.sound.play(Paths.sound('confirmMenu'));
if (ClientPrefs.flashing) {
grpOptions.forEach(function(grpOptions:Alphabet)
{
FlxFlicker.flicker(grpOptions, 1, 0.06, false, false, function(flick:FlxFlicker)
{
openSelectedSubstate(options[curSelected]);
});
});
} else {
new FlxTimer().start(1, function(tmr:FlxTimer)
{
openSelectedSubstate(options[curSelected]);
});
}
}
}
}

function changeSelection(change:Int = 0) {
curSelected += change;
if (curSelected < 0)
curSelected = options.length - 1;
if (curSelected >= options.length)
curSelected = 0;

var bullShit:Int = 0;

for (item in grpOptions.members) {
item.targetY = bullShit - curSelected;
bullShit++;

item.alpha = 0.6;
if (item.targetY == 0) {
item.alpha = 1;
selectorLeft.x = item.x - 63;
selectorLeft.y = item.y;
selectorRight.x = item.x + item.width + 15;
selectorRight.y = item.y;
var add:Float = (grpOptions.members.length > 4 ? grpOptions.members.length * 8 : 0);
camFollow.setPosition(item.getGraphicMidpoint().x, item.getGraphicMidpoint().y - add);
}
}
}

function quitGame() {
FlxG.camera.fade(FlxColor.BLACK, 0.5, false, function() { Sys.exit(0); }, false);
}
}
96 changes: 55 additions & 41 deletions source/meta/substate/PauseSubState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,14 @@ class PauseSubState extends MusicBeatSubstate
'Resume',
'Restart Song',
'Change Difficulty',
'Go to Options',
'Exit to freeplay',
'Exit to menu',
'Close Game'
'Options',
'Exit'
];
var exitChoices = [
'Exit to Freeplay',
'Exit to Main Menu',
'Exit Game',
'Back'
];
var difficultyChoices = [];
var curSelected:Int = 0;
Expand Down Expand Up @@ -237,6 +241,48 @@ class PauseSubState extends MusicBeatSubstate
regenMenu();
}

if (menuItems == exitChoices)
{
if(menuItems.length - 1 != curSelected && exitChoices.contains(daSelected)) {
switch (daSelected)
{
case "Exit to Freeplay":
PlayState.deathCounter = 0;
PlayState.seenCutscene = false;

Mods.loadTheFirstEnabledMod();
MusicBeatState.switchState(new FreeplayState());
PlayState.cancelMusicFadeTween();
FlxG.sound.playMusic(Paths.music('freakyMenu'));
PlayState.changedDifficulty = false;
PlayState.chartingMode = false;
case "Exit to Menu":
PlayState.deathCounter = 0;
PlayState.seenCutscene = false;

Mods.loadTheFirstEnabledMod();
if (PlayState.isStoryMode) {
MusicBeatState.switchState(new StoryMenuState());
} else {
if (ClientPrefs.simpleMain)
MusicBeatState.switchState(new SimpleMainMenuState());
else
MusicBeatState.switchState(new MainMenuState());
}
PlayState.cancelMusicFadeTween();
FlxG.sound.playMusic(Paths.music('freakyMenu'));
PlayState.changedDifficulty = false;
PlayState.chartingMode = false;
case "Exit Game":
FlxG.switchState(new GameExitState());
}
return;
}

menuItems = menuItemsOG;
regenMenu();
}

switch (daSelected)
{
case "Resume":
Expand Down Expand Up @@ -282,7 +328,7 @@ class PauseSubState extends MusicBeatSubstate
PlayState.instance.botplayTxt.visible = PlayState.instance.cpuControlled;
PlayState.instance.botplayTxt.alpha = 1;
PlayState.instance.botplaySine = 0;
case "Go to Options":
case "Options":
PlayState.deathCounter = 0;
PlayState.seenCutscene = false;

Expand All @@ -292,42 +338,10 @@ class PauseSubState extends MusicBeatSubstate
PlayState.changedDifficulty = false;
PlayState.chartingMode = false;
fromPlayState = true;
case "Exit to freeplay":
PlayState.deathCounter = 0;
PlayState.seenCutscene = false;

Mods.loadTheFirstEnabledMod();
MusicBeatState.switchState(new FreeplayState());
PlayState.cancelMusicFadeTween();
FlxG.sound.playMusic(Paths.music('freakyMenu'));
PlayState.changedDifficulty = false;
PlayState.chartingMode = false;
case "Exit to menu":
PlayState.deathCounter = 0;
PlayState.seenCutscene = false;

Mods.loadTheFirstEnabledMod();
if(PlayState.isStoryMode) {
MusicBeatState.switchState(new StoryMenuState());
} else {
if (ClientPrefs.simpleMain)
MusicBeatState.switchState(new SimpleMainMenuState());
else
MusicBeatState.switchState(new MainMenuState());
}
PlayState.cancelMusicFadeTween();
FlxG.sound.playMusic(Paths.music('freakyMenu'));
PlayState.changedDifficulty = false;
PlayState.chartingMode = false;
case "Close Game":
persistentUpdate = false;
FlxG.mouse.visible = true;
// WIP
openSubState(new Prompt('Are you sure you want to close the game?', 0, () -> lime.system.System.exit(0), () -> {
persistentUpdate = true;
FlxG.mouse.visible = false;
},
false));
case "Exit":
menuItems = exitChoices;
deleteSkipTimeText();
regenMenu();
}
}
}
Expand Down

0 comments on commit 6578bc8

Please sign in to comment.