示例#1
0
 public LoadingScreen(FreelancerGame game, IEnumerator <object> loader)
 {
     this.game   = game;
     this.loader = loader;
     manager     = new XmlUIManager(game, "game", null, game.GameData.GetInterfaceXml("loading"));
     manager.OnConstruct();
 }
示例#2
0
 public XmlUIServerList(XInt.ServerList sl, XInt.Style style, XmlUIManager manager) : base(style, manager, false)
 {
     Positioning = sl;
     ID          = sl.ID;
     Lua         = new ServerListAPI(this);
     grid        = new GridControl(manager, dividerPositions, columnTitles, GetGridRect, new ServerListContent(this), NUM_ROWS);
 }
示例#3
0
 public XmlUIPanel(XInt.Style style, XmlUIManager manager, bool setLua = true) : base(manager)
 {
     if (setLua)
     {
         Lua = new PanelAPI(this);
     }
     Style = style;
     if (style.Models != null)
     {
         foreach (var model in style.Models)
         {
             var res = new ModelInfo();
             res.Drawable = Manager.Game.ResourceManager.GetDrawable(
                 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));
         }
     }
 }
示例#4
0
 public static void DrawShadowedText(XmlUIManager m, Font font, float size, string text, float x, float y, Color4 c, Color4?s)
 {
     if (s != null)
     {
         m.Game.Renderer2D.DrawString(font, size, text, x + 2, y + 2, s.Value);
     }
     m.Game.Renderer2D.DrawString(font, size, text, x, y, c);
 }
示例#5
0
        public static void DrawTextCentered(XmlUIManager m, Font font, float sz, string text, Rectangle rect, Color4 c, Color4?s)
        {
            var size = m.Game.Renderer2D.MeasureString(font, sz, text);
            var pos  = new Vector2(
                rect.X + (rect.Width / 2f - size.X / 2),
                rect.Y + (rect.Height / 2f - size.Y / 2)
                );

            DrawShadowedText(m, font, sz, text, pos.X, pos.Y, c, s);
        }
示例#6
0
 public XmlChatBox(XInt.ChatBox chat, XInt.Style style, XmlUIManager man) : base(style, man)
 {
     Positioning = chat;
     ID          = chat.ID;
     ChatBox     = chat;
     Lua         = new LuaChatBox(this);
     renderText  = false;
     font        = man.Game.Fonts.GetSystemFont("Arial Unicode MS");
     boldFont    = man.Game.Fonts.GetSystemFont("Arial Unicode MS", FontStyles.Bold);
     elem        = Texts.Where((x) => x.ID == chat.DisplayArea).First();
     Visible     = false;
 }
示例#7
0
        public void Draw(XmlUIManager manager, Rectangle r)
        {
            if (_font == null)
            {
                _font = manager.GetFont(Style.Font);
            }
            var s = Text;

            if (!string.IsNullOrEmpty(s))
            {
                var textR = GetRectangle(r);
                if (Style.Background != null)
                {
                    manager.Game.Renderer2D.FillRectangle(textR, Style.Background.Value);
                }
                if (Style.Lines > 0)
                {
                    var tSize = (int)GetTextSize(textR.Height / (float)Style.Lines);
                    int a;
                    int dY      = 0;
                    var wrapped = string.Join("\n", TextUtils.WrapText(
                                                  manager.Game.Renderer2D,
                                                  _font,
                                                  tSize,
                                                  s,
                                                  textR.Width - 2,
                                                  0,
                                                  out a,
                                                  ref dY));
                    DrawShadowedText(manager, _font, tSize, wrapped, textR.X, textR.Y, ColorOverride ?? Style.Color, Style.Shadow);
                }
                else if (Style.Align == XInt.Align.Baseline)
                {
                    var sz   = GetTextSize(textR.Height);
                    var size = manager.Game.Renderer2D.MeasureString(_font, sz, s);
                    var pos  = new Vector2(
                        textR.X + (textR.Width / 2f - size.X / 2),
                        textR.Y + (textR.Height / 2f - _font.LineHeight(sz) / 2)
                        );
                    if (Style.Shadow != null)
                    {
                        manager.Game.Renderer2D.DrawStringBaseline(_font, sz, s, pos.X + 2, pos.Y + 2, pos.X, Style.Shadow.Value);
                    }
                    manager.Game.Renderer2D.DrawStringBaseline(_font, sz, s, pos.X, pos.Y, pos.X, ColorOverride ?? Style.Color);
                }
                else
                {
                    DrawTextCentered(manager, _font, GetTextSize(textR.Height), s, textR, ColorOverride ?? Style.Color, Style.Shadow);
                }
            }
            ColorOverride = null;
        }
        public XmlUIButton(XmlUIManager manager, XInt.Button button, XInt.Style style) : base(style, manager)
        {
            Button      = button;
            Positioning = button;
            if (Style.HoverStyle != null)
            {
                hoverChunk = LuaStyleEnvironment.L.CompileChunk(
                    style.HoverStyle, "buttonHover", new Neo.IronLua.LuaCompileOptions()
                    );
            }

            ID = button.ID;
        }
