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.1C++appmanager.h

AppManager.h

SDK Source File: AppManager.h

Source / SDK 6.1 / C++ / Core

AppManager.h

AppManager.h
CPP
1/* Copyright Statement:
2 *
3 * (C) 2021-2024 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) = 0;
49 virtual void on_Close() {}
50 virtual void on_Timer(uint8_t timerID){};
51
52 uint32_t GetTime() const { return curTime; }
53 uint32_t GetTimeSeconds() const { return curTime / 1000; }
54
55 void SendNetworkMessage(uint32_t type, NetworkMessage *msg) const;
56
57 void SendExternalMessage(uint32_t type, uint8_t *data, size_t size) const;
58
59 void SaveState(void *data, size_t size) const;
60 i32_t LoadState(u32_t *id, void *data, size_t size) const;
61
62 void SaveState(SaveMessage* msg) const;
63 i32_t LoadState(u32_t *id, SaveMessage* msg) const;
64
65 bool SetTimer(uint8_t id, uint32_t delay, bool suspended = false);
66 bool StartTimer(uint8_t id);
67 bool StopTimer(uint8_t id);
68 void KillTimer(uint8_t id);
69
70 void ShowFPSCounter(bool b);
71
72 bool IsMasterModule()
73 {
74 if (this->Module == 0)
75 return true;
76 else
77 return false;
78 }
79
80 inline int GetImageAssetsCount() {return GFX_getAssetsCount();}
81 inline int GetSoundAssetsCount() {return SND_getAssetsCount();}
82
83 private:
84 void handleTimers();
85
86 public:
87 Cubios::Scene Scene;
88 uint32_t Module;
89
90 private:
91 AppManager *appMgr;
92 uint32_t curTime;
93
94 std::vector<Timer_t> timers;
95
96 uint8_t appUUID[10];
97 };
98
99 class AppManager
100 {
101 private:
102 friend Application;
103 static const uint8_t m_sMaxRxPacketSize = 113;
104 static const uint8_t m_sMaxPacketType = 31;
105
106 uint32_t prevTime;
107 std::shared_ptr<Application> application;
108
109 uint8_t *sendBuffer;
110
111 void handleNetPacket();
112
113 void handleExternalData();
114
115 void handleTwist();
116 void handleTap();
117
118 void SendNetworkMessage(uint32_t type, uint8_t *data, size_t size) const;
119
120 void SendExternalMessage(uint32_t type, uint8_t *, size_t size);
121
122 public:
123 AppManager() : prevTime(0), sendBuffer(nullptr) {}
124 int Main();
125
126 void SetApplication(Application *app, const std::string &appIdentifier = "");
127 };
128
129}
130
131
Wrapped for easier reading. Turn wrap off to inspect exact line lengths.
Context Rail

Related nodes

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