From 6af4bed9fa13db116bc0d09a3cea6415fa14e090 Mon Sep 17 00:00:00 2001 From: J-D-K Date: Fri, 18 Jul 2025 06:22:55 -0400 Subject: [PATCH] Change AppState to BaseState. Update headers. --- .clang-format | 286 +++++++++++++----- Libraries/FsLib | 2 +- include/JKSV.hpp | 3 +- include/StateManager.hpp | 13 +- include/appstates/BackupMenuState.hpp | 34 ++- .../appstates/{AppState.hpp => BaseState.hpp} | 11 +- include/appstates/BaseTask.hpp | 11 +- include/appstates/ConfirmState.hpp | 55 ++-- include/appstates/ExtrasMenuState.hpp | 6 +- include/appstates/MainMenuState.hpp | 25 +- include/appstates/ProgressState.hpp | 12 +- include/appstates/SaveCreateState.hpp | 15 +- include/appstates/SettingsState.hpp | 8 +- include/appstates/TaskState.hpp | 4 +- include/appstates/TextTitleSelectState.hpp | 4 +- include/appstates/TitleInfoState.hpp | 37 +-- include/appstates/TitleOptionState.hpp | 31 +- include/appstates/TitleSelectCommon.hpp | 9 +- include/appstates/TitleSelectState.hpp | 4 +- include/appstates/UserOptionState.hpp | 19 +- source/JKSV.cpp | 4 +- source/StateManager.cpp | 6 +- source/appstates/AppState.cpp | 53 ---- source/appstates/BackupMenuState.cpp | 32 +- source/appstates/BaseState.cpp | 28 ++ source/appstates/BaseTask.cpp | 2 +- source/appstates/ExtrasMenuState.cpp | 10 +- source/appstates/MainMenuState.cpp | 10 +- source/appstates/ProgressState.cpp | 2 +- source/appstates/SaveCreateState.cpp | 14 +- source/appstates/SettingsState.cpp | 12 +- source/appstates/TaskState.cpp | 2 +- source/appstates/TextTitleSelectState.cpp | 8 +- source/appstates/TitleInfoState.cpp | 8 +- source/appstates/TitleOptionState.cpp | 20 +- source/appstates/TitleSelectCommon.cpp | 4 +- source/appstates/TitleSelectState.cpp | 10 +- source/appstates/UserOptionState.cpp | 16 +- source/config.cpp | 6 +- source/data/data.cpp | 2 +- source/fs/SaveMetaData.cpp | 6 +- source/fs/io.cpp | 12 +- source/fs/zip.cpp | 16 +- source/remote/GoogleDrive.cpp | 6 +- source/remote/WebDav.cpp | 6 +- source/strings.cpp | 2 +- 46 files changed, 519 insertions(+), 367 deletions(-) rename include/appstates/{AppState.hpp => BaseState.hpp} (91%) delete mode 100644 source/appstates/AppState.cpp create mode 100644 source/appstates/BaseState.cpp diff --git a/.clang-format b/.clang-format index 8b5ab5e..11fc93c 100644 --- a/.clang-format +++ b/.clang-format @@ -1,136 +1,274 @@ --- -Language: Cpp +BasedOnStyle: GNU AccessModifierOffset: -4 AlignAfterOpenBracket: Align -AlignConsecutiveMacros: false -AlignConsecutiveAssignments: false -AlignConsecutiveDeclarations: false +AlignArrayOfStructures: None +AlignConsecutiveAssignments: + Enabled: true + AcrossEmptyLines: false + AcrossComments: false + AlignCompound: false + AlignFunctionPointers: false + PadOperators: false +AlignConsecutiveBitFields: + Enabled: true + AcrossEmptyLines: false + AcrossComments: false + AlignCompound: false + AlignFunctionPointers: false + PadOperators: false +AlignConsecutiveDeclarations: + Enabled: false + AcrossEmptyLines: false + AcrossComments: false + AlignCompound: false + AlignFunctionPointers: false + PadOperators: false +AlignConsecutiveMacros: + Enabled: false + AcrossEmptyLines: false + AcrossComments: false + AlignCompound: false + AlignFunctionPointers: false + PadOperators: false +AlignConsecutiveShortCaseStatements: + Enabled: false + AcrossEmptyLines: false + AcrossComments: false + AlignCaseArrows: false + AlignCaseColons: false +AlignConsecutiveTableGenBreakingDAGArgColons: + Enabled: false + AcrossEmptyLines: false + AcrossComments: false + AlignCompound: false + AlignFunctionPointers: false + PadOperators: false +AlignConsecutiveTableGenCondOperatorColons: + Enabled: false + AcrossEmptyLines: false + AcrossComments: false + AlignCompound: false + AlignFunctionPointers: false + PadOperators: false +AlignConsecutiveTableGenDefinitionColons: + Enabled: false + AcrossEmptyLines: false + AcrossComments: false + AlignCompound: false + AlignFunctionPointers: false + PadOperators: false AlignEscapedNewlines: Right -AlignOperands: true -AlignTrailingComments: true +AlignOperands: Align +AlignTrailingComments: + Kind: Always + OverEmptyLines: 0 AllowAllArgumentsOnNextLine: false -AllowAllConstructorInitializersOnNextLine: true AllowAllParametersOfDeclarationOnNextLine: false -AllowShortBlocksOnASingleLine: Never -AllowShortCaseLabelsOnASingleLine: false -AllowShortFunctionsOnASingleLine: None +AllowBreakBeforeNoexceptSpecifier: Never +AllowShortBlocksOnASingleLine: Always +AllowShortCaseExpressionOnASingleLine: true +AllowShortCaseLabelsOnASingleLine: true +AllowShortCompoundRequirementOnASingleLine: true +AllowShortEnumsOnASingleLine: true +AllowShortFunctionsOnASingleLine: All +AllowShortIfStatementsOnASingleLine: AllIfsAndElse AllowShortLambdasOnASingleLine: All -AllowShortIfStatementsOnASingleLine: Never -AllowShortLoopsOnASingleLine: false +AllowShortLoopsOnASingleLine: true AlwaysBreakAfterDefinitionReturnType: None -AlwaysBreakAfterReturnType: None AlwaysBreakBeforeMultilineStrings: false -AlwaysBreakTemplateDeclarations: Yes +AttributeMacros: + - __capability BinPackArguments: false BinPackParameters: false +BitFieldColonSpacing: Both BraceWrapping: - AfterCaseLabel: true - AfterClass: true - AfterControlStatement: true - AfterEnum: true - AfterFunction: true - AfterNamespace: true + AfterCaseLabel: true + AfterClass: true + AfterControlStatement: Always + AfterEnum: true + AfterFunction: true + AfterNamespace: true AfterObjCDeclaration: true - AfterStruct: true - AfterUnion: true + AfterStruct: true + AfterUnion: true AfterExternBlock: true - BeforeCatch: true - BeforeElse: true - IndentBraces: false + BeforeCatch: true + BeforeElse: true + BeforeLambdaBody: false + BeforeWhile: true + IndentBraces: true SplitEmptyFunction: true SplitEmptyRecord: true SplitEmptyNamespace: true -BreakBeforeBinaryOperators: None -BreakBeforeBraces: Custom -BreakBeforeInheritanceComma: false -BreakInheritanceList: BeforeColon -BreakBeforeTernaryOperators: true -BreakConstructorInitializersBeforeComma: false -BreakConstructorInitializers: BeforeColon +BreakAdjacentStringLiterals: true +BreakAfterAttributes: Leave BreakAfterJavaFieldAnnotations: false +BreakAfterReturnType: None +BreakArrays: false +BreakBeforeBinaryOperators: None +BreakBeforeBraces: Allman +BreakBeforeConceptDeclarations: Never +BreakBeforeInlineASMColon: OnlyMultiline +BreakBeforeTernaryOperators: true +BreakConstructorInitializers: BeforeComma +BreakFunctionDefinitionParameters: false +BreakInheritanceList: BeforeColon BreakStringLiterals: true -ColumnLimit: 120 -CommentPragmas: '^ IWYU pragma:' +BreakTemplateDeclarations: Yes +ColumnLimit: 128 +CommentPragmas: "^ IWYU pragma:" CompactNamespaces: false -ConstructorInitializerAllOnOneLineOrOnePerLine: false ConstructorInitializerIndentWidth: 4 ContinuationIndentWidth: 4 Cpp11BracedListStyle: true -DeriveLineEnding: true DerivePointerAlignment: false -DisableFormat: false +DisableFormat: false +EmptyLineAfterAccessModifier: Never +EmptyLineBeforeAccessModifier: LogicalBlock ExperimentalAutoDetectBinPacking: false -FixNamespaceComments: true +FixNamespaceComments: false ForEachMacros: - foreach - Q_FOREACH - BOOST_FOREACH -IncludeBlocks: Preserve +IfMacros: + - KJ_IF_MAYBE +IncludeBlocks: Regroup IncludeCategories: - - Regex: '^"(llvm|llvm-c|clang|clang-c)/' - Priority: 2 - SortPriority: 0 - - Regex: '^(<|"(gtest|gmock|isl|json)/)' - Priority: 3 - SortPriority: 0 - - Regex: '.*' - Priority: 1 - SortPriority: 0 -IncludeIsMainRegex: '(Test)?$' -IncludeIsMainSourceRegex: '' + - Regex: ^"(llvm|llvm-c|clang|clang-c)/ + Priority: 2 + SortPriority: 0 + CaseSensitive: false + - Regex: ^(<|"(gtest|gmock|isl|json)/) + Priority: 3 + SortPriority: 0 + CaseSensitive: false + - Regex: .* + Priority: 1 + SortPriority: 0 + CaseSensitive: false +IncludeIsMainRegex: (Test)?$ +IncludeIsMainSourceRegex: "" IndentAccessModifiers: true +IndentCaseBlocks: false IndentCaseLabels: true +IndentExternBlock: AfterExternBlock IndentGotoLabels: true -IndentPPDirectives: None -IndentWidth: 4 +IndentPPDirectives: AfterHash +IndentRequiresClause: true +IndentWidth: 4 IndentWrappedFunctionNames: false +InsertBraces: false +InsertNewlineAtEOF: false +InsertTrailingCommas: None +IntegerLiteralSeparator: + Binary: 0 + BinaryMinDigits: 0 + Decimal: 0 + DecimalMinDigits: 0 + Hex: 0 + HexMinDigits: 0 JavaScriptQuotes: Leave JavaScriptWrapImports: true -KeepEmptyLinesAtTheStartOfBlocks: true -MacroBlockBegin: '' -MacroBlockEnd: '' -MaxEmptyLinesToKeep: 2 +KeepEmptyLines: + AtEndOfFile: false + AtStartOfBlock: true + AtStartOfFile: true +LambdaBodyIndentation: Signature +LineEnding: LF +MacroBlockBegin: "" +MacroBlockEnd: "" +MainIncludeChar: Quote +MaxEmptyLinesToKeep: 1 NamespaceIndentation: All ObjCBinPackProtocolList: Auto ObjCBlockIndentWidth: 2 +ObjCBreakBeforeNestedBlockParam: true ObjCSpaceAfterProperty: false ObjCSpaceBeforeProtocolList: true +PPIndentWidth: -1 +PackConstructorInitializers: BinPack PenaltyBreakAssignment: 2 PenaltyBreakBeforeFirstCallParameter: 19 PenaltyBreakComment: 300 PenaltyBreakFirstLessLess: 120 +PenaltyBreakOpenParenthesis: 0 +PenaltyBreakScopeResolution: 500 PenaltyBreakString: 1000 PenaltyBreakTemplateDeclaration: 10 PenaltyExcessCharacter: 1000000 +PenaltyIndentedWhitespace: 0 PenaltyReturnTypeOnItsOwnLine: 1000 PointerAlignment: Right -ReflowComments: false -SortIncludes: true -SortUsingDeclarations: true +QualifierAlignment: Left +ReferenceAlignment: Pointer +ReflowComments: true +RemoveBracesLLVM: false +RemoveParentheses: Leave +RemoveSemicolon: false +RequiresClausePosition: OwnLine +RequiresExpressionIndentation: OuterScope +SeparateDefinitionBlocks: Leave +ShortNamespaceLines: 1 +SkipMacroDefinitionBody: false +SortIncludes: CaseSensitive +SortJavaStaticImport: Before +SortUsingDeclarations: LexicographicNumeric SpaceAfterCStyleCast: false SpaceAfterLogicalNot: false SpaceAfterTemplateKeyword: true +SpaceAroundPointerQualifiers: Default SpaceBeforeAssignmentOperators: true +SpaceBeforeCaseColon: false SpaceBeforeCpp11BracedList: false SpaceBeforeCtorInitializerColon: true SpaceBeforeInheritanceColon: true -SpaceBeforeParens: ControlStatements +SpaceBeforeJsonColon: false +SpaceBeforeParens: ControlStatementsExceptControlMacros +SpaceBeforeParensOptions: + AfterControlStatements: false + AfterForeachMacros: false + AfterFunctionDeclarationName: false + AfterFunctionDefinitionName: false + AfterIfMacros: false + AfterOverloadedOperator: false + AfterPlacementOperator: true + AfterRequiresInClause: false + AfterRequiresInExpression: false + BeforeNonEmptyParentheses: false SpaceBeforeRangeBasedForLoopColon: true -SpaceInEmptyBlock: false -SpaceInEmptyParentheses: false -SpacesBeforeTrailingComments: 1 -SpacesInAngles: false -SpacesInConditionalStatement: false -SpacesInContainerLiterals: true -SpacesInCStyleCastParentheses: false -SpacesInParentheses: false -SpacesInSquareBrackets: false SpaceBeforeSquareBrackets: false -Standard: Latest +SpaceInEmptyBlock: false +SpacesBeforeTrailingComments: 1 +SpacesInAngles: Never +SpacesInContainerLiterals: true +SpacesInLineCommentPrefix: + Minimum: 1 + Maximum: -1 +SpacesInParens: Never +SpacesInParensOptions: + ExceptDoubleParentheses: false + InConditionalStatements: false + InCStyleCasts: false + InEmptyParentheses: false + Other: false +SpacesInSquareBrackets: false +Standard: Latest +StatementAttributeLikeMacros: + - Q_EMIT StatementMacros: - Q_UNUSED - QT_REQUIRE_VERSION -TabWidth: 4 -UseCRLF: false -UseTab: Never -... +TabWidth: 8 +TableGenBreakInsideDAGArg: DontBreak +UseTab: Never +VerilogBreakBetweenInstancePorts: true +WhitespaceSensitiveMacros: + - BOOST_PP_STRINGIZE + - CF_SWIFT_NAME + - NS_SWIFT_NAME + - PP_STRINGIZE + - STRINGIZE +AllowAllConstructorInitializersOnNextLine: false +Language: Cpp diff --git a/Libraries/FsLib b/Libraries/FsLib index 06eb888..5c1c56f 160000 --- a/Libraries/FsLib +++ b/Libraries/FsLib @@ -1 +1 @@ -Subproject commit 06eb88857db32e2cd54b143d9ea7ac28b1e20ff2 +Subproject commit 5c1c56fb8fbb7f67f67c55417adbf5cd1feaba77 diff --git a/include/JKSV.hpp b/include/JKSV.hpp index 5027b40..cfadab3 100644 --- a/include/JKSV.hpp +++ b/include/JKSV.hpp @@ -1,6 +1,7 @@ #pragma once -#include "appstates/AppState.hpp" +#include "appstates/BaseState.hpp" #include "sdl.hpp" + #include #include diff --git a/include/StateManager.hpp b/include/StateManager.hpp index 1dfdcb1..ea14b31 100644 --- a/include/StateManager.hpp +++ b/include/StateManager.hpp @@ -1,5 +1,6 @@ #pragma once -#include "appstates/AppState.hpp" +#include "appstates/BaseState.hpp" + #include #include @@ -7,10 +8,10 @@ class StateManager { public: // Singleton. No copying or constructing. - StateManager(const StateManager &) = delete; - StateManager(StateManager &&) = delete; + StateManager(const StateManager &) = delete; + StateManager(StateManager &&) = delete; StateManager &operator=(const StateManager &) = delete; - StateManager &operator=(StateManager &&) = delete; + StateManager &operator=(StateManager &&) = delete; /// @brief Runs the state update routine. static void update(); @@ -23,7 +24,7 @@ class StateManager /// @brief Pushes a new state to the state vector. /// @param newState Shared_ptr to state to push. - static void push_state(std::shared_ptr newState); + static void push_state(std::shared_ptr newState); private: /// @brief Private constructor so no constructing. @@ -34,5 +35,5 @@ class StateManager static StateManager &get_instance(); /// @brief This is the vector that holds the pointers to the states. - static inline std::vector> sm_stateVector; + static inline std::vector> sm_stateVector; }; diff --git a/include/appstates/BackupMenuState.hpp b/include/appstates/BackupMenuState.hpp index 44c8045..0c721c8 100644 --- a/include/appstates/BackupMenuState.hpp +++ b/include/appstates/BackupMenuState.hpp @@ -1,5 +1,5 @@ #pragma once -#include "appstates/AppState.hpp" +#include "appstates/BaseState.hpp" #include "data/data.hpp" #include "fslib.hpp" #include "sdl.hpp" @@ -7,10 +7,11 @@ #include "ui/Menu.hpp" #include "ui/SlideOutPanel.hpp" #include "ui/TextScroll.hpp" + #include /// @brief This is the state where the user can backup and restore saves. -class BackupMenuState final : public AppState +class BackupMenuState final : public BaseState { public: /// @brief Creates a new backup selection state. @@ -55,43 +56,44 @@ class BackupMenuState final : public AppState private: /// @brief Pointer to current user. - data::User *m_user = nullptr; + data::User *m_user{}; /// @brief Pointer to data for selected title. - data::TitleInfo *m_titleInfo = nullptr; + data::TitleInfo *m_titleInfo{}; /// @brief Save data type we're working with. - FsSaveDataType m_saveType; + FsSaveDataType m_saveType{}; /// @brief Path to the target directory of the title. - fslib::Path m_directoryPath; + fslib::Path m_directoryPath{}; /// @brief Directory listing of the above. - fslib::Directory m_directoryListing; + fslib::Directory m_directoryListing{}; /// @brief This is the scrolling text at the top. - ui::TextScroll m_titleScroll; + ui::TextScroll m_titleScroll{}; /// @brief Variable that saves whether or not the filesystem has data in it. - bool m_saveHasData = false; + bool m_saveHasData{}; /// @brief Data struct passed to functions. - std::shared_ptr m_dataStruct; + std::shared_ptr m_dataStruct{}; - /// @brief Whether or not anything beyond this point needs to be init'd. Everything here is static and shared by all instances. - static inline bool sm_isInitialized = false; + /// @brief Whether or not anything beyond this point needs to be init'd. Everything here is static and shared by all + /// instances. + static inline bool sm_isInitialized{}; /// @brief The menu used by all instances of BackupMenuState. - static inline std::shared_ptr sm_backupMenu = nullptr; + static inline std::shared_ptr sm_backupMenu{}; /// @brief The slide out panel used by all instances of BackupMenuState. - static inline std::unique_ptr sm_slidePanel = nullptr; + static inline std::unique_ptr sm_slidePanel{}; /// @brief Inner render target so the menu only renders to a certain area. - static inline sdl::SharedTexture sm_menuRenderTarget = nullptr; + static inline sdl::SharedTexture sm_menuRenderTarget{}; /// @brief The width of the panels. This is set according to the control guide text. - static inline int sm_panelWidth = 0; + static inline int sm_panelWidth{}; /// @brief This is the function called when New Backup is selected. void name_and_create_backup(); diff --git a/include/appstates/AppState.hpp b/include/appstates/BaseState.hpp similarity index 91% rename from include/appstates/AppState.hpp rename to include/appstates/BaseState.hpp index 6b48825..506ef7a 100644 --- a/include/appstates/AppState.hpp +++ b/include/appstates/BaseState.hpp @@ -1,16 +1,17 @@ #pragma once #include "sdl.hpp" + #include -class AppState +class BaseState { public: /// @brief Base application state class. /// @param isClosable Optional. Controls whether or not the state should allow JKSV to close. - AppState(bool isClosable = true); + BaseState(bool isClosable = true); /// @brief Ends homebutton and plus locking. - virtual ~AppState(); + virtual ~BaseState(); /// @brief Every derived class is required to have this function. virtual void update() = 0; @@ -47,8 +48,8 @@ class AppState bool m_isActive = true; /// @brief Stores whether or not the state has focus. - bool m_hasFocus = false; + bool m_hasFocus{}; /// @brief Stores whether or not the state allows closing. - bool m_isClosable = true; + bool m_isClosable{}; }; diff --git a/include/appstates/BaseTask.hpp b/include/appstates/BaseTask.hpp index 6dc577c..df248d2 100644 --- a/include/appstates/BaseTask.hpp +++ b/include/appstates/BaseTask.hpp @@ -1,12 +1,13 @@ #pragma once -#include "appstates/AppState.hpp" +#include "appstates/BaseState.hpp" #include "system/Timer.hpp" #include "ui/ColorMod.hpp" + #include #include /// @brief Normally, I wouldn't do this, but this holds a single function both TaskState and ProgressState share... -class BaseTask : public AppState +class BaseTask : public BaseState { public: /// @brief Constructor. Starts the glyph timer and sets AppState to not allow closing. @@ -28,13 +29,13 @@ class BaseTask : public AppState private: /// @brief This is the current frame of the loading glyph animation. - int m_currentFrame = 0; + int m_currentFrame{}; /// @brief This is the timer used for changing the current glyph/frame of the animation. - sys::Timer m_frameTimer; + sys::Timer m_frameTimer{}; /// @brief This is used to give the animation its pulsing color. - ui::ColorMod m_colorMod; + ui::ColorMod m_colorMod{}; /// @brief This array holds the glyphs of the loading sequence. I think it's from the Wii? static inline std::array sm_glyphArray = diff --git a/include/appstates/ConfirmState.hpp b/include/appstates/ConfirmState.hpp index d09d7ad..3245dc7 100644 --- a/include/appstates/ConfirmState.hpp +++ b/include/appstates/ConfirmState.hpp @@ -1,6 +1,6 @@ #pragma once #include "StateManager.hpp" -#include "appstates/AppState.hpp" +#include "appstates/BaseState.hpp" #include "appstates/ProgressState.hpp" #include "appstates/TaskState.hpp" #include "colors.hpp" @@ -9,6 +9,7 @@ #include "strings.hpp" #include "system/Task.hpp" #include "ui/render_functions.hpp" + #include #include #include @@ -24,10 +25,11 @@ namespace /// @tparam StateType The state type spawned on confirmation. Ex: TaskState, ProgressState /// @tparam StructType The type of struct passed to the state on confirmation. template -class ConfirmState final : public AppState +class ConfirmState final : public BaseState { public: - /// @brief All functions passed to this state need to follow this signature: void function( *, std::shared_ptr<>) + /// @brief All functions passed to this state need to follow this signature: void function( *, + /// std::shared_ptr<>) using TaskFunction = void (*)(TaskType *, std::shared_ptr); /// @brief Constructor for new ConfirmState. @@ -39,12 +41,16 @@ class ConfirmState final : public AppState bool holdRequired, TaskFunction function, std::shared_ptr dataStruct) - : AppState(false), m_queryString(queryString), m_yesString(strings::get_by_name(strings::names::YES_NO, 0)), - m_hold(holdRequired), m_function(function), m_dataStruct(dataStruct) + : BaseState(false) + , m_queryString(queryString) + , m_yesString(strings::get_by_name(strings::names::YES_NO, 0)) + , m_hold(holdRequired) + , m_function(function) + , m_dataStruct(dataStruct) { // This is to make centering the Yes [A] string more accurate. m_yesX = YES_X_CENTER_COORDINATE - (sdl::text::get_width(22, m_yesString.c_str()) / 2); - m_noX = 820 - (sdl::text::get_width(22, strings::get_by_name(strings::names::YES_NO, 1)) / 2); + m_noX = 820 - (sdl::text::get_width(22, strings::get_by_name(strings::names::YES_NO, 1)) / 2); } /// @brief Required even if it does nothing. @@ -53,15 +59,13 @@ class ConfirmState final : public AppState /// @brief Just updates the ConfirmState. void update() override { - // This is to guard against the dialog being triggered right away. To do: Maybe figure out a better way to accomplish this? - if (input::button_pressed(HidNpadButton_A) && !m_triggerGuard) - { - m_triggerGuard = true; - } + // This is to guard against the dialog being triggered right away. To do: Maybe figure out a better way to + // accomplish this? + if (input::button_pressed(HidNpadButton_A) && !m_triggerGuard) { m_triggerGuard = true; } if (m_triggerGuard && input::button_pressed(HidNpadButton_A) && !m_hold) { - AppState::deactivate(); + BaseState::deactivate(); auto newState = std::make_shared(m_function, m_dataStruct); @@ -71,39 +75,40 @@ class ConfirmState final : public AppState { // Get the starting tick count and change the Yes string to the first holding string. m_startingTickCount = SDL_GetTicks64(); - m_yesString = strings::get_by_name(strings::names::HOLDING_STRINGS, 0); + m_yesString = strings::get_by_name(strings::names::HOLDING_STRINGS, 0); } else if (m_triggerGuard && input::button_held(HidNpadButton_A) && m_hold) { uint64_t TickCount = SDL_GetTicks64() - m_startingTickCount; - // If the TickCount is >= 3 seconds, confirmed. Else, just change the string so we can see we're not holding for nothing? + // If the TickCount is >= 3 seconds, confirmed. Else, just change the string so we can see we're not holding for + // nothing? if (TickCount >= 3000) { - AppState::deactivate(); + BaseState::deactivate(); auto newState = std::make_shared(m_function, m_dataStruct); } else if (TickCount >= 2000) { m_yesString = strings::get_by_name(strings::names::HOLDING_STRINGS, 2); - m_yesX = YES_X_CENTER_COORDINATE - (sdl::text::get_width(22, m_yesString.c_str()) / 2); + m_yesX = YES_X_CENTER_COORDINATE - (sdl::text::get_width(22, m_yesString.c_str()) / 2); } else if (TickCount >= 1000) { m_yesString = strings::get_by_name(strings::names::HOLDING_STRINGS, 1); - m_yesX = YES_X_CENTER_COORDINATE - (sdl::text::get_width(22, m_yesString.c_str()) / 2); + m_yesX = YES_X_CENTER_COORDINATE - (sdl::text::get_width(22, m_yesString.c_str()) / 2); } } else if (input::button_released(HidNpadButton_A)) { m_yesString = strings::get_by_name(strings::names::YES_NO, 0); - m_yesX = YES_X_CENTER_COORDINATE - (sdl::text::get_width(22, m_yesString.c_str()) / 2); + m_yesX = YES_X_CENTER_COORDINATE - (sdl::text::get_width(22, m_yesString.c_str()) / 2); } else if (input::button_pressed(HidNpadButton_B)) { // Just deactivate and don't do anything. - AppState::deactivate(); + BaseState::deactivate(); } } @@ -132,10 +137,10 @@ class ConfirmState final : public AppState private: /// @brief String displayed - std::string m_queryString; + std::string m_queryString{}; /// @brief Yes or [X] [A] - std::string m_yesString; + std::string m_yesString{}; /// @brief X coordinate to render the Yes [A] int m_yesX{}; @@ -144,17 +149,17 @@ class ConfirmState final : public AppState int m_noX{}; /// @brief This is to prevent the dialog from triggering immediately. - bool m_triggerGuard = false; + bool m_triggerGuard{}; /// @brief Whether or not holding [A] to confirm is required. - bool m_hold; + bool m_hold{}; /// @brief Keep track of the ticks/time needed to confirm. uint64_t m_startingTickCount{}; /// @brief Function to execute if action is confirmed. - TaskFunction m_function; + TaskFunction m_function{}; /// @brief Pointer to data struct passed to ^ - std::shared_ptr m_dataStruct; + std::shared_ptr m_dataStruct{}; }; diff --git a/include/appstates/ExtrasMenuState.hpp b/include/appstates/ExtrasMenuState.hpp index 8ec4eeb..919673a 100644 --- a/include/appstates/ExtrasMenuState.hpp +++ b/include/appstates/ExtrasMenuState.hpp @@ -1,10 +1,10 @@ #pragma once -#include "appstates/AppState.hpp" +#include "appstates/BaseState.hpp" #include "sdl.hpp" #include "ui/Menu.hpp" /// @brief Extras menu. -class ExtrasMenuState final : public AppState +class ExtrasMenuState final : public BaseState { public: /// @brief Constructor. @@ -24,5 +24,5 @@ class ExtrasMenuState final : public AppState ui::Menu m_extrasMenu; /// @brief Render target for menu. - sdl::SharedTexture m_renderTarget; + sdl::SharedTexture m_renderTarget{}; }; diff --git a/include/appstates/MainMenuState.hpp b/include/appstates/MainMenuState.hpp index 2c45ec9..5d5ddf4 100644 --- a/include/appstates/MainMenuState.hpp +++ b/include/appstates/MainMenuState.hpp @@ -1,12 +1,13 @@ #pragma once -#include "appstates/AppState.hpp" +#include "appstates/BaseState.hpp" #include "data/data.hpp" #include "sdl.hpp" #include "ui/IconMenu.hpp" + #include /// @brief The main -class MainMenuState final : public AppState +class MainMenuState final : public BaseState { public: /// @brief Creates and initializes the main menu. @@ -29,35 +30,35 @@ class MainMenuState final : public AppState private: /// @brief Render target this state renders to. - sdl::SharedTexture m_renderTarget = nullptr; + sdl::SharedTexture m_renderTarget{}; /// @brief The background gradient. - sdl::SharedTexture m_background = nullptr; + sdl::SharedTexture m_background{}; /// @brief Icon for the settings option, - sdl::SharedTexture m_settingsIcon = nullptr; + sdl::SharedTexture m_settingsIcon{}; /// @brief Icon for the extras option. - sdl::SharedTexture m_extrasIcon = nullptr; + sdl::SharedTexture m_extrasIcon{}; /// @brief Special menu type that uses icons. ui::IconMenu m_mainMenu; /// @brief Pointer to control guide string so I don't need to call string::getByName every loop. - const char *m_controlGuide = nullptr; + const char *m_controlGuide{}; /// @brief X coordinate of the control guide in the bottom right corner. - int m_controlGuideX; + int m_controlGuideX{}; /// @brief This is the list of user pointers from data. - static inline data::UserList sm_users; + static inline data::UserList sm_users{}; /// @brief This is the pointer to the settings state. - static inline std::shared_ptr sm_settingsState = nullptr; + static inline std::shared_ptr sm_settingsState{}; /// @brief This is the pointer to the extras state. - static inline std::shared_ptr sm_extrasState = nullptr; + static inline std::shared_ptr sm_extrasState{}; /// @brief This is the vector of title selection states. - static inline std::vector> sm_states; + static inline std::vector> sm_states{}; }; diff --git a/include/appstates/ProgressState.hpp b/include/appstates/ProgressState.hpp index 2ed5429..907cfa2 100644 --- a/include/appstates/ProgressState.hpp +++ b/include/appstates/ProgressState.hpp @@ -1,6 +1,7 @@ #pragma once #include "appstates/BaseTask.hpp" #include "system/ProgressTask.hpp" + #include #include @@ -14,7 +15,8 @@ class ProgressState final : public BaseTask /// @note All functions passed to this must follow this signature: void function(sys::ProgressTask *, ) template ProgressState(void (*function)(sys::ProgressTask *, Args...), Args... args) - : BaseTask(), m_task(function, std::forward(args)...){}; + : BaseTask() + , m_task(function, std::forward(args)...){}; /// @brief Required destructor. ~ProgressState() {}; @@ -30,14 +32,14 @@ class ProgressState final : public BaseTask sys::ProgressTask m_task; /// @brief Progress which is saved as a rounded whole number. - size_t m_progress = 0; + size_t m_progress{}; /// @brief Width of the green bar in pixels. - size_t m_progressBarWidth = 0; + size_t m_progressBarWidth{}; /// @brief X coordinate of the percentage string. - int m_percentageX = 0; + int m_percentageX{}; /// @brief Percentage as a string for printing to screen. - std::string m_percentageString; + std::string m_percentageString{}; }; diff --git a/include/appstates/SaveCreateState.hpp b/include/appstates/SaveCreateState.hpp index 0751fce..b3a3282 100644 --- a/include/appstates/SaveCreateState.hpp +++ b/include/appstates/SaveCreateState.hpp @@ -1,13 +1,14 @@ #pragma once -#include "appstates/AppState.hpp" +#include "appstates/BaseState.hpp" #include "appstates/TitleSelectCommon.hpp" #include "data/data.hpp" #include "ui/Menu.hpp" #include "ui/SlideOutPanel.hpp" + #include /// @brief This is the state that is spawned when CreateSaveData is selected from the user menu. -class SaveCreateState final : public AppState +class SaveCreateState final : public BaseState { public: /// @brief Constructs a new SaveCreateState. @@ -29,20 +30,20 @@ class SaveCreateState final : public AppState private: /// @brief Pointer to target user. - data::User *m_user; + data::User *m_user{}; /// @brief Pointer to title selection view for the current user. - TitleSelectCommon *m_titleSelect; + TitleSelectCommon *m_titleSelect{}; /// @brief Menu populated with every title found on the system. ui::Menu m_saveMenu; /// @brief Vector of pointers to the title info. This allows sorting them alphabetically and other things. - std::vector m_titleInfoVector; + std::vector m_titleInfoVector{}; /// @brief Whether or not a refresh is required on the next update() call. - bool m_refreshRequired = false; + bool m_refreshRequired{}; /// @brief Shared slide panel all instances use. There's no point in allocating a new one every time. - static inline std::unique_ptr sm_slidePanel = nullptr; + static inline std::unique_ptr sm_slidePanel{}; }; diff --git a/include/appstates/SettingsState.hpp b/include/appstates/SettingsState.hpp index 331facb..29fa30d 100644 --- a/include/appstates/SettingsState.hpp +++ b/include/appstates/SettingsState.hpp @@ -1,10 +1,10 @@ #pragma once -#include "appstates/AppState.hpp" +#include "appstates/BaseState.hpp" #include "sdl.hpp" #include "ui/Menu.hpp" /// @brief The state for settings. -class SettingsState final : public AppState +class SettingsState final : public BaseState { public: /// @brief Constructs a new settings state. @@ -24,10 +24,10 @@ class SettingsState final : public AppState ui::Menu m_settingsMenu; /// @brief Render target to render to. - sdl::SharedTexture m_renderTarget = nullptr; + sdl::SharedTexture m_renderTarget{}; /// @brief X coordinate of the control guide in the bottom right corner. - int m_controlGuideX = 0; + int m_controlGuideX{}; /// @brief Runs a routine to update the menu strings for the menu. void update_menu_options(); diff --git a/include/appstates/TaskState.hpp b/include/appstates/TaskState.hpp index 3c8d4d1..e2b343a 100644 --- a/include/appstates/TaskState.hpp +++ b/include/appstates/TaskState.hpp @@ -1,6 +1,7 @@ #pragma once #include "appstates/BaseTask.hpp" #include "system/Task.hpp" + #include /// @brief State that spawns a task and allows updates to be printed to screen. @@ -13,7 +14,8 @@ class TaskState final : public BaseTask /// @note All functions passed must follow this signature: void function(sys::Task *, ) template TaskState(void (*function)(sys::Task *, Args...), Args... args) - : BaseTask(), m_task(function, std::forward(args)...){}; + : BaseTask() + , m_task(function, std::forward(args)...){}; /// @brief Required destructor. ~TaskState() {}; diff --git a/include/appstates/TextTitleSelectState.hpp b/include/appstates/TextTitleSelectState.hpp index bca702b..0bee168 100644 --- a/include/appstates/TextTitleSelectState.hpp +++ b/include/appstates/TextTitleSelectState.hpp @@ -26,11 +26,11 @@ class TextTitleSelectState final : public TitleSelectCommon private: /// @brief Pointer to user view "belongs" to. - data::User *m_user; + data::User *m_user{}; /// @brief Menu to display titles to select from. ui::Menu m_titleSelectMenu; /// @brief Target to render to. - sdl::SharedTexture m_renderTarget; + sdl::SharedTexture m_renderTarget{}; }; diff --git a/include/appstates/TitleInfoState.hpp b/include/appstates/TitleInfoState.hpp index 5d1d24b..813615c 100644 --- a/include/appstates/TitleInfoState.hpp +++ b/include/appstates/TitleInfoState.hpp @@ -1,13 +1,14 @@ #pragma once -#include "appstates/AppState.hpp" +#include "appstates/BaseState.hpp" #include "data/data.hpp" #include "system/Timer.hpp" #include "ui/SlideOutPanel.hpp" #include "ui/TextScroll.hpp" + #include #include -class TitleInfoState final : public AppState +class TitleInfoState final : public BaseState { public: /// @brief Constructs a new title info state. @@ -26,50 +27,50 @@ class TitleInfoState final : public AppState private: /// @brief Pointer to user. - data::User *m_user; + data::User *m_user{}; /// @brief Pointer to title info. - data::TitleInfo *m_titleInfo; + data::TitleInfo *m_titleInfo{}; /// @brief This is a pointer to the title's icon. - sdl::SharedTexture m_icon; + sdl::SharedTexture m_icon{}; /// @brief This is the scrolling text for the title. - ui::TextScroll m_titleScroll; + ui::TextScroll m_titleScroll{}; /// @brief This is the scrolling text for the publisher. - ui::TextScroll m_publisherScroll; + ui::TextScroll m_publisherScroll{}; /// @brief This string holds the application ID. - std::string m_applicationID; + std::string m_applicationID{}; /// @brief This holds the hex save data id of the file on nand. - std::string m_saveDataID; + std::string m_saveDataID{}; /// @brief This holds the time the game was first played. - std::string m_firstPlayed; + std::string m_firstPlayed{}; /// @brief This holds the last played timestamp. - std::string m_lastPlayed; + std::string m_lastPlayed{}; /// @brief This holds the play time string. - std::string m_playTime; + std::string m_playTime{}; /// @brief This holds the total launches string. - std::string m_totalLaunches; + std::string m_totalLaunches{}; /// @brief This holds the save data type string. - std::string m_saveDataType; + std::string m_saveDataType{}; /// @brief Bool to tell whether or not static members are initialized. - static inline bool sm_initialized = false; + static inline bool sm_initialized{}; /// @brief This is the render target for the title text just in case it needs scrolling. - static inline sdl::SharedTexture sm_titleTarget = nullptr; + static inline sdl::SharedTexture sm_titleTarget{}; /// @brief This is the render target for the publisher string. - static inline sdl::SharedTexture sm_publisherTarget = nullptr; + static inline sdl::SharedTexture sm_publisherTarget{}; /// @brief Slide panel. - static inline std::unique_ptr sm_slidePanel = nullptr; + static inline std::unique_ptr sm_slidePanel{}; }; diff --git a/include/appstates/TitleOptionState.hpp b/include/appstates/TitleOptionState.hpp index c0023c6..26613cd 100644 --- a/include/appstates/TitleOptionState.hpp +++ b/include/appstates/TitleOptionState.hpp @@ -1,12 +1,13 @@ #pragma once -#include "appstates/AppState.hpp" +#include "appstates/BaseState.hpp" #include "appstates/TitleSelectCommon.hpp" #include "data/data.hpp" #include "ui/Menu.hpp" #include "ui/SlideOutPanel.hpp" + #include -class TitleOptionState final : public AppState +class TitleOptionState final : public BaseState { public: /// @brief Constructs a new title option state. @@ -33,43 +34,43 @@ class TitleOptionState final : public AppState typedef struct { /// @brief Pointer to the target user. - data::User *m_user = nullptr; + data::User *m_user{}; /// @brief The target title's data. - data::TitleInfo *m_titleInfo = nullptr; + data::TitleInfo *m_titleInfo{}; /// @brief Allows tasks to signal deactivation. - TitleOptionState *m_spawningState = nullptr; + TitleOptionState *m_spawningState{}; /// @brief The target title select. This is used for updating it. - TitleSelectCommon *m_titleSelect = nullptr; + TitleSelectCommon *m_titleSelect{}; } DataStruct; private: /// @brief This is just in case the option should only apply to the current user. - data::User *m_user = nullptr; + data::User *m_user{}; /// @brief This is the target title. - data::TitleInfo *m_titleInfo = nullptr; + data::TitleInfo *m_titleInfo{}; /// @brief Pointer to the title selection being used for updating. - TitleSelectCommon *m_titleSelect; + TitleSelectCommon *m_titleSelect{}; /// @brief The struct passed to functions. - std::shared_ptr m_dataStruct; + std::shared_ptr m_dataStruct{}; /// @brief This holds whether or not the state should deactivate itself on the next update loop. - bool m_exitRequired = false; + bool m_exitRequired{}; /// @brief This stores whether or a not a refresh is required on the next update(). - bool m_refreshRequired = false; + bool m_refreshRequired{}; /// @brief This is so it's known whether or not to initialize the static members of this class. - static inline bool sm_initialized = false; + static inline bool sm_initialized{}; /// @brief Menu used and shared by all instances. - static inline std::unique_ptr sm_titleOptionMenu = nullptr; + static inline std::unique_ptr sm_titleOptionMenu{}; /// @brief This is shared by all instances of this class. - static inline std::unique_ptr sm_slidePanel = nullptr; + static inline std::unique_ptr sm_slidePanel{}; }; diff --git a/include/appstates/TitleSelectCommon.hpp b/include/appstates/TitleSelectCommon.hpp index 1ff5ac6..c09628b 100644 --- a/include/appstates/TitleSelectCommon.hpp +++ b/include/appstates/TitleSelectCommon.hpp @@ -1,11 +1,12 @@ #pragma once -#include "appstates/AppState.hpp" +#include "appstates/BaseState.hpp" /// @brief Class that both view types are derived from. -class TitleSelectCommon : public AppState +class TitleSelectCommon : public BaseState { public: - /// @brief Constructs a new TitleSelectCommon. Basically just calculates the X coordinate of the control if it wasn't already. + /// @brief Constructs a new TitleSelectCommon. Basically just calculates the X coordinate of the control if it wasn't + /// already. TitleSelectCommon(); /// @brief Required destructor. @@ -25,5 +26,5 @@ class TitleSelectCommon : public AppState private: /// @brief X coordinate the control guide is rendered at. - static inline int m_titleControlsX = 0; + static inline int m_titleControlsX{}; }; diff --git a/include/appstates/TitleSelectState.hpp b/include/appstates/TitleSelectState.hpp index a60faf6..ab2d0f3 100644 --- a/include/appstates/TitleSelectState.hpp +++ b/include/appstates/TitleSelectState.hpp @@ -26,10 +26,10 @@ class TitleSelectState final : public TitleSelectCommon private: /// @brief Pointer to the user the view belongs to. - data::User *m_user = nullptr; + data::User *m_user{}; /// @brief Target to render to. - sdl::SharedTexture m_renderTarget = nullptr; + sdl::SharedTexture m_renderTarget{}; /// @brief Tiled title selection view. ui::TitleView m_titleView; diff --git a/include/appstates/UserOptionState.hpp b/include/appstates/UserOptionState.hpp index 1dda929..a2051bc 100644 --- a/include/appstates/UserOptionState.hpp +++ b/include/appstates/UserOptionState.hpp @@ -1,13 +1,14 @@ #pragma once -#include "appstates/AppState.hpp" +#include "appstates/BaseState.hpp" #include "appstates/TitleSelectCommon.hpp" #include "data/data.hpp" #include "ui/Menu.hpp" #include "ui/SlideOutPanel.hpp" + #include /// @brief State that allows certain actions to be taken for users. -class UserOptionState final : public AppState +class UserOptionState final : public BaseState { public: /// @brief Constructs a new UserOptionState. @@ -32,28 +33,28 @@ class UserOptionState final : public AppState typedef struct { /// @brief Pointer to the target user. - data::User *m_user; + data::User *m_user{}; /// @brief Pointer to >this spawning state. - UserOptionState *m_spawningState; + UserOptionState *m_spawningState{}; } DataStruct; private: /// @brief Pointer to the target user. - data::User *m_user; + data::User *m_user{}; /// @brief Pointer to the selection view. - TitleSelectCommon *m_titleSelect; + TitleSelectCommon *m_titleSelect{}; /// @brief Menu that displays the options available. ui::Menu m_userOptionMenu; /// @brief Shared pointer to pass data to tasks and functions. - std::shared_ptr m_dataStruct; + std::shared_ptr m_dataStruct{}; /// @brief This allows spawned tasks to signal to the main thread to update the view. - bool m_refreshRequired = false; + bool m_refreshRequired{}; /// @brief Slide panel all instances shared. - static inline std::unique_ptr m_menuPanel = nullptr; + static inline std::unique_ptr m_menuPanel{}; }; diff --git a/source/JKSV.cpp b/source/JKSV.cpp index 6fe2305..bb05354 100644 --- a/source/JKSV.cpp +++ b/source/JKSV.cpp @@ -86,7 +86,7 @@ JKSV::JKSV() fslib::Path workingDirectory = config::get_working_directory(); if (!fslib::directory_exists(workingDirectory) && !fslib::create_directories_recursively(workingDirectory)) { - logger::log("Error creating working directory: %s", fslib::get_error_string()); + logger::log("Error creating working directory: %s", fslib::error::get_string()); return; } @@ -95,7 +95,7 @@ JKSV::JKSV() if (!fslib::directory_exists(sviDir) && !fslib::create_directories_recursively(sviDir)) { // This one isn't fatal, but it can be super fatal later if this fails. - logger::log("Error creating svi directory: %s", fslib::get_error_string()); + logger::log("Error creating svi directory: %s", fslib::error::get_string()); } // JKSV also has no internal strings anymore. This is FATAL now. diff --git a/source/StateManager.cpp b/source/StateManager.cpp index 5a30ad3..e2424fd 100644 --- a/source/StateManager.cpp +++ b/source/StateManager.cpp @@ -15,7 +15,7 @@ void StateManager::update() for (size_t i = instance.sm_stateVector.size() - 1; i > 0; i--) { // Grab a raw pointer to avoid reference count increase. - AppState *appState = instance.sm_stateVector.at(i).get(); + BaseState *appState = instance.sm_stateVector.at(i).get(); if (!appState->is_active()) { @@ -41,7 +41,7 @@ void StateManager::render() StateManager &instance = StateManager::get_instance(); // Loop and render all states. - for (std::shared_ptr &appState : instance.sm_stateVector) + for (std::shared_ptr &appState : instance.sm_stateVector) { appState->render(); } @@ -62,7 +62,7 @@ bool StateManager::back_is_closable() return instance.sm_stateVector.back()->is_closable(); } -void StateManager::push_state(std::shared_ptr newState) +void StateManager::push_state(std::shared_ptr newState) { // Instance. StateManager &instance = StateManager::get_instance(); diff --git a/source/appstates/AppState.cpp b/source/appstates/AppState.cpp deleted file mode 100644 index c08fbc9..0000000 --- a/source/appstates/AppState.cpp +++ /dev/null @@ -1,53 +0,0 @@ -#include "appstates/AppState.hpp" -#include - -AppState::AppState(bool isClosable) : m_isClosable(isClosable) -{ - if (!m_isClosable) - { - appletBeginBlockingHomeButton(0); - } -} - -AppState::~AppState() -{ - if (!m_isClosable) - { - appletEndBlockingHomeButton(); - } -} - -void AppState::deactivate() -{ - m_isActive = false; -} - -void AppState::reactivate() -{ - m_isActive = true; -} - -bool AppState::is_active() const -{ - return m_isActive; -} - -void AppState::give_focus() -{ - m_hasFocus = true; -} - -void AppState::take_focus() -{ - m_hasFocus = false; -} - -bool AppState::has_focus() const -{ - return m_hasFocus; -} - -bool AppState::is_closable() const -{ - return m_isClosable; -} diff --git a/source/appstates/BackupMenuState.cpp b/source/appstates/BackupMenuState.cpp index b8264e9..9789ed6 100644 --- a/source/appstates/BackupMenuState.cpp +++ b/source/appstates/BackupMenuState.cpp @@ -70,7 +70,7 @@ BackupMenuState::BackupMenuState(data::User *user, data::TitleInfo *titleInfo, F if (!fslib::directory_exists(targetPath) && !fslib::create_directory(targetPath)) { logger::log(STRING_ERROR_CONSTRUCTING, "Error creating target directory on SD!"); - AppState::deactivate(); + BaseState::deactivate(); } // Fill this out. Target path is not set here. @@ -135,7 +135,7 @@ BackupMenuState::~BackupMenuState() void BackupMenuState::update() { - bool hasFocus = AppState::has_focus(); + bool hasFocus = BaseState::has_focus(); if (input::button_pressed(HidNpadButton_A) && sm_backupMenu->get_selected() == 0 && m_saveHasData) { @@ -179,7 +179,7 @@ void BackupMenuState::update() else if (sm_slidePanel->is_closed()) { sm_slidePanel->reset(); - AppState::deactivate(); + BaseState::deactivate(); } // Update title scrolling. @@ -193,7 +193,7 @@ void BackupMenuState::update() void BackupMenuState::render() { // Save this locally. - bool hasFocus = AppState::has_focus(); + bool hasFocus = BaseState::has_focus(); // Clear panel target. sm_slidePanel->clear_target(); @@ -396,9 +396,9 @@ static void create_new_backup(sys::ProgressTask *task, bool hasMeta = fs::fill_save_meta_data(saveInfo, saveMeta); // This extension search is lazy and needs to be revised. - if (config::get_by_key(config::keys::EXPORT_TO_ZIP) || std::strstr(targetPath.c_string(), "zip")) + if (config::get_by_key(config::keys::EXPORT_TO_ZIP) || std::strstr(targetPath.full_path(), "zip")) { - zipFile newBackup = zipOpen64(targetPath.c_string(), APPEND_STATUS_CREATE); + zipFile newBackup = zipOpen64(targetPath.full_path(), APPEND_STATUS_CREATE); if (!newBackup) { // To do: Pop up. @@ -466,7 +466,7 @@ static void overwrite_backup(sys::ProgressTask *task, std::shared_ptrtargetPath)) || (fslib::file_exists(dataStruct->targetPath) && !fslib::delete_file(dataStruct->targetPath))) { - logger::log(STRING_ERROR_PREFIX, fslib::get_error_string()); + logger::log(STRING_ERROR_PREFIX, fslib::error::get_string()); task->finished(); return; } @@ -475,9 +475,9 @@ static void overwrite_backup(sys::ProgressTask *task, std::shared_ptrtargetPath.c_string())) + if (std::strstr(STRING_ZIP_EXTENSION, dataStruct->targetPath.full_path())) { - zipFile backupZip = zipOpen64(dataStruct->targetPath.c_string(), APPEND_STATUS_CREATE); + zipFile backupZip = zipOpen64(dataStruct->targetPath.full_path(), APPEND_STATUS_CREATE); if (!backupZip) { logger::log("Error overwriting backup: Couldn't create new zip!"); @@ -544,7 +544,7 @@ static void restore_backup(sys::ProgressTask *task, std::shared_ptrfinished(); @@ -572,9 +572,9 @@ static void restore_backup(sys::ProgressTask *task, std::shared_ptrtargetPath.c_string(), ".zip") != NULL) + else if (std::strstr(dataStruct->targetPath.full_path(), ".zip") != NULL) { - unzFile targetZip = unzOpen64(dataStruct->targetPath.c_string()); + unzFile targetZip = unzOpen64(dataStruct->targetPath.full_path()); if (!targetZip) { ui::PopMessageManager::push_message(ui::PopMessageManager::DEFAULT_MESSAGE_TICKS, @@ -622,18 +622,18 @@ static void delete_backup(sys::Task *task, std::shared_ptrset_status(strings::get_by_name(strings::names::DELETING_FILES, 0), dataStruct->targetPath.c_string()); + task->set_status(strings::get_by_name(strings::names::DELETING_FILES, 0), dataStruct->targetPath.full_path()); } if (fslib::directory_exists(dataStruct->targetPath) && !fslib::delete_directory_recursively(dataStruct->targetPath)) { - logger::log("Error deleting folder backup: %s", fslib::get_error_string()); + logger::log("Error deleting folder backup: %s", fslib::error::get_string()); ui::PopMessageManager::push_message(ui::PopMessageManager::DEFAULT_MESSAGE_TICKS, strings::get_by_name(strings::names::POP_MESSAGES_BACKUP_MENU, 4)); } else if (fslib::file_exists(dataStruct->targetPath) && !fslib::delete_file(dataStruct->targetPath)) { - logger::log("Error deleting backup: %s", fslib::get_error_string()); + logger::log("Error deleting backup: %s", fslib::error::get_string()); ui::PopMessageManager::push_message(ui::PopMessageManager::DEFAULT_MESSAGE_TICKS, strings::get_by_name(strings::names::POP_MESSAGES_BACKUP_MENU, 4)); } @@ -646,7 +646,7 @@ static void upload_backup(sys::ProgressTask *task, std::shared_ptrset_status(strings::get_by_name(strings::names::BACKUPMENU_STATUS, 1), - dataStruct->targetPath.get_filename().data()); + dataStruct->targetPath.get_filename()); } // To do: This but flashier. diff --git a/source/appstates/BaseState.cpp b/source/appstates/BaseState.cpp new file mode 100644 index 0000000..87b5d35 --- /dev/null +++ b/source/appstates/BaseState.cpp @@ -0,0 +1,28 @@ +#include "appstates/BaseState.hpp" + +#include + +BaseState::BaseState(bool isClosable) + : m_isClosable(isClosable) +{ + if (!m_isClosable) { appletBeginBlockingHomeButton(0); } +} + +BaseState::~BaseState() +{ + if (!m_isClosable) { appletEndBlockingHomeButton(); } +} + +void BaseState::deactivate() { m_isActive = false; } + +void BaseState::reactivate() { m_isActive = true; } + +bool BaseState::is_active() const { return m_isActive; } + +void BaseState::give_focus() { m_hasFocus = true; } + +void BaseState::take_focus() { m_hasFocus = false; } + +bool BaseState::has_focus() const { return m_hasFocus; } + +bool BaseState::is_closable() const { return m_isClosable; } diff --git a/source/appstates/BaseTask.cpp b/source/appstates/BaseTask.cpp index 7f61fb8..9482860 100644 --- a/source/appstates/BaseTask.cpp +++ b/source/appstates/BaseTask.cpp @@ -7,7 +7,7 @@ namespace constexpr uint64_t TICKS_GLYPH_TRIGGER = 50; } // namespace -BaseTask::BaseTask() : AppState(false) +BaseTask::BaseTask() : BaseState(false) { m_frameTimer.start(TICKS_GLYPH_TRIGGER); } diff --git a/source/appstates/ExtrasMenuState.cpp b/source/appstates/ExtrasMenuState.cpp index 26a820e..edf7fea 100644 --- a/source/appstates/ExtrasMenuState.cpp +++ b/source/appstates/ExtrasMenuState.cpp @@ -43,7 +43,9 @@ ExtrasMenuState::ExtrasMenuState() void ExtrasMenuState::update() { - m_extrasMenu.update(AppState::has_focus()); + const bool hasFocus = BaseState::has_focus(); + + m_extrasMenu.update(hasFocus); if (input::button_pressed(HidNpadButton_A)) { @@ -64,13 +66,15 @@ void ExtrasMenuState::update() } else if (input::button_pressed(HidNpadButton_B)) { - AppState::deactivate(); + BaseState::deactivate(); } } void ExtrasMenuState::render() { + const bool hasFocus = BaseState::has_focus(); + m_renderTarget->clear(colors::TRANSPARENT); - m_extrasMenu.render(m_renderTarget->get(), AppState::has_focus()); + m_extrasMenu.render(m_renderTarget->get(), hasFocus); m_renderTarget->render(NULL, 201, 91); } diff --git a/source/appstates/MainMenuState.cpp b/source/appstates/MainMenuState.cpp index 4214e15..3c47110 100644 --- a/source/appstates/MainMenuState.cpp +++ b/source/appstates/MainMenuState.cpp @@ -48,8 +48,10 @@ MainMenuState::MainMenuState() void MainMenuState::update() { + const bool hasFocus = BaseState::has_focus(); + // Update the main menu. - m_mainMenu.update(AppState::has_focus()); + m_mainMenu.update(hasFocus); int selected = m_mainMenu.get_selected(); @@ -77,15 +79,17 @@ void MainMenuState::update() void MainMenuState::render() { + const bool hasFocus = BaseState::has_focus(); + // Clear render target by rendering background to it. m_background->render(m_renderTarget->get(), 0, 0); // render menu. - m_mainMenu.render(m_renderTarget->get(), AppState::has_focus()); + m_mainMenu.render(m_renderTarget->get(), hasFocus); // render target to screen. m_renderTarget->render(NULL, 0, 91); // render next state for current user and control guide if this state has focus. To do: Maybe this different? - if (AppState::has_focus()) + if (hasFocus) { sm_states.at(m_mainMenu.get_selected())->render(); sdl::text::render(NULL, m_controlGuideX, 673, 22, sdl::text::NO_TEXT_WRAP, colors::WHITE, m_controlGuide); diff --git a/source/appstates/ProgressState.cpp b/source/appstates/ProgressState.cpp index d1831c9..a04e6e5 100644 --- a/source/appstates/ProgressState.cpp +++ b/source/appstates/ProgressState.cpp @@ -20,7 +20,7 @@ void ProgressState::update() } else if (!m_task.is_running()) { - AppState::deactivate(); + BaseState::deactivate(); } m_progressBarWidth = std::ceil(656.0f * m_task.get_current()); diff --git a/source/appstates/SaveCreateState.cpp b/source/appstates/SaveCreateState.cpp index b261327..0020cfa 100644 --- a/source/appstates/SaveCreateState.cpp +++ b/source/appstates/SaveCreateState.cpp @@ -46,6 +46,8 @@ SaveCreateState::SaveCreateState(data::User *user, TitleSelectCommon *titleSelec void SaveCreateState::update() { + const bool hasFocus = BaseState::has_focus(); + if (m_refreshRequired) { // There's no other way to get the save info so... @@ -56,8 +58,8 @@ void SaveCreateState::update() m_refreshRequired = false; } - m_saveMenu.update(AppState::has_focus()); - sm_slidePanel->update(AppState::has_focus()); + m_saveMenu.update(hasFocus); + sm_slidePanel->update(hasFocus); if (input::button_pressed(HidNpadButton_A)) { @@ -71,16 +73,18 @@ void SaveCreateState::update() else if (sm_slidePanel->is_closed()) { sm_slidePanel->reset(); - AppState::deactivate(); + BaseState::deactivate(); } } void SaveCreateState::render() { + const bool hasFocus = BaseState::has_focus(); + // Clear slide target, render menu, render slide to frame buffer. sm_slidePanel->clear_target(); - m_saveMenu.render(sm_slidePanel->get_target(), AppState::has_focus()); - sm_slidePanel->render(NULL, AppState::has_focus()); + m_saveMenu.render(sm_slidePanel->get_target(), hasFocus); + sm_slidePanel->render(NULL, hasFocus); } void SaveCreateState::data_and_view_refresh_required() diff --git a/source/appstates/SettingsState.cpp b/source/appstates/SettingsState.cpp index eda5e55..19c33f4 100644 --- a/source/appstates/SettingsState.cpp +++ b/source/appstates/SettingsState.cpp @@ -64,7 +64,9 @@ SettingsState::SettingsState() void SettingsState::update() { - m_settingsMenu.update(AppState::has_focus()); + const bool hasFocus = BaseState::has_focus(); + + m_settingsMenu.update(hasFocus); if (input::button_pressed(HidNpadButton_A)) { @@ -72,17 +74,19 @@ void SettingsState::update() } else if (input::button_pressed(HidNpadButton_B)) { - AppState::deactivate(); + BaseState::deactivate(); } } void SettingsState::render() { + const bool hasFocus = BaseState::has_focus(); + m_renderTarget->clear(colors::TRANSPARENT); - m_settingsMenu.render(m_renderTarget->get(), AppState::has_focus()); + m_settingsMenu.render(m_renderTarget->get(), hasFocus); m_renderTarget->render(NULL, 201, 91); - if (AppState::has_focus()) + if (hasFocus) { sdl::text::render(NULL, m_controlGuideX, diff --git a/source/appstates/TaskState.cpp b/source/appstates/TaskState.cpp index 21efa03..0508052 100644 --- a/source/appstates/TaskState.cpp +++ b/source/appstates/TaskState.cpp @@ -18,7 +18,7 @@ void TaskState::update() } if (!m_task.is_running()) { - AppState::deactivate(); + BaseState::deactivate(); } } diff --git a/source/appstates/TextTitleSelectState.cpp b/source/appstates/TextTitleSelectState.cpp index 4b60f22..136235b 100644 --- a/source/appstates/TextTitleSelectState.cpp +++ b/source/appstates/TextTitleSelectState.cpp @@ -30,7 +30,7 @@ TextTitleSelectState::TextTitleSelectState(data::User *user) void TextTitleSelectState::update() { - m_titleSelectMenu.update(AppState::has_focus()); + m_titleSelectMenu.update(BaseState::has_focus()); // Both title selection states work too differently for this stuff to be shared IMO. if (input::button_pressed(HidNpadButton_A)) @@ -59,7 +59,7 @@ void TextTitleSelectState::update() } else { - logger::log(fslib::get_error_string()); + logger::log(fslib::error::get_string()); } } else if (input::button_pressed(HidNpadButton_X)) @@ -92,14 +92,14 @@ void TextTitleSelectState::update() } else if (input::button_pressed(HidNpadButton_B)) { - AppState::deactivate(); + BaseState::deactivate(); } } void TextTitleSelectState::render() { m_renderTarget->clear(colors::TRANSPARENT); - m_titleSelectMenu.render(m_renderTarget->get(), AppState::has_focus()); + m_titleSelectMenu.render(m_renderTarget->get(), BaseState::has_focus()); TitleSelectCommon::render_control_guide(); m_renderTarget->render(NULL, 201, 91); } diff --git a/source/appstates/TitleInfoState.cpp b/source/appstates/TitleInfoState.cpp index 7164626..50d8e66 100644 --- a/source/appstates/TitleInfoState.cpp +++ b/source/appstates/TitleInfoState.cpp @@ -103,7 +103,7 @@ TitleInfoState::~TitleInfoState() void TitleInfoState::update() { // Grab this instead of calling the function over and over. - bool hasFocus = AppState::has_focus(); + const bool hasFocus = BaseState::has_focus(); // Update slide panel. sm_slidePanel->update(hasFocus); @@ -119,7 +119,7 @@ void TitleInfoState::update() else if (sm_slidePanel->is_closed()) { sm_slidePanel->reset(); - AppState::deactivate(); + BaseState::deactivate(); } } @@ -131,7 +131,7 @@ void TitleInfoState::render() static constexpr int SIZE_RECT_WIDTH = SIZE_PANEL_WIDTH - SIZE_PANEL_SUB; // This is whether or not the state currently has focus. - bool hasFocus = AppState::has_focus(); + bool hasFocus = BaseState::has_focus(); // Clear the title and publisher targets. sm_titleTarget->clear(colors::DIALOG_BOX); @@ -240,5 +240,5 @@ void TitleInfoState::render() colors::WHITE, m_saveDataType.c_str()); - sm_slidePanel->render(NULL, AppState::has_focus()); + sm_slidePanel->render(NULL, hasFocus); } diff --git a/source/appstates/TitleOptionState.cpp b/source/appstates/TitleOptionState.cpp index 5dd08d9..381d7cf 100644 --- a/source/appstates/TitleOptionState.cpp +++ b/source/appstates/TitleOptionState.cpp @@ -92,8 +92,8 @@ void TitleOptionState::update() } // Update panel and menu. - sm_slidePanel->update(AppState::has_focus()); - sm_titleOptionMenu->update(AppState::has_focus()); + sm_slidePanel->update(BaseState::has_focus()); + sm_titleOptionMenu->update(BaseState::has_focus()); if (input::button_pressed(HidNpadButton_A)) { @@ -247,15 +247,15 @@ void TitleOptionState::update() sm_slidePanel->reset(); sm_titleOptionMenu->set_selected(0); // Deactivate and allow state to be purged. - AppState::deactivate(); + BaseState::deactivate(); } } void TitleOptionState::render() { sm_slidePanel->clear_target(); - sm_titleOptionMenu->render(sm_slidePanel->get_target(), AppState::has_focus()); - sm_slidePanel->render(NULL, AppState::has_focus()); + sm_titleOptionMenu->render(sm_slidePanel->get_target(), BaseState::has_focus()); + sm_slidePanel->render(NULL, BaseState::has_focus()); } void TitleOptionState::close_on_update() @@ -321,7 +321,7 @@ static void change_output_path(data::TitleInfo *targetTitle) if (fslib::directory_exists(oldPath) && !fslib::rename_directory(oldPath, newPath)) { // Bail if this fails, because something is really wrong. - logger::log("Error setting new output path: %s", fslib::get_error_string()); + logger::log("Error setting new output path: %s", fslib::error::get_string()); return; } @@ -367,7 +367,7 @@ static void reset_save_data(sys::Task *task, std::shared_ptrm_user->get_save_info_by_id(dataStruct->m_titleInfo->get_application_id()))) { - logger::log(ERROR_RESETTING_SAVE, fslib::get_error_string()); + logger::log(ERROR_RESETTING_SAVE, fslib::error::get_string()); ui::PopMessageManager::push_message(ui::PopMessageManager::DEFAULT_MESSAGE_TICKS, strings::get_by_name(strings::names::TITLE_OPTION_POPS, 2)); task->finished(); @@ -378,7 +378,7 @@ static void reset_save_data(sys::Task *task, std::shared_ptrfinished(); @@ -389,7 +389,7 @@ static void reset_save_data(sys::Task *task, std::shared_ptrfinished(); @@ -505,7 +505,7 @@ static void export_svi_file(data::TitleInfo *titleInfo) fslib::File sviFile(sviPath, FsOpenMode_Create | FsOpenMode_Write, SIZE_SVI_FILE); if (!sviFile) { - logger::log("Error exporting SVI file: %s", fslib::get_error_string()); + logger::log("Error exporting SVI file: %s", fslib::error::get_string()); ui::PopMessageManager::push_message(ui::PopMessageManager::DEFAULT_MESSAGE_TICKS, strings::get_by_name(strings::names::TITLE_OPTION_POPS, 5)); } diff --git a/source/appstates/TitleSelectCommon.cpp b/source/appstates/TitleSelectCommon.cpp index 8386a13..6c1bf55 100644 --- a/source/appstates/TitleSelectCommon.cpp +++ b/source/appstates/TitleSelectCommon.cpp @@ -13,7 +13,9 @@ TitleSelectCommon::TitleSelectCommon() void TitleSelectCommon::render_control_guide() { - if (AppState::has_focus()) + const bool hasFocus = BaseState::has_focus(); + + if (hasFocus) { sdl::text::render(NULL, m_titleControlsX, diff --git a/source/appstates/TitleSelectState.cpp b/source/appstates/TitleSelectState.cpp index d0f24a9..467fc02 100644 --- a/source/appstates/TitleSelectState.cpp +++ b/source/appstates/TitleSelectState.cpp @@ -31,11 +31,11 @@ void TitleSelectState::update() { if (m_user->get_total_data_entries() <= 0) { - AppState::deactivate(); + BaseState::deactivate(); return; } - m_titleView.update(AppState::has_focus()); + m_titleView.update(BaseState::has_focus()); if (input::button_pressed(HidNpadButton_A)) { @@ -56,7 +56,7 @@ void TitleSelectState::update() } else { - logger::log(fslib::get_error_string()); + logger::log(fslib::error::get_string()); } } else if (input::button_pressed(HidNpadButton_X)) @@ -72,7 +72,7 @@ void TitleSelectState::update() { // This will reset all the tiles so they're 128x128. m_titleView.reset(); - AppState::deactivate(); + BaseState::deactivate(); } else if (input::button_pressed(HidNpadButton_Y)) { @@ -94,7 +94,7 @@ void TitleSelectState::update() void TitleSelectState::render() { m_renderTarget->clear(colors::TRANSPARENT); - m_titleView.render(m_renderTarget->get(), AppState::has_focus()); + m_titleView.render(m_renderTarget->get(), BaseState::has_focus()); TitleSelectCommon::render_control_guide(); m_renderTarget->render(NULL, 201, 91); } diff --git a/source/appstates/UserOptionState.cpp b/source/appstates/UserOptionState.cpp index 8b9bc7c..60ba52b 100644 --- a/source/appstates/UserOptionState.cpp +++ b/source/appstates/UserOptionState.cpp @@ -61,7 +61,7 @@ UserOptionState::UserOptionState(data::User *user, TitleSelectCommon *titleSelec void UserOptionState::update() { // Update the main panel. - m_menuPanel->update(AppState::has_focus()); + m_menuPanel->update(BaseState::has_focus()); // See if this needs to be done. if (m_refreshRequired) @@ -145,11 +145,11 @@ void UserOptionState::update() } else if (m_menuPanel->is_closed()) { - AppState::deactivate(); + BaseState::deactivate(); m_menuPanel->reset(); } - m_userOptionMenu.update(AppState::has_focus()); + m_userOptionMenu.update(BaseState::has_focus()); } void UserOptionState::render() @@ -159,8 +159,8 @@ void UserOptionState::render() // Render panel. m_menuPanel->clear_target(); - m_userOptionMenu.render(m_menuPanel->get_target(), AppState::has_focus()); - m_menuPanel->render(NULL, AppState::has_focus()); + m_userOptionMenu.render(m_menuPanel->get_target(), BaseState::has_focus()); + m_menuPanel->render(NULL, BaseState::has_focus()); } void UserOptionState::data_and_view_refresh_required() @@ -213,10 +213,10 @@ static void backup_all_for_user(sys::ProgressTask *task, std::shared_ptrget_path_safe_nickname() + " - " + stringutil::get_date_string() + ".zip"; - zipFile targetZip = zipOpen64(targetPath.c_string(), APPEND_STATUS_CREATE); + zipFile targetZip = zipOpen64(targetPath.full_path(), APPEND_STATUS_CREATE); if (!targetZip) { - logger::log("Error creating zip: %s", fslib::get_error_string()); + logger::log("Error creating zip: %s", fslib::error::get_string()); continue; } fs::copy_directory_to_zip(fs::DEFAULT_SAVE_ROOT, targetZip, task); @@ -230,7 +230,7 @@ static void backup_all_for_user(sys::ProgressTask *task, std::shared_ptr(saveInfo->save_data_space_id), saveInfo->save_data_id))) { - logger::log(STRING_ERROR_TEMPLATE.data(), saveInfo->application_id, fslib::get_error_string()); + logger::log(STRING_ERROR_TEMPLATE.data(), saveInfo->application_id, fslib::error::get_string()); return false; } // We need to temporarily close the file system. if (!fslib::close_file_system(fs::DEFAULT_SAVE_MOUNT)) { - logger::log(STRING_ERROR_TEMPLATE.data(), saveInfo->application_id, fslib::get_error_string()); + logger::log(STRING_ERROR_TEMPLATE.data(), saveInfo->application_id, fslib::error::get_string()); return false; } @@ -77,7 +77,7 @@ bool fs::process_save_meta_data(const FsSaveDataInfo *saveInfo, const SaveMetaDa // Now reopen it. if (!fslib::open_save_data_with_save_info(fs::DEFAULT_SAVE_MOUNT, *saveInfo)) { - logger::log(STRING_ERROR_TEMPLATE.data(), saveInfo->application_id, fslib::get_error_string()); + logger::log(STRING_ERROR_TEMPLATE.data(), saveInfo->application_id, fslib::error::get_string()); return false; } diff --git a/source/fs/io.cpp b/source/fs/io.cpp index b6abfa4..1f78320 100644 --- a/source/fs/io.cpp +++ b/source/fs/io.cpp @@ -59,14 +59,14 @@ void fs::copy_file(const fslib::Path &source, fslib::File destinationFile(destination, FsOpenMode_Create | FsOpenMode_Write, sourceFile.get_size()); if (!sourceFile || !destinationFile) { - logger::log("Error opening one of the files: %s", fslib::get_error_string()); + logger::log("Error opening one of the files: %s", fslib::error::get_string()); return; } // Set status if task pointer was passed. if (task) { - task->set_status(strings::get_by_name(strings::names::COPYING_FILES, 0), source.c_string()); + task->set_status(strings::get_by_name(strings::names::COPYING_FILES, 0), source.full_path()); } // Shared struct both threads use @@ -115,7 +115,7 @@ void fs::copy_file(const fslib::Path &source, // Need to try to commit before going over the journaling space limit. if (!fslib::commit_data_to_file_system(commitDevice)) { - logger::log(fslib::get_error_string()); + logger::log(fslib::error::get_string()); // I guess break the loop here? break; } @@ -144,7 +144,7 @@ void fs::copy_file(const fslib::Path &source, // One last commit for good luck. if (!fslib::commit_data_to_file_system(commitDevice)) { - logger::log(fslib::get_error_string()); + logger::log(fslib::error::get_string()); } // Wait for read thread and free it. @@ -160,7 +160,7 @@ void fs::copy_directory(const fslib::Path &source, fslib::Directory sourceDir(source); if (!sourceDir) { - logger::log("Error opening directory for reading: %s", fslib::get_error_string()); + logger::log("Error opening directory for reading: %s", fslib::error::get_string()); return; } @@ -173,7 +173,7 @@ void fs::copy_directory(const fslib::Path &source, // Try to create new destination folder and continue loop on failure. if (!fslib::directory_exists(newDestination) && !fslib::create_directory(newDestination)) { - logger::log("Error creating new destination directory: %s", fslib::get_error_string()); + logger::log("Error creating new destination directory: %s", fslib::error::get_string()); continue; } diff --git a/source/fs/zip.cpp b/source/fs/zip.cpp index 3353a26..1582568 100644 --- a/source/fs/zip.cpp +++ b/source/fs/zip.cpp @@ -86,7 +86,7 @@ void fs::copy_directory_to_zip(const fslib::Path &source, zipFile destination, s fslib::Directory sourceDir(source); if (!sourceDir) { - logger::log("Error opening source directory: %s", fslib::get_error_string()); + logger::log("Error opening source directory: %s", fslib::error::get_string()); return; } @@ -107,7 +107,7 @@ void fs::copy_directory_to_zip(const fslib::Path &source, zipFile destination, s fslib::File sourceFile(fullSource, FsOpenMode_Read); if (!sourceFile) { - logger::log("Error zipping file: %s", fslib::get_error_string()); + logger::log("Error zipping file: %s", fslib::error::get_string()); continue; } @@ -144,7 +144,7 @@ void fs::copy_directory_to_zip(const fslib::Path &source, zipFile destination, s // Update task if passed. if (task) { - task->set_status(strings::get_by_name(strings::names::COPYING_FILES, 1), fullSource.c_string()); + task->set_status(strings::get_by_name(strings::names::COPYING_FILES, 1), fullSource.full_path()); task->reset(static_cast(sourceFile.get_size())); } @@ -232,7 +232,7 @@ void fs::copy_zip_to_directory(unzFile source, // To do: Make FsLib handle this correctly. First condition is a workaround for now... if (directories.is_valid() && !fslib::create_directories_recursively(directories)) { - logger::log("Error creating zip file path \"%s\": %s", directories.c_string(), fslib::get_error_string()); + logger::log("Error creating zip file path \"%s\": %s", directories.full_path(), fslib::error::get_string()); continue; } @@ -241,7 +241,7 @@ void fs::copy_zip_to_directory(unzFile source, currentFileInfo.uncompressed_size); if (!destinationFile) { - logger::log("Error creating file from zip: %s", fslib::get_error_string()); + logger::log("Error creating file from zip: %s", fslib::error::get_string()); continue; } @@ -290,7 +290,7 @@ void fs::copy_zip_to_directory(unzFile source, // Commit if (!fslib::commit_data_to_file_system(commitDevice)) { - logger::log("Error committing data to save: %s", fslib::get_error_string()); + logger::log("Error committing data to save: %s", fslib::error::get_string()); } // Reopen, seek to previous position. @@ -322,7 +322,7 @@ void fs::copy_zip_to_directory(unzFile source, if (!fslib::commit_data_to_file_system(commitDevice)) { - logger::log("Error performing final file commit: %s", fslib::get_error_string()); + logger::log("Error performing final file commit: %s", fslib::error::get_string()); } } while (unzGoToNextFile(source) != UNZ_END_OF_LIST_OF_FILE); } @@ -349,7 +349,7 @@ void fs::create_zip_fileinfo(zip_fileinfo &info) bool fs::zip_has_contents(const fslib::Path &zipPath) { - unzFile testZip = unzOpen(zipPath.c_string()); + unzFile testZip = unzOpen(zipPath.full_path()); if (!testZip) { return false; diff --git a/source/remote/GoogleDrive.cpp b/source/remote/GoogleDrive.cpp index e832732..7a1e527 100644 --- a/source/remote/GoogleDrive.cpp +++ b/source/remote/GoogleDrive.cpp @@ -168,7 +168,7 @@ bool remote::GoogleDrive::upload_file(const fslib::Path &source) fslib::File sourceFile(source, FsOpenMode_Read); if (!sourceFile) { - logger::log("Error uploading file: %s", fslib::get_error_string()); + logger::log("Error uploading file: %s", fslib::error::get_string()); return false; } @@ -182,7 +182,7 @@ bool remote::GoogleDrive::upload_file(const fslib::Path &source) // Json to post. json::Object postJson = json::new_object(json_object_new_object); - json_object *driveName = json_object_new_string(source.get_filename().data()); + json_object *driveName = json_object_new_string(source.get_filename()); json::add_object(postJson, JSON_KEY_NAME, driveName); // Append the parent. if (!m_parent.empty()) @@ -270,7 +270,7 @@ bool remote::GoogleDrive::patch_file(remote::Item *file, const fslib::Path &sour fslib::File sourceFile(source, FsOpenMode_Read); if (!sourceFile) { - logger::log(STRING_PATCH_ERROR, fslib::get_error_string()); + logger::log(STRING_PATCH_ERROR, fslib::error::get_string()); return false; } diff --git a/source/remote/WebDav.cpp b/source/remote/WebDav.cpp index d50c8fa..14e4b91 100644 --- a/source/remote/WebDav.cpp +++ b/source/remote/WebDav.cpp @@ -134,7 +134,7 @@ bool remote::WebDav::upload_file(const fslib::Path &source) fslib::File file(source, FsOpenMode_Read); if (!file) { - logger::log(STRING_ERROR_UPLOADING, fslib::get_error_string()); + logger::log(STRING_ERROR_UPLOADING, fslib::error::get_string()); return false; } @@ -173,7 +173,7 @@ bool remote::WebDav::patch_file(remote::Item *item, const fslib::Path &source) fslib::File file(source, FsOpenMode_Read); if (!file) { - logger::log(STRING_ERROR_PATCHING, fslib::get_error_string()); + logger::log(STRING_ERROR_PATCHING, fslib::error::get_string()); return false; } @@ -207,7 +207,7 @@ bool remote::WebDav::download_file(const remote::Item *item, const fslib::Path & fslib::File file(destination, FsOpenMode_Create | FsOpenMode_Write); if (!file) { - logger::log(STRING_ERROR_DOWNLOADING, fslib::get_error_string()); + logger::log(STRING_ERROR_DOWNLOADING, fslib::error::get_string()); return false; } diff --git a/source/strings.cpp b/source/strings.cpp index 8073d8e..004b9c3 100644 --- a/source/strings.cpp +++ b/source/strings.cpp @@ -77,7 +77,7 @@ bool strings::initialize() { fslib::Path filePath = get_file_path(); - json::Object stringJSON = json::new_object(json_object_from_file, filePath.c_string()); + json::Object stringJSON = json::new_object(json_object_from_file, filePath.full_path()); if (!stringJSON) { return false;