コード例 #1
0
        private void btnCancel_Click(object sender, EventArgs e)
        {
            m_theme = null;

            DialogResult = DialogResult.Cancel;
            this.Close();
        }
コード例 #2
0
        private void btnThemeAdd_Click(object sender, EventArgs e)
        {
            newTheme ib = new newTheme();

            if (ib.ShowDialog(this) == DialogResult.OK)
            {
                SoundTheme theme = ib.getTheme();
                if (null != theme)
                {
                    m_themeManager.AddTheme(ref theme);
                    cbTheme.SelectedIndex = cbTheme.Items.Add(theme.name);
                    SetTheme(theme.name);
                }
            }
        }
コード例 #3
0
        public void PlayTheme(string theme)
        {
            if (!m_themes.Themes().ContainsKey(theme))
            {
                m_owner.Log("ERROR: Theme not found!");
                return;
            }

            lock (m_activeTheme)
            {
                m_owner.Log("Starting theme...");

                // set theme to active
                m_activeTheme = m_themes[theme];

                // load sounds
                foreach (string soundFile in m_activeTheme.effect)
                {
                    m_owner.Log("loading sound: {0}", soundFile);
                    m_soundManager.LoadSound3D(soundFile);
                }

                // load ambient sounds
                foreach (string soundFile in m_activeTheme.ambient)
                {
                    m_owner.Log("loading ambient sound: {0}", soundFile);
                    m_soundManager.LoadSound(soundFile);
                }

                // play ambient
                m_ambientIndex = 0;
                bool success = m_soundManager.PlaySound(m_activeTheme.ambient[m_ambientIndex], true, m_themes.AmbientVolume);

                // set timer for sounds
                m_effectIndex          = 0;
                m_effectTimer.Interval = m_minRandInterval + (m_randAction.Next() % m_maxRandInterval);
                m_owner.Log("play sound: next interval in {0} second/s", m_effectTimer.Interval);
                m_effectTimer.Enabled = true;

                m_owner.Log("Started!");
            }
        }
コード例 #4
0
        private void SetTheme(string name)
        {
            SoundTheme theme = m_themeManager.themes[name];

            Log("Setting theme: {0}", name);

            lblEffectVolume.Text  = string.Format(EffectSoundVolumeFormat, m_themeManager.EffectVolume);
            lblAmbientVolume.Text = string.Format(AmbientSoundVolumeFormat, m_themeManager.AmbientVolume);

            int themeidx = cbTheme.Items.IndexOf(theme.name);

            if (themeidx != -1)
            {
                // select previous item
                cbTheme.SelectedIndex = cbTheme.Items.IndexOf(theme.name);
            }
            else
            {
                // add new item
                int idx = cbTheme.Items.Add(theme.name);
                cbTheme.SelectedIndex = idx;
            }

            lbEffectSounds.Items.Clear();
            foreach (string sound in theme.effect)
            {
                lbEffectSounds.Items.Add(sound);
            }

            lbAmbientSounds.Items.Clear();
            foreach (string sound in theme.ambient)
            {
                lbAmbientSounds.Items.Add(sound);
            }

            tbEffectVolume.Value = m_themeManager.EffectVolume;
            lblEffectVolume.Text = string.Format(EffectSoundVolumeFormat, m_themeManager.EffectVolume);

            tbAmbientVolume.Value = m_themeManager.AmbientVolume;
            lblAmbientVolume.Text = string.Format(AmbientSoundVolumeFormat, m_themeManager.AmbientVolume);
        }
コード例 #5
0
        private void btnOk_Click(object sender, EventArgs e)
        {
            // need to validate text
            if (tbValue.Text.Length == 0)
            {
                MessageBox.Show(this, "theme name must not be empty", "error");
                return;
            }

            if (lbEffects.Items.Count == 0)
            {
                MessageBox.Show(this, "must be atleast one sound", "error");
                return;
            }

            if (lbAmbient.Items.Count == 0)
            {
                MessageBox.Show(this, "must be atleast one ambient sound", "error");
                return;
            }

            m_theme = new SoundTheme(tbValue.Text);
            foreach (string sound in lbEffects.Items)
            {
                m_theme.AddSound(sound);
            }

            foreach (string sound in lbAmbient.Items)
            {
                m_theme.AddAmbient(sound);
            }

            DialogResult = DialogResult.OK;

            this.Close();
        }
コード例 #6
0
 public void AddTheme(ref SoundTheme theme)
 {
     m_themes[theme.name] = theme;
 }