Skip to content

Commit

Permalink
v0.3.0 Update
Browse files Browse the repository at this point in the history
* Automated drive detection
* OS Updating
* Loading Windows
  • Loading branch information
EricGoldsteinNz authored Jul 27, 2023
1 parent e4c0c9f commit 8d2e0b7
Show file tree
Hide file tree
Showing 4 changed files with 126 additions and 63 deletions.
47 changes: 25 additions & 22 deletions build.bat
Original file line number Diff line number Diff line change
@@ -1,22 +1,25 @@
@echo off
set ver=0.2.6
rem build script for the distributable versions of tadpole
if not exist "venv\" (
py -m venv venv
)
if not exist "venv\Lib\site-packages\PyInstaller" (
venv\Scripts\python -m pip install pyinstaller
)
if not exist "venv\Lib\site-packages\PIL" (
venv\Scripts\python -m pip install Pillow
)
pyinstaller.exe tadpole.py --onefile -F --icon frog.ico --clean --noconsole --version-file versioninfo --add-data="frog.ico;."
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.md" license.txt
tar -a -cf tadpole-%ver%-py.zip tadpole.py frogtool.py tadpole_functions.py "readme.md" license.txt
cd ../
@echo off
set ver=0.3.0
rem build script for the distributable versions of tadpole
if not exist "venv\" (
py -m venv venv
)
if not exist "venv\Lib\site-packages\PyInstaller" (
venv\Scripts\python -m pip install pyinstaller
)
if not exist "venv\Lib\site-packages\PIL" (
venv\Scripts\python -m pip install Pillow
)
if not exist "venv\Lib\site-packages\PyQt5" (
venv\Scripts\python -m pip install PyQt5
)
pyinstaller.exe tadpole.py --onefile -F --icon frog.ico --clean --noconsole --version-file versioninfo --add-data="frog.ico;."
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.md" license.txt
tar -a -cf tadpole-%ver%-py.zip tadpole.py frogtool.py tadpole_functions.py "readme.md" license.txt
cd ../
48 changes: 39 additions & 9 deletions tadpole.py
Original file line number Diff line number Diff line change
@@ -1,27 +1,33 @@
#GUI imports
from PyQt5.QtWidgets import *
from PyQt5.QtGui import *
from PyQt5.QtCore import QTimer
#OS imports - these should probably be moved somewhere else
import os
import sys
import string
import threading
#Feature imports
import frogtool
import tadpole_functions

import requests

import json
import time

basedir = os.path.dirname(__file__)

static_NoDrives = "N/A"
static_AllSystems = "ALL"


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

print(f"Running frogtool with drive ({drive}) and console ({console})")
try:
if(console =="ALL"):
if(console == static_AllSystems):
for console in frogtool.systems.keys():
result = frogtool.process_sys(drive,console, False)
QMessageBox.about(window,"Result",result)
Expand All @@ -48,7 +54,7 @@ def reloadDriveList():

else:
# disable functions
window.combobox_drive.addItem(QIcon(), "N/A", "N/A")
window.combobox_drive.addItem(QIcon(), static_NoDrives, static_NoDrives)
window.status_bar.showMessage("No SF2000 Drive Detected. Click refresh button to try again.", 20000)
toggle_features(False)

Expand All @@ -71,7 +77,7 @@ def toggle_features(enable: bool):
def loadROMsToTable():
drive = window.combobox_drive.currentText()
system = window.combobox_console.currentText()
if drive == "???" or system == "???":
if drive == static_NoDrives or system == "???" or system == static_AllSystems:
return
roms_path = f"{drive}/{system}"
try:
Expand Down Expand Up @@ -217,12 +223,18 @@ def __init__(self):
self.tbl_gamelist.horizontalHeader().setSectionResizeMode(1,QHeaderView.ResizeToContents)
self.tbl_gamelist.cellClicked.connect(catchTableCellClicked)
layout.addWidget(self.tbl_gamelist,rowCounter, 0, 1, -1)

#reload Drives Timer
self.timer=QTimer()
self.timer.timeout.connect(reloadDriveList)
self.timer.start(1000)

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_updateToV1_5 = QAction("V1.5", self, triggered=self.UpdatetoV1_5)
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)
Expand All @@ -238,6 +250,8 @@ def loadMenus(self):
self.menu_file.addAction(self.exit_action)

self.menu_os = self.menuBar().addMenu("&OS")
self.menu_os.menu_update = self.menu_os.addMenu("Update")
self.menu_os.menu_update.addAction(self.action_updateToV1_5)
self.menu_os.addAction(self.action_changeBootLogo)
self.menu_os.addAction(self.GBABIOSFix_action)
self.menu_os.addAction(self.action_changeShortcuts)
Expand Down Expand Up @@ -335,6 +349,23 @@ def ConsoleLogos_change(self, url):
else:
msgBox.close()
QMessageBox.about(self, "Failure","ERROR: Something went wrong while trying to change the console logos")

