Skip to content

Commit

Permalink
new option system
Browse files Browse the repository at this point in the history
  • Loading branch information
x8c8r committed Jul 1, 2024
1 parent 2609284 commit 71131bd
Show file tree
Hide file tree
Showing 11 changed files with 474 additions and 77 deletions.
7 changes: 7 additions & 0 deletions assets/preload/data/monster/monsterDialogue2.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
:dad:i am the pumpkin head
:bf:what the fuck are you talking about man
:dad:i have like a fucking pumpkin for a head are you fucking stupid
:bf:go fuck yourself
:dad:you go fuck yourself
:dad:fuck your own ass sideways to the point where you cant fucking feel it anymore you fucking shithead kys
:bf:ok
File renamed without changes.
5 changes: 5 additions & 0 deletions assets/preload/data/south/southDialogue2.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
:bf:ok that was pretty good i guess
:bf:so what now
:dad:well things are about to go south after this song
:dad:you might meet some monster or something
:bf:...
7 changes: 7 additions & 0 deletions assets/preload/data/spookeez/spookeezDialogue2.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
:dad:it is the spooky month
:bf:what the fuck
:dad:it is the spooky month
:bf:first of all
:bf:what the fuck are you 2 squeakers doing in my attic
:bf:second of all
:bf:IT IS THE MIDDLE OF JU-
6 changes: 6 additions & 0 deletions source/CoolUtil.hx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package;

import flixel.math.FlxRandom;
import lime.utils.Assets;

using StringTools;
Expand Down Expand Up @@ -39,4 +40,9 @@ class CoolUtil
}
return dumbArray;
}

public static function randomArray(ar:Array<Dynamic>):Dynamic {
var res = new FlxRandom().int(0, ar.length-1);
return ar[res];
}
}
77 changes: 53 additions & 24 deletions source/OptionsMenu.hx
Original file line number Diff line number Diff line change
Expand Up @@ -31,35 +31,61 @@ class OptionsMenu extends MusicBeatState
Universal:
type - 2Type,
name,
initial value
2Type:
values = [val1, val2]
currently selected value
writtenValues = [textForVal1, textForVal2]
function that runs on change
]
*/

var options:Array<Array<Dynamic>> = [
[ // Keybinds
"2Type",
"Keybinds",
0,
[0, 1],
0,
["DFJK", "WASD"]
"DFJK",
["DFJK", "WASD"],
() -> {
if (SaveManagement.getOption("Keybinds") == "DFJK")
controls.setKeyboardScheme(KeyboardScheme.Solo, true);
else
controls.setKeyboardScheme(KeyboardScheme.Duo(true), true);
}
],
[ // Inputs
"2Type",
"Input System",
"New",
["New", "Old"],
null
],
[ // Scroll Dir
"2Type",
"Scroll Direction",
"Up",
["Up", "Down"],
null
],
[ // Hitsounds
"2Type",
"Hitsounds",
"Off",
["Off", "On"],
null
]
];

