From: <sv...@op...> - 2024-04-07 20:13:23
|
Author: sagamusix Date: Sun Apr 7 22:13:15 2024 New Revision: 20522 URL: https://source.openmpt.org/browse/openmpt/?op=revision&rev=20522 Log: [New] Add a /play command line switch, which automatically starts playback of one of the modules passed via the command-line (https://bugs.openmpt.org/view.php?id=1751). Modified: trunk/OpenMPT/mptrack/IPCWindow.cpp trunk/OpenMPT/mptrack/IPCWindow.h trunk/OpenMPT/mptrack/Mptrack.cpp Modified: trunk/OpenMPT/mptrack/IPCWindow.cpp ============================================================================== --- trunk/OpenMPT/mptrack/IPCWindow.cpp Sun Apr 7 22:01:56 2024 (r20521) +++ trunk/OpenMPT/mptrack/IPCWindow.cpp Sun Apr 7 22:13:15 2024 (r20522) @@ -10,9 +10,11 @@ #include "stdafx.h" #include "IPCWindow.h" +#include "Mainfrm.h" +#include "ModDocTemplate.h" +#include "Mptrack.h" #include "../common/version.h" -#include "Mptrack.h" OPENMPT_NAMESPACE_BEGIN @@ -86,6 +88,13 @@ result = (theApp.GetConfigPath().ToWide() == path) ? 1 : 0; } break; + case Function::PlayCurrent: + if(CMainFrame::GetMainFrame()) + { + if(CMainFrame::GetMainFrame()->PlayMod(CMainFrame::GetMainFrame()->GetActiveDoc())) + result = 1; + } + break; default: result = 0; break; @@ -209,7 +218,7 @@ - bool SendToIPC(const std::vector<mpt::PathString> &filenames) + bool SendToIPC(const std::vector<mpt::PathString> &filenames, bool autoplay) { HWND ipcWnd = FindIPCWindow(); if(!ipcWnd) @@ -227,6 +236,10 @@ return false; } } + if(autoplay) + { + SendIPC(ipcWnd, Function::PlayCurrent); + } return true; } Modified: trunk/OpenMPT/mptrack/IPCWindow.h ============================================================================== --- trunk/OpenMPT/mptrack/IPCWindow.h Sun Apr 7 22:01:56 2024 (r20521) +++ trunk/OpenMPT/mptrack/IPCWindow.h Sun Apr 7 22:13:15 2024 (r20522) @@ -23,7 +23,8 @@ GetVersion = 0x03, // returns Version::GewRawVersion() GetArchitecture = 0x04, // returns mpt::OS::Windows::Architecture HasSameBinaryPath = 0x05, - HasSameSettingsPath = 0x06 + HasSameSettingsPath = 0x06, + PlayCurrent = 0x07, }; void Open(HINSTANCE hInstance); @@ -48,7 +49,7 @@ HWND FindIPCWindow(FlagSet<InstanceRequirements> require); // Send file open requests to other OpenMPT instance, if there is one - bool SendToIPC(const std::vector<mpt::PathString> &filenames); + bool SendToIPC(const std::vector<mpt::PathString> &filenames, bool autoplay); } Modified: trunk/OpenMPT/mptrack/Mptrack.cpp ============================================================================== --- trunk/OpenMPT/mptrack/Mptrack.cpp Sun Apr 7 22:01:56 2024 (r20521) +++ trunk/OpenMPT/mptrack/Mptrack.cpp Sun Apr 7 22:13:15 2024 (r20522) @@ -294,7 +294,8 @@ public: std::vector<mpt::PathString> m_fileNames; bool m_noDls = false, m_noPlugins = false, m_noAssembly = false, m_noSysCheck = false, m_noWine = false, - m_portable = false, m_noCrashHandler = false, m_debugCrashHandler = false, m_sharedInstance = false; + m_portable = false, m_noCrashHandler = false, m_debugCrashHandler = false, m_sharedInstance = false, + m_autoPlay = false; #ifdef ENABLE_TESTS bool m_noTests = false; #endif @@ -315,6 +316,7 @@ if(!lstrcmpi(param, _T("noCrashHandler"))) { m_noCrashHandler = true; return; } if(!lstrcmpi(param, _T("DebugCrashHandler"))) { m_debugCrashHandler = true; return; } if(!lstrcmpi(param, _T("shared"))) { m_sharedInstance = true; return; } + if(!lstrcmpi(param, _T("play"))) { m_autoPlay = true; return; } #ifdef ENABLE_TESTS if (!lstrcmpi(param, _T("noTests"))) { m_noTests = true; return; } #endif @@ -1165,7 +1167,7 @@ // Set up paths to store configuration in SetupPaths(cmdInfo.m_portable); - if(cmdInfo.m_sharedInstance && IPCWindow::SendToIPC(cmdInfo.m_fileNames)) + if(cmdInfo.m_sharedInstance && IPCWindow::SendToIPC(cmdInfo.m_fileNames, cmdInfo.m_autoPlay)) { ExitProcess(0); } @@ -1269,7 +1271,7 @@ ExceptionHandler::ConfigureSystemHandler(); } - if(TrackerSettings::Instance().MiscUseSingleInstance && IPCWindow::SendToIPC(cmdInfo.m_fileNames)) + if(TrackerSettings::Instance().MiscUseSingleInstance && IPCWindow::SendToIPC(cmdInfo.m_fileNames, cmdInfo.m_autoPlay)) { ExitProcess(0); } @@ -1466,6 +1468,10 @@ pMainFrame->ShowWindow(m_nCmdShow); pMainFrame->UpdateWindow(); + if(cmdInfo.m_autoPlay) + { + pMainFrame->PlayMod(pMainFrame->GetActiveDoc()); + } EndWaitCursor(); |