diff options
| author | Jonathan Bradley <jcb@pikum.xyz> | 2025-02-18 19:34:34 -0500 |
|---|---|---|
| committer | Jonathan Bradley <jcb@pikum.xyz> | 2025-02-18 19:34:34 -0500 |
| commit | fae5df7328306078421cfdda65279f7e90f7658f (patch) | |
| tree | f9ef2dce3d9bab2452e5582574409610a08d5ba9 /editor | |
| parent | cdad60ab666ac27209138ba127d91caf7337e6fc (diff) | |
pke-editor: modal for mtsdf settings and gen
Diffstat (limited to 'editor')
| -rw-r--r-- | editor/editor.cpp | 53 |
1 files changed, 42 insertions, 11 deletions
diff --git a/editor/editor.cpp b/editor/editor.cpp index 27d993e..860e470 100644 --- a/editor/editor.cpp +++ b/editor/editor.cpp @@ -838,16 +838,48 @@ void GenerateMTSDF(FontTypeMSDFSettings *msdf_settings, const Asset *a) { FontType_RegisterFont(font_title, ah_image, ah_glyphs, &ft_spacing); } +bool RecordImGui_GenerateMTSDFModal() { + bool ret_value = false; + static struct FontTypeMSDFSettings msdf_settings{}; + if (ImGui::BeginPopupModal("MTSDFModal", nullptr, ImGuiWindowFlags_AlwaysAutoResize)) { + + ImGui::InputFloat("Minimum Scale", &msdf_settings.minimum_scale); + ImGui::InputFloat("Pixel Range", &msdf_settings.px_range); + + ImGui::Text("Select font:"); + ImGui::BeginDisabled(msdf_settings.minimum_scale <= 0.0 || msdf_settings.px_range <= 0.0); + pk_handle_bucket_index_T asset_bucket_count = AM_GetBucketCount(); + for (pk_handle_bucket_index_T b = 0; b < asset_bucket_count; ++b) { + pk_handle_item_index_T count; + auto *assets = AM_GetAssets(b, count); + for (pk_handle_item_index_T i = 0; i < count; ++i) { + const auto &asset = assets[i]; + if (asset.handle == EntityHandle_MAX) + continue; + if (!PK_HAS_FLAG(asset.type, PKE_ASSET_TYPE_FONT)) { + continue; + } + if (ImGui::Selectable(asset.basePath)) { + GenerateMTSDF(&msdf_settings, &asset); + ImGui::CloseCurrentPopup(); + } + } + } + ImGui::EndDisabled(); + ImGui::Separator(); + if (ImGui::Button("Cancel")) { + ImGui::CloseCurrentPopup(); + } + ImGui::EndPopup(); + } + return ret_value; +} + void RecordImGuiAssets() { if (!ImGui::Begin("AssetList")) { ImGui::End(); return; } - // TODO this needs stored somewhere. - // User should input these values on a per-font basis. - struct FontTypeMSDFSettings msdf_settings{}; - msdf_settings.minimum_scale = 7 * 2; - msdf_settings.px_range = 2; static ImGuiTableFlags tableFlags{ ImGuiTableFlags_Borders | @@ -875,11 +907,7 @@ void RecordImGuiAssets() { ImGui::PushID(i); ImGui::TableNextRow(); ImGui::TableSetColumnIndex(0); - if ((asset.type & PKE_ASSET_TYPE_FONT) != PKE_ASSET_TYPE_UNSET) { - if (ImGui::Button("Create MTSDF")) { - GenerateMTSDF(&msdf_settings, &asset); - } - } + // buttons go here ImGui::TableSetColumnIndex(1); ImGui::Text("%i", (uint8_t)asset.type); ImGui::TableSetColumnIndex(2); @@ -897,7 +925,6 @@ void RecordImGuiAssets() { ImGui::PopID(); } ImGui::EndTable(); - } ImGui::End(); } @@ -1494,6 +1521,9 @@ void RecordImGuiSceneEditor() { if (ImGui::Button("Create Entity Type")) { ImGui::OpenPopup("CreateEntityType"); } + if (ImGui::Button("Generate MTSDF")) { + ImGui::OpenPopup("MTSDFModal"); + } if (ImGui::Button("Clear Selection")) { selectedEntity = nullptr; } @@ -1547,6 +1577,7 @@ void RecordImGuiSceneEditor() { RecordImGuiModalCreateAsset(); RecordImGuiModalCreateEntityType(); + RecordImGui_GenerateMTSDFModal(); ImGui::End(); } |
