1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
//! Contributors screen system
//!
//! This module displays GitHub contributors loaded from contributors.json
use super::avatar_loader::{AvatarFallback, AvatarImage};
use crate::dice3d::types::{
ContributorCard, ContributorsData, ContributorsList, ContributorsScreenRoot, ContributorsState,
IconAssets, IconType,
};
use bevy::prelude::*;
/// Initialize contributors data
pub fn init_contributors(mut commands: Commands) {
let data = ContributorsData::load();
commands.insert_resource(ContributorsState { data, loaded: true });
}
/// Setup the Contributors screen
pub fn setup_contributors_screen(
mut commands: Commands,
contributors_state: Res<ContributorsState>,
icon_assets: Res<IconAssets>,
) {
let header_color = Color::srgb(0.9, 0.8, 0.4);
let text_color = Color::srgb(0.85, 0.85, 0.9);
let subtext_color = Color::srgb(0.6, 0.6, 0.7);
let card_bg = Color::srgb(0.12, 0.12, 0.18);
let accent_color = Color::srgb(0.4, 0.7, 1.0);
// Root container (hidden by default)
commands
.spawn((
NodeBundle {
style: Style {
position_type: PositionType::Absolute,
top: Val::Px(45.0),
left: Val::Px(0.0),
right: Val::Px(0.0),
bottom: Val::Px(0.0),
flex_direction: FlexDirection::Column,
padding: UiRect::all(Val::Px(20.0)),
overflow: Overflow::clip(),
..default()
},
background_color: BackgroundColor(Color::srgb(0.08, 0.08, 0.12)),
visibility: Visibility::Hidden,
..default()
},
ContributorsScreenRoot,
))
.with_children(|parent| {
// Header section
parent
.spawn(NodeBundle {
style: Style {
width: Val::Percent(100.0),
flex_direction: FlexDirection::Column,
align_items: AlignItems::Center,
margin: UiRect::bottom(Val::Px(20.0)),
..default()
},
..default()
})
.with_children(|header| {
// Title with icon
header
.spawn(NodeBundle {
style: Style {
flex_direction: FlexDirection::Row,
align_items: AlignItems::Center,
column_gap: Val::Px(12.0),
..default()
},
..default()
})
.with_children(|row| {
// Icon
if let Some(icon_handle) = icon_assets.icons.get(&IconType::Character) {
row.spawn(ImageBundle {
image: UiImage::new(icon_handle.clone()),
style: Style {
width: Val::Px(36.0),
height: Val::Px(36.0),
..default()
},
..default()
});
}
row.spawn(TextBundle::from_section(
"Contributors",
TextStyle {
font_size: 32.0,
color: header_color,
..default()
},
));
});
// Subtitle with repo info
header.spawn(TextBundle::from_section(
format!("Thank you to everyone who has contributed to {}", contributors_state.data.repository),
TextStyle {
font_size: 16.0,
color: subtext_color,
..default()
},
));
// Last updated
header.spawn(
TextBundle::from_section(
format!("Last updated: {}", contributors_state.data.last_updated),
TextStyle {
font_size: 12.0,
color: Color::srgb(0.5, 0.5, 0.55),
..default()
},
)
.with_style(Style {
margin: UiRect::top(Val::Px(5.0)),
..default()
}),
);
});
// Divider
parent.spawn(NodeBundle {
style: Style {
width: Val::Percent(100.0),
height: Val::Px(1.0),
margin: UiRect::vertical(Val::Px(10.0)),
..default()
},
background_color: BackgroundColor(Color::srgb(0.3, 0.3, 0.35)),
..default()
});
// Scrollable contributors list
parent
.spawn((
NodeBundle {
style: Style {
width: Val::Percent(100.0),
flex_grow: 1.0,
flex_direction: FlexDirection::Column,
overflow: Overflow::clip_y(),
..default()
},
..default()
},
ContributorsList,
))
.with_children(|list| {
// Contributors grid/list
list.spawn(NodeBundle {
style: Style {
width: Val::Percent(100.0),
flex_direction: FlexDirection::Row,
flex_wrap: FlexWrap::Wrap,
justify_content: JustifyContent::Center,
row_gap: Val::Px(15.0),
column_gap: Val::Px(15.0),
padding: UiRect::all(Val::Px(10.0)),
..default()
},
..default()
})
.with_children(|grid| {
// Spawn a card for each contributor
for (index, contributor) in contributors_state.data.contributors.iter().enumerate() {
spawn_contributor_card(
grid,
index,
&contributor.login,
contributor.display_name(),
&contributor.avatar_url,
contributor.contributions,
contributor.role.as_deref(),
card_bg,
text_color,
subtext_color,
accent_color,
);
}
// If no contributors, show message
if contributors_state.data.contributors.is_empty() {
grid.spawn(TextBundle::from_section(
"No contributors data available.\nContributors will be updated at release time.",
TextStyle {
font_size: 16.0,
color: subtext_color,
..default()
},
));
}
});
});
// Footer with GitHub link
parent
.spawn(NodeBundle {
style: Style {
width: Val::Percent(100.0),
justify_content: JustifyContent::Center,
padding: UiRect::top(Val::Px(20.0)),
..default()
},
..default()
})
.with_children(|footer| {
footer.spawn(TextBundle::from_section(
"Want to contribute? Visit github.com/edgarhsanchez/dndgamerolls",
TextStyle {
font_size: 14.0,
color: accent_color,
..default()
},
));
});
});
}
/// Spawn a contributor card
fn spawn_contributor_card(
parent: &mut ChildBuilder,
index: usize,
login: &str,
display_name: &str,
avatar_url: &str,
contributions: u32,
role: Option<&str>,
card_bg: Color,
text_color: Color,
subtext_color: Color,
accent_color: Color,
) {
parent
.spawn((
NodeBundle {
style: Style {
width: Val::Px(200.0),
min_height: Val::Px(120.0),
flex_direction: FlexDirection::Column,
align_items: AlignItems::Center,
padding: UiRect::all(Val::Px(15.0)),
border: UiRect::all(Val::Px(1.0)),
..default()
},
background_color: BackgroundColor(card_bg),
border_color: BorderColor(Color::srgb(0.25, 0.25, 0.3)),
border_radius: BorderRadius::all(Val::Px(8.0)),
..default()
},
ContributorCard { index },
))
.with_children(|card| {
// Avatar container (circle)
card.spawn(NodeBundle {
style: Style {
width: Val::Px(64.0),
height: Val::Px(64.0),
justify_content: JustifyContent::Center,
align_items: AlignItems::Center,
margin: UiRect::bottom(Val::Px(10.0)),
overflow: Overflow::clip(),
..default()
},
background_color: BackgroundColor(accent_color.with_alpha(0.3)),
border_radius: BorderRadius::all(Val::Px(32.0)),
..default()
})
.with_children(|avatar_container| {
if !avatar_url.is_empty() {
// Spawn image that will be loaded from URL
avatar_container.spawn((
ImageBundle {
style: Style {
width: Val::Px(64.0),
height: Val::Px(64.0),
..default()
},
// Start with transparent, will be replaced when loaded
background_color: BackgroundColor(Color::NONE),
..default()
},
AvatarImage {
url: avatar_url.to_string(),
loaded: false,
failed: false,
},
));
// Fallback initial - hidden by default, shown only if avatar fails to load
let initial = display_name
.chars()
.next()
.unwrap_or('?')
.to_uppercase()
.to_string();
avatar_container.spawn((
TextBundle {
text: Text::from_section(
initial,
TextStyle {
font_size: 28.0,
color: accent_color,
..default()
},
),
style: Style {
position_type: PositionType::Absolute,
..default()
},
visibility: Visibility::Hidden,
..default()
},
AvatarFallback {
url: avatar_url.to_string(),
},
));
} else {
// No avatar URL, just show initial
let initial = display_name
.chars()
.next()
.unwrap_or('?')
.to_uppercase()
.to_string();
avatar_container.spawn(TextBundle::from_section(
initial,
TextStyle {
font_size: 28.0,
color: accent_color,
..default()
},
));
}
});
// Display name
card.spawn(TextBundle::from_section(
display_name,
TextStyle {
font_size: 16.0,
color: text_color,
..default()
},
));
// Username (if different from display name)
if display_name != login {
card.spawn(TextBundle::from_section(
format!("@{}", login),
TextStyle {
font_size: 12.0,
color: subtext_color,
..default()
},
));
}
// Role badge (if any)
if let Some(role_text) = role {
card.spawn(
TextBundle::from_section(
role_text,
TextStyle {
font_size: 11.0,
color: Color::srgb(0.4, 0.8, 0.4),
..default()
},
)
.with_style(Style {
margin: UiRect::top(Val::Px(5.0)),
..default()
}),
);
}
// Contributions count
card.spawn(
TextBundle::from_section(
format!("{} contributions", contributions),
TextStyle {
font_size: 12.0,
color: subtext_color,
..default()
},
)
.with_style(Style {
margin: UiRect::top(Val::Px(8.0)),
..default()
}),
);
});
}