Пример #1
0
        // 生成と終了


        /// <summary>
        ///     コンストラクタ。一部のグローバルリソースを初期化する。
        /// </summary>
        public App()
        {
            using var _ = new LogBlock(Log.現在のメソッド名);

            SystemConfig.Update();
            UserConfig.Update();

            this.乱数      = new Random(DateTime.Now.Millisecond);
            this.システム設定  = SystemConfig.読み込む();
            this.ユーザリスト  = new SelectableList <ユーザ設定>();
            this.全譜面リスト  = new Dictionary <string, 曲.Score>();
            this.曲ツリーリスト = new SelectableList <曲.曲ツリー>();
            this.現行化     = new 曲.現行化();

            #region " Skin.yaml を読み込んで、リソース関連のフォルダ変数を更新する。"
            //----------------
            {
                // DrumSounds
                var drumSounds = this.システム設定.DrumSoundsFolder;
                Folder.フォルダ変数を追加または更新する("DrumSounds", (Path.IsPathRooted(drumSounds.数なしパス)) ?
                                        drumSounds.数なしパス :
                                        new VariablePath(@$ "$(ResourcesRoot)\{drumSounds}").数なしパス);
                Log.Info($"DrumSounds folder: {new VariablePath( Folder.フォルダ変数の内容を返す( "DrumSounds" ) ).変数付きパス}");

                // SystemSounds
                var systemSounds = this.システム設定.SystemSoundsFolder;
                Folder.フォルダ変数を追加または更新する("SystemSounds", (Path.IsPathRooted(systemSounds.数なしパス)) ?
                                        systemSounds.数なしパス :
                                        new VariablePath(@$ "$(ResourcesRoot)\{systemSounds}").数なしパス);
Пример #2
0
        /// <summary>
        ///     アプリケーションの起動処理を行う。
        /// </summary>
        protected override void OnLoad(EventArgs e)
        {
            // ※ このメソッドは GUI スレッドで実行されるので、後回しにできる初期化処理は進行描画タスクに回して、
            //   なるべく早くこのメソッドを抜けること。

            Log.Header("アプリケーション起動");
            using var _ = new LogBlock(Log.現在のメソッド名);


            // フォームを設定する。

            this.Text       = $"DTXMania2 Release {int.Parse( Application.ProductVersion.Split( '.' ).ElementAt( 0 ) ):000}";
            this.ClientSize = new Size(1024, 576);
            this.Icon       = Properties.Resources.DTXMania2;

            this.ScreenMode = new ScreenMode(this);

            Global.App    = this;
            Global.Handle = this.Handle;


            // サウンドデバイスとサウンドタイマを初期化する。これらは入力デバイスで使用されるので先に初期化する。

            this.サウンドデバイス = new SoundDevice(CSCore.CoreAudioAPI.AudioClientShareMode.Shared);
            // マスタ音量(小:0~1:大)... 0.5を超えるとだいたいWASAPI共有モードのリミッターに抑制されるようになる
            // ※サウンドデバイスの音量プロパティはコンストラクタの実行後でないと set できないので、初期化子にはしないこと。(した場合の挙動は不安定)
            this.サウンドデバイス.音量 = 0.5f;
            this.サウンドタイマ     = new SoundTimer(this.サウンドデバイス);


            // 入力デバイスを初期化する。これらは GUI スレッドで行う必要がある。

            this.KeyboardHID        = new KeyboardHID(this.サウンドタイマ);
            this.GameControllersHID = new GameControllersHID(this.Handle, this.サウンドタイマ);
            this.MidiIns            = new MidiIns(this.サウンドタイマ);


            // システム設定ファイルを読み込む。

            SystemConfig.最新版にバージョンアップする();
            this.システム設定 = SystemConfig.読み込む();

            this._システム設定をもとにリソース関連のフォルダ変数を更新する();


            // メインループを別スレッドで開始する。

            if (!this._進行描画タスクを起動する().WaitOne(5000))
            {
                throw new TimeoutException("進行描画タスクの起動処理がタイムアウトしました。");
            }


            // 初期化完了。(進行描画タスクの起動後に)

            this._未初期化 = false;


            // 全画面モードが設定されているならここで全画面に切り替える。

            if (this.システム設定.全画面モードである)
            {
                this.ScreenMode.ToFullscreenMode();
            }

            base.OnLoad(e);
        }