OSDN Git Service

#28263 DTX2WAV003:
authoryyagi <yyagi.dtxmania@gmail.com>
Wed, 7 Feb 2018 14:21:50 +0000 (23:21 +0900)
committeryyagi <yyagi.dtxmania@gmail.com>
Wed, 7 Feb 2018 14:21:50 +0000 (23:21 +0900)
 * DTX2WAVの起動時にDTXMania本体が既に起動済みだった場合は、警告を表示して自身を終了する機能
 * 自身の二重起動抑制
 * NOWLOADINGサウンド抑制
 * ウェイリングチップ並びにウェイリングエフェクトの表示抑制
 * 録音完了ダイアログの表示位置修正

DTX2WAV/DTX2WAV.csproj
DTX2WAV/Form1.cs
DTX2WAV/Form_FInished_OK.Designer.cs [moved from DTX2WAV/Form_FInished.Designer.cs with 97% similarity]
DTX2WAV/Form_FInished_OK.cs [moved from DTX2WAV/Form_FInished.cs with 78% similarity]
DTX2WAV/Form_FInished_OK.resx [moved from DTX2WAV/Form_FInished.resx with 100% similarity]
DTX2WAV/Program.cs
DTX2WAV/Properties/AssemblyInfo.cs
DTXMania/コード/ステージ/06.曲読み込み/CStage曲読み込み.cs
DTXMania/コード/ステージ/07.演奏/CStage演奏画面共通.cs

index e4b4f0d..8994bf7 100644 (file)
     <Compile Include="Form1.Designer.cs">
       <DependentUpon>Form1.cs</DependentUpon>
     </Compile>
-    <Compile Include="Form_FInished.cs">
+    <Compile Include="Form_FInished_OK.cs">
       <SubType>Form</SubType>
     </Compile>
-    <Compile Include="Form_FInished.Designer.cs">
-      <DependentUpon>Form_FInished.cs</DependentUpon>
+    <Compile Include="Form_FInished_OK.Designer.cs">
+      <DependentUpon>Form_FInished_OK.cs</DependentUpon>
     </Compile>
     <Compile Include="Form_Recording.cs">
       <SubType>Form</SubType>
@@ -75,8 +75,8 @@
     <EmbeddedResource Include="Form1.resx">
       <DependentUpon>Form1.cs</DependentUpon>
     </EmbeddedResource>
-    <EmbeddedResource Include="Form_FInished.resx">
-      <DependentUpon>Form_FInished.cs</DependentUpon>
+    <EmbeddedResource Include="Form_FInished_OK.resx">
+      <DependentUpon>Form_FInished_OK.cs</DependentUpon>
     </EmbeddedResource>
     <EmbeddedResource Include="Form_Recording.resx">
       <DependentUpon>Form_Recording.cs</DependentUpon>
index bc8af41..d20b6d7 100644 (file)
@@ -16,7 +16,8 @@ namespace DTX2WAV
        public partial class Main : Form
        {
                Form_Recording formRecording;
-
+               Form_Finished_OK formFinishedOK;
+               
                public Main()
                {
                        InitializeComponent();
@@ -212,10 +213,12 @@ namespace DTX2WAV
                        //      MessageBoxIcon.Information
                        //);
 
-                       using (Form_Finished f = new Form_Finished())
-                       {
-                               f.ShowDialog();
-                       }
+                       formFinishedOK = new Form_Finished_OK();
+                       //formFinishedOK.StartPosition = FormStartPosition.CenterParent;
+                       formFinishedOK.ShowDialog(this);
+
+                       formFinishedOK.Dispose();
+                       formFinishedOK = null;
                }
 
                /// <summary>
@@ -330,7 +333,6 @@ namespace DTX2WAV
                        {
                                COPYDATASTRUCT cds = (COPYDATASTRUCT)Marshal.PtrToStructure(m.LParam, typeof(COPYDATASTRUCT));
                                string strMessage = Marshal.PtrToStringUni(cds.lpData);
-//Debug.WriteLine("Msg received: " + strMessage);
                                formRecording.label_state.Text = strMessage;    // Form_Recordingにメッセージの内容を伝える
                        }
                        base.WndProc(ref m);
similarity index 97%
rename from DTX2WAV/Form_FInished.Designer.cs
rename to DTX2WAV/Form_FInished_OK.Designer.cs
index 05e0c82..7938285 100644 (file)
@@ -1,6 +1,6 @@
 namespace DTX2WAV
 {
-       partial class Form_Finished
+       partial class Form_Finished_OK
        {
                /// <summary>
                /// Required designer variable.
@@ -28,7 +28,7 @@
                /// </summary>
                private void InitializeComponent()
                {
-                       System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Form_Finished));
+                       System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Form_Finished_OK));
                        this.button_OK = new System.Windows.Forms.Button();
                        this.label_finished = new System.Windows.Forms.Label();
                        this.SuspendLayout();
