1
0
Fork 0
mirror of https://github.com/DarkMatterCore/nxdumptool.git synced 2024-11-22 18:26:39 +00:00

Display a CrashFrame warning at startup if the application is running under applet mode.

Other changes include:

* defines: added NON_MOVEABLE macro.
* AsyncTask: set class as non-moveable, too.
* RootView: provide an override for getDefaultFocus().
* StatusInfoTask: replace GetStatusInfoData with IsInternetConnectionAvailable().
This commit is contained in:
Pablo Curiel 2021-07-30 17:07:26 -04:00
parent bc842d8905
commit 962cf00ba9
10 changed files with 36 additions and 13 deletions

View file

@ -97,8 +97,9 @@ namespace nxdt::tasks
} }
protected: protected:
/* Set class as non-copyable. */ /* Set class as non-copyable and non-moveable. */
NON_COPYABLE(AsyncTask); NON_COPYABLE(AsyncTask);
NON_MOVEABLE(AsyncTask);
virtual ~AsyncTask(void) noexcept virtual ~AsyncTask(void) noexcept
{ {

View file

@ -47,6 +47,10 @@
cls(const cls&) = delete; \ cls(const cls&) = delete; \
cls& operator=(const cls&) = delete cls& operator=(const cls&) = delete
#define NON_MOVEABLE(cls) \
cls(cls&&) = delete; \
cls& operator=(cls&&) = delete
#define ALWAYS_INLINE inline __attribute__((always_inline)) #define ALWAYS_INLINE inline __attribute__((always_inline))
#define ALWAYS_INLINE_LAMBDA __attribute__((always_inline)) #define ALWAYS_INLINE_LAMBDA __attribute__((always_inline))

View file

@ -51,6 +51,7 @@ namespace nxdt::views
protected: protected:
void draw(NVGcontext* vg, int x, int y, unsigned width, unsigned height, brls::Style* style, brls::FrameContext* ctx) override; 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 layout(NVGcontext* vg, brls::Style* style, brls::FontStash* stash) override;
brls::View *getDefaultFocus(void) override;
public: public:
RootView(void); RootView(void);

View file

@ -72,7 +72,7 @@ namespace nxdt::tasks
StatusInfoTask(void); StatusInfoTask(void);
~StatusInfoTask(void); ~StatusInfoTask(void);
const StatusInfoData* GetStatusInfoData(void); bool IsInternetConnectionAvailable(void);
ALWAYS_INLINE StatusInfoEvent::Subscription RegisterListener(StatusInfoEvent::Callback cb) ALWAYS_INLINE StatusInfoEvent::Subscription RegisterListener(StatusInfoEvent::Callback cb)
{ {

@ -1 +1 @@
Subproject commit 1e2134a2ef140a7bca3fb799aba294dda1db1075 Subproject commit cf58d0115c358faa39c71867c6e49f0aa5756e59

View file

@ -1,3 +1,5 @@
{ {
"unknown": "Unknown" "unknown": "Unknown",
"applet_mode_warning": "\uE8B2 Warning: the application is running under Applet Mode! \uE8B2\nThis mode severely limits the amount of usable RAM. If you consistently reproduce any crashes, please consider running the application via title override (hold R while launching a game)."
} }

View file

@ -23,6 +23,8 @@
#include <scope_guard.hpp> #include <scope_guard.hpp>
#include <root_view.hpp> #include <root_view.hpp>
using namespace brls::i18n::literals; /* For _i18n. */
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
/* Set scope guard to clean up resources at exit. */ /* Set scope guard to clean up resources at exit. */
@ -40,11 +42,18 @@ int main(int argc, char *argv[])
/* Initialize Borealis. */ /* Initialize Borealis. */
if (!brls::Application::init(APP_TITLE)) return EXIT_FAILURE; if (!brls::Application::init(APP_TITLE)) return EXIT_FAILURE;
/* Create root view. */ /* Check if we're running under applet mode. */
nxdt::views::RootView *root_view = new nxdt::views::RootView(); if (utilsAppletModeCheck())
{
/* Add the root view to the stack. */ /* Push crash frame with the applet mode warning. */
brls::Application::pushView(root_view); brls::Application::pushView(new brls::CrashFrame("generic/applet_mode_warning"_i18n, [](brls::View *view) {
/* Swap crash frame with root view whenever the crash frame button is clicked. */
brls::Application::swapView(new nxdt::views::RootView());
}));
} else {
/* Push root view. */
brls::Application::pushView(new nxdt::views::RootView());
}
/* Run the application. */ /* Run the application. */
while(brls::Application::mainLoop()); while(brls::Application::mainLoop());

View file

@ -241,13 +241,14 @@ namespace nxdt::views
brls::ListItem *update_nswdb_xml = new brls::ListItem("options_tab/update_nswdb_xml/label"_i18n, "options_tab/update_nswdb_xml/description"_i18n); brls::ListItem *update_nswdb_xml = new brls::ListItem("options_tab/update_nswdb_xml/label"_i18n, "options_tab/update_nswdb_xml/description"_i18n);
update_nswdb_xml->getClickEvent()->subscribe([this](brls::View* view) { update_nswdb_xml->getClickEvent()->subscribe([this](brls::View* view) {
if (!this->status_info_task->GetStatusInfoData()->ip_addr) if (!this->status_info_task->IsInternetConnectionAvailable())
{ {
/* Display a notification if no Internet connection is available. */ /* Display a notification if no Internet connection is available. */
this->DisplayNotification("options_tab/notifications/no_internet_connection"_i18n); this->DisplayNotification("options_tab/notifications/no_internet_connection"_i18n);
return; return;
} }
/* Open update dialog. */
OptionsTabUpdateFileDialog *dialog = new OptionsTabUpdateFileDialog(NSWDB_XML_PATH, NSWDB_XML_URL, false, "options_tab/notifications/nswdb_xml_updated"_i18n); OptionsTabUpdateFileDialog *dialog = new OptionsTabUpdateFileDialog(NSWDB_XML_PATH, NSWDB_XML_URL, false, "options_tab/notifications/nswdb_xml_updated"_i18n);
dialog->open(false); dialog->open(false);
}); });
@ -264,7 +265,7 @@ namespace nxdt::views
this->DisplayNotification("options_tab/notifications/is_nso"_i18n); this->DisplayNotification("options_tab/notifications/is_nso"_i18n);
return; return;
} else } else
if (!this->status_info_task->GetStatusInfoData()->ip_addr) if (!this->status_info_task->IsInternetConnectionAvailable())
{ {
/* Display a notification if no Internet connection is available. */ /* Display a notification if no Internet connection is available. */
this->DisplayNotification("options_tab/notifications/no_internet_connection"_i18n); this->DisplayNotification("options_tab/notifications/no_internet_connection"_i18n);

View file

@ -266,4 +266,9 @@ namespace nxdt::views
this->usb_icon->setBoundaries(x_pos, y_pos, 0, 0); this->usb_icon->setBoundaries(x_pos, y_pos, 0, 0);
this->usb_icon->invalidate(); this->usb_icon->invalidate();
} }
brls::View* RootView::getDefaultFocus(void)
{
return this->sidebar->getChild(0);
}
} }

View file

@ -42,9 +42,9 @@ namespace nxdt::tasks
brls::Logger::debug("Status info task stopped."); brls::Logger::debug("Status info task stopped.");
} }
const StatusInfoData* StatusInfoTask::GetStatusInfoData(void) bool StatusInfoTask::IsInternetConnectionAvailable(void)
{ {
return &(this->status_info_data); return (this->status_info_data.ip_addr != NULL);
} }
void StatusInfoTask::run(retro_time_t current_time) void StatusInfoTask::run(retro_time_t current_time)