Esempio n. 1
0
        public void Init(Control a_mainControl, Form a_formMdiParent, Form startupForm)
        {
            m_formMdiParent   = a_formMdiParent;
            this._startupForm = startupForm;

            string[] renderers = StageBase.GetAvailableRenderers(null);

            this._stage = StageBase.CreateRenderer(this._renderStrategy, a_mainControl, null); //renderers[0] //GDI Direct3D OpenGL

            Stage.Fullscreen = m_bFullscreen;
            Stage.Init();

            if (this._renderStrategy == "GDI")
            {
                //Precalculate some raster operations (look-up tables)
                m_rasterOps = new RasterOps();
                m_rasterOps.PreCalcBlendMode(RasterOps.ROPs.AddPin);
                m_rasterOps.PreCalcBlendMode(RasterOps.ROPs.Lightest);
                m_rasterOps.PreCalcBlendMode(RasterOps.ROPs.Difference);
            }

            string sMediaPath = null;

            //TODO: ugly way of getting path - do something about it in AppSettings.Instance
            if (AppSettings.Instance.GetPath("Media") != null)
            {
                sMediaPath = AppSettings.Instance.GetPath("Media");
            }
            if (sMediaPath == null)
            {
                sMediaPath = AppSettings.BaseDirectory + "\\Media";
            }
            m_castlib = new CastLib(this);
            m_castlib.Init(sMediaPath);

            try
            {
                this._soundManager = Audio.SoundManager.CreateSystem(null, a_mainControl); //DirectX Bass
                if (this._soundManager != null)
                {
                    this._soundManager.DefaultSoundPath = null;
                    if (AppSettings.Instance.GetPath("Sound") != null)
                    {
                        this._soundManager.DefaultSoundPath = AppSettings.Instance.GetPath("Sound");
                    }
                    if (this._soundManager.DefaultSoundPath == null)
                    {
                        this._soundManager.DefaultSoundPath = this.CastLib.DirectoryPath; //System.IO.Directory.GetCurrentDirectory;
                    }
                }
            }
            catch { }

            if (AppSettings.Instance.GetNodeText("ShowEditors") != "false")
            {
                //TODO: let user decide if/which GUI should be used!
                if (EditorFactory.LoadDll("Endogine.Editors.dll"))
                {
                    if (AppSettings.Instance.GetNodeText("ShowEditors.CamControl") == "true")
                    {
                        this.OpenEditor("CamControl");
                        this.CamControl.Location = new Point(700, 50);
                    }

                    if (AppSettings.Instance.GetNodeText("ShowEditors.SceneGraphViewer") == "true")
                    {
                        m_sceneGraphViewer = (ISceneGraphViewer)this.OpenEditor("SceneGraphViewer");
                        m_sceneGraphViewer.SelectedSprite = Stage.DefaultParent;
                    }

                    if (AppSettings.Instance.GetNodeText("ShowEditors.MessageWindow") == "true")
                    {
                        m_msgWnd = (IMessageWindow)this.OpenEditor("MessageWindow");
                    }

                    if (AppSettings.Instance.GetNodeText("ShowEditors.ResourceBrowser") == "true")
                    {
                        this.OpenEditor("ResourceBrowser");
                    }
                }
            }

            if (AppSettings.Instance.GetNodeText("OnScreenEdit") == "true")
            {
                this.m_bSendMouseEventsToSprites = false;
            }

            this.Stage.OnEndUpdate += new StageBase.RenderDelegate(Stage_OnEndUpdate);
        }