Splashscreen.h
Splashscreen.h
CPP1/* Copyright Statement:2 *3 * (C) 2021-2024 Cubios Inc. All rights reserved.4 */56#include "native.h"7#include "AppManager.h"8#include "Gfx.h"910namespace Cubios11{12 namespace SplsParms13 {14 const uint8_t SPLASH_SCREEN_MAX_LEADERS = 10;15 const uint8_t SPLASH_SCREEN_MAX_NAMED_VALUES = 3;16 const uint8_t LEADERBOARD_SIZE = 120;17 const uint8_t LEADER_TABLE_FONT_SIZE = 6;1819 enum e_LeadersDataType20 {21 typeNumber = 1,22 typeTime = 2,23 };2425 enum e_ScreensType26 {27 Empty = 0,28 FirstLeaderGroup,29 SecondLeaderGroup,30 HighScore,31 LeaderboardIcon,32 AppName,33 MainImage,34 LastResultsIcon,35 NamedValue1,36 NamedValue2,37 NamedValue3,38 TwistIcon,39 TwistLabelWithIcon,40 TwistLabelWithoutIcon,41 PatIcon,42 PatLabelWithIcon,43 PatLabelWithoutIcon,44 QRCode,45 TypeMax,46 };4748 enum e_LabelTypes49 {50 LabelPatWithIcon = 0,51 LabelPatWithoutIcon,52 LabelTwistWithIcon,53 LabelTwistWithoutIcon,54 LabelsCount,55 };5657 enum e_LeaderBoardType58 {59 LeaderBoardWithoutSaves = 0,60 LeaderBoardWithSaves,61 };6263 enum e_animatedIcons64 {65 iconPat = 0,66 iconTwist,67 iconsCount,68 };69 }7071 typedef struct72 {73 std::string name;74 std::string value;75 } SplsLeaderData;7677 typedef struct78 {79 std::string name;80 std::string value;81 uint8_t fontSize;82 } SplsResultData;8384 typedef struct85 {86 std::string value;87 std::string lbValue;88 std::string label;89 uint8_t fontSize;90 } SplsRecordData;9192 typedef struct93 {94 Cubios::spriteID_t background;95 Cubios::spriteID_t mainImage;96 Cubios::spriteID_t name;97 Cubios::spriteID_t resultsIcon;98 Cubios::spriteID_t leaderboardIcon;99 Cubios::spriteID_t QRcode;100 Cubios::spriteID_t borderYou;101 } SplsSpriteData;102103 typedef struct104 {105 uint8_t frame;106 uint32_t time;107 uint32_t playbackSpeed;108 std::vector<Cubios::spriteID_t> spriteID;109 } SplsAnimation;110111 class Splashscreen112 {113 public:114 Splashscreen(Cubios::Application *app, SplsParms::e_LeadersDataType dataType);115 ~Splashscreen();116117 void InitSplashScreenSprites(Cubios::spriteID_t backgroundSprite = -1,118 Cubios::spriteID_t mainImageSprite = -1,119 Cubios::spriteID_t gameNameSprite = -1,120 Cubios::spriteID_t QRcodeSprite = -1,121 Cubios::spriteID_t leaderboardIcon = -1,122 Cubios::spriteID_t resultsIcon = -1,123 Cubios::spriteID_t twistIcon_1 = -1,124 Cubios::spriteID_t twistIcon_2 = -1,125 Cubios::spriteID_t tapIcon_1 = -1,126 Cubios::spriteID_t tapIcon_2 = -1,127 Cubios::spriteID_t borderYou = -1);128129 virtual void Render(Cubios::Screen* screen);130 virtual void Tick(uint32_t currentTime, uint32_t deltaTime);131132 void SetRecord(uint32_t value);133 void SetNamedValue(uint8_t idx, std::string name, uint32_t value, SplsParms::e_LeadersDataType type = SplsParms::e_LeadersDataType::typeNumber);134135 void SetSeparator(std::string s);136 void SetLabel(SplsParms::e_LabelTypes idx, std::string text);137 void SetApplicationName(std::string name);138 void SetLeaderBoardTable(SplsParms::e_LeaderBoardType type);139 void SetLeaderBoardTable(uint32_t (&lbTable)[TOPOLOGY_FACES_MAX][TOPOLOGY_POSITIONS_MAX]);140 void SetPlaybackSpeed(SplsParms::e_LabelTypes idx, uint32_t speed);141 void SetQRCodeLink(std::string link);142 void SetColors(Cubios::Math::Color key, Cubios::Math::Color base);143144 void SetTopology(uint8_t screen, Cubios::TOPOLOGY_place_t p);145 void GetTopology(TOPOLOGY_orientation_mode_t mode, bool replaceFaceToOrientation);146147 virtual void RenderUserDefinedScreen(uint8_t type) {};148149 protected:150 virtual void RenderBackground(uint32_t type);151152 void ValueToShortString(uint32_t value, std::string &str, SplsParms::e_LeadersDataType dataType);153 void ValueToLongString(uint32_t value, std::string &str, SplsParms::e_LeadersDataType dataType, uint8_t &fontSize);154155 void SetTransform(float x, float y, int rotation = 0);156 void RotateTransformToPosition();157158 void RenderImage(Cubios::spriteID_t ID);159 void RenderText(std::string content, uint8_t fontSize, Cubios::Math::Color c, Cubios::text_align_t alignment = Cubios::text_align_t::TEXT_ALIGN_CENTER);160161 void RenderScreen();162163 void SplitLabels(std::string from, std::vector<std::string> &to);164165 void GetApplicationVersion();166167 void RenderControlLabel(SplsParms::e_LabelTypes type);168 void RenderControlIcon(SplsParms::e_animatedIcons type);169170 void RenderParameter(uint8_t idx);171 void RenderBest();172 void RenderResultsIcon();173174 void RenderBorderYou(uint8_t y);175 void RenderLeaderGroup(bool isFirstGroup);176177 void RenderQRCode();178 void RenderLeaderBoardIcon();179 void RenderAppName();180 void RenderMainImage();181182 private:183 Cubios::LB_info_t splashscreen_basicInfo;184 SplsParms::e_LeadersDataType leadersDataType;185186 SplsLeaderData leadersSplashScreen[SplsParms::SPLASH_SCREEN_MAX_LEADERS]{187 {"Alex", "5 000"},188 {"Kim", "4 000"},189 {"Beth", "3 000"},190 {"Ethan", "2 000"},191 {"Mia", "1 000"},192 {"Lucas", "900"},193 {"Jonas", "800"},194 {"Diego", "700"},195 {"Chloe", "500"},196 {"Simon", "100"},197 };198199 Cubios::Math::Transform transform;200 Cubios::Math::Color color{Cubios::Math::Color(255, 0, 255)};201202 SplsRecordData record{"0", "0", "Top score", 10};203 SplsResultData params[SplsParms::SPLASH_SCREEN_MAX_NAMED_VALUES];204205 std::string separator{"\n"};206 std::vector<std::string> appName;207208 std::vector<std::string> labels[SplsParms::LabelsCount];209210 SplsAnimation animation[SplsParms::iconsCount];211212 std::string QRCode{""};213 std::string version{""};214215 std::string leaderBoardText{"LEADERBOARD"};216 std::string lastResultsText{"LAST RESULTS"};217218 Cubios::TOPOLOGY_place_t place[SCREENS_MAX];219220 protected:221 Cubios::Application *app;222 uint8_t renderScreen;223224 Cubios::Math::Color baseColor{Cubios::Gfx::Colors::white};225 Cubios::Math::Color keyColor{Cubios::Gfx::Colors::white};226227 // Special sprites228 SplsSpriteData sprites{-1, -1, -1, -1, -1, -1, -1};229230 uint32_t leaderBoardTable[TOPOLOGY_FACES_MAX][TOPOLOGY_POSITIONS_MAX];231 };232}233
Wrapped for easier reading. Turn wrap off to inspect exact line lengths.