Files
2026-11-28 22:22:21 +01:00

86 lines
4.5 KiB
Dart
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import 'package:flutter/material.dart';
/// Where a target design comes from (only used to order and group the picker).
enum TargetGroup { classic, design, holiday }
/// One target design of the v5 set (FigCraft Designs/target-designs/v5).
///
/// Every design has the same geometry in a 1200 × 1200 space: centre
/// (600, 600), ring 1 at r 510, the black at r 180; decoration and glow only
/// outside ring 1, transparent beyond. Each design comes with its own screen
/// background (target-backgrounds/v3), shown on the target screens. Hits are stored in that space, so a hit lands on the same
/// ring whatever design is picked. The default ([id] 0, "00 Privzeta") is
/// drawn as vectors (sharp at any zoom); the others are 1600 px WebP images
/// with transparency.
class TargetStyle {
final int id; // 1–35 are the old Target<id>.jpg, so saved choices carry over
final String sl;
final String en;
final String de;
final TargetGroup group;
final Color glow; // outer glow colour, used for the picker's selection ring
const TargetStyle(this.id, this.sl, this.en, this.de, this.group, this.glow);
bool get isDefault => id == 0;
bool get isHoliday => group == TargetGroup.holiday;
/// Image asset; null for the vector default.
String? get asset => isDefault ? null : 'assets/targets/v5/t${id.toString().padLeft(2, '0')}.webp';
/// Its background on the target screens (target-backgrounds/v3, laid out
/// round the result screen's target), in dark or light.
String background(bool dark) => 'assets/backgrounds/t${id.toString().padLeft(2, '0')}_${dark ? 'dark' : 'light'}.webp';
String name(String language) => switch (language) {
'Slovenian' => sl,
'German' => de,
_ => en,
};
static const TargetStyle fallback = TargetStyle(0, 'Privzeta', 'Default', 'Standard', TargetGroup.classic, Color(0xFF9FD8FF));
static TargetStyle byId(int? id) =>
[...all, ...holidays].firstWhere((t) => t.id == id, orElse: () => fallback);
/// Holiday targets: never in the picker, only shown (locked) during their
/// holiday – see HolidayTheme.
static const List<TargetStyle> holidays = [
TargetStyle(70, 'Božič', 'Christmas', 'Weihnachten', TargetGroup.holiday, Color(0xFFE2231A)),
TargetStyle(71, 'Novo leto', 'New Year', 'Neujahr', TargetGroup.holiday, Color(0xFF7A2CFF)),
TargetStyle(72, 'Velika noč', 'Easter', 'Ostern', TargetGroup.holiday, Color(0xFFB6E86E)),
TargetStyle(73, 'Valentinovo', 'Valentine\'s Day', 'Valentinstag', TargetGroup.holiday, Color(0xFFE2112F)),
TargetStyle(74, 'Noč čarovnic', 'Halloween', 'Halloween', TargetGroup.holiday, Color(0xFF7A2CFF)),
TargetStyle(75, 'Pust', 'Carnival', 'Fasching', TargetGroup.holiday, Color(0xFFFF2F6D)),
TargetStyle(76, 'Martinovo', 'St Martin\'s Day', 'Martinstag', TargetGroup.holiday, Color(0xFF7A1E4A)),
TargetStyle(77, 'Praznik dela', 'Labour Day', 'Tag der Arbeit', TargetGroup.holiday, Color(0xFFE2231A)),
TargetStyle(78, 'Kresna noč', 'Midsummer night', 'Johannisnacht', TargetGroup.holiday, Color(0xFFFF3D00)),
TargetStyle(79, 'Dan državnosti', 'Statehood Day', 'Staatsfeiertag', TargetGroup.holiday, Color(0xFF1C4FA0)),
];
/// The designs the app ships, in picker order (a 3 × 3 grid). The rest of
/// the v5 set (FigCraft Designs/target-designs/v5) is not used for now; to
/// bring one back, add its line here and its webp to assets/targets/v5 (and
/// its backgrounds to assets/backgrounds). A saved id that is no longer
/// here (1, 19, 42 from earlier versions) falls back to the default.
static const List<TargetStyle> all = [
fallback,
TargetStyle(5, 'Plameni', 'Flames', 'Flammen', TargetGroup.classic, Color(0xFFFF3D00)),
TargetStyle(7, 'Sončno rumena', 'Sunny yellow', 'Sonnengelb', TargetGroup.classic, Color(0xFFFFA000)),
TargetStyle(18, 'Ledeni kristal', 'Ice crystal', 'Eiskristall', TargetGroup.classic, Color(0xFF00B8FF)),
TargetStyle(40, 'Kovinar', 'Kovinar', 'Kovinar', TargetGroup.design, Color(0xFF12855C)),
TargetStyle(53, 'Kamuflaža', 'Camouflage', 'Tarnmuster', TargetGroup.design, Color(0xFF3E4A26)),
TargetStyle(61, 'Cvetlice', 'Flowers', 'Blumen', TargetGroup.design, Color(0xFFFF6FB0)),
TargetStyle(11, 'Galaksija', 'Galaxy', 'Galaxie', TargetGroup.classic, Color(0xFF6A2DFF)),
TargetStyle(14, 'Mavrica', 'Rainbow', 'Regenbogen', TargetGroup.classic, Color(0xFF7A5CFF)),
];
@override
bool operator ==(Object other) => other is TargetStyle && other.id == id;
@override
int get hashCode => id.hashCode;
}