UIWindow collapsing fix
Co-Authored-By: Ne_Eo <NeeEoo@users.noreply.github.com>
This commit is contained in:
@@ -123,6 +123,7 @@ class FunkinSprite extends FlxSkewedSprite implements IBeatReceiver implements I
|
|||||||
private var countedBeat = 0;
|
private var countedBeat = 0;
|
||||||
public function beatHit(curBeat:Int)
|
public function beatHit(curBeat:Int)
|
||||||
{
|
{
|
||||||
|
if(!animEnabled) return;
|
||||||
if (beatAnims.length > 0 && (curBeat + beatOffset) % beatInterval == 0)
|
if (beatAnims.length > 0 && (curBeat + beatOffset) % beatInterval == 0)
|
||||||
{
|
{
|
||||||
if(skipNegativeBeats && curBeat < 0) return;
|
if(skipNegativeBeats && curBeat < 0) return;
|
||||||
|
|||||||
@@ -139,7 +139,7 @@ class CharterNote extends UISprite implements ICharterSelectable {
|
|||||||
|
|
||||||
sustainDraggable = false;
|
sustainDraggable = false;
|
||||||
if (!hovered && susLength != 0) {
|
if (!hovered && susLength != 0) {
|
||||||
UIState.state.updateSpriteRect(sustainSpr);
|
sustainSpr.updateSpriteRect();
|
||||||
sustainDraggable = UIState.state.isOverlapping(sustainSpr, @:privateAccess sustainSpr.__rect);
|
sustainDraggable = UIState.state.isOverlapping(sustainSpr, @:privateAccess sustainSpr.__rect);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -85,7 +85,7 @@ class CharterStrumline extends UISprite {
|
|||||||
healthIcons.follow(this, ((40 * 4) - healthIcons.width) / 2, 7 + (__healthYOffset = FlxMath.lerp(__healthYOffset, draggable ? 8 : 0, 1/20)));
|
healthIcons.follow(this, ((40 * 4) - healthIcons.width) / 2, 7 + (__healthYOffset = FlxMath.lerp(__healthYOffset, draggable ? 8 : 0, 1/20)));
|
||||||
|
|
||||||
draggingSprite.selectable = draggable;
|
draggingSprite.selectable = draggable;
|
||||||
UIState.state.updateSpriteRect(draggingSprite);
|
draggingSprite.updateSpriteRect();
|
||||||
|
|
||||||
var dragScale:Float = FlxMath.lerp(draggingSprite.scale.x, draggable ? 1 : 0.8, 1/16);
|
var dragScale:Float = FlxMath.lerp(draggingSprite.scale.x, draggable ? 1 : 0.8, 1/16);
|
||||||
draggingSprite.scale.set(dragScale, dragScale);
|
draggingSprite.scale.set(dragScale, dragScale);
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ class CharterStrumlineButton extends UISprite {
|
|||||||
|
|
||||||
super.update(elapsed);
|
super.update(elapsed);
|
||||||
|
|
||||||
UIState.state.updateSpriteRect(button);
|
button.updateSpriteRect();
|
||||||
if(UIState.state.curContextMenu == null && UIState.state.isOverlapping(button, button.__rect)) {
|
if(UIState.state.curContextMenu == null && UIState.state.isOverlapping(button, button.__rect)) {
|
||||||
buttonScale.set(0.95, 0.95);
|
buttonScale.set(0.95, 0.95);
|
||||||
if (FlxG.mouse.justPressed && onClick != null) {
|
if (FlxG.mouse.justPressed && onClick != null) {
|
||||||
|
|||||||
@@ -45,6 +45,11 @@ class UISliceSprite extends UISprite {
|
|||||||
var bottom:FlxFrame = null;
|
var bottom:FlxFrame = null;
|
||||||
var bottomright:FlxFrame = null;
|
var bottomright:FlxFrame = null;
|
||||||
|
|
||||||
|
public var topHeight:Int = 0;
|
||||||
|
public var bottomHeight:Int = 0;
|
||||||
|
public var leftWidth:Int = 0;
|
||||||
|
public var rightWidth:Int = 0;
|
||||||
|
|
||||||
override function set_frames(val) {
|
override function set_frames(val) {
|
||||||
super.set_frames(val);
|
super.set_frames(val);
|
||||||
calculateFrames();
|
calculateFrames();
|
||||||
@@ -70,6 +75,11 @@ class UISliceSprite extends UISprite {
|
|||||||
bottomleft = frames.frames[framesOffset + 6];
|
bottomleft = frames.frames[framesOffset + 6];
|
||||||
bottom = frames.frames[framesOffset + 7];
|
bottom = frames.frames[framesOffset + 7];
|
||||||
bottomright = frames.frames[framesOffset + 8];
|
bottomright = frames.frames[framesOffset + 8];
|
||||||
|
|
||||||
|
leftWidth = Std.int(Math.max(topleft.frame.width, Math.max(middleleft.frame.width, bottomleft.frame.width)));
|
||||||
|
rightWidth = Std.int(Math.max(topright.frame.width, Math.max(middleright.frame.width, bottomright.frame.width)));
|
||||||
|
topHeight = Std.int(Math.max(topleft.frame.height, Math.max(top.frame.height, topright.frame.height)));
|
||||||
|
bottomHeight = Std.int(Math.max(topleft.frame.height, Math.max(top.frame.height, topright.frame.height)));
|
||||||
}
|
}
|
||||||
|
|
||||||
public override function draw() @:privateAccess {
|
public override function draw() @:privateAccess {
|
||||||
|
|||||||
@@ -55,7 +55,8 @@ class UISprite extends FlxSprite {
|
|||||||
FlxCamera._defaultCameras = cameras;
|
FlxCamera._defaultCameras = cameras;
|
||||||
|
|
||||||
for(m in members)
|
for(m in members)
|
||||||
m.update(elapsed);
|
if(m.exists && m.active)
|
||||||
|
m.update(elapsed);
|
||||||
|
|
||||||
FlxCamera._defaultCameras = __oldDefCams;
|
FlxCamera._defaultCameras = __oldDefCams;
|
||||||
}
|
}
|
||||||
@@ -114,4 +115,11 @@ class UISprite extends FlxSprite {
|
|||||||
if (hoverCallback != null)
|
if (hoverCallback != null)
|
||||||
hoverCallback();
|
hoverCallback();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function updateSpriteRect() {
|
||||||
|
__rect.x = x;
|
||||||
|
__rect.y = y;
|
||||||
|
__rect.width = width;
|
||||||
|
__rect.height = height;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -59,28 +59,15 @@ class UIState extends MusicBeatState {
|
|||||||
currentFocus.onTextEdit(str, start, end);
|
currentFocus.onTextEdit(str, start, end);
|
||||||
}
|
}
|
||||||
|
|
||||||
public inline function updateSpriteRect(spr:UISprite) {
|
|
||||||
spr.__rect.x = spr.x;
|
|
||||||
spr.__rect.y = spr.y;
|
|
||||||
spr.__rect.width = spr.width;
|
|
||||||
spr.__rect.height = spr.height;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function updateButtonHandler(spr:UISprite, buttonHandler:Void->Void) {
|
public function updateButtonHandler(spr:UISprite, buttonHandler:Void->Void) {
|
||||||
spr.__rect.x = spr.x;
|
spr.updateSpriteRect();
|
||||||
spr.__rect.y = spr.y;
|
|
||||||
spr.__rect.width = spr.width;
|
|
||||||
spr.__rect.height = spr.height;
|
|
||||||
updateRectButtonHandler(spr, spr.__rect, buttonHandler);
|
updateRectButtonHandler(spr, spr.__rect, buttonHandler);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function isOverlapping(spr:UISprite, rect:FlxRect) {
|
public function isOverlapping(spr:UISprite, rect:FlxRect) {
|
||||||
for(camera in spr.__lastDrawCameras) {
|
for(camera in spr.__lastDrawCameras) {
|
||||||
var pos = FlxG.mouse.getScreenPosition(camera, FlxPoint.get());
|
var pos = FlxG.mouse.getScreenPosition(camera, FlxPoint.get());
|
||||||
__rect.x = rect.x;
|
__rect.copyFrom(rect);
|
||||||
__rect.y = rect.y;
|
|
||||||
__rect.width = rect.width;
|
|
||||||
__rect.height = rect.height;
|
|
||||||
|
|
||||||
__rect.x -= camera.scroll.x * spr.scrollFactor.x;
|
__rect.x -= camera.scroll.x * spr.scrollFactor.x;
|
||||||
__rect.y -= camera.scroll.y * spr.scrollFactor.y;
|
__rect.y -= camera.scroll.y * spr.scrollFactor.y;
|
||||||
|
|||||||
@@ -18,19 +18,28 @@ class UIWindow extends UISliceSprite {
|
|||||||
public override function update(elapsed:Float) {
|
public override function update(elapsed:Float) {
|
||||||
super.update(elapsed);
|
super.update(elapsed);
|
||||||
|
|
||||||
if(collapsable && FlxG.mouse.justPressed) {
|
cursor = ARROW;
|
||||||
// TOOLBAR
|
|
||||||
|
if(collapsable) {
|
||||||
__rect.x = x; __rect.y = y;
|
__rect.x = x; __rect.y = y;
|
||||||
__rect.width = bWidth; __rect.height = 23;
|
__rect.width = bWidth; __rect.height = topHeight;
|
||||||
|
|
||||||
if(UIState.state.isOverlapping(this, __rect)) {
|
if(UIState.state.isOverlapping(this, __rect)) {
|
||||||
content.exists = !content.exists;
|
cursor = BUTTON;
|
||||||
drawMiddle = !drawMiddle;
|
if(FlxG.mouse.justPressed) {
|
||||||
drawBottom = !drawBottom;
|
content.exists = !content.exists;
|
||||||
|
drawMiddle = !drawMiddle;
|
||||||
|
drawBottom = !drawBottom;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
__rect.x = x; __rect.y = y+23;
|
__rect.x = x;
|
||||||
__rect.width = bWidth; __rect.height = bHeight-23;
|
__rect.width = bWidth;
|
||||||
|
if(content.exists) {
|
||||||
|
__rect.y = y+topHeight;
|
||||||
|
__rect.height = bHeight-topHeight;
|
||||||
|
}
|
||||||
hovered = UIState.state.isOverlapping(this, __rect);
|
hovered = UIState.state.isOverlapping(this, __rect);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user