Skip to content

Commit

Permalink
Merge release/1.3.1 into master
Browse files Browse the repository at this point in the history
Merge release/1.3.1 into master
Merge pull request #25 from chrisism/hotfix/fixing_rendering_issues
  • Loading branch information
chrisism authored Mar 1, 2023
2 parents 05b9d83 + 6e0aaeb commit 6f9408a
Show file tree
Hide file tree
Showing 12 changed files with 166 additions and 99 deletions.
3 changes: 3 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
## Current
- Custom skin view for View ROM
- More details about addon plugins
- Fixed linking assets to wrong directory
- Fixed category rendering
- Added rebuild views option in settings dialog

## Previous
- Added support for PEGI rating
Expand Down
4 changes: 4 additions & 0 deletions resources/language/resource.language.en_gb/strings.po
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,10 @@ msgctxt "#40855"
msgid "Scrape ROM"
msgstr ""

msgctxt "#40856"
msgid "Rebuild all views"
msgstr ""

############################
# Scraping settings
############################
Expand Down
23 changes: 23 additions & 0 deletions resources/lib/commands/rom_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ def cmd_edit_rom(args):
options = collections.OrderedDict()
options['ROM_EDIT_METADATA'] = f'{kodi.translate(40853)} ...'
options['ROM_EDIT_ASSETS'] = f'{kodi.translate(40854)} ...'
# options['ROM_EDIT_DEFAULT_ASSETS'] = 'Choose default Assets/Artwork ...'
options['EDIT_ROM_STATUS'] = f'ROM status: {rom.get_finished_str()}'
if rom.has_launchers():
options['EDIT_ROM_LAUNCHERS'] = 'Manage associated launchers'
Expand Down Expand Up @@ -161,6 +162,28 @@ def cmd_rom_assets(args):

AppMediator.sync_cmd('ROM_EDIT_ASSETS', {'rom_id': rom_id, 'selected_asset': asset.id})

@AppMediator.register('ROM_EDIT_DEFAULT_ASSETS')
def cmd_rom_edit_default_assets(args):
rom_id:str = args['rom_id'] if 'rom_id' in args else None
preselected_option = args['selected_asset'] if 'selected_asset' in args else None

uow = UnitOfWork(globals.g_PATHS.DATABASE_FILE_PATH)
with uow:
repository = ROMsRepository(uow)
rom = repository.find_rom(rom_id)

selected_asset_to_edit = editors.edit_object_default_assets(rom, preselected_option)
if selected_asset_to_edit is None:
args["selected_asset"] = None
AppMediator.sync_cmd('EDIT_ROM', args)
return

if editors.edit_default_asset(rom, selected_asset_to_edit):
repository.update_rom(rom)
uow.commit()

AppMediator.sync_cmd('ROM_EDIT_DEFAULT_ASSETS', {'rom_id': rom.get_id(), 'selected_asset': selected_asset_to_edit.id})

#
# Remove ROMCollection
#
Expand Down
7 changes: 0 additions & 7 deletions resources/lib/commands/romcollection_roms_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,13 +89,6 @@ def cmd_manage_roms(args):
def cmd_set_roms_default_artwork(args):
romcollection_id:str = args['romcollection_id'] if 'romcollection_id' in args else None

# if not launcher.supports_launching_roms():
# kodi.dialog_OK(
# 'm_subcommand_set_roms_default_artwork() ' +
# 'Launcher "{0}" is not a ROM launcher.'.format(launcher.__class__.__name__) +
# 'This is a bug, please report it.')
# return

