コード例 #1
0
ファイル: GameApp.cs プロジェクト: lennyhans/OpenMB
 public GameApp(GameConfigXml gameOptions = null, string mod = null)
 {
     this.state       = RunState.Stopped;
     this.gameOptions = gameOptions;
     this.mod         = mod;
     AppStateManager.Instance.OnAppStateManagerStarted += new Action(OnAppStateManagerStarted);
 }
コード例 #2
0
ファイル: frmConfigure.cs プロジェクト: lennyhans/OpenMB
        private void btnOK_Click(object sender, EventArgs e)
        {
            Hide();
            GameConfigXml gameOptions = controller.SaveConfigure();
            GameApp       app         = new GameApp(gameOptions, mod);

            app.Run();
        }
コード例 #3
0
ファイル: EngineManager.cs プロジェクト: lennyhans/OpenMB
        private bool InitGame(GameConfigXml gameOptions)
        {
            try
            {
                isEditMode = gameOptions.CoreConfig.IsEnableEditMode;

                return(true);
            }
            catch
            {
                return(false);
            }
        }
コード例 #4
0
        public frmConfigureController(frmConfigure form)
        {
            this.form = form;

            root = new Root();

            AudioConfig    = new AudioConfigure();
            GameConfig     = new GameConfigure();
            GraphicConfig  = new GraphicConfigure();
            ResourceConfig = new ResourceConfigure();
            gameXmlConfig  = GameConfigXml.Load("game.xml", root);

            form.Controller = this;
        }
コード例 #5
0
        private bool InitGame(GameConfigXml gameOptions)
        {
            try
            {
                isEditMode = gameOptions.CoreConfig.IsEnableEditMode;

                TimerManager.Instance.Init(1257, 3, 29, 9, 0, 0);

                return(true);
            }
            catch
            {
                return(false);
            }
        }
コード例 #6
0
        private bool InitSubSystem(GameConfigXml gameOptions)
        {
            appStateMgr = new AppStateManager();
            locateMgr   = LocateSystem.Instance;
            modMgr      = new ModManager();
            outputMgr   = new OutputManager();
            soundMgr    = new MusicSoundManager();
            uiMgr       = new ScreenManager();

            MusicSoundManager.Instance.InitSystem(
                gameOptions.AudioConfig.EnableMusic,
                gameOptions.AudioConfig.EnableSound
                );

            return(true);
        }
コード例 #7
0
        public bool Init(string windowTitle, GameConfigXml gameOptions)
        {
            if (!InitRender(windowTitle, ref gameOptions))
            {
                return(false);
            }

            if (!InitSubSystem(gameOptions))
            {
                return(false);
            }

            if (!InitGame(gameOptions))
            {
                return(false);
            }

            return(true);
        }
コード例 #8
0
        private bool InitRender(string wndTitle, ref GameConfigXml gameOptions)
        {
            root = Root.Singleton == null ? new Root() : Root.Singleton;
            root.FrameStarted += new FrameListener.FrameStartedHandler(frameStarted);

            log         = EngineLogManager.Instance.CreateLog("./Log/Engine.log");
            rendererLog = LogManager.Singleton.CreateLog("./Log/Mogre.log", true, true, false);
            rendererLog.SetDebugOutputEnabled(true);

            RenderSystem        rs     = null;
            IniConfigFileParser parser = new IniConfigFileParser();

            if (gameOptions == null)
            {
                gameOptions = GameConfigXml.Load("game.xml", root);
            }

            defaultRenderSystemName = gameOptions.GraphicConfig.CurrentRenderSystem;
            var renderParams = gameOptions.GraphicConfig[gameOptions.GraphicConfig.CurrentRenderSystem];

            if (!string.IsNullOrEmpty(defaultRenderSystemName))
            {
                var videModeRenderParam = renderParams.Where(o => o.Name == "Video Mode").First();
                rs = root.GetRenderSystemByName(defaultRenderSystemName);
                string strVideoMode = Regex.Match(
                    videModeRenderParam.Value,
                    "[0-9]{3,4} x [0-9]{3,4}").Value;
                VideoMode["Width"]  = strVideoMode.Split('x')[0].Trim();
                VideoMode["Height"] = strVideoMode.Split('x')[1].Trim();
            }

            var ogreConfigMap = rs.GetConfigOptions();

            if (rs != null && renderParams != null)
            {
                foreach (var kpl in renderParams)
                {
                    string renderParamKey   = kpl.Name;
                    string renderParamValue = kpl.Value;
                    //Validate the render parameter
                    if (!ogreConfigMap[renderParamKey].possibleValues.Contains(renderParamValue))
                    {
                        renderParamValue = ogreConfigMap[renderParamKey].possibleValues[0];
                    }
                    rs.SetConfigOption(renderParamKey, renderParamValue);
                }
                root.RenderSystem = rs;
            }

            renderWindow = root.Initialise(true, wndTitle);

            IntPtr hwnd;

            renderWindow.GetCustomAttribute("WINDOW", out hwnd);
            Helper.SetRenderWindowIcon(new System.Drawing.Icon(Path.Combine(Environment.CurrentDirectory, "app.ico")), hwnd);

            viewport = renderWindow.AddViewport(null);
            ColourValue cv = new ColourValue(0.5f, 0.5f, 0.5f);

            viewport.BackgroundColour = cv;

            viewport.Camera = null;

            int hWnd = 0;

            renderWindow.GetCustomAttribute("WINDOW", out hWnd);

            inputMgr        = MOIS.InputManager.CreateInputSystem((uint)hWnd);
            keyboard        = (Keyboard)inputMgr.CreateInputObject(MOIS.Type.OISKeyboard, true);
            mouse           = (Mouse)inputMgr.CreateInputObject(MOIS.Type.OISMouse, true);
            keyMouseManager = new InputKeyMouseManager();
            keyMouseManager.SomeKeyPressd += KeyMouseManager_SomeKeyPressd;

            MouseState_NativePtr mouseState = mouse.MouseState;

            mouseState.width  = viewport.ActualWidth;
            mouseState.height = viewport.ActualHeight;

            foreach (var resource in gameOptions.ResourcesConfig.Resources)
            {
                foreach (var resLoc in resource.ResourceLocs)
                {
                    ResourceGroupManager.Singleton.AddResourceLocation(resLoc, resource.Type, ResourceGroupManager.DEFAULT_RESOURCE_GROUP_NAME);
                }
            }

            foreach (var keyMapper in gameOptions.InputConfig.Mappers)
            {
                KeyMapperManager.Instance.AddKeyMapper(keyMapper.GameKeyCode, keyMapper.GetKeyCollections());
            }

            if (!LocateSystem.Instance.IsInit)
            {
                LocateSystem.Instance.InitLocateSystem(LocateSystem.Instance.ConvertReadableStringToLocate(gameOptions.LocateConfig.CurrentLocate));
            }

            SkinManager.Instance.LoadSkin("Default.skn");

            ResourceGroupManager.Singleton.AddResourceLocation(
                string.Format("./Media/Engine/Fonts/{0}/", LocateSystem.Instance.Locate.ToString()), "FileSystem",
                "General");

            TextureManager.Singleton.DefaultNumMipmaps = 5;

            ResourceGroupManager.Singleton.InitialiseAllResourceGroups();

            UIManager.Instance.Init("AMOFTrayMgr", renderWindow, mouse, new UIListener());


            timer = new Timer();
            timer.Reset();

            renderWindow.IsActive = true;

            this.gameOptions = gameOptions;

            log.LogMessage("Game Started!");

            return(true);
        }