diff --git a/build.bat b/build.bat index c1aec29..8d78e18 100644 --- a/build.bat +++ b/build.bat @@ -1,5 +1,5 @@ @echo off -set ver=0.2.4 +set ver=0.2.5 rem build script for the distributable versions of tadpole if not exist "venv\" ( py -m venv venv diff --git a/tadpole.py b/tadpole.py index dc49d0f..eb5ba1f 100644 --- a/tadpole.py +++ b/tadpole.py @@ -9,6 +9,7 @@ import frogtool import tadpole_functions +import time def RunFrogTool(): drive = window.combobox_drive.currentText() @@ -78,6 +79,25 @@ def viewThumbnail(rom_path): window.window_thumbnail = thumbnailWindow() window.window_thumbnail.loadThumbnail(rom_path) window.window_thumbnail.show() + +def BGM_change(source=""): + #Check the selected drive looks like a Frog card + drive = window.combobox_drive.currentText() + + if not tadpole_functions.checkDriveLooksFroggy(drive): + QMessageBox.about(window, "Something doesn't Look Right","The selected drive doesn't contain critical SF2000 files. The action you selected has been aborted for your safety.") + return + + msgBox = QMessageBox() + msgBox.setWindowTitle("Downloading Background Music") + msgBox.setText("Now downloading Background music. Depending on your internet connection speed this may take some time, please wait patiently.") + msgBox.show() + if tadpole_functions.changeBackgroundMusic(drive,source): + msgBox.close() + QMessageBox.about(window,"Success","Background music changed successfully") + else: + msgBox.close() + QMessageBox.about(window,"Failure","Something went wrong while trying to change the background music") #SubClass QMainWindow to create a Tadpole general interface @@ -143,12 +163,23 @@ def __init__(self): layout.addWidget(self.tbl_gamelist,rowCounter, 0, 1, -1) def create_actions(self): + #File Menu self.about_action = QAction("&About", self, triggered=self.about) self.exit_action = QAction("E&xit", self, shortcut="Ctrl+Q",triggered=self.close) + #OS Menu self.action_changeBootLogo = QAction("Change &Boot Logo", self, triggered=self.changeBootLogo) self.GBABIOSFix_action = QAction("&GBA BIOS Fix", self, triggered=self.GBABIOSFix) self.action_changeShortcuts = QAction("Change Game Shortcuts", self, triggered=self.changeGameShortcuts) self.action_removeShortcutLabels = QAction("Remove Shortcut Labels", self, triggered=self.removeShortcutLabels) + #Background Music Menu + self.action_DisableBackgroundMusic = QAction("&Disable", self, triggered=self.BGM_DisableBackgroundMusic) + self.action_bgm_donkeyKong = QAction("Donkey Kong", self, triggered=self.BGM_DonkeyKong) + self.action_bgm_pokemon = QAction("Pokemon", self, triggered=self.BGM_Pokemon) + self.action_bgm_supermariooverworld = QAction("Super Mario Overworld", self, triggered=self.BGM_SuperMarioOverworld) + #Console Logos + self.action_consolelogos_Default = QAction("Restore Default", self, triggered=self.ConsoleLogos_RestoreDefault) + self.action_consolelogos_Western = QAction("Western Logos", self, triggered=self.ConsoleLogos_WesternLogos) + def loadMenus(self): self.menu_file = self.menuBar().addMenu("&File") @@ -160,10 +191,16 @@ def loadMenus(self): self.menu_os.addAction(self.GBABIOSFix_action) self.menu_os.addAction(self.action_changeShortcuts) self.menu_os.addAction(self.action_removeShortcutLabels) - - - + + self.menu_bgm = self.menuBar().addMenu("&Background Music") + self.menu_bgm.addAction(self.action_DisableBackgroundMusic) + self.menu_bgm.addAction(self.action_bgm_donkeyKong) + self.menu_bgm.addAction(self.action_bgm_pokemon) + self.menu_bgm.addAction(self.action_bgm_supermariooverworld) + self.menu_consoleLogos = self.menuBar().addMenu("Console Logos") + self.menu_consoleLogos.addAction(self.action_consolelogos_Default) + self.menu_consoleLogos.addAction(self.action_consolelogos_Western) def about(self): QMessageBox.about(self, "About Tadpole","Tadpole was created by EricGoldstein based on the original work from tzlion on frogtool") @@ -194,8 +231,9 @@ def changeBootLogo(self): QMessageBox.about(self, "Change Boot Logo","Boot logo successfully changed") def changeGameShortcuts(self): - #Check the selected drive looks like a Frog card drive = window.combobox_drive.currentText() + #Check the selected drive looks like a Frog card + #Open a new modal to change the shortcuts for a specific gamename window.window_shortcuts = changeGameShortcutsWindow() window.window_shortcuts.setDrive(drive) @@ -203,10 +241,47 @@ def changeGameShortcuts(self): def removeShortcutLabels(self): self.UnderDevelopmentPopup() + + def ConsoleLogos_RestoreDefault(self): + self.ConsoleLogos_change("https://github.com/EricGoldsteinNz/SF2000_Resources/raw/main/ConsoleLogos/default/sfcdr.cpl") + + def ConsoleLogos_WesternLogos(self): + self.ConsoleLogos_change("https://github.com/EricGoldsteinNz/SF2000_Resources/raw/main/ConsoleLogos/western_console_logos/sfcdr.cpl") + + + def BGM_DisableBackgroundMusic(self): + BGM_change() + + def BGM_Pokemon(self): + BGM_change("https://github.com/EricGoldsteinNz/SF2000_Resources/raw/main/BackgroundMusic/Pokemon-Theme.bgm") + + def BGM_DonkeyKong(self): + BGM_change("https://github.com/EricGoldsteinNz/SF2000_Resources/raw/main/BackgroundMusic/Donkey_Kong_Country-Aquatic_Ambience.bgm") + + def BGM_SuperMarioOverworld(self): + BGM_change("https://github.com/EricGoldsteinNz/SF2000_Resources/raw/main/BackgroundMusic/Super_Mario-Overworld_Theme.bgm") def UnderDevelopmentPopup(self): QMessageBox.about(self, "Developement","This feature is still under development") + def ConsoleLogos_change(self, url): + drive = window.combobox_drive.currentText() + + if not tadpole_functions.checkDriveLooksFroggy(drive): + QMessageBox.about(window, "Something doesn't Look Right","The selected drive doesn't contain critical SF2000 files. The action you selected has been aborted for your safety.") + return + + msgBox = QMessageBox() + msgBox.setWindowTitle("Downloading Console Logos") + msgBox.setText("Now downloading Console Logos. Depending on your internet connection speed this may take some time, please wait patiently.") + msgBox.show() + if tadpole_functions.changeConsoleLogos(drive, url): + msgBox.close() + QMessageBox.about(self, "Success","Console logos successfully changed") + else: + msgBox.close() + QMessageBox.about(self, "Failure","ERROR: Something went wrong while trying to change the console logos") + # Subclass Qidget to create a thumbnail viewing window class thumbnailWindow(QWidget): @@ -312,6 +387,8 @@ def changeShortcut(self): return tadpole_functions.changeGameShortcut(f"{self.drive}",console,position,game) print(f"changed {console} shortcut {position} to {game} successfully") + QMessageBox.about(window,"Success",f"changed {console} shortcut {position} to {game} successfully") + #Initialise the Application app = QApplication(sys.argv) diff --git a/tadpole_functions.py b/tadpole_functions.py index c9ecd22..bbb0608 100644 --- a/tadpole_functions.py +++ b/tadpole_functions.py @@ -7,6 +7,7 @@ import struct import zlib import frogtool +import requests systems = { @@ -109,10 +110,9 @@ def QImageToRGB565Logo(inputQImage): } def getThumbnailFromZXX(filepath): - return False -""" - file_handle = open(filepath, 'rb') #rb for read, wb for write - zxx_content = bytearray(file_handle.read(os.path.getsize(filepath))) + """ + file_handle = open(filepath, 'rb') #rb for read bytes + zxx_content = bytearray(file_handle.read(os.path.getsize(filepath)))#can probably reduce this to 288*104*2 file_handle.close() thumbnailQImage = QImage() for y in range (0, 288): @@ -121,8 +121,9 @@ def getThumbnailFromZXX(filepath): intColor = thumbnailQImage.setPixel(x,y,) - return thumbnailQImage -""" + return thumbnailQImage""" + return False + offset_logo_presequence = [0x62, 0x61, 0x64, 0x5F, 0x65, 0x78, 0x63, 0x65, 0x70, 0x74, 0x69, 0x6F, 0x6E, 0x00, 0x00, 0x00] offset_buttonMap_presequence = [0x00, 0x00, 0x00, 0x71, 0xDB, 0x8E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00] offset_buttonMap_postsequence = [0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00] @@ -249,9 +250,9 @@ def findSequence(needle, haystack, offset = 0): froggyFoldersAndFiles = [ -"\bios", -"\Resources", -"\bios\bisrv.asd" +"/bios", +"/Resources", +"/bios/bisrv.asd" ] """ @@ -263,6 +264,37 @@ def findSequence(needle, haystack, offset = 0): """ def checkDriveLooksFroggy(drivePath): for file in froggyFoldersAndFiles: - if not (os.path.exists(file_path)): + if not (os.path.exists(f"{drivePath}/{file}")): + print(f"missing file {drivePath}/{file}") return False - return True \ No newline at end of file + return True + +""" +This function downloads a file from the internet and renames it to pagefile.sys to replace the background music. + + +""" +def changeBackgroundMusic(drivePath, url=""): + return downloadAndReplace(drivePath, "/Resources/pagefile.sys", url) + +def changeConsoleLogos(drivePath, url=""): + return downloadAndReplace(drivePath, "/Resources/sfcdr.cpl", url) + +def downloadAndReplace(drivePath, fileToReplace, url=""): + try: + #retrieve bgm from github resources + content = "" + if not url == "": + print(f"Downloading {fileToReplace} from {url}") + content = requests.get(url).content + #write the new bgm to file + bgmPath = f"{drivePath}{fileToReplace}" + file_handle = open(bgmPath, 'wb') #rb for read, wb for write + if not content == "": + file_handle.write(content) + file_handle.close() + print ("Finished download and replace successfully") + return True + except (OSError, IOError) as error: + print("An error occured while trying to download and replace a file.") + return False \ No newline at end of file diff --git a/versioninfo b/versioninfo index 5cb77c5..3a9185a 100644 --- a/versioninfo +++ b/versioninfo @@ -1,7 +1,7 @@ VSVersionInfo( ffi=FixedFileInfo( - filevers=(0, 2, 1, 0), - prodvers=(0, 2, 1, 0), + filevers=(0, 2, 5, 0), + prodvers=(0, 2, 5, 0), mask=0x3f, flags=0x0, OS=0x4, @@ -15,12 +15,12 @@ VSVersionInfo( u'080904B0', [StringStruct(u'CompanyName', u'EricGoldstein'), StringStruct(u'FileDescription', u'tadpole'), - StringStruct(u'FileVersion', u'0.2.4'), + StringStruct(u'FileVersion', u'0.2.5'), StringStruct(u'InternalName', u'tadpole'), StringStruct(u'LegalCopyright', u'by EricGoldstein 2023'), StringStruct(u'OriginalFilename', u'tadpole.exe'), StringStruct(u'ProductName', u'tadpole'), - StringStruct(u'ProductVersion', u'0.2.4')]) + StringStruct(u'ProductVersion', u'0.2.5')]) ]), VarFileInfo([VarStruct(u'Translation', [2057, 1200])]) ]