similarity index 78%
rename from DTX2WAV/Form_FInished.cs
rename to DTX2WAV/Form_FInished_OK.cs
index 88bbce7..12fed89 100644 (file)
@@ -10,15 +10,16 @@ using System.Windows.Forms;
 
 namespace DTX2WAV
 {
-       public partial class Form_Finished : Form
+       public partial class Form_Finished_OK : Form
        {
-               public Form_Finished()
+               public Form_Finished_OK()
                {
                        InitializeComponent();
                }
 
                private void button_OK_Click(object sender, EventArgs e)
                {
-                       this.Close();           }
+                       this.Close();
+               }
        }
 }
index b694d60..5c559b5 100644 (file)
@@ -3,6 +3,9 @@ using System.Collections.Generic;
 using System.Linq;
 using System.Threading.Tasks;
 using System.Windows.Forms;
+using System.Diagnostics;
+using System.Runtime.InteropServices;
+using System.IO;
 
 namespace DTX2WAV
 {
@@ -14,9 +17,169 @@ namespace DTX2WAV
                [STAThread]
                static void Main()
                {
-                       Application.EnableVisualStyles();
-                       Application.SetCompatibleTextRenderingDefault(false);
-                       Application.Run(new Main());
+                       // 以下、DOBON.NETを参照した。mutexを使って二重起動を抑制。
+                       //Mutex名を決める(必ずアプリケーション固有の文字列に変更すること!)
+                       string mutexName = "DTX2WAV";
+                       //Mutexオブジェクトを作成する
+                       System.Threading.Mutex mutex = new System.Threading.Mutex(false, mutexName);
+
+                       bool hasHandle = false;
+                       try
+                       {
+                               try
+                               {
+                                       // mutexの所有権を要求する
+                                       hasHandle = mutex.WaitOne(0, false);
+                               }
+                               //.NET Framework 2.0以降の場合
+                               catch (System.Threading.AbandonedMutexException)
+                               {
+                                       //別のアプリケーションがmutexを解放しないで終了した時
+                                       hasHandle = true;
+                               }
+                               #region [ mutexを得られなければ、既に起動済みと判断して、そっちを最前面に出して、こっちは終了 ]
+                               if (hasHandle == false)
+                               {
+                                       //得られなかった場合は、すでに起動していると判断して終了
+                                       //MessageBox.Show("多重起動はできません。");
+
+                                       // 得られなかった場合は、既に起動していると判断して、
+                                       // 既に起動しているほうを最前面に出す
+                                       Process prevProcess = GetPreviousProcess();
+                                       if (prevProcess != null)
+                                       {
+                                               WakeupWindow(prevProcess.MainWindowHandle);
+                                       }
+                                       return;
+                               }
+                               #endregion
+
+                               #region [ DTXMania本体が既に起動されていないか確認する。既に起動済みなら警告して終了 ]
+                               Process dtxmaniaProcess = GetProcessesByFileName("DTXManiaGR.exe");
+                               if (dtxmaniaProcess != null)
+                               {
+                                       MessageBox.Show(
+                                               "既にDTXMania本体が起動しています。DTX2WAVを起動する前に、DTXMania本体を終了してください。",
+                                               "DTX2WAV",
+                                               MessageBoxButtons.OK,
+                                               MessageBoxIcon.Exclamation
+                                       );
+                                       return;
+                               }
+
+                               #endregion
+
+                               #region [ アプリを通常通り起動する ]
+                               Application.EnableVisualStyles();
+                               Application.SetCompatibleTextRenderingDefault(false);
+                               Application.Run(new Main());
+                               #endregion
+                       }
+                       finally
+                       {
+                               if (hasHandle)
+                               {
+                                       // mutexを解放する
+                                       mutex.ReleaseMutex();
+                               }
+                               mutex.Close();
+                       }
+
+
                }
+
+               // .NET TIPSより
+               // 実行中の同じアプリケーションのプロセスを取得する
+               // http://www.atmarkit.co.jp/fdotnet/dotnettips/151winshow/winshow.html
+               public static Process GetPreviousProcess()
+               {
+                       Process curProcess = Process.GetCurrentProcess();
+                       Process[] allProcesses = Process.GetProcessesByName(curProcess.ProcessName);
+
+                       foreach (Process checkProcess in allProcesses)
+                       {
+                               // 自分自身のプロセスIDは無視する
+                               if (checkProcess.Id != curProcess.Id)
+                               {
+                                       // プロセスのフルパス名を比較して同じアプリケーションか検証
+                                       if (String.Compare(
+                                                checkProcess.MainModule.FileName,
+                                                curProcess.MainModule.FileName, true) == 0)
+                                       {
+                                               // 同じフルパス名のプロセスを取得
+                                               return checkProcess;
+                                       }
+                               }
+                       }
+
+                       // 同じアプリケーションのプロセスが見つからない!
+                       return null;
+               }
+
+               /// <summary>
+               /// 指定した実行ファイル名のプロセスを取得する。
+               /// https://dobon.net/vb/dotnet/process/getprocessesbyfilename.html
+               /// </summary>
+               /// <param name="searchFileName">検索する実行ファイル名。</param>
+               /// <returns>最初に一致したProcess。</returns>
+               public static System.Diagnostics.Process GetProcessesByFileName(string searchFileName)
+               {
+                       searchFileName = searchFileName.ToLower();
+
+                       //すべてのプロセスを列挙する
+                       foreach (System.Diagnostics.Process p
+                               in System.Diagnostics.Process.GetProcesses())
+                       {
+                               string fileName;
+                               try
+                               {
+                                       //メインモジュールのパスを取得する
+                                       fileName = p.MainModule.FileName;
+                               }
+                               catch (System.ComponentModel.Win32Exception)
+                               {
+                                       //MainModuleの取得に失敗
+                                       fileName = "";
+                               }
+                               if (0 < fileName.Length)
+                               {
+                                       //ファイル名の部分を取得する
+                                       fileName = System.IO.Path.GetFileName(fileName);
+                                       //探しているファイル名と一致した時、コレクションに追加
+                                       if (searchFileName.Equals(fileName.ToLower()))
+                                       {
+                                               return p;
+                                       }
+                               }
+                       }
+
+                       return null;
+               }
+
+
+               // .NET TIPSより
+               // 外部プロセスのウィンドウを最前面にする
+               // http://www.atmarkit.co.jp/fdotnet/dotnettips/151winshow/winshow.html
+               public static void WakeupWindow(IntPtr hWnd)
+               {
+                       // メイン・ウィンドウが最小化されていれば元に戻す
+                       if (IsIconic(hWnd))
+                       {
+                               ShowWindowAsync(hWnd, SW_RESTORE);
+                       }
+
+                       // メイン・ウィンドウを最前面に表示する
+                       SetForegroundWindow(hWnd);
+               }
+               // 外部プロセスのメイン・ウィンドウを起動するためのWin32 API
+               [DllImport("user32.dll")]
+               private static extern bool SetForegroundWindow(IntPtr hWnd);
+               [DllImport("user32.dll")]
+               private static extern bool ShowWindowAsync(IntPtr hWnd, int nCmdShow);
+               [DllImport("user32.dll")]
+               private static extern bool IsIconic(IntPtr hWnd);
+               // ShowWindowAsync関数のパラメータに渡す定義値
+               private const int SW_RESTORE = 9;  // 画面を元の大きさに戻す
+
        }
 }
