Skip to content

Commit e69724c

Browse files
committed
Add option to disable stacking
1 parent 8664b25 commit e69724c

File tree

7 files changed

+59
-26
lines changed

7 files changed

+59
-26
lines changed

app/lib/bloc/settings.dart

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ class SetonixSettings with SetonixSettingsMappable implements LeapSettings {
5454
final String? lastVersion;
5555
@override
5656
final bool nativeTitleBar;
57+
final bool stackedCards;
5758
final bool showConnectYour, showConnectNetwork;
5859
final GameProperty gameProperty;
5960
final List<ListGameServer> servers;
@@ -74,6 +75,7 @@ class SetonixSettings with SetonixSettingsMappable implements LeapSettings {
7475
this.lastVersion,
7576
this.gameProperty = const GameProperty(),
7677
this.servers = const [],
78+
this.stackedCards = true,
7779
this.highContrast = false,
7880
this.zoom = 1,
7981
this.swamps = const [],
@@ -112,6 +114,7 @@ class SetonixSettings with SetonixSettingsMappable implements LeapSettings {
112114
zoom: prefs.getDouble('zoom') ?? 1,
113115
swamps: prefs.getStringList('swamps') ?? [],
114116
scrollSensitivity: prefs.getDouble('scrollSensitivity') ?? 1,
117+
stackedCards: prefs.getBool('stackedCards') ?? true,
115118
density: ThemeDensity.values.byName(
116119
prefs.getString('density') ?? ThemeDensity.system.name,
117120
),
@@ -133,6 +136,7 @@ class SetonixSettings with SetonixSettingsMappable implements LeapSettings {
133136
} else {
134137
await prefs.setString('last_version', lastVersion!);
135138
}
139+
await prefs.setBool('stackedCards', stackedCards);
136140
await prefs.setString('gameProperty', gameProperty.toJson());
137141
await prefs.setStringList(
138142
'servers', servers.map((e) => e.toJson()).toList());
@@ -260,6 +264,11 @@ class SettingsCubit extends Cubit<SetonixSettings>
260264
return save();
261265
}
262266

267+
Future<void> changeStackedCards(bool value) {
268+
emit(state.copyWith(stackedCards: value));
269+
return save();
270+
}
271+
263272
Future<void> importSettings(String data) {
264273
final settings = SetonixSettingsMapper.fromJson(data);
265274
emit(settings);

app/lib/bloc/settings.mapper.dart

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,9 @@ class SetonixSettingsMapper extends ClassMapperBase<SetonixSettings> {
117117
static List<ListGameServer> _$servers(SetonixSettings v) => v.servers;
118118
static const Field<SetonixSettings, List<ListGameServer>> _f$servers =
119119
Field('servers', _$servers, opt: true, def: const []);
120+
static bool _$stackedCards(SetonixSettings v) => v.stackedCards;
121+
static const Field<SetonixSettings, bool> _f$stackedCards =
122+
Field('stackedCards', _$stackedCards, opt: true, def: true);
120123
static bool _$highContrast(SetonixSettings v) => v.highContrast;
121124
static const Field<SetonixSettings, bool> _f$highContrast =
122125
Field('highContrast', _$highContrast, opt: true, def: false);
@@ -145,6 +148,7 @@ class SetonixSettingsMapper extends ClassMapperBase<SetonixSettings> {
145148
#lastVersion: _f$lastVersion,
146149
#gameProperty: _f$gameProperty,
147150
#servers: _f$servers,
151+
#stackedCards: _f$stackedCards,
148152
#highContrast: _f$highContrast,
149153
#zoom: _f$zoom,
150154
#swamps: _f$swamps,
@@ -164,6 +168,7 @@ class SetonixSettingsMapper extends ClassMapperBase<SetonixSettings> {
164168
lastVersion: data.dec(_f$lastVersion),
165169
gameProperty: data.dec(_f$gameProperty),
166170
servers: data.dec(_f$servers),
171+
stackedCards: data.dec(_f$stackedCards),
167172
highContrast: data.dec(_f$highContrast),
168173
zoom: data.dec(_f$zoom),
169174
swamps: data.dec(_f$swamps),
@@ -240,6 +245,7 @@ abstract class SetonixSettingsCopyWith<$R, $In extends SetonixSettings, $Out>
240245
String? lastVersion,
241246
GameProperty? gameProperty,
242247
List<ListGameServer>? servers,
248+
bool? stackedCards,
243249
bool? highContrast,
244250
double? zoom,
245251
List<String>? swamps,
@@ -281,6 +287,7 @@ class _SetonixSettingsCopyWithImpl<$R, $Out>
281287
Object? lastVersion = $none,
282288
GameProperty? gameProperty,
283289
List<ListGameServer>? servers,
290+
bool? stackedCards,
284291
bool? highContrast,
285292
double? zoom,
286293
List<String>? swamps,
@@ -297,6 +304,7 @@ class _SetonixSettingsCopyWithImpl<$R, $Out>
297304
if (lastVersion != $none) #lastVersion: lastVersion,
298305
if (gameProperty != null) #gameProperty: gameProperty,
299306
if (servers != null) #servers: servers,
307+
if (stackedCards != null) #stackedCards: stackedCards,
300308
if (highContrast != null) #highContrast: highContrast,
301309
if (zoom != null) #zoom: zoom,
302310
if (swamps != null) #swamps: swamps,
@@ -316,6 +324,7 @@ class _SetonixSettingsCopyWithImpl<$R, $Out>
316324
lastVersion: data.get(#lastVersion, or: $value.lastVersion),
317325
gameProperty: data.get(#gameProperty, or: $value.gameProperty),
318326
servers: data.get(#servers, or: $value.servers),
327+
stackedCards: data.get(#stackedCards, or: $value.stackedCards),
319328
highContrast: data.get(#highContrast, or: $value.highContrast),
320329
zoom: data.get(#zoom, or: $value.zoom),
321330
swamps: data.get(#swamps, or: $value.swamps),

app/lib/board/hand/item.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,12 +122,12 @@ abstract class HandItem<T> extends PositionComponent
122122
@override
123123
Future<void> onLoad() async {
124124
super.onLoad();
125+
_sprite.size = Vector2.all(height - labelHeight);
125126
_sprite.sprite = game.blankSprite;
126127
add(_sprite);
127128
}
128129

129130
void _resetPosition() {
130-
_sprite.position = Vector2(0, labelHeight);
131131
priority = priorityNormal;
132132
if (!_label.isMounted) add(_label);
133133
final cursor = _cursorHitbox;

app/lib/board/hand/view.dart

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ class GameHand extends CustomPainterComponent
9797
previousState.showDuplicates != newState.showDuplicates ||
9898
previousState.searchTerm != newState.searchTerm;
9999
static const itemAngle = 0.01;
100-
static const activeItemWidth = 95;
100+
static const activeItemWidth = 100;
101101
static const itemWidth = 60;
102102
static const itemYOffset = 3;
103103
void _layoutChildren() {
@@ -108,15 +108,19 @@ class GameHand extends CustomPainterComponent
108108

109109
children.toList().whereType<HandItem>().forEachIndexed((index, element) {
110110
final double activeRelative = active - index;
111-
final angle = activeRelative * itemAngle;
112-
element.angle = angle;
113111
// Figure out how "active" this item is (0 = fully active, 1 = inactive)
114112
final progress = 1 - activeRelative.abs().clamp(0, 1);
115-
final currentWidth = itemWidth + (activeItemWidth - itemWidth) * progress;
113+
var x = center.x + 128 * activeRelative;
114+
var y = center.y;
115+
if (game.settingsCubit.state.stackedCards) {
116+
final currentWidth =
117+
itemWidth + (activeItemWidth - itemWidth) * progress;
116118

117-
final offset = activeRelative <= -1 ? -activeItemWidth / 2 : 0;
118-
final y = center.y + itemYOffset * activeRelative.abs();
119-
final x = center.x + offset + activeRelative * currentWidth;
119+
final offset = activeRelative <= -1 ? -activeItemWidth / 2 : 0;
120+
y = center.y + itemYOffset * activeRelative.abs();
121+
x = center.x + offset + activeRelative * currentWidth;
122+
element.angle = activeRelative * itemAngle;
123+
}
120124

121125
element.changeLabelVisibility(activeRelative.abs() >= 1);
122126

app/lib/l10n/app_en.arb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,5 +249,6 @@
249249
"desktop": "Desktop",
250250
"compact": "Compact",
251251
"standard": "Standard",
252-
"comfortable": "Comfortable"
252+
"comfortable": "Comfortable",
253+
"stackedCards": "Stacked cards"
253254
}

app/lib/pages/settings/personalization.dart

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -102,17 +102,7 @@ class PersonalizationSettingsPage extends StatelessWidget {
102102
.read<SettingsCubit>()
103103
.changeHighContrast(value),
104104
),
105-
]),
106-
),
107-
),
108-
if (!kIsWeb && (Platform.isWindows || Platform.isLinux))
109-
Card(
110-
margin: settingsCardMargin,
111-
child: Padding(
112-
padding: settingsCardPadding,
113-
child: Column(
114-
crossAxisAlignment: CrossAxisAlignment.stretch,
115-
children: [
105+
if (!kIsWeb && (Platform.isWindows || Platform.isLinux))
116106
SwitchListTile(
117107
value: state.nativeTitleBar,
118108
title: Text(
@@ -123,9 +113,29 @@ class PersonalizationSettingsPage extends StatelessWidget {
123113
.read<SettingsCubit>()
124114
.changeNativeTitleBar(value),
125115
),
126-
]),
127-
),
116+
]),
128117
),
118+
),
119+
Card(
120+
margin: settingsCardMargin,
121+
child: Padding(
122+
padding: settingsCardPadding,
123+
child: Column(
124+
crossAxisAlignment: CrossAxisAlignment.stretch,
125+
children: [
126+
SwitchListTile(
127+
title:
128+
Text(AppLocalizations.of(context).stackedCards),
129+
secondary:
130+
const PhosphorIcon(PhosphorIconsLight.stack),
131+
value: state.stackedCards,
132+
onChanged: (value) => context
133+
.read<SettingsCubit>()
134+
.changeStackedCards(value),
135+
),
136+
]),
137+
),
138+
),
129139
]);
130140
},
131141
));

plugin/rust/Cargo.lock

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)