main.cpp 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. #include "PolycodeWindowsPlayer.h"
  2. #include <Polycode.h>
  3. #include "PolycodePlayerView.h"
  4. #include "windows.h"
  5. #include "resource.h"
  6. #include <io.h>
  7. #include <fcntl.h>
  8. using namespace Polycode;
  9. extern Win32Core *core;
  10. void wtoc(char* Dest, TCHAR* Source, int SourceSize)
  11. {
  12. for(int i = 0; i < SourceSize; ++i)
  13. Dest[i] = (char)Source[i];
  14. }
  15. int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
  16. {
  17. PolycodeView *view = new PolycodeView(hInstance, nCmdShow, L"", false, false);
  18. PolycodeWindowsPlayer *player = new PolycodeWindowsPlayer(view, "main.polyapp", false, false);
  19. HICON mainIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_ICON1));
  20. SendMessage(view->hwnd, WM_SETICON, ICON_SMALL, (LPARAM) mainIcon );
  21. //player->addEventListener(view, PolycodeDebugEvent::EVENT_ERROR);
  22. //player->addEventListener(view, PolycodeDebugEvent::EVENT_PRINT);
  23. player->runPlayer();
  24. core = (Win32Core*)player->getCore();
  25. MSG Msg;
  26. do {
  27. while (PeekMessage(&Msg, NULL, 0, 0, PM_REMOVE)) {
  28. TranslateMessage(&Msg);
  29. DispatchMessage(&Msg);
  30. }
  31. } while(player->Update());
  32. return Msg.wParam;
  33. }