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.3Pawnsplashscreen.inc

splashscreen.inc

SDK Source File: splashscreen.inc

Source / SDK 6.3 / 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", "5000"],
185 ["Kim", "4000"],
186 ["Beth", "3000"],
187 ["Ethan", "2000"],
188 ["Mia", "1000"],
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 } else {
664 if (dataType == e_ssLeadersDataType:ssTypeNumber)
665 leadersSplashScreen[leaderI].value = ssToString((SPLASH_SCREEN_MAX_LEADERS - leaderI) * 1000, dataType, size);
666 else
667 leadersSplashScreen[leaderI].value = ssToString((leaderI + 1) * 1000, dataType, size);
668 }
669 }
670 splashscreenInWebRecord = splashscreen_basicInfo.selfScore;
671 splashscreenPlayerScore = ssToString(splashscreen_basicInfo.selfScore, dataType, size);
672
673 if (!init.places) {
674 ssGetTopologyPlaces();
675 init.places = true;
676 }
677
678 init.basic = true;
679}
680/******/
681
682/****f* PawnLibs/splashscreen/InitSplashScreenBasics
683 * Summary
684 * Calculation of coordinates and rotation angle relative to screen
685 * rotation in topology
686 * Synopsis
687 */
688stock ssSetPosition(screen, x = 120, y = 120, angle = 0)
689/*
690 * Inputs
691 * * screen - The ID of the screen relative to which the coordinates
692 * and rotation angle will be transformed
693 * * x - X coordinate
694 * * y - Y coordinate
695 * * angle - angle of rotation of sprite or text
696 * Source
697 */
698{
699 ssPosition.x = x;
700 ssPosition.y = y;
701 ssPosition.angle = angle;
702 ssSetPositionRotate(screen);
703}
704/******/
705
706/****f* PawnLibs/splashscreen/InitSplashScreenBasics
707 * Summary
708 * Rendering image
709 * Synopsis
710 */
711stock ssRenderImage(id)
712/*
713 * Inputs
714 * * id - Image ID
715 * Source
716 */
717{
718 GFX_drawImageXY(ssPosition.x, ssPosition.y, 0xff, 0xff00ff, 100, 100, ssPosition.angle, MIRROR_BLANK, id);
719}
720/******/
721
722/****f* PawnLibs/splashscreen/InitSplashScreenBasics
723 * Summary
724 * Rendering text
725 * Synopsis
726 */
727stock ssRenderText(text[], size, color, align = TEXT_ALIGN_CENTER)
728/*
729 * Inputs
730 * * text - text to display
731 * * size - text size
732 * * color - text color
733 * * align - text align
734 * Source
735 */
736{
737 GFX_drawTextXY(ssPosition.x, ssPosition.y, size, ssPosition.angle, SPLASH_SCREEN_FONT_ID, align, color, text);
738}
739/******/
740
741stock ssSplitString(const strsrc[], strdest[][], l_separator) {
742 new i = 0, li;
743 new aNum = 0;
744 new len = 0;
745 while (i <= strlen(strsrc)) {
746 if ((strsrc { i } == l_separator || i == strlen(strsrc))) {
747 len = strmid(strdest[aNum], strsrc, li, i, 128);
748 strdest[aNum][len] = 0;
749 li = i + 1;
750 aNum++;
751 }
752 i++;
753 }
754 return 1;
755}
756
757stock GetByte(dword, i) {
758 return (dword >> i * 8) & 0xff;
759}
760
761stock ssToString(data, dataType, & size, bool:short = true) {
762 new dataStr { STRING_VALUE_SIZE };
763 new leaderData = data;
764
765 new time[5];
766 new divider[5] = [100, 24, 60, 60, 1000];
767 new timeMask[3] { 3 } = ["dhm", "hms", "ms"];
768
769 new number[4];
770 new numberMask[3] { 2 } = [".b", ".m", ".k"];
771
772 new countSymbols = 0;
773
774 dataStr = zeroValue;
775
776 if (data > 0) {
777 if (dataType == e_ssLeadersDataType:ssTypeTime) {
778 for (new i = 4; i >= 0; i--) {
779 time[i] = leaderData % divider[i];
780 leaderData /= divider[i];
781 }
782
783 if (short) {
784 if (data < 60000) {
785 strformat(dataStr, sizeof(dataStr), true, "%d.%ds", time[3], time[4] / 100 % 10);
786 } else {
787 for (new i = 0; i < 3; i++) {
788 if (time[i] != 0) {
789 strformat(dataStr, sizeof(dataStr), true, "%d%c %d%c", time[i], timeMask[i] { 0 }, time[i + 1], timeMask[i] { 1 });
790 break;
791 }
792 }
793 }
794 } else {
795 if (data < 60000) {
796 strformat(dataStr, sizeof(dataStr), true, "%d.%ds", time[3], time[4] / 100 % 10);
797 countSymbols = 3 + (time[3] < 10 ? 1 : 2);
798 } else if (data < 3600000) {
799 strformat(dataStr, sizeof(dataStr), true, "%dm %ds", time[2], time[3]);
800 countSymbols = 3 + (time[2] < 10 ? 1 : 2) + (time[3] < 10 ? 1 : 2);
801 } else {
802 for (new i = 0; i < 2; i++) {
803 if (time[i] != 0) {
804 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 });
805 countSymbols = 5 + (time[i] < 10 ? 1 : 2) + (time[i + 1] < 10 ? 1 : 2) + (time[i + 2] < 10 ? 1 : 2);
806 break;
807 }
808 }
809 }
810 }
811 } else {
812 for (new i = 3; i >= 0; i--) {
813 number[i] = leaderData % 1000;
814 leaderData /= 1000;
815 }
816 if (!short) {
817 for (new i = 0; i < 4; i++) {
818 if (number[i] != 0 || dataStr != "0") {
819 if (dataStr == "0") {
820 strformat(dataStr, sizeof(dataStr), true, "%d", number[i]);
821 countSymbols = (number[i] < 10 ? 1 : (number[i] < 100 ? 2 : 3));
822 } else {
823 strformat(dataStr, sizeof(dataStr), true, "%s %03d", dataStr, number[i]);
824 countSymbols += 4;
825 }
826 }
827 }
828 } else {
829 if (data <= 999) {
830 strformat(dataStr, sizeof(dataStr), true, "%d", number[3]);
831 } else if (data <= 99999) {
832 strformat(dataStr, sizeof(dataStr), true, "%d %03d", number[2], number[3]);
833 countSymbols = 5;
834 } else {
835 for (new i = 0; i < 3; i++) {
836 if (number[i] != 0) {
837 strformat(dataStr, sizeof(dataStr), true, "%d%c%d%c", number[i], numberMask[i] { 0 }, number[i + 1] / 100 % 10, numberMask[i] { 1 });
838 break;
839 }
840 }
841 }
842 }
843
844 }
845 }
846
847 if (countSymbols <= 9) {
848 size = 14;
849 } else if (countSymbols <= 11) {
850 size = 12;
851 } else {
852 size = 10;
853 }
854
855 return dataStr;
856}
857
858stock ssGetApplicationVersion() {
859 new version[APP_VERSION];
860 getAppVersion(version);
861 strformat(ssApplicationVersionStr, sizeof(ssApplicationVersionStr), true, "v %d.%d.%d", version.major, version.minor, version.patch);
862}
863
864stock ssSetPositionRotate(screen) {
865 new temp = ssPosition.x;
866 switch (ssPlaces[screen].position) {
867 case 1 : {
868 ssPosition.x = ssPosition.y;
869 ssPosition.y = 240 - temp;
870 ssPosition.angle = 270;
871 }
872 case 2 : {
873 ssPosition.x = 240 - ssPosition.x;
874 ssPosition.y = 240 - ssPosition.y;
875 ssPosition.angle = 180;
876 }
877 case 3 : {
878 ssPosition.x = 240 - ssPosition.y;
879 ssPosition.y = temp;
880 ssPosition.angle = 90;
881 }
882 }
883}
884
885stock ssGetTopologyPlaces() {
886 new ssFacelet[TOPOLOGY_FACELET];
887 for (ssFacelet.module = SELF_ID, ssFacelet.screen = 0; ssFacelet.screen < SCREENS_MAX; ssFacelet.screen++) {
888 ssPlaces[ssFacelet.screen] = TOPOLOGY_getPlace(ssFacelet, TOPOLOGY_orientation_mode:ORIENTATION_MODE_SPLASH);
889 ssPlaces[ssFacelet.screen].face = TOPOLOGY_getPlaceOrientation(ssPlaces[ssFacelet.screen]);
890 }
891}
892
893stock ssRenderBackground(screen) {
894 GFX_clear(0xffffffff);
895 if (ssSprites.background != -1) {
896 ssSetPosition(screen);
897 ssRenderImage(ssSprites.background);
898 } else {
899 ssRenderBackgroundUserDefined(screen, leaderBoardMapping[ssPlaces[screen].face] { ssPlaces[screen].position });
900 }
901}
902
903stock ssRenderMainImage(screen) {
904 if (ssSprites.mainImage >= 0) {
905 ssSetPosition(screen);
906 ssRenderImage(ssSprites.mainImage);
907 }
908}
909
910stock ssRenderAppName(screen) {
911 if (ssSprites.name >= 0) {
912 ssSetPosition(screen);
913 ssRenderImage(ssSprites.name);
914 } else if (ssAppNameText != " ") {
915 new text[2] { 64 };
916 ssSplitString(ssAppNameText, text, separator);
917 ssSetPosition(screen, .y = 100);
918 ssRenderText(text[0], 14, keyColor);
919 ssSetPosition(screen, .y = 140);
920 ssRenderText(text[1], 14, keyColor);
921 }
922}
923
924stock ssRenderLeaderBoardSprite(screen) {
925 if (ssSprites.leaderboard >= 0) {
926 ssSetPosition(screen);
927 ssRenderImage(ssSprites.leaderboard);
928 }
929
930 ssSetPosition(screen, .y = 200);
931 ssRenderText(leaderBoardText, 10, baseColor, TEXT_ALIGN_BOTTOM_CENTER);
932}
933
934stock ssRenderQRCode(screen) {
935 if (ssQRCodeLink != " ") {
936 ssSetPosition(screen, .y = 110);
937 GFX_drawQrCodeXY(ssPosition.x, ssPosition.y, 8, 0xffffffff, 0xff000000, ssPosition.angle, 0, ssQRCodeLink);
938 } else if (ssSprites.qrCode >= 0) {
939 ssSetPosition(screen, .y = 110);
940 ssRenderImage(ssSprites.qrCode);
941 }
942 ssSetPosition(screen, .y = 225);
943 ssRenderText(ssApplicationVersionStr, 9, baseColor);
944}
945
946stock ssRenderLeaderGroup(screen, bool:isFirstGroup) {
947 new nameColor = baseColor;
948 new text[1];
949 new num = 0;
950
951 new leaderName { 9 };
952 new leaderScore { 10 };
953 for (new i = 0; i < 5; ++i) {
954 nameColor = baseColor;
955
956 if (i == 4 && !isFirstGroup && splashscreen_basicInfo.selfPosition > SPLASH_SCREEN_MAX_LEADERS) {
957 num = splashscreen_basicInfo.selfPosition;
958 strformat(leaderScore, sizeof(leaderScore), true, "%s", splashscreenPlayerScore);
959 } else if (i == 3 && !isFirstGroup && splashscreen_basicInfo.selfPosition > SPLASH_SCREEN_MAX_LEADERS) {
960 num = 0;
961 } else {
962 num = i + 1 + (isFirstGroup ? 0 : 5);
963 strformat(leaderName, sizeof(leaderName), true, "%d %s", i + 1 + (isFirstGroup ? 0 : 5), leadersSplashScreen[num - 1].name);
964 strformat(leaderScore, sizeof(leaderScore), true, "%s", leadersSplashScreen[num - 1].value);
965 }
966
967 if (splashscreen_basicInfo.selfPosition == num) {
968 nameColor = keyColor;
969 strformat(leaderName, sizeof(leaderName), true, "%d you", splashscreen_basicInfo.selfPosition);
970 ssRenderBorderYou(screen, 30 + 40 * i);
971 }
972
973 if (num > 0) {
974 ssSetPosition(screen, 10, 30 + 40 * i);
975 ssRenderText(leaderName, LEADER_TABLE_FONT, nameColor, TEXT_ALIGN_LEFT_CORNER);
976
977 ssSetPosition(screen, 230, 30 + 40 * i);
978 ssRenderText(leaderScore, LEADER_TABLE_FONT, keyColor, TEXT_ALIGN_RIGHT_CORNER);
979 } else {
980 ssSetPosition(screen, 50, 30 + 40 * i);
981 ssRenderText(threeDots, LEADER_TABLE_FONT, baseColor, TEXT_ALIGN_LEFT_CORNER);
982
983 }
984 }
985}
986
987stock ssRenderBorderYou(screen, y) {
988 if (ssSprites.borderYou >= 0) {
989 ssSetPosition(screen, .x = 120, .y = y);
990 ssRenderImage(ssSprites.borderYou);
991 }
992}
993stock ssRenderResultsSprite(screen) {
994 if (ssSprites.resultsIcon >= 0) {
995 ssSetPosition(screen);
996 ssRenderImage(ssSprites.resultsIcon);
997 }
998
999 ssSetPosition(screen, .y = 200);
1000 ssRenderText(lastResultsText, 10, baseColor);
1001}
1002
1003stock ssRenderParameter(screen, counter) {
1004
1005 ssSetPosition(screen, .y = 110);
1006 ssRenderText(ssParameters[counter].value, 15, keyColor);
1007
1008 ssSetPosition(screen, .y = 150);
1009 ssRenderText(ssParameters[counter].name, 10, baseColor);
1010}
1011
1012stock ssRenderBest(screen) {
1013 new score { STRING_VALUE_SIZE };
1014 new label { STRING_VALUE_SIZE };
1015 if (strval(ssRecord.value) == 0) {
1016 strformat(score, sizeof(score), true, "%s", leadersSplashScreen[0].value);
1017 label = "Top Score";
1018 } else {
1019 if (splashscreenInScriptRecord > splashscreenInWebRecord) {
1020 strformat(score, sizeof(score), true, "%s", ssRecord.value);
1021 } else {
1022 strformat(score, sizeof(score), true, "%s", splashscreenPlayerScore);
1023 }
1024 strformat(score, sizeof(score), true, "%s", ssRecord.value);
1025
1026 label = "Personal best";
1027 }
1028 ssSetPosition(screen, .y = 110);
1029 ssRenderText(score, ssRecord.fontSize, keyColor);
1030
1031 ssSetPosition(screen, .y = 150);
1032 ssRenderText(label, 8, baseColor);
1033}
1034
1035stock ssRenderTwistIcon(screen) {
1036 if (ssSprites.twist1 == -1 && ssSprites.twist2 == -1)
1037 return;
1038
1039 new id = ssSprites.twist2 == -1 ? ssSprites.twist1 : ssIconsFrame.twist ? ssSprites.twist1 : ssSprites.twist2;
1040
1041 ssSetPosition(screen);
1042 ssRenderImage(id);
1043}
1044
1045stock ssRenderTwistLabelWithoutIcon(screen) {
1046 new text[3] { 64 };
1047 ssSplitString(twistWithoutIcon, text, separator);
1048
1049 ssSetPosition(screen);
1050 ssRenderText(text[0], 17, keyColor);
1051
1052 ssSetPosition(screen, .y = 160);
1053 ssRenderText(text[1], 10, baseColor);
1054
1055
1056 ssSetPosition(screen, .y = 190);
1057 ssRenderText(text[2], 10, baseColor);
1058}
1059
1060stock ssRenderPatLabelWithoutIcon(screen) {
1061 new text[3] { 64 };
1062 ssSplitString(patWithoutIcon, text, separator);
1063
1064 ssSetPosition(screen);
1065 ssRenderText(text[0], 10, keyColor);
1066
1067 ssSetPosition(screen, .y = 160);
1068 ssRenderText(text[1], 8, baseColor);
1069
1070
1071 ssSetPosition(screen, .y = 190);
1072 ssRenderText(text[2], 8, baseColor);
1073}
1074
1075stock ssRenderPatIcon(screen) {
1076 if (ssSprites.pat1 == -1 && ssSprites.pat2 == -1)
1077 return;
1078
1079 new id = ssSprites.pat2 == -1 ? ssSprites.pat1 : ssIconsFrame.pat ? ssSprites.pat1 : ssSprites.pat2;
1080
1081 ssSetPosition(screen);
1082 ssRenderImage(id);
1083}
1084
1085stock ssRenderLabelWithIcon(screen, txt {}) {
1086 new text[2] { 64 };
1087 ssSplitString(txt, text, separator);
1088
1089 ssSetPosition(screen, .y = 190);
1090 ssRenderText(text[0], 8, keyColor);
1091
1092 ssSetPosition(screen, .y = 220);
1093 ssRenderText(text[1], 8, baseColor);
1094}
1095
1096stock ssRenderScreen(screen) {
1097 if (!init.basic) {
1098 LOG_w("Please call InitSplashScreenBasics() before rendering!");
1099 return;
1100 }
1101 ssRenderBackground(screen);
1102
1103 switch (leaderBoardMapping[ssPlaces[screen].face] { ssPlaces[screen].position }) {
1104 case ssEmpty: {}
1105 case ssFirstLeaderGroup: {
1106 ssRenderLeaderGroup(screen, true);
1107 }
1108 case ssSecondLeaderGroup: {
1109 ssRenderLeaderGroup(screen, false);
1110 }
1111 case ssHighScore: {
1112 ssRenderBest(screen);
1113 }
1114 case ssLeaderboardSprite: {
1115 ssRenderLeaderBoardSprite(screen);
1116 }
1117 case ssAppName: {
1118 ssRenderAppName(screen);
1119 }
1120 case ssMainImage: {
1121 ssRenderMainImage(screen);
1122 }
1123 case ssLastResultsSprite: {
1124 ssRenderResultsSprite(screen);
1125 }
1126 case ssLastParameter1: {
1127 ssRenderParameter(screen, 0);
1128 }
1129 case ssLastParameter2: {
1130 ssRenderParameter(screen, 1);
1131 }
1132 case ssLastParameter3: {
1133 ssRenderParameter(screen, 2);
1134 }
1135 case ssTwistIcon: {
1136 ssRenderTwistIcon(screen);
1137 }
1138 case ssTwistLabelWithIcon: {
1139 ssRenderTwistIcon(screen);
1140 ssRenderLabelWithIcon(screen, twistWithIcon);
1141 }
1142 case ssTwistLabelWithoutIcon: {
1143 ssRenderTwistLabelWithoutIcon(screen);
1144 }
1145 case ssPatIcon: {
1146 ssRenderPatIcon(screen);
1147 }
1148 case ssPatLabelWithIcon: {
1149 ssRenderPatIcon(screen);
1150 ssRenderLabelWithIcon(screen, patWithIcon);
1151 }
1152 case ssPatLabelWithoutIcon: {
1153 ssRenderPatLabelWithoutIcon(screen);
1154 }
1155 case ssQRCode: {
1156 ssRenderQRCode(screen);
1157 }
1158 default: {
1159 ssON_Render_UserDefined(screen, leaderBoardMapping[ssPlaces[screen].face] { ssPlaces[screen].position });
1160 }
1161 }
1162}
1163
Wrapped for easier reading. Turn wrap off to inspect exact line lengths.
Context Rail

Related nodes

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