WOWCube Docs logo
WOWCube Docs
Mission Control
Section Shortcuts
APIExamplesSourceWOWConnectChangelog
Filters
SDK and language defaults persist in cookies.
SDK version
Navigation Tree
Collapsed by default, focused on the active path.
Made byMcKay Seamons
GitHub
  1. Home
  2. Docs
  3. Source
  4. splashscreen.inc
Mission NodeSDK 6.2Pawnsplashscreen.inc

splashscreen.inc

SDK Source File: splashscreen.inc

Source / SDK 6.2 / Pawn / Core

splashscreen.inc

splashscreen.inc
CPP
1#include "string.inc"
2#include "leaderboard.inc"
3#include "graphics.inc"
4#include "topology.inc"
5#include "log.inc"
6
7/****d* PawnLibs/splashscreen/e_ssScreensType
8 * Summary
9 * Enum the main preset types of screens.
10 * Synopsis
11 */
12const e_ssScreensType: {
13 ssEmpty = 0,
14 ssFirstLeaderGroup,
15 ssSecondLeaderGroup,
16 ssHighScore,
17 ssLeaderboardSprite,
18 ssAppName,
19 ssMainImage,
20 ssLastResultsSprite,
21 ssLastParameter1,
22 ssLastParameter2,
23 ssLastParameter3,
24 ssTwistIcon,
25 ssTwistLabelWithIcon,
26 ssTwistLabelWithoutIcon,
27 ssPatIcon,
28 ssPatLabelWithIcon,
29 ssPatLabelWithoutIcon,
30 ssQRCode,
31 ssTypeMax,
32}
33/*
34 * Description
35 * * ssEmpty - A blank screen, only the background is displayed
36 * * ssFirstLeaderGroup - Leaderboard screen with 1-5 positions
37 * * ssSecondLeaderGroup - Leaderboard screen with 6-10 positions
38 * * ssHighScore - The display screen of the personal best or
39 * the top score of the leaderboard
40 * * ssLeaderboardSprite - Leaderboard sprite screen
41 * * ssAppName - App title screen
42 * * ssMainImage - App logo screen
43 * * ssLastResultsSprite - Last results sprite screen
44 * * ssLastParameter1 - Parameter1 screen
45 * * ssLastParameter2 - Parameter2 screen
46 * * ssLastParameter3 - Parameter3 screen
47 * * ssTwistIcon - Twist icon screen without label
48 * * ssTwistLabelWithIcon - Twist label screen with icon
49 * * ssTwistLabelWithoutIcon - Twist label screen without label
50 * * ssPatIcon - Pat icon screen without label
51 * * ssPatLabelWithIcon - Pat label screen with icon
52 * * ssPatLabelWithoutIcon - Pat label screen without label
53 * * ssQRCode - QR code screen
54 * * ssTypeMax - The maximum value of the types is used as the
55 first value of the user-defined types
56 ******/
57
58/****d* PawnLibs/splashscreen/SPLASH_SCREEN_MAX_LEADERS
59 * Summary
60 * How many leaders can be displayed on the splash screen.
61 * Synopsis
62 */
63#define SPLASH_SCREEN_MAX_LEADERS 10
64/******/
65
66/****d* PawnLibs/splashscreen/SPLASH_SCREEN_MAX_PARAMETERS
67 * Summary
68 * How many different detailed parametr types exist.
69 * Synopsis
70 */
71#define SPLASH_SCREEN_MAX_PARAMETERS 3
72/******/
73
74/****d* PawnLibs/splashscreen/LEADERBOARD_SIZE
75 * Summary
76 * The size of the leaderboard array obtained in LB_getScore.
77 * Synopsis
78 */
79#define LEADERBOARD_SIZE 30
80/******/
81
82/****d* PawnLibs/splashscreen/STRING_VALUE_SIZE
83 * Summary
84 * The maximum length of a string to output a value.
85 * Synopsis
86 */
87#define STRING_VALUE_SIZE 15
88/******/
89
90/****s* PawnLibs/splashscreen/LEADER_DATA
91 * Summary
92 * Array with named fields which represents a line in score table.
93 * Synopsis
94 */
95#define LEADER_DATA .name{16}, .value{STRING_VALUE_SIZE}
96/*
97 * Description
98 * Fields:
99 * * name - user name
100 * * value - user score
101 * See also
102 ******/
103
104/****s* PawnLibs/splashscreen/LEADER_DATA
105 * Summary
106 * An array with named fields, which represents the values on
107 * the parameters screen.
108 * Synopsis
109 */
110#define PARAMETRS_DATA .name{10}, .value{STRING_VALUE_SIZE}, .fontSize
111/*
112 * Description
113 * Fields:
114 * * name - user name
115 * * value - user score
116 * * fontSize - font size
117 * See also
118 ******/
119
120/****s* PawnLibs/splashscreen/LEADER_DATA
121 * Summary
122 * An array with named fields, which represents the values on
123 * the record screen.
124 * Synopsis
125 */
126#define RECORD_DATA .value{STRING_VALUE_SIZE}, .fontSize
127/*
128 * Description
129 * Fields:
130 * * name - user name
131 * * value - user score
132 * * fontSize - font size
133 * See also
134 ******/
135
136const SPLASH_SCREEN_FONT_ID = 0;
137const LEADER_TABLE_FONT = 6;
138
139/****c* PawnLibs/splashscreen/e_ssLeadersDataType
140 * Summary
141 * Enumeration of results type in the leader board.
142 * Synopsis
143 */
144const e_ssLeadersDataType: {
145 ssTypeNumber = 1,
146 ssTypeTime = 2,
147}
148/*
149 * Description
150 * * ssTypeNumber - display scores in the leader board
151 * * ssTypeTime - display time in the leader board
152 ******/
153
154/****c* PawnLibs/splashscreen/e_ssLeaderBoardType
155 * Summary
156 * Enumeration of the leader board types.
157 * Synopsis
158 */
159const e_ssLeaderBoardType: {
160 ssWithoutSaves = 0,
161 ssWithSaves = 1,
162}
163/*
164 * Description
165 * * ssWithoutSaves - first run of the application and it does not have saves and
166 * previous results
167 * * ssWithSaves - application has a save to continue from
168 ******/
169
170// Default texts for splashscreen
171new leaderBoardText { 12 } = "LEADERBOARD";
172new lastResultsText { 16 } = "LAST RESULTS";
173new twistWithIcon { 64 } = "twist|to continue";
174new twistWithoutIcon { 64 } = "twist|to start";
175new patWithIcon { 64 } = "triple Pat|to start new";
176new patWithoutIcon { 64 } = "triple Pat|to continue";
177new separator = '|';
178
179new ssAppNameText { 64 } = " ";
180new ssQRCodeLink { 32 } = " ";
181
182// Default leaderboard for splashscreen
183new leadersSplashScreen[SPLASH_SCREEN_MAX_LEADERS][LEADER_DATA] = [
184 ["Alex", "5 000"],
185 ["Kim", "4 000"],
186 ["Beth", "3 000"],
187 ["Ethan", "2 000"],
188 ["Mia", "1 000"],
189 ["Lucas", "900"],
190 ["Jonas", "800"],
191 ["Diego", "700"],
192 ["Chloe", "500"],
193 ["Simon", "100"],
194];
195
196// Special sprites
197new ssSprites[.background, .leaderboard, .resultsIcon, .mainImage, .twist1, .twist2, .pat1, .pat2, .qrCode, .name, .borderYou] = [-1, ...];
198
199new baseColor = 0xFFFFFFFF;
200new keyColor = 0xFFFFFFFF;
201
202new leaderBoardMapping[TOPOLOGY_FACES_MAX] { TOPOLOGY_POSITIONS_MAX };
203
204new ssParameters[SPLASH_SCREEN_MAX_PARAMETERS][PARAMETRS_DATA];
205new ssRecord[RECORD_DATA];
206
207new splashscreen_basicInfo[LB_INFO];
208new splashscreen_leadTableScore[LEADERBOARD_SIZE];
209
210new splashscreenPlayerScore { STRING_VALUE_SIZE };
211new splashscreenInScriptRecord = 0;
212new splashscreenInWebRecord = 0;
213
214new threeDots { 3 } = "...";
215new zeroValue { STRING_VALUE_SIZE } = "0";
216new ssApplicationVersionStr { STRING_VALUE_SIZE } = "v";
217
218new init[bool:.basic, bool:.places] = [false, false];
219new ssPlaybackSpeed[.twist, .pat] = [500, 500];
220new ssIconsFrame[.twist, .pat] = [500, 500];
221
222new ssPlaces[SCREENS_MAX][TOPOLOGY_PLACE] = [
223 [TOPOLOGY_FACES_MAX, TOPOLOGY_POSITIONS_MAX],
224 [TOPOLOGY_FACES_MAX, TOPOLOGY_POSITIONS_MAX],
225 [TOPOLOGY_FACES_MAX, TOPOLOGY_POSITIONS_MAX]
226];
227
228// Preset table for displaying a splash screen without saving
229new leaderBoardTableWithoutSaves[TOPOLOGY_FACES_MAX] { TOPOLOGY_POSITIONS_MAX } = [
230 { ssTwistLabelWithoutIcon, ssTwistIcon, ssMainImage, ssAppName, },
231 { ssTwistLabelWithoutIcon, ssTwistIcon, ssQRCode, ssAppName, },
232 { ssTwistLabelWithoutIcon, ssTwistIcon, ssEmpty, ssEmpty, },
233 { ssEmpty, ssEmpty, ssTwistIcon, ssTwistLabelWithoutIcon, },
234 { ssHighScore, ssSecondLeaderGroup, ssFirstLeaderGroup, ssLeaderboardSprite, },
235 { ssHighScore, ssSecondLeaderGroup, ssFirstLeaderGroup, ssLeaderboardSprite, },
236];
237// Preset table for displaying a splash screen with saving
238new leaderBoardTableWithSaves[TOPOLOGY_FACES_MAX] { TOPOLOGY_POSITIONS_MAX } = [
239 { ssTwistLabelWithIcon, ssPatLabelWithIcon, ssMainImage, ssAppName, },
240 { ssTwistLabelWithIcon, ssPatLabelWithIcon, ssQRCode, ssAppName, },
241 { ssLastParameter1, ssLastParameter2, ssLastResultsSprite, ssLastParameter3, },
242 { ssLastParameter1, ssLastParameter2, ssLastResultsSprite, ssLastParameter3, },
243 { ssHighScore, ssSecondLeaderGroup, ssFirstLeaderGroup, ssLeaderboardSprite, },
244 { ssHighScore, ssSecondLeaderGroup, ssFirstLeaderGroup, ssLeaderboardSprite, },
245];
246
247new ssPosition[.x, .y, .angle];
248
249/****f* PawnLibs/splashscreen/ssON_Render
250 * Summary
251 * Splash screen ON_Render
252 * Synopsis
253 */
254stock ssON_Render()
255/*
256 * Description
257 * Splash screen rendering
258 * Inputs
259 * Source
260 */
261{
262
263 for (new screen = 0; screen < SCREENS_MAX; screen++) {
264 GFX_setRenderTarget(screen);
265 ssRenderScreen(screen);
266 GFX_render();
267 }
268}
269/******/
270
271/****f* PawnLibs/splashscreen/ssON_Tick
272 * Summary
273 * Splash screen ON_Tick
274 * Synopsis
275 */
276stock ssON_Tick(dt)
277/*
278 * Description
279 * Splash screen rendering
280 * Inputs
281 * * dt - Delta time between ticks
282 * Source
283 */
284{
285 static ssDeltaTime[.pat, .twist];
286
287 ssDeltaTime.pat += dt;
288 ssDeltaTime.twist += dt;
289
290 if (ssDeltaTime.pat > ssPlaybackSpeed.pat) {
291 ssIconsFrame.pat++;
292 ssIconsFrame.pat %= 2;
293 ssDeltaTime.pat = 0;
294 }
295
296 if (ssDeltaTime.twist > ssPlaybackSpeed.twist) {
297 ssIconsFrame.twist++;
298 ssIconsFrame.twist %= 2;
299 ssDeltaTime.twist = 0;
300 }
301 ssON_Tick_UserDefined(dt);
302}
303/******/
304
305/****f* PawnLibs/splashscreen/ssSetPlaces
306 * Summary
307 * Customize topology
308 * Synopsis
309 */
310stock ssSetPlaces(place0[TOPOLOGY_PLACE], place1[TOPOLOGY_PLACE], place2[TOPOLOGY_PLACE])
311/*
312 * Description
313 * Set user-defined topology
314 * Inputs
315 * * place0 - the place for the 0 screen
316 * * place1 - the place for the 1 screen
317 * * place2 - the place for the 2 screen
318 * Source
319 */
320{
321 ssPlaces[0] = place0;
322 ssPlaces[1] = place1;
323 ssPlaces[2] = place2;
324
325 init.places = true;
326}
327/******/
328
329/****f* PawnLibs/splashscreen/ssSetPlaces
330 * Summary
331 * Get topology for customize
332 * Synopsis
333 */
334stock ssGetPlace(screen)
335/*
336 * Description
337 * Get topology for customize screens
338 * Inputs
339 * * screen - The ID of the screen
340 * Source
341 */
342{
343 return ssPlaces[screen];
344}
345/******/
346
347/****f* PawnLibs/splashscreen/ssSetSplashScreenNamedValue
348 * Summary
349 * Set named value, for example: 'time', 'level' etc
350 * Synopsis
351 */
352stock ssSetSplashScreenNamedValue(name { 10 }, value, e_ssLeadersDataType:valueType = e_ssLeadersDataType:ssTypeNumber)
353/*
354 * Description
355 * Set named value, for example: 'time', 'level' etc
356 * Inputs
357 * * name - name of the parameter
358 * * value - value of the parameter
359 * * valueType - type of the parameter value
360 * Source
361 */
362{
363 static counter = 0;
364
365 ssParameters[counter].name = name;
366 ssParameters[counter].value = ssToString(value, valueType, ssParameters[counter].fontSize, false);
367
368 counter = (counter + 1) % SPLASH_SCREEN_MAX_PARAMETERS;
369}
370/******/
371
372/****f* PawnLibs/splashscreen/ssSetSplashScreenRecord
373 * Summary
374 * Customize record
375 * Synopsis
376 */
377stock ssSetSplashScreenRecord(value, e_ssLeadersDataType:valueType = e_ssLeadersDataType:ssTypeNumber)
378/*
379 * Description
380 * Set user-defined record
381 * Inputs
382 * * value - value of the record
383 * * valueType - type of the record value
384 * Source
385 */
386{
387 static counter = 0;
388
389 ssRecord.value = ssToString(value, valueType, ssRecord.fontSize, false);
390}
391/******/
392
393/****f* PawnLibs/splashscreen/SetSeparator
394 * Summary
395 * Customize twist and Pat labels
396 * Synopsis
397 */
398stock ssSetSeparator(l_separator)
399/*
400 * Description
401 * Set user-defined separator
402 * Inputs
403 * * l_separator - text separator for splitting into 2 lines
404 * Source
405 */
406{
407 separator = l_separator;
408}
409/******/
410
411/****f* PawnLibs/splashscreen/ssSetTexts
412 * Summary
413 * Customize twist and Pat labels
414 * Synopsis
415 */
416stock ssSetTexts(patWI[] = "", patWoI[] = "", twistWI[] = "", twistWoI[] = "")
417/*
418 * Description
419 * Set user-defined twist and Pat labels
420 * Inputs
421 * * patWI - the text for pat screen with icon
422 * * patWoI - the text for pat screen without icon
423 * * twistWI - the text for twist screen with icon
424 * * twistWoI - the text for twist screen without icon
425 * Source
426 */
427{
428 strcopy(patWithIcon, patWI);
429 strcopy(patWithoutIcon, patWoI);
430 strcopy(twistWithIcon, twistWI);
431 strcopy(twistWithoutIcon, twistWoI);
432}
433/******/
434
435/****f* PawnLibs/splashscreen/ssSetApplicationNameText
436 * Summary
437 * Customize text of the application name
438 * Synopsis
439 */
440stock ssSetApplicationNameText(title { 64 })
441/*
442 * Description
443 * Set user-defined text of the application name. Used if the s
444 * prite of the application title is missing
445 * Inputs
446 * * title - name of application
447 * Source
448 */
449{
450 strcopy(ssAppNameText, title);
451}
452/******/
453
454/****f* PawnLibs/splashscreen/ssSetLeaderBoardTablePreset
455 * Summary
456 * Customize leaderboard table from preset
457 * Synopsis
458 */
459stock ssSetLeaderBoardTablePreset(e_ssLeaderBoardType:type)
460/*
461 * Description
462 * Set leaderBoardMapping from preset by type
463 * Inputs
464 * * type - The type of the preset table
465 * See also
466 * * e_ssLeaderBoardType
467 * * e_ssLeadersDataType
468 * Source
469 */
470{
471 switch (type) {
472 case ssWithoutSaves: {
473 leaderBoardMapping = leaderBoardTableWithoutSaves;
474 }
475 case ssWithSaves: {
476 leaderBoardMapping = leaderBoardTableWithSaves;
477 }
478 }
479}
480/******/
481
482/****f* PawnLibs/splashscreen/ssSetLeaderBoardTable
483 * Summary
484 * Customize leaderboard table from user-defined table
485 * Synopsis
486 */
487stock ssSetLeaderBoardTable(e_ssLeaderBoardType:leaderBoardTable[TOPOLOGY_FACES_MAX] { TOPOLOGY_POSITIONS_MAX })
488/*
489 * Description
490 * Set leaderBoardMapping from user-defined table
491 * Inputs
492 * * leaderBoardTable - user-defined table
493 * See also
494 * * e_ssLeaderBoardType
495 * * e_ssLeadersDataType
496 * Source
497 */
498{
499 leaderBoardMapping = leaderBoardTable;
500}
501
502/****f* PawnLibs/splashscreen/ssSetQRCodeLink
503 * Summary
504 * Customize playback speed for animated icons
505 * Synopsis
506 */
507stock ssSetPlaybackSpeed(pat, twist)
508/*
509 * Description
510 * Set playback speed for animated icons
511 * Inputs
512 * * pat - playback speed for pat icon
513 * * twist - playback speed for twist icon
514 * Source
515 */
516{
517 ssPlaybackSpeed.pat = pat;
518 ssPlaybackSpeed.twist = twist;
519}
520/******/
521
522/****f* PawnLibs/splashscreen/ssSetQRCodeLink
523 * Summary
524 * Customize link for a QR Code
525 * Synopsis
526 */
527stock ssSetQRCodeLink(qrCodeLink { 32 })
528/*
529 * Description
530 * Set link for a QR Code. If not specified, the QR code sprite will be displayed
531 * Inputs
532 * * qrCodeLink - qrCodeLink
533 * Source
534 */
535{
536 strcopy(ssQRCodeLink, qrCodeLink);
537}
538/******/
539
540/****f* PawnLibs/splashscreen/InitSplashScreenSprites
541 * Summary
542 * Customize splash screen.
543 * Synopsis
544 */
545stock InitSplashScreenSprites(backgroundSprite = -1,
546 mainImageSprite = -1,
547 gameNameSprite = -1,
548 QRcodeSprite = -1,
549 leaderboardIcon = -1,
550 resultsIcon = -1,
551 twistIcon_1 = -1,
552 twistIcon_2 = -1,
553 patIcon_1 = -1,
554 patIcon_2 = -1,
555 borderYou = -1)
556/*
557 * Description
558 * Set IDs of sprite used to draw different elements of the splash screen.
559 * Inputs
560 * * backgroundSprite - ID of a background image. If ID=-1, then a user defined render will be called
561 * * mainImageSprite - ID of an application logo, may differ from a menu
562 * icon
563 * * gameNameSprite - ID of an image with application name, to display it with
564 * some custom font
565 * * QRcodeSprite - ID of a QR code
566 * * leaderboardIcon - ID of a leader board icon
567 * * resultsIcon - ID of a result icon
568 * * twistIcon_1, twistIcon_2 - IDs of twist animation images
569 * * patIcon_1, patIcon_2 - IDs of Pat animation images
570 * * borderYou - a border that highlights you in the leaderboard
571 * Source
572 */
573{
574 ssSprites.background = backgroundSprite;
575 ssSprites.mainImage = mainImageSprite;
576 ssSprites.name = gameNameSprite;
577 ssSprites.qrCode = QRcodeSprite;
578 ssSprites.leaderboard = leaderboardIcon;
579 ssSprites.resultsIcon = resultsIcon;
580 ssSprites.twist1 = twistIcon_1;
581 ssSprites.twist2 = twistIcon_2;
582 ssSprites.pat1 = patIcon_1;
583 ssSprites.pat2 = patIcon_2;
584 ssSprites.borderYou = borderYou;
585
586 if (ssSprites.background < 0) {
587 LOG_w("splashscreen.inc: Background sprite is not initialized");
588 }
589 if (ssSprites.mainImage < 0) {
590 LOG_w("splashscreen.inc: Main image sprite is not initialized");
591 }
592 if (ssSprites.name < 0) {
593 LOG_w("splashscreen.inc: App name sprite is not initialized");
594 }
595 if (ssSprites.qrCode < 0) {
596 LOG_w("splashscreen.inc: QR code sprite is not initialized");
597 }
598 if (ssSprites.leaderboard < 0) {
599 LOG_w("splashscreen.inc: Leaderboard icon sprite is not initialized");
600 }
601 if (ssSprites.resultsIcon < 0) {
602 LOG_w("splashscreen.inc: Results icon sprite is not initialized");
603 }
604 if (ssSprites.twist1 < 0) {
605 LOG_w("splashscreen.inc: Twist icon 1-st sprite is not initialized");
606 }
607 if (ssSprites.twist2 < 0) {
608 LOG_w("splashscreen.inc: Twist icon 2-nd sprite is not initialized");
609 }
610 if (ssSprites.pat1 < 0) {
611 LOG_w("splashscreen.inc: Pat icon 1-st sprite is not initialized");
612 }
613 if (ssSprites.pat2 < 0) {
614 LOG_w("splashscreen.inc: Pat icon 2-nd sprite is not initialized");
615 }
616}
617/******/
618
619/****f* PawnLibs/splashscreen/InitSplashScreenBasics
620 * Summary
621 * Set how splash screen should be displayed.
622 * Synopsis
623 */
624stock InitSplashScreenBasics(base = 0xFFFFFFFF, key = 0xFFFFFFFF,
625 e_ssLeadersDataType:dataType = ssTypeNumber)
626/*
627 * Inputs
628 * * base - base color for all text labels in ARGB8888 format
629 * * key - accent color for text labels in ARGB8888 format
630 * * leaderBoardType - type of splash screen
631 * * dataType - type of results in the leader board
632 * See also
633 * * e_ssLeaderBoardType
634 * * e_ssLeadersDataType
635 * Source
636 */
637{
638 new size;
639 baseColor = base;
640 keyColor = key;
641
642 ssGetApplicationVersion();
643
644 LB_getInfo(splashscreen_basicInfo);
645 LB_getScore(splashscreen_leadTableScore);
646
647 for (new leaderI = 0; leaderI < SPLASH_SCREEN_MAX_LEADERS; ++leaderI) {
648 if (leaderI < splashscreen_basicInfo.leadCount) {
649 for (new i = 0; i < 5; i++) {
650 leadersSplashScreen[leaderI].name { i } = GetByte(splashscreen_leadTableScore[leaderI * 3 + i / 4], i % 4);
651 }
652
653 if (splashscreen_leadTableScore[leaderI * 3 + 1] & 0xffffff00) {
654 leadersSplashScreen[leaderI].name { 5 } = '.';
655 leadersSplashScreen[leaderI].name { 6 } = '.';
656 leadersSplashScreen[leaderI].name { 7 } = '.';
657 }
658
659 leadersSplashScreen[leaderI].value = ssToString(splashscreen_leadTableScore[leaderI * 3 + 2], dataType, size);
660
661 } else if (splashscreen_basicInfo.leadCount > 0) {
662 leadersSplashScreen[leaderI].value = zeroValue;
663 }
664 }
665 splashscreenInWebRecord = splashscreen_basicInfo.selfScore;
666 splashscreenPlayerScore = ssToString(splashscreen_basicInfo.selfScore, dataType, size);
667
668 if (!init.places) {
669 ssGetTopologyPlaces();
670 init.places = true;
671 }
672
673 init.basic = true;
674}
675/******/
676
677/****f* PawnLibs/splashscreen/InitSplashScreenBasics
678 * Summary
679 * Calculation of coordinates and rotation angle relative to screen
680 * rotation in topology
681 * Synopsis
682 */
683stock ssSetPosition(screen, x = 120, y = 120, angle = 0)
684/*
685 * Inputs
686 * * screen - The ID of the screen relative to which the coordinates
687 * and rotation angle will be transformed
688 * * x - X coordinate
689 * * y - Y coordinate
690 * * angle - angle of rotation of sprite or text
691 * Source
692 */
693{
694 ssPosition.x = x;
695 ssPosition.y = y;
696 ssPosition.angle = angle;
697 ssSetPositionRotate(screen);
698}
699/******/
700
701/****f* PawnLibs/splashscreen/InitSplashScreenBasics
702 * Summary
703 * Rendering image
704 * Synopsis
705 */
706stock ssRenderImage(id)
707/*
708 * Inputs
709 * * id - Image ID
710 * Source
711 */
712{
713 GFX_drawImageXY(ssPosition.x, ssPosition.y, 0xff, 0xff00ff, 100, 100, ssPosition.angle, MIRROR_BLANK, id);
714}
715/******/
716
717/****f* PawnLibs/splashscreen/InitSplashScreenBasics
718 * Summary
719 * Rendering text
720 * Synopsis
721 */
722stock ssRenderText(text[], size, color, align = TEXT_ALIGN_CENTER)
723/*
724 * Inputs
725 * * text - text to display
726 * * size - text size
727 * * color - text color
728 * * align - text align
729 * Source
730 */
731{
732 GFX_drawTextXY(ssPosition.x, ssPosition.y, size, ssPosition.angle, SPLASH_SCREEN_FONT_ID, align, color, text);
733}
734/******/
735
736stock ssSplitString(const strsrc[], strdest[][], l_separator) {
737 new i = 0, li;
738 new aNum = 0;
739 new len = 0;
740 while (i <= strlen(strsrc)) {
741 if ((strsrc { i } == l_separator || i == strlen(strsrc))) {
742 len = strmid(strdest[aNum], strsrc, li, i, 128);
743 strdest[aNum][len] = 0;
744 li = i + 1;
745 aNum++;
746 }
747 i++;
748 }
749 return 1;
750}
751
752stock GetByte(dword, i) {
753 return (dword >> i * 8) & 0xff;
754}
755
756stock ssToString(data, dataType, & size, bool:short = true) {
757 new dataStr { STRING_VALUE_SIZE };
758 new leaderData = data;
759
760 new time[5];
761 new divider[5] = [100, 24, 60, 60, 1000];
762 new timeMask[3] { 3 } = ["dhm", "hms", "ms"];
763
764 new number[4];
765 new numberMask[3] { 2 } = [".b", ".m", ".k"];
766
767 new countSymbols = 0;
768
769 dataStr = zeroValue;
770
771 if (data > 0) {
772 if (dataType == e_ssLeadersDataType:ssTypeTime) {
773 for (new i = 4; i >= 0; i--) {
774 time[i] = leaderData % divider[i];
775 leaderData /= divider[i];
776 }
777
778 if (short) {
779 if (data < 60000) {
780 strformat(dataStr, sizeof(dataStr), true, "%d.%ds", time[3], time[4] / 100 % 10);
781 } else {
782 for (new i = 0; i < 3; i++) {
783 if (time[i] != 0) {
784 strformat(dataStr, sizeof(dataStr), true, "%d%c %d%c", time[i], timeMask[i] { 0 }, time[i + 1], timeMask[i] { 1 });
785 break;
786 }
787 }
788 }
789 } else {
790 if (data < 60000) {
791 strformat(dataStr, sizeof(dataStr), true, "%d.%ds", time[3], time[4] / 100 % 10);
792 countSymbols = 3 + (time[3] < 10 ? 1 : 2);
793 } else if (data < 3600000) {
794 strformat(dataStr, sizeof(dataStr), true, "%dm %ds", time[2], time[3]);
795 countSymbols = 3 + (time[2] < 10 ? 1 : 2) + (time[3] < 10 ? 1 : 2);
796 } else {
797 for (new i = 0; i < 2; i++) {
798 if (time[i] != 0) {
799 strformat(dataStr, sizeof(dataStr), true, "%d%c %d%c %d%c", time[i], timeMask[i] { 0 }, time[i + 1], timeMask[i] { 1 }, time[i + 2], timeMask[i] { 2 });
800 countSymbols = 5 + (time[i] < 10 ? 1 : 2) + (time[i + 1] < 10 ? 1 : 2) + (time[i + 2] < 10 ? 1 : 2);
801 break;
802 }
803 }
804 }
805 }
806 } else {
807 for (new i = 3; i >= 0; i--) {
808 number[i] = leaderData % 1000;
809 leaderData /= 1000;
810 }
811 if (!short) {
812 for (new i = 0; i < 4; i++) {
813 if (number[i] != 0 || dataStr != "0") {
814 if (dataStr == "0") {
815 strformat(dataStr, sizeof(dataStr), true, "%d", number[i]);
816 countSymbols = (number[i] < 10 ? 1 : (number[i] < 100 ? 2 : 3));
817 } else {
818 strformat(dataStr, sizeof(dataStr), true, "%s %03d", dataStr, number[i]);
819 countSymbols += 4;
820 }
821 }
822 }
823 } else {
824 if (data <= 999) {
825 strformat(dataStr, sizeof(dataStr), true, "%d", number[3]);
826 } else if (data <= 99999) {
827 strformat(dataStr, sizeof(dataStr), true, "%d %03d", number[2], number[3]);
828 countSymbols = 5;
829 } else {
830 for (new i = 0; i < 3; i++) {
831 if (number[i] != 0) {
832 strformat(dataStr, sizeof(dataStr), true, "%d%c%d%c", number[i], numberMask[i] { 0 }, number[i + 1] / 100 % 10, numberMask[i] { 1 });
833 break;
834 }
835 }
836 }
837 }
838
839 }
840 }
841
842 if (countSymbols <= 9) {
843 size = 14;
844 } else if (countSymbols <= 11) {
845 size = 12;
846 } else {
847 size = 10;
848 }
849
850 return dataStr;
851}
852
853stock ssGetApplicationVersion() {
854 new version[APP_VERSION];
855 getAppVersion(version);
856 strformat(ssApplicationVersionStr, sizeof(ssApplicationVersionStr), true, "v %d.%d.%d", version.major, version.minor, version.patch);
857}
858
859stock ssSetPositionRotate(screen) {
860 new temp = ssPosition.x;
861 switch (ssPlaces[screen].position) {
862 case 1 : {
863 ssPosition.x = ssPosition.y;
864 ssPosition.y = 240 - temp;
865 ssPosition.angle = 270;
866 }
867 case 2 : {
868 ssPosition.x = 240 - ssPosition.x;
869 ssPosition.y = 240 - ssPosition.y;
870 ssPosition.angle = 180;
871 }
872 case 3 : {
873 ssPosition.x = 240 - ssPosition.y;
874 ssPosition.y = temp;
875 ssPosition.angle = 90;
876 }
877 }
878}
879
880stock ssGetTopologyPlaces() {
881 new ssFacelet[TOPOLOGY_FACELET];
882 for (ssFacelet.module = SELF_ID, ssFacelet.screen = 0; ssFacelet.screen < SCREENS_MAX; ssFacelet.screen++) {
883 ssPlaces[ssFacelet.screen] = TOPOLOGY_getPlace(ssFacelet, TOPOLOGY_orientation_mode:ORIENTATION_MODE_SPLASH);
884 ssPlaces[ssFacelet.screen].face = TOPOLOGY_getPlaceOrientation(ssPlaces[ssFacelet.screen]);
885 }
886}
887
888stock ssRenderBackground(screen) {
889 GFX_clear(0xffffffff);
890 if (ssSprites.background != -1) {
891 ssSetPosition(screen);
892 ssRenderImage(ssSprites.background);
893 } else {
894 ssRenderBackgroundUserDefined(screen, leaderBoardMapping[ssPlaces[screen].face] { ssPlaces[screen].position });
895 }
896}
897
898stock ssRenderMainImage(screen) {
899 if (ssSprites.mainImage >= 0) {
900 ssSetPosition(screen);
901 ssRenderImage(ssSprites.mainImage);
902 }
903}
904
905stock ssRenderAppName(screen) {
906 if (ssSprites.name >= 0) {
907 ssSetPosition(screen);
908 ssRenderImage(ssSprites.name);
909 } else if (ssAppNameText != " ") {
910 new text[2] { 64 };
911 ssSplitString(ssAppNameText, text, separator);
912 ssSetPosition(screen, .y = 100);
913 ssRenderText(text[0], 14, keyColor);
914 ssSetPosition(screen, .y = 140);
915 ssRenderText(text[1], 14, keyColor);
916 }
917}
918
919stock ssRenderLeaderBoardSprite(screen) {
920 if (ssSprites.leaderboard >= 0) {
921 ssSetPosition(screen);
922 ssRenderImage(ssSprites.leaderboard);
923 }
924
925 ssSetPosition(screen, .y = 200);
926 ssRenderText(leaderBoardText, 10, baseColor, TEXT_ALIGN_BOTTOM_CENTER);
927}
928
929stock ssRenderQRCode(screen) {
930 if (ssQRCodeLink != " ") {
931 ssSetPosition(screen, .y = 110);
932 GFX_drawQrCodeXY(ssPosition.x, ssPosition.y, 8, 0xffffffff, 0xff000000, ssPosition.angle, 0, ssQRCodeLink);
933 } else if (ssSprites.qrCode >= 0) {
934 ssSetPosition(screen, .y = 110);
935 ssRenderImage(ssSprites.qrCode);
936 }
937 ssSetPosition(screen, .y = 225);
938 ssRenderText(ssApplicationVersionStr, 9, baseColor);
939}
940
941stock ssRenderLeaderGroup(screen, bool:isFirstGroup) {
942 new nameColor = baseColor;
943 new text[1];
944 new num = 0;
945
946 new leaderName { 9 };
947 new leaderScore { 10 };
948 for (new i = 0; i < 5; ++i) {
949 nameColor = baseColor;
950
951 if (i == 4 && !isFirstGroup && splashscreen_basicInfo.selfPosition > SPLASH_SCREEN_MAX_LEADERS) {
952 num = splashscreen_basicInfo.selfPosition;
953 strformat(leaderScore, sizeof(leaderScore), true, "%s", splashscreenPlayerScore);
954 } else if (i == 3 && !isFirstGroup && splashscreen_basicInfo.selfPosition > SPLASH_SCREEN_MAX_LEADERS) {
955 num = 0;
956 } else {
957 num = i + 1 + (isFirstGroup ? 0 : 5);
958 strformat(leaderName, sizeof(leaderName), true, "%d %s", i + 1 + (isFirstGroup ? 0 : 5), leadersSplashScreen[num - 1].name);
959 strformat(leaderScore, sizeof(leaderScore), true, "%s", leadersSplashScreen[num - 1].value);
960 }
961
962 if (splashscreen_basicInfo.selfPosition == num) {
963 nameColor = keyColor;
964 strformat(leaderName, sizeof(leaderName), true, "%d you", splashscreen_basicInfo.selfPosition);
965 ssRenderBorderYou(screen, 30 + 40 * i);
966 }
967
968 if (num > 0) {
969 ssSetPosition(screen, 10, 30 + 40 * i);
970 ssRenderText(leaderName, LEADER_TABLE_FONT, nameColor, TEXT_ALIGN_LEFT_CORNER);
971
972 ssSetPosition(screen, 230, 30 + 40 * i);
973 ssRenderText(leaderScore, LEADER_TABLE_FONT, keyColor, TEXT_ALIGN_RIGHT_CORNER);
974 } else {
975 ssSetPosition(screen, 50, 30 + 40 * i);
976 ssRenderText(threeDots, LEADER_TABLE_FONT, baseColor, TEXT_ALIGN_LEFT_CORNER);
977
978 }
979 }
980}
981
982stock ssRenderBorderYou(screen, y) {
983 if (ssSprites.borderYou >= 0) {
984 ssSetPosition(screen, .x = 120, .y = y);
985 ssRenderImage(ssSprites.borderYou);
986 }
987}
988stock ssRenderResultsSprite(screen) {
989 if (ssSprites.resultsIcon >= 0) {
990 ssSetPosition(screen);
991 ssRenderImage(ssSprites.resultsIcon);
992 }
993
994 ssSetPosition(screen, .y = 200);
995 ssRenderText(lastResultsText, 10, baseColor);
996}
997
998stock ssRenderParameter(screen, counter) {
999
1000 ssSetPosition(screen, .y = 110);
1001 ssRenderText(ssParameters[counter].value, 15, keyColor);
1002
1003 ssSetPosition(screen, .y = 150);
1004 ssRenderText(ssParameters[counter].name, 10, baseColor);
1005}
1006
1007stock ssRenderBest(screen) {
1008 new score { STRING_VALUE_SIZE };
1009 new label { STRING_VALUE_SIZE };
1010 if (strval(ssRecord.value) == 0) {
1011 strformat(score, sizeof(score), true, "%s", leadersSplashScreen[0].value);
1012 label = "Top Score";
1013 } else {
1014 if (splashscreenInScriptRecord > splashscreenInWebRecord) {
1015 strformat(score, sizeof(score), true, "%s", ssRecord.value);
1016 } else {
1017 strformat(score, sizeof(score), true, "%s", splashscreenPlayerScore);
1018 }
1019 strformat(score, sizeof(score), true, "%s", ssRecord.value);
1020
1021 label = "Personal best";
1022 }
1023 ssSetPosition(screen, .y = 110);
1024 ssRenderText(score, ssRecord.fontSize, keyColor);
1025
1026 ssSetPosition(screen, .y = 150);
1027 ssRenderText(label, 8, baseColor);
1028}
1029
1030stock ssRenderTwistIcon(screen) {
1031 if (ssSprites.twist1 == -1 && ssSprites.twist2 == -1)
1032 return;
1033
1034 new id = ssSprites.twist2 == -1 ? ssSprites.twist1 : ssIconsFrame.twist ? ssSprites.twist1 : ssSprites.twist2;
1035
1036 ssSetPosition(screen);
1037 ssRenderImage(id);
1038}
1039
1040stock ssRenderTwistLabelWithoutIcon(screen) {
1041 new text[3] { 64 };
1042 ssSplitString(twistWithoutIcon, text, separator);
1043
1044 ssSetPosition(screen);
1045 ssRenderText(text[0], 17, keyColor);
1046
1047 ssSetPosition(screen, .y = 160);
1048 ssRenderText(text[1], 10, baseColor);
1049
1050
1051 ssSetPosition(screen, .y = 190);
1052 ssRenderText(text[2], 10, baseColor);
1053}
1054
1055stock ssRenderPatLabelWithoutIcon(screen) {
1056 new text[3] { 64 };
1057 ssSplitString(patWithoutIcon, text, separator);
1058
1059 ssSetPosition(screen);
1060 ssRenderText(text[0], 10, keyColor);
1061
1062 ssSetPosition(screen, .y = 160);
1063 ssRenderText(text[1], 8, baseColor);
1064
1065
1066 ssSetPosition(screen, .y = 190);
1067 ssRenderText(text[2], 8, baseColor);
1068}
1069
1070stock ssRenderPatIcon(screen) {
1071 if (ssSprites.pat1 == -1 && ssSprites.pat2 == -1)
1072 return;
1073
1074 new id = ssSprites.pat2 == -1 ? ssSprites.pat1 : ssIconsFrame.pat ? ssSprites.pat1 : ssSprites.pat2;
1075
1076 ssSetPosition(screen);
1077 ssRenderImage(id);
1078}
1079
1080stock ssRenderLabelWithIcon(screen, txt {}) {
1081 new text[2] { 64 };
1082 ssSplitString(txt, text, separator);
1083
1084 ssSetPosition(screen, .y = 190);
1085 ssRenderText(text[0], 8, keyColor);
1086
1087 ssSetPosition(screen, .y = 220);
1088 ssRenderText(text[1], 8, baseColor);
1089}
1090
1091stock ssRenderScreen(screen) {
1092 if (!init.basic) {
1093 LOG_w("Please call InitSplashScreenBasics() before rendering!");
1094 return;
1095 }
1096 ssRenderBackground(screen);
1097
1098 switch (leaderBoardMapping[ssPlaces[screen].face] { ssPlaces[screen].position }) {
1099 case ssEmpty: {}
1100 case ssFirstLeaderGroup: {
1101 ssRenderLeaderGroup(screen, true);
1102 }
1103 case ssSecondLeaderGroup: {
1104 ssRenderLeaderGroup(screen, false);
1105 }
1106 case ssHighScore: {
1107 ssRenderBest(screen);
1108 }
1109 case ssLeaderboardSprite: {
1110 ssRenderLeaderBoardSprite(screen);
1111 }
1112 case ssAppName: {
1113 ssRenderAppName(screen);
1114 }
1115 case ssMainImage: {
1116 ssRenderMainImage(screen);
1117 }
1118 case ssLastResultsSprite: {
1119 ssRenderResultsSprite(screen);
1120 }
1121 case ssLastParameter1: {
1122 ssRenderParameter(screen, 0);
1123 }
1124 case ssLastParameter2: {
1125 ssRenderParameter(screen, 1);
1126 }
1127 case ssLastParameter3: {
1128 ssRenderParameter(screen, 2);
1129 }
1130 case ssTwistIcon: {
1131 ssRenderTwistIcon(screen);
1132 }
1133 case ssTwistLabelWithIcon: {
1134 ssRenderTwistIcon(screen);
1135 ssRenderLabelWithIcon(screen, twistWithIcon);
1136 }
1137 case ssTwistLabelWithoutIcon: {
1138 ssRenderTwistLabelWithoutIcon(screen);
1139 }
1140 case ssPatIcon: {
1141 ssRenderPatIcon(screen);
1142 }
1143 case ssPatLabelWithIcon: {
1144 ssRenderPatIcon(screen);
1145 ssRenderLabelWithIcon(screen, patWithIcon);
1146 }
1147 case ssPatLabelWithoutIcon: {
1148 ssRenderPatLabelWithoutIcon(screen);
1149 }
1150 case ssQRCode: {
1151 ssRenderQRCode(screen);
1152 }
1153 default: {
1154 ssON_Render_UserDefined(screen, leaderBoardMapping[ssPlaces[screen].face] { ssPlaces[screen].position });
1155 }
1156 }
1157}
1158
Wrapped for easier reading. Turn wrap off to inspect exact line lengths.
Context Rail

Related nodes

fixed.inc
Source / SDK 6.2 / Pawn / Core
graphics.inc
Source / SDK 6.2 / Pawn / Core
leaderboard.inc
Source / SDK 6.2 / Pawn / Core
log.inc
Source / SDK 6.2 / Pawn / Core
Previous Node
sound.inc
Source / SDK 6.2 / Pawn / Core
Next Node
string.inc
Source / SDK 6.2 / Pawn / Core