Skip to content

Commit

Permalink
Merge pull request #2 from hrydgard/master
Browse files Browse the repository at this point in the history
Update README.md
  • Loading branch information
Panderner authored Jan 8, 2021
2 parents f715509 + 57fda69 commit 7796eea
Show file tree
Hide file tree
Showing 34 changed files with 570 additions and 140 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -775,7 +775,7 @@ if(NOT MSVC)
endif()


find_package(LibZip)
find_package(LIBZIP)
if(LIBZIP_FOUND AND USE_SYSTEM_LIBZIP)
add_definitions(-DSHARED_LIBZIP)
else()
Expand Down
2 changes: 1 addition & 1 deletion Common/File/PathBrowser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ bool PathBrowser::CanNavigateUp() {
}
#endif
*/
if (path_ == "/") {
if (path_ == "/" || path_ == "") {
return false;
}
return true;
Expand Down
6 changes: 6 additions & 0 deletions Common/System/System.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@ enum SystemProperty {
SYSPROP_CLIPBOARD_TEXT,
SYSPROP_GPUDRIVER_VERSION,

// Separate SD cards or similar.
// Need hacky solutions to get at this.
SYSPROP_HAS_ADDITIONAL_STORAGE,
SYSPROP_ADDITIONAL_STORAGE_DIRS,

SYSPROP_HAS_FILE_BROWSER,
SYSPROP_HAS_FOLDER_BROWSER,
SYSPROP_HAS_IMAGE_BROWSER,
Expand Down Expand Up @@ -95,6 +100,7 @@ enum SystemProperty {
};

std::string System_GetProperty(SystemProperty prop);
std::vector<std::string> System_GetPropertyStringVec(SystemProperty prop);
int System_GetPropertyInt(SystemProperty prop);
float System_GetPropertyFloat(SystemProperty prop);
bool System_GetPropertyBool(SystemProperty prop);
Expand Down
4 changes: 4 additions & 0 deletions Common/UI/View.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -803,6 +803,10 @@ void TextView::Draw(UIContext &dc) {
dc.DrawTextRect(text_.c_str(), bounds_.Offset(1.0f, 1.0f), shadowColor, textAlign_);
}
dc.DrawTextRect(text_.c_str(), bounds_, textColor, textAlign_);
if (small_) {
// If we changed font style, reset it.
dc.SetFontStyle(dc.theme->uiFont);
}
if (clip) {
dc.PopScissor();
}
Expand Down
16 changes: 8 additions & 8 deletions Core/Dialog/SavedataParam.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1485,19 +1485,20 @@ int SavedataParam::SetPspParam(SceUtilitySavedataParam *param)
}

const std::string thisSaveName = FixedToString(saveNameListData[i], ARRAY_SIZE(saveNameListData[i]));
DEBUG_LOG(SCEUTILITY, "Name : %s", thisSaveName.c_str());

std::string fileDataDir = savePath + GetGameName(param) + thisSaveName;
PSPFileInfo info = GetSaveInfo(fileDataDir);
if (info.exists) {
SetFileInfo(realCount, info, thisSaveName);
DEBUG_LOG(SCEUTILITY,"%s Exist",fileDataDir.c_str());
DEBUG_LOG(SCEUTILITY, "Save data exists: %s = %s", thisSaveName.c_str(), fileDataDir.c_str());
realCount++;
} else {
if (listEmptyFile) {
ClearFileInfo(saveDataList[realCount], thisSaveName);
DEBUG_LOG(SCEUTILITY,"Don't Exist");
DEBUG_LOG(SCEUTILITY, "Listing missing save data: %s = %s", thisSaveName.c_str(), fileDataDir.c_str());
realCount++;
} else {
DEBUG_LOG(SCEUTILITY, "Save data not found: %s = %s", thisSaveName.c_str(), fileDataDir.c_str());
}
}
}
Expand All @@ -1513,18 +1514,18 @@ int SavedataParam::SetPspParam(SceUtilitySavedataParam *param)
saveDataListCount = 1;

