diff --git a/assets/images/ui/sticker-menu/back-arrow-but-smaller-for-present-art.png b/assets/images/ui/sticker-menu/back-arrow-but-smaller-for-present-art.png new file mode 100644 index 00000000..8eec1e67 Binary files /dev/null and b/assets/images/ui/sticker-menu/back-arrow-but-smaller-for-present-art.png differ diff --git a/source/entities/Minigame.hx b/source/entities/Minigame.hx index be055d2b..da4224da 100644 --- a/source/entities/Minigame.hx +++ b/source/entities/Minigame.hx @@ -38,7 +38,7 @@ class Minigame extends Interactable { super.update(elapsed); - if (ready_to_play && Ctrl.interact[1]) + if (ready_to_play && (Ctrl.interact[1] || FlxG.mouse.overlaps(this) && FlxG.mouse.justReleased)) { start_minigame(); } diff --git a/source/entities/NPC.hx b/source/entities/NPC.hx index 5c348718..f2d6b3c7 100644 --- a/source/entities/NPC.hx +++ b/source/entities/NPC.hx @@ -40,7 +40,7 @@ class NPC extends Interactable sprite_anim.anim(PresentAnimation.IDLE); case NEARBY: sprite_anim.anim(PresentAnimation.NEARBY); - if (Ctrl.jinteract[1]) + if (Ctrl.jinteract[1] || FlxG.mouse.overlaps(this) && FlxG.mouse.justReleased) start_chat(); case CHATTING: sprite_anim.anim(PresentAnimation.IDLE); diff --git a/source/entities/Player.hx b/source/entities/Player.hx index 146366a4..1c99e948 100644 --- a/source/entities/Player.hx +++ b/source/entities/Player.hx @@ -192,7 +192,7 @@ class Player extends BaseUser { if (active_activity_area == null) return; - if (Ctrl.interact[1]) + if (Ctrl.interact[1] || FlxG.mouse.overlaps(active_activity_area) && FlxG.mouse.justReleased) { active_activity_area.on_interact(this); } @@ -243,7 +243,7 @@ class Player extends BaseUser closest.marked = true; active_interactable = closest; - if (Ctrl.jinteract[1]) + if (Ctrl.jinteract[1] || FlxG.mouse.overlaps(this) && FlxG.mouse.justReleased) { active_interactable.on_interact(); } diff --git a/source/states/substates/ArtSubstate.hx b/source/states/substates/ArtSubstate.hx index 4547b37d..a46a6d2f 100644 --- a/source/states/substates/ArtSubstate.hx +++ b/source/states/substates/ArtSubstate.hx @@ -2,6 +2,8 @@ package states.substates; import data.JsonData; import entities.Present; +import flixel.tweens.FlxEase; +import ui.button.HoverButton; class ArtSubstate extends flixel.FlxSubState { @@ -9,6 +11,8 @@ class ArtSubstate extends flixel.FlxSubState var data:data.types.TankmasDefs.PresentDef; var theText:FlxText; + var back_button:HoverButton; + override public function new(content:String) { super(); @@ -37,9 +41,24 @@ class ArtSubstate extends flixel.FlxSubState theText.setFormat(null, 32, FlxColor.WHITE, CENTER, OUTLINE, FlxColor.BLACK); add(theText); + add(back_button = new HoverButton((b) -> back_button_activated())); + + back_button.scrollFactor.set(0, 0); + + back_button.loadAllFromAnimationSet("back-arrow-but-smaller-for-present-art"); + back_button.setPosition(FlxG.width - back_button.width - 16, FlxG.height - back_button.height - 16); + back_button.offset.y = -back_button.height; + back_button.tween = FlxTween.tween(back_button.offset, {y: 0}, 0.25, {ease: FlxEase.cubeInOut}); + + back_button.on_neutral = (b) -> b.alpha = 0.35; + back_button.on_hover = (b) -> b.alpha = 0.75; + members.for_all_members((member:flixel.FlxBasic) -> cast(member, FlxObject).scrollFactor.set(0, 0)); } + function back_button_activated() + close(); + override function update(elapsed:Float) { super.update(elapsed); @@ -54,7 +73,7 @@ class ArtSubstate extends flixel.FlxSubState art.x += 5; if (Ctrl.menuConfirm[1]) close(); - if (FlxG.mouse.justPressed && FlxG.mouse.overlaps(theText)) + if (FlxG.mouse.justPressed && FlxG.mouse.overlaps(theText) && !FlxG.mouse.overlaps(back_button)) FlxG.openURL(data.link != null ? data.link : 'https://${data.artist.toLowerCase()}.newgrounds.com'); } } diff --git a/source/ui/DialogueBox.hx b/source/ui/DialogueBox.hx index 5de1f1de..8c0cedd2 100644 --- a/source/ui/DialogueBox.hx +++ b/source/ui/DialogueBox.hx @@ -142,7 +142,7 @@ class DialogueBox extends FlxTypedGroupExt FlxTween.tween(bg, {y: -bg.height}, 0.15, {ease: FlxEase.quadIn, onComplete: (t:FlxTween) -> next_dlg()}); sstate(WAIT); case TYPING: - if (Ctrl.interact[1]) + if (Ctrl.interact[1] || FlxG.mouse.justPressed) type_index = dlg.text.str.length - 1; if (ttick() % type_rate == 0) type(); diff --git a/source/ui/button/HoverButton.hx b/source/ui/button/HoverButton.hx index 89698a50..0eff8ca2 100644 --- a/source/ui/button/HoverButton.hx +++ b/source/ui/button/HoverButton.hx @@ -5,6 +5,8 @@ import flixel.system.FlxAssets.FlxGraphicAsset; class HoverButton extends FlxSpriteExt { public var on_release:HoverButton->Void; + public var on_hover:HoverButton->Void; + public var on_neutral:HoverButton->Void; var enabled:Bool = true; @@ -16,15 +18,22 @@ class HoverButton extends FlxSpriteExt override function update(elapsed:Float) { - var overlapping:Bool = FlxG.mouse.overlaps(this) && enabled; - var overlap_scale:Float = overlapping ? 1.1 : 1; + var hovering:Bool = FlxG.mouse.overlaps(this) && enabled; + var hover_scale:Float = hovering ? 1.1 : 1; - if (FlxG.mouse.pressed && overlapping) - overlap_scale = 1.35; + if (hovering) + if (on_hover != null) + on_hover(this); + if (!hovering) + if (on_neutral != null) + on_neutral(this); - scale.set(overlap_scale, overlap_scale); + if (FlxG.mouse.pressed && hovering) + hover_scale = 1.35; - if (overlapping && FlxG.mouse.justReleased) + scale.set(hover_scale, hover_scale); + + if (hovering && FlxG.mouse.justReleased) if (on_release != null) on_release(this);