From 42b9986fc8a63987b423f8a2052f4815d0a2c907 Mon Sep 17 00:00:00 2001 From: rubenwardy Date: Thu, 12 Jan 2023 19:48:18 +0000 Subject: [PATCH] Enable game support for texture packs --- app/blueprints/packages/game_hub.py | 3 +- app/blueprints/packages/packages.py | 2 +- app/tasks/importtasks.py | 5 ++- app/templates/packages/game_hub.html | 7 ++++ app/templates/packages/view.html | 62 +++++++++++++++++----------- 5 files changed, 50 insertions(+), 29 deletions(-) diff --git a/app/blueprints/packages/game_hub.py b/app/blueprints/packages/game_hub.py index a8c3ac64..f68abc93 100644 --- a/app/blueprints/packages/game_hub.py +++ b/app/blueprints/packages/game_hub.py @@ -38,7 +38,6 @@ def game_hub(package: Package): new = join(query.order_by(db.desc(Package.approved_at))).limit(4).all() pop_mod = join(query.filter_by(type=PackageType.MOD).order_by(db.desc(Package.score))).limit(8).all() - pop_gam = join(query.filter_by(type=PackageType.GAME).order_by(db.desc(Package.score))).limit(8).all() pop_txp = join(query.filter_by(type=PackageType.TXP).order_by(db.desc(Package.score))).limit(8).all() high_reviewed = join(query.order_by(db.desc(Package.score - Package.score_downloads))) \ .filter(Package.reviews.any()).limit(4).all() @@ -50,5 +49,5 @@ def game_hub(package: Package): updated = updated[:4] return render_template("packages/game_hub.html", package=package, count=count, - new=new, updated=updated, pop_mod=pop_mod, pop_txp=pop_txp, pop_gam=pop_gam, + new=new, updated=updated, pop_mod=pop_mod, pop_txp=pop_txp, high_reviewed=high_reviewed) diff --git a/app/blueprints/packages/packages.py b/app/blueprints/packages/packages.py index 492ec0f5..fe75d28f 100644 --- a/app/blueprints/packages/packages.py +++ b/app/blueprints/packages/packages.py @@ -648,7 +648,7 @@ class GameSupportForm(FlaskForm): @login_required @is_package_page def game_support(package): - if package.type != PackageType.MOD: + if package.type != PackageType.MOD and package.type != PackageType.TXP: abort(404) can_edit = package.checkPerm(current_user, Permission.EDIT_PACKAGE) diff --git a/app/tasks/importtasks.py b/app/tasks/importtasks.py index e9dad5ec..8412f723 100644 --- a/app/tasks/importtasks.py +++ b/app/tasks/importtasks.py @@ -145,7 +145,7 @@ def postReleaseCheckUpdate(self, release: PackageRelease, path): pass # Update game support - if package.type == PackageType.MOD: + if package.type == PackageType.MOD or package.type == PackageType.TXP: try: resolver = GameSupportResolver(db.session) @@ -158,7 +158,8 @@ def postReleaseCheckUpdate(self, release: PackageRelease, path): game_is_supported[game.id] = False resolver.set_supported(package, game_is_supported, 10) - resolver.update(package) + if package.type == PackageType.MOD: + resolver.update(package) except LogicError as e: raise TaskError(e.message) diff --git a/app/templates/packages/game_hub.html b/app/templates/packages/game_hub.html index 91238bdc..6d47bfa5 100644 --- a/app/templates/packages/game_hub.html +++ b/app/templates/packages/game_hub.html @@ -48,6 +48,13 @@ {{ render_pkggrid(pop_mod) }} + + {{ _("See more") }} + +

{{ _("Top Texture Packs") }}

+ {{ render_pkggrid(pop_txp) }} + + {{ _("See more") }} diff --git a/app/templates/packages/view.html b/app/templates/packages/view.html index a1d7aa11..801ffa58 100644 --- a/app/templates/packages/view.html +++ b/app/templates/packages/view.html @@ -442,31 +442,45 @@ {% endif %} - {% if package.type == package.type.MOD %} -

- {% if package.checkPerm(current_user, "EDIT_PACKAGE") %} - - - - {% endif %} - {{ _("Compatible Games") }} -

-
- {% for support in package.getSortedSupportedGames() %} - - {{ _("%(title)s by %(display_name)s", - title=support.game.title, display_name=support.game.author.display_name) }} - - {% else %} - {{ _("No specific game is required") }} - {% endfor %} -
+ {% if package.type == package.type.MOD or package.type == package.type.TXP %} + {% set supported_games = package.getSortedSupportedGames() %} + {% if supported_games or package.type == package.type.MOD %} +

+ {% if package.checkPerm(current_user, "EDIT_PACKAGE") %} + + + + {% endif %} + {{ _("Compatible Games") }} +

+
+ {% for support in supported_games %} + + {{ _("%(title)s by %(display_name)s", + title=support.game.title, display_name=support.game.author.display_name) }} + + {% else %} + {{ _("No specific game is required") }} + {% endfor %} +
-

- {{ _("This is an experimental feature.") }} - {{ _("Supported games are determined by an algorithm, and may not be correct.") }} -

+ {% if package.type == package.type.MOD %} +

+ {{ _("This is an experimental feature.") }} + {{ _("Supported games are determined by an algorithm, and may not be correct.") }} +

+ {% endif %} + {% elif package.checkPerm(current_user, "EDIT_PACKAGE") %} +

+ {% if package.checkPerm(current_user, "EDIT_PACKAGE") %} + + + + {% endif %} + {{ _("Please specify compatible games") }} +

+ {% endif %} {% endif %}