msgBox.cpp 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. //-----------------------------------------------------------------------------
  2. // Copyright (c) 2013 GarageGames, LLC
  3. //
  4. // Permission is hereby granted, free of charge, to any person obtaining a copy
  5. // of this software and associated documentation files (the "Software"), to
  6. // deal in the Software without restriction, including without limitation the
  7. // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  8. // sell copies of the Software, and to permit persons to whom the Software is
  9. // furnished to do so, subject to the following conditions:
  10. //
  11. // The above copyright notice and this permission notice shall be included in
  12. // all copies or substantial portions of the Software.
  13. //
  14. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  19. // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
  20. // IN THE SOFTWARE.
  21. //-----------------------------------------------------------------------------
  22. #include "platform/platform.h"
  23. #include "console/console.h"
  24. #include "platform/nativeDialogs/msgBox.h"
  25. // these are the return values for message box dialog buttons
  26. void initMessageBoxVars()
  27. {
  28. Con::setIntVariable("$MROk", MROk);
  29. Con::setIntVariable("$MRCancel", MRCancel);
  30. Con::setIntVariable("$MRRetry", MRRetry);
  31. Con::setIntVariable("$MRDontSave", MRDontSave);
  32. }
  33. //////////////////////////////////////////////////////////////////////////
  34. static EnumTable::Enums sgButtonEnums[] =
  35. {
  36. { MBOk, "Ok" },
  37. { MBOkCancel, "OkCancel" },
  38. { MBRetryCancel, "RetryCancel" },
  39. { MBSaveDontSave, "SaveDontSave" }, // maps to yes/no on win, to save/discard on mac.
  40. { MBSaveDontSaveCancel, "SaveDontSaveCancel" }, // maps to yes/no/cancel on win, to save/cancel/don'tsave on mac.
  41. { 0, NULL }
  42. };
  43. static EnumTable::Enums sgIconEnums[] =
  44. {
  45. { MIInformation, "Information" },// win: blue i, mac: app icon or talking head
  46. { MIWarning, "Warning" }, // win & mac: yellow triangle with exclamation pt
  47. { MIStop, "Stop" }, // win: red x, mac: app icon or stop icon, depending on version
  48. { MIQuestion, "Question" }, // win: blue ?, mac: app icon
  49. { 0, NULL }
  50. };
  51. //////////////////////////////////////////////////////////////////////////
  52. static S32 getIDFromName(EnumTable::Enums *table, const char *name, S32 def = -1)
  53. {
  54. for(S32 i = 0;table[i].label != NULL;++i)
  55. {
  56. if(dStricmp(table[i].label, name) == 0)
  57. return table[i].index;
  58. }
  59. AssertWarn(false,"getIDFromName(): didn't find that name" );
  60. return def;
  61. }
  62. //-------------------------------------------------------------------------
  63. #include "msgBox_ScriptBinding.h"