diff --git a/SourceFiles/DeviceResources.cpp b/SourceFiles/DeviceResources.cpp index 5231719..00f33ba 100644 --- a/SourceFiles/DeviceResources.cpp +++ b/SourceFiles/DeviceResources.cpp @@ -240,6 +240,11 @@ void DeviceResources::UpdateOffscreenResources(int width, int height) { m_d3dOffscreenDepthStencilView.Reset(); m_offscreenDepthStencil.Reset(); + const int maxWidth = D3D11_REQ_TEXTURE2D_U_OR_V_DIMENSION; // Dx11 maximum texture dimension + const int maxHeight = D3D11_REQ_TEXTURE2D_U_OR_V_DIMENSION; // Dx11 maximum texture dimension + width = std::min(width, maxWidth); + height = std::min(height, maxHeight); + const DXGI_FORMAT backBufferFormat = (m_options & (c_FlipPresent | c_AllowTearing | c_EnableHDR)) ? NoSRGB(m_backBufferFormat) : m_backBufferFormat; diff --git a/SourceFiles/MapBrowser.cpp b/SourceFiles/MapBrowser.cpp index 37bfea4..e651b7d 100644 --- a/SourceFiles/MapBrowser.cpp +++ b/SourceFiles/MapBrowser.cpp @@ -170,17 +170,22 @@ void MapBrowser::Render() ImGui_ImplDX11_NewFrame(); ImGui_ImplWin32_NewFrame(); ImGui::NewFrame(); + if (m_show_error_msg) { + ShowErrorMessage(); + } + else { - draw_ui(m_dat_managers, m_dat_manager_to_show_in_dat_browser, m_map_renderer.get(), picking_info, m_csv_data, m_FPS_target, m_timer, m_extract_panel_info); + draw_ui(m_dat_managers, m_dat_manager_to_show_in_dat_browser, m_map_renderer.get(), picking_info, m_csv_data, m_FPS_target, m_timer, m_extract_panel_info); - if (!m_mft_indices_to_extract.empty()) { - draw_dat_load_progress_bar(m_dat_managers[m_dat_manager_to_show_in_dat_browser]->get_num_files_for_type(FFNA_Type3) - m_mft_indices_to_extract.size(), - m_dat_managers[m_dat_manager_to_show_in_dat_browser]->get_num_files_for_type(FFNA_Type3)); - } + if (!m_mft_indices_to_extract.empty()) { + draw_dat_load_progress_bar(m_dat_managers[m_dat_manager_to_show_in_dat_browser]->get_num_files_for_type(FFNA_Type3) - m_mft_indices_to_extract.size(), + m_dat_managers[m_dat_manager_to_show_in_dat_browser]->get_num_files_for_type(FFNA_Type3)); + } - static bool show_demo_window = false; - if (show_demo_window) - ImGui::ShowDemoWindow(&show_demo_window); + static bool show_demo_window = false; + if (show_demo_window) + ImGui::ShowDemoWindow(&show_demo_window); + } // Dear ImGui Render ImGui::Render(); @@ -287,10 +292,31 @@ void MapBrowser::Render() HRESULT hrSave = DirectX::SaveToDDSFile(compressedImage.GetImages(), compressedImage.GetImageCount(), compressedImage.GetMetadata(), DDS_FLAGS_NONE, filename.c_str()); if (FAILED(hrSave)) { - // Handle the error + m_mft_indices_to_extract.clear(); + + m_error_msg = std::format("SaveToDDSFile failed. Try lowering the resolution (i.e. use less pixels per tile)."); + m_show_error_msg = true; } } + else { + m_mft_indices_to_extract.clear(); + + m_error_msg = std::format("Compress failed. Try lowering the resolution (i.e. use less pixels per tile)."); + m_show_error_msg = true; + } } + else { + m_mft_indices_to_extract.clear(); + + m_error_msg = std::format("GenerateMipMaps failed. Try lowering the resolution (i.e. use less pixels per tile)."); + m_show_error_msg = true; + } + } + else { + m_mft_indices_to_extract.clear(); + + m_error_msg = std::format("CaptureTexture failed. Not enough VRAM, try lowering the resolution (i.e. use less pixels per tile)."); + m_show_error_msg = true; } } @@ -339,6 +365,35 @@ void MapBrowser::ClearOffscreen() { m_deviceResources->PIXEndEvent(); } +void MapBrowser::ShowErrorMessage() { + if (m_show_error_msg) { + // Set the window to be centered + ImGui::SetNextWindowPos(ImVec2(ImGui::GetIO().DisplaySize.x * 0.5f, + ImGui::GetIO().DisplaySize.y * 0.5f), + ImGuiCond_Appearing, ImVec2(0.5f, 0.5f)); + + // Set the window to have a red border + ImGui::PushStyleColor(ImGuiCol_Border, ImVec4(1.0f, 0.0f, 0.0f, 1.0f)); + + // Create a window that is not resizable, not movable and with a title bar + ImGui::Begin("Error", &m_show_error_msg, ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove); + + // Display the error message + ImGui::Text("%s", m_error_msg.c_str()); + + // Close button + if (ImGui::Button("Close")) { + m_show_error_msg = false; + } + + // End the window + ImGui::End(); + + // Pop the style color for the border + ImGui::PopStyleColor(); + } +} + #pragma region Message Handlers // Message handlers void MapBrowser::OnActivated() diff --git a/SourceFiles/MapBrowser.h b/SourceFiles/MapBrowser.h index 6f3f953..ac3beee 100644 --- a/SourceFiles/MapBrowser.h +++ b/SourceFiles/MapBrowser.h @@ -55,6 +55,8 @@ class MapBrowser final : public DX::IDeviceNotify void Clear(); void ClearOffscreen(); + void ShowErrorMessage(); + void CreateDeviceDependentResources(); void CreateWindowSizeDependentResources(); @@ -83,4 +85,7 @@ class MapBrowser final : public DX::IDeviceNotify std::vector> m_csv_data; std::unique_ptr m_map_renderer; + + std::string m_error_msg = ""; + bool m_show_error_msg = false; }; diff --git a/SourceFiles/draw_extract_panel.cpp b/SourceFiles/draw_extract_panel.cpp index f8993de..d7f4c63 100644 --- a/SourceFiles/draw_extract_panel.cpp +++ b/SourceFiles/draw_extract_panel.cpp @@ -3,7 +3,7 @@ #include "GuiGlobalConstants.h" #include "GWUnpacker.h" -constexpr int max_pixel_per_tile_dir = 20; +constexpr int max_pixel_per_tile_dir = 16384; void draw_extract_panel(ExtractPanelInfo& extract_panel_info, DATManager* dat_manager) {