Skip to content

Commit

Permalink
am don
Browse files Browse the repository at this point in the history
  • Loading branch information
mcagabe19 committed Dec 17, 2024
1 parent 0a5b2d8 commit d906260
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 30 deletions.
77 changes: 47 additions & 30 deletions source/editors/CharacterEditorState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -221,28 +221,43 @@ class CharacterEditorState extends MusicBeatState
FlxG.mouse.visible = true;
reloadCharacterOptions();

addVirtualPad(LEFT_FULL, A_B_C_D_V_X_Y_Z);
addVirtualPad(LEFT_FULL, CHARACTER_EDITOR);
addVirtualPadCamera();

super.create();
}

function addHelpScreen()
{
var str:Array<String> = ["CAMERA",
"E/Q - Camera Zoom In/Out",
"J/K/L/I - Move Camera",
"R - Reset Camera Zoom",
"",
"CHARACTER",
"T - Reset Current Offset",
"W/S - Previous/Next Animation",
"Space - Replay Animation",
"Arrow Keys/Mouse & Right Click - Move Offset",
"A/D - Frame Advance (Back/Forward)",
"",
"OTHER",
"Hold Shift - Move Offsets 10x faster and Camera 4x faster"];
var str:Array<String>;
if (mobile.MobileControls.enabled) {
str = ["CAMERA",
"X/Y - Camera Zoom In/Out",
"Z - Reset Camera Zoom",
"",
"CHARACTER",
"A - Reset Current Offset",
"V/D - Previous/Next Animation",
"Arrow Buttons - Move Offset",
"",
"OTHER",
"Hold C - Move Offsets 10x faster and Camera 4x faster"];
} else {
str = ["CAMERA",
"E/Q - Camera Zoom In/Out",
"J/K/L/I - Move Camera",
"R - Reset Camera Zoom",
"",
"CHARACTER",
"T - Reset Current Offset",
"W/S - Previous/Next Animation",
"Space - Replay Animation",
"Arrow Keys/Mouse & Right Click - Move Offset",
"A/D - Frame Advance (Back/Forward)",
"",
"OTHER",
"Hold Shift - Move Offsets 10x faster and Camera 4x faster"];
}

helpBg = new FlxSprite().makeGraphic(1, 1, FlxColor.BLACK);
helpBg.scale.set(FlxG.width, FlxG.height);
Expand Down Expand Up @@ -1437,24 +1452,24 @@ class CharacterEditorState extends MusicBeatState
return;
}

