Skip to content

Commit

Permalink
audio settings & an useless mod setup menu
Browse files Browse the repository at this point in the history
mod setup menu by joalor64

also command key support, idk i just wanna to make mac support a bit better
  • Loading branch information
charlesisfeline committed Apr 6, 2024
1 parent c7e13b2 commit 13a3ce6
Show file tree
Hide file tree
Showing 25 changed files with 445 additions and 133 deletions.
4 changes: 4 additions & 0 deletions source/Main.hx
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ class Main extends Sprite
startFullscreen: false // if the game should start at fullscreen mode
};

// changes how modifier keys are shown in UI.
// small heads-up Command is mapped to WINDOWS in Haxeflixel, Option is curiously mapped to ALT still though.
public static var modifier_keys:Array<String> = #if !mac ['Control', 'Alt']; #else['Command', 'Option']; #end

public static var fpsVar:FPSCounter;
public static var watermark:Sprite;
public static var colorFilter:ColorBlindness;
Expand Down
9 changes: 3 additions & 6 deletions source/backend/ClientPrefs.hx
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,6 @@ import states.StartingState;

// Add a variable here and it will get automatically saved
@:structInit class SaveVariables {
/*
options i probably may implement soon :)
public var judgementCounter:Bool = false;
public var middleScroll:Bool = false;
public var opponentStrums:Bool = true;
*/
public var downScroll:Bool = false;
public var middleScroll:Bool = false;
public var opponentStrums:Bool = true;
Expand All @@ -28,11 +22,14 @@ import states.StartingState;
public var watermarkIcon:Bool = true;
public var flashing:Bool = true;
public var autoPause:Bool = true;
public var musicVolume:Float = 100;
public var sfxVolume:Float = 100;
public var fullscreen:Bool = false;
public var showWatermark:Bool = true;
public var antialiasing:Bool = true;
public var noteSkin:String = 'Default';
public var splashSkin:String = 'Psych';
public var accuracyType:String = 'Judgement';
public var instantRespawn:Bool = false;
public var splashAlpha:Float = 0.6;
public var fpsRainbow:Bool = false; //kadedev
Expand Down
4 changes: 2 additions & 2 deletions source/backend/Difficulty.hx
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ class Difficulty
inline public static function getFilePath(num:Null<Int> = null) {
if(num == null) num = PlayState.storyDifficulty;

var filePostfix:String = list[num];
if(Paths.formatToSongPath(filePostfix) != Paths.formatToSongPath(defaultDifficulty)) filePostfix = '-' + filePostfix;
var filePostfix:String = list[num].toLowerCase();
if(Paths.formatToSongPath(filePostfix) != Paths.formatToSongPath(defaultDifficulty).toLowerCase()) filePostfix = '-' + filePostfix;
else filePostfix = '';
return Paths.formatToSongPath(filePostfix);
}
Expand Down
4 changes: 3 additions & 1 deletion source/backend/InputFormatter.hx
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,12 @@ class InputFormatter {
switch (key) {
case BACKSPACE:
return "BckSpc";
#if mac case WINDOWS:
return 'Command'; #end
case CONTROL:
return "Ctrl";
case ALT:
return "Alt";
return Main.modifier_keys[1];
case CAPSLOCK:
return "Caps";
case PAGEUP:
Expand Down
2 changes: 1 addition & 1 deletion source/options/ControlsSubState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ class ControlsSubState extends MusicBeatSubstate
close();
return;
}
if(FlxG.keys.justPressed.CONTROL || FlxG.gamepads.anyJustPressed(LEFT_SHOULDER) || FlxG.gamepads.anyJustPressed(RIGHT_SHOULDER)) swapMode();
if(#if !mac FlxG.keys.justPressed.CONTROL #else FlxG.keys.justPressed.WINDOWS #end || FlxG.gamepads.anyJustPressed(LEFT_SHOULDER) || FlxG.gamepads.anyJustPressed(RIGHT_SHOULDER)) swapMode();

if(FlxG.keys.justPressed.LEFT || FlxG.keys.justPressed.RIGHT || FlxG.gamepads.anyJustPressed(DPAD_LEFT) || FlxG.gamepads.anyJustPressed(DPAD_RIGHT) ||
FlxG.gamepads.anyJustPressed(LEFT_STICK_DIGITAL_LEFT) || FlxG.gamepads.anyJustPressed(LEFT_STICK_DIGITAL_RIGHT)) updateAlt(true);
Expand Down
7 changes: 7 additions & 0 deletions source/options/GameplaySettingsSubState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,13 @@ class GameplaySettingsSubState extends BaseOptionsMenu
'bool');
addOption(option);

var option:Option = new Option('Accuracy Type:',
"The way accuracy is calculated. \nNote = Depending on if a note is hit or not.\nJudgement = Depending on Judgement.\nMillisecond = Depending on milliseconds.",
'accuracyType',
'string',
['Note', 'Judgement', 'Millisecond']);
addOption(option);

var option:Option = new Option('Auto Pause',
"If checked, the game automatically pauses\nwhen you click out of the window.",
'autoPause',
Expand Down
22 changes: 20 additions & 2 deletions source/options/GraphicsSettingsSubState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ class GraphicsSettingsSubState extends BaseOptionsMenu {
var antialiasingOption:Int;
var boyfriend:Character = null;
public function new() {
title = 'Graphics';
rpcTitle = 'Graphics Settings Menu'; //for Discord Rich Presence
title = 'Graphics & Auidio';
rpcTitle = 'Graphics & Audio Settings Menu'; //for Discord Rich Presence

boyfriend = new Character(700, 170, 'bf', true);
boyfriend.setGraphicSize(Std.int(boyfriend.width * 0.75));
Expand Down Expand Up @@ -45,6 +45,24 @@ class GraphicsSettingsSubState extends BaseOptionsMenu {
"If checked, allows the GPU to be used for caching textures, decreasing RAM usage.\nDon't turn this on if you have a shitty Graphics Card.", //Description
'cacheOnGPU',
'bool');

var option:Option = new Option('Music Volume',
"Pretty self explanatory, isn't it? Sets in-game music volume. (Not menus.)",
'musicVolume',
'int');
addOption(option);
option.minValue = 0;
option.maxValue = 100;
option.displayFormat = '%v%';

var option:Option = new Option('Sound Effect Volume',
"Pretty self explanatory, isn't it? Sets in-game SFX volume. (Not menus.)",
'sfxVolume',
'int');
addOption(option);
option.minValue = 0;
option.maxValue = 100;
option.displayFormat = '%v%';
addOption(option);

#if !html5 //Apparently other framerates isn't correctly supported on Browser? Probably it has some V-Sync shit enabled by default, idk
Expand Down
2 changes: 1 addition & 1 deletion source/options/NotesSubState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ class NotesSubState extends MusicBeatSubstate
var controllerPressed:Bool = (controls.controllerMode && controls.ACCEPT);
//

if(FlxG.keys.justPressed.CONTROL)
if(#if !mac FlxG.keys.justPressed.CONTROL #else FlxG.keys.pressed.WINDOWS #end)
{
onPixel = !onPixel;
spawnNotes();
Expand Down
4 changes: 2 additions & 2 deletions source/options/PrefsMenu.hx
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ import backend.StageData;

class PrefsMenu extends MusicBeatState
{
var options:Array<String> = ['Graphics', 'Visuals and UI', 'Gameplay'];
var options:Array<String> = ['Gameplay', 'Graphics & Audio', 'Visuals and UI'];
private var grpOptions:FlxTypedGroup<Alphabet>;
private static var curSelected:Int = 0;
public static var menuBG:FlxSprite;
public static var onPlayState:Bool = false;

function openSelectedSubstate(label:String) {
switch(label) {
case 'Graphics':
case 'Graphics & Audio':
openSubState(new options.GraphicsSettingsSubState());
case 'Visuals and UI':
openSubState(new options.VisualsUISubState());
Expand Down
88 changes: 47 additions & 41 deletions source/psychlua/ExtraFunctions.hx
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
package psychlua;

import flixel.input.keyboard.FlxKey;
import flixel.util.FlxSave;
import openfl.utils.Assets;

//
/*
// Things to trivialize some dumb stuff like splitting strings on older Lua
//
*/

class ExtraFunctions
{
Expand All @@ -14,48 +15,48 @@ class ExtraFunctions
var lua:State = funk.lua;

// Keyboard & Gamepads
Lua_helper.add_callback(lua, "keyboardJustPressed", function(name:String)
{
return Reflect.getProperty(FlxG.keys.justPressed, name);
});
Lua_helper.add_callback(lua, "keyboardPressed", function(name:String)
{
return Reflect.getProperty(FlxG.keys.pressed, name);
});
Lua_helper.add_callback(lua, "keyboardReleased", function(name:String)
{
return Reflect.getProperty(FlxG.keys.justReleased, name);
});
Lua_helper.add_callback(lua, "keyboardJustPressed", function(name:String) return Reflect.getProperty(FlxG.keys.justPressed, name.toUpperCase()));
Lua_helper.add_callback(lua, "keyboardPressed", function(name:String) return Reflect.getProperty(FlxG.keys.pressed, name.toUpperCase()));
Lua_helper.add_callback(lua, "keyboardReleased", function(name:String) return Reflect.getProperty(FlxG.keys.justReleased, name.toUpperCase()));

Lua_helper.add_callback(lua, "anyGamepadJustPressed", function(name:String)
Lua_helper.add_callback(lua, "firstKeyJustPressed", function():String
{
return FlxG.gamepads.anyJustPressed(name);
var result:String = cast (FlxG.keys.firstJustPressed(), FlxKey).toString();
if (result == null || result.length < 1) result = "NONE"; // "Why?" `FlxKey.toStringMap` does not contain `FlxKey.NONE`, so we need to have a check for it.

return result;
});
Lua_helper.add_callback(lua, "anyGamepadPressed", function(name:String)

Lua_helper.add_callback(lua, "firstKeyPressed", function():String
{
return FlxG.gamepads.anyPressed(name);
var result:String = cast (FlxG.keys.firstPressed(), FlxKey).toString();
if (result == null || result.length < 1) result = "NONE";

return result;
});
Lua_helper.add_callback(lua, "anyGamepadReleased", function(name:String)

Lua_helper.add_callback(lua, "firstKeyJustReleased", function():String
{
return FlxG.gamepads.anyJustReleased(name);
var result:String = cast (FlxG.keys.firstJustReleased(), FlxKey).toString();
if (result == null || result.length < 1) result = "NONE";

return result;
});

Lua_helper.add_callback(lua, "anyGamepadJustPressed", function(name:String) return FlxG.gamepads.anyJustPressed(name));
Lua_helper.add_callback(lua, "anyGamepadPressed", function(name:String) return FlxG.gamepads.anyPressed(name));
Lua_helper.add_callback(lua, "anyGamepadReleased", function(name:String) return FlxG.gamepads.anyJustReleased(name));

Lua_helper.add_callback(lua, "gamepadAnalogX", function(id:Int, ?leftStick:Bool = true)
{
var controller = FlxG.gamepads.getByID(id);
if (controller == null)
{
return 0.0;
}
if (controller == null) return 0.0;
return controller.getXAxis(leftStick ? LEFT_ANALOG_STICK : RIGHT_ANALOG_STICK);
});
Lua_helper.add_callback(lua, "gamepadAnalogY", function(id:Int, ?leftStick:Bool = true)
{
var controller = FlxG.gamepads.getByID(id);
if (controller == null)
{
return 0.0;
}
if (controller == null) return 0.0;
return controller.getYAxis(leftStick ? LEFT_ANALOG_STICK : RIGHT_ANALOG_STICK);
});
Lua_helper.add_callback(lua, "gamepadJustPressed", function(id:Int, name:String)
Expand Down Expand Up @@ -120,6 +121,10 @@ class ExtraFunctions
return false;
});

Lua_helper.add_callback(lua, "isOfType", function(tag:String, cls:String):Bool {
return Std.isOfType(LuaUtils.getObjectDirectly(tag), Type.resolveClass(cls));
});

// Save data management
Lua_helper.add_callback(lua, "initSaveData", function(name:String, ?folder:String = 'psychenginemods') {
if(!PlayState.instance.modchartSaves.exists(name))
Expand Down Expand Up @@ -171,25 +176,28 @@ class ExtraFunctions
});

// File management
Lua_helper.add_callback(lua, "parseJson", function(location:String):{} {
var parsed:{} = {};

if (FileSystem.exists(Paths.getPath('data/$location', TEXT)))
parsed = tjson.TJSON.parse(File.getContent(Paths.getPath('data/$location', TEXT)));
else parsed = tjson.TJSON.parse(location);

return parsed;
});

Lua_helper.add_callback(lua, "checkFileExists", function(filename:String, ?absolute:Bool = false) {
#if MODS_ALLOWED
if(absolute)
{
return FileSystem.exists(filename);
}
if(absolute) return FileSystem.exists(filename);

var path:String = Paths.modFolders(filename);
if(FileSystem.exists(path))
{
return true;
}
return FileSystem.exists(Paths.getPath('assets/$filename', TEXT));
return FileSystem.exists(Paths.getPath(filename, TEXT));
#else
if(absolute)
{
return Assets.exists(filename);
}
return Assets.exists(Paths.getPath('assets/$filename', TEXT));
return Assets.exists(Paths.getPath(filename, TEXT));
#end
});
Lua_helper.add_callback(lua, "saveFile", function(path:String, content:String, ?absolute:Bool = false)
Expand Down Expand Up @@ -242,9 +250,7 @@ class ExtraFunctions
#if sys
if(FileSystem.exists(folder)) {
for (folder in FileSystem.readDirectory(folder)) {
if (!list.contains(folder)) {
list.push(folder);
}
if (!list.contains(folder)) list.push(folder);
}
}
#end
Expand Down
16 changes: 16 additions & 0 deletions source/psychlua/ReflectionFunctions.hx
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,22 @@ class ReflectionFunctions
else
FunkinLua.luaTrace('addInstance: Can\'t add what doesn\'t exist~ ($objectName)', false, false, FlxColor.RED);
});
Lua_helper.add_callback(lua, "removeInstance", function(objectName:String, destroy:Bool = true)
{
if (PlayState.instance.variables.exists(objectName))
{
var obj:Dynamic = PlayState.instance.variables.get(objectName);
LuaUtils.getTargetInstance().remove(obj, true);
if (destroy)
{
obj.kill();
obj.destroy();
PlayState.instance.variables.remove(objectName);
}
}
else
FunkinLua.luaTrace('removeInstance: Variable $objectName does not exist and cannot be removed!');
});
Lua_helper.add_callback(lua, "instanceArg", function(instanceName:String, ?className:String = null)
{
var retStr:String = '$instanceStr::$instanceName';
Expand Down
4 changes: 2 additions & 2 deletions source/states/FreeplayState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ class FreeplayState extends MusicBeatState {
bottomBG.alpha = 0.6;
add(bottomBG);

var leText:String = "[SPACE] - Listen to the Song / [CTRL] - Open the Modifiers Menu / [RESET] - Reset your Score / [HOLD C] - Enable Character Selector";
var leText:String = "[SPACE] - Listen to the Song / [" + Main.modifier_keys[0] + "] - Open the Modifiers Menu / [RESET] - Reset your Score / [HOLD C] - Enable Character Selector";
bottomString = leText;
var size:Int = 16;
bottomText = new FlxText(bottomBG.x, bottomBG.y + 4, FlxG.width, leText, size);
Expand Down Expand Up @@ -330,7 +330,7 @@ class FreeplayState extends MusicBeatState {
}
}

if(FlxG.keys.justPressed.CONTROL && !player.playingMusic){
if(#if !mac FlxG.keys.justPressed.CONTROL #else FlxG.keys.justPressed.WINDOWS #end && !player.playingMusic){
persistentUpdate = false;
openSubState(new GameplayChangersSubstate());
}else if(FlxG.keys.justPressed.SPACE){
Expand Down
Loading

0 comments on commit 13a3ce6

Please sign in to comment.