示例#1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="FreezingArcher.Messaging.WindowErrorMessage"/> class.
 /// </summary>
 /// <param name="window">Window.</param>
 /// <param name="error">Error.</param>
 /// <param name="message">Message.</param>
 public WindowErrorMessage (Window window, string error, string message)
 {
     Window = window;
     Error = error;
     Message = message;
 }
示例#2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="FreezingArcher.Messaging.WindowResizeMessage"/> class.
 /// </summary>
 /// <param name="window">Window.</param>
 /// <param name="width">Width.</param>
 /// <param name="height">Height.</param>
 public WindowResizeMessage (Window window, int width, int height)
 {
     Window = window;
     Width = width;
     Height = height;
 }
示例#3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="FreezingArcher.Messaging.WindowMoveMessage"/> class.
 /// </summary>
 /// <param name="window">Window.</param>
 /// <param name="x">The x movement.</param>
 /// <param name="y">The y movement.</param>
 public WindowMoveMessage (Window window, int x, int y)
 {
     Window = window;
     X = x;
     Y = y;
 }
示例#4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="FreezingArcher.Messaging.WindowFocusMessage"/> class.
 /// </summary>
 /// <param name="window">Window.</param>
 /// <param name="focus">If set to <c>true</c> the window is focused.</param>
 public WindowFocusMessage (Window window, bool focus)
 {
     Window = window;
     Focus = focus;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="FreezingArcher.Messaging.WindowMouseOverMessage"/> class.
 /// </summary>
 /// <param name="window">Window.</param>
 /// <param name="enter">If set to <c>true</c> mouse entered window.</param>
 public WindowMouseOverMessage (Window window, bool enter)
 {
     Window = window;
     Enter = enter;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="FreezingArcher.Messaging.WindowMinimizeMessage"/> class.
 /// </summary>
 /// <param name="window">Window.</param>
 /// <param name="minimized">If set to <c>true</c> window is minimized.</param>
 public WindowMinimizeMessage (Window window, bool minimized)
 {
     Window = window;
     Minimized = minimized;
 }
示例#7
0
        /// <summary>
        /// Initializes a new instance of the <see cref="FreezingArcher.Core.Application"/> class.
        /// </summary>
        // / <param name="game">The initial root game.</param>
        public Application (string name, string[] args)
        {
            ManagedThreadId = Thread.CurrentThread.ManagedThreadId;

            Name = name;
            Frametime = 5;
            Logger.Initialize (name);
            ObjectManager = new ObjectManager();
            ValidMessages = new[] { (int) MessageId.Input };
            MessageManager = new MessageManager ();
            MessageManager += this;
            ConfigManager.Initialize (MessageManager);
            EntityFactory.Instance = new EntityFactory(ObjectManager);

            CommandLineInterface.Instance.SetHelp ("Freezing Archer 3D game engine/framework", "Alpha 0.0.1",
                "AreonDev", 2015, 'h', "help", true, true, null,
                new string[] {"Authors: David Bögelsack, Fin Christensen, Willy Failla und Martin Koppehel\n"});

            // set fullscreen if overriden by command line.
            CommandLineInterface.Instance.AddOption<bool> (b => {
                if (b)
                    ConfigManager.Instance["freezing_archer"].AddOverride ("general", "fullscreen", new Value (true));
            }, 'f', "fullscreen", "Set window to fullscreen. By default the value from the config file is used.");

            CommandLineInterface.Instance.AddOption<int> (
                i => ConfigManager.Instance ["freezing_archer"].AddOverride ("general", "fullscreen_monitor",
                    new Value (i)), 'm', "fullscreen-monitor",
                "Set the physical monitor the application should use for a fullscreen window.", "INT");

            CommandLineInterface.Instance.AddOption<string> (
                r => ConfigManager.Instance ["freezing_archer"].AddOverride ("general", "resolution", new Value (r)),
                'r', "resolution", "Set the resolution a fullscreen window should have.", "RES", false,
                ConfigManager.Instance["freezing_archer"].GetString ("general", "resolution"));

            CommandLineInterface.Instance.AddOption<string> (
                s => ConfigManager.Instance ["freezing_archer"].AddOverride ("general", "size", new Value (s)),
                's', "size", "Set window size.", "SIZE", false,
                ConfigManager.Instance ["freezing_archer"].GetString ("general", "size"));

            CommandLineInterface.Instance.AddOption<int> (i => {
                if (i > 0)
                {
                    if (i > 8)
                    {
                        Logger.Log.AddLogEntry (LogLevel.Error, "CommandLineInterface", Status.BadArgument,
                            "The given loglevel '{0}' is not valid. Using configuration value...", i);
                        return;
                    }
                    ConfigManager.Instance["freezing_archer"].AddOverride ("general", "loglevel", new Value (i));
                }
            }, 'l', "loglevel", "Set loglevel. If 0 or nothing is given the value from the config file is used.",
                "INT");

            if (!CommandLineInterface.Instance.ParseArguments (args))
            {
                IsCommandLineInterface = true;
                return;
            }

            Logger.Log.SetLogLevel ((LogLevel) ConfigManager.Instance["freezing_archer"]
                .GetInteger ("general", "loglevel"));

            Logger.Log.AddLogEntry (LogLevel.Info, ClassName, "Creating new application '{0}'", name);
            AudioManager = new AudioManager ();
            RendererContext = new RendererContext(MessageManager);
            Localizer.Initialize (MessageManager);

            Logger.Log.AddLogEntry(LogLevel.Warning, ClassName, Status.ZombieApocalypse);

            Window = new Window (
                ParserUtils.ParseVector (
                    ConfigManager.Instance["freezing_archer"].GetString ("general", "size")),
                ParserUtils.ParseVector (
                    ConfigManager.Instance["freezing_archer"].GetString ("general", "resolution")),
                name);

            MessageManager += Window;
            Game = new Game (name, ObjectManager, MessageManager, null, RendererContext);
            LoadAgain = false;
            InitAgain = false;

            Window.WindowResize = (GlfwWindowPtr window, int width, int height) => {
                Window.MSize = new Vector2i(width, height);

                if (MessageCreated != null)
                    MessageCreated (new WindowResizeMessage (Window, width, height));
            };
            
            Window.WindowMove = (GlfwWindowPtr window, int x, int y) => {
                if (MessageCreated != null)
                    MessageCreated (new WindowMoveMessage (Window, x, y));
            };
            
            Window.WindowClose = (GlfwWindowPtr window) => {
                if (MessageCreated != null)
                    MessageCreated (new WindowCloseMessage (Window));
            };
            
            Window.WindowFocus = (GlfwWindowPtr window, bool focus) => {
                Logger.Log.AddLogEntry (LogLevel.Debug, ClassName, "Window '{0}' changed focus state to '{1}'",
                    Window.Title, focus);
                if (MessageCreated != null)
                    MessageCreated (new WindowFocusMessage (Window, focus));
            };
            
            Window.WindowMinimize = (GlfwWindowPtr window, bool minimized) => {
                Logger.Log.AddLogEntry (LogLevel.Debug, ClassName,
                    "Window '{0}' changed minimized state to '{1}'", Window.Title, minimized);
                if (MessageCreated != null)
                    MessageCreated (new WindowMinimizeMessage (Window, minimized));
            };
            
            Window.WindowError = (GlfwError error, string desc) => {
                Logger.Log.AddLogEntry (LogLevel.Debug, ClassName, "Window '{0}' threw an error: [{1}] {2}",
                    Window.Title, error.ToString (), desc);
                if (MessageCreated != null)
                    MessageCreated (new WindowErrorMessage (Window, error.ToString (), desc));
            };
            
            Window.MouseButton = (GlfwWindowPtr wnd, MouseButton btn, KeyAction action) =>
                InputManager.HandleMouseButton(wnd, btn, action);

            Window.MouseMove = (GlfwWindowPtr wnd, double x, double y) => InputManager.HandleMouseMove(wnd, x, y);
            
            Window.MouseOver = (GlfwWindowPtr window, bool enter) => {
                if (enter)
                    Logger.Log.AddLogEntry (LogLevel.Debug, ClassName, "Mouse entered window '{0}'",
                        Window.Title);
                else
                    Logger.Log.AddLogEntry (LogLevel.Debug, ClassName, "Mouse left window '{0}'",
                        Window.Title);

                if (MessageCreated != null)
                    MessageCreated (new WindowMouseOverMessage (Window, enter));
            };
            
            Window.MouseScroll = (GlfwWindowPtr wnd, double xoffset, double yoffset) =>
                InputManager.HandleMouseScroll(wnd, xoffset, yoffset);
            
            Window.KeyAction = (GlfwWindowPtr wnd, Key key, int scanCode, KeyAction action, KeyModifiers mods) =>
                InputManager.HandleKeyboardInput(wnd, key, scanCode, action, mods);
        }
示例#8
0
 /// <summary>
 /// Initializes a new instance of the <see cref="FreezingArcher.Messaging.WindowCloseMessage"/> class.
 /// </summary>
 /// <param name="window">Window.</param>
 public WindowCloseMessage (Window window)
 {
     Window = window;
 }