diff --git a/engine/source/backend/Controls.hx b/engine/source/backend/Controls.hx index 76d71f4..b4e5ad0 100644 --- a/engine/source/backend/Controls.hx +++ b/engine/source/backend/Controls.hx @@ -23,6 +23,11 @@ class Controls implements IFlxDestroyable { */ public static var p2(default, null):Controls = new Controls(); + /** + * Used for arrow field's when it's not maintained by a player. + */ + public static var blank(default, null):Controls = new Controls(); + // UI // /** * When you press left to move through ui elements diff --git a/engine/source/backend/system/Settings.hx b/engine/source/backend/system/Settings.hx index 995d6a9..2d07325 100644 --- a/engine/source/backend/system/Settings.hx +++ b/engine/source/backend/system/Settings.hx @@ -25,7 +25,7 @@ enum abstract FpsType(String) from String to String { /** * The main settings for the engine. */ -@:structInit class MainSettings { +class MainSettings { #if MOD_SUPPORT /** * If true, this is like enabling soloOnlyMode in Modding. @@ -105,12 +105,14 @@ enum abstract FpsType(String) from String to String { * If true, logs with the `Warning` level won't show up. */ public var ignoreLogWarnings:Bool = true; + + @:allow(backend.system.Settings) function new() {} } /** * The settings for each player. */ -@:structInit class PlayerSettings { +class PlayerSettings { /** * If true, the strums will be at the bottom of the screen instead of the top. */ @@ -123,7 +125,7 @@ enum abstract FpsType(String) from String to String { /** * Basically, do you wish for the characters to repeat their sing anim every time they hit a sustain note? */ - public var beatLoop:Bool = true; + public var stepJitter:Bool = true; /** * If true, press shit all you fucking want asshole. */ @@ -158,6 +160,8 @@ enum abstract FpsType(String) from String to String { * If true, missing a note or sustain piece will make you miss that entire note. Otherwise you can miss each note piece. */ public var missFullSustain:Bool = true; + + @:allow(backend.system.Settings) function new() {} } /** @@ -167,33 +171,33 @@ class Settings { /** * The current settings. */ - public static var setup(default, set):MainSettings = {} + public static var setup(default, set):MainSettings = new MainSettings(); inline static function set_setup(value:MainSettings):MainSettings return setup = value; /** * Default settings. */ - public static var defaults(default, null):MainSettings = {} + public static var defaults(default, null):MainSettings = new MainSettings(); /** * Player 1's settings! */ - public static var setupP1(default, set):PlayerSettings = {} + public static var setupP1(default, set):PlayerSettings = new PlayerSettings(); inline static function set_setupP1(value:PlayerSettings):PlayerSettings return setupP1 = value; /** * Default player 1 settings. */ - public static var defaultsP1(default, null):PlayerSettings = {} + public static var defaultsP1(default, null):PlayerSettings = new PlayerSettings(); /** * Player 2's settings! */ - public static var setupP2(default, set):PlayerSettings = {} + public static var setupP2(default, set):PlayerSettings = new PlayerSettings(); inline static function set_setupP2(value:PlayerSettings):PlayerSettings return setupP2 = value; /** * Default player settings. */ - public static var defaultsP2(default, null):PlayerSettings = {} + public static var defaultsP2(default, null):PlayerSettings = new PlayerSettings(); } \ No newline at end of file diff --git a/engine/source/objects/gameplay/ArrowField.hx b/engine/source/objects/gameplay/ArrowField.hx index 5c9a4de..c5e5c36 100644 --- a/engine/source/objects/gameplay/ArrowField.hx +++ b/engine/source/objects/gameplay/ArrowField.hx @@ -71,9 +71,17 @@ class ArrowField extends BeatGroup { * If true, this field is maintained by a player. */ public var isPlayer(get, never):Bool; - inline function get_isPlayer():Bool { + inline function get_isPlayer():Bool return status != null && (status == !PlayConfig.enemyPlay || PlayConfig.enableP2) && !PlayConfig.botplay; - } + + public var controls(get, never):Null; + inline function get_controls():Null + if (status == null) return Controls.blank; + else return status == PlayConfig.enemyPlay ? Controls.p2 : Controls.p1; + public var settings(get, never):Null; + inline function get_settings():Null + if (status == null) return Settings.setupP1; + else return status == PlayConfig.enemyPlay ? Settings.setupP2 : Settings.setupP1; // signals /** @@ -110,7 +118,7 @@ class ArrowField extends BeatGroup { /** * The strums of the field. */ - public var strums(default, null):BeatTypedGroup = new BeatTypedGroup(); + public var strums(default, null):BeatTypedSpriteGroup = new BeatTypedSpriteGroup(); /** * The notes of the field. */ @@ -121,6 +129,7 @@ class ArrowField extends BeatGroup { public var sustains(default, null):BeatTypedGroup> = new BeatTypedGroup>(); public var noteKillRange:Float = 350; + public var strumSpacing:Float = -45; /** * The amount of strums in the field. @@ -130,13 +139,18 @@ class ArrowField extends BeatGroup { inline function set_strumCount(value:Int):Int return strumCount = 4;//Std.int(FlxMath.bound(value, 1, 9)); - override public function new(mania:Int = 4, ?singers:Array) { + override public function new(?singers:Array, mania:Int = 4) { strumCount = mania; super(); for (i in 0...strumCount) strums.add(new Strum(this, i)); - setFieldPosition(FlxG.width / 2, FlxG.height / 2); + + strums.group.memberAdded.add((_:Strum) -> strums.members.sort((a:Strum, b:Strum) -> return FlxSort.byValues(FlxSort.ASCENDING, a.id, b.id))); + strums.group.memberRemoved.add((_:Strum) -> strums.members.sort((a:Strum, b:Strum) -> return FlxSort.byValues(FlxSort.ASCENDING, a.id, b.id))); + + resetInternalPositions(); + setPosition(FlxG.width / 2, FlxG.height / 2); if (singers != null) assignedActors = singers; @@ -147,8 +161,6 @@ class ArrowField extends BeatGroup { } inline function _input():Void { - var isP2:Bool = status == PlayConfig.enemyPlay; - var controls:Controls = isP2 ? Controls.p2 : Controls.p1; for (i => strum in strums.members) input( i, @@ -174,7 +186,7 @@ class ArrowField extends BeatGroup { controls.noteRightReleased ] [i], - isP2 ? Settings.setupP2 : Settings.setupP1 + settings ); } @@ -238,6 +250,7 @@ class ArrowField extends BeatGroup { } override function update(elapsed:Float):Void { + // Hopefully the on update method is temporary until I can find a better way. As on input was giving some issues. if (isPlayer) _input(); @@ -330,18 +343,51 @@ class ArrowField extends BeatGroup { } } - /** - * Set's the position of the strums. - * @param x The x position. - * @param y The y position. - */ - public function setFieldPosition(x:Float = 0, y:Float = 0):Void { + public var totalWidth(default, null):Float; + public function resetInternalPositions():Void { + inline function helper(a:Strum, b:Strum):Void + if (a != null && b != null) + b.x = a.x + a.width + strumSpacing; + for (i => strum in strums.members) { - strum.setPosition(x - (Note.baseWidth / 2), y); - strum.x += Note.baseWidth * i; - strum.x -= (Note.baseWidth * ((strumCount - 1) / 2)); - // if (SaveManager.getOption('strumShift')) strum.x -= Note.baseWidth / 2.4; + strum.y = -strum.height / 2; + helper(strum, strums.members[i + 1]); } + + totalWidth = 0; // reset width + for (i => strum in strums.members) + totalWidth += strum.width; + + totalWidth += strumSpacing * (strumCount - 1); + for (strum in strums) + strum.x -= totalWidth / 2; + } + + /** + * The center x position of the field. + */ + @:isVar public var x(get, set):Float = 0; + inline function get_x():Float + return strums.x; + inline function set_x(value:Float):Float + return strums.x = value; + /** + * The center y position of the field. + */ + @:isVar public var y(get, set):Float = 0; + inline function get_y():Float + return strums.y; + inline function set_y(value:Float):Float + return strums.y = value; + + /** + * Set's the center position of the strum group. + * @param x The center x position. + * @param y The center y position. + */ + inline public function setPosition(x:Float = 0, y:Float = 0):Void { + this.x = x; + this.y = y; } /** diff --git a/engine/source/objects/gameplay/Note.hx b/engine/source/objects/gameplay/Note.hx index 8bb1d4a..8e2d32c 100644 --- a/engine/source/objects/gameplay/Note.hx +++ b/engine/source/objects/gameplay/Note.hx @@ -27,11 +27,6 @@ class Note extends FlxSprite { public var tail(default, null):BeatTypedGroup = new BeatTypedGroup(); // Note specific variables. - /** - * The base overall note width. - */ - public static var baseWidth(default, null):Float = 160 * 0.7; - /** * The strum lane index. */ @@ -118,7 +113,7 @@ class Note extends FlxSprite { strum ??= setStrum; var distance:{position:Float, time:Float} = {position: 0, time: 0} - var scrollAngle:Float = 270; + var scrollAngle:Float = setField.settings.downscroll ? 90 : 270; var angleDir:Float = Math.PI / 180; angleDir = scrollAngle * angleDir; diff --git a/engine/source/states/PlayState.hx b/engine/source/states/PlayState.hx index 593eb60..87513c1 100644 --- a/engine/source/states/PlayState.hx +++ b/engine/source/states/PlayState.hx @@ -445,9 +445,11 @@ class PlayState extends BeatState { ]; // TODO: @Zyflx said to tweak the y position, do it after HUD visuals are finalized. for (i => field in fields) { - var fieldWidth:Float = Note.baseWidth * 4; // TODO: Get ArrowField positioning working! - field.setFieldPosition((FlxG.width / 2) - (fieldWidth / 2) + (fieldWidth * i) - (fieldWidth * ((order.length - 1) / 2)), (FlxG.height / 2) - (FlxG.height / 2.2)); + field.y = (FlxG.height / 2) - ((FlxG.height / 2.6) * (Settings.setupP1.downscroll ? -1 : 1)); + field.x = (FlxG.width / 2) - (field.strums.width / 2); + field.x += field.strums.width * i; + field.x -= (field.strums.width * ((fields.length - 1) / 2)); field.visible = true; } } @@ -458,8 +460,8 @@ class PlayState extends BeatState { ArrowField.player = arrowFieldMapping.get(chartData.fieldSettings.player); // position system doesn't work yet, so for now there being put on screen like this - enemyField.setFieldPosition((FlxG.width / 2) - (FlxG.width / 4), (FlxG.height / 2) - (FlxG.height / 2.2)); - playerField.setFieldPosition((FlxG.width / 2) + (FlxG.width / 4), (FlxG.height / 2) - (FlxG.height / 2.2)); + enemyField.setPosition((FlxG.width / 2) - (FlxG.width / 4), (FlxG.height / 2) - ((FlxG.height / 2.6) * (Settings.setupP2.downscroll ? -1 : 1))); + playerField.setPosition((FlxG.width / 2) + (FlxG.width / 4), (FlxG.height / 2) - ((FlxG.height / 2.6) * (Settings.setupP1.downscroll ? -1 : 1))); enemyField.visible = playerField.visible = true; countdownAssets = { diff --git a/setup/Main.hx b/setup/Main.hx index 03bc96e..815dc3c 100644 --- a/setup/Main.hx +++ b/setup/Main.hx @@ -31,7 +31,7 @@ class Main { static var optionalCheck:Map = new Map(); static var questDesc:Map = new Map(); - static var dashes:String = '-------------------------------------------------------------------------------'; + inline static var dashes:String = '-------------------------------------------------------------------------------'; public static function main():Void { // arguments