feat: featch cards to storage
This commit is contained in:
@@ -44,10 +44,27 @@ class CardComponent extends PositionComponent
|
||||
|
||||
@override
|
||||
Future<void> onLoad() async {
|
||||
// اگر تصویر از قبل در حافظه آماده باشد (از کشِ دیسک/preload)، همان لحظه ست میشود
|
||||
// ⇒ کارت با تصویرِ درست و بدونِ پرش رندر میشود. وگرنه بدونِ مسدودکردنِ رندر در
|
||||
// پسزمینه بارگذاری و بهمحضِ آمادهشدن جایگزین میشود (نسخهی برداری تا آن لحظه).
|
||||
if (code.isNotEmpty) {
|
||||
_front = await CardImages.front(skin, code);
|
||||
final cached = CardImages.cachedFront(skin, code);
|
||||
if (cached != null) {
|
||||
_front = cached;
|
||||
} else {
|
||||
CardImages.front(skin, code).then((s) {
|
||||
if (isMounted) _front = s;
|
||||
});
|
||||
}
|
||||
}
|
||||
final cb = CardImages.cachedBack(skin);
|
||||
if (cb != null) {
|
||||
_back = cb;
|
||||
} else {
|
||||
CardImages.back(skin).then((s) {
|
||||
if (isMounted) _back = s;
|
||||
});
|
||||
}
|
||||
_back = await CardImages.back(skin);
|
||||
}
|
||||
|
||||
/// برگرداندنِ کارت از پشت به رو با انیمیشن (هنگام پخششدن از روی دسته).
|
||||
|
||||
@@ -7,6 +7,7 @@ import 'package:flame/game.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart' show HapticFeedback;
|
||||
|
||||
import '../../../../../core/network/card_images.dart';
|
||||
import '../../../../../core/service/app_sounds.dart';
|
||||
import '../../../../../core/settings/app_settings.dart';
|
||||
import '../../../../../core/theme/app_theme.dart';
|
||||
@@ -79,6 +80,7 @@ class HokmGame extends FlameGame {
|
||||
|
||||
@override
|
||||
Future<void> onLoad() async {
|
||||
CardImages.preloadDeck(skin); // گرمکردنِ کشِ تصاویرِ کارت (پسزمینه، fire-and-forget)
|
||||
add(Felt(carpetUrl: carpetUrl));
|
||||
if (!AppSettings.I.lowGraphics.value) {
|
||||
add(Motes()); // ذراتِ طلاییِ معلق برای اتمسفر (در حالتِ کممصرف خاموش)
|
||||
|
||||
Reference in New Issue
Block a user