mirror of
https://github.com/hrydgard/ppsspp.git
synced 2025-04-02 11:01:50 -04:00
Merge branch 'crc32_patch3' of https://github.com/sum2012/ppsspp into sum2012-crc32_patch3
This commit is contained in:
commit
467a63813a
2 changed files with 33 additions and 0 deletions
|
@ -42,6 +42,7 @@
|
|||
#include "UI/MiscScreens.h"
|
||||
#include "UI/MainScreen.h"
|
||||
#include "UI/BackgroundAudio.h"
|
||||
#include "Core/Reporting.h"
|
||||
|
||||
GameScreen::GameScreen(const Path &gamePath) : UIDialogScreenWithGameBackground(gamePath) {
|
||||
g_BackgroundAudio.SetGame(gamePath);
|
||||
|
@ -50,6 +51,27 @@ GameScreen::GameScreen(const Path &gamePath) : UIDialogScreenWithGameBackground(
|
|||
GameScreen::~GameScreen() {
|
||||
}
|
||||
|
||||
template <typename I> std::string int2hexstr(I w, size_t hex_len = sizeof(I) << 1) {
|
||||
static const char* digits = "0123456789ABCDEF";
|
||||
std::string rc(hex_len, '0');
|
||||
for (size_t i = 0, j = (hex_len - 1) * 4; i < hex_len; ++i, j -= 4)
|
||||
rc[i] = digits[(w >> j) & 0x0f];
|
||||
return rc;
|
||||
}
|
||||
|
||||
void GameScreen::update() {
|
||||
UIScreen::update();
|
||||
|
||||
// Has the user requested a CRC32?
|
||||
if (CRC32string == "...") {
|
||||
// Wait until the CRC32 is ready. It might take time on some devices.
|
||||
if (Reporting::HasCRC(gamePath_)) {
|
||||
uint32_t crcvalue = Reporting::RetrieveCRC(gamePath_);
|
||||
CRC32string = int2hexstr(crcvalue);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void GameScreen::CreateViews() {
|
||||
std::shared_ptr<GameInfo> info = g_gameInfoCache->GetInfo(NULL, gamePath_, GAMEINFO_WANTBG | GAMEINFO_WANTSIZE);
|
||||
|
||||
|
@ -149,6 +171,7 @@ void GameScreen::CreateViews() {
|
|||
btnSetBackground_ = rightColumnItems->Add(new Choice(ga->T("Use UI background")));
|
||||
btnSetBackground_->OnClick.Handle(this, &GameScreen::OnSetBackground);
|
||||
btnSetBackground_->SetVisibility(V_GONE);
|
||||
rightColumnItems->Add(new ChoiceWithValueDisplay(&CRC32string, ga->T("CRC32 CALC"), (const char*)nullptr))->OnClick.Handle(this, &GameScreen::OnDoCRC32);
|
||||
}
|
||||
|
||||
UI::Choice *GameScreen::AddOtherChoice(UI::Choice *choice) {
|
||||
|
@ -278,6 +301,12 @@ UI::EventReturn GameScreen::OnCwCheat(UI::EventParams &e) {
|
|||
return UI::EVENT_DONE;
|
||||
}
|
||||
|
||||
UI::EventReturn GameScreen::OnDoCRC32(UI::EventParams& e) {
|
||||
CRC32string = "...";
|
||||
return UI::EVENT_DONE;
|
||||
}
|
||||
|
||||
|
||||
UI::EventReturn GameScreen::OnSwitchBack(UI::EventParams &e) {
|
||||
TriggerFinish(DR_OK);
|
||||
return UI::EVENT_DONE;
|
||||
|
|
|
@ -34,6 +34,8 @@ public:
|
|||
GameScreen(const Path &gamePath);
|
||||
~GameScreen();
|
||||
|
||||
void update() override;
|
||||
|
||||
void render() override;
|
||||
|
||||
std::string tag() const override { return "game"; }
|
||||
|
@ -61,6 +63,7 @@ private:
|
|||
UI::EventReturn OnDeleteConfig(UI::EventParams &e);
|
||||
UI::EventReturn OnCwCheat(UI::EventParams &e);
|
||||
UI::EventReturn OnSetBackground(UI::EventParams &e);
|
||||
UI::EventReturn OnDoCRC32(UI::EventParams& e);
|
||||
|
||||
// As we load metadata in the background, we need to be able to update these after the fact.
|
||||
UI::TextView *tvTitle_;
|
||||
|
@ -77,4 +80,5 @@ private:
|
|||
UI::Choice *btnSetBackground_;
|
||||
std::vector<UI::Choice *> otherChoices_;
|
||||
std::vector<Path> saveDirs;
|
||||
std::string CRC32string;
|
||||
};
|
||||
|
|
Loading…
Add table
Reference in a new issue