Esempio n. 1
0
        public DDMusic(DDSound sound_binding)
        {
            this.Sound = sound_binding;
            this.Sound.PostLoadeds.Add(handle => DDSoundUtils.SetVolume(handle, 0.0));             // ロードしたらミュートしておく。

            DDMusicUtils.Add(this);
        }
Esempio n. 2
0
        public DDMusic(DDSound sound_binding)
        {
            this.Sound            = sound_binding;
            this.Sound.PostLoaded = () => DDSoundUtils.SetVolume(this.Sound.GetHandle(0), 0.0);             // ロードしたらミュートしておく。

            DDMusicUtils.Add(this);
        }
Esempio n. 3
0
        public static void EachFrame()
        {
            if (1 <= PlayInfos.Count)
            {
                PlayInfo info = PlayInfos.Dequeue();

                if (info != null)
                {
                    switch (info.Command)
                    {
                    case PlayInfo.Command_e.PLAY:
                        DDSoundUtils.Play(info.Music.Sound.GetHandle(0), info.Once, info.Resume);
                        break;

                    case PlayInfo.Command_e.VOLUME_RATE:
                        DDSoundUtils.SetVolume(info.Music.Sound.GetHandle(0), DDSoundUtils.MixVolume(DDGround.MusicVolume, info.Music.Volume) * info.VolumeRate);
                        break;

                    case PlayInfo.Command_e.STOP:
                        DDSoundUtils.Stop(info.Music.Sound.GetHandle(0));

#if true // 再生していたローカルBGMのみ解放する。
                        if (info.Music.Locally)
                        {
                            info.Music.Sound.Unload();
                        }
#else // 全てのローカルBGMを解放する。
                        DDMusicUtils.UnloadLocally();
#endif
                        break;

                    default:
                        throw new DDError();
                    }
                }
            }
        }
