Merge pull request #6519 from juhalaukkanen/master

cheat.db import - minimal feedback to user
This commit is contained in:
Henrik Rydgård 2014-07-23 10:32:06 +02:00
commit 6fab8e2f74
4 changed files with 47 additions and 5 deletions

View File

@ -1470,8 +1470,23 @@ if(UNITTEST)
endif()
if (TargetBin)
if (IOS)
add_executable(${TargetBin} MACOSX_BUNDLE ${NativeAppSource})
if (IOS OR APPLE)
set(ICON_PATH_ABS ${CMAKE_CURRENT_SOURCE_DIR}/assets/icon-114.icns)
set( MACOSX_BUNDLE_ICON_FILE icon-114.icns )
set_source_files_properties(${ICON_PATH_ABS} PROPERTIES MACOSX_PACKAGE_LOCATION "Resources")
# TODO: there must a native way to copy these.
# Now this is very prone to errors when changes occur.
# Also better to have assets under Resources dir.
file(GLOB_RECURSE FLASH0_FILES flash0/*)
file(GLOB_RECURSE LANG_FILES lang/*)
file(GLOB_RECURSE SHADER_FILES assets/shaders/*)
set_source_files_properties(${NativeAssets} PROPERTIES MACOSX_PACKAGE_LOCATION "MacOS/assets")
set_source_files_properties(${FLASH0_FILES} PROPERTIES MACOSX_PACKAGE_LOCATION "MacOS/assets/flash0/font")
set_source_files_properties(${LANG_FILES} PROPERTIES MACOSX_PACKAGE_LOCATION "MacOS/assets/lang")
set_source_files_properties(${SHADER_FILES} PROPERTIES MACOSX_PACKAGE_LOCATION "MacOS/assets/shaders")
add_executable(${TargetBin} MACOSX_BUNDLE ${ICON_PATH_ABS} ${NativeAssets} ${SHADER_FILES} ${FLASH0_FILES} ${LANG_FILES} ${NativeAppSource})
else()
add_executable(${TargetBin} ${NativeAppSource})
endif()

View File

@ -73,7 +73,7 @@ void CwCheatScreen::CreateViews() {
leftColumn->Add(new Choice(d->T("Back")))->OnClick.Handle<UIScreen>(this, &UIScreen::OnBack);
//leftColumn->Add(new Choice(k->T("Add Cheat")))->OnClick.Handle(this, &CwCheatScreen::OnAddCheat);
leftColumn->Add(new Choice(k->T("Import Cheats")))->OnClick.Handle(this, &CwCheatScreen::OnImportCheat);
#ifdef _WIN32
#if defined(_WIN32) || defined(__APPLE__) || defined(__linux__)
leftColumn->Add(new Choice(k->T("Edit Cheat File")))->OnClick.Handle(this, &CwCheatScreen::OnEditCheatFile);
#endif
leftColumn->Add(new Choice(k->T("Enable/Disable All")))->OnClick.Handle(this, &CwCheatScreen::OnEnableAll);
@ -145,9 +145,9 @@ UI::EventReturn CwCheatScreen::OnAddCheat(UI::EventParams &params) {
}
UI::EventReturn CwCheatScreen::OnEditCheatFile(UI::EventParams &params) {
std::string cheatFile;
#ifdef _WIN32
std::string cheatFile = activeCheatFile;
cheatFile = activeCheatFile;
// Can't rely on a .txt file extension to auto-open in the right editor,
// so let's find notepad
wchar_t notepad_path[MAX_PATH];
@ -175,6 +175,15 @@ UI::EventReturn CwCheatScreen::OnEditCheatFile(UI::EventParams &params) {
if (!retval) {
ERROR_LOG(BOOT, "Failed creating notepad process");
}
#elif defined(__APPLE__) || defined(__linux__)
#if defined(__linux__)
cheatFile = "xdg-open ";
#elif defined(__APPLE__)
cheatFile = "open ";
#endif
cheatFile.append(activeCheatFile);
NOTICE_LOG(BOOT, "Launching %s", cheatFile.c_str());
system(cheatFile.c_str());
#endif
return UI::EVENT_DONE;
}
@ -190,6 +199,10 @@ UI::EventReturn CwCheatScreen::OnImportCheat(UI::EventParams &params) {
std::fstream fs;
File::OpenCPPFile(fs, cheatFile, std::ios::in);
if (!fs.is_open()) {
WARN_LOG(COMMON, "Unable to open %s\n", cheatFile.c_str());
}
while (fs.good()) {
getline(fs, line); // get line from file
if (line == "_S " + gameTitle.substr(0, 4) + "-" + gameTitle.substr(4)) {
@ -238,9 +251,12 @@ UI::EventReturn CwCheatScreen::OnImportCheat(UI::EventParams &params) {
if (title2.substr(0, 2) != "_S" && it != title.end() && (++it) != title.end()) {
fs << title[0] << "\n" << title[1];
}
NOTICE_LOG(COMMON, "Imported %lu entries from %s.\n", newList.size(), cheatFile.c_str());
if (newList.size() != 0) {
fs << "\n";
}
for (int i = 0; i < (int)newList.size(); i++) {
fs << newList[i];
if (i < (int)newList.size() - 1) {

View File

@ -878,6 +878,17 @@ void NativeResized() {
// The UI now supports any offset but not the EmuScreen yet.
uiContext->SetBounds(Bounds(0, 0, dp_xres, dp_yres));
// uiContext->SetBounds(Bounds(dp_xres/2, 0, dp_xres / 2, dp_yres / 2));
// OSX 10.6 and SDL 1.2 bug.
#ifdef __APPLE__
static int dp_xres_old=dp_xres;
if (dp_xres != dp_xres_old) {
UIShader_Init();
uiTexture->Load("ui_atlas.zim");
dp_xres_old = dp_xres;
}
#endif
}
}

BIN
assets/icon-114.icns Normal file

Binary file not shown.