Skip to content

Commit

Permalink
android.. changes
Browse files Browse the repository at this point in the history
  • Loading branch information
JordanSantiagoYT committed Oct 27, 2023
1 parent 30db7bf commit afcf168
Show file tree
Hide file tree
Showing 14 changed files with 1,585 additions and 1,260 deletions.
24 changes: 24 additions & 0 deletions source/ClientPrefs.hx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ class ClientPrefs { //default settings if it can't find a save file containing y
public static var showFPS:Bool = true;
public static var flashing:Bool = true;
public static var globalAntialiasing:Bool = true;
public static var dynamicColors:Bool = true;
public static var healthDisplay:Bool = true;
public static var ghostTapAnim:Bool = true;
public static var spaceVPose:Bool = true;
Expand Down Expand Up @@ -79,6 +80,11 @@ class ClientPrefs { //default settings if it can't find a save file containing y
public static var holdNoteHits:Bool = false;
public static var comboScoreEffect:Bool = false;
public static var noGunsRNG:Bool = false;
public static var hitboxSelection:String = 'Original';
public static var hitboxAlpha:Float = 0.5;
public static var virtualPadAlpha:Float = 0.5;
public static var hitboxSpace:Bool = false;
public static var hitboxSpaceLocation:String = 'Bottom';
public static var comboMultiType:String = 'osu!';
public static var noteOffset:Int = 0;
public static var arrowHSV:Array<Array<Int>> = [[0, 0, 0], [0, 0, 0], [0, 0, 0], [0, 0, 0]];
Expand Down Expand Up @@ -263,7 +269,13 @@ class ClientPrefs { //default settings if it can't find a save file containing y
FlxG.save.data.pbRControls = pbRControls;
FlxG.save.data.doubleGhost = doubleGhost;
FlxG.save.data.bfIconStyle = bfIconStyle;
FlxG.save.data.hitboxSelection = hitboxSelection;
FlxG.save.data.hitboxAlpha = hitboxAlpha;
FlxG.save.data.virtualPadAlpha = virtualPadAlpha;
FlxG.save.data.hitboxSpace = hitboxSpace;
FlxG.save.data.hitboxSpaceLocation = hitboxSpaceLocation;
FlxG.save.data.noteStyleThing = noteStyleThing;
FlxG.save.data.dynamicColors = dynamicColors;
FlxG.save.data.antiCheatEnable = antiCheatEnable;
FlxG.save.data.randomBotplayText = randomBotplayText;
FlxG.save.data.showNPS = showNPS;
Expand Down Expand Up @@ -422,6 +434,18 @@ class ClientPrefs { //default settings if it can't find a save file containing y
if(FlxG.save.data.colorQuants != null) {
colorQuants = FlxG.save.data.colorQuants;
}
if (FlxG.save.data.hitboxSelection != null) {
hitboxSelection = FlxG.save.data.hitboxSelection;
}
if (FlxG.save.data.hitboxAlpha != null) {
hitboxAlpha = FlxG.save.data.hitboxAlpha;
}
if (FlxG.save.data.virtualPadAlpha != null) {
virtualPadAlpha = FlxG.save.data.virtualPadAlpha;
}
if (FlxG.save.data.dynamicColors != null) {
dynamicColors = FlxG.save.data.dynamicColors;
}
if(FlxG.save.data.pbRControls != null) {
pbRControls = FlxG.save.data.pbRControls;
}
Expand Down
10 changes: 9 additions & 1 deletion source/Controls.hx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package;
#if android
import android.flixel.FlxButton;
import android.flixel.FlxHitbox;
import android.flixel.FlxNewHitbox;
import android.flixel.FlxVirtualPad;
#end
import flixel.FlxG;
Expand Down Expand Up @@ -400,11 +401,18 @@ class Controls extends FlxActionSet
action.add(input);
}

public function setHitBox(Hitbox:FlxHitbox) {
public function setHitBox(Hitbox:FlxHitbox, NewHitbox:FlxNewHitbox) {
if (Hitbox != null) {
inline forEachBound(Control.NOTE_UP, (action, state) -> addbuttonNOTES(action, Hitbox.buttonUp, state));
inline forEachBound(Control.NOTE_DOWN, (action, state) -> addbuttonNOTES(action, Hitbox.buttonDown, state));
inline forEachBound(Control.NOTE_LEFT, (action, state) -> addbuttonNOTES(action, Hitbox.buttonLeft, state));
inline forEachBound(Control.NOTE_RIGHT, (action, state) -> addbuttonNOTES(action, Hitbox.buttonRight, state));
} else if (NewHitbox != null) {
inline forEachBound(Control.NOTE_UP, (action, state) -> addbuttonNOTES(action, NewHitbox.buttonUp, state));
inline forEachBound(Control.NOTE_DOWN, (action, state) -> addbuttonNOTES(action, NewHitbox.buttonDown, state));
inline forEachBound(Control.NOTE_LEFT, (action, state) -> addbuttonNOTES(action, NewHitbox.buttonLeft, state));
inline forEachBound(Control.NOTE_RIGHT, (action, state) -> addbuttonNOTES(action, NewHitbox.buttonRight, state));
}
}

public function setVirtualPadUI(VirtualPad:FlxVirtualPad, DPad:FlxDPadMode, Action:FlxActionMode) {
Expand Down
3 changes: 2 additions & 1 deletion source/MusicBeatState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@ class MusicBeatState extends FlxUIState
case 3: // BOTH_FULL
controls.setVirtualPadNOTES(androidControls.virtualPad, BOTH_FULL, NONE);
case 4: // HITBOX
controls.setHitBox(androidControls.hitbox);
if (ClientPrefs.hitboxSelection != 'New') controls.setHitBox(androidControls.hitbox, null);
if (ClientPrefs.hitboxSelection == 'New') controls.setHitBox(null, androidControls.newHitbox);
case 5: // KEYBOARD
}

Expand Down
6 changes: 5 additions & 1 deletion source/PauseSubState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class PauseSubState extends MusicBeatSubstate
var grpMenuShit:FlxTypedGroup<Alphabet>;

var menuItems:Array<String> = [];
var menuItemsOG:Array<String> = ['Resume', 'Restart Song', 'Change Gameplay Settings', 'Change Difficulty', 'Options', 'Exit'];
var menuItemsOG:Array<String> = ['Resume', 'Restart Song', 'Change Gameplay Settings', 'Change Difficulty', #if android 'Chart Editor', #end 'Options', 'Exit'];
var menuItemsExit:Array<String> = [(PlayState.isStoryMode ? 'Exit to Story Menu' : 'Exit to Freeplay'), 'Exit to Main Menu', 'Exit Game', 'Back'];
var difficultyChoices = [];
var curSelected:Int = 0;
Expand Down Expand Up @@ -291,6 +291,10 @@ class PauseSubState extends MusicBeatSubstate
case "End Song":
close();
PlayState.instance.finishSong(true);
case 'Chart Editor':
MusicBeatState.switchState(new editors.ChartingState());
MusicBeatState.windowNameSuffix = " - Chart Editor";
PlayState.chartingMode = true;
case "Change Gameplay Settings":
persistentUpdate = false;
openSubState(new GameplayChangersSubstate());
Expand Down
271 changes: 126 additions & 145 deletions source/android/AndroidControls.hx
Original file line number Diff line number Diff line change
@@ -1,145 +1,126 @@
package android;

import android.flixel.FlxHitbox;
import android.flixel.FlxVirtualPad;
import flixel.FlxG;
import flixel.group.FlxSpriteGroup;
import flixel.math.FlxPoint;
import flixel.util.FlxDestroyUtil;

class AndroidControls extends FlxSpriteGroup
{
public var virtualPad:FlxVirtualPad;
public var hitbox:FlxHitbox;

public function new()
{
super();

switch (AndroidControls.getMode())
{
case 0: // RIGHT_FULL
initControler(0);
case 1: // LEFT_FULL
initControler(1);
case 2: // CUSTOM
initControler(2);
case 3: // BOTH_FULL
initControler(3);
case 4: // HITBOX
initControler(4);
case 5: // KEYBOARD
}
}

private function initControler(virtualPadMode:Int = 0):Void
{
switch (virtualPadMode)
{
case 0:
virtualPad = new FlxVirtualPad(RIGHT_FULL, NONE);
add(virtualPad);
case 1:
virtualPad = new FlxVirtualPad(LEFT_FULL, NONE);
add(virtualPad);
case 2:
virtualPad = AndroidControls.getCustomMode(new FlxVirtualPad(RIGHT_FULL, NONE));
add(virtualPad);
case 3:
virtualPad = new FlxVirtualPad(BOTH_FULL, NONE);
add(virtualPad);
case 4:
hitbox = new FlxHitbox();
add(hitbox);
}
}

override public function destroy():Void
{
super.destroy();

if (virtualPad != null)
{
virtualPad = FlxDestroyUtil.destroy(virtualPad);
virtualPad = null;
}

if (hitbox != null)
{
hitbox = FlxDestroyUtil.destroy(hitbox);
hitbox = null;
}
}

public static function setOpacity(opacity:Float = 0.6):Void
{
FlxG.save.data.androidControlsOpacity = opacity;
FlxG.save.flush();
}

public static function getOpacity():Float
{
if (FlxG.save.data.androidControlsOpacity == null)
{
FlxG.save.data.androidControlsOpacity = 0.6;
FlxG.save.flush();
}

return FlxG.save.data.androidControlsOpacity;
}

public static function setMode(mode:Int = 0):Void
{
FlxG.save.data.androidControlsMode = mode;
FlxG.save.flush();
}

public static function getMode():Int
{
if (FlxG.save.data.androidControlsMode == null)
{
FlxG.save.data.androidControlsMode = 0;
FlxG.save.flush();
}

return FlxG.save.data.androidControlsMode;
}

public static function setCustomMode(virtualPad:FlxVirtualPad):Void
{
if (FlxG.save.data.buttons == null)
{
FlxG.save.data.buttons = new Array();
for (buttons in virtualPad)
FlxG.save.data.buttons.push(FlxPoint.get(buttons.x, buttons.y));
}
else
{
var tempCount:Int = 0;
for (buttons in virtualPad)
{
FlxG.save.data.buttons[tempCount] = FlxPoint.get(buttons.x, buttons.y);
tempCount++;
}
}

FlxG.save.flush();
}

public static function getCustomMode(virtualPad:FlxVirtualPad):FlxVirtualPad
{
var tempCount:Int = 0;

if (FlxG.save.data.buttons == null)
return virtualPad;

for (buttons in virtualPad)
{
buttons.x = FlxG.save.data.buttons[tempCount].x;
buttons.y = FlxG.save.data.buttons[tempCount].y;
tempCount++;
}

return virtualPad;
}
}
package android;

import android.flixel.FlxNewHitbox;
import android.flixel.FlxHitbox;
import android.flixel.FlxVirtualPad;
import flixel.util.FlxDestroyUtil;
import flixel.FlxG;
import flixel.math.FlxPoint;




class AndroidControls extends FlxSpriteGroup {
public var virtualPad:FlxVirtualPad;
public var hitbox:FlxHitbox;
public var newHitbox:FlxNewHitbox;

public function new() {
super();

switch (AndroidControls.getMode()) {
case 0: // RIGHT_FULL
initControler(0);
case 1: // LEFT_FULL
initControler(1);
case 2: // CUSTOM
initControler(2);
case 3: // BOTH_FULL
initControler(3);
case 4: // HITBOX
if (ClientPrefs.hitboxSelection != 'New') {
initControler(5);
} else {
initControler(4);
}
case 5: // KEYBOARD
}
}

private function initControler(virtualPadMode:Int = 0):Void {
switch (virtualPadMode) {
case 0:
virtualPad = new FlxVirtualPad(RIGHT_FULL, NONE);
add(virtualPad);
case 1:
virtualPad = new FlxVirtualPad(LEFT_FULL, NONE);
add(virtualPad);
case 2:
virtualPad = AndroidControls.getCustomMode(new FlxVirtualPad(RIGHT_FULL, NONE));
add(virtualPad);
case 3:
virtualPad = new FlxVirtualPad(BOTH_FULL, NONE);
add(virtualPad);
case 4:
newHitbox = new FlxNewHitbox();
add(newHitbox);
case 5:
hitbox = new FlxHitbox();
add(hitbox);
}
}

override public function destroy():Void {
super.destroy();

if (virtualPad != null) {
virtualPad = FlxDestroyUtil.destroy(virtualPad);
virtualPad = null;
}

if (newHitbox != null) {
newHitbox = FlxDestroyUtil.destroy(newHitbox);
newHitbox = null;
}

if (hitbox != null) {
hitbox = FlxDestroyUtil.destroy(hitbox);
hitbox = null;
}
}

public static function setMode(mode:Int = 0):Void {
FlxG.save.data.androidControlsMode = mode;
FlxG.save.flush();
}

public static function getMode():Int {
if (FlxG.save.data.androidControlsMode == null) {
FlxG.save.data.androidControlsMode = 0;
FlxG.save.flush();
}

return FlxG.save.data.androidControlsMode;
}

public static function setCustomMode(virtualPad:FlxVirtualPad):Void {
if (FlxG.save.data.buttons == null) {
FlxG.save.data.buttons = new Array();
for (buttons in virtualPad)
FlxG.save.data.buttons.push(FlxPoint.get(buttons.x, buttons.y));
} else {
var tempCount:Int = 0;
for (buttons in virtualPad) {
FlxG.save.data.buttons[tempCount] = FlxPoint.get(buttons.x, buttons.y);
tempCount++;
}
}

FlxG.save.flush();
}

public static function getCustomMode(virtualPad:FlxVirtualPad):FlxVirtualPad {
var tempCount:Int = 0;

if (FlxG.save.data.buttons == null)
return virtualPad;

for (buttons in virtualPad) {
buttons.x = FlxG.save.data.buttons[tempCount].x;
buttons.y = FlxG.save.data.buttons[tempCount].y;
tempCount++;
}

return virtualPad;
}
}
Loading

0 comments on commit afcf168

Please sign in to comment.