Skip to content

Commit

Permalink
Admin Options and Stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
CamLikesKirby committed May 23, 2024
1 parent fe9d9c3 commit 4e3fb3a
Show file tree
Hide file tree
Showing 5 changed files with 201 additions and 39 deletions.
150 changes: 150 additions & 0 deletions source/AdminOptionsMenu.hx
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
package;

import flixel.tweens.FlxTween;
import flixel.tweens.FlxEase;
import Controls.KeyboardScheme;
import Controls.Control;
import flash.text.TextField;
import flixel.FlxG;
import flixel.FlxSprite;
import flixel.addons.display.FlxGridOverlay;
import flixel.group.FlxGroup.FlxTypedGroup;
import flixel.input.keyboard.FlxKey;
import flixel.math.FlxMath;
import flixel.text.FlxText;
import flixel.util.FlxColor;
import lime.utils.Assets;
import flixel.util.FlxTimer;
#if desktop
import Discord.DiscordClient;
#end

class AdminOptionsMenu extends MusicBeatState
{
var selector:FlxText;
var curSelected:Int = 0;

var controlsStrings:Array<String> = [];

private var grpControls:FlxTypedGroup<Alphabet>;

override function create()
{
#if desktop
DiscordClient.changePresence("In the Admin Options Menu", null);
#end
var menuBG:FlxSprite = new FlxSprite();
menuBG.color = 0xff373737;
menuBG.setGraphicSize(Std.int(menuBG.width * 1.1));
menuBG.updateHitbox();
menuBG.antialiasing = true;
menuBG.loadGraphic(MainMenuState.randomizeBG());
add(menuBG);

controlsStrings = CoolUtil.coolStringFile(
(FlxG.save.data.adminMode ? 'Admin Mode ON' : 'Admin Mode OFF')
+ "\n" + (FlxG.save.data.botplay ? 'Bot Play ON' : 'Bot Play OFF')
+ "\n" + (FlxG.save.data.practiceMode ? 'Practice Mode ON' : 'Practice Mode OFF')
);

grpControls = new FlxTypedGroup<Alphabet>();
add(grpControls);

for (i in 0...controlsStrings.length)
{
var controlLabel:Alphabet = new Alphabet(0, (70 * i) + 30, controlsStrings[i], true, false);
controlLabel.screenCenter(X);
controlLabel.itemType = 'Vertical';
controlLabel.isMenuItem = true;
controlLabel.targetY = i;
grpControls.add(controlLabel);
// DONT PUT X IN THE FIRST PARAMETER OF new ALPHABET() !!
}

super.create();
}

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

if (controls.BACK)
{
FlxG.save.flush();
FlxG.switchState(new OptionsMenu());
}
if (controls.UP_P)
changeSelection(-1);
if (controls.DOWN_P)
changeSelection(1);

if (controls.ACCEPT)
{
grpControls.remove(grpControls.members[curSelected]);
switch(curSelected)
{
case 0:
FlxG.save.data.adminMode = !FlxG.save.data.adminMode;
updateGroupControls((FlxG.save.data.adminMode ? 'Admin Mode ON' : 'Admin Mode OFF'), 1, 'Vertical');
case 1:
FlxG.save.data.botplay = !FlxG.save.data.botplay;
updateGroupControls(FlxG.save.data.botplay ? 'Bot Play ON' : 'Bot Play OFF', 13, 'Vertical');
case 2:
FlxG.save.data.practiceMode = !FlxG.save.data.practiceMode;
updateGroupControls(FlxG.save.data.practiceMode ? 'Practice Mode ON' : 'Practice Mode OFF', 13, 'Vertical');
}
}
}

var isSettingControl:Bool = false;

override function beatHit()
{
super.beatHit();
FlxTween.tween(FlxG.camera, {zoom:1.05}, 0.3, {ease: FlxEase.quadOut, type: BACKWARD});
}
function updateGroupControls(controlText:String, yIndex:Int, controlTextItemType:String)
{
var ctrl:Alphabet = new Alphabet(0, (70 * curSelected) + 30, controlText, true, false);
ctrl.screenCenter(X);
ctrl.isMenuItem = true;
ctrl.targetY = curSelected - yIndex;
ctrl.itemType = controlTextItemType;
grpControls.add(ctrl);
}

function changeSelection(change:Int = 0)
{
#if !switch
// NGio.logEvent('Fresh');
#end

FlxG.sound.play(Paths.sound('scrollMenu'), 0.4);

curSelected += change;

if (curSelected < 0)
curSelected = grpControls.length - 1;
if (curSelected >= grpControls.length)
curSelected = 0;

// selector.y = (70 * curSelected) + 30;

var bullShit:Int = 0;

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

item.alpha = 0.6;
// item.setGraphicSize(Std.int(item.width * 0.8));

if (item.targetY == 0)
{
item.alpha = 1;
// item.setGraphicSize(Std.int(item.width));
}
}
}
}
15 changes: 9 additions & 6 deletions source/OptionsMenu.hx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class OptionsMenu extends MusicBeatState
];
var curSongBarOptionSelected:Int;
public static var onPlayState:Bool = false;

