Skip to content

Commit

Permalink
library view: add complete / missing DLC status to base games
Browse files Browse the repository at this point in the history
  • Loading branch information
a1ex4 committed Nov 6, 2023
1 parent 6f4dd90 commit 600fca3
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 5 deletions.
7 changes: 6 additions & 1 deletion app/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,10 +227,15 @@ def get_library_status(title_id):
else:
version['has_version'] = False

all_existing_dlcs = get_all_existing_dlc(title_id)
owned_dlcs = [t['app_id'] for t in title_files if t['type'] == APP_TYPE_DLC]
has_all_dlcs = all(dlc in owned_dlcs for dlc in all_existing_dlcs)

library_status = {
'has_base': has_base,
'has_latest_version': has_latest_version,
'version': available_versions
'version': available_versions,
'has_all_dlcs': has_all_dlcs
}
return library_status

Expand Down
17 changes: 13 additions & 4 deletions app/templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,10 @@

<div class="col-auto">
<div class="btn-group dropdown-center" role="group">
<button type="button" class="btn btn-primary"><i class="bi bi-funnel-fill"></i></button>
<div class="btn-group" role="group">
<button id="filterDropdownBtn" type="button" class="btn btn-primary dropdown-toggle"
data-bs-toggle="dropdown" data-bs-auto-close="outside" aria-expanded="false">
Filters
<i class="bi bi-funnel-fill"></i>
</button>
<ul class="dropdown-menu">
<li>
Expand Down Expand Up @@ -113,9 +112,19 @@ <h5 class="card-title game-title">{{ game.name }}</h5>
{% if game.has_latest_version is defined %}
{% if game.has_latest_version %}
<span class="badge rounded-pill text-bg-success game-tag" data-bs-tag="Up to date"><i
class="bi bi-box-seam-fill"></i></span>
class="bi bi-check-circle-fill"></i></span>
{% else %}
<span class="badge rounded-pill text-bg-warning game-tag" data-bs-tag="Outdated"><i
class="bi bi-arrow-down-circle"></i></span>
{% endif %}
{% endif %}
<!-- Game has all DLCs or incomplete -->
{% if game.has_all_dlcs is defined %}
{% if game.has_all_dlcs %}
<span class="badge rounded-pill text-bg-success game-tag" data-bs-tag="Complete"><i
class="bi bi-box-seam-fill"></i></span>
{% else %}
<span class="badge rounded-pill text-bg-warning game-tag" data-bs-tag="Missing DLC"><i
class="bi bi-box-seam-fill"></i></span>
{% endif %}
{% endif %}
Expand Down Expand Up @@ -219,7 +228,7 @@ <h5 class="card-title game-title">{{ game.name }}</h5>

if ((activeTypeFilters.size === 0 || Array.from(activeTypeFilters).some(tag => cardTagsText.includes(tag))) &&
(activeUpdateFilters.size === 0 || Array.from(activeUpdateFilters).some(tag => cardTagsText.includes(tag))) &&
(activeCompletionFilters.size === 0 || Array.from(activeUpdateFilters).some(tag => cardTagsText.includes(tag)))) {
(activeCompletionFilters.size === 0 || Array.from(activeCompletionFilters).some(tag => cardTagsText.includes(tag)))) {
card.parent().removeAttr('filtered-tag');
if ((card.parent().attr('filtered-text') != 'set') ){
card.parent().removeClass('d-none');
Expand Down
10 changes: 10 additions & 0 deletions app/titles.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,16 @@ def get_all_dlc_existing_versions(app_id):
else:
print(f'DLC app ID not in cnmts.json: {app_id.upper()}')
return None

def get_all_existing_dlc(title_id):
title_id = title_id.lower()
dlcs = []
for app_id in cnmts_db.keys():
for version, version_description in cnmts_db[app_id].items():
if version_description.get('titleType') == 130 and version_description.get('otherApplicationId') == title_id:
if app_id.upper() not in dlcs:
dlcs.append(app_id.upper())
return dlcs

def set_titledb_default_files():
os.system(f"cd {TITLEDB_DIR} && git sparse-checkout set {'/' + ' /'.join(TITLEDB_DEFAULT_FILES)} --no-cone")
Expand Down

0 comments on commit 600fca3

Please sign in to comment.