Skip to content

Commit

Permalink
add pointers for midpoint, base, and pivot
Browse files Browse the repository at this point in the history
  • Loading branch information
KoloInDaCrib committed Nov 24, 2024
1 parent 967fef6 commit c5c94ce
Show file tree
Hide file tree
Showing 3 changed files with 91 additions and 1 deletion.
20 changes: 20 additions & 0 deletions source/funkin/ui/debug/char/pages/CharCreatorFreeplayPage.hx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import funkin.ui.debug.char.animate.CharSelectAtlasSprite;
import funkin.ui.freeplay.BGScrollingText;
import funkin.ui.AtlasText;
import funkin.graphics.adobeanimate.FlxAtlasSprite;
import flixel.addons.display.shapes.FlxShapeCircle;
import flixel.group.FlxSpriteGroup;
import flixel.math.FlxPoint;
import flixel.util.FlxColor;
Expand Down Expand Up @@ -79,6 +80,9 @@ class CharCreatorFreeplayPage extends CharCreatorDefaultPage
var djAnims:Array<AnimationData> = [];
var currentDJAnimation:Int = 0;

var pivotPointer:FlxShapeCircle;
var basePointer:FlxShapeCircle;

override public function new(state:CharCreatorState, data:WizardGenerateParams)
{
super(state);
Expand Down Expand Up @@ -116,12 +120,28 @@ class CharCreatorFreeplayPage extends CharCreatorDefaultPage
}

initBackground();

pivotPointer = new FlxShapeCircle(0, 0, 16, cast {thickness: 2, color: 0xffff00ff}, 0xffff00ff);
basePointer = new FlxShapeCircle(0, 0, 16, cast {thickness: 2, color: 0xff00ffff}, 0xff00ffff);
pivotPointer.visible = basePointer.visible = false;

add(pivotPointer);
add(basePointer);
}

override public function update(elapsed:Float)
{
super.update(elapsed);

var pivotPos = dj.getPivotPosition();
var basePos = dj.getBasePosition();

if (pivotPos != null) pivotPointer.setPosition(pivotPos.x - pivotPointer.width / 2, pivotPos.y - pivotPointer.height / 2);
if (basePos != null) basePointer.setPosition(basePos.x - basePointer.width / 2, basePos.y - basePointer.height / 2);

pivotPointer.visible = (daState.menubarCheckViewPivot.selected && pivotPos != null);
basePointer.visible = (daState.menubarCheckViewBase.selected && basePos != null);

// no need for handleKeybinds function since these are the only functions in update methinks
if (FlxG.keys.justPressed.SPACE) playDJAnimation();

Expand Down
36 changes: 36 additions & 0 deletions source/funkin/ui/debug/char/pages/CharCreatorGameplayPage.hx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import funkin.data.stage.StageRegistry;
import funkin.ui.debug.char.components.dialogs.gameplay.*;
import funkin.ui.debug.char.components.dialogs.DefaultPageDialog;
import flixel.util.FlxColor;
import flixel.addons.display.shapes.FlxShapeCircle;

using StringTools;

Expand All @@ -38,6 +39,11 @@ class CharCreatorGameplayPage extends CharCreatorDefaultPage
public var ghostCharacter:CharCreatorCharacter;
public var ghostId(default, set):String = ""; // empty string means current character

// points
var atlasCharPivotPointer:FlxShapeCircle;
var atlasCharBasePointer:FlxShapeCircle;
var midPointPointer:FlxShapeCircle;

override public function new(daState:CharCreatorState, wizardParams:WizardGenerateParams)
{
super(daState);
Expand Down Expand Up @@ -71,6 +77,19 @@ class CharCreatorGameplayPage extends CharCreatorDefaultPage
animDialog.charAnimDropdown.selectedIndex = 0;
currentCharacter.playAnimation(currentCharacter.animations[0].name);
}

atlasCharPivotPointer = new FlxShapeCircle(0, 0, 16, cast {thickness: 2, color: 0xffff00ff}, 0xffff00ff);
atlasCharBasePointer = new FlxShapeCircle(0, 0, 16, cast {thickness: 2, color: 0xff00ffff}, 0xff00ffff);
midPointPointer = new FlxShapeCircle(0, 0, 16, cast {thickness: 2, color: 0xffffff00}, 0xffffff00);

atlasCharPivotPointer.zIndex = atlasCharBasePointer.zIndex = midPointPointer.zIndex = 10000;
atlasCharPivotPointer.visible = atlasCharBasePointer.visible = midPointPointer.visible = false;

add(atlasCharPivotPointer);
add(atlasCharBasePointer);
add(midPointPointer);

sortAssets();
}

override public function update(elapsed:Float)
Expand All @@ -79,6 +98,23 @@ class CharCreatorGameplayPage extends CharCreatorDefaultPage
labelAnimOffsetX.text = "" + (currentCharacter.getAnimationData(currentCharacter.getCurrentAnimation())?.offsets[0] ?? 0);
labelAnimOffsetY.text = "" + (currentCharacter.getAnimationData(currentCharacter.getCurrentAnimation())?.offsets[1] ?? 0);