function restoreOptionValues() {
var it = 0;
trace(FlxG.save.data.options);
var it = 0;
for (option in options.iterator()) {
var type:String = option[0];
var name:String = option[1];

switch (type) {
case "2Type":
option[4] = FlxG.save.data.options[it];
if (SaveManagement.getOption(name) != null)
option[2] = SaveManagement.getOption(name);
default:
trace("Invalid option type");
}
Expand All @@ -69,7 +95,7 @@ class OptionsMenu extends MusicBeatState

override function create()
{
var menuBG:FlxSprite = new FlxSprite().loadGraphic(Paths.image('menuDesat'));
/*var menuBG:FlxSprite = new FlxSprite().loadGraphic(Paths.image('menuDesat'));
controlsStrings = CoolUtil.coolStringFile(
(FlxG.save.data.dfjk ? 'DFJK' : 'WASD') + "\n" +
(FlxG.save.data.newInput ? "New input" : "Old Input") + "\n" +
Expand All @@ -82,12 +108,12 @@ class OptionsMenu extends MusicBeatState
menuBG.updateHitbox();
menuBG.screenCenter();
menuBG.antialiasing = true;
add(menuBG);
add(menuBG);*/

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

/*restoreOptionValues();
restoreOptionValues();

var it = 0;
for (option in options.iterator()) {
Expand All @@ -98,7 +124,7 @@ class OptionsMenu extends MusicBeatState

changeOption(option, it, false);
it++;
}*/
}

for (i in 0...controlsStrings.length)
{
Expand Down Expand Up @@ -146,8 +172,8 @@ class OptionsMenu extends MusicBeatState

if (controls.ACCEPT)
{
// changeOption(options[curSelected], curSelected);
if (curSelected != grpControls.length-1)
changeOption(options[curSelected], curSelected);
/*if (curSelected != grpControls.length-1)
grpControls.remove(grpControls.members[curSelected]);
switch(curSelected)
{
Expand Down Expand Up @@ -186,7 +212,7 @@ class OptionsMenu extends MusicBeatState
ctrl.isMenuItem = true;
ctrl.targetY = curSelected - 4;
grpControls.add(ctrl);
}
}*/
}
}

Expand Down Expand Up @@ -233,19 +259,22 @@ class OptionsMenu extends MusicBeatState

switch (type) {
case "2Type":
var values = option[3];
var curValue = option[4];
var writtenValues = option[5];
var curValue:String = option[2];
var values:Array<String> = option[3];

if (update) {
option[4] = curValue == 0 ? 1 : 0;
FlxG.save.data.options[selectNumber] = option[4];
var cur = values.indexOf(curValue)+1;
option[2] = values[cur] == null ? values[0] : values[cur];

SaveManagement.setOption(name, option[2]);

if (option[5] != null) option[5]();

trace(name);
trace(SaveManagement.getOption(name));
}

trace(writtenValues);
trace(option[4]);
grpControls.members[selectNumber].text = name+": " + writtenValues[option[4]];
trace("Changed value of " + name + " to " + option[4]);
grpControls.members[selectNumber].text = name+": " + Std.string(option[2]);
default:
trace("Incorrect option type");
}
Expand Down
76 changes: 39 additions & 37 deletions source/PlayState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,13 @@ import sys.FileSystem;

class PlayState extends MusicBeatState
{
public static var instance(get,null):PlayState;
public static function get_instance():PlayState {
if (instance == null)
instance = new PlayState();
return instance;
}

public static var curStage:String = '';
public static var SONG:SwagSong;
public static var isStoryMode:Bool = false;
Expand All @@ -65,8 +72,6 @@ class PlayState extends MusicBeatState
public static var isPixel:Bool = false;
public static var isGood:Bool = false;

var halloweenLevel:Bool = false;

private var vocals:FlxSound;

private var dad:Character;
Expand Down Expand Up @@ -150,7 +155,7 @@ class PlayState extends MusicBeatState

public static var campaignScore:Int = 0;

var defaultCamZoom:Float = 1.05;
public static var defaultCamZoom:Float = 1.05;

public static var daPixelZoom:Float = 6;

Expand Down Expand Up @@ -190,7 +195,10 @@ class PlayState extends MusicBeatState
specialgf = true;
}

theFunne = FlxG.save.data.newInput;
// theFunne = FlxG.save.data.newInput;
theFunne = SaveManagement.getOption("Input System") == "New";

trace(SaveManagement.getOption("Input System"));
if (FlxG.sound.music != null)
FlxG.sound.music.stop();

Expand Down Expand Up @@ -265,34 +273,6 @@ class PlayState extends MusicBeatState
Conductor.mapBPMChanges(SONG);
Conductor.changeBPM(SONG.bpm);

switch (SONG.song.toLowerCase().trim())
{
case 'tutorial':
dialogue = ["Hey you're pretty cute.", 'Use the arrow keys to keep up \nwith me singing.'];
case 'bopeebo':
dialogue = [
'HEY!',
"You think you can just sing\nwith my daughter like that?",
"If you want to date her...",
"You're going to have to go \nthrough ME first!"
];
case 'fresh':
dialogue = ["Not too shabby boy.", ""];
case 'dadbattle':
dialogue = [
"gah you think you're hot stuff?",
"If you can beat me here...",
"Only then I will even CONSIDER letting you\ndate my daughter!"
];
case 'senpai':
dialogue = CoolUtil.coolTextFile(Paths.txt('senpai/senpaiDialogue'));
case 'roses':
dialogue = CoolUtil.coolTextFile(Paths.txt('roses/rosesDialogue'));
case 'thorns':
dialogue = CoolUtil.coolTextFile(Paths.txt('thorns/thornsDialogue'));
case 'winter-horrorland':
dialogue = CoolUtil.coolTextFile(Paths.txt('winter-horrorland/winter-horrorlandDialogue'));
}

#if desktop
if (hasDialogue)
Expand All @@ -303,14 +283,35 @@ class PlayState extends MusicBeatState
if (files[i].endsWith('.txt'))
dialogueFiles.push(files[i].replace('.txt', '').trim());
}

trace(dialogueFiles);
dialogue = CoolUtil.coolTextFile(Paths.txt(SONG.song.toLowerCase().trim()+'/'+dialogueFiles[FlxG.random.int(0, dialogueFiles.length-1)]));
}
#else
dialogue = [
":bf:GO FUCK YOURSELF",
":dad:GO FUCK YOURSELF",
":bf:GO FUCK YOURSELF",
":dad:GO FUCK YOURSELF",
":bf:GO FUCK YOURSELF",
":dad:GO FUCK YOURSELF",
":bf:FUCK YOURSELF",
":dad:GO FUCK YOURSELF",
":bf:FUCK",
":dad:FUCK",
":bf:FUCK",
":dad:GO FUCK YOURSELF",
":bf:GO FUCK YOURSELF",
":dad:GO FUCK YOURSELF",
":bf:GO FUCK YOURSELF",
":dad:GO FUCK YOURSELF",
":bf:GO FUCK YOURSELF"
]
#end