if (virtualPad.buttonZ.justPressed || FlxG.keys.justPressed.R) {
if (FlxG.keys.justPressed.R || virtualPad.buttonZ.justPressed) {
FlxG.camera.zoom = 1;
}

var shiftMult:Float = 1;
var ctrlMult:Float = 1;
var shiftMultBig:Float = 1;
if(FlxG.keys.pressed.SHIFT)
if(FlxG.keys.pressed.SHIFT || virtualPad.buttonC.pressed)
{
shiftMult = 4;
shiftMultBig = 10;
}

if (virtualPad.buttonX.pressed || FlxG.keys.pressed.E && FlxG.camera.zoom < 3) {
if (FlxG.keys.pressed.E || virtualPad.buttonX.pressed && FlxG.camera.zoom < 3) {
FlxG.camera.zoom += elapsed * FlxG.camera.zoom * shiftMult;
if(FlxG.camera.zoom > 3) FlxG.camera.zoom = 3;
}
if (virtualPad.buttonY.pressed || FlxG.keys.pressed.Q && FlxG.camera.zoom > 0.1) {
if (FlxG.keys.pressed.Q || virtualPad.buttonY.pressed && FlxG.camera.zoom > 0.1) {
FlxG.camera.zoom -= elapsed * FlxG.camera.zoom * shiftMult;
if(FlxG.camera.zoom < 0.1) FlxG.camera.zoom = 0.1;
}
Expand Down Expand Up @@ -1485,34 +1500,33 @@ class CharacterEditorState extends MusicBeatState
}
else holdingFrameTime = 0;

if(FlxG.keys.justPressed.W) curAnim--;
else if(FlxG.keys.justPressed.S) curAnim++;

if(FlxG.keys.justPressed.W || virtualPad.buttonV.justPressed) curAnim--;
else if(FlxG.keys.justPressed.S || virtualPad.buttonD.justPressed) curAnim++;

if (curAnim < 0)
curAnim = char.animationsArray.length - 1;

if (curAnim >= char.animationsArray.length)
curAnim = 0;

if ((virtualPad.buttonD.justPressed || FlxG.keys.justPressed.S) || (virtualPad.buttonV.justPressed || FlxG.keys.justPressed.W) || FlxG.keys.justPressed.SPACE)
if ((FlxG.keys.justPressed.S || virtualPad.buttonD.justPressed) || (FlxG.keys.justPressed.W || virtualPad.buttonV.justPressed) || FlxG.keys.justPressed.SPACE)
{
char.playAnim(animList[curAnim].anim, true);
updateText();
}
if (virtualPad.buttonA.justPressed || FlxG.keys.justPressed.T)
if (FlxG.keys.justPressed.T)
{
char.animationsArray[curAnim].offsets = [0, 0];

char.addOffset(char.animationsArray[curAnim].anim, char.animationsArray[curAnim].offsets[0], char.animationsArray[curAnim].offsets[1]);
updateText();
}

var controlArray:Array<Bool> = [virtualPad.buttonLeft.justPressed || FlxG.keys.justPressed.LEFT, virtualPad.buttonRight.justPressed || FlxG.keys.justPressed.RIGHT, virtualPad.buttonUp.justPressed || FlxG.keys.justPressed.UP, virtualPad.buttonDown.justPressed || FlxG.keys.justPressed.DOWN];
var controlArray:Array<Bool> = (mobile.MobileControls.enabled) ? [virtualPad.buttonLeft.justPressed, virtualPad.buttonRight.justPressed, virtualPad.buttonUp.justPressed, virtualPad.buttonDown.justPressed] : [FlxG.keys.justPressed.LEFT, FlxG.keys.justPressed.RIGHT, FlxG.keys.justPressed.UP, FlxG.keys.justPressed.DOWN];

for (i in 0...controlArray.length) {
if(controlArray[i]) {
var holdShift = virtualPad.buttonC.pressed || FlxG.keys.pressed.SHIFT;
var holdShift = FlxG.keys.pressed.SHIFT;
var multiplier = 1;
if (holdShift)
multiplier = 10;
Expand Down Expand Up @@ -1569,8 +1583,14 @@ class CharacterEditorState extends MusicBeatState
frameAdvanceText.color = clr;

// OTHER CONTROLS
if(FlxG.keys.justPressed.F1 || (helpBg.visible && FlxG.keys.justPressed.ESCAPE))
if((FlxG.keys.justPressed.F1 || virtualPad.buttonF.justPressed) || (helpBg.visible && FlxG.keys.justPressed.ESCAPE))
{
if (mobile.MobileControls.enabled){
virtualPad.forEachAlive(function(button:mobile.flixel.FlxButton){
if(button != virtualPad.buttonF)
button.visible = !button.visible;
});
}
helpBg.visible = !helpBg.visible;
helpTexts.visible = helpBg.visible;
}
Expand Down Expand Up @@ -1664,9 +1684,6 @@ class CharacterEditorState extends MusicBeatState

if (data.length > 0)
{
#if mobile
SUtil.saveContent('$_char.json', data);
#else
_file = new FileReference();
_file.addEventListener(Event.COMPLETE, onSaveComplete);
_file.addEventListener(Event.CANCEL, onSaveCancel);
Expand Down
11 changes: 11 additions & 0 deletions source/mobile/flixel/FlxVirtualPad.hx
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ enum FlxActionMode
A_B_C_D_V_X_Y_Z;
CHART_EDITOR;
DIALOGUE_PORTRAIT_EDITOR;
CHARACTER_EDITOR;
MENU_CHARACTER_EDITOR;
NOTE_SPLASH_DEBUG;
NONE;
Expand Down Expand Up @@ -189,6 +190,16 @@ class FlxVirtualPad extends FlxTypedSpriteGroup<FlxButton>
add(buttonB = createButton(FlxG.width - 262, FlxG.height - 131, 'b', 0xFFCB00));
add(buttonZ = createButton(FlxG.width - 132, FlxG.height - 251, 'z', 0xCCB98E));
add(buttonA = createButton(FlxG.width - 132, FlxG.height - 131, 'a', 0xFF0000));
case CHARACTER_EDITOR:
add(buttonF = createButton(FlxG.width - 132, FlxG.height - 371, 'f', 0xB1FC00));
add(buttonV = createButton(FlxG.width - 522, FlxG.height - 251, 'v', 0x49A9B2));
add(buttonD = createButton(FlxG.width - 522, FlxG.height - 131, 'd', 0x0078FF));
add(buttonX = createButton(FlxG.width - 392, FlxG.height - 251, 'x', 0x99062D));
add(buttonC = createButton(FlxG.width - 392, FlxG.height - 131, 'c', 0x44FF00));
add(buttonY = createButton(FlxG.width - 262, FlxG.height - 251, 'y', 0x4A35B9));
add(buttonB = createButton(FlxG.width - 262, FlxG.height - 131, 'b', 0xFFCB00));
add(buttonZ = createButton(FlxG.width - 132, FlxG.height - 251, 'z', 0xCCB98E));
add(buttonA = createButton(FlxG.width - 132, FlxG.height - 131, 'a', 0xFF0000));
case CHART_EDITOR:
add(buttonUp2 = createButton(FlxG.width - 652, FlxG.height - 251, 'up', 0x00FF00));
add(buttonDown2 = createButton(FlxG.width - 652, FlxG.height - 131, 'down', 0x00FFFF));
Expand Down

0 comments on commit d906260

Please sign in to comment.