1
0
mirror of https://github.com/Melon-Bread/Pet.GB synced 2024-11-28 13:58:20 -05:00
Pet.GB/source/InfoMenu.hx
Rain Clark 94e90430d4 Info menu not works ℹ️
Pauses rest of game when open
2016-10-07 06:01:39 -04:00

83 lines
2.3 KiB
Haxe

package;
import flixel.FlxG;
import flixel.FlxSprite;
import flixel.group.FlxGroup;
import flixel.text.FlxText;
import flixel.util.FlxColor;
class InfoMenu extends FlxTypedGroup<FlxSprite>
{
private var _sprBackground:FlxSprite;
private var _txtTitle:FlxText;
private var _txtAGE:FlxText;
private var _txtINT:FlxText;
private var _txtHAP:FlxText;
private var _txtDIS:FlxText;
private var _txtFooter:FlxText;
private var _gel:Gel;
public function new(gel:Gel)
{
super();
_gel = gel;
_sprBackground = new FlxSprite(9, 9, AssetPaths.Menu__png);
add(_sprBackground);
_txtTitle = new FlxText((_sprBackground.x + 11), (_sprBackground.y + 2), 0, "Gel Info", 16);
_txtTitle.setFormat(AssetPaths.EarlyGameBoy__ttf, 16, FlxColor.fromRGB(8, 24, 32, 0), CENTER);
add(_txtTitle);
// Content
_txtAGE = new FlxText((_txtTitle.x + 7), (_sprBackground.y + 33), 0 , "Age: " + _gel.Age + " Days");
_txtAGE.setFormat(AssetPaths.EarlyGameBoy__ttf, 8, FlxColor.fromRGB(8, 24, 32, 0), CENTER);
add(_txtAGE);
_txtINT = new FlxText(_txtAGE.x, (_txtAGE.y + _txtAGE.height + 1), 0, "Int: " + _gel.Intellect + " Pts");
_txtINT.setFormat(AssetPaths.EarlyGameBoy__ttf, 8, FlxColor.fromRGB(8, 24, 32, 0), CENTER);
add (_txtINT);
_txtHAP = new FlxText(_txtINT.x, (_txtINT.y + _txtINT.height + 1), 0, "HAP: " + _gel.Happiness + " Pct");
_txtHAP.setFormat(AssetPaths.EarlyGameBoy__ttf, 8, FlxColor.fromRGB(8, 24, 32, 0), CENTER);
add (_txtHAP);
_txtDIS = new FlxText(_txtHAP.x, (_txtHAP.y + _txtHAP.height + 1), 0, "DIS: " + _gel.Discipline + " Pct");
_txtDIS.setFormat(AssetPaths.EarlyGameBoy__ttf, 8, FlxColor.fromRGB(8, 24, 32, 0), CENTER);
add (_txtDIS);
// Footer
_txtFooter = new FlxText((_sprBackground.x + 12), (_sprBackground.height - 12), 0, "Press B To Close", 8);
_txtFooter.setFormat(AssetPaths.EarlyGameBoy__ttf, 8, FlxColor.fromRGB(8, 24, 32, 0), CENTER);
add(_txtFooter);
active = false;
visible = false;
}
public function OpenMenu():Void
{
//_sprBackground.drawFrame();
visible = true;
active = true;
}
override public function update(elapsed:Float):Void
{
super.update(elapsed);
// TODO: When B is pressed fade this menu out
if (FlxG.keys.pressed.Z || FlxG.gamepads.anyJustPressed(B))
closeMenu();
}
private function closeMenu():Void
{
active = false;
visible = false;
}
}