From ee8608d3b9f02982786553a80da1f336cff9da79 Mon Sep 17 00:00:00 2001 From: Yoshman29 <81191621+YoshiCrafter29@users.noreply.github.com> Date: Tue, 18 Apr 2023 18:55:18 +0200 Subject: [PATCH] scrollbar --- TODO.md | 12 +++++- assets/images/editors/ui/scrollbar-bg.png | Bin 0 -> 153 bytes assets/images/editors/ui/scrollbar-icon.png | Bin 0 -> 146 bytes assets/images/editors/ui/scrollbar.png | Bin 0 -> 880 bytes assets/images/editors/ui/scrollbar.xml | 33 +++++++++++++++ source/funkin/editors/charter/Charter.hx | 16 +++++++- source/funkin/editors/ui/UIScrollBar.hx | 43 ++++++++++++++++++++ 7 files changed, 102 insertions(+), 2 deletions(-) create mode 100644 assets/images/editors/ui/scrollbar-bg.png create mode 100644 assets/images/editors/ui/scrollbar-icon.png create mode 100644 assets/images/editors/ui/scrollbar.png create mode 100644 assets/images/editors/ui/scrollbar.xml create mode 100644 source/funkin/editors/ui/UIScrollBar.hx diff --git a/TODO.md b/TODO.md index dfeafe44..19203234 100644 --- a/TODO.md +++ b/TODO.md @@ -3,7 +3,17 @@ ## `v1.0.0` - Initial release - [x] Remove Herobrine -- [*] Chart Editor +- [ ] Chart Editor + - [x] Place & Delete notes + - [x] Ctrl+Z & Ctrl+Y + - [x] Selection box & dragging + - [ ] Scroll bar at the right + Song info + - [ ] Algorithm to make note placements faster & sorted out + - [ ] Fix the strumlines bar when zooming out + - [ ] Play here working + - [ ] Events (including Camera Movement) + - [ ] Custom Notes + - [ ] Metadata Editing - [ ] New Switch Mod menu - [ ] Add note offset - [ ] Dialogue diff --git a/assets/images/editors/ui/scrollbar-bg.png b/assets/images/editors/ui/scrollbar-bg.png new file mode 100644 index 0000000000000000000000000000000000000000..1c6547a722b60c7f4f7154dbe4fe74720021fe75 GIT binary patch literal 153 zcmeAS@N?(olHy`uVBq!ia0vp^B0$W@!3HGnP3ltxQk(@Ik;M!Qe1}1p@p%4<6riBD zr;B4q#Vy~X8+jWPL>vw-Z)m8N6gJwF3gkUYeZ>67M#|eHYpIB1uF+RCwC$n9olWK@`VlW_L;VkCBT=F$&!%n1B~;JaC~xY@!}8 zw!jL=ub_wo&;&S$g_DV(l9-0JA{E*akk*s<7kE_S!5@chI&0UR+1c(cMq+Ibm~@iO z%)WW^o%eaOhn)vCO#}9}^*XHrXpA9*`eTi$-D%TKdTIo4NZX0+VPhRI*8Qeu+4Wv? zOVw3}=|z^3IRNs8NULPZbXb%xf z1V?NTTo1Gh1iY@{xI=h5x`)ZWa|0_1B7ty5AdvLP&?Nyv_K^Q1g_E058E=HfyZWKu>xEH zt^oh%!0X|JI@&vhDGW3LAp7%SP{@FS%w}$2{w)~^fuO6eQ~3FV)5e1##YhY&KmlY0 zQwY#zEBG-zG7b#*#q2%+!@flY@>T*l&Xz#lSjX|U1hRR=8G48S>wfZBM+LY7Tmh~C zTfp7@oxJ*;1LXn^4*Ff$eF%oy7P4gnCYOi!YEr$^H;qdH?zw$K@SHtGFAtmHG``;z zQc3|14*A7~MmN1YtS@EoNXMd53a~uUAxh1)LOFqX9atzMuuBJ~cjEZ+yWDX5Lbhzc zq-{jEus()&`=@a+z|qw6bn?x1z0`P`w_n&3tC<|po9GEC#Q=wQ7Q(4`rq$Erb`%uW zmov1WFydcSiUF1w&<*0a=Z6mgY0nk_p#a2mSur@QbNlo<*(1R@z$>c0O zV6BG--r2n8T-~81qxiE7Hp@AGEE%ycMbD`wov(FNPJRLWA=M;D@*ms)0000 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/source/funkin/editors/charter/Charter.hx b/source/funkin/editors/charter/Charter.hx index 2d87b8f6..fea6069b 100644 --- a/source/funkin/editors/charter/Charter.hx +++ b/source/funkin/editors/charter/Charter.hx @@ -40,6 +40,8 @@ class Charter extends UIState { public var topMenu:Array; + public var scrollBar:UIScrollBar; + public var topMenuSpr:UITopMenu; public var gridBackdrop:CharterBackdrop; public var beatSeparator:FlxBackdrop; @@ -332,10 +334,12 @@ class Charter extends UIState { conductorFollowerSpr.cameras = selectionBox.cameras = notesGroup.cameras = gridBackdrop.cameras = [charterCamera]; - topMenuSpr = new UITopMenu(topMenu); topMenuSpr.cameras = uiGroup.cameras = [uiCamera]; + scrollBar = new UIScrollBar(FlxG.width - 20, topMenuSpr.bHeight, 1000, 0, 100); + uiGroup.add(scrollBar); + topLimit = new FlxSprite(); topLimit.makeGraphic(1, 1, -1); topLimit.color = 0xFF888888; @@ -389,6 +393,13 @@ class Charter extends UIState { strumLines.add(new CharterStrumline(strL)); } + + refreshBPMSensitive(); + } + + public function refreshBPMSensitive() { + // refreshes everything dependant on BPM, and BPM changes + scrollBar.length = Conductor.getStepForTime(FlxG.sound.music.getDefault(vocals).length); } public override function beatHit(curBeat:Int) { @@ -593,6 +604,9 @@ class Charter extends UIState { super.update(elapsed); + scrollBar.size = (FlxG.height / 40 / charterCamera.zoom); + scrollBar.start = Conductor.curStepFloat - (scrollBar.size / 2); + if (gridBackdrop.strumlinesAmount != (gridBackdrop.strumlinesAmount = strumLines.length)) updateDisplaySprites(); diff --git a/source/funkin/editors/ui/UIScrollBar.hx b/source/funkin/editors/ui/UIScrollBar.hx new file mode 100644 index 00000000..ff567981 --- /dev/null +++ b/source/funkin/editors/ui/UIScrollBar.hx @@ -0,0 +1,43 @@ +package funkin.editors.ui; + +class UIScrollBar extends UISprite { + public var length:Float; + public var start:Float; + public var size:Float; + + public var thumb:UISliceSprite; + + public var value:Float; + + public var onChange:Float->Void; + + 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)); + updateHitbox(); + this.start = start; + this.size = size; + this.length = length; + + thumb = new UISliceSprite(0, 0, w, h, 'editors/ui/scrollbar'); + members.push(thumb); + } + + public override function update(elapsed:Float) { + super.update(elapsed); + thumb.follow(this, 0, FlxMath.remapToRange(start, -(size/2), length + size, 0, height)); + thumb.bHeight = Std.int(FlxMath.remapToRange(size, -(size/2), length + size, 0, height)); + + if (hovered) { + if (FlxG.mouse.justReleased) { + var mousePos = FlxG.mouse.getScreenPosition(camera); + var yPos = FlxMath.remapToRange(mousePos.y, y, y+height, -(size/2), length + size); + if (yPos >= 0 && yPos < length) { + onChange(value = yPos); + } + } + } else if (thumb.hovered) { + // todo: scrolling + } + } +} \ No newline at end of file