{% extends "base.html" %}

{% block title %}
	{{ _("Game Support for %(username)s", username=user.display_name) }}
{% endblock %}

{% block content %}
	<a class="btn btn-secondary float-end" href="/help/game_support/">{{ _("Help") }}</a>
	<h1 class="mb-5">{{ self.title() }}</h1>
	<p>
		{{ _("You should specify the games supported by your mods and texture packs.") }}
		{{ _("Specifying game support makes it easier for players to find your content.") }}
		{{ _("If your package is game independent, confirm this using 'Supports all games'") }}
	</p>


	<div class="list-group mt-3 mb-5">
		{% for package in packages %}
			<div class="list-group-item">
				<div class="row">
					<div class="col-md-2 text-muted">
						<img
							class="img-fluid"
							style="max-height: 22px; max-width: 22px;"
							src="{{ package.get_thumb_or_placeholder() }}" />

						<span class="ps-2">
							{{ package.title }}
						</span>
					</div>
					<div class="col">
						{% if package.supports_all_games %}
							<span class="text-muted pe-2">
								<i>
									{{ _("Supports all games") }}
								</i>
							</span>
						{% endif %}

						{% set supported_games = package.get_sorted_game_support_pair()[0] %}
						{% if supported_games %}
							{% for support in supported_games %}
								<a class="badge bg-secondary"
										href="{{ support.game.get_url('packages.view') }}">
									{{ _("%(title)s by %(display_name)s",
											title=support.game.title, display_name=support.game.author.display_name) }}
								</a>
							{% endfor %}
						{% elif not package.supports_all_games %}
							<span class="text-danger">
								{{ _("No supported games listed. Please either add supported games or check 'Supports all games'") }}
							</span>
						{% endif %}
					</div>
					<div class="col-auto">
						<a class="btn btn-sm btn-primary" href="{{ package.get_url('packages.game_support') }}">Game Support</a>
						<a class="btn btn-sm btn-secondary" href="{{ package.get_url('packages.view') }}">Package</a>
					</div>
				</div>
			</div>
		{% else %}
			<p class="text-muted">{{ _("Nothing to do :)") }}</p>
		{% endfor %}
	</div>

	{% if bulk_support_names %}
		<h2>{{ _("Bulk support all games") }}</h2>
		<p>
			{{ _("Click the button below to confirm that the following packages do support all games, except for any games listed in unsupported_games:") }}
			{{ bulk_support_names }}
		</p>
		<form method="post" action="{{ url_for('todo.confirm_supports_all_games', username=user.username) }}">
			<input type="hidden" name="csrf_token" value="{{ csrf_token() }}" />
			<input type="submit" value="{{ _('Confirm') }}" class="btn btn-primary">
		</form>
	{% endif %}
{% endblock %}