// get and stock file info for each file
DEBUG_LOG(SCEUTILITY,"Name : %s",GetSaveName(param).c_str());

std::string fileDataDir = savePath + GetGameName(param) + GetSaveName(param);
PSPFileInfo info = GetSaveInfo(fileDataDir);
if (info.exists) {
SetFileInfo(0, info, GetSaveName(param));
ERROR_LOG(SCEUTILITY,"%s Exist",fileDataDir.c_str());
DEBUG_LOG(SCEUTILITY, "Save data exists: %s = %s", GetSaveName(param).c_str(), fileDataDir.c_str());
saveNameListDataCount = 1;
} else {
if (listEmptyFile) {
ClearFileInfo(saveDataList[0], GetSaveName(param));
DEBUG_LOG(SCEUTILITY,"Don't Exist");
DEBUG_LOG(SCEUTILITY, "Listing missing save data: %s = %s", GetSaveName(param).c_str(), fileDataDir.c_str());
} else {
DEBUG_LOG(SCEUTILITY, "Save data not found: %s = %s", GetSaveName(param).c_str(), fileDataDir.c_str());
}
saveNameListDataCount = 0;
return 0;
Expand Down Expand Up @@ -1631,7 +1632,6 @@ PSPFileInfo SavedataParam::GetSaveInfo(std::string saveDir) {
}
}
}
ERROR_LOG(HLE, "size = %d", info.size);
return info;
}

Expand Down
7 changes: 7 additions & 0 deletions Qt/QtMain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,13 @@ std::string System_GetProperty(SystemProperty prop) {
}
}

std::vector<std::string> System_GetPropertyStringVec(SystemProperty prop) {
switch (prop) {
default:
return std::vector<std::string>();
}
}