index c2e9838..f84c5b6 100644 (file)
@@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
 // すべての値を指定するか、次を使用してビルド番号とリビジョン番号を既定に設定できます
 // 既定値にすることができます:
 // [assembly: AssemblyVersion("1.0.*")]
-[assembly: AssemblyVersion("2.0.0.0")]
-[assembly: AssemblyFileVersion("2.0.0.0")]
+[assembly: AssemblyVersion("4.0.0.0")]
+[assembly: AssemblyFileVersion("4.0.0.0")]
index 63fa919..9b4e4aa 100644 (file)
@@ -83,7 +83,8 @@ namespace DTXMania
                                        this.strSTAGEFILE = CSkin.Path(@"Graphics\\ScreenNowLoading background.jpg");
                                        this.b音符を表示する = true;
                                }
-                               if (((cdtx.SOUND_NOWLOADING != null) && (cdtx.SOUND_NOWLOADING.Length > 0)) && File.Exists(cdtx.strフォルダ名 + cdtx.SOUND_NOWLOADING))
+                               if (((cdtx.SOUND_NOWLOADING != null) && (cdtx.SOUND_NOWLOADING.Length > 0)) && File.Exists(cdtx.strフォルダ名 + cdtx.SOUND_NOWLOADING)
+                                       && (!CDTXMania.Instance.DTX2WAVmode.Enabled))
                                {
                                        string strNowLoadingサウンドファイルパス = cdtx.strフォルダ名 + cdtx.SOUND_NOWLOADING;
                                        try
@@ -454,33 +455,37 @@ namespace DTXMania
 
                                case CStage.Eフェーズ.NOWLOADING_BMPファイルを読み込む:
                                        {
-                                               TimeSpan span;
-                                               DateTime timeBeginLoadBMPAVI = DateTime.Now;
-                                               if (CDTXMania.Instance.ConfigIni.bBGA)
-                                                       CDTXMania.Instance.DTX.tBMP_BMPTEXの読み込み();
+                                               if (!CDTXMania.Instance.DTX2WAVmode.Enabled)
+                                               {
+                                                       TimeSpan span;
+                                                       DateTime timeBeginLoadBMPAVI = DateTime.Now;
+                                                       if (CDTXMania.Instance.ConfigIni.bBGA)
+                                                               CDTXMania.Instance.DTX.tBMP_BMPTEXの読み込み();
 
-                                               if (CDTXMania.Instance.ConfigIni.bAVI)
-                                                       CDTXMania.Instance.DTX.tAVIの読み込み();
-                                               span = (TimeSpan)(DateTime.Now - timeBeginLoadBMPAVI);
-                                               Trace.TraceInformation("BMP/AVI読込所要時間({0,4}): {1}", (CDTXMania.Instance.DTX.listBMP.Count + CDTXMania.Instance.DTX.listBMPTEX.Count + CDTXMania.Instance.DTX.listAVI.Count), span.ToString());
+                                                       if (CDTXMania.Instance.ConfigIni.bAVI)
+                                                               CDTXMania.Instance.DTX.tAVIの読み込み();
+                                                       span = (TimeSpan)(DateTime.Now - timeBeginLoadBMPAVI);
+                                                       Trace.TraceInformation("BMP/AVI読込所要時間({0,4}): {1}", (CDTXMania.Instance.DTX.listBMP.Count + CDTXMania.Instance.DTX.listBMPTEX.Count + CDTXMania.Instance.DTX.listAVI.Count), span.ToString());
 
 
-                                               if (bitmapFilename != null)
-                                               {
-                                                       bitmapFilename.Dispose();
-                                                       bitmapFilename = null;
-                                               }
-                                               if (graphicsFilename != null)
-                                               {
-                                                       graphicsFilename.Dispose();
-                                                       graphicsFilename = null;
-                                               }
-                                               if (ftFilename != null)
-                                               {
-                                                       ftFilename.Dispose();
-                                                       ftFilename = null;
+                                                       if (bitmapFilename != null)
+                                                       {
+                                                               bitmapFilename.Dispose();
+                                                               bitmapFilename = null;
+                                                       }
+                                                       if (graphicsFilename != null)
+                                                       {
+                                                               graphicsFilename.Dispose();
+                                                               graphicsFilename = null;
+                                                       }
+                                                       if (ftFilename != null)
+                                                       {
+                                                               ftFilename.Dispose();
+                                                               ftFilename = null;
+                                                       }
                                                }
                                                CDTXMania.Instance.Timer.t更新();
+
                                                base.eフェーズID = CStage.Eフェーズ.NOWLOADING_LPを再配置する;
                                                return (int)E曲読込画面の戻り値.継続;
                                        }
index 67083ef..c779c3e 100644 (file)
@@ -660,10 +660,10 @@ namespace DTXMania
                                        }
                                }
 
-                               // AVI / BGA
                                if (base.eフェーズID != CStage.Eフェーズ.演奏_STAGE_FAILED &&
                                        base.eフェーズID != CStage.Eフェーズ.演奏_STAGE_FAILED_フェードアウト)
                                {
+                                       // AVI / BGA
                                        actAVI.t進行描画(
                                                CDTXMania.Instance.ConfigIni.cdMovieX[CDTXMania.Instance.ConfigIni.eActiveInst],
                                                CDTXMania.Instance.ConfigIni.cdMovieY[CDTXMania.Instance.ConfigIni.eActiveInst],
@@ -3484,7 +3484,7 @@ namespace DTXMania
 
                private void t進行描画_チップ_ウェイリング(ref CChip pChip)
                {
-                       if (CDTXMania.Instance.ConfigIni.bGuitar有効)
+                       if (CDTXMania.Instance.ConfigIni.bGuitar有効 && (!CDTXMania.Instance.DTX2WAVmode.Enabled))
                        {
                                EPart indexInst = pChip.bGuitar可視チップ_Wailing含む ? EPart.Guitar : EPart.Bass;
                                #region [ Sud Hid Inv 処理 ]