50 lines
2.1 KiB
C++
50 lines
2.1 KiB
C++
#define TESLA_INIT_IMPL // If you have more than one file using the tesla header, only define this in the main one
|
|
#include <tesla.hpp> // The Tesla Header
|
|
|
|
class GuiTest : public tsl::Gui {
|
|
public:
|
|
GuiTest(u8 arg1, u8 arg2, bool arg3) { }
|
|
|
|
// Called when this Gui gets loaded to create the UI
|
|
// Allocate all your elements on the heap. libtesla will make sure to clean them up when not needed anymore
|
|
virtual tsl::elm::Element* createUI() override {
|
|
auto rootFrame = new tsl::elm::OverlayFrame("Tesla Template", "v1.1.0");
|
|
auto list = new tsl::elm::List();
|
|
|
|
list->addItem(new tsl::elm::ListItem("Test List Item"));
|
|
list->addItem(new tsl::elm::ToggleListItem("Test Toggle List Item", true));
|
|
|
|
rootFrame->setContent(list);
|
|
|
|
return rootFrame;
|
|
}
|
|
|
|
// Called once every frame to update values
|
|
virtual void update() override {
|
|
|
|
}
|
|
|
|
// Called once every frame to handle inputs not handled by other UI elements
|
|
virtual bool handleInput(u64 keysDown, u64 keysHeld, touchPosition touchInput, JoystickPosition leftJoyStick, JoystickPosition rightJoyStick) override {
|
|
return false; // Return true here to singal the inputs have been consumed
|
|
}
|
|
};
|
|
|
|
class OverlayTest : public tsl::Overlay {
|
|
public:
|
|
// libtesla already initialized fs, hid, pl, pmdmnt, hid:sys, set:sys and the SD card
|
|
virtual void initServices() override {} // Called at the start to initialize all services necessary for this Overlay
|
|
virtual void exitServices() override {} // Callet at the end to clean up all services previously initialized
|
|
|
|
virtual void onShow() override {} // Called before overlay wants to change from invisible to visible state
|
|
virtual void onHide() override {} // Called before overlay wants to change from visible to invisible state
|
|
|
|
virtual std::unique_ptr<tsl::Gui> loadInitialGui() override {
|
|
return initially<GuiTest>(1, 2, true); // Initial Gui to load. It's possible to pass arguments to it's constructor like this
|
|
}
|
|
};
|
|
|
|
int main(int argc, char **argv) {
|
|
return tsl::loop<OverlayTest>(argc, argv);
|
|
}
|