override function create()
{
#if desktop
Expand Down Expand Up @@ -94,7 +94,6 @@ class OptionsMenu extends MusicBeatState
+ "\n" + (FlxG.save.data.disableFps ? LanguageManager.getTextString('option_enable_fps') : LanguageManager.getTextString('option_disable_fps'))
+ "\n" + (CompatTool.save.data.compatMode ? LanguageManager.getTextString('option_enable_compat') : LanguageManager.getTextString('option_disable_compat'))
+ "\n" + (FlxG.save.data.modchart ? 'Mod Chart OFF' : 'Mod Chart ON')
+ "\n" + (FlxG.save.data.botplay ? 'Bot Play ON' : 'Bot Play OFF')
);

grpControls = new FlxTypedGroup<Alphabet>();
Expand Down Expand Up @@ -212,12 +211,16 @@ class OptionsMenu extends MusicBeatState
updateGroupControls(CompatTool.save.data.compatMode ? LanguageManager.getTextString('option_enable_compat') : LanguageManager.getTextString('option_disable_compat'), 11, 'Vertical');
case 12:
if (!awaitingExploitation) FlxG.save.data.modchart = !FlxG.save.data.modchart;
updateGroupControls(FlxG.save.data.modchart ? 'Mod Chart OFF' : 'Mod Chart ON', 12, 'Vertical');
case 13:
FlxG.save.data.botplay = !FlxG.save.data.botplay;
updateGroupControls(FlxG.save.data.botplay ? 'Bot Play ON' : 'Bot Play OFF', 13, 'Vertical');
updateGroupControls(FlxG.save.data.modchart ? 'Mod Chart OFF' : 'Mod Chart ON', 12, 'Vertical');
}
}

if (FlxG.keys.justPressed.SEVEN)
{
FlxG.save.flush();
CompatTool.save.flush();
FlxG.switchState(new AdminOptionsMenu());
}
}

var isSettingControl:Bool = false;
Expand Down
51 changes: 29 additions & 22 deletions source/PlayState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,8 @@ class PlayState extends MusicBeatState

var bfTween:ColorTween;

var adminMode:Bool;

var tweenTime:Float;

var songPosBar:FlxBar;
Expand Down Expand Up @@ -464,6 +466,8 @@ class PlayState extends MusicBeatState

barType = FlxG.save.data.songBarOption;

adminMode = FlxG.save.data.adminMode;

resetShader();

if (FreeplayState.isaCustomSong) {
Expand Down Expand Up @@ -2256,6 +2260,14 @@ class PlayState extends MusicBeatState
}
function startCountdown():Void
{
if (SONG.song.toLowerCase() == 'cheating' || SONG.song.toLowerCase() == 'unfairness' || SONG.song.toLowerCase() == 'exploitation')
{
if(FlxG.save.data.botplay || FlxG.save.data.practiceMode && !adminMode)
{
FlxG.switchState(new SusState()); // hehe get jumpscared non-admins
}
}

inCutscene = false;

generateStaticArrows(0);
Expand Down Expand Up @@ -3813,7 +3825,7 @@ class PlayState extends MusicBeatState
}
}

#if debug
if (adminMode) {
if (FlxG.keys.justPressed.THREE)
{
if(FlxTransitionableState.skipNextTransIn)
Expand All @@ -3829,7 +3841,8 @@ class PlayState extends MusicBeatState
DiscordClient.changePresence("Chart Editor", null, null, true);
#end
}
#end
}


// FlxG.watch.addQuick('VOL', vocals.amplitudeLeft);
// FlxG.watch.addQuick('VOLRight', vocals.amplitudeRight);
Expand Down Expand Up @@ -3884,27 +3897,23 @@ class PlayState extends MusicBeatState
iconP1.changeState('normal');
}

#if debug
if (adminMode) {
if (FlxG.keys.justPressed.FOUR)
{
trace('DUMP LOL:\nDAD POSITION: ${dad.getPosition()}\nBOYFRIEND POSITION: ${boyfriend.getPosition()}\nGF POSITION: ${gf.getPosition()}\nCAMERA POSITION: ${camFollow.getPosition()}');
}
/*if (FlxG.keys.justPressed.FIVE)
if (FlxG.keys.justPressed.FIVE)
{
FlxG.switchState(new CharacterDebug(dad.curCharacter));
}
if (FlxG.keys.justPressed.SEMICOLON)
{
FlxG.switchState(new CharacterDebug(boyfriend.curCharacter));
}
if (FlxG.keys.justPressed.COMMA)
if (FlxG.keys.justPressed.NINE)
{
FlxG.switchState(new CharacterDebug(gf.curCharacter));
}
if (FlxG.keys.justPressed.EIGHT)
FlxG.switchState(new AnimationDebug(dad.curCharacter));
if (FlxG.keys.justPressed.SIX)
FlxG.switchState(new AnimationDebug(boyfriend.curCharacter));*/
FlxG.switchState(new AnimationDebug(boyfriend.curCharacter));
if (FlxG.keys.justPressed.TWO) //Go 10 seconds into the future :O
{
FlxG.sound.music.pause();
Expand Down Expand Up @@ -3945,9 +3954,7 @@ class PlayState extends MusicBeatState
vocals.play();
boyfriend.stunned = false;
}
/*if (FlxG.keys.justPressed.THREE)
FlxG.switchState(new AnimationDebug(gf.curCharacter));*/
#end
}

