diff --git a/include/custom_layout_tab.hpp b/include/custom_layout_tab.hpp deleted file mode 100644 index da3e48b..0000000 --- a/include/custom_layout_tab.hpp +++ /dev/null @@ -1,36 +0,0 @@ -/* - Borealis, a Nintendo Switch UI Library - Copyright (C) 2020 natinusala - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#include - -class CustomLayoutTab : public brls::AbsoluteLayout -{ - public: - CustomLayoutTab(); - - brls::View* getDefaultFocus() override; - brls::View* getNextFocus(brls::FocusDirection direction, brls::View* currentView) override; - void layout(NVGcontext* vg, brls::Style* style, brls::FontStash* stash); - - private: - brls::NavigationMap navigationMap; - - brls::Button* firstButton; - brls::Button* secondButton; - brls::Button* thirdButton; -}; diff --git a/include/root_view.hpp b/include/root_view.hpp new file mode 100644 index 0000000..309fd5f --- /dev/null +++ b/include/root_view.hpp @@ -0,0 +1,37 @@ +/* + * root_view.hpp + * + * Copyright (c) 2020-2021, DarkMatterCore . + * + * This file is part of nxdumptool (https://github.com/DarkMatterCore/nxdumptool). + * + * nxdumptool is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * nxdumptool is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include + +namespace nxdt::views +{ + class RootView: public brls::TabFrame + { + private: + nxdt::tasks::GameCardTask *gc_status_task = nullptr; + nxdt::tasks::TitleTask *title_task = nullptr; + nxdt::tasks::UmsTask *ums_task = nullptr; + nxdt::tasks::UsbHostTask *usb_host_task = nullptr; + + public: + RootView(void); + }; +} diff --git a/include/sample_installer_page.hpp b/include/sample_installer_page.hpp deleted file mode 100644 index 753f402..0000000 --- a/include/sample_installer_page.hpp +++ /dev/null @@ -1,38 +0,0 @@ -/* - Borealis, a Nintendo Switch UI Library - Copyright (C) 2019 natinusala - Copyright (C) 2019 Billy Laws - Copyright (C) 2019 p-sam - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#pragma once - -#include - -class SampleInstallerPage : public brls::View -{ - private: - brls::Button* button; - brls::Label* label; - - public: - SampleInstallerPage(brls::StagedAppletFrame* frame, std::string label); - ~SampleInstallerPage(); - - void draw(NVGcontext* vg, int x, int y, unsigned width, unsigned height, brls::Style* style, brls::FrameContext* ctx) override; - void layout(NVGcontext* vg, brls::Style* style, brls::FontStash* stash) override; - brls::View* getDefaultFocus() override; -}; diff --git a/include/sample_loading_page.hpp b/include/sample_loading_page.hpp deleted file mode 100644 index 035e049..0000000 --- a/include/sample_loading_page.hpp +++ /dev/null @@ -1,42 +0,0 @@ -/* - Borealis, a Nintendo Switch UI Library - Copyright (C) 2019 natinusala - Copyright (C) 2019 Billy Laws - Copyright (C) 2019 p-sam - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#pragma once - -#include - -class SampleLoadingPage : public brls::View -{ - private: - brls::StagedAppletFrame* frame; - brls::ProgressDisplay* progressDisp; - brls::Label* label; - int progressValue = 0; - - public: - SampleLoadingPage(brls::StagedAppletFrame* frame); - ~SampleLoadingPage(); - - void draw(NVGcontext* vg, int x, int y, unsigned width, unsigned height, brls::Style* style, brls::FrameContext* ctx) override; - void layout(NVGcontext* vg, brls::Style* style, brls::FontStash* stash) override; - - void willAppear(bool resetState = false) override; - void willDisappear(bool resetState = false) override; -}; diff --git a/include/tasks.hpp b/include/tasks.hpp index b8243a7..4c02236 100644 --- a/include/tasks.hpp +++ b/include/tasks.hpp @@ -52,13 +52,22 @@ namespace nxdt::tasks GameCardStatus cur_gc_status = GameCardStatus_NotInserted; GameCardStatus prev_gc_status = GameCardStatus_NotInserted; + public: GameCardTask(void); ~GameCardTask(void); void run(retro_time_t current_time) override; - GameCardStatusEvent* GetTaskEvent(void); + ALWAYS_INLINE GameCardStatusEvent::Subscription RegisterListener(GameCardStatusEvent::Callback cb) + { + return this->gc_status_event.subscribe(cb); + } + + ALWAYS_INLINE void UnregisterListener(GameCardStatusEvent::Subscription subscription) + { + this->gc_status_event.unsubscribe(subscription); + } }; /* Title task. */ @@ -71,15 +80,24 @@ namespace nxdt::tasks TitleApplicationMetadataVector user_metadata; void PopulateApplicationMetadataVector(bool is_system); + public: TitleTask(void); ~TitleTask(void); void run(retro_time_t current_time) override; - VoidEvent* GetTaskEvent(void); - TitleApplicationMetadataVector* GetApplicationMetadata(bool is_system); + + ALWAYS_INLINE VoidEvent::Subscription RegisterListener(VoidEvent::Callback cb) + { + return this->title_event.subscribe(cb); + } + + ALWAYS_INLINE void UnregisterListener(VoidEvent::Subscription subscription) + { + this->title_event.unsubscribe(subscription); + } }; /* USB Mass Storage task. */ @@ -97,9 +115,17 @@ namespace nxdt::tasks void run(retro_time_t current_time) override; - VoidEvent* GetTaskEvent(void); - UmsDeviceVector* GetUmsDevices(void); + + ALWAYS_INLINE VoidEvent::Subscription RegisterListener(VoidEvent::Callback cb) + { + return this->ums_event.subscribe(cb); + } + + ALWAYS_INLINE void UnregisterListener(VoidEvent::Subscription subscription) + { + this->ums_event.unsubscribe(subscription); + } }; /* USB host device connection task. */ @@ -116,14 +142,16 @@ namespace nxdt::tasks void run(retro_time_t current_time) override; - BooleanEvent* GetTaskEvent(void); + ALWAYS_INLINE BooleanEvent::Subscription RegisterListener(BooleanEvent::Callback cb) + { + return this->usb_host_event.subscribe(cb); + } + + ALWAYS_INLINE void UnregisterListener(BooleanEvent::Subscription subscription) + { + this->usb_host_event.unsubscribe(subscription); + } }; } -/* Declared in main.cpp. */ -extern nxdt::tasks::GameCardTask *g_gamecardTask; -extern nxdt::tasks::TitleTask *g_titleTask; -extern nxdt::tasks::UmsTask *g_umsTask; -extern nxdt::tasks::UsbHostTask *g_usbHostTask; - #endif /* __TASKS_HPP__ */ diff --git a/romfs/i18n/en-US/custom_layout.json b/romfs/i18n/en-US/custom_layout.json deleted file mode 100644 index 86a6ba3..0000000 --- a/romfs/i18n/en-US/custom_layout.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "first_button": "First button", - "second_button": "Second button", - "third_button": "Third button" -} diff --git a/romfs/i18n/en-US/installer.json b/romfs/i18n/en-US/installer.json deleted file mode 100644 index 1fa8482..0000000 --- a/romfs/i18n/en-US/installer.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "open": "Open example installer", - - "title": "My great installer", - - "stage1": { - "text": "Here, you would normally do useful things", - "button": "Go to step 2" - }, - - "stage2": { - "text": "Example loading display" - }, - - "stage3": { - "button": "Finish" - } -} diff --git a/romfs/i18n/en-US/main.json b/romfs/i18n/en-US/main.json deleted file mode 100644 index 5eb224d..0000000 --- a/romfs/i18n/en-US/main.json +++ /dev/null @@ -1,76 +0,0 @@ -{ - "tabs": { - "first": "First tab", - "second": "Second tab", - "third": "Third tab", - "fourth": "Fourth tab", - "custom_navigation_tab": "Custom Layout" - }, - - "pozznx": { - "open": "Open a dialog", - "warning": "Warning: PozzNX will wipe all data on your Switch and render it inoperable, do you want to proceed?", - "running": "Running PozzNX...", - "continue": "Continue" - }, - - "notify": "Post a random notification", - - "tv": { - "resolution": "TV Resolution", - "automatic": "Automatic" - }, - - "i18n": { - "title": "Language: {0} ({1})", - "lang": "English" - }, - - "jank": { - "jank": "User Interface Jankiness", - "native": "Native", - "minimal": "Minimal", - "regular": "Regular", - "maximum": "Maximum", - "saxophone": "SX OS", - "vista": "Windows Vista", - "ios": "iOS 14" - }, - - "divide": { - "title": "Divide by 0", - "description": "Can the Switch do it?", - "crash": "The software was closed because an error occured:\nSIGABRT (signal 6)" - }, - - "more": "For more information about how to use Nintendo Switch and its features, please refer to the Nintendo Support Website on your smart device or PC.", - - "actions": { - "title": "Custom Actions", - "notify": "Show notification", - "triggered": "Custom Action triggered" - }, - - "layers": { - "title": "Select Layer", - "layer1": "Layer 1", - "layer2": "Layer 2", - - "item1": "Item 1", - "item2": "Item 2", - "item3": "Item 3" - }, - - "keyboard": { - "string": { - "title": "Open Keyboard", - "default": "Default text", - "help": "Help message" - }, - "number": { - "title": "Open Num Keyboard", - "help": "Help message" - } - } -} - diff --git a/romfs/i18n/en-US/popup.json b/romfs/i18n/en-US/popup.json deleted file mode 100644 index e1c0084..0000000 --- a/romfs/i18n/en-US/popup.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "open": "Open popup", - - "red": "Red", - "green": "Green", - "blue": "Blue", - - "title": "Popup title", - "subtitle": { - "left": "Subtitle left", - "right": "Subtitle right" - } -} diff --git a/romfs/i18n/en-US/root_view.json b/romfs/i18n/en-US/root_view.json new file mode 100644 index 0000000..2c3b0a1 --- /dev/null +++ b/romfs/i18n/en-US/root_view.json @@ -0,0 +1,9 @@ +{ + "tabs": { + "gamecard": "Gamecard", + "user_titles": "User titles", + "system_titles": "System titles", + "options": "Options", + "about": "About" + } +} diff --git a/source/custom_layout_tab.cpp b/source/custom_layout_tab.cpp deleted file mode 100644 index 6feb557..0000000 --- a/source/custom_layout_tab.cpp +++ /dev/null @@ -1,97 +0,0 @@ -/* - Borealis, a Nintendo Switch UI Library - Copyright (C) 2020 natinusala - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#include "custom_layout_tab.hpp" - -using namespace brls::i18n::literals; - -CustomLayoutTab::CustomLayoutTab() -{ - // Create views - this->firstButton = new brls::Button(brls::ButtonStyle::REGULAR); - this->firstButton->setLabel("custom_layout/first_button"_i18n); - this->addView(this->firstButton); - - this->secondButton = new brls::Button(brls::ButtonStyle::REGULAR); - this->secondButton->setLabel("custom_layout/second_button"_i18n); - this->addView(this->secondButton); - - this->thirdButton = new brls::Button(brls::ButtonStyle::REGULAR); - this->thirdButton->setLabel("custom_layout/third_button"_i18n); - this->addView(this->thirdButton); - - // Populate custom navigation map - this->navigationMap.add( - this->firstButton, - brls::FocusDirection::RIGHT, - this->secondButton); - - this->navigationMap.add( - this->secondButton, - brls::FocusDirection::LEFT, - this->firstButton); - - this->navigationMap.add( - this->secondButton, - brls::FocusDirection::DOWN, - this->thirdButton); - - this->navigationMap.add( - this->thirdButton, - brls::FocusDirection::UP, - this->secondButton); -} - -#define BUTTON_WIDTH 300 -#define BUTTON_HEIGHT 50 -#define PADDING 75 - -void CustomLayoutTab::layout(NVGcontext* vg, brls::Style* style, brls::FontStash* stash) -{ - int x = this->getX(); - int y = this->getY(); - - // Fully custom layout - this->firstButton->setBoundaries( - x + PADDING, - y + PADDING, - BUTTON_WIDTH, - BUTTON_HEIGHT); - - this->secondButton->setBoundaries( - x + PADDING * 2 + BUTTON_WIDTH, - y + PADDING, - BUTTON_WIDTH, - BUTTON_HEIGHT); - - this->thirdButton->setBoundaries( - x + PADDING * 2 + BUTTON_WIDTH, - y + PADDING * 2 + BUTTON_HEIGHT, - BUTTON_WIDTH, - BUTTON_HEIGHT); -} - -brls::View* CustomLayoutTab::getDefaultFocus() -{ - return this->firstButton->getDefaultFocus(); -} - -brls::View* CustomLayoutTab::getNextFocus(brls::FocusDirection direction, brls::View* currentView) -{ - return this->navigationMap.getNextFocus(direction, currentView); -} diff --git a/source/main.cpp b/source/main.cpp index ba0fb9c..b6e0f0d 100644 --- a/source/main.cpp +++ b/source/main.cpp @@ -1,51 +1,31 @@ /* - Borealis, a Nintendo Switch UI Library - Copyright (C) 2019-2020 natinusala - Copyright (C) 2019 p-sam - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ + * main.cpp + * + * Copyright (c) 2020-2021, DarkMatterCore . + * + * This file is part of nxdumptool (https://github.com/DarkMatterCore/nxdumptool). + * + * nxdumptool is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * nxdumptool is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ #include -#include #include - -#include "custom_layout_tab.hpp" -#include "sample_installer_page.hpp" -#include "sample_loading_page.hpp" - -namespace i18n = brls::i18n; // for loadTranslations() and getStr() -using namespace i18n::literals; // for _i18n - -std::vector NOTIFICATIONS = { - "You have cool hair", - "I like your shoes", - "borealis is powered by nanovg", - "The Triforce is an inside job", - "Pozznx will trigger in one day and twelve hours", - "Aurora Borealis? At this time of day, at this time of year, in this part of the gaming market, located entirely within your Switch?!", - "May I see it?", - "Hmm, Steamed Hams!" -}; - -nxdt::tasks::GameCardTask *g_gamecardTask = nullptr; -nxdt::tasks::TitleTask *g_titleTask = nullptr; -nxdt::tasks::UmsTask *g_umsTask = nullptr; -nxdt::tasks::UsbHostTask *g_usbHostTask = nullptr; +#include int main(int argc, char *argv[]) { + /* Set scope guard to clean up resources at exit. */ ON_SCOPE_EXIT { utilsCloseResources(); }; /* Initialize application resources. */ @@ -55,162 +35,20 @@ int main(int argc, char *argv[]) brls::Logger::setLogLevel(brls::LogLevel::DEBUG); /* Load Borealis translation files. */ - i18n::loadTranslations(); + brls::i18n::loadTranslations(); /* Initialize Borealis. */ if (!brls::Application::init(APP_TITLE)) return EXIT_FAILURE; - /* Start background tasks. */ - g_gamecardTask = new nxdt::tasks::GameCardTask(); - g_titleTask = new nxdt::tasks::TitleTask(); - g_umsTask = new nxdt::tasks::UmsTask(); - g_usbHostTask = new nxdt::tasks::UsbHostTask(); + /* Create root view. */ + nxdt::views::RootView *root_view = new nxdt::views::RootView(); - /* Create root tab frame. */ - brls::TabFrame *root_frame = new brls::TabFrame(); - root_frame->setTitle(APP_TITLE); - root_frame->setIcon(BOREALIS_ASSET("icon/" APP_TITLE ".jpg")); - root_frame->setFooterText("v" APP_VERSION); - - - - - - - - brls::List *testList = new brls::List(); - - brls::ListItem* dialogItem = new brls::ListItem("main/pozznx/open"_i18n); - dialogItem->getClickEvent()->subscribe([](brls::View* view) { - brls::Dialog* dialog = new brls::Dialog("main/pozznx/warning"_i18n); - - brls::GenericEvent::Callback closeCallback = [dialog](brls::View* view) { - dialog->close(); - brls::Application::notify("main/pozznx/running"_i18n); - }; - - std::string continueStr = "main/pozznx/continue"_i18n; - - dialog->addButton(continueStr, closeCallback); - dialog->addButton(continueStr, closeCallback); - dialog->addButton(continueStr, closeCallback); - - dialog->setCancelable(false); - - dialog->open(); - }); - - brls::ListItem* notificationItem = new brls::ListItem("main/notify"_i18n); - notificationItem->getClickEvent()->subscribe([](brls::View* view) { - std::string notification = NOTIFICATIONS[std::rand() % NOTIFICATIONS.size()]; - brls::Application::notify(notification); - }); - - brls::ListItem* themeItem = new brls::ListItem("main/tv/resolution"_i18n); - themeItem->setValue("main/tv/automatic"_i18n); - - brls::ListItem* i18nItem = new brls::ListItem(i18n::getStr("main/i18n/title", i18n::getCurrentLocale(), "main/i18n/lang"_i18n)); - - brls::SelectListItem* jankItem = new brls::SelectListItem( - "main/jank/jank"_i18n, - { - "main/jank/native"_i18n, - "main/jank/minimal"_i18n, - "main/jank/regular"_i18n, - "main/jank/maximum"_i18n, - "main/jank/saxophone"_i18n, - "main/jank/vista"_i18n, - "main/jank/ios"_i18n, - }); - - brls::ListItem* crashItem = new brls::ListItem("main/divide/title"_i18n, "main/divide/description"_i18n); - crashItem->getClickEvent()->subscribe([](brls::View* view) { brls::Application::crash("main/divide/crash"_i18n); }); - - brls::ListItem* installerItem = new brls::ListItem("installer/open"_i18n); - installerItem->getClickEvent()->subscribe([](brls::View* view) { - brls::StagedAppletFrame* stagedFrame = new brls::StagedAppletFrame(); - stagedFrame->setTitle("installer/title"_i18n); - - stagedFrame->addStage(new SampleInstallerPage(stagedFrame, "installer/stage1/button"_i18n)); - stagedFrame->addStage(new SampleLoadingPage(stagedFrame)); - stagedFrame->addStage(new SampleInstallerPage(stagedFrame, "installer/stage3/button"_i18n)); - - brls::Application::pushView(stagedFrame); - }); - - brls::ListItem* popupItem = new brls::ListItem("popup/open"_i18n); - popupItem->getClickEvent()->subscribe([](brls::View* view) { - brls::TabFrame* popupTabFrame = new brls::TabFrame(); - popupTabFrame->addTab("popup/red"_i18n, new brls::Rectangle(nvgRGB(255, 0, 0))); - popupTabFrame->addTab("popup/green"_i18n, new brls::Rectangle(nvgRGB(0, 255, 0))); - popupTabFrame->addTab("popup/blue"_i18n, new brls::Rectangle(nvgRGB(0, 0, 255))); - brls::PopupFrame::open("popup/title"_i18n, BOREALIS_ASSET("icon/" APP_TITLE ".jpg"), popupTabFrame, "popup/subtitle/left"_i18n, "popup/subtitle/right"_i18n); - }); - - brls::SelectListItem* layerSelectItem = new brls::SelectListItem("main/layers/title"_i18n, { "main/layers/layer1"_i18n, "main/layers/layer2"_i18n }); - - brls::InputListItem* keyboardItem = new brls::InputListItem("main/keyboard/string/title"_i18n, "main/keyboard/string/default"_i18n, "main/keyboard/string/help"_i18n, "", 16); - - brls::IntegerInputListItem* keyboardNumberItem = new brls::IntegerInputListItem("main/keyboard/number/title"_i18n, 1337, "main/keyboard/number/help"_i18n, "", 10); - - testList->addView(dialogItem); - testList->addView(notificationItem); - testList->addView(themeItem); - testList->addView(i18nItem); - testList->addView(jankItem); - testList->addView(crashItem); - testList->addView(installerItem); - testList->addView(popupItem); - testList->addView(keyboardItem); - testList->addView(keyboardNumberItem); - - brls::Label* testLabel = new brls::Label(brls::LabelStyle::REGULAR, "main/more"_i18n, true); - testList->addView(testLabel); - - brls::ListItem* actionTestItem = new brls::ListItem("main/actions/title"_i18n); - actionTestItem->registerAction("main/actions/notify"_i18n, brls::Key::L, [] { - brls::Application::notify("main/actions/triggered"_i18n); - return true; - }); - testList->addView(actionTestItem); - - brls::LayerView* testLayers = new brls::LayerView(); - brls::List* layerList1 = new brls::List(); - brls::List* layerList2 = new brls::List(); - - layerList1->addView(new brls::Header("main/layers/layer1"_i18n, false)); - layerList1->addView(new brls::ListItem("main/layers/item1"_i18n)); - layerList1->addView(new brls::ListItem("main/layers/item2"_i18n)); - layerList1->addView(new brls::ListItem("main/layers/item3"_i18n)); - - layerList2->addView(new brls::Header("main/layers/layer2"_i18n, false)); - layerList2->addView(new brls::ListItem("main/layers/item1"_i18n)); - layerList2->addView(new brls::ListItem("main/layers/item2"_i18n)); - layerList2->addView(new brls::ListItem("main/layers/item3"_i18n)); - - testLayers->addLayer(layerList1); - testLayers->addLayer(layerList2); - - layerSelectItem->getValueSelectedEvent()->subscribe([=](size_t selection) { - testLayers->changeLayer(selection); - }); - - testList->addView(layerSelectItem); - - root_frame->addTab("main/tabs/first"_i18n, testList); - root_frame->addTab("main/tabs/second"_i18n, testLayers); - root_frame->addSeparator(); - root_frame->addTab("main/tabs/third"_i18n, new brls::Rectangle(nvgRGB(255, 0, 0))); - root_frame->addTab("main/tabs/fourth"_i18n, new brls::Rectangle(nvgRGB(0, 255, 0))); - root_frame->addSeparator(); - root_frame->addTab("main/tabs/custom_navigation_tab"_i18n, new CustomLayoutTab()); - - // Add the root view to the stack - brls::Application::pushView(root_frame); - - // Run the app - while (brls::Application::mainLoop()); + /* Add the root view to the stack. */ + brls::Application::pushView(root_view); - // Exit + /* Run the application. */ + while(brls::Application::mainLoop()); + + /* Exit. */ return EXIT_SUCCESS; } diff --git a/source/root_view.cpp b/source/root_view.cpp new file mode 100644 index 0000000..4673336 --- /dev/null +++ b/source/root_view.cpp @@ -0,0 +1,54 @@ +/* + * root_view.cpp + * + * Copyright (c) 2020-2021, DarkMatterCore . + * + * This file is part of nxdumptool (https://github.com/DarkMatterCore/nxdumptool). + * + * nxdumptool is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * nxdumptool is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include +#include +//#include +//#include +//#include +//#include +//#include + +using namespace brls::i18n::literals; /* For _i18n. */ + +namespace nxdt::views +{ + RootView::RootView(void) : brls::TabFrame() + { + /* Start background tasks. */ + this->gc_status_task = new nxdt::tasks::GameCardTask(); + this->title_task = new nxdt::tasks::TitleTask(); + this->ums_task = new nxdt::tasks::UmsTask(); + this->usb_host_task = new nxdt::tasks::UsbHostTask(); + + /* Set UI properties. */ + this->setTitle(APP_TITLE); + this->setIcon(BOREALIS_ASSET("icon/" APP_TITLE ".jpg")); + this->setFooterText("v" APP_VERSION); + + /* Add tabs. */ + this->addTab("root_view/tabs/gamecard"_i18n, new brls::Rectangle(nvgRGB(255, 0, 0))); + this->addTab("root_view/tabs/user_titles"_i18n, new brls::Rectangle(nvgRGB(0, 255, 0))); + this->addTab("root_view/tabs/system_titles"_i18n, new brls::Rectangle(nvgRGB(0, 0, 255))); + this->addTab("root_view/tabs/options"_i18n, new brls::Rectangle(nvgRGB(255, 255, 0))); + this->addTab("root_view/tabs/about"_i18n, new brls::Rectangle(nvgRGB(255, 0, 255))); + } +} diff --git a/source/sample_installer_page.cpp b/source/sample_installer_page.cpp deleted file mode 100644 index 697a016..0000000 --- a/source/sample_installer_page.cpp +++ /dev/null @@ -1,77 +0,0 @@ -/* - Borealis, a Nintendo Switch UI Library - Copyright (C) 2019 natinusala - Copyright (C) 2019 Billy Laws - Copyright (C) 2019 p-sam - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#include "sample_installer_page.hpp" - -#include - -using namespace brls::i18n::literals; - -SampleInstallerPage::SampleInstallerPage(brls::StagedAppletFrame* frame, std::string label) -{ - // Label - this->button = (new brls::Button(brls::ButtonStyle::BORDERLESS))->setLabel(label)->setImage(BOREALIS_ASSET("icon/" APP_TITLE ".jpg")); - this->button->setParent(this); - this->button->getClickEvent()->subscribe([frame](View* view) { - if (frame->isLastStage()) - brls::Application::popView(); - else - frame->nextStage(); - }); - this->label = new brls::Label(brls::LabelStyle::DIALOG, "installer/stage1/text"_i18n, true); - this->label->setHorizontalAlign(NVG_ALIGN_CENTER); - this->label->setParent(this); -} - -void SampleInstallerPage::draw(NVGcontext* vg, int x, int y, unsigned width, unsigned height, brls::Style* style, brls::FrameContext* ctx) -{ - this->label->frame(ctx); - this->button->frame(ctx); -} - -brls::View* SampleInstallerPage::getDefaultFocus() -{ - return this->button; -} - -void SampleInstallerPage::layout(NVGcontext* vg, brls::Style* style, brls::FontStash* stash) -{ - this->label->setWidth(roundf((float)this->width * style->CrashFrame.labelWidth)); - this->label->invalidate(true); - - this->label->setBoundaries( - this->x + this->width / 2 - this->label->getWidth() / 2, - this->y + (this->height - style->AppletFrame.footerHeight) / 2, - this->label->getWidth(), - this->label->getHeight()); - - this->button->setBoundaries( - this->x + this->width / 2 - style->CrashFrame.buttonWidth / 2, - this->y + this->height / 2 + style->CrashFrame.buttonHeight, - style->CrashFrame.buttonWidth, - style->CrashFrame.buttonHeight); - this->button->invalidate(); -} - -SampleInstallerPage::~SampleInstallerPage() -{ - delete this->label; - delete this->button; -} diff --git a/source/sample_loading_page.cpp b/source/sample_loading_page.cpp deleted file mode 100644 index 846a5fc..0000000 --- a/source/sample_loading_page.cpp +++ /dev/null @@ -1,82 +0,0 @@ -/* - Borealis, a Nintendo Switch UI Library - Copyright (C) 2019 natinusala - Copyright (C) 2019 Billy Laws - Copyright (C) 2019 p-sam - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#include "sample_loading_page.hpp" - -#include - -using namespace brls::i18n::literals; - -SampleLoadingPage::SampleLoadingPage(brls::StagedAppletFrame* frame) - : frame(frame) -{ - // Label - this->progressDisp = new brls::ProgressDisplay(); - this->progressDisp->setProgress(this->progressValue, 1000); - this->progressDisp->setParent(this); - this->label = new brls::Label(brls::LabelStyle::DIALOG, "installer/stage2/text"_i18n, true); - this->label->setHorizontalAlign(NVG_ALIGN_CENTER); - this->label->setParent(this); -} - -void SampleLoadingPage::draw(NVGcontext* vg, int x, int y, unsigned width, unsigned height, brls::Style* style, brls::FrameContext* ctx) -{ - if (progressValue == 500) - this->frame->nextStage(); - - this->progressValue++; - this->progressDisp->setProgress(this->progressValue, 500); - this->progressDisp->frame(ctx); - this->label->frame(ctx); -} - -void SampleLoadingPage::layout(NVGcontext* vg, brls::Style* style, brls::FontStash* stash) -{ - this->label->setWidth(roundf((float)this->width * style->CrashFrame.labelWidth)); - this->label->invalidate(true); - - this->label->setBoundaries( - this->x + this->width / 2 - this->label->getWidth() / 2, - this->y + (this->height - style->AppletFrame.footerHeight) / 2, - this->label->getWidth(), - this->label->getHeight()); - - this->progressDisp->setBoundaries( - this->x + this->width / 2 - style->CrashFrame.buttonWidth, - this->y + this->height / 2, - style->CrashFrame.buttonWidth * 2, - style->CrashFrame.buttonHeight); -} - -void SampleLoadingPage::willAppear(bool resetState) -{ - this->progressDisp->willAppear(resetState); -} - -void SampleLoadingPage::willDisappear(bool resetState) -{ - this->progressDisp->willDisappear(resetState); -} - -SampleLoadingPage::~SampleLoadingPage() -{ - delete this->progressDisp; - delete this->label; -} diff --git a/source/tasks.cpp b/source/tasks.cpp index e6d1a8f..e0c193a 100644 --- a/source/tasks.cpp +++ b/source/tasks.cpp @@ -52,11 +52,6 @@ namespace nxdt::tasks } } - GameCardStatusEvent* GameCardTask::GetTaskEvent(void) - { - return &(this->gc_status_event); - } - /* Title task. */ TitleTask::TitleTask(void) : brls::RepeatingTask(NXDT_TASK_INTERVAL) @@ -118,11 +113,6 @@ namespace nxdt::tasks } } - VoidEvent* TitleTask::GetTaskEvent(void) - { - return &(this->title_event); - } - TitleApplicationMetadataVector* TitleTask::GetApplicationMetadata(bool is_system) { return (is_system ? &(this->system_metadata) : &(this->user_metadata)); @@ -180,11 +170,6 @@ namespace nxdt::tasks } } - VoidEvent* UmsTask::GetTaskEvent(void) - { - return &(this->ums_event); - } - UmsDeviceVector* UmsTask::GetUmsDevices(void) { return &(this->ums_devices); @@ -215,9 +200,4 @@ namespace nxdt::tasks brls::Logger::debug("USB host status change triggered: {}.", this->cur_usb_host_status); } } - - BooleanEvent* UsbHostTask::GetTaskEvent(void) - { - return &(this->usb_host_event); - } }