public static bool Button(string text) { if (currentArea.HasValue) { Rect r = new Rect(currentArea.Value.x, currentArea.Value.y, currentArea.Value.width, GUI.skin.button.fixedHeight); int offset = GUI.skin.button.fixedHeight + GUI.skin.button.margin.bottom; currentArea = new Rect(currentArea.Value.x, currentArea.Value.y + offset, currentArea.Value.width, currentArea.Value.height - offset); return GUI.Button(r, text); } return false; }
public static void BeginArea(Rect rect) { if (!currentArea.HasValue) { currentArea = rect; } else { throw new InvalidOperationException("We already have an area begun"); } }
public static bool Button(Rect rect, string text) { if (isRendering) { bool result = Button(rect, GUI.skin.button.normal.background, GUI.skin.button); Color oldColor = color; if (result) { color = Color.green; } Label(rect, text, GUI.skin.button); color = oldColor; return result; } return false; }
public static bool Button(Rect rect, Texture texture, GUIStyle style) { if (isRendering) { Rectangle r = rect; if (Camera.FullScreen.Bounds.Contains(r)) { spriteBatch.Draw((Texture2D)texture, r, color); } if (Input.GetMouseButtonDown(0) && rect.Contains(Input.mousePositionXna)) { return true; } for (int i = 0; i < Input.touches.Length; i++) { if (Input.touches[i].phase == TouchPhase.Began && rect.Contains(Input.touches[i].cleanPosition)) { return true; } } } return false; }
public static bool Button(Rect rect, Texture texture) { return Button(rect, texture, GUI.skin.button); }
public static string TextField(Rect rect, string m_strLevelName) { //throw new NotImplementedException(); return m_strLevelName; }
public static void Label(Rect rect, string text, GUIStyle style) { if (isRendering) { Rectangle r = rect; if (Camera.FullScreen.Bounds.Contains(r)) { Microsoft.Xna.Framework.Vector2 pos = new Microsoft.Xna.Framework.Vector2(r.Location.X, r.Location.Y); if (style.alignment == TextAnchor.MiddleCenter) { Microsoft.Xna.Framework.Vector2 sz = GUI.spriteFont.MeasureString(text); pos += new Microsoft.Xna.Framework.Vector2(Mathf.Floor((rect.width - sz.X) / 2), Mathf.Floor((rect.height - sz.Y) / 2)); } spriteBatch.DrawString(GUI.spriteFont, text ?? "", pos, color); } } }
public static void Label(Rect rect, string text) { Label(rect, text, GUIStyle.none); }
public static void DrawTexture(Rect rect, Rect source, Vector2 origin, Vector2 size, Texture texture, float rot) { if (isRendering) { Rectangle r = new Rectangle((int)rect.x + (int)(size.x * origin.x), (int)rect.y + (int)(size.y * origin.y), (int)rect.width, (int)rect.height); Rectangle s = source; Vector2 o = new Vector2(texture.width * origin.x, texture.height * origin.y); if (Camera.FullScreen.Bounds.Intersects(r)) { spriteBatch.Draw((Microsoft.Xna.Framework.Graphics.Texture2D)texture, r, s, color, rot, o, SpriteEffects.None, 0.0f); } } }
public static void DrawTexture(Rect rect, Texture texture) { if (isRendering) { Rectangle r = rect; if (Camera.FullScreen.Bounds.Intersects(r)) { spriteBatch.Draw((Microsoft.Xna.Framework.Graphics.Texture2D)texture, r, color); } } }