New button design

This commit is contained in:
NeeEoo
2024-04-16 02:17:11 +02:00
parent 19d6e88e9e
commit 759a124fd0
5 changed files with 52 additions and 23 deletions
+8 -3
View File
@@ -54,6 +54,9 @@ class StageEditor extends UIState {
public var showOutlines:Bool = true;
public var showCharacters:Bool = true;
public static inline var SPRITE_WINDOW_WIDTH:Int = 400;
public static inline var SPRITE_WINDOW_BUTTON_HEIGHT:Int = 64;
public var undos:UndoList<StageChange> = new UndoList<StageChange>();
public inline static function exID(id:String) {
@@ -242,14 +245,16 @@ class StageEditor extends UIState {
topMenuSpr = new UITopMenu(topMenu);
topMenuSpr.cameras = uiGroup.cameras = [uiCamera];
final margin = 22;
final width = 470;
final margin = 0;//22;
final width = SPRITE_WINDOW_WIDTH;
final TOP_MENU_HEIGHT = 25;
var buttonSize:FlxPoint = FlxPoint.get(width-margin*2, 32);
var buttonSize:FlxPoint = FlxPoint.get(width-margin*2, SPRITE_WINDOW_BUTTON_HEIGHT);
stageSpritesWindow = new UIButtonList<StageElementButton>(Std.int(FlxG.width - width), TOP_MENU_HEIGHT, width, Std.int(FlxG.height - TOP_MENU_HEIGHT), "Stage Sprites", buttonSize);
stageSpritesWindow.collapsable = true;
stageSpritesWindow.topAlpha = 0.9;
stageSpritesWindow.middleAlpha = 0.5;
stageSpritesWindow.bottomAlpha = 0.5;
stageSpritesWindow.buttonSpacing = 0;
stageSpritesWindow.addButton.callback = () -> {
// TODO: implement this
}
@@ -13,7 +13,7 @@ class StageCharacterButton extends StageElementButton {
this.char = charPos.extra.get(StageEditor.exID("char"));
super(x,y, xml);
color = 0xffa5c4ff;
color = 0xff7aa8ff;
updateInfo(charPos);
}
@@ -21,14 +21,26 @@ class StageElementButton extends UIButton {
public var selected:Bool = false;
public var tagColor:UISliceSprite;
public function new(x:Float,y:Float, xml:Access) {
this.xml = xml;
super(x,y, getInfoText(), function () {
onSelect();
//CharacterEditor.instance.playAnimation(this.sprite.name);
}, 282);
}, StageEditor.SPRITE_WINDOW_WIDTH, StageEditor.SPRITE_WINDOW_BUTTON_HEIGHT);
autoAlpha = false;
tagColor = new UISliceSprite(x, y, 10, StageEditor.SPRITE_WINDOW_BUTTON_HEIGHT, 'editors/ui/button');
tagColor.alpha = 1; // Make entire sprite transparent
tagColor.selectable = false;
tagColor.active = false;
//members.push(tagColor);
topAlpha = middleAlpha = bottomAlpha = 0.7;
field.alignment = LEFT;
ghostButton = new UIButton(x+282+17, y, "", function () {
onGhostClick();
//CharacterEditor.instance.ghostAnim(this.anim);
@@ -77,6 +89,9 @@ class StageElementButton extends UIButton {
hovered = !deleteButton.hovered;
updatePos();
super.update(elapsed);
field.x += 12;
tagColor.color = color;
if(selected != _lastSelected) {
_lastSelected = selected;
@@ -104,12 +119,23 @@ class StageElementButton extends UIButton {
public function updatePos() {
// buttons
deleteButton.x = (editButton.x = (ghostButton.x = (x+282+17))+32+17)+32+17;
deleteButton.y = editButton.y = ghostButton.y = y;
var spacing = 8;
var buttonY = y + (bHeight - 32) / 2;
deleteButton.x = bWidth - deleteButton.bWidth - spacing;
deleteButton.y = buttonY;
editButton.x = deleteButton.x - editButton.bWidth - spacing;
editButton.y = buttonY;
ghostButton.x = editButton.x - ghostButton.bWidth - spacing;
ghostButton.y = buttonY;
//deleteButton.x = (editButton.x = (ghostButton.x = (x+282+17))+32+17)+32+17;
//deleteButton.y = editButton.y = ghostButton.y = y;
// icons
ghostIcon.x = ghostButton.x + 8; ghostIcon.y = ghostButton.y + 8;
editIcon.x = editButton.x + 8; editIcon.y = editButton.y + 8;
deleteIcon.x = deleteButton.x + (15/2); deleteIcon.y = deleteButton.y + 8;
tagColor.x = x;// + bWidth - tagColor.bWidth;
tagColor.y = y;
}
public function getSprite():FunkinSprite {
@@ -143,6 +169,11 @@ class StageElementButton extends UIButton {
public function getInfoText():String {
var pos = getPos();
var text = '${getName()} (${CoolUtil.quantize(pos.x, 100)}, ${CoolUtil.quantize(pos.y, 100)})';
var sprite = getSprite();
if(sprite != null) {
text += '\nScale: (${CoolUtil.quantize(sprite.scale.x, 100)}, ${CoolUtil.quantize(sprite.scale.y, 100)})';
text += '\nScroll: (${CoolUtil.quantize(sprite.scrollFactor.x, 100)}, ${CoolUtil.quantize(sprite.scrollFactor.y, 100)})';
}
pos.put();
return text;
}
+2 -1
View File
@@ -95,7 +95,8 @@ class UIButtonList<T:UIButton> extends UIWindow {
curMovingInterval = 0;
}
}
addIcon.x = addButton.x + addButton.bWidth / 2 - addIcon.width / 2; addIcon.y = addButton.y + addButton.bHeight / 2 - addIcon.height / 2;
addIcon.x = addButton.x + addButton.bWidth / 2 - addIcon.width / 2;
addIcon.y = addButton.y + addButton.bHeight / 2 - addIcon.height / 2;
}
var nextscrollY:Float = 0;
public override function update(elapsed:Float) {
+7 -15
View File
@@ -31,17 +31,9 @@ class UISliceSprite extends UISprite {
bHeight = h;
}
override function set_alpha(value:Float) {
super.set_alpha(value);
topAlpha = alpha;
middleAlpha = alpha;
bottomAlpha = alpha;
return value;
}
public var topAlpha:Float = 1;
public var middleAlpha:Float = 1;
public var bottomAlpha:Float = 1;
public var topAlpha:Null<Float> = null;
public var middleAlpha:Null<Float> = null;
public var bottomAlpha:Null<Float> = null;
public var drawTop:Bool = true;
public var drawMiddle:Bool = true;
@@ -102,8 +94,8 @@ class UISliceSprite extends UISprite {
var oldAlpha = alpha;
// TOP
if (drawTop) {
super.set_alpha(topAlpha);
// TOP LEFT
if(topAlpha != null) alpha = topAlpha;
frame = topleft;
setPosition(x, y);
__setSize(
@@ -132,7 +124,7 @@ class UISliceSprite extends UISprite {
// MIDDLE
if (drawMiddle && bHeight > top.frame.height + bottom.frame.height) {
super.set_alpha(middleAlpha);
if(middleAlpha != null) alpha = middleAlpha;
var middleHeight:Float = bHeight - (topleft.frame.height * Math.min(bHeight/(topleft.frame.height*2), 1)) -
bottomleft.frame.height * Math.min(bHeight/(bottomleft.frame.height*2), 1);
@@ -159,7 +151,7 @@ class UISliceSprite extends UISprite {
// BOTTOM
if (drawBottom) {
super.set_alpha(bottomAlpha);
if(bottomAlpha != null) alpha = bottomAlpha;
// BOTTOM LEFT
frame = bottomleft;
setPosition(x, y + bHeight - (bottomleft.frame.height * Math.min(bHeight/(bottomleft.frame.height*2), 1)));
@@ -190,7 +182,7 @@ class UISliceSprite extends UISprite {
super.drawSuper();
}
super.set_alpha(oldAlpha);
alpha = oldAlpha;
}
setPosition(x, y);