From 5138ba72e70fafcc0acbe0d1a8d81287bc4dfd09 Mon Sep 17 00:00:00 2001 From: lunarcleint <88809950+lunarcleint@users.noreply.github.com> Date: Wed, 2 Aug 2023 19:10:23 -0700 Subject: [PATCH] dumping a bunch of stuff (ui button list still fucking broken) --- .../editors/character/CharacterEditor.hx | 44 +++--- .../editors/character/CharacterInfoScreen.hx | 9 +- .../character/CharacterPropertiesWindow.hx | 2 +- .../editors/charter/CharterEventScreen.hx | 19 ++- .../editors/charter/CharterStrumlineScreen.hx | 10 +- source/funkin/editors/import.hx | 1 + source/funkin/editors/ui/UIButtonList.hx | 133 ++++++++++-------- source/funkin/editors/ui/UIScrollBar.hx | 1 + source/funkin/game/Character.hx | 5 +- source/funkin/game/PlayState.hx | 10 +- source/funkin/options/Options.hx | 1 + .../options/categories/AppearanceOptions.hx | 4 + 12 files changed, 140 insertions(+), 99 deletions(-) diff --git a/source/funkin/editors/character/CharacterEditor.hx b/source/funkin/editors/character/CharacterEditor.hx index f49d4d5d..d64dfc0e 100644 --- a/source/funkin/editors/character/CharacterEditor.hx +++ b/source/funkin/editors/character/CharacterEditor.hx @@ -31,7 +31,7 @@ class CharacterEditor extends UIState { // WINDOWS public var characterPropertiresWindow:CharacterPropertiesWindow; - public var characterAnimsWindow:UIButtonList; + public var characterAnimsWindow:UIButtonList; // camera for the character itself so that it can be unzoomed/zoomed in again public var charCamera:FlxCamera; @@ -236,10 +236,13 @@ class CharacterEditor extends UIState { topMenuSpr.cameras = uiGroup.cameras = [uiCamera]; characterPropertiresWindow = new CharacterPropertiesWindow(); - characterAnimsWindow = new UIButtonList(777, 209, 473, 488, "Character Animations", function() CharacterEditor.instance.createAnimWithUI()); - for (i=>anim in character.getNameList()) - characterAnimsWindow.insert(new CharacterAnimButtons(0,0, anim, character.getAnimOffset(anim)), 0); uiGroup.add(characterPropertiresWindow); + + characterAnimsWindow = new UIButtonList(777, 209, 473, 488, "Character Animations", FlxPoint.get(429, 32), FlxPoint.get(0, 16)); + characterAnimsWindow.addButton.callback = + function() CharacterEditor.instance.createAnimWithUI(); + for (i=>anim in character.getNameList()) + characterAnimsWindow.add(new CharacterAnimButtons(0,0, anim, character.getAnimOffset(anim))); uiGroup.add(characterAnimsWindow); playAnimation(character.getNameList()[0]); @@ -263,7 +266,7 @@ class CharacterEditor extends UIState { } if (character != null) - characterPropertiresWindow.characterInfo.text = '(${character.getNameList().length}) Animations\nFlipped: ${character.flipX}\nSprite: ${character.sprite}\nAnim: ${character.getAnimName()}\nOffset: (${character.frameOffset.x}, ${character.frameOffset.y})'; + characterPropertiresWindow.characterInfo.text = '${character.getNameList().length} Animations\nFlipped: ${character.flipX}\nSprite: ${character.sprite}\nAnim: ${character.getAnimName()}\nOffset: (${character.frameOffset.x}, ${character.frameOffset.y})'; if (!(characterPropertiresWindow.hovered || characterAnimsWindow.hovered) && !characterAnimsWindow.dragging) { if (FlxG.mouse.wheel != 0) { @@ -376,10 +379,9 @@ class CharacterEditor extends UIState { ghosts.setOffsets(anim, offsets.clone()); } - for (button in characterAnimsWindow.buttons.members) { - var charButton:CharacterAnimButtons = cast(button, CharacterAnimButtons); + for (charButton in characterAnimsWindow.buttons.members) charButton.updateInfo(charButton.anim, character.getAnimOffset(charButton.anim), ghosts.animGhosts[charButton.anim].visible); - } + changeOffset(character.getAnimName(), FlxPoint.get(0, 0), false); // apply da new offsets } if (v != null) @@ -436,10 +438,12 @@ class CharacterEditor extends UIState { })); } - public function createAnim(animData:AnimData, animID:Int = 0, addtoUndo:Bool = true) { + public function createAnim(animData:AnimData, animID:Int = -1, addtoUndo:Bool = true) { XMLUtil.addAnimToSprite(character, animData); ghosts.createGhost(animData.name); - characterAnimsWindow.insert(new CharacterAnimButtons(0, 0, animData.name, FlxPoint.get(animData.x,animData.y)), animID); + var newButton = new CharacterAnimButtons(0, 0, animData.name, FlxPoint.get(animData.x,animData.y)); + if (animID == -1) characterAnimsWindow.add(newButton); + else characterAnimsWindow.insert(newButton, animID); playAnimation(animData.name); @@ -450,7 +454,8 @@ class CharacterEditor extends UIState { public function editAnim(name:String, animData:AnimData, addtoUndo:Bool = true) { var oldAnimData:AnimData = character.animDatas.get(name); var buttoner:CharacterAnimButtons = null; - for (i in characterAnimsWindow.members) if (cast(i, CharacterAnimButtons).anim == name) buttoner = cast i; + for (button in characterAnimsWindow.buttons.members) + if (button.anim == name) buttoner = button; ghosts.removeGhost(name); XMLUtil.addAnimToSprite(character, animData); @@ -470,6 +475,9 @@ class CharacterEditor extends UIState { else playAnimation(character.getNameList()[Std.int(Math.abs(character.getNameList().indexOf(name)-1))]); + for(button in characterAnimsWindow.buttons.members) + if(button.anim == name) characterAnimsWindow.remove(button); + // undo shit blah blah var oldID:Int = character.getNameList().indexOf(name); var oldAnimData:AnimData = character.animDatas.get(name); @@ -478,13 +486,6 @@ class CharacterEditor extends UIState { character.removeAnimation(name); if (character.animOffsets.exists(name)) character.animOffsets.remove(name); if (character.animDatas.exists(name)) character.animDatas.remove(name); - for(i in characterAnimsWindow.buttons.members) { - if(i is CharacterAnimButtons) { - var i:CharacterAnimButtons = cast i; - if(i.anim == name) - characterAnimsWindow.remove(i); - } - } if (addtoUndo) addToUndo(CDeleteAnim(oldID, oldAnimData)); @@ -513,9 +514,10 @@ class CharacterEditor extends UIState { var ghost:Character = ghosts.animGhosts.get(anim); ghost.visible = !ghost.visible; - var button:CharacterAnimButtons = null; - for (i in characterAnimsWindow.members) if (cast(i, CharacterAnimButtons).anim == anim) button = cast(i ,CharacterAnimButtons); - button.updateInfo(anim, character.getAnimOffset(anim), ghost.visible); + var animButton:CharacterAnimButtons = null; + for (button in characterAnimsWindow.buttons.members) + if (button.anim == anim) animButton = button; + animButton.updateInfo(anim, character.getAnimOffset(anim), ghost.visible); } function _playback_play_anim(_) { diff --git a/source/funkin/editors/character/CharacterInfoScreen.hx b/source/funkin/editors/character/CharacterInfoScreen.hx index 0f0b09a1..7f7169fa 100644 --- a/source/funkin/editors/character/CharacterInfoScreen.hx +++ b/source/funkin/editors/character/CharacterInfoScreen.hx @@ -13,6 +13,7 @@ class CharacterInfoScreen extends UISubstateWindow { public var gameOverCharTextBox:UITextBox; public var antialiasingCheckbox:UICheckbox; public var flipXCheckbox:UICheckbox; + public var iconColorWheel:UIColorwheel; public var positionXStepper:UINumericStepper; public var positionYStepper:UINumericStepper; public var cameraXStepper:UINumericStepper; @@ -36,7 +37,7 @@ class CharacterInfoScreen extends UISubstateWindow { public override function create() { winTitle = "Editing Character"; winWidth = 714; - winHeight = 500; + winHeight = 600; super.create(); @@ -69,7 +70,11 @@ class CharacterInfoScreen extends UISubstateWindow { add(flipXCheckbox); addLabelOn(flipXCheckbox, "Flipped"); - add(title = new UIText(spriteTextBox.x, spriteTextBox.y + 10 + 46 + 64, 0, "Character Data", 28)); + iconColorWheel = new UIColorwheel(flipXCheckbox.x + 100, flipXCheckbox.y, character.iconColor); + add(iconColorWheel); + addLabelOn(iconColorWheel, "Icon Color"); + + add(title = new UIText(spriteTextBox.x, spriteTextBox.y + 10 + 46 + 64 + 100, 0, "Character Data", 28)); positionXStepper = new UINumericStepper(title.x, title.y + title.height + 36, character.globalOffset.x, 0.001, 2, null, null, 84); add(positionXStepper); diff --git a/source/funkin/editors/character/CharacterPropertiesWindow.hx b/source/funkin/editors/character/CharacterPropertiesWindow.hx index f13478c7..4ffe5329 100644 --- a/source/funkin/editors/character/CharacterPropertiesWindow.hx +++ b/source/funkin/editors/character/CharacterPropertiesWindow.hx @@ -20,7 +20,7 @@ class CharacterPropertiesWindow extends UIWindow { }, 200); members.push(editButton); - characterInfo = new UIText(x + 450 + 20 - 42 - 400, y + 36 + 10, 400, "() Animations:\nFlipped:\nSprite:\nAnim:\nOffset: (,)"); + characterInfo = new UIText(x + 450 + 20 - 42 - 400, y + 36 + 10, 400, "0 Animations:\nFlipped:\nSprite:\nAnim:\nOffset: (,)"); characterInfo.alignment = LEFT; members.push(characterInfo); } diff --git a/source/funkin/editors/charter/CharterEventScreen.hx b/source/funkin/editors/charter/CharterEventScreen.hx index 525670c9..a0a66d3b 100644 --- a/source/funkin/editors/charter/CharterEventScreen.hx +++ b/source/funkin/editors/charter/CharterEventScreen.hx @@ -14,7 +14,7 @@ class CharterEventScreen extends UISubstateWindow { public var step:Float = 0; public var events:Array = []; - public var eventsList:UIButtonList = null; + public var eventsList:UIButtonList; public var eventName:UIText; @@ -41,7 +41,11 @@ class CharterEventScreen extends UISubstateWindow { FlxG.sound.music.pause(); // prevent the song from continuing Charter.instance.vocals.pause(); - eventsList = new UIButtonList(0,0,75, 570, "", ()-> openSubState(new CharterEventTypeSelection(function(eventName) { + + events = chartEvent.events.copy(); + + eventsList = new UIButtonList(0,0,75, 570, "", FlxPoint.get(73, 40)); + eventsList.addButton.callback = () -> openSubState(new CharterEventTypeSelection(function(eventName) { events.push({ time: Conductor.getTimeForStep(chartEvent.step), params: [], @@ -49,11 +53,11 @@ class CharterEventScreen extends UISubstateWindow { }); eventsList.add(new EventButton(events[events.length-1], CharterEvent.generateEventIcon(events[events.length-1]), events.length-1, this, eventsList)); changeTab(events.length-1); - })), 1, 2); - events = chartEvent.events.copy(); + })); for (k=>i in events) eventsList.add(new EventButton(i, CharterEvent.generateEventIcon(i), k, this, eventsList)); add(eventsList); + paramsPanel = new FlxGroup(); add(paramsPanel); @@ -212,13 +216,15 @@ class CharterEventScreen extends UISubstateWindow { ]; } } + class EventButton extends UIButton { public var icon:FlxSprite = null; public var event:ChartEvent = null; public var deleteButton:UIButton; public var deleteIcon:FlxSprite; - public function new(event:ChartEvent, icon:FlxSprite, id:Int, substate:CharterEventScreen, parent:UIButtonList) { - super(0,0,"",function() { + + public function new(event:ChartEvent, icon:FlxSprite, id:Int, substate:CharterEventScreen, parent:UIButtonList) { + super(0,0,"" ,function() { substate.changeTab(id); for(i in parent.buttons.members) { if(i is EventButton) { @@ -244,6 +250,7 @@ class EventButton extends UIButton { deleteIcon.antialiasing = false; members.push(deleteIcon); } + override function update(elapsed) { super.update(elapsed); icon.setPosition(x + (18 - icon.width / 2),y + (20 - icon.height / 2)); diff --git a/source/funkin/editors/charter/CharterStrumlineScreen.hx b/source/funkin/editors/charter/CharterStrumlineScreen.hx index 7bcbb9fe..2fdb3b51 100644 --- a/source/funkin/editors/charter/CharterStrumlineScreen.hx +++ b/source/funkin/editors/charter/CharterStrumlineScreen.hx @@ -10,7 +10,7 @@ class CharterStrumlineScreen extends UISubstateWindow { public var strumLineID:Int = -1; public var strumLine:ChartStrumLine; - public var charactersList:UIButtonList; + public var charactersList:UIButtonList; public var typeDropdown:UIDropDown; public var stagePositionDropdown:UIDropDown; public var hudScaleStepper:UINumericStepper; @@ -56,8 +56,10 @@ class CharterStrumlineScreen extends UISubstateWindow { function addLabelOn(ui:UISprite, text:String) add(new UIText(ui.x, ui.y - 24, 0, text)); - charactersList = new UIButtonList(15, 43, 250, 330, "", () -> charactersList.add(new CharacterButton(0,0,"New Char", charactersList)), 2, 2); - for (i in strumLine.characters) charactersList.add(new CharacterButton(0,0,i, charactersList)); + charactersList = new UIButtonList(15, 43, 250, 330, "", FlxPoint.get(246, 75)); + charactersList.addButton.callback = () -> charactersList.add(new CharacterButton(0,0,"New Char", charactersList)); + for (i in strumLine.characters) + charactersList.add(new CharacterButton(0,0,i, charactersList)); charactersList.cameraSpacing = 2; add(charactersList); @@ -157,7 +159,7 @@ class CharacterButton extends UIButton { public var deleteButton:UIButton; public var deleteIcon:FlxSprite; - public function new(x:Float, y:Float, char:String, parent:UIButtonList) { + public function new(x:Float, y:Float, char:String, parent:UIButtonList) { charIcon = new HealthIcon(char); charIcon.scale.set(0.5, 0.5); charIcon.updateHitbox(); diff --git a/source/funkin/editors/import.hx b/source/funkin/editors/import.hx index 3083047d..b15a4507 100644 --- a/source/funkin/editors/import.hx +++ b/source/funkin/editors/import.hx @@ -1,5 +1,6 @@ package funkin.editors; import funkin.editors.ui.*; +import flixel.math.FlxPoint; using funkin.editors.ui.UIUtil; \ No newline at end of file diff --git a/source/funkin/editors/ui/UIButtonList.hx b/source/funkin/editors/ui/UIButtonList.hx index ca7b5e36..bc17c294 100644 --- a/source/funkin/editors/ui/UIButtonList.hx +++ b/source/funkin/editors/ui/UIButtonList.hx @@ -5,76 +5,88 @@ import flixel.group.FlxGroup; import flixel.util.FlxColor; import flixel.math.FlxPoint; import funkin.game.Character; +import flixel.util.FlxSort; -class UIButtonList extends UIWindow { - public var character:Character; - - public var buttons:FlxTypedGroup = new FlxTypedGroup(); +class UIButtonList extends UIWindow { + public var buttons:FlxTypedGroup = new FlxTypedGroup(); public var addButton:UIButton; public var addIcon:FlxSprite; + public var buttonCameras:FlxCamera; - public var cameraSpacing = 36; + public var cameraSpacing = 30; + + public var buttonSpacing:Float = 16; + public var buttonSize:FlxPoint = FlxPoint.get(); + public var buttonOffset:FlxPoint = FlxPoint.get(); + public var dragging:Bool = false; - var _buttonXOffset:Float = 16; - var _buttonYOffset:Float = 16; + var curMoving:T = null; + var curMovingInterval:Float = 0; - public function new(x:Int, y:Int, width:Int, height:Int, windowName:String, addButtonCallback:Void->Void = null, buttonXOffset:Float = 16, buttonYOffset:Float = 16) { + public function new(x:Int, y:Int, width:Int, height:Int, windowName:String, buttonSize:FlxPoint, ?buttonOffset:FlxPoint, ?buttonSpacing:Float) { + if (buttonSpacing != null) this.buttonSpacing = buttonSpacing; + this.buttonSize = buttonSize; + if (buttonOffset != null) this.buttonOffset = buttonOffset; super(x, y, width, height, windowName); - members.push(buttons); - _buttonXOffset = buttonXOffset; - _buttonYOffset = buttonYOffset; - buttonCameras = new FlxCamera(x, y+cameraSpacing, width, height-cameraSpacing); + + buttonCameras = new FlxCamera(x, y+cameraSpacing, width-2, height-cameraSpacing); FlxG.cameras.add(buttonCameras, false); buttonCameras.bgColor = 0; - addButton = new UIButton(25, 16, "", addButtonCallback != null ? addButtonCallback : function() return false, Math.floor(bWidth - buttonXOffset * 2)); + addButton = new UIButton(25, 16, "", null, Std.int(buttonSize.x)); addButton.color = 0xFF00FF00; + addButton.cameras = [buttonCameras]; addIcon = new FlxSprite(addButton.x + addButton.bHeight / 2, addButton.y + (32/2) - 8).loadGraphic(Paths.image('editors/charter/add-button')); addIcon.antialiasing = false; addButton.members.push(addIcon); - add(addButton); + members.push(addButton); + + members.push(buttons); + scrollY = buttonCameras.scroll.y = -this.buttonSpacing; } - public function add(button:UIButton) - insert(button, Math.floor(Math.max(buttons.members.indexOf(addButton), 0))); - public function insert(button:UIButton, position:Int) { + + public inline function add(button:T) + buttons.add(button); + + public inline function insert(button:T, position:Int) { buttons.insert(position, button); - button.cameras = [buttonCameras]; - button.x = _buttonXOffset; - if (addButton.bHeight != button.bHeight) addButton.bHeight = button.bHeight; scrollY += button.bHeight; } - public function remove(button:UIButton) { - buttons.remove(button, true); + + public inline function remove(button:T) { + buttons.members.remove(button); button.destroy(); } - var _curMoving:UIButton = null; - var _curMovingInterval:Float = 0; - public function updateButtonsPos(elapsed:Float) { + + public inline function updateButtonsPos(elapsed:Float) { for (i => button in buttons.members) { - if (_curMoving != button) { - for (i in button.members) - if (i is UIButton) { - var i:UIButton = cast(i, UIButton); - i.selectable = true; - } - button.y = CoolUtil.fpsLerp(button.y, -scrollY + ((buttons.members[i-1] != null ? buttons.members[i-1].bHeight : 0) + _buttonYOffset) * i, 0.25); - button.shouldPress = true; + if (button == null) continue; + + if (curMoving != button) { + button.setPosition( + (bWidth/2) - (buttonSize.x/2), + CoolUtil.fpsLerp(button.y, (buttonSize.y+buttonSpacing) * i, 0.25)); } - if (button != addButton && button.hovered && FlxG.mouse.justPressed) _curMoving = button; + if (button.hovered && FlxG.mouse.justPressed) curMoving = button; } - if (_curMoving != null) { - _curMovingInterval += FlxG.mouse.deltaY; - if (Math.abs(_curMovingInterval) > addButton.bHeight / 2) { - _curMovingInterval = 999; - _curMoving.shouldPress = false; - _curMoving.y = CoolUtil.fpsLerp(_curMoving.y, FlxG.mouse.getScreenPosition(buttonCameras).y - (_curMoving.bHeight / 2), 0.3); - buttons.sort(function(o,a,b) return flixel.util.FlxSort.byValues(o, a == addButton ? 999 : a.y + (a.bHeight / 2), b == addButton ? 999 : b.y + (a.bHeight / 2)), -1); + + if (addButton != null) + addButton.setPosition( + (bWidth/2) - (buttonSize.x/2), + CoolUtil.fpsLerp(addButton.y, (buttonSize.y+buttonSpacing) * buttons.members.length, 0.25)); + + if (curMoving != null) { + curMovingInterval += FlxG.mouse.deltaY; + if (Math.abs(curMovingInterval) > addButton.bHeight / 2) { + curMovingInterval = 999; + curMoving.y = CoolUtil.fpsLerp(curMoving.y, FlxG.mouse.getWorldPosition(buttonCameras).y - (curMoving.bHeight / 2), 0.3); + buttons.sort(function(o, a:T, b:T) return FlxSort.byValues(o, a.y + (a.bHeight / 2), b.y + (a.bHeight / 2)), -1); } if (FlxG.mouse.justReleased) { - _curMoving = null; - _curMovingInterval = 0; + curMoving = null; + curMovingInterval = 0; } } addIcon.x = addButton.x + addButton.bWidth / 2 - addIcon.width / 2; addIcon.y = addButton.y + addButton.bHeight / 2 - addIcon.height / 2; @@ -84,28 +96,33 @@ class UIButtonList extends UIWindow { public override function update(elapsed:Float) { updateButtonsPos(elapsed); + dragging = curMoving != null; + super.update(elapsed); - __rect.x = x; __rect.y = y+23; - __rect.width = bWidth; __rect.height = bHeight-23; - var nextscrollY = scrollY - ((hovered = UIState.state.isOverlapping(this, __rect)) ? FlxG.mouse.wheel : 0) * 12; - if (_curMoving != null) { - for (i in _curMoving.members) - if (i is UIButton) { - var i:UIButton = cast(i, UIButton); - i.selectable = false; - } - nextscrollY -= Math.min((bHeight - 100) - FlxG.mouse.getScreenPosition(buttonCameras).y, 0) / 5; - nextscrollY += Math.min(FlxG.mouse.getScreenPosition(buttonCameras).y - 100, 0) / 5; + + // Camera Stuff + var nextscrollY = scrollY - (hovered ? FlxG.mouse.wheel : 0) * 12; + + if (curMoving != null) { + nextscrollY -= Math.min((bHeight - 100) - FlxG.mouse.getWorldPosition(buttonCameras).y, 0) / 8; + nextscrollY += Math.min(FlxG.mouse.getWorldPosition(buttonCameras).y - 100, 0) / 8; } - scrollY = FlxMath.bound(nextscrollY, 0, -_buttonYOffset + Math.abs(Math.min(bHeight - ((addButton.bHeight + _buttonYOffset) * buttons.members.length + (cameraSpacing + _buttonYOffset)), 0))); - for (button in buttons.members) - if (button != null) button.selectable = (hovered && _curMoving == null); + + if (nextscrollY >= (-buttonSpacing) && nextscrollY + buttonCameras.height <= (addButton.y + 32 + (buttonSpacing*1.5))) + scrollY = nextscrollY; + + buttonCameras.scroll.y = FlxMath.lerp(buttonCameras.scroll.y, nextscrollY, 1/3); + + for (button in buttons) { + if (button != null) button.selectable = (hovered && !dragging); + button.cameras = [buttonCameras]; + } + if (__lastDrawCameras[0] != null) { buttonCameras.height = bHeight - cameraSpacing; buttonCameras.x = x - __lastDrawCameras[0].scroll.x; buttonCameras.y = y + cameraSpacing - __lastDrawCameras[0].scroll.y; buttonCameras.zoom = __lastDrawCameras[0].zoom; } - dragging = _curMoving != null; } } \ No newline at end of file diff --git a/source/funkin/editors/ui/UIScrollBar.hx b/source/funkin/editors/ui/UIScrollBar.hx index 3acfccda..171846d7 100644 --- a/source/funkin/editors/ui/UIScrollBar.hx +++ b/source/funkin/editors/ui/UIScrollBar.hx @@ -17,6 +17,7 @@ class UIScrollBar extends UISprite { public function new(x:Float, y:Float, length:Float, start:Float, size:Float, w:Int = 20, ?h:Int) { super(x, y, Paths.image("editors/ui/scrollbar-bg")); scale.y = h.getDefault(Std.int(FlxG.height - y)); + alpha = 0.5; updateHitbox(); this.start = start; this.size = size; diff --git a/source/funkin/game/Character.hx b/source/funkin/game/Character.hx index f8f303f4..7e589ef7 100644 --- a/source/funkin/game/Character.hx +++ b/source/funkin/game/Character.hx @@ -52,6 +52,7 @@ class Character extends FunkinSprite implements IBeatReceiver implements IOffset public var playerOffsets:Bool = false; public var icon:String = null; + public var iconColor:FlxColor = -1; public var gameOverCharacter:String = "bf-dead"; public var cameraOffset:FlxPoint = new FlxPoint(0, 0); @@ -373,7 +374,8 @@ class Character extends FunkinSprite implements IBeatReceiver implements IOffset if (xml.x.exists("camy")) cameraOffset.y = Std.parseFloat(xml.x.get("camy")); if (xml.x.exists("holdTime")) holdTime = CoolUtil.getDefault(Std.parseFloat(xml.x.get("holdTime")), 4); if (xml.x.exists("flipX")) flipX = (xml.x.get("flipX") == "true"); - if (xml.x.exists("icon")) icon = xml.x.get("icon"); // idk why this is broke it just is + if (xml.x.exists("icon")) icon = xml.x.get("icon"); + if (xml.x.exists("color")) iconColor = FlxColor.fromString(xml.x.get("color")); if (xml.x.exists("scale")) { var scale = Std.parseFloat(xml.x.get("scale")).getDefault(1); this.scale.set(scale, scale); @@ -407,6 +409,7 @@ class Character extends FunkinSprite implements IBeatReceiver implements IOffset xml.set("holdTime", Std.string(holdTime)); xml.set("flipX", Std.string(flipX)); xml.set("icon", icon); + xml.set("color", iconColor.toHexString(false).replace("0x", "#")); xml.set("scale", Std.string(scale.x)); xml.set("antialiasing", antialiasing == true ? "true" : "false"); xml.set("sprite", sprite); diff --git a/source/funkin/game/PlayState.hx b/source/funkin/game/PlayState.hx index eaf9162c..9b564454 100644 --- a/source/funkin/game/PlayState.hx +++ b/source/funkin/game/PlayState.hx @@ -682,15 +682,13 @@ class PlayState extends MusicBeatState healthBarBG.scrollFactor.set(); add(healthBarBG); - - healthBar = new FlxBar(healthBarBG.x + 4, healthBarBG.y + 4, RIGHT_TO_LEFT, Std.int(healthBarBG.width - 8), Std.int(healthBarBG.height - 8), this, 'health', 0, maxHealth); healthBar.scrollFactor.set(); - if (opponentMode) - healthBar.createFilledBar(0xFF66FF33, 0xFFFF0000); // switch the colors - else - healthBar.createFilledBar(0xFFFF0000, 0xFF66FF33); + var leftColor:Int = dad.iconColor != -1 && Options.colorHealthBar ? dad.iconColor : 0xFFFF0000; + var rightColor:Int = boyfriend.iconColor != -1 && Options.colorHealthBar ? boyfriend.iconColor : 0xFF66FF33; + if (opponentMode) healthBar.createFilledBar(rightColor, leftColor); // switch the colors + else healthBar.createFilledBar(leftColor, rightColor); add(healthBar); health = maxHealth / 2; diff --git a/source/funkin/options/Options.hx b/source/funkin/options/Options.hx index 2ab18f71..39d983e9 100644 --- a/source/funkin/options/Options.hx +++ b/source/funkin/options/Options.hx @@ -27,6 +27,7 @@ class Options public static var antialiasing:Bool = true; public static var volume:Float = 1; public static var week6PixelPerfect:Bool = true; + public static var colorHealthBar:Bool = true; public static var lowMemoryMode:Bool = false; public static var betaUpdates:Bool = false; public static var splashesEnabled:Bool = true; diff --git a/source/funkin/options/categories/AppearanceOptions.hx b/source/funkin/options/categories/AppearanceOptions.hx index 7d4986a9..591d9fca 100644 --- a/source/funkin/options/categories/AppearanceOptions.hx +++ b/source/funkin/options/categories/AppearanceOptions.hx @@ -15,6 +15,10 @@ class AppearanceOptions extends OptionsScreen { "Antialiasing", "If unchecked, will disable antialiasing on every sprite. Can boost performances at the cost of sharper, more pixely sprites", "antialiasing")); + add(new Checkbox( + "Colored Healthbar", + "If unchecked, the game will use the orginal red/green health bar from the week 6 fnf game.", + "colorHealthBar")); add(new Checkbox( "Pixel Perfect Effect", "If checked, Week 6 will have a pixel perfect effect to it enabled, aligning every pixel on the screen.",