Skip to content

Commit

Permalink
Changed all the assets to webp x2
Browse files Browse the repository at this point in the history
  • Loading branch information
Wolfteam committed Sep 4, 2022
1 parent af3e3c6 commit c1fb7ed
Show file tree
Hide file tree
Showing 11 changed files with 39 additions and 29 deletions.
1 change: 1 addition & 0 deletions lib/domain/app_constants.dart
Expand Up @@ -5,6 +5,7 @@ import 'models/models.dart';

const na = 'N/A';
const githubPage = 'https://github.com/Wolfteam/Shiori';
const imageFileExtension = '.webp';

//This order matches the one in the game, and the numbers represent each image
const artifactOrder = [4, 2, 5, 1, 3];
Expand Down
29 changes: 15 additions & 14 deletions lib/domain/assets.dart
@@ -1,6 +1,7 @@
import 'dart:convert';

import 'package:flutter/services.dart' show rootBundle;
import 'package:shiori/domain/app_constants.dart';
import 'package:shiori/domain/enums/enums.dart';
import 'package:shiori/domain/extensions/string_extensions.dart';

Expand All @@ -23,7 +24,7 @@ class Assets {
static String characterFullBasePath = 'assets/characters_full';
static String skillsBasePath = 'assets/skills';
static String elementsBasePath = 'assets/elements';
static String noImageAvailableName = 'na.png';
static String noImageAvailableName = 'na$imageFileExtension';

//Weapons
static String weaponsBasePath = 'assets/weapons';
Expand Down Expand Up @@ -196,19 +197,19 @@ class Assets {
static String getElementPathFromType(ElementType type) {
switch (type) {
case ElementType.anemo:
return getElementPath('anemo.png');
return getElementPath('anemo$imageFileExtension');
case ElementType.cryo:
return getElementPath('cryo.png');
return getElementPath('cryo$imageFileExtension');
case ElementType.dendro:
return getElementPath('dendro.png');
return getElementPath('dendro$imageFileExtension');
case ElementType.electro:
return getElementPath('electro.png');
return getElementPath('electro$imageFileExtension');
case ElementType.geo:
return getElementPath('geo.png');
return getElementPath('geo$imageFileExtension');
case ElementType.hydro:
return getElementPath('hydro.png');
return getElementPath('hydro$imageFileExtension');
case ElementType.pyro:
return getElementPath('pyro.png');
return getElementPath('pyro$imageFileExtension');
default:
throw Exception('Invalid element type = $type');
}
Expand All @@ -221,21 +222,21 @@ class Assets {
static String getArtifactPathFromType(ArtifactType type) {
switch (type) {
case ArtifactType.clock:
return getMaterialPath('clock.png', MaterialType.others);
return getMaterialPath('clock$imageFileExtension', MaterialType.others);
case ArtifactType.crown:
return getMaterialPath('crown.png', MaterialType.others);
return getMaterialPath('crown$imageFileExtension', MaterialType.others);
case ArtifactType.flower:
return getMaterialPath('flower.png', MaterialType.others);
return getMaterialPath('flower$imageFileExtension', MaterialType.others);
case ArtifactType.goblet:
return getMaterialPath('goblet.png', MaterialType.others);
return getMaterialPath('goblet$imageFileExtension', MaterialType.others);
case ArtifactType.plume:
return getMaterialPath('plume.png', MaterialType.others);
return getMaterialPath('plume$imageFileExtension', MaterialType.others);
default:
throw Exception('Invalid artifact type = $type');
}
}

static String getOriginalResinPath() => Assets.getCurrencyMaterialPath('fragile-resin.png');
static String getOriginalResinPath() => Assets.getCurrencyMaterialPath('fragile-resin$imageFileExtension');

static String getGadgetPath(String image) => '$gadgetsBasePath/$image';

Expand Down
12 changes: 7 additions & 5 deletions lib/domain/extensions/weapon_type_extensions.dart
@@ -1,19 +1,21 @@
import 'package:shiori/domain/app_constants.dart';

import '../assets.dart';
import '../enums/weapon_type.dart';

extension WeaponTypeExtension on WeaponType {
String getWeaponAssetPath() {
switch (this) {
case WeaponType.bow:
return Assets.getWeaponPath('amos-bow.png', this);
return Assets.getWeaponPath('amos-bow$imageFileExtension', this);
case WeaponType.sword:
return Assets.getWeaponPath('skyward-blade.png', this);
return Assets.getWeaponPath('skyward-blade$imageFileExtension', this);
case WeaponType.catalyst:
return Assets.getWeaponPath('lost-prayer-to-the-sacred-winds.png', this);
return Assets.getWeaponPath('lost-prayer-to-the-sacred-winds$imageFileExtension', this);
case WeaponType.claymore:
return Assets.getWeaponPath('wolfs-gravestone.png', this);
return Assets.getWeaponPath('wolfs-gravestone$imageFileExtension', this);
case WeaponType.polearm:
return Assets.getWeaponPath('skyward-spine.png', this);
return Assets.getWeaponPath('skyward-spine$imageFileExtension', this);
default:
throw Exception('Invalid weapon type = ${this}');
}
Expand Down
6 changes: 3 additions & 3 deletions lib/infrastructure/file/artifact_file_service.dart
Expand Up @@ -62,9 +62,9 @@ class ArtifactFileServiceImpl extends ArtifactFileService {
return [fullImagePath];
}

var imageWithoutExt = image.split('.png').first;
var imageWithoutExt = image.split(imageFileExtension).first;
imageWithoutExt = imageWithoutExt.substring(0, imageWithoutExt.length - 1);
return artifactOrder.map((e) => Assets.getArtifactPath('$imageWithoutExt$e.png')).toList();
return artifactOrder.map((e) => Assets.getArtifactPath('$imageWithoutExt$e$imageFileExtension')).toList();
}

@override
Expand All @@ -79,7 +79,7 @@ class ArtifactFileServiceImpl extends ArtifactFileService {

final imgs = getArtifactRelatedParts(fullImagePath, image, bonus);
final order = getArtifactOrder(type);
return imgs.firstWhere((el) => el.endsWith('$order.png'));
return imgs.firstWhere((el) => el.endsWith('$order$imageFileExtension'));
}

@override
Expand Down
3 changes: 2 additions & 1 deletion lib/presentation/home/widgets/materials_card.dart
@@ -1,4 +1,5 @@
import 'package:flutter/material.dart';
import 'package:shiori/domain/app_constants.dart';
import 'package:shiori/domain/assets.dart';
import 'package:shiori/generated/l10n.dart';
import 'package:shiori/presentation/home/widgets/card_description.dart';
Expand All @@ -22,7 +23,7 @@ class MaterialsCard extends StatelessWidget {
title: s.materials,
iconToTheLeft: iconToTheLeft,
onClick: _gotoMaterialsPage,
icon: Image.asset(Assets.getOtherMaterialPath('bag.png'), width: 60, height: 60, color: theme.colorScheme.secondary),
icon: Image.asset(Assets.getOtherMaterialPath('bag$imageFileExtension'), width: 60, height: 60, color: theme.colorScheme.secondary),
children: [
CardDescription(text: s.checkAllMaterials),
],
Expand Down
3 changes: 2 additions & 1 deletion lib/presentation/home/widgets/monsters_card.dart
@@ -1,4 +1,5 @@
import 'package:flutter/material.dart';
import 'package:shiori/domain/app_constants.dart';
import 'package:shiori/domain/assets.dart';
import 'package:shiori/generated/l10n.dart';
import 'package:shiori/presentation/home/widgets/card_description.dart';
Expand All @@ -22,7 +23,7 @@ class MonstersCard extends StatelessWidget {
onClick: (context) => _goToMonstersPage(context),
iconToTheLeft: iconToTheLeft,
icon: Image.asset(
Assets.getOtherMaterialPath('monster.png'),
Assets.getOtherMaterialPath('monster$imageFileExtension'),
width: 60,
height: 60,
color: theme.colorScheme.secondary,
Expand Down
@@ -1,6 +1,7 @@
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:shiori/application/bloc.dart';
import 'package:shiori/domain/app_constants.dart';
import 'package:shiori/domain/assets.dart';
import 'package:shiori/domain/models/models.dart';
import 'package:shiori/generated/l10n.dart';
Expand Down Expand Up @@ -69,7 +70,7 @@ class _CakeCard extends StatelessWidget {
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Image.asset(Assets.getOtherMaterialPath('cake.png'), width: 120, height: 120),
Image.asset(Assets.getOtherMaterialPath('cake$imageFileExtension'), width: 120, height: 120),
//The cake has some space in the top and bottom, that's why we used this offset here
FractionalTranslation(
translation: const Offset(0, -0.5),
Expand Down
3 changes: 2 additions & 1 deletion lib/presentation/home/widgets/wish_simulator_card.dart
@@ -1,4 +1,5 @@
import 'package:flutter/material.dart';
import 'package:shiori/domain/app_constants.dart';
import 'package:shiori/domain/assets.dart';
import 'package:shiori/generated/l10n.dart';
import 'package:shiori/presentation/home/widgets/card_description.dart';
Expand All @@ -22,7 +23,7 @@ class WishSimulatorCard extends StatelessWidget {
title: s.wishSimulator,
iconToTheLeft: iconToTheLeft,
onClick: _gotoWishSimulatorPage,
icon: Image.asset(Assets.getOtherMaterialPath('gacha.png'), width: 60, height: 60, color: theme.colorScheme.secondary),
icon: Image.asset(Assets.getOtherMaterialPath('gacha$imageFileExtension'), width: 60, height: 60, color: theme.colorScheme.secondary),
children: [
CardDescription(text: s.tryYourLuck),
],
Expand Down
2 changes: 1 addition & 1 deletion lib/presentation/shared/ascension_level.dart
Expand Up @@ -30,7 +30,7 @@ class AscensionLevel extends StatelessWidget {
iconSize: iconSize,
icon: Opacity(
opacity: isSelected ? 1 : 0.2,
child: Image.asset(Assets.getOtherMaterialPath('mark_wind_crystal.png'), width: 40, height: 40),
child: Image.asset(Assets.getOtherMaterialPath('mark_wind_crystal$imageFileExtension'), width: 40, height: 40),
),
splashRadius: 20,
onPressed: () {
Expand Down
3 changes: 2 additions & 1 deletion lib/presentation/shared/images/primogem_icon.dart
@@ -1,12 +1,13 @@
import 'package:flutter/material.dart';
import 'package:shiori/domain/app_constants.dart';
import 'package:shiori/domain/assets.dart';

class PrimoGemIcon extends StatelessWidget {
@override
Widget build(BuildContext context) {
return IconButton(
iconSize: 30,
icon: Image.asset(Assets.getCurrencyMaterialPath('primogem.png')),
icon: Image.asset(Assets.getCurrencyMaterialPath('primogem$imageFileExtension')),
onPressed: null,
);
}
Expand Down
3 changes: 2 additions & 1 deletion lib/presentation/splash/splash_page.dart
@@ -1,4 +1,5 @@
import 'package:flutter/material.dart';
import 'package:shiori/domain/app_constants.dart';
import 'package:shiori/domain/assets.dart';

class SplashPage extends StatelessWidget {
Expand All @@ -12,7 +13,7 @@ class SplashPage extends StatelessWidget {
child: Container(
margin: const EdgeInsets.all(10),
child: Image.asset(
Assets.getCharacterFullPath('Paimon.png'),
Assets.getCharacterFullPath('Paimon$imageFileExtension'),
fit: BoxFit.scaleDown,
),
),
Expand Down

0 comments on commit c1fb7ed

Please sign in to comment.