mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-04-20 03:25:16 +00:00
rMsgBox eliminated
This commit is contained in:
parent
a666318b95
commit
4b7f9c38a6
12 changed files with 70 additions and 139 deletions
|
@ -1,11 +1,13 @@
|
|||
#include "stdafx.h"
|
||||
#include "rPlatform.h"
|
||||
#include "Log.h"
|
||||
#include "rMsgBox.h"
|
||||
#include <iostream>
|
||||
#include <cinttypes>
|
||||
#include "Thread.h"
|
||||
#include "File.h"
|
||||
#include "Log.h"
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <Windows.h>
|
||||
#endif
|
||||
|
||||
using namespace Log;
|
||||
|
||||
|
@ -93,13 +95,17 @@ struct FileListener : LogListener
|
|||
fs::file mFile;
|
||||
bool mPrependChannelName;
|
||||
|
||||
FileListener(const std::string& name = _PRGNAME_, bool prependChannel = true)
|
||||
: mFile(fs::get_config_dir() + name + ".log", fom::rewrite)
|
||||
FileListener(const std::string& name = _PRGNAME_ ".log", bool prependChannel = true)
|
||||
: mFile(fs::get_config_dir() + name, fom::rewrite)
|
||||
, mPrependChannelName(prependChannel)
|
||||
{
|
||||
if (!mFile)
|
||||
{
|
||||
rMessageBox("Can't create log file! (" + name + ".log)", "Error", rICON_ERROR);
|
||||
#ifdef _WIN32
|
||||
MessageBoxA(0, ("Can't create log file: " + name).c_str(), "Error", MB_ICONERROR);
|
||||
#else
|
||||
std::printf("Can't create log file: %s\n", name.c_str());
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -137,7 +143,7 @@ LogManager::LogManager()
|
|||
it->addListener(listener);
|
||||
it++;
|
||||
}
|
||||
std::shared_ptr<LogListener> TTYListener(new FileListener("TTY",false));
|
||||
std::shared_ptr<LogListener> TTYListener(new FileListener("TTY.log", false));
|
||||
getChannel(TTY).addListener(TTYListener);
|
||||
#ifdef BUFFERED_LOGGING
|
||||
mLogConsumer = std::thread(&LogManager::consumeLog, this);
|
||||
|
@ -257,20 +263,23 @@ void log_message(Log::LogType type, Log::Severity sev, std::string text)
|
|||
{
|
||||
if (g_log_manager)
|
||||
{
|
||||
// another msvc bug makes this not work, uncomment this when it's fixed
|
||||
//g_log_manager->log({logType, severity, text});
|
||||
Log::LogMessage msg{ type, sev, std::move(text) };
|
||||
g_log_manager->log(msg);
|
||||
g_log_manager->log({ type, sev, std::move(text) });
|
||||
}
|
||||
else
|
||||
{
|
||||
rMessageBox(text,
|
||||
const auto severity =
|
||||
sev == Severity::Notice ? "Notice" :
|
||||
sev == Severity::Warning ? "Warning" :
|
||||
sev == Severity::Success ? "Success" :
|
||||
sev == Severity::Error ? "Error" : "Unknown",
|
||||
sev == Severity::Notice ? rICON_INFORMATION :
|
||||
sev == Severity::Warning ? rICON_EXCLAMATION :
|
||||
sev == Severity::Error ? rICON_ERROR : rICON_INFORMATION);
|
||||
sev == Severity::Error ? "Error" : "Unknown";
|
||||
|
||||
#ifdef _WIN32
|
||||
MessageBoxA(0, text.c_str(), severity,
|
||||
sev == Severity::Notice ? MB_ICONINFORMATION :
|
||||
sev == Severity::Warning ? MB_ICONEXCLAMATION :
|
||||
sev == Severity::Error ? MB_ICONERROR : MB_ICONINFORMATION);
|
||||
#else
|
||||
std::printf("[Log:%s] %s\n", severity, text.c_str());
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,38 +0,0 @@
|
|||
#include "stdafx.h"
|
||||
#include "restore_new.h"
|
||||
#pragma warning(push)
|
||||
#pragma message("TODO: remove wx dependency: <wx/msgdlg.h>")
|
||||
#pragma warning(disable : 4996)
|
||||
#include <wx/msgdlg.h>
|
||||
#pragma warning(pop)
|
||||
#include "define_new_memleakdetect.h"
|
||||
#include "rMsgBox.h"
|
||||
|
||||
#ifndef QT_UI
|
||||
rMessageDialog::rMessageDialog(void *parent, const std::string& msg, const std::string& title , long style )
|
||||
{
|
||||
handle = reinterpret_cast<void*>(new wxMessageDialog(
|
||||
reinterpret_cast<wxWindow*>(parent)
|
||||
, fmt::FromUTF8(msg)
|
||||
, fmt::FromUTF8(title)
|
||||
, style
|
||||
));
|
||||
}
|
||||
|
||||
rMessageDialog::~rMessageDialog()
|
||||
{
|
||||
delete reinterpret_cast<wxMessageDialog*>(handle);
|
||||
}
|
||||
|
||||
long rMessageDialog::ShowModal()
|
||||
{
|
||||
return reinterpret_cast<wxMessageDialog*>(handle)->ShowModal();
|
||||
}
|
||||
|
||||
long rMessageBox(const std::string& message, const std::string& title, long style)
|
||||
{
|
||||
return wxMessageBox(fmt::FromUTF8(message), fmt::FromUTF8(title),style);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
@ -1,38 +0,0 @@
|
|||
#pragma once
|
||||
|
||||
enum MsgBoxParams : unsigned long
|
||||
{
|
||||
rYES_DEFAULT = 0x0,
|
||||
rOK_DEFAULT = 0x0,
|
||||
rCENTRE = 0x1,
|
||||
rYES = 0x2, //res
|
||||
rOK = 0x4,
|
||||
rNO = 0x8, //res
|
||||
rCANCEL = 0x10,
|
||||
rYES_NO = 0xA,
|
||||
rNO_DEFAULT = 0x80,
|
||||
rICON_EXCLAMATION = 0x100,
|
||||
rICON_ERROR = 0x200,
|
||||
rICON_HAND = 0x200,
|
||||
rICON_QUESTION = 0x400,
|
||||
rICON_INFORMATION = 0x800,
|
||||
rHELP = 0x1000,
|
||||
rID_CANCEL = 0x13ED,
|
||||
rID_YES = 0x13EF, //resDialog
|
||||
rSTAY_ON_TOP = 0x8000,
|
||||
rICON_NONE = 0x40000,
|
||||
rICON_AUTH_NEEDED = 0x80000,
|
||||
rCANCEL_DEFAULT = 0x80000000,
|
||||
};
|
||||
|
||||
struct rMessageDialog
|
||||
{
|
||||
rMessageDialog(void *parent, const std::string& msg, const std::string& title = "RPCS3", long style = rOK | rCENTRE);
|
||||
rMessageDialog(const rMessageDialog& other) = delete;
|
||||
~rMessageDialog();
|
||||
long ShowModal();
|
||||
void *handle;
|
||||
};
|
||||
|
||||
long rMessageBox(const std::string& message, const std::string& title,long style);
|
||||
|
|
@ -335,10 +335,9 @@ namespace fxm
|
|||
if (pair.second)
|
||||
{
|
||||
id_aux_initialize(pair.second.get());
|
||||
return std::move(pair.second);
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
return std::move(pair.second);
|
||||
}
|
||||
|
||||
// Create the object unconditionally (old object will be removed if it exists)
|
||||
|
@ -356,30 +355,29 @@ namespace fxm
|
|||
return std::move(pair.second);
|
||||
}
|
||||
|
||||
// Emplace the object
|
||||
template<typename T>
|
||||
bool import(const std::shared_ptr<T>& ptr)
|
||||
// Emplace the object returned by provider() and return it if no object exists
|
||||
template<typename T, typename F>
|
||||
auto import(F&& provider) -> decltype(static_cast<std::shared_ptr<T>>(provider()))
|
||||
{
|
||||
static const auto size = sizeof(T); // forbid forward declarations
|
||||
|
||||
auto pair = add<T, false>(WRAP_EXPR(ptr));
|
||||
auto pair = add<T, false>(std::forward<F>(provider));
|
||||
|
||||
if (pair.second)
|
||||
{
|
||||
id_aux_initialize(pair.second.get());
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
return std::move(pair.second);
|
||||
}
|
||||
|
||||
// Emplace the object unconditionally (old object will be removed if it exists)
|
||||
template<typename T>
|
||||
void import_always(const std::shared_ptr<T>& ptr)
|
||||
// Emplace the object return by provider() (old object will be removed if it exists)
|
||||
template<typename T, typename F>
|
||||
auto import_always(F&& provider) -> decltype(static_cast<std::shared_ptr<T>>(provider()))
|
||||
{
|
||||
static const auto size = sizeof(T); // forbid forward declarations
|
||||
|
||||
auto pair = add<T, true>(WRAP_EXPR(ptr));
|
||||
auto pair = add<T, true>(std::forward<F>(provider));
|
||||
|
||||
if (pair.first)
|
||||
{
|
||||
|
@ -387,6 +385,7 @@ namespace fxm
|
|||
}
|
||||
|
||||
id_aux_initialize(pair.second.get());
|
||||
return std::move(pair.second);
|
||||
}
|
||||
|
||||
// Get the object unconditionally (create an object if it doesn't exist)
|
||||
|
|
|
@ -4,18 +4,15 @@
|
|||
#include "Emu/IdManager.h"
|
||||
#include "Emu/SysCalls/Modules.h"
|
||||
|
||||
#include "Utilities/rMsgBox.h"
|
||||
#include "Emu/FS/VFS.h"
|
||||
#include "Emu/FS/vfsFile.h"
|
||||
#include "Loader/PSF.h"
|
||||
#include "cellSysutil.h"
|
||||
#include "cellMsgDialog.h"
|
||||
#include "cellGame.h"
|
||||
|
||||
extern Module<> cellGame;
|
||||
|
||||
// Specified as second content_permission_t constructor argument to inform temporary directory
|
||||
static struct temporary_content_dir_tag_t{} const temporary_content_dir_tag{};
|
||||
|
||||
// Normal content directory (if is_temporary is not involved):
|
||||
// contentInfo = dir
|
||||
// usrdir = dir + "/USRDIR"
|
||||
|
@ -33,14 +30,9 @@ struct content_permission_t final
|
|||
// true if temporary directory is created and must be moved or deleted
|
||||
bool is_temporary = false;
|
||||
|
||||
content_permission_t(const std::string& dir)
|
||||
content_permission_t(const std::string& dir, bool is_temp)
|
||||
: dir(dir)
|
||||
{
|
||||
}
|
||||
|
||||
content_permission_t(const std::string& dir, const temporary_content_dir_tag_t&)
|
||||
: dir(dir)
|
||||
, is_temporary(true)
|
||||
, is_temporary(is_temp)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -191,7 +183,7 @@ s32 cellGameBootCheck(vm::ptr<u32> type, vm::ptr<u32> attributes, vm::ptr<CellGa
|
|||
*attributes = 0; // TODO
|
||||
if (dirName) strcpy_trunc(*dirName, ""); // ???
|
||||
|
||||
if (!fxm::make<content_permission_t>("/dev_bdvd/PS3_GAME"))
|
||||
if (!fxm::make<content_permission_t>("/dev_bdvd/PS3_GAME", false))
|
||||
{
|
||||
return CELL_GAME_ERROR_BUSY;
|
||||
}
|
||||
|
@ -203,7 +195,7 @@ s32 cellGameBootCheck(vm::ptr<u32> type, vm::ptr<u32> attributes, vm::ptr<CellGa
|
|||
*attributes = 0; // TODO
|
||||
if (dirName) strcpy_trunc(*dirName, titleId);
|
||||
|
||||
if (!fxm::make<content_permission_t>("/dev_hdd0/game/" + titleId))
|
||||
if (!fxm::make<content_permission_t>("/dev_hdd0/game/" + titleId, false))
|
||||
{
|
||||
return CELL_GAME_ERROR_BUSY;
|
||||
}
|
||||
|
@ -215,7 +207,7 @@ s32 cellGameBootCheck(vm::ptr<u32> type, vm::ptr<u32> attributes, vm::ptr<CellGa
|
|||
*attributes = CELL_GAME_ATTRIBUTE_PATCH; // TODO
|
||||
if (dirName) strcpy_trunc(*dirName, titleId); // ???
|
||||
|
||||
if (!fxm::make<content_permission_t>("/dev_bdvd/PS3_GAME"))
|
||||
if (!fxm::make<content_permission_t>("/dev_bdvd/PS3_GAME", false))
|
||||
{
|
||||
return CELL_GAME_ERROR_BUSY;
|
||||
}
|
||||
|
@ -257,7 +249,7 @@ s32 cellGamePatchCheck(vm::ptr<CellGameContentSize> size, vm::ptr<void> reserved
|
|||
return CELL_GAME_ERROR_NOTPATCH;
|
||||
}
|
||||
|
||||
if (!fxm::make<content_permission_t>("/dev_hdd0/game/" + psf.GetString("TITLE_ID")))
|
||||
if (!fxm::make<content_permission_t>("/dev_hdd0/game/" + psf.GetString("TITLE_ID"), false))
|
||||
{
|
||||
return CELL_GAME_ERROR_BUSY;
|
||||
}
|
||||
|
@ -295,7 +287,7 @@ s32 cellGameDataCheck(u32 type, vm::cptr<char> dirName, vm::ptr<CellGameContentS
|
|||
return CELL_GAME_RET_NONE;
|
||||
}
|
||||
|
||||
if (!fxm::make<content_permission_t>("/dev_bdvd/PS3_GAME"))
|
||||
if (!fxm::make<content_permission_t>("/dev_bdvd/PS3_GAME", false))
|
||||
{
|
||||
return CELL_GAME_ERROR_BUSY;
|
||||
}
|
||||
|
@ -310,7 +302,7 @@ s32 cellGameDataCheck(u32 type, vm::cptr<char> dirName, vm::ptr<CellGameContentS
|
|||
return CELL_GAME_RET_NONE;
|
||||
}
|
||||
|
||||
if (!fxm::make<content_permission_t>(dir))
|
||||
if (!fxm::make<content_permission_t>(dir, false))
|
||||
{
|
||||
return CELL_GAME_ERROR_BUSY;
|
||||
}
|
||||
|
@ -487,7 +479,7 @@ s32 cellGameCreateGameData(vm::ptr<CellGameSetInitParams> init, vm::ptr<char[CEL
|
|||
return CELL_GAME_ERROR_ACCESS_ERROR; // ???
|
||||
}
|
||||
|
||||
if (!fxm::make<content_permission_t>(dir, temporary_content_dir_tag))
|
||||
if (!fxm::make<content_permission_t>(dir, true))
|
||||
{
|
||||
return CELL_GAME_ERROR_BUSY;
|
||||
}
|
||||
|
@ -639,7 +631,23 @@ s32 cellGameContentErrorDialog(s32 type, s32 errNeedSizeKB, vm::cptr<char> dirNa
|
|||
errorMsg += fmt::format("\nDirectory name: %s", dirName.get_ptr());
|
||||
}
|
||||
|
||||
rMessageBox(errorMsg, "Error", rICON_ERROR | rOK);
|
||||
const auto dlg = Emu.GetCallbacks().get_msg_dialog();
|
||||
|
||||
dlg->type.bg_invisible = true;
|
||||
dlg->type.button_type = 2; // OK
|
||||
dlg->type.disable_cancel = true;
|
||||
|
||||
const auto p = std::make_shared<std::promise<void>>();
|
||||
std::future<void> future = p->get_future();
|
||||
|
||||
dlg->on_close = [=](s32 status)
|
||||
{
|
||||
p->set_value();
|
||||
};
|
||||
|
||||
dlg->Create(errorMsg);
|
||||
|
||||
future.get();
|
||||
|
||||
return CELL_OK;
|
||||
}
|
||||
|
|
|
@ -61,9 +61,9 @@ s32 cellMsgDialogOpen2(u32 type, vm::cptr<char> msgString, vm::ptr<CellMsgDialog
|
|||
default: return CELL_MSGDIALOG_ERROR_PARAM;
|
||||
}
|
||||
|
||||
const std::shared_ptr<MsgDialogBase> dlg(Emu.GetCallbacks().get_msg_dialog());
|
||||
const auto dlg = fxm::import<MsgDialogBase>(WRAP_EXPR(Emu.GetCallbacks().get_msg_dialog()));
|
||||
|
||||
if (!fxm::import(dlg))
|
||||
if (!dlg)
|
||||
{
|
||||
return CELL_SYSUTIL_ERROR_BUSY;
|
||||
}
|
||||
|
|
|
@ -74,7 +74,7 @@ class MsgDialogBase
|
|||
public:
|
||||
atomic_t<MsgDialogState> state{ MsgDialogState::Open };
|
||||
|
||||
MsgDialogType type;
|
||||
MsgDialogType type{};
|
||||
|
||||
std::function<void(s32 status)> on_close;
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@ struct EmuCallbacks
|
|||
std::function<std::unique_ptr<class PadHandlerBase>()> get_pad_handler;
|
||||
std::function<std::unique_ptr<class GSFrameBase>(frame_type)> get_gs_frame;
|
||||
std::function<std::shared_ptr<class GSRender>()> get_gs_render;
|
||||
std::function<std::unique_ptr<class MsgDialogBase>()> get_msg_dialog;
|
||||
std::function<std::shared_ptr<class MsgDialogBase>()> get_msg_dialog;
|
||||
std::function<std::unique_ptr<class SaveDialogBase>()> get_save_dialog;
|
||||
};
|
||||
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
#include "stdafx.h"
|
||||
#include "stdafx_gui.h"
|
||||
#include "Utilities/rMsgBox.h"
|
||||
|
||||
//#include "Emu/Cell/PPUProgramCompiler.h"
|
||||
//using namespace PPU_opcodes;
|
||||
|
@ -390,7 +389,7 @@ void CompilerELF::LoadElf(wxCommandEvent& event)
|
|||
"All Files (*.*)|*.*",
|
||||
wxFD_OPEN | wxFD_FILE_MUST_EXIST);
|
||||
|
||||
if(ctrl.ShowModal() == rID_CANCEL) return;
|
||||
if(ctrl.ShowModal() == wxID_CANCEL) return;
|
||||
LoadElf(fmt::ToUTF8(ctrl.GetPath()));
|
||||
}
|
||||
|
||||
|
|
|
@ -63,7 +63,6 @@
|
|||
<ClCompile Include="..\Utilities\config_context.cpp" />
|
||||
<ClCompile Include="..\Utilities\Log.cpp" />
|
||||
<ClCompile Include="..\Utilities\File.cpp" />
|
||||
<ClCompile Include="..\Utilities\rMsgBox.cpp" />
|
||||
<ClCompile Include="..\Utilities\rPlatform.cpp" />
|
||||
<ClCompile Include="..\Utilities\rTime.cpp" />
|
||||
<ClCompile Include="..\Utilities\rXml.cpp" />
|
||||
|
@ -371,7 +370,6 @@
|
|||
<ClInclude Include="..\Utilities\MTRingbuffer.h" />
|
||||
<ClInclude Include="..\Utilities\Log.h" />
|
||||
<ClInclude Include="..\Utilities\File.h" />
|
||||
<ClInclude Include="..\Utilities\rMsgBox.h" />
|
||||
<ClInclude Include="..\Utilities\rPlatform.h" />
|
||||
<ClInclude Include="..\Utilities\rTime.h" />
|
||||
<ClInclude Include="..\Utilities\rXml.h" />
|
||||
|
|
|
@ -485,9 +485,6 @@
|
|||
<ClCompile Include="Emu\SysCalls\LogBase.cpp">
|
||||
<Filter>Emu\SysCalls</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\Utilities\rMsgBox.cpp">
|
||||
<Filter>Utilities</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\Utilities\rPlatform.cpp">
|
||||
<Filter>Utilities</Filter>
|
||||
</ClCompile>
|
||||
|
@ -1418,9 +1415,6 @@
|
|||
<ClInclude Include="..\Utilities\MTRingbuffer.h">
|
||||
<Filter>Utilities</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\Utilities\rMsgBox.h">
|
||||
<Filter>Utilities</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\Utilities\rPlatform.h">
|
||||
<Filter>Utilities</Filter>
|
||||
</ClInclude>
|
||||
|
|
|
@ -145,9 +145,9 @@ bool Rpcs3App::OnInit()
|
|||
}
|
||||
};
|
||||
|
||||
callbacks.get_msg_dialog = []() -> std::unique_ptr<MsgDialogBase>
|
||||
callbacks.get_msg_dialog = []() -> std::shared_ptr<MsgDialogBase>
|
||||
{
|
||||
return std::make_unique<MsgDialogFrame>();
|
||||
return std::make_shared<MsgDialogFrame>();
|
||||
};
|
||||
|
||||
callbacks.get_save_dialog = []() -> std::unique_ptr<SaveDialogBase>
|
||||
|
|
Loading…
Add table
Reference in a new issue