diff --git a/source/funkin/editors/character/CharacterEditor.hx b/source/funkin/editors/character/CharacterEditor.hx index 1f7f837c..9bef8da7 100644 --- a/source/funkin/editors/character/CharacterEditor.hx +++ b/source/funkin/editors/character/CharacterEditor.hx @@ -10,6 +10,7 @@ import flixel.math.FlxPoint; import funkin.backend.system.framerate.Framerate; import funkin.backend.utils.XMLUtil.AnimData; import funkin.editors.ui.UIContextMenu.UIContextMenuOption; +import funkin.editors.ui.UIContextMenu.UIContextMenuOptionSpr; import funkin.game.Character; import haxe.xml.Access; import haxe.xml.Printer; @@ -112,6 +113,19 @@ class CharacterEditor extends UIState { label: "Redo", keybinds: [[CONTROL, Y], [CONTROL, SHIFT, Z]], onSelect: _edit_redo + }, + null, + { + label: "Edit information", + color: 0xFF959829, icon: 4, + onCreate: function (button:UIContextMenuOptionSpr) {button.label.offset.x = button.icon.offset.x = -2;}, + onSelect: _edit_info + }, + { + label: "Edit sprite", + color: 0xFF959829, icon: 4, + onCreate: function (button:UIContextMenuOptionSpr) {button.label.offset.x = button.icon.offset.x = -2;}, + onSelect: _edit_sprite } ] }, @@ -434,6 +448,10 @@ class CharacterEditor extends UIState { function _edit_undo(_) {} function _edit_redo(_) {} + function _edit_info(_) + characterPropertiesWindow.editCharacterInfoUI(); + function _edit_sprite(_) {} + function _offsets_left(_) _change_offset(-1, 0); function _offsets_up(_) _change_offset(0, -1); function _offsets_down(_) _change_offset(0, 1); diff --git a/source/funkin/editors/character/CharacterIconDisplay.hx b/source/funkin/editors/character/CharacterIconDisplay.hx deleted file mode 100644 index 1a4a90f0..00000000 --- a/source/funkin/editors/character/CharacterIconDisplay.hx +++ /dev/null @@ -1,53 +0,0 @@ -package funkin.editors.character; - -import openfl.geom.Point; -import openfl.geom.Rectangle; -import openfl.display.BitmapData; -import flixel.util.FlxColor; - -using funkin.backend.utils.BitmapUtil; - -// DONT DELETE I MIGHT USE LATER -lunar -class CharacterIconDisplay extends UISprite { - public var healthBarBG:FlxSprite; - public var healthBar:FlxSprite; - public var textProperties:UIText; - - public function new(x:Float, y:Float, name:String, icon:String, color:Null, barWidth:Int) { - super(x, y); - - var path:String = Paths.image('icons/${icon}'); - if (!Assets.exists(path)) path = Paths.image('icons/face'); - - var imageBitmap:BitmapData = Assets.getBitmapData(path, true, false); - var iconBitmap:BitmapData = new BitmapData(150, 150, true, 0x00000000); - - iconBitmap.copyPixels(imageBitmap, new Rectangle(0, 0, 150, 150), new Point(0,0)); - - loadGraphic(FlxG.bitmap.add(iconBitmap.crop())); - scale.x = scale.y = 40/pixels.height; - updateHitbox(); - - // bye guys :(( - imageBitmap.dispose(); iconBitmap.dispose(); - - antialiasing = true; - - healthBarBG = new FlxSprite(x+(width/2), y+(height*(2.25/4))+2).makeSolid(barWidth-Std.int(width), 10, 0xFF000000); - healthBar = new FlxSprite(healthBarBG.x+2, healthBarBG.y+2).makeSolid( - Std.int(healthBarBG.width-4), Std.int(healthBarBG.height-4), - color != null ? color : 0xFFFFFFFF - ); - - textProperties = new UIText(x+width+2, healthBarBG.y-14, 0, 'Character Properties of ${name}...', 13); - - members.push(healthBarBG); - members.push(healthBar); - members.push(textProperties); - } - - public override function draw() { - drawMembers(); - drawSuper(); - } -} \ No newline at end of file diff --git a/source/funkin/editors/character/CharacterInfoScreen.hx b/source/funkin/editors/character/CharacterInfoScreen.hx index 15d296b2..dc1e5a1e 100644 --- a/source/funkin/editors/character/CharacterInfoScreen.hx +++ b/source/funkin/editors/character/CharacterInfoScreen.hx @@ -112,71 +112,4 @@ class CharacterInfoScreen extends UISubstateWindow { ] }); } -} - -class UIIconColorPicker extends UISliceSprite { - public var colorWheel:UIColorwheel; - - public var iconSprite:FlxSprite; - public var iconTextBox:UITextBox; - - public var pickerButton:UIButton; - public var pickerIcon:FlxSprite; - - public function new(x:Float, y:Float, icon:String, antialaising:Bool, colorWheel:UIColorwheel) { - super(x, y, 12+125+12, 4+125+4+32+12, 'editors/ui/inputbox'); - - this.colorWheel = colorWheel; - - iconTextBox = new UITextBox(x+12, y+4+125+4, icon, 125); - iconTextBox.onChange = (newIcon:String) -> {updateIcon(newIcon);} - members.push(iconTextBox); - - members.push(iconSprite = new FlxSprite()); - iconSprite.antialiasing = antialaising; - - pickerButton = new UIButton(x+12+125-26, y+12, "", colorPick, 26, 26); - pickerButton.frames = Paths.getFrames('editors/ui/inputbox'); - members.push(pickerButton); - - pickerIcon = new FlxSprite(pickerButton.x+7, pickerButton.y+7).loadGraphic(Paths.image("editors/ui/picker")); - members.push(pickerIcon); - - updateIcon(icon); - } - - var __path:String = null; - public function updateIcon(icon:String) { - if (iconSprite.animation.exists(icon)) return; - @:privateAccess iconSprite.animation.clearAnimations(); - - var path:String = Paths.image('icons/$icon'); - if (!Assets.exists(path)) path = Paths.image('icons/face'); - - iconSprite.loadGraphic(__path = path, true, 150, 150); - iconSprite.animation.add(icon, [0], 0, false); - iconSprite.animation.play(icon); - - iconSprite.scale.set(125/150, 125/150); - iconSprite.updateHitbox(); - iconSprite.setPosition(x+12, y+4); - - __cachedColor = null; - } - - var __cachedColor:Null = null; - public function colorPick() { - if (__cachedColor == null) { - var imageBitmap:BitmapData = Assets.getBitmapData(__path, true, false); - __cachedColor = imageBitmap.getMostPresentColor(); - imageBitmap.dispose(); - } - - if (colorWheel != null) { - colorWheel.hue = __cachedColor.hue; - colorWheel.saturation = __cachedColor.saturation; - colorWheel.brightness = __cachedColor.brightness; - colorWheel.updateWheel(); - } - } } \ No newline at end of file diff --git a/source/funkin/editors/ui/UIIconColorPicker.hx b/source/funkin/editors/ui/UIIconColorPicker.hx new file mode 100644 index 00000000..0d4ae922 --- /dev/null +++ b/source/funkin/editors/ui/UIIconColorPicker.hx @@ -0,0 +1,73 @@ +package funkin.editors.ui; + +import openfl.display.BitmapData; +import flixel.util.FlxColor; + +using funkin.backend.utils.BitmapUtil; + +class UIIconColorPicker extends UISliceSprite { + public var colorWheel:UIColorwheel; + + public var iconSprite:FlxSprite; + public var iconTextBox:UITextBox; + + public var pickerButton:UIButton; + public var pickerIcon:FlxSprite; + + public function new(x:Float, y:Float, icon:String, antialaising:Bool, colorWheel:UIColorwheel) { + super(x, y, 12+125+12, 4+125+4+32+12, 'editors/ui/inputbox'); + + this.colorWheel = colorWheel; + + iconTextBox = new UITextBox(x+12, y+4+125+4, icon, 125); + iconTextBox.onChange = (newIcon:String) -> {updateIcon(newIcon);} + members.push(iconTextBox); + + members.push(iconSprite = new FlxSprite()); + iconSprite.antialiasing = antialaising; + + pickerButton = new UIButton(x+12+125-26, y+12, "", colorPick, 26, 26); + pickerButton.frames = Paths.getFrames('editors/ui/inputbox'); + members.push(pickerButton); + + pickerIcon = new FlxSprite(pickerButton.x+7, pickerButton.y+7).loadGraphic(Paths.image("editors/ui/picker")); + members.push(pickerIcon); + + updateIcon(icon); + } + + var __path:String = null; + public function updateIcon(icon:String) { + if (iconSprite.animation.exists(icon)) return; + @:privateAccess iconSprite.animation.clearAnimations(); + + var path:String = Paths.image('icons/$icon'); + if (!Assets.exists(path)) path = Paths.image('icons/face'); + + iconSprite.loadGraphic(__path = path, true, 150, 150); + iconSprite.animation.add(icon, [0], 0, false); + iconSprite.animation.play(icon); + + iconSprite.scale.set(125/150, 125/150); + iconSprite.updateHitbox(); + iconSprite.setPosition(x+12, y+4); + + __cachedColor = null; + } + + var __cachedColor:Null = null; + public function colorPick() { + if (__cachedColor == null) { + var imageBitmap:BitmapData = Assets.getBitmapData(__path, true, false); + __cachedColor = imageBitmap.getMostPresentColor(); + imageBitmap.dispose(); + } + + if (colorWheel != null) { + colorWheel.hue = __cachedColor.hue; + colorWheel.saturation = __cachedColor.saturation; + colorWheel.brightness = __cachedColor.brightness; + colorWheel.updateWheel(); + } + } +} \ No newline at end of file