drop down
This commit is contained in:
+1
-1
@@ -1 +1 @@
|
||||
1769
|
||||
1785
|
||||
@@ -77,6 +77,7 @@ class DesktopMain extends MusicBeatState {
|
||||
|
||||
super.update(elapsed);
|
||||
|
||||
|
||||
if (screenSize.x != FlxG.width || screenSize.y != FlxG.height) {
|
||||
screenSize.set(FlxG.width, FlxG.height);
|
||||
updateScreenRes();
|
||||
@@ -174,7 +175,7 @@ class MouseInput {
|
||||
public function overlapsRect(spr:FlxBasic, rect:FlxRect, ?camera:FlxCamera) {
|
||||
if (__cancelled) return false;
|
||||
if (camera == null) camera = FlxG.camera;
|
||||
if (spr is FlxObject) {
|
||||
if (spr is FlxObject && camera != null) {
|
||||
var obj = cast(spr, FlxObject);
|
||||
rect.x -= camera.scroll.x * obj.scrollFactor.x;
|
||||
rect.y -= camera.scroll.y * obj.scrollFactor.y;
|
||||
|
||||
@@ -17,6 +17,13 @@ class CharacterEditor extends WindowContent {
|
||||
public var camFollow:FlxObject;
|
||||
public var tabView:TabView;
|
||||
|
||||
public var animList:Array<String> = [];
|
||||
|
||||
/**
|
||||
* ANIMATION TAB
|
||||
*/
|
||||
public var animsDropDown:DropDown;
|
||||
|
||||
public override function create() {
|
||||
super.create();
|
||||
|
||||
@@ -58,6 +65,20 @@ class CharacterEditor extends WindowContent {
|
||||
tabView = new TabView(800, 20, 400, 580, ["Animation Settings", "Character Settings"]);
|
||||
tabView.updateAnchor(1, 0, [camHUD]);
|
||||
add(tabView);
|
||||
|
||||
animsDropDown = new DropDown(10, 10, [], function(id) {
|
||||
char.playAnim(animList[id], true);
|
||||
});
|
||||
refreshAnims();
|
||||
|
||||
for(spr in [animsDropDown])
|
||||
tabView.tabs[0].add(spr);
|
||||
}
|
||||
|
||||
public function refreshAnims() {
|
||||
@:privateAccess animList = [for(k=>e in char.animation._animations) k];
|
||||
animsDropDown.options = animList;
|
||||
animsDropDown.onSelectionChange(0);
|
||||
}
|
||||
|
||||
public override function update(elapsed:Float) {
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
package funkin.desktop.sprites;
|
||||
|
||||
import funkin.desktop.theme.Theme.ThemeData;
|
||||
import flixel.math.FlxPoint;
|
||||
|
||||
class DropDown extends Button {
|
||||
public var selectedIndex:Int = -1;
|
||||
public var onChange:Int->Void;
|
||||
public var options:Array<String>;
|
||||
|
||||
public function new(x:Float, y:Float, options:Array<String>, onChange:Int->Void, curId:Int = 0, ?normalButton:ThemeData, ?hoverButton:ThemeData, ?pressedButton:ThemeData, ?disabledButton:ThemeData) {
|
||||
super(x, y, "", onClick, normalButton, hoverButton, pressedButton, disabledButton);
|
||||
this.options = options;
|
||||
onSelectionChange(curId);
|
||||
}
|
||||
|
||||
public function onClick() {
|
||||
var pos:FlxPoint = getScreenPosition();
|
||||
pos.y += height;
|
||||
|
||||
var camPos = camera != null ? FlxPoint.get(camera.x - (camera.scroll.x * scrollFactor.x), camera.y - (camera.scroll.y * scrollFactor.y)) : FlxPoint.get();
|
||||
|
||||
ContextMenu.open(pos.x + camPos.x, pos.y + camPos.y, [for(o in options) {
|
||||
{
|
||||
name: o
|
||||
}
|
||||
}], onSelectionChange);
|
||||
|
||||
camPos.put();
|
||||
}
|
||||
|
||||
public function onSelectionChange(id:Int) {
|
||||
selectedIndex = id;
|
||||
label.text = options[id];
|
||||
if (onChange != null)
|
||||
onChange(id);
|
||||
}
|
||||
}
|
||||
@@ -27,7 +27,7 @@ class TabView extends WindowGroup<FlxBasic> {
|
||||
add(bg);
|
||||
for(k=>t in tabs) {
|
||||
// BUTTON
|
||||
var b = new Button(0, y, t, function() {
|
||||
var b = new Button(0, 0, t, function() {
|
||||
switchTab(k);
|
||||
}, DesktopMain.theme.tabButtonUnselected, DesktopMain.theme.tabButtonHover, DesktopMain.theme.tabButtonPressed, DesktopMain.theme.tabButtonSelected);
|
||||
|
||||
@@ -36,7 +36,7 @@ class TabView extends WindowGroup<FlxBasic> {
|
||||
|
||||
// TAB
|
||||
var tab = new WindowGroup<FlxBasic>();
|
||||
tab.y = 20;
|
||||
tab.y += b.height;
|
||||
this.tabs.push(tab);
|
||||
add(tab);
|
||||
}
|
||||
|
||||
@@ -19,8 +19,6 @@ class ContextMenu extends WindowGroup<FlxObject> {
|
||||
super();
|
||||
this.callback = callback;
|
||||
this.contextOptions = options;
|
||||
|
||||
DesktopMain.contextMenu = FlxDestroyUtil.destroy(DesktopMain.contextMenu);
|
||||
|
||||
var bgTheme = DesktopMain.theme.contextBackground;
|
||||
var optionTheme = DesktopMain.theme.contextOption;
|
||||
@@ -58,16 +56,18 @@ class ContextMenu extends WindowGroup<FlxObject> {
|
||||
contextCamera.pixelPerfectRender = true;
|
||||
contextCamera.bgColor = 0;
|
||||
FlxG.cameras.add(contextCamera, false);
|
||||
}
|
||||
|
||||
DesktopMain.contextMenu = this;
|
||||
public static function open(x:Float, y:Float, options:Array<ContextOption>, callback:Int->Void) {
|
||||
DesktopMain.contextMenu = new ContextMenu(x, y, options, callback);
|
||||
}
|
||||
|
||||
public override function update(elapsed:Float) {
|
||||
super.update(elapsed);
|
||||
if (DesktopMain.mouseInput.overlaps(bg, camera)) {
|
||||
if (DesktopMain.mouseInput.overlaps(bg, contextCamera)) {
|
||||
for(i=>o in selectionBGs) {
|
||||
var wasVisible = o.visible;
|
||||
if (o.visible = DesktopMain.mouseInput.overlaps(o, camera)) {
|
||||
if (o.visible = DesktopMain.mouseInput.overlaps(o, contextCamera)) {
|
||||
if (DesktopMain.mouseInput.justReleased) {
|
||||
// select option
|
||||
if (contextOptions[i].callback != null)
|
||||
@@ -75,6 +75,7 @@ class ContextMenu extends WindowGroup<FlxObject> {
|
||||
if (callback != null)
|
||||
callback(i);
|
||||
destroy();
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (o.visible != wasVisible) {
|
||||
@@ -85,14 +86,15 @@ class ContextMenu extends WindowGroup<FlxObject> {
|
||||
} else {
|
||||
if (DesktopMain.mouseInput.justPressed) {
|
||||
destroy();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override function destroy() {
|
||||
super.destroy();
|
||||
DesktopMain.contextMenu = null;
|
||||
FlxG.cameras.remove(contextCamera, true);
|
||||
DesktopMain.contextMenu = null;
|
||||
super.destroy();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -56,7 +56,7 @@ class WindowDragHitbox extends FlxObject {
|
||||
dragging = true;
|
||||
} else if (DesktopMain.mouseInput.justPressedRight) {
|
||||
var input = DesktopMain.mouseInput;
|
||||
new ContextMenu(input.screenPos.x, input.screenPos.y, [
|
||||
ContextMenu.open(input.screenPos.x, input.screenPos.y, [
|
||||
{
|
||||
name: "Close",
|
||||
callback: function() {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package funkin.game;
|
||||
|
||||
import flixel.graphics.frames.FlxFrame;
|
||||
import flixel.math.FlxPoint;
|
||||
import funkin.interfaces.IBeatReceiver;
|
||||
import funkin.interfaces.IOffsetCompatible;
|
||||
@@ -18,6 +19,8 @@ import haxe.Exception;
|
||||
import haxe.io.Path;
|
||||
import funkin.system.Conductor;
|
||||
|
||||
import flash.geom.ColorTransform;
|
||||
|
||||
import funkin.scripting.DummyScript;
|
||||
import funkin.scripting.Script;
|
||||
import funkin.scripting.events.*;
|
||||
@@ -55,6 +58,9 @@ class Character extends FlxSprite implements IBeatReceiver implements IOffsetCom
|
||||
public var script:Script;
|
||||
public var xml:Access;
|
||||
|
||||
public var shadowFrame:CharacterShadowFrame;
|
||||
|
||||
|
||||
public inline function getCameraPosition() {
|
||||
var midpoint = getMidpoint();
|
||||
var event = new PointEvent(
|
||||
@@ -269,7 +275,41 @@ class Character extends FlxSprite implements IBeatReceiver implements IOffsetCom
|
||||
return super.getScreenBounds(newRect, camera);
|
||||
}
|
||||
|
||||
var __drawingShadowFrame = false;
|
||||
var __oldColorTransform = new ColorTransform();
|
||||
public override function draw() {
|
||||
if (!__drawingShadowFrame && shadowFrame != null) {
|
||||
__drawingShadowFrame = true;
|
||||
|
||||
var oldFrame = _frame;
|
||||
var oldPos = FlxPoint.get(rotOffset.x, rotOffset.y);
|
||||
|
||||
__oldColorTransform.copyColorTransform(colorTransform);
|
||||
|
||||
colorTransform.alphaMultiplier = 1;
|
||||
colorTransform.alphaOffset = 0;
|
||||
colorTransform.blueMultiplier = 0;
|
||||
colorTransform.blueOffset = 25;
|
||||
colorTransform.greenMultiplier = 0;
|
||||
colorTransform.greenOffset = 25;
|
||||
colorTransform.redMultiplier = 0;
|
||||
colorTransform.redOffset = 25;
|
||||
|
||||
_frame = shadowFrame.frame;
|
||||
var o = getAnimOffset(shadowFrame.anim);
|
||||
rotOffset.set(o.x, o.y);
|
||||
super.draw();
|
||||
|
||||
_frame = oldFrame;
|
||||
rotOffset.set(oldPos.x, oldPos.y);
|
||||
|
||||
colorTransform.copyColorTransform(__oldColorTransform);
|
||||
|
||||
oldPos.put();
|
||||
|
||||
__drawingShadowFrame = false;
|
||||
}
|
||||
|
||||
if ((isPlayer != playerOffsets) != (flipX != __baseFlipped)) {
|
||||
__reverseDrawProcedure = true;
|
||||
|
||||
@@ -284,6 +324,12 @@ class Character extends FlxSprite implements IBeatReceiver implements IOffsetCom
|
||||
super.draw();
|
||||
}
|
||||
|
||||
public function getAnimOffset(name:String) {
|
||||
if (animOffsets[name] != null)
|
||||
return animOffsets[name];
|
||||
return FlxPoint.weak(0, 0);
|
||||
}
|
||||
|
||||
public var lastAnimContext:PlayAnimContext = DANCE;
|
||||
public function playAnim(AnimName:String, Force:Bool = false, Context:PlayAnimContext = NONE, Reversed:Bool = false, Frame:Int = 0):Void
|
||||
{
|
||||
@@ -295,11 +341,8 @@ class Character extends FlxSprite implements IBeatReceiver implements IOffsetCom
|
||||
|
||||
animation.play(event.animName, event.force, event.reverse, event.startingFrame);
|
||||
|
||||
var daOffset = animOffsets.get(event.animName);
|
||||
if (daOffset != null)
|
||||
rotOffset.set(daOffset.x, daOffset.y);
|
||||
else
|
||||
rotOffset.set(0, 0);
|
||||
var daOffset = getAnimOffset(event.animName);
|
||||
rotOffset.set(daOffset.x, daOffset.y);
|
||||
|
||||
offset.set(globalOffset.x * (isPlayer != playerOffsets ? 1 : -1), -globalOffset.y);
|
||||
|
||||
@@ -321,4 +364,9 @@ class Character extends FlxSprite implements IBeatReceiver implements IOffsetCom
|
||||
{
|
||||
animOffsets[name] = new FlxPoint(x, y);
|
||||
}
|
||||
}
|
||||
|
||||
typedef CharacterShadowFrame = {
|
||||
var anim:String;
|
||||
var frame:FlxFrame;
|
||||
}
|
||||
@@ -21,6 +21,7 @@ import flixel.FlxCamera;
|
||||
import flixel.util.FlxAxes;
|
||||
import flixel.graphics.frames.FlxFrame;
|
||||
import flixel.graphics.frames.FlxFramesCollection;
|
||||
import flash.geom.ColorTransform;
|
||||
|
||||
using StringTools;
|
||||
|
||||
@@ -330,4 +331,15 @@ class CoolUtil
|
||||
|
||||
return spr;
|
||||
}
|
||||
|
||||
public static function copyColorTransform(color1:ColorTransform, color2:ColorTransform) {
|
||||
color1.alphaMultiplier = color2.alphaMultiplier;
|
||||
color1.alphaOffset = color2.alphaOffset;
|
||||
color1.blueMultiplier = color2.blueMultiplier;
|
||||
color1.blueOffset = color2.blueOffset;
|
||||
color1.greenMultiplier = color2.greenMultiplier;
|
||||
color1.greenOffset = color2.greenOffset;
|
||||
color1.redMultiplier = color2.redMultiplier;
|
||||
color1.redOffset = color2.redOffset;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user