if (currentCharacter.atlasCharacter != null)
{
var pivotPos = currentCharacter.atlasCharacter.getPivotPosition();
var basePos = currentCharacter.atlasCharacter.getBasePosition();

if (pivotPos != null) atlasCharPivotPointer.setPosition(pivotPos.x - atlasCharPivotPointer.width / 2, pivotPos.y - atlasCharPivotPointer.height / 2);
if (basePos != null) atlasCharBasePointer.setPosition(basePos.x - atlasCharBasePointer.width / 2, basePos.y - atlasCharBasePointer.height / 2);

atlasCharPivotPointer.visible = (daState.menubarCheckViewPivot.selected && pivotPos != null);
atlasCharBasePointer.visible = (daState.menubarCheckViewBase.selected && basePos != null);
}
else
{
midPointPointer.setPosition(currentCharacter.getMidpoint().x - midPointPointer.width / 2, currentCharacter.getMidpoint().y - midPointPointer.height / 2);
midPointPointer.visible = daState.menubarCheckViewMidpoint.selected;
}

super.update(elapsed);
}

Expand Down
36 changes: 35 additions & 1 deletion source/funkin/ui/debug/char/pages/CharCreatorSelectPage.hx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import funkin.ui.debug.char.pages.subpages.CharSelectIndexSubPage;
import funkin.ui.debug.char.components.dialogs.select.*;
import funkin.ui.debug.char.components.dialogs.DefaultPageDialog;
import funkin.util.FileUtil;
import flixel.addons.display.shapes.FlxShapeCircle;
import flixel.group.FlxSpriteGroup.FlxTypedSpriteGroup;
import flixel.group.FlxSpriteGroup;
import flixel.tweens.FlxEase;
Expand Down Expand Up @@ -67,11 +68,15 @@ class CharCreatorSelectPage extends CharCreatorDefaultPage
var pixelIconFiles:Array<WizardFile> = [];

var dialogMap:Map<PlayCharDialogType, DefaultPageDialog>;

var subPages:Map<CharCreatorSelectSubPage, FlxSpriteGroup>;

var handleInput:Bool = true;

var playerPivotPointer:FlxShapeCircle;
var playerBasePointer:FlxShapeCircle;
var gfPivotPointer:FlxShapeCircle;
var gfBasePointer:FlxShapeCircle;

override public function new(state:CharCreatorState, data:WizardGenerateParams)
{
super(state);
Expand Down Expand Up @@ -127,6 +132,17 @@ class CharCreatorSelectPage extends CharCreatorDefaultPage
subPages.set(IndexSubPage, new CharSelectIndexSubPage(this));

add(subPages[IndexSubPage]);

playerPivotPointer = new FlxShapeCircle(0, 0, 16, cast {thickness: 2, color: 0xffff00ff}, 0xffff00ff);
playerBasePointer = new FlxShapeCircle(0, 0, 16, cast {thickness: 2, color: 0xff00ffff}, 0xff00ffff);
gfPivotPointer = new FlxShapeCircle(0, 0, 16, cast {thickness: 2, color: 0xffff00ff}, 0xffff00ff);
gfBasePointer = new FlxShapeCircle(0, 0, 16, cast {thickness: 2, color: 0xff00ffff}, 0xff00ffff);
playerPivotPointer.visible = playerBasePointer.visible = gfPivotPointer.visible = gfBasePointer.visible = false;

add(playerPivotPointer);
add(playerBasePointer);
add(gfPivotPointer);
add(gfPivotPointer);
}

// i am unsure whether or not there are more animations than these
Expand Down Expand Up @@ -393,6 +409,24 @@ class CharCreatorSelectPage extends CharCreatorDefaultPage
if (FlxG.keys.justPressed.W) changeCharAnim(-1, FlxG.keys.pressed.SHIFT);
if (FlxG.keys.justPressed.S) changeCharAnim(1, FlxG.keys.pressed.SHIFT);
}

var playerPivotPos = bf.getPivotPosition();
var playerBasePos = bf.getBasePosition();

if (playerPivotPos != null) playerPivotPointer.setPosition(playerPivotPos.x - playerPivotPointer.width / 2,
playerPivotPos.y - playerPivotPointer.height / 2);
if (playerBasePos != null) playerBasePointer.setPosition(playerBasePos.x - playerBasePointer.width / 2, playerBasePos.y - playerBasePointer.height / 2);

var gfPlayerPos = gf.getPivotPosition();
var gfBasePos = gf.getBasePosition();

if (gfPlayerPos != null) gfPivotPointer.setPosition(gfPlayerPos.x - gfPivotPointer.width / 2, gfPlayerPos.y - gfPivotPointer.height / 2);
if (gfBasePos != null) gfBasePointer.setPosition(gfBasePos.x - gfBasePointer.width / 2, gfBasePos.y - gfBasePointer.height / 2);

playerPivotPointer.visible = (daState.menubarCheckViewPivot.selected && playerPivotPos != null);
playerBasePointer.visible = (daState.menubarCheckViewBase.selected && playerBasePos != null);
gfPivotPointer.visible = (daState.menubarCheckViewPivot.selected && gfPlayerPos != null);
gfBasePointer.visible = (daState.menubarCheckViewBase.selected && gfBasePos != null);
}
}

Expand Down

0 comments on commit c5c94ce

Please sign in to comment.