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. AppManager.h
Mission NodeSDK 6.3C++appmanager.h

AppManager.h

SDK Source File: AppManager.h

Source / SDK 6.3 / C++ / Core

AppManager.h

AppManager.h
CPP
1/* Copyright Statement:
2 *
3 * (C) 2021-2025 Cubios Inc. All rights reserved.
4 */
5
6#pragma once
7
8#include "native.h"
9#include <stdint.h>
10#include <exception>
11#include <memory>
12#include <array>
13#include "Scene.h"
14#include "Screen.h"
15#include "NetworkMessage.h"
16#include "SaveMessage.h"
17
18namespace Cubios
19{
20 class AppManager;
21
22 struct Timer_t
23 {
24 bool suspended;
25 uint32_t delay;
26 uint32_t time;
27 uint8_t id;
28 };
29
30 class Application
31 {
32 public:
33 friend AppManager;
34 Application() : appMgr(nullptr), curTime(0), Module(Cubios::cubeN)
35 {
36 }
37 virtual ~Application()
38 {
39 }
40
41 virtual void on_Message(uint32_t type, uint8_t *pkt, u32_t size) = 0;
42 virtual void on_ExternalMessage(uint8_t *pkt, u32_t size) = 0;
43
44 virtual void on_PhysicsTick(const std::array<Screen, 3> &screens) = 0;
45 virtual void on_Tick(uint32_t time, uint32_t dt) = 0;
46 virtual void on_Render(std::array<Screen, 3> &screens) = 0;
47 virtual void on_Twist(const TOPOLOGY_twistInfo_t &twist) = 0;
48 virtual void on_Tap(uint32_t count) {};
49 virtual void on_Pat(uint32_t count) {};
50 virtual void on_Close() {}
51 virtual void on_Timer(uint8_t timerID){};
52
53 uint32_t GetTime() const { return curTime; }
54 uint32_t GetTimeSeconds() const { return curTime / 1000; }
55
56 void SendNetworkMessage(uint32_t type, NetworkMessage *msg) const;
57
58 void SendExternalMessage(uint32_t type, uint8_t *data, size_t size) const;
59
60 void SaveState(void *data, size_t size) const;
61 i32_t LoadState(u32_t *id, void *data, size_t size) const;
62
63 void SaveState(SaveMessage* msg) const;
64 i32_t LoadState(u32_t *id, SaveMessage* msg) const;
65
66 bool SetTimer(uint8_t id, uint32_t delay, bool suspended = false);
67 bool StartTimer(uint8_t id);
68 bool StopTimer(uint8_t id);
69 void KillTimer(uint8_t id);
70
71 void ShowFPSCounter(bool b);
72
73 bool IsMasterModule()
74 {
75 if (this->Module == 0)
76 return true;
77 else
78 return false;
79 }
80
81 inline int GetImageAssetsCount() {return GFX_getAssetsCount();}
82 inline int GetSoundAssetsCount() {return SND_getAssetsCount();}
83
84 private:
85 void handleTimers();
86
87 public:
88 Cubios::Scene Scene;
89 uint32_t Module;
90
91 private:
92 AppManager *appMgr;
93 uint32_t curTime;
94
95 std::vector<Timer_t> timers;
96
97 uint8_t appUUID[10];
98 };
99
100 class AppManager
101 {
102 private:
103 friend Application;
104 static const uint8_t m_sMaxRxPacketSize = 113;
105 static const uint8_t m_sMaxPacketType = 31;
106
107 uint32_t prevTime;
108 std::shared_ptr<Application> application;
109
110 uint8_t *sendBuffer;
111
112 void handleNetPacket();
113
114 void handleExternalData();
115
116 void handleTwist();
117 void handlePat();
118
119 void SendNetworkMessage(uint32_t type, uint8_t *data, size_t size) const;
120
121 void SendExternalMessage(uint32_t type, uint8_t *, size_t size);
122
123 public:
124 AppManager() : prevTime(0), sendBuffer(nullptr) {}
125 int Main();
126
127 void SetApplication(Application *app, const std::string &appIdentifier = "");
128 };
129
130}
131
132
Wrapped for easier reading. Turn wrap off to inspect exact line lengths.
Context Rail

Related nodes

AppManager.cpp
Source / SDK 6.3 / C++ / Core
Gfx.h
Source / SDK 6.3 / C++ / Core
native access.h
Source / SDK 6.3 / C++ / Core
native defines.h
Source / SDK 6.3 / C++ / Core
Previous Node
AppManager.cpp
Source / SDK 6.3 / C++ / Core
Next Node
Gfx.h
Source / SDK 6.3 / C++ / Core