diff options
| author | Jonathan Bradley <jcb@pikum.xyz> | 2024-01-05 08:06:32 -0500 |
|---|---|---|
| committer | Jonathan Bradley <jcb@pikum.xyz> | 2024-01-05 08:06:32 -0500 |
| commit | ef6cb7fd7cd8c5ddfc894fb65dde7b86cb586c18 (patch) | |
| tree | 3cb7ce3bb856b76fe9f40070475c81c656069b97 /editor | |
| parent | b2a8cab15fe0790ea74f446d1aa92fd96c924660 (diff) | |
refactor AssetType checkboxes to flags
Diffstat (limited to 'editor')
| -rw-r--r-- | editor/editor.cpp | 31 |
1 files changed, 10 insertions, 21 deletions
diff --git a/editor/editor.cpp b/editor/editor.cpp index 40f187a..0743db9 100644 --- a/editor/editor.cpp +++ b/editor/editor.cpp @@ -511,29 +511,21 @@ void RecordImGuiModalCreateAsset() { ImGui::InputText("Asset Key", assetKey, AssetKeyLength); - static bool bShader = false, bModel = false, bTexture = false, bAudio = false; - if (ImGui::Checkbox("Shader", &bShader)) { - bModel = false; - bTexture = false; - bAudio = false; + static uint32_t assetTypeMask = 0U; + if (ImGui::CheckboxFlags("Shader", &assetTypeMask, 1U << static_cast<AssetType_T>(PKE_ASSET_TYPE_SHADER))) { + assetTypeMask = assetTypeMask & (1U << static_cast<AssetType_T>(PKE_ASSET_TYPE_SHADER)); type = PKE_ASSET_TYPE_SHADER; } - if (ImGui::Checkbox("Model", &bModel)) { - bShader = false; - bTexture = false; - bAudio = false; + if (ImGui::CheckboxFlags("Model", &assetTypeMask, 1U << static_cast<AssetType_T>(PKE_ASSET_TYPE_MODEL))) { + assetTypeMask = assetTypeMask & (1U << static_cast<AssetType_T>(PKE_ASSET_TYPE_MODEL)); type = PKE_ASSET_TYPE_MODEL; } - if (ImGui::Checkbox("Texture", &bTexture)) { - bShader = false; - bModel = false; - bAudio = false; + if (ImGui::CheckboxFlags("Texture", &assetTypeMask, 1U << static_cast<AssetType_T>(PKE_ASSET_TYPE_TEXTURE))) { + assetTypeMask = assetTypeMask & (1U << static_cast<AssetType_T>(PKE_ASSET_TYPE_TEXTURE)); type = PKE_ASSET_TYPE_TEXTURE; } - if (ImGui::Checkbox("Audio", &bAudio)) { - bShader = false; - bModel = false; - bTexture = false; + if (ImGui::CheckboxFlags("Audio", &assetTypeMask, 1U << static_cast<AssetType_T>(PKE_ASSET_TYPE_AUDIO))) { + assetTypeMask = assetTypeMask & (1U << static_cast<AssetType_T>(PKE_ASSET_TYPE_AUDIO)); type = PKE_ASSET_TYPE_AUDIO; } @@ -562,10 +554,7 @@ void RecordImGuiModalCreateAsset() { if (shouldClose) { type = PKE_ASSET_TYPE_UNSET; - bModel = false; - bTexture = false; - bModel = false; - bAudio = false; + assetTypeMask = 0U; assetKey[0] = '\0'; assetPath[0] = '\0'; ImGui::CloseCurrentPopup(); |
