Exemplo n.º 1
0
 public Sound()
 {
     this._soundManager = SoundManager.DefaultSoundManager;
     this._strategy = this._soundManager.CreateSoundStrategy();
     this._strategy.Sound = this;
     this.Init();
     this._soundManager.SoundCreated(this);
 }
Exemplo n.º 2
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="name"></param>
        /// <param name="renderControl"></param>
        /// <returns></returns>
        public static SoundManager CreateSystem(string name, Control renderControl)
        {
            System.Reflection.Assembly ass = GetAssembly(name, null);
            if (ass == null)
                return null;

            string sFullname = ass.FullName.Substring(0,ass.FullName.IndexOf(","));
            Type scriptClass = ass.GetType(sFullname+".SoundManager");
            if (scriptClass == null)
                throw new Exception("SoundManager class not found in renderer " + name);

            System.Reflection.ConstructorInfo cons = scriptClass.GetConstructor(new Type[]{typeof(Control)});

            object o = null;
            try
            {
                o = cons.Invoke(new object[] { renderControl });
            }
            catch (Exception e)
            {
                if (sFullname.ToLower().Contains(".bass"))
                    throw new Exception("BASS audio needs some external .dlls. Download from http://codeproject.com/csharp/Endogine.asp");

                throw new Exception("Sound system failed to load: " + scriptClass.FullName + "\r\n(Inner: " + e.Message + ")");
            }
            SoundManager._defaultSoundManager = (SoundManager)o;
            SoundManager._defaultSoundManager.DefaultSoundPath = System.IO.Directory.GetCurrentDirectory();

            return (SoundManager)o;
        }
Exemplo n.º 3
0
 public virtual void Dispose()
 {
     this.Free();
     this._soundManager.SoundDisposed(this);
     this._soundManager = null;
 }
Exemplo n.º 4
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);
        }