Exemplo n.º 1
0
 public DebugView(FreelancerGame game)
 {
     this.game               = game;
     igrender                = new ImGuiHelper(game, 1f);
     igrender.SetCursor      = false;
     igrender.HandleKeyboard = false;
 }
Exemplo n.º 2
0
 public UiData(FreelancerGame game)
 {
     ResourceManager = game.ResourceManager;
     FileSystem      = game.GameData.VFS;
     Infocards       = game.GameData.Ini.Infocards;
     Fonts           = game.Fonts;
     NavbarIcons     = game.GameData.GetBaseNavbarIcons();
     Sounds          = game.Sound;
     DataPath        = game.GameData.Ini.Freelancer.DataPath;
     if (game.GameData.Ini.Navmap != null)
     {
         NavmapIcons = new IniNavmapIcons(game.GameData.Ini.Navmap);
     }
     else
     {
         NavmapIcons = new NavmapIcons();
     }
     if (!string.IsNullOrWhiteSpace(game.GameData.Ini.Freelancer.XInterfacePath))
     {
         OpenFolder(game.GameData.Ini.Freelancer.XInterfacePath);
     }
     else
     {
         OpenDefault();
     }
 }
Exemplo n.º 3
0
        static Exception StartGame(GameConfig config)
        {
#if !DEBUG
            try
            {
#endif
            var game = new FreelancerGame(config);
            game.Run();

            return(null);

#if !DEBUG
        }

        catch (Exception ex)
        {
            // no point in trying to recover from unrecoverable state
            //game.Crashed();
            Console.Out.WriteLine("Unhandled {0}: ", ex.GetType().Name);
            Console.Out.WriteLine(ex.Message);
            Console.Out.WriteLine(ex.StackTrace);
            return(ex);
        }
#endif
        }
 public void Update(FreelancerGame game)
 {
     ViewportWidth  = game.Width;
     ViewportHeight = game.Height;
     Update(baseWidget, TimeSpan.FromSeconds(game.TotalTime),
            game.Mouse.X, game.Mouse.Y, game.Mouse.IsButtonDown(MouseButtons.Left));
 }
Exemplo n.º 5
0
 public InfocardDisplay(FreelancerGame g, Rectangle rect, params Infocard[] card)
 {
     infocards = card;
     rectangle = rect;
     renderer  = g.Renderer2D;
     fnts      = g.Fonts;
     UpdateLayout();
 }
Exemplo n.º 6
0
 public UiContext(FreelancerGame game)
 {
     RenderContext         = game.RenderContext;
     Data                  = new UiData(game);
     this.game             = game;
     game.Mouse.MouseDown += MouseOnMouseDown;
     game.Mouse.MouseUp   += MouseOnMouseUp;
     CommandBuffer         = new CommandBuffer();
 }
Exemplo n.º 7
0
        public UiContext(FreelancerGame game, string file)
        {
            Renderer2D            = game.Renderer2D;
            RenderState           = game.RenderState;
            Data                  = new UiData(game);
            this.game             = game;
            game.Mouse.MouseDown += MouseOnMouseDown;
            game.Mouse.MouseUp   += MouseOnMouseUp;
            var w = Data.LoadXml(file);

            w.ApplyStylesheet(Data.Stylesheet);
            SetWidget(w);
        }
        public static void Main(string[] args)
        {
            FreelancerGame flgame = null;

            AppHandler.Run(() =>
            {
                Func <string> filePath = null;
                if (args.Length > 0)
                {
                    filePath = () => args[0];
                }
                var cfg = GameConfig.Create(true, filePath);
                flgame  = new FreelancerGame(cfg);
                flgame.Run();
            }, () => flgame.Crashed());
        }
