From 3cca0e5549ccca876943e163e70822cd173a56b6 Mon Sep 17 00:00:00 2001 From: LuigiBlood Date: Thu, 22 Aug 2019 13:16:58 +0200 Subject: [PATCH 1/3] [App] Add Command Line Combo N64 + 64DD Image Loading With --combo --- Source/Project64-core/AppInit.cpp | 13 ++++++++ Source/Project64-core/Settings.cpp | 1 + Source/Project64-core/Settings/SettingsID.h | 1 + Source/Project64/main.cpp | 37 +++++++++++++++++---- 4 files changed, 46 insertions(+), 6 deletions(-) diff --git a/Source/Project64-core/AppInit.cpp b/Source/Project64-core/AppInit.cpp index 36f73cc48..cf1d4a8b4 100644 --- a/Source/Project64-core/AppInit.cpp +++ b/Source/Project64-core/AppInit.cpp @@ -186,6 +186,19 @@ static bool ParseCommand(int32_t argc, char **argv) g_Settings->SaveBool(Cmd_ShowHelp, true); return false; } + else if (strcmp(argv[i], "--combo") == 0) + { + if (ArgsLeft >= 2) + { + g_Settings->SaveString(Cmd_ComboDiskFile, &(argv[i + 1][0])); + i++; + } + else + { + WriteTrace(TraceAppInit, TraceError, "not enough parameters for '%d: %s'", i, argv[i]); + return false; + } + } else if (ArgsLeft == 0 && argv[i][0] != '-') { g_Settings->SaveString(Cmd_RomFile, &(argv[i][0])); diff --git a/Source/Project64-core/Settings.cpp b/Source/Project64-core/Settings.cpp index ace544033..c8a1fdde4 100644 --- a/Source/Project64-core/Settings.cpp +++ b/Source/Project64-core/Settings.cpp @@ -90,6 +90,7 @@ void CSettings::AddHowToHandleSetting(const char * BaseDirectory) AddHandler(Cmd_BaseDirectory, new CSettingTypeTempString(BaseDirectory)); AddHandler(Cmd_ShowHelp, new CSettingTypeTempBool(false)); AddHandler(Cmd_RomFile, new CSettingTypeTempString("")); + AddHandler(Cmd_ComboDiskFile, new CSettingTypeTempString("")); //Support Files AddHandler(SupportFile_Settings, new CSettingTypeApplicationPath("Settings", "ConfigFile", SupportFile_SettingsDefault)); diff --git a/Source/Project64-core/Settings/SettingsID.h b/Source/Project64-core/Settings/SettingsID.h index b2fc3dd65..dee580f50 100644 --- a/Source/Project64-core/Settings/SettingsID.h +++ b/Source/Project64-core/Settings/SettingsID.h @@ -24,6 +24,7 @@ enum SettingID //Command Settings Cmd_BaseDirectory, Cmd_RomFile, + Cmd_ComboDiskFile, Cmd_ShowHelp, //Support Files diff --git a/Source/Project64/main.cpp b/Source/Project64/main.cpp index 58cde2d79..a4a87d831 100644 --- a/Source/Project64/main.cpp +++ b/Source/Project64/main.cpp @@ -23,24 +23,49 @@ int WINAPI WinMain(HINSTANCE /*hInstance*/, HINSTANCE /*hPrevInstance*/, LPSTR / g_Plugins->SetRenderWindows(&MainWindow, &HiddenWindow); Notify().SetMainWindow(&MainWindow); CSupportWindow SupportWindow; + bool isROMLoaded = false; - if (g_Settings->LoadStringVal(Cmd_RomFile).length() > 0) + if (g_Settings->LoadStringVal(Cmd_RomFile).length() > 0 && g_Settings->LoadStringVal(Cmd_ComboDiskFile).length() > 0) { + //Handle Combo Loading (N64 ROM AND 64DD Disk) + MainWindow.Show(true); //Show the main window - //N64 ROM or 64DD Disk + + stdstr extcombo = CPath(g_Settings->LoadStringVal(Cmd_ComboDiskFile)).GetExtension(); + stdstr ext = CPath(g_Settings->LoadStringVal(Cmd_RomFile)).GetExtension(); + + if (g_Settings->LoadStringVal(Cmd_ComboDiskFile).length() > 0 + && ((_stricmp(extcombo.c_str(), "ndd") == 0) || (_stricmp(extcombo.c_str(), "d64") == 0))) + { + if ((!(_stricmp(ext.c_str(), "ndd") == 0)) && (!(_stricmp(ext.c_str(), "d64") == 0))) + { + //Cmd_ComboDiskFile must be a 64DD disk image + //Cmd_RomFile must be a N64 ROM image + isROMLoaded = CN64System::RunDiskComboImage(g_Settings->LoadStringVal(Cmd_RomFile).c_str(), g_Settings->LoadStringVal(Cmd_ComboDiskFile).c_str()); + } + } + } + else if (g_Settings->LoadStringVal(Cmd_RomFile).length() > 0) + { + //Handle Single Game (N64 ROM or 64DD Disk) + + MainWindow.Show(true); //Show the main window + stdstr ext = CPath(g_Settings->LoadStringVal(Cmd_RomFile)).GetExtension(); if ((!(_stricmp(ext.c_str(), "ndd") == 0)) && (!(_stricmp(ext.c_str(), "d64") == 0))) { - //File Extension is not *.ndd so it should be a N64 ROM - CN64System::RunFileImage(g_Settings->LoadStringVal(Cmd_RomFile).c_str()); + //File Extension is not *.ndd/*.d64 so it should be a N64 ROM + isROMLoaded = CN64System::RunFileImage(g_Settings->LoadStringVal(Cmd_RomFile).c_str()); } else { //Ext is *.ndd/*.d64, so it should be a disk file. - CN64System::RunDiskImage(g_Settings->LoadStringVal(Cmd_RomFile).c_str()); + isROMLoaded = CN64System::RunDiskImage(g_Settings->LoadStringVal(Cmd_RomFile).c_str()); } } - else + + //Handle Main Window if ROM is not loaded and running + if (!isROMLoaded) { SupportWindow.Show(reinterpret_cast(MainWindow.GetWindowHandle())); if (UISettingsLoadBool(RomBrowser_Enabled)) From f43201fdea7927b1e22b24a9426ef6289a5cde39 Mon Sep 17 00:00:00 2001 From: LuigiBlood Date: Thu, 22 Aug 2019 13:44:30 +0200 Subject: [PATCH 2/3] [App] Add "Open Combo" File Menu for Combo N64 + 64DD Loading. Also added seperate functions for generic game loading, N64 ROM loading, and 64DD Disk loading. --- Source/Project64-core/Multilanguage.h | 1 + .../Multilanguage/LanguageClass.cpp | 1 + Source/Project64/UserInterface/MainMenu.cpp | 51 +++++++++++++++++-- Source/Project64/UserInterface/MainMenu.h | 5 +- .../Project64/UserInterface/MenuShortCuts.cpp | 3 ++ 5 files changed, 55 insertions(+), 6 deletions(-) diff --git a/Source/Project64-core/Multilanguage.h b/Source/Project64-core/Multilanguage.h index 39bb97669..de9e6556a 100644 --- a/Source/Project64-core/Multilanguage.h +++ b/Source/Project64-core/Multilanguage.h @@ -64,6 +64,7 @@ enum LanguageStringID MENU_RECENT_ROM = 107, MENU_RECENT_DIR = 108, MENU_EXIT = 109, + MENU_OPEN_COMBO = 110, //System Menu MENU_SYSTEM = 120, diff --git a/Source/Project64-core/Multilanguage/LanguageClass.cpp b/Source/Project64-core/Multilanguage/LanguageClass.cpp index fc625f30a..2a92c02ee 100644 --- a/Source/Project64-core/Multilanguage/LanguageClass.cpp +++ b/Source/Project64-core/Multilanguage/LanguageClass.cpp @@ -71,6 +71,7 @@ void CLanguage::LoadDefaultStrings(void) DEF_STR(MENU_RECENT_ROM, "Recent ROM"); DEF_STR(MENU_RECENT_DIR, "Recent ROM Directories"); DEF_STR(MENU_EXIT, "E&xit"); + DEF_STR(MENU_OPEN_COMBO, "Open &Combo"); //System Menu DEF_STR(MENU_SYSTEM, "&System"); diff --git a/Source/Project64/UserInterface/MainMenu.cpp b/Source/Project64/UserInterface/MainMenu.cpp index 76091fb52..de7e3ca79 100644 --- a/Source/Project64/UserInterface/MainMenu.cpp +++ b/Source/Project64/UserInterface/MainMenu.cpp @@ -96,7 +96,29 @@ int CMainMenu::ProcessAccelerator(HWND hWnd, void * lpMsg) std::string CMainMenu::ChooseFileToOpen(HWND hParent) { CPath FileName; - const char * Filter = "N64 ROMs (*.zip, *.7z, *.?64, *.rom, *.usa, *.jap, *.pal, *.bin, *.ndd)\0*.?64;*.zip;*.7z;*.bin;*.rom;*.usa;*.jap;*.pal;*.ndd\0All files (*.*)\0*.*\0"; + const char * Filter = "N64 ROMs & Disks (*.zip, *.7z, *.?64, *.rom, *.usa, *.jap, *.pal, *.bin, *.ndd, *.d64)\0*.?64;*.zip;*.7z;*.bin;*.rom;*.usa;*.jap;*.pal;*.ndd;*.d64\0All files (*.*)\0*.*\0"; + if (FileName.SelectFile(hParent, g_Settings->LoadStringVal(RomList_GameDir).c_str(), Filter, true)) + { + return FileName; + } + return ""; +} + +std::string CMainMenu::ChooseROMFileToOpen(HWND hParent) +{ + CPath FileName; + const char * Filter = "N64 ROMs (*.zip, *.7z, *.?64, *.rom, *.usa, *.jap, *.pal, *.bin)\0*.?64;*.zip;*.7z;*.bin;*.rom;*.usa;*.jap;*.pal\0All files (*.*)\0*.*\0"; + if (FileName.SelectFile(hParent, g_Settings->LoadStringVal(RomList_GameDir).c_str(), Filter, true)) + { + return FileName; + } + return ""; +} + +std::string CMainMenu::ChooseDiskFileToOpen(HWND hParent) +{ + CPath FileName; + const char * Filter = "N64DD Disk Image (*.ndd, *.d64)\0*.ndd;*.d64\0All files (*.*)\0*.*\0"; if (FileName.SelectFile(hParent, g_Settings->LoadStringVal(RomList_GameDir).c_str(), Filter, true)) { return FileName; @@ -130,6 +152,23 @@ void CMainMenu::OnOpenRom(HWND hWnd) } } +void CMainMenu::OnOpenCombo(HWND hWnd) +{ + std::string FileROM = ChooseROMFileToOpen(hWnd); + if (FileROM.length() == 0) + { + return; + } + + std::string FileDisk = ChooseDiskFileToOpen(hWnd); + if (FileDisk.length() == 0) + { + return; + } + + g_BaseSystem->RunDiskComboImage(FileROM.c_str(), FileDisk.c_str()); +} + void CMainMenu::OnRomInfo(HWND hWnd) { if (g_Disk) @@ -245,6 +284,7 @@ bool CMainMenu::ProcessMessage(HWND hWnd, DWORD /*FromAccelerator*/, DWORD MenuI switch (MenuID) { case ID_FILE_OPEN_ROM: OnOpenRom(hWnd); break; + case ID_FILE_OPEN_COMBO: OnOpenCombo(hWnd); break; case ID_FILE_ROM_INFO: OnRomInfo(hWnd); break; case ID_FILE_STARTEMULATION: m_Gui->SaveWindowLoc(); @@ -293,12 +333,11 @@ bool CMainMenu::ProcessMessage(HWND hWnd, DWORD /*FromAccelerator*/, DWORD MenuI WriteTrace(TraceUserInterface, TraceDebug, "ID_SYSTEM_SWAPDISK"); { // Open Disk - CPath FileName; - const char * Filter = "N64DD Disk Image (*.ndd, *.d64)\0*.ndd;*.d64\0All files (*.*)\0*.*\0"; - if (FileName.SelectFile(hWnd, g_Settings->LoadStringVal(RomList_GameDir).c_str(), Filter, true)) + stdstr FileName = ChooseDiskFileToOpen(hWnd); + if (FileName.length() != 0) { g_Disk->SaveDiskImage(); - g_Disk->SwapDiskImage(FileName); + g_Disk->SwapDiskImage(FileName.c_str()); } } break; @@ -752,6 +791,8 @@ void CMainMenu::FillOutMenu(HMENU hMenu) MenuItemList FileMenu; Item.Reset(ID_FILE_OPEN_ROM, MENU_OPEN, m_ShortCuts.ShortCutString(ID_FILE_OPEN_ROM, RunningState)); FileMenu.push_back(Item); + Item.Reset(ID_FILE_OPEN_COMBO, MENU_OPEN_COMBO, m_ShortCuts.ShortCutString(ID_FILE_OPEN_COMBO, RunningState)); + FileMenu.push_back(Item); if (!inBasicMode) { Item.Reset(ID_FILE_ROM_INFO, MENU_ROM_INFO, m_ShortCuts.ShortCutString(ID_FILE_ROM_INFO, RunningState)); diff --git a/Source/Project64/UserInterface/MainMenu.h b/Source/Project64/UserInterface/MainMenu.h index 8490b4492..6fd4bb5fc 100644 --- a/Source/Project64/UserInterface/MainMenu.h +++ b/Source/Project64/UserInterface/MainMenu.h @@ -4,7 +4,7 @@ enum MainMenuID { //File Menu - ID_FILE_OPEN_ROM = 4000, ID_FILE_ROM_INFO, ID_FILE_STARTEMULATION, ID_FILE_ENDEMULATION, + ID_FILE_OPEN_ROM = 4000, ID_FILE_OPEN_COMBO, ID_FILE_ROM_INFO, ID_FILE_STARTEMULATION, ID_FILE_ENDEMULATION, ID_FILE_ROMDIRECTORY, ID_FILE_REFRESHROMLIST, ID_FILE_EXIT, //language @@ -75,6 +75,7 @@ private: CMainMenu& operator=(const CMainMenu&); // Disable assignment void OnOpenRom(HWND hWnd); + void OnOpenCombo(HWND hWnd); void OnRomInfo(HWND hWnd); void OnEndEmulation(void); void OnScreenShot(void); @@ -88,6 +89,8 @@ private: stdstr GetFileLastMod(const CPath & FileName); void RebuildAccelerators(void); std::string ChooseFileToOpen(HWND hParent); + std::string ChooseROMFileToOpen(HWND hParent); + std::string ChooseDiskFileToOpen(HWND hParent); void SetTraceModuleSetttings(SettingID Type); static void SettingsChanged(CMainMenu * _this); diff --git a/Source/Project64/UserInterface/MenuShortCuts.cpp b/Source/Project64/UserInterface/MenuShortCuts.cpp index 715065d82..6ddfe48d5 100644 --- a/Source/Project64/UserInterface/MenuShortCuts.cpp +++ b/Source/Project64/UserInterface/MenuShortCuts.cpp @@ -379,6 +379,7 @@ void CShortCuts::Load(bool InitialValues) m_ShortCuts.clear(); AddShortCut(ID_FILE_OPEN_ROM, STR_SHORTCUT_FILEMENU, MENU_OPEN, CMenuShortCutKey::ACCESS_NOT_IN_FULLSCREEN); + AddShortCut(ID_FILE_OPEN_COMBO, STR_SHORTCUT_FILEMENU, MENU_OPEN_COMBO, CMenuShortCutKey::ACCESS_NOT_IN_FULLSCREEN); AddShortCut(ID_FILE_ROM_INFO, STR_SHORTCUT_FILEMENU, MENU_ROM_INFO, CMenuShortCutKey::ACCESS_NOT_IN_FULLSCREEN); AddShortCut(ID_FILE_STARTEMULATION, STR_SHORTCUT_FILEMENU, MENU_START, CMenuShortCutKey::ACCESS_NOT_IN_FULLSCREEN); AddShortCut(ID_FILE_ENDEMULATION, STR_SHORTCUT_FILEMENU, MENU_END, CMenuShortCutKey::ACCESS_GAME_RUNNING); @@ -431,6 +432,8 @@ void CShortCuts::Load(bool InitialValues) { m_ShortCuts.find(ID_FILE_OPEN_ROM)->second.AddShortCut('O', TRUE, false, false, CMenuShortCutKey::ACCESS_GAME_RUNNING); m_ShortCuts.find(ID_FILE_OPEN_ROM)->second.AddShortCut('O', TRUE, false, false, CMenuShortCutKey::ACCESS_GAME_NOT_RUNNING); + m_ShortCuts.find(ID_FILE_OPEN_COMBO)->second.AddShortCut('O', TRUE, false, TRUE, CMenuShortCutKey::ACCESS_GAME_RUNNING); + m_ShortCuts.find(ID_FILE_OPEN_COMBO)->second.AddShortCut('O', TRUE, false, TRUE, CMenuShortCutKey::ACCESS_GAME_NOT_RUNNING); m_ShortCuts.find(ID_FILE_STARTEMULATION)->second.AddShortCut(VK_F11, false, false, false, CMenuShortCutKey::ACCESS_GAME_NOT_RUNNING); m_ShortCuts.find(ID_FILE_ENDEMULATION)->second.AddShortCut(VK_F12, false, false, false, CMenuShortCutKey::ACCESS_GAME_RUNNING); m_ShortCuts.find(ID_FILE_REFRESHROMLIST)->second.AddShortCut(VK_F5, false, false, false, CMenuShortCutKey::ACCESS_GAME_NOT_RUNNING); From ad2bcddfb231087d6d77027d1771f3068a9588da Mon Sep 17 00:00:00 2001 From: LuigiBlood Date: Thu, 22 Aug 2019 14:15:01 +0200 Subject: [PATCH 3/3] [Lang] Update English/French with Open Combo --- Lang/English.pj.Lang | 1 + Lang/French.pj.Lang | 1 + 2 files changed, 2 insertions(+) diff --git a/Lang/English.pj.Lang b/Lang/English.pj.Lang index 051bd4902..30dd81bdf 100644 --- a/Lang/English.pj.Lang +++ b/Lang/English.pj.Lang @@ -34,6 +34,7 @@ #107# "Recent ROM" #108# "Recent ROM Directories" #109# "E&xit" +#110# "Open &Combo" //System Menu #120# "&System" diff --git a/Lang/French.pj.Lang b/Lang/French.pj.Lang index 1d0063498..166d84a97 100644 --- a/Lang/French.pj.Lang +++ b/Lang/French.pj.Lang @@ -34,6 +34,7 @@ #107# "ROM récentes" #108# "Répertoires des ROM récentes" #109# "&Quitter" +#110# "Ouvrir &Combo" //System Menu #120# "&Système"