diff --git a/Utilities/Log.cpp b/Utilities/Log.cpp index da7c723ae0..d5794f7d69 100644 --- a/Utilities/Log.cpp +++ b/Utilities/Log.cpp @@ -1,11 +1,13 @@ #include "stdafx.h" -#include "rPlatform.h" -#include "Log.h" -#include "rMsgBox.h" #include #include #include "Thread.h" #include "File.h" +#include "Log.h" + +#ifdef _WIN32 +#include +#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 TTYListener(new FileListener("TTY",false)); + std::shared_ptr 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 } } diff --git a/Utilities/rMsgBox.cpp b/Utilities/rMsgBox.cpp deleted file mode 100644 index 152ac74b94..0000000000 --- a/Utilities/rMsgBox.cpp +++ /dev/null @@ -1,38 +0,0 @@ -#include "stdafx.h" -#include "restore_new.h" -#pragma warning(push) -#pragma message("TODO: remove wx dependency: ") -#pragma warning(disable : 4996) -#include -#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(new wxMessageDialog( - reinterpret_cast(parent) - , fmt::FromUTF8(msg) - , fmt::FromUTF8(title) - , style - )); -} - -rMessageDialog::~rMessageDialog() -{ - delete reinterpret_cast(handle); -} - -long rMessageDialog::ShowModal() -{ - return reinterpret_cast(handle)->ShowModal(); -} - -long rMessageBox(const std::string& message, const std::string& title, long style) -{ - return wxMessageBox(fmt::FromUTF8(message), fmt::FromUTF8(title),style); -} - -#endif - diff --git a/Utilities/rMsgBox.h b/Utilities/rMsgBox.h deleted file mode 100644 index f19081fe5c..0000000000 --- a/Utilities/rMsgBox.h +++ /dev/null @@ -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); - diff --git a/rpcs3/Emu/IdManager.h b/rpcs3/Emu/IdManager.h index 83b35d1308..347fa2b5b1 100644 --- a/rpcs3/Emu/IdManager.h +++ b/rpcs3/Emu/IdManager.h @@ -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 - bool import(const std::shared_ptr& ptr) + // Emplace the object returned by provider() and return it if no object exists + template + auto import(F&& provider) -> decltype(static_cast>(provider())) { static const auto size = sizeof(T); // forbid forward declarations - auto pair = add(WRAP_EXPR(ptr)); + auto pair = add(std::forward(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 - void import_always(const std::shared_ptr& ptr) + // Emplace the object return by provider() (old object will be removed if it exists) + template + auto import_always(F&& provider) -> decltype(static_cast>(provider())) { static const auto size = sizeof(T); // forbid forward declarations - auto pair = add(WRAP_EXPR(ptr)); + auto pair = add(std::forward(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) diff --git a/rpcs3/Emu/SysCalls/Modules/cellGame.cpp b/rpcs3/Emu/SysCalls/Modules/cellGame.cpp index 578f8e56d2..a047abb7ee 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellGame.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellGame.cpp @@ -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 type, vm::ptr attributes, vm::ptr("/dev_bdvd/PS3_GAME")) + if (!fxm::make("/dev_bdvd/PS3_GAME", false)) { return CELL_GAME_ERROR_BUSY; } @@ -203,7 +195,7 @@ s32 cellGameBootCheck(vm::ptr type, vm::ptr attributes, vm::ptr("/dev_hdd0/game/" + titleId)) + if (!fxm::make("/dev_hdd0/game/" + titleId, false)) { return CELL_GAME_ERROR_BUSY; } @@ -215,7 +207,7 @@ s32 cellGameBootCheck(vm::ptr type, vm::ptr attributes, vm::ptr("/dev_bdvd/PS3_GAME")) + if (!fxm::make("/dev_bdvd/PS3_GAME", false)) { return CELL_GAME_ERROR_BUSY; } @@ -257,7 +249,7 @@ s32 cellGamePatchCheck(vm::ptr size, vm::ptr reserved return CELL_GAME_ERROR_NOTPATCH; } - if (!fxm::make("/dev_hdd0/game/" + psf.GetString("TITLE_ID"))) + if (!fxm::make("/dev_hdd0/game/" + psf.GetString("TITLE_ID"), false)) { return CELL_GAME_ERROR_BUSY; } @@ -295,7 +287,7 @@ s32 cellGameDataCheck(u32 type, vm::cptr dirName, vm::ptr("/dev_bdvd/PS3_GAME")) + if (!fxm::make("/dev_bdvd/PS3_GAME", false)) { return CELL_GAME_ERROR_BUSY; } @@ -310,7 +302,7 @@ s32 cellGameDataCheck(u32 type, vm::cptr dirName, vm::ptr(dir)) + if (!fxm::make(dir, false)) { return CELL_GAME_ERROR_BUSY; } @@ -487,7 +479,7 @@ s32 cellGameCreateGameData(vm::ptr init, vm::ptr(dir, temporary_content_dir_tag)) + if (!fxm::make(dir, true)) { return CELL_GAME_ERROR_BUSY; } @@ -639,7 +631,23 @@ s32 cellGameContentErrorDialog(s32 type, s32 errNeedSizeKB, vm::cptr 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::future future = p->get_future(); + + dlg->on_close = [=](s32 status) + { + p->set_value(); + }; + + dlg->Create(errorMsg); + + future.get(); return CELL_OK; } diff --git a/rpcs3/Emu/SysCalls/Modules/cellMsgDialog.cpp b/rpcs3/Emu/SysCalls/Modules/cellMsgDialog.cpp index 3d9e54c750..621145f57e 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellMsgDialog.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellMsgDialog.cpp @@ -61,9 +61,9 @@ s32 cellMsgDialogOpen2(u32 type, vm::cptr msgString, vm::ptr dlg(Emu.GetCallbacks().get_msg_dialog()); + const auto dlg = fxm::import(WRAP_EXPR(Emu.GetCallbacks().get_msg_dialog())); - if (!fxm::import(dlg)) + if (!dlg) { return CELL_SYSUTIL_ERROR_BUSY; } diff --git a/rpcs3/Emu/SysCalls/Modules/cellMsgDialog.h b/rpcs3/Emu/SysCalls/Modules/cellMsgDialog.h index 11da4f9212..37b71020bf 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellMsgDialog.h +++ b/rpcs3/Emu/SysCalls/Modules/cellMsgDialog.h @@ -74,7 +74,7 @@ class MsgDialogBase public: atomic_t state{ MsgDialogState::Open }; - MsgDialogType type; + MsgDialogType type{}; std::function on_close; diff --git a/rpcs3/Emu/System.h b/rpcs3/Emu/System.h index ba95ccd5da..5b83cf7ca6 100644 --- a/rpcs3/Emu/System.h +++ b/rpcs3/Emu/System.h @@ -15,7 +15,7 @@ struct EmuCallbacks std::function()> get_pad_handler; std::function(frame_type)> get_gs_frame; std::function()> get_gs_render; - std::function()> get_msg_dialog; + std::function()> get_msg_dialog; std::function()> get_save_dialog; }; diff --git a/rpcs3/Gui/CompilerELF.cpp b/rpcs3/Gui/CompilerELF.cpp index bc1bc501f4..999ebbf7c4 100644 --- a/rpcs3/Gui/CompilerELF.cpp +++ b/rpcs3/Gui/CompilerELF.cpp @@ -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())); } diff --git a/rpcs3/emucore.vcxproj b/rpcs3/emucore.vcxproj index 2aafa09a45..0a1ae395e5 100644 --- a/rpcs3/emucore.vcxproj +++ b/rpcs3/emucore.vcxproj @@ -63,7 +63,6 @@ - @@ -371,7 +370,6 @@ - diff --git a/rpcs3/emucore.vcxproj.filters b/rpcs3/emucore.vcxproj.filters index f00ffa9883..8ae7833a65 100644 --- a/rpcs3/emucore.vcxproj.filters +++ b/rpcs3/emucore.vcxproj.filters @@ -485,9 +485,6 @@ Emu\SysCalls - - Utilities - Utilities @@ -1418,9 +1415,6 @@ Utilities - - Utilities - Utilities diff --git a/rpcs3/rpcs3.cpp b/rpcs3/rpcs3.cpp index 10f2a54dff..485eec695e 100644 --- a/rpcs3/rpcs3.cpp +++ b/rpcs3/rpcs3.cpp @@ -145,9 +145,9 @@ bool Rpcs3App::OnInit() } }; - callbacks.get_msg_dialog = []() -> std::unique_ptr + callbacks.get_msg_dialog = []() -> std::shared_ptr { - return std::make_unique(); + return std::make_shared(); }; callbacks.get_save_dialog = []() -> std::unique_ptr