diff --git a/Editor/AnimationWindow.cpp b/Editor/AnimationWindow.cpp index adc845439..dad5f38e2 100644 --- a/Editor/AnimationWindow.cpp +++ b/Editor/AnimationWindow.cpp @@ -190,7 +190,7 @@ void AnimationWindow::Create(EditorComponent* _editor) recordCombo.selected_font.anim.typewriter.character_start = 1; recordCombo.SetSize(XMFLOAT2(wid, hei)); recordCombo.SetPos(XMFLOAT2(x, y += step)); - recordCombo.AddItem("..."); + recordCombo.SetInvalidSelectionText("..."); recordCombo.AddItem("Transform " ICON_TRANSLATE " " ICON_ROTATE " " ICON_SCALE); recordCombo.AddItem("Position " ICON_TRANSLATE); recordCombo.AddItem("Rotation " ICON_ROTATE); @@ -203,9 +203,6 @@ void AnimationWindow::Create(EditorComponent* _editor) recordCombo.AddItem("Light [outer cone] " ICON_POINTLIGHT); recordCombo.AddItem("Close loop " ICON_LOOP, ~0ull); recordCombo.OnSelect([&](wi::gui::EventArgs args) { - if (args.iValue == 0) - return; - wi::scene::Scene& scene = editor->GetCurrentScene(); AnimationComponent* animation = scene.animations.GetComponent(entity); @@ -299,36 +296,36 @@ void AnimationWindow::Create(EditorComponent* _editor) switch (args.iValue) { default: + case 0: + paths.push_back(AnimationComponent::AnimationChannel::Path::TRANSLATION); + paths.push_back(AnimationComponent::AnimationChannel::Path::ROTATION); + paths.push_back(AnimationComponent::AnimationChannel::Path::SCALE); + break; case 1: paths.push_back(AnimationComponent::AnimationChannel::Path::TRANSLATION); - paths.push_back(AnimationComponent::AnimationChannel::Path::ROTATION); - paths.push_back(AnimationComponent::AnimationChannel::Path::SCALE); break; case 2: - paths.push_back(AnimationComponent::AnimationChannel::Path::TRANSLATION); - break; - case 3: paths.push_back(AnimationComponent::AnimationChannel::Path::ROTATION); break; - case 4: + case 3: paths.push_back(AnimationComponent::AnimationChannel::Path::SCALE); break; - case 5: + case 4: paths.push_back(AnimationComponent::AnimationChannel::Path::WEIGHTS); break; - case 6: + case 5: paths.push_back(AnimationComponent::AnimationChannel::Path::LIGHT_COLOR); break; - case 7: + case 6: paths.push_back(AnimationComponent::AnimationChannel::Path::LIGHT_INTENSITY); break; - case 8: + case 7: paths.push_back(AnimationComponent::AnimationChannel::Path::LIGHT_RANGE); break; - case 9: + case 8: paths.push_back(AnimationComponent::AnimationChannel::Path::LIGHT_INNERCONE); break; - case 10: + case 9: paths.push_back(AnimationComponent::AnimationChannel::Path::LIGHT_OUTERCONE); break; } @@ -523,7 +520,7 @@ void AnimationWindow::Create(EditorComponent* _editor) } } } - recordCombo.SetSelectedWithoutCallback(0); + recordCombo.SetSelectedWithoutCallback(-1); RefreshKeyframesList(); }); recordCombo.SetTooltip("Record selected entities' specified channels into the animation at the current time."); diff --git a/Editor/ComponentsWindow.cpp b/Editor/ComponentsWindow.cpp index cd8b43a43..a6f9b5c4e 100644 --- a/Editor/ComponentsWindow.cpp +++ b/Editor/ComponentsWindow.cpp @@ -39,7 +39,7 @@ void ComponentsWindow::Create(EditorComponent* _editor) newComponentCombo.selected_font.anim.typewriter.time = 2; newComponentCombo.selected_font.anim.typewriter.character_start = 1; newComponentCombo.SetTooltip("Add a component to the first selected entity."); - newComponentCombo.AddItem("...", ~0ull); + newComponentCombo.SetInvalidSelectionText("..."); newComponentCombo.AddItem("Name", 0); newComponentCombo.AddItem("Layer " ICON_LAYER, 1); newComponentCombo.AddItem("Transform " ICON_TRANSFORM, 2); @@ -56,7 +56,7 @@ void ComponentsWindow::Create(EditorComponent* _editor) newComponentCombo.AddItem("Force Field " ICON_FORCE, 13); newComponentCombo.AddItem("Animation " ICON_ANIMATION, 14); newComponentCombo.OnSelect([=](wi::gui::EventArgs args) { - newComponentCombo.SetSelectedWithoutCallback(0); + newComponentCombo.SetSelectedWithoutCallback(-1); if (editor->translator.selected.empty()) return; Scene& scene = editor->GetCurrentScene(); diff --git a/Editor/OptionsWindow.cpp b/Editor/OptionsWindow.cpp index c71552acc..633dbbc76 100644 --- a/Editor/OptionsWindow.cpp +++ b/Editor/OptionsWindow.cpp @@ -134,7 +134,9 @@ void OptionsWindow::Create(EditorComponent* _editor) newCombo.selected_font.anim.typewriter.looped = true; newCombo.selected_font.anim.typewriter.time = 2; newCombo.selected_font.anim.typewriter.character_start = 1; - newCombo.AddItem("...", ~0ull); + newCombo.SetInvalidSelectionText("..."); + newCombo.AddItem("Cube " ICON_CUBE, 13); + newCombo.AddItem("Plane " ICON_SQUARE, 14); newCombo.AddItem("Transform " ICON_TRANSFORM, 0); newCombo.AddItem("Material " ICON_MATERIAL, 1); newCombo.AddItem("Point Light " ICON_POINTLIGHT, 2); @@ -148,11 +150,9 @@ void OptionsWindow::Create(EditorComponent* _editor) newCombo.AddItem("Emitter " ICON_EMITTER, 10); newCombo.AddItem("HairParticle " ICON_HAIR, 11); newCombo.AddItem("Camera " ICON_CAMERA, 12); - newCombo.AddItem("Cube Object " ICON_CUBE, 13); - newCombo.AddItem("Plane Object " ICON_SQUARE, 14); newCombo.AddItem("Animation " ICON_ANIMATION, 15); newCombo.OnSelect([&](wi::gui::EventArgs args) { - newCombo.SetSelectedWithoutCallback(0); + newCombo.SetSelectedWithoutCallback(-1); const EditorComponent::EditorScene& editorscene = editor->GetCurrentEditorScene(); const CameraComponent& camera = editorscene.camera; Scene& scene = editor->GetCurrentScene(); diff --git a/Editor/TerrainGenerator.cpp b/Editor/TerrainGenerator.cpp index 82fa41555..d9c17abec 100644 --- a/Editor/TerrainGenerator.cpp +++ b/Editor/TerrainGenerator.cpp @@ -469,25 +469,25 @@ void TerrainGenerator::Create() addModifierCombo.SetTooltip("Add a new modifier that will affect terrain generation."); addModifierCombo.SetSize(XMFLOAT2(wid, hei)); addModifierCombo.SetPos(XMFLOAT2(x, y += step)); - addModifierCombo.AddItem("..."); + addModifierCombo.SetInvalidSelectionText("..."); addModifierCombo.AddItem("Perlin Noise"); addModifierCombo.AddItem("Voronoi Noise"); addModifierCombo.AddItem("Heightmap Image"); addModifierCombo.OnSelect([this](wi::gui::EventArgs args) { - addModifierCombo.SetSelectedWithoutCallback(0); + addModifierCombo.SetSelectedWithoutCallback(-1); Generation_Cancel(); switch (args.iValue) { default: break; - case 1: + case 0: AddModifier(new PerlinModifier); break; - case 2: + case 1: AddModifier(new VoronoiModifier); break; - case 3: + case 2: AddModifier(new HeightmapModifier); break; } diff --git a/WickedEngine/wiGUI.cpp b/WickedEngine/wiGUI.cpp index d8270efa6..85f46b119 100644 --- a/WickedEngine/wiGUI.cpp +++ b/WickedEngine/wiGUI.cpp @@ -2192,10 +2192,14 @@ namespace wi::gui if (selected >= 0) { selected_font.SetText(items[selected].name); - selected_font.params.posX = translation.x + scale.x * 0.5f; - selected_font.params.posY = translation.y + scale.y * 0.5f; - selected_font.Update(dt); } + else + { + selected_font.SetText(invalid_selection_text); + } + selected_font.params.posX = translation.x + scale.x * 0.5f; + selected_font.params.posY = translation.y + scale.y * 0.5f; + selected_font.Update(dt); } void ComboBox::Render(const wi::Canvas& canvas, CommandList cmd) const { @@ -2282,10 +2286,7 @@ namespace wi::gui // control-base sprites[state].Draw(cmd); - if (selected >= 0) - { - selected_font.Draw(cmd); - } + selected_font.Draw(cmd); // drop-down if (state == ACTIVE) @@ -2385,7 +2386,7 @@ namespace wi::gui items.back().name = name; items.back().userdata = userdata; - if (selected < 0) + if (selected < 0 && invalid_selection_text.empty()) { selected = 0; } @@ -2469,6 +2470,10 @@ namespace wi::gui { items[index].userdata = userdata; } + void ComboBox::SetInvalidSelectionText(const std::string& text) + { + wi::helper::StringConvert(text, invalid_selection_text); + } std::string ComboBox::GetItemText(int index) const { if (index >= 0) diff --git a/WickedEngine/wiGUI.h b/WickedEngine/wiGUI.h index 73cbd76a3..be11aa796 100644 --- a/WickedEngine/wiGUI.h +++ b/WickedEngine/wiGUI.h @@ -519,6 +519,7 @@ namespace wi::gui wi::vector items; wi::Color drop_color = wi::Color::Ghost(); + std::wstring invalid_selection_text; float GetDropOffset(const wi::Canvas& canvas) const; float GetItemOffset(const wi::Canvas& canvas, int index) const; @@ -541,6 +542,7 @@ namespace wi::gui std::string GetItemText(int index) const; uint64_t GetItemUserData(int index) const; size_t GetItemCount() const { return items.size(); } + void SetInvalidSelectionText(const std::string& text); void Update(const wi::Canvas& canvas, float dt) override; void Render(const wi::Canvas& canvas, wi::graphics::CommandList cmd) const override; diff --git a/WickedEngine/wiVersion.cpp b/WickedEngine/wiVersion.cpp index 83a766514..b5a8675e0 100644 --- a/WickedEngine/wiVersion.cpp +++ b/WickedEngine/wiVersion.cpp @@ -9,7 +9,7 @@ namespace wi::version // minor features, major updates, breaking compatibility changes const int minor = 71; // minor bug fixes, alterations, refactors, updates - const int revision = 18; + const int revision = 19; const std::string version_string = std::to_string(major) + "." + std::to_string(minor) + "." + std::to_string(revision);