mirror of
https://github.com/BernardoGiordano/Checkpoint
synced 2024-11-28 11:30:22 +00:00
Re-add file copy graphics
This commit is contained in:
parent
6c2d4a74d2
commit
257d447919
8 changed files with 61 additions and 5 deletions
|
@ -40,4 +40,7 @@ inline std::string g_selectedCheatKey;
|
|||
inline std::vector<std::string> g_selectedCheatCodes;
|
||||
inline volatile bool g_isLoadingTitles = false;
|
||||
|
||||
inline std::u16string g_currentFile;
|
||||
inline bool g_isTransferringFile = false;
|
||||
|
||||
#endif
|
|
@ -158,6 +158,17 @@ void MainScreen::drawTop(void) const
|
|||
C2D_DrawText(&version, C2D_WithColor, 400 - 4 - ceilf(0.45f * version.width), 3.0f, 0.5f, 0.45f, 0.45f, COLOR_GREY_LIGHT);
|
||||
C2D_DrawImageAt(flag, 400 - 24 - ceilf(version.width * 0.45f), 0.0f, 0.5f, NULL, 1.0f, 1.0f);
|
||||
C2D_DrawText(&checkpoint, C2D_WithColor, 400 - 6 - 0.45f * version.width - 0.5f * checkpoint.width - 19, 2.0f, 0.5f, 0.5f, 0.5f, COLOR_WHITE);
|
||||
|
||||
if (g_isTransferringFile) {
|
||||
C2D_DrawRectSolid(0, 0, 0.5f, 400, 240, COLOR_OVERLAY);
|
||||
|
||||
float size = 0.7f;
|
||||
C2D_Text text;
|
||||
C2D_TextParse(&text, dynamicBuf, StringUtils::UTF16toUTF8(g_currentFile).c_str());
|
||||
C2D_TextOptimize(&text);
|
||||
C2D_DrawText(&text, C2D_WithColor, ceilf((400 - StringUtils::textWidth(text, size)) / 2),
|
||||
ceilf((240 - size * fontGetInfo(NULL)->lineFeed) / 2), 0.9f, size, size, COLOR_WHITE);
|
||||
}
|
||||
}
|
||||
|
||||
void MainScreen::drawBottom(void) const
|
||||
|
@ -236,6 +247,10 @@ void MainScreen::drawBottom(void) const
|
|||
// play coins
|
||||
C2D_DrawText(&coins, C2D_WithColor, ceilf(318 - StringUtils::textWidth(coins, scaleInst)), -1, 0.5f, scaleInst, scaleInst, COLOR_WHITE);
|
||||
}
|
||||
|
||||
if (g_isTransferringFile) {
|
||||
C2D_DrawRectSolid(0, 0, 0.5f, 400, 240, COLOR_OVERLAY);
|
||||
}
|
||||
}
|
||||
|
||||
void MainScreen::update(touchPosition* touch)
|
||||
|
|
|
@ -42,6 +42,8 @@ bool io::fileExists(FS_Archive archive, const std::u16string& path)
|
|||
|
||||
void io::copyFile(FS_Archive srcArch, FS_Archive dstArch, const std::u16string& srcPath, const std::u16string& dstPath)
|
||||
{
|
||||
g_isTransferringFile = true;
|
||||
|
||||
u32 size = 0;
|
||||
FSStream input(srcArch, srcPath, FS_OPEN_READ);
|
||||
if (input.good()) {
|
||||
|
@ -55,11 +57,22 @@ void io::copyFile(FS_Archive srcArch, FS_Archive dstArch, const std::u16string&
|
|||
|
||||
FSStream output(dstArch, dstPath, FS_OPEN_WRITE, input.size());
|
||||
if (output.good()) {
|
||||
size_t slashpos = srcPath.rfind(StringUtils::UTF8toUTF16("/"));
|
||||
g_currentFile = srcPath.substr(slashpos + 1, srcPath.length() - slashpos - 1);
|
||||
|
||||
u32 rd;
|
||||
u8* buf = new u8[size];
|
||||
do {
|
||||
rd = input.read(buf, size);
|
||||
output.write(buf, rd);
|
||||
|
||||
// avoid freezing the UI
|
||||
// this will be made less horrible next time...
|
||||
C3D_FrameBegin(C3D_FRAME_SYNCDRAW);
|
||||
g_screen->drawTop();
|
||||
C2D_SceneBegin(g_bottom);
|
||||
g_screen->drawBottom();
|
||||
Gui::frameEnd();
|
||||
} while (!input.eof());
|
||||
delete[] buf;
|
||||
}
|
||||
|
@ -71,6 +84,8 @@ void io::copyFile(FS_Archive srcArch, FS_Archive dstArch, const std::u16string&
|
|||
|
||||
input.close();
|
||||
output.close();
|
||||
|
||||
g_isTransferringFile = false;
|
||||
}
|
||||
|
||||
Result io::copyDirectory(FS_Archive srcArch, FS_Archive dstArch, const std::u16string& srcPath, const std::u16string& dstPath)
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
|
||||
static std::vector<Thread> threads;
|
||||
|
||||
static bool forceRefresh = false;
|
||||
static bool forceRefresh = false;
|
||||
|
||||
void Threads::create(ThreadFunc entrypoint)
|
||||
{
|
||||
|
@ -55,6 +55,6 @@ void Threads::titles(void)
|
|||
|
||||
g_isLoadingTitles = true;
|
||||
loadTitles(forceRefresh);
|
||||
forceRefresh = true;
|
||||
forceRefresh = true;
|
||||
g_isLoadingTitles = false;
|
||||
}
|
|
@ -44,4 +44,7 @@ inline std::string g_selectedCheatKey;
|
|||
inline std::vector<std::string> g_selectedCheatCodes;
|
||||
inline u32 g_username_dotsize;
|
||||
|
||||
inline std::string g_currentFile = "";
|
||||
inline bool g_isTransferringFile = false;
|
||||
|
||||
#endif
|
|
@ -204,6 +204,14 @@ void MainScreen::draw() const
|
|||
SDLH_DrawText(26, 16, 672 + (40 - checkpoint_h) / 2 + 2, theme().c6, "checkpoint");
|
||||
SDLH_DrawText(20, 16 + checkpoint_w + 8, 672 + (40 - checkpoint_h) / 2 + checkpoint_h - ver_h, theme().c6, ver);
|
||||
SDLH_DrawText(24, 16 * 3 + checkpoint_w + 8 + ver_w, 672 + (40 - checkpoint_h) / 2 + checkpoint_h - inst_h, theme().c6, "\ue046 Instructions");
|
||||
|
||||
if (g_isTransferringFile) {
|
||||
SDLH_DrawRect(0, 0, 1280, 720, COLOR_OVERLAY);
|
||||
|
||||
u32 w, h;
|
||||
SDLH_GetTextDimensions(28, g_currentFile.c_str(), &w, &h);
|
||||
SDLH_DrawText(28, (1280 - w) / 2, (720 - h) / 2, COLOR_WHITE, g_currentFile.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
void MainScreen::update(touchPosition* touch)
|
||||
|
|
|
@ -34,6 +34,8 @@ bool io::fileExists(const std::string& path)
|
|||
|
||||
void io::copyFile(const std::string& srcPath, const std::string& dstPath)
|
||||
{
|
||||
g_isTransferringFile = true;
|
||||
|
||||
FILE* src = fopen(srcPath.c_str(), "rb");
|
||||
if (src == NULL) {
|
||||
Logger::getInstance().log(Logger::ERROR, "Failed to open source file " + srcPath + " during copy with errno %d. Skipping...", errno);
|
||||
|
@ -52,10 +54,19 @@ void io::copyFile(const std::string& srcPath, const std::string& dstPath)
|
|||
|
||||
u8* buf = new u8[BUFFER_SIZE];
|
||||
u64 offset = 0;
|
||||
|
||||
size_t slashpos = srcPath.rfind("/");
|
||||
g_currentFile = srcPath.substr(slashpos + 1, srcPath.length() - slashpos - 1);
|
||||
|
||||
while (offset < sz) {
|
||||
u32 count = fread((char*)buf, 1, BUFFER_SIZE, src);
|
||||
fwrite((char*)buf, 1, count, dst);
|
||||
offset += count;
|
||||
|
||||
// avoid freezing the UI
|
||||
// this will be made less horrible next time...
|
||||
g_screen->draw();
|
||||
SDLH_Render();
|
||||
}
|
||||
|
||||
delete[] buf;
|
||||
|
@ -67,6 +78,8 @@ void io::copyFile(const std::string& srcPath, const std::string& dstPath)
|
|||
Logger::getInstance().log(Logger::ERROR, "Committing file " + dstPath + " to the save archive.");
|
||||
fsdevCommitDevice("save");
|
||||
}
|
||||
|
||||
g_isTransferringFile = false;
|
||||
}
|
||||
|
||||
Result io::copyDirectory(const std::string& srcPath, const std::string& dstPath)
|
||||
|
@ -234,6 +247,7 @@ std::tuple<bool, Result, std::string> io::backup(size_t index, u128 uid, size_t
|
|||
false, systemKeyboardAvailable.second, "System keyboard applet not accessible.\nThe suggested destination folder was used\ninstead.");
|
||||
}
|
||||
|
||||
ret = std::make_tuple(true, 0, "Progress correctly saved to disk.");
|
||||
Logger::getInstance().log(Logger::INFO, "Backup succeeded.");
|
||||
return ret;
|
||||
}
|
||||
|
|
|
@ -110,9 +110,7 @@ Result servicesInit(void)
|
|||
}
|
||||
}
|
||||
|
||||
if (R_SUCCEEDED(res = pdmqryInitialize())) {
|
||||
|
||||
}
|
||||
if (R_SUCCEEDED(res = pdmqryInitialize())) {}
|
||||
else {
|
||||
Logger::getInstance().log(Logger::WARN, "pdmqryInitialize failed with result 0x%08lX.", res);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue