Main.cpp 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. #include <File.h>
  2. #include <FileSystem.h>
  3. #include <Font.h>
  4. #include <GraphicsApi.h>
  5. #include <main.h>
  6. #include <Network.h>
  7. #include <RenderThread.h>
  8. #include <Screen.h>
  9. #include <Window.h>
  10. #include "CustomDX12API.h"
  11. #include "Globals.h"
  12. #include "Initialization.h"
  13. #include "World.h"
  14. int KSGStart Framework::Start(Framework::Startparam p)
  15. {
  16. Network::Start(20);
  17. initVariables();
  18. setDebugDX(1);
  19. #ifdef _DEBUG
  20. Logging::LoggingChannel* outputDebugLoggingChannel
  21. = new Framework::Logging::OutputDebugStringLoggingChannel();
  22. Framework::Logging::zLoggingHandler()->addChannel(
  23. Logging::LogLevel::Error, outputDebugLoggingChannel);
  24. Framework::Logging::zLoggingHandler()->addChannel(Logging::LogLevel::Debug,
  25. dynamic_cast<Logging::LoggingChannel*>(
  26. outputDebugLoggingChannel->getThis()));
  27. Framework::Logging::zLoggingHandler()->addChannel(Logging::LogLevel::Info,
  28. dynamic_cast<Logging::LoggingChannel*>(
  29. outputDebugLoggingChannel->getThis()));
  30. Framework::Logging::zLoggingHandler()->addChannel(
  31. Logging::LogLevel::Warning,
  32. dynamic_cast<Logging::LoggingChannel*>(
  33. outputDebugLoggingChannel->getThis()));
  34. Framework::Logging::zLoggingHandler()->addChannel(Logging::LogLevel::Trace,
  35. dynamic_cast<Logging::LoggingChannel*>(
  36. outputDebugLoggingChannel->getThis()));
  37. #endif
  38. File d;
  39. d.setFile("data/schriften");
  40. auto list = d.getFileList();
  41. for (Text* fontFile : *list)
  42. {
  43. LTDSFile dat;
  44. dat.setPfad(
  45. new Text(Text("data/schriften/").operator+(fontFile->getText())));
  46. dat.readData();
  47. Text* name = fontFile->getTeilText(0, fontFile->getLength() - 5);
  48. fontRegister->put(*name, RCPointer<Font>::of(dat.loadFont()));
  49. name->release();
  50. }
  51. list->release();
  52. NativeWindow window;
  53. ::window = &window;
  54. WNDCLASS wc = Framework::F_Normal(p.hinst);
  55. wc.lpszClassName = "Factory Craft";
  56. window.create(WS_POPUPWINDOW, wc);
  57. Monitor m = Framework::getMonitor(0);
  58. window.setBounds(Point(m.x, m.y), Point(m.width, m.height));
  59. window.setDisplayMode(SW_SHOWNORMAL);
  60. window.setPreCloseAction([&window](void* p, void* f) {
  61. StopMessageLoop(window.getWindowHandle());
  62. });
  63. window.setMouseAction(_ret1ME);
  64. window.setKeyboardAction(_ret1TE);
  65. Screen3D screen(
  66. dynamic_cast<NativeWindow*>(window.getThis()), new CustomDX12API());
  67. screen.setHandleUserInputsOnTick(0);
  68. window.setScreen(dynamic_cast<Screen*>(screen.getThis()));
  69. screen.setFillColor(0);
  70. screen.setTestRend(0);
  71. uiFactory = Framework::defaultUI(fontRegister->get("normal"), &screen);
  72. uiFactory.createButton = createButton;
  73. uiFactory.createTextField = createTextField;
  74. uiFactory.createCheckBox = createCheckBox;
  75. uiFactory.createObjTable = createObjTable;
  76. uiFactory.createWindow = createWindow;
  77. initMenus();
  78. RenderTh rTh;
  79. rTh.setMaxFps(-1);
  80. rTh.setQuiet(0);
  81. rTh.setScreen(dynamic_cast<Screen*>(screen.getThis()));
  82. rTh.setTickFunktion([](void* p, void* o, double time) {
  83. if (World::INSTANCE)
  84. {
  85. World::INSTANCE->onTick(time);
  86. }
  87. });
  88. renderThread = &rTh;
  89. rTh.beginn();
  90. StartMessageLoop();
  91. rTh.terminate();
  92. releaseVariables();
  93. Network::Exit();
  94. return 0;
  95. }