main.cpp 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. #include "PolycodeWindowsPlayer.h"
  2. #include <Polycode.h>
  3. #include "PolycodeView.h"
  4. #include "windows.h"
  5. #include "resource.h"
  6. #define STANDALONE_MODE
  7. using namespace Polycode;
  8. extern Win32Core *core;
  9. void wtoc(char* Dest, TCHAR* Source, int SourceSize)
  10. {
  11. for(int i = 0; i < SourceSize; ++i)
  12. Dest[i] = (char)Source[i];
  13. }
  14. int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
  15. {
  16. int nArgs;
  17. LPWSTR *szArglist = CommandLineToArgvW(GetCommandLineW(), &nArgs);
  18. String fileName = "";
  19. if(nArgs > 1) {
  20. fileName = String(szArglist[1]);
  21. }
  22. fileName = fileName.replace("\\", "/");
  23. PolycodeView *view = new PolycodeView(hInstance, nCmdShow, L"Polycode Player", false, false);
  24. PolycodeWindowsPlayer *player = new PolycodeWindowsPlayer(view, fileName.c_str(), false, true);
  25. HICON mainIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_ICON1));
  26. SendMessage(view->hwnd, WM_SETICON, ICON_SMALL, (LPARAM) mainIcon );
  27. // player->addEventListener(view, PolycodeDebugEvent::EVENT_ERROR);
  28. // player->addEventListener(view, PolycodeDebugEvent::EVENT_PRINT);
  29. player->runPlayer();
  30. core = (Win32Core*)player->getCore();
  31. MSG Msg;
  32. do {
  33. if(PeekMessage(&Msg, NULL, 0,0,PM_REMOVE)) {
  34. TranslateMessage(&Msg);
  35. DispatchMessage(&Msg);
  36. }
  37. } while(player->Update());
  38. delete player;
  39. return Msg.wParam;
  40. }