示例#9
0
 public GridControl(XmlUIManager manager, 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.manager          = manager;
     for (int i = -1; i < dividerPositions.Length; i++)
     {
         for (int j = 0; j < rowCount; j++)
         {
             children.Add(new GridHitRect(j, i, this));
         }
     }
     headerFont  = manager.Game.Fonts.GetSystemFont("Agency FB");
     contentFont = manager.Game.Fonts.GetSystemFont("Arial Unicode MS");
 }
示例#10
0
        public LuaMenu(FreelancerGame g) : base(g)
        {
            api = new LuaAPI(this);
            ui  = new XmlUIManager(g, "menu", api, g.GameData.GetInterfaceXml("mainmenu"));
            ui.OnConstruct();
            ui.Enter();
            g.GameData.PopulateCursors();
            g.CursorKind = CursorKind.None;
            intro        = g.GameData.GetIntroScene();
            scene        = new Cutscene(intro.Scripts, Game);
            scene.Update(TimeSpan.FromSeconds(1f / 60f)); //Do all the setup events - smoother entrance
            cur = g.ResourceManager.GetCursor("arrow");
            GC.Collect();                                 //crap
            g.Sound.PlayMusic(intro.Music);
#if DEBUG
            g.Keyboard.KeyDown += Keyboard_KeyDown;
#endif
            FadeIn(0.1, 0.3);
        }
示例#11
0
        public LuaMenu(FreelancerGame g) : base(g)
        {
            api = new MenuAPI(this);
            ui  = new XmlUIManager(g, g.GameData.GetInterfaceXml("mainmenu"), new LuaAPI("menu", api),
                                   new LuaAPI("options", new OptionsAPI(this)));
            ui.OnConstruct();
            ui.Enter();
            g.GameData.PopulateCursors();
            g.CursorKind = CursorKind.None;
            intro        = g.GameData.GetIntroScene();
            scene        = new Cutscene(new ThnScriptContext(intro.Scripts), Game.GameData, Game.Viewport, Game);
            scene.Update(TimeSpan.FromSeconds(1f / 60f)); //Do all the setup events - smoother entrance
            FLLog.Info("Thn", "Playing " + intro.ThnName);
            cur = g.ResourceManager.GetCursor("arrow");
            GC.Collect(); //crap
            g.Sound.PlayMusic(intro.Music);
#if DEBUG
            g.Keyboard.KeyDown += Keyboard_KeyDown;
#endif
            FadeIn(0.1, 0.3);
        }
示例#12
0
 public XmlUIScene(XmlUIManager manager)
 {
     Manager = manager;
 }
示例#13
0
 public LuaDom(XmlUIManager manager, XmlUIScene scn)
 {
     this.manager = manager;
     this.scn     = scn;
 }
示例#14
0
 public LuaSound(XmlUIManager manager) => this.manager = manager;
示例#15
0
 public ScriptedHud(object api, bool space, FreelancerGame game)
 {
     UI = new XmlUIManager(game, "game", api, game.GameData.GetInterfaceXml(space ? "hud" : "baseside"));
 }
示例#16
0
 public XmlUIPanel(XInt.Panel pnl, XInt.Style style, XmlUIManager manager) : this(style, manager)
 {
     Positioning = pnl;
     ID          = pnl.ID;
 }
示例#17
0
 public XmlUIImage(XInt.Image img, XmlUIManager manager) : base(manager)
 {
     texture = ImageLib.Generic.FromFile(manager.Game.GameData.ResolveDataPath(img.Path.Substring(2)));
 }
示例#18
0
 public XmlUIElement(XmlUIManager manager)
 {
     this.Manager = manager;
     Lua          = new LuaAPI(this);
 }