Skip to content

Commit

Permalink
Several fixes
Browse files Browse the repository at this point in the history
- System loadouts now properly handle newly-created categories
- Fixed a bug involving the GUI placement of some categories
- The last commit broke exporting; it's now fixed
- Fixed folders being made for system-exclusive categories on other systems
  • Loading branch information
Mode8fx committed Jul 16, 2022
1 parent a8e5f8f commit b56dedf
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 16 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ Yes. These are included in `settings.ini`, and you can add your own:
- `General Attributes`: These are similar to Specific Attributes, but they cover any attribute that starts with these keywords (e.g. "Rev" covers "Rev 1", "Rev 2", "Rev A", etc.)
### Can I add my own systems to the list? Can I add new nicknames to existing systems?
Yes, you can do both of these by editing `SystemNames.py` (just follow the format that's already in the file).
### Can I add my own special categories in addition to the existing ones like Unlicensed and Unreleased?
Yes. The categories are included in `SpecialCategories.py`, and you can edit them or add your own.
### What DAT files should I use?
This program was designed for use with No-Intro's Parent-Clone DAT files. These can be found on No-Intro's DAT-o-MATIC, specifically the [Daily Downloads](https://datomatic.no-intro.org/index.php?page=download&s=64&op=daily) page. Scroll down, select `P/C XML` in the dropdown, then click Prepare, then Download.
### Are disc-based systems supported?
Expand Down
4 changes: 3 additions & 1 deletion SpecialCategories.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ def __init__(self, name, keywords, description=None, exclusiveSystems=None):
self.keywords = [self.keywords]
self.description = description
self.exclusiveSystems = exclusiveSystems
if not (self.exclusiveSystems is None or isinstance(self.exclusiveSystems, list) or isinstance(self.exclusiveSystems, tuple)):
self.exclusiveSystems = [self.exclusiveSystems]
self.folderName = slugify(name)


Expand Down Expand Up @@ -109,7 +111,7 @@ def __init__(self, name, keywords, description=None, exclusiveSystems=None):

Category(
name = "GBA Video",
description = None,
description = "(Only applies to GBA.)",
keywords = [
"Game Boy Advance Video"
],
Expand Down
4 changes: 3 additions & 1 deletion SpecialCategoriesDefault.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ def __init__(self, name, keywords, description=None, exclusiveSystems=None):
self.keywords = [self.keywords]
self.description = description
self.exclusiveSystems = exclusiveSystems
if not (self.exclusiveSystems is None or isinstance(self.exclusiveSystems, list) or isinstance(self.exclusiveSystems, tuple)):
self.exclusiveSystems = [self.exclusiveSystems]
self.folderName = slugify(name)


Expand Down Expand Up @@ -109,7 +111,7 @@ def __init__(self, name, keywords, description=None, exclusiveSystems=None):

Category(
name = "GBA Video",
description = None,
description = "(Only applies to GBA.)",
keywords = [
"Game Boy Advance Video"
],
Expand Down
41 changes: 27 additions & 14 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -444,13 +444,16 @@ def addSystemTab(self, systemName="New System", datFilePath="", romsetFolderPath
self.Export_IncludeSpecial_.append([])
self.includeSpecialChoices.append([])
self.Export_IncludeSpecial_[i].append(ttk.Checkbutton(self.Export_IncludeFrame_[self.exportTabNum]))
self.includeSpecialChoices[i].append(tk.IntVar(value=includeSpecial[i]))
if len(includeSpecial) > i:
self.includeSpecialChoices[i].append(tk.IntVar(value=includeSpecial[i]))
else:
self.includeSpecialChoices[i].append(tk.IntVar(value=False))
self.Export_IncludeSpecial_[i][self.exportTabNum].configure(text=SpecialCategories[i].name, variable=self.includeSpecialChoices[i][self.exportTabNum])
if SpecialCategories[i].exclusiveSystems is not None and systemName not in SpecialCategories[i].exclusiveSystems:
numSkipped += 1
else:
currCol = (i+numSkipped)%3
currRow = (i+numSkipped)//3
currCol = (i-numSkipped)%3
currRow = (i-numSkipped)//3
self.Export_IncludeSpecial_[i][self.exportTabNum].grid(column=currCol, padx=10, pady=10, row=currRow, sticky='w')
self.Export_IncludeFrame_[self.exportTabNum].configure(text='Include')
self.Export_IncludeFrame_[self.exportTabNum].grid(column='0', padx='20', pady='10', row='6', sticky='w')
Expand Down Expand Up @@ -589,7 +592,8 @@ def export_saveSystemLoadout(self):
loadout[self.exportSystemNames[i]]["Include Games from Non-Primary Regions"] = str(self.includeOtherRegionsChoices[i].get())
loadout[self.exportSystemNames[i]]["Rom List"] = self.romListFileChoices[i].get()
for j in range(len(SpecialCategories)):
loadout[self.exportSystemNames[i]]["Include "+SpecialCategories[j].name] = str(self.includeSpecialChoices[j][i].get())
if (SpecialCategories[j].exclusiveSystems is None) or (self.exportSystemNames[i] in SpecialCategories[j].exclusiveSystems):
loadout[self.exportSystemNames[i]]["Include "+SpecialCategories[j].name] = str(self.includeSpecialChoices[j][i].get())
loadout[self.exportSystemNames[i]]["Extract Compressed Roms"] = str(self.extractArchivesChoices[i].get())
loadout[self.exportSystemNames[i]]["Create Game Folder for Each Game"] = str(self.parentFolderChoices[i].get())
loadout[self.exportSystemNames[i]]["Create Region Folders"] = str(self.sortByPrimaryRegionChoices[i].get())
Expand All @@ -599,6 +603,9 @@ def export_saveSystemLoadout(self):
with open(loadoutFile, 'w') as lf:
loadout.write(lf)

def keyValIsTrue(self, k, v):
return k.get(v) == "True"

def export_loadSystemLoadout(self):
if self.exportTabNum > 0:
if not askyesno("EzRO", "This will replace your current system loadout. Continue?"):
Expand All @@ -614,9 +621,10 @@ def export_loadSystemLoadout(self):
loadout.read(loadoutFile)
for key in loadout.keys():
if key in systemNamesDict.keys():
curr_includeSpecial = [loadout[key].get("Include "+cat.name) == "1" for cat in SpecialCategories]
self.addSystemTab(systemName=key, datFilePath=loadout[key]["Input No-Intro DAT"], romsetFolderPath=loadout[key]["Input Romset"], outputFolderDirectory=loadout[key]["Output Directory"],
outputType=loadout[key]["Output Type"], includeOtherRegions=loadout[key]["Include Games from Non-Primary Regions"], romList=loadout[key]["Rom List"],
includeSpecial=loadout[key], extractArchives=loadout[key]["Extract Compressed Roms"], parentFolder=loadout[key]["Create Game Folder for Each Game"],
includeSpecial=curr_includeSpecial, extractArchives=loadout[key]["Extract Compressed Roms"], parentFolder=loadout[key]["Create Game Folder for Each Game"],
sortByPrimaryRegion=loadout[key]["Create Region Folders"], primaryRegionInRoot=loadout[key]["Do Not Create Folder for Primary Region"],
specialCategoryFolder=loadout[key]["Create Folders for Special Categories"], overwriteDuplicates=loadout[key]["Overwrite Duplicate Files"])

Expand Down Expand Up @@ -1179,9 +1187,9 @@ def renameArchiveAndContent(self, archivePath, newName):

def mainExport(self, systemIndices):
global currSystemName, currSystemSourceFolder, currSystemTargetFolder, currSystemDAT, romsetCategory
global extractArchives, exportToGameParentFolder, sortByPrimaryRegion, primaryRegionInRoot, specialCategoryFolder, overwriteDuplicates
global ignoredFolders, primaryRegions, favoritesList, includeSpecial
global export_regionGroupNames, export_regionPriorityTypes, export_regionTags
global includeOtherRegions, extractArchives, exportToGameParentFolder, sortByPrimaryRegion, primaryRegionInRoot
global specialCategoryFolder, overwriteDuplicates, ignoredFolders, primaryRegions, favoritesList
global includeSpecial, export_regionGroupNames, export_regionPriorityTypes, export_regionTags

if not self.recentlyVerified:
if not askyesno("EzRO Export", "If you haven't done so already, it is recommended that you update/audit your romsets whenever you export (or if this is your first time running EzRO). This will make sure your rom names match those in the No-Intro DAT files.\n\nContinue with export?"):
Expand Down Expand Up @@ -1226,8 +1234,9 @@ def mainExport(self, systemIndices):
favoritesFile = self.romListFileChoices[currIndex].get()
includeOtherRegions = self.includeOtherRegionsChoices[currIndex].get()
ignoredFolders = []
includeSpecial = []
for i in range(len(SpecialCategories)):
includeSpecial[i] = self.includeSpecialChoices[i][currIndex].get()
includeSpecial.append(self.includeSpecialChoices[i][currIndex].get())
if (not includeSpecial[i]) and ((SpecialCategories[i].exclusiveSystems is None) or (currSystemName in SpecialCategories[i].exclusiveSystems)):
ignoredFolders.append(SpecialCategories[i].name)
extractArchives = self.extractArchivesChoices[currIndex].get()
Expand Down Expand Up @@ -1614,10 +1623,11 @@ def targetExists(self, sourceRomPath, targetRomPath):
def getSpecialFolders(self, rom):
currSpecialFolders = []
for category in SpecialCategories:
for keyword in category.keywords:
if keyword in rom:
currSpecialFolders.append(category.name)
break
if category.exclusiveSystems is None or (currSystemName in category.exclusiveSystems):
for keyword in category.keywords:
if keyword in rom:
currSpecialFolders.append(category.name)
break
return currSpecialFolders

def createMainCopiedLog(self, currIndex, logType="Export"):
Expand Down Expand Up @@ -1994,7 +2004,10 @@ def loadConfig(self):
self.g_specialCategoryFolder.set(defaultSettings["Organization"]["Create Folders for Special Categories"] == "True")
self.g_overwriteDuplicates.set(defaultSettings["Organization"]["Overwrite Duplicate Files"] == "True")
for i in range(len(SpecialCategories)):
self.g_includeSpecial[i].set(defaultSettings["Include"][SpecialCategories[i].name] == "True")
try:
self.g_includeSpecial[i].set(defaultSettings["Include"][SpecialCategories[i].name] == "True")
except:
self.g_includeSpecial[i].set(False)
self.g_includeOtherRegions.set(defaultSettings["Include"]["(1G1R) Games from Other Regions"] == "True")
except:
showerror("EzRO", "Invalid settings.ini file. Delete it and reload, then a new default file will be created.")
Expand Down

0 comments on commit b56dedf

Please sign in to comment.