public XmlUIServerList(XInt.ServerList sl, XInt.Style style, XmlUIScene scene) : base(style, scene, false) { Positioning = sl; ID = sl.ID; Lua = new ServerListAPI(this); grid = new GridControl(scene, dividerPositions, columnTitles, GetGridRect, new ServerListContent(this), NUM_ROWS); }
public XmlUIPanel(XInt.Style style, XmlUIScene scene, bool setLua = true) : base(scene) { if (setLua) { Lua = new PanelAPI(this); } Style = style; if (style.Models != null) { foreach (var model in style.Models) { var res = new ModelInfo(); res.Drawable = Scene.Manager.Game.ResourceManager.GetDrawable( Scene.Manager.Game.GameData.ResolveDataPath(model.Path.Substring(2)) ); res.Transform = Matrix4.CreateScale(model.Transform[2], model.Transform[3], 1) * Matrix4.CreateTranslation(model.Transform[0], model.Transform[1], 0); if (model.Color != null) { //Dc is modified var l0 = ((Utf.Cmp.ModelFile)res.Drawable).Levels[0]; var vms = l0.Mesh; //Save Mesh material state for (int i = l0.StartMesh; i < l0.StartMesh + l0.MeshCount; i++) { var mat = (BasicMaterial)vms.Meshes[i].Material?.Render; if (mat == null) { continue; } bool found = false; foreach (var m in res.Materials) { if (m.Mat == mat) { found = true; break; } } if (found) { continue; } res.Materials.Add(new ModifiedMaterial() { Mat = mat, Dc = mat.Dc }); } } models.Add(res); } } if (Style.Texts != null) { foreach (var t in Style.Texts) { Texts.Add(new TextElement(t)); } } }
public XmlUITextBox(XInt.TextBox text, XInt.Style style, XmlUIScene scn) : base(style, scn) { Positioning = text; ID = text.ID; TextBox = text; Lua = new LuaTextBox(this); font = scn.Manager.Game.Fonts.GetSystemFont("Arial Unicode MS"); elem = Texts.Where((x) => x.ID == text.DisplayArea).First(); }
public XmlChatBox(XInt.ChatBox chat, XInt.Style style, XmlUIScene scn) : base(style, scn) { Positioning = chat; ID = chat.ID; ChatBox = chat; Lua = new LuaChatBox(this); renderText = false; font = scn.Manager.Game.Fonts.GetSystemFont("Arial Unicode MS"); boldFont = scn.Manager.Game.Fonts.GetSystemFont("Arial Unicode MS", FontStyles.Bold); elem = Texts.Where((x) => x.ID == chat.DisplayArea).First(); Visible = false; }
public XmlUIButton(XmlUIScene scene, XInt.Button button, XInt.Style style) : base(style, scene) { Button = button; Positioning = button; if (Style.HoverStyle != null) { hoverChunk = LuaStyleEnvironment.L.CompileChunk( style.HoverStyle, "buttonHover", new Neo.IronLua.LuaCompileOptions() ); } ID = button.ID; }
public XmlUIPanel(XInt.Panel pnl, XInt.Style style, XmlUIScene scene) : this(style, scene) { Positioning = pnl; ID = pnl.ID; if (pnl.Text != null) { foreach (var t in pnl.Text) { var f = Texts.FirstOrDefault(x => x.ID == t.Item); if (f != null) { f.Text = t.Value; } } } }
public XmlUIButton(XmlUIScene scene, XInt.Button button, XInt.Style style) : base(style, scene) { Button = button; Positioning = button; if (Style.HoverStyle != null) { hoverChunk = LuaStyleEnvironment.L.CompileChunk( style.HoverStyle, "buttonHover", new Neo.IronLua.LuaCompileOptions() ); } if (Texts.Count > 0) { Texts[0].Text = scene.Manager.GetString(button.Strid, button.InfocardId, button.Text); Texts[0].ColorOverride = hoverStyle.TextColor; } ID = button.ID; }
public GridControl(XmlUIScene scene, float[] dividerPositions, string[] columnTitles, Func <Rectangle> getRect, IGridContent content, int rowCount) { this.dividerPositions = dividerPositions; this.getRect = getRect; this.rowCount = rowCount; this.content = content; this.columnTitles = columnTitles; this.scene = scene; for (int i = -1; i < dividerPositions.Length; i++) { for (int j = 0; j < rowCount; j++) { children.Add(new GridHitRect(j, i, this)); } } headerFont = scene.Manager.Game.Fonts.GetSystemFont("Agency FB"); contentFont = scene.Manager.Game.Fonts.GetSystemFont("Arial Unicode MS"); }
public XmlUIPanel(XInt.Panel pnl, XInt.Style style, XmlUIScene scene) : this(style, scene) { Positioning = pnl; ID = pnl.ID; if (pnl.Text != null) { foreach (var t in pnl.Text) { var f = Texts.FirstOrDefault(x => x.ID == t.Item); if (f != null) { var txt = scene.Manager.GetString(t.Strid, t.InfocardId, t.Value); if (txt != null) { f.Text = txt; } } } } }
public XmlUIImage(XInt.Image img, XmlUIScene scene) : base(scene) { texture = ImageLib.Generic.FromFile(scene.Manager.Game.GameData.ResolveDataPath(img.Path.Substring(2))); }
public LuaDom(XmlUIManager manager, XmlUIScene scn) { this.manager = manager; this.scn = scn; }
void LoadScene(string id) { stackChanged = true; var scene = new XmlUIScene(this); Scenes.Push(scene); scene.lua = new Lua(); scene.env = scene.lua.CreateEnvironment(); scene.env.DoChunk("events = {}", "$internal"); scene.env.Add(apiname, api); scene.env.Add("dom", new LuaDom(this, scene)); scene.env.Add("sound", new LuaSound(this)); LuaStyleEnvironment.RegisterFuncs(scene.env); scene._g = (dynamic)scene.env; var scn = xml.Scenes.Where((x) => x.ID == id).First(); if (scn.Scripts != null) { foreach (var script in scn.Scripts) { scene.env.DoChunk(script, "$xml"); } } foreach (var item in scn.Items) { if (item is XInt.Button) { var btn = (XInt.Button)item; Elements.Add(new XmlUIButton(scene, btn, styles.Where((x) => x.ID == btn.Style).First())); } else if (item is XInt.Image) { Elements.Add(new XmlUIImage((XInt.Image)item, scene)); } else if (item is XInt.ServerList) { var sl = (XInt.ServerList)item; Elements.Add(new XmlUIServerList(sl, styles.Where((x) => x.ID == sl.Style).First(), scene)); } else if (item is XInt.CharacterList) { var cl = (XInt.CharacterList)item; Elements.Add(new XmlUICharacterList(cl, styles.Where(x => x.ID == cl.Style).First(), scene)); } else if (item is XInt.TextBox) { var tx = (XInt.TextBox)item; Elements.Add(new XmlUITextBox(tx, styles.Where((x) => x.ID == tx.Style).First(), scene)); } else if (item is XInt.ChatBox) { var cb = (XInt.ChatBox)item; Elements.Add(new XmlChatBox(cb, styles.Where((x) => x.ID == cb.Style).First(), scene)); } else if (item is XInt.Panel) { var pnl = (XInt.Panel)item; Elements.Add(new XmlUIPanel(pnl, styles.Where((x) => x.ID == pnl.Style).First(), scene)); } } }
void LoadScene(string id) { stackChanged = true; var scene = new XmlUIScene(this); Scenes.Push(scene); scene.lua = new Lua(); scene.env = scene.lua.CreateEnvironment(); scene.env.DoChunk("events = {}", "$internal"); if (apis != null) { foreach (var api in apis) { scene.env.Add(api.ApiName, api.Api); } } scene.env.Add("dom", new LuaDom(this, scene)); scene.env.Add("sound", new LuaSound(this)); LuaStyleEnvironment.RegisterFuncs(scene.env); scene._g = (dynamic)scene.env; var scn = xml.Scenes.Where((x) => x.ID == id).First(); if (scn.Scripts != null) { foreach (var script in scn.Scripts) { try { scene.env.DoChunk(script, "$SCENE:" + scn.ID); } catch (LuaParseException e) { //Better exception message to the console when this crashes throw new Exception(string.Format("Lua Error: {0} at {1}:{2}:{3}", e.Message, e.FileName, e.Line, e.Column)); } } } foreach (var item in scn.Items) { if (item is XInt.Button) { var btn = (XInt.Button)item; Elements.Add(new XmlUIButton(scene, btn, styles.Where((x) => x.ID == btn.Style).First())); } else if (item is XInt.Image) { Elements.Add(new XmlUIImage((XInt.Image)item, scene)); } else if (item is XInt.ServerList) { var sl = (XInt.ServerList)item; Elements.Add(new XmlUIServerList(sl, styles.Where((x) => x.ID == sl.Style).First(), scene)); } else if (item is XInt.CharacterList) { var cl = (XInt.CharacterList)item; Elements.Add(new XmlUICharacterList(cl, styles.Where(x => x.ID == cl.Style).First(), scene)); } else if (item is XInt.TextBox) { var tx = (XInt.TextBox)item; Elements.Add(new XmlUITextBox(tx, styles.Where((x) => x.ID == tx.Style).First(), scene)); } else if (item is XInt.ChatBox) { var cb = (XInt.ChatBox)item; Elements.Add(new XmlChatBox(cb, styles.Where((x) => x.ID == cb.Style).First(), scene)); } else if (item is XInt.Panel) { var pnl = (XInt.Panel)item; Elements.Add(new XmlUIPanel(pnl, styles.Where((x) => x.ID == pnl.Style).First(), scene)); } } }
public XmlUIElement(XmlUIScene scene) { this.Scene = scene; Lua = new LuaAPI(this); }