If the user opens a ZIP file, offer to install it (it will show up in Homebrew & Demos).

No progress bar yet, it just freezes during install.
This commit is contained in:
Henrik Rydgård 2013-12-05 14:14:15 +01:00
parent 160cafdb34
commit d6c8c6cfa0
10 changed files with 134 additions and 12 deletions

View File

@ -1160,6 +1160,7 @@ set(NativeAppSource
UI/ControlMappingScreen.cpp
UI/Store.cpp
UI/CwCheatScreen.cpp
UI/InstallZipScreen.cpp
UI/ui_atlas.cpp)
if(ANDROID AND ARM)
set(NativeAppSource ${NativeAppSource} android/jni/ArmEmitterTest.cpp)

View File

@ -44,11 +44,10 @@
#include "Core/MIPS/JitCommon/JitCommon.h"
#include "Core/SaveState.h"
#include "UI/OnScreenDisplay.h"
#include "UI/ui_atlas.h"
#include "UI/OnScreenDisplay.h"
#include "UI/GamepadEmu.h"
#include "UI/UIShader.h"
#include "UI/MainScreen.h"
#include "UI/EmuScreen.h"
#include "UI/DevScreens.h"
@ -56,7 +55,7 @@
#include "UI/MiscScreens.h"
#include "UI/ControlMappingScreen.h"
#include "UI/GameSettingsScreen.h"
#include "UI/InstallZipScreen.h"
EmuScreen::EmuScreen(const std::string &filename)
: booted_(false), gamePath_(filename), invalid_(true), pauseTrigger_(false) {
@ -459,13 +458,20 @@ void EmuScreen::update(InputState &input) {
UpdateUIState(UISTATE_INGAME);
if (errorMessage_.size()) {
// Special handling for ZIP files. It's not very robust to check an error message but meh,
// at least it's pre-translation.
if (errorMessage_.find("ZIP") != std::string::npos) {
screenManager()->push(new InstallZipScreen(gamePath_));
errorMessage_ = "";
return;
}
I18NCategory *g = GetI18NCategory("Error");
std::string errLoadingFile = g->T("Error loading file");
std::string errLoadingFile = g->T("Error loading file", "Could not load game");
errLoadingFile.append(" ");
errLoadingFile.append(g->T(errorMessage_.c_str()));
screenManager()->push(new PromptScreen(
errLoadingFile, "OK", ""));
screenManager()->push(new PromptScreen(errLoadingFile, "OK", ""));
errorMessage_ = "";
return;
}

66
UI/InstallZipScreen.cpp Normal file
View File

@ -0,0 +1,66 @@
// Copyright (c) 2013- PPSSPP Project.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, version 2.0 or later versions.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License 2.0 for more details.
// A copy of the GPL 2.0 should have been included with the program.
// If not, see http://www.gnu.org/licenses/
// Official git repository and contact information can be found at
// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.
#include "base/logging.h"
#include "i18n/i18n.h"
#include "ui/ui.h"
#include "ui/view.h"
#include "ui/viewgroup.h"
#include "UI/ui_atlas.h"
#include "file/file_util.h"
#include "Core/Util/GameManager.cpp"
#include "UI/InstallZipScreen.h"
void InstallZipScreen::CreateViews() {
using namespace UI;
FileInfo fileInfo;
bool success = getFileInfo(zipPath_.c_str(), &fileInfo);
I18NCategory *di = GetI18NCategory("Dialog");
Margins actionMenuMargins(0, 100, 15, 0);
root_ = new LinearLayout(ORIENT_HORIZONTAL);
ViewGroup *leftColumn = new AnchorLayout(new LinearLayoutParams(1.0f));
root_->Add(leftColumn);
leftColumn->Add(new TextView(di->T("Install game from ZIP file?"), ALIGN_LEFT, false, new AnchorLayoutParams(10, 10, NONE, NONE)));
leftColumn->Add(new TextView(zipPath_, ALIGN_LEFT, false, new AnchorLayoutParams(10, 60, NONE, NONE)));
ViewGroup *rightColumnItems = new LinearLayout(ORIENT_VERTICAL, new LinearLayoutParams(300, FILL_PARENT, actionMenuMargins));
root_->Add(rightColumnItems);
installChoice_ = rightColumnItems->Add(new Choice(di->T("Install")));
installChoice_->OnClick.Handle(this, &InstallZipScreen::OnInstall);
rightColumnItems->Add(new Choice(di->T("Back")))->OnClick.Handle<UIScreen>(this, &UIScreen::OnBack);
rightColumnItems->Add(new CheckBox(&deleteZipFile_, di->T("Delete ZIP file")));
}
UI::EventReturn InstallZipScreen::OnInstall(UI::EventParams &params) {
installChoice_->SetEnabled(false);
if (g_GameManager.InstallGameOnThread(zipPath_)) {
screenManager()->finishDialog(this, DR_OK);
}
return UI::EVENT_DONE;
}
void InstallZipScreen::update(InputState &input) {
UIScreen::update(input);
}

41
UI/InstallZipScreen.h Normal file
View File

@ -0,0 +1,41 @@
// Copyright (c) 2013- PPSSPP Project.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, version 2.0 or later versions.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License 2.0 for more details.
// A copy of the GPL 2.0 should have been included with the program.
// If not, see http://www.gnu.org/licenses/
// Official git repository and contact information can be found at
// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.
#pragma once
#include "base/functional.h"
#include "ui/view.h"
#include "ui/ui_screen.h"
#include "UI/MiscScreens.h"
class InstallZipScreen : public UIDialogScreenWithBackground {
public:
InstallZipScreen(std::string zipPath) : installChoice_(0), zipPath_(zipPath), deleteZipFile_(false) {}
virtual void update(InputState &input);
protected:
virtual void CreateViews();
private:
UI::EventReturn OnInstall(UI::EventParams &params);
UI::Choice *installChoice_;
std::string zipPath_;
bool deleteZipFile_;
};

View File

@ -269,7 +269,6 @@ void NewLanguageScreen::OnCompleted(DialogResult result) {
if (result != DR_OK)
return;
std::string oldLang = g_Config.sLanguageIni;
std::string iniFile = langs_[listView_->GetSelected()].name;
size_t dot = iniFile.find('.');
@ -281,7 +280,7 @@ void NewLanguageScreen::OnCompleted(DialogResult result) {
return;
g_Config.sLanguageIni = code;
if (i18nrepo.LoadIni(g_Config.sLanguageIni)) {
// Dunno what else to do here.
if (langValuesMapping.find(code) == langValuesMapping.end()) {

View File

@ -35,6 +35,7 @@
<ClCompile Include="TiltAnalogSettingsScreen.cpp" />
<ClCompile Include="TouchControlLayoutScreen.cpp" />
<ClCompile Include="TouchControlVisibilityScreen.cpp" />
<ClCompile Include="InstallZipScreen.cpp" />
<ClCompile Include="UIShader.cpp" />
<ClCompile Include="ui_atlas.cpp" />
</ItemGroup>
@ -54,6 +55,7 @@
<ClInclude Include="TiltAnalogSettingsScreen.h" />
<ClInclude Include="TouchControlLayoutScreen.h" />
<ClInclude Include="TouchControlVisibilityScreen.h" />
<ClInclude Include="InstallZipScreen.h" />
<ClInclude Include="UIShader.h" />
<ClInclude Include="ui_atlas.h" />
</ItemGroup>
@ -186,4 +188,4 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
</Project>

View File

@ -40,6 +40,9 @@
<ClCompile Include="TiltAnalogSettingsScreen.cpp">
<Filter>Screens</Filter>
</ClCompile>
<ClCompile Include="InstallZipScreen.cpp">
<Filter>Screens</Filter>
</ClCompile>
<ClCompile Include="Store.cpp" />
</ItemGroup>
<ItemGroup>
@ -81,6 +84,9 @@
<ClInclude Include="TiltAnalogSettingsScreen.h">
<Filter>Screens</Filter>
</ClInclude>
<ClInclude Include="InstallZipScreen.h">
<Filter>Screens</Filter>
</ClInclude>
<ClInclude Include="Store.h" />
</ItemGroup>
<ItemGroup>
@ -88,4 +94,4 @@
<UniqueIdentifier>{faee5dce-633b-4ba6-b19d-ea70ee3c1c38}</UniqueIdentifier>
</Filter>
</ItemGroup>
</Project>
</Project>

View File

@ -280,6 +280,7 @@ LOCAL_SRC_FILES := \
$(SRC)/UI/TouchControlLayoutScreen.cpp \
$(SRC)/UI/TouchControlVisibilityScreen.cpp \
$(SRC)/UI/CwCheatScreen.cpp \
$(SRC)/UI/InstallZipScreen.cpp \
$(SRC)/UI/NativeApp.cpp
include $(BUILD_SHARED_LIBRARY)

2
lang

@ -1 +1 @@
Subproject commit 2afe06365967319795f799c468ea0b35b7fc1f77
Subproject commit 6eb6c50d59aa6a7fed418126f806a8cbbeb8a64c

2
native

@ -1 +1 @@
Subproject commit 1e03cd84c31e30e26ea9c82c89184938734cf863
Subproject commit 4caec3871c71df3d8d2440cc772171523fbea182