Skip to content

Commit

Permalink
Merge pull request #4 from EricGoldsteinNz/v0.2.1
Browse files Browse the repository at this point in the history
Added Features:
Refresh drives button
"ALL" systems rebuilding option
GBA BIOS Fix
Games List Displayed
  • Loading branch information
EricGoldsteinNz authored Jun 25, 2023
2 parents 37a3029 + cb637d4 commit f676f66
Show file tree
Hide file tree
Showing 5 changed files with 169 additions and 36 deletions.
6 changes: 4 additions & 2 deletions build.bat
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,13 @@ if not exist "venv\Lib\site-packages\PyInstaller" (
if not exist "venv\Lib\site-packages\PIL" (
venv\Scripts\python -m pip install Pillow
)
pyinstaller.exe --onefile -F tadpole.py --icon frog.ico --clean --noconsole
pyinstaller.exe --onefile -F tadpole.py --icon frog.ico --clean --noconsole --version-file versioninfo
copy README.md "dist\readme.md"
copy LICENSE "dist\license.txt"
copy tadpole.py "dist\tadpole.py"
copy frogtool.py "dist\frogtool.py"
copy tadpole_functions.py "dist\tadpole_functions.py"
cd dist
tar -a -cf tadpole-%ver%-win.zip tadpole.exe readme.txt license.txt
tar -a -cf tadpole-%ver%-py.zip tadpole.py readme.txt license.txt
tar -a -cf tadpole-%ver%-py.zip tadpole.py frogtool.py tadpole_functions.py readme.txt license.txt
cd ../
25 changes: 16 additions & 9 deletions frogtool.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,14 +85,23 @@ def sort_without_file_ext(unsorted_list):
return sorted(sort_map, key=sort_map.get)


def process_sys(drive, system, test_mode):
print(f"Processing {system}")

roms_path = f"{drive}/{system}"
def getROMList(roms_path):
if not os.path.isdir(roms_path):
print(f"! Couldn't find folder {roms_path}")
print(" Check the provided path points to an SF2000 SD card!")
raise StopExecution
files = os.scandir(roms_path)
files = list(filter(check_rom, files))
filenames = list(map(file_entry_to_name, files))
return filenames
#TODO

def process_sys(drive, system, test_mode):
print(f"Processing {system}")

roms_path = f"{drive}/{system}"
filenames = getROMList(roms_path)


index_path_files = f"{drive}/Resources/{systems[system][0]}"
index_path_cn = f"{drive}/Resources/{systems[system][1]}"
Expand All @@ -106,9 +115,8 @@ def process_sys(drive, system, test_mode):
if system != "ARCADE":
convert_zip_image_pairs_to_zxx(roms_path, system)

files = os.scandir(roms_path)
files = list(filter(check_rom, files))
no_files = len(files)

no_files = len(filenames)
if no_files == 0:
print("No ROMs found! Type Y to confirm you want to save an empty game list, or anything else to cancel")
conf = input()
Expand All @@ -118,7 +126,7 @@ def process_sys(drive, system, test_mode):
else:
print(f"Found {no_files} ROMs")

filenames = list(map(file_entry_to_name, files))

stripped_names = list(map(strip_file_extension, filenames))

# prepare maps of filenames to index name for the 3 index files
Expand Down Expand Up @@ -146,7 +154,6 @@ def find_matching_file_diff_ext(target, files):


def convert_zip_image_pairs_to_zxx(roms_path, system):

img_files = os.scandir(roms_path)
img_files = list(filter(check_img, img_files))
zip_files = os.scandir(roms_path)
Expand Down
140 changes: 118 additions & 22 deletions tadpole.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,54 @@
from PyQt5.QtWidgets import (QApplication, QMainWindow, QWidget, QMessageBox, QGridLayout, QLabel, QComboBox, QPushButton)
#GUI imports
from PyQt5.QtWidgets import *
from PyQt5.QtGui import (QIcon)
import frogtool
#OS imports - these should probably be moved somewhere else
import os
import sys
import string
#Feature imports
import frogtool
import tadpole_functions


def RunFrogTool():
drive = window.combobox_drive.currentText()
console = window.combobox_console.currentText()

print(f"Running Frogtool with drive ({drive}) and console ({console})")
result = frogtool.process_sys(drive,console, False)
QMessageBox.about(window,"Result",result)
print(f"Running frogtool with drive ({drive}) and console ({console})")
try:
if(console =="ALL"):
for console in frogtool.systems.keys():
result = frogtool.process_sys(drive,console, False)
QMessageBox.about(window,"Result",result)

else:
result = frogtool.process_sys(drive,console, False)
QMessageBox.about(window,"Result",result)
except frogtool.StopExecution:
pass

def reloadDriveList():
available_drives = ['%s:' % d for d in string.ascii_uppercase if os.path.exists('%s:' % d)]
window.combobox_drive.clear()
for drive in available_drives:
window.combobox_drive.addItem(QIcon(),drive,drive)

def loadROMsToTable():
drive = window.combobox_drive.currentText()
system = window.combobox_console.currentText()
if drive == "???" or system == "???":
return
roms_path = f"{drive}/{system}"
try:
files = frogtool.getROMList(roms_path)
window.tbl_gamelist.setRowCount(len(files))
for i, (name) in enumerate(files):
window.tbl_gamelist.setItem(i,0,QTableWidgetItem(f"{name}"))
except frogtool.StopExecution:
#Empty the table
window.tbl_gamelist.setRowCount(0)

window.tbl_gamelist.show()

#SubClass QMainWindow to create a Tadpole general interface
class MainWindow (QMainWindow):
Expand All @@ -20,29 +57,90 @@ def __init__(self):
self.setWindowTitle("Tadpole - SF2000 Tool")
widget = QWidget()
self.setCentralWidget(widget)

#Load the Menus
self.create_actions()
self.loadMenus()

layout = QGridLayout(widget)
rowCounter = 0

colCounter = 0
#Drive Select Widgets
self.lbl_drive = QLabel(text="Drive:")
self.combobox_drive = QComboBox()
layout.addWidget(self.lbl_drive, rowCounter, 0)
layout.addWidget(self.combobox_drive, rowCounter, 1)
rowCounter += 1

self.combobox_drive.currentIndexChanged.connect(loadROMsToTable)
self.btn_refreshDrives = QPushButton()
self.btn_refreshDrives.setIcon(self.style().standardIcon(getattr(QStyle, "SP_BrowserReload")))
self.btn_refreshDrives.clicked.connect(reloadDriveList)
layout.addWidget(self.lbl_drive, rowCounter, colCounter)
colCounter += 1
layout.addWidget(self.combobox_drive, rowCounter, colCounter)
colCounter += 1
layout.addWidget(self.btn_refreshDrives,rowCounter,colCounter)
colCounter += 1

#Console Select Widgets
self.lbl_console = QLabel(text="Console:")
self.combobox_console = QComboBox()
layout.addWidget(self.lbl_console, rowCounter, 0)
layout.addWidget(self.combobox_console, rowCounter, 1)
self.combobox_console.currentIndexChanged.connect(loadROMsToTable)
layout.addWidget(self.lbl_console, rowCounter, colCounter)
colCounter += 1
layout.addWidget(self.combobox_console, rowCounter, colCounter)
colCounter += 1

#Update Button Widget
self.btn_update = QPushButton("Update!")
layout.addWidget(self.btn_update, rowCounter, colCounter)
self.btn_update.clicked.connect(RunFrogTool)
colCounter += 1

self.lbl_fillerR1 = QLabel()
layout.addWidget(self.lbl_fillerR1, rowCounter, colCounter)
layout.setColumnStretch(colCounter,1)
colCounter += 1

#New Row
rowCounter += 1
colCounter = 0

#Game Table Widget
self.tbl_gamelist = QTableWidget()
self.tbl_gamelist.setColumnCount(4)
self.tbl_gamelist.setHorizontalHeaderLabels(["Name","Size","Thumbnail","Actions"])
layout.addWidget(self.tbl_gamelist,rowCounter, 0, 1, -1)


def loadMenus(self):
self.menu_file = self.menuBar().addMenu("&File")
self.menu_file.addAction(self.about_action)
self.menu_file.addAction(self.exit_action)

#Update Widget
self.button = QPushButton("Update!")
layout.addWidget(self.button, rowCounter, 0)

self.menu_os = self.menuBar().addMenu("&OS")
self.menu_os.addAction(self.GBABIOSFix_action)


def create_actions(self):
self.about_action = QAction("&About", self, triggered=self.about)
self.exit_action = QAction("E&xit", self, shortcut="Ctrl+Q",triggered=self.close)
self.GBABIOSFix_action = QAction("&GBA BIOS Fix", self, triggered=self.GBABIOSFix)


def about(self):
QMessageBox.about(self, "About Tadpole","Tadpole was created by EricGoldstein based on the original work from tzlion on frogtool")

def GBABIOSFix(self):
drive = window.combobox_drive.currentText()
try:
tadpole_functions.GBABIOSFix(drive)
except tadpole_functions.Exception_InvalidPath:
QMessageBox.about(self, "GBA BIOS Fix","An error occurred. Please ensure that you have the right drive selected and <i>gba_bios.bin</i> exists in the <i>bios</i> folder")
return
QMessageBox.about(self, "GBA BIOS Fix","BIOS successfully copied")


def UnderDevelopmentPopup(self):
QMessageBox.about(self, "Developement","This feature is still under development")

#Initialise the Application
app = QApplication(sys.argv)

Expand All @@ -52,10 +150,7 @@ def __init__(self):
#Update list of drives
available_drives_placeholder = "???"
window.combobox_drive.addItem(QIcon(),available_drives_placeholder,available_drives_placeholder)
available_drives = ['%s:' % d for d in string.ascii_uppercase if os.path.exists('%s:' % d)]
window.combobox_drive.clear()
for drive in available_drives:
window.combobox_drive.addItem(QIcon(),drive,drive)
reloadDriveList()


#Update list of consoles
Expand All @@ -64,10 +159,11 @@ def __init__(self):
window.combobox_console.clear()
for console in frogtool.systems.keys():
window.combobox_console.addItem(QIcon(),console,console)

#Add ALL to the list to add this fucntionality from frogtool
window.combobox_console.addItem(QIcon(),"ALL","ALL")


window.button.clicked.connect(RunFrogTool)


window.show()
app.exec()
28 changes: 28 additions & 0 deletions tadpole_functions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import os
import sys
import shutil

def GBABIOSFix(drive):
if drive == "???":
raise Exception_InvalidPath
GBABIOSPath = f"{drive}/bios/gba_bios.bin"
if not os.path.exists(GBABIOSPath):
print(f"! Couldn't find game list file {GBABIOSPath}")
print(" Check the provided path points to an SF2000 SD card!")
raise Exception_InvalidPath
try:
GBAFolderPath = f"{drive}/GBA/mnt/sda1/bios/"
ROMSFolderPath = f"{drive}/ROMS/mnt/sda1/bios/"
os.makedirs(os.path.dirname(GBAFolderPath), exist_ok=True)
os.makedirs(os.path.dirname(ROMSFolderPath), exist_ok=True)
shutil.copyfile(GBABIOSPath, f"{GBAFolderPath}/gba_bios.bin")
shutil.copyfile(GBABIOSPath, f"{ROMSFolderPath}/gba_bios.bin")
except (OSError, IOError) as error:
print("! Failed to copy GBA BIOS.")
print(error)
raise Exception_InvalidPath



class Exception_InvalidPath(Exception):
pass
6 changes: 3 additions & 3 deletions versioninfo
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ VSVersionInfo(
u'080904B0',
[StringStruct(u'CompanyName', u'EricGoldstein'),
StringStruct(u'FileDescription', u'tadpole'),
StringStruct(u'FileVersion', u'0.1.1'),
StringStruct(u'FileVersion', u'0.2.1'),
StringStruct(u'InternalName', u'tadpole'),
StringStruct(u'LegalCopyright', u'by taizou 2023'),
StringStruct(u'LegalCopyright', u'by EricGoldstein 2023'),
StringStruct(u'OriginalFilename', u'tadpole.exe'),
StringStruct(u'ProductName', u'tadpole'),
StringStruct(u'ProductVersion', u'0.1.1')])
StringStruct(u'ProductVersion', u'0.2.1')])
]),
VarFileInfo([VarStruct(u'Translation', [2057, 1200])])
]
Expand Down

0 comments on commit f676f66

Please sign in to comment.