CCCommon-mac.mm 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. /****************************************************************************
  2. Copyright (c) 2010-2012 cocos2d-x.org
  3. Copyright (c) 2013-2016 Chukong Technologies Inc.
  4. Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
  5. http://www.cocos2d-x.org
  6. Permission is hereby granted, free of charge, to any person obtaining a copy
  7. of this software and associated documentation files (the "Software"), to deal
  8. in the Software without restriction, including without limitation the rights
  9. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  10. copies of the Software, and to permit persons to whom the Software is
  11. furnished to do so, subject to the following conditions:
  12. The above copyright notice and this permission notice shall be included in
  13. all copies or substantial portions of the Software.
  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 FROM,
  19. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  20. THE SOFTWARE.
  21. ****************************************************************************/
  22. #include "platform/CCPlatformConfig.h"
  23. #if CC_TARGET_PLATFORM == CC_PLATFORM_MAC
  24. #include "platform/CCCommon.h"
  25. #include "base/CCDirector.h"
  26. #include <stdarg.h>
  27. #include <stdio.h>
  28. #include <Cocoa/Cocoa.h>
  29. NS_CC_BEGIN
  30. void LuaLog(const char * format)
  31. {
  32. puts(format);
  33. }
  34. // ios no MessageBox, use log instead
  35. void MessageBox(const char * msg, const char * title)
  36. {
  37. NSString * tmpTitle = (title) ? [NSString stringWithUTF8String : title] : nil;
  38. NSString * tmpMsg = (msg) ? [NSString stringWithUTF8String : msg] : nil;
  39. NSAlert *alert = [[[NSAlert alloc] init] autorelease];
  40. [alert addButtonWithTitle:@"OK"];
  41. [alert setMessageText:tmpMsg];
  42. [alert setInformativeText:tmpTitle];
  43. [alert setAlertStyle:NSWarningAlertStyle];
  44. auto glview = Director::getInstance()->getOpenGLView();
  45. id window = glview->getCocoaWindow();
  46. [alert beginSheetModalForWindow:window
  47. modalDelegate:[window delegate]
  48. didEndSelector:nil
  49. contextInfo:nil];
  50. }
  51. NS_CC_END
  52. #endif // CC_TARGET_PLATFORM == CC_PLATFORM_MAC