mirror of
https://github.com/hrydgard/ppsspp.git
synced 2025-04-02 11:01:50 -04:00
Move AsyncImageFileView to Common, which required some more shuffling around of stuff.
This commit is contained in:
parent
e654f6937a
commit
ec6d330ae4
27 changed files with 274 additions and 219 deletions
|
@ -692,6 +692,8 @@ add_library(Common STATIC
|
|||
Common/Render/TextureAtlas.h
|
||||
Common/Render/DrawBuffer.cpp
|
||||
Common/Render/DrawBuffer.h
|
||||
Common/Render/ManagedTexture.cpp
|
||||
Common/Render/ManagedTexture.h
|
||||
Common/Render/Text/draw_text.cpp
|
||||
Common/Render/Text/draw_text.h
|
||||
Common/Render/Text/draw_text_android.cpp
|
||||
|
@ -710,6 +712,8 @@ add_library(Common STATIC
|
|||
Common/Thread/ThreadUtil.h
|
||||
Common/Thread/ThreadManager.cpp
|
||||
Common/Thread/ThreadManager.h
|
||||
Common/UI/AsyncImageFileView.cpp
|
||||
Common/UI/AsyncImageFileView.h
|
||||
Common/UI/Root.cpp
|
||||
Common/UI/Root.h
|
||||
Common/UI/Screen.cpp
|
||||
|
@ -1293,8 +1297,6 @@ list(APPEND NativeAppSource
|
|||
UI/MemStickScreen.cpp
|
||||
UI/ProfilerDraw.h
|
||||
UI/ProfilerDraw.cpp
|
||||
UI/TextureUtil.h
|
||||
UI/TextureUtil.cpp
|
||||
UI/ComboKeyMappingScreen.h
|
||||
UI/ComboKeyMappingScreen.cpp
|
||||
UI/Theme.h
|
||||
|
|
|
@ -477,6 +477,7 @@
|
|||
<ClInclude Include="Net\WebsocketServer.h" />
|
||||
<ClInclude Include="Profiler\Profiler.h" />
|
||||
<ClInclude Include="Render\DrawBuffer.h" />
|
||||
<ClInclude Include="Render\ManagedTexture.h" />
|
||||
<ClInclude Include="Render\TextureAtlas.h" />
|
||||
<ClInclude Include="Render\Text\draw_text.h" />
|
||||
<ClInclude Include="Render\Text\draw_text_android.h" />
|
||||
|
@ -549,6 +550,7 @@
|
|||
<ClInclude Include="Thread\ThreadUtil.h" />
|
||||
<ClInclude Include="Thunk.h" />
|
||||
<ClInclude Include="TimeUtil.h" />
|
||||
<ClInclude Include="UI\AsyncImageFileView.h" />
|
||||
<ClInclude Include="UI\Context.h" />
|
||||
<ClInclude Include="UI\Root.h" />
|
||||
<ClInclude Include="UI\Screen.h" />
|
||||
|
@ -905,6 +907,7 @@
|
|||
<ClCompile Include="Net\WebsocketServer.cpp" />
|
||||
<ClCompile Include="Profiler\Profiler.cpp" />
|
||||
<ClCompile Include="Render\DrawBuffer.cpp" />
|
||||
<ClCompile Include="Render\ManagedTexture.cpp" />
|
||||
<ClCompile Include="Render\TextureAtlas.cpp" />
|
||||
<ClCompile Include="Render\Text\draw_text.cpp" />
|
||||
<ClCompile Include="Render\Text\draw_text_android.cpp" />
|
||||
|
@ -988,6 +991,7 @@
|
|||
<ClCompile Include="Thread\ThreadUtil.cpp" />
|
||||
<ClCompile Include="Thunk.cpp" />
|
||||
<ClCompile Include="TimeUtil.cpp" />
|
||||
<ClCompile Include="UI\AsyncImageFileView.cpp" />
|
||||
<ClCompile Include="UI\Context.cpp" />
|
||||
<ClCompile Include="UI\Root.cpp" />
|
||||
<ClCompile Include="UI\Screen.cpp" />
|
||||
|
|
|
@ -446,6 +446,12 @@
|
|||
<ClInclude Include="VR\OpenXRLoader.h">
|
||||
<Filter>VR</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="UI\AsyncImageFileView.h">
|
||||
<Filter>UI</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Render\ManagedTexture.h">
|
||||
<Filter>Render</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="ABI.cpp" />
|
||||
|
@ -845,6 +851,12 @@
|
|||
<ClCompile Include="VR\OpenXRLoader.cpp">
|
||||
<Filter>VR</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="UI\AsyncImageFileView.cpp">
|
||||
<Filter>UI</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Render\ManagedTexture.cpp">
|
||||
<Filter>Render</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Filter Include="Crypto">
|
||||
|
|
|
@ -14,8 +14,7 @@
|
|||
#include "Common/File/VFS/VFS.h"
|
||||
#include "Common/Log.h"
|
||||
#include "Common/TimeUtil.h"
|
||||
#include "UI/TextureUtil.h"
|
||||
#include "UI/GameInfoCache.h"
|
||||
#include "Common/Render/ManagedTexture.h"
|
||||
|
||||
static Draw::DataFormat ZimToT3DFormat(int zim) {
|
||||
switch (zim) {
|
||||
|
@ -217,38 +216,3 @@ std::unique_ptr<ManagedTexture> CreateTextureFromFileData(Draw::DrawContext *dra
|
|||
return std::unique_ptr<ManagedTexture>();
|
||||
}
|
||||
}
|
||||
|
||||
void GameIconView::GetContentDimensions(const UIContext &dc, float &w, float &h) const {
|
||||
w = textureWidth_;
|
||||
h = textureHeight_;
|
||||
}
|
||||
|
||||
void GameIconView::Draw(UIContext &dc) {
|
||||
using namespace UI;
|
||||
std::shared_ptr<GameInfo> info = g_gameInfoCache->GetInfo(NULL, gamePath_, GAMEINFO_WANTBG | GAMEINFO_WANTSIZE);
|
||||
|
||||
if (!info->icon.texture) {
|
||||
return;
|
||||
}
|
||||
|
||||
textureWidth_ = info->icon.texture->Width() * scale_;
|
||||
textureHeight_ = info->icon.texture->Height() * scale_;
|
||||
|
||||
// Fade icon with the backgrounds.
|
||||
double loadTime = info->icon.timeLoaded;
|
||||
auto pic = info->GetBGPic();
|
||||
if (pic) {
|
||||
loadTime = std::max(loadTime, pic->timeLoaded);
|
||||
}
|
||||
uint32_t color = whiteAlpha(ease((time_now_d() - loadTime) * 3));
|
||||
|
||||
// Adjust size so we don't stretch the image vertically or horizontally.
|
||||
// Make sure it's not wider than 144 (like Doom Legacy homebrew), ugly in the grid mode.
|
||||
float nw = std::min(bounds_.h * textureWidth_ / textureHeight_, (float)bounds_.w);
|
||||
|
||||
dc.Flush();
|
||||
dc.GetDrawContext()->BindTexture(0, info->icon.texture->GetTexture());
|
||||
dc.Draw()->Rect(bounds_.x, bounds_.y, nw, bounds_.h, color);
|
||||
dc.Flush();
|
||||
dc.RebindTexture();
|
||||
}
|
|
@ -43,18 +43,3 @@ private:
|
|||
std::unique_ptr<ManagedTexture> CreateTextureFromFile(Draw::DrawContext *draw, const char *filename, ImageFileType fileType, bool generateMips);
|
||||
std::unique_ptr<ManagedTexture> CreateTextureFromFileData(Draw::DrawContext *draw, const uint8_t *data, int size, ImageFileType fileType, bool generateMips, const char *name);
|
||||
|
||||
class GameIconView : public UI::InertView {
|
||||
public:
|
||||
GameIconView(const Path &gamePath, float scale, UI::LayoutParams *layoutParams = 0)
|
||||
: InertView(layoutParams), 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:
|
||||
Path gamePath_;
|
||||
float scale_ = 1.0f;
|
||||
int textureWidth_ = 0;
|
||||
int textureHeight_ = 0;
|
||||
};
|
113
Common/UI/AsyncImageFileView.cpp
Normal file
113
Common/UI/AsyncImageFileView.cpp
Normal file
|
@ -0,0 +1,113 @@
|
|||
#include "Common/UI/View.h"
|
||||
#include "Common/UI/AsyncImageFileView.h"
|
||||
#include "Common/UI/Context.h"
|
||||
#include "Common/Render/DrawBuffer.h"
|
||||
|
||||
AsyncImageFileView::AsyncImageFileView(const Path &filename, UI::ImageSizeMode sizeMode, UI::LayoutParams *layoutParams)
|
||||
: UI::Clickable(layoutParams), canFocus_(true), filename_(filename), color_(0xFFFFFFFF), sizeMode_(sizeMode), textureFailed_(false), fixedSizeW_(0.0f), fixedSizeH_(0.0f) {}
|
||||
|
||||
AsyncImageFileView::~AsyncImageFileView() {}
|
||||
|
||||
static float DesiredSize(float sz, float contentSize, UI::MeasureSpec spec) {
|
||||
float measured;
|
||||
UI::MeasureBySpec(sz, contentSize, spec, &measured);
|
||||
return measured;
|
||||
}
|
||||
|
||||
void AsyncImageFileView::GetContentDimensionsBySpec(const UIContext &dc, UI::MeasureSpec horiz, UI::MeasureSpec vert, float &w, float &h) const {
|
||||
if (texture_ && texture_->GetTexture()) {
|
||||
float texw = (float)texture_->Width();
|
||||
float texh = (float)texture_->Height();
|
||||
float desiredW = DesiredSize(layoutParams_->width, w, horiz);
|
||||
float desiredH = DesiredSize(layoutParams_->height, h, vert);
|
||||
switch (sizeMode_) {
|
||||
case UI::IS_FIXED:
|
||||
w = fixedSizeW_;
|
||||
h = fixedSizeH_;
|
||||
break;
|
||||
case UI::IS_KEEP_ASPECT:
|
||||
w = texw;
|
||||
h = texh;
|
||||
if (desiredW != w || desiredH != h) {
|
||||
float aspect = w / h;
|
||||
// We need the other dimension based on the desired scale to find the best aspect.
|
||||
float desiredWOther = DesiredSize(layoutParams_->height, h * (desiredW / w), vert);
|
||||
float desiredHOther = DesiredSize(layoutParams_->width, w * (desiredH / h), horiz);
|
||||
|
||||
float diffW = fabsf(aspect - desiredW / desiredWOther);
|
||||
float diffH = fabsf(aspect - desiredH / desiredHOther);
|
||||
if (diffW < diffH) {
|
||||
w = desiredW;
|
||||
h = desiredWOther;
|
||||
} else {
|
||||
w = desiredHOther;
|
||||
h = desiredH;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case UI::IS_DEFAULT:
|
||||
default:
|
||||
w = texw;
|
||||
h = texh;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
w = 16;
|
||||
h = 16;
|
||||
}
|
||||
}
|
||||
|
||||
void AsyncImageFileView::SetFilename(const Path &filename) {
|
||||
if (filename_ != filename) {
|
||||
textureFailed_ = false;
|
||||
filename_ = filename;
|
||||
texture_.reset(nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
void AsyncImageFileView::DeviceLost() {
|
||||
if (texture_.get())
|
||||
texture_->DeviceLost();
|
||||
}
|
||||
|
||||
void AsyncImageFileView::DeviceRestored(Draw::DrawContext *draw) {
|
||||
if (texture_.get())
|
||||
texture_->DeviceRestored(draw);
|
||||
}
|
||||
|
||||
void AsyncImageFileView::Draw(UIContext &dc) {
|
||||
using namespace Draw;
|
||||
if (!texture_ && !textureFailed_ && !filename_.empty()) {
|
||||
texture_ = CreateTextureFromFile(dc.GetDrawContext(), filename_.c_str(), DETECT, true);
|
||||
if (!texture_.get())
|
||||
textureFailed_ = true;
|
||||
}
|
||||
|
||||
if (HasFocus()) {
|
||||
dc.FillRect(dc.theme->itemFocusedStyle.background, bounds_.Expand(3));
|
||||
}
|
||||
|
||||
// TODO: involve sizemode
|
||||
if (texture_ && texture_->GetTexture()) {
|
||||
dc.Flush();
|
||||
dc.GetDrawContext()->BindTexture(0, texture_->GetTexture());
|
||||
dc.Draw()->Rect(bounds_.x, bounds_.y, bounds_.w, bounds_.h, color_);
|
||||
dc.Flush();
|
||||
dc.RebindTexture();
|
||||
if (!text_.empty()) {
|
||||
dc.DrawText(text_.c_str(), bounds_.centerX() + 1, bounds_.centerY() + 1, 0x80000000, ALIGN_CENTER | FLAG_DYNAMIC_ASCII);
|
||||
dc.DrawText(text_.c_str(), bounds_.centerX(), bounds_.centerY(), 0xFFFFFFFF, ALIGN_CENTER | FLAG_DYNAMIC_ASCII);
|
||||
}
|
||||
} else {
|
||||
if (!filename_.empty()) {
|
||||
// draw a black rectangle to represent the missing screenshot.
|
||||
dc.FillRect(UI::Drawable(0xFF000000), GetBounds());
|
||||
} else {
|
||||
// draw a dark gray rectangle to represent no save state.
|
||||
dc.FillRect(UI::Drawable(0x50202020), GetBounds());
|
||||
}
|
||||
if (!text_.empty()) {
|
||||
dc.DrawText(text_.c_str(), bounds_.centerX(), bounds_.centerY(), 0xFFFFFFFF, ALIGN_CENTER | FLAG_DYNAMIC_ASCII);
|
||||
}
|
||||
}
|
||||
}
|
44
Common/UI/AsyncImageFileView.h
Normal file
44
Common/UI/AsyncImageFileView.h
Normal file
|
@ -0,0 +1,44 @@
|
|||
#pragma once
|
||||
|
||||
#include "Common/UI/View.h"
|
||||
#include "Common/Render/ManagedTexture.h"
|
||||
#include "Common/File/Path.h"
|
||||
|
||||
class UIContext;
|
||||
|
||||
// AsyncImageFileView loads a texture from a file, and reloads it as necessary.
|
||||
// TODO: Actually make async, doh.
|
||||
class AsyncImageFileView : public UI::Clickable {
|
||||
public:
|
||||
AsyncImageFileView(const Path &filename, UI::ImageSizeMode sizeMode, UI::LayoutParams *layoutParams = 0);
|
||||
~AsyncImageFileView();
|
||||
|
||||
void GetContentDimensionsBySpec(const UIContext &dc, UI::MeasureSpec horiz, UI::MeasureSpec vert, float &w, float &h) const override;
|
||||
void Draw(UIContext &dc) override;
|
||||
std::string DescribeText() const override { return text_; }
|
||||
|
||||
void DeviceLost() override;
|
||||
void DeviceRestored(Draw::DrawContext *draw) override;
|
||||
|
||||
void SetFilename(const Path &filename);
|
||||
void SetColor(uint32_t color) { color_ = color; }
|
||||
void SetOverlayText(std::string text) { text_ = text; }
|
||||
void SetFixedSize(float fixW, float fixH) { fixedSizeW_ = fixW; fixedSizeH_ = fixH; }
|
||||
void SetCanBeFocused(bool can) { canFocus_ = can; }
|
||||
|
||||
bool CanBeFocused() const override { return canFocus_; }
|
||||
|
||||
const Path &GetFilename() const { return filename_; }
|
||||
|
||||
private:
|
||||
bool canFocus_;
|
||||
Path filename_;
|
||||
std::string text_;
|
||||
uint32_t color_;
|
||||
UI::ImageSizeMode sizeMode_;
|
||||
|
||||
std::unique_ptr<ManagedTexture> texture_;
|
||||
bool textureFailed_;
|
||||
float fixedSizeW_;
|
||||
float fixedSizeH_;
|
||||
};
|
|
@ -10,9 +10,9 @@
|
|||
#include "Common/UI/Context.h"
|
||||
#include "Common/Render/DrawBuffer.h"
|
||||
#include "Common/Render/Text/draw_text.h"
|
||||
#include "Common/Render/ManagedTexture.h"
|
||||
#include "Common/Log.h"
|
||||
#include "Common/LogReporting.h"
|
||||
#include "UI/TextureUtil.h"
|
||||
|
||||
UIContext::UIContext() {
|
||||
fontStyle_ = new UI::FontStyle();
|
||||
|
|
|
@ -31,6 +31,7 @@ using namespace std::placeholders;
|
|||
#include "Common/UI/Context.h"
|
||||
#include "Common/UI/Tween.h"
|
||||
#include "Common/UI/View.h"
|
||||
#include "Common/UI/AsyncImageFileView.h"
|
||||
#include "Common/VR/PPSSPPVR.h"
|
||||
|
||||
#include "Common/Data/Text/I18n.h"
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
#include "Common/File/Path.h"
|
||||
#include "Common/StringUtils.h"
|
||||
#include "Common/TimeUtil.h"
|
||||
#include "Common/Render/ManagedTexture.h"
|
||||
#include "Core/FileSystems/ISOFileSystem.h"
|
||||
#include "Core/FileSystems/DirectoryFileSystem.h"
|
||||
#include "Core/FileSystems/VirtualDiscFileSystem.h"
|
||||
|
@ -39,7 +40,6 @@
|
|||
#include "Core/Util/GameManager.h"
|
||||
#include "Core/Config.h"
|
||||
#include "UI/GameInfoCache.h"
|
||||
#include "UI/TextureUtil.h"
|
||||
|
||||
GameInfoCache *g_gameInfoCache;
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
#include "Common/Thread/Event.h"
|
||||
#include "Core/ELF/ParamSFO.h"
|
||||
#include "Common/File/Path.h"
|
||||
#include "UI/TextureUtil.h"
|
||||
#include "Common/Render/ManagedTexture.h"
|
||||
|
||||
namespace Draw {
|
||||
class DrawContext;
|
||||
|
|
|
@ -43,6 +43,7 @@
|
|||
#include "UI/MiscScreens.h"
|
||||
#include "UI/MainScreen.h"
|
||||
#include "UI/BackgroundAudio.h"
|
||||
#include "UI/SavedataScreen.h"
|
||||
#include "Core/Reporting.h"
|
||||
|
||||
GameScreen::GameScreen(const Path &gamePath) : UIDialogScreenWithGameBackground(gamePath) {
|
||||
|
|
|
@ -114,7 +114,6 @@
|
|||
#include "UI/OnScreenDisplay.h"
|
||||
#include "UI/RemoteISOScreen.h"
|
||||
#include "UI/TiltEventProcessor.h"
|
||||
#include "UI/TextureUtil.h"
|
||||
#include "UI/Theme.h"
|
||||
|
||||
#if !defined(MOBILE_DEVICE) && defined(USING_QT_UI)
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
#include "Common/StringUtils.h"
|
||||
#include "Common/System/System.h"
|
||||
#include "Common/VR/PPSSPPVR.h"
|
||||
#include "Common/UI/AsyncImageFileView.h"
|
||||
|
||||
#include "Core/Reporting.h"
|
||||
#include "Core/SaveState.h"
|
||||
|
@ -49,115 +50,6 @@
|
|||
#include "UI/OnScreenDisplay.h"
|
||||
#include "UI/GameInfoCache.h"
|
||||
|
||||
AsyncImageFileView::AsyncImageFileView(const Path &filename, UI::ImageSizeMode sizeMode, UI::LayoutParams *layoutParams)
|
||||
: UI::Clickable(layoutParams), canFocus_(true), filename_(filename), color_(0xFFFFFFFF), sizeMode_(sizeMode), textureFailed_(false), fixedSizeW_(0.0f), fixedSizeH_(0.0f) {}
|
||||
|
||||
AsyncImageFileView::~AsyncImageFileView() {}
|
||||
|
||||
static float DesiredSize(float sz, float contentSize, UI::MeasureSpec spec) {
|
||||
float measured;
|
||||
UI::MeasureBySpec(sz, contentSize, spec, &measured);
|
||||
return measured;
|
||||
}
|
||||
|
||||
void AsyncImageFileView::GetContentDimensionsBySpec(const UIContext &dc, UI::MeasureSpec horiz, UI::MeasureSpec vert, float &w, float &h) const {
|
||||
if (texture_ && texture_->GetTexture()) {
|
||||
float texw = (float)texture_->Width();
|
||||
float texh = (float)texture_->Height();
|
||||
float desiredW = DesiredSize(layoutParams_->width, w, horiz);
|
||||
float desiredH = DesiredSize(layoutParams_->height, h, vert);
|
||||
switch (sizeMode_) {
|
||||
case UI::IS_FIXED:
|
||||
w = fixedSizeW_;
|
||||
h = fixedSizeH_;
|
||||
break;
|
||||
case UI::IS_KEEP_ASPECT:
|
||||
w = texw;
|
||||
h = texh;
|
||||
if (desiredW != w || desiredH != h) {
|
||||
float aspect = w / h;
|
||||
// We need the other dimension based on the desired scale to find the best aspect.
|
||||
float desiredWOther = DesiredSize(layoutParams_->height, h * (desiredW / w), vert);
|
||||
float desiredHOther = DesiredSize(layoutParams_->width, w * (desiredH / h), horiz);
|
||||
|
||||
float diffW = fabsf(aspect - desiredW / desiredWOther);
|
||||
float diffH = fabsf(aspect - desiredH / desiredHOther);
|
||||
if (diffW < diffH) {
|
||||
w = desiredW;
|
||||
h = desiredWOther;
|
||||
} else {
|
||||
w = desiredHOther;
|
||||
h = desiredH;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case UI::IS_DEFAULT:
|
||||
default:
|
||||
w = texw;
|
||||
h = texh;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
w = 16;
|
||||
h = 16;
|
||||
}
|
||||
}
|
||||
|
||||
void AsyncImageFileView::SetFilename(const Path &filename) {
|
||||
if (filename_ != filename) {
|
||||
textureFailed_ = false;
|
||||
filename_ = filename;
|
||||
texture_.reset(nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
void AsyncImageFileView::DeviceLost() {
|
||||
if (texture_.get())
|
||||
texture_->DeviceLost();
|
||||
}
|
||||
|
||||
void AsyncImageFileView::DeviceRestored(Draw::DrawContext *draw) {
|
||||
if (texture_.get())
|
||||
texture_->DeviceRestored(draw);
|
||||
}
|
||||
|
||||
void AsyncImageFileView::Draw(UIContext &dc) {
|
||||
using namespace Draw;
|
||||
if (!texture_ && !textureFailed_ && !filename_.empty()) {
|
||||
texture_ = CreateTextureFromFile(dc.GetDrawContext(), filename_.c_str(), DETECT, true);
|
||||
if (!texture_.get())
|
||||
textureFailed_ = true;
|
||||
}
|
||||
|
||||
if (HasFocus()) {
|
||||
dc.FillRect(dc.theme->itemFocusedStyle.background, bounds_.Expand(3));
|
||||
}
|
||||
|
||||
// TODO: involve sizemode
|
||||
if (texture_ && texture_->GetTexture()) {
|
||||
dc.Flush();
|
||||
dc.GetDrawContext()->BindTexture(0, texture_->GetTexture());
|
||||
dc.Draw()->Rect(bounds_.x, bounds_.y, bounds_.w, bounds_.h, color_);
|
||||
dc.Flush();
|
||||
dc.RebindTexture();
|
||||
if (!text_.empty()) {
|
||||
dc.DrawText(text_.c_str(), bounds_.centerX()+1, bounds_.centerY()+1, 0x80000000, ALIGN_CENTER | FLAG_DYNAMIC_ASCII);
|
||||
dc.DrawText(text_.c_str(), bounds_.centerX(), bounds_.centerY(), 0xFFFFFFFF, ALIGN_CENTER | FLAG_DYNAMIC_ASCII);
|
||||
}
|
||||
} else {
|
||||
if (!filename_.empty()) {
|
||||
// draw a black rectangle to represent the missing screenshot.
|
||||
dc.FillRect(UI::Drawable(0xFF000000), GetBounds());
|
||||
} else {
|
||||
// draw a dark gray rectangle to represent no save state.
|
||||
dc.FillRect(UI::Drawable(0x50202020), GetBounds());
|
||||
}
|
||||
if (!text_.empty()) {
|
||||
dc.DrawText(text_.c_str(), bounds_.centerX(), bounds_.centerY(), 0xFFFFFFFF, ALIGN_CENTER | FLAG_DYNAMIC_ASCII);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void AfterSaveStateAction(SaveState::Status status, const std::string &message, void *) {
|
||||
if (!message.empty() && (!g_Config.bDumpFrames || !g_Config.bDumpVideoOutput)) {
|
||||
osm.Show(message, status == SaveState::Status::SUCCESS ? 2.0 : 5.0);
|
||||
|
|
|
@ -24,7 +24,11 @@
|
|||
#include "Common/UI/UIScreen.h"
|
||||
#include "Common/UI/ViewGroup.h"
|
||||
#include "UI/MiscScreens.h"
|
||||
#include "UI/TextureUtil.h"
|
||||
|
||||
enum class PauseScreenMode {
|
||||
MAIN,
|
||||
DISPLAY_SETTINGS,
|
||||
};
|
||||
|
||||
class GamePauseScreen : public UIDialogScreenWithGameBackground {
|
||||
public:
|
||||
|
@ -64,41 +68,5 @@ private:
|
|||
// hack
|
||||
bool finishNextFrame_ = false;
|
||||
Path gamePath_;
|
||||
};
|
||||
|
||||
// AsyncImageFileView loads a texture from a file, and reloads it as necessary.
|
||||
// TODO: Actually make async, doh.
|
||||
class AsyncImageFileView : public UI::Clickable {
|
||||
public:
|
||||
AsyncImageFileView(const Path &filename, UI::ImageSizeMode sizeMode, UI::LayoutParams *layoutParams = 0);
|
||||
~AsyncImageFileView();
|
||||
|
||||
void GetContentDimensionsBySpec(const UIContext &dc, UI::MeasureSpec horiz, UI::MeasureSpec vert, float &w, float &h) const override;
|
||||
void Draw(UIContext &dc) override;
|
||||
std::string DescribeText() const override { return text_; }
|
||||
|
||||
void DeviceLost() override;
|
||||
void DeviceRestored(Draw::DrawContext *draw) override;
|
||||
|
||||
void SetFilename(const Path &filename);
|
||||
void SetColor(uint32_t color) { color_ = color; }
|
||||
void SetOverlayText(std::string text) { text_ = text; }
|
||||
void SetFixedSize(float fixW, float fixH) { fixedSizeW_ = fixW; fixedSizeH_ = fixH; }
|
||||
void SetCanBeFocused(bool can) { canFocus_ = can; }
|
||||
|
||||
bool CanBeFocused() const override { return canFocus_; }
|
||||
|
||||
const Path &GetFilename() const { return filename_; }
|
||||
|
||||
private:
|
||||
bool canFocus_;
|
||||
Path filename_;
|
||||
std::string text_;
|
||||
uint32_t color_;
|
||||
UI::ImageSizeMode sizeMode_;
|
||||
|
||||
std::unique_ptr<ManagedTexture> texture_;
|
||||
bool textureFailed_;
|
||||
float fixedSizeW_;
|
||||
float fixedSizeH_;
|
||||
PauseScreenMode mode_ = PauseScreenMode::MAIN;
|
||||
};
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
// TODO: For text align flags, probably shouldn't be in gfx_es2/...
|
||||
#include "Common/Render/DrawBuffer.h"
|
||||
#include "Common/GPU/thin3d.h"
|
||||
#include "Common/UI/AsyncImageFileView.h"
|
||||
#include "Common/UI/Context.h"
|
||||
#include "UI/PauseScreen.h"
|
||||
#include "UI/ReportScreen.h"
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
#include "Common/UI/Context.h"
|
||||
#include "Common/UI/View.h"
|
||||
#include "Common/UI/ViewGroup.h"
|
||||
#include "Common/UI/AsyncImageFileView.h"
|
||||
#include "UI/SavedataScreen.h"
|
||||
#include "UI/MainScreen.h"
|
||||
#include "UI/GameInfoCache.h"
|
||||
|
@ -707,3 +708,38 @@ void SavedataScreen::sendMessage(const char *message, const char *value) {
|
|||
stateBrowser_->SetSearchFilter(searchFilter_);
|
||||
}
|
||||
}
|
||||
|
||||
void GameIconView::GetContentDimensions(const UIContext &dc, float &w, float &h) const {
|
||||
w = textureWidth_;
|
||||
h = textureHeight_;
|
||||
}
|
||||
|
||||
void GameIconView::Draw(UIContext &dc) {
|
||||
using namespace UI;
|
||||
std::shared_ptr<GameInfo> info = g_gameInfoCache->GetInfo(NULL, gamePath_, GAMEINFO_WANTBG | GAMEINFO_WANTSIZE);
|
||||
|
||||
if (!info->icon.texture) {
|
||||
return;
|
||||
}
|
||||
|
||||
textureWidth_ = info->icon.texture->Width() * scale_;
|
||||
textureHeight_ = info->icon.texture->Height() * scale_;
|
||||
|
||||
// Fade icon with the backgrounds.
|
||||
double loadTime = info->icon.timeLoaded;
|
||||
auto pic = info->GetBGPic();
|
||||
if (pic) {
|
||||
loadTime = std::max(loadTime, pic->timeLoaded);
|
||||
}
|
||||
uint32_t color = whiteAlpha(ease((time_now_d() - loadTime) * 3));
|
||||
|
||||
// Adjust size so we don't stretch the image vertically or horizontally.
|
||||
// Make sure it's not wider than 144 (like Doom Legacy homebrew), ugly in the grid mode.
|
||||
float nw = std::min(bounds_.h * textureWidth_ / textureHeight_, (float)bounds_.w);
|
||||
|
||||
dc.Flush();
|
||||
dc.GetDrawContext()->BindTexture(0, info->icon.texture->GetTexture());
|
||||
dc.Draw()->Rect(bounds_.x, bounds_.y, nw, bounds_.h, color);
|
||||
dc.Flush();
|
||||
dc.RebindTexture();
|
||||
}
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
#include "Common/UI/ViewGroup.h"
|
||||
|
||||
#include "UI/MiscScreens.h"
|
||||
#include "UI/GameInfoCache.h"
|
||||
|
||||
enum class SavedataSortOption {
|
||||
FILENAME,
|
||||
|
@ -88,3 +89,19 @@ protected:
|
|||
SavedataBrowser *stateBrowser_;
|
||||
std::string searchFilter_;
|
||||
};
|
||||
|
||||
class GameIconView : public UI::InertView {
|
||||
public:
|
||||
GameIconView(const Path &gamePath, float scale, UI::LayoutParams *layoutParams = 0)
|
||||
: InertView(layoutParams), 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:
|
||||
Path gamePath_;
|
||||
float scale_ = 1.0f;
|
||||
int textureWidth_ = 0;
|
||||
int textureHeight_ = 0;
|
||||
};
|
||||
|
|
|
@ -26,12 +26,12 @@
|
|||
#include "Common/Data/Text/I18n.h"
|
||||
#include "Common/Data/Format/JSONReader.h"
|
||||
#include "Common/StringUtils.h"
|
||||
#include "Common/Render/ManagedTexture.h"
|
||||
#include "Core/Config.h"
|
||||
#include "Core/System.h"
|
||||
#include "Core/Util/GameManager.h"
|
||||
#include "UI/EmuScreen.h"
|
||||
#include "UI/Store.h"
|
||||
#include "UI/TextureUtil.h"
|
||||
|
||||
const std::string storeBaseUrl = "http://store.ppsspp.org/";
|
||||
|
||||
|
|
|
@ -61,7 +61,6 @@
|
|||
<ClCompile Include="ReportScreen.cpp" />
|
||||
<ClCompile Include="SavedataScreen.cpp" />
|
||||
<ClCompile Include="Store.cpp" />
|
||||
<ClCompile Include="TextureUtil.cpp" />
|
||||
<ClCompile Include="TiltAnalogSettingsScreen.cpp" />
|
||||
<ClCompile Include="TiltEventProcessor.cpp" />
|
||||
<ClCompile Include="TouchControlLayoutScreen.cpp" />
|
||||
|
@ -96,7 +95,6 @@
|
|||
<ClInclude Include="ReportScreen.h" />
|
||||
<ClInclude Include="SavedataScreen.h" />
|
||||
<ClInclude Include="Store.h" />
|
||||
<ClInclude Include="TextureUtil.h" />
|
||||
<ClInclude Include="TiltAnalogSettingsScreen.h" />
|
||||
<ClInclude Include="TiltEventProcessor.h" />
|
||||
<ClInclude Include="TouchControlLayoutScreen.h" />
|
||||
|
|
|
@ -67,7 +67,6 @@
|
|||
<ClCompile Include="RemoteISOScreen.cpp">
|
||||
<Filter>Screens</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="TextureUtil.cpp" />
|
||||
<ClCompile Include="DiscordIntegration.cpp" />
|
||||
<ClCompile Include="GPUDriverTestScreen.cpp">
|
||||
<Filter>Screens</Filter>
|
||||
|
@ -81,6 +80,7 @@
|
|||
<ClCompile Include="MemStickScreen.cpp">
|
||||
<Filter>Screens</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Theme.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="GameInfoCache.h" />
|
||||
|
@ -149,7 +149,6 @@
|
|||
<ClInclude Include="RemoteISOScreen.h">
|
||||
<Filter>Screens</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="TextureUtil.h" />
|
||||
<ClInclude Include="DiscordIntegration.h" />
|
||||
<ClInclude Include="GPUDriverTestScreen.h">
|
||||
<Filter>Screens</Filter>
|
||||
|
@ -163,6 +162,7 @@
|
|||
<ClInclude Include="MemStickScreen.h">
|
||||
<Filter>Screens</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Theme.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Filter Include="Screens">
|
||||
|
|
|
@ -448,6 +448,7 @@
|
|||
<ClInclude Include="..\..\Common\Net\WebsocketServer.h" />
|
||||
<ClInclude Include="..\..\Common\Profiler\Profiler.h" />
|
||||
<ClInclude Include="..\..\Common\Render\DrawBuffer.h" />
|
||||
<ClInclude Include="..\..\Common\Render\ManagedTexture.h" />
|
||||
<ClInclude Include="..\..\Common\Render\TextureAtlas.h" />
|
||||
<ClInclude Include="..\..\Common\Render\Text\draw_text.h" />
|
||||
<ClInclude Include="..\..\Common\Render\Text\draw_text_android.h" />
|
||||
|
@ -495,6 +496,7 @@
|
|||
<ClInclude Include="..\..\Common\Thread\ParallelLoop.h" />
|
||||
<ClInclude Include="..\..\Common\Thunk.h" />
|
||||
<ClInclude Include="..\..\Common\TimeUtil.h" />
|
||||
<ClInclude Include="..\..\Common\UI\AsyncImageFileView.h" />
|
||||
<ClInclude Include="..\..\Common\UI\Context.h" />
|
||||
<ClInclude Include="..\..\Common\UI\Root.h" />
|
||||
<ClInclude Include="..\..\Common\UI\Screen.h" />
|
||||
|
@ -578,6 +580,7 @@
|
|||
<ClCompile Include="..\..\Common\Net\WebsocketServer.cpp" />
|
||||
<ClCompile Include="..\..\Common\Profiler\Profiler.cpp" />
|
||||
<ClCompile Include="..\..\Common\Render\DrawBuffer.cpp" />
|
||||
<ClCompile Include="..\..\Common\Render\ManagedTexture.cpp" />
|
||||
<ClCompile Include="..\..\Common\Render\TextureAtlas.cpp" />
|
||||
<ClCompile Include="..\..\Common\Render\Text\draw_text.cpp" />
|
||||
<ClCompile Include="..\..\Common\Render\Text\draw_text_android.cpp" />
|
||||
|
@ -613,6 +616,7 @@
|
|||
<ClCompile Include="..\..\Common\Thread\ParallelLoop.cpp" />
|
||||
<ClCompile Include="..\..\Common\Thunk.cpp" />
|
||||
<ClCompile Include="..\..\Common\TimeUtil.cpp" />
|
||||
<ClCompile Include="..\..\Common\UI\AsyncImageFileView.cpp" />
|
||||
<ClCompile Include="..\..\Common\UI\Context.cpp" />
|
||||
<ClCompile Include="..\..\Common\UI\Root.cpp" />
|
||||
<ClCompile Include="..\..\Common\UI\Screen.cpp" />
|
||||
|
|
|
@ -405,6 +405,12 @@
|
|||
<ClCompile Include="..\..\Common\GPU\Vulkan\VulkanLoader.cpp">
|
||||
<Filter>GPU\Vulkan</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\Common\UI\AsyncImageFileView.cpp">
|
||||
<Filter>UI</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\Common\Render\ManagedTexture.cpp">
|
||||
<Filter>Render</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="targetver.h" />
|
||||
|
@ -748,6 +754,12 @@
|
|||
<ClInclude Include="..\..\Common\GPU\Vulkan\VulkanLoader.h">
|
||||
<Filter>GPU\Vulkan</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\Common\UI\AsyncImageFileView.h">
|
||||
<Filter>UI</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\Common\Render\ManagedTexture.h">
|
||||
<Filter>Render</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="..\..\Common\Math\fast\fast_matrix_neon.S">
|
||||
|
|
|
@ -407,7 +407,6 @@
|
|||
<ClInclude Include="..\..\UI\ReportScreen.h" />
|
||||
<ClInclude Include="..\..\UI\SavedataScreen.h" />
|
||||
<ClInclude Include="..\..\UI\Store.h" />
|
||||
<ClInclude Include="..\..\UI\TextureUtil.h" />
|
||||
<ClInclude Include="..\..\UI\TiltAnalogSettingsScreen.h" />
|
||||
<ClInclude Include="..\..\UI\TiltEventProcessor.h" />
|
||||
<ClInclude Include="..\..\UI\TouchControlLayoutScreen.h" />
|
||||
|
@ -444,7 +443,6 @@
|
|||
<ClCompile Include="..\..\UI\ReportScreen.cpp" />
|
||||
<ClCompile Include="..\..\UI\SavedataScreen.cpp" />
|
||||
<ClCompile Include="..\..\UI\Store.cpp" />
|
||||
<ClCompile Include="..\..\UI\TextureUtil.cpp" />
|
||||
<ClCompile Include="..\..\UI\TiltAnalogSettingsScreen.cpp" />
|
||||
<ClCompile Include="..\..\UI\TiltEventProcessor.cpp" />
|
||||
<ClCompile Include="..\..\UI\TouchControlLayoutScreen.cpp" />
|
||||
|
@ -467,4 +465,4 @@
|
|||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
</Project>
|
|
@ -28,11 +28,12 @@
|
|||
<ClCompile Include="..\..\UI\ReportScreen.cpp" />
|
||||
<ClCompile Include="..\..\UI\SavedataScreen.cpp" />
|
||||
<ClCompile Include="..\..\UI\Store.cpp" />
|
||||
<ClCompile Include="..\..\UI\TextureUtil.cpp" />
|
||||
<ClCompile Include="..\..\UI\TiltAnalogSettingsScreen.cpp" />
|
||||
<ClCompile Include="..\..\UI\TiltEventProcessor.cpp" />
|
||||
<ClCompile Include="..\..\UI\TouchControlLayoutScreen.cpp" />
|
||||
<ClCompile Include="..\..\UI\TouchControlVisibilityScreen.cpp" />
|
||||
<ClCompile Include="..\..\UI\ChatScreen.cpp" />
|
||||
<ClCompile Include="..\..\UI\Theme.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="pch.h" />
|
||||
|
@ -63,10 +64,11 @@
|
|||
<ClInclude Include="..\..\UI\ReportScreen.h" />
|
||||
<ClInclude Include="..\..\UI\SavedataScreen.h" />
|
||||
<ClInclude Include="..\..\UI\Store.h" />
|
||||
<ClInclude Include="..\..\UI\TextureUtil.h" />
|
||||
<ClInclude Include="..\..\UI\TiltAnalogSettingsScreen.h" />
|
||||
<ClInclude Include="..\..\UI\TiltEventProcessor.h" />
|
||||
<ClInclude Include="..\..\UI\TouchControlLayoutScreen.h" />
|
||||
<ClInclude Include="..\..\UI\TouchControlVisibilityScreen.h" />
|
||||
<ClInclude Include="..\..\UI\ChatScreen.h" />
|
||||
<ClInclude Include="..\..\UI\Theme.h" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
</Project>
|
|
@ -166,6 +166,7 @@ EXEC_AND_LIB_FILES := \
|
|||
$(SRC)/Common/GPU/Shader.cpp \
|
||||
$(SRC)/Common/GPU/ShaderWriter.cpp \
|
||||
$(SRC)/Common/GPU/ShaderTranslation.cpp \
|
||||
$(SRC)/Common/Render/ManagedTexture.cpp \
|
||||
$(SRC)/Common/Render/DrawBuffer.cpp \
|
||||
$(SRC)/Common/Render/TextureAtlas.cpp \
|
||||
$(SRC)/Common/Render/Text/draw_text.cpp \
|
||||
|
@ -192,6 +193,7 @@ EXEC_AND_LIB_FILES := \
|
|||
$(SRC)/Common/Thread/ThreadUtil.cpp \
|
||||
$(SRC)/Common/Thread/ThreadManager.cpp \
|
||||
$(SRC)/Common/Thread/ParallelLoop.cpp \
|
||||
$(SRC)/Common/UI/AsyncImageFileView.cpp \
|
||||
$(SRC)/Common/UI/Root.cpp \
|
||||
$(SRC)/Common/UI/Screen.cpp \
|
||||
$(SRC)/Common/UI/UI.cpp \
|
||||
|
@ -713,7 +715,6 @@ LOCAL_SRC_FILES := \
|
|||
$(SRC)/UI/OnScreenDisplay.cpp \
|
||||
$(SRC)/UI/ProfilerDraw.cpp \
|
||||
$(SRC)/UI/NativeApp.cpp \
|
||||
$(SRC)/UI/TextureUtil.cpp \
|
||||
$(SRC)/UI/Theme.cpp \
|
||||
$(SRC)/UI/ComboKeyMappingScreen.cpp
|
||||
|
||||
|
|
|
@ -281,12 +281,14 @@ SOURCES_CXX += \
|
|||
$(COMMONDIR)/Net/Sinks.cpp \
|
||||
$(COMMONDIR)/Net/URL.cpp \
|
||||
$(COMMONDIR)/Net/WebsocketServer.cpp \
|
||||
$(COMMONDIR)/Render/ManagedTexture.cpp \
|
||||
$(COMMONDIR)/Render/DrawBuffer.cpp \
|
||||
$(COMMONDIR)/Render/TextureAtlas.cpp \
|
||||
$(COMMONDIR)/Serialize/Serializer.cpp \
|
||||
$(COMMONDIR)/Thread/ThreadUtil.cpp \
|
||||
$(COMMONDIR)/Thread/ParallelLoop.cpp \
|
||||
$(COMMONDIR)/Thread/ThreadManager.cpp \
|
||||
$(COMMONDIR)/UI/AsyncImageFileView.cpp \
|
||||
$(COMMONDIR)/UI/Root.cpp \
|
||||
$(COMMONDIR)/UI/Screen.cpp \
|
||||
$(COMMONDIR)/UI/UI.cpp \
|
||||
|
@ -616,8 +618,7 @@ SOURCES_CXX += \
|
|||
$(COREDIR)/Util/PPGeDraw.cpp \
|
||||
$(COREDIR)/Util/AudioFormat.cpp \
|
||||
$(COREDIR)/Util/PortManager.cpp \
|
||||
$(CORE_DIR)/UI/TextureUtil.cpp \
|
||||
$(CORE_DIR)/UI/GameInfoCache.cpp
|
||||
$(CORE_DIR)/UI/GameInfoCache.cpp
|
||||
|
||||
SOURCES_CXX += $(COREDIR)/HLE/__sceAudio.cpp
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue