From 6d6e9ad134a022283c8a10a289ab1c8592b60a01 Mon Sep 17 00:00:00 2001 From: narumi Date: Sat, 12 Aug 2023 23:25:42 +0800 Subject: [PATCH] Revert point buff icon, add more default value --- .../modules/battle/simulation_preview.dart | 2 +- lib/app/modules/event/event_detail_page.dart | 2 +- lib/app/modules/item/item_list.dart | 6 ++++- lib/generated/models/gamedata/event.g.dart | 16 +++++++----- lib/models/gamedata/event.dart | 26 +++++-------------- 5 files changed, 23 insertions(+), 29 deletions(-) diff --git a/lib/app/modules/battle/simulation_preview.dart b/lib/app/modules/battle/simulation_preview.dart index 3ad232e7c..aede87ab1 100644 --- a/lib/app/modules/battle/simulation_preview.dart +++ b/lib/app/modules/battle/simulation_preview.dart @@ -762,7 +762,7 @@ class _SimulationPreviewState extends State { options.pointBuffs.remove(groupId); } String? icon = groupDetail?.icon; - icon ??= buffs.firstOrNull?.iconFix; + icon ??= buffs.firstOrNull?.icon; rows.add(ListTile( dense: true, diff --git a/lib/app/modules/event/event_detail_page.dart b/lib/app/modules/event/event_detail_page.dart index 7ffe80e30..9f7e9a684 100644 --- a/lib/app/modules/event/event_detail_page.dart +++ b/lib/app/modules/event/event_detail_page.dart @@ -180,7 +180,7 @@ class _EventDetailPageState extends State { pointName = Transl.itemNames(pointGroup.name).l; } pointName ??= S.current.event_point_reward + (rewardGroups.length > 1 ? ' $groupId' : ''); - final icon = pointGroup?.icon ?? event.pointBuffs.firstWhereOrNull((buff) => buff.groupId == groupId)?.iconFix; + final icon = pointGroup?.icon ?? event.pointBuffs.firstWhereOrNull((buff) => buff.groupId == groupId)?.icon; tabs.add(Tab( child: Text.rich(TextSpan(children: [ if (icon != null) CenterWidgetSpan(child: db.getIconImage(icon, width: 24)), diff --git a/lib/app/modules/item/item_list.dart b/lib/app/modules/item/item_list.dart index 7dca6ce80..69b9af78c 100644 --- a/lib/app/modules/item/item_list.dart +++ b/lib/app/modules/item/item_list.dart @@ -376,7 +376,11 @@ class _ItemListTabState extends State { } break; case _ItemSortType.id: - sortedEntries.sort2((e) => e.key); + if (widget.category == ItemCategory.event) { + sortedEntries.sort2((e) => -e.key); + } else { + sortedEntries.sort2((e) => e.key); + } break; case _ItemSortType.owned: sortedEntries.sort2((e) => e.key == Items.qpId ? double.negativeInfinity : db.curUser.items[e.key] ?? 0); diff --git a/lib/generated/models/gamedata/event.g.dart b/lib/generated/models/gamedata/event.g.dart index 93b2fb2c5..549e1db06 100644 --- a/lib/generated/models/gamedata/event.g.dart +++ b/lib/generated/models/gamedata/event.g.dart @@ -379,9 +379,11 @@ Map _$ShopReleaseToJson(ShopRelease instance) => EventPointReward( - groupId: json['groupId'] as int, + groupId: json['groupId'] as int? ?? 0, point: json['point'] as int, - gifts: (json['gifts'] as List).map((e) => Gift.fromJson(Map.from(e as Map))).toList(), + gifts: + (json['gifts'] as List?)?.map((e) => Gift.fromJson(Map.from(e as Map))).toList() ?? + const [], ); Map _$EventPointRewardToJson(EventPointReward instance) => { @@ -391,7 +393,7 @@ Map _$EventPointRewardToJson(EventPointReward instance) => EventPointGroup( - groupId: json['groupId'] as int, + groupId: json['groupId'] as int? ?? 0, name: json['name'] as String? ?? "", icon: json['icon'] as String?, ); @@ -438,7 +440,7 @@ const _$ItemBGTypeEnumMap = { }; EventPointActivity _$EventPointActivityFromJson(Map json) => EventPointActivity( - groupId: json['groupId'] as int, + groupId: json['groupId'] as int? ?? 0, point: json['point'] as int? ?? 0, objectType: $enumDecodeNullable(_$EventPointActivityObjectTypeEnumMap, json['objectType']) ?? EventPointActivityObjectType.none, @@ -830,9 +832,9 @@ Map _$EventRewardSceneGuideToJson(EventRewardSceneGuide instanc }; EventRewardScene _$EventRewardSceneFromJson(Map json) => EventRewardScene( - slot: json['slot'] as int, - groupId: json['groupId'] as int, - type: json['type'] as int, + slot: json['slot'] as int? ?? 0, + groupId: json['groupId'] as int? ?? 0, + type: json['type'] as int? ?? 0, guides: (json['guides'] as List?) ?.map((e) => EventRewardSceneGuide.fromJson(Map.from(e as Map))) .toList() ?? diff --git a/lib/models/gamedata/event.dart b/lib/models/gamedata/event.dart index 5989c96f0..f48fb7621 100644 --- a/lib/models/gamedata/event.dart +++ b/lib/models/gamedata/event.dart @@ -557,9 +557,9 @@ class EventPointReward { // String bgImageGet; EventPointReward({ - required this.groupId, + this.groupId = 0, required this.point, - required this.gifts, + this.gifts = const [], // required this.bgImagePoint, // required this.bgImageGet, }); @@ -576,7 +576,7 @@ class EventPointGroup { String? icon; EventPointGroup({ - required this.groupId, + this.groupId = 0, this.name = "", String? icon, }) : icon = icon != null && icon.endsWith('/Items/0.png') ? null : icon; @@ -615,18 +615,6 @@ class EventPointBuff { this.lv = 0, }); - String get iconFix { - if (groupId ~/ 100 == 80442) { - final match = RegExp(r'/Items/(\d+).png').firstMatch(icon); - String? iconId = match?.group(1); - if (iconId != null) { - iconId = iconId.padLeft(2, '0'); - return "https://static.atlasacademy.io/JP/EventUI/Prefabs/80442/img_LeaderIcon$iconId.png"; - } - } - return icon; - } - factory EventPointBuff.fromJson(Map json) => _$EventPointBuffFromJson(json); Map toJson() => _$EventPointBuffToJson(this); @@ -641,7 +629,7 @@ class EventPointActivity { int objectValue; EventPointActivity({ - required this.groupId, + this.groupId = 0, this.point = 0, this.objectType = EventPointActivityObjectType.none, this.objectId = 0, @@ -1097,9 +1085,9 @@ class EventRewardScene { List flags; EventRewardScene({ - required this.slot, - required this.groupId, - required this.type, + this.slot = 0, + this.groupId = 0, + this.type = 0, this.guides = const [], required this.tabOnImage, required this.tabOffImage,