Enable game support for texture packs

This commit is contained in:
rubenwardy 2023-01-12 19:48:18 +00:00
parent 605015f812
commit 42b9986fc8
5 changed files with 50 additions and 29 deletions

@ -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)

@ -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)

@ -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)

@ -48,6 +48,13 @@
{{ render_pkggrid(pop_mod) }}
<a href="{{ url_for('packages.list_all', type='txp', sort='score', order='desc', game=package.getId()) }}" class="btn btn-secondary float-right">
{{ _("See more") }}
</a>
<h2 class="my-3">{{ _("Top Texture Packs") }}</h2>
{{ render_pkggrid(pop_txp) }}
<a href="{{ url_for('packages.list_all', sort='reviews', order='desc', game=package.getId()) }}" class="btn btn-secondary float-right">
{{ _("See more") }}
</a>

@ -442,31 +442,45 @@
</dl>
{% endif %}
{% if package.type == package.type.MOD %}
<h3>
{% if package.checkPerm(current_user, "EDIT_PACKAGE") %}
<a href="{{ package.getURL('packages.game_support') }}" class="btn btn-secondary btn-sm float-right">
<i class="fas fa-pen"></i>
</a>
{% endif %}
{{ _("Compatible Games") }}
</h3>
<div style="max-height: 300px; overflow: hidden auto;">
{% for support in package.getSortedSupportedGames() %}
<a class="badge badge-secondary"
href="{{ support.game.getURL('packages.view') }}">
{{ _("%(title)s by %(display_name)s",
title=support.game.title, display_name=support.game.author.display_name) }}
</a>
{% else %}
{{ _("No specific game is required") }}
{% endfor %}
</div>
{% 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 %}
<h3>
{% if package.checkPerm(current_user, "EDIT_PACKAGE") %}
<a href="{{ package.getURL('packages.game_support') }}" class="btn btn-secondary btn-sm float-right">
<i class="fas fa-pen"></i>
</a>
{% endif %}
{{ _("Compatible Games") }}
</h3>
<div style="max-height: 300px; overflow: hidden auto;">
{% for support in supported_games %}
<a class="badge badge-secondary"
href="{{ support.game.getURL('packages.view') }}">
{{ _("%(title)s by %(display_name)s",
title=support.game.title, display_name=support.game.author.display_name) }}
</a>
{% else %}
{{ _("No specific game is required") }}
{% endfor %}
</div>
<p class="text-muted small mt-2 mb-0">
{{ _("This is an experimental feature.") }}
{{ _("Supported games are determined by an algorithm, and may not be correct.") }}
</p>
{% if package.type == package.type.MOD %}
<p class="text-muted small mt-2 mb-0">
{{ _("This is an experimental feature.") }}
{{ _("Supported games are determined by an algorithm, and may not be correct.") }}
</p>
{% endif %}
{% elif package.checkPerm(current_user, "EDIT_PACKAGE") %}
<p class="alert alert-warning">
{% if package.checkPerm(current_user, "EDIT_PACKAGE") %}
<a href="{{ package.getURL('packages.game_support') }}" class="btn btn-warning btn-sm float-right">
<i class="fas fa-pen"></i>
</a>
{% endif %}
{{ _("Please specify compatible games") }}
</p>
{% endif %}
{% endif %}
<h3>