2019-09-25 16:39:17 +02:00
|
|
|
using System;
|
2019-11-02 14:21:42 +01:00
|
|
|
using System.Collections.Generic;
|
|
|
|
using Coroutine;
|
2019-09-19 20:23:18 +02:00
|
|
|
using Microsoft.Xna.Framework;
|
|
|
|
using Microsoft.Xna.Framework.Graphics;
|
2019-11-02 14:21:42 +01:00
|
|
|
using Microsoft.Xna.Framework.Input;
|
2019-09-19 20:23:18 +02:00
|
|
|
using MLEM.Cameras;
|
|
|
|
using MLEM.Extended.Extensions;
|
|
|
|
using MLEM.Extended.Tiled;
|
2019-09-20 13:22:05 +02:00
|
|
|
using MLEM.Font;
|
2019-09-25 16:39:17 +02:00
|
|
|
using MLEM.Misc;
|
2019-09-19 20:23:18 +02:00
|
|
|
using MLEM.Startup;
|
2019-09-20 13:22:05 +02:00
|
|
|
using MLEM.Textures;
|
|
|
|
using MLEM.Ui;
|
|
|
|
using MLEM.Ui.Elements;
|
|
|
|
using MLEM.Ui.Style;
|
2019-09-19 20:23:18 +02:00
|
|
|
using MonoGame.Extended.Tiled;
|
|
|
|
|
|
|
|
namespace Sandbox {
|
|
|
|
public class GameImpl : MlemGame {
|
|
|
|
|
|
|
|
public GameImpl() {
|
|
|
|
this.IsMouseVisible = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
protected override void LoadContent() {
|
|
|
|
base.LoadContent();
|
|
|
|
|
2019-09-20 13:22:05 +02:00
|
|
|
var tex = LoadContent<Texture2D>("Textures/Test");
|
|
|
|
this.UiSystem.Style = new UntexturedStyle(this.SpriteBatch) {
|
|
|
|
Font = new GenericSpriteFont(LoadContent<SpriteFont>("Fonts/TestFont")),
|
|
|
|
TextScale = 0.1F,
|
|
|
|
PanelTexture = new NinePatch(new TextureRegion(tex, 0, 8, 24, 24), 8),
|
|
|
|
ButtonTexture = new NinePatch(new TextureRegion(tex, 24, 8, 16, 16), 4)
|
|
|
|
};
|
|
|
|
this.UiSystem.AutoScaleReferenceSize = new Point(1280, 720);
|
|
|
|
this.UiSystem.AutoScaleWithScreen = true;
|
|
|
|
this.UiSystem.GlobalScale = 5;
|
|
|
|
|
2019-11-02 14:21:42 +01:00
|
|
|
var screen = new Panel(Anchor.Center, new Vector2(200, 100), Vector2.Zero, false, true, new Point(5, 10));
|
|
|
|
screen.IsHidden = false;
|
|
|
|
screen.OnUpdated += (element, time) => {
|
|
|
|
if (this.InputHandler.IsKeyPressed(Keys.Escape))
|
|
|
|
CoroutineHandler.Start(PlayAnimation(screen));
|
|
|
|
};
|
|
|
|
this.UiSystem.Add("Screen", screen);
|
2019-09-25 16:39:17 +02:00
|
|
|
|
2019-11-02 14:21:42 +01:00
|
|
|
for (var i = 0; i < 100; i++) {
|
|
|
|
screen.AddChild(new Button(Anchor.AutoLeft, new Vector2(1, 10), i.ToString()));
|
|
|
|
}
|
2019-09-25 16:39:17 +02:00
|
|
|
}
|
|
|
|
|
2019-11-02 14:21:42 +01:00
|
|
|
private static IEnumerator<Wait> PlayAnimation(Panel screen) {
|
|
|
|
var show = screen.IsHidden;
|
|
|
|
screen.IsHidden = false;
|
|
|
|
var time = 0;
|
2019-11-02 14:53:59 +01:00
|
|
|
const float total = 20;
|
2019-11-02 14:21:42 +01:00
|
|
|
while (time <= total) {
|
|
|
|
yield return new WaitEvent(CoroutineEvents.Update);
|
|
|
|
var percent = show ? time / total : 1 - time / total;
|
|
|
|
screen.Root.Scale = percent;
|
|
|
|
time++;
|
|
|
|
}
|
|
|
|
if (!show)
|
|
|
|
screen.IsHidden = true;
|
2019-09-19 20:23:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
protected override void DoDraw(GameTime gameTime) {
|
|
|
|
this.GraphicsDevice.Clear(Color.Black);
|
|
|
|
base.DoDraw(gameTime);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|