if (startingSong)
{
Expand Down Expand Up @@ -3997,7 +4004,7 @@ class PlayState extends MusicBeatState
FlxG.watch.addQuick("beatShit", curBeat);
FlxG.watch.addQuick("stepShit", curStep);

if (health <= 0 && !botPlay)
if (health <= 0 && !botPlay && !FlxG.save.data.practiceMode)
{
if(!perfectMode)
{
Expand Down Expand Up @@ -4324,10 +4331,10 @@ class PlayState extends MusicBeatState
if (!inCutscene && !botPlay)
keyShit();

#if debug
if (adminMode) {
if (FlxG.keys.justPressed.ONE)
endSong();
#end
}

if (updatevels)
{
Expand Down Expand Up @@ -4566,7 +4573,7 @@ class PlayState extends MusicBeatState

FlxG.sound.music.volume = 0;
vocals.volume = 0;
if (SONG.validScore && !botPlay && !(!modchartoption && (SONG.song.toLowerCase() == 'cheating' || SONG.song.toLowerCase() == 'unfairness' || SONG.song.toLowerCase() == 'kabunga' || localFunny == CharacterFunnyEffect.Exbungo || localFunny == CharacterFunnyEffect.Recurser || SONG.song.toLowerCase() == 'exploitation')))
if (SONG.validScore && !FlxG.save.data.practiceMode && !botPlay && !(!modchartoption && (SONG.song.toLowerCase() == 'cheating' || SONG.song.toLowerCase() == 'unfairness' || SONG.song.toLowerCase() == 'kabunga' || localFunny == CharacterFunnyEffect.Exbungo || localFunny == CharacterFunnyEffect.Recurser || SONG.song.toLowerCase() == 'exploitation')))
{
trace("score is valid");

Expand All @@ -4588,7 +4595,7 @@ class PlayState extends MusicBeatState
}
#end

if (!botPlay) {
if (!botPlay || !FlxG.save.data.practiceMode) {
// Song Character Unlocks (Story Mode)
if (isStoryMode)
{
Expand Down Expand Up @@ -4637,7 +4644,7 @@ class PlayState extends MusicBeatState
FlxG.save.data.songsCompleted = new Array<String>();
}
completedSongs = FlxG.save.data.songsCompleted;
if (!botPlay) completedSongs.push(storyPlaylist[0]);
if (!botPlay || !FlxG.save.data.practiceMode) completedSongs.push(storyPlaylist[0]);
for (i in 0...mustCompleteSongs.length)
{
if (!completedSongs.contains(mustCompleteSongs[i]))
Expand Down Expand Up @@ -4727,13 +4734,13 @@ class PlayState extends MusicBeatState
// if ()
StoryMenuState.weekUnlocked[Std.int(Math.min(storyWeek + 1, StoryMenuState.weekUnlocked.length - 1))] = true;

if (SONG.validScore && !botPlay)
if (SONG.validScore && !botPlay && !FlxG.save.data.practiceMode)
{
Highscore.saveWeekScore(storyWeek, campaignScore,
storyDifficulty, characteroverride == "none" || characteroverride == "bf" ? "bf" : characteroverride);
}

if (!botPlay) FlxG.save.data.weekUnlocked = StoryMenuState.weekUnlocked;
if (!botPlay && !FlxG.save.data.practiceMode) FlxG.save.data.weekUnlocked = StoryMenuState.weekUnlocked;
FlxG.save.flush();
}
else
Expand Down Expand Up @@ -4810,7 +4817,7 @@ class PlayState extends MusicBeatState
FlxG.save.data.songsCompletedCanon = new Array<String>();
}
completedSongs = FlxG.save.data.songsCompletedCanon;
if (!botPlay) completedSongs.push(curSong);
if (!botPlay || !FlxG.save.data.practiceMode) completedSongs.push(curSong);
for (i in 0...mustCompleteSongs.length)
{
if (!completedSongs.contains(mustCompleteSongs[i]))
Expand Down
11 changes: 11 additions & 0 deletions source/SaveDataHandler.hx
Original file line number Diff line number Diff line change
Expand Up @@ -61,5 +61,16 @@ class SaveDataHandler

if (FlxG.save.data.songBarOption == null)
FlxG.save.data.songBarOption = 'ShowTime';

if (FlxG.save.data.adminMode == null) {
#if debug
FlxG.save.data.adminMode = true;
#else
FlxG.save.data.adminMode = false;
#end
}

if (FlxG.save.data.practiceMode == null)
FlxG.save.data.practiceMode = false;
}
}
Loading

0 comments on commit 4e3fb3a

Please sign in to comment.