Esempio n. 4
0
        public static void EachFrame()
        {
            //Ground.EL.ExecuteAllTask();

            DDGround.EL.ExecuteAllTask();
            DDGround.SystemTasks.ExecuteAllTask();
            DispDebug();
            DDMouse.PosChanged_Delay();
            DDCurtain.EachFrame();

            if (!DDSEUtils.EachFrame())
            {
                DDMusicUtils.EachFrame();
            }

            DDSubScreenUtils.ChangeDrawScreen(DX.DX_SCREEN_BACK);

            if (DDGround.RealScreenDraw_W == -1)
            {
                bool mosaicFlag =
                    DDConfig.DrawScreen_MosaicFlag &&
                    DDGround.RealScreen_W % DDConsts.Screen_W == 0 &&
                    DDGround.RealScreen_H % DDConsts.Screen_H == 0;

                if (mosaicFlag)
                {
                    DX.SetDrawMode(DX.DX_DRAWMODE_NEAREST);
                }

                if (DX.DrawExtendGraph(0, 0, DDGround.RealScreen_W, DDGround.RealScreen_H, DDGround.MainScreen.GetHandle(), 0) != 0)                 // ? 失敗
                {
                    throw new DDError();
                }

                if (mosaicFlag)
                {
                    DX.SetDrawMode(DDConsts.DEFAULT_DX_DRAWMODE);                     // restore
                }
            }
            else
            {
                if (DX.DrawBox(0, 0, DDGround.RealScreen_W, DDGround.RealScreen_H, DX.GetColor(0, 0, 0), 1) != 0)                 // ? 失敗
                {
                    throw new DDError();
                }

                bool mosaicFlag =
                    DDConfig.DrawScreen_MosaicFlag &&
                    DDGround.RealScreenDraw_W % DDConsts.Screen_W == 0 &&
                    DDGround.RealScreenDraw_H % DDConsts.Screen_H == 0;

                if (mosaicFlag)
                {
                    DX.SetDrawMode(DX.DX_DRAWMODE_NEAREST);
                }

                if (DX.DrawExtendGraph(
                        DDGround.RealScreenDraw_L,
                        DDGround.RealScreenDraw_T,
                        DDGround.RealScreenDraw_L + DDGround.RealScreenDraw_W,
                        DDGround.RealScreenDraw_T + DDGround.RealScreenDraw_H, DDGround.MainScreen.GetHandle(), 0) != 0)                 // ? 失敗
                {
                    throw new DDError();
                }

                if (mosaicFlag)
                {
                    DX.SetDrawMode(DDConsts.DEFAULT_DX_DRAWMODE);                     // restore
                }
            }

            GC.Collect(0);

            FrameProcessingMillis = (int)(DDUtils.GetCurrTime() - FrameStartTime);

            if (FrameProcessingMillis_Worst < FrameProcessingMillis || !DDUtils.CountDown(ref FrameProcessingMillis_WorstFrame))
            {
                FrameProcessingMillis_Worst      = FrameProcessingMillis;
                FrameProcessingMillis_WorstFrame = 120;
            }

            // DxLib >

            DX.ScreenFlip();

            if (DX.CheckHitKey(DX.KEY_INPUT_ESCAPE) == 1 || DX.ProcessMessage() == -1)
            {
                throw new DDCoffeeBreak();
            }

            // < DxLib

            CheckHz();

            ProcFrame++;
            DDUtils.CountDown(ref FreezeInputFrame);
            WindowIsActive = DDUtils.IsWindowActive();

            if (SCommon.IMAX < ProcFrame)             // 192.9日程度でカンスト
            {
                ProcFrame = SCommon.IMAX;             // 2bs
                throw new DDError();
            }

            DDPad.EachFrame();
            DDKey.EachFrame();
            DDInput.EachFrame();
            DDMouse.EachFrame();

            // Swap MainScreen
            {
                DDSubScreen tmp = DDGround.MainScreen;
                DDGround.MainScreen     = DDGround.LastMainScreen;
                DDGround.LastMainScreen = tmp;
            }

            DDGround.MainScreen.ChangeDrawScreen();

            // ? ALT + ENTER -> フルスクリーン切り替え
            if ((1 <= DDKey.GetInput(DX.KEY_INPUT_LALT) || 1 <= DDKey.GetInput(DX.KEY_INPUT_RALT)) && DDKey.GetInput(DX.KEY_INPUT_RETURN) == 1)
            {
                // ? 現在フルスクリーン -> フルスクリーン解除
                if (
                    DDGround.RealScreen_W == DDGround.MonitorRect.W &&
                    DDGround.RealScreen_H == DDGround.MonitorRect.H
                    )
                {
                    DDMain.SetScreenSize(DDGround.UnfullScreen_W, DDGround.UnfullScreen_H);
                }
                else                 // ? 現在フルスクリーンではない -> フルスクリーンにする
                {
                    DDGround.UnfullScreen_W = DDGround.RealScreen_W;
                    DDGround.UnfullScreen_H = DDGround.RealScreen_H;

                    DDMain.SetFullScreen();
                }
                DDEngine.FreezeInput(30);                 // エンターキー押下がゲームに影響しないように
            }

            DX.ClearDrawScreen();
        }
Esempio n. 5
0
 public void Play(bool once = false, bool resume = false, double volume = 1.0, int fadeFrameMax = 30)
 {
     this.Touch();             // 再生までタイムラグがある。再生時にラグらないよう、ここでロードしておく
     DDMusicUtils.Play(this, once, resume, volume, fadeFrameMax);
 }
Esempio n. 6
0
 public void Play(bool once = false, bool resume = false, double volume = 1.0, int fadeFrameMax = 30)
 {
     DDMusicUtils.Play(this, once, resume, volume, fadeFrameMax);
 }
Esempio n. 7
0
 private static void UnloadLocally()
 {
     DDPictureUtils.UnloadLocally();
     DDMusicUtils.UnloadLocally(music => !music.Sound.IsPlaying());
     DDSEUtils.UnloadLocally(se => !se.Sound.IsPlaying());
 }
Esempio n. 8
0
 private static void TouchGlobally()
 {
     DDPictureUtils.TouchGlobally();
     DDMusicUtils.TouchGlobally();
     DDSEUtils.TouchGlobally();
 }