Modified files for SDL2.

This commit is contained in:
LuisAntonRebollo 2015-01-18 22:52:29 +01:00
parent d08db6cc54
commit 21d58bb191
33 changed files with 436 additions and 136 deletions

View file

@ -195,9 +195,9 @@ bool PopupMenu::onMessageObjectReceived(StringTableEntry queue, Message *msg )
// Console Methods
//-----------------------------------------------------------------------------
DefineConsoleMethod(PopupMenu, insertItem, S32, (S32 pos, const char * title, const char * accelerator), ("", ""), "(pos[, title][, accelerator])")
DefineConsoleMethod(PopupMenu, insertItem, S32, (S32 pos, const char * title, const char * accelerator, const char* cmd), ("", "", ""), "(pos[, title][, accelerator][, cmd])")
{
return object->insertItem(pos, title, accelerator);
return object->insertItem(pos, title, accelerator, cmd);
}
DefineConsoleMethod(PopupMenu, removeItem, void, (S32 pos), , "(pos)")
@ -216,9 +216,9 @@ DefineConsoleMethod(PopupMenu, insertSubMenu, S32, (S32 pos, String title, Strin
return object->insertSubMenu(pos, title, mnu);
}
DefineConsoleMethod(PopupMenu, setItem, bool, (S32 pos, const char * title, const char * accelerator), (""), "(pos, title[, accelerator])")
DefineConsoleMethod(PopupMenu, setItem, bool, (S32 pos, const char * title, const char * accelerator, const char *cmd), (""), "(pos, title[, accelerator][, cmd])")
{
return object->setItem(pos, title, accelerator);
return object->setItem(pos, title, accelerator, cmd);
}
//-----------------------------------------------------------------------------

View file

@ -85,11 +85,11 @@ public:
/// returns the menu item's ID, or -1 on failure.
/// implementd on a per-platform basis.
/// TODO: factor out common code
S32 insertItem(S32 pos, const char *title, const char* accelerator);
S32 insertItem(S32 pos, const char *title, const char* accelerator, const char* cmd);
/// Sets the name title and accelerator for
/// an existing item.
bool setItem(S32 pos, const char *title, const char* accelerator);
bool setItem(S32 pos, const char *title, const char* accelerator, const char* cmd);
/// pass NULL for @p title to insert a separator
/// returns the menu item's ID, or -1 on failure.

View file

@ -37,6 +37,7 @@ enum MBButtons
MBRetryCancel,
MBSaveDontSave,
MBSaveDontSaveCancel,
MBAlertAssert
};
enum MBIcons

View file

@ -174,6 +174,15 @@ namespace Platform
bool isdst; ///< True if daylight savings time is active
};
enum ALERT_ASSERT_RESULT
{
ALERT_ASSERT_DEBUG,
ALERT_ASSERT_IGNORE,
ALERT_ASSERT_IGNORE_ALL,
ALERT_ASSERT_EXIT
};
void getLocalTime(LocalTime &);
/// Converts the local time to a formatted string appropriate
@ -300,6 +309,7 @@ namespace Platform
void AlertOK(const char *windowTitle, const char *message);
bool AlertOKCancel(const char *windowTitle, const char *message);
bool AlertRetry(const char *windowTitle, const char *message);
ALERT_ASSERT_RESULT AlertAssert(const char *windowTitle, const char *message);
// Volumes
struct VolumeInformation

View file

@ -33,6 +33,7 @@ PlatformAssert *PlatformAssert::platformAssert = NULL;
PlatformAssert::PlatformAssert()
{
processing = false;
ignoreAll = false;
}
//--------------------------------------
@ -94,47 +95,57 @@ bool PlatformAssert::process(Type assertType,
U32 lineNumber,
const char *message)
{
// If we're somehow recursing, just die.
if(processing)
Platform::debugBreak();
processing = true;
bool ret = true;
// always dump to the Assert to the Console
if (Con::isActive())
{
if (assertType == Warning)
Con::warnf(ConsoleLogEntry::Assert, "%s(%ld) : %s - %s", filename, lineNumber, typeName[assertType], message);
else
Con::errorf(ConsoleLogEntry::Assert, "%s(%ld) : %s - %s", filename, lineNumber, typeName[assertType], message);
}
// if not a WARNING pop-up a dialog box
if (assertType != Warning)
{
// used for processing navGraphs (an assert won't botch the whole build)
if(Con::getBoolVariable("$FP::DisableAsserts", false) == true)
Platform::forceShutdown(1);
char buffer[2048];
dSprintf(buffer, 2048, "%s(%ld) : %s", filename, lineNumber, typeName[assertType] );
#ifdef TORQUE_DEBUG
// In debug versions, allow a retry even for ISVs...
bool retry = displayMessageBox(buffer, message, true);
#else
bool retry = displayMessageBox(buffer, message, ((assertType == Fatal) ? true : false) );
#endif
if(!retry)
Platform::forceShutdown(1);
ret = askToEnterDebugger(message);
}
processing = false;
return ret;
// If we're somehow recursing, just die.
if(processing)
Platform::debugBreak();
processing = true;
bool ret = false;
// always dump to the Assert to the Console
if (Con::isActive())
{
if (assertType == Warning)
Con::warnf(ConsoleLogEntry::Assert, "%s(%ld,0): {%s} - %s", filename, lineNumber, typeName[assertType], message);
else
Con::errorf(ConsoleLogEntry::Assert, "%s(%ld,0): {%s} - %s", filename, lineNumber, typeName[assertType], message);
}
// if not a WARNING pop-up a dialog box
if (assertType != Warning)
{
// used for processing navGraphs (an assert won't botch the whole build)
if(Con::getBoolVariable("$FP::DisableAsserts", false) == true)
Platform::forceShutdown(1);
char buffer[2048];
dSprintf(buffer, 2048, "%s: (%s @ %ld)", typeName[assertType], filename, lineNumber);
if( !ignoreAll )
{
// Display message box with Debug, Ignore, Ignore All, and Exit options
switch( Platform::AlertAssert(buffer, message) )
{
case Platform::ALERT_ASSERT_DEBUG:
ret = true;
break;
case Platform::ALERT_ASSERT_IGNORE:
ret = false;
break;
case Platform::ALERT_ASSERT_IGNORE_ALL:
ignoreAll = true;
ret = false;
break;
default:
case Platform::ALERT_ASSERT_EXIT:
Platform::forceShutdown(1);
break;
}
}
}
processing = false;
return ret;
}
bool PlatformAssert::processingAssert()
@ -170,3 +181,11 @@ const char* avar(const char *message, ...)
dVsprintf(buffer, sizeof(buffer), message, args);
return( buffer );
}
//-----------------------------------------------------------------------------
ConsoleFunction( Assert, void, 3, 3, "(condition, message) - Fatal Script Assertion" )
{
// Process Assertion.
AssertISV( dAtob(argv[1]), argv[2] );
}

View file

@ -40,6 +40,7 @@ public:
private:
static PlatformAssert *platformAssert;
bool processing;
bool ignoreAll;
virtual bool displayMessageBox(const char *title, const char *message, bool retry);
virtual bool process(Type assertType,