当前位置: 首页>>代码示例>>C#>>正文


C# ConfigFile.GetSectionIterator方法代码示例

本文整理汇总了C#中ConfigFile.GetSectionIterator方法的典型用法代码示例。如果您正苦于以下问题:C# ConfigFile.GetSectionIterator方法的具体用法?C# ConfigFile.GetSectionIterator怎么用?C# ConfigFile.GetSectionIterator使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ConfigFile的用法示例。


在下文中一共展示了ConfigFile.GetSectionIterator方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ReadWheelsFromFiles

        /// <summary>
        /// Go through our media/wheels/ directory and find all of the wheel definitions we have, then make dictionaries out of them
        /// and add them to our one big dictionary.		
        /// </summary>
        public void ReadWheelsFromFiles()
        {
            // since we can run this whenever (like when we're tweaking files), we want to clear our dictionary first
            wheels.Clear();

            // get all of the filenames of the files in media/wheels/
            IEnumerable<string> files = Directory.EnumerateFiles("media/vehicles/", "*.wheel", SearchOption.AllDirectories);

            foreach (string filename in files) {
                // I forgot ogre had this functionality already built in
                ConfigFile cfile = new ConfigFile();
                cfile.Load(filename, "=", true);

                // each .wheel file can have multiple [sections]. We'll use each section name as the wheel name
                ConfigFile.SectionIterator sectionIterator = cfile.GetSectionIterator();
                while (sectionIterator.MoveNext()) {
                    string wheelname = sectionIterator.CurrentKey;
                    // make a dictionary
                    var wheeldict = new Dictionary<string, float>();
                    // go over every property in the file and add it to the dictionary, parsing it as a float
                    foreach (KeyValuePair<string, string> pair in sectionIterator.Current) {
                        wheeldict.Add(pair.Key, float.Parse(pair.Value, culture));
                    }

                    wheels[wheelname] = wheeldict;
                }

                cfile.Dispose();
                sectionIterator.Dispose();
            }
        }
开发者ID:CisciarpMaster,项目名称:PonyKart,代码行数:35,代码来源:WheelFactory.cs

示例2: Init

        public void Init()
        {
            // Create root object
             mRoot = new Root();

             // Define Resources
             ConfigFile cf = new ConfigFile();
             cf.Load("resources.cfg", "\t:=", true);
             ConfigFile.SectionIterator seci = cf.GetSectionIterator();
             String secName, typeName, archName;

             while (seci.MoveNext())
             {
            secName = seci.CurrentKey;
            ConfigFile.SettingsMultiMap settings = seci.Current;
            foreach (KeyValuePair<string, string> pair in settings)
            {
               typeName = pair.Key;
               archName = pair.Value;
               ResourceGroupManager.Singleton.AddResourceLocation(archName, typeName, secName);
            }
             }

             // Setup RenderSystem
             RenderSystem rs = mRoot.GetRenderSystemByName("Direct3D9 Rendering Subsystem");
             // or use "OpenGL Rendering Subsystem"
             mRoot.RenderSystem = rs;
             rs.SetConfigOption("Full Screen", "No");
             rs.SetConfigOption("Video Mode", "800 x 600 @ 32-bit colour");

             // Create Render Window
             mRoot.Initialise(false, "Main Ogre Window");
             NameValuePairList misc = new NameValuePairList();
             misc["externalWindowHandle"] = Handle.ToString();
             mWindow = mRoot.CreateRenderWindow("Main RenderWindow", 800, 600, false, misc);

             // Init resources
             TextureManager.Singleton.DefaultNumMipmaps = 5;
             ResourceGroupManager.Singleton.InitialiseAllResourceGroups();

             // Create a Simple Scene
             SceneManager mgr = mRoot.CreateSceneManager(SceneType.ST_GENERIC);
             Camera cam = mgr.CreateCamera("Camera");
             cam.AutoAspectRatio = true;
             mWindow.AddViewport(cam);

             Entity ent = mgr.CreateEntity("ninja", "ninja.mesh");
             mgr.RootSceneNode.CreateChildSceneNode().AttachObject(ent);

             cam.Position = new Vector3(0, 200, -400);
             cam.LookAt(ent.BoundingBox.Center);
        }
开发者ID:andyhebear,项目名称:mogresdk,代码行数:52,代码来源:Form1.cs

