Skip to content

Commit

Permalink
did some shit
Browse files Browse the repository at this point in the history
  • Loading branch information
mcagabe19 committed Nov 28, 2024
1 parent 1668ce6 commit 109b7d8
Show file tree
Hide file tree
Showing 8 changed files with 58 additions and 42 deletions.
2 changes: 1 addition & 1 deletion source/backend/ClientPrefs.hx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import states.TitleState;
@:structInit class SaveVariables {
// Mobile and Mobile Controls Releated
public var extraButtons:String = "NONE"; // mobile extra button option
public var hitbox2:Bool = true; // hitbox extra button position option
public var hitboxPos:Bool = true; // hitbox extra button position option
public var dynamicColors:Bool = true; // yes cause its cool -Karim
public var controlsAlpha:Float = FlxG.onMobile ? 0.6 : 0;
public var screensaver:Bool = false;
Expand Down
32 changes: 16 additions & 16 deletions source/backend/MusicBeatState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ class MusicBeatState extends FlxState
}

public var touchPad:TouchPad;
public var touchPadCam:FlxCamera;
public var mobileControls:IMobileControls;
public var camControls:FlxCamera;
public var tpadCam:FlxCamera;
public var mobileControlsCam:FlxCamera;

public function addTouchPad(DPad:String, Action:String)
{
Expand All @@ -38,10 +38,10 @@ class MusicBeatState extends FlxState
touchPad = FlxDestroyUtil.destroy(touchPad);
}

if(tpadCam != null)
if(touchPadCam != null)
{
FlxG.cameras.remove(tpadCam);
tpadCam = FlxDestroyUtil.destroy(tpadCam);
FlxG.cameras.remove(touchPadCam);
touchPadCam = FlxDestroyUtil.destroy(touchPadCam);
}
}

Expand All @@ -62,11 +62,11 @@ class MusicBeatState extends FlxState
}

mobileControls.instance = MobileData.setButtonsColors(mobileControls.instance);
camControls = new FlxCamera();
camControls.bgColor.alpha = 0;
FlxG.cameras.add(camControls, defaultDrawTarget);
mobileControlsCam = new FlxCamera();
mobileControlsCam.bgColor.alpha = 0;
FlxG.cameras.add(mobileControlsCam, defaultDrawTarget);

mobileControls.instance.cameras = [camControls];
mobileControls.instance.cameras = [mobileControlsCam];
mobileControls.instance.visible = false;
add(mobileControls.instance);
}
Expand All @@ -80,21 +80,21 @@ class MusicBeatState extends FlxState
mobileControls = null;
}

if(camControls != null)
if (mobileControlsCam != null)
{
FlxG.cameras.remove(camControls);
camControls = FlxDestroyUtil.destroy(camControls);
FlxG.cameras.remove(mobileControlsCam);
mobileControlsCam = FlxDestroyUtil.destroy(mobileControlsCam);
}
}

public function addTouchPadCamera(defaultDrawTarget:Bool = false):Void
{
if (touchPad != null)
{
tpadCam = new FlxCamera();
tpadCam.bgColor.alpha = 0;
FlxG.cameras.add(tpadCam, defaultDrawTarget);
touchPad.cameras = [tpadCam];
touchPadCam = new FlxCamera();
touchPadCam.bgColor.alpha = 0;
FlxG.cameras.add(touchPadCam, defaultDrawTarget);
touchPad.cameras = [touchPadCam];
}
}

Expand Down
33 changes: 16 additions & 17 deletions source/backend/MusicBeatSubstate.hx
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ class MusicBeatSubstate extends FlxSubState
return Controls.instance;

public var touchPad:TouchPad;
public var touchPadCam:FlxCamera;
public var mobileControls:IMobileControls;
public var camControls:FlxCamera;
public var tpadCam:FlxCamera;
public var mobileControlsCam:FlxCamera;

