2016-06-05 01:32:57 +00:00
|
|
|
#include <common/StdString.h>
|
|
|
|
#include <Common/Trace.h>
|
|
|
|
#include <Project64-core/N64System/SystemGlobals.h>
|
2018-04-02 18:30:50 +00:00
|
|
|
#include <Project64-core/Settings.h>
|
2021-04-14 05:34:15 +00:00
|
|
|
#include <Project64-core/N64System/N64System.h>
|
2017-01-10 06:45:53 +00:00
|
|
|
#include <Project64-core/N64System/Recompiler/RecompilerCodeLog.h>
|
2021-04-14 05:34:15 +00:00
|
|
|
#include "Notification.h"
|
2016-06-05 01:32:57 +00:00
|
|
|
#include "JavaBridge.h"
|
|
|
|
#if defined(ANDROID)
|
|
|
|
#include <android/log.h>
|
|
|
|
|
|
|
|
extern JavaBridge * g_JavaBridge;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
CNotificationImp & Notify(void)
|
|
|
|
{
|
2016-11-21 07:00:09 +00:00
|
|
|
static CNotificationImp Notify;
|
|
|
|
return Notify;
|
2016-06-05 01:32:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
CNotificationImp::CNotificationImp() :
|
2016-09-17 01:43:32 +00:00
|
|
|
m_NextMsg(0)
|
2016-06-05 01:32:57 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
CNotificationImp::~CNotificationImp()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2016-07-09 21:28:30 +00:00
|
|
|
void CNotificationImp::DisplayError(const char * Message) const
|
2016-06-05 01:32:57 +00:00
|
|
|
{
|
2016-07-09 21:28:30 +00:00
|
|
|
#ifdef ANDROID
|
|
|
|
g_JavaBridge->DisplayError(Message);
|
2016-08-03 10:43:06 +00:00
|
|
|
#else
|
2021-03-16 04:59:26 +00:00
|
|
|
Message = NULL; // Not used
|
2016-07-09 21:28:30 +00:00
|
|
|
#endif
|
2016-06-05 01:32:57 +00:00
|
|
|
}
|
|
|
|
|
2016-07-09 21:28:30 +00:00
|
|
|
void CNotificationImp::DisplayError(LanguageStringID StringID) const
|
2016-06-05 01:32:57 +00:00
|
|
|
{
|
2016-07-09 21:28:30 +00:00
|
|
|
if (g_Lang)
|
|
|
|
{
|
|
|
|
DisplayError(g_Lang->GetString(StringID).c_str());
|
|
|
|
}
|
2016-06-05 01:32:57 +00:00
|
|
|
}
|
|
|
|
|
2016-07-09 21:28:30 +00:00
|
|
|
void CNotificationImp::FatalError(LanguageStringID StringID) const
|
2016-06-05 01:32:57 +00:00
|
|
|
{
|
2016-07-09 21:28:30 +00:00
|
|
|
if (g_Lang)
|
|
|
|
{
|
|
|
|
FatalError(g_Lang->GetString(StringID).c_str());
|
|
|
|
}
|
2016-06-05 01:32:57 +00:00
|
|
|
}
|
|
|
|
|
2016-07-09 21:28:30 +00:00
|
|
|
void CNotificationImp::FatalError(const char * Message) const
|
2016-06-05 01:32:57 +00:00
|
|
|
{
|
2016-07-09 21:28:30 +00:00
|
|
|
WriteTrace(TraceUserInterface, TraceError, Message);
|
|
|
|
DisplayError(Message);
|
|
|
|
if (g_BaseSystem)
|
|
|
|
{
|
|
|
|
g_BaseSystem->CloseCpu();
|
|
|
|
}
|
2016-06-05 01:32:57 +00:00
|
|
|
}
|
|
|
|
|
2019-04-22 21:31:10 +00:00
|
|
|
void CNotificationImp::DisplayWarning(const char * Message) const
|
|
|
|
{
|
|
|
|
#ifdef ANDROID
|
|
|
|
g_JavaBridge->DisplayError(Message);
|
|
|
|
#else
|
2021-03-16 04:59:26 +00:00
|
|
|
Message = NULL; // Not used
|
2019-04-22 21:31:10 +00:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
void CNotificationImp::DisplayWarning(LanguageStringID StringID) const
|
|
|
|
{
|
|
|
|
if (g_Lang)
|
|
|
|
{
|
|
|
|
DisplayError(g_Lang->GetString(StringID).c_str());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-07-09 21:28:30 +00:00
|
|
|
void CNotificationImp::DisplayMessage(int DisplayTime, LanguageStringID StringID) const
|
2016-06-05 01:32:57 +00:00
|
|
|
{
|
2016-07-09 21:28:30 +00:00
|
|
|
DisplayMessage(DisplayTime, g_Lang->GetString(StringID).c_str());
|
2016-06-05 01:32:57 +00:00
|
|
|
}
|
|
|
|
|
2021-03-16 04:59:26 +00:00
|
|
|
// User feedback
|
2016-06-05 01:32:57 +00:00
|
|
|
void CNotificationImp::DisplayMessage(int DisplayTime, const char * Message) const
|
|
|
|
{
|
|
|
|
#ifdef ANDROID
|
|
|
|
if (g_JavaBridge == NULL) { return; }
|
2016-09-17 01:43:32 +00:00
|
|
|
g_JavaBridge->DisplayMessage(Message, DisplayTime);
|
2016-07-09 21:28:30 +00:00
|
|
|
#else
|
2021-03-16 04:59:26 +00:00
|
|
|
// Ignore warning usage
|
2016-07-09 21:28:30 +00:00
|
|
|
DisplayTime = DisplayTime;
|
|
|
|
Message = Message;
|
2016-06-05 01:32:57 +00:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2016-08-11 10:43:51 +00:00
|
|
|
void CNotificationImp::DisplayMessage2(const char * Message) const
|
2016-06-05 01:32:57 +00:00
|
|
|
{
|
2016-08-11 10:43:51 +00:00
|
|
|
#ifdef ANDROID
|
|
|
|
if (g_JavaBridge == NULL) { return; }
|
|
|
|
|
2016-09-17 01:43:32 +00:00
|
|
|
g_JavaBridge->DisplayMessage2(Message);
|
2016-08-11 10:43:51 +00:00
|
|
|
#else
|
2021-03-16 04:59:26 +00:00
|
|
|
// Ignore warning usage
|
2016-08-11 10:43:51 +00:00
|
|
|
Message = Message;
|
|
|
|
#endif
|
2016-06-05 01:32:57 +00:00
|
|
|
}
|
|
|
|
|
2021-03-16 04:59:26 +00:00
|
|
|
// Ask a yes/no question to the user, yes = true, no = false
|
2016-06-05 01:32:57 +00:00
|
|
|
bool CNotificationImp::AskYesNoQuestion(const char * /*Question*/) const
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void CNotificationImp::BreakPoint(const char * FileName, int32_t LineNumber)
|
|
|
|
{
|
2017-01-10 06:45:53 +00:00
|
|
|
Flush_Recompiler_Log();
|
|
|
|
TraceFlushLog();
|
2016-06-05 01:32:57 +00:00
|
|
|
if (g_Settings->LoadBool(Debugger_Enabled))
|
|
|
|
{
|
2016-07-09 21:28:30 +00:00
|
|
|
FatalError(stdstr_f("Break point found at\n%s\nLine: %d", FileName, LineNumber).c_str());
|
2016-06-05 01:32:57 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-05-18 11:51:36 +00:00
|
|
|
FatalError("Fatal error: emulation stopped");
|
2016-08-11 10:43:51 +00:00
|
|
|
}
|
2016-06-05 01:32:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void CNotificationImp::AppInitDone(void)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
bool CNotificationImp::ProcessGuiMessages(void) const
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void CNotificationImp::ChangeFullScreen(void) const
|
|
|
|
{
|
2016-08-12 13:46:23 +00:00
|
|
|
}
|