Skip to content

Commit

Permalink
Merge pull request #45 from PixlJacket/master
Browse files Browse the repository at this point in the history
Stage Darkness Option
  • Loading branch information
Yoshubs authored Sep 25, 2021
2 parents c2a411a + 347fe2c commit 320f1f7
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 6 deletions.
11 changes: 11 additions & 0 deletions source/Init.hx
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,12 @@ class Init extends FlxState
'Whether to reduce movements, like icons bouncing or beat zooms in gameplay.',
NOT_FORCED
],
'Stage Darkness' => [
0,
1,
'Darkens non-ui elements, useful if you find the characters and backgrounds distracting.',
NOT_FORCED
],
'Display Accuracy' => [true, 0, 'Whether to display your accuracy on screen.', NOT_FORCED],
'Disable Antialiasing' => [
false,
Expand Down Expand Up @@ -223,6 +229,11 @@ class Init extends FlxState
|| trueSettings.get("Framerate Cap") > 360)
trueSettings.set("Framerate Cap", 30);

if (!Std.isOfType(trueSettings.get("Stage Darkness"), Int)
|| trueSettings.get("Stage Darkness") < 0
|| trueSettings.get("Stage Darkness") > 100)
trueSettings.set("Stage Darkness", 0);

// 'hardcoded' ui skins
gameSettings.get("UI Skin")[4] = CoolUtil.returnAssetsLibrary('UI');
if (!gameSettings.get("UI Skin")[4].contains(trueSettings.get("UI Skin")))
Expand Down
17 changes: 14 additions & 3 deletions source/gameFolder/gameObjects/userInterface/menu/Selector.hx
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@ class Selector extends FlxTypedSpriteGroup<FlxSprite>
public var options:Array<String>;

public var fpsCap:Bool = false;
public var darkBG:Bool = false;

public function new(x:Float = 0, y:Float = 0, word:String, options:Array<String>, fpsCap:Bool = false)
public function new(x:Float = 0, y:Float = 0, word:String, options:Array<String>, fpsCap:Bool = false, darkBG:Bool = false)
{
// call back the function
super(x, y);
Expand All @@ -33,6 +34,7 @@ class Selector extends FlxTypedSpriteGroup<FlxSprite>
// generate multiple pieces

this.fpsCap = fpsCap;
this.darkBG = darkBG;

#if html5
// lol heres how we fuck with everyone
Expand All @@ -51,9 +53,18 @@ class Selector extends FlxTypedSpriteGroup<FlxSprite>

chosenOptionString = Init.trueSettings.get(word);
if (fpsCap)
{
chosenOptionString = Std.string(Init.trueSettings.get(word));
optionChosen = new Alphabet(FlxG.width / 2 + ((fpsCap) ? 200 : 0), shiftY + 20, chosenOptionString, ((fpsCap) ? false : true), false);
add(optionChosen);
optionChosen = new Alphabet(FlxG.width / 2 + ((fpsCap) ? 200 : 0), shiftY + 20, chosenOptionString, ((fpsCap) ? false : true), false);
add(optionChosen);
// This is weird...
}
else if (darkBG)
{
chosenOptionString = Std.string(Init.trueSettings.get(word));
optionChosen = new Alphabet(FlxG.width / 2 + ((darkBG) ? 200 : 0), shiftY + 20, chosenOptionString, ((darkBG) ? false : true), false);
add(optionChosen);
}
}

public function createSelector(objectX:Float = 0, objectY:Float = 0, word:String, dir:String):FNFSprite
Expand Down
8 changes: 7 additions & 1 deletion source/gameFolder/meta/state/PlayState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,12 @@ class PlayState extends MusicBeatState
// set song position before beginning
Conductor.songPosition = -(Conductor.crochet * 4);

// darken everything but the arrows and ui via a flxsprite
var darknessBG:FlxSprite = new FlxSprite(FlxG.width * -0.5, FlxG.height * -0.5).makeGraphic(FlxG.width * 2, FlxG.height * 2, FlxColor.BLACK);
darknessBG.alpha = Init.trueSettings.get('Stage Darkness') * 0.01;
darknessBG.scrollFactor.set(0, 0);
add(darknessBG);

// strum setup
strumLines = new FlxTypedGroup<Strumline>();

Expand All @@ -269,7 +275,7 @@ class PlayState extends MusicBeatState
// create the game camera
camFollow = new FlxObject(0, 0, 1, 1);
camFollow.setPosition(camPos.x, camPos.y);
// check if the camera was following someone previouslyw
// check if the camera was following someone previously
if (prevCamFollow != null)
{
camFollow = prevCamFollow;
Expand Down
32 changes: 30 additions & 2 deletions source/gameFolder/meta/state/menus/OptionsMenuState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ class OptionsMenuState extends MusicBeatState
If you plug in a value, the script will run when the option is hovered over.
*/

// NOTE : Make sure to check Init.hx if you are trying to add options.

#if !html5
Discord.changePresence('OPTIONS MENU', 'Main Menu');
#end
Expand Down Expand Up @@ -91,6 +93,7 @@ class OptionsMenuState extends MusicBeatState
['Accessibility Settings', null],
['', null],
['Filter', getFromOption],
["Stage Darkness", getFromOption],
['Reduced Movements', getFromOption],
// this shouldn't be get from option, just testing
['', null],
Expand Down Expand Up @@ -387,7 +390,7 @@ class OptionsMenuState extends MusicBeatState
case 1:
// selector
var selector:Selector = new Selector(10, letter.y, letter.text, Init.gameSettings.get(letter.text)[4],
(letter.text == 'Framerate Cap') ? true : false);
(letter.text == 'Framerate Cap') ? true : false, (letter.text == 'Stage Darkness') ? true : false);

extrasMap.set(letter, selector);
default:
Expand Down Expand Up @@ -454,7 +457,8 @@ class OptionsMenuState extends MusicBeatState
function updateSelector(selector:Selector, updateBy:Int)
{
var fps = selector.fpsCap;
if (!fps)
var bgdark = selector.darkBG;
if (!fps && !bgdark)
{
// get the current option as a number
var storedNumber:Int = 0;
Expand Down Expand Up @@ -483,6 +487,30 @@ class OptionsMenuState extends MusicBeatState
Init.trueSettings.set(activeSubgroup.members[curSelection].text, selector.chosenOptionString);
Init.saveSettings();
}
else if (bgdark)
{
// lazily hardcoded darkness cap
var originaldark = Init.trueSettings.get(activeSubgroup.members[curSelection].text);
var increase = 5 * updateBy;
if (originaldark + increase < 0)
increase = 0;
// high darkness cap
if (originaldark + increase > 100)
increase = 0;

if (updateBy == -1)
selector.selectorPlay('left', 'press');
else
selector.selectorPlay('right', 'press');

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

originaldark += increase;
selector.chosenOptionString = Std.string(originaldark);
selector.optionChosen.text = Std.string(originaldark);
Init.trueSettings.set(activeSubgroup.members[curSelection].text, originaldark);
Init.saveSettings();
}
else
{ // bro I dont even know if the engine works in html5 why am I even doing this
// lazily hardcoded fps cap
Expand Down

0 comments on commit 320f1f7

Please sign in to comment.