def UpdatetoV1_5(self):
drive = window.combobox_drive.currentText()
url = "https://api.github.com/repos/EricGoldsteinNz/SF2000_Resources/contents/OS/V1.5"

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.downloadDirectoryFromGithub(drive, url):
msgBox.close()
QMessageBox.about(self, "Success","Update successfully Downloaded")
else:
msgBox.close()
QMessageBox.about(self, "Failure","ERROR: Something went wrong while trying to download the update")




# Subclass Qidget to create a thumbnail viewing window
Expand Down Expand Up @@ -451,17 +482,15 @@ def changeShortcut(self):
window = MainWindow()

#Update list of drives
available_drives_placeholder = "???"
window.combobox_drive.addItem(QIcon(),available_drives_placeholder,available_drives_placeholder)
window.combobox_drive.addItem(QIcon(),static_NoDrives,static_NoDrives)
reloadDriveList()


#Update list of consoles
available_consoles_placeholder = "???"
window.combobox_console.addItem(QIcon(),available_consoles_placeholder,available_consoles_placeholder)
window.combobox_console.clear()
#Add ALL to the list to add this fucntionality from frogtool
window.combobox_console.addItem(QIcon(),"ALL","ALL")
window.combobox_console.addItem(QIcon(),static_AllSystems,static_AllSystems)
for console in frogtool.systems.keys():
window.combobox_console.addItem(QIcon(),console,console)

Expand All @@ -470,4 +499,5 @@ def changeShortcut(self):


window.show()
app.exec()
app.exec()

40 changes: 35 additions & 5 deletions tadpole_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
import sys
import shutil
import hashlib
import zipfile
import io
from PyQt5.QtGui import *
from PyQt5.QtCore import *
import struct
Expand Down Expand Up @@ -392,14 +394,42 @@ def downloadAndReplace(drivePath, fileToReplace, url=""):
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 == "":
#write the content to file
bgmPath = f"{drivePath}{fileToReplace}"
file_handle = open(bgmPath, 'wb') #rb for read, wb for write
file_handle.write(content)
file_handle.close()
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
return False


def downloadDirectoryFromGithub(location, url):
response = requests.get(url)
if response.status_code == 200:
data = json.loads(response.content)
for item in data:
if item["type"] == "dir":
#create folder then recursively download
foldername = item["name"]
print(f"creating directory {location}/{foldername}")
os.makedirs(os.path.dirname(f"{location}/{foldername}/"), exist_ok=True)
downloadDirectoryFromGithub(f"{location}/{foldername}",item["url"])
else:# all other cases should be files
filename = item["name"]
downloadFileFromGithub(f"{location}/{filename}",item["download_url"])

return True
raise ConnectionError("Unable to V1.5 Update. (Status Code: {})".format(response.status_code))
return False

def downloadFileFromGithub(outFile, url):
r = requests.get(url)
with open(outFile, 'wb') as f:
print(f'downloading {url} to {outFile}')
f.write(r.content)


54 changes: 27 additions & 27 deletions versioninfo
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
VSVersionInfo(
ffi=FixedFileInfo(
filevers=(0, 2, 6, 0),
prodvers=(0, 2, 6, 0),
mask=0x3f,
flags=0x0,
OS=0x4,
fileType=0x1,
subtype=0x0,
date=(0, 0)
),
kids=[
StringFileInfo(
[StringTable(
u'080904B0',
[StringStruct(u'CompanyName', u'EricGoldstein'),
StringStruct(u'FileDescription', u'tadpole'),
StringStruct(u'FileVersion', u'0.2.6'),
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.6')])
]),
VarFileInfo([VarStruct(u'Translation', [2057, 1200])])
]
)
VSVersionInfo(
ffi=FixedFileInfo(
filevers=(0, 3, 0, 0),
prodvers=(0, 3, 0, 0),
mask=0x3f,
flags=0x0,
OS=0x4,
fileType=0x1,
subtype=0x0,
date=(0, 0)
),
kids=[
StringFileInfo(
[StringTable(
u'080904B0',
[StringStruct(u'CompanyName', u'EricGoldstein'),
StringStruct(u'FileDescription', u'tadpole'),
StringStruct(u'FileVersion', u'0.3.0'),
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.3.0')])
]),
VarFileInfo([VarStruct(u'Translation', [2057, 1200])])
]
)

0 comments on commit 8d2e0b7

Please sign in to comment.