Beispiel #1
0
 public ModManager()
 {
     installedMods     = new Dictionary <string, ModManifest>();
     currentMod        = null;
     modConfigData     = new IniConfigFile();
     modInstallRootDir = null;
     parser            = new IniConfigFileParser();
     loadModWorker     = new BackgroundWorker();
     loadModWorker.WorkerReportsProgress = true;
     loadModWorker.DoWork             += loadModWorker_DoWork;
     loadModWorker.RunWorkerCompleted += loadModWorker_RunWorkerCompleted;
     loadModWorker.ProgressChanged    += loadModWorker_ProgressChanged;
 }
Beispiel #2
0
        string GetModInstallRootDir()
        {
            modConfigData = (IniConfigFile)parser.Load("Game.cfg");
            IniConfigFileSection section = modConfigData["Mods"];

            if (section != null)
            {
                string modDir = section["ModDir"];
                if (!string.IsNullOrEmpty(modDir))
                {
                    modInstallRootDir = modDir;
                }
            }
            return(modInstallRootDir);
        }
        public frmConfigureController(frmConfigure form)
        {
            this.form = form;

            AudioConfig   = new AudioConfigure();
            GameConfig    = new GameConfigure();
            GraphicConfig = new GraphicConfigure();

            parser  = new IniConfigFileParser();
            gameCfg = (IniConfigFile)parser.Load("game.cfg");
            ogreCfg = (IniConfigFile)parser.Load("ogre.cfg");
            r       = new Root();

            form.Controller = this;
        }
Beispiel #4
0
        private bool InitRender(string wndTitle, ref Dictionary <string, string> 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 = new Dictionary <string, string>();

                IniConfigFile cf       = (IniConfigFile)parser.Load("Game.cfg");
                var           sections = cf.Sections;
                foreach (var section in sections)
                {
                    foreach (var kpl in section.KeyValuePairs)
                    {
                        gameOptions.Add(kpl.Key, kpl.Value);
                    }
                }

                cf       = (IniConfigFile)parser.Load("ogre.cfg");
                sections = cf.Sections;
                string renderSystem = null;
                foreach (var section in sections)
                {
                    if (section.Name == "")
                    {
                        foreach (var kpl in section.KeyValuePairs)
                        {
                            renderSystem = kpl.Value;
                            gameOptions.Add(kpl.Key, kpl.Value);
                        }
                    }
                    else if (section.Name == renderSystem)
                    {
                        foreach (var kpl in section.KeyValuePairs)
                        {
                            gameOptions.Add("Render Params_" + kpl.Key, kpl.Value);
                        }
                    }
                }
            }

            defaultRenderSystemName = gameOptions.Where(o => o.Key == "Render System").First().Value;
            var renderParams = gameOptions.Where(o => o.Key.StartsWith("Render Params"));

            if (!string.IsNullOrEmpty(defaultRenderSystemName))
            {
                var videModeRenderParam = renderParams.Where(o => o.Key == "Render Params_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.Key.Split('_')[1];
                    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);

            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 = InputManager.CreateInputSystem((uint)hWnd);
            keyboard = (Keyboard)inputMgr.CreateInputObject(MOIS.Type.OISKeyboard, true);
            mouse    = (Mouse)inputMgr.CreateInputObject(MOIS.Type.OISMouse, true);

            mouse.MouseMoved    += new MouseListener.MouseMovedHandler(mouseMoved);
            mouse.MousePressed  += new MouseListener.MousePressedHandler(mousePressed);
            mouse.MouseReleased += new MouseListener.MouseReleasedHandler(mouseReleased);

            keyboard.KeyPressed  += new KeyListener.KeyPressedHandler(keyPressed);
            keyboard.KeyReleased += new KeyListener.KeyReleasedHandler(keyReleased);

            MouseState_NativePtr mouseState = mouse.MouseState;

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

            string        secName, typeName, archName;
            IniConfigFile conf = new IniConfigFile();

            conf = (IniConfigFile)parser.Load("resources.cfg");
            for (int i = 0; i < conf.Sections.Count; i++)
            {
                secName = conf.Sections[i].Name;
                for (int j = 0; j < conf.Sections[i].KeyValuePairs.Count; j++)
                {
                    typeName = conf.Sections[i].KeyValuePairs[j].Key;
                    archName = conf.Sections[i].KeyValuePairs[j].Value;
                    ResourceGroupManager.Singleton.AddResourceLocation(archName, typeName, secName);
                }
            }

            if (!LocateSystem.Singleton.IsInit)
            {
                LocateSystem.Singleton.InitLocateSystem(LocateSystem.Singleton.ConvertLocateShortStringToLocateInfo(gameOptions.Where(o => o.Key == "CurrentLocate").First().Value));
            }

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

            TextureManager.Singleton.DefaultNumMipmaps = 5;

            ResourceGroupManager.Singleton.InitialiseAllResourceGroups();

            trayMgr = new SdkTrayManager("AMOFTrayMgr", renderWindow, mouse, new SdkTrayListener());

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

            renderWindow.IsActive = true;

            this.gameOptions = gameOptions;

            log.LogMessage("Game Started!");

            return(true);
        }