Skip to content

Commit

Permalink
Important code improvements, web browser menu and bookmarks
Browse files Browse the repository at this point in the history
  • Loading branch information
XorTroll committed Dec 17, 2019
1 parent 26bfc20 commit fdc9fe9
Show file tree
Hide file tree
Showing 33 changed files with 819 additions and 811 deletions.
10 changes: 4 additions & 6 deletions 0.8-temp-changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@

- Now rebooting will reboot to RCM/payload, same way as if you rebooted from HOME menu's power menu.

- The web browser system was improved, adding now a custom menu, and the possibility to save a page as a bookmark after having browsed it.

## Quark / USB

- Quark's target version was changed to Java 9 or higher, since trying to support Java 8 too made it complicated to get it working.
Expand All @@ -32,16 +34,12 @@

- Goldleaf also sets it's version as the serial number descriptor, so Quark can use it. Development builds have "-dev" after the version ("0.8.0-dev", for instance), which will make Quark warn about its possible unstability.

- Quark now displays the time anything was logged in the log box. That way, one can easily identify if USB connection is still working, for instance, with installs or long file copying.

## (Planned features)

- Integrated emuiibo 0.4.0 (next version) support

- Web browser bookmark system (skeleton code is already there)

- More internal code improvements

- Something else? (open to suggestions, will look into issues for ideas)

- Try to improve both filesystem and error system (the first one to use more the second one), since currently both are kinda poorly implemented

- Write proper documentation and FAQ, specially about Quark/USB
4 changes: 4 additions & 0 deletions Goldleaf/Include/Types.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ enum class Storage

enum class Language
{
Invalid,
English,
Spanish,
German,
Expand All @@ -97,6 +98,9 @@ enum class Language
Dutch,
};

std::string LanguageToString(Language lang);
Language StringToLanguage(std::string str);

struct ColorScheme
{
pu::ui::Color Background;
Expand Down
31 changes: 16 additions & 15 deletions Goldleaf/Include/set/set_Settings.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,31 +26,32 @@ namespace set
{
struct WebBookmark
{
std::string Name;
std::string URL;
std::string name;
std::string url;
};

#define SET_OPTIONAL_VALUE(type, name) \
type name; \
bool has_##name;

struct Settings
{
Language CustomLanguage;
std::string KeysPath;
std::string ExternalRomFs;
ColorScheme CustomScheme;
u32 MenuItemSize;
bool HasScrollBar;
pu::ui::Color ScrollBarColor;
bool HasProgressBar;
pu::ui::Color ProgressBarColor;
bool IgnoreRequiredFirmwareVersion;
std::vector<WebBookmark> Bookmarks;
SET_OPTIONAL_VALUE(Language, custom_lang)
SET_OPTIONAL_VALUE(std::string, external_romfs)
SET_OPTIONAL_VALUE(pu::ui::Color, scrollbar_color)
SET_OPTIONAL_VALUE(pu::ui::Color, progressbar_color)
SET_OPTIONAL_VALUE(ColorScheme, custom_scheme)
SET_OPTIONAL_VALUE(u32, menu_item_size)

bool ignore_required_fw_ver;
std::vector<WebBookmark> bookmarks;

void Save();
std::string PathForResource(std::string Path);
void ApplyScrollBarColor(pu::ui::elm::Menu::Ref &Menu);
void ApplyProgressBarColor(pu::ui::elm::ProgressBar::Ref &PBar);
};

static const std::string SettingsFile = "sdmc:/" + consts::Root + "/settings.json";

Settings ProcessSettings();
bool Exists();
}
5 changes: 5 additions & 0 deletions Goldleaf/Include/ui/ui_MainApplication.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
#include <ui/ui_UnusedTicketsLayout.hpp>
#include <ui/ui_TitleDumperLayout.hpp>
#include <ui/ui_UpdateLayout.hpp>
#include <ui/ui_WebBrowserLayout.hpp>

#include <ui/ui_ClickableImage.hpp>

Expand Down Expand Up @@ -68,6 +69,7 @@ namespace ui
void amiibo_Input(u64 down, u64 up, u64 held);
void settings_Input(u64 down, u64 up, u64 held);
void memory_Input(u64 down, u64 up, u64 held);
void webBrowser_Input(u64 down, u64 up, u64 held);
void about_Input(u64 down, u64 up, u64 held);
void userImage_OnClick();
void helpImage_OnClick();
Expand All @@ -90,7 +92,9 @@ namespace ui
SettingsLayout::Ref &GetSettingsLayout();
MemoryLayout::Ref &GetMemoryLayout();
UpdateLayout::Ref &GetUpdateLayout();
WebBrowserLayout::Ref &GetWebBrowserLayout();
AboutLayout::Ref &GetAboutLayout();

private:
u32 preblv;
bool preisch;
Expand All @@ -116,6 +120,7 @@ namespace ui
SettingsLayout::Ref settings;
MemoryLayout::Ref memory;
UpdateLayout::Ref update;
WebBrowserLayout::Ref webBrowser;
AboutLayout::Ref about;
pu::ui::elm::Image::Ref baseImage;
pu::ui::elm::TextBlock::Ref timeText;
Expand Down
4 changes: 2 additions & 2 deletions Goldleaf/Include/ui/ui_PartitionBrowserLayout.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ namespace ui
void HandleFileDirectly(String Path);
bool GoBack();
bool WarnNANDWriteAccess();
void fsItems_Click();
void fsItems_Click_Y();
void fsItems_Click(String item);
void fsItems_Click_Y(String item);
fs::Explorer *GetExplorer();
private:
fs::Explorer *gexp;
Expand Down
2 changes: 1 addition & 1 deletion Goldleaf/Include/ui/ui_UnusedTicketsLayout.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ namespace ui
PU_SMART_CTOR(UnusedTicketsLayout)

void UpdateElements(bool Cooldown);
void tickets_Click();
void tickets_Click(hos::Ticket ticket);
private:
std::vector<hos::Ticket> tickets;
pu::ui::elm::TextBlock::Ref notTicketsText;
Expand Down
40 changes: 40 additions & 0 deletions Goldleaf/Include/ui/ui_WebBrowserLayout.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@

/*
Goldleaf - Multipurpose homebrew tool for Nintendo Switch
Copyright (C) 2018-2019 XorTroll
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 <https://www.gnu.org/licenses/>.
*/

#pragma once
#include <ui/ui_Includes.hpp>
#include <pu/Plutonium>

namespace ui
{
class WebBrowserLayout : public pu::ui::Layout
{
public:
WebBrowserLayout();
PU_SMART_CTOR(WebBrowserLayout)

void Refresh();
void input_Click();
void bookmark_Click(set::WebBookmark bmk);
private:
pu::ui::elm::Menu::Ref optionsMenu;
};
}
10 changes: 5 additions & 5 deletions Goldleaf/Source/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@

#include <ui/ui_MainApplication.hpp>

ui::MainApplication::Ref mainapp;
set::Settings gsets;
ui::MainApplication::Ref global_app;
set::Settings global_settings;
bool gupdated = false;

int main()
Expand All @@ -31,10 +31,10 @@ int main()
if(R_FAILED(rc)) fatalThrow(rc);

auto renderer = pu::ui::render::Renderer::New(SDL_INIT_EVERYTHING, pu::ui::render::RendererInitOptions::RendererNoSound, pu::ui::render::RendererHardwareFlags);
mainapp = ui::MainApplication::New(renderer);
global_app = ui::MainApplication::New(renderer);

mainapp->Prepare();
mainapp->ShowWithFadeIn();
global_app->Prepare();
global_app->ShowWithFadeIn();

Exit();
return 0;
Expand Down
35 changes: 35 additions & 0 deletions Goldleaf/Source/Types.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,41 @@ namespace consts
std::string TempUpdatePath = Root + "/UpdateTemp.nro";
}

