Upload current progress

Currently it just crashes the switch when you try to add a day, not sure how to fix it.
This commit is contained in:
SeanOMik 2020-03-20 15:38:44 -05:00
parent b933676b1e
commit fb900854f0
No known key found for this signature in database
GPG Key ID: FA4D55AC05268A88
7 changed files with 222 additions and 122 deletions

View File

@ -1,48 +1,29 @@
{
"configurations": [
{
"name": "DKP Aarch64 Windows",
"includePath": [
"C:/devkitPro/devkitA64/aarch64-none-elf/include/**",
"C:/devkitPro/devkitA64/lib/gcc/aarch64-none-elf/8.3.0/include/**",
"C:/devkitPro/libnx/include/**",
"C:/devkitPro/portlibs/switch/include/**",
"C:/devkitPro/portlibs/switch/include/freetype2/**",
"${workspaceFolder}/include/**",
"${workspaceFolder}/libs/libtesla/include/**"
],
"defines": [
"SWITCH",
"__SWITCH__",
"__aarch64__"
],
"compilerPath": "C:/devkitPro/devkitA64/bin/aarch64-none-elf-g++",
"cStandard": "c11",
"cppStandard": "c++17",
"intelliSenseMode": "gcc-x64"
},
{
"name": "DKP Aarch64 Linux",
"includePath": [
"/opt/devkitpro/devkitA64/aarch64-none-elf/include/**",
"/opt/devkitpro/devkitA64/lib/gcc/aarch64-none-elf/8.3.0/include/**",
"/opt/devkitpro/libnx/include/**",
"/opt/devkitpro/portlibs/switch/include/**",
"/opt/devkitpro/portlibs/switch/include/**",
"/opt/devkitpro/portlibs/switch/include/freetype2/**",
"${workspaceFolder}/include/**",
"${workspaceFolder}/libs/libtesla/include/**"
],
"defines": [
"SWITCH",
"__SWITCH__",
"__aarch64__"
],
"compilerPath": "/opt/devkitpro/devkitA64/bin/aarch64-none-elf-g++",
"cStandard": "c11",
"cppStandard": "c++17",
"intelliSenseMode": "gcc-x64"
"name": "Switch",
"includePath": [
"${devkitA64}/aarch64-none-elf/include/**",
"${devkitA64}/lib/gcc/aarch64-none-elf/8.3.0/include/**",
"${devkitpro}/libnx/include/**",
"${devkitpro}/portlibs/switch/include/*",
"${workspaceFolder}/libs/libtesla/include/**"
],
"defines": [
"UNICODE",
"_UNICODE",
"__aarch64__",
"__SWITCH__",
"HAVE_LIBNX",
"EXPERIMENTAL",
"DEBUG"
],
"windowsSdkVersion": "10.0.17763.0",
"compilerPath": "${devkitA64}/bin/aarch64-none-elf-gcc",
"cStandard": "c11",
"cppStandard": "c++17",
"intelliSenseMode": "gcc-x64"
}
],
"version": 4
}
}

139
.vscode/settings.json vendored
View File

@ -1,57 +1,84 @@
{
"files.associations": {
"chrono": "cpp",
"string_view": "cpp",
"array": "cpp",
"atomic": "cpp",
"bit": "cpp",
"*.tcc": "cpp",
"cctype": "cpp",
"clocale": "cpp",
"cmath": "cpp",
"cstdarg": "cpp",
"cstddef": "cpp",
"cstdint": "cpp",
"cstdio": "cpp",
"cstdlib": "cpp",
"cstring": "cpp",
"ctime": "cpp",
"cwchar": "cpp",
"cwctype": "cpp",
"deque": "cpp",
"unordered_map": "cpp",
"vector": "cpp",
"exception": "cpp",
"algorithm": "cpp",
"functional": "cpp",
"iterator": "cpp",
"memory": "cpp",
"memory_resource": "cpp",
"numeric": "cpp",
"optional": "cpp",
"random": "cpp",
"ratio": "cpp",
"string": "cpp",
"system_error": "cpp",
"tuple": "cpp",
"type_traits": "cpp",
"utility": "cpp",
"fstream": "cpp",
"initializer_list": "cpp",
"iosfwd": "cpp",
"istream": "cpp",
"limits": "cpp",
"new": "cpp",
"ostream": "cpp",
"sstream": "cpp",
"stdexcept": "cpp",
"streambuf": "cpp",
"thread": "cpp",
"cinttypes": "cpp",
"typeinfo": "cpp",
"codecvt": "cpp",
"condition_variable": "cpp",
"iomanip": "cpp",
"mutex": "cpp"
}
{
"files.associations": {
"new": "cpp",
"array": "cpp",
"atomic": "cpp",
"*.tcc": "cpp",
"cctype": "cpp",
"clocale": "cpp",
"cmath": "cpp",
"cstdarg": "cpp",
"cstddef": "cpp",
"cstdint": "cpp",
"cstdio": "cpp",
"cstdlib": "cpp",
"cstring": "cpp",
"cwchar": "cpp",
"cwctype": "cpp",
"deque": "cpp",
"unordered_map": "cpp",
"vector": "cpp",
"exception": "cpp",
"algorithm": "cpp",
"functional": "cpp",
"iterator": "cpp",
"memory": "cpp",
"memory_resource": "cpp",
"numeric": "cpp",
"optional": "cpp",
"random": "cpp",
"string": "cpp",
"string_view": "cpp",
"system_error": "cpp",
"tuple": "cpp",
"type_traits": "cpp",
"utility": "cpp",
"fstream": "cpp",
"initializer_list": "cpp",
"iosfwd": "cpp",
"iostream": "cpp",
"istream": "cpp",
"limits": "cpp",
"ostream": "cpp",
"sstream": "cpp",
"stdexcept": "cpp",
"streambuf": "cpp",
"cinttypes": "cpp",
"typeinfo": "cpp",
"fitz.h": "c",
"list": "cpp",
"textures.h": "c",
"sdl_helper.h": "c",
"common.hpp": "c",
"chrono": "cpp",
"codecvt": "cpp",
"ctime": "cpp",
"ratio": "cpp",
"common.h": "c",
"sdl.h": "c",
"bitset": "c",
"cfenv": "c",
"charconv": "c",
"complex": "c",
"condition_variable": "c",
"csetjmp": "c",
"csignal": "c",
"cuchar": "c",
"forward_list": "c",
"unordered_set": "c",
"map": "c",
"regex": "c",
"set": "c",
"future": "c",
"iomanip": "c",
"mutex": "c",
"scoped_allocator": "c",
"shared_mutex": "c",
"thread": "c",
"typeindex": "c",
"valarray": "c",
"status_bar.h": "c",
"sdl_ttf.h": "c",
"sdl_image.h": "c"
}
}

View File

@ -45,7 +45,15 @@ SOURCES := source
DATA := data
INCLUDES := include libs/libtesla/include
VERSION_MAJOR := 0
VERSION_MINOR := 1
VERSION_MICRO := 0
APP_TITLE := Time Travel Overlay
APP_AUTHOR := SeanOMik
APP_VERSION := ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_MICRO}-beta
NO_ICON := 1
#ICON := icon.jpg
#---------------------------------------------------------------------------------
# options for code generation

View File

@ -1,2 +1,5 @@
# Tesla-Template
A template repository for Tesla Overlay Homebrews
# Time Travel Overlay
A Time travel overlay for nx-ovlloader. Mainly made for Animal Crossing - New Horizons.
## State:
Currently it just crashes the switch when you try to go forward a day, not sure how to fix it.

1
libs/libtesla Submodule

@ -0,0 +1 @@
Subproject commit ca0b4657dc340839fae3a98923be9d3fbd67bf4f

42
source/elm_button.hpp Normal file
View File

@ -0,0 +1,42 @@
#pragma once
#include <tesla.hpp>
class Button : public tsl::elm::Element {
public:
inline Button(u16 x, u16 y, u16 w, u16 h, const std::string &txt, std::function<bool(s64, Button)> click_action) : Element(), m_text(txt), m_onClick(click_action), x(x), y(y), width(w), height(h) { }
inline Button(const std::string &txt, std::function<bool(s64, Button)> cb) : Element(), m_text(txt), m_onClick(cb), x(this->getX()), y(this->getY()), width(this->getWidth()), height(tsl::style::ListItemDefaultHeight) { }
inline virtual ~Button() {}
inline tsl::elm::Element* requestFocus(tsl::elm::Element *oldFocus, tsl::FocusDirection direction) override {
return this;
}
inline virtual void draw(tsl::gfx::Renderer *renderer) override {
this->renderer = renderer;
renderer->drawRect(this->getX(), this->getY(), this->getWidth(), 1, a({ 0x5, 0x5, 0x5, 0xF }));
renderer->drawRect(this->getX(), this->getY() + this->getHeight(), this->getWidth(), 1, a({ 0x5, 0x5, 0x5, 0xF }));
renderer->drawString(this->m_text.c_str(), false, this->getX() + 20, this->getY() + 45, 23, a({ 0xF, 0xF, 0xF, 0xF }));
}
inline void layout(u16 parentX, u16 parentY, u16 parentWidth, u16 parentHeight) override {
}
inline virtual bool onClick(u64 keys) override {
return m_onClick(keys, *this);
}
tsl::gfx::Renderer *renderer;
private:
u16 x;
u16 y;
u16 width;
u16 height;
std::string m_text;
std::function<bool(s64, Button)> m_onClick;
};

View File

@ -1,49 +1,87 @@
#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 {
#include <switch.h>
#include "elm_button.hpp"
Result rc;
class TimeTravelGui : public tsl::Gui {
public:
GuiTest(u8 arg1, u8 arg2, bool arg3) { }
TimeTravelGui() { }
// 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 rootFrame = new tsl::elm::OverlayFrame("Time Travel", "v0.1.0-beta");
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));
if (R_FAILED(rc)) {
printf("setInitialize() failed: 0x%x.\n", rc);
// If we failed to initialize, display the error.
list->addItem(new tsl::elm::ListItem("Failed to initialize! (0x" + std::to_string(rc) + ")"));
}
u64 current_time;
if (R_SUCCEEDED(rc)) {
// Set system time
rc = timeGetCurrentTime(TimeType_Default, &current_time);
// If we failed to get the time, display the error.
if (R_FAILED(rc)) {
printf("timeGetCurrentTime() failed: 0x%x.\n", rc);
list->addItem(new tsl::elm::ListItem("Failed get current time! (0x" + std::to_string(rc) + ")"));
} else { // Only add the +1 day button if it got time correctly.
list->addItem(new Button("+1 Day", [=](u64 keys, Button btn)->bool {
if (keys & KEY_A) {
u64 day_ahead_time = current_time + 86400; // Add one day (in seconds) to the current time
rc = timeSetCurrentTime(TimeType_Default, current_time);
if (R_SUCCEEDED(rc)) {
list->addItem(new tsl::elm::ListItem("Added 1 day!"));
} else {
printf("timeSetCurrentTime() failed: 0x%x.\n", rc);
// If we failed to set time, display the error.
list->addItem(new tsl::elm::ListItem("Failed to set time! (0x" + std::to_string(rc) + ")"));
}
return true;
}
return false;
}), tsl::style::ListItemDefaultHeight);
}
}
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 {
class TimeTravelOverlay : 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 initServices() override { // Called at the start to initialize all services necessary for this Overlay
consoleInit(NULL);
timeInitialize();
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
rc = setInitialize();
}
virtual void exitServices() override { // Called at the end to clean up all services previously initialized
timeExit();
}
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
return initially<TimeTravelGui>(); // 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);
return tsl::loop<TimeTravelOverlay>(argc, argv);
}