2016-06-05 01:32:57 +00:00
|
|
|
/****************************************************************************
|
|
|
|
* *
|
|
|
|
* Project64 - A Nintendo 64 emulator. *
|
|
|
|
* http://www.pj64-emu.com/ *
|
|
|
|
* Copyright (C) 2012 Project64. All rights reserved. *
|
|
|
|
* *
|
|
|
|
* License: *
|
|
|
|
* GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html *
|
|
|
|
* *
|
|
|
|
****************************************************************************/
|
|
|
|
#include <common/StdString.h>
|
|
|
|
#include <Common/Trace.h>
|
|
|
|
#include <Project64-core/N64System/SystemGlobals.h>
|
|
|
|
#include <Project64-core/Settings/SettingsClass.h>
|
2016-07-09 21:28:30 +00:00
|
|
|
#include <Project64-core/N64System/N64Class.h>
|
2016-06-05 01:32:57 +00:00
|
|
|
#include "NotificationClass.h"
|
|
|
|
#include "JavaBridge.h"
|
|
|
|
#if defined(ANDROID)
|
|
|
|
#include <android/log.h>
|
|
|
|
|
|
|
|
extern JavaBridge * g_JavaBridge;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
CNotificationImp & Notify(void)
|
|
|
|
{
|
|
|
|
static CNotificationImp g_Notify;
|
|
|
|
return g_Notify;
|
|
|
|
}
|
|
|
|
|
|
|
|
CNotificationImp::CNotificationImp() :
|
2016-08-12 13:46:23 +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
|
|
|
|
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
|
|
|
}
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
//User Feedback
|
|
|
|
void CNotificationImp::DisplayMessage(int DisplayTime, const char * Message) const
|
|
|
|
{
|
|
|
|
#ifdef ANDROID
|
|
|
|
if (g_JavaBridge == NULL) { return; }
|
|
|
|
|
2016-08-12 13:46:23 +00:00
|
|
|
if (m_NextMsg > 0 || DisplayTime > 0)
|
2016-06-05 01:32:57 +00:00
|
|
|
{
|
2016-08-12 13:46:23 +00:00
|
|
|
time_t Now = time(NULL);
|
|
|
|
if (DisplayTime == 0 && Now < m_NextMsg)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (DisplayTime > 0)
|
|
|
|
{
|
|
|
|
m_NextMsg = Now + DisplayTime;
|
|
|
|
}
|
|
|
|
if (m_NextMsg == 0)
|
|
|
|
{
|
|
|
|
m_NextMsg = 0;
|
|
|
|
}
|
2016-08-11 10:43:51 +00:00
|
|
|
}
|
2016-08-12 13:46:23 +00:00
|
|
|
m_Message[0] = Message;
|
|
|
|
UpdateMessage();
|
2016-06-05 01:32:57 +00:00
|
|
|
|
2016-07-09 21:28:30 +00:00
|
|
|
#else
|
|
|
|
// ignore warning usage
|
|
|
|
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-08-12 13:46:23 +00:00
|
|
|
m_Message[1] = Message;
|
2016-08-11 10:43:51 +00:00
|
|
|
|
2016-08-12 13:46:23 +00:00
|
|
|
UpdateMessage();
|
2016-08-11 10:43:51 +00:00
|
|
|
#else
|
|
|
|
// ignore warning usage
|
|
|
|
Message = Message;
|
|
|
|
#endif
|
2016-06-05 01:32:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Ask a Yes/No Question to the user, yes = true, no = false
|
|
|
|
bool CNotificationImp::AskYesNoQuestion(const char * /*Question*/) const
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void CNotificationImp::BreakPoint(const char * FileName, int32_t LineNumber)
|
|
|
|
{
|
|
|
|
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
|
|
|
|
{
|
2016-07-09 21:28:30 +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
|
|
|
}
|
|
|
|
|
|
|
|
void CNotificationImp::UpdateMessage(void) const
|
|
|
|
{
|
|
|
|
#ifdef ANDROID
|
|
|
|
std::string message = m_Message[0];
|
|
|
|
if (message.length() > 0 && m_Message[1].length())
|
|
|
|
{
|
|
|
|
message += " ";
|
|
|
|
}
|
|
|
|
message += m_Message[1];
|
|
|
|
if (message.length() > 0)
|
|
|
|
{
|
|
|
|
g_JavaBridge->DisplayMessage(message.c_str());
|
|
|
|
}
|
|
|
|
#endif
|
2016-06-05 01:32:57 +00:00
|
|
|
}
|