2019-08-10 21:37:10 +02:00
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Text;
|
|
|
|
using Microsoft.Xna.Framework;
|
|
|
|
using Microsoft.Xna.Framework.Graphics;
|
|
|
|
using MLEM.Font;
|
|
|
|
using MLEM.Textures;
|
|
|
|
|
|
|
|
namespace MLEM.Ui.Style {
|
|
|
|
public class UntexturedStyle : UiStyle {
|
|
|
|
|
|
|
|
public UntexturedStyle(SpriteBatch batch) {
|
2019-08-28 18:27:17 +02:00
|
|
|
this.SelectionIndicator = GenerateTexture(batch, Color.Transparent, Color.Red);
|
2019-08-10 21:37:10 +02:00
|
|
|
this.ButtonTexture = GenerateTexture(batch, Color.CadetBlue);
|
|
|
|
this.ButtonHoveredColor = Color.LightGray;
|
|
|
|
this.PanelTexture = GenerateTexture(batch, Color.Gray);
|
|
|
|
this.TextFieldTexture = GenerateTexture(batch, Color.MediumBlue);
|
|
|
|
this.TextFieldHoveredColor = Color.LightGray;
|
2019-08-12 19:44:16 +02:00
|
|
|
this.ScrollBarBackground = GenerateTexture(batch, Color.LightBlue);
|
|
|
|
this.ScrollBarScrollerTexture = GenerateTexture(batch, Color.Blue);
|
2019-08-13 21:23:20 +02:00
|
|
|
this.CheckboxTexture = GenerateTexture(batch, Color.LightBlue);
|
|
|
|
this.CheckboxHoveredColor = Color.LightGray;
|
|
|
|
this.CheckboxCheckmark = GenerateTexture(batch, Color.Blue).Region;
|
|
|
|
this.RadioTexture = GenerateTexture(batch, Color.AliceBlue);
|
|
|
|
this.RadioHoveredColor = Color.LightGray;
|
|
|
|
this.RadioCheckmark = GenerateTexture(batch, Color.CornflowerBlue).Region;
|
2019-08-13 23:54:29 +02:00
|
|
|
this.TooltipBackground = GenerateTexture(batch, Color.DarkGray);
|
|
|
|
this.TooltipBackgroundColor = new Color(Color.Black, 0.65F);
|
2019-08-10 21:37:10 +02:00
|
|
|
this.Font = new EmptyFont();
|
|
|
|
}
|
|
|
|
|
2019-08-28 18:27:17 +02:00
|
|
|
private static NinePatch GenerateTexture(SpriteBatch batch, Color color, Color? outlineColor = null) {
|
|
|
|
var outli = outlineColor ?? Color.Black;
|
2019-08-10 21:37:10 +02:00
|
|
|
var tex = new Texture2D(batch.GraphicsDevice, 3, 3);
|
|
|
|
tex.SetData(new[] {
|
2019-08-28 18:27:17 +02:00
|
|
|
outli, outli, outli,
|
|
|
|
outli, color, outli,
|
|
|
|
outli, outli, outli
|
2019-08-10 21:37:10 +02:00
|
|
|
});
|
|
|
|
batch.Disposing += (sender, args) => {
|
|
|
|
if (tex != null) {
|
|
|
|
tex.Dispose();
|
|
|
|
tex = null;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
return new NinePatch(tex, 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
private class EmptyFont : IGenericFont {
|
|
|
|
|
2019-08-25 19:07:45 +02:00
|
|
|
public float LineHeight => 1;
|
|
|
|
|
2019-08-10 21:37:10 +02:00
|
|
|
public Vector2 MeasureString(string text) {
|
|
|
|
return Vector2.One;
|
|
|
|
}
|
|
|
|
|
|
|
|
public Vector2 MeasureString(StringBuilder text) {
|
|
|
|
return Vector2.One;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void DrawString(SpriteBatch batch, string text, Vector2 position, Color color) {
|
|
|
|
}
|
|
|
|
|
|
|
|
public void DrawString(SpriteBatch batch, string text, Vector2 position, Color color, float rotation, Vector2 origin, float scale, SpriteEffects effects, float layerDepth) {
|
|
|
|
}
|
|
|
|
|
|
|
|
public void DrawString(SpriteBatch batch, string text, Vector2 position, Color color, float rotation, Vector2 origin, Vector2 scale, SpriteEffects effects, float layerDepth) {
|
|
|
|
}
|
|
|
|
|
|
|
|
public void DrawString(SpriteBatch batch, StringBuilder text, Vector2 position, Color color) {
|
|
|
|
}
|
|
|
|
|
|
|
|
public void DrawString(SpriteBatch batch, StringBuilder text, Vector2 position, Color color, float rotation, Vector2 origin, float scale, SpriteEffects effects, float layerDepth) {
|
|
|
|
}
|
|
|
|
|
|
|
|
public void DrawString(SpriteBatch batch, StringBuilder text, Vector2 position, Color color, float rotation, Vector2 origin, Vector2 scale, SpriteEffects effects, float layerDepth) {
|
|
|
|
}
|
|
|
|
|
|
|
|
public void DrawCenteredString(SpriteBatch batch, string text, Vector2 position, float scale, Color color, bool horizontal = true, bool vertical = false, float addedScale = 0) {
|
|
|
|
}
|
|
|
|
|
2019-08-25 19:07:45 +02:00
|
|
|
public string SplitString(string text, float width, float scale) {
|
|
|
|
return text;
|
2019-08-10 21:37:10 +02:00
|
|
|
}
|
|
|
|
|
2019-09-05 18:15:51 +02:00
|
|
|
public string TruncateString(string text, float width, float scale, bool fromBack = false) {
|
|
|
|
return text;
|
|
|
|
}
|
|
|
|
|
2019-08-10 21:37:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|