Skip to content
This repository has been archived by the owner on Jan 26, 2025. It is now read-only.

Commit

Permalink
some more work on ui stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
MaybeMaru committed Dec 12, 2023
1 parent e9b09cb commit 437cb27
Show file tree
Hide file tree
Showing 3 changed files with 83 additions and 15 deletions.
50 changes: 41 additions & 9 deletions source/funkin/objects/funkui/FourSideSprite.hx
Original file line number Diff line number Diff line change
@@ -1,29 +1,61 @@
package funkin.objects.funkui;

enum FourSideStyle {
NONE;
OUTLINE(thickness:Float, ?color:FlxColor);
}

class FourSideSprite extends FlxSprite {
function __quickDraw(spr:FlxSprite, x:Float, y:Float, flipX:Bool, flipY:Bool) {
pixels.fillRect(new Rectangle(x,y,spr.width,spr.height), FlxColor.TRANSPARENT);
static var rect:Rectangle = new Rectangle();
static function getRect(X:Float,Y:Float,W:Float,H:Float) {
rect.setTo(X,Y,W,H);
return rect;
}

function __quickDraw(spr:FlxSprite, x:Float, y:Float, flipX:Bool, flipY:Bool, fill:FlxColor) {
pixels.fillRect(getRect(x,y,spr.width,spr.height), fill);
spr.flipX = flipX;
spr.flipY = flipY;
stamp(spr, Std.int(x), Std.int(y));
}

public function new(X:Float, Y:Float, Width:Int, Height:Int, Color:Int) {
public function new(X:Float, Y:Float, Width:Int, Height:Int, Color:Int, Style:FourSideStyle = NONE) {
super(X,Y);
final key:String = 'foursidesprite::$Width$Height$Color::';

if (FlxG.bitmap.checkCache(key)) {
loadGraphic(FlxG.bitmap.get(key));
}
else {
makeGraphic(Width, Height, Color, false, key);
final side = new FlxSprite("assets/images/ui/round.png");
side.color = Color;
__quickDraw(side, 0, 0, false, false);
__quickDraw(side, width - side.width, 0, true, false);
__quickDraw(side, 0, height - side.height, false, true);
__quickDraw(side, width - side.width, height - side.height, true, true);
switch (Style) {
case NONE:
makeGraphic(Width, Height, Color, false, key);
side.color = Color;
__doDraw(side);

case OUTLINE(thickness, color):
makeGraphic(Width, Height, color, false, key);
side.color = color;
__doDraw(side);

pixels.fillRect(getRect(thickness, thickness, Width - (thickness * 2), Height - (thickness * 2)), Color);
side.color = Color;
__doDraw(side, thickness, color);
}

side.destroy();
}
}

override function draw() {
if (visible) super.draw();
}

private function __doDraw(side:FlxSprite, out:Float = 0.0, fill:FlxColor = FlxColor.TRANSPARENT) {
__quickDraw(side, out, out, false, false, fill);
__quickDraw(side, width - side.width - out, out, true, false, fill);
__quickDraw(side, out, height - side.height - out, false, true, fill);
__quickDraw(side, width - side.width - out, height - side.height - out, true, true, fill);
}
}
40 changes: 39 additions & 1 deletion source/funkin/objects/funkui/FunkDropDown.hx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ class FunkDropDown extends FourSideSprite implements IFunkUIObject {
private var openButton:FourSideSprite;
private var text:FunkUIText;

private var dropContainer:FourSideSprite;
private var dropSelect:FourSideSprite;
private var dropText:FunkUIText;

public function new(?X:Float, ?Y:Float, Width:Int = 125) {
super(X, Y, Width, 25, 0xff2068A3);
ogX = X;
Expand All @@ -22,23 +26,57 @@ class FunkDropDown extends FourSideSprite implements IFunkUIObject {
final arrow = new FlxSprite("assets/images/ui/arrow.png");
openButton.stamp(arrow, Std.int(btnPos + (arrow.width * 0.25)), Std.int(arrow.height * 0.25));
arrow.destroy();

dropSelect = new FourSideSprite(0, 0, Std.int((width * 0.875) - 12), 18, 0xff3559B5);
dropText = new FunkUIText(0, 0, "", Std.int(width * 0.875), FlxG.height, 14);

setList(["Value", "Ass", "Balls", "Fuck", "Puta Vida"]); //
}

public var list(default, null):Array<Dynamic> = [];

public function setList(array:Array<Dynamic>) {
list = array;
dropContainer = new FourSideSprite(0,0, Std.int(width * 0.875), (17*list.length) + 14, 0xff28272E, OUTLINE(2, 0xff535358));
dropText.text = "";
for (i in 0...list.length) {
dropText.text += Std.string(list[i]) + "\n";
}
}

override function update(elapsed:Float) {
super.update(elapsed);

dropSelect.visible = false;
if (FlxG.mouse.overlaps(dropContainer)) {
dropSelect.visible = true;
}
}

public function setUIPosition(X:Float, Y:Float) {
setPosition(X,Y);
text.setPosition(X + 4, Y + 3);
openButton.setPosition(X,Y);
openButton.setPosition(X, Y);
dropContainer.setPosition(X, Y + 28);
dropSelect.setPosition(X + 6, Y + 34);
dropText.setPosition(X + 8, Y + 34);
}

override function draw() {
super.draw();
text.draw();
openButton.draw();
dropContainer.draw();
dropSelect.draw();
dropText.draw();
}

override function destroy() {
super.destroy();
openButton = FlxDestroyUtil.destroy(openButton);
text = FlxDestroyUtil.destroy(text);
dropContainer = FlxDestroyUtil.destroy(dropContainer);
dropSelect = FlxDestroyUtil.destroy(dropSelect);
dropText = FlxDestroyUtil.destroy(dropText);
}
}
8 changes: 3 additions & 5 deletions source/funkin/util/CoolUtil.hx
Original file line number Diff line number Diff line change
Expand Up @@ -243,16 +243,14 @@ class CoolUtil {
if (FlxG.state is MusicBeatState) {
cast(FlxG.state, MusicBeatState).startTransition();
}
//if (FlxG.state is PlayState)
// Conductor.vocals.pause();
}

/*
* RATING UTIL
*/
*/

public static var judgeOffsets:Array<Int> = [127, 106, 43];
public static var returnJudgements:Array<String> = ['shit', 'bad', 'good'];
public static final judgeOffsets:Array<Int> = [127, 106, 43];
public static final returnJudgements:Array<String> = ['shit', 'bad', 'good'];

public static function getNoteJudgement(noteDiff:Float):String {
for (i in 0...judgeOffsets.length) {
Expand Down

0 comments on commit 437cb27

Please sign in to comment.