diff --git a/.gitignore b/.gitignore index 36d47d6..50211d9 100644 --- a/.gitignore +++ b/.gitignore @@ -14,5 +14,6 @@ host/nxdumptool *.log *.spec *.exe +*.dksh main.cpp /code_templates/tmp/* diff --git a/Makefile b/Makefile index d32db32..a9514d0 100644 --- a/Makefile +++ b/Makefile @@ -40,7 +40,7 @@ include $(DEVKITPRO)/libnx/switch_rules GIT_BRANCH := $(shell git rev-parse --abbrev-ref HEAD) GIT_COMMIT := $(shell git rev-parse --short HEAD) -GIT_REV := ${GIT_BRANCH}.${GIT_COMMIT} +GIT_REV := ${GIT_BRANCH}-${GIT_COMMIT} ifneq (, $(strip $(shell git status --porcelain 2>/dev/null))) GIT_REV := $(GIT_REV)-dirty @@ -54,6 +54,7 @@ APP_TITLE := nxdumptool APP_AUTHOR := DarkMatterCore APP_VERSION := ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_MICRO} +# TODO: remove this after the PoC builds are no longer needed. ifneq ($(origin BUILD_TYPE),undefined) APP_TITLE := ${BUILD_TYPE} endif @@ -62,14 +63,16 @@ TARGET := ${APP_TITLE} BUILD := build SOURCES := source source/core source/fatfs DATA := data -ICON := romfs/icon/${APP_TITLE}.jpg +ICON := resources/img/${APP_TITLE}.jpg INCLUDES := include include/core include/fatfs -ROMFS := romfs +ROMFS := resources + +BOREALIS_PATH := libs/borealis USBHSFS_PATH := $(TOPDIR)/libs/libusbhsfs -BOREALIS_PATH := libs/borealis -BOREALIS_RESOURCES := romfs:/ +# Output folders for autogenerated files in RomFS. +OUT_SHADERS := shaders #--------------------------------------------------------------------------------- # options for code generation @@ -80,18 +83,21 @@ CFLAGS := -g -Wall -Werror -O2 -ffunction-sections $(ARCH) $(DEFINES) $(INCLUDE CFLAGS += -DVERSION_MAJOR=${VERSION_MAJOR} -DVERSION_MINOR=${VERSION_MINOR} -DVERSION_MICRO=${VERSION_MICRO} CFLAGS += -DAPP_TITLE=\"${APP_TITLE}\" -DAPP_AUTHOR=\"${APP_AUTHOR}\" -DAPP_VERSION=\"${APP_VERSION}\" CFLAGS += -DGIT_BRANCH=\"${GIT_BRANCH}\" -DGIT_COMMIT=\"${GIT_COMMIT}\" -DGIT_REV=\"${GIT_REV}\" -CFLAGS += -DBOREALIS_RESOURCES="\"${BOREALIS_RESOURCES}\"" CFLAGS += `aarch64-none-elf-pkg-config zlib --cflags` CFLAGS += `aarch64-none-elf-pkg-config libxml-2.0 --cflags` -CFLAGS += `aarch64-none-elf-pkg-config json-c --cflags` -CFLAGS += `aarch64-none-elf-pkg-config libturbojpeg --cflags` +#CFLAGS += `aarch64-none-elf-pkg-config json-c --cflags` -CXXFLAGS := $(CFLAGS) -std=c++20 -O2 -Wno-volatile -Wno-unused-parameter +CXXFLAGS := $(CFLAGS) -std=c++20 -O2 -Wno-volatile + +# TODO: remove this if a fix is ever pushed to borealis. +CFLAGS += -Wno-unused-function -Wno-misleading-indentation +CXXFLAGS += -Wno-unused-function -Wno-misleading-indentation ASFLAGS := -g $(ARCH) LDFLAGS := -specs=$(DEVKITPRO)/libnx/switch.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map) LIBS := -lcurl -lmbedtls -lmbedx509 -lmbedcrypto -lxml2 -lz -lusbhsfs -lntfs-3g -llwext4 -lnx +#LIBS += -ljson-c #--------------------------------------------------------------------------------- # list of directories containing libraries, this must be the top level containing @@ -119,6 +125,7 @@ export DEPSDIR := $(CURDIR)/$(BUILD) CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c))) CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp))) SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s))) +GLSLFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.glsl))) BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*))) #--------------------------------------------------------------------------------- @@ -140,6 +147,18 @@ export OFILES_SRC := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o) export OFILES := $(OFILES_BIN) $(OFILES_SRC) export HFILES_BIN := $(addsuffix .h,$(subst .,_,$(BINFILES))) +ifneq ($(strip $(ROMFS)),) + ROMFS_TARGETS := + ROMFS_FOLDERS := + ifneq ($(strip $(OUT_SHADERS)),) + ROMFS_SHADERS := $(ROMFS)/$(OUT_SHADERS) + ROMFS_TARGETS += $(patsubst %.glsl, $(ROMFS_SHADERS)/%.dksh, $(GLSLFILES)) + ROMFS_FOLDERS += $(ROMFS_SHADERS) + endif + + export ROMFS_DEPS := $(foreach file,$(ROMFS_TARGETS),$(CURDIR)/$(file)) +endif + export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \ $(foreach dir,$(LIBDIRS),-I$(dir)/include) \ -I$(CURDIR)/$(BUILD) @@ -188,10 +207,10 @@ ifneq ($(ROMFS),) export NROFLAGS += --romfsdir=$(CURDIR)/$(ROMFS) endif -.PHONY: $(BUILD) clean clean_all all +.PHONY: all clean clean_all #--------------------------------------------------------------------------------- -all: $(BUILD) +all: $(ROMFS_TARGETS) | $(BUILD) $(BUILD): usbhsfs @[ -d $@ ] || mkdir -p $@ @@ -200,13 +219,46 @@ $(BUILD): usbhsfs usbhsfs: @$(MAKE) --no-print-directory -C $(USBHSFS_PATH) BUILD_TYPE=GPL release +ifneq ($(strip $(ROMFS_TARGETS)),) + +$(ROMFS_TARGETS): | $(ROMFS_FOLDERS) + +$(ROMFS_FOLDERS): + @mkdir -p $@ + +$(ROMFS_SHADERS)/%_vsh.dksh: %_vsh.glsl + @echo {vert} $(notdir $<) + @uam -s vert -o $@ $< + +$(ROMFS_SHADERS)/%_tcsh.dksh: %_tcsh.glsl + @echo {tess_ctrl} $(notdir $<) + @uam -s tess_ctrl -o $@ $< + +$(ROMFS_SHADERS)/%_tesh.dksh: %_tesh.glsl + @echo {tess_eval} $(notdir $<) + @uam -s tess_eval -o $@ $< + +$(ROMFS_SHADERS)/%_gsh.dksh: %_gsh.glsl + @echo {geom} $(notdir $<) + @uam -s geom -o $@ $< + +$(ROMFS_SHADERS)/%_fsh.dksh: %_fsh.glsl + @echo {frag} $(notdir $<) + @uam -s frag -o $@ $< + +$(ROMFS_SHADERS)/%.dksh: %.glsl + @echo {comp} $(notdir $<) + @uam -s comp -o $@ $< + +endif + #--------------------------------------------------------------------------------- clean: @echo clean ... ifeq ($(strip $(APP_JSON)),) - @rm -fr $(BUILD) $(TARGET).nro $(TARGET).nacp $(TARGET).elf + @rm -fr $(BUILD) $(ROMFS_FOLDERS) $(TARGET).nro $(TARGET).nacp $(TARGET).elf else - @rm -fr $(BUILD) $(TARGET).nsp $(TARGET).nso $(TARGET).npdm $(TARGET).elf + @rm -fr $(BUILD) $(ROMFS_FOLDERS) $(TARGET).nsp $(TARGET).nso $(TARGET).npdm $(TARGET).elf endif clean_all: clean @@ -226,9 +278,9 @@ ifeq ($(strip $(APP_JSON)),) all : $(OUTPUT).nro ifeq ($(strip $(NO_NACP)),) -$(OUTPUT).nro : $(OUTPUT).elf $(OUTPUT).nacp +$(OUTPUT).nro : $(OUTPUT).elf $(OUTPUT).nacp $(ROMFS_DEPS) else -$(OUTPUT).nro : $(OUTPUT).elf +$(OUTPUT).nro : $(OUTPUT).elf $(ROMFS_DEPS) endif else diff --git a/code_templates/nsp_dumper_stor.c b/code_templates/nsp_dumper_stor.c index c7be27e..3542434 100644 --- a/code_templates/nsp_dumper_stor.c +++ b/code_templates/nsp_dumper_stor.c @@ -264,7 +264,7 @@ static void nspDump(TitleInfo *title_info, u64 free_space) consolePrint("%s #%u initialize nca ctx succeeded\n", titleGetNcmContentTypeName(content_info->content_type), content_info->id_offset); // don't go any further with this nca if we can't access its fs data because it's pointless - // to do: add preload warning + // TODO: add preload warning if (cur_nca_ctx->rights_id_available && !cur_nca_ctx->titlekey_retrieved) { j++; diff --git a/code_templates/nsp_dumper_usb.c b/code_templates/nsp_dumper_usb.c index 5057fc2..cb7fbb5 100644 --- a/code_templates/nsp_dumper_usb.c +++ b/code_templates/nsp_dumper_usb.c @@ -254,7 +254,7 @@ static void dump_thread_func(void *arg) consolePrint("%s #%u initialize nca ctx succeeded\n", titleGetNcmContentTypeName(content_info->content_type), content_info->id_offset); // don't go any further with this nca if we can't access its fs data because it's pointless - // to do: add preload warning + // TODO: add preload warning if (cur_nca_ctx->rights_id_available && !cur_nca_ctx->titlekey_retrieved) { j++; diff --git a/include/captioned_image.hpp b/include/captioned_image.hpp new file mode 100644 index 0000000..1980a69 --- /dev/null +++ b/include/captioned_image.hpp @@ -0,0 +1,34 @@ +/* + Copyright 2020-2021 natinusala + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include + +class CaptionedImage : public brls::Box +{ + public: + CaptionedImage(); + + void onChildFocusGained(brls::View* directChild, brls::View* focusedView) override; + void onChildFocusLost(brls::View* directChild, brls::View* focusedView) override; + + static brls::View* create(); + + private: + BRLS_BIND(brls::Image, image, "image"); + BRLS_BIND(brls::Label, label, "label"); +}; diff --git a/include/components_tab.hpp b/include/components_tab.hpp new file mode 100644 index 0000000..a7aab4f --- /dev/null +++ b/include/components_tab.hpp @@ -0,0 +1,30 @@ +/* + Copyright 2021 natinusala + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include + +class ComponentsTab : public brls::Box +{ + public: + ComponentsTab(); + + static brls::View* create(); + + private: + bool onPrimaryButtonClicked(brls::View* view); +}; diff --git a/include/core/bfsar.h b/include/core/nxdt_bfsar.h similarity index 91% rename from include/core/bfsar.h rename to include/core/nxdt_bfsar.h index 5c53181..593db52 100644 --- a/include/core/bfsar.h +++ b/include/core/nxdt_bfsar.h @@ -1,5 +1,5 @@ /* - * bfsar.h + * nxdt_bfsar.h * * Copyright (c) 2020-2021, DarkMatterCore . * @@ -21,8 +21,8 @@ #pragma once -#ifndef __BFSAR_H__ -#define __BFSAR_H__ +#ifndef __NXDT_BFSAR_H__ +#define __NXDT_BFSAR_H__ #ifdef __cplusplus extern "C" { @@ -41,4 +41,4 @@ const char *bfsarGetFilePath(void); } #endif -#endif /* __BFSAR_H__ */ +#endif /* __NXDT_BFSAR_H__ */ diff --git a/include/main_activity.hpp b/include/main_activity.hpp new file mode 100644 index 0000000..cfbe3e3 --- /dev/null +++ b/include/main_activity.hpp @@ -0,0 +1,26 @@ +/* + Copyright 2020-2021 natinusala + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include + +class MainActivity : public brls::Activity +{ + public: + // Declare that the content of this activity is the given XML file + CONTENT_FROM_XML_RES("activity/main.xml"); +}; diff --git a/include/recycling_list_tab.hpp b/include/recycling_list_tab.hpp new file mode 100644 index 0000000..c3b09da --- /dev/null +++ b/include/recycling_list_tab.hpp @@ -0,0 +1,27 @@ +/* + Copyright 2020-2021 natinusala + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include + +class RecyclingListTab : public brls::Box +{ + public: + RecyclingListTab(); + + static brls::View* create(); +}; diff --git a/source/about_tab.cpp b/legacy_borealis/about_tab.cpp similarity index 100% rename from source/about_tab.cpp rename to legacy_borealis/about_tab.cpp diff --git a/include/about_tab.hpp b/legacy_borealis/about_tab.hpp similarity index 100% rename from include/about_tab.hpp rename to legacy_borealis/about_tab.hpp diff --git a/source/error_frame.cpp b/legacy_borealis/error_frame.cpp similarity index 100% rename from source/error_frame.cpp rename to legacy_borealis/error_frame.cpp diff --git a/include/error_frame.hpp b/legacy_borealis/error_frame.hpp similarity index 100% rename from include/error_frame.hpp rename to legacy_borealis/error_frame.hpp diff --git a/include/focusable_item.hpp b/legacy_borealis/focusable_item.hpp similarity index 100% rename from include/focusable_item.hpp rename to legacy_borealis/focusable_item.hpp diff --git a/source/gamecard_tab.cpp b/legacy_borealis/gamecard_tab.cpp similarity index 100% rename from source/gamecard_tab.cpp rename to legacy_borealis/gamecard_tab.cpp diff --git a/include/gamecard_tab.hpp b/legacy_borealis/gamecard_tab.hpp similarity index 100% rename from include/gamecard_tab.hpp rename to legacy_borealis/gamecard_tab.hpp diff --git a/source/layered_error_frame.cpp b/legacy_borealis/layered_error_frame.cpp similarity index 100% rename from source/layered_error_frame.cpp rename to legacy_borealis/layered_error_frame.cpp diff --git a/include/layered_error_frame.hpp b/legacy_borealis/layered_error_frame.hpp similarity index 100% rename from include/layered_error_frame.hpp rename to legacy_borealis/layered_error_frame.hpp diff --git a/source/root_view.cpp b/legacy_borealis/root_view.cpp similarity index 100% rename from source/root_view.cpp rename to legacy_borealis/root_view.cpp diff --git a/include/root_view.hpp b/legacy_borealis/root_view.hpp similarity index 100% rename from include/root_view.hpp rename to legacy_borealis/root_view.hpp diff --git a/source/tasks.cpp b/legacy_borealis/tasks.cpp similarity index 100% rename from source/tasks.cpp rename to legacy_borealis/tasks.cpp diff --git a/include/tasks.hpp b/legacy_borealis/tasks.hpp similarity index 100% rename from include/tasks.hpp rename to legacy_borealis/tasks.hpp diff --git a/source/user_titles_tab.cpp b/legacy_borealis/user_titles_tab.cpp similarity index 100% rename from source/user_titles_tab.cpp rename to legacy_borealis/user_titles_tab.cpp diff --git a/include/user_titles_tab.hpp b/legacy_borealis/user_titles_tab.hpp similarity index 100% rename from include/user_titles_tab.hpp rename to legacy_borealis/user_titles_tab.hpp diff --git a/legacy/dumper.c b/legacy_nxdumptool/dumper.c similarity index 100% rename from legacy/dumper.c rename to legacy_nxdumptool/dumper.c diff --git a/legacy/dumper.h b/legacy_nxdumptool/dumper.h similarity index 100% rename from legacy/dumper.h rename to legacy_nxdumptool/dumper.h diff --git a/legacy/nca.c b/legacy_nxdumptool/nca.c similarity index 100% rename from legacy/nca.c rename to legacy_nxdumptool/nca.c diff --git a/legacy/nca.h b/legacy_nxdumptool/nca.h similarity index 100% rename from legacy/nca.h rename to legacy_nxdumptool/nca.h diff --git a/legacy/ui.c b/legacy_nxdumptool/ui.c similarity index 100% rename from legacy/ui.c rename to legacy_nxdumptool/ui.c diff --git a/legacy/ui.h b/legacy_nxdumptool/ui.h similarity index 100% rename from legacy/ui.h rename to legacy_nxdumptool/ui.h diff --git a/legacy/util.c b/legacy_nxdumptool/util.c similarity index 100% rename from legacy/util.c rename to legacy_nxdumptool/util.c diff --git a/legacy/util.h b/legacy_nxdumptool/util.h similarity index 100% rename from legacy/util.h rename to legacy_nxdumptool/util.h diff --git a/libs/borealis b/libs/borealis index 44a95c7..53e96bd 160000 --- a/libs/borealis +++ b/libs/borealis @@ -1 +1 @@ -Subproject commit 44a95c77bae903623d822dab1c3a505810f1f30f +Subproject commit 53e96bd1b3b249f897eb22a96dd388492ae1a0cd diff --git a/romfs/i18n/en-US/brls.json b/resources/i18n/en-US/brls.json similarity index 100% rename from romfs/i18n/en-US/brls.json rename to resources/i18n/en-US/brls.json diff --git a/resources/i18n/en-US/demo.json b/resources/i18n/en-US/demo.json new file mode 100644 index 0000000..c5a99f1 --- /dev/null +++ b/resources/i18n/en-US/demo.json @@ -0,0 +1,48 @@ +{ + "title": "Borealis Demo App", + + "tabs": { + "components": "Basic components", + "layout": "Layout and alignment", + "recycling": "Recycling lists", + "popups": "Popups, notifications and dialogs", + "hos_layout": "Horizon layouts", + "misc_layouts": "Misc. layouts", + "misc_components": "Misc. components", + "misc_tools": "Misc. dev tools", + "about": "About borealis" + }, + + "welcome": "Welcome to the borealis demo! Feel free to explore and discover what the library can do.", + + "components": { + "buttons_header": "Buttons", + "button_primary": "Primary button", + "button_highlight": "\uE13C Highlight button", + "button_wrapping": "Default button with wrapping text", + "button_bordered": "Bordered button", + "button_borderless": "Borderless button", + + "labels_header": "Labels", + "regular_label": "This is a label. By default, they will automatically wrap and expand their height, should the remaining vertical space allow it. Otherwise, they will be truncated, like some of the tabs of the sidebar.", + "label_left": "This label is left-aligned", + "label_center": "This label is center-aligned", + "label_right": "This label is right-aligned", + + "images_header_title": "Images", + "images_header_subtitle": "Focus them to see the scaling method", + "images_downscaled": "Downscaled", + "images_original": "Original", + "images_upscaled": "Upscaled", + "images_stretched": "Stretched", + "images_cropped": "Cropped" + }, + + "about": { + "title": "borealis", + "description": "A hardware accelerated, controller and TV oriented UI library for PC and Nintendo Switch (libnx).", + "github": "Find it on github.com/natinusala/borealis", + "licence": "Licensed under Apache 2.0", + "logo_credit": "Logo by @MeganRoshelle" + } +} diff --git a/resources/i18n/fr/brls.json b/resources/i18n/fr/brls.json new file mode 100644 index 0000000..9ed2173 --- /dev/null +++ b/resources/i18n/fr/brls.json @@ -0,0 +1,15 @@ +{ + "hints": { + "ok": "OK", + "back": "Retour", + "exit": "Quitter" + }, + + "crash_frame": { + "button": "OK" + }, + + "thumbnail_sidebar": { + "save": "Sauvegarder" + } +} diff --git a/resources/i18n/fr/demo.json b/resources/i18n/fr/demo.json new file mode 100644 index 0000000..69a88e3 --- /dev/null +++ b/resources/i18n/fr/demo.json @@ -0,0 +1 @@ +{} diff --git a/resources/img/borealis_256.png b/resources/img/borealis_256.png new file mode 100644 index 0000000..d120a87 Binary files /dev/null and b/resources/img/borealis_256.png differ diff --git a/resources/img/borealis_96.png b/resources/img/borealis_96.png new file mode 100644 index 0000000..fe3e53a Binary files /dev/null and b/resources/img/borealis_96.png differ diff --git a/romfs/icon/nxdumptool.jpg b/resources/img/nxdumptool.jpg similarity index 100% rename from romfs/icon/nxdumptool.jpg rename to resources/img/nxdumptool.jpg diff --git a/resources/img/tiles.png b/resources/img/tiles.png new file mode 100644 index 0000000..26cbbe5 Binary files /dev/null and b/resources/img/tiles.png differ diff --git a/romfs/material/LICENSE.txt b/resources/material/LICENSE.txt similarity index 100% rename from romfs/material/LICENSE.txt rename to resources/material/LICENSE.txt diff --git a/romfs/material/MaterialIcons-Regular.ttf b/resources/material/MaterialIcons-Regular.ttf similarity index 100% rename from romfs/material/MaterialIcons-Regular.ttf rename to resources/material/MaterialIcons-Regular.ttf diff --git a/resources/xml/activity/main.xml b/resources/xml/activity/main.xml new file mode 100644 index 0000000..d0e2dca --- /dev/null +++ b/resources/xml/activity/main.xml @@ -0,0 +1,102 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/resources/xml/tabs/components.xml b/resources/xml/tabs/components.xml new file mode 100644 index 0000000..0635473 --- /dev/null +++ b/resources/xml/tabs/components.xml @@ -0,0 +1,216 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/resources/xml/tabs/layout.xml b/resources/xml/tabs/layout.xml new file mode 100644 index 0000000..f0afa12 --- /dev/null +++ b/resources/xml/tabs/layout.xml @@ -0,0 +1,4 @@ + diff --git a/resources/xml/tabs/recycling_list.xml b/resources/xml/tabs/recycling_list.xml new file mode 100644 index 0000000..8506f5a --- /dev/null +++ b/resources/xml/tabs/recycling_list.xml @@ -0,0 +1,11 @@ + + + + + diff --git a/resources/xml/views/captioned_image.xml b/resources/xml/views/captioned_image.xml new file mode 100644 index 0000000..2c31270 --- /dev/null +++ b/resources/xml/views/captioned_image.xml @@ -0,0 +1,21 @@ + + + + + + + diff --git a/romfs/i18n/en-US/about_tab.json b/romfs/i18n/en-US/about_tab.json deleted file mode 100644 index 72687be..0000000 --- a/romfs/i18n/en-US/about_tab.json +++ /dev/null @@ -1,34 +0,0 @@ -{ - "description": "Nintendo Switch Dump Tool", - - "copyright": "Licensed under GPLv3+\n\u00A9 2020 - 2021 {0}\n{1}", - - "dependencies": { - "header": "Dependencies", - "line_00": "\uE016 {0} is powered by Borealis, a hardware-accelerated UI library: {1}.", - "line_01": "\uE016 USB Mass Storage device support is powered by libusbhsfs: {0}.", - "line_02": "\uE016 FatFs is used to mount FAT volumes from the eMMC storage: {0}.", - "line_03": "\uE016 LZ4 is used to decompress NSO binaries: {0}." - }, - - "acknowledgments": { - "header": "Acknowledgments", - "line_00": "\uE016 Switchbrew and libnx contributors.", - "line_01": "\uE016 SciresM, for hactool and Atmosphère-NX.", - "line_02": "\uE016 shchmue, for Lockpick and its runtime key-collection algorithm, as well as helping in reverse engineering tasks.", - "line_03": "\uE016 Adubbz, for Tinfoil and its ES service bindings.", - "line_04": "\uE016 RattletraPM, for the awesome icon.", - "line_05": "\uE016 Whovian9369, for being a key piece throughout the whole development by providing with lots of testing and cool ideas.", - "line_06": "\uE016 0Liam, Shadów and SimonTime, for their tremendous help in understanding Nintendo Switch file and data formats.", - "line_07": "\uE016 The folks from NSWDB.COM and No-Intro.org, for being kind enough to put up public APIs to perform online checksum lookups.", - "line_08": "\uE016 The folks at the nxdumptool Discord server.", - "line_09": "\uE016 The Comfy Boyes, for always being awesome and supportive. You know who you are.", - "line_10": "\uE016 My girlfriend, for always being by my side and motivating me to keep working on all my projects. I love you. \uE87D", - "line_11": "\uE016 And, at last but not least, you! Thank you for using my work!" - }, - - "links": { - "header": "Additional links and resources", - "line_00": "\uE016 Discord server: {0}." - } -} diff --git a/romfs/i18n/en-US/gamecard_tab.json b/romfs/i18n/en-US/gamecard_tab.json deleted file mode 100644 index 5fae0f5..0000000 --- a/romfs/i18n/en-US/gamecard_tab.json +++ /dev/null @@ -1,57 +0,0 @@ -{ - "notification": "Gamecard status change detected!", - - "error_frame": { - "not_inserted": "No gamecard inserted.", - "processing": "Processing gamecard, please wait...", - "nogc_enabled": "A gamecard has been inserted, but the \"nogc\" patch is enabled.\nNothing at all can be done with the inserted gamecard.\nDisabling this patch *will* update the Lotus ASIC firmware if it's outdated.\nConsider disabling this patch if you wish to use gamecard dumping features.", - "lafw_update_required": "A gamecard has been inserted, but a Lotus ASIC firmware update is required.\nUpdate your console using the inserted gamecard and try again.", - "info_not_loaded": "A gamecard has been inserted, but an unexpected I/O error occurred.\nPlease report this issue at \"{0}\"." - }, - - "list": { - "properties_table": { - "header": "Gamecard properties", - "capacity": "Capacity", - "total_size": "Total size", - "trimmed_size": "Trimmed size", - "update_version": "Bundled update version", - "lafw_version": "Required LAFW version", - "lafw_version_value": "%lu or greater (%s)", - "sdk_version": "SDK version", - "compatibility_type": "Compatibility type" - }, - - "dump_options": "Dump options", - - "dump_card_image": { - "label": "Dump gamecard image (XCI)", - "description": "Generates a raw gamecard image. This is the option most people will want to use." - }, - - "dump_certificate": { - "label": "Dump gamecard certificate", - "description": "The gamecard certificate is used to unequivocally identify each individual gamecard." - }, - - "dump_header": { - "label": "Dump gamecard header", - "description": "The gamecard header holds information such as the location of the root HFS partition and the gamecard capacity.\nOnly useful for developers, preservationists and advanced users." - }, - - "dump_decrypted_cardinfo": { - "label": "Dump decrypted CardInfo area", - "description": "The CardInfo area holds information such as the bundled system update version and the Lotus ASIC firmware version required by the gamecard.\nThis area is part of the gamecard header, but it's always encrypted.\nOnly useful for developers, preservationists and advanced users." - }, - - "dump_initial_data": { - "label": "Dump InitialData area", - "description": "The InitialData area holds cryptographic information used by the Lotus ASIC to communicate with the gamecard.\nIt can't be dumped through normal means - it's not part of the storage areas from gamecard images.\nOnly useful for developers, preservationists and advanced users." - }, - - "dump_hfs_partitions": { - "label": "Dump Hash File System (HFS) partitions", - "description": "Dumps data from the HFS partitions within the gamecard storage areas, in both raw and extracted forms." - } - } -} diff --git a/romfs/i18n/en-US/generic.json b/romfs/i18n/en-US/generic.json deleted file mode 100644 index 47a19eb..0000000 --- a/romfs/i18n/en-US/generic.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "unknown": "Unknown" -} diff --git a/romfs/i18n/en-US/root_view.json b/romfs/i18n/en-US/root_view.json deleted file mode 100644 index e99bba0..0000000 --- a/romfs/i18n/en-US/root_view.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "applet_mode": "\uE8B2 Applet Mode \uE8B2", - - "date": "{1:02d}/{2:02d}/{0} {3:02d}:{4:02d}:{5:02d} {6}", - - "not_connected": "Not connected", - - "tabs": { - "gamecard": "Gamecard", - "user_titles": "User titles", - "system_titles": "System titles", - "options": "Options", - "about": "About" - } -} diff --git a/romfs/i18n/en-US/user_titles_tab.json b/romfs/i18n/en-US/user_titles_tab.json deleted file mode 100644 index bfa9771..0000000 --- a/romfs/i18n/en-US/user_titles_tab.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "no_titles_available": "No user titles available.", - "notification": "User titles list updated!" -} diff --git a/source/captioned_image.cpp b/source/captioned_image.cpp new file mode 100644 index 0000000..31becfa --- /dev/null +++ b/source/captioned_image.cpp @@ -0,0 +1,65 @@ +/* + Copyright 2020-2021 natinusala + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include "captioned_image.hpp" + +CaptionedImage::CaptionedImage() +{ + // Load the XML file and inflate ourself with its content + // The top-level Box in the XML corresponds to us, and every XML child + // is added to our children (and the attributes are applied) + // The CaptionedImage instance basically becomes what's written in the XML + this->inflateFromXMLRes("xml/views/captioned_image.xml"); + + // The label stays hidden until focused, so hide it right away + this->label->hide([] {}); + + // Forward Image and Label XML attributes + this->forwardXMLAttribute("scalingType", this->image); + this->forwardXMLAttribute("image", this->image); + this->forwardXMLAttribute("focusUp", this->image); + this->forwardXMLAttribute("focusRight", this->image); + this->forwardXMLAttribute("focusDown", this->image); + this->forwardXMLAttribute("focusLeft", this->image); + this->forwardXMLAttribute("imageWidth", this->image, "width"); + this->forwardXMLAttribute("imageHeight", this->image, "height"); + + this->forwardXMLAttribute("caption", this->label, "text"); +} + +void CaptionedImage::onChildFocusGained(brls::View* directChild, brls::View* focusedView) +{ + // Called when a child of ours gets focused, in that case it's the Image + + Box::onChildFocusGained(directChild, focusedView); + + this->label->show([] {}); +} + +void CaptionedImage::onChildFocusLost(brls::View* directChild, brls::View* focusedView) +{ + // Called when a child of ours losts focused, in that case it's the Image + + Box::onChildFocusLost(directChild, focusedView); + + this->label->hide([] {}); +} + +brls::View* CaptionedImage::create() +{ + // Called by the XML engine to create a new CaptionedImage + return new CaptionedImage(); +} diff --git a/source/components_tab.cpp b/source/components_tab.cpp new file mode 100644 index 0000000..e64c548 --- /dev/null +++ b/source/components_tab.cpp @@ -0,0 +1,43 @@ +/* + Copyright 2021 natinusala + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include "components_tab.hpp" + +ComponentsTab::ComponentsTab() +{ + // Inflate the tab from the XML file + this->inflateFromXMLRes("xml/tabs/components.xml"); + + // Bind the button click to a method using the macro (just for the sake of showcasing it, it's overkill in this situation) + BRLS_REGISTER_CLICK_BY_ID("button_primary", this->onPrimaryButtonClicked); + + // Get a handle to the button and register the action directly + brls::Button* highlightButton = (brls::Button*)this->getView("button_highlight"); + highlightButton->registerAction( + "Honk", brls::BUTTON_A, [](brls::View* view) { return true; }, false, brls::SOUND_HONK); +} + +bool ComponentsTab::onPrimaryButtonClicked(brls::View* view) +{ + brls::Logger::info("Clicked"); + return true; +} + +brls::View* ComponentsTab::create() +{ + // Called by the XML engine to create a new ComponentsTab + return new ComponentsTab(); +} diff --git a/source/core/gamecard.c b/source/core/gamecard.c index 97d8d17..4f5ae4a 100644 --- a/source/core/gamecard.c +++ b/source/core/gamecard.c @@ -961,7 +961,7 @@ static bool gamecardGetHandleAndStorage(u32 partition) NX_INLINE void gamecardCloseHandle(void) { - /* TO DO: find a way to properly close a gamecard handle. */ + /* TODO: find a way to properly close a gamecard handle. */ if (!g_gameCardHandle.value) return; svcCloseHandle(g_gameCardHandle.value); g_gameCardHandle.value = 0; diff --git a/source/core/bfsar.c b/source/core/nxdt_bfsar.c similarity index 94% rename from source/core/bfsar.c rename to source/core/nxdt_bfsar.c index 8823e97..934f5a7 100644 --- a/source/core/bfsar.c +++ b/source/core/nxdt_bfsar.c @@ -1,5 +1,5 @@ /* - * bfsar.c + * nxdt_bfsar.c * * Copyright (c) 2020-2021, DarkMatterCore . * @@ -20,7 +20,7 @@ */ #include "nxdt_utils.h" -#include "bfsar.h" +#include "nxdt_bfsar.h" #include "romfs.h" #include "title.h" @@ -75,6 +75,8 @@ bool bfsarInitialize(void) /* Create BFSAR file in the SD card root directory. */ if (use_root) sprintf(g_bfsarPath, "/" BFSAR_FILENAME); + LOG_MSG("BFSAR path: \"%s\".", g_bfsarPath); + /* Check if the BFSAR file is already available and not empty. */ bfsar_file = fopen(g_bfsarPath, "rb"); if (bfsar_file) @@ -104,16 +106,16 @@ bool bfsarInitialize(void) } /* Initialize NCA context. */ - if (!ncaInitializeContext(nca_ctx, NcmStorageId_BuiltInSystem, 0, titleGetContentInfoByTypeAndIdOffset(title_info, NcmContentType_Data, 0), NULL)) + if (!ncaInitializeContext(nca_ctx, NcmStorageId_BuiltInSystem, 0, titleGetContentInfoByTypeAndIdOffset(title_info, NcmContentType_Program, 0), NULL)) { - LOG_MSG("Failed to initialize qlaunch Data NCA context!"); + LOG_MSG("Failed to initialize qlaunch Program NCA context!"); break; } /* Initialize RomFS context. */ - if (!romfsInitializeContext(&romfs_ctx, &(nca_ctx->fs_ctx[0]))) + if (!romfsInitializeContext(&romfs_ctx, &(nca_ctx->fs_ctx[1]))) { - LOG_MSG("Failed to initialize RomFS context for qlaunch Data NCA!"); + LOG_MSG("Failed to initialize RomFS context for qlaunch Program NCA!"); break; } @@ -185,7 +187,7 @@ void bfsarExit(void) { /* Clear BFSAR file path. */ *g_bfsarPath = '\0'; - g_bfttfInterfaceInit = false; + g_bfsarInterfaceInit = false; } } @@ -195,7 +197,7 @@ const char *bfsarGetFilePath(void) SCOPED_TRY_LOCK(&g_bfsarMutex) { - if (g_bfttfInterfaceInit) ret = (const char*)g_bfsarPath; + if (g_bfsarInterfaceInit) ret = (const char*)g_bfsarPath; } return ret; diff --git a/source/core/nxdt_utils.c b/source/core/nxdt_utils.c index 853c7b2..0e69eee 100644 --- a/source/core/nxdt_utils.c +++ b/source/core/nxdt_utils.c @@ -29,7 +29,7 @@ #include "usb.h" #include "title.h" #include "bfttf.h" -#include "bfsar.h" +#include "nxdt_bfsar.h" #include "fatfs/ff.h" /* Reference: https://docs.microsoft.com/en-us/windows/win32/fileio/filesystem-functionality-comparison#limits. */ @@ -87,7 +87,7 @@ static size_t utilsGetUtf8CodepointCount(const char *str, size_t str_size, size_ bool utilsInitializeResources(const int program_argc, const char **program_argv) { Result rc = 0; - bool ret = false; + bool ret = false, flag = false; SCOPED_LOCK(&g_resourcesMutex) { @@ -160,7 +160,12 @@ bool utilsInitializeResources(const int program_argc, const char **program_argv) /* Mount eMMC BIS System partition. */ if (!utilsMountEmmcBisSystemPartitionStorage()) break; + /* Enable video recording. */ + rc = appletIsGamePlayRecordingSupported(&flag); + if (R_SUCCEEDED(rc) && flag) appletInitializeGamePlayRecording(); + /* Disable screen dimming and auto sleep. */ + /* TODO: only use this function right before starting a dump procedure - make sure to handle power button presses as well. */ appletSetMediaPlaybackState(true); /* Overclock system. */ @@ -839,7 +844,7 @@ static void utilsOverclockSystemAppletHook(AppletHookType hook, void *param) if (hook != AppletHookType_OnOperationMode && hook != AppletHookType_OnPerformanceMode) return; - /* TO DO: read config here to actually know the value to use with utilsOverclockSystem. */ + /* TODO: read config here to actually know the value to use with utilsOverclockSystem. */ utilsOverclockSystem(true); } diff --git a/source/main.cpp b/source/main.cpp index b6e0f0d..fbeea48 100644 --- a/source/main.cpp +++ b/source/main.cpp @@ -1,54 +1,59 @@ -/* - * 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 -int main(int argc, char *argv[]) +#include + +#include "captioned_image.hpp" +#include "components_tab.hpp" +#include "main_activity.hpp" +#include "recycling_list_tab.hpp" + +using namespace brls::literals; // for _i18n + +int main(int argc, char* argv[]) { /* Set scope guard to clean up resources at exit. */ ON_SCOPE_EXIT { utilsCloseResources(); }; - + /* Initialize application resources. */ if (!utilsInitializeResources(argc, (const char**)argv)) return EXIT_FAILURE; - - /* Set Borealis log level. */ + + // Set log level + // We recommend to use INFO for real apps brls::Logger::setLogLevel(brls::LogLevel::DEBUG); - - /* Load Borealis translation files. */ - brls::i18n::loadTranslations(); - - /* Initialize Borealis. */ - if (!brls::Application::init(APP_TITLE)) return EXIT_FAILURE; - - /* Create root view. */ - nxdt::views::RootView *root_view = new nxdt::views::RootView(); - - /* Add the root view to the stack. */ - brls::Application::pushView(root_view); - - /* Run the application. */ - while(brls::Application::mainLoop()); - - /* Exit. */ + + // Init the app and i18n + if (!brls::Application::init()) + { + brls::Logger::error("Unable to init Borealis application"); + return EXIT_FAILURE; + } + + brls::Application::createWindow("demo/title"_i18n); + + // Have the application register an action on every activity that will quit when you press BUTTON_START + brls::Application::setGlobalQuit(true); + + // Register custom views (including tabs, which are views) + brls::Application::registerXMLView("CaptionedImage", CaptionedImage::create); + brls::Application::registerXMLView("RecyclingListTab", RecyclingListTab::create); + brls::Application::registerXMLView("ComponentsTab", ComponentsTab::create); + + // Add custom values to the theme + brls::getLightTheme().addColor("captioned_image/caption", nvgRGB(2, 176, 183)); + brls::getDarkTheme().addColor("captioned_image/caption", nvgRGB(51, 186, 227)); + + // Add custom values to the style + brls::getStyle().addMetric("about/padding_top_bottom", 50); + brls::getStyle().addMetric("about/padding_sides", 75); + brls::getStyle().addMetric("about/description_margin", 50); + + // Create and push the main activity to the stack + brls::Application::pushActivity(new MainActivity()); + + // Run the app + while (brls::Application::mainLoop()); + + // Exit return EXIT_SUCCESS; } diff --git a/source/main_activity.cpp b/source/main_activity.cpp new file mode 100644 index 0000000..b4e1a35 --- /dev/null +++ b/source/main_activity.cpp @@ -0,0 +1,17 @@ +/* + Copyright 2020-2021 natinusala + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include "main_activity.hpp" diff --git a/source/recycling_list_tab.cpp b/source/recycling_list_tab.cpp new file mode 100644 index 0000000..4c4a82b --- /dev/null +++ b/source/recycling_list_tab.cpp @@ -0,0 +1,29 @@ +/* + Copyright 2020-2021 natinusala + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include "recycling_list_tab.hpp" + +RecyclingListTab::RecyclingListTab() +{ + // Inflate the tab from the XML file + this->inflateFromXMLRes("xml/tabs/recycling_list.xml"); +} + +brls::View* RecyclingListTab::create() +{ + // Called by the XML engine to create a new RecyclingListTab + return new RecyclingListTab(); +}