Skip to content

Commit

Permalink
Updated to latest libtesla
Browse files Browse the repository at this point in the history
  • Loading branch information
WerWolv committed Feb 29, 2020
1 parent a9875d4 commit 193fc25
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 40 deletions.
6 changes: 5 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@
"codecvt": "cpp",
"condition_variable": "cpp",
"iomanip": "cpp",
"mutex": "cpp"
"mutex": "cpp",
"forward_list": "cpp",
"list": "cpp",
"map": "cpp",
"valarray": "cpp"
}
}
20 changes: 6 additions & 14 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ TARGET := $(notdir $(CURDIR))
BUILD := build
SOURCES := source
DATA := data
INCLUDES := include
INCLUDES := include libs/libtesla/include

NO_ICON := 1

Expand All @@ -57,18 +57,18 @@ CFLAGS := -g -Wall -O2 -ffunction-sections \

CFLAGS += $(INCLUDE) -D__SWITCH__

CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -std=c++17
CXXFLAGS := $(CFLAGS) -fno-exceptions -std=c++17

ASFLAGS := -g $(ARCH)
LDFLAGS = -specs=$(DEVKITPRO)/libnx/switch.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map)

LIBS := -lnx -ltesla -lnx
LIBS := -lnx

#---------------------------------------------------------------------------------
# list of directories containing libraries, this must be the top level containing
# include and lib
#---------------------------------------------------------------------------------
LIBDIRS := $(PORTLIBS) $(LIBNX) $(TOPDIR)/libs/libtesla
LIBDIRS := $(PORTLIBS) $(LIBNX)


#---------------------------------------------------------------------------------
Expand Down Expand Up @@ -170,7 +170,6 @@ $(BUILD):

#---------------------------------------------------------------------------------
clean:
@$(MAKE) --no-print-directory -C $(TOPDIR)/libs/libtesla -f Makefile clean
@rm -fr $(BUILD) $(TARGET).ovl $(TARGET).nro $(TARGET).nacp $(TARGET).elf


Expand All @@ -189,17 +188,10 @@ $(OUTPUT).ovl : $(OUTPUT).elf $(OUTPUT).nacp
@elf2nro $< $@ $(NROFLAGS)
@echo "built ... $(notdir $(OUTPUT).ovl)"

$(OUTPUT).elf : $(OFILES) libs/libtesla/lib/libtesla.a
$(OUTPUT).elf : $(OFILES)

$(OFILES_SRC) : $(HFILES_BIN)

libs/libtesla/lib/libtesla.a:
@$(MAKE) --no-print-directory -C $(TOPDIR)/libs/libtesla -f Makefile

clean:
@$(MAKE) --no-print-directory -C $(TOPDIR)/libs/libtesla -f Makefile clean
@rm -fr $(BUILD) $(TARGET).ovl $(TARGET).nro $(TARGET).nacp $(TARGET).elf

#---------------------------------------------------------------------------------
# you need a rule like this for each extension you use as binary data
#---------------------------------------------------------------------------------
Expand All @@ -212,4 +204,4 @@ clean:

#---------------------------------------------------------------------------------------
endif
#---------------------------------------------------------------------------------------
#---------------------------------------------------------------------------------------
52 changes: 28 additions & 24 deletions source/main.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#define TESLA_INIT_IMPL
#include <tesla.hpp>

#include <fstream>
Expand All @@ -19,15 +20,14 @@ bool isProgramRunning(u64 programId) {
class GuiMain : public tsl::Gui {
public:
GuiMain() {
this->setTitle("Sysmodules");
this->setSubtitle("v1.0.0");

}

~GuiMain() { }

virtual tsl::Element* createUI() {
tsl::element::Frame *rootFrame = new tsl::element::Frame();
tsl::element::List *sysmoduleList = new tsl::element::List();
virtual tsl::elm::Element* createUI() {
tsl::elm::OverlayFrame *rootFrame = new tsl::elm::OverlayFrame("Sysmodules", "v1.1.0");
tsl::elm::List *sysmoduleList = new tsl::elm::List();

for (auto contentsFolder : std::filesystem::directory_iterator("sdmc:/atmosphere/contents")) {
auto toolboxFile = contentsFolder.path() / "toolbox.json";
Expand All @@ -50,8 +50,8 @@ class GuiMain : public tsl::Gui {

if (contentsFolder.path().string().find(sysmoduleProgramIdString) != std::string::npos) {

auto listEntry = new tsl::element::ToggleListItem(sysmoduleName, isProgramRunning(sysmoduleProgramId));
listEntry->setStateChangeListener([listEntry, sysmoduleProgramId](bool state) -> bool {
auto listEntry = new tsl::elm::ToggleListItem(sysmoduleName, isProgramRunning(sysmoduleProgramId));
listEntry->setStateChangedListener([listEntry, sysmoduleProgramId](bool state) -> bool {
if (!isProgramRunning(sysmoduleProgramId)) {
const NcmProgramLocation programLocation {
.program_id = sysmoduleProgramId,
Expand All @@ -75,16 +75,20 @@ class GuiMain : public tsl::Gui {
}
}


if (this->m_sysmoduleListItems.size() == 0) {
auto warning = new tsl::element::CustomDrawer(0, 0, 100, FB_WIDTH, [](u16 x, u16 y, tsl::Screen *screen){
screen->drawString("\uE150", false, 180, 250, 90, tsl::a(0xFFFF));
screen->drawString("No sysmodules found!", false, 110, 340, 25, tsl::a(0xFFFF));
auto warning = new tsl::elm::CustomDrawer([](tsl::gfx::Renderer *renderer, u16 x, u16 y, u16 w, u16 h){
renderer->drawString("\uE150", false, 180, 250, 90, renderer->a(0xFFFF));
renderer->drawString("No sysmodules found!", false, 110, 340, 25, renderer->a(0xFFFF));
});

rootFrame->addElement(warning);
delete sysmoduleList;

rootFrame->setContent(warning);
} else {
rootFrame->setContent(sysmoduleList);
}

rootFrame->addElement(sysmoduleList);

return rootFrame;
}
Expand All @@ -100,31 +104,31 @@ class GuiMain : public tsl::Gui {
}

private:
std::map<u64, tsl::element::ToggleListItem*> m_sysmoduleListItems;
std::map<u64, tsl::elm::ToggleListItem*> m_sysmoduleListItems;

};


class TemplateOverlay : public tsl::Overlay {
class OverlaySysmodules : public tsl::Overlay {
public:
TemplateOverlay() { }
~TemplateOverlay() { }
OverlaySysmodules() { }
~OverlaySysmodules() { }

tsl::Gui* onSetup() {
smInitialize();
void initServices() override {
pmshellInitialize();
smExit();

return new GuiMain();
}

void onDestroy() {
void exitServices() override {
pmshellExit();
}

std::unique_ptr<tsl::Gui> loadInitialGui() override {
return initially<GuiMain>();
}

};


tsl::Overlay *overlayLoad() {
return new TemplateOverlay();
int main(int argc, char **argv) {
return tsl::loop<OverlaySysmodules>(argc, argv);
}

0 comments on commit 193fc25

Please sign in to comment.