Skip to content

Commit

Permalink
Cleanup/refactor lots of things
Browse files Browse the repository at this point in the history
  • Loading branch information
Epicpkmn11 committed Dec 9, 2024
1 parent ddfd63e commit 54f08d4
Show file tree
Hide file tree
Showing 48 changed files with 401 additions and 551 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
*.3dsx
*.cia
*.nds
*.dsi
*.elf
*.smdh
*.bin
Expand All @@ -13,4 +14,4 @@ nds/build/sprites.h
*.t3x
*.tdx
*.DS_Store
*.vscode
*.vscode
2 changes: 1 addition & 1 deletion 3ds/Universal-Core
79 changes: 79 additions & 0 deletions include/3ds/Platform.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
/*
* This file is part of Universal-Updater
* Copyright (C) 2019-2021 Universal-Team
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
* * Requiring preservation of specified reasonable legal notices or
* author attributions in that material or in the Appropriate Legal
* Notices displayed by works containing it.
* * Prohibiting misrepresentation of the origin of that material,
* or requiring that modified versions of such material be marked in
* reasonable ways as different from the original version.
*/

#ifndef _PLATFORM_3DS_HPP
#define _PLATFORM_3DS_HPP

#include <3ds.h>

/* Include Definitions for Universal-Updater here. */
#define CONFIG_PATH "sdmc:/3ds/Universal-Updater/Config.json"
#define _STORE_PATH "sdmc:/3ds/Universal-Updater/stores/"
#define _SHORTCUT_PATH "sdmc:/3ds/Universal-Updater/shortcuts/"
#define THEME_JSON "sdmc:/3ds/Universal-Updater/Themes.json"

#define SHEET_PATH_KEY "sheet"
#define SHEET_URL_KEY "sheetURL"

/* Meta data related things. */
#define _META_PATH "sdmc:/3ds/Universal-Updater/MetaData.json"
#define _OLD_UPDATE_PATH "sdmc:/3ds/Universal-Updater/updates.json"

#define DEFAULT_BASE_URL "https://github.com/Universal-Team/db/raw/master/docs/unistore/"
#define DEFAULT_UNISTORE_NAME "universal-db.unistore"
#define DEFAULT_SPRITESHEET_NAME "universal-db.t3x"
#define DEFAULT_UNISTORE (DEFAULT_BASE_URL DEFAULT_UNISTORE_NAME)
#define DEFAULT_SPRITESHEET (DEFAULT_BASE_URL DEFAULT_SPRITESHEET_NAME)

typedef Thread ThreadPtr;

namespace Platform {
inline void ScanKeys(void) { return hidScanInput(); }
inline u32 KeysDown(void) { return hidKeysDown(); }
inline u32 KeysDownRepeat(void) { return hidKeysDownRepeat(); }
inline void TouchRead(touchPosition *data) { hidTouchRead(data); }

inline bool MainLoop() { return aptMainLoop(); }
inline void waitForVBlank(void) { return gspWaitForVBlank(); }
inline void AllowExit(bool allow) { return aptSetHomeAllowed(allow); }

inline int ThreadJoin(ThreadPtr t, u64 timeout_ns) { return threadJoin(t, timeout_ns); }
inline ThreadPtr CreateThread(ThreadFunc entrypoint) {
int32_t Prio = 0;
svcGetThreadPriority(&Prio, CUR_THREAD_HANDLE);
return threadCreate(entrypoint, NULL, 64 * 1024, Prio - 1, -2, false);
}

void Initialize(char *ARGV[]);
void Exit(void);

namespace WiFi {
inline void Init(void) { /* NOP */ };
bool Connected(void);
}
};