Exemplo n.º 9
0
        public static void Main(string[] args)
        {
            if (Platform.RunningOS == OS.Windows)
            {
                string bindir   = Path.GetDirectoryName(typeof(MainClass).Assembly.Location);
                var    fullpath = Path.Combine(bindir, IntPtr.Size == 8 ? "x64" : "x86");
                SetDllDirectory(fullpath);
            }
            if (!Platform.CheckDependencies())
            {
                return;
            }
            FreelancerGame flgame = null;

#if !DEBUG
            var domain = AppDomain.CurrentDomain;
            domain.UnhandledException += (object sender, UnhandledExceptionEventArgs e) => {
                var ex = (Exception)(e.ExceptionObject);
                CrashWindow.Run("Uh-oh!", "Librelancer has crashed. See the log for more information.",
                                ex.Message + "\n" + ex.StackTrace);
            };
            try {
#endif
            Func <string> filePath = null;
            if (args.Length > 0)
            {
                filePath = () => args[0];
            }
            var cfg = GameConfig.Create(true, filePath);
            flgame = new FreelancerGame(cfg);
            flgame.Run();
#if !DEBUG
        }

        catch (Exception ex)
        {
            try { flgame.Crashed(); } catch { }
            CrashWindow.Run("Uh-oh!", "Librelancer has crashed. See the log for more information.", ex.Message + "\n" + ex.StackTrace);
        }
#endif
        }
 public UiContext(FreelancerGame game)
 {
     Renderer2D      = game.Renderer2D;
     RenderState     = game.RenderState;
     ResourceManager = game.ResourceManager;
     FileSystem      = game.GameData.VFS;
     Infocards       = game.GameData.Ini.Infocards;
     Fonts           = game.Fonts;
     NavbarIcons     = game.GameData.GetBaseNavbarIcons();
     Sounds          = game.Sound;
     DataPath        = game.GameData.Ini.Freelancer.DataPath;
     if (!string.IsNullOrWhiteSpace(game.GameData.Ini.Freelancer.XInterfacePath))
     {
         OpenFolder(game.GameData.Ini.Freelancer.XInterfacePath);
     }
     else
     {
         OpenDefault();
     }
     this.game             = game;
     game.Mouse.MouseDown += MouseOnMouseDown;
     game.Mouse.MouseUp   += MouseOnMouseUp;
 }
Exemplo n.º 11
0
        public MainState(FreelancerGame game) : base(game)
        {
            manager = new UIManager(game);
            uiFont  = game.Fonts.GetSystemFont("Arial");
            //Construct Menu
            menuBackground           = new PanelElement2D(manager);
            menuBackground.FillColor = new Color4(0, 0, 0, 0.25f);
            manager.Elements.Add(menuBackground);
            var btnOpen = new ButtonElement2D(manager, uiFont)
            {
                Label = "Open"
            };

            btnOpen.AutoSize(Game.Renderer2D);
            btnOpen.Position2D    = new Vector2(10, 10);
            btnOpen.Clicked      += OpenFxDialog;
            menuBackground.Height = 20 + btnOpen.Height;
            manager.Elements.Add(btnOpen);

            var btnRefresh = new ButtonElement2D(manager, uiFont)
            {
                Label = "Refresh"
            };

            btnRefresh.AutoSize(Game.Renderer2D);
            btnRefresh.Position2D = new Vector2(10 + btnOpen.Position2D.X + btnOpen.Width, 10);
            btnRefresh.Clicked   += () => {
                if (currentOpen != null)
                {
                    DoOpenFx(currentOpen);
                }
            };
            manager.Elements.Add(btnRefresh);

            var btnOptions = new ButtonElement2D(manager, uiFont)
            {
                Label = "Options"
            };

            btnOptions.AutoSize(Game.Renderer2D);
            btnOptions.Position2D = new Vector2(10 + btnRefresh.Position2D.X + btnRefresh.Width, 10);
            btnOptions.Clicked   += OptionsDialog;
            manager.Elements.Add(btnOptions);

            var btnExit = new ButtonElement2D(manager, uiFont)
            {
                Label = "Exit"
            };

            btnExit.AutoSize(Game.Renderer2D);
            btnExit.Position2D = new Vector2(10 + btnOptions.Position2D.X + btnOptions.Width, 10);
            btnExit.Clicked   += () => MessageDialog("Are you sure you want to exit?", Game.Exit);
            manager.Elements.Add(btnExit);

            zoomSlider = new SliderElement2D(manager, uiFont)
            {
                Label = "Zoom:"
            };
            zoomSlider.AutoSize(Game.Renderer2D);
            zoomSlider.Position2D = new Vector2(10 + btnExit.Position2D.X + btnExit.Width, 10);
            manager.Elements.Add(zoomSlider);

            //Setup input and rendering
            Game.Keyboard.TextInput += Keyboard_TextInput;
            Game.Keyboard.KeyDown   += Keyboard_KeyDown;
            cam                = new ChaseCamera(Game.Viewport);
            renderer           = new SystemRenderer(cam, Game.GameData, Game.ResourceManager);
            renderer.NullColor = new Color4(0.1072961f, 0.1587983f, 0.1845494f, 1);
        }