| 818 | } |
| 819 | |
| 820 | void pathtracer_2d::draw_export_scene_modal() |
| 821 | { |
| 822 | if (open_export_scene_modal) |
| 823 | { |
| 824 | ImGui::OpenPopup("Export Scene"); |
| 825 | open_export_scene_modal = false; |
| 826 | } |
| 827 | |
| 828 | bool open = true; |
| 829 | if (!ImGui::BeginPopupModal("Export Scene", &open, ImGuiWindowFlags_AlwaysAutoResize)) |
| 830 | { |
| 831 | return; |
| 832 | } |
| 833 | |
| 834 | ImGui::Text("Directory:"); |
| 835 | ImGui::TextWrapped("%s", scenes_directory.empty() ? "<unresolved>" : scenes_directory.c_str()); |
| 836 | ImGui::InputText("Filename", export_scene_filename, IM_ARRAYSIZE(export_scene_filename)); |
| 837 | |
| 838 | if (ImGui::Button("Save")) |
| 839 | { |
| 840 | std::string filename = export_scene_filename; |
| 841 | if (filename.empty()) |
| 842 | { |
| 843 | scene_io_status = "Export failed: filename is empty"; |
| 844 | scene_io_error = true; |
| 845 | } |
| 846 | else if (scenes_directory.empty()) |
| 847 | { |
| 848 | scene_io_status = "Export failed: scenes directory unresolved"; |
| 849 | scene_io_error = true; |
| 850 | } |
| 851 | else |
| 852 | { |
| 853 | std::filesystem::path output = std::filesystem::path(scenes_directory) / filename; |
| 854 | if (output.extension().string().empty()) output.replace_extension(".json"); |
| 855 | scene_file_path = output.string(); |
| 856 | save_scene_to_file(scene_file_path); |
| 857 | load_scenes(); |
| 858 | } |
| 859 | |
| 860 | ImGui::CloseCurrentPopup(); |
| 861 | } |
| 862 | ImGui::SameLine(); |
| 863 | if (ImGui::Button("Cancel")) |
| 864 | { |
| 865 | ImGui::CloseCurrentPopup(); |
| 866 | } |
| 867 | |
| 868 | ImGui::EndPopup(); |
| 869 | } |
| 870 | |
| 871 | void pathtracer_2d::on_window_resize(int2 size) |
| 872 | { |