mirror of
https://github.com/joel16/VITA-Homebrew-Sorter.git
synced 2024-11-26 21:00:27 +00:00
app: Minor stylistic changes
This commit is contained in:
parent
a737107ce4
commit
1bae5c47bc
@ -67,6 +67,7 @@ target_link_libraries(${PROJECT_NAME}
|
||||
png
|
||||
pthread
|
||||
lzma
|
||||
bz2
|
||||
z
|
||||
vitaGL
|
||||
vitashark
|
||||
|
@ -1,5 +1,4 @@
|
||||
#ifndef _VITA_HB_SORTER_APP_LIST_H_
|
||||
#define _VITA_HB_SORTER_APP_LIST_H_
|
||||
#pragma once
|
||||
|
||||
#include <vector>
|
||||
#include <string>
|
||||
@ -53,5 +52,3 @@ namespace AppList {
|
||||
int Restore(void);
|
||||
bool Compare(const std::string &db_name);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -1,5 +1,4 @@
|
||||
#ifndef _VITA_HB_SORTER_CONFIG_H_
|
||||
#define _VITA_HB_SORTER_CONFIG_H_
|
||||
#pragma once
|
||||
|
||||
typedef struct {
|
||||
bool beta_features = false;
|
||||
@ -25,5 +24,3 @@ namespace Config {
|
||||
int Save(config_t &config);
|
||||
int Load(void);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -1,5 +1,4 @@
|
||||
#ifndef _VITA_HB_SORTER_FS_H_
|
||||
#define _VITA_HB_SORTER_FS_H_
|
||||
#pragma once
|
||||
|
||||
#include <psp2/io/dirent.h>
|
||||
#include <psp2/types.h>
|
||||
@ -17,5 +16,3 @@ namespace FS {
|
||||
std::string GetFileExt(const std::string &filename);
|
||||
int GetDirList(const std::string &path, std::vector<SceIoDirent> &entries);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -1,8 +1,5 @@
|
||||
#ifndef _VITA_HB_SORTER_GUI_H_
|
||||
#define _VITA_HB_SORTER_GUI_H_
|
||||
#pragma once
|
||||
|
||||
namespace GUI {
|
||||
int RenderLoop(void);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -1,10 +1,7 @@
|
||||
#ifndef _VITA_HB_SORTER_KEYBOARD_H_
|
||||
#define _VITA_HB_SORTER_KEYBOARD_H_
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace Keyboard {
|
||||
std::string GetText(const std::string &title);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -1,10 +1,7 @@
|
||||
#ifndef _VITA_HB_SORTER_LOADOUTS_H_
|
||||
#define _VITA_HB_SORTER_LOADOUTS_H_
|
||||
#pragma once
|
||||
|
||||
namespace Loadouts {
|
||||
int Backup(void);
|
||||
int Restore(const std::string &filename);
|
||||
int Delete(const std::string &filename);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -1,10 +1,7 @@
|
||||
#ifndef _VITA_HB_SORTER_LOG_H_
|
||||
#define _VITA_HB_SORTER_LOG_H_
|
||||
#pragma once
|
||||
|
||||
namespace Log {
|
||||
int Init(void);
|
||||
int Exit(void);
|
||||
int Error(const char *format, ...);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -1,10 +1,7 @@
|
||||
#ifndef _VITA_HB_SORTER_POWER_H_
|
||||
#define _VITA_HB_SORTER_POWER_H_
|
||||
#pragma once
|
||||
|
||||
namespace Power {
|
||||
void InitThread(void);
|
||||
void Lock(void);
|
||||
void Unlock(void);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -1,5 +1,4 @@
|
||||
#ifndef _VITA_HB_SORTER_TEXTURES_H_
|
||||
#define _VITA_HB_SORTER_TEXTURES_H_
|
||||
#pragma once
|
||||
|
||||
#include <vitaGL.h>
|
||||
#include <vector>
|
||||
@ -16,5 +15,3 @@ namespace Textures {
|
||||
bool Init(void);
|
||||
void Exit(void);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -1,5 +1,4 @@
|
||||
#ifndef _VITA_HB_SORTER_UTILS_H_
|
||||
#define _VITA_HB_SORTER_UTILS_H_
|
||||
#pragma once
|
||||
|
||||
#include <psp2/ctrl.h>
|
||||
#include <psp2/system_param.h>
|
||||
@ -24,5 +23,3 @@ namespace Utils {
|
||||
int GetDateFormat(void);
|
||||
void GetDateString(char string[24], SceSystemParamDateFormat format, SceDateTime &time);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -116,8 +116,9 @@ namespace AppList {
|
||||
char *error = nullptr;
|
||||
char db_path_backup[] = "ur0:shell/db/app.db.sort.bkp";
|
||||
|
||||
if (R_FAILED(ret = FS::CopyFile(db_path, db_path_backup)))
|
||||
if (R_FAILED(ret = FS::CopyFile(db_path, db_path_backup))) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
ret = sqlite3_open_v2(db_path, &db, SQLITE_OPEN_READWRITE, nullptr);
|
||||
if (ret != SQLITE_OK) {
|
||||
@ -155,14 +156,16 @@ namespace AppList {
|
||||
|
||||
if ((title == "(null)") && (titleId == "(null)")) {
|
||||
// Check if power icon on PSTV, otherwise use reserved01.
|
||||
if (entries[i].icon0Type == 8)
|
||||
if (entries[i].icon0Type == 8) {
|
||||
query.append("icon0Type = " + std::to_string(entries[i].icon0Type) + ";");
|
||||
else if (reserved01 != "(null)")
|
||||
}
|
||||
else if (reserved01 != "(null)") {
|
||||
query.append("reserved01 = " + reserved01 + ";");
|
||||
}
|
||||
}
|
||||
else {
|
||||
query.append((titleId == "(null)"? "title = \"" + title + "\"" : "titleId = \"" + titleId + "\"")
|
||||
+ (entries[i].icon0Type == 7? " AND reserved01 = " + reserved01 + ";" : ";"));
|
||||
+ (entries[i].icon0Type == 7? " AND reserved01 = " + reserved01 + ";" : ";"));
|
||||
}
|
||||
|
||||
ret = sqlite3_exec(db, query.c_str(), nullptr, nullptr, &error);
|
||||
@ -211,8 +214,9 @@ namespace AppList {
|
||||
char *error = nullptr;
|
||||
char db_path_backup[] = "ur0:shell/db/app.db.sort.bkp";
|
||||
|
||||
if (R_FAILED(ret = FS::CopyFile(db_path, db_path_backup)))
|
||||
if (R_FAILED(ret = FS::CopyFile(db_path, db_path_backup))) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
ret = sqlite3_open_v2(db_path, &db, SQLITE_OPEN_READWRITE, nullptr);
|
||||
if (ret != SQLITE_OK) {
|
||||
@ -293,8 +297,9 @@ namespace AppList {
|
||||
std::transform(entryAname.begin(), entryAname.end(), entryAname.begin(), [](unsigned char c){ return std::tolower(c); });
|
||||
std::transform(entryBname.begin(), entryBname.end(), entryBname.begin(), [](unsigned char c){ return std::tolower(c); });
|
||||
|
||||
if (entryAname.compare(entryBname) < 0)
|
||||
if (entryAname.compare(entryBname) < 0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
@ -306,8 +311,9 @@ namespace AppList {
|
||||
std::transform(entryAname.begin(), entryAname.end(), entryAname.begin(), [](unsigned char c){ return std::tolower(c); });
|
||||
std::transform(entryBname.begin(), entryBname.end(), entryBname.begin(), [](unsigned char c){ return std::tolower(c); });
|
||||
|
||||
if (entryBname.compare(entryAname) < 0)
|
||||
if (entryBname.compare(entryAname) < 0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
@ -319,8 +325,9 @@ namespace AppList {
|
||||
std::transform(entryAname.begin(), entryAname.end(), entryAname.begin(), [](unsigned char c){ return std::tolower(c); });
|
||||
std::transform(entryBname.begin(), entryBname.end(), entryBname.begin(), [](unsigned char c){ return std::tolower(c); });
|
||||
|
||||
if (entryAname.compare(entryBname) < 0)
|
||||
if (entryAname.compare(entryBname) < 0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
@ -332,8 +339,9 @@ namespace AppList {
|
||||
std::transform(entryAname.begin(), entryAname.end(), entryAname.begin(), [](unsigned char c){ return std::tolower(c); });
|
||||
std::transform(entryBname.begin(), entryBname.end(), entryBname.begin(), [](unsigned char c){ return std::tolower(c); });
|
||||
|
||||
if (entryBname.compare(entryAname) < 0)
|
||||
if (entryBname.compare(entryAname) < 0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
@ -369,13 +377,16 @@ namespace AppList {
|
||||
int ret = 0;
|
||||
std::string backup_path;
|
||||
|
||||
if (!FS::FileExists("ux0:data/VITAHomebrewSorter/backup/app.db.bkp"))
|
||||
if (!FS::FileExists("ux0:data/VITAHomebrewSorter/backup/app.db.bkp")) {
|
||||
backup_path = "ux0:data/VITAHomebrewSorter/backup/app.db.bkp";
|
||||
else
|
||||
}
|
||||
else {
|
||||
backup_path = "ux0:data/VITAHomebrewSorter/backup/app.db";
|
||||
}
|
||||
|
||||
if (R_FAILED(ret = FS::CopyFile(db_path, backup_path)))
|
||||
if (R_FAILED(ret = FS::CopyFile(db_path, backup_path))) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -384,13 +395,16 @@ namespace AppList {
|
||||
int ret = 0;
|
||||
std::string restore_path;
|
||||
|
||||
if (!FS::FileExists("ux0:data/VITAHomebrewSorter/backup/app.db"))
|
||||
if (!FS::FileExists("ux0:data/VITAHomebrewSorter/backup/app.db")) {
|
||||
restore_path = "ux0:data/VITAHomebrewSorter/backup/app.db.bkp";
|
||||
else
|
||||
}
|
||||
else {
|
||||
restore_path = "ux0:data/VITAHomebrewSorter/backup/app.db";
|
||||
}
|
||||
|
||||
if (R_FAILED(ret = FS::CopyFile(restore_path, db_path)))
|
||||
if (R_FAILED(ret = FS::CopyFile(restore_path, db_path))) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -450,8 +464,9 @@ namespace AppList {
|
||||
sqlite3_finalize(stmt);
|
||||
sqlite3_close(db);
|
||||
|
||||
if (app_entries.empty() || loadout_entries.empty())
|
||||
if (app_entries.empty() || loadout_entries.empty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
std::set_difference(app_entries.begin(), app_entries.end(), loadout_entries.begin(), loadout_entries.end(),
|
||||
std::inserter(diff_entries, diff_entries.begin()));
|
||||
|
@ -39,8 +39,9 @@ namespace Config {
|
||||
SceSize len = sceClibSnprintf(buffer.get(), 128, config_file, config.beta_features? "true" : "false",
|
||||
config.sort_by, config.sort_folders, config.sort_mode, CONFIG_VERSION);
|
||||
|
||||
if (R_FAILED(ret = FS::WriteFile(config_path, buffer.get(), len)))
|
||||
if (R_FAILED(ret = FS::WriteFile(config_path, buffer.get(), len))) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -61,8 +61,9 @@ namespace FS {
|
||||
current_level += level; // append folder to the current level
|
||||
|
||||
// create current level
|
||||
if (!FS::DirExists(current_level) && sceIoMkdir(current_level.c_str(), 0777) != 0)
|
||||
if (!FS::DirExists(current_level) && sceIoMkdir(current_level.c_str(), 0777) != 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
current_level += "/"; // don't forget to append a slash
|
||||
}
|
||||
@ -144,12 +145,14 @@ namespace FS {
|
||||
unsigned char *data = nullptr;
|
||||
SceOff size = 0;
|
||||
|
||||
if (R_FAILED(ret = FS::GetFileSize(src_path, size)))
|
||||
if (R_FAILED(ret = FS::GetFileSize(src_path, size))) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
data = new unsigned char[size];
|
||||
if (!data)
|
||||
if (!data) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (R_FAILED(ret = FS::ReadFile(src_path, data, size))) {
|
||||
delete[] data;
|
||||
@ -181,25 +184,29 @@ namespace FS {
|
||||
static bool IsDBFile(const std::string &filename) {
|
||||
std::string ext = FS::GetFileExt(filename);
|
||||
|
||||
if (!ext.compare(".DB"))
|
||||
if (!ext.compare(".DB")) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool Sort(const SceIoDirent &entryA, const SceIoDirent &entryB) {
|
||||
if ((SCE_S_ISDIR(entryA.d_stat.st_mode)) && !(SCE_S_ISDIR(entryB.d_stat.st_mode)))
|
||||
if ((SCE_S_ISDIR(entryA.d_stat.st_mode)) && !(SCE_S_ISDIR(entryB.d_stat.st_mode))) {
|
||||
return true;
|
||||
else if (!(SCE_S_ISDIR(entryA.d_stat.st_mode)) && (SCE_S_ISDIR(entryB.d_stat.st_mode)))
|
||||
}
|
||||
else if (!(SCE_S_ISDIR(entryA.d_stat.st_mode)) && (SCE_S_ISDIR(entryB.d_stat.st_mode))) {
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
std::u16string entryA_name = reinterpret_cast<const char16_t *>(entryA.d_name);
|
||||
std::u16string entryB_name = reinterpret_cast<const char16_t *>(entryB.d_name);
|
||||
std::transform(entryA_name.begin(), entryA_name.end(), entryA_name.begin(), [](unsigned char c){ return std::tolower(c); });
|
||||
std::transform(entryB_name.begin(), entryB_name.end(), entryB_name.begin(), [](unsigned char c){ return std::tolower(c); });
|
||||
|
||||
if (entryA_name.compare(entryB_name) < 0)
|
||||
if (entryA_name.compare(entryB_name) < 0) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
@ -221,11 +228,13 @@ namespace FS {
|
||||
ret = sceIoDread(dir, &entry);
|
||||
|
||||
if (ret > 0) {
|
||||
if (!FS::IsDBFile(entry.d_name))
|
||||
if (!FS::IsDBFile(entry.d_name)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (SCE_S_ISDIR(entry.d_stat.st_mode))
|
||||
if (SCE_S_ISDIR(entry.d_stat.st_mode)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
entries.push_back(entry);
|
||||
}
|
||||
|
@ -175,17 +175,20 @@ namespace GUI {
|
||||
Config::Save(cfg);
|
||||
state = StateDone;
|
||||
}
|
||||
else
|
||||
else {
|
||||
state = StateError;
|
||||
}
|
||||
break;
|
||||
|
||||
case StateConfirmSwap:
|
||||
AppList::Backup();
|
||||
backupExists = true;
|
||||
if ((AppList::SavePages(entries.pages)) == 0)
|
||||
if ((AppList::SavePages(entries.pages)) == 0) {
|
||||
state = StateDone;
|
||||
else
|
||||
}
|
||||
else {
|
||||
state = StateError;
|
||||
}
|
||||
break;
|
||||
|
||||
case StateRestore:
|
||||
@ -258,8 +261,9 @@ namespace GUI {
|
||||
Config::Save(cfg);
|
||||
}
|
||||
|
||||
if (is_selected)
|
||||
if (is_selected) {
|
||||
ImGui::SetItemDefaultFocus();
|
||||
}
|
||||
}
|
||||
|
||||
ImGui::EndCombo();
|
||||
@ -280,8 +284,9 @@ namespace GUI {
|
||||
Config::Save(cfg);
|
||||
}
|
||||
|
||||
if (is_selected)
|
||||
if (is_selected) {
|
||||
ImGui::SetItemDefaultFocus();
|
||||
}
|
||||
}
|
||||
|
||||
ImGui::EndCombo();
|
||||
@ -319,15 +324,17 @@ namespace GUI {
|
||||
ImGui::SameLine();
|
||||
|
||||
GUI::DisableButtonInit(cfg.sort_mode == SortDefault);
|
||||
if (ImGui::Button("Apply Sort", ImVec2(ImGui::GetContentRegionAvail().x * 0.5f, 0.0f)))
|
||||
if (ImGui::Button("Apply Sort", ImVec2(ImGui::GetContentRegionAvail().x * 0.5f, 0.0f))) {
|
||||
state = StateConfirmSort;
|
||||
}
|
||||
GUI::DisableButtonExit(cfg.sort_mode == SortDefault);
|
||||
|
||||
ImGui::SameLine();
|
||||
|
||||
GUI::DisableButtonInit(!backupExists);
|
||||
if (ImGui::Button("Restore Backup", ImVec2(ImGui::GetContentRegionAvail().x * 1.0f, 0.0f)))
|
||||
if (ImGui::Button("Restore Backup", ImVec2(ImGui::GetContentRegionAvail().x * 1.0f, 0.0f))) {
|
||||
state = StateRestore;
|
||||
}
|
||||
GUI::DisableButtonExit(!backupExists);
|
||||
|
||||
ImGui::Dummy(ImVec2(0.0f, 5.0f)); // Spacing
|
||||
@ -433,14 +440,16 @@ namespace GUI {
|
||||
|
||||
ImGui::SameLine();
|
||||
|
||||
if (ImGui::Button("Apply Changes", ImVec2(ImGui::GetContentRegionAvail().x * 0.5f, 0.0f)))
|
||||
if (ImGui::Button("Apply Changes", ImVec2(ImGui::GetContentRegionAvail().x * 0.5f, 0.0f))) {
|
||||
state = StateConfirmSwap;
|
||||
}
|
||||
|
||||
ImGui::SameLine();
|
||||
|
||||
GUI::DisableButtonInit(!backupExists);
|
||||
if (ImGui::Button("Restore Backup", ImVec2(ImGui::GetContentRegionAvail().x * 1.0f, 0.0f)))
|
||||
if (ImGui::Button("Restore Backup", ImVec2(ImGui::GetContentRegionAvail().x * 1.0f, 0.0f))) {
|
||||
state = StateRestore;
|
||||
}
|
||||
GUI::DisableButtonExit(!backupExists);
|
||||
|
||||
ImGui::Dummy(ImVec2(0.0f, 5.0f)); // Spacing
|
||||
@ -464,8 +473,9 @@ namespace GUI {
|
||||
std::string pageNo = std::to_string(entries.pages[i].pageNo);
|
||||
const bool is_selected = (old_page_id == static_cast<int>(i));
|
||||
if (ImGui::Selectable(pageNo.c_str(), is_selected)) {
|
||||
if (old_page_id == -1)
|
||||
if (old_page_id == -1) {
|
||||
old_page_id = i;
|
||||
}
|
||||
else {
|
||||
int temp = entries.pages[i].pageNo;
|
||||
entries.pages[i].pageNo = entries.pages[old_page_id].pageNo;
|
||||
@ -491,15 +501,17 @@ namespace GUI {
|
||||
ImGui::Dummy(ImVec2(0.0f, 5.0f)); // Spacing
|
||||
|
||||
if (ImGui::Button("Backup current loadout", ImVec2(ImGui::GetContentRegionAvail().x * 1.0f, 0.0f))) {
|
||||
if (R_SUCCEEDED(Loadouts::Backup()))
|
||||
if (R_SUCCEEDED(Loadouts::Backup())) {
|
||||
FS::GetDirList("ux0:data/VITAHomebrewSorter/loadouts", loadouts);
|
||||
}
|
||||
}
|
||||
|
||||
ImGui::Dummy(ImVec2(0.0f, 5.0f)); // Spacing
|
||||
|
||||
if (ImGui::BeginTable("LoadoutList", 4, tableFlags)) {
|
||||
if (loadouts.empty())
|
||||
if (loadouts.empty()) {
|
||||
ImGui::Text("No loadouts found");
|
||||
}
|
||||
else {
|
||||
ImGui::TableSetupColumn("", ImGuiTableColumnFlags_WidthFixed);
|
||||
ImGui::TableSetupColumn("Title");
|
||||
@ -637,8 +649,9 @@ namespace GUI {
|
||||
|
||||
pad = Utils::ReadControls();
|
||||
|
||||
if (pressed & SCE_CTRL_START)
|
||||
if (pressed & SCE_CTRL_START) {
|
||||
done = true;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -20,8 +20,9 @@ namespace Keyboard {
|
||||
std::string text = std::string();
|
||||
|
||||
int Init(const std::string &title) {
|
||||
if (running)
|
||||
if (running) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Clear our text buffer
|
||||
text.clear();
|
||||
@ -52,10 +53,12 @@ namespace Keyboard {
|
||||
}
|
||||
|
||||
SceCommonDialogStatus Update(void) {
|
||||
if (!running)
|
||||
if (!running) {
|
||||
return SCE_COMMON_DIALOG_STATUS_NONE;
|
||||
}
|
||||
|
||||
SceCommonDialogStatus status = sceImeDialogGetStatus();
|
||||
|
||||
if (status == SCE_COMMON_DIALOG_STATUS_FINISHED) {
|
||||
SceImeDialogResult result;
|
||||
sceClibMemset(&result, 0, sizeof(SceImeDialogResult));
|
||||
@ -65,8 +68,9 @@ namespace Keyboard {
|
||||
std::u16string buffer_u16 = reinterpret_cast<char16_t *>(buffer);
|
||||
text = std::wstring_convert<std::codecvt_utf8_utf16<char16_t>, char16_t>{}.to_bytes(buffer_u16.data());
|
||||
}
|
||||
else
|
||||
else {
|
||||
status = static_cast<SceCommonDialogStatus>(SCE_COMMON_DIALOG_STATUS_CANCELLED);
|
||||
}
|
||||
|
||||
sceImeDialogTerm();
|
||||
running = false;
|
||||
@ -76,19 +80,24 @@ namespace Keyboard {
|
||||
}
|
||||
|
||||
std::string GetText(const std::string &title) {
|
||||
if (R_FAILED(Init(title)))
|
||||
if (R_FAILED(Keyboard::Init(title))) {
|
||||
return std::string();
|
||||
}
|
||||
|
||||
bool done = false;
|
||||
|
||||
do {
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
glClearColor(0, 0, 0, 1);
|
||||
|
||||
SceCommonDialogStatus status = Update();
|
||||
if (status == SCE_COMMON_DIALOG_STATUS_FINISHED)
|
||||
SceCommonDialogStatus status = Keyboard::Update();
|
||||
|
||||
if (status == SCE_COMMON_DIALOG_STATUS_FINISHED) {
|
||||
done = true;
|
||||
else if (status != SCE_COMMON_DIALOG_STATUS_CANCELLED)
|
||||
}
|
||||
else if (status != SCE_COMMON_DIALOG_STATUS_CANCELLED) {
|
||||
done = false;
|
||||
}
|
||||
|
||||
vglSwapBuffers(GL_TRUE);
|
||||
} while(!done);
|
||||
|
@ -15,19 +15,22 @@ namespace Loadouts {
|
||||
int ret = 0;
|
||||
std::string filename = Keyboard::GetText("Enter loadout name");
|
||||
|
||||
if (filename.empty())
|
||||
if (filename.empty()) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
// In the case user adds an extension, remove it.
|
||||
filename = Loadouts::StripExt(filename);
|
||||
const std::string loadout_path = "ux0:data/VITAHomebrewSorter/loadouts/" + filename + ".db";
|
||||
const std::string layout_path = "ux0:data/VITAHomebrewSorter/loadouts/" + filename + ".ini";
|
||||
|
||||
if (R_FAILED(ret = FS::CopyFile(db_path, loadout_path)))
|
||||
if (R_FAILED(ret = FS::CopyFile(db_path, loadout_path))) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
if (R_FAILED(ret = FS::CopyFile(ini_path, layout_path)))
|
||||
if (R_FAILED(ret = FS::CopyFile(ini_path, layout_path))) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -40,11 +43,13 @@ namespace Loadouts {
|
||||
const std::string loadout_path = "ux0:data/VITAHomebrewSorter/loadouts/" + raw_filename + ".db";
|
||||
const std::string layout_path = "ux0:data/VITAHomebrewSorter/loadouts/" + raw_filename + ".ini";
|
||||
|
||||
if (R_FAILED(ret = FS::CopyFile(loadout_path, db_path)))
|
||||
if (R_FAILED(ret = FS::CopyFile(loadout_path, db_path))) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
if (R_FAILED(ret = FS::CopyFile(layout_path, ini_path)))
|
||||
if (R_FAILED(ret = FS::CopyFile(layout_path, ini_path))) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -57,11 +62,13 @@ namespace Loadouts {
|
||||
const std::string loadout_path = "ux0:data/VITAHomebrewSorter/loadouts/" + raw_filename + ".db";
|
||||
const std::string layout_path = "ux0:data/VITAHomebrewSorter/loadouts/" + raw_filename + ".ini";
|
||||
|
||||
if (R_FAILED(ret = FS::RemoveFile(loadout_path)))
|
||||
if (R_FAILED(ret = FS::RemoveFile(loadout_path))) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
if (R_FAILED(ret = FS::RemoveFile(layout_path)))
|
||||
if (R_FAILED(ret = FS::RemoveFile(layout_path))) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -13,16 +13,19 @@ namespace Log {
|
||||
void Init(void) {
|
||||
const std::string path = "ux0:data/VITAHomebrewSorter/debug.log";
|
||||
|
||||
if (!FS::FileExists(path))
|
||||
if (!FS::FileExists(path)) {
|
||||
FS::CreateFile(path);
|
||||
}
|
||||
|
||||
if (R_FAILED(log_file = sceIoOpen(path.c_str(), SCE_O_WRONLY | SCE_O_APPEND, 0)))
|
||||
if (R_FAILED(log_file = sceIoOpen(path.c_str(), SCE_O_WRONLY | SCE_O_APPEND, 0))) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void Exit(void) {
|
||||
if (R_FAILED(sceIoClose(log_file)))
|
||||
if (R_FAILED(sceIoClose(log_file))) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void Error(const char *data, ...) {
|
||||
@ -37,7 +40,8 @@ namespace Log {
|
||||
|
||||
sceClibPrintf("%s\n", error_string.c_str());
|
||||
|
||||
if (R_FAILED(sceIoWrite(log_file, error_string.data(), error_string.length())))
|
||||
if (R_FAILED(sceIoWrite(log_file, error_string.data(), error_string.length()))) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -88,11 +88,13 @@ namespace Services {
|
||||
|
||||
sceSysmoduleLoadModule(SCE_SYSMODULE_JSON);
|
||||
|
||||
if (!FS::DirExists("ux0:data/VITAHomebrewSorter/backup"))
|
||||
if (!FS::DirExists("ux0:data/VITAHomebrewSorter/backup")) {
|
||||
FS::MakeDir("ux0:data/VITAHomebrewSorter/backup");
|
||||
}
|
||||
|
||||
if (!FS::DirExists("ux0:data/VITAHomebrewSorter/loadouts"))
|
||||
if (!FS::DirExists("ux0:data/VITAHomebrewSorter/loadouts")) {
|
||||
FS::MakeDir("ux0:data/VITAHomebrewSorter/loadouts");
|
||||
}
|
||||
|
||||
Log::Init();
|
||||
Textures::Init();
|
||||
|
@ -8,8 +8,9 @@ namespace Power {
|
||||
|
||||
static int Thread(SceSize args, void *argp) {
|
||||
while (true) {
|
||||
if (lock_power)
|
||||
if (lock_power) {
|
||||
sceKernelPowerTick(SCE_KERNEL_POWER_TICK_DISABLE_AUTO_SUSPEND);
|
||||
}
|
||||
|
||||
sceKernelDelayThread(10 * 1000 * 1000);
|
||||
}
|
||||
@ -20,8 +21,9 @@ namespace Power {
|
||||
void InitThread(void) {
|
||||
SceUID thread = 0;
|
||||
|
||||
if (R_SUCCEEDED(thread = sceKernelCreateThread("Power::Thread", Power::Thread, 0x10000100, 0x40000, 0, 0, nullptr)))
|
||||
if (R_SUCCEEDED(thread = sceKernelCreateThread("Power::Thread", Power::Thread, 0x10000100, 0x40000, 0, 0, nullptr))) {
|
||||
sceKernelStartThread(thread, 0, nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
void Lock(void) {
|
||||
|
@ -45,12 +45,14 @@ static int psp2DirectWrite(PSP2File *p, const void *zBuf, int iAmt, sqlite_int64
|
||||
int nWrite = 0; /* Return value from sceIoWrite() */
|
||||
|
||||
ofst = sceIoLseek(p->fd, iOfst, SCE_SEEK_SET);
|
||||
if (ofst != iOfst)
|
||||
if (ofst != iOfst) {
|
||||
return SQLITE_IOERR_WRITE;
|
||||
}
|
||||
|
||||
nWrite = sceIoWrite(p->fd, zBuf, iAmt);
|
||||
if (nWrite != iAmt)
|
||||
if (nWrite != iAmt) {
|
||||
return SQLITE_IOERR_WRITE;
|
||||
}
|
||||
|
||||
return SQLITE_OK;
|
||||
}
|
||||
@ -99,20 +101,24 @@ static int psp2Read(sqlite3_file *pFile, void *zBuf, int iAmt, sqlite_int64 iOfs
|
||||
** a journal file when there is data cached in the write-buffer.
|
||||
*/
|
||||
rc = psp2FlushBuffer(p);
|
||||
if (rc != SQLITE_OK)
|
||||
if (rc != SQLITE_OK) {
|
||||
return rc;
|
||||
}
|
||||
|
||||
ofst = sceIoLseek(p->fd, iOfst, SCE_SEEK_SET);
|
||||
if (ofst != iOfst)
|
||||
if (ofst != iOfst) {
|
||||
return SQLITE_IOERR_READ;
|
||||
}
|
||||
|
||||
nRead = sceIoRead(p->fd, zBuf, iAmt);
|
||||
|
||||
if (nRead == iAmt)
|
||||
if (nRead == iAmt) {
|
||||
return SQLITE_OK;
|
||||
}
|
||||
else if (nRead >= 0) {
|
||||
if (nRead < iAmt)
|
||||
if (nRead < iAmt) {
|
||||
sceClibMemset(&(static_cast<char*>(zBuf))[nRead], 0, iAmt-nRead);
|
||||
}
|
||||
|
||||
return SQLITE_IOERR_SHORT_READ;
|
||||
}
|
||||
@ -140,8 +146,9 @@ static int psp2Write(sqlite3_file *pFile, const void *zBuf, int iAmt, sqlite_int
|
||||
*/
|
||||
if (p->nBuffer == SQLITE_PSP2VFS_BUFFERSZ || p->iBufferOfst+p->nBuffer != i) {
|
||||
int rc = psp2FlushBuffer(p);
|
||||
if (rc != SQLITE_OK)
|
||||
if (rc != SQLITE_OK) {
|
||||
return rc;
|
||||
}
|
||||
}
|
||||
|
||||
assert(p->nBuffer == 0 || p->iBufferOfst+p->nBuffer == i);
|
||||
@ -149,8 +156,9 @@ static int psp2Write(sqlite3_file *pFile, const void *zBuf, int iAmt, sqlite_int
|
||||
|
||||
/* Copy as much data as possible into the buffer. */
|
||||
nCopy = SQLITE_PSP2VFS_BUFFERSZ - p->nBuffer;
|
||||
if (nCopy > n)
|
||||
if (nCopy > n) {
|
||||
nCopy = n;
|
||||
}
|
||||
|
||||
sceClibMemcpy(&p->aBuffer[p->nBuffer], z, nCopy);
|
||||
p->nBuffer += nCopy;
|
||||
@ -160,8 +168,9 @@ static int psp2Write(sqlite3_file *pFile, const void *zBuf, int iAmt, sqlite_int
|
||||
z += nCopy;
|
||||
}
|
||||
}
|
||||
else
|
||||
else {
|
||||
return psp2DirectWrite(p, zBuf, iAmt, iOfst);
|
||||
}
|
||||
|
||||
return SQLITE_OK;
|
||||
}
|
||||
@ -182,8 +191,9 @@ static int psp2Sync(sqlite3_file *pFile, int flags) {
|
||||
int rc = 0;
|
||||
|
||||
rc = psp2FlushBuffer(p);
|
||||
if (rc != SQLITE_OK)
|
||||
if (rc != SQLITE_OK) {
|
||||
return rc;
|
||||
}
|
||||
|
||||
rc = sceIoSyncByFd(p->fd, 0);
|
||||
return (rc == 0? SQLITE_OK : SQLITE_IOERR_FSYNC);
|
||||
@ -203,13 +213,15 @@ static int psp2FileSize(sqlite3_file *pFile, sqlite_int64 *pSize) {
|
||||
** not worth the trouble.
|
||||
*/
|
||||
rc = psp2FlushBuffer(p);
|
||||
if (rc != SQLITE_OK)
|
||||
if (rc != SQLITE_OK) {
|
||||
return rc;
|
||||
}
|
||||
|
||||
rc = sceIoGetstatByFd(p->fd, &sStat);
|
||||
|
||||
if (rc != 0)
|
||||
if (rc != 0) {
|
||||
return SQLITE_IOERR_FSTAT;
|
||||
}
|
||||
|
||||
*pSize = sStat.st_size;
|
||||
return SQLITE_OK;
|
||||
@ -278,29 +290,36 @@ static int psp2Open(sqlite3_vfs *pVfs, const char *zName, sqlite3_file *pFile, i
|
||||
int oflags = 0; /* flags to pass to open() call */
|
||||
char *aBuf = 0;
|
||||
|
||||
if (zName == 0)
|
||||
if (zName == 0) {
|
||||
return SQLITE_IOERR;
|
||||
}
|
||||
|
||||
if (flags & SQLITE_OPEN_MAIN_JOURNAL) {
|
||||
aBuf = reinterpret_cast<char*>(sqlite3_malloc(SQLITE_PSP2VFS_BUFFERSZ));
|
||||
|
||||
if (!aBuf)
|
||||
if (!aBuf) {
|
||||
return SQLITE_NOMEM;
|
||||
}
|
||||
}
|
||||
|
||||
if (flags & SQLITE_OPEN_EXCLUSIVE)
|
||||
if (flags & SQLITE_OPEN_EXCLUSIVE) {
|
||||
oflags |= SCE_O_EXCL;
|
||||
if (flags & SQLITE_OPEN_CREATE)
|
||||
}
|
||||
if (flags & SQLITE_OPEN_CREATE) {
|
||||
oflags |= SCE_O_CREAT;
|
||||
if (flags & SQLITE_OPEN_READONLY)
|
||||
}
|
||||
if (flags & SQLITE_OPEN_READONLY) {
|
||||
oflags |= SCE_O_RDONLY;
|
||||
if (flags & SQLITE_OPEN_READWRITE)
|
||||
}
|
||||
if (flags & SQLITE_OPEN_READWRITE) {
|
||||
oflags |= SCE_O_RDWR;
|
||||
}
|
||||
|
||||
// TODO(xyz): sqlite tries to open inexistant journal and then tries to read from it, wtf?
|
||||
// so force O_CREAT here
|
||||
if (flags & SQLITE_OPEN_MAIN_JOURNAL && !(flags & SQLITE_OPEN_EXCLUSIVE))
|
||||
if (flags & SQLITE_OPEN_MAIN_JOURNAL && !(flags & SQLITE_OPEN_EXCLUSIVE)) {
|
||||
oflags |= SCE_O_CREAT;
|
||||
}
|
||||
|
||||
sceClibMemset(p, 0, sizeof(PSP2File));
|
||||
p->fd = sceIoOpen(zName, oflags, 7);
|
||||
@ -312,8 +331,9 @@ static int psp2Open(sqlite3_vfs *pVfs, const char *zName, sqlite3_file *pFile, i
|
||||
|
||||
p->aBuffer = aBuf;
|
||||
|
||||
if (pOutFlags)
|
||||
if (pOutFlags) {
|
||||
*pOutFlags = flags;
|
||||
}
|
||||
|
||||
p->base.pMethods = &psp2io;
|
||||
return SQLITE_OK;
|
||||
@ -512,8 +532,9 @@ sqlite3_vfs *sqlite3_psp2vfs(void) {
|
||||
}
|
||||
|
||||
int sqlite3_os_init(void) {
|
||||
if (sqlite3_vfs_register(sqlite3_psp2vfs(), 1) != SQLITE_OK)
|
||||
if (sqlite3_vfs_register(sqlite3_psp2vfs(), 1) != SQLITE_OK) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -50,8 +50,9 @@ namespace Textures {
|
||||
png_image_free(&image);
|
||||
}
|
||||
}
|
||||
else
|
||||
else {
|
||||
Log::Error("png_image_begin_read_from_memory failed: %s\n", image.message);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
@ -72,12 +72,11 @@ namespace Utils {
|
||||
return ret;
|
||||
}
|
||||
|
||||
if (button == SCE_SYSTEM_PARAM_ENTER_BUTTON_CIRCLE)
|
||||
if (button == SCE_SYSTEM_PARAM_ENTER_BUTTON_CIRCLE) {
|
||||
return SCE_CTRL_CIRCLE;
|
||||
else
|
||||
return SCE_CTRL_CROSS;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return SCE_CTRL_CROSS;
|
||||
}
|
||||
|
||||
int GetCancelButton(void) {
|
||||
@ -87,12 +86,11 @@ namespace Utils {
|
||||
return ret;
|
||||
}
|
||||
|
||||
if (button == SCE_SYSTEM_PARAM_ENTER_BUTTON_CIRCLE)
|
||||
if (button == SCE_SYSTEM_PARAM_ENTER_BUTTON_CIRCLE) {
|
||||
return SCE_CTRL_CROSS;
|
||||
else
|
||||
return SCE_CTRL_CIRCLE;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return SCE_CTRL_CIRCLE;
|
||||
}
|
||||
|
||||
int GetDateFormat(void) {
|
||||
|
Loading…
Reference in New Issue
Block a user