#endif
2 changes: 2 additions & 0 deletions include/3ds/data/GFXData.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ class GFXData {
/* UniStore Sprite Handler. */
void LoadUniStoreSheet(const std::string &SheetFile);
void UnloadUniStoreSheets();
inline void UpdateUniStoreSprites() { /* NOP */ }
inline void HideUniStoreSprites() { /* NOP */ }
void DrawUniStoreIcons(const std::vector<std::tuple<int, int, bool>> &Indexes);

void DrawBox(const int XPos, const int YPos, const int Width = 50, const int Height = 50, const bool Selected = false);
Expand Down
32 changes: 0 additions & 32 deletions include/Common.hpp

This file was deleted.

31 changes: 5 additions & 26 deletions include/3ds/UniversalUpdater.hpp → include/UniversalUpdater.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@
#include "GFXData.hpp"
#include "Meta.hpp"
#include "MSGData.hpp"
#include "screenCommon.hpp"
#include "structs.hpp"
#include "ThemeData.hpp"
#include "UniStore.hpp"

Expand All @@ -42,33 +40,17 @@
#include "TopList.hpp"
#include "UniStoreSelector.hpp"


#include <3ds.h>
#include <memory>
#include <string>


/* Include Definitions for Universal-Updater here. */
#define CONFIG_PATH "sdmc:/3ds/Universal-Updater/Config.json"
#define _STORE_PATH "sdmc:/3ds/Universal-Updater/stores/"
#define THEME_JSON "sdmc:/3ds/Universal-Updater/Themes.json"

#define SHEET_PATH_KEY "sheet"
#define SHEET_URL_KEY "sheetURL"

/* Meta data related things. */
#define _META_PATH "sdmc:/3ds/Universal-Updater/MetaData.json"
#define _OLD_UPDATE_PATH "sdmc:/3ds/Universal-Updater/updates.json"


class UU {
std::unique_ptr<TopGrid> TGrid = nullptr;
std::unique_ptr<TopList> TList = nullptr;

public:
enum class TopMode : uint8_t { Grid = 0, List };
void Initialize();
void Initialize(char *ARGV[]);
void ScanInput();

void Draw();
int Handler();
int Handler(char *ARGV[]);

void SwitchTopMode(const UU::TopMode TMode);

Expand All @@ -86,9 +68,6 @@ class UU {
touchPosition T = { 0, 0 };
bool Exiting = false;
TopMode TMode = TopMode::Grid;
private:
std::unique_ptr<TopGrid> TGrid = nullptr;
std::unique_ptr<TopList> TList = nullptr;
};

#endif
2 changes: 2 additions & 0 deletions include/menus/tabs/QueueMenu.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@

#include "structs.hpp"

#include <array>


class QueueMenu {
public:
Expand Down
1 change: 1 addition & 0 deletions include/menus/tabs/Tabs.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
#include "QueueMenu.hpp"
#include "structs.hpp"

#include <memory>

class Tabs {
public:
Expand Down
81 changes: 31 additions & 50 deletions include/nds/UniversalUpdater.hpp → include/nds/Platform.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,33 +24,15 @@
* reasonable ways as different from the original version.
*/

#ifndef _UNIVERSAL_UPDATER_HPP
#define _UNIVERSAL_UPDATER_HPP
#ifndef _PLATFORM_NDS_HPP
#define _PLATFORM_NDS_HPP

#include "ConfigData.hpp"
#include "font.hpp"
#include "GFXData.hpp"
#include "Meta.hpp"
#include "MSGData.hpp"
#include "structs.hpp"
#include "ThemeData.hpp"
#include "UniStore.hpp"

/* Menus. */
#include "Tabs.hpp"
#include "TopGrid.hpp"
#include "TopList.hpp"
#include "UniStoreSelector.hpp"


#include <memory>
#include <nds.h>
#include <string>


/* Include Definitions for Universal-Updater here. */
#define CONFIG_PATH "/_nds/Universal-Updater/Config.json"
#define _STORE_PATH "/_nds/Universal-Updater/stores/"
#define _SHORTCUT_PATH "/_nds/Universal-Updater/shortcuts/"
#define THEME_JSON "/_nds/Universal-Updater/Themes.json"

#define SHEET_PATH_KEY "dsSheet"
Expand All @@ -60,39 +42,38 @@
#define _META_PATH "/_nds/Universal-Updater/MetaData.json"
#define _OLD_UPDATE_PATH "/_nds/Universal-Updater/updates.json" // Technically not needed.

#define DEFAULT_BASE_URL "https://github.com/Universal-Team/db/raw/master/docs/unistore/"
#define DEFAULT_UNISTORE_NAME "universal-db.unistore"
#define DEFAULT_SPRITESHEET_NAME "universal-db.tdx"
#define DEFAULT_UNISTORE (DEFAULT_BASE_URL DEFAULT_UNISTORE_NAME)
#define DEFAULT_SPRITESHEET (DEFAULT_BASE_URL DEFAULT_SPRITESHEET_NAME)

class UU {
static void VBlankHandler(void);
typedef Thread *ThreadPtr;

std::unique_ptr<TopGrid> TGrid = nullptr;
std::unique_ptr<TopList> TList = nullptr;
namespace Platform {
inline void ScanKeys(void) { return scanKeys(); }
inline u32 KeysDown(void) { return keysDown(); }
inline u32 KeysDownRepeat(void) { return keysDownRepeat(); }
inline void TouchRead(touchPosition *data) {
touchRead(data);
data->px = data->px * 5 / 4;
data->py = data->py * 5 / 4;
}

static int QueueMenuRefresh;
inline bool MainLoop() {return pmMainLoop(); }
inline void waitForVBlank(void) { return threadWaitForVBlank(); }
inline void AllowExit(bool allow) { (void)allow; /* NOP */ }

public:
enum class TopMode : uint8_t { Grid = 0, List };
void Initialize(char *ARGV[]);
void ScanInput();

void Draw();
int Handler(char *ARGV[]);
inline int ThreadJoin(ThreadPtr t, u64 timeout_ns) { (void)timeout_ns; return threadJoin(t); }
ThreadPtr CreateThread(ThreadFunc entrypoint);

void SwitchTopMode(const UU::TopMode TMode);

static std::unique_ptr<UU> App;
std::unique_ptr<ConfigData> CData = nullptr;
std::unique_ptr<GFXData> GData = nullptr;
std::unique_ptr<Meta> MData = nullptr;
std::unique_ptr<MSGData> MSData = nullptr;
std::unique_ptr<UniStore> Store = nullptr;
std::unique_ptr<Tabs> _Tabs = nullptr;
std::unique_ptr<ThemeData> TData = nullptr; // TODO: Find a good way to handle the active theme through defines.
std::unique_ptr<UniStoreSelector> USelector = nullptr;
void Initialize(char *ARGV[]);
inline void Exit() { /* NOP */ }

uint32_t Down = 0, Repeat = 0;
touchPosition T = { 0, 0 };
bool Exiting = false;
TopMode TMode = TopMode::Grid;
};
namespace WiFi {
void Init(void);
bool Connected(void);
}
}

#endif
#endif
39 changes: 0 additions & 39 deletions include/nds/utils/WiFi.hpp

This file was deleted.

2 changes: 0 additions & 2 deletions include/utils/DownloadUtils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@ namespace DownloadUtils {
curl_off_t Speed();
curl_off_t CurrentProgress();
curl_off_t TotalSize();

bool WiFiAvailable();
};

#endif
2 changes: 1 addition & 1 deletion nds/Universal-Core
Binary file removed nds/Universal-Updater.dsi
Binary file not shown.
2 changes: 1 addition & 1 deletion nds/build/version.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#ifndef VERSION_HPP
#define VERSION_HPP

#define VER_NUMBER "-07ac62d"
#define VER_NUMBER "-ddfd63e"

#endif
Loading

0 comments on commit 54f08d4

Please sign in to comment.