Files
ppsspp/UI/MainScreen.h
T
Claude 363d816789 Game screen: Compress game as CSO
"Compress game" in the game screen's ... menu, for ISO, CSO, CHD and PSN
EBOOT.PBP games. It opens a list of the CSO presets (and Extract to ISO
for anything that's not an ISO already):

- Best: libdeflate level 12, 64K blocks
- PSP Compatible: zlib level 9, 2K blocks, readable by custom firmware

These match maxcso's presets, and the CSOs come out byte-identical to its.
The writer, Core/FileSystems/CSOCompress, reads the input through PPSSPP's
own block devices, so recompressing is a single pass with no temporary
file.

The original is deleted when done, unless "Keep the original file" is
checked (off by default). When the new name is taken, by a kept original
or another file, a number is added to it.

The work runs on a thread using every core, with a progress bar and time
left at the bottom of the game screen. It keeps going when the screen is
left, and the ... menu offers Cancel meanwhile. On the game list the
game's icon is covered by "Compressing...", and clicking it opens the
game screen instead of playing. When done, recents follow the new file
and the game screen and lists refresh.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CCxekYqPnzNr5d8Tp1q7aZ
2026-10-19 16:01:53 +02:00

134 lines
4.0 KiB
C++

// 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 <functional>
#include <string_view>
#include "Common/File/Path.h"
#include "Common/UI/UIScreen.h"
#include "Common/UI/ViewGroup.h"
#include "Common/UI/TabHolder.h"
#include "Common/UI/PopupScreens.h"
#include "UI/BaseScreens.h"
#include "Common/File/PathBrowser.h"
#include "UI/GameBrowser.h"
class RemoteISOBrowseScreen;
struct HighlightedBackground {
Path gamePath;
double startTime;
double endTime;
};
class MainScreen : public UIBaseScreen {
public:
MainScreen();
~MainScreen();
bool isTopLevel() const override { return true; }
const char *tag() const override { return "Main"; }
// Horrible hack to show the demos & homebrew tab after having installed a game from a zip file.
static bool showHomebrewTab;
bool key(const KeyInput &touch) override;
bool WantsTextInput() const override;
protected:
ViewLayoutMode LayoutMode() const override { return ViewLayoutMode::IgnoreBottomInset; }
void CreateViews() override;
void CreateRecentTab();
GameBrowser *CreateBrowserTab(const Path &path, std::string_view title, std::string_view howToTitle, std::string_view howToUri, BrowseFlags browseFlags, int *viewMode, float *scrollPos);
void CreateMainButtons(UI::ViewGroup *parent, bool vertical);
void DrawBackground(UIContext &dc) override;
void update() override;
void sendMessage(UIMessage message, const char *value) override;
void dialogFinished(const Screen *dialog, DialogResult result) override;
void DrawBackgroundFor(UIContext &dc, const Path &gamePath, float alpha);
void OnGameSelected(UI::EventParams &e);
void OnGameSelectedInstant(UI::EventParams &e);
void OnGameHighlight(UI::EventParams &e);
// Event handlers
void OnLoadFile(UI::EventParams &e);
void OnGameSettings(UI::EventParams &e);
void OnCredits(UI::EventParams &e);
void OnPPSSPPOrg(UI::EventParams &e);
void OnForums(UI::EventParams &e);
void OnDownloadUpgrade(UI::EventParams &e);
void OnAllowStorage(UI::EventParams &e);
UI::TabHolder *tabHolder_ = nullptr;
Path restoreFocusGamePath_;
std::vector<GameBrowser *> gameBrowsers_;
std::vector<HighlightedBackground> highlightedBackgrounds_;
Path highlightedGamePath_;
bool backFromStore_ = false;
bool lockBackgroundAudio_ = false;
int packGeneration_ = 0; // GamePacker::Generation() the game lists were made at.
bool lastVertical_ = false;
bool confirmedTemporary_ = false;
bool searchChanged_ = false;
std::string searchFilter_;
friend class RemoteISOBrowseScreen;
private:
void InstantHighlight(const Path &path);
};
class UmdReplaceScreen : public UIBaseDialogScreen {
public:
const char *tag() const override { return "UmdReplace"; }
protected:
void CreateViews() override;
void update() override;
private:
void OnGameSelected(UI::EventParams &e);
void OnGameSettings(UI::EventParams &e);
};
class GridSettingsPopupScreen : public UI::PopupScreen {
public:
GridSettingsPopupScreen(std::string_view label) : PopupScreen(label) {}
void CreatePopupContents(UI::ViewGroup *parent) override;
UI::Event OnRecentChanged;
const char *tag() const override { return "GridSettings"; }
private:
void GridPlusClick(UI::EventParams &e);
void GridMinusClick(UI::EventParams &e);
void OnRecentClearClick(UI::EventParams &e);
const float MAX_GAME_GRID_SCALE = 3.0f;
const float MIN_GAME_GRID_SCALE = 0.8f;
};
void LaunchBuyGold(ScreenManager *screenManager);