uow = UnitOfWork(globals.g_PATHS.DATABASE_FILE_PATH)
with uow:
repository = ROMCollectionRepository(uow)
Expand Down
36 changes: 25 additions & 11 deletions resources/lib/commands/view_rendering_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,14 +261,18 @@ def _render_root_view(categories_repository: CategoryRepository, romcollections_
root_items = []
for root_category in root_categories:
logger.debug(f'Processing category "{root_category.get_name()}"')
root_items.append(_render_category_listitem(root_category))
rendered_item = _render_category_listitem(root_category)
if rendered_item:
root_items.append(rendered_item)
if render_sub_views:
_render_category_view(root_category, categories_repository, romcollections_repository,
roms_repository, views_repository, render_sub_views)

for root_romcollection in root_romcollections:
logger.debug(f'Processing romcollection "{root_romcollection.get_name()}"')
root_items.append(_render_romcollection_listitem(root_romcollection))
rendered_item = _render_romcollection_listitem(root_romcollection)
if rendered_item:
root_items.append(rendered_item)
if render_sub_views:
collection_view_data = _render_romcollection_view(root_romcollection, roms_repository)
views_repository.store_view(root_romcollection.get_id(), root_romcollection.get_type(), collection_view_data)
Expand All @@ -281,19 +285,23 @@ def _render_root_view(categories_repository: CategoryRepository, romcollections_

root_vcategory = VirtualCategoryFactory.create(constants.VCATEGORY_ROOT_ID)
logger.debug('Processing root virtual category')
root_items.append(_render_category_listitem(root_vcategory))
rendered_item = _render_category_listitem(root_vcategory)
if rendered_item:
root_items.append(rendered_item)
if render_sub_views:
_render_category_view(root_vcategory, categories_repository, romcollections_repository,
roms_repository, views_repository, render_sub_views)

for vcollection_id in constants.VCOLLECTIONS:
vcollection = VirtualCollectionFactory.create(vcollection_id)
logger.debug(f'Processing virtual collection "{vcollection.get_name()}"')
root_items.append(_render_romcollection_listitem(vcollection))
rendered_item = _render_romcollection_listitem(vcollection)
if rendered_item:
root_items.append(rendered_item)
collection_view_data = _render_romcollection_view(vcollection, roms_repository)
views_repository.store_view(vcollection.get_id(), vcollection.get_type(), collection_view_data)

logger.debug('Storing {} items in root view.'.format(len(root_items)))
logger.debug(f'Storing {len(root_items)} items in root view.')
root_data['items'] = root_items
views_repository.store_root_view(root_data)

Expand All @@ -318,15 +326,19 @@ def _render_category_view(category_obj: Category, categories_repository: Categor
if sub_category is None:
continue
logger.debug(f'Processing category "{sub_category.get_name()}", part of "{category_obj.get_name()}"')
view_items.append(_render_category_listitem(sub_category))
rendered_item = _render_category_listitem(sub_category)
if rendered_item:
view_items.append(rendered_item)
if render_sub_views:
_render_category_view(sub_category, categories_repository, romcollections_repository, roms_repository,
views_repository, render_sub_views)

for romcollection in romcollections:
logger.debug(f"Processing romcollection '{romcollection.get_name()}'")
try:
view_items.append(_render_romcollection_listitem(romcollection))
rendered_item = _render_romcollection_listitem(romcollection)
if rendered_item:
view_items.append(rendered_item)
except Exception:
logger.exception(f"Exception while rendering list item ROM Collection '{romcollection.get_name()}'")
kodi.notify_error(f"Failed to process ROM collection {romcollection.get_name()}")
Expand Down Expand Up @@ -377,8 +389,9 @@ def _render_romcollection_view(romcollection_obj: ROMCollection, roms_repository
def _render_category_listitem(category_obj: Category) -> dict:
# --- Do not render row if category finished ---
if category_obj.is_finished() and \
(category_obj.get_type() in constants.OBJ_VIRTUAL_TYPES or settings.getSettingAsBool('display_hide_finished')):
return
(category_obj.get_type() in constants.OBJ_VIRTUAL_TYPES or \
settings.getSettingAsBool('display_hide_finished')):
return None

category_name = category_obj.get_name()
ICON_OVERLAY = 5 if category_obj.is_finished() else 4
Expand Down Expand Up @@ -412,8 +425,9 @@ def _render_category_listitem(category_obj: Category) -> dict:
def _render_romcollection_listitem(romcollection_obj: ROMCollection) -> dict:
# --- Do not render row if romcollection finished ---
if romcollection_obj.is_finished() and \
(romcollection_obj.get_type() in constants.OBJ_VIRTUAL_TYPES or settings.getSettingAsBool('display_hide_finished')):
return
(romcollection_obj.get_type() in constants.OBJ_VIRTUAL_TYPES or \
settings.getSettingAsBool('display_hide_finished')):
return None

romcollection_name = romcollection_obj.get_name()
ICON_OVERLAY = 5 if romcollection_obj.is_finished() else 4
Expand Down
17 changes: 11 additions & 6 deletions resources/lib/domain.py
Original file line number Diff line number Diff line change
Expand Up @@ -559,7 +559,8 @@ def __init__(self,
# Core functions
# --------------------------------------------------------------------------------------------
@abc.abstractmethod
def get_object_name(self) -> str: pass
def get_object_name(self) -> str:
pass

@abc.abstractmethod
def get_assets_kind(self) -> int:
Expand All @@ -569,7 +570,7 @@ def get_assets_kind(self) -> int:
def get_type(self) -> str:
pass

# --- Metadata --------------------------------------------------------------------------------
# --- Metadata --------------------------------------------------------------------------------
def get_name(self):
return self.entity_data['m_name'] if 'm_name' in self.entity_data else 'Unknown'

Expand Down Expand Up @@ -728,7 +729,8 @@ def get_asset_paths(self) -> typing.List[AssetPath]:
return list(self.asset_paths.values())

def get_asset_path(self, asset_info: AssetInfo, fallback_to_root = True) -> io.FileName:
if not asset_info: return None
if not asset_info:
return None
if asset_info.id in self.asset_paths:
return self.asset_paths[asset_info.id].get_path_FN()

Expand Down Expand Up @@ -776,7 +778,8 @@ def get_view_assets(self) -> typing.Dict[str,str]:
value = asset.get_path()

if self.is_mappable_asset(asset_info):
if asset_info.id == constants.ASSET_ICON_ID: fallback_str = self.get_default_icon()
if asset_info.id == constants.ASSET_ICON_ID:
fallback_str = self.get_default_icon()
value = self.get_mapped_asset_str(asset_info, fallback=fallback_str)

view_assets[asset_info.fname_infix] = value
Expand Down Expand Up @@ -1544,9 +1547,11 @@ def copy(self):
def get_asset_ids_list(self):
return constants.ROM_ASSET_ID_LIST

def get_mappable_asset_ids_list(self): return constants.MAPPABLE_ROM_ASSET_ID_LIST
def get_mappable_asset_ids_list(self):
return constants.MAPPABLE_ROM_ASSET_ID_LIST

def get_default_icon(self) -> str: return 'DefaultProgram.png'
def get_default_icon(self) -> str:
return 'DefaultProgram.png'

def create_dto(self) -> api.ROMObj:
dto_data:dict = api.ROMObj.get_data_template()
Expand Down
Loading

0 comments on commit 6f9408a

Please sign in to comment.