std::string LanguageToString(Language lang)
{
std::string langstr;
switch(lang)
{
case Language::English:
return "en";
case Language::Spanish:
return "es";
case Language::German:
return "de";
case Language::French:
return "fr";
case Language::Invalid:
return "it";
case Language::Dutch:
return "nl";
default:
break;
}
return langstr;
}

Language StringToLanguage(std::string str)
{
auto lang = Language::Invalid;
if(str == "en") lang = Language::English;
else if(str == "es") lang = Language::Spanish;
else if(str == "de") lang = Language::German;
else if(str == "fr") lang = Language::French;
else if(str == "it") lang = Language::Italian;
else if(str == "nl") lang = Language::Dutch;
return lang;
}

String Version::AsString()
{
String txt = std::to_string(this->Major) + "." + std::to_string(this->Minor);
Expand Down
4 changes: 2 additions & 2 deletions Goldleaf/Source/nsp/nsp_Installer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
#include <dirent.h>
#include <chrono>

extern set::Settings gsets;
extern set::Settings global_settings;

namespace nsp
{
Expand Down Expand Up @@ -141,7 +141,7 @@ namespace nsp
ncmContentStorageHas(&cst, &hascnmt, &record.ContentId);
serviceClose(&cst.s);
if(!hascnmt) ncas.push_back(record);
cnmt.GetInstallContentMeta(ccnmt, record, gsets.IgnoreRequiredFirmwareVersion);
cnmt.GetInstallContentMeta(ccnmt, record, global_settings.ignore_required_fw_ver);
baseappid = hos::GetBaseApplicationId(mrec.id, static_cast<ncm::ContentMetaType>(mrec.type));
auto recs = cnmt.GetContentRecords();
memset(&entrynacp, 0, sizeof(entrynacp));
Expand Down
Loading

0 comments on commit fdc9fe9

Please sign in to comment.