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 uint32_t GetPersonalBest();133 void SetRecord(uint32_t value);134 void SetNamedValue(uint8_t idx, std::string name, uint32_t value, SplsParms::e_LeadersDataType type = SplsParms::e_LeadersDataType::typeNumber);135136 void SetSeparator(std::string s);137 void SetLabel(SplsParms::e_LabelTypes idx, std::string text);138 void SetApplicationName(std::string name);139 void SetLeaderBoardTable(SplsParms::e_LeaderBoardType type);140 void SetLeaderBoardTable(uint32_t (&lbTable)[TOPOLOGY_FACES_MAX][TOPOLOGY_POSITIONS_MAX]);141 void SetPlaybackSpeed(SplsParms::e_LabelTypes idx, uint32_t speed);142 void SetQRCodeLink(std::string link);143 void SetColors(Cubios::Math::Color key, Cubios::Math::Color base);144145 void SetTopology(uint8_t screen, Cubios::TOPOLOGY_place_t p);146 void GetTopology(TOPOLOGY_orientation_mode_t mode, bool replaceFaceToOrientation);147148 virtual void RenderUserDefinedScreen(uint8_t type) {};149150 protected:151 virtual void RenderBackground(uint32_t type);152153 void ValueToShortString(uint32_t value, std::string &str, SplsParms::e_LeadersDataType dataType);154 void ValueToLongString(uint32_t value, std::string &str, SplsParms::e_LeadersDataType dataType, uint8_t &fontSize);155156 void SetTransform(float x, float y, int rotation = 0);157 void RotateTransformToPosition();158159 void RenderImage(Cubios::spriteID_t ID);160 void RenderText(std::string content, uint8_t fontSize, Cubios::Math::Color c, Cubios::text_align_t alignment = Cubios::text_align_t::TEXT_ALIGN_CENTER);161162 void RenderScreen();163164 void SplitLabels(std::string from, std::vector<std::string> &to);165166 void GetApplicationVersion();167168 void RenderControlLabel(SplsParms::e_LabelTypes type);169 void RenderControlIcon(SplsParms::e_animatedIcons type);170171 void RenderParameter(uint8_t idx);172 void RenderBest();173 void RenderResultsIcon();174175 void RenderBorderYou(uint8_t y);176 void RenderLeaderGroup(bool isFirstGroup);177178 void RenderQRCode();179 void RenderLeaderBoardIcon();180 void RenderAppName();181 void RenderMainImage();182183 private:184 Cubios::LB_info_t splashscreen_basicInfo;185 SplsParms::e_LeadersDataType leadersDataType;186187 SplsLeaderData leadersSplashScreen[SplsParms::SPLASH_SCREEN_MAX_LEADERS]{188 {"Alex", "5000"},189 {"Kim", "4000"},190 {"Beth", "3000"},191 {"Ethan", "2000"},192 {"Mia", "1 000"},193 {"Lucas", "900"},194 {"Jonas", "800"},195 {"Diego", "700"},196 {"Chloe", "500"},197 {"Simon", "100"},198 };199200 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 protected:219 Cubios::Application *app;220 uint8_t renderScreen;221222 Cubios::Math::Color baseColor{Cubios::Gfx::Colors::white};223 Cubios::Math::Color keyColor{Cubios::Gfx::Colors::white};224225 // Special sprites226 SplsSpriteData sprites{-1, -1, -1, -1, -1, -1, -1};227228 uint32_t leaderBoardTable[TOPOLOGY_FACES_MAX][TOPOLOGY_POSITIONS_MAX];229230 Cubios::Math::Transform transform;231 Cubios::TOPOLOGY_place_t place[SCREENS_MAX];232233 };234}235
Wrapped for easier reading. Turn wrap off to inspect exact line lengths.