mirror of
https://github.com/hrydgard/ppsspp.git
synced 2024-11-22 21:09:52 +00:00
Bunch more linting
This commit is contained in:
parent
e0c12c9547
commit
4d6905672e
@ -934,7 +934,7 @@ void ARM64XEmitter::SetJumpTarget(FixupBranch const& branch)
|
||||
|
||||
FixupBranch ARM64XEmitter::CBZ(ARM64Reg Rt)
|
||||
{
|
||||
FixupBranch branch;
|
||||
FixupBranch branch{};
|
||||
branch.ptr = m_code;
|
||||
branch.type = 0;
|
||||
branch.reg = Rt;
|
||||
@ -943,7 +943,7 @@ FixupBranch ARM64XEmitter::CBZ(ARM64Reg Rt)
|
||||
}
|
||||
FixupBranch ARM64XEmitter::CBNZ(ARM64Reg Rt)
|
||||
{
|
||||
FixupBranch branch;
|
||||
FixupBranch branch{};
|
||||
branch.ptr = m_code;
|
||||
branch.type = 1;
|
||||
branch.reg = Rt;
|
||||
@ -952,7 +952,7 @@ FixupBranch ARM64XEmitter::CBNZ(ARM64Reg Rt)
|
||||
}
|
||||
FixupBranch ARM64XEmitter::B(CCFlags cond)
|
||||
{
|
||||
FixupBranch branch;
|
||||
FixupBranch branch{};
|
||||
branch.ptr = m_code;
|
||||
branch.type = 2;
|
||||
branch.cond = cond;
|
||||
@ -961,7 +961,7 @@ FixupBranch ARM64XEmitter::B(CCFlags cond)
|
||||
}
|
||||
FixupBranch ARM64XEmitter::TBZ(ARM64Reg Rt, u8 bit)
|
||||
{
|
||||
FixupBranch branch;
|
||||
FixupBranch branch{};
|
||||
branch.ptr = m_code;
|
||||
branch.type = 3;
|
||||
branch.reg = Rt;
|
||||
@ -971,7 +971,7 @@ FixupBranch ARM64XEmitter::TBZ(ARM64Reg Rt, u8 bit)
|
||||
}
|
||||
FixupBranch ARM64XEmitter::TBNZ(ARM64Reg Rt, u8 bit)
|
||||
{
|
||||
FixupBranch branch;
|
||||
FixupBranch branch{};
|
||||
branch.ptr = m_code;
|
||||
branch.type = 4;
|
||||
branch.reg = Rt;
|
||||
@ -981,7 +981,7 @@ FixupBranch ARM64XEmitter::TBNZ(ARM64Reg Rt, u8 bit)
|
||||
}
|
||||
FixupBranch ARM64XEmitter::B()
|
||||
{
|
||||
FixupBranch branch;
|
||||
FixupBranch branch{};
|
||||
branch.ptr = m_code;
|
||||
branch.type = 5;
|
||||
HINT(HINT_NOP);
|
||||
@ -989,7 +989,7 @@ FixupBranch ARM64XEmitter::B()
|
||||
}
|
||||
FixupBranch ARM64XEmitter::BL()
|
||||
{
|
||||
FixupBranch branch;
|
||||
FixupBranch branch{};
|
||||
branch.ptr = m_code;
|
||||
branch.type = 6;
|
||||
HINT(HINT_NOP);
|
||||
|
@ -7,9 +7,6 @@
|
||||
#include "Common/File/Path.h"
|
||||
#include "Common/Log.h"
|
||||
|
||||
Buffer::Buffer() { }
|
||||
Buffer::~Buffer() { }
|
||||
|
||||
char *Buffer::Append(size_t length) {
|
||||
if (length > 0) {
|
||||
size_t old_size = data_.size();
|
||||
@ -125,7 +122,7 @@ bool Buffer::FlushToFile(const Path &filename) {
|
||||
FILE *f = File::OpenCFile(filename, "wb");
|
||||
if (!f)
|
||||
return false;
|
||||
if (data_.size()) {
|
||||
if (!data_.empty()) {
|
||||
fwrite(&data_[0], 1, data_.size(), f);
|
||||
}
|
||||
fclose(f);
|
||||
|
@ -11,9 +11,8 @@ class Path;
|
||||
// Does not do synchronization, must use external mutexes.
|
||||
class Buffer {
|
||||
public:
|
||||
Buffer();
|
||||
Buffer() = default;
|
||||
Buffer(Buffer &&) = default;
|
||||
~Buffer();
|
||||
|
||||
static Buffer Void() {
|
||||
Buffer buf;
|
||||
|
@ -54,10 +54,9 @@ struct D3D11DepthStencilKey {
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
class D3D11DepthStencilState : public DepthStencilState {
|
||||
public:
|
||||
~D3D11DepthStencilState() {}
|
||||
~D3D11DepthStencilState() = default;
|
||||
DepthStencilStateDesc desc;
|
||||
};
|
||||
|
||||
@ -116,7 +115,7 @@ public:
|
||||
void SetScissorRect(int left, int top, int width, int height) override;
|
||||
void SetViewport(const Viewport &viewport) override;
|
||||
void SetBlendFactor(float color[4]) override {
|
||||
if (memcmp(blendFactor_, color, sizeof(float) * 4)) {
|
||||
if (0 != memcmp(blendFactor_, color, sizeof(float) * 4)) {
|
||||
memcpy(blendFactor_, color, sizeof(float) * 4);
|
||||
blendFactorDirty_ = true;
|
||||
}
|
||||
@ -130,7 +129,7 @@ public:
|
||||
|
||||
|
||||
void Draw(int vertexCount, int offset) override;
|
||||
void DrawIndexed(int vertexCount, int offset) override;
|
||||
void DrawIndexed(int indexCount, int offset) override;
|
||||
void DrawUP(const void *vdata, int vertexCount) override;
|
||||
void Clear(int mask, uint32_t colorval, float depthVal, int stencilVal) override;
|
||||
|
||||
@ -251,7 +250,7 @@ D3D11DrawContext::D3D11DrawContext(ID3D11Device *device, ID3D11DeviceContext *de
|
||||
context1_(deviceContext1),
|
||||
featureLevel_(featureLevel),
|
||||
swapChain_(swapChain),
|
||||
deviceList_(deviceList) {
|
||||
deviceList_(std::move(deviceList)) {
|
||||
|
||||
// We no longer support Windows Phone.
|
||||
_assert_(featureLevel_ >= D3D_FEATURE_LEVEL_9_3);
|
||||
|
@ -248,7 +248,7 @@ bool OpenGLShaderModule::Compile(GLRenderManager *render, ShaderLanguage languag
|
||||
source_ = std::string((const char *)data, dataSize);
|
||||
// Add the prelude on automatically.
|
||||
if (glstage_ == GL_FRAGMENT_SHADER || glstage_ == GL_VERTEX_SHADER) {
|
||||
if (source_.find("#version") == source_.npos) {
|
||||
if (source_.find("#version") == std::string::npos) {
|
||||
source_ = ApplyGLSLPrelude(source_, glstage_);
|
||||
}
|
||||
} else {
|
||||
|
@ -575,8 +575,6 @@ ShaderWriter &ShaderWriter::LoadTexture2D(const char *sampName, const char *uv,
|
||||
ShaderWriter &ShaderWriter::GetTextureSize(const char *szVariable, const char *texName) {
|
||||
switch (lang_.shaderLanguage) {
|
||||
case HLSL_D3D11:
|
||||
F(" float2 %s; %s.GetDimensions(%s.x, %s.y);", szVariable, texName, szVariable, szVariable);
|
||||
break;
|
||||
case HLSL_D3D9:
|
||||
F(" float2 %s; %s.GetDimensions(%s.x, %s.y);", szVariable, texName, szVariable, szVariable);
|
||||
break;
|
||||
|
@ -55,8 +55,8 @@ struct CachedReadback {
|
||||
struct FrameDataShared {
|
||||
// For synchronous readbacks.
|
||||
VkFence readbackFence = VK_NULL_HANDLE;
|
||||
bool useMultiThreading;
|
||||
bool measurePresentTime;
|
||||
bool useMultiThreading = false;
|
||||
bool measurePresentTime = false;
|
||||
|
||||
void Init(VulkanContext *vulkan, bool useMultiThreading, bool measurePresentTime);
|
||||
void Destroy(VulkanContext *vulkan);
|
||||
|
@ -141,7 +141,7 @@ struct RPKey {
|
||||
|
||||
class VKRRenderPass {
|
||||
public:
|
||||
VKRRenderPass(const RPKey &key) : key_(key) {}
|
||||
explicit VKRRenderPass(const RPKey &key) : key_(key) {}
|
||||
|
||||
VkRenderPass Get(VulkanContext *vulkan, RenderPassType rpType, VkSampleCountFlagBits sampleCount);
|
||||
void Destroy(VulkanContext *vulkan) {
|
||||
|
@ -1,4 +1,4 @@
|
||||
#include <stdarg.h>
|
||||
#include <cstdarg>
|
||||
|
||||
#include "VulkanProfiler.h"
|
||||
#include "VulkanContext.h"
|
||||
|
@ -73,7 +73,7 @@ void VulkanQueueRunner::DestroyDeviceObjects() {
|
||||
syncReadback_.Destroy(vulkan_);
|
||||
|
||||
renderPasses_.IterateMut([&](const RPKey &rpkey, VKRRenderPass *rp) {
|
||||
_assert_(rp);
|
||||
_dbg_assert_(rp);
|
||||
rp->Destroy(vulkan_);
|
||||
delete rp;
|
||||
});
|
||||
|
@ -248,10 +248,10 @@ struct SinglePipelineTask {
|
||||
|
||||
class CreateMultiPipelinesTask : public Task {
|
||||
public:
|
||||
CreateMultiPipelinesTask(VulkanContext *vulkan, std::vector<SinglePipelineTask> tasks) : vulkan_(vulkan), tasks_(tasks) {
|
||||
CreateMultiPipelinesTask(VulkanContext *vulkan, std::vector<SinglePipelineTask> tasks) : vulkan_(vulkan), tasks_(std::move(tasks)) {
|
||||
tasksInFlight_.fetch_add(1);
|
||||
}
|
||||
~CreateMultiPipelinesTask() {}
|
||||
~CreateMultiPipelinesTask() = default;
|
||||
|
||||
TaskType Type() const override {
|
||||
return TaskType::CPU_COMPUTE;
|
||||
@ -745,8 +745,8 @@ void VulkanRenderManager::BeginFrame(bool enableProfiling, bool enableLogProfile
|
||||
// unless we want to limit ourselves to only measure the main cmd buffer.
|
||||
// Later versions of Vulkan have support for clearing queries on the CPU timeline, but we don't want to rely on that.
|
||||
// Reserve the first two queries for initCmd.
|
||||
frameData.profile.timestampDescriptions.push_back("initCmd Begin");
|
||||
frameData.profile.timestampDescriptions.push_back("initCmd");
|
||||
frameData.profile.timestampDescriptions.emplace_back("initCmd Begin");
|
||||
frameData.profile.timestampDescriptions.emplace_back("initCmd");
|
||||
VkCommandBuffer initCmd = GetInitCmd();
|
||||
}
|
||||
}
|
||||
|
@ -103,7 +103,7 @@ public:
|
||||
std::string fragmentShaderSource;
|
||||
std::string geometryShaderSource;
|
||||
|
||||
VkPrimitiveTopology topology;
|
||||
VkPrimitiveTopology topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST;
|
||||
VkVertexInputAttributeDescription attrs[8]{};
|
||||
VkVertexInputBindingDescription ibd{};
|
||||
VkPipelineVertexInputStateCreateInfo vis{ VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO };
|
||||
@ -577,7 +577,7 @@ private:
|
||||
|
||||
bool insideFrame_ = false;
|
||||
// probably doesn't need to be atomic.
|
||||
std::atomic<bool> runCompileThread_;
|
||||
std::atomic<bool> runCompileThread_{};
|
||||
|
||||
bool useRenderThread_ = true;
|
||||
bool measurePresentTime_ = false;
|
||||
|
@ -398,7 +398,7 @@ public:
|
||||
std::vector<std::string> GetDeviceList() const override {
|
||||
std::vector<std::string> list;
|
||||
for (int i = 0; i < vulkan_->GetNumPhysicalDevices(); i++) {
|
||||
list.push_back(vulkan_->GetPhysicalDeviceProperties(i).properties.deviceName);
|
||||
list.emplace_back(vulkan_->GetPhysicalDeviceProperties(i).properties.deviceName);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
@ -548,10 +548,6 @@ void DrawContext::DestroyPresets() {
|
||||
}
|
||||
}
|
||||
|
||||
DrawContext::~DrawContext() {
|
||||
// TODO: Can't call DestroyPresets here, too late.
|
||||
}
|
||||
|
||||
void ConvertFromRGBA8888(uint8_t *dst, const uint8_t *src, uint32_t dstStride, uint32_t srcStride, uint32_t width, uint32_t height, DataFormat format) {
|
||||
// Must skip stride in the cases below. Some games pack data into the cracks, like MotoGP.
|
||||
const uint32_t *src32 = (const uint32_t *)src;
|
||||
|
@ -89,7 +89,7 @@ enum class BlendFactor : uint8_t {
|
||||
ONE_MINUS_SRC1_ALPHA,
|
||||
};
|
||||
|
||||
enum class StencilOp {
|
||||
enum class StencilOp : uint8_t {
|
||||
KEEP = 0,
|
||||
ZERO = 1,
|
||||
REPLACE = 2,
|
||||
@ -334,7 +334,7 @@ public:
|
||||
uint32_t MaxBugIndex() const {
|
||||
return (uint32_t)MAX_BUG;
|
||||
}
|
||||
const char *GetBugName(uint32_t bug);
|
||||
static const char *GetBugName(uint32_t bug);
|
||||
|
||||
enum : uint32_t {
|
||||
NO_DEPTH_CANNOT_DISCARD_STENCIL_ADRENO = 0,
|
||||
@ -454,7 +454,7 @@ public:
|
||||
int Width() const { return width_; }
|
||||
int Height() const { return height_; }
|
||||
int Layers() const { return layers_; }
|
||||
int MultiSampleLevel() { return multiSampleLevel_; }
|
||||
int MultiSampleLevel() const { return multiSampleLevel_; }
|
||||
|
||||
virtual void UpdateTag(const char *tag) {}
|
||||
protected:
|
||||
@ -695,7 +695,7 @@ struct BackendState {
|
||||
|
||||
class DrawContext {
|
||||
public:
|
||||
virtual ~DrawContext();
|
||||
virtual ~DrawContext() = default;
|
||||
bool CreatePresets();
|
||||
void DestroyPresets();
|
||||
|
||||
|
@ -8,7 +8,7 @@
|
||||
// expected to be implemented by subclasses.
|
||||
class GraphicsContext {
|
||||
public:
|
||||
virtual ~GraphicsContext() {}
|
||||
virtual ~GraphicsContext() = default;
|
||||
|
||||
virtual bool InitFromRenderThread(std::string *errorMessage) { return true; }
|
||||
virtual void ShutdownFromRenderThread() {}
|
||||
|
@ -80,7 +80,7 @@ bool GenericLogEnabled(LogLevel level, Log type) {
|
||||
return false;
|
||||
}
|
||||
|
||||
LogManager *LogManager::logManager_ = NULL;
|
||||
LogManager *LogManager::logManager_ = nullptr;
|
||||
|
||||
// NOTE: Needs to be kept in sync with the Log enum.
|
||||
static const char * const g_logTypeNames[] = {
|
||||
@ -215,8 +215,8 @@ void LogManager::ChangeFileLog(const char *filename) {
|
||||
|
||||
void LogManager::SaveConfig(Section *section) {
|
||||
for (int i = 0; i < (int)Log::NUMBER_OF_LOGS; i++) {
|
||||
section->Set((std::string(log_[i].m_shortName) + "Enabled").c_str(), log_[i].enabled);
|
||||
section->Set((std::string(log_[i].m_shortName) + "Level").c_str(), (int)log_[i].level);
|
||||
section->Set((std::string(log_[i].m_shortName) + "Enabled"), log_[i].enabled);
|
||||
section->Set((std::string(log_[i].m_shortName) + "Level"), (int)log_[i].level);
|
||||
}
|
||||
}
|
||||
|
||||
@ -224,8 +224,8 @@ void LogManager::LoadConfig(const Section *section, bool debugDefaults) {
|
||||
for (int i = 0; i < (int)Log::NUMBER_OF_LOGS; i++) {
|
||||
bool enabled = false;
|
||||
int level = 0;
|
||||
section->Get((std::string(log_[i].m_shortName) + "Enabled").c_str(), &enabled, true);
|
||||
section->Get((std::string(log_[i].m_shortName) + "Level").c_str(), &level, (int)(debugDefaults ? LogLevel::LDEBUG : LogLevel::LERROR));
|
||||
section->Get((std::string(log_[i].m_shortName) + "Enabled"), &enabled, true);
|
||||
section->Get((std::string(log_[i].m_shortName) + "Level"), &level, (int)(debugDefaults ? LogLevel::LDEBUG : LogLevel::LERROR));
|
||||
log_[i].enabled = enabled;
|
||||
log_[i].level = (LogLevel)level;
|
||||
}
|
||||
@ -246,7 +246,7 @@ void LogManager::LogLine(LogLevel level, Log type, const char *file, int line, c
|
||||
static const char sep = '/';
|
||||
#endif
|
||||
const char *fileshort = strrchr(file, sep);
|
||||
if (fileshort != NULL) {
|
||||
if (fileshort) {
|
||||
do
|
||||
--fileshort;
|
||||
while (fileshort > file && *fileshort != sep);
|
||||
@ -302,7 +302,7 @@ void LogManager::Init(bool *enabledSetting) {
|
||||
|
||||
void LogManager::Shutdown() {
|
||||
delete logManager_;
|
||||
logManager_ = NULL;
|
||||
logManager_ = nullptr;
|
||||
}
|
||||
|
||||
void LogManager::AddListener(LogListener *listener) {
|
||||
|
@ -45,7 +45,7 @@ struct LogMessage {
|
||||
// pure virtual interface
|
||||
class LogListener {
|
||||
public:
|
||||
virtual ~LogListener() {}
|
||||
virtual ~LogListener() = default;
|
||||
|
||||
virtual void Log(const LogMessage &msg) = 0;
|
||||
};
|
||||
|
@ -19,8 +19,8 @@
|
||||
#include <algorithm> // min
|
||||
#include <cstring>
|
||||
#include <string> // System: To be able to add strings with "+"
|
||||
#include <math.h>
|
||||
#include <stdarg.h>
|
||||
#include <cmath>
|
||||
#include <cstdarg>
|
||||
#ifndef _MSC_VER
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
@ -106,7 +106,7 @@ typedef x86_thread_state64_t SContext;
|
||||
|
||||
#elif defined(__linux__)
|
||||
|
||||
#include <signal.h>
|
||||
#include <csignal>
|
||||
|
||||
#if PPSSPP_ARCH(AMD64)
|
||||
|
||||
|
@ -31,8 +31,8 @@
|
||||
#ifdef _WIN32
|
||||
#include "Common/CommonWindows.h"
|
||||
#else
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <cerrno>
|
||||
#include <cstdio>
|
||||
#endif
|
||||
|
||||
#ifdef __APPLE__
|
||||
|
@ -38,9 +38,6 @@
|
||||
|
||||
namespace net {
|
||||
|
||||
Connection::Connection() {
|
||||
}
|
||||
|
||||
Connection::~Connection() {
|
||||
Disconnect();
|
||||
if (resolved_ != nullptr)
|
||||
@ -173,7 +170,7 @@ bool Connection::Connect(int maxTries, double timeout, bool *cancelConnect) {
|
||||
int selectResult = 0;
|
||||
long timeoutHalfSeconds = floor(2 * timeout);
|
||||
while (timeoutHalfSeconds >= 0 && selectResult == 0) {
|
||||
struct timeval tv;
|
||||
struct timeval tv{};
|
||||
tv.tv_sec = 0;
|
||||
if (timeoutHalfSeconds > 0) {
|
||||
// Wait up to 0.5 seconds between cancel checks.
|
||||
|
@ -14,7 +14,6 @@ namespace net {
|
||||
|
||||
class Connection {
|
||||
public:
|
||||
Connection();
|
||||
virtual ~Connection();
|
||||
|
||||
// Inits the sockaddr_in.
|
||||
|
@ -1,9 +1,9 @@
|
||||
#include "ppsspp_config.h"
|
||||
#include "Common/Net/Resolve.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
@ -98,7 +98,7 @@ bool DNSResolve(const std::string &host, const std::string &service, addrinfo **
|
||||
else if (type == DNSType::IPV6)
|
||||
hints.ai_family = AF_INET6;
|
||||
|
||||
const char *servicep = service.length() == 0 ? nullptr : service.c_str();
|
||||
const char *servicep = service.empty() ? nullptr : service.c_str();
|
||||
|
||||
*res = nullptr;
|
||||
int result = getaddrinfo(host.c_str(), servicep, &hints, res);
|
||||
@ -125,7 +125,7 @@ bool DNSResolve(const std::string &host, const std::string &service, addrinfo **
|
||||
|
||||
void DNSResolveFree(addrinfo *res)
|
||||
{
|
||||
if (res != NULL)
|
||||
if (res)
|
||||
freeaddrinfo(res);
|
||||
}
|
||||
|
||||
@ -163,8 +163,7 @@ bool GetIPList(std::vector<std::string> &IP4s) {
|
||||
#elif defined(SIOCGIFCONF) // Better detection on Linux/UNIX/MacOS/some Android
|
||||
INFO_LOG(Log::sceNet, "GetIPList from SIOCGIFCONF");
|
||||
static struct ifreq ifreqs[32];
|
||||
struct ifconf ifc;
|
||||
memset(&ifc, 0, sizeof(ifconf));
|
||||
struct ifconf ifc{};
|
||||
ifc.ifc_req = ifreqs;
|
||||
ifc.ifc_len = sizeof(ifreqs);
|
||||
|
||||
@ -198,7 +197,7 @@ bool GetIPList(std::vector<std::string> &IP4s) {
|
||||
if (ifreqs[i].ifr_addr.sa_family == AF_INET) {
|
||||
// is a valid IP4 Address
|
||||
if (inet_ntop(AF_INET, &((struct sockaddr_in*)addr)->sin_addr, ipstr, sizeof(ipstr)) != 0) {
|
||||
IP4s.push_back(ipstr);
|
||||
IP4s.emplace_back(ipstr);
|
||||
}
|
||||
}
|
||||
/*else if (ifreqs[i].ifr_addr.sa_family == AF_INET6) {
|
||||
|
@ -32,11 +32,11 @@
|
||||
|
||||
#include <cstdarg>
|
||||
|
||||
#include <errno.h>
|
||||
#include <cerrno>
|
||||
|
||||
#include <string>
|
||||
#include <sstream>
|
||||
#include <limits.h>
|
||||
#include <climits>
|
||||
|
||||
#include <algorithm>
|
||||
#include <iomanip>
|
||||
@ -235,7 +235,7 @@ void DataToHexString(int indent, uint32_t startAddr, const uint8_t* data, size_t
|
||||
std::string StringFromFormat(const char* format, ...)
|
||||
{
|
||||
va_list args;
|
||||
std::string temp = "";
|
||||
std::string temp;
|
||||
#ifdef _WIN32
|
||||
int required = 0;
|
||||
|
||||
@ -275,7 +275,7 @@ std::string StringFromInt(int value) {
|
||||
// Turns " hej " into "hej". Also handles tabs.
|
||||
std::string StripSpaces(const std::string &str) {
|
||||
const size_t s = str.find_first_not_of(" \t\r\n");
|
||||
if (str.npos != s)
|
||||
if (std::string::npos != s)
|
||||
return str.substr(s, str.find_last_not_of(" \t\r\n") - s + 1);
|
||||
else
|
||||
return "";
|
||||
@ -295,7 +295,7 @@ std::string StripQuotes(const std::string& s)
|
||||
// Turns " hej " into "hej". Also handles tabs.
|
||||
std::string_view StripSpaces(std::string_view str) {
|
||||
const size_t s = str.find_first_not_of(" \t\r\n");
|
||||
if (str.npos != s)
|
||||
if (std::string::npos != s)
|
||||
return str.substr(s, str.find_last_not_of(" \t\r\n") - s + 1);
|
||||
else
|
||||
return "";
|
||||
@ -398,7 +398,7 @@ std::string ReplaceAll(std::string_view input, std::string_view src, std::string
|
||||
// TODO: Don't mutate the input, just append stuff to the output instead.
|
||||
while (true) {
|
||||
pos = result.find(src, pos);
|
||||
if (pos == result.npos)
|
||||
if (pos == std::string_view::npos)
|
||||
break;
|
||||
result.replace(pos, src.size(), dest);
|
||||
pos += dest.size();
|
||||
|
@ -115,7 +115,6 @@ const char* safe_string(const char* s);
|
||||
|
||||
long parseHexLong(const std::string &s);
|
||||
long parseLong(std::string s);
|
||||
std::string StringFromFormat(const char* format, ...);
|
||||
// Cheap!
|
||||
bool CharArrayFromFormatV(char* out, int outsize, const char* format, va_list args);
|
||||
|
||||
|
@ -22,7 +22,6 @@ namespace Draw {
|
||||
class RasterState;
|
||||
}
|
||||
|
||||
class Texture;
|
||||
class DrawBuffer;
|
||||
class TextDrawer;
|
||||
|
||||
|
@ -35,7 +35,7 @@ void IconCache::SaveToFile(FILE *file) {
|
||||
// First, compute the total size. If above a threshold, remove until under.
|
||||
Decimate(MAX_SAVED_CACHE_SIZE);
|
||||
|
||||
DiskCacheHeader header;
|
||||
DiskCacheHeader header{};
|
||||
header.magic = ICON_CACHE_MAGIC;
|
||||
header.version = ICON_CACHE_VERSION;
|
||||
header.entryCount = (uint32_t)cache_.size();
|
||||
@ -43,8 +43,7 @@ void IconCache::SaveToFile(FILE *file) {
|
||||
fwrite(&header, 1, sizeof(header), file);
|
||||
|
||||
for (auto &iter : cache_) {
|
||||
DiskCacheEntry entryHeader;
|
||||
memset(&entryHeader, 0, sizeof(entryHeader)); // valgrind complains about padding bytes
|
||||
DiskCacheEntry entryHeader{};
|
||||
entryHeader.keyLen = (uint32_t)iter.first.size();
|
||||
entryHeader.dataLen = (uint32_t)iter.second.data.size();
|
||||
entryHeader.format = iter.second.format;
|
||||
@ -58,7 +57,7 @@ void IconCache::SaveToFile(FILE *file) {
|
||||
bool IconCache::LoadFromFile(FILE *file) {
|
||||
std::unique_lock<std::mutex> lock(lock_);
|
||||
|
||||
DiskCacheHeader header;
|
||||
DiskCacheHeader header{};
|
||||
if (fread(&header, 1, sizeof(header), file) != sizeof(DiskCacheHeader)) {
|
||||
return false;
|
||||
}
|
||||
@ -69,7 +68,7 @@ bool IconCache::LoadFromFile(FILE *file) {
|
||||
double now = time_now_d();
|
||||
|
||||
for (uint32_t i = 0; i < header.entryCount; i++) {
|
||||
DiskCacheEntry entryHeader;
|
||||
DiskCacheEntry entryHeader{};
|
||||
if (fread(&entryHeader, 1, sizeof(entryHeader), file) != sizeof(entryHeader)) {
|
||||
break;
|
||||
}
|
||||
@ -157,7 +156,7 @@ void IconCache::Decimate(int64_t maxSize) {
|
||||
|
||||
int64_t totalSize = 0;
|
||||
for (auto &iter : cache_) {
|
||||
totalSize += iter.second.data.size();
|
||||
totalSize += (int64_t)iter.second.data.size();
|
||||
}
|
||||
|
||||
if (totalSize <= maxSize) {
|
||||
@ -173,7 +172,7 @@ void IconCache::Decimate(int64_t maxSize) {
|
||||
|
||||
std::vector<SortEntry> sortEntries;
|
||||
sortEntries.reserve(cache_.size());
|
||||
for (auto iter : cache_) {
|
||||
for (const auto &iter : cache_) {
|
||||
sortEntries.push_back({ iter.first, iter.second.usedTimeStamp, iter.second.data.size() });
|
||||
}
|
||||
|
||||
@ -183,7 +182,7 @@ void IconCache::Decimate(int64_t maxSize) {
|
||||
});
|
||||
|
||||
while (totalSize > maxSize && !sortEntries.empty()) {
|
||||
totalSize -= sortEntries.back().size;
|
||||
totalSize -= (int64_t)sortEntries.back().size;
|
||||
auto iter = cache_.find(sortEntries.back().key);
|
||||
if (iter != cache_.end()) {
|
||||
if (iter->second.texture) {
|
||||
|
@ -88,7 +88,7 @@ void EnableFocusMovement(bool enable) {
|
||||
if (focusedView) {
|
||||
focusedView->FocusChanged(FF_LOSTFOCUS);
|
||||
}
|
||||
focusedView = 0;
|
||||
focusedView = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -79,7 +79,7 @@ void ScreenManager::update() {
|
||||
overlayScreen_->update();
|
||||
}
|
||||
// The background screen doesn't need updating.
|
||||
if (stack_.size()) {
|
||||
if (!stack_.empty()) {
|
||||
stack_.back().screen->update();
|
||||
}
|
||||
}
|
||||
|
@ -118,7 +118,7 @@ private:
|
||||
|
||||
class Transition {
|
||||
public:
|
||||
Transition() {}
|
||||
Transition() = default;
|
||||
};
|
||||
|
||||
enum {
|
||||
|
@ -123,7 +123,7 @@ const char *DefaultLangRegion() {
|
||||
std::vector<std::string> keys;
|
||||
mapping.GetKeys("LangRegionNames", keys);
|
||||
|
||||
for (std::string key : keys) {
|
||||
for (const std::string &key : keys) {
|
||||
if (startsWithNoCase(key, langRegion)) {
|
||||
// Exact submatch, or different case. Let's use it.
|
||||
defaultLangRegion = key;
|
||||
@ -718,21 +718,10 @@ static const ConfigSetting soundSettings[] = {
|
||||
};
|
||||
|
||||
static bool DefaultShowTouchControls() {
|
||||
int deviceType = System_GetPropertyInt(SYSPROP_DEVICE_TYPE);
|
||||
if (deviceType == DEVICE_TYPE_MOBILE) {
|
||||
std::string name = System_GetProperty(SYSPROP_NAME);
|
||||
if (KeyMap::HasBuiltinController(name)) {
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
} else if (deviceType == DEVICE_TYPE_TV) {
|
||||
return false;
|
||||
} else if (deviceType == DEVICE_TYPE_DESKTOP) {
|
||||
return false;
|
||||
} else if (deviceType == DEVICE_TYPE_VR) {
|
||||
return false;
|
||||
} else {
|
||||
switch (System_GetPropertyInt(SYSPROP_DEVICE_TYPE)) {
|
||||
case DEVICE_TYPE_MOBILE:
|
||||
return !KeyMap::HasBuiltinController(System_GetProperty(SYSPROP_NAME));
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -1063,9 +1052,9 @@ void Config::LoadLangValuesMapping() {
|
||||
|
||||
for (size_t i = 0; i < keys.size(); i++) {
|
||||
std::string langName;
|
||||
langRegionNames->Get(keys[i].c_str(), &langName, "ERROR");
|
||||
langRegionNames->Get(keys[i], &langName, "ERROR");
|
||||
std::string langCode;
|
||||
systemLanguage->Get(keys[i].c_str(), &langCode, "ENGLISH");
|
||||
systemLanguage->Get(keys[i], &langCode, "ENGLISH");
|
||||
int iLangCode = PSP_SYSTEMPARAM_LANGUAGE_ENGLISH;
|
||||
if (langCodeMapping.find(langCode) != langCodeMapping.end())
|
||||
iLangCode = langCodeMapping[langCode];
|
||||
@ -1356,7 +1345,7 @@ bool Config::Save(const char *saveReason) {
|
||||
Section *postShaderSetting = iniFile.GetOrCreateSection("PostShaderSetting");
|
||||
postShaderSetting->Clear();
|
||||
for (const auto &[k, v] : mPostShaderSetting) {
|
||||
postShaderSetting->Set(k.c_str(), v);
|
||||
postShaderSetting->Set(k, v);
|
||||
}
|
||||
Section *postShaderChain = iniFile.GetOrCreateSection("PostShaderList");
|
||||
postShaderChain->Clear();
|
||||
@ -1772,7 +1761,7 @@ bool Config::saveGameConfig(const std::string &pGameId, const std::string &title
|
||||
Section *postShaderSetting = iniFile.GetOrCreateSection("PostShaderSetting");
|
||||
postShaderSetting->Clear();
|
||||
for (const auto &[k, v] : mPostShaderSetting) {
|
||||
postShaderSetting->Set(k.c_str(), v);
|
||||
postShaderSetting->Set(k, v);
|
||||
}
|
||||
|
||||
Section *postShaderChain = iniFile.GetOrCreateSection("PostShaderList");
|
||||
@ -1987,15 +1976,15 @@ void PlayTimeTracker::Load(const Section *section) {
|
||||
// Parse the string.
|
||||
PlayTime gameTime{};
|
||||
if (2 == sscanf(value.c_str(), "%d,%llu", &gameTime.totalTimePlayed, (long long *)&gameTime.lastTimePlayed)) {
|
||||
tracker_[iter.first.c_str()] = gameTime;
|
||||
tracker_[iter.first] = gameTime;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void PlayTimeTracker::Save(Section *section) {
|
||||
for (auto iter : tracker_) {
|
||||
for (auto &iter : tracker_) {
|
||||
std::string formatted = StringFromFormat("%d,%llu", iter.second.totalTimePlayed, iter.second.lastTimePlayed);
|
||||
section->Set(iter.first.c_str(), formatted);
|
||||
section->Set(iter.first, formatted);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -74,7 +74,7 @@ struct ConfigSetting {
|
||||
CustomButtonDefaultCallback customButton;
|
||||
};
|
||||
|
||||
ConfigSetting(const char *ini, bool *v, bool def, CfgFlag flags = CfgFlag::DEFAULT)
|
||||
ConfigSetting(const char *ini, bool *v, bool def, CfgFlag flags = CfgFlag::DEFAULT) noexcept
|
||||
: iniKey_(ini), type_(TYPE_BOOL), flags_(flags) {
|
||||
ptr_.b = v;
|
||||
cb_.b = nullptr;
|
||||
@ -82,7 +82,7 @@ struct ConfigSetting {
|
||||
getPtrLUT()[v] = this;
|
||||
}
|
||||
|
||||
ConfigSetting(const char *ini, int *v, int def, CfgFlag flags = CfgFlag::DEFAULT)
|
||||
ConfigSetting(const char *ini, int *v, int def, CfgFlag flags = CfgFlag::DEFAULT) noexcept
|
||||
: iniKey_(ini), type_(TYPE_INT), flags_(flags) {
|
||||
ptr_.i = v;
|
||||
cb_.i = nullptr;
|
||||
@ -90,7 +90,7 @@ struct ConfigSetting {
|
||||
getPtrLUT()[v] = this;
|
||||
}
|
||||
|
||||
ConfigSetting(const char *ini, int *v, int def, std::string(*transTo)(int), int (*transFrom)(const std::string &), CfgFlag flags = CfgFlag::DEFAULT)
|
||||
ConfigSetting(const char *ini, int *v, int def, std::string(*transTo)(int), int (*transFrom)(const std::string &), CfgFlag flags = CfgFlag::DEFAULT) noexcept
|
||||
: iniKey_(ini), type_(TYPE_INT), flags_(flags), translateTo_(transTo), translateFrom_(transFrom) {
|
||||
ptr_.i = v;
|
||||
cb_.i = nullptr;
|
||||
@ -98,7 +98,7 @@ struct ConfigSetting {
|
||||
getPtrLUT()[v] = this;
|
||||
}
|
||||
|
||||
ConfigSetting(const char *ini, uint32_t *v, uint32_t def, CfgFlag flags = CfgFlag::DEFAULT)
|
||||
ConfigSetting(const char *ini, uint32_t *v, uint32_t def, CfgFlag flags = CfgFlag::DEFAULT) noexcept
|
||||
: iniKey_(ini), type_(TYPE_UINT32), flags_(flags) {
|
||||
ptr_.u = v;
|
||||
cb_.u = nullptr;
|
||||
@ -106,7 +106,7 @@ struct ConfigSetting {
|
||||
getPtrLUT()[v] = this;
|
||||
}
|
||||
|
||||
ConfigSetting(const char *ini, uint64_t *v, uint64_t def, CfgFlag flags = CfgFlag::DEFAULT)
|
||||
ConfigSetting(const char *ini, uint64_t *v, uint64_t def, CfgFlag flags = CfgFlag::DEFAULT) noexcept
|
||||
: iniKey_(ini), type_(TYPE_UINT64), flags_(flags) {
|
||||
ptr_.lu = v;
|
||||
cb_.lu = nullptr;
|
||||
@ -114,7 +114,7 @@ struct ConfigSetting {
|
||||
getPtrLUT()[v] = this;
|
||||
}
|
||||
|
||||
ConfigSetting(const char *ini, float *v, float def, CfgFlag flags = CfgFlag::DEFAULT)
|
||||
ConfigSetting(const char *ini, float *v, float def, CfgFlag flags = CfgFlag::DEFAULT) noexcept
|
||||
: iniKey_(ini), type_(TYPE_FLOAT), flags_(flags) {
|
||||
ptr_.f = v;
|
||||
cb_.f = nullptr;
|
||||
@ -122,7 +122,7 @@ struct ConfigSetting {
|
||||
getPtrLUT()[v] = this;
|
||||
}
|
||||
|
||||
ConfigSetting(const char *ini, std::string *v, const char *def, CfgFlag flags = CfgFlag::DEFAULT)
|
||||
ConfigSetting(const char *ini, std::string *v, const char *def, CfgFlag flags = CfgFlag::DEFAULT) noexcept
|
||||
: iniKey_(ini), type_(TYPE_STRING), flags_(flags) {
|
||||
ptr_.s = v;
|
||||
cb_.s = nullptr;
|
||||
@ -130,7 +130,7 @@ struct ConfigSetting {
|
||||
getPtrLUT()[v] = this;
|
||||
}
|
||||
|
||||
ConfigSetting(const char *ini, Path *v, const char *def, CfgFlag flags = CfgFlag::DEFAULT)
|
||||
ConfigSetting(const char *ini, Path *v, const char *def, CfgFlag flags = CfgFlag::DEFAULT) noexcept
|
||||
: iniKey_(ini), type_(TYPE_PATH), flags_(flags) {
|
||||
ptr_.p = v;
|
||||
cb_.p = nullptr;
|
||||
@ -138,7 +138,7 @@ struct ConfigSetting {
|
||||
getPtrLUT()[v] = this;
|
||||
}
|
||||
|
||||
ConfigSetting(const char *iniX, const char *iniY, const char *iniScale, const char *iniShow, ConfigTouchPos *v, ConfigTouchPos def, CfgFlag flags = CfgFlag::DEFAULT)
|
||||
ConfigSetting(const char *iniX, const char *iniY, const char *iniScale, const char *iniShow, ConfigTouchPos *v, ConfigTouchPos def, CfgFlag flags = CfgFlag::DEFAULT) noexcept
|
||||
: iniKey_(iniX), ini2_(iniY), ini3_(iniScale), ini4_(iniShow), type_(TYPE_TOUCH_POS), flags_(flags) {
|
||||
ptr_.touchPos = v;
|
||||
cb_.touchPos = nullptr;
|
||||
@ -146,7 +146,7 @@ struct ConfigSetting {
|
||||
getPtrLUT()[v] = this;
|
||||
}
|
||||
|
||||
ConfigSetting(const char *iniKey, const char *iniImage, const char *iniShape, const char *iniToggle, const char *iniRepeat, ConfigCustomButton *v, ConfigCustomButton def, CfgFlag flags = CfgFlag::DEFAULT)
|
||||
ConfigSetting(const char *iniKey, const char *iniImage, const char *iniShape, const char *iniToggle, const char *iniRepeat, ConfigCustomButton *v, ConfigCustomButton def, CfgFlag flags = CfgFlag::DEFAULT) noexcept
|
||||
: iniKey_(iniKey), ini2_(iniImage), ini3_(iniShape), ini4_(iniToggle), ini5_(iniRepeat), type_(TYPE_CUSTOM_BUTTON), flags_(flags) {
|
||||
ptr_.customButton = v;
|
||||
cb_.customButton = nullptr;
|
||||
@ -154,49 +154,49 @@ struct ConfigSetting {
|
||||
getPtrLUT()[v] = this;
|
||||
}
|
||||
|
||||
ConfigSetting(const char *ini, bool *v, BoolDefaultCallback def, CfgFlag flags = CfgFlag::DEFAULT)
|
||||
ConfigSetting(const char *ini, bool *v, BoolDefaultCallback def, CfgFlag flags = CfgFlag::DEFAULT) noexcept
|
||||
: iniKey_(ini), type_(TYPE_BOOL), flags_(flags) {
|
||||
ptr_.b = v;
|
||||
cb_.b = def;
|
||||
getPtrLUT()[v] = this;
|
||||
}
|
||||
|
||||
ConfigSetting(const char *ini, int *v, IntDefaultCallback def, CfgFlag flags = CfgFlag::DEFAULT)
|
||||
ConfigSetting(const char *ini, int *v, IntDefaultCallback def, CfgFlag flags = CfgFlag::DEFAULT) noexcept
|
||||
: iniKey_(ini), type_(TYPE_INT), flags_(flags) {
|
||||
ptr_.i = v;
|
||||
cb_.i = def;
|
||||
getPtrLUT()[v] = this;
|
||||
}
|
||||
|
||||
ConfigSetting(const char *ini, int *v, IntDefaultCallback def, std::string(*transTo)(int), int(*transFrom)(const std::string &), CfgFlag flags = CfgFlag::DEFAULT)
|
||||
ConfigSetting(const char *ini, int *v, IntDefaultCallback def, std::string(*transTo)(int), int(*transFrom)(const std::string &), CfgFlag flags = CfgFlag::DEFAULT) noexcept
|
||||
: iniKey_(ini), type_(TYPE_INT), flags_(flags), translateTo_(transTo), translateFrom_(transFrom) {
|
||||
ptr_.i = v;
|
||||
cb_.i = def;
|
||||
getPtrLUT()[v] = this;
|
||||
}
|
||||
|
||||
ConfigSetting(const char *ini, uint32_t *v, Uint32DefaultCallback def, CfgFlag flags = CfgFlag::DEFAULT)
|
||||
ConfigSetting(const char *ini, uint32_t *v, Uint32DefaultCallback def, CfgFlag flags = CfgFlag::DEFAULT) noexcept
|
||||
: iniKey_(ini), type_(TYPE_UINT32), flags_(flags) {
|
||||
ptr_.u = v;
|
||||
cb_.u = def;
|
||||
getPtrLUT()[v] = this;
|
||||
}
|
||||
|
||||
ConfigSetting(const char *ini, float *v, FloatDefaultCallback def, CfgFlag flags = CfgFlag::DEFAULT)
|
||||
ConfigSetting(const char *ini, float *v, FloatDefaultCallback def, CfgFlag flags = CfgFlag::DEFAULT) noexcept
|
||||
: iniKey_(ini), type_(TYPE_FLOAT), flags_(flags) {
|
||||
ptr_.f = v;
|
||||
cb_.f = def;
|
||||
getPtrLUT()[v] = this;
|
||||
}
|
||||
|
||||
ConfigSetting(const char *ini, std::string *v, StringDefaultCallback def, CfgFlag flags = CfgFlag::DEFAULT)
|
||||
ConfigSetting(const char *ini, std::string *v, StringDefaultCallback def, CfgFlag flags = CfgFlag::DEFAULT) noexcept
|
||||
: iniKey_(ini), type_(TYPE_STRING), flags_(flags) {
|
||||
ptr_.s = v;
|
||||
cb_.s = def;
|
||||
getPtrLUT()[v] = this;
|
||||
}
|
||||
|
||||
ConfigSetting(const char *iniX, const char *iniY, const char *iniScale, const char *iniShow, ConfigTouchPos *v, TouchPosDefaultCallback def, CfgFlag flags = CfgFlag::DEFAULT)
|
||||
ConfigSetting(const char *iniX, const char *iniY, const char *iniScale, const char *iniShow, ConfigTouchPos *v, TouchPosDefaultCallback def, CfgFlag flags = CfgFlag::DEFAULT) noexcept
|
||||
: iniKey_(iniX), ini2_(iniY), ini3_(iniScale), ini4_(iniShow), type_(TYPE_TOUCH_POS), flags_(flags) {
|
||||
ptr_.touchPos = v;
|
||||
cb_.touchPos = def;
|
||||
@ -232,9 +232,9 @@ struct ConfigSetting {
|
||||
|
||||
private:
|
||||
CfgFlag flags_;
|
||||
SettingPtr ptr_;
|
||||
SettingPtr ptr_{};
|
||||
DefaultValue default_{};
|
||||
DefaultCallback cb_;
|
||||
DefaultCallback cb_{};
|
||||
|
||||
// We only support transform for ints.
|
||||
std::string (*translateTo_)(int) = nullptr;
|
||||
|
@ -60,7 +60,7 @@
|
||||
#endif
|
||||
#endif
|
||||
|
||||
StereoResampler::StereoResampler()
|
||||
StereoResampler::StereoResampler() noexcept
|
||||
: m_maxBufsize(MAX_BUFSIZE_DEFAULT)
|
||||
, m_targetBufsize(TARGET_BUFSIZE_DEFAULT) {
|
||||
// Need to have space for the worst case in case it changes.
|
||||
|
@ -28,7 +28,7 @@ struct AudioDebugStats;
|
||||
|
||||
class StereoResampler {
|
||||
public:
|
||||
StereoResampler();
|
||||
StereoResampler() noexcept;
|
||||
~StereoResampler();
|
||||
|
||||
// Called from audio threads
|
||||
|
@ -36,7 +36,7 @@ struct WavData {
|
||||
int raw_bytes_per_frame = 0;
|
||||
uint8_t *raw_data = nullptr;
|
||||
int raw_data_size = 0;
|
||||
u8 at3_extradata[16];
|
||||
u8 at3_extradata[16]{};
|
||||
|
||||
bool Read(RIFFReader &riff);
|
||||
|
||||
@ -45,6 +45,7 @@ struct WavData {
|
||||
raw_data = nullptr;
|
||||
}
|
||||
|
||||
[[nodiscard]]
|
||||
bool IsSimpleWAV() const {
|
||||
bool isBad = raw_bytes_per_frame > sizeof(int16_t) * num_channels;
|
||||
return !isBad && num_channels > 0 && sample_rate >= 8000 && codec == 0;
|
||||
@ -210,7 +211,7 @@ public:
|
||||
decoder_ = nullptr;
|
||||
}
|
||||
|
||||
bool IsOK() { return wave_.raw_data != nullptr; }
|
||||
bool IsOK() const { return wave_.raw_data != nullptr; }
|
||||
|
||||
bool Read(int *buffer, int len) {
|
||||
if (!wave_.raw_data)
|
||||
|
@ -69,7 +69,7 @@ private:
|
||||
UI::EventReturn OnReplace(UI::EventParams ¶ms);
|
||||
UI::EventReturn OnReplaceAll(UI::EventParams ¶ms);
|
||||
|
||||
void MappedCallback(const MultiInputMapping &key);
|
||||
void MappedCallback(const MultiInputMapping &kdf);
|
||||
|
||||
enum Action {
|
||||
NONE,
|
||||
@ -82,7 +82,7 @@ private:
|
||||
UI::Choice *replaceAllButton_ = nullptr;
|
||||
std::vector<UI::View *> rows_;
|
||||
Action action_ = NONE;
|
||||
int actionIndex_;
|
||||
int actionIndex_ = 0;
|
||||
int pspKey_;
|
||||
std::string keyName_;
|
||||
ScreenManager *scrm_;
|
||||
@ -124,7 +124,7 @@ void SingleControlMapper::Refresh() {
|
||||
replaceAllButton_ = new Choice(iter->second, new LinearLayoutParams(leftColumnWidth, itemH));
|
||||
} else {
|
||||
// No image? Let's translate.
|
||||
replaceAllButton_ = new Choice(mc->T(keyName_.c_str()), new LinearLayoutParams(leftColumnWidth, itemH));
|
||||
replaceAllButton_ = new Choice(mc->T(keyName_), new LinearLayoutParams(leftColumnWidth, itemH));
|
||||
replaceAllButton_->SetCentered(true);
|
||||
}
|
||||
root->Add(replaceAllButton_)->OnClick.Handle(this, &SingleControlMapper::OnReplaceAll);
|
||||
@ -157,7 +157,7 @@ void SingleControlMapper::Refresh() {
|
||||
d->OnClick.Handle(this, &SingleControlMapper::OnDelete);
|
||||
}
|
||||
|
||||
if (mappings.size() == 0) {
|
||||
if (mappings.empty()) {
|
||||
// look like an empty line
|
||||
Choice *c = rightColumn->Add(new Choice("", new LinearLayoutParams(FILL_PARENT, itemH)));
|
||||
c->OnClick.Handle(this, &SingleControlMapper::OnAdd);
|
||||
@ -608,7 +608,7 @@ UI::EventReturn AnalogSetupScreen::OnResetToDefaults(UI::EventParams &e) {
|
||||
|
||||
class Backplate : public UI::InertView {
|
||||
public:
|
||||
Backplate(float scale, UI::LayoutParams *layoutParams = nullptr) : InertView(layoutParams), scale_(scale) {}
|
||||
explicit Backplate(float scale, UI::LayoutParams *layoutParams = nullptr) : InertView(layoutParams), scale_(scale) {}
|
||||
|
||||
void Draw(UIContext &dc) override {
|
||||
for (float dy = 0.0f; dy <= 4.0f; dy += 1.0f) {
|
||||
@ -682,7 +682,7 @@ protected:
|
||||
|
||||
class MockScreen : public UI::InertView {
|
||||
public:
|
||||
MockScreen(UI::LayoutParams *layoutParams = nullptr) : InertView(layoutParams) {
|
||||
explicit MockScreen(UI::LayoutParams *layoutParams = nullptr) : InertView(layoutParams) {
|
||||
}
|
||||
|
||||
void Draw(UIContext &dc) override {
|
||||
|
@ -227,7 +227,7 @@ void InstallZipScreen::update() {
|
||||
std::string err = g_GameManager.GetInstallError();
|
||||
if (!err.empty()) {
|
||||
if (doneView_)
|
||||
doneView_->SetText(iz->T(err.c_str()));
|
||||
doneView_->SetText(iz->T(err));
|
||||
} else if (installStarted_) {
|
||||
if (doneView_)
|
||||
doneView_->SetText(iz->T("Installed!"));
|
||||
|
@ -344,7 +344,7 @@ void JitCompareScreen::UpdateDisasm() {
|
||||
} else { // viewMode_ == ViewMode::STATS
|
||||
statsContainer_->Clear();
|
||||
|
||||
BlockCacheStats bcStats;
|
||||
BlockCacheStats bcStats{};
|
||||
blockCacheDebug->ComputeStats(bcStats);
|
||||
|
||||
char stats[1024];
|
||||
|
@ -123,7 +123,7 @@ static bool IsTempPath(const Path &str) {
|
||||
|
||||
class GameButton : public UI::Clickable {
|
||||
public:
|
||||
GameButton(const Path &gamePath, bool gridStyle, UI::LayoutParams *layoutParams = 0)
|
||||
GameButton(const Path &gamePath, bool gridStyle, UI::LayoutParams *layoutParams = nullptr)
|
||||
: UI::Clickable(layoutParams), gridStyle_(gridStyle), gamePath_(gamePath) {}
|
||||
|
||||
void Draw(UIContext &dc) override;
|
||||
@ -227,7 +227,7 @@ private:
|
||||
|
||||
void GameButton::Draw(UIContext &dc) {
|
||||
std::shared_ptr<GameInfo> ginfo = g_gameInfoCache->GetInfo(dc.GetDrawContext(), gamePath_, GameInfoFlags::PARAM_SFO | GameInfoFlags::ICON);
|
||||
Draw::Texture *texture = 0;
|
||||
Draw::Texture *texture = nullptr;
|
||||
u32 color = 0, shadowColor = 0;
|
||||
using namespace UI;
|
||||
|
||||
@ -685,7 +685,7 @@ bool GameBrowser::HasSpecialFiles(std::vector<Path> &filenames) {
|
||||
if (path_.GetPath().ToString() == "!RECENT") {
|
||||
filenames.clear();
|
||||
for (auto &str : g_Config.RecentIsos()) {
|
||||
filenames.push_back(Path(str));
|
||||
filenames.emplace_back(str);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@ -1326,7 +1326,7 @@ void MainScreen::CreateViews() {
|
||||
|
||||
root_->SetTag("mainroot");
|
||||
|
||||
upgradeBar_ = 0;
|
||||
upgradeBar_ = nullptr;
|
||||
if (!g_Config.upgradeMessage.empty()) {
|
||||
auto u = GetI18NCategory(I18NCat::UPGRADE);
|
||||
upgradeBar_ = new LinearLayout(ORIENT_HORIZONTAL, new LinearLayoutParams(FILL_PARENT, WRAP_CONTENT));
|
||||
|
@ -170,7 +170,7 @@ protected:
|
||||
float prevHighlightProgress_ = 0.0f;
|
||||
bool backFromStore_ = false;
|
||||
bool lockBackgroundAudio_ = false;
|
||||
bool lastVertical_;
|
||||
bool lastVertical_ = false;
|
||||
bool confirmedTemporary_ = false;
|
||||
UI::ScrollView *scrollAllGames_ = nullptr;
|
||||
bool searchKeyModifier_ = false;
|
||||
|
@ -236,7 +236,7 @@ void MemStickScreen::CreateViews() {
|
||||
|
||||
leftColumn->Add(new Spacer(new LinearLayoutParams(FILL_PARENT, 12.0f, 0.0f)));
|
||||
|
||||
std::string_view confirmButtonText = "";
|
||||
std::string_view confirmButtonText;
|
||||
ImageID confirmButtonImage = ImageID::invalid();
|
||||
switch (choice_) {
|
||||
case CHOICE_BROWSE_FOLDER:
|
||||
@ -310,9 +310,9 @@ UI::EventReturn MemStickScreen::SetFolderManually(UI::EventParams ¶ms) {
|
||||
auto di = GetI18NCategory(I18NCat::DIALOG);
|
||||
|
||||
std::string newPath = value;
|
||||
size_t pos = newPath.find_last_not_of("/");
|
||||
size_t pos = newPath.find_last_not_of('/');
|
||||
// Gotta have at least something but a /, and also needs to start with a /.
|
||||
if (newPath.empty() || pos == newPath.npos || newPath[0] != '/') {
|
||||
if (newPath.empty() || pos == std::string::npos || newPath[0] != '/') {
|
||||
settingInfo_->Show(sy->T("ChangingMemstickPathInvalid", "That path couldn't be used to save Memory Stick files."), nullptr);
|
||||
return;
|
||||
}
|
||||
@ -456,7 +456,7 @@ void MemStickScreen::update() {
|
||||
}
|
||||
}
|
||||
|
||||
ConfirmMemstickMoveScreen::ConfirmMemstickMoveScreen(Path newMemstickFolder, bool initialSetup)
|
||||
ConfirmMemstickMoveScreen::ConfirmMemstickMoveScreen(const Path &newMemstickFolder, bool initialSetup)
|
||||
: newMemstickFolder_(newMemstickFolder), initialSetup_(initialSetup), progressReporter_() {
|
||||
existingFilesInNewFolder_ = FolderSeemsToBeUsed(newMemstickFolder);
|
||||
if (initialSetup_) {
|
||||
|
@ -38,7 +38,7 @@ class NoticeView;
|
||||
class MemStickScreen : public UIDialogScreenWithBackground {
|
||||
public:
|
||||
MemStickScreen(bool initialSetup);
|
||||
~MemStickScreen() {}
|
||||
~MemStickScreen() = default;
|
||||
|
||||
const char *tag() const override { return "MemStick"; }
|
||||
|
||||
@ -95,7 +95,7 @@ private:
|
||||
|
||||
class ConfirmMemstickMoveScreen : public UIDialogScreenWithBackground {
|
||||
public:
|
||||
ConfirmMemstickMoveScreen(Path newMemstickFolder, bool initialSetup);
|
||||
ConfirmMemstickMoveScreen(const Path &newMemstickFolder, bool initialSetup);
|
||||
~ConfirmMemstickMoveScreen();
|
||||
|
||||
const char *tag() const override { return "ConfirmMemstickMove"; }
|
||||
|
@ -80,7 +80,7 @@ static Draw::Texture *bgTexture;
|
||||
|
||||
class Animation {
|
||||
public:
|
||||
virtual ~Animation() {}
|
||||
virtual ~Animation() = default;
|
||||
virtual void Draw(UIContext &dc, double t, float alpha, float x, float y, float z) = 0;
|
||||
};
|
||||
|
||||
@ -254,7 +254,7 @@ private:
|
||||
}
|
||||
}
|
||||
|
||||
std::shared_ptr<GameInfo> GetInfo(UIContext &dc, int index) {
|
||||
static std::shared_ptr<GameInfo> GetInfo(UIContext &dc, int index) {
|
||||
if (index < 0) {
|
||||
return nullptr;
|
||||
}
|
||||
@ -264,7 +264,7 @@ private:
|
||||
return g_gameInfoCache->GetInfo(dc.GetDrawContext(), Path(recentIsos[index]), GameInfoFlags::BG);
|
||||
}
|
||||
|
||||
void DrawTex(UIContext &dc, std::shared_ptr<GameInfo> &ginfo, float amount) {
|
||||
static void DrawTex(UIContext &dc, std::shared_ptr<GameInfo> &ginfo, float amount) {
|
||||
if (!ginfo || amount <= 0.0f)
|
||||
return;
|
||||
GameInfoTex *pic = ginfo->GetBGPic();
|
||||
@ -568,7 +568,7 @@ void TextureShaderScreen::CreateViews() {
|
||||
for (int i = 0; i < (int)shaders_.size(); i++) {
|
||||
if (shaders_[i].section == g_Config.sTextureShaderName)
|
||||
selected = i;
|
||||
items.push_back(std::string(ps->T(shaders_[i].section.c_str(), shaders_[i].name.c_str())));
|
||||
items.emplace_back(ps->T(shaders_[i].section, shaders_[i].name));
|
||||
}
|
||||
adaptor_ = UI::StringVectorListAdaptor(items, selected);
|
||||
|
||||
@ -611,7 +611,7 @@ NewLanguageScreen::NewLanguageScreen(std::string_view title) : ListPopupScreen(t
|
||||
}
|
||||
#endif
|
||||
|
||||
File::FileInfo lang = tempLangs[i];
|
||||
const File::FileInfo &lang = tempLangs[i];
|
||||
langs_.push_back(lang);
|
||||
|
||||
std::string code;
|
||||
@ -958,12 +958,12 @@ void CreditsScreen::DrawForeground(UIContext &dc) {
|
||||
"fp64",
|
||||
"",
|
||||
cr->T("specialthanks", "Special thanks to:"),
|
||||
specialthanksMaxim.c_str(),
|
||||
specialthanksKeithGalocy.c_str(),
|
||||
specialthanksOrphis.c_str(),
|
||||
specialthanksangelxwind.c_str(),
|
||||
specialthanksW_MS.c_str(),
|
||||
specialthankssolarmystic.c_str(),
|
||||
specialthanksMaxim,
|
||||
specialthanksKeithGalocy,
|
||||
specialthanksOrphis,
|
||||
specialthanksangelxwind,
|
||||
specialthanksW_MS,
|
||||
specialthankssolarmystic,
|
||||
cr->T("all the forum mods"),
|
||||
"",
|
||||
cr->T("this translation by", ""), // Empty string as this is the original :)
|
||||
|
@ -28,7 +28,7 @@
|
||||
// Background worker threads should be spawned in NativeInit and joined
|
||||
// in NativeShutdown.
|
||||
|
||||
#include <locale.h>
|
||||
#include <clocale>
|
||||
#include <algorithm>
|
||||
#include <cstdlib>
|
||||
#include <memory>
|
||||
@ -529,7 +529,7 @@ void NativeInit(int argc, const char *argv[], const char *savegame_dir, const ch
|
||||
|
||||
LogManager *logman = LogManager::GetInstance();
|
||||
|
||||
const char *fileToLog = 0;
|
||||
const char *fileToLog = nullptr;
|
||||
Path stateToLoad;
|
||||
|
||||
bool gotBootFilename = false;
|
||||
|
@ -70,13 +70,13 @@ static NoticeLevel GetNoticeLevel(OSDType type) {
|
||||
|
||||
// Align only matters here for the ASCII-only flag.
|
||||
static void MeasureNotice(const UIContext &dc, NoticeLevel level, const std::string &text, const std::string &details, const std::string &iconName, int align, float *width, float *height, float *height1) {
|
||||
dc.MeasureText(dc.theme->uiFont, 1.0f, 1.0f, text.c_str(), width, height, align);
|
||||
dc.MeasureText(dc.theme->uiFont, 1.0f, 1.0f, text, width, height, align);
|
||||
|
||||
*height1 = *height;
|
||||
|
||||
float width2 = 0.0f, height2 = 0.0f;
|
||||
if (!details.empty()) {
|
||||
dc.MeasureText(dc.theme->uiFont, extraTextScale, extraTextScale, details.c_str(), &width2, &height2, align);
|
||||
dc.MeasureText(dc.theme->uiFont, extraTextScale, extraTextScale, details, &width2, &height2, align);
|
||||
*width = std::max(*width, width2);
|
||||
*height += 5.0f + height2;
|
||||
}
|
||||
@ -157,7 +157,7 @@ static void RenderNotice(UIContext &dc, Bounds bounds, float height1, NoticeLeve
|
||||
bounds.x += iconW + 5.0f;
|
||||
bounds.w -= iconW + 5.0f;
|
||||
|
||||
dc.DrawTextShadowRect(text.c_str(), bounds.Inset(0.0f, 1.0f, 0.0f, 0.0f), foreGround, (align & FLAG_DYNAMIC_ASCII));
|
||||
dc.DrawTextShadowRect(text, bounds.Inset(0.0f, 1.0f, 0.0f, 0.0f), foreGround, (align & FLAG_DYNAMIC_ASCII));
|
||||
|
||||
if (!details.empty()) {
|
||||
Bounds bottomTextBounds = bounds.Inset(3.0f, height1 + 5.0f, 3.0f, 3.0f);
|
||||
@ -220,11 +220,11 @@ static void RenderOSDProgressBar(UIContext &dc, const OnScreenDisplay::Entry &en
|
||||
dc.SetFontStyle(dc.theme->uiFont);
|
||||
dc.SetFontScale(1.0f, 1.0f);
|
||||
|
||||
dc.DrawTextShadowRect(entry.text.c_str(), bounds, colorAlpha(0xFFFFFFFF, alpha), (align & FLAG_DYNAMIC_ASCII) | ALIGN_CENTER);
|
||||
dc.DrawTextShadowRect(entry.text, bounds, colorAlpha(0xFFFFFFFF, alpha), (align & FLAG_DYNAMIC_ASCII) | ALIGN_CENTER);
|
||||
}
|
||||
|
||||
static void MeasureLeaderboardTracker(UIContext &dc, const std::string &text, float *width, float *height) {
|
||||
dc.MeasureText(dc.GetFontStyle(), 1.0f, 1.0f, text.c_str(), width, height);
|
||||
dc.MeasureText(dc.GetFontStyle(), 1.0f, 1.0f, text, width, height);
|
||||
*width += 16.0f;
|
||||
*height += 10.0f;
|
||||
}
|
||||
@ -237,7 +237,7 @@ static void RenderLeaderboardTracker(UIContext &dc, const Bounds &bounds, const
|
||||
dc.FillRect(background, bounds);
|
||||
dc.SetFontStyle(dc.theme->uiFont);
|
||||
dc.SetFontScale(1.0f, 1.0f);
|
||||
dc.DrawTextShadowRect(text.c_str(), bounds.Inset(5.0f, 5.0f), colorAlpha(0xFFFFFFFF, alpha), ALIGN_VCENTER | ALIGN_HCENTER);
|
||||
dc.DrawTextShadowRect(text, bounds.Inset(5.0f, 5.0f), colorAlpha(0xFFFFFFFF, alpha), ALIGN_VCENTER | ALIGN_HCENTER);
|
||||
}
|
||||
|
||||
void OnScreenMessagesView::Draw(UIContext &dc) {
|
||||
@ -317,11 +317,11 @@ void OnScreenMessagesView::Draw(UIContext &dc) {
|
||||
measuredEntry.align2 = 0;
|
||||
// If we have newlines, we may be looking at ASCII debug output. But let's verify.
|
||||
if (entry.text.find('\n') != std::string::npos) {
|
||||
if (!UTF8StringHasNonASCII(entry.text.c_str()))
|
||||
if (!UTF8StringHasNonASCII(entry.text))
|
||||
measuredEntry.align |= FLAG_DYNAMIC_ASCII;
|
||||
}
|
||||
if (entry.text2.find('\n') != std::string::npos) {
|
||||
if (!UTF8StringHasNonASCII(entry.text2.c_str()))
|
||||
if (!UTF8StringHasNonASCII(entry.text2))
|
||||
measuredEntry.align2 |= FLAG_DYNAMIC_ASCII;
|
||||
}
|
||||
|
||||
|
@ -244,7 +244,7 @@ void RetroAchievementsLeaderboardScreen::update() {
|
||||
Poll();
|
||||
}
|
||||
|
||||
RetroAchievementsSettingsScreen::~RetroAchievementsSettingsScreen() {}
|
||||
RetroAchievementsSettingsScreen::~RetroAchievementsSettingsScreen() = default;
|
||||
|
||||
void RetroAchievementsSettingsScreen::CreateTabs() {
|
||||
auto ac = GetI18NCategory(I18NCat::ACHIEVEMENTS);
|
||||
@ -417,7 +417,7 @@ static void MeasureGameAchievementSummary(const UIContext &dc, float *w, float *
|
||||
float tw, th;
|
||||
dc.MeasureText(dc.theme->uiFont, 1.0f, 1.0f, "Wg", &tw, &th);
|
||||
|
||||
dc.MeasureText(dc.theme->uiFont, 0.66f, 0.66f, description.c_str(), w, h);
|
||||
dc.MeasureText(dc.theme->uiFont, 0.66f, 0.66f, description, w, h);
|
||||
*h += 8.0f + th;
|
||||
*w += 8.0f;
|
||||
}
|
||||
@ -654,7 +654,7 @@ static void RenderLeaderboardEntry(UIContext &dc, const rc_client_leaderboard_en
|
||||
dc.SetFontStyle(dc.theme->uiFont);
|
||||
|
||||
dc.SetFontScale(1.5f, 1.5f);
|
||||
dc.DrawTextRect(StringFromFormat("%d", entry->rank).c_str(), Bounds(bounds.x + 4.0f, bounds.y + 4.0f, numberSpace - 10.0f, bounds.h - 4.0f * 2.0f), fgColor, ALIGN_TOPRIGHT);
|
||||
dc.DrawTextRect(StringFromFormat("%d", entry->rank), Bounds(bounds.x + 4.0f, bounds.y + 4.0f, numberSpace - 10.0f, bounds.h - 4.0f * 2.0f), fgColor, ALIGN_TOPRIGHT);
|
||||
|
||||
dc.SetFontScale(1.0f, 1.0f);
|
||||
dc.DrawTextRect(entry->user, bounds.Inset(iconSpace + 5.0f, 2.0f, 5.0f, 5.0f), fgColor, ALIGN_TOPLEFT);
|
||||
@ -695,11 +695,11 @@ void AchievementView::Click() {
|
||||
type++;
|
||||
type = type % 5;
|
||||
switch (type) {
|
||||
case 0: g_OSD.ShowAchievementUnlocked(achievement_->id); break;
|
||||
case 1: g_OSD.ShowAchievementProgress(achievement_->id, true); break;
|
||||
case 2: g_OSD.ShowAchievementProgress(achievement_->id, false); break;
|
||||
case 3: g_OSD.ShowChallengeIndicator(achievement_->id, true); break;
|
||||
case 4: g_OSD.ShowChallengeIndicator(achievement_->id, false); break;
|
||||
case 0: g_OSD.ShowAchievementUnlocked((int)achievement_->id); break;
|
||||
case 1: g_OSD.ShowAchievementProgress((int)achievement_->id, true); break;
|
||||
case 2: g_OSD.ShowAchievementProgress((int)achievement_->id, false); break;
|
||||
case 3: g_OSD.ShowChallengeIndicator((int)achievement_->id, true); break;
|
||||
case 4: g_OSD.ShowChallengeIndicator((int)achievement_->id, false); break;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
@ -285,7 +285,7 @@ void SavedataButton::UpdateText(const std::shared_ptr<GameInfo> &ginfo) {
|
||||
if (subtitle_.empty() && ginfo->gameSizeOnDisk > 0) {
|
||||
std::string date = ginfo->GetMTime();
|
||||
std::string savedata_title = ginfo->GetParamSFO().GetValueString("SAVEDATA_TITLE");
|
||||
subtitle_ = CleanSaveString(savedata_title) + " (" + NiceSizeFormat(ginfo->gameSizeOnDisk) + ", " + date.c_str() + ")";
|
||||
subtitle_ = CleanSaveString(savedata_title) + " (" + NiceSizeFormat(ginfo->gameSizeOnDisk) + ", " + date + ")";
|
||||
}
|
||||
}
|
||||
|
||||
@ -375,7 +375,7 @@ void SavedataButton::Draw(UIContext &dc) {
|
||||
dc.PushScissor(bounds_);
|
||||
|
||||
UpdateText(ginfo);
|
||||
dc.MeasureText(dc.GetFontStyle(), 1.0f, 1.0f, title_.c_str(), &tw, &th, 0);
|
||||
dc.MeasureText(dc.GetFontStyle(), 1.0f, 1.0f, title_, &tw, &th, 0);
|
||||
|
||||
int availableWidth = bounds_.w - 150;
|
||||
float sineWidth = std::max(0.0f, (tw - availableWidth)) / 2.0f;
|
||||
@ -389,9 +389,9 @@ void SavedataButton::Draw(UIContext &dc) {
|
||||
tb.w = std::max(1.0f, bounds_.w - 150.0f);
|
||||
dc.PushScissor(tb);
|
||||
}
|
||||
dc.DrawText(title_.c_str(), bounds_.x + tx, bounds_.y + 4, style.fgColor, ALIGN_TOPLEFT);
|
||||
dc.DrawText(title_, bounds_.x + tx, bounds_.y + 4, style.fgColor, ALIGN_TOPLEFT);
|
||||
dc.SetFontScale(0.6f, 0.6f);
|
||||
dc.DrawText(subtitle_.c_str(), bounds_.x + tx, bounds_.y2() - 7, style.fgColor, ALIGN_BOTTOM);
|
||||
dc.DrawText(subtitle_, bounds_.x + tx, bounds_.y2() - 7, style.fgColor, ALIGN_BOTTOM);
|
||||
dc.SetFontScale(1.0f, 1.0f);
|
||||
|
||||
if (availableWidth < tw) {
|
||||
|
17
UI/Store.cpp
17
UI/Store.cpp
@ -268,10 +268,10 @@ private:
|
||||
UI::EventReturn OnCancel(UI::EventParams &e);
|
||||
UI::EventReturn OnLaunchClick(UI::EventParams &e);
|
||||
|
||||
bool IsGameInstalled() {
|
||||
bool IsGameInstalled() const {
|
||||
return g_GameManager.IsGameInstalled(entry_.file);
|
||||
}
|
||||
std::string DownloadURL();
|
||||
std::string DownloadURL() const;
|
||||
|
||||
StoreEntry entry_;
|
||||
UI::Button *uninstallButton_ = nullptr;
|
||||
@ -380,10 +380,10 @@ void ProductView::Update() {
|
||||
}
|
||||
if (launchButton_)
|
||||
launchButton_->SetEnabled(g_GameManager.GetState() == GameManagerState::IDLE);
|
||||
View::Update();
|
||||
ViewGroup::Update();
|
||||
}
|
||||
|
||||
std::string ProductView::DownloadURL() {
|
||||
std::string ProductView::DownloadURL() const {
|
||||
if (entry_.downloadURL.empty()) {
|
||||
// Construct the URL.
|
||||
return StoreBaseUrl() + "files/" + entry_.file + ".zip";
|
||||
@ -446,7 +446,7 @@ void StoreScreen::update() {
|
||||
|
||||
g_DownloadManager.Update();
|
||||
|
||||
if (listing_.get() != 0 && listing_->Done()) {
|
||||
if (listing_.get() && listing_->Done()) {
|
||||
resultCode_ = listing_->ResultCode();
|
||||
if (listing_->ResultCode() == 200) {
|
||||
std::string listingJson;
|
||||
@ -573,7 +573,10 @@ void StoreScreen::CreateViews() {
|
||||
|
||||
ProductItemView *StoreScreen::GetSelectedItem() {
|
||||
for (int i = 0; i < scrollItemView_->GetNumSubviews(); ++i) {
|
||||
ProductItemView *item = static_cast<ProductItemView *>(scrollItemView_->GetViewByIndex(i));
|
||||
ProductItemView *item = dynamic_cast<ProductItemView *>(scrollItemView_->GetViewByIndex(i));
|
||||
if (!item) {
|
||||
continue;
|
||||
}
|
||||
if (item->GetEntry().name == lastSelectedName_)
|
||||
return item;
|
||||
}
|
||||
@ -582,7 +585,7 @@ ProductItemView *StoreScreen::GetSelectedItem() {
|
||||
}
|
||||
|
||||
UI::EventReturn StoreScreen::OnGameSelected(UI::EventParams &e) {
|
||||
ProductItemView *item = static_cast<ProductItemView *>(e.v);
|
||||
ProductItemView *item = dynamic_cast<ProductItemView *>(e.v);
|
||||
if (!item)
|
||||
return UI::EVENT_DONE;
|
||||
|
||||
|
@ -390,7 +390,7 @@ static void EmuThreadJoin() {
|
||||
|
||||
static void PushCommand(std::string cmd, std::string param) {
|
||||
std::lock_guard<std::mutex> guard(frameCommandLock);
|
||||
frameCommands.push(FrameCommand(cmd, param));
|
||||
frameCommands.push(FrameCommand(std::move(cmd), std::move(param)));
|
||||
}
|
||||
|
||||
// Android implementation of callbacks to the Java part of the app
|
||||
@ -440,7 +440,7 @@ std::vector<std::string> System_GetPropertyStringVec(SystemProperty prop) {
|
||||
|
||||
case SYSPROP_TEMP_DIRS:
|
||||
default:
|
||||
return std::vector<std::string>();
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
||||
@ -576,7 +576,7 @@ std::string Android_GetInputDeviceDebugString() {
|
||||
return "(N/A)";
|
||||
}
|
||||
|
||||
const char *charArray = env->GetStringUTFChars(jstr, 0);
|
||||
const char *charArray = env->GetStringUTFChars(jstr, nullptr);
|
||||
std::string retVal = charArray;
|
||||
env->ReleaseStringUTFChars(jstr, charArray);
|
||||
env->DeleteLocalRef(jstr);
|
||||
@ -587,7 +587,7 @@ std::string Android_GetInputDeviceDebugString() {
|
||||
std::string GetJavaString(JNIEnv *env, jstring jstr) {
|
||||
if (!jstr)
|
||||
return "";
|
||||
const char *str = env->GetStringUTFChars(jstr, 0);
|
||||
const char *str = env->GetStringUTFChars(jstr, nullptr);
|
||||
std::string cpp_string = std::string(str);
|
||||
env->ReleaseStringUTFChars(jstr, str);
|
||||
return cpp_string;
|
||||
@ -632,16 +632,16 @@ extern "C" void Java_org_ppsspp_ppsspp_NativeApp_audioConfig
|
||||
|
||||
// Easy way for the Java side to ask the C++ side for configuration options, such as
|
||||
// the rotation lock which must be controlled from Java on Android.
|
||||
static std::string QueryConfig(std::string query) {
|
||||
static std::string QueryConfig(std::string_view query) {
|
||||
char temp[128];
|
||||
if (query == "screenRotation") {
|
||||
INFO_LOG(Log::G3D, "g_Config.screenRotation = %d", g_Config.iScreenRotation);
|
||||
snprintf(temp, sizeof(temp), "%d", g_Config.iScreenRotation);
|
||||
return std::string(temp);
|
||||
return temp;
|
||||
} else if (query == "immersiveMode") {
|
||||
return std::string(g_Config.bImmersiveMode ? "1" : "0");
|
||||
return g_Config.bImmersiveMode ? "1" : "0";
|
||||
} else if (query == "sustainedPerformanceMode") {
|
||||
return std::string(g_Config.bSustainedPerformanceMode ? "1" : "0");
|
||||
return g_Config.bSustainedPerformanceMode ? "1" : "0";
|
||||
} else if (query == "androidJavaGL") {
|
||||
// If we're using Vulkan, we say no... need C++ to use Vulkan.
|
||||
if (GetGPUBackend() == GPUBackend::VULKAN) {
|
||||
@ -766,7 +766,7 @@ extern "C" void Java_org_ppsspp_ppsspp_NativeApp_init
|
||||
}
|
||||
|
||||
std::string user_data_path = GetJavaString(env, jdataDir);
|
||||
if (user_data_path.size() > 0)
|
||||
if (!user_data_path.empty())
|
||||
user_data_path += "/";
|
||||
std::string shortcut_param = GetJavaString(env, jshortcutParam);
|
||||
std::string cacheDir = GetJavaString(env, jcacheDir);
|
||||
@ -994,7 +994,6 @@ extern "C" jboolean Java_org_ppsspp_ppsspp_NativeRenderer_displayInit(JNIEnv * e
|
||||
INFO_LOG(Log::G3D, "BeginAndroidShutdown. Looping until emu thread done...");
|
||||
// Skipping GL calls here because the old context is lost.
|
||||
while (graphicsContext->ThreadFrame()) {
|
||||
continue;
|
||||
}
|
||||
INFO_LOG(Log::G3D, "Joining emu thread");
|
||||
EmuThreadJoin();
|
||||
@ -1042,9 +1041,9 @@ extern "C" jboolean Java_org_ppsspp_ppsspp_NativeRenderer_displayInit(JNIEnv * e
|
||||
}
|
||||
|
||||
static void recalculateDpi() {
|
||||
g_display.dpi = display_dpi_x;
|
||||
g_display.dpi_scale_x = 240.0f / display_dpi_x;
|
||||
g_display.dpi_scale_y = 240.0f / display_dpi_y;
|
||||
g_display.dpi = (float)display_dpi_x;
|
||||
g_display.dpi_scale_x = 240.0f / (float)display_dpi_x;
|
||||
g_display.dpi_scale_y = 240.0f / (float)display_dpi_y;
|
||||
g_display.dpi_scale_real_x = g_display.dpi_scale_x;
|
||||
g_display.dpi_scale_real_y = g_display.dpi_scale_y;
|
||||
|
||||
@ -1122,7 +1121,7 @@ bool System_MakeRequest(SystemRequestType type, int requestId, const std::string
|
||||
case SystemRequestType::INPUT_TEXT_MODAL:
|
||||
{
|
||||
std::string serialized = StringFromFormat("%d:@:%s:@:%s", requestId, param1.c_str(), param2.c_str());
|
||||
PushCommand("inputbox", serialized.c_str());
|
||||
PushCommand("inputbox", serialized);
|
||||
return true;
|
||||
}
|
||||
case SystemRequestType::BROWSE_FOR_IMAGE:
|
||||
@ -1229,7 +1228,7 @@ extern "C" void JNICALL Java_org_ppsspp_ppsspp_NativeApp_touch
|
||||
(JNIEnv *, jclass, float x, float y, int code, int pointerId) {
|
||||
if (!renderer_inited)
|
||||
return;
|
||||
TouchInput touch;
|
||||
TouchInput touch{};
|
||||
touch.id = pointerId;
|
||||
touch.x = x * g_display.dpi_scale_x;
|
||||
touch.y = y * g_display.dpi_scale_y;
|
||||
@ -1280,8 +1279,8 @@ extern "C" void Java_org_ppsspp_ppsspp_NativeApp_joystickAxis(
|
||||
AxisInput *axis = new AxisInput[count];
|
||||
_dbg_assert_(count <= env->GetArrayLength(axisIds));
|
||||
_dbg_assert_(count <= env->GetArrayLength(values));
|
||||
jint *axisIdBuffer = env->GetIntArrayElements(axisIds, NULL);
|
||||
jfloat *valueBuffer = env->GetFloatArrayElements(values, NULL);
|
||||
jint *axisIdBuffer = env->GetIntArrayElements(axisIds, nullptr);
|
||||
jfloat *valueBuffer = env->GetFloatArrayElements(values, nullptr);
|
||||
|
||||
// These are dirty-filtered on the Java side.
|
||||
for (int i = 0; i < count; i++) {
|
||||
@ -1508,7 +1507,7 @@ std::vector<std::string> System_GetCameraDeviceList() {
|
||||
getEnv()->DeleteLocalRef(dev);
|
||||
continue;
|
||||
}
|
||||
deviceListVector.push_back(std::string(cdev));
|
||||
deviceListVector.emplace_back(cdev);
|
||||
getEnv()->ReleaseStringUTFChars(dev, cdev);
|
||||
getEnv()->DeleteLocalRef(dev);
|
||||
}
|
||||
@ -1532,9 +1531,9 @@ extern "C" void JNICALL Java_org_ppsspp_ppsspp_NativeApp_setSatInfoAndroid(JNIEn
|
||||
}
|
||||
|
||||
extern "C" void JNICALL Java_org_ppsspp_ppsspp_NativeApp_pushCameraImageAndroid(JNIEnv *env, jclass, jbyteArray image) {
|
||||
if (image != NULL) {
|
||||
if (image) {
|
||||
jlong size = env->GetArrayLength(image);
|
||||
jbyte* buffer = env->GetByteArrayElements(image, NULL);
|
||||
jbyte* buffer = env->GetByteArrayElements(image, nullptr);
|
||||
Camera::pushCameraImage(size, (unsigned char *)buffer);
|
||||
env->ReleaseByteArrayElements(image, buffer, JNI_ABORT);
|
||||
}
|
||||
@ -1693,7 +1692,7 @@ extern "C" jstring Java_org_ppsspp_ppsspp_ShortcutActivity_queryGameName(JNIEnv
|
||||
|
||||
INFO_LOG(Log::System, "queryGameName(%s)", path.c_str());
|
||||
|
||||
std::string result = "";
|
||||
std::string result;
|
||||
|
||||
GameInfoCache *cache = new GameInfoCache();
|
||||
std::shared_ptr<GameInfo> info = cache->GetInfo(nullptr, path, GameInfoFlags::PARAM_SFO);
|
||||
@ -1765,8 +1764,8 @@ Java_org_ppsspp_ppsspp_ShortcutActivity_queryGameIcon(JNIEnv * env, jclass clazz
|
||||
if (info->Ready(GameInfoFlags::ICON)) {
|
||||
if (!info->icon.data.empty()) {
|
||||
INFO_LOG(Log::System, "requestIcon: Got icon");
|
||||
result = env->NewByteArray(info->icon.data.size());
|
||||
env->SetByteArrayRegion(result, 0, info->icon.data.size(), (const jbyte *)info->icon.data.data());
|
||||
result = env->NewByteArray((jsize)info->icon.data.size());
|
||||
env->SetByteArrayRegion(result, 0, (jsize)info->icon.data.size(), (const jbyte *)info->icon.data.data());
|
||||
}
|
||||
} else {
|
||||
INFO_LOG(Log::System, "requestIcon: Filetype unknown");
|
||||
|
@ -28,6 +28,8 @@ import android.os.Environment;
|
||||
import android.os.PowerManager;
|
||||
import android.os.Vibrator;
|
||||
import android.provider.MediaStore;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.documentfile.provider.DocumentFile;
|
||||
import android.text.InputType;
|
||||
import android.util.Log;
|
||||
@ -92,7 +94,6 @@ public abstract class NativeActivity extends Activity {
|
||||
// audioFocusChangeListener to listen to changes in audio state
|
||||
private AudioFocusChangeListener audioFocusChangeListener;
|
||||
private AudioManager audioManager;
|
||||
private PowerManager powerManager;
|
||||
|
||||
private Vibrator vibrator;
|
||||
|
||||
@ -213,7 +214,7 @@ public abstract class NativeActivity extends Activity {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRequestPermissionsResult(int requestCode, String [] permissions, int[] grantResults) {
|
||||
public void onRequestPermissionsResult(int requestCode, @NonNull String [] permissions, @NonNull int[] grantResults) {
|
||||
switch (requestCode) {
|
||||
case REQUEST_CODE_STORAGE_PERMISSION:
|
||||
if (permissionsGranted(permissions, grantResults)) {
|
||||
@ -259,7 +260,7 @@ public abstract class NativeActivity extends Activity {
|
||||
// Try another method.
|
||||
String removableStoragePath;
|
||||
list = new ArrayList<String>();
|
||||
File fileList[] = new File("/storage/").listFiles();
|
||||
File[] fileList = new File("/storage/").listFiles();
|
||||
if (fileList != null) {
|
||||
for (File file : fileList) {
|
||||
if (!file.getAbsolutePath().equalsIgnoreCase(Environment.getExternalStorageDirectory().getAbsolutePath()) && file.isDirectory() && file.canRead()) {
|
||||
@ -357,7 +358,7 @@ public abstract class NativeActivity extends Activity {
|
||||
// Get the optimal buffer sz
|
||||
detectOptimalAudioSettings();
|
||||
}
|
||||
powerManager = (PowerManager) getSystemService(Context.POWER_SERVICE);
|
||||
PowerManager powerManager = (PowerManager) getSystemService(Context.POWER_SERVICE);
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
||||
if (powerManager != null && powerManager.isSustainedPerformanceModeSupported()) {
|
||||
sustainedPerfSupported = true;
|
||||
@ -427,7 +428,7 @@ public abstract class NativeActivity extends Activity {
|
||||
}
|
||||
catch (Exception e) {
|
||||
NativeApp.reportException(e, null);
|
||||
Log.e(TAG, "Failed to get SD storage dirs: " + e.toString());
|
||||
Log.e(TAG, "Failed to get SD storage dirs: " + e);
|
||||
}
|
||||
|
||||
Log.i(TAG, "End of storage paths");
|
||||
@ -708,7 +709,7 @@ public abstract class NativeActivity extends Activity {
|
||||
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, "Failed to set framerate: " + e.toString());
|
||||
Log.e(TAG, "Failed to set framerate: " + e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -918,7 +919,7 @@ public abstract class NativeActivity extends Activity {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onConfigurationChanged(Configuration newConfig) {
|
||||
public void onConfigurationChanged(@NonNull Configuration newConfig) {
|
||||
Log.i(TAG, "onConfigurationChanged");
|
||||
super.onConfigurationChanged(newConfig);
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
|
||||
@ -1228,12 +1229,12 @@ public abstract class NativeActivity extends Activity {
|
||||
getContentResolver().takePersistableUriPermission(selectedFile, Intent.FLAG_GRANT_READ_URI_PERMISSION);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Log.w(TAG, "Exception getting permissions for document: " + e.toString());
|
||||
Log.w(TAG, "Exception getting permissions for document: " + e);
|
||||
NativeApp.sendRequestResult(requestId, false, "", 0);
|
||||
NativeApp.reportException(e, selectedFile.toString());
|
||||
return;
|
||||
}
|
||||
Log.i(TAG, "Browse file finished:" + selectedFile.toString());
|
||||
Log.i(TAG, "Browse file finished:" + selectedFile);
|
||||
NativeApp.sendRequestResult(requestId, true, selectedFile.toString(), 0);
|
||||
}
|
||||
} else if (requestCode == RESULT_OPEN_DOCUMENT_TREE) {
|
||||
@ -1246,7 +1247,7 @@ public abstract class NativeActivity extends Activity {
|
||||
getContentResolver().takePersistableUriPermission(selectedDirectoryUri, Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Log.w(TAG, "Exception getting permissions for document: " + e.toString());
|
||||
Log.w(TAG, "Exception getting permissions for document: " + e);
|
||||
NativeApp.reportException(e, selectedDirectoryUri.toString());
|
||||
// Even if we got an exception getting permissions, continue and try to pass along the file. Maybe this version of Android
|
||||
// doesn't need it. If we can't access it, we'll fail in some other way later.
|
||||
@ -1520,7 +1521,7 @@ public abstract class NativeActivity extends Activity {
|
||||
return true;
|
||||
} else if (command.equals("vibrate")) {
|
||||
int milliseconds = -1;
|
||||
if (!params.equals("")) {
|
||||
if (!params.isEmpty()) {
|
||||
try {
|
||||
milliseconds = Integer.parseInt(params);
|
||||
} catch (NumberFormatException e) {
|
||||
@ -1576,7 +1577,7 @@ public abstract class NativeActivity extends Activity {
|
||||
recreate();
|
||||
} else if (command.equals("graphics_restart")) {
|
||||
Log.i(TAG, "graphics_restart");
|
||||
if (params != null && !params.equals("")) {
|
||||
if (params != null && !params.isEmpty()) {
|
||||
overrideShortcutParam = params;
|
||||
}
|
||||
shuttingDown = true;
|
||||
|
@ -207,19 +207,21 @@ public class PpssppActivity extends NativeActivity {
|
||||
// to handle more than one...
|
||||
ArrayList<Uri> childDirs = new ArrayList<>();
|
||||
|
||||
while (c.moveToNext()) {
|
||||
final String mimeType = c.getString(2);
|
||||
final boolean isDirectory = mimeType.equals(DocumentsContract.Document.MIME_TYPE_DIR);
|
||||
if (isDirectory) {
|
||||
final String childDocumentId = c.getString(0);
|
||||
final Uri childUri = DocumentsContract.buildDocumentUriUsingTree(uri, childDocumentId);
|
||||
childDirs.add(childUri);
|
||||
} else {
|
||||
final long fileSize = c.getLong(1);
|
||||
sizeSum += fileSize;
|
||||
if (c != null) {
|
||||
while (c.moveToNext()) {
|
||||
final String mimeType = c.getString(2);
|
||||
final boolean isDirectory = mimeType.equals(DocumentsContract.Document.MIME_TYPE_DIR);
|
||||
if (isDirectory) {
|
||||
final String childDocumentId = c.getString(0);
|
||||
final Uri childUri = DocumentsContract.buildDocumentUriUsingTree(uri, childDocumentId);
|
||||
childDirs.add(childUri);
|
||||
} else {
|
||||
final long fileSize = c.getLong(1);
|
||||
sizeSum += fileSize;
|
||||
}
|
||||
}
|
||||
c.close();
|
||||
}
|
||||
c.close();
|
||||
c = null;
|
||||
|
||||
for (Uri childUri : childDirs) {
|
||||
|
Loading…
Reference in New Issue
Block a user