int System_GetPropertyInt(SystemProperty prop) {
switch (prop) {
#if defined(SDL)
Expand Down
7 changes: 7 additions & 0 deletions SDL/SDLMain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,13 @@ std::string System_GetProperty(SystemProperty prop) {
}
}

std::vector<std::string> System_GetPropertyStringVec(SystemProperty prop) {
switch (prop) {
default:
return std::vector<std::string>();
}
}

int System_GetPropertyInt(SystemProperty prop) {
switch (prop) {
case SYSPROP_AUDIO_SAMPLE_RATE:
Expand Down
6 changes: 4 additions & 2 deletions UI/CwCheatScreen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -328,8 +328,10 @@ bool CwCheatScreen::RebuildCheatFile(int index) {
return false;
}

for (const auto &line : lines) {
fs << line << '\n';
for (int i = 0; i < lines.size(); ++i) {
fs << lines[i];
if (i != lines.size()-1)
fs << '\n';
}
fs.close();

Expand Down
44 changes: 36 additions & 8 deletions UI/MainScreen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -540,13 +540,29 @@ UI::EventReturn GameBrowser::LastClick(UI::EventParams &e) {
return UI::EVENT_DONE;
}

UI::EventReturn GameBrowser::HomeClick(UI::EventParams &e) {
#if PPSSPP_PLATFORM(ANDROID) || PPSSPP_PLATFORM(SWITCH) || defined(USING_QT_UI) || defined(USING_WIN_UI) || PPSSPP_PLATFORM(UWP)
if (System_GetPropertyBool(SYSPROP_HAS_FOLDER_BROWSER)) {
System_SendMessage("browse_folder", "");
UI::EventReturn GameBrowser::BrowseClick(UI::EventParams &e) {
System_SendMessage("browse_folder", "");
return UI::EVENT_DONE;
}

UI::EventReturn GameBrowser::StorageClick(UI::EventParams &e) {
std::vector<std::string> storageDirs = System_GetPropertyStringVec(SYSPROP_ADDITIONAL_STORAGE_DIRS);
if (storageDirs.empty()) {
// Shouldn't happen - this button shouldn't be clickable.
return UI::EVENT_DONE;
}
if (storageDirs.size() == 1) {
SetPath(storageDirs[0]);
} else {
SetPath(g_Config.memStickDirectory);
// TODO: We should popup a dialog letting the user choose one.
SetPath(storageDirs[0]);
}
return UI::EVENT_DONE;
}

UI::EventReturn GameBrowser::HomeClick(UI::EventParams &e) {
#if PPSSPP_PLATFORM(ANDROID) || PPSSPP_PLATFORM(SWITCH) || defined(USING_WIN_UI) || PPSSPP_PLATFORM(UWP)
SetPath(g_Config.memStickDirectory);
#else
SetPath(getenv("HOME"));
#endif
Expand Down Expand Up @@ -656,10 +672,12 @@ void GameBrowser::Refresh() {
if (browseFlags_ & BrowseFlags::NAVIGATE) {
topBar->Add(new Spacer(2.0f));
topBar->Add(new TextView(path_.GetFriendlyPath().c_str(), ALIGN_VCENTER | FLAG_WRAP_TEXT, true, new LinearLayoutParams(FILL_PARENT, 64.0f, 1.0f)));
topBar->Add(new Choice(ImageID("I_HOME"), new LayoutParams(WRAP_CONTENT, 64.0f)))->OnClick.Handle(this, &GameBrowser::HomeClick);
if (System_GetPropertyBool(SYSPROP_HAS_ADDITIONAL_STORAGE)) {
topBar->Add(new Choice(ImageID("I_SDCARD"), new LayoutParams(WRAP_CONTENT, 64.0f)))->OnClick.Handle(this, &GameBrowser::StorageClick);
}
if (System_GetPropertyBool(SYSPROP_HAS_FOLDER_BROWSER)) {
topBar->Add(new Choice(mm->T("Browse", "Browse..."), new LayoutParams(WRAP_CONTENT, 64.0f)))->OnClick.Handle(this, &GameBrowser::HomeClick);
} else {
topBar->Add(new Choice(mm->T("Home"), new LayoutParams(WRAP_CONTENT, 64.0f)))->OnClick.Handle(this, &GameBrowser::HomeClick);
topBar->Add(new Choice(mm->T("Browse", "Browse..."), new LayoutParams(WRAP_CONTENT, 64.0f)))->OnClick.Handle(this, &GameBrowser::BrowseClick);
}
} else {
topBar->Add(new Spacer(new LinearLayoutParams(FILL_PARENT, 64.0f, 1.0f)));
Expand Down Expand Up @@ -762,6 +780,7 @@ void GameBrowser::Refresh() {
gameList_->Add(new DirButton("..", *gridStyle_, new UI::LinearLayoutParams(UI::FILL_PARENT, UI::FILL_PARENT)))->
OnClick.Handle(this, &GameBrowser::NavigateClick);
}

// Add any pinned paths before other directories.
auto pinnedPaths = GetPinnedPaths();
for (auto it = pinnedPaths.begin(), end = pinnedPaths.end(); it != end; ++it) {
Expand Down Expand Up @@ -1079,6 +1098,13 @@ void MainScreen::CreateViews() {
logos->Add(new ImageView(ImageID("I_ICON"), IS_DEFAULT, new AnchorLayoutParams(64, 64, 10, 10, NONE, NONE, false)));
}
logos->Add(new ImageView(ImageID("I_LOGO"), IS_DEFAULT, new LinearLayoutParams(Margins(-12, 0, 0, 0))));

#if defined(USING_WIN_UI) || defined(USING_QT_UI) || PPSSPP_PLATFORM(UWP)
if (!g_Config.bFullScreen) {
logos->Add(new ImageView(ImageID("I_FULLSCREEN"), IS_DEFAULT, new AnchorLayoutParams(64, 64, NONE, 0, 0, NONE, false)));
}
#endif

rightColumnItems->Add(logos);
TextView *ver = rightColumnItems->Add(new TextView(versionString, new LinearLayoutParams(Margins(70, -6, 0, 0))));
ver->SetSmall(true);
Expand Down Expand Up @@ -1274,6 +1300,7 @@ bool MainScreen::DrawBackgroundFor(UIContext &dc, const std::string &gamePath, f
}

UI::EventReturn MainScreen::OnGameSelected(UI::EventParams &e) {
g_Config.Save("MainScreen::OnGameSelected");
#ifdef _WIN32
std::string path = ReplaceAll(e.s, "\\", "/");
#else
Expand Down Expand Up @@ -1328,6 +1355,7 @@ UI::EventReturn MainScreen::OnGameHighlight(UI::EventParams &e) {
}

UI::EventReturn MainScreen::OnGameSelectedInstant(UI::EventParams &e) {
g_Config.Save("MainScreen::OnGameSelectedInstant");
#ifdef _WIN32
std::string path = ReplaceAll(e.s, "\\", "/");
#else
Expand Down
2 changes: 2 additions & 0 deletions UI/MainScreen.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ class GameBrowser : public UI::LinearLayout {
UI::EventReturn NavigateClick(UI::EventParams &e);
UI::EventReturn LayoutChange(UI::EventParams &e);
UI::EventReturn LastClick(UI::EventParams &e);
UI::EventReturn BrowseClick(UI::EventParams &e);
UI::EventReturn StorageClick(UI::EventParams &e);
UI::EventReturn HomeClick(UI::EventParams &e);
UI::EventReturn PinToggleClick(UI::EventParams &e);
UI::EventReturn GridSettingsClick(UI::EventParams &e);
Expand Down
7 changes: 7 additions & 0 deletions UWP/PPSSPP_UWPMain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,13 @@ std::string System_GetProperty(SystemProperty prop) {
}
}

std::vector<std::string> System_GetPropertyStringVec(SystemProperty prop) {
switch (prop) {
default:
return std::vector<std::string>();
}
}

int System_GetPropertyInt(SystemProperty prop) {
switch (prop) {
case SYSPROP_AUDIO_SAMPLE_RATE:
Expand Down
7 changes: 7 additions & 0 deletions Windows/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,13 @@ std::string System_GetProperty(SystemProperty prop) {
}
}

std::vector<std::string> System_GetPropertyStringVec(SystemProperty prop) {
switch (prop) {
default:
return std::vector<std::string>();
}
}

// Ugly!
extern WindowsAudioBackend *winAudioBackend;

Expand Down
Binary file modified android/assets/ui_atlas.meta
Binary file not shown.
Binary file modified android/assets/ui_atlas.zim
Binary file not shown.
43 changes: 36 additions & 7 deletions android/jni/app-android.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
#include <thread>
#include <atomic>

#include <android/log.h>

#ifndef _MSC_VER
#include <jni.h>
#include <android/native_window_jni.h>
Expand Down Expand Up @@ -122,6 +124,8 @@ std::string langRegion;
std::string mogaVersion;
std::string boardName;

std::vector<std::string> g_additionalStorageDirs;

static float left_joystick_x_async;
static float left_joystick_y_async;
static float right_joystick_x_async;
Expand Down Expand Up @@ -364,6 +368,15 @@ std::string System_GetProperty(SystemProperty prop) {
}
}

std::vector<std::string> System_GetPropertyStringVec(SystemProperty prop) {
switch (prop) {
case SYSPROP_ADDITIONAL_STORAGE_DIRS:
return g_additionalStorageDirs;
default:
return std::vector<std::string>();
}
}

int System_GetPropertyInt(SystemProperty prop) {
switch (prop) {
case SYSPROP_SYSTEMVERSION:
Expand Down Expand Up @@ -410,6 +423,8 @@ bool System_GetPropertyBool(SystemProperty prop) {
return androidVersion >= 23; // 6.0 Marshmallow introduced run time permissions.
case SYSPROP_SUPPORTS_SUSTAINED_PERF_MODE:
return sustainedPerfSupported; // 7.0 introduced sustained performance mode as an optional feature.
case SYSPROP_HAS_ADDITIONAL_STORAGE:
return !g_additionalStorageDirs.empty();
case SYSPROP_HAS_BACK_BUTTON:
return true;
case SYSPROP_HAS_IMAGE_BROWSER:
Expand Down Expand Up @@ -530,16 +545,19 @@ static void parse_args(std::vector<std::string> &args, const std::string value)
}
}

// Need to use raw Android logging before NativeInit.
#define EARLY_LOG(...) __android_log_print(ANDROID_LOG_INFO, "PPSSPP", __VA_ARGS__)

extern "C" void Java_org_ppsspp_ppsspp_NativeApp_init
(JNIEnv *env, jclass, jstring jmodel, jint jdeviceType, jstring jlangRegion, jstring japkpath,
jstring jdataDir, jstring jexternalDir, jstring jlibraryDir, jstring jcacheDir, jstring jshortcutParam,
jstring jdataDir, jstring jexternalStorageDir, jstring jadditionalStorageDirs, jstring jlibraryDir, jstring jcacheDir, jstring jshortcutParam,
jint jAndroidVersion, jstring jboard) {
setCurrentThreadName("androidInit");

// Makes sure we get early permission grants.
ProcessFrameCommands(env);

INFO_LOG(SYSTEM, "NativeApp.init() -- begin");
EARLY_LOG("NativeApp.init() -- begin");
PROFILE_INIT();

renderer_inited = false;
Expand All @@ -559,9 +577,18 @@ extern "C" void Java_org_ppsspp_ppsspp_NativeApp_init
systemName = GetJavaString(env, jmodel);
langRegion = GetJavaString(env, jlangRegion);

INFO_LOG(SYSTEM, "NativeApp.init(): device name: '%s'", systemName.c_str());
EARLY_LOG("NativeApp.init(): device name: '%s'", systemName.c_str());

std::string externalStorageDir = GetJavaString(env, jexternalStorageDir);
std::string additionalStorageDirsString = GetJavaString(env, jadditionalStorageDirs);

if (!additionalStorageDirsString.empty()) {
SplitString(additionalStorageDirsString, ':', g_additionalStorageDirs);
for (auto &str : g_additionalStorageDirs) {
EARLY_LOG("Additional storage: %s", str.c_str());
}
}

std::string externalDir = GetJavaString(env, jexternalDir);
std::string user_data_path = GetJavaString(env, jdataDir);
if (user_data_path.size() > 0)
user_data_path += "/";
Expand All @@ -570,8 +597,8 @@ extern "C" void Java_org_ppsspp_ppsspp_NativeApp_init
std::string cacheDir = GetJavaString(env, jcacheDir);
std::string buildBoard = GetJavaString(env, jboard);
boardName = buildBoard;
INFO_LOG(SYSTEM, "NativeApp.init(): External storage path: %s", externalDir.c_str());
INFO_LOG(SYSTEM, "NativeApp.init(): Launch shortcut parameter: %s", shortcut_param.c_str());
EARLY_LOG("NativeApp.init(): External storage path: %s", externalStorageDir.c_str());
EARLY_LOG("NativeApp.init(): Launch shortcut parameter: %s", shortcut_param.c_str());

std::string app_name;
std::string app_nice_name;
Expand Down Expand Up @@ -600,7 +627,9 @@ extern "C" void Java_org_ppsspp_ppsspp_NativeApp_init
}
}

NativeInit((int)args.size(), &args[0], user_data_path.c_str(), externalDir.c_str(), cacheDir.c_str());
NativeInit((int)args.size(), &args[0], user_data_path.c_str(), externalStorageDir.c_str(), cacheDir.c_str());

// No need to use EARLY_LOG anymore.

retry:
// Now that we've loaded config, set javaGL.
Expand Down
Loading

0 comments on commit 7796eea

Please sign in to comment.