forked from jpeterbaker/bga_homeworlds
-
Notifications
You must be signed in to change notification settings - Fork 0
/
homeworlds.css
495 lines (458 loc) · 10.8 KB
/
homeworlds.css
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
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
/**
*------
* BGA framework: © Gregory Isabelli <[email protected]> & Emmanuel Colin <[email protected]>
* Homeworlds implementation : © <Jonathan Baker> <[email protected]>
*
* This code has been produced on the BGA studio platform for use on http://boardgamearena.com.
* See http://en.boardgamearena.com/#!doc/Studio for more information.
* -----
*
* homeworlds.css
*
* Homeworlds stylesheet
*
*/
#HWboard{
/* Board margin-right makes space for bank */
margin-right:210px;
/* height:1000px; */
/*background:rgba(255,255,255,0.3);*/
display:block;
}
#HWbank{
/*
Bank must not have default position type (static)
or its width/height can't be used for relative sizes of stacks
*/
position:relative;
width:200px;
height:600px;
float:right;
background:rgba(0,0,0,0.3);
}
/* A stack is a place for identical pieces in the bank */
.HWstack{
display:inline-block;
position:absolute;
width:33.3%;
height:25%;
}
/*
Make pieces in the stack higher the more children there are
It's better to count from the end than from the beginning because,
while adding tutorial annotation images,
mousing over an element causes it to have a new child
at the beginning of its list.
If you determine height by counting from the start of the list,
the pieces hop around as you mouse over the bank.
*/
.HWstack>*{
position:absolute;
}
.HWstack>*:nth-last-child(1){
bottom:0px;
z-index:1;
}
.HWstack>*:nth-last-child(2){
bottom:20px;
z-index:2;
}
.HWstack>*:nth-last-child(3){
bottom:40px;
z-index:3;
}
/*
Pieces traveling to the board should be in front of stacked pieces
in order to not look weird.
*/
.HWship,.HWstar{
z-index:4;
}
/********
Systems
********/
.HWsystem{
border:2px solid black;
display:inline-block;
margin:5px;
}
/* A homeworld system with a non-none homeplayer_id attribute*/
.HWsystem:not([homeplayer_id=none]){
border:2px dashed black;
/* Include if player-colored borders are wanted
outline-width:2px;
outline-style:solid;
*/
}
/*
A dummy div so that the system container can be centered
and rows of same-sized systems are created
*/
.HWcenterizer{
text-align:center;
display:block;
min-height:50px;
}
/* A centered, collection-fitting container for same-sized systems */
.HWsystem_container{
display:inline-block;
vertical-align:top;
}
/* All pieces use the same sprite background */
.HWship,.HWstar,.HWbanked {
background-image:url('img/sprites.svg');
background-repeat:no-repeat;
background-size:128px 600px;
display:inline-block;
/* full size: 256px 1200; */
}
.HWship,.HWstar,#HWturn_token{
position:relative;
transition:.5s;
}
.HWstar_container{
display:inline-block;
text-align:center;
}
.HWsystem_label{
margin-left:5px;
margin-right:5px;
float:bottom;
}
/* Symbol indicator appears on pieces for colorblind friendliness */
.HWcolor_symbol{
position:absolute;
height:20px;
width:20px;
left:0;
right:0;
margin:auto;
background-image:url('img/colorblind.svg');
background-repeat:no-repeat;
background-size:20px 80px;
}
/* To get the symbol in a vertically good spot,
pieces need a margin according to their size */
.HWsymbol_red{
background-position-y:-0px;
}
.HWsymbol_yellow{
background-position-y:-20px;
}
.HWsymbol_green{
background-position-y:-40px;
}
.HWsymbol_blue{
background-position-y:-60px;
}
.HWlarge.HWbanked>.HWcolor_symbol,.HWlarge.HWship>.HWcolor_symbol{
margin-top:40px;
}
.HWmedium.HWbanked>.HWcolor_symbol,.HWmedium.HWship>.HWcolor_symbol{
margin-top:32px;
}
.HWsmall.HWbanked>.HWcolor_symbol,.HWsmall.HWship>.HWcolor_symbol{
margin-top:15px;
}
.HWlarge.HWstar>.HWcolor_symbol{
margin-top:15px;
}
.HWmedium.HWstar>.HWcolor_symbol{
margin-top:10px;
}
.HWsmall.HWstar>.HWcolor_symbol{
margin-top:5px;
}
/* Hide the symbol on covered children */
.HWbanked:not(:first-child)>.HWcolor_symbol{
display:none;
}
/* Hide the symbol when colorblind mode is off */
html.colorblind_off .HWcolor_symbol{
display:none;
}
/*
The background image has every piece sprite.
This section sets the vertical background offset by piece color and orientation.
*/
/* Offset for the top of the color section in the sprite image */
.HWred{
--offsetC:-6px
}
.HWyellow{
--offsetC:-156px;
}
.HWgreen{
--offsetC:-305.5px
}
.HWblue{
--offsetC:-455px
}
/* Additional offsetP for the top of the piece */
.HWlarge.HWship,.HWlarge.HWbanked{
--offsetP:-0px;
margin-top:5px;
height:86px
}
.HWmedium.HWship,.HWmedium.HWbanked{
--offsetP:-9px;
margin-top:14px;
height:68px
}
.HWsmall.HWship,.HWsmall.HWbanked{
--offsetP:-18px;
margin-top:23px;
height:50px
}
.HWlarge.HWstar{
--offsetP:-93px;
margin-top:5px;
height:49px
}
.HWmedium.HWstar{
--offsetP:-98px;
margin-top:10px;
height:39px
}
.HWsmall.HWstar{
--offsetP:-103.5px;
margin-top:15.5px;
height:29px
}
/* Add the offsets together */
.HWship,.HWstar,.HWbanked{
background-position-y:calc(var(--offsetC) + var(--offsetP))
}
/* Non-banked pieces get bottom margin matching top margin for symmetry */
.HWlarge.HWship{
margin-bottom:5px;
}
.HWmedium.HWship{
margin-bottom:14px;
}
.HWsmall.HWship{
margin-bottom:23px;
}
.HWlarge.HWstar{
margin-bottom:5px;
}
.HWmedium.HWstar{
margin-bottom:10px;
}
.HWsmall.HWstar{
margin-bottom:15.5px;
}
/* Horizontal offset by and width depend on piece size. */
.HWlarge{
background-position-x:-1.5px;
width:49px;
}
.HWmedium{
background-position-x:-54.5px;
width:39px;
}
.HWsmall{
background-position-x:-98px;
width:29px;
}
.HWship{
transform:rotate(var(--rotateAmount));
}
.HWstar,#HWturn_token{
--rotateAmount:0deg;
}
/*
Give ships and stars a little horizontal margin
Use margin to center banked pieces
*/
.HWship,.HWstar{
margin-left:5px;
margin-right:5px;
}
.HWbanked{
margin:auto;
left:0;
right:0
}
/*
Ships and systems can be friendly or hostile.
These terms will need to be generalized if 3+ player is implemented.
*/
.HWhostile{
float:left;
}
.HWhostile.HWship{
--rotateAmount:180deg;
}
.HWfriendly{
float:right;
}
.HWfriendly.HWship{
--rotateAmount:0deg;
}
/***************
Selectable stuff
***************/
.HWselectable{
cursor:pointer;
}
/* Selectable stacks and systems get a white background that brightens on hover */
.HWselectable.HWstack,.HWselectable.HWsystem{
background-color:rgba(255,255,255,0.3);
}
.HWselectable.HWstack:hover,.HWselectable.HWsystem:hover{
background-color:rgba(255,255,255,0.6);
}
/* Selectable ships and stars get a shadow and rise on hover*/
.HWselectable.HWship.HWfriendly:not([activate]),.HWselectable.HWstar{
filter:drop-shadow(15px -15px 10px black);
}
.HWhostile.HWship.HWselectable{
/* Reverse the shadow for hostile ships since they're rotated */
filter:drop-shadow(-15px 15px 10px black);
}
.HWselectable.HWpiece:hover,.HWselectable#HWturn_token:hover{
transform:translate(0px,-5px) rotate(var(--rotateAmount));
}
#HWturn_token.HWonly_option{
filter:drop-shadow(15px -15px 10px black);
}
/* Use a custom "activate" attribute to highlight with power color */
[activate=pending]{
filter:drop-shadow(15px -15px 10px indigo);
}
[activate=sacrifice]{
/*opacity:0;*/
}
[activate='1']{
filter:drop-shadow(10px -10px 10px red);
}
[activate='2']{
filter:drop-shadow(10px -10px 10px yellow);
}
[activate='3']{
filter:drop-shadow(10px -10px 10px green);
}
[activate='4']{
filter:drop-shadow(10px -10px 10px blue);
}
/*
Borrowed from
https://www.kirupa.com/snippets/getting_jittery_on_hover_using_only_css.htm
*/
.HWoverpopulated {
animation-duration: 1s;
animation-timing-function: ease-in-out;
animation-fill-mode: forwards;
animation-iteration-count: infinite;
animation-name: jittery;
}
@keyframes jittery {
10% {
transform: rotate(var(--rotateAmount)) translate(-2px, -3px) scale(1.01, 1.01);
}
20% {
transform: rotate(var(--rotateAmount)) translate(3px, 2px) scale(.99, .99);
}
30% {
transform: rotate(var(--rotateAmount)) translate(-4px, -5px) scale(1.01, 1.01);
}
40% {
transform: rotate(var(--rotateAmount)) translate(2px, 3px) scale(1, 1);
}
50% {
transform: rotate(var(--rotateAmount)) translate(-1px, -2px) scale(.98, .98);
}
60% {
transform: rotate(var(--rotateAmount)) translate(0px, 3px) scale(1.02, 1.02);
}
70% {
transform: rotate(var(--rotateAmount)) translate(-2px, -4px) scale(1, 1);
}
80% {
transform: rotate(var(--rotateAmount)) translate(3px, 5px) scale(.99, .99);
}
90% {
transform: rotate(var(--rotateAmount)) translate(-5px, -3px) scale(1.1, 1.1);
}
100% {
transform: rotate(var(--rotateAmount)) translate(3px, 1px) scale(.95, .95);
}
}
/* Modifications to main BGA display */
.player_score_value{
display:none
}
.fa-star{
display:none
}
.HWfirst_player_indicator{
font-size:75%;
}
/* Turn token */
.HWtoken_space{
position:relative;/*Relative or absolute position needed for sliding*/
/* Token moves up 5px on hover, systems are normally 96px high because large ships are 86 px and have 5px above and below*/
height:96px;
width:96px;
margin-top:5px;
display:inline-block;
float:left;
}
#HWturn_token{
position:relative;/*Relative or absolute position needed for sliding*/
background-image:url('img/turn_token.svg');
background-repeat:no-repeat;
background-size:100%;
height:100%;
width:100%;
/*
Without a z-index it sometimes appears to slide under pieces,
and pieces need z-index 4 to stay in front of stacked pieces
*/
z-index:5;
}
/* Animation marker shouldn't appear */
.HWanimarker{
/*
display:none;
This seems to make pieces invisible when markers are used for animations
*/
position:relative;
height:0px;
width:0px;
/* A size and background make it easier to find when debugging */
/*height:50px;*/
/*width:50px;*/
/*background-color:rebeccapurple;*/
/**/
}
/*
The centering margins of banked pieces mess up animations otherwise
This should probably be the same as for stars and ships to avoid jumpiness,
but I don't want to include it in the same command since this is the
animation section.
*/
.HWsliding:not(#HWturn_token){
margin-left:5px;
margin-right:5px;
}
/*
Try to make tutorial annotations right-side up on hostile ships.
Animations mess up my correction, so turn it off (not too noticeable)
*/
.HWhostile.HWship>.archiveCommentPointed{
transform: rotate(180deg);
left:0;
animation:none;
-webkit-animation:none;
}
.HWhostile.HWship.HWsmall>.archiveCommentPointed{
top:-35px;
}
.HWhostile.HWship.HWmedium>.archiveCommentPointed{
top:-25px;
}
.HWhostile.HWship.HWlarge>.archiveCommentPointed{
top:-15px;
}