pesci

Untitled

Sep 22nd, 2021
668
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. bool CPythonApplication::Create(PyObject * poSelf, const char * c_szName, int width, int height, int Windowed)
  2. {
  3.     NANOBEGIN
  4.         Windowed = CPythonSystem::Instance().GetScreenMode() ? 1 : 0;
  5.  
  6.     bool bAnotherWindow = false;
  7.  
  8.     if (FindWindow(NULL, c_szName))
  9.         bAnotherWindow = true;
  10.  
  11.     m_dwWidth = width;
  12.     m_dwHeight = height;
  13.  
  14.     // Window
  15.     UINT WindowMode = __GetWindowMode(Windowed ? true : false);
  16.  
  17.     if (!CMSWindow::Create(c_szName, 4, 0, WindowMode, ::LoadIcon( GetInstance(), MAKEINTRESOURCE( IDI_METIN2 ) ), IDC_CURSOR_NORMAL))
  18.     {
  19.         TraceError("CMSWindow::Create failed");
  20.         SET_EXCEPTION(CREATE_WINDOW);
  21.         return false;
  22.     }
  23.  
  24.     if (m_pySystem.IsUseDefaultIME())
  25.         CPythonIME::Instance().UseDefaultIME();
  26.  
  27.     if (!m_pySystem.GetScreenMode() && (m_pySystem.IsUseDefaultIME() || LocaleService_IsEUROPE()))
  28.     {
  29.         m_isWindowed = false;
  30.         m_isWindowFullScreenEnable = TRUE;
  31.         __SetFullScreenWindow(GetWindowHandle(), width, height, m_pySystem.GetBPP());
  32.  
  33.         Windowed = true;
  34.     }
  35.     else
  36.     {
  37.         AdjustSize(m_pySystem.GetWidth(), m_pySystem.GetHeight());
  38.  
  39.         if (Windowed)
  40.         {
  41.             m_isWindowed = true;
  42.  
  43.             RECT work_area{ 0,0,0,0 };
  44.             SystemParametersInfo(SPI_GETWORKAREA, 0, &work_area, 0);
  45.  
  46.             // Get Screen Size with Taskbar
  47.             const int32_t work_area_width = work_area.right - work_area.left;
  48.             const int32_t work_area_height = work_area.bottom - work_area.top;
  49.  
  50.             // Get Application (caption) Size
  51.             const int32_t caption_height = GetSystemMetrics(SM_CYFRAME) + GetSystemMetrics(SM_CYCAPTION) + GetSystemMetrics(SM_CXPADDEDBORDER);
  52.  
  53.             // Get Maximum Available Resolution
  54.             const int32_t screen_width = GetScreenWidth();
  55.             const int32_t screen_height = GetScreenHeight();
  56.  
  57.             // Get config.cfg desired size
  58.             const int32_t window_width = m_pySystem.GetWidth();
  59.             const int32_t window_height = m_pySystem.GetHeight();
  60.  
  61.             // Get Taskbar Size
  62.             const int32_t taskbar_height = GetScreenHeight() - work_area_height;
  63.  
  64.             //TraceError("Caption Height %d", caption_height);
  65.             //TraceError("Taskbar Height %d", taskbar_height);
  66.             //TraceError("Screen Resolution %dx%d", screen_width, screen_height);
  67.             //TraceError("Maximum Available Resolution %dx%d", work_area_width, work_area_height);
  68.             //TraceError("CFG Resolution %dx%d", window_width, window_height);
  69.         }
  70.         else
  71.         {
  72.             m_isWindowed = false;
  73.             SetPosition(0, 0);
  74.         }
  75.     }
  76.  
  77.     NANOEND
  78.         ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  79.         ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  80.  
  81.         // Cursor
  82.         if (!CreateCursors())
  83.         {
  84.             TraceError("CMSWindow::Cursors Create Error");
  85.             SET_EXCEPTION("CREATE_CURSOR");
  86.             return false;
  87.         }
  88.  
  89.  
  90.         // Sound
  91.         if (!m_SoundManager.Create())
  92.         {
  93.             TraceError("SoundManager Create Error");
  94.             SET_EXCEPTION("CREATE_SOUNDMANAGER");
  95.             return false;
  96.         }
  97.  
  98.         extern bool GRAPHICS_CAPS_SOFTWARE_TILING;
  99.  
  100.         if (!m_pySystem.IsAutoTiling())
  101.             GRAPHICS_CAPS_SOFTWARE_TILING = m_pySystem.IsSoftwareTiling();
  102.  
  103.         // Device
  104.         if (!CreateDevice(m_pySystem.GetWidth(), m_pySystem.GetHeight(), Windowed, m_pySystem.GetBPP(), m_pySystem.GetFrequency()))
  105.             return false;
  106.  
  107.         GrannyCreateSharedDeformBuffer();
  108.  
  109.         if (m_pySystem.IsAutoTiling())
  110.         {
  111.             if (m_grpDevice.IsFastTNL())
  112.                 m_pyBackground.ReserveSoftwareTilingEnable(false);
  113.             else
  114.                 m_pyBackground.ReserveSoftwareTilingEnable(true);
  115.         }
  116.         else
  117.             m_pyBackground.ReserveSoftwareTilingEnable(m_pySystem.IsSoftwareTiling());
  118.  
  119.         SetVisibleMode(true);
  120.  
  121.         if (m_isWindowFullScreenEnable) //m_pySystem.IsUseDefaultIME() && !m_pySystem.IsWindowed())
  122.             SetWindowPos(GetWindowHandle(), HWND_TOP, 0, 0, width, height, SWP_SHOWWINDOW);
  123.  
  124.         if (!InitializeKeyboard(GetWindowHandle()))
  125.             return false;
  126.  
  127.         m_pySystem.GetDisplaySettings();
  128.  
  129.         // Mouse
  130.         if (m_pySystem.IsSoftwareCursor())
  131.             SetCursorMode(CURSOR_MODE_SOFTWARE);
  132.         else
  133.             SetCursorMode(CURSOR_MODE_HARDWARE);
  134.  
  135.         // Network
  136.         if (!m_netDevice.Create())
  137.         {
  138.             TraceError("NetDevice::Create failed");
  139.             SET_EXCEPTION("CREATE_NETWORK");
  140.             return false;
  141.         }
  142.  
  143.         if (!m_grpDevice.IsFastTNL())
  144.             CGrannyLODController::SetMinLODMode(true);
  145.  
  146.         m_pyItem.Create();
  147.  
  148.         // Other Modules
  149.         DefaultFont_Startup();
  150.  
  151.         CPythonIME::Instance().Create(GetWindowHandle());
  152.         CPythonIME::Instance().SetText("", 0);
  153.         CPythonTextTail::Instance().Initialize();
  154.  
  155.         // Light Manager
  156.         m_LightManager.Initialize();
  157.  
  158.         CGraphicImageInstance::CreateSystem(32);
  159.  
  160.         // SphereMap
  161.         CGrannyMaterial::CreateSphereMap(0, "d:/ymir work/special/spheremap.jpg");
  162.         CGrannyMaterial::CreateSphereMap(1, "d:/ymir work/special/spheremap01.jpg");
  163.  
  164. #ifdef ENABLE_DISCORD_RPC
  165.         m_pyNetworkStream.Discord_Start();
  166. #endif
  167.  
  168.         return true;
  169. }
RAW Paste Data