mirror of
https://github.com/hrydgard/ppsspp.git
synced 2025-04-02 11:01:50 -04:00
Address feedback
This commit is contained in:
parent
59088e0921
commit
64dbd97731
9 changed files with 32 additions and 28 deletions
|
@ -6,6 +6,23 @@
|
|||
|
||||
#include "Common/StringUtils.h"
|
||||
|
||||
// Not strictly a parser...
|
||||
void NiceSizeFormat(size_t size, char *out, size_t bufSize) {
|
||||
const char *sizes[] = { "B","KB","MB","GB","TB","PB","EB" };
|
||||
int s = 0;
|
||||
int frac = 0;
|
||||
while (size >= 1024) {
|
||||
s++;
|
||||
frac = (int)size & 1023;
|
||||
size /= 1024;
|
||||
}
|
||||
float f = (float)size + ((float)frac / 1024.0f);
|
||||
if (s == 0)
|
||||
snprintf(out, bufSize, "%d B", (int)size);
|
||||
else
|
||||
snprintf(out, bufSize, "%3.1f %s", f, sizes[s]);
|
||||
}
|
||||
|
||||
bool Version::ParseVersionString(std::string str) {
|
||||
if (str.empty())
|
||||
return false;
|
||||
|
|
|
@ -70,3 +70,5 @@ static bool TryParse(const std::string &str, N *const output) {
|
|||
} else
|
||||
return false;
|
||||
}
|
||||
|
||||
void NiceSizeFormat(size_t size, char *out, size_t bufSize);
|
||||
|
|
|
@ -41,9 +41,11 @@ bool free_disk_space(const Path &path, int64_t &space) {
|
|||
int res = statvfs(path.c_str(), &diskstat);
|
||||
|
||||
if (res == 0) {
|
||||
// Not sure why we're excluding Android here anyway...
|
||||
#ifndef __ANDROID__
|
||||
if (diskstat.f_flag & ST_RDONLY) {
|
||||
space = -1;
|
||||
// No space to write.
|
||||
space = 0;
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -1045,11 +1045,11 @@ int SavedataParam::BuildHash(unsigned char *output,
|
|||
return 0;
|
||||
}
|
||||
|
||||
// TODO: Merge with NiceSizeFormat? That one has a decimal though.
|
||||
std::string SavedataParam::GetSpaceText(u64 size, bool roundUp)
|
||||
{
|
||||
static const char *suffixes[] = {"B", "KB", "MB", "GB"};
|
||||
char text[50];
|
||||
|
||||
static const char *suffixes[] = {"B", "KB", "MB", "GB"};
|
||||
for (size_t i = 0; i < ARRAY_SIZE(suffixes); ++i)
|
||||
{
|
||||
if (size < 1024)
|
||||
|
@ -1063,7 +1063,6 @@ std::string SavedataParam::GetSpaceText(u64 size, bool roundUp)
|
|||
size /= 1024;
|
||||
}
|
||||
}
|
||||
|
||||
snprintf(text, sizeof(text), "%llu TB", size);
|
||||
return std::string(text);
|
||||
}
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
#include "Common/System/NativeApp.h"
|
||||
#include "Common/System/Display.h"
|
||||
#include "Common/Data/Text/I18n.h"
|
||||
#include "Common/Data/Text/Parsers.h"
|
||||
|
||||
#include "Common/File/AndroidStorage.h"
|
||||
#include "Common/File/FileUtil.h"
|
||||
|
@ -91,8 +92,9 @@ static bool SwitchMemstickFolderTo(Path newMemstickFolder) {
|
|||
|
||||
static std::string FormatSpaceString(int64_t space) {
|
||||
if (space >= 0) {
|
||||
// TODO: Smarter display (MB, GB as appropriate). Don't we have one of these somewhere?
|
||||
return StringFromFormat("%lld MB", space / (1024 * 1024));
|
||||
char buffer[50];
|
||||
NiceSizeFormat(space, buffer, sizeof(buffer));
|
||||
return buffer;
|
||||
} else {
|
||||
return "N/A";
|
||||
}
|
||||
|
|
|
@ -34,9 +34,10 @@ public:
|
|||
~MemStickScreen() {}
|
||||
|
||||
std::string tag() const override { return "game"; }
|
||||
void CreateViews() override;
|
||||
|
||||
protected:
|
||||
void CreateViews() override;
|
||||
|
||||
void sendMessage(const char *message, const char *value) override;
|
||||
void dialogFinished(const Screen *dialog, DialogResult result) override;
|
||||
void update() override;
|
||||
|
@ -67,6 +68,7 @@ class ConfirmMemstickMoveScreen : public UIDialogScreenWithBackground {
|
|||
public:
|
||||
ConfirmMemstickMoveScreen(Path newMemstickFolder, bool initialSetup);
|
||||
|
||||
protected:
|
||||
void CreateViews() override;
|
||||
|
||||
private:
|
||||
|
|
|
@ -348,7 +348,7 @@ void PostLoadConfig() {
|
|||
}
|
||||
|
||||
bool CreateDirectoriesAndroid() {
|
||||
// TODO: Really not sure why this code is Android-exclusive, except the ".nomedia" part.
|
||||
// TODO: We should probably simply use this as the shared function to create memstick directories.
|
||||
|
||||
Path pspDir = g_Config.memStickDirectory;
|
||||
if (pspDir.GetFilename() != "PSP") {
|
||||
|
|
|
@ -53,24 +53,6 @@ namespace W32Util
|
|||
MoveWindow(hwnd, x, y, width, height, FALSE);
|
||||
}
|
||||
|
||||
void NiceSizeFormat(size_t size, char *out)
|
||||
{
|
||||
const char *sizes[] = {"B","KB","MB","GB","TB","PB","EB"};
|
||||
int s = 0;
|
||||
int frac = 0;
|
||||
while (size>=1024)
|
||||
{
|
||||
s++;
|
||||
frac = (int)size & 1023;
|
||||
size /= 1024;
|
||||
}
|
||||
float f = (float)size + ((float)frac / 1024.0f);
|
||||
if (s==0)
|
||||
sprintf(out, "%d B", (int)size);
|
||||
else
|
||||
sprintf(out, "%3.1f %s", f, sizes[s]);
|
||||
}
|
||||
|
||||
BOOL CopyTextToClipboard(HWND hwnd, const char *text) {
|
||||
std::wstring wtext = ConvertUTF8ToWString(text);
|
||||
return CopyTextToClipboard(hwnd, wtext);
|
||||
|
|
|
@ -6,8 +6,6 @@
|
|||
namespace W32Util
|
||||
{
|
||||
void CenterWindow(HWND hwnd);
|
||||
HBITMAP CreateBitmapFromARGB(HWND someHwnd, DWORD *image, int w, int h);
|
||||
void NiceSizeFormat(size_t size, char *out);
|
||||
BOOL CopyTextToClipboard(HWND hwnd, const char *text);
|
||||
BOOL CopyTextToClipboard(HWND hwnd, const std::wstring &wtext);
|
||||
void MakeTopMost(HWND hwnd, bool topMost);
|
||||
|
|
Loading…
Add table
Reference in a new issue