示例3: InitResources

        /// <summary>
        /// Basically adds all of the resource locations but doesn't actually load anything.
        /// </summary>
        private static void InitResources()
        {
            ConfigFile file = new ConfigFile();
            file.Load("media/plugins/resources.cfg", "\t:=", true);
            ConfigFile.SectionIterator sectionIterator = file.GetSectionIterator();

            while (sectionIterator.MoveNext()) {
                string currentKey = sectionIterator.CurrentKey;
                foreach (KeyValuePair<string, string> pair in sectionIterator.Current) {
                    string key = pair.Key;
                    string name = pair.Value;
                    ResourceGroupManager.Singleton.AddResourceLocation(name, key, currentKey);
                }
            }

            file.Dispose();
            sectionIterator.Dispose();
        }
开发者ID:CisciarpMaster,项目名称:PonyKart,代码行数:21,代码来源:LKernel+(ogre+initialisers).cs

示例4: DefineResources

        void DefineResources()
        {
            ConfigFile cf = new ConfigFile();
             cf.Load("resources.cfg", "\t:=", true);
             ConfigFile.SectionIterator seci = cf.GetSectionIterator();
             String secName, typeName, archName;

             while (seci.MoveNext())
             {
                 secName = seci.CurrentKey;
                 ConfigFile.SettingsMultiMap settings = seci.Current;
                 foreach (KeyValuePair<string, string> pair in settings)
                 {
                     typeName = pair.Key;
                     archName = pair.Value;
                     ResourceGroupManager.Singleton.AddResourceLocation(archName, typeName, secName);
                 }
             }
        }
开发者ID:andyhebear,项目名称:mogresdk,代码行数:19,代码来源:Program.cs

示例5: DefineResources

        private void DefineResources()
        {
            ConfigFile configFile = new ConfigFile();
            configFile.Load("resources.cfg", "\t:=", true);

            var section = configFile.GetSectionIterator();
            while (section.MoveNext())
            {
                foreach (var line in section.Current)
                {
                    ResourceGroupManager.Singleton.AddResourceLocation(
                        line.Value, line.Key, section.CurrentKey);
                }
            }
        }
开发者ID:anthony-martin,项目名称:Triangles-in-space,代码行数:15,代码来源:Renderer.cs

示例6: Initialise

        public void Initialise()
        {
            m_Root = new Root();
            ConfigFile cf = new ConfigFile();
            cf.Load("Resources.cfg", "\t:=", true);

            ConfigFile.SectionIterator seci = cf.GetSectionIterator();

            while (seci.MoveNext())
            {
                ConfigFile.SettingsMultiMap settings = seci.Current;
                foreach (KeyValuePair<string, string> pair in settings)
                    ResourceGroupManager.Singleton.AddResourceLocation(pair.Value, pair.Key, seci.CurrentKey);
            }

            if (!m_Root.RestoreConfig())
                if (!m_Root.ShowConfigDialog())
                    return;

            m_RenderWindow = m_Root.Initialise(true);
            ResourceGroupManager.Singleton.InitialiseAllResourceGroups();

            m_SceneManager = m_Root.CreateSceneManager(SceneType.ST_GENERIC);
            m_Camera = m_SceneManager.CreateCamera("MainCamera");
            m_Viewport = m_RenderWindow.AddViewport(m_Camera);
            m_Camera.NearClipDistance = 0.1f;
            m_Camera.FarClipDistance = 1000.0f;

            MOIS.ParamList pl = new MOIS.ParamList();
            IntPtr windowHnd;
            m_RenderWindow.GetCustomAttribute("WINDOW", out windowHnd);
            pl.Insert("WINDOW", windowHnd.ToString());

            m_InputManager = MOIS.InputManager.CreateInputSystem(pl);

            m_Keyboard = (MOIS.Keyboard)m_InputManager.CreateInputObject(MOIS.Type.OISKeyboard, false);
            m_Mouse = (MOIS.Mouse)m_InputManager.CreateInputObject(MOIS.Type.OISMouse, false);

            m_NewtonWorld = new World();
            m_NewtonDebugger = new Debugger(m_NewtonWorld);
            m_NewtonDebugger.Init(m_SceneManager);

            m_GameCamera = new GameCamera();
            m_ObjectManager = new ObjectManager();
        }
开发者ID:Marchew,项目名称:Tachycardia,代码行数:45,代码来源:Core.cs

示例7: SetupResources

        /// Method which will define the source of resources (other than current folder)
        public virtual void SetupResources()
        {
            // Load resource paths from config file
            ConfigFile cf = new ConfigFile();
            cf.Load("resources.cfg", "\t:=", true);

            // Go through all sections & settings in the file
            ConfigFile.SectionIterator seci = cf.GetSectionIterator();

            String secName, typeName, archName;

            // Normally we would use the foreach syntax, which enumerates the values, but in this case we need CurrentKey too;
            while (seci.MoveNext())
            {
                secName = seci.CurrentKey;
                ConfigFile.SettingsMultiMap settings = seci.Current;
                foreach (KeyValuePair<string, string> pair in settings)
                {
                    typeName = pair.Key;
                    archName = pair.Value;
                    ResourceGroupManager.Singleton.AddResourceLocation(archName, typeName, secName);
                }
            }
        }
开发者ID:joproulx,项目名称:FrisbeeSimulator,代码行数:25,代码来源:Example.cs

示例8: Initialise

        public bool Initialise()
        {
            m_Shutdown = false;

            m_Rand = new Random();

            new Mogre.LogManager();
            m_Log = Mogre.LogManager.Singleton.CreateLog("OgreLogfile.log", true, true, false);

            m_Root = new Root();
            ConfigFile cf = new ConfigFile();
            cf.Load("Resources.cfg", "\t:=", true);

            ConfigFile.SectionIterator seci = cf.GetSectionIterator();

            while (seci.MoveNext())
            {
                ConfigFile.SettingsMultiMap settings = seci.Current;
                foreach (KeyValuePair<string, string> pair in settings)
                    ResourceGroupManager.Singleton.AddResourceLocation(pair.Value, pair.Key, seci.CurrentKey);
            }

            if (!m_Root.RestoreConfig())    // comment this line to view configuration dialog box
                if (!m_Root.ShowConfigDialog())
                    return false;

            m_RenderWindow = m_Root.Initialise(true);
            ResourceGroupManager.Singleton.InitialiseAllResourceGroups();

            m_SceneManager = m_Root.CreateSceneManager(SceneType.ST_GENERIC);
            m_Camera = m_SceneManager.CreateCamera("MainCamera");
            m_Viewport = m_RenderWindow.AddViewport(m_Camera);
            m_Camera.NearClipDistance = 0.1f;
            m_Camera.FarClipDistance = 1000.0f;

            MOIS.ParamList pl = new MOIS.ParamList();
            IntPtr windowHnd;
            m_RenderWindow.GetCustomAttribute("WINDOW", out windowHnd);
            pl.Insert("WINDOW", windowHnd.ToString());

            m_InputManager = MOIS.InputManager.CreateInputSystem(pl);

            m_Keyboard = (MOIS.Keyboard)m_InputManager.CreateInputObject(MOIS.Type.OISKeyboard, true);
            m_Mouse = (MOIS.Mouse)m_InputManager.CreateInputObject(MOIS.Type.OISMouse, true);

            m_NewtonWorld = new World();
            m_NewtonWorld.SetWorldSize(new AxisAlignedBox(-500, -500, -500, 500, 500, 500));
            m_NewtonDebugger = new Debugger(m_NewtonWorld);
            m_NewtonDebugger.Init(m_SceneManager);

            m_GameCamera = new GameCamera();
            m_ObjectManager = new ObjectManager();
            m_StateManager = new StateManager();
            m_PhysicsManager = new PhysicsManager();
            m_SoundDict = new SoundDict();

            /*
             * To co tu mamy nalezy przeniesc jak najszybciej do ogitora
             * Materialy dla kazdej mapy moga byc inne inne parametry inne powiazania itp wiec tworzone
             * sa oddzielnie dla kazdej nowej mapy, a potem przy obiektach konkretny material jest przypsiywany
             * przy starcie ladowania physicsmanager powinien byc wyczyszczony
             */

            //inicjalizacja konkretnych obiektow, w sumie tylko nadanie nazw w dictionary
            m_PhysicsManager.addMaterial("Metal");
            //podstawowe
            m_PhysicsManager.addMaterial("Ground");
            m_PhysicsManager.addMaterial("Trigger");
            m_PhysicsManager.addMaterial("Player");
            m_PhysicsManager.addMaterial("NPC");

            //laczenie materialow w pary
            //dla kazdej mapy rozne powiazania (zapewne beda sie powtarzac ale im wieksza ilosc
            //materialow tym wieksze obciazenie dla silnika wiec nalezy to ograniczac
            //dla kazdej pary materialow mozna ustawic rozne parametry kolizji
            //jak tarcie, elastycznosc, miekkosc kolizji oraz callback ktory jest wywolywany przy kolizji
            m_PhysicsManager.addMaterialPair("Metal", "Metal");
            m_PhysicsManager.getMaterialPair("MetalMetal").SetDefaultFriction(1.5f, 1.4f);
            m_PhysicsManager.setPairCallback("MetalMetal", "MetalCallback");

            //obowiazkowe
            m_PhysicsManager.addMaterialPair("Trigger", "Player");//wyzwalacze pozycja obowiazkowa
            m_PhysicsManager.setPairCallback("TriggerPlayer", "TriggerCallback");

            //obowiazkowe
            m_PhysicsManager.addMaterialPair("Ground", "Player");//ground material podstawowy
            m_PhysicsManager.getMaterialPair("GroundPlayer").SetDefaultElasticity(0);
            m_PhysicsManager.setPairCallback("GroundPlayer", "GroundPlayerCallback");

            // NPC:
            //m_PhysicsManager.addMaterialPair("NPC", "NPC");//ground material podstawowy
            //m_PhysicsManager.getMaterialPair("NPCNPC").SetDefaultElasticity(0);
            //m_PhysicsManager.setPairCallback("NPCNPC", "NPCNPCCallback");

            //m_PhysicsManager.addMaterialPair("Ground", "NPC");//ground material podstawowy
            //m_PhysicsManager.getMaterialPair("GroundNPC").SetDefaultElasticity(0);
            // m_PhysicsManager.setPairCallback("GroundNPC", "GroundPlayerCallback");
            /*
                                    * Koniec inicjalizacji materialow ktora musi sie znalezc w opisie mapy, dla niekumatych w ogitorze.
                                    */
//.........这里部分代码省略.........
开发者ID:secred,项目名称:Tachycardia,代码行数:101,代码来源:Core.cs

示例9: ImportResources

        private void ImportResources()
        {
            ConfigFile config = new ConfigFile();
            config.Load("resources.cfg", "=", true);

            ConfigFile.SectionIterator itr = config.GetSectionIterator();
            while (itr.MoveNext())
            {
                foreach (var line in itr.Current)
                    ResourceGroupManager.Singleton.AddResourceLocation(line.Value, line.Key, itr.CurrentKey);
            }
        }
开发者ID:nigelchanyk,项目名称:Archetype,代码行数:12,代码来源:Application.cs

示例10: Initiliase

        public bool Initiliase(bool autoCreateWindow)
        {
            root = new Root();

            ConfigFile cf = new ConfigFile();
            cf.Load("resources.cfg", "\t:=", true);

            // Go through all sections & settings in the file
            ConfigFile.SectionIterator seci = cf.GetSectionIterator();

            String secName, typeName, archName;

            // Normally we would use the foreach syntax, which enumerates the values, but in this case we need CurrentKey too;
            while (seci.MoveNext())
            {
                secName = seci.CurrentKey;
                ConfigFile.SettingsMultiMap settings = seci.Current;
                foreach (KeyValuePair<string, string> pair in settings)
                {
                    typeName = pair.Key;
                    archName = pair.Value;
                    ResourceGroupManager.Singleton.AddResourceLocation(archName, typeName, secName);
                }
            }

            //-----------------------------------------------------
            // 3 Configures the application and creates the window
            //-----------------------------------------------------
            string renderSystem = "Direct3D9 Rendering Subsystem";

            if (!FindRenderSystem(renderSystem))
                throw new Exception("Unable to find render system: " + renderSystem);

            //we found it, we might as well use it!
            root.RenderSystem.SetConfigOption("VSync", "Yes");      // graphics card doesn't work so hard, physics engine should be more stable
            root.RenderSystem.SetConfigOption("Full Screen", "No");
            root.RenderSystem.SetConfigOption("Video Mode", "1024 x 768 @ 32-bit colour");

            // scene manager
            sceneManager = root.CreateSceneManager(SceneType.ST_GENERIC);

            // render window
            this.renderWindow = root.Initialise(autoCreateWindow, "GlueEngine");
            return true;
        }
开发者ID:andyhebear,项目名称:glueeengine,代码行数:45,代码来源:GraphicsManager.cs

示例11: _InitOgre

        protected bool _InitOgre()
        {
            lock (this)
            {
                IntPtr hWnd = IntPtr.Zero;

                foreach (PresentationSource source in PresentationSource.CurrentSources)
                {
                    var hwndSource = (source as HwndSource);
                    if (hwndSource != null)
                    {
                        hWnd = hwndSource.Handle;
                        break;
                    }
                }

                if (hWnd == IntPtr.Zero) return false;

                CallResourceItemLoaded(new ResourceLoadEventArgs("Engine", 0));

                // load the OGRE engine
                //
                _root = new Root();

                // configure resource paths from : "resources.cfg" file
                //
                var configFile = new ConfigFile();
                configFile.Load("resources.cfg", "\t:=", true);

                // Go through all sections & settings in the file
                //
                ConfigFile.SectionIterator seci = configFile.GetSectionIterator();

                // Normally we would use the foreach syntax, which enumerates the values,
                // but in this case we need CurrentKey too;
                while (seci.MoveNext())
                {
                    string secName = seci.CurrentKey;

                    ConfigFile.SettingsMultiMap settings = seci.Current;
                    foreach (var pair in settings)
                    {
                        string typeName = pair.Key;
                        string archName = pair.Value;
                        ResourceGroupManager.Singleton.AddResourceLocation(archName, typeName, secName);
                    }
                }

                // Configures the application and creates the Window
                // A window HAS to be created, even though we'll never use it.
                //
                bool foundit = false;
                foreach (RenderSystem rs in _root.GetAvailableRenderers())
                {
                    if (rs == null) continue;

                    _root.RenderSystem = rs;
                    String rname = _root.RenderSystem.Name;
                    if (rname == "Direct3D9 Rendering Subsystem")
                    {
                        foundit = true;
                        break;
                    }
                }

                if (!foundit)
                    return false;

                _root.RenderSystem.SetConfigOption("Full Screen", "No");
                _root.RenderSystem.SetConfigOption("Video Mode", "1024 x 768 @ 32-bit colour");

                _root.Initialise(false);

                var misc = new NameValuePairList();
                misc["externalWindowHandle"] = hWnd.ToString();
                _renderWindow = _root.CreateRenderWindow("OgreImageSource Windows", 0, 0, false, misc);
                _renderWindow.IsAutoUpdated = false;

                InitResourceLoad();
                ResourceGroupManager.Singleton.InitialiseAllResourceGroups();

                this.Dispatcher.Invoke(
                    (MethodInvoker)delegate
                                       {
                                           if (CreateDefaultScene)
                                           {
                                               //-----------------------------------------------------
                                               // 4 Create the SceneManager
                                               //
                                               //		ST_GENERIC = octree
                                               //		ST_EXTERIOR_CLOSE = simple terrain
                                               //		ST_EXTERIOR_FAR = nature terrain (depreciated)
                                               //		ST_EXTERIOR_REAL_FAR = paging landscape
                                               //		ST_INTERIOR = Quake3 BSP
                                               //-----------------------------------------------------
                                               _sceneManager = _root.CreateSceneManager(SceneType.ST_GENERIC, "SceneMgr");
                                               _sceneManager.AmbientLight = new ColourValue(0.5f, 0.5f, 0.5f);

                                               //-----------------------------------------------------
                                               // 5 Create the camera
//.........这里部分代码省略.........
开发者ID:andyhebear,项目名称:esdogre,代码行数:101,代码来源:OgreImage.cs

示例12: Initialise

        public void Initialise()
        {
            Root = new Root();
            ConfigFile cf = new ConfigFile();
            cf.Load("Resources.cfg", "\t:=", true);

            ConfigFile.SectionIterator seci = cf.GetSectionIterator();

            while (seci.MoveNext())
            {
                ConfigFile.SettingsMultiMap settings = seci.Current;
                foreach (KeyValuePair<string, string> pair in settings)
                    ResourceGroupManager.Singleton.AddResourceLocation(pair.Value, pair.Key, seci.CurrentKey);
            }

            if (!Root.RestoreConfig())
                if (!Root.ShowConfigDialog())
                    return;

            Root.RenderSystem.SetConfigOption("VSync", "Yes");
            RenderWindow = Root.Initialise(true, "Kolejny epicki erpeg");  // @@@@@@@@@@@@@@@ Nazwa okna gry.

            ResourceGroupManager.Singleton.InitialiseAllResourceGroups();

            SceneManager = Root.CreateSceneManager(SceneType.ST_GENERIC);
            Camera = SceneManager.CreateCamera("MainCamera");
            Viewport = RenderWindow.AddViewport(Camera);
            Camera.NearClipDistance = 0.1f;
            Camera.FarClipDistance = 1000.0f;
            Camera.AspectRatio = ((float)RenderWindow.Width / (float)RenderWindow.Height);

            MOIS.ParamList pl = new MOIS.ParamList();
            IntPtr windowHnd;
            RenderWindow.GetCustomAttribute("WINDOW", out windowHnd);
            pl.Insert("WINDOW", windowHnd.ToString());

            InputManager = MOIS.InputManager.CreateInputSystem(pl);

            Keyboard = (MOIS.Keyboard)InputManager.CreateInputObject(MOIS.Type.OISKeyboard, true);
            Mouse = (MOIS.Mouse)InputManager.CreateInputObject(MOIS.Type.OISMouse, true);

            NewtonWorld = new World();
            NewtonDebugger = new Debugger(NewtonWorld);
            NewtonDebugger.Init(SceneManager);

            GameCamera = new GameCamera();
            ObjectManager = new ObjectManager();

            MaterialManager = new MaterialManager();
            MaterialManager.Initialise();

            Items = new Items();
            PrizeManager = new PrizeManager();  //////////////////// @@ Brand nju staff. Nawet trochę działa :Δ
            CharacterProfileManager = new CharacterProfileManager();
            Quests = new Quests();
            NPCManager = new NPCManager();

            Labeler = new TextLabeler(5);
            Random = new Random();
            HumanController = new HumanController();

            TypedInput = new TypedInput();

            SoundManager = new SoundManager();

            Dialog = new Dialog();
            Mysz = new MOIS.MouseState_NativePtr();
            Conversations = new Conversations();

            TriggerManager = new TriggerManager();

            Engine.Singleton.Keyboard.KeyPressed += new MOIS.KeyListener.KeyPressedHandler(TypedInput.onKeyPressed);
            Mouse.MouseReleased += new MOIS.MouseListener.MouseReleasedHandler(MouseReleased);

            IngameConsole = new IngameConsole();
            IngameConsole.Init();
            IngameConsole.AddCommand("dupa", "soundOddawajPiec");
            IngameConsole.AddCommand("tp", "ZejscieDoPiwnicy");
            IngameConsole.AddCommand("exit", "Exit", "Wychodzi z gry. Ale odkrywcze. Super. Musze sprawdzic jak sie zachowa konsola przy duzej dlugosci linii xD llllllllllllllllllllllllllllllllllllllllllllmmmmmmmmmmmmmmmmmmmmmiiiiiiiiiiiiiiii");
            IngameConsole.AddCommand("play", "playSound", "Odtwarza dzwiek. Skladnia: play <sciezka do pliku>. Np. play other/haa.mp3");
            IngameConsole.AddCommand("map", "ChangeMap");
            IngameConsole.AddCommand("save", "SaveGame");
            IngameConsole.AddCommand("load", "LoadGame");
            IngameConsole.AddCommand("help", "ConsoleHelp");
            IngameConsole.AddCommand("h", "CommandHelp");
        }
开发者ID:janPierdolnikParda,项目名称:RPG,代码行数:86,代码来源:Engine.cs

示例13: Initialise

        /// <summary>
        /// Creates the folder and file if they don't exist, and either prints some data to it (if it doesn't exist) or reads from it (if it does)
        /// </summary>
        public static void Initialise()
        {
            SetupDictionaries();
            #if DEBUG
            string pkPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\Ponykart";

            // if a folder doesn't exist there, create it
            if (!Directory.Exists(pkPath))
                Directory.CreateDirectory(pkPath);

            string optionsPath = pkPath + "\\options.ini";
            #else
            string optionsPath = "options.ini";
            #endif

            // create it if the file doesn't exist, and write out some defaults
            if (!File.Exists(optionsPath)) {
                using (FileStream stream = File.Create(optionsPath)) {
                    using (StreamWriter writer = new StreamWriter(stream)) {
                        foreach (KeyValuePair<string, string> pair in defaults) {
                            writer.WriteLine(pair.Key + "=" + pair.Value);
                        }
                    }
                }
                ModelDetail = ModelDetailOption.Medium;
            }
            // otherwise we just read from it
            else {
                ConfigFile cfile = new ConfigFile();
                cfile.Load(optionsPath, "=", true);

                ConfigFile.SectionIterator sectionIterator = cfile.GetSectionIterator();
                sectionIterator.MoveNext();
                foreach (KeyValuePair<string, string> pair in sectionIterator.Current) {
                    dict[pair.Key] = pair.Value;
                }
                ModelDetail = (ModelDetailOption) Enum.Parse(typeof(ModelDetailOption), dict["ModelDetail"], true);
                ShadowDetail = (ShadowDetailOption) Enum.Parse(typeof(ShadowDetailOption), dict["ShadowDetail"], true);

                cfile.Dispose();
                sectionIterator.Dispose();
            }

            #if DEBUG
            // since we sometimes add new options, we want to make sure the .ini file has all of them
            Save();
            #endif
        }
开发者ID:CisciarpMaster,项目名称:PonyKart,代码行数:51,代码来源:Options.cs

示例14: DefineResources

        /// <summary>
        /// Process the config file and add all the proper resource locations
        /// </summary>
        private void DefineResources()
        {
            // load the configuration file
            ConfigFile cf = new ConfigFile();
            cf.Load(RESOURCE_FILE, "\t:=", true);

            // process each section in the configuration file
            ConfigFile.SectionIterator itr = cf.GetSectionIterator();
            while (itr.MoveNext())
            {
                string sectionName = itr.CurrentKey;
                ConfigFile.SettingsMultiMap smm = itr.Current;

                // each section is set of key/value pairs
                // value is the resource type (FileSystem, Zip, etc)
                // key is the location of the resource set
                foreach (KeyValuePair<string, string> kv in smm)
                {
                    // add the resource location to Ogre
                    ResourceGroupManager.Singleton.AddResourceLocation(kv.Value, kv.Key, sectionName);
                }
            }
        }
开发者ID:andyhebear,项目名称:ymfas,代码行数:26,代码来源:TestEngine_Init.cs

示例15: InitRenderer

        public void InitRenderer()
        {
            try
            {
                OgreRoot = new Root();

                {	//Load config file data
                    ConfigFile cf = new ConfigFile();
                    cf.Load("./resources.cfg", "\t:=", true);
                    ConfigFile.SectionIterator seci = cf.GetSectionIterator();
                    String secName, typeName, archName;

                    while (seci.MoveNext())
                    {
                        secName = seci.CurrentKey;
                        ConfigFile.SettingsMultiMap settings = seci.Current;
                        foreach (KeyValuePair<String, String> pair in settings)
                        {
                            typeName = pair.Key;
                            archName = pair.Value;
                            ResourceGroupManager.Singleton.AddResourceLocation(archName, typeName, secName);
                        }
                    }
                }

                OgreRenderSystem = OgreRoot.GetRenderSystemByName("Direct3D9 Rendering Subsystem");
                OgreRenderSystem.SetConfigOption("Full Screen", "No");
                OgreRenderSystem.SetConfigOption("Video Mode", "800 x 600 @ 32-bit colour");

                OgreRoot.RenderSystem = OgreRenderSystem;
                OgreRoot.Initialise(false, "Main Ogre Window");

                NameValuePairList misc = new NameValuePairList();
                misc["externalWindowHandle"] = RenderPanel.Handle.ToString();
                misc["FSAA"] = "4";
                OgreRenderWindow = OgreRoot.CreateRenderWindow("Main RenderWindow", 800, 600, false, misc);

                OgreRenderWindow.IsActive = true;
                OgreRenderWindow.IsAutoUpdated = true;

                MaterialManager.Singleton.SetDefaultTextureFiltering(TextureFilterOptions.TFO_ANISOTROPIC);

                //Trigger background resource load
                StartResourceThread();
            }
            catch (Exception ex)
            {
                Console.WriteLine("Error during renderer initialization:" + ex.Message + "," + ex.StackTrace);
            }
        }
开发者ID:Jerdak,项目名称:OgreWpf,代码行数:50,代码来源:Window1.xaml.cs


注:本文中的ConfigFile.GetSectionIterator方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。