if (SONG.stage == "spooky")
{
curStage = "spooky";
halloweenLevel = true;

var hallowTex = Paths.getSparrowAtlas('stages/halloween_bg');

Expand Down Expand Up @@ -815,7 +816,8 @@ class PlayState extends MusicBeatState
strumLine = new FlxSprite(0, 50).makeGraphic(FlxG.width, 10);
strumLine.scrollFactor.set();

if (FlxG.save.data.downscroll)
// if (FlxG.save.data.downscroll)
if (SaveManagement.getOption("Scroll Direction") == "Down")
strumLine.y = FlxG.height - 165;

strumLineNotes = new FlxTypedGroup<FlxSprite>();
Expand Down Expand Up @@ -1889,15 +1891,15 @@ class PlayState extends MusicBeatState
daNote.destroy();
}

if (FlxG.save.data.downscroll)
if (SaveManagement.getOption("Scroll Direction") == "Down")
daNote.y = (strumLine.y - (Conductor.songPosition - daNote.strumTime) * (-0.45 * FlxMath.roundDecimal(SONG.speed, 2)));
else
daNote.y = (strumLine.y - (Conductor.songPosition - daNote.strumTime) * (0.45 * FlxMath.roundDecimal(SONG.speed, 2)));
//trace(daNote.y);
// WIP interpolation shit? Need to fix the pause issue
// daNote.y = (strumLine.y - (songTime - daNote.strumTime) * (0.45 * PlayState.SONG.speed));

if (daNote.y < -daNote.height && !FlxG.save.data.downscroll || daNote.y >= strumLine.y + 106 && FlxG.save.data.downscroll)
if (daNote.y < -daNote.height && SaveManagement.getOption("Scroll Direction") == "Up" || daNote.y >= strumLine.y + 106 && SaveManagement.getOption("Scroll Direction") == "Down")
{
if (daNote.isSustainNote && daNote.wasGoodHit)
{
Expand Down Expand Up @@ -2114,7 +2116,7 @@ class PlayState extends MusicBeatState

if (daRating != 'shit' || daRating != 'bad')
{
if (FlxG.save.data.hitsounds)
if (SaveManagement.getOption("Hitsounds") == "On")
FlxG.sound.play(Paths.sound('hitsound'));
songScore += score;

Expand Down
Loading

0 comments on commit 71131bd

Please sign in to comment.