public function addTouchPad(DPad:String, Action:String)
{
Expand All @@ -48,10 +48,10 @@ class MusicBeatSubstate extends FlxSubState
touchPad = FlxDestroyUtil.destroy(touchPad);
}

if(tpadCam != null)
if(touchPadCam != null)
{
FlxG.cameras.remove(tpadCam);
tpadCam = FlxDestroyUtil.destroy(tpadCam);
FlxG.cameras.remove(touchPadCam);
touchPadCam = FlxDestroyUtil.destroy(touchPadCam);
}
}

Expand All @@ -72,11 +72,11 @@ class MusicBeatSubstate extends FlxSubState
}

mobileControls.instance = MobileData.setButtonsColors(mobileControls.instance);
camControls = new FlxCamera();
camControls.bgColor.alpha = 0;
FlxG.cameras.add(camControls, defaultDrawTarget);
mobileControlsCam = new FlxCamera();
mobileControlsCam.bgColor.alpha = 0;
FlxG.cameras.add(mobileControlsCam, defaultDrawTarget);

mobileControls.instance.cameras = [camControls];
mobileControls.instance.cameras = [mobileControlsCam];
mobileControls.instance.visible = false;
add(mobileControls.instance);
}
Expand All @@ -90,21 +90,21 @@ class MusicBeatSubstate extends FlxSubState
mobileControls = null;
}

if(camControls != null)
if (mobileControlsCam != null)
{
FlxG.cameras.remove(camControls);
camControls = FlxDestroyUtil.destroy(camControls);
FlxG.cameras.remove(mobileControlsCam);
mobileControlsCam = FlxDestroyUtil.destroy(mobileControlsCam);
}
}

public function addTouchPadCamera(defaultDrawTarget:Bool = false):Void
{
if (touchPad != null)
{
tpadCam = new FlxCamera();
tpadCam.bgColor.alpha = 0;
FlxG.cameras.add(tpadCam, defaultDrawTarget);
touchPad.cameras = [tpadCam];
touchPadCam = new FlxCamera();
touchPadCam.bgColor.alpha = 0;
FlxG.cameras.add(touchPadCam, defaultDrawTarget);
touchPad.cameras = [touchPadCam];
}
}

Expand All @@ -115,7 +115,6 @@ class MusicBeatSubstate extends FlxSubState
removeMobileControls();

super.destroy();

}

override function update(elapsed:Float)
Expand Down
6 changes: 3 additions & 3 deletions source/mobile/objects/Hitbox.hx
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ import openfl.geom.Matrix;
*/
class Hitbox extends MobileInputManager implements IMobileControls
{
final offsetFir:Int = (ClientPrefs.data.hitbox2 ? Std.int(FlxG.height / 4) * 3 : 0);
final offsetSec:Int = (ClientPrefs.data.hitbox2 ? 0 : Std.int(FlxG.height / 4));
final offsetFir:Int = (ClientPrefs.data.hitboxPos ? Std.int(FlxG.height / 4) * 3 : 0);
final offsetSec:Int = (ClientPrefs.data.hitboxPos ? 0 : Std.int(FlxG.height / 4));

public var buttonLeft:TouchButton = new TouchButton(0, 0, [MobileInputID.HITBOX_LEFT, MobileInputID.NOTE_LEFT]);
public var buttonDown:TouchButton = new TouchButton(0, 0, [MobileInputID.HITBOX_DOWN, MobileInputID.NOTE_DOWN]);
Expand Down Expand Up @@ -125,7 +125,7 @@ class Hitbox extends MobileInputManager implements IMobileControls
hint.label = new FlxSprite();
hint.labelStatusDiff = (ClientPrefs.data.hitboxType != "Hidden") ? ClientPrefs.data.controlsAlpha : 0.00001;
hint.label.loadGraphic(createHintGraphic(Width, Math.floor(Height * 0.035), true));
if (ClientPrefs.data.hitbox2)
if (ClientPrefs.data.hitboxPos)
hint.label.offset.y -= (hint.height - hint.label.height) / 2;
else
hint.label.offset.y += (hint.height - hint.label.height) / 2;
Expand Down
3 changes: 0 additions & 3 deletions source/mobile/objects/TouchPad.hx
Original file line number Diff line number Diff line change
Expand Up @@ -149,9 +149,6 @@ class TouchPad extends MobileInputManager implements IMobileControls
var field = Reflect.field(this, button);
if (button.toLowerCase().contains('extra') && Std.isOfType(field, TouchButton))
{
// if (MobileData.save.data.extraData[int] == null)
// MobileData.save.data.extraData.push(FlxPoint.get(field.x, field.y));
// else
MobileData.save.data.extraData[int] = FlxPoint.get(field.x, field.y);
++int;
}
Expand Down
2 changes: 1 addition & 1 deletion source/mobile/options/MobileOptionsSubState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ class MobileOptionsSubState extends BaseOptionsMenu
addOption(option);

option = new Option('Hitbox Position', 'If checked, the hitbox will be put at the bottom of the screen, otherwise will stay at the top.',
'hitbox2', BOOL);
'hitboxPos', BOOL);
addOption(option);
}

Expand Down
4 changes: 3 additions & 1 deletion source/options/ControlsSubState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,8 @@ class ControlsSubState extends MusicBeatSubstate
add(text);

createTexts();

addTouchPad('NONE', 'B');
}

var lastID:Int = 0;
Expand Down Expand Up @@ -284,7 +286,7 @@ class ControlsSubState extends MusicBeatSubstate

if(!binding)
{
if(FlxG.keys.justPressed.ESCAPE || FlxG.gamepads.anyJustPressed(B))
if(touchPad.buttonB.justPressed || FlxG.keys.justPressed.ESCAPE || FlxG.gamepads.anyJustPressed(B))
{
controls.isInSubstate = false;
close();
Expand Down
18 changes: 18 additions & 0 deletions source/psychlua/ExtraFunctions.hx
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,12 @@ class ExtraFunctions
case 'down': return PlayState.instance.controls.NOTE_DOWN_P;
case 'up': return PlayState.instance.controls.NOTE_UP_P;
case 'right': return PlayState.instance.controls.NOTE_RIGHT_P;
case 'space':
var mobileShit:Bool = false;
if (Controls.instance.mobileC)
if (MusicBeatState.getState().mobileControls != null)
mobileShit = MusicBeatState.getState().mobileControls.buttonExtra.justPressed;
return PlayState.instance.controls.justPressed('space') || mobileShit;
default: return PlayState.instance.controls.justPressed(name);
}
return false;
Expand All @@ -119,6 +125,12 @@ class ExtraFunctions
case 'down': return PlayState.instance.controls.NOTE_DOWN;
case 'up': return PlayState.instance.controls.NOTE_UP;
case 'right': return PlayState.instance.controls.NOTE_RIGHT;
case 'space':
var mobileShit:Bool = false;
if (Controls.instance.mobileC)
if (MusicBeatState.getState().mobileControls != null)
mobileShit = MusicBeatState.getState().mobileControls.buttonExtra.pressed;
return PlayState.instance.controls.pressed('space') || mobileShit;
default: return PlayState.instance.controls.pressed(name);
}
return false;
Expand All @@ -130,6 +142,12 @@ class ExtraFunctions
case 'down': return PlayState.instance.controls.NOTE_DOWN_R;
case 'up': return PlayState.instance.controls.NOTE_UP_R;
case 'right': return PlayState.instance.controls.NOTE_RIGHT_R;
case 'space':
var mobileShit:Bool = false;
if (Controls.instance.mobileC)
if (MusicBeatState.getState().mobileControls != null)
mobileShit = MusicBeatState.getState().mobileControls.buttonExtra.justReleased;
return PlayState.instance.controls.justReleased('space') || mobileShit;
default: return PlayState.instance.controls.justReleased(name);
}
return false;
Expand Down

0 comments on commit 109b7d8

Please sign in to comment.