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

139
.vscode/settings.json vendored
View File

@ -1,57 +1,84 @@
{ {
"files.associations": { "files.associations": {
"chrono": "cpp", "new": "cpp",
"string_view": "cpp", "array": "cpp",
"array": "cpp", "atomic": "cpp",
"atomic": "cpp", "*.tcc": "cpp",
"bit": "cpp", "cctype": "cpp",
"*.tcc": "cpp", "clocale": "cpp",
"cctype": "cpp", "cmath": "cpp",
"clocale": "cpp", "cstdarg": "cpp",
"cmath": "cpp", "cstddef": "cpp",
"cstdarg": "cpp", "cstdint": "cpp",
"cstddef": "cpp", "cstdio": "cpp",
"cstdint": "cpp", "cstdlib": "cpp",
"cstdio": "cpp", "cstring": "cpp",
"cstdlib": "cpp", "cwchar": "cpp",
"cstring": "cpp", "cwctype": "cpp",
"ctime": "cpp", "deque": "cpp",
"cwchar": "cpp", "unordered_map": "cpp",
"cwctype": "cpp", "vector": "cpp",
"deque": "cpp", "exception": "cpp",
"unordered_map": "cpp", "algorithm": "cpp",
"vector": "cpp", "functional": "cpp",
"exception": "cpp", "iterator": "cpp",
"algorithm": "cpp", "memory": "cpp",
"functional": "cpp", "memory_resource": "cpp",
"iterator": "cpp", "numeric": "cpp",
"memory": "cpp", "optional": "cpp",
"memory_resource": "cpp", "random": "cpp",
"numeric": "cpp", "string": "cpp",
"optional": "cpp", "string_view": "cpp",
"random": "cpp", "system_error": "cpp",
"ratio": "cpp", "tuple": "cpp",
"string": "cpp", "type_traits": "cpp",
"system_error": "cpp", "utility": "cpp",
"tuple": "cpp", "fstream": "cpp",
"type_traits": "cpp", "initializer_list": "cpp",
"utility": "cpp", "iosfwd": "cpp",
"fstream": "cpp", "iostream": "cpp",
"initializer_list": "cpp", "istream": "cpp",
"iosfwd": "cpp", "limits": "cpp",
"istream": "cpp", "ostream": "cpp",
"limits": "cpp", "sstream": "cpp",
"new": "cpp", "stdexcept": "cpp",
"ostream": "cpp", "streambuf": "cpp",
"sstream": "cpp", "cinttypes": "cpp",
"stdexcept": "cpp", "typeinfo": "cpp",
"streambuf": "cpp", "fitz.h": "c",
"thread": "cpp", "list": "cpp",
"cinttypes": "cpp", "textures.h": "c",
"typeinfo": "cpp", "sdl_helper.h": "c",
"codecvt": "cpp", "common.hpp": "c",
"condition_variable": "cpp", "chrono": "cpp",
"iomanip": "cpp", "codecvt": "cpp",
"mutex": "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 DATA := data
INCLUDES := include libs/libtesla/include 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 NO_ICON := 1
#ICON := icon.jpg
#--------------------------------------------------------------------------------- #---------------------------------------------------------------------------------
# options for code generation # options for code generation

View File

@ -1,2 +1,5 @@
# Tesla-Template # Time Travel Overlay
A template repository for Tesla Overlay Homebrews 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 #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 #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: public:
GuiTest(u8 arg1, u8 arg2, bool arg3) { } TimeTravelGui() { }
// Called when this Gui gets loaded to create the UI // 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 // 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 { 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(); auto list = new tsl::elm::List();
list->addItem(new tsl::elm::ListItem("Test List Item")); if (R_FAILED(rc)) {
list->addItem(new tsl::elm::ToggleListItem("Test Toggle List Item", true)); 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); rootFrame->setContent(list);
return rootFrame; 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: public:
// libtesla already initialized fs, hid, pl, pmdmnt, hid:sys, set:sys and the SD card // 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 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 consoleInit(NULL);
timeInitialize();
virtual void onShow() override {} // Called before overlay wants to change from invisible to visible state rc = setInitialize();
virtual void onHide() override {} // Called before overlay wants to change from visible to invisible state }
virtual void exitServices() override { // Called at the end to clean up all services previously initialized
timeExit();
}
virtual std::unique_ptr<tsl::Gui> loadInitialGui() override { 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) { int main(int argc, char **argv) {
return tsl::loop<OverlayTest>(argc, argv); return tsl::loop<TimeTravelOverlay>(argc, argv);
} }