Files
ppsspp/UI/MiscViews.h
T
Henrik RydgårdandClaude Opus 5.5 0066599f9a Game browser: Add an XMB-style large list mode
- Fixes #22202

A third view mode next to grid and list: a list with full size icons,
scaled by the grid icon size setting. Like the XMB, the selected (or
hovered) game plays its ICON1.PMF in place of the icon.

The per-tab grid bools become GameBrowserView1-4 ints. The old GridView
keys are still read, to pick the default, but no longer saved.

The PMF decoding moved out of GameScreen's PMFView into a shared
PMFVideoTexture.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-14 10:24:32 +02:00

164 lines
4.6 KiB
C++

#pragma once
#include "Common/Common.h"
#include "Common/UI/View.h"
#include "UI/ViewGroup.h"
#include "UI/GameInfoCache.h"
// Compound view, showing a text with an icon.
class TextWithImage : public UI::LinearLayout {
public:
TextWithImage(ImageID imageID, std::string_view text, UI::LinearLayoutParams *layoutParams = nullptr);
};
// Compound view, showing a copyable string.
class CopyableText : public UI::LinearLayout {
public:
CopyableText(ImageID imageID, std::string_view text, UI::LinearLayoutParams *layoutParams = nullptr);
};
enum class TopBarFlags {
Default = 0,
Portrait = 1,
ContextMenuButton = 2,
NoBackButton = 4,
};
ENUM_CLASS_BITOPS(TopBarFlags);
class TopBar : public UI::LinearLayout {
public:
// The context is needed to get the theme for the background.
TopBar(const UIContext &ctx, TopBarFlags flags, std::string_view title, UI::LayoutParams *layoutParams = nullptr);
UI::View *GetBackButton() const { return backButton_; }
UI::View *GetContextMenuButton() const { return contextMenuButton_; }
UI::Event OnContextMenuClick;
private:
UI::Choice *backButton_ = nullptr;
UI::Choice *contextMenuButton_ = nullptr;
};
class ShinyIcon : public UI::ImageView {
public:
ShinyIcon(ImageID atlasImage, UI::LayoutParams *layoutParams = 0) : UI::ImageView(atlasImage, "", layoutParams) {}
void Draw(UIContext &dc) override;
void SetAnimated(bool anim) { animated_ = anim; }
private:
bool animated_ = true;
};
// Title at the top of a scrolling pane of settings. May later include a back button, but currently doesn't.
// The gamePath_ is used to draw the icon of the game who's settings are currently being edited.
// settingsCategory is used to build the help URL.
class PaneTitleBar : public UI::LinearLayout {
public:
PaneTitleBar(const Path &gamePath, std::string_view title, const std::string_view settingsCategory, UI::LayoutParams *layoutParams = nullptr);
private:
Path gamePath_;
};
class GameImageView : public UI::InertView {
public:
GameImageView(const Path &gamePath, GameInfoFlags image, float scale, UI::LayoutParams *layoutParams = 0)
: InertView(layoutParams), image_(image), gamePath_(gamePath), scale_(scale) {
}
void GetContentDimensions(const UIContext &dc, float &w, float &h) const override;
void Draw(UIContext &dc) override;
std::string DescribeText() const override { return ""; }
private:
GameInfoTex *GetTex(std::shared_ptr<GameInfo> info) const;
Path gamePath_;
GameInfoFlags image_;
float scale_ = 1.0f;
};
class GameInfoBGView : public UI::InertView {
public:
GameInfoBGView(const Path &gamePath, UI::LayoutParams *layoutParams) : InertView(layoutParams), gamePath_(gamePath) {}
void Draw(UIContext &dc) override;
std::string DescribeText() const override { return ""; }
void SetColor(uint32_t c) { color_ = c; }
protected:
Path gamePath_;
uint32_t color_ = 0xFFC0C0C0;
};
class SettingHint : public UI::TextView {
public:
SettingHint(std::string_view text, UI::View *setting);
std::string DescribeText() const override { return setting_ ? setting_->DescribeText() : ""; } // So that descriptions show up in searches under their parent views
void Draw(UIContext &dc) override;
private:
UI::View *setting_;
};
void AddRotationPicker(ScreenManager *screenManager, UI::ViewGroup *parent, bool text);
class SearchBar : public UI::InertView {
public:
SearchBar(UI::LayoutParams *params);
void Draw(UIContext &dc) override;
bool Touch(const TouchInput &input) override;
void SetSearchFilter(std::string_view filter) {
searchFilter_ = filter;
}
void GetContentDimensions(const UIContext &dc, float &w, float &h) const override;
UI::Event OnCancel;
private:
std::string searchFilter_ = "N/A";
};
enum class SearchState {
MATCH,
MISMATCH,
PENDING,
};
struct ViewSearch {
SearchBar *searchBar;
std::string searchFilter;
std::vector<SearchState> searchStates;
bool searchPending;
void ApplySearchFilter(UI::ViewGroup *viewGroup, bool setKeyboardFocus);
bool Key(UI::ViewGroup *viewGroup, const KeyInput &input);
};
struct PMFPlayer;
namespace Draw {
class DrawContext;
class Texture;
}
// Decodes a PMF video (like a game's ICON1.PMF) into a texture, looping.
class PMFVideoTexture {
public:
explicit PMFVideoTexture(std::string data);
~PMFVideoTexture();
bool IsValid() const { return player_ != nullptr; }
int Width() const { return width_; }
int Height() const { return height_; }
// Returns the frame to show at the given time, or nullptr if none is decoded yet.
Draw::Texture *Update(Draw::DrawContext *draw, double timeSeconds);
void DeviceLost();
private:
std::string data_;
std::vector<u8> frame_;
Draw::Texture *curFrame_ = nullptr;
PMFPlayer *player_ = nullptr;
int width_ = 0;
int height_ = 0;
};