From 510fd5dce7507d7796a963fbb1c602696721a184 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tur=C3=A1nszki=20J=C3=A1nos?= Date: Tue, 23 Jul 2024 06:56:01 +0200 Subject: [PATCH] editor: added multiselection edit for many things --- Editor/CameraComponentWindow.cpp | 121 ++++--- Editor/ColliderWindow.cpp | 140 ++++---- Editor/DecalWindow.cpp | 18 +- Editor/EmitterWindow.cpp | 332 +++++++++++++------ Editor/EnvProbeWindow.cpp | 139 ++++---- Editor/FontWindow.cpp | 405 ++++++++++++++--------- Editor/ForceFieldWindow.cpp | 23 +- Editor/HairParticleWindow.cpp | 92 ++++-- Editor/HierarchyWindow.cpp | 4 +- Editor/IKWindow.cpp | 43 ++- Editor/LayerWindow.cpp | 64 ++-- Editor/MaterialWindow.cpp | 395 ++++++++++++++++------ Editor/MeshWindow.cpp | 144 ++++++--- Editor/NameWindow.cpp | 13 +- Editor/ScriptWindow.cpp | 36 ++- Editor/SoundWindow.cpp | 96 ++++-- Editor/SpringWindow.cpp | 91 ++++-- Editor/SpriteWindow.cpp | 540 +++++++++++++++++++------------ Editor/TransformWindow.cpp | 2 +- 19 files changed, 1752 insertions(+), 946 deletions(-) diff --git a/Editor/CameraComponentWindow.cpp b/Editor/CameraComponentWindow.cpp index a215af20b..7401e107b 100644 --- a/Editor/CameraComponentWindow.cpp +++ b/Editor/CameraComponentWindow.cpp @@ -82,7 +82,7 @@ void CameraComponentWindow::Create(EditorComponent* _editor) editor->RecordEntity(archive, entity); editor->componentsWnd.RefreshEntityTree(); - }); + }); float x = 140; float y = 0; @@ -96,13 +96,16 @@ void CameraComponentWindow::Create(EditorComponent* _editor) farPlaneSlider.SetPos(XMFLOAT2(x, y)); farPlaneSlider.SetValue(editor->GetCurrentEditorScene().camera.zFarP); farPlaneSlider.OnSlide([=](wi::gui::EventArgs args) { - Scene& scene = editor->GetCurrentScene(); - CameraComponent* camera = scene.cameras.GetComponent(entity); - if (camera == nullptr) - return; - camera->zFarP = args.fValue; - camera->SetDirty(); - }); + wi::scene::Scene& scene = editor->GetCurrentScene(); + for (auto& x : editor->translator.selected) + { + CameraComponent* camera = scene.cameras.GetComponent(x.entity); + if (camera == nullptr) + continue; + camera->zFarP = args.fValue; + camera->SetDirty(); + } + }); AddWidget(&farPlaneSlider); nearPlaneSlider.Create(0.01f, 10, 0.1f, 10000, "Near Plane: "); @@ -111,13 +114,16 @@ void CameraComponentWindow::Create(EditorComponent* _editor) nearPlaneSlider.SetPos(XMFLOAT2(x, y += step)); nearPlaneSlider.SetValue(editor->GetCurrentEditorScene().camera.zNearP); nearPlaneSlider.OnSlide([=](wi::gui::EventArgs args) { - Scene& scene = editor->GetCurrentScene(); - CameraComponent* camera = scene.cameras.GetComponent(entity); - if (camera == nullptr) - return; - camera->zNearP = args.fValue; - camera->SetDirty(); - }); + wi::scene::Scene& scene = editor->GetCurrentScene(); + for (auto& x : editor->translator.selected) + { + CameraComponent* camera = scene.cameras.GetComponent(x.entity); + if (camera == nullptr) + continue; + camera->zNearP = args.fValue; + camera->SetDirty(); + } + }); AddWidget(&nearPlaneSlider); fovSlider.Create(1, 179, 60, 10000, "FOV: "); @@ -126,13 +132,16 @@ void CameraComponentWindow::Create(EditorComponent* _editor) fovSlider.SetPos(XMFLOAT2(x, y += step)); fovSlider.SetValue(editor->GetCurrentEditorScene().camera.fov / XM_PI * 180.f); fovSlider.OnSlide([=](wi::gui::EventArgs args) { - Scene& scene = editor->GetCurrentScene(); - CameraComponent* camera = scene.cameras.GetComponent(entity); - if (camera == nullptr) - return; - camera->fov = args.fValue / 180.f * XM_PI; - camera->SetDirty(); - }); + wi::scene::Scene& scene = editor->GetCurrentScene(); + for (auto& x : editor->translator.selected) + { + CameraComponent* camera = scene.cameras.GetComponent(x.entity); + if (camera == nullptr) + continue; + camera->fov = args.fValue / 180.f * XM_PI; + camera->SetDirty(); + } + }); AddWidget(&fovSlider); focalLengthSlider.Create(0.001f, 100, 1, 10000, "Focal Length: "); @@ -140,13 +149,16 @@ void CameraComponentWindow::Create(EditorComponent* _editor) focalLengthSlider.SetSize(XMFLOAT2(wid, hei)); focalLengthSlider.SetPos(XMFLOAT2(x, y += step)); focalLengthSlider.OnSlide([=](wi::gui::EventArgs args) { - Scene& scene = editor->GetCurrentScene(); - CameraComponent* camera = scene.cameras.GetComponent(entity); - if (camera == nullptr) - return; - camera->focal_length = args.fValue; - camera->SetDirty(); - }); + wi::scene::Scene& scene = editor->GetCurrentScene(); + for (auto& x : editor->translator.selected) + { + CameraComponent* camera = scene.cameras.GetComponent(x.entity); + if (camera == nullptr) + continue; + camera->focal_length = args.fValue; + camera->SetDirty(); + } + }); AddWidget(&focalLengthSlider); apertureSizeSlider.Create(0, 1, 0, 10000, "Aperture Size: "); @@ -154,13 +166,16 @@ void CameraComponentWindow::Create(EditorComponent* _editor) apertureSizeSlider.SetSize(XMFLOAT2(wid, hei)); apertureSizeSlider.SetPos(XMFLOAT2(x, y += step)); apertureSizeSlider.OnSlide([=](wi::gui::EventArgs args) { - Scene& scene = editor->GetCurrentScene(); - CameraComponent* camera = scene.cameras.GetComponent(entity); - if (camera == nullptr) - return; - camera->aperture_size = args.fValue; - camera->SetDirty(); - }); + wi::scene::Scene& scene = editor->GetCurrentScene(); + for (auto& x : editor->translator.selected) + { + CameraComponent* camera = scene.cameras.GetComponent(x.entity); + if (camera == nullptr) + continue; + camera->aperture_size = args.fValue; + camera->SetDirty(); + } + }); AddWidget(&apertureSizeSlider); apertureShapeXSlider.Create(0, 2, 1, 10000, "Aperture Shape X: "); @@ -168,13 +183,16 @@ void CameraComponentWindow::Create(EditorComponent* _editor) apertureShapeXSlider.SetSize(XMFLOAT2(wid, hei)); apertureShapeXSlider.SetPos(XMFLOAT2(x, y += step)); apertureShapeXSlider.OnSlide([=](wi::gui::EventArgs args) { - Scene& scene = editor->GetCurrentScene(); - CameraComponent* camera = scene.cameras.GetComponent(entity); - if (camera == nullptr) - return; - camera->aperture_shape.x = args.fValue; - camera->SetDirty(); - }); + wi::scene::Scene& scene = editor->GetCurrentScene(); + for (auto& x : editor->translator.selected) + { + CameraComponent* camera = scene.cameras.GetComponent(x.entity); + if (camera == nullptr) + continue; + camera->aperture_shape.x = args.fValue; + camera->SetDirty(); + } + }); AddWidget(&apertureShapeXSlider); apertureShapeYSlider.Create(0, 2, 1, 10000, "Aperture Shape Y: "); @@ -182,13 +200,16 @@ void CameraComponentWindow::Create(EditorComponent* _editor) apertureShapeYSlider.SetSize(XMFLOAT2(wid, hei)); apertureShapeYSlider.SetPos(XMFLOAT2(x, y += step)); apertureShapeYSlider.OnSlide([=](wi::gui::EventArgs args) { - Scene& scene = editor->GetCurrentScene(); - CameraComponent* camera = scene.cameras.GetComponent(entity); - if (camera == nullptr) - return; - camera->aperture_shape.y = args.fValue; - camera->SetDirty(); - }); + wi::scene::Scene& scene = editor->GetCurrentScene(); + for (auto& x : editor->translator.selected) + { + CameraComponent* camera = scene.cameras.GetComponent(x.entity); + if (camera == nullptr) + continue; + camera->aperture_shape.y = args.fValue; + camera->SetDirty(); + } + }); AddWidget(&apertureShapeYSlider); diff --git a/Editor/ColliderWindow.cpp b/Editor/ColliderWindow.cpp index be6680cd3..36c53c974 100644 --- a/Editor/ColliderWindow.cpp +++ b/Editor/ColliderWindow.cpp @@ -23,7 +23,7 @@ void ColliderWindow::Create(EditorComponent* _editor) editor->RecordEntity(archive, entity); editor->componentsWnd.RefreshEntityTree(); - }); + }); float x = 60; float y = 4; @@ -41,12 +41,14 @@ void ColliderWindow::Create(EditorComponent* _editor) cpuCheckBox.SetSize(XMFLOAT2(hei, hei)); cpuCheckBox.OnClick([=](wi::gui::EventArgs args) { wi::scene::Scene& scene = editor->GetCurrentScene(); - ColliderComponent* collider = scene.colliders.GetComponent(entity); - if (collider == nullptr) - return; - - collider->SetCPUEnabled(args.bValue); - }); + for (auto& x : editor->translator.selected) + { + ColliderComponent* collider = scene.colliders.GetComponent(x.entity); + if (collider == nullptr) + continue; + collider->SetCPUEnabled(args.bValue); + } + }); AddWidget(&cpuCheckBox); gpuCheckBox.Create("GPU: "); @@ -54,12 +56,14 @@ void ColliderWindow::Create(EditorComponent* _editor) gpuCheckBox.SetSize(XMFLOAT2(hei, hei)); gpuCheckBox.OnClick([=](wi::gui::EventArgs args) { wi::scene::Scene& scene = editor->GetCurrentScene(); - ColliderComponent* collider = scene.colliders.GetComponent(entity); - if (collider == nullptr) - return; - - collider->SetGPUEnabled(args.bValue); - }); + for (auto& x : editor->translator.selected) + { + ColliderComponent* collider = scene.colliders.GetComponent(x.entity); + if (collider == nullptr) + continue; + collider->SetGPUEnabled(args.bValue); + } + }); AddWidget(&gpuCheckBox); shapeCombo.Create("Shape: "); @@ -70,11 +74,13 @@ void ColliderWindow::Create(EditorComponent* _editor) shapeCombo.AddItem("Plane", (uint64_t)ColliderComponent::Shape::Plane); shapeCombo.OnSelect([=](wi::gui::EventArgs args) { wi::scene::Scene& scene = editor->GetCurrentScene(); - ColliderComponent* collider = scene.colliders.GetComponent(entity); - if (collider == nullptr) - return; - - collider->shape = (ColliderComponent::Shape)args.userdata; + for (auto& x : editor->translator.selected) + { + ColliderComponent* collider = scene.colliders.GetComponent(x.entity); + if (collider == nullptr) + continue; + collider->shape = (ColliderComponent::Shape)args.userdata; + } }); AddWidget(&shapeCombo); @@ -83,12 +89,14 @@ void ColliderWindow::Create(EditorComponent* _editor) radiusSlider.SetPos(XMFLOAT2(x, y += step)); radiusSlider.OnSlide([&](wi::gui::EventArgs args) { wi::scene::Scene& scene = editor->GetCurrentScene(); - ColliderComponent* collider = scene.colliders.GetComponent(entity); - if (collider == nullptr) - return; - - collider->radius = args.fValue; - }); + for (auto& x : editor->translator.selected) + { + ColliderComponent* collider = scene.colliders.GetComponent(x.entity); + if (collider == nullptr) + continue; + collider->radius = args.fValue; + } + }); AddWidget(&radiusSlider); @@ -100,12 +108,14 @@ void ColliderWindow::Create(EditorComponent* _editor) offsetX.SetPos(XMFLOAT2(x, y += step)); offsetX.OnSlide([=](wi::gui::EventArgs args) { wi::scene::Scene& scene = editor->GetCurrentScene(); - ColliderComponent* collider = scene.colliders.GetComponent(entity); - if (collider == nullptr) - return; - - collider->offset.x = args.fValue; - }); + for (auto& x : editor->translator.selected) + { + ColliderComponent* collider = scene.colliders.GetComponent(x.entity); + if (collider == nullptr) + continue; + collider->offset.x = args.fValue; + } + }); AddWidget(&offsetX); offsetY.Create(-10, 10, 0, 10000, "Offset Y: "); @@ -113,12 +123,14 @@ void ColliderWindow::Create(EditorComponent* _editor) offsetY.SetPos(XMFLOAT2(x, y += step)); offsetY.OnSlide([=](wi::gui::EventArgs args) { wi::scene::Scene& scene = editor->GetCurrentScene(); - ColliderComponent* collider = scene.colliders.GetComponent(entity); - if (collider == nullptr) - return; - - collider->offset.y = args.fValue; - }); + for (auto& x : editor->translator.selected) + { + ColliderComponent* collider = scene.colliders.GetComponent(x.entity); + if (collider == nullptr) + continue; + collider->offset.y = args.fValue; + } + }); AddWidget(&offsetY); offsetZ.Create(-10, 10, 0, 10000, "Offset Z: "); @@ -126,12 +138,14 @@ void ColliderWindow::Create(EditorComponent* _editor) offsetZ.SetPos(XMFLOAT2(x, y += step)); offsetZ.OnSlide([=](wi::gui::EventArgs args) { wi::scene::Scene& scene = editor->GetCurrentScene(); - ColliderComponent* collider = scene.colliders.GetComponent(entity); - if (collider == nullptr) - return; - - collider->offset.z = args.fValue; - }); + for (auto& x : editor->translator.selected) + { + ColliderComponent* collider = scene.colliders.GetComponent(x.entity); + if (collider == nullptr) + continue; + collider->offset.z = args.fValue; + } + }); AddWidget(&offsetZ); @@ -143,12 +157,14 @@ void ColliderWindow::Create(EditorComponent* _editor) tailX.SetPos(XMFLOAT2(x, y += step)); tailX.OnSlide([=](wi::gui::EventArgs args) { wi::scene::Scene& scene = editor->GetCurrentScene(); - ColliderComponent* collider = scene.colliders.GetComponent(entity); - if (collider == nullptr) - return; - - collider->tail.x = args.fValue; - }); + for (auto& x : editor->translator.selected) + { + ColliderComponent* collider = scene.colliders.GetComponent(x.entity); + if (collider == nullptr) + continue; + collider->tail.x = args.fValue; + } + }); AddWidget(&tailX); tailY.Create(-10, 10, 0, 10000, "Tail Y: "); @@ -156,12 +172,14 @@ void ColliderWindow::Create(EditorComponent* _editor) tailY.SetPos(XMFLOAT2(x, y += step)); tailY.OnSlide([=](wi::gui::EventArgs args) { wi::scene::Scene& scene = editor->GetCurrentScene(); - ColliderComponent* collider = scene.colliders.GetComponent(entity); - if (collider == nullptr) - return; - - collider->tail.y = args.fValue; - }); + for (auto& x : editor->translator.selected) + { + ColliderComponent* collider = scene.colliders.GetComponent(x.entity); + if (collider == nullptr) + continue; + collider->tail.y = args.fValue; + } + }); AddWidget(&tailY); tailZ.Create(-10, 10, 0, 10000, "Tail Z: "); @@ -169,12 +187,14 @@ void ColliderWindow::Create(EditorComponent* _editor) tailZ.SetPos(XMFLOAT2(x, y += step)); tailZ.OnSlide([=](wi::gui::EventArgs args) { wi::scene::Scene& scene = editor->GetCurrentScene(); - ColliderComponent* collider = scene.colliders.GetComponent(entity); - if (collider == nullptr) - return; - - collider->tail.z = args.fValue; - }); + for (auto& x : editor->translator.selected) + { + ColliderComponent* collider = scene.colliders.GetComponent(x.entity); + if (collider == nullptr) + continue; + collider->tail.z = args.fValue; + } + }); AddWidget(&tailZ); diff --git a/Editor/DecalWindow.cpp b/Editor/DecalWindow.cpp index 22bb31469..213231121 100644 --- a/Editor/DecalWindow.cpp +++ b/Editor/DecalWindow.cpp @@ -23,7 +23,7 @@ void DecalWindow::Create(EditorComponent* _editor) editor->RecordEntity(archive, entity); editor->componentsWnd.RefreshEntityTree(); - }); + }); float x = 200; float y = 0; @@ -43,10 +43,12 @@ void DecalWindow::Create(EditorComponent* _editor) onlyalphaCheckBox.SetSize(XMFLOAT2(hei, hei)); onlyalphaCheckBox.SetTooltip("You can enable this to only use alpha channel from basecolor map. Useful for blending normalmap-only decals."); onlyalphaCheckBox.OnClick([=](wi::gui::EventArgs args) { - Scene& scene = editor->GetCurrentScene(); - DecalComponent* decal = scene.decals.GetComponent(entity); - if (decal != nullptr) + wi::scene::Scene& scene = editor->GetCurrentScene(); + for (auto& x : editor->translator.selected) { + DecalComponent* decal = scene.decals.GetComponent(x.entity); + if (decal == nullptr) + continue; decal->SetBaseColorOnlyAlpha(args.bValue); } }); @@ -56,10 +58,12 @@ void DecalWindow::Create(EditorComponent* _editor) slopeBlendPowerSlider.SetSize(XMFLOAT2(100, hei)); slopeBlendPowerSlider.SetTooltip("Set a power factor for blending on surface slopes. 0 = no slope blend, increasing = more slope blend"); slopeBlendPowerSlider.OnSlide([=](wi::gui::EventArgs args) { - Scene& scene = editor->GetCurrentScene(); - DecalComponent* decal = scene.decals.GetComponent(entity); - if (decal != nullptr) + wi::scene::Scene& scene = editor->GetCurrentScene(); + for (auto& x : editor->translator.selected) { + DecalComponent* decal = scene.decals.GetComponent(x.entity); + if (decal == nullptr) + continue; decal->slopeBlendPower = args.fValue; } }); diff --git a/Editor/EmitterWindow.cpp b/Editor/EmitterWindow.cpp index 5b0fdf030..855512c02 100644 --- a/Editor/EmitterWindow.cpp +++ b/Editor/EmitterWindow.cpp @@ -22,7 +22,7 @@ void EmitterWindow::Create(EditorComponent* _editor) editor->RecordEntity(archive, entity); editor->componentsWnd.RefreshEntityTree(); - }); + }); float x = 130; float y = 0; @@ -34,9 +34,12 @@ void EmitterWindow::Create(EditorComponent* _editor) restartButton.SetPos(XMFLOAT2(x, y)); restartButton.SetSize(XMFLOAT2(wid, itemheight)); restartButton.OnClick([&](wi::gui::EventArgs args) { - auto emitter = GetEmitter(); - if (emitter != nullptr) + wi::scene::Scene& scene = editor->GetCurrentScene(); + for (auto& x : editor->translator.selected) { + wi::EmittedParticleSystem* emitter = scene.emitters.GetComponent(x.entity); + if (emitter == nullptr) + continue; emitter->Restart(); } }); @@ -45,9 +48,12 @@ void EmitterWindow::Create(EditorComponent* _editor) burstButton.Create("Burst"); burstButton.OnClick([&](wi::gui::EventArgs args) { - auto emitter = GetEmitter(); - if (emitter != nullptr) + wi::scene::Scene& scene = editor->GetCurrentScene(); + for (auto& x : editor->translator.selected) { + wi::EmittedParticleSystem* emitter = scene.emitters.GetComponent(x.entity); + if (emitter == nullptr) + continue; emitter->Burst(std::atoi(burstCountInput.GetValue().c_str())); } }); @@ -66,9 +72,12 @@ void EmitterWindow::Create(EditorComponent* _editor) meshComboBox.SetPos(XMFLOAT2(x, y += step)); meshComboBox.SetEnabled(false); meshComboBox.OnSelect([&](wi::gui::EventArgs args) { - auto emitter = GetEmitter(); - if (emitter != nullptr) + wi::scene::Scene& scene = editor->GetCurrentScene(); + for (auto& x : editor->translator.selected) { + wi::EmittedParticleSystem* emitter = scene.emitters.GetComponent(x.entity); + if (emitter == nullptr) + continue; if (args.iValue == 0) { emitter->meshID = INVALID_ENTITY; @@ -91,9 +100,12 @@ void EmitterWindow::Create(EditorComponent* _editor) shaderTypeComboBox.AddItem("DISTORTION", wi::EmittedParticleSystem::PARTICLESHADERTYPE::SOFT_DISTORTION); shaderTypeComboBox.AddItem("LIGHTING", wi::EmittedParticleSystem::PARTICLESHADERTYPE::SOFT_LIGHTING); shaderTypeComboBox.OnSelect([&](wi::gui::EventArgs args) { - auto emitter = GetEmitter(); - if (emitter != nullptr) + wi::scene::Scene& scene = editor->GetCurrentScene(); + for (auto& x : editor->translator.selected) { + wi::EmittedParticleSystem* emitter = scene.emitters.GetComponent(x.entity); + if (emitter == nullptr) + continue; emitter->shaderType = (wi::EmittedParticleSystem::PARTICLESHADERTYPE)args.userdata; } }); @@ -106,9 +118,12 @@ void EmitterWindow::Create(EditorComponent* _editor) sortCheckBox.SetPos(XMFLOAT2(x, y += step)); sortCheckBox.SetSize(XMFLOAT2(itemheight, itemheight)); sortCheckBox.OnClick([&](wi::gui::EventArgs args) { - auto emitter = GetEmitter(); - if (emitter != nullptr) + wi::scene::Scene& scene = editor->GetCurrentScene(); + for (auto& x : editor->translator.selected) { + wi::EmittedParticleSystem* emitter = scene.emitters.GetComponent(x.entity); + if (emitter == nullptr) + continue; emitter->SetSorted(args.bValue); } }); @@ -121,9 +136,12 @@ void EmitterWindow::Create(EditorComponent* _editor) depthCollisionsCheckBox.SetPos(XMFLOAT2(x, y += step)); depthCollisionsCheckBox.SetSize(XMFLOAT2(itemheight, itemheight)); depthCollisionsCheckBox.OnClick([&](wi::gui::EventArgs args) { - auto emitter = GetEmitter(); - if (emitter != nullptr) + wi::scene::Scene& scene = editor->GetCurrentScene(); + for (auto& x : editor->translator.selected) { + wi::EmittedParticleSystem* emitter = scene.emitters.GetComponent(x.entity); + if (emitter == nullptr) + continue; emitter->SetDepthCollisionEnabled(args.bValue); } }); @@ -136,9 +154,12 @@ void EmitterWindow::Create(EditorComponent* _editor) sphCheckBox.SetPos(XMFLOAT2(x, y += step)); sphCheckBox.SetSize(XMFLOAT2(itemheight, itemheight)); sphCheckBox.OnClick([&](wi::gui::EventArgs args) { - auto emitter = GetEmitter(); - if (emitter != nullptr) + wi::scene::Scene& scene = editor->GetCurrentScene(); + for (auto& x : editor->translator.selected) { + wi::EmittedParticleSystem* emitter = scene.emitters.GetComponent(x.entity); + if (emitter == nullptr) + continue; emitter->SetSPHEnabled(args.bValue); } }); @@ -151,9 +172,12 @@ void EmitterWindow::Create(EditorComponent* _editor) pauseCheckBox.SetPos(XMFLOAT2(x, y += step)); pauseCheckBox.SetSize(XMFLOAT2(itemheight, itemheight)); pauseCheckBox.OnClick([&](wi::gui::EventArgs args) { - auto emitter = GetEmitter(); - if (emitter != nullptr) + wi::scene::Scene& scene = editor->GetCurrentScene(); + for (auto& x : editor->translator.selected) { + wi::EmittedParticleSystem* emitter = scene.emitters.GetComponent(x.entity); + if (emitter == nullptr) + continue; emitter->SetPaused(args.bValue); } }); @@ -177,12 +201,15 @@ void EmitterWindow::Create(EditorComponent* _editor) volumeCheckBox.SetPos(XMFLOAT2(x, y += step)); volumeCheckBox.SetSize(XMFLOAT2(itemheight, itemheight)); volumeCheckBox.OnClick([&](wi::gui::EventArgs args) { - auto emitter = GetEmitter(); - if (emitter != nullptr) + wi::scene::Scene& scene = editor->GetCurrentScene(); + for (auto& x : editor->translator.selected) { + wi::EmittedParticleSystem* emitter = scene.emitters.GetComponent(x.entity); + if (emitter == nullptr) + continue; emitter->SetVolumeEnabled(args.bValue); } - }); + }); volumeCheckBox.SetCheck(false); volumeCheckBox.SetTooltip("Enable volume for the emitter. Particles will be emitted inside volume."); AddWidget(&volumeCheckBox); @@ -192,12 +219,15 @@ void EmitterWindow::Create(EditorComponent* _editor) frameBlendingCheckBox.SetPos(XMFLOAT2(x, y += step)); frameBlendingCheckBox.SetSize(XMFLOAT2(itemheight, itemheight)); frameBlendingCheckBox.OnClick([&](wi::gui::EventArgs args) { - auto emitter = GetEmitter(); - if (emitter != nullptr) + wi::scene::Scene& scene = editor->GetCurrentScene(); + for (auto& x : editor->translator.selected) { + wi::EmittedParticleSystem* emitter = scene.emitters.GetComponent(x.entity); + if (emitter == nullptr) + continue; emitter->SetFrameBlendingEnabled(args.bValue); } - }); + }); frameBlendingCheckBox.SetCheck(false); frameBlendingCheckBox.SetTooltip("If sprite sheet animation is in effect, frames will be smoothly blended."); AddWidget(&frameBlendingCheckBox); @@ -207,12 +237,15 @@ void EmitterWindow::Create(EditorComponent* _editor) collidersDisabledCheckBox.SetPos(XMFLOAT2(x, y += step)); collidersDisabledCheckBox.SetSize(XMFLOAT2(itemheight, itemheight)); collidersDisabledCheckBox.OnClick([&](wi::gui::EventArgs args) { - auto emitter = GetEmitter(); - if (emitter != nullptr) + wi::scene::Scene& scene = editor->GetCurrentScene(); + for (auto& x : editor->translator.selected) { + wi::EmittedParticleSystem* emitter = scene.emitters.GetComponent(x.entity); + if (emitter == nullptr) + continue; emitter->SetCollidersDisabled(args.bValue); } - }); + }); collidersDisabledCheckBox.SetCheck(false); collidersDisabledCheckBox.SetTooltip("Simply disables all colliders for acting on this particle system"); AddWidget(&collidersDisabledCheckBox); @@ -222,12 +255,15 @@ void EmitterWindow::Create(EditorComponent* _editor) takeColorCheckBox.SetPos(XMFLOAT2(x, y += step)); takeColorCheckBox.SetSize(XMFLOAT2(itemheight, itemheight)); takeColorCheckBox.OnClick([&](wi::gui::EventArgs args) { - auto emitter = GetEmitter(); - if (emitter != nullptr) + wi::scene::Scene& scene = editor->GetCurrentScene(); + for (auto& x : editor->translator.selected) { + wi::EmittedParticleSystem* emitter = scene.emitters.GetComponent(x.entity); + if (emitter == nullptr) + continue; emitter->SetTakeColorFromMesh(args.bValue); } - }); + }); takeColorCheckBox.SetCheck(false); takeColorCheckBox.SetTooltip("If it emits from a mesh, then particle color will be taken from mesh material surface."); AddWidget(&takeColorCheckBox); @@ -249,12 +285,15 @@ void EmitterWindow::Create(EditorComponent* _editor) frameRateInput.SetTooltip("Enter a value to enable looping sprite sheet animation (frames per second). Set 0 for animation along paritcle lifetime."); frameRateInput.SetDescription("Frame Rate: "); frameRateInput.OnInputAccepted([this](wi::gui::EventArgs args) { - auto emitter = GetEmitter(); - if (emitter != nullptr) + wi::scene::Scene& scene = editor->GetCurrentScene(); + for (auto& x : editor->translator.selected) { + wi::EmittedParticleSystem* emitter = scene.emitters.GetComponent(x.entity); + if (emitter == nullptr) + continue; emitter->frameRate = args.fValue; } - }); + }); AddWidget(&frameRateInput); framesXInput.Create(""); @@ -264,12 +303,15 @@ void EmitterWindow::Create(EditorComponent* _editor) framesXInput.SetTooltip("How many horizontal frames there are in the spritesheet."); framesXInput.SetDescription("Frames: "); framesXInput.OnInputAccepted([this](wi::gui::EventArgs args) { - auto emitter = GetEmitter(); - if (emitter != nullptr) + wi::scene::Scene& scene = editor->GetCurrentScene(); + for (auto& x : editor->translator.selected) { + wi::EmittedParticleSystem* emitter = scene.emitters.GetComponent(x.entity); + if (emitter == nullptr) + continue; emitter->framesX = (uint32_t)args.iValue; } - }); + }); AddWidget(&framesXInput); framesYInput.Create(""); @@ -278,12 +320,15 @@ void EmitterWindow::Create(EditorComponent* _editor) framesYInput.SetText(""); framesYInput.SetTooltip("How many vertical frames there are in the spritesheet."); framesYInput.OnInputAccepted([this](wi::gui::EventArgs args) { - auto emitter = GetEmitter(); - if (emitter != nullptr) + wi::scene::Scene& scene = editor->GetCurrentScene(); + for (auto& x : editor->translator.selected) { + wi::EmittedParticleSystem* emitter = scene.emitters.GetComponent(x.entity); + if (emitter == nullptr) + continue; emitter->framesY = (uint32_t)args.iValue; } - }); + }); AddWidget(&framesYInput); frameCountInput.Create(""); @@ -293,12 +338,15 @@ void EmitterWindow::Create(EditorComponent* _editor) frameCountInput.SetTooltip("Enter a value to enable the random sprite sheet frame selection's max frame number."); frameCountInput.SetDescription("Frame Count: "); frameCountInput.OnInputAccepted([this](wi::gui::EventArgs args) { - auto emitter = GetEmitter(); - if (emitter != nullptr) + wi::scene::Scene& scene = editor->GetCurrentScene(); + for (auto& x : editor->translator.selected) { + wi::EmittedParticleSystem* emitter = scene.emitters.GetComponent(x.entity); + if (emitter == nullptr) + continue; emitter->frameCount = (uint32_t)args.iValue; } - }); + }); AddWidget(&frameCountInput); frameStartInput.Create(""); @@ -308,12 +356,15 @@ void EmitterWindow::Create(EditorComponent* _editor) frameStartInput.SetTooltip("Specifies the starting frame of the animation."); frameStartInput.SetDescription("Start Frame: "); frameStartInput.OnInputAccepted([this](wi::gui::EventArgs args) { - auto emitter = GetEmitter(); - if (emitter != nullptr) + wi::scene::Scene& scene = editor->GetCurrentScene(); + for (auto& x : editor->translator.selected) { + wi::EmittedParticleSystem* emitter = scene.emitters.GetComponent(x.entity); + if (emitter == nullptr) + continue; emitter->frameStart = (uint32_t)args.iValue; } - }); + }); AddWidget(&frameStartInput); @@ -326,12 +377,15 @@ void EmitterWindow::Create(EditorComponent* _editor) VelocityXInput.SetPos(XMFLOAT2(x, y += step)); VelocityXInput.SetSize(XMFLOAT2(38, itemheight)); VelocityXInput.OnInputAccepted([&](wi::gui::EventArgs args) { - auto emitter = GetEmitter(); - if (emitter != nullptr) + wi::scene::Scene& scene = editor->GetCurrentScene(); + for (auto& x : editor->translator.selected) { + wi::EmittedParticleSystem* emitter = scene.emitters.GetComponent(x.entity); + if (emitter == nullptr) + continue; emitter->velocity.x = args.fValue; } - }); + }); AddWidget(&VelocityXInput); VelocityYInput.Create(""); @@ -340,12 +394,15 @@ void EmitterWindow::Create(EditorComponent* _editor) VelocityYInput.SetPos(XMFLOAT2(x + 40, y)); VelocityYInput.SetSize(XMFLOAT2(38, itemheight)); VelocityYInput.OnInputAccepted([&](wi::gui::EventArgs args) { - auto emitter = GetEmitter(); - if (emitter != nullptr) + wi::scene::Scene& scene = editor->GetCurrentScene(); + for (auto& x : editor->translator.selected) { + wi::EmittedParticleSystem* emitter = scene.emitters.GetComponent(x.entity); + if (emitter == nullptr) + continue; emitter->velocity.y = args.fValue; } - }); + }); AddWidget(&VelocityYInput); VelocityZInput.Create(""); @@ -354,12 +411,15 @@ void EmitterWindow::Create(EditorComponent* _editor) VelocityZInput.SetPos(XMFLOAT2(x + 80, y)); VelocityZInput.SetSize(XMFLOAT2(38, itemheight)); VelocityZInput.OnInputAccepted([&](wi::gui::EventArgs args) { - auto emitter = GetEmitter(); - if (emitter != nullptr) + wi::scene::Scene& scene = editor->GetCurrentScene(); + for (auto& x : editor->translator.selected) { + wi::EmittedParticleSystem* emitter = scene.emitters.GetComponent(x.entity); + if (emitter == nullptr) + continue; emitter->velocity.z = args.fValue; } - }); + }); AddWidget(&VelocityZInput); @@ -371,12 +431,15 @@ void EmitterWindow::Create(EditorComponent* _editor) GravityXInput.SetPos(XMFLOAT2(x, y += step)); GravityXInput.SetSize(XMFLOAT2(38, itemheight)); GravityXInput.OnInputAccepted([&](wi::gui::EventArgs args) { - auto emitter = GetEmitter(); - if (emitter != nullptr) + wi::scene::Scene& scene = editor->GetCurrentScene(); + for (auto& x : editor->translator.selected) { + wi::EmittedParticleSystem* emitter = scene.emitters.GetComponent(x.entity); + if (emitter == nullptr) + continue; emitter->gravity.x = args.fValue; } - }); + }); AddWidget(&GravityXInput); GravityYInput.Create(""); @@ -385,12 +448,15 @@ void EmitterWindow::Create(EditorComponent* _editor) GravityYInput.SetPos(XMFLOAT2(x + 40, y)); GravityYInput.SetSize(XMFLOAT2(38, itemheight)); GravityYInput.OnInputAccepted([&](wi::gui::EventArgs args) { - auto emitter = GetEmitter(); - if (emitter != nullptr) + wi::scene::Scene& scene = editor->GetCurrentScene(); + for (auto& x : editor->translator.selected) { + wi::EmittedParticleSystem* emitter = scene.emitters.GetComponent(x.entity); + if (emitter == nullptr) + continue; emitter->gravity.y = args.fValue; } - }); + }); AddWidget(&GravityYInput); GravityZInput.Create(""); @@ -399,24 +465,30 @@ void EmitterWindow::Create(EditorComponent* _editor) GravityZInput.SetPos(XMFLOAT2(x + 80, y)); GravityZInput.SetSize(XMFLOAT2(38, itemheight)); GravityZInput.OnInputAccepted([&](wi::gui::EventArgs args) { - auto emitter = GetEmitter(); - if (emitter != nullptr) + wi::scene::Scene& scene = editor->GetCurrentScene(); + for (auto& x : editor->translator.selected) { + wi::EmittedParticleSystem* emitter = scene.emitters.GetComponent(x.entity); + if (emitter == nullptr) + continue; emitter->gravity.z = args.fValue; } - }); + }); AddWidget(&GravityZInput); maxParticlesSlider.Create(100.0f, 1000000.0f, 10000, 100000, "Max count: "); maxParticlesSlider.SetSize(XMFLOAT2(wid, itemheight)); maxParticlesSlider.SetPos(XMFLOAT2(x, y += step)); maxParticlesSlider.OnSlide([&](wi::gui::EventArgs args) { - auto emitter = GetEmitter(); - if (emitter != nullptr) + wi::scene::Scene& scene = editor->GetCurrentScene(); + for (auto& x : editor->translator.selected) { + wi::EmittedParticleSystem* emitter = scene.emitters.GetComponent(x.entity); + if (emitter == nullptr) + continue; emitter->SetMaxParticleCount((uint32_t)args.iValue); } - }); + }); maxParticlesSlider.SetEnabled(false); maxParticlesSlider.SetTooltip("Set the maximum amount of particles this system can handle. This has an effect on the memory budget."); AddWidget(&maxParticlesSlider); @@ -425,9 +497,12 @@ void EmitterWindow::Create(EditorComponent* _editor) emitCountSlider.SetSize(XMFLOAT2(wid, itemheight)); emitCountSlider.SetPos(XMFLOAT2(x, y += step)); emitCountSlider.OnSlide([&](wi::gui::EventArgs args) { - auto emitter = GetEmitter(); - if (emitter != nullptr) + wi::scene::Scene& scene = editor->GetCurrentScene(); + for (auto& x : editor->translator.selected) { + wi::EmittedParticleSystem* emitter = scene.emitters.GetComponent(x.entity); + if (emitter == nullptr) + continue; emitter->count = args.fValue; } }); @@ -439,9 +514,12 @@ void EmitterWindow::Create(EditorComponent* _editor) emitSizeSlider.SetSize(XMFLOAT2(wid, itemheight)); emitSizeSlider.SetPos(XMFLOAT2(x, y += step)); emitSizeSlider.OnSlide([&](wi::gui::EventArgs args) { - auto emitter = GetEmitter(); - if (emitter != nullptr) + wi::scene::Scene& scene = editor->GetCurrentScene(); + for (auto& x : editor->translator.selected) { + wi::EmittedParticleSystem* emitter = scene.emitters.GetComponent(x.entity); + if (emitter == nullptr) + continue; emitter->size = args.fValue; } }); @@ -453,9 +531,12 @@ void EmitterWindow::Create(EditorComponent* _editor) emitRotationSlider.SetSize(XMFLOAT2(wid, itemheight)); emitRotationSlider.SetPos(XMFLOAT2(x, y += step)); emitRotationSlider.OnSlide([&](wi::gui::EventArgs args) { - auto emitter = GetEmitter(); - if (emitter != nullptr) + wi::scene::Scene& scene = editor->GetCurrentScene(); + for (auto& x : editor->translator.selected) { + wi::EmittedParticleSystem* emitter = scene.emitters.GetComponent(x.entity); + if (emitter == nullptr) + continue; emitter->rotation = args.fValue; } }); @@ -467,9 +548,12 @@ void EmitterWindow::Create(EditorComponent* _editor) emitNormalSlider.SetSize(XMFLOAT2(wid, itemheight)); emitNormalSlider.SetPos(XMFLOAT2(x, y += step)); emitNormalSlider.OnSlide([&](wi::gui::EventArgs args) { - auto emitter = GetEmitter(); - if (emitter != nullptr) + wi::scene::Scene& scene = editor->GetCurrentScene(); + for (auto& x : editor->translator.selected) { + wi::EmittedParticleSystem* emitter = scene.emitters.GetComponent(x.entity); + if (emitter == nullptr) + continue; emitter->normal_factor = args.fValue; } }); @@ -481,9 +565,12 @@ void EmitterWindow::Create(EditorComponent* _editor) emitScalingSlider.SetSize(XMFLOAT2(wid, itemheight)); emitScalingSlider.SetPos(XMFLOAT2(x, y += step)); emitScalingSlider.OnSlide([&](wi::gui::EventArgs args) { - auto emitter = GetEmitter(); - if (emitter != nullptr) + wi::scene::Scene& scene = editor->GetCurrentScene(); + for (auto& x : editor->translator.selected) { + wi::EmittedParticleSystem* emitter = scene.emitters.GetComponent(x.entity); + if (emitter == nullptr) + continue; emitter->scaleX = args.fValue; } }); @@ -495,9 +582,12 @@ void EmitterWindow::Create(EditorComponent* _editor) emitLifeSlider.SetSize(XMFLOAT2(wid, itemheight)); emitLifeSlider.SetPos(XMFLOAT2(x, y += step)); emitLifeSlider.OnSlide([&](wi::gui::EventArgs args) { - auto emitter = GetEmitter(); - if (emitter != nullptr) + wi::scene::Scene& scene = editor->GetCurrentScene(); + for (auto& x : editor->translator.selected) { + wi::EmittedParticleSystem* emitter = scene.emitters.GetComponent(x.entity); + if (emitter == nullptr) + continue; emitter->life = args.fValue; } }); @@ -509,9 +599,12 @@ void EmitterWindow::Create(EditorComponent* _editor) emitRandomnessSlider.SetSize(XMFLOAT2(wid, itemheight)); emitRandomnessSlider.SetPos(XMFLOAT2(x, y += step)); emitRandomnessSlider.OnSlide([&](wi::gui::EventArgs args) { - auto emitter = GetEmitter(); - if (emitter != nullptr) + wi::scene::Scene& scene = editor->GetCurrentScene(); + for (auto& x : editor->translator.selected) { + wi::EmittedParticleSystem* emitter = scene.emitters.GetComponent(x.entity); + if (emitter == nullptr) + continue; emitter->random_factor = args.fValue; } }); @@ -523,9 +616,12 @@ void EmitterWindow::Create(EditorComponent* _editor) emitLifeRandomnessSlider.SetSize(XMFLOAT2(wid, itemheight)); emitLifeRandomnessSlider.SetPos(XMFLOAT2(x, y += step)); emitLifeRandomnessSlider.OnSlide([&](wi::gui::EventArgs args) { - auto emitter = GetEmitter(); - if (emitter != nullptr) + wi::scene::Scene& scene = editor->GetCurrentScene(); + for (auto& x : editor->translator.selected) { + wi::EmittedParticleSystem* emitter = scene.emitters.GetComponent(x.entity); + if (emitter == nullptr) + continue; emitter->random_life = args.fValue; } }); @@ -537,9 +633,12 @@ void EmitterWindow::Create(EditorComponent* _editor) emitColorRandomnessSlider.SetSize(XMFLOAT2(wid, itemheight)); emitColorRandomnessSlider.SetPos(XMFLOAT2(x, y += step)); emitColorRandomnessSlider.OnSlide([&](wi::gui::EventArgs args) { - auto emitter = GetEmitter(); - if (emitter != nullptr) + wi::scene::Scene& scene = editor->GetCurrentScene(); + for (auto& x : editor->translator.selected) { + wi::EmittedParticleSystem* emitter = scene.emitters.GetComponent(x.entity); + if (emitter == nullptr) + continue; emitter->random_color = args.fValue; } }); @@ -551,9 +650,12 @@ void EmitterWindow::Create(EditorComponent* _editor) emitMotionBlurSlider.SetSize(XMFLOAT2(wid, itemheight)); emitMotionBlurSlider.SetPos(XMFLOAT2(x, y += step)); emitMotionBlurSlider.OnSlide([&](wi::gui::EventArgs args) { - auto emitter = GetEmitter(); - if (emitter != nullptr) + wi::scene::Scene& scene = editor->GetCurrentScene(); + for (auto& x : editor->translator.selected) { + wi::EmittedParticleSystem* emitter = scene.emitters.GetComponent(x.entity); + if (emitter == nullptr) + continue; emitter->motionBlurAmount = args.fValue; } }); @@ -565,9 +667,12 @@ void EmitterWindow::Create(EditorComponent* _editor) emitMassSlider.SetSize(XMFLOAT2(wid, itemheight)); emitMassSlider.SetPos(XMFLOAT2(x, y += step)); emitMassSlider.OnSlide([&](wi::gui::EventArgs args) { - auto emitter = GetEmitter(); - if (emitter != nullptr) + wi::scene::Scene& scene = editor->GetCurrentScene(); + for (auto& x : editor->translator.selected) { + wi::EmittedParticleSystem* emitter = scene.emitters.GetComponent(x.entity); + if (emitter == nullptr) + continue; emitter->mass = args.fValue; } }); @@ -581,9 +686,12 @@ void EmitterWindow::Create(EditorComponent* _editor) timestepSlider.SetSize(XMFLOAT2(wid, itemheight)); timestepSlider.SetPos(XMFLOAT2(x, y += step)); timestepSlider.OnSlide([&](wi::gui::EventArgs args) { - auto emitter = GetEmitter(); - if (emitter != nullptr) + wi::scene::Scene& scene = editor->GetCurrentScene(); + for (auto& x : editor->translator.selected) { + wi::EmittedParticleSystem* emitter = scene.emitters.GetComponent(x.entity); + if (emitter == nullptr) + continue; emitter->FIXED_TIMESTEP = args.fValue; } }); @@ -597,12 +705,15 @@ void EmitterWindow::Create(EditorComponent* _editor) dragSlider.SetSize(XMFLOAT2(wid, itemheight)); dragSlider.SetPos(XMFLOAT2(x, y += step)); dragSlider.OnSlide([&](wi::gui::EventArgs args) { - auto emitter = GetEmitter(); - if (emitter != nullptr) + wi::scene::Scene& scene = editor->GetCurrentScene(); + for (auto& x : editor->translator.selected) { + wi::EmittedParticleSystem* emitter = scene.emitters.GetComponent(x.entity); + if (emitter == nullptr) + continue; emitter->drag = args.fValue; } - }); + }); dragSlider.SetEnabled(false); dragSlider.SetTooltip("The velocity will be multiplied with this value, so lower than 1 will slow decelerate the particles."); AddWidget(&dragSlider); @@ -611,12 +722,15 @@ void EmitterWindow::Create(EditorComponent* _editor) restitutionSlider.SetSize(XMFLOAT2(wid, itemheight)); restitutionSlider.SetPos(XMFLOAT2(x, y += step)); restitutionSlider.OnSlide([&](wi::gui::EventArgs args) { - auto emitter = GetEmitter(); - if (emitter != nullptr) + wi::scene::Scene& scene = editor->GetCurrentScene(); + for (auto& x : editor->translator.selected) { + wi::EmittedParticleSystem* emitter = scene.emitters.GetComponent(x.entity); + if (emitter == nullptr) + continue; emitter->restitution = args.fValue; } - }); + }); restitutionSlider.SetEnabled(false); restitutionSlider.SetTooltip("If the particles have collision enabled, then after collision this is a multiplier for their bouncing velocities"); AddWidget(&restitutionSlider); @@ -629,9 +743,12 @@ void EmitterWindow::Create(EditorComponent* _editor) sph_h_Slider.SetSize(XMFLOAT2(wid, itemheight)); sph_h_Slider.SetPos(XMFLOAT2(x, y += step)); sph_h_Slider.OnSlide([&](wi::gui::EventArgs args) { - auto emitter = GetEmitter(); - if (emitter != nullptr) + wi::scene::Scene& scene = editor->GetCurrentScene(); + for (auto& x : editor->translator.selected) { + wi::EmittedParticleSystem* emitter = scene.emitters.GetComponent(x.entity); + if (emitter == nullptr) + continue; emitter->SPH_h = args.fValue; } }); @@ -643,9 +760,12 @@ void EmitterWindow::Create(EditorComponent* _editor) sph_K_Slider.SetSize(XMFLOAT2(wid, itemheight)); sph_K_Slider.SetPos(XMFLOAT2(x, y += step)); sph_K_Slider.OnSlide([&](wi::gui::EventArgs args) { - auto emitter = GetEmitter(); - if (emitter != nullptr) + wi::scene::Scene& scene = editor->GetCurrentScene(); + for (auto& x : editor->translator.selected) { + wi::EmittedParticleSystem* emitter = scene.emitters.GetComponent(x.entity); + if (emitter == nullptr) + continue; emitter->SPH_K = args.fValue; } }); @@ -657,9 +777,12 @@ void EmitterWindow::Create(EditorComponent* _editor) sph_p0_Slider.SetSize(XMFLOAT2(wid, itemheight)); sph_p0_Slider.SetPos(XMFLOAT2(x, y += step)); sph_p0_Slider.OnSlide([&](wi::gui::EventArgs args) { - auto emitter = GetEmitter(); - if (emitter != nullptr) + wi::scene::Scene& scene = editor->GetCurrentScene(); + for (auto& x : editor->translator.selected) { + wi::EmittedParticleSystem* emitter = scene.emitters.GetComponent(x.entity); + if (emitter == nullptr) + continue; emitter->SPH_p0 = args.fValue; } }); @@ -671,9 +794,12 @@ void EmitterWindow::Create(EditorComponent* _editor) sph_e_Slider.SetSize(XMFLOAT2(wid, itemheight)); sph_e_Slider.SetPos(XMFLOAT2(x, y += step)); sph_e_Slider.OnSlide([&](wi::gui::EventArgs args) { - auto emitter = GetEmitter(); - if (emitter != nullptr) + wi::scene::Scene& scene = editor->GetCurrentScene(); + for (auto& x : editor->translator.selected) { + wi::EmittedParticleSystem* emitter = scene.emitters.GetComponent(x.entity); + if (emitter == nullptr) + continue; emitter->SPH_e = args.fValue; } }); diff --git a/Editor/EnvProbeWindow.cpp b/Editor/EnvProbeWindow.cpp index f3b5a74fa..47d3c8fe4 100644 --- a/Editor/EnvProbeWindow.cpp +++ b/Editor/EnvProbeWindow.cpp @@ -24,7 +24,7 @@ void EnvProbeWindow::Create(EditorComponent* _editor) editor->RecordEntity(archive, entity); editor->componentsWnd.RefreshEntityTree(); - }); + }); float x = 5, y = 0, step = 35; @@ -40,9 +40,12 @@ void EnvProbeWindow::Create(EditorComponent* _editor) realTimeCheckBox.SetPos(XMFLOAT2(x + 100, y)); realTimeCheckBox.SetEnabled(false); realTimeCheckBox.OnClick([&](wi::gui::EventArgs args) { - EnvironmentProbeComponent* probe = editor->GetCurrentScene().probes.GetComponent(entity); - if (probe != nullptr) + wi::scene::Scene& scene = editor->GetCurrentScene(); + for (auto& x : editor->translator.selected) { + EnvironmentProbeComponent* probe = scene.probes.GetComponent(x.entity); + if (probe == nullptr) + continue; probe->SetRealTime(args.bValue); probe->SetDirty(); } @@ -54,13 +57,16 @@ void EnvProbeWindow::Create(EditorComponent* _editor) msaaCheckBox.SetPos(XMFLOAT2(x + 200, y)); msaaCheckBox.SetEnabled(false); msaaCheckBox.OnClick([&](wi::gui::EventArgs args) { - EnvironmentProbeComponent* probe = editor->GetCurrentScene().probes.GetComponent(entity); - if (probe != nullptr) + wi::scene::Scene& scene = editor->GetCurrentScene(); + for (auto& x : editor->translator.selected) { + EnvironmentProbeComponent* probe = scene.probes.GetComponent(x.entity); + if (probe == nullptr) + continue; probe->SetMSAA(args.bValue); probe->SetDirty(); } - }); + }); AddWidget(&msaaCheckBox); refreshButton.Create("Refresh"); @@ -68,9 +74,12 @@ void EnvProbeWindow::Create(EditorComponent* _editor) refreshButton.SetPos(XMFLOAT2(x, y+= step)); refreshButton.SetEnabled(false); refreshButton.OnClick([&](wi::gui::EventArgs args) { - EnvironmentProbeComponent* probe = editor->GetCurrentScene().probes.GetComponent(entity); - if (probe != nullptr) + wi::scene::Scene& scene = editor->GetCurrentScene(); + for (auto& x : editor->translator.selected) { + EnvironmentProbeComponent* probe = scene.probes.GetComponent(x.entity); + if (probe == nullptr) + continue; probe->SetDirty(); } }); @@ -81,11 +90,13 @@ void EnvProbeWindow::Create(EditorComponent* _editor) refreshAllButton.SetPos(XMFLOAT2(x + 120, y)); refreshAllButton.SetEnabled(true); refreshAllButton.OnClick([&](wi::gui::EventArgs args) { - Scene& scene = editor->GetCurrentScene(); - for (size_t i = 0; i < scene.probes.GetCount(); ++i) + wi::scene::Scene& scene = editor->GetCurrentScene(); + for (auto& x : editor->translator.selected) { - EnvironmentProbeComponent& probe = scene.probes[i]; - probe.SetDirty(); + EnvironmentProbeComponent* probe = scene.probes.GetComponent(x.entity); + if (probe == nullptr) + continue; + probe->SetDirty(); } }); AddWidget(&refreshAllButton); @@ -95,33 +106,38 @@ void EnvProbeWindow::Create(EditorComponent* _editor) importButton.SetPos(XMFLOAT2(x, y += step)); importButton.SetEnabled(false); importButton.OnClick([&](wi::gui::EventArgs args) { - Scene& scene = editor->GetCurrentScene(); - EnvironmentProbeComponent* probe = scene.probes.GetComponent(entity); - if (probe != nullptr && probe->texture.IsValid()) + wi::scene::Scene& scene = editor->GetCurrentScene(); + for (auto& x : editor->translator.selected) { - wi::helper::FileDialogParams params; - params.type = wi::helper::FileDialogParams::OPEN; - params.description = "DDS"; - params.extensions = { "DDS" }; - wi::helper::FileDialog(params, [=](std::string fileName) { - wi::eventhandler::Subscribe_Once(wi::eventhandler::EVENT_THREAD_SAFE_POINT, [=](uint64_t userdata) { + EnvironmentProbeComponent* probe = scene.probes.GetComponent(x.entity); + if (probe == nullptr) + continue; + if (probe != nullptr && probe->texture.IsValid()) + { + wi::helper::FileDialogParams params; + params.type = wi::helper::FileDialogParams::OPEN; + params.description = "DDS"; + params.extensions = { "DDS" }; + wi::helper::FileDialog(params, [=](std::string fileName) { + wi::eventhandler::Subscribe_Once(wi::eventhandler::EVENT_THREAD_SAFE_POINT, [=](uint64_t userdata) { - wi::Resource resource = wi::resourcemanager::Load(fileName); - if (has_flag(resource.GetTexture().GetDesc().misc_flags, wi::graphics::ResourceMiscFlag::TEXTURECUBE)) - { - probe->textureName = fileName; - probe->CreateRenderData(); - } - else - { - wi::helper::messageBox("Error!", "The texture you tried to open is not a cubemap texture, so it won't be imported!"); - } + wi::Resource resource = wi::resourcemanager::Load(fileName); + if (has_flag(resource.GetTexture().GetDesc().misc_flags, wi::graphics::ResourceMiscFlag::TEXTURECUBE)) + { + probe->textureName = fileName; + probe->CreateRenderData(); + } + else + { + wi::helper::messageBox("Error!", "The texture you tried to open is not a cubemap texture, so it won't be imported!"); + } + }); }); - }); + } } - }); + }); AddWidget(&importButton); exportButton.Create("Export Cubemap"); @@ -129,35 +145,40 @@ void EnvProbeWindow::Create(EditorComponent* _editor) exportButton.SetPos(XMFLOAT2(x, y += step)); exportButton.SetEnabled(false); exportButton.OnClick([&](wi::gui::EventArgs args) { - Scene& scene = editor->GetCurrentScene(); - EnvironmentProbeComponent* probe = scene.probes.GetComponent(entity); - if (probe != nullptr && probe->texture.IsValid()) + wi::scene::Scene& scene = editor->GetCurrentScene(); + for (auto& x : editor->translator.selected) { - wi::helper::FileDialogParams params; - params.type = wi::helper::FileDialogParams::SAVE; - params.description = "DDS"; - params.extensions = { "DDS" }; - wi::helper::FileDialog(params, [=](std::string fileName) { - wi::eventhandler::Subscribe_Once(wi::eventhandler::EVENT_THREAD_SAFE_POINT, [=](uint64_t userdata) { + EnvironmentProbeComponent* probe = scene.probes.GetComponent(x.entity); + if (probe == nullptr) + continue; + if (probe != nullptr && probe->texture.IsValid()) + { + wi::helper::FileDialogParams params; + params.type = wi::helper::FileDialogParams::SAVE; + params.description = "DDS"; + params.extensions = { "DDS" }; + wi::helper::FileDialog(params, [=](std::string fileName) { + wi::eventhandler::Subscribe_Once(wi::eventhandler::EVENT_THREAD_SAFE_POINT, [=](uint64_t userdata) { - std::string extension = wi::helper::toUpper(wi::helper::GetExtensionFromFileName(fileName)); - std::string filename_replaced = fileName; - if (extension != "DDS") - { - filename_replaced = wi::helper::ReplaceExtension(fileName, "DDS"); - } + std::string extension = wi::helper::toUpper(wi::helper::GetExtensionFromFileName(fileName)); + std::string filename_replaced = fileName; + if (extension != "DDS") + { + filename_replaced = wi::helper::ReplaceExtension(fileName, "DDS"); + } - bool success = wi::helper::saveTextureToFile(probe->texture, filename_replaced); - assert(success); + bool success = wi::helper::saveTextureToFile(probe->texture, filename_replaced); + assert(success); - if (success) - { - editor->PostSaveText("Exported environment cubemap: ", filename_replaced); - } + if (success) + { + editor->PostSaveText("Exported environment cubemap: ", filename_replaced); + } + }); }); - }); + } } }); AddWidget(&exportButton); @@ -173,10 +194,12 @@ void EnvProbeWindow::Create(EditorComponent* _editor) resolutionCombo.AddItem("1024", 1024); resolutionCombo.AddItem("2048", 2048); resolutionCombo.OnSelect([&](wi::gui::EventArgs args) { - Scene& scene = editor->GetCurrentScene(); - EnvironmentProbeComponent* probe = scene.probes.GetComponent(entity); - if (probe != nullptr) + wi::scene::Scene& scene = editor->GetCurrentScene(); + for (auto& x : editor->translator.selected) { + EnvironmentProbeComponent* probe = scene.probes.GetComponent(x.entity); + if (probe == nullptr) + continue; probe->resolution = (uint32_t)args.userdata; probe->CreateRenderData(); } diff --git a/Editor/FontWindow.cpp b/Editor/FontWindow.cpp index 8f7f0a340..f6488a089 100644 --- a/Editor/FontWindow.cpp +++ b/Editor/FontWindow.cpp @@ -34,48 +34,55 @@ void FontWindow::Create(EditorComponent* _editor) textInput.Create(""); textInput.SetPos(XMFLOAT2(x, y)); textInput.OnInput([=](wi::gui::EventArgs args) { - wi::SpriteFont* font = editor->GetCurrentScene().fonts.GetComponent(entity); - if (font == nullptr) - return; - - font->SetText(args.sValue); - }); + wi::scene::Scene& scene = editor->GetCurrentScene(); + for (auto& x : editor->translator.selected) + { + wi::SpriteFont* font = scene.fonts.GetComponent(x.entity); + if (font == nullptr) + continue; + font->SetText(args.sValue); + } + }); AddWidget(&textInput); fontStyleButton.Create(""); fontStyleButton.SetDescription("Style: "); fontStyleButton.SetTooltip("Load a font style from file (.TTF) to apply to this font."); fontStyleButton.OnClick([=](wi::gui::EventArgs args) { - wi::SpriteFont* font = editor->GetCurrentScene().fonts.GetComponent(entity); - if (font == nullptr) - return; - - if (font->fontStyleResource.IsValid()) + wi::scene::Scene& scene = editor->GetCurrentScene(); + for (auto& x : editor->translator.selected) { - wi::Archive& archive = editor->AdvanceHistory(); - archive << EditorComponent::HISTORYOP_COMPONENT_DATA; - editor->RecordEntity(archive, entity); + wi::SpriteFont* font = scene.fonts.GetComponent(x.entity); + if (font == nullptr) + continue; - font->fontStyleResource = {}; - font->fontStyleName = ""; - fontStyleButton.SetText("default"); - fontStyleButton.font.fontStyleResource = {}; - fontStyleButton.font.params.style = 0; + if (font->fontStyleResource.IsValid()) + { + wi::Archive& archive = editor->AdvanceHistory(); + archive << EditorComponent::HISTORYOP_COMPONENT_DATA; + editor->RecordEntity(archive, entity); - editor->RecordEntity(archive, entity); - } - else - { - wi::helper::FileDialogParams params; - params.type = wi::helper::FileDialogParams::OPEN; - params.description = "Font (*.TTF)"; - params.extensions = wi::resourcemanager::GetSupportedFontStyleExtensions(); - wi::helper::FileDialog(params, [=](std::string fileName) { - font->fontStyleResource = wi::resourcemanager::Load(fileName); - font->fontStyleName = fileName; - fontStyleButton.SetText(wi::helper::GetFileNameFromPath(font->fontStyleName)); - fontStyleButton.font.fontStyleResource = font->fontStyleResource; - }); + font->fontStyleResource = {}; + font->fontStyleName = ""; + fontStyleButton.SetText("default"); + fontStyleButton.font.fontStyleResource = {}; + fontStyleButton.font.params.style = 0; + + editor->RecordEntity(archive, entity); + } + else + { + wi::helper::FileDialogParams params; + params.type = wi::helper::FileDialogParams::OPEN; + params.description = "Font (*.TTF)"; + params.extensions = wi::resourcemanager::GetSupportedFontStyleExtensions(); + wi::helper::FileDialog(params, [=](std::string fileName) { + font->fontStyleResource = wi::resourcemanager::Load(fileName); + font->fontStyleName = fileName; + fontStyleButton.SetText(wi::helper::GetFileNameFromPath(font->fontStyleName)); + fontStyleButton.font.fontStyleResource = font->fontStyleResource; + }); + } } }); AddWidget(&fontStyleButton); @@ -99,11 +106,15 @@ void FontWindow::Create(EditorComponent* _editor) fontSizeCombo.AddItem("96", 96); fontSizeCombo.AddItem("108", 108); fontSizeCombo.OnSelect([=](wi::gui::EventArgs args) { - wi::SpriteFont* font = editor->GetCurrentScene().fonts.GetComponent(entity); - if (font == nullptr) - return; - font->params.size = int(args.userdata); - }); + wi::scene::Scene& scene = editor->GetCurrentScene(); + for (auto& x : editor->translator.selected) + { + wi::SpriteFont* font = scene.fonts.GetComponent(x.entity); + if (font == nullptr) + continue; + font->params.size = int(args.userdata); + } + }); AddWidget(&fontSizeCombo); hAlignCombo.Create("H Align: "); @@ -112,11 +123,15 @@ void FontWindow::Create(EditorComponent* _editor) hAlignCombo.AddItem("Center", wi::font::WIFALIGN_CENTER); hAlignCombo.AddItem("Right", wi::font::WIFALIGN_RIGHT); hAlignCombo.OnSelect([=](wi::gui::EventArgs args) { - wi::SpriteFont* font = editor->GetCurrentScene().fonts.GetComponent(entity); - if (font == nullptr) - return; - font->params.h_align = wi::font::Alignment(args.userdata); - }); + wi::scene::Scene& scene = editor->GetCurrentScene(); + for (auto& x : editor->translator.selected) + { + wi::SpriteFont* font = scene.fonts.GetComponent(x.entity); + if (font == nullptr) + continue; + font->params.h_align = wi::font::Alignment(args.userdata); + } + }); AddWidget(&hAlignCombo); vAlignCombo.Create("V Align: "); @@ -125,167 +140,231 @@ void FontWindow::Create(EditorComponent* _editor) vAlignCombo.AddItem("Center", wi::font::WIFALIGN_CENTER); vAlignCombo.AddItem("Bottom", wi::font::WIFALIGN_BOTTOM); vAlignCombo.OnSelect([=](wi::gui::EventArgs args) { - wi::SpriteFont* font = editor->GetCurrentScene().fonts.GetComponent(entity); - if (font == nullptr) - return; - font->params.v_align = wi::font::Alignment(args.userdata); - }); + wi::scene::Scene& scene = editor->GetCurrentScene(); + for (auto& x : editor->translator.selected) + { + wi::SpriteFont* font = scene.fonts.GetComponent(x.entity); + if (font == nullptr) + continue; + font->params.v_align = wi::font::Alignment(args.userdata); + } + }); AddWidget(&vAlignCombo); rotationSlider.Create(0, 360, 0, 10000, "Rotation: "); rotationSlider.SetTooltip("Z Rotation around alignment center point. The editor input is in degrees."); rotationSlider.OnSlide([=](wi::gui::EventArgs args) { - wi::SpriteFont* font = editor->GetCurrentScene().fonts.GetComponent(entity); - if (font == nullptr) - return; - font->params.rotation = wi::math::DegreesToRadians(args.fValue); - }); + wi::scene::Scene& scene = editor->GetCurrentScene(); + for (auto& x : editor->translator.selected) + { + wi::SpriteFont* font = scene.fonts.GetComponent(x.entity); + if (font == nullptr) + continue; + font->params.rotation = wi::math::DegreesToRadians(args.fValue); + } + }); AddWidget(&rotationSlider); spacingSlider.Create(0, 10, 0, 10000, "Spacing: "); spacingSlider.SetTooltip("Horizontal spacing between characters."); spacingSlider.OnSlide([=](wi::gui::EventArgs args) { - wi::SpriteFont* font = editor->GetCurrentScene().fonts.GetComponent(entity); - if (font == nullptr) - return; - font->params.spacingX = args.fValue; - }); + wi::scene::Scene& scene = editor->GetCurrentScene(); + for (auto& x : editor->translator.selected) + { + wi::SpriteFont* font = scene.fonts.GetComponent(x.entity); + if (font == nullptr) + continue; + font->params.spacingX = args.fValue; + } + }); AddWidget(&spacingSlider); softnessSlider.Create(0, 1, 0, 10000, "Softness: "); softnessSlider.OnSlide([=](wi::gui::EventArgs args) { - wi::SpriteFont* font = editor->GetCurrentScene().fonts.GetComponent(entity); - if (font == nullptr) - return; - font->params.softness = args.fValue; - }); + wi::scene::Scene& scene = editor->GetCurrentScene(); + for (auto& x : editor->translator.selected) + { + wi::SpriteFont* font = scene.fonts.GetComponent(x.entity); + if (font == nullptr) + continue; + font->params.softness = args.fValue; + } + }); AddWidget(&softnessSlider); boldenSlider.Create(0, 1, 0, 10000, "Bolden: "); boldenSlider.OnSlide([=](wi::gui::EventArgs args) { - wi::SpriteFont* font = editor->GetCurrentScene().fonts.GetComponent(entity); - if (font == nullptr) - return; - font->params.bolden = args.fValue; - }); + wi::scene::Scene& scene = editor->GetCurrentScene(); + for (auto& x : editor->translator.selected) + { + wi::SpriteFont* font = scene.fonts.GetComponent(x.entity); + if (font == nullptr) + continue; + font->params.bolden = args.fValue; + } + }); AddWidget(&boldenSlider); shadowSoftnessSlider.Create(0, 1, 0, 10000, "Shadow Softness: "); shadowSoftnessSlider.OnSlide([=](wi::gui::EventArgs args) { - wi::SpriteFont* font = editor->GetCurrentScene().fonts.GetComponent(entity); - if (font == nullptr) - return; - font->params.shadow_softness = args.fValue; - }); + wi::scene::Scene& scene = editor->GetCurrentScene(); + for (auto& x : editor->translator.selected) + { + wi::SpriteFont* font = scene.fonts.GetComponent(x.entity); + if (font == nullptr) + continue; + font->params.shadow_softness = args.fValue; + } + }); AddWidget(&shadowSoftnessSlider); shadowBoldenSlider.Create(0, 1, 0, 10000, "Shadow Bolden: "); shadowBoldenSlider.OnSlide([=](wi::gui::EventArgs args) { - wi::SpriteFont* font = editor->GetCurrentScene().fonts.GetComponent(entity); - if (font == nullptr) - return; - font->params.shadow_bolden = args.fValue; - }); + wi::scene::Scene& scene = editor->GetCurrentScene(); + for (auto& x : editor->translator.selected) + { + wi::SpriteFont* font = scene.fonts.GetComponent(x.entity); + if (font == nullptr) + continue; + font->params.shadow_bolden = args.fValue; + } + }); AddWidget(&shadowBoldenSlider); shadowOffsetXSlider.Create(-2, 2, 0, 10000, "Shadow Offset X: "); shadowOffsetXSlider.OnSlide([=](wi::gui::EventArgs args) { - wi::SpriteFont* font = editor->GetCurrentScene().fonts.GetComponent(entity); - if (font == nullptr) - return; - font->params.shadow_offset_x = args.fValue; - }); + wi::scene::Scene& scene = editor->GetCurrentScene(); + for (auto& x : editor->translator.selected) + { + wi::SpriteFont* font = scene.fonts.GetComponent(x.entity); + if (font == nullptr) + continue; + font->params.shadow_offset_x = args.fValue; + } + }); AddWidget(&shadowOffsetXSlider); shadowOffsetYSlider.Create(-2, 2, 0, 10000, "Shadow Offset Y: "); shadowOffsetYSlider.OnSlide([=](wi::gui::EventArgs args) { - wi::SpriteFont* font = editor->GetCurrentScene().fonts.GetComponent(entity); - if (font == nullptr) - return; - font->params.shadow_offset_y = args.fValue; - }); + wi::scene::Scene& scene = editor->GetCurrentScene(); + for (auto& x : editor->translator.selected) + { + wi::SpriteFont* font = scene.fonts.GetComponent(x.entity); + if (font == nullptr) + continue; + font->params.shadow_offset_y = args.fValue; + } + }); AddWidget(&shadowOffsetYSlider); intensitySlider.Create(0, 100, 1, 10000, "Intensity: "); intensitySlider.OnSlide([=](wi::gui::EventArgs args) { - wi::SpriteFont* font = editor->GetCurrentScene().fonts.GetComponent(entity); - if (font == nullptr) - return; - font->params.intensity = args.fValue; - }); + wi::scene::Scene& scene = editor->GetCurrentScene(); + for (auto& x : editor->translator.selected) + { + wi::SpriteFont* font = scene.fonts.GetComponent(x.entity); + if (font == nullptr) + continue; + font->params.intensity = args.fValue; + } + }); AddWidget(&intensitySlider); shadowIntensitySlider.Create(0, 100, 1, 10000, "Shadow Intensity: "); shadowIntensitySlider.OnSlide([=](wi::gui::EventArgs args) { - wi::SpriteFont* font = editor->GetCurrentScene().fonts.GetComponent(entity); - if (font == nullptr) - return; - font->params.shadow_intensity = args.fValue; - }); + wi::scene::Scene& scene = editor->GetCurrentScene(); + for (auto& x : editor->translator.selected) + { + wi::SpriteFont* font = scene.fonts.GetComponent(x.entity); + if (font == nullptr) + continue; + font->params.shadow_intensity = args.fValue; + } + }); AddWidget(&shadowIntensitySlider); hiddenCheckBox.Create("Hidden: "); hiddenCheckBox.SetTooltip("Hide / unhide the font"); hiddenCheckBox.OnClick([=](wi::gui::EventArgs args) { - wi::SpriteFont* font = editor->GetCurrentScene().fonts.GetComponent(entity); - if (font == nullptr) - return; - font->SetHidden(args.bValue); - }); + wi::scene::Scene& scene = editor->GetCurrentScene(); + for (auto& x : editor->translator.selected) + { + wi::SpriteFont* font = scene.fonts.GetComponent(x.entity); + if (font == nullptr) + continue; + font->SetHidden(args.bValue); + } + }); AddWidget(&hiddenCheckBox); cameraFacingCheckBox.Create("Camera Facing: "); cameraFacingCheckBox.SetTooltip("Camera facing fonts will always rotate towards the camera."); cameraFacingCheckBox.OnClick([=](wi::gui::EventArgs args) { - wi::SpriteFont* font = editor->GetCurrentScene().fonts.GetComponent(entity); - if (font == nullptr) - return; - font->SetCameraFacing(args.bValue); - }); + wi::scene::Scene& scene = editor->GetCurrentScene(); + for (auto& x : editor->translator.selected) + { + wi::SpriteFont* font = scene.fonts.GetComponent(x.entity); + if (font == nullptr) + continue; + font->SetCameraFacing(args.bValue); + } + }); AddWidget(&cameraFacingCheckBox); cameraScalingCheckBox.Create("Camera Scaling: "); cameraScalingCheckBox.SetTooltip("Camera scaling fonts will always keep the same size on screen, irrespective of the distance to the camera."); cameraScalingCheckBox.OnClick([=](wi::gui::EventArgs args) { - wi::SpriteFont* font = editor->GetCurrentScene().fonts.GetComponent(entity); - if (font == nullptr) - return; - font->SetCameraScaling(args.bValue); - }); + wi::scene::Scene& scene = editor->GetCurrentScene(); + for (auto& x : editor->translator.selected) + { + wi::SpriteFont* font = scene.fonts.GetComponent(x.entity); + if (font == nullptr) + continue; + font->SetCameraScaling(args.bValue); + } + }); AddWidget(&cameraScalingCheckBox); depthTestCheckBox.Create("Depth Test: "); depthTestCheckBox.SetTooltip("Depth tested fonts will be clipped against geometry."); depthTestCheckBox.OnClick([=](wi::gui::EventArgs args) { - wi::SpriteFont* font = editor->GetCurrentScene().fonts.GetComponent(entity); - if (font == nullptr) - return; - if (args.bValue) + wi::scene::Scene& scene = editor->GetCurrentScene(); + for (auto& x : editor->translator.selected) { - font->params.enableDepthTest(); + wi::SpriteFont* font = scene.fonts.GetComponent(x.entity); + if (font == nullptr) + continue; + if (args.bValue) + { + font->params.enableDepthTest(); + } + else + { + font->params.disableDepthTest(); + } } - else - { - font->params.disableDepthTest(); - } - }); + }); AddWidget(&depthTestCheckBox); sdfCheckBox.Create("SDF: "); sdfCheckBox.SetTooltip("Signed Distance Field rendering is used for improved font upscaling, softness, boldness and soft shadow effects."); sdfCheckBox.OnClick([=](wi::gui::EventArgs args) { - wi::SpriteFont* font = editor->GetCurrentScene().fonts.GetComponent(entity); - if (font == nullptr) - return; - if (args.bValue) + wi::scene::Scene& scene = editor->GetCurrentScene(); + for (auto& x : editor->translator.selected) { - font->params.enableSDFRendering(); + wi::SpriteFont* font = scene.fonts.GetComponent(x.entity); + if (font == nullptr) + continue; + if (args.bValue) + { + font->params.enableSDFRendering(); + } + else + { + font->params.disableSDFRendering(); + } } - else - { - font->params.disableSDFRendering(); - } - }); + }); AddWidget(&sdfCheckBox); colorModeCombo.Create("Color mode: "); @@ -295,9 +374,12 @@ void FontWindow::Create(EditorComponent* _editor) colorModeCombo.AddItem("Shadow color"); colorModeCombo.SetTooltip("Choose the destination data of the color picker."); colorModeCombo.OnSelect([=](wi::gui::EventArgs args) { - wi::SpriteFont* font = editor->GetCurrentScene().fonts.GetComponent(entity); - if (font != nullptr) + wi::scene::Scene& scene = editor->GetCurrentScene(); + for (auto& x : editor->translator.selected) { + wi::SpriteFont* font = scene.fonts.GetComponent(x.entity); + if (font == nullptr) + continue; if (args.iValue == 0) { colorPicker.SetPickColor(font->params.color); @@ -307,14 +389,17 @@ void FontWindow::Create(EditorComponent* _editor) colorPicker.SetPickColor(font->params.shadowColor); } } - }); + }); AddWidget(&colorModeCombo); colorPicker.Create("Color", wi::gui::Window::WindowControls::NONE); colorPicker.OnColorChanged([&](wi::gui::EventArgs args) { - wi::SpriteFont* font = editor->GetCurrentScene().fonts.GetComponent(entity); - if (font != nullptr) + wi::scene::Scene& scene = editor->GetCurrentScene(); + for (auto& x : editor->translator.selected) { + wi::SpriteFont* font = scene.fonts.GetComponent(x.entity); + if (font == nullptr) + continue; switch (colorModeCombo.GetSelected()) { default: @@ -326,7 +411,7 @@ void FontWindow::Create(EditorComponent* _editor) break; } } - }); + }); AddWidget(&colorPicker); typewriterInfoLabel.Create("Tip: if you add Sound Component to text, then the typewriter animation will use that sound as typewriter sound effect."); @@ -336,21 +421,29 @@ void FontWindow::Create(EditorComponent* _editor) typewriterTimeSlider.Create(0, 10, 0, 10000, "Typewriter time: "); typewriterTimeSlider.SetTooltip("Time to complete typewriter animation (0 = disable)."); typewriterTimeSlider.OnSlide([=](wi::gui::EventArgs args) { - wi::SpriteFont* font = editor->GetCurrentScene().fonts.GetComponent(entity); - if (font == nullptr) - return; - font->anim.typewriter.time = args.fValue; - }); + wi::scene::Scene& scene = editor->GetCurrentScene(); + for (auto& x : editor->translator.selected) + { + wi::SpriteFont* font = scene.fonts.GetComponent(x.entity); + if (font == nullptr) + continue; + font->anim.typewriter.time = args.fValue; + } + }); AddWidget(&typewriterTimeSlider); typewriterLoopedCheckBox.Create("Typewriter Looped: "); typewriterLoopedCheckBox.SetTooltip("Whether typewriter animation is looped or not."); typewriterLoopedCheckBox.OnClick([=](wi::gui::EventArgs args) { - wi::SpriteFont* font = editor->GetCurrentScene().fonts.GetComponent(entity); - if (font == nullptr) - return; - font->anim.typewriter.looped = args.bValue; - }); + wi::scene::Scene& scene = editor->GetCurrentScene(); + for (auto& x : editor->translator.selected) + { + wi::SpriteFont* font = scene.fonts.GetComponent(x.entity); + if (font == nullptr) + continue; + font->anim.typewriter.looped = args.bValue; + } + }); AddWidget(&typewriterLoopedCheckBox); typewriterStartInput.Create(""); @@ -359,11 +452,15 @@ void FontWindow::Create(EditorComponent* _editor) typewriterStartInput.SetPos(XMFLOAT2(x, y)); typewriterStartInput.SetSize(XMFLOAT2(siz, hei)); typewriterStartInput.OnInputAccepted([=](wi::gui::EventArgs args) { - wi::SpriteFont* font = editor->GetCurrentScene().fonts.GetComponent(entity); - if (font == nullptr) - return; - font->anim.typewriter.character_start = (size_t)args.iValue; - }); + wi::scene::Scene& scene = editor->GetCurrentScene(); + for (auto& x : editor->translator.selected) + { + wi::SpriteFont* font = scene.fonts.GetComponent(x.entity); + if (font == nullptr) + continue; + font->anim.typewriter.character_start = (size_t)args.iValue; + } + }); AddWidget(&typewriterStartInput); SetMinimized(true); diff --git a/Editor/ForceFieldWindow.cpp b/Editor/ForceFieldWindow.cpp index d5677a1d1..6b10822cd 100644 --- a/Editor/ForceFieldWindow.cpp +++ b/Editor/ForceFieldWindow.cpp @@ -22,7 +22,7 @@ void ForceFieldWindow::Create(EditorComponent* _editor) editor->RecordEntity(archive, entity); editor->componentsWnd.RefreshEntityTree(); - }); + }); float x = 60; float y = 0; @@ -34,9 +34,12 @@ void ForceFieldWindow::Create(EditorComponent* _editor) typeComboBox.SetPos(XMFLOAT2(x, y)); typeComboBox.SetSize(XMFLOAT2(wid, hei)); typeComboBox.OnSelect([&](wi::gui::EventArgs args) { - ForceFieldComponent* force = editor->GetCurrentScene().forces.GetComponent(entity); - if (force != nullptr && args.iValue >= 0) + wi::scene::Scene& scene = editor->GetCurrentScene(); + for (auto& x : editor->translator.selected) { + ForceFieldComponent* force = scene.forces.GetComponent(x.entity); + if (force == nullptr) + continue; switch (args.iValue) { case 0: @@ -62,9 +65,12 @@ void ForceFieldWindow::Create(EditorComponent* _editor) gravitySlider.SetSize(XMFLOAT2(wid, hei)); gravitySlider.SetPos(XMFLOAT2(x, y += step)); gravitySlider.OnSlide([&](wi::gui::EventArgs args) { - ForceFieldComponent* force = editor->GetCurrentScene().forces.GetComponent(entity); - if (force != nullptr) + wi::scene::Scene& scene = editor->GetCurrentScene(); + for (auto& x : editor->translator.selected) { + ForceFieldComponent* force = scene.forces.GetComponent(x.entity); + if (force == nullptr) + continue; force->gravity = args.fValue; } }); @@ -77,9 +83,12 @@ void ForceFieldWindow::Create(EditorComponent* _editor) rangeSlider.SetSize(XMFLOAT2(wid, hei)); rangeSlider.SetPos(XMFLOAT2(x, y += step)); rangeSlider.OnSlide([&](wi::gui::EventArgs args) { - ForceFieldComponent* force = editor->GetCurrentScene().forces.GetComponent(entity); - if (force != nullptr) + wi::scene::Scene& scene = editor->GetCurrentScene(); + for (auto& x : editor->translator.selected) { + ForceFieldComponent* force = scene.forces.GetComponent(x.entity); + if (force == nullptr) + continue; force->range = args.fValue; } }); diff --git a/Editor/HairParticleWindow.cpp b/Editor/HairParticleWindow.cpp index 9ebb0be6a..a4c6423e6 100644 --- a/Editor/HairParticleWindow.cpp +++ b/Editor/HairParticleWindow.cpp @@ -22,7 +22,7 @@ void HairParticleWindow::Create(EditorComponent* _editor) editor->RecordEntity(archive, entity); editor->componentsWnd.RefreshEntityTree(); - }); + }); float x = 120; float y = 0; @@ -39,9 +39,12 @@ void HairParticleWindow::Create(EditorComponent* _editor) meshComboBox.SetPos(XMFLOAT2(x, y)); meshComboBox.SetEnabled(false); meshComboBox.OnSelect([&](wi::gui::EventArgs args) { - auto hair = GetHair(); - if (hair != nullptr) + wi::scene::Scene& scene = editor->GetCurrentScene(); + for (auto& x : editor->translator.selected) { + wi::HairParticleSystem* hair = scene.hairs.GetComponent(x.entity); + if (hair == nullptr) + continue; if (args.iValue == 0) { hair->meshID = INVALID_ENTITY; @@ -61,9 +64,12 @@ void HairParticleWindow::Create(EditorComponent* _editor) countSlider.SetSize(XMFLOAT2(wid, hei)); countSlider.SetPos(XMFLOAT2(x, y += step)); countSlider.OnSlide([&](wi::gui::EventArgs args) { - auto hair = GetHair(); - if (hair != nullptr) + wi::scene::Scene& scene = editor->GetCurrentScene(); + for (auto& x : editor->translator.selected) { + wi::HairParticleSystem* hair = scene.hairs.GetComponent(x.entity); + if (hair == nullptr) + continue; hair->strandCount = (uint32_t)args.iValue; hair->SetDirty(); } @@ -76,9 +82,12 @@ void HairParticleWindow::Create(EditorComponent* _editor) lengthSlider.SetSize(XMFLOAT2(wid, hei)); lengthSlider.SetPos(XMFLOAT2(x, y += step)); lengthSlider.OnSlide([&](wi::gui::EventArgs args) { - auto hair = GetHair(); - if (hair != nullptr) + wi::scene::Scene& scene = editor->GetCurrentScene(); + for (auto& x : editor->translator.selected) { + wi::HairParticleSystem* hair = scene.hairs.GetComponent(x.entity); + if (hair == nullptr) + continue; hair->length = args.fValue; hair->SetDirty(); } @@ -91,9 +100,12 @@ void HairParticleWindow::Create(EditorComponent* _editor) stiffnessSlider.SetSize(XMFLOAT2(wid, hei)); stiffnessSlider.SetPos(XMFLOAT2(x, y += step)); stiffnessSlider.OnSlide([&](wi::gui::EventArgs args) { - auto hair = GetHair(); - if (hair != nullptr) + wi::scene::Scene& scene = editor->GetCurrentScene(); + for (auto& x : editor->translator.selected) { + wi::HairParticleSystem* hair = scene.hairs.GetComponent(x.entity); + if (hair == nullptr) + continue; hair->stiffness = args.fValue; hair->SetDirty(); } @@ -106,9 +118,12 @@ void HairParticleWindow::Create(EditorComponent* _editor) randomnessSlider.SetSize(XMFLOAT2(wid, hei)); randomnessSlider.SetPos(XMFLOAT2(x, y += step)); randomnessSlider.OnSlide([&](wi::gui::EventArgs args) { - auto hair = GetHair(); - if (hair != nullptr) + wi::scene::Scene& scene = editor->GetCurrentScene(); + for (auto& x : editor->translator.selected) { + wi::HairParticleSystem* hair = scene.hairs.GetComponent(x.entity); + if (hair == nullptr) + continue; hair->randomness = args.fValue; hair->SetDirty(); } @@ -121,9 +136,12 @@ void HairParticleWindow::Create(EditorComponent* _editor) //segmentcountSlider.SetSize(XMFLOAT2(wid, hei)); //segmentcountSlider.SetPos(XMFLOAT2(x, y += step)); //segmentcountSlider.OnSlide([&](wi::gui::EventArgs args) { - // auto hair = GetHair(); - // if (hair != nullptr) + // wi::scene::Scene& scene = editor->GetCurrentScene(); + // for (auto& x : editor->translator.selected) // { + // wi::HairParticleSystem* hair = scene.hairs.GetComponent(x.entity); + // if (hair == nullptr) + // continue; // hair->segmentCount = (uint32_t)args.iValue; // } //}); @@ -135,9 +153,12 @@ void HairParticleWindow::Create(EditorComponent* _editor) randomSeedSlider.SetSize(XMFLOAT2(wid, hei)); randomSeedSlider.SetPos(XMFLOAT2(x, y += step)); randomSeedSlider.OnSlide([&](wi::gui::EventArgs args) { - auto hair = GetHair(); - if (hair != nullptr) + wi::scene::Scene& scene = editor->GetCurrentScene(); + for (auto& x : editor->translator.selected) { + wi::HairParticleSystem* hair = scene.hairs.GetComponent(x.entity); + if (hair == nullptr) + continue; hair->randomSeed = (uint32_t)args.iValue; hair->SetDirty(); } @@ -150,9 +171,12 @@ void HairParticleWindow::Create(EditorComponent* _editor) viewDistanceSlider.SetSize(XMFLOAT2(wid, hei)); viewDistanceSlider.SetPos(XMFLOAT2(x, y += step)); viewDistanceSlider.OnSlide([&](wi::gui::EventArgs args) { - auto hair = GetHair(); - if (hair != nullptr) + wi::scene::Scene& scene = editor->GetCurrentScene(); + for (auto& x : editor->translator.selected) { + wi::HairParticleSystem* hair = scene.hairs.GetComponent(x.entity); + if (hair == nullptr) + continue; hair->viewDistance = args.fValue; hair->SetDirty(); } @@ -168,9 +192,12 @@ void HairParticleWindow::Create(EditorComponent* _editor) framesXInput.SetTooltip("How many horizontal frames there are in the spritesheet."); framesXInput.SetDescription("Frames: "); framesXInput.OnInputAccepted([this](wi::gui::EventArgs args) { - auto hair = GetHair(); - if (hair != nullptr) + wi::scene::Scene& scene = editor->GetCurrentScene(); + for (auto& x : editor->translator.selected) { + wi::HairParticleSystem* hair = scene.hairs.GetComponent(x.entity); + if (hair == nullptr) + continue; hair->framesX = (uint32_t)args.iValue; hair->SetDirty(); } @@ -183,13 +210,16 @@ void HairParticleWindow::Create(EditorComponent* _editor) framesYInput.SetText(""); framesYInput.SetTooltip("How many vertical frames there are in the spritesheet."); framesYInput.OnInputAccepted([this](wi::gui::EventArgs args) { - auto hair = GetHair(); - if (hair != nullptr) + wi::scene::Scene& scene = editor->GetCurrentScene(); + for (auto& x : editor->translator.selected) { + wi::HairParticleSystem* hair = scene.hairs.GetComponent(x.entity); + if (hair == nullptr) + continue; hair->framesY = (uint32_t)args.iValue; hair->SetDirty(); } - }); + }); AddWidget(&framesYInput); step = 20; @@ -201,13 +231,16 @@ void HairParticleWindow::Create(EditorComponent* _editor) frameCountInput.SetTooltip("Enter a value to enable the random sprite sheet frame selection's max frame number."); frameCountInput.SetDescription("Frame Count: "); frameCountInput.OnInputAccepted([this](wi::gui::EventArgs args) { - auto hair = GetHair(); - if (hair != nullptr) + wi::scene::Scene& scene = editor->GetCurrentScene(); + for (auto& x : editor->translator.selected) { + wi::HairParticleSystem* hair = scene.hairs.GetComponent(x.entity); + if (hair == nullptr) + continue; hair->frameCount = (uint32_t)args.iValue; hair->SetDirty(); } - }); + }); AddWidget(&frameCountInput); frameStartInput.Create(""); @@ -217,13 +250,16 @@ void HairParticleWindow::Create(EditorComponent* _editor) frameStartInput.SetTooltip("Specifies the first frame of the sheet that can be used."); frameStartInput.SetDescription("First Frame: "); frameStartInput.OnInputAccepted([this](wi::gui::EventArgs args) { - auto hair = GetHair(); - if (hair != nullptr) + wi::scene::Scene& scene = editor->GetCurrentScene(); + for (auto& x : editor->translator.selected) { + wi::HairParticleSystem* hair = scene.hairs.GetComponent(x.entity); + if (hair == nullptr) + continue; hair->frameStart = (uint32_t)args.iValue; hair->SetDirty(); } - }); + }); AddWidget(&frameStartInput); diff --git a/Editor/HierarchyWindow.cpp b/Editor/HierarchyWindow.cpp index 1ed938dd7..9b63c9b71 100644 --- a/Editor/HierarchyWindow.cpp +++ b/Editor/HierarchyWindow.cpp @@ -22,7 +22,7 @@ void HierarchyWindow::Create(EditorComponent* _editor) editor->RecordEntity(archive, entity); editor->componentsWnd.RefreshEntityTree(); - }); + }); float x = 80; float xx = x; @@ -55,7 +55,7 @@ void HierarchyWindow::Create(EditorComponent* _editor) editor->componentsWnd.RefreshEntityTree(); - }); + }); parentCombo.SetTooltip("Choose a parent entity (also works if selected entity has no transform)"); AddWidget(&parentCombo); diff --git a/Editor/IKWindow.cpp b/Editor/IKWindow.cpp index 997ad7026..0dd3f32be 100644 --- a/Editor/IKWindow.cpp +++ b/Editor/IKWindow.cpp @@ -35,10 +35,12 @@ void IKWindow::Create(EditorComponent* _editor) targetCombo.SetPos(XMFLOAT2(x, y)); targetCombo.SetEnabled(false); targetCombo.OnSelect([&](wi::gui::EventArgs args) { - Scene& scene = editor->GetCurrentScene(); - InverseKinematicsComponent* ik = scene.inverse_kinematics.GetComponent(entity); - if (ik != nullptr) + wi::scene::Scene& scene = editor->GetCurrentScene(); + for (auto& x : editor->translator.selected) { + InverseKinematicsComponent* ik = scene.inverse_kinematics.GetComponent(x.entity); + if (ik == nullptr) + continue; if (args.iValue == 0) { ik->target = INVALID_ENTITY; @@ -48,7 +50,7 @@ void IKWindow::Create(EditorComponent* _editor) ik->target = scene.transforms.GetEntity(args.iValue - 1); } } - }); + }); targetCombo.SetTooltip("Choose a target entity (with transform) that the IK will follow"); AddWidget(&targetCombo); @@ -57,8 +59,15 @@ void IKWindow::Create(EditorComponent* _editor) disabledCheckBox.SetPos(XMFLOAT2(x, y += step)); disabledCheckBox.SetSize(XMFLOAT2(hei, hei)); disabledCheckBox.OnClick([=](wi::gui::EventArgs args) { - editor->GetCurrentScene().inverse_kinematics.GetComponent(entity)->SetDisabled(args.bValue); - }); + wi::scene::Scene& scene = editor->GetCurrentScene(); + for (auto& x : editor->translator.selected) + { + InverseKinematicsComponent* ik = scene.inverse_kinematics.GetComponent(x.entity); + if (ik == nullptr) + continue; + ik->SetDisabled(args.bValue); + } + }); AddWidget(&disabledCheckBox); chainLengthSlider.Create(0, 10, 0, 10, "Chain Length: "); @@ -66,8 +75,15 @@ void IKWindow::Create(EditorComponent* _editor) chainLengthSlider.SetPos(XMFLOAT2(x, y += step)); chainLengthSlider.SetSize(XMFLOAT2(siz, hei)); chainLengthSlider.OnSlide([&](wi::gui::EventArgs args) { - editor->GetCurrentScene().inverse_kinematics.GetComponent(entity)->chain_length = args.iValue; - }); + wi::scene::Scene& scene = editor->GetCurrentScene(); + for (auto& x : editor->translator.selected) + { + InverseKinematicsComponent* ik = scene.inverse_kinematics.GetComponent(x.entity); + if (ik == nullptr) + continue; + ik->chain_length = args.iValue; + } + }); AddWidget(&chainLengthSlider); iterationCountSlider.Create(0, 10, 1, 10, "Iteration Count: "); @@ -75,8 +91,15 @@ void IKWindow::Create(EditorComponent* _editor) iterationCountSlider.SetPos(XMFLOAT2(x, y += step)); iterationCountSlider.SetSize(XMFLOAT2(siz, hei)); iterationCountSlider.OnSlide([&](wi::gui::EventArgs args) { - editor->GetCurrentScene().inverse_kinematics.GetComponent(entity)->iteration_count = args.iValue; - }); + wi::scene::Scene& scene = editor->GetCurrentScene(); + for (auto& x : editor->translator.selected) + { + InverseKinematicsComponent* ik = scene.inverse_kinematics.GetComponent(x.entity); + if (ik == nullptr) + continue; + ik->iteration_count = args.iValue; + } + }); AddWidget(&iterationCountSlider); SetMinimized(true); diff --git a/Editor/LayerWindow.cpp b/Editor/LayerWindow.cpp index 762467fb9..f23e1ebd9 100644 --- a/Editor/LayerWindow.cpp +++ b/Editor/LayerWindow.cpp @@ -22,7 +22,7 @@ void LayerWindow::Create(EditorComponent* _editor) editor->RecordEntity(archive, entity); editor->componentsWnd.RefreshEntityTree(); - }); + }); float x = 30; float y = 0; @@ -44,23 +44,25 @@ void LayerWindow::Create(EditorComponent* _editor) layers[i].SetText(std::to_string(i) + ": "); layers[i].SetPos(XMFLOAT2(x + 20 + (i % 5) * 50, y + (i / 5) * step)); layers[i].OnClick([=](wi::gui::EventArgs args) { - - LayerComponent* layer = editor->GetCurrentScene().layers.GetComponent(entity); - if (layer == nullptr) + wi::scene::Scene& scene = editor->GetCurrentScene(); + for (auto& x : editor->translator.selected) { - layer = &editor->GetCurrentScene().layers.Create(entity); - } + LayerComponent* layer = scene.layers.GetComponent(x.entity); + if (layer == nullptr) + { + layer = &editor->GetCurrentScene().layers.Create(x.entity); + } - if (args.bValue) - { - layer->layerMask |= 1 << i; + if (args.bValue) + { + layer->layerMask |= 1 << i; + } + else + { + layer->layerMask &= ~(1 << i); + } } - else - { - layer->layerMask &= ~(1 << i); - } - - }); + }); AddWidget(&layers[i]); } @@ -69,28 +71,36 @@ void LayerWindow::Create(EditorComponent* _editor) enableAllButton.Create("ALL " ICON_CHECK); enableAllButton.SetPos(XMFLOAT2(x, y)); enableAllButton.OnClick([this](wi::gui::EventArgs args) { - LayerComponent* layer = editor->GetCurrentScene().layers.GetComponent(entity); - if (layer == nullptr) + wi::scene::Scene& scene = editor->GetCurrentScene(); + for (auto& x : editor->translator.selected) { - layer = &editor->GetCurrentScene().layers.Create(entity); + LayerComponent* layer = scene.layers.GetComponent(x.entity); + if (layer == nullptr) + { + layer = &editor->GetCurrentScene().layers.Create(x.entity); + } + if (layer == nullptr) + return; + layer->layerMask = ~0; } - if (layer == nullptr) - return; - layer->layerMask = ~0; }); AddWidget(&enableAllButton); enableNoneButton.Create("NONE " ICON_DISABLED); enableNoneButton.SetPos(XMFLOAT2(x + 120, y)); enableNoneButton.OnClick([this](wi::gui::EventArgs args) { - LayerComponent* layer = editor->GetCurrentScene().layers.GetComponent(entity); - if (layer == nullptr) + wi::scene::Scene& scene = editor->GetCurrentScene(); + for (auto& x : editor->translator.selected) { - layer = &editor->GetCurrentScene().layers.Create(entity); + LayerComponent* layer = scene.layers.GetComponent(x.entity); + if (layer == nullptr) + { + layer = &editor->GetCurrentScene().layers.Create(x.entity); + } + if (layer == nullptr) + return; + layer->layerMask = 0; } - if (layer == nullptr) - return; - layer->layerMask = 0; }); AddWidget(&enableNoneButton); diff --git a/Editor/MaterialWindow.cpp b/Editor/MaterialWindow.cpp index 74dc3be3f..37fb7e120 100644 --- a/Editor/MaterialWindow.cpp +++ b/Editor/MaterialWindow.cpp @@ -5,6 +5,26 @@ using namespace wi::graphics; using namespace wi::ecs; using namespace wi::scene; +MaterialComponent* get_material(Scene& scene, PickResult x) +{ + MaterialComponent* material = scene.materials.GetComponent(x.entity); + if (material == nullptr) + { + // Material could be selected indirectly as part of selected subset: + ObjectComponent* object = scene.objects.GetComponent(x.entity); + if (object != nullptr && object->meshID != INVALID_ENTITY) + { + MeshComponent* mesh = scene.meshes.GetComponent(object->meshID); + if (mesh != nullptr) + { + Entity materialID = mesh->subsets[x.subsetIndex].materialID; + material = scene.materials.GetComponent(materialID); + } + } + } + return material; +}; + void MaterialWindow::Create(EditorComponent* _editor) { editor = _editor; @@ -23,22 +43,28 @@ void MaterialWindow::Create(EditorComponent* _editor) editor->RecordEntity(archive, entity); editor->componentsWnd.RefreshEntityTree(); - }); + }); float hei = 18; float step = hei + 2; float x = 150, y = 0; float wid = 130; + shadowReceiveCheckBox.Create("Receive Shadow: "); shadowReceiveCheckBox.SetTooltip("Receives shadow or not?"); shadowReceiveCheckBox.SetPos(XMFLOAT2(x, y)); shadowReceiveCheckBox.SetSize(XMFLOAT2(hei, hei)); shadowReceiveCheckBox.OnClick([&](wi::gui::EventArgs args) { - MaterialComponent* material = editor->GetCurrentScene().materials.GetComponent(entity); - if (material != nullptr) + wi::scene::Scene& scene = editor->GetCurrentScene(); + for (auto& x : editor->translator.selected) + { + MaterialComponent* material = get_material(scene, x); + if (material == nullptr) + continue; material->SetReceiveShadow(args.bValue); - }); + } + }); AddWidget(&shadowReceiveCheckBox); shadowCasterCheckBox.Create("Cast Shadow: "); @@ -46,9 +72,14 @@ void MaterialWindow::Create(EditorComponent* _editor) shadowCasterCheckBox.SetPos(XMFLOAT2(x, y += step)); shadowCasterCheckBox.SetSize(XMFLOAT2(hei, hei)); shadowCasterCheckBox.OnClick([&](wi::gui::EventArgs args) { - MaterialComponent* material = editor->GetCurrentScene().materials.GetComponent(entity); - if (material != nullptr) + wi::scene::Scene& scene = editor->GetCurrentScene(); + for (auto& x : editor->translator.selected) + { + MaterialComponent* material = get_material(scene, x); + if (material == nullptr) + continue; material->SetCastShadow(args.bValue); + } }); AddWidget(&shadowCasterCheckBox); @@ -57,9 +88,14 @@ void MaterialWindow::Create(EditorComponent* _editor) useVertexColorsCheckBox.SetPos(XMFLOAT2(x, y += step)); useVertexColorsCheckBox.SetSize(XMFLOAT2(hei, hei)); useVertexColorsCheckBox.OnClick([&](wi::gui::EventArgs args) { - MaterialComponent* material = editor->GetCurrentScene().materials.GetComponent(entity); - if (material != nullptr) + wi::scene::Scene& scene = editor->GetCurrentScene(); + for (auto& x : editor->translator.selected) + { + MaterialComponent* material = get_material(scene, x); + if (material == nullptr) + continue; material->SetUseVertexColors(args.bValue); + } }); AddWidget(&useVertexColorsCheckBox); @@ -68,10 +104,14 @@ void MaterialWindow::Create(EditorComponent* _editor) specularGlossinessCheckBox.SetPos(XMFLOAT2(x, y += step)); specularGlossinessCheckBox.SetSize(XMFLOAT2(hei, hei)); specularGlossinessCheckBox.OnClick([&](wi::gui::EventArgs args) { - MaterialComponent* material = editor->GetCurrentScene().materials.GetComponent(entity); - if (material != nullptr) + wi::scene::Scene& scene = editor->GetCurrentScene(); + for (auto& x : editor->translator.selected) + { + MaterialComponent* material = get_material(scene, x); + if (material == nullptr) + continue; material->SetUseSpecularGlossinessWorkflow(args.bValue); - SetEntity(entity); + } }); AddWidget(&specularGlossinessCheckBox); @@ -80,9 +120,14 @@ void MaterialWindow::Create(EditorComponent* _editor) occlusionPrimaryCheckBox.SetPos(XMFLOAT2(x, y += step)); occlusionPrimaryCheckBox.SetSize(XMFLOAT2(hei, hei)); occlusionPrimaryCheckBox.OnClick([&](wi::gui::EventArgs args) { - MaterialComponent* material = editor->GetCurrentScene().materials.GetComponent(entity); - if (material != nullptr) + wi::scene::Scene& scene = editor->GetCurrentScene(); + for (auto& x : editor->translator.selected) + { + MaterialComponent* material = get_material(scene, x); + if (material == nullptr) + continue; material->SetOcclusionEnabled_Primary(args.bValue); + } }); AddWidget(&occlusionPrimaryCheckBox); @@ -91,9 +136,14 @@ void MaterialWindow::Create(EditorComponent* _editor) occlusionSecondaryCheckBox.SetPos(XMFLOAT2(x, y += step)); occlusionSecondaryCheckBox.SetSize(XMFLOAT2(hei, hei)); occlusionSecondaryCheckBox.OnClick([&](wi::gui::EventArgs args) { - MaterialComponent* material = editor->GetCurrentScene().materials.GetComponent(entity); - if (material != nullptr) + wi::scene::Scene& scene = editor->GetCurrentScene(); + for (auto& x : editor->translator.selected) + { + MaterialComponent* material = get_material(scene, x); + if (material == nullptr) + continue; material->SetOcclusionEnabled_Secondary(args.bValue); + } }); AddWidget(&occlusionSecondaryCheckBox); @@ -102,10 +152,15 @@ void MaterialWindow::Create(EditorComponent* _editor) vertexAOCheckBox.SetPos(XMFLOAT2(x, y += step)); vertexAOCheckBox.SetSize(XMFLOAT2(hei, hei)); vertexAOCheckBox.OnClick([&](wi::gui::EventArgs args) { - MaterialComponent* material = editor->GetCurrentScene().materials.GetComponent(entity); - if (material != nullptr) + wi::scene::Scene& scene = editor->GetCurrentScene(); + for (auto& x : editor->translator.selected) + { + MaterialComponent* material = get_material(scene, x); + if (material == nullptr) + continue; material->SetVertexAODisabled(!args.bValue); - }); + } + }); AddWidget(&vertexAOCheckBox); windCheckBox.Create("Wind: "); @@ -113,10 +168,15 @@ void MaterialWindow::Create(EditorComponent* _editor) windCheckBox.SetPos(XMFLOAT2(x, y += step)); windCheckBox.SetSize(XMFLOAT2(hei, hei)); windCheckBox.OnClick([&](wi::gui::EventArgs args) { - MaterialComponent* material = editor->GetCurrentScene().materials.GetComponent(entity); - if (material != nullptr) + wi::scene::Scene& scene = editor->GetCurrentScene(); + for (auto& x : editor->translator.selected) + { + MaterialComponent* material = get_material(scene, x); + if (material == nullptr) + continue; material->SetUseWind(args.bValue); - }); + } + }); AddWidget(&windCheckBox); doubleSidedCheckBox.Create("Double sided: "); @@ -124,10 +184,15 @@ void MaterialWindow::Create(EditorComponent* _editor) doubleSidedCheckBox.SetPos(XMFLOAT2(x, y += step)); doubleSidedCheckBox.SetSize(XMFLOAT2(hei, hei)); doubleSidedCheckBox.OnClick([&](wi::gui::EventArgs args) { - MaterialComponent* material = editor->GetCurrentScene().materials.GetComponent(entity); - if (material != nullptr) + wi::scene::Scene& scene = editor->GetCurrentScene(); + for (auto& x : editor->translator.selected) + { + MaterialComponent* material = get_material(scene, x); + if (material == nullptr) + continue; material->SetDoubleSided(args.bValue); - }); + } + }); AddWidget(&doubleSidedCheckBox); outlineCheckBox.Create("Cartoon Outline: "); @@ -135,10 +200,15 @@ void MaterialWindow::Create(EditorComponent* _editor) outlineCheckBox.SetPos(XMFLOAT2(x, y += step)); outlineCheckBox.SetSize(XMFLOAT2(hei, hei)); outlineCheckBox.OnClick([&](wi::gui::EventArgs args) { - MaterialComponent* material = editor->GetCurrentScene().materials.GetComponent(entity); - if (material != nullptr) + wi::scene::Scene& scene = editor->GetCurrentScene(); + for (auto& x : editor->translator.selected) + { + MaterialComponent* material = get_material(scene, x); + if (material == nullptr) + continue; material->SetOutlineEnabled(args.bValue); - }); + } + }); AddWidget(&outlineCheckBox); preferUncompressedCheckBox.Create("Prefer Uncompressed Textures: "); @@ -146,11 +216,16 @@ void MaterialWindow::Create(EditorComponent* _editor) preferUncompressedCheckBox.SetPos(XMFLOAT2(x, y += step)); preferUncompressedCheckBox.SetSize(XMFLOAT2(hei, hei)); preferUncompressedCheckBox.OnClick([&](wi::gui::EventArgs args) { - MaterialComponent* material = editor->GetCurrentScene().materials.GetComponent(entity); - if (material != nullptr) + wi::scene::Scene& scene = editor->GetCurrentScene(); + for (auto& x : editor->translator.selected) + { + MaterialComponent* material = get_material(scene, x); + if (material == nullptr) + continue; material->SetPreferUncompressedTexturesEnabled(args.bValue); - textureSlotComboBox.SetSelected(textureSlotComboBox.GetSelected()); - }); + } + textureSlotComboBox.SetSelected(textureSlotComboBox.GetSelected()); // update + }); AddWidget(&preferUncompressedCheckBox); @@ -159,9 +234,12 @@ void MaterialWindow::Create(EditorComponent* _editor) shaderTypeComboBox.SetPos(XMFLOAT2(x, y += step)); shaderTypeComboBox.SetSize(XMFLOAT2(wid, hei)); shaderTypeComboBox.OnSelect([&](wi::gui::EventArgs args) { - MaterialComponent* material = editor->GetCurrentScene().materials.GetComponent(entity); - if (material != nullptr) + wi::scene::Scene& scene = editor->GetCurrentScene(); + for (auto& x : editor->translator.selected) { + MaterialComponent* material = get_material(scene, x); + if (material == nullptr) + continue; if (args.iValue >= MaterialComponent::SHADERTYPE_COUNT) { material->SetCustomShaderID(args.iValue - MaterialComponent::SHADERTYPE_COUNT); @@ -174,7 +252,7 @@ void MaterialWindow::Create(EditorComponent* _editor) blendModeComboBox.SetEnabled(true); } } - }); + }); shaderTypeComboBox.SetEnabled(false); shaderTypeComboBox.SetMaxVisibleItemCount(5); AddWidget(&shaderTypeComboBox); @@ -183,12 +261,15 @@ void MaterialWindow::Create(EditorComponent* _editor) blendModeComboBox.SetPos(XMFLOAT2(x, y += step)); blendModeComboBox.SetSize(XMFLOAT2(wid, hei)); blendModeComboBox.OnSelect([&](wi::gui::EventArgs args) { - MaterialComponent* material = editor->GetCurrentScene().materials.GetComponent(entity); - if (material != nullptr && args.iValue >= 0) + wi::scene::Scene& scene = editor->GetCurrentScene(); + for (auto& x : editor->translator.selected) { + MaterialComponent* material = get_material(scene, x); + if (material == nullptr) + continue; material->userBlendMode = (wi::enums::BLENDMODE)args.iValue; } - }); + }); blendModeComboBox.AddItem("Opaque"); blendModeComboBox.AddItem("Alpha"); blendModeComboBox.AddItem("Premultiplied"); @@ -203,12 +284,15 @@ void MaterialWindow::Create(EditorComponent* _editor) shadingRateComboBox.SetPos(XMFLOAT2(x, y += step)); shadingRateComboBox.SetSize(XMFLOAT2(wid, hei)); shadingRateComboBox.OnSelect([&](wi::gui::EventArgs args) { - MaterialComponent* material = editor->GetCurrentScene().materials.GetComponent(entity); - if (material != nullptr) + wi::scene::Scene& scene = editor->GetCurrentScene(); + for (auto& x : editor->translator.selected) { + MaterialComponent* material = get_material(scene, x); + if (material == nullptr) + continue; material->shadingRate = (ShadingRate)args.iValue; } - }); + }); shadingRateComboBox.AddItem("1X1"); shadingRateComboBox.AddItem("1X2"); shadingRateComboBox.AddItem("2X1"); @@ -230,9 +314,14 @@ void MaterialWindow::Create(EditorComponent* _editor) normalMapSlider.SetSize(XMFLOAT2(wid, hei)); normalMapSlider.SetPos(XMFLOAT2(x, y += step)); normalMapSlider.OnSlide([&](wi::gui::EventArgs args) { - MaterialComponent* material = editor->GetCurrentScene().materials.GetComponent(entity); - if (material != nullptr) + wi::scene::Scene& scene = editor->GetCurrentScene(); + for (auto& x : editor->translator.selected) + { + MaterialComponent* material = get_material(scene, x); + if (material == nullptr) + continue; material->SetNormalMapStrength(args.fValue); + } }); AddWidget(&normalMapSlider); @@ -241,9 +330,14 @@ void MaterialWindow::Create(EditorComponent* _editor) roughnessSlider.SetSize(XMFLOAT2(wid, hei)); roughnessSlider.SetPos(XMFLOAT2(x, y += step)); roughnessSlider.OnSlide([&](wi::gui::EventArgs args) { - MaterialComponent* material = editor->GetCurrentScene().materials.GetComponent(entity); - if (material != nullptr) + wi::scene::Scene& scene = editor->GetCurrentScene(); + for (auto& x : editor->translator.selected) + { + MaterialComponent* material = get_material(scene, x); + if (material == nullptr) + continue; material->SetRoughness(args.fValue); + } }); AddWidget(&roughnessSlider); @@ -252,9 +346,14 @@ void MaterialWindow::Create(EditorComponent* _editor) reflectanceSlider.SetSize(XMFLOAT2(wid, hei)); reflectanceSlider.SetPos(XMFLOAT2(x, y += step)); reflectanceSlider.OnSlide([&](wi::gui::EventArgs args) { - MaterialComponent* material = editor->GetCurrentScene().materials.GetComponent(entity); - if (material != nullptr) + wi::scene::Scene& scene = editor->GetCurrentScene(); + for (auto& x : editor->translator.selected) + { + MaterialComponent* material = get_material(scene, x); + if (material == nullptr) + continue; material->SetReflectance(args.fValue); + } }); AddWidget(&reflectanceSlider); @@ -263,9 +362,14 @@ void MaterialWindow::Create(EditorComponent* _editor) metalnessSlider.SetSize(XMFLOAT2(wid, hei)); metalnessSlider.SetPos(XMFLOAT2(x, y += step)); metalnessSlider.OnSlide([&](wi::gui::EventArgs args) { - MaterialComponent* material = editor->GetCurrentScene().materials.GetComponent(entity); - if (material != nullptr) + wi::scene::Scene& scene = editor->GetCurrentScene(); + for (auto& x : editor->translator.selected) + { + MaterialComponent* material = get_material(scene, x); + if (material == nullptr) + continue; material->SetMetalness(args.fValue); + } }); AddWidget(&metalnessSlider); @@ -274,9 +378,14 @@ void MaterialWindow::Create(EditorComponent* _editor) alphaRefSlider.SetSize(XMFLOAT2(wid, hei)); alphaRefSlider.SetPos(XMFLOAT2(x, y += step)); alphaRefSlider.OnSlide([&](wi::gui::EventArgs args) { - MaterialComponent* material = editor->GetCurrentScene().materials.GetComponent(entity); - if (material != nullptr) + wi::scene::Scene& scene = editor->GetCurrentScene(); + for (auto& x : editor->translator.selected) + { + MaterialComponent* material = get_material(scene, x); + if (material == nullptr) + continue; material->SetAlphaRef(args.fValue); + } }); AddWidget(&alphaRefSlider); @@ -285,9 +394,14 @@ void MaterialWindow::Create(EditorComponent* _editor) emissiveSlider.SetSize(XMFLOAT2(wid, hei)); emissiveSlider.SetPos(XMFLOAT2(x, y += step)); emissiveSlider.OnSlide([&](wi::gui::EventArgs args) { - MaterialComponent* material = editor->GetCurrentScene().materials.GetComponent(entity); - if (material != nullptr) + wi::scene::Scene& scene = editor->GetCurrentScene(); + for (auto& x : editor->translator.selected) + { + MaterialComponent* material = get_material(scene, x); + if (material == nullptr) + continue; material->SetEmissiveStrength(args.fValue); + } }); AddWidget(&emissiveSlider); @@ -296,10 +410,15 @@ void MaterialWindow::Create(EditorComponent* _editor) transmissionSlider.SetSize(XMFLOAT2(wid, hei)); transmissionSlider.SetPos(XMFLOAT2(x, y += step)); transmissionSlider.OnSlide([&](wi::gui::EventArgs args) { - MaterialComponent* material = editor->GetCurrentScene().materials.GetComponent(entity); - if (material != nullptr) + wi::scene::Scene& scene = editor->GetCurrentScene(); + for (auto& x : editor->translator.selected) + { + MaterialComponent* material = get_material(scene, x); + if (material == nullptr) + continue; material->SetTransmissionAmount(args.fValue); - }); + } + }); AddWidget(&transmissionSlider); refractionSlider.Create(0, 1, 0, 1000, "Refraction: "); @@ -307,10 +426,15 @@ void MaterialWindow::Create(EditorComponent* _editor) refractionSlider.SetSize(XMFLOAT2(wid, hei)); refractionSlider.SetPos(XMFLOAT2(x, y += step)); refractionSlider.OnSlide([&](wi::gui::EventArgs args) { - MaterialComponent* material = editor->GetCurrentScene().materials.GetComponent(entity); - if (material != nullptr) + wi::scene::Scene& scene = editor->GetCurrentScene(); + for (auto& x : editor->translator.selected) + { + MaterialComponent* material = get_material(scene, x); + if (material == nullptr) + continue; material->SetRefractionAmount(args.fValue); - }); + } + }); AddWidget(&refractionSlider); pomSlider.Create(0, 1.0f, 0.0f, 1000, "Par Occl Mapping: "); @@ -318,9 +442,14 @@ void MaterialWindow::Create(EditorComponent* _editor) pomSlider.SetSize(XMFLOAT2(wid, hei)); pomSlider.SetPos(XMFLOAT2(x, y += step)); pomSlider.OnSlide([&](wi::gui::EventArgs args) { - MaterialComponent* material = editor->GetCurrentScene().materials.GetComponent(entity); - if (material != nullptr) + wi::scene::Scene& scene = editor->GetCurrentScene(); + for (auto& x : editor->translator.selected) + { + MaterialComponent* material = get_material(scene, x); + if (material == nullptr) + continue; material->SetParallaxOcclusionMapping(args.fValue); + } }); AddWidget(&pomSlider); @@ -329,10 +458,15 @@ void MaterialWindow::Create(EditorComponent* _editor) anisotropyStrengthSlider.SetSize(XMFLOAT2(wid, hei)); anisotropyStrengthSlider.SetPos(XMFLOAT2(x, y += step)); anisotropyStrengthSlider.OnSlide([&](wi::gui::EventArgs args) { - MaterialComponent* material = editor->GetCurrentScene().materials.GetComponent(entity); - if (material != nullptr) + wi::scene::Scene& scene = editor->GetCurrentScene(); + for (auto& x : editor->translator.selected) + { + MaterialComponent* material = get_material(scene, x); + if (material == nullptr) + continue; material->anisotropy_strength = args.fValue; - }); + } + }); AddWidget(&anisotropyStrengthSlider); anisotropyRotationSlider.Create(0, 360, 0.0f, 360, "Anisotropy Rot: "); @@ -340,10 +474,15 @@ void MaterialWindow::Create(EditorComponent* _editor) anisotropyRotationSlider.SetSize(XMFLOAT2(wid, hei)); anisotropyRotationSlider.SetPos(XMFLOAT2(x, y += step)); anisotropyRotationSlider.OnSlide([&](wi::gui::EventArgs args) { - MaterialComponent* material = editor->GetCurrentScene().materials.GetComponent(entity); - if (material != nullptr) + wi::scene::Scene& scene = editor->GetCurrentScene(); + for (auto& x : editor->translator.selected) + { + MaterialComponent* material = get_material(scene, x); + if (material == nullptr) + continue; material->anisotropy_rotation = wi::math::DegreesToRadians(args.fValue); - }); + } + }); AddWidget(&anisotropyRotationSlider); @@ -352,9 +491,14 @@ void MaterialWindow::Create(EditorComponent* _editor) displacementMappingSlider.SetSize(XMFLOAT2(wid, hei)); displacementMappingSlider.SetPos(XMFLOAT2(x, y += step)); displacementMappingSlider.OnSlide([&](wi::gui::EventArgs args) { - MaterialComponent* material = editor->GetCurrentScene().materials.GetComponent(entity); - if (material != nullptr) + wi::scene::Scene& scene = editor->GetCurrentScene(); + for (auto& x : editor->translator.selected) + { + MaterialComponent* material = get_material(scene, x); + if (material == nullptr) + continue; material->SetDisplacementMapping(args.fValue); + } }); AddWidget(&displacementMappingSlider); @@ -363,9 +507,14 @@ void MaterialWindow::Create(EditorComponent* _editor) subsurfaceScatteringSlider.SetSize(XMFLOAT2(wid, hei)); subsurfaceScatteringSlider.SetPos(XMFLOAT2(x, y += step)); subsurfaceScatteringSlider.OnSlide([&](wi::gui::EventArgs args) { - MaterialComponent* material = editor->GetCurrentScene().materials.GetComponent(entity); - if (material != nullptr) + wi::scene::Scene& scene = editor->GetCurrentScene(); + for (auto& x : editor->translator.selected) + { + MaterialComponent* material = get_material(scene, x); + if (material == nullptr) + continue; material->SetSubsurfaceScatteringAmount(args.fValue); + } }); AddWidget(&subsurfaceScatteringSlider); @@ -374,9 +523,12 @@ void MaterialWindow::Create(EditorComponent* _editor) texAnimFrameRateSlider.SetSize(XMFLOAT2(wid, hei)); texAnimFrameRateSlider.SetPos(XMFLOAT2(x, y += step)); texAnimFrameRateSlider.OnSlide([&](wi::gui::EventArgs args) { - MaterialComponent* material = editor->GetCurrentScene().materials.GetComponent(entity); - if (material != nullptr) + wi::scene::Scene& scene = editor->GetCurrentScene(); + for (auto& x : editor->translator.selected) { + MaterialComponent* material = get_material(scene, x); + if (material == nullptr) + continue; material->texAnimFrameRate = args.fValue; } }); @@ -387,9 +539,12 @@ void MaterialWindow::Create(EditorComponent* _editor) texAnimDirectionSliderU.SetSize(XMFLOAT2(wid, hei)); texAnimDirectionSliderU.SetPos(XMFLOAT2(x, y += step)); texAnimDirectionSliderU.OnSlide([&](wi::gui::EventArgs args) { - MaterialComponent* material = editor->GetCurrentScene().materials.GetComponent(entity); - if (material != nullptr) + wi::scene::Scene& scene = editor->GetCurrentScene(); + for (auto& x : editor->translator.selected) { + MaterialComponent* material = get_material(scene, x); + if (material == nullptr) + continue; material->texAnimDirection.x = args.fValue; } }); @@ -400,9 +555,12 @@ void MaterialWindow::Create(EditorComponent* _editor) texAnimDirectionSliderV.SetSize(XMFLOAT2(wid, hei)); texAnimDirectionSliderV.SetPos(XMFLOAT2(x, y += step)); texAnimDirectionSliderV.OnSlide([&](wi::gui::EventArgs args) { - MaterialComponent* material = editor->GetCurrentScene().materials.GetComponent(entity); - if (material != nullptr) + wi::scene::Scene& scene = editor->GetCurrentScene(); + for (auto& x : editor->translator.selected) { + MaterialComponent* material = get_material(scene, x); + if (material == nullptr) + continue; material->texAnimDirection.y = args.fValue; } }); @@ -413,9 +571,12 @@ void MaterialWindow::Create(EditorComponent* _editor) texMulSliderX.SetSize(XMFLOAT2(wid, hei)); texMulSliderX.SetPos(XMFLOAT2(x, y += step)); texMulSliderX.OnSlide([&](wi::gui::EventArgs args) { - MaterialComponent* material = editor->GetCurrentScene().materials.GetComponent(entity); - if (material != nullptr) + wi::scene::Scene& scene = editor->GetCurrentScene(); + for (auto& x : editor->translator.selected) { + MaterialComponent* material = get_material(scene, x); + if (material == nullptr) + continue; material->SetDirty(); material->texMulAdd.x = args.fValue; } @@ -427,9 +588,12 @@ void MaterialWindow::Create(EditorComponent* _editor) texMulSliderY.SetSize(XMFLOAT2(wid, hei)); texMulSliderY.SetPos(XMFLOAT2(x, y += step)); texMulSliderY.OnSlide([&](wi::gui::EventArgs args) { - MaterialComponent* material = editor->GetCurrentScene().materials.GetComponent(entity); - if (material != nullptr) + wi::scene::Scene& scene = editor->GetCurrentScene(); + for (auto& x : editor->translator.selected) { + MaterialComponent* material = get_material(scene, x); + if (material == nullptr) + continue; material->SetDirty(); material->texMulAdd.y = args.fValue; } @@ -442,12 +606,15 @@ void MaterialWindow::Create(EditorComponent* _editor) sheenRoughnessSlider.SetSize(XMFLOAT2(wid, hei)); sheenRoughnessSlider.SetPos(XMFLOAT2(x, y += step)); sheenRoughnessSlider.OnSlide([&](wi::gui::EventArgs args) { - MaterialComponent* material = editor->GetCurrentScene().materials.GetComponent(entity); - if (material != nullptr) + wi::scene::Scene& scene = editor->GetCurrentScene(); + for (auto& x : editor->translator.selected) { + MaterialComponent* material = get_material(scene, x); + if (material == nullptr) + continue; material->SetSheenRoughness(args.fValue); } - }); + }); AddWidget(&sheenRoughnessSlider); clearcoatSlider.Create(0, 1, 0, 1000, "Clearcoat: "); @@ -455,12 +622,15 @@ void MaterialWindow::Create(EditorComponent* _editor) clearcoatSlider.SetSize(XMFLOAT2(wid, hei)); clearcoatSlider.SetPos(XMFLOAT2(x, y += step)); clearcoatSlider.OnSlide([&](wi::gui::EventArgs args) { - MaterialComponent* material = editor->GetCurrentScene().materials.GetComponent(entity); - if (material != nullptr) + wi::scene::Scene& scene = editor->GetCurrentScene(); + for (auto& x : editor->translator.selected) { + MaterialComponent* material = get_material(scene, x); + if (material == nullptr) + continue; material->SetClearcoatFactor(args.fValue); } - }); + }); AddWidget(&clearcoatSlider); clearcoatRoughnessSlider.Create(0, 1, 0, 1000, "Clearcoat Roughness: "); @@ -468,12 +638,15 @@ void MaterialWindow::Create(EditorComponent* _editor) clearcoatRoughnessSlider.SetSize(XMFLOAT2(wid, hei)); clearcoatRoughnessSlider.SetPos(XMFLOAT2(x, y += step)); clearcoatRoughnessSlider.OnSlide([&](wi::gui::EventArgs args) { - MaterialComponent* material = editor->GetCurrentScene().materials.GetComponent(entity); - if (material != nullptr) + wi::scene::Scene& scene = editor->GetCurrentScene(); + for (auto& x : editor->translator.selected) { + MaterialComponent* material = get_material(scene, x); + if (material == nullptr) + continue; material->SetClearcoatRoughness(args.fValue); } - }); + }); AddWidget(&clearcoatRoughnessSlider); blendTerrainSlider.Create(0, 2, 0, 1000, "Blend with terrain: "); @@ -481,12 +654,15 @@ void MaterialWindow::Create(EditorComponent* _editor) blendTerrainSlider.SetSize(XMFLOAT2(wid, hei)); blendTerrainSlider.SetPos(XMFLOAT2(x, y += step)); blendTerrainSlider.OnSlide([&](wi::gui::EventArgs args) { - MaterialComponent* material = editor->GetCurrentScene().materials.GetComponent(entity); - if (material != nullptr) + wi::scene::Scene& scene = editor->GetCurrentScene(); + for (auto& x : editor->translator.selected) { + MaterialComponent* material = get_material(scene, x); + if (material == nullptr) + continue; material->blend_with_terrain_height = args.fValue; } - }); + }); AddWidget(&blendTerrainSlider); @@ -500,14 +676,17 @@ void MaterialWindow::Create(EditorComponent* _editor) materialNameField.SetPos(XMFLOAT2(10, y += step)); materialNameField.SetSize(XMFLOAT2(300, hei)); materialNameField.OnInputAccepted([=](wi::gui::EventArgs args) { - NameComponent* name = editor->GetCurrentScene().names.GetComponent(entity); - if (name != nullptr) + wi::scene::Scene& scene = editor->GetCurrentScene(); + for (auto& x : editor->translator.selected) { + NameComponent* name = scene.names.GetComponent(x.entity); + if (name == nullptr) + continue; *name = args.sValue; editor->componentsWnd.RefreshEntityTree(); } - }); + }); AddWidget(&materialNameField); colorComboBox.Create("Color picker mode: "); @@ -527,9 +706,12 @@ void MaterialWindow::Create(EditorComponent* _editor) colorPicker.SetVisible(true); colorPicker.SetEnabled(true); colorPicker.OnColorChanged([&](wi::gui::EventArgs args) { - MaterialComponent* material = editor->GetCurrentScene().materials.GetComponent(entity); - if (material != nullptr) + wi::scene::Scene& scene = editor->GetCurrentScene(); + for (auto& x : editor->translator.selected) { + MaterialComponent* material = get_material(scene, x); + if (material == nullptr) + continue; switch (colorComboBox.GetSelected()) { default: @@ -556,7 +738,7 @@ void MaterialWindow::Create(EditorComponent* _editor) break; } } - }); + }); AddWidget(&colorPicker); @@ -759,13 +941,16 @@ void MaterialWindow::Create(EditorComponent* _editor) textureSlotUvsetField.SetPos(XMFLOAT2(x + textureSlotLabel.GetScale().x + 2, y)); textureSlotUvsetField.SetSize(XMFLOAT2(hei, hei)); textureSlotUvsetField.OnInputAccepted([this](wi::gui::EventArgs args) { - MaterialComponent* material = editor->GetCurrentScene().materials.GetComponent(entity); - if (material != nullptr) + wi::scene::Scene& scene = editor->GetCurrentScene(); + for (auto& x : editor->translator.selected) { + MaterialComponent* material = get_material(scene, x); + if (material == nullptr) + continue; int slot = textureSlotComboBox.GetSelected(); material->textures[slot].uvset = (uint32_t)args.iValue; } - }); + }); AddWidget(&textureSlotUvsetField); @@ -829,7 +1014,7 @@ void MaterialWindow::SetEntity(Entity entity) texMulSliderX.SetValue(material->texMulAdd.x); texMulSliderY.SetValue(material->texMulAdd.y); alphaRefSlider.SetValue(material->alphaRef); - blendModeComboBox.SetSelected((int)material->userBlendMode); + blendModeComboBox.SetSelectedWithoutCallback((int)material->userBlendMode); shaderTypeComboBox.ClearItems(); shaderTypeComboBox.AddItem("PBR", MaterialComponent::SHADERTYPE_PBR); @@ -849,13 +1034,13 @@ void MaterialWindow::SetEntity(Entity entity) } if (material->GetCustomShaderID() >= 0) { - shaderTypeComboBox.SetSelected(MaterialComponent::SHADERTYPE_COUNT + material->GetCustomShaderID()); + shaderTypeComboBox.SetSelectedWithoutCallback(MaterialComponent::SHADERTYPE_COUNT + material->GetCustomShaderID()); } else { - shaderTypeComboBox.SetSelectedByUserdata(material->shaderType); + shaderTypeComboBox.SetSelectedByUserdataWithoutCallback(material->shaderType); } - shadingRateComboBox.SetSelected((int)material->shadingRate); + shadingRateComboBox.SetSelectedWithoutCallback((int)material->shadingRate); colorComboBox.SetEnabled(true); colorPicker.SetEnabled(true); diff --git a/Editor/MeshWindow.cpp b/Editor/MeshWindow.cpp index ba9ebd8dd..9aff91843 100644 --- a/Editor/MeshWindow.cpp +++ b/Editor/MeshWindow.cpp @@ -7,6 +7,21 @@ using namespace wi::ecs; using namespace wi::scene; +MeshComponent* get_mesh(Scene& scene, PickResult x) +{ + MeshComponent* mesh = scene.meshes.GetComponent(x.entity); + if (mesh == nullptr) + { + // Mesh could be selected indirectly as part of selected object: + ObjectComponent* object = scene.objects.GetComponent(x.entity); + if (object != nullptr && object->meshID != INVALID_ENTITY) + { + mesh = scene.meshes.GetComponent(object->meshID); + } + } + return mesh; +}; + void MeshWindow::Create(EditorComponent* _editor) { editor = _editor; @@ -25,7 +40,7 @@ void MeshWindow::Create(EditorComponent* _editor) editor->RecordEntity(archive, entity); editor->componentsWnd.RefreshEntityTree(); - }); + }); float x = 95; float y = 0; @@ -122,9 +137,12 @@ void MeshWindow::Create(EditorComponent* _editor) doubleSidedCheckBox.SetSize(XMFLOAT2(hei, hei)); doubleSidedCheckBox.SetPos(XMFLOAT2(x, y += step)); doubleSidedCheckBox.OnClick([&](wi::gui::EventArgs args) { - MeshComponent* mesh = editor->GetCurrentScene().meshes.GetComponent(entity); - if (mesh != nullptr) + wi::scene::Scene& scene = editor->GetCurrentScene(); + for (auto& x : editor->translator.selected) { + MeshComponent* mesh = get_mesh(scene, x); + if (mesh == nullptr) + continue; mesh->SetDoubleSided(args.bValue); } }); @@ -135,12 +153,15 @@ void MeshWindow::Create(EditorComponent* _editor) doubleSidedShadowCheckBox.SetSize(XMFLOAT2(hei, hei)); doubleSidedShadowCheckBox.SetPos(XMFLOAT2(x, y += step)); doubleSidedShadowCheckBox.OnClick([&](wi::gui::EventArgs args) { - MeshComponent* mesh = editor->GetCurrentScene().meshes.GetComponent(entity); - if (mesh != nullptr) + wi::scene::Scene& scene = editor->GetCurrentScene(); + for (auto& x : editor->translator.selected) { + MeshComponent* mesh = get_mesh(scene, x); + if (mesh == nullptr) + continue; mesh->SetDoubleSidedShadow(args.bValue); } - }); + }); AddWidget(&doubleSidedShadowCheckBox); bvhCheckBox.Create("Enable BVH: "); @@ -148,9 +169,12 @@ void MeshWindow::Create(EditorComponent* _editor) bvhCheckBox.SetSize(XMFLOAT2(hei, hei)); bvhCheckBox.SetPos(XMFLOAT2(x, y += step)); bvhCheckBox.OnClick([&](wi::gui::EventArgs args) { - MeshComponent* mesh = editor->GetCurrentScene().meshes.GetComponent(entity); - if (mesh != nullptr) + wi::scene::Scene& scene = editor->GetCurrentScene(); + for (auto& x : editor->translator.selected) { + MeshComponent* mesh = get_mesh(scene, x); + if (mesh == nullptr) + continue; mesh->SetBVHEnabled(args.bValue); } }); @@ -161,9 +185,12 @@ void MeshWindow::Create(EditorComponent* _editor) quantizeCheckBox.SetSize(XMFLOAT2(hei, hei)); quantizeCheckBox.SetPos(XMFLOAT2(x, y += step)); quantizeCheckBox.OnClick([&](wi::gui::EventArgs args) { - MeshComponent* mesh = editor->GetCurrentScene().meshes.GetComponent(entity); - if (mesh != nullptr) + wi::scene::Scene& scene = editor->GetCurrentScene(); + for (auto& x : editor->translator.selected) { + MeshComponent* mesh = get_mesh(scene, x); + if (mesh == nullptr) + continue; mesh->SetQuantizedPositionsDisabled(args.bValue); mesh->CreateRenderData(); if (!mesh->BLASes.empty()) @@ -171,7 +198,7 @@ void MeshWindow::Create(EditorComponent* _editor) mesh->CreateRaytracingRenderData(); } } - }); + }); AddWidget(&quantizeCheckBox); impostorCreateButton.Create("Create Impostor"); @@ -212,9 +239,12 @@ void MeshWindow::Create(EditorComponent* _editor) tessellationFactorSlider.SetSize(XMFLOAT2(wid, hei)); tessellationFactorSlider.SetPos(XMFLOAT2(x, y += step)); tessellationFactorSlider.OnSlide([&](wi::gui::EventArgs args) { - MeshComponent* mesh = editor->GetCurrentScene().meshes.GetComponent(entity); - if (mesh != nullptr) + wi::scene::Scene& scene = editor->GetCurrentScene(); + for (auto& x : editor->translator.selected) { + MeshComponent* mesh = get_mesh(scene, x); + if (mesh == nullptr) + continue; mesh->tessellationFactor = args.fValue; } }); @@ -228,12 +258,15 @@ void MeshWindow::Create(EditorComponent* _editor) flipCullingButton.SetSize(XMFLOAT2(mod_wid, hei)); flipCullingButton.SetPos(XMFLOAT2(mod_x, y += step)); flipCullingButton.OnClick([&](wi::gui::EventArgs args) { - MeshComponent* mesh = editor->GetCurrentScene().meshes.GetComponent(entity); - if (mesh != nullptr) + wi::scene::Scene& scene = editor->GetCurrentScene(); + for (auto& x : editor->translator.selected) { + MeshComponent* mesh = get_mesh(scene, x); + if (mesh == nullptr) + continue; mesh->FlipCulling(); - SetEntity(entity, subset); } + SetEntity(entity, subset); }); AddWidget(&flipCullingButton); @@ -242,12 +275,15 @@ void MeshWindow::Create(EditorComponent* _editor) flipNormalsButton.SetSize(XMFLOAT2(mod_wid, hei)); flipNormalsButton.SetPos(XMFLOAT2(mod_x, y += step)); flipNormalsButton.OnClick([&](wi::gui::EventArgs args) { - MeshComponent* mesh = editor->GetCurrentScene().meshes.GetComponent(entity); - if (mesh != nullptr) + wi::scene::Scene& scene = editor->GetCurrentScene(); + for (auto& x : editor->translator.selected) { + MeshComponent* mesh = get_mesh(scene, x); + if (mesh == nullptr) + continue; mesh->FlipNormals(); - SetEntity(entity, subset); } + SetEntity(entity, subset); }); AddWidget(&flipNormalsButton); @@ -256,12 +292,15 @@ void MeshWindow::Create(EditorComponent* _editor) computeNormalsSmoothButton.SetSize(XMFLOAT2(mod_wid, hei)); computeNormalsSmoothButton.SetPos(XMFLOAT2(mod_x, y += step)); computeNormalsSmoothButton.OnClick([&](wi::gui::EventArgs args) { - MeshComponent* mesh = editor->GetCurrentScene().meshes.GetComponent(entity); - if (mesh != nullptr) + wi::scene::Scene& scene = editor->GetCurrentScene(); + for (auto& x : editor->translator.selected) { + MeshComponent* mesh = get_mesh(scene, x); + if (mesh == nullptr) + continue; mesh->ComputeNormals(MeshComponent::COMPUTE_NORMALS_SMOOTH); - SetEntity(entity, subset); } + SetEntity(entity, subset); }); AddWidget(&computeNormalsSmoothButton); @@ -270,12 +309,15 @@ void MeshWindow::Create(EditorComponent* _editor) computeNormalsHardButton.SetSize(XMFLOAT2(mod_wid, hei)); computeNormalsHardButton.SetPos(XMFLOAT2(mod_x, y += step)); computeNormalsHardButton.OnClick([&](wi::gui::EventArgs args) { - MeshComponent* mesh = editor->GetCurrentScene().meshes.GetComponent(entity); - if (mesh != nullptr) + wi::scene::Scene& scene = editor->GetCurrentScene(); + for (auto& x : editor->translator.selected) { + MeshComponent* mesh = get_mesh(scene, x); + if (mesh == nullptr) + continue; mesh->ComputeNormals(MeshComponent::COMPUTE_NORMALS_HARD); - SetEntity(entity, subset); } + SetEntity(entity, subset); }); AddWidget(&computeNormalsHardButton); @@ -284,11 +326,13 @@ void MeshWindow::Create(EditorComponent* _editor) recenterButton.SetSize(XMFLOAT2(mod_wid, hei)); recenterButton.SetPos(XMFLOAT2(mod_x, y += step)); recenterButton.OnClick([&](wi::gui::EventArgs args) { - MeshComponent* mesh = editor->GetCurrentScene().meshes.GetComponent(entity); - if (mesh != nullptr) + wi::scene::Scene& scene = editor->GetCurrentScene(); + for (auto& x : editor->translator.selected) { + MeshComponent* mesh = get_mesh(scene, x); + if (mesh == nullptr) + continue; mesh->Recenter(); - SetEntity(entity, subset); } }); AddWidget(&recenterButton); @@ -298,11 +342,13 @@ void MeshWindow::Create(EditorComponent* _editor) recenterToBottomButton.SetSize(XMFLOAT2(mod_wid, hei)); recenterToBottomButton.SetPos(XMFLOAT2(mod_x, y += step)); recenterToBottomButton.OnClick([&](wi::gui::EventArgs args) { - MeshComponent* mesh = editor->GetCurrentScene().meshes.GetComponent(entity); - if (mesh != nullptr) + wi::scene::Scene& scene = editor->GetCurrentScene(); + for (auto& x : editor->translator.selected) { + MeshComponent* mesh = get_mesh(scene, x); + if (mesh == nullptr) + continue; mesh->RecenterToBottom(); - SetEntity(entity, subset); } }); AddWidget(&recenterToBottomButton); @@ -551,9 +597,12 @@ void MeshWindow::Create(EditorComponent* _editor) optimizeButton.SetSize(XMFLOAT2(mod_wid, hei)); optimizeButton.SetPos(XMFLOAT2(mod_x, y += step)); optimizeButton.OnClick([&](wi::gui::EventArgs args) { - MeshComponent* mesh = editor->GetCurrentScene().meshes.GetComponent(entity); - if (mesh != nullptr) + wi::scene::Scene& scene = editor->GetCurrentScene(); + for (auto& x : editor->translator.selected) { + MeshComponent* mesh = get_mesh(scene, x); + if (mesh == nullptr) + continue; // https://github.com/zeux/meshoptimizer#vertex-cache-optimization size_t index_count = mesh->indices.size(); @@ -565,9 +614,9 @@ void MeshWindow::Create(EditorComponent* _editor) mesh->indices = indices; mesh->CreateRenderData(); - SetEntity(entity, subset); } - }); + SetEntity(entity, subset); + }); AddWidget(&optimizeButton); exportHeaderButton.Create("Export to C++ header"); @@ -706,7 +755,7 @@ void MeshWindow::Create(EditorComponent* _editor) meshsubset.materialID = scene.materials.GetEntity(args.iValue - 1); } } - }); + }); subsetMaterialComboBox.SetTooltip("Set the base material of the selected MeshSubset"); AddWidget(&subsetMaterialComboBox); @@ -729,10 +778,16 @@ void MeshWindow::Create(EditorComponent* _editor) morphTargetSlider.SetSize(XMFLOAT2(wid, hei)); morphTargetSlider.SetPos(XMFLOAT2(x, y += step)); morphTargetSlider.OnSlide([&](wi::gui::EventArgs args) { - MeshComponent* mesh = editor->GetCurrentScene().meshes.GetComponent(entity); - if (mesh != nullptr && morphTargetCombo.GetSelected() < (int)mesh->morph_targets.size()) + wi::scene::Scene& scene = editor->GetCurrentScene(); + for (auto& x : editor->translator.selected) { - mesh->morph_targets[morphTargetCombo.GetSelected()].weight = args.fValue; + MeshComponent* mesh = get_mesh(scene, x); + if (mesh == nullptr) + continue; + if (morphTargetCombo.GetSelected() < (int)mesh->morph_targets.size()) + { + mesh->morph_targets[morphTargetCombo.GetSelected()].weight = args.fValue; + } } }); AddWidget(&morphTargetSlider); @@ -742,9 +797,12 @@ void MeshWindow::Create(EditorComponent* _editor) lodgenButton.SetSize(XMFLOAT2(wid, hei)); lodgenButton.SetPos(XMFLOAT2(x, y += step)); lodgenButton.OnClick([&](wi::gui::EventArgs args) { - MeshComponent* mesh = editor->GetCurrentScene().meshes.GetComponent(entity); - if (mesh != nullptr) + wi::scene::Scene& scene = editor->GetCurrentScene(); + for (auto& x : editor->translator.selected) { + MeshComponent* mesh = get_mesh(scene, x); + if (mesh == nullptr) + continue; if (mesh->subsets_per_lod == 0) { // if there were no lods before, record the subset count without lods: @@ -844,9 +902,9 @@ void MeshWindow::Create(EditorComponent* _editor) mesh->subsets = subsets; mesh->CreateRenderData(); - SetEntity(entity, subset); } - }); + SetEntity(entity, subset); + }); AddWidget(&lodgenButton); lodCountSlider.Create(2, 10, 6, 8, "LOD Count: "); diff --git a/Editor/NameWindow.cpp b/Editor/NameWindow.cpp index 88acc8fa6..5d78b0b58 100644 --- a/Editor/NameWindow.cpp +++ b/Editor/NameWindow.cpp @@ -35,13 +35,16 @@ void NameWindow::Create(EditorComponent* _editor) nameInput.SetPos(XMFLOAT2(x, y)); nameInput.SetSize(XMFLOAT2(siz, hei)); nameInput.OnInputAccepted([=](wi::gui::EventArgs args) { - NameComponent* name = editor->GetCurrentScene().names.GetComponent(entity); - if (name == nullptr) + wi::scene::Scene& scene = editor->GetCurrentScene(); + for (auto& x : editor->translator.selected) { - name = &editor->GetCurrentScene().names.Create(entity); + NameComponent* name = scene.names.GetComponent(x.entity); + if (name == nullptr) + { + name = &editor->GetCurrentScene().names.Create(x.entity); + } + name->name = args.sValue; } - name->name = args.sValue; - editor->componentsWnd.RefreshEntityTree(); }); AddWidget(&nameInput); diff --git a/Editor/ScriptWindow.cpp b/Editor/ScriptWindow.cpp index 6e739cbe8..035687a55 100644 --- a/Editor/ScriptWindow.cpp +++ b/Editor/ScriptWindow.cpp @@ -1,6 +1,8 @@ #include "stdafx.h" #include "ScriptWindow.h" +using namespace wi::scene; + void ScriptWindow::Create(EditorComponent* _editor) { editor = _editor; @@ -61,11 +63,13 @@ void ScriptWindow::Create(EditorComponent* _editor) playonceCheckBox.SetSize(XMFLOAT2(hei, hei)); playonceCheckBox.OnClick([=](wi::gui::EventArgs args) { wi::scene::Scene& scene = editor->GetCurrentScene(); - wi::scene::ScriptComponent* script = scene.scripts.GetComponent(entity); - if (script == nullptr) - return; - - script->SetPlayOnce(args.bValue); + for (auto& x : editor->translator.selected) + { + ScriptComponent* script = scene.scripts.GetComponent(x.entity); + if (script == nullptr) + continue; + script->SetPlayOnce(args.bValue); + } }); AddWidget(&playonceCheckBox); @@ -74,17 +78,19 @@ void ScriptWindow::Create(EditorComponent* _editor) playstopButton.SetSize(XMFLOAT2(wid, hei)); playstopButton.OnClick([=](wi::gui::EventArgs args) { wi::scene::Scene& scene = editor->GetCurrentScene(); - wi::scene::ScriptComponent* script = scene.scripts.GetComponent(entity); - if (script == nullptr) - return; - - if (script->IsPlaying()) + for (auto& x : editor->translator.selected) { - script->Stop(); - } - else - { - script->Play(); + ScriptComponent* script = scene.scripts.GetComponent(x.entity); + if (script == nullptr) + continue; + if (script->IsPlaying()) + { + script->Stop(); + } + else + { + script->Play(); + } } }); AddWidget(&playstopButton); diff --git a/Editor/SoundWindow.cpp b/Editor/SoundWindow.cpp index 6c7f33c49..270d325e9 100644 --- a/Editor/SoundWindow.cpp +++ b/Editor/SoundWindow.cpp @@ -49,7 +49,7 @@ void SoundWindow::Create(EditorComponent* _editor) editor->RecordEntity(archive, entity); editor->componentsWnd.RefreshEntityTree(); - }); + }); float x = 60; float y = 0; @@ -79,7 +79,7 @@ void SoundWindow::Create(EditorComponent* _editor) }); }); } - }); + }); AddWidget(&openButton); filenameLabel.Create("Filename"); @@ -92,9 +92,12 @@ void SoundWindow::Create(EditorComponent* _editor) playstopButton.SetPos(XMFLOAT2(x, y += step)); playstopButton.SetSize(XMFLOAT2(wid, hei)); playstopButton.OnClick([&](wi::gui::EventArgs args) { - SoundComponent* sound = editor->GetCurrentScene().sounds.GetComponent(entity); - if (sound != nullptr) + wi::scene::Scene& scene = editor->GetCurrentScene(); + for (auto& x : editor->translator.selected) { + SoundComponent* sound = scene.sounds.GetComponent(x.entity); + if (sound == nullptr) + continue; if (sound->IsPlaying()) { sound->Stop(); @@ -106,7 +109,7 @@ void SoundWindow::Create(EditorComponent* _editor) playstopButton.SetText(ICON_STOP); } } - }); + }); AddWidget(&playstopButton); playstopButton.SetEnabled(false); @@ -116,12 +119,15 @@ void SoundWindow::Create(EditorComponent* _editor) loopedCheckbox.SetSize(XMFLOAT2(hei, hei)); loopedCheckbox.SetCheckText(ICON_LOOP); loopedCheckbox.OnClick([&](wi::gui::EventArgs args) { - SoundComponent* sound = editor->GetCurrentScene().sounds.GetComponent(entity); - if (sound != nullptr) + wi::scene::Scene& scene = editor->GetCurrentScene(); + for (auto& x : editor->translator.selected) { + SoundComponent* sound = scene.sounds.GetComponent(x.entity); + if (sound == nullptr) + continue; sound->SetLooped(args.bValue); } - }); + }); AddWidget(&loopedCheckbox); loopedCheckbox.SetEnabled(false); @@ -130,13 +136,16 @@ void SoundWindow::Create(EditorComponent* _editor) reverbCheckbox.SetPos(XMFLOAT2(x, y += step)); reverbCheckbox.SetSize(XMFLOAT2(hei, hei)); reverbCheckbox.OnClick([&](wi::gui::EventArgs args) { - SoundComponent* sound = editor->GetCurrentScene().sounds.GetComponent(entity); - if (sound != nullptr) + wi::scene::Scene& scene = editor->GetCurrentScene(); + for (auto& x : editor->translator.selected) { + SoundComponent* sound = scene.sounds.GetComponent(x.entity); + if (sound == nullptr) + continue; sound->soundinstance.SetEnableReverb(args.bValue); wi::audio::CreateSoundInstance(&sound->soundResource.GetSound(), &sound->soundinstance); } - }); + }); AddWidget(&reverbCheckbox); reverbCheckbox.SetEnabled(false); @@ -145,12 +154,15 @@ void SoundWindow::Create(EditorComponent* _editor) disable3dCheckbox.SetPos(XMFLOAT2(x, y += step)); disable3dCheckbox.SetSize(XMFLOAT2(hei, hei)); disable3dCheckbox.OnClick([&](wi::gui::EventArgs args) { - SoundComponent* sound = editor->GetCurrentScene().sounds.GetComponent(entity); - if (sound != nullptr) + wi::scene::Scene& scene = editor->GetCurrentScene(); + for (auto& x : editor->translator.selected) { + SoundComponent* sound = scene.sounds.GetComponent(x.entity); + if (sound == nullptr) + continue; sound->SetDisable3D(args.bValue); } - }); + }); AddWidget(&disable3dCheckbox); loopedCheckbox.SetEnabled(false); @@ -159,12 +171,15 @@ void SoundWindow::Create(EditorComponent* _editor) volumeSlider.SetPos(XMFLOAT2(x, y += step)); volumeSlider.SetSize(XMFLOAT2(wid, hei)); volumeSlider.OnSlide([&](wi::gui::EventArgs args) { - SoundComponent* sound = editor->GetCurrentScene().sounds.GetComponent(entity); - if (sound != nullptr) + wi::scene::Scene& scene = editor->GetCurrentScene(); + for (auto& x : editor->translator.selected) { + SoundComponent* sound = scene.sounds.GetComponent(x.entity); + if (sound == nullptr) + continue; sound->volume = args.fValue; } - }); + }); AddWidget(&volumeSlider); volumeSlider.SetEnabled(false); @@ -172,13 +187,16 @@ void SoundWindow::Create(EditorComponent* _editor) submixComboBox.SetPos(XMFLOAT2(x, y += step)); submixComboBox.SetSize(XMFLOAT2(wid, hei)); submixComboBox.OnSelect([&](wi::gui::EventArgs args) { - SoundComponent* sound = editor->GetCurrentScene().sounds.GetComponent(entity); - if (sound != nullptr) + wi::scene::Scene& scene = editor->GetCurrentScene(); + for (auto& x : editor->translator.selected) { + SoundComponent* sound = scene.sounds.GetComponent(x.entity); + if (sound == nullptr) + continue; sound->soundinstance.type = (wi::audio::SUBMIX_TYPE)args.iValue; wi::audio::CreateSoundInstance(&sound->soundResource.GetSound(), &sound->soundinstance); } - }); + }); submixComboBox.AddItem("SOUNDEFFECT"); submixComboBox.AddItem("MUSIC"); submixComboBox.AddItem("USER0"); @@ -192,7 +210,7 @@ void SoundWindow::Create(EditorComponent* _editor) reverbComboBox.SetSize(XMFLOAT2(wid, hei)); reverbComboBox.OnSelect([&](wi::gui::EventArgs args) { wi::audio::SetReverb((wi::audio::REVERB_PRESET)args.iValue); - }); + }); reverbComboBox.AddItem("DEFAULT"); reverbComboBox.AddItem("GENERIC"); reverbComboBox.AddItem("FOREST"); @@ -235,13 +253,16 @@ void SoundWindow::Create(EditorComponent* _editor) beginInput.SetTooltip("Beginning of the playback in seconds, relative to the Sound it will be created from (0 = from beginning)."); beginInput.SetSize(XMFLOAT2(wid, hei)); beginInput.OnInputAccepted([&](wi::gui::EventArgs args) { - SoundComponent* sound = editor->GetCurrentScene().sounds.GetComponent(entity); - if (sound != nullptr) + wi::scene::Scene& scene = editor->GetCurrentScene(); + for (auto& x : editor->translator.selected) { + SoundComponent* sound = scene.sounds.GetComponent(x.entity); + if (sound == nullptr) + continue; sound->soundinstance.begin = args.fValue; wi::audio::CreateSoundInstance(&sound->soundResource.GetSound(), &sound->soundinstance); } - }); + }); AddWidget(&beginInput); lengthInput.Create(""); @@ -249,13 +270,16 @@ void SoundWindow::Create(EditorComponent* _editor) lengthInput.SetTooltip("Length in seconds (0 = until end)"); lengthInput.SetSize(XMFLOAT2(wid, hei)); lengthInput.OnInputAccepted([&](wi::gui::EventArgs args) { - SoundComponent* sound = editor->GetCurrentScene().sounds.GetComponent(entity); - if (sound != nullptr) + wi::scene::Scene& scene = editor->GetCurrentScene(); + for (auto& x : editor->translator.selected) { + SoundComponent* sound = scene.sounds.GetComponent(x.entity); + if (sound == nullptr) + continue; sound->soundinstance.length = args.fValue; wi::audio::CreateSoundInstance(&sound->soundResource.GetSound(), &sound->soundinstance); } - }); + }); AddWidget(&lengthInput); loopBeginInput.Create(""); @@ -263,13 +287,16 @@ void SoundWindow::Create(EditorComponent* _editor) loopBeginInput.SetTooltip("Loop region begin in seconds, relative to the instance begin time (0 = from beginning)"); loopBeginInput.SetSize(XMFLOAT2(wid, hei)); loopBeginInput.OnInputAccepted([&](wi::gui::EventArgs args) { - SoundComponent* sound = editor->GetCurrentScene().sounds.GetComponent(entity); - if (sound != nullptr) + wi::scene::Scene& scene = editor->GetCurrentScene(); + for (auto& x : editor->translator.selected) { + SoundComponent* sound = scene.sounds.GetComponent(x.entity); + if (sound == nullptr) + continue; sound->soundinstance.loop_begin = args.fValue; wi::audio::CreateSoundInstance(&sound->soundResource.GetSound(), &sound->soundinstance); } - }); + }); AddWidget(&loopBeginInput); loopLengthInput.Create(""); @@ -277,13 +304,16 @@ void SoundWindow::Create(EditorComponent* _editor) loopLengthInput.SetTooltip("Loop region length in seconds (0 = until the end)"); loopLengthInput.SetSize(XMFLOAT2(wid, hei)); loopLengthInput.OnInputAccepted([&](wi::gui::EventArgs args) { - SoundComponent* sound = editor->GetCurrentScene().sounds.GetComponent(entity); - if (sound != nullptr) + wi::scene::Scene& scene = editor->GetCurrentScene(); + for (auto& x : editor->translator.selected) { + SoundComponent* sound = scene.sounds.GetComponent(x.entity); + if (sound == nullptr) + continue; sound->soundinstance.loop_length = args.fValue; wi::audio::CreateSoundInstance(&sound->soundResource.GetSound(), &sound->soundinstance); } - }); + }); AddWidget(&loopLengthInput); SetMinimized(true); diff --git a/Editor/SpringWindow.cpp b/Editor/SpringWindow.cpp index 5a06759ec..810fa26f2 100644 --- a/Editor/SpringWindow.cpp +++ b/Editor/SpringWindow.cpp @@ -48,10 +48,15 @@ void SpringWindow::Create(EditorComponent* _editor) disabledCheckBox.SetPos(XMFLOAT2(x, y += step)); disabledCheckBox.SetSize(XMFLOAT2(hei, hei)); disabledCheckBox.OnClick([=](wi::gui::EventArgs args) { - if (!editor->GetCurrentScene().springs.Contains(entity)) - return; - editor->GetCurrentScene().springs.GetComponent(entity)->SetDisabled(args.bValue); - }); + wi::scene::Scene& scene = editor->GetCurrentScene(); + for (auto& x : editor->translator.selected) + { + SpringComponent* spring = scene.springs.GetComponent(x.entity); + if (spring == nullptr) + continue; + spring->SetDisabled(args.bValue); + } + }); AddWidget(&disabledCheckBox); gravityCheckBox.Create("Gravity enabled: "); @@ -59,10 +64,15 @@ void SpringWindow::Create(EditorComponent* _editor) gravityCheckBox.SetPos(XMFLOAT2(x, y += step)); gravityCheckBox.SetSize(XMFLOAT2(hei, hei)); gravityCheckBox.OnClick([=](wi::gui::EventArgs args) { - if (!editor->GetCurrentScene().springs.Contains(entity)) - return; - editor->GetCurrentScene().springs.GetComponent(entity)->SetGravityEnabled(args.bValue); - }); + wi::scene::Scene& scene = editor->GetCurrentScene(); + for (auto& x : editor->translator.selected) + { + SpringComponent* spring = scene.springs.GetComponent(x.entity); + if (spring == nullptr) + continue; + spring->SetGravityEnabled(args.bValue); + } + }); AddWidget(&gravityCheckBox); stiffnessSlider.Create(0, 1, 0.1f, 100000, "Stiffness: "); @@ -70,10 +80,15 @@ void SpringWindow::Create(EditorComponent* _editor) stiffnessSlider.SetPos(XMFLOAT2(x, y += step)); stiffnessSlider.SetSize(XMFLOAT2(siz, hei)); stiffnessSlider.OnSlide([&](wi::gui::EventArgs args) { - if (!editor->GetCurrentScene().springs.Contains(entity)) - return; - editor->GetCurrentScene().springs.GetComponent(entity)->stiffnessForce = args.fValue; - }); + wi::scene::Scene& scene = editor->GetCurrentScene(); + for (auto& x : editor->translator.selected) + { + SpringComponent* spring = scene.springs.GetComponent(x.entity); + if (spring == nullptr) + continue; + spring->stiffnessForce = args.fValue; + } + }); AddWidget(&stiffnessSlider); dragSlider.Create(0, 1, 0.8f, 100000, "Drag: "); @@ -81,10 +96,15 @@ void SpringWindow::Create(EditorComponent* _editor) dragSlider.SetPos(XMFLOAT2(x, y += step)); dragSlider.SetSize(XMFLOAT2(siz, hei)); dragSlider.OnSlide([&](wi::gui::EventArgs args) { - if (!editor->GetCurrentScene().springs.Contains(entity)) - return; - editor->GetCurrentScene().springs.GetComponent(entity)->dragForce = args.fValue; - }); + wi::scene::Scene& scene = editor->GetCurrentScene(); + for (auto& x : editor->translator.selected) + { + SpringComponent* spring = scene.springs.GetComponent(x.entity); + if (spring == nullptr) + continue; + spring->dragForce = args.fValue; + } + }); AddWidget(&dragSlider); windSlider.Create(0, 1, 0, 100000, "Wind affection: "); @@ -92,10 +112,15 @@ void SpringWindow::Create(EditorComponent* _editor) windSlider.SetPos(XMFLOAT2(x, y += step)); windSlider.SetSize(XMFLOAT2(siz, hei)); windSlider.OnSlide([&](wi::gui::EventArgs args) { - if (!editor->GetCurrentScene().springs.Contains(entity)) - return; - editor->GetCurrentScene().springs.GetComponent(entity)->windForce = args.fValue; - }); + wi::scene::Scene& scene = editor->GetCurrentScene(); + for (auto& x : editor->translator.selected) + { + SpringComponent* spring = scene.springs.GetComponent(x.entity); + if (spring == nullptr) + continue; + spring->windForce = args.fValue; + } + }); AddWidget(&windSlider); gravitySlider.Create(0, 1, 0, 100000, "Gravity affection: "); @@ -103,10 +128,15 @@ void SpringWindow::Create(EditorComponent* _editor) gravitySlider.SetPos(XMFLOAT2(x, y += step)); gravitySlider.SetSize(XMFLOAT2(siz, hei)); gravitySlider.OnSlide([&](wi::gui::EventArgs args) { - if (!editor->GetCurrentScene().springs.Contains(entity)) - return; - editor->GetCurrentScene().springs.GetComponent(entity)->gravityPower = args.fValue; - }); + wi::scene::Scene& scene = editor->GetCurrentScene(); + for (auto& x : editor->translator.selected) + { + SpringComponent* spring = scene.springs.GetComponent(x.entity); + if (spring == nullptr) + continue; + spring->gravityPower = args.fValue; + } + }); AddWidget(&gravitySlider); hitradiusSlider.Create(0, 1, 0, 100000, "Collision hit radius: "); @@ -114,10 +144,15 @@ void SpringWindow::Create(EditorComponent* _editor) hitradiusSlider.SetPos(XMFLOAT2(x, y += step)); hitradiusSlider.SetSize(XMFLOAT2(siz, hei)); hitradiusSlider.OnSlide([&](wi::gui::EventArgs args) { - if (!editor->GetCurrentScene().springs.Contains(entity)) - return; - editor->GetCurrentScene().springs.GetComponent(entity)->hitRadius = args.fValue; - }); + wi::scene::Scene& scene = editor->GetCurrentScene(); + for (auto& x : editor->translator.selected) + { + SpringComponent* spring = scene.springs.GetComponent(x.entity); + if (spring == nullptr) + continue; + spring->hitRadius = args.fValue; + } + }); AddWidget(&hitradiusSlider); diff --git a/Editor/SpriteWindow.cpp b/Editor/SpriteWindow.cpp index 4313f203c..92d8a70aa 100644 --- a/Editor/SpriteWindow.cpp +++ b/Editor/SpriteWindow.cpp @@ -33,43 +33,47 @@ void SpriteWindow::Create(EditorComponent* _editor) textureButton.sprites[wi::gui::ACTIVE].params.color = wi::Color::White(); textureButton.sprites[wi::gui::DEACTIVATING].params.color = wi::Color::Gray(); textureButton.OnClick([this](wi::gui::EventArgs args) { - wi::Sprite* sprite = editor->GetCurrentScene().sprites.GetComponent(entity); - if (sprite == nullptr) - return; - - if (sprite->textureResource.IsValid()) + wi::scene::Scene& scene = editor->GetCurrentScene(); + for (auto& x : editor->translator.selected) { - wi::Archive& archive = editor->AdvanceHistory(); - archive << EditorComponent::HISTORYOP_COMPONENT_DATA; - editor->RecordEntity(archive, entity); + wi::Sprite* sprite = scene.sprites.GetComponent(x.entity); + if (sprite == nullptr) + continue; - sprite->textureResource = {}; - sprite->textureName = ""; - sprite->params.siz = XMFLOAT2(1, 1); - sprite->params.image_subresource = -1; + if (sprite->textureResource.IsValid()) + { + wi::Archive& archive = editor->AdvanceHistory(); + archive << EditorComponent::HISTORYOP_COMPONENT_DATA; + editor->RecordEntity(archive, entity); - editor->RecordEntity(archive, entity); - } - else - { - wi::helper::FileDialogParams params; - params.type = wi::helper::FileDialogParams::OPEN; - params.description = "Texture"; - params.extensions = wi::resourcemanager::GetSupportedImageExtensions(); - wi::helper::FileDialog(params, [=](std::string fileName) { - sprite->textureResource = wi::resourcemanager::Load(fileName); - sprite->textureName = fileName; - textureButton.SetImage(sprite->textureResource); - if (sprite->textureResource.IsValid()) - { - const TextureDesc& desc = sprite->textureResource.GetTexture().GetDesc(); - sprite->params.siz = XMFLOAT2(1, float(desc.height) / float(desc.width)); - } - else - { - sprite->params.siz = XMFLOAT2(1, 1); - } - }); + sprite->textureResource = {}; + sprite->textureName = ""; + sprite->params.siz = XMFLOAT2(1, 1); + sprite->params.image_subresource = -1; + + editor->RecordEntity(archive, entity); + } + else + { + wi::helper::FileDialogParams params; + params.type = wi::helper::FileDialogParams::OPEN; + params.description = "Texture"; + params.extensions = wi::resourcemanager::GetSupportedImageExtensions(); + wi::helper::FileDialog(params, [=](std::string fileName) { + sprite->textureResource = wi::resourcemanager::Load(fileName); + sprite->textureName = fileName; + textureButton.SetImage(sprite->textureResource); + if (sprite->textureResource.IsValid()) + { + const TextureDesc& desc = sprite->textureResource.GetTexture().GetDesc(); + sprite->params.siz = XMFLOAT2(1, float(desc.height) / float(desc.width)); + } + else + { + sprite->params.siz = XMFLOAT2(1, 1); + } + }); + } } }); AddWidget(&textureButton); @@ -81,144 +85,192 @@ void SpriteWindow::Create(EditorComponent* _editor) maskButton.sprites[wi::gui::ACTIVE].params.color = wi::Color::White(); maskButton.sprites[wi::gui::DEACTIVATING].params.color = wi::Color::Gray(); maskButton.OnClick([this](wi::gui::EventArgs args) { - wi::Sprite* sprite = editor->GetCurrentScene().sprites.GetComponent(entity); - if (sprite == nullptr) - return; - - if (sprite->maskResource.IsValid()) + wi::scene::Scene& scene = editor->GetCurrentScene(); + for (auto& x : editor->translator.selected) { - wi::Archive& archive = editor->AdvanceHistory(); - archive << EditorComponent::HISTORYOP_COMPONENT_DATA; - editor->RecordEntity(archive, entity); + wi::Sprite* sprite = scene.sprites.GetComponent(x.entity); + if (sprite == nullptr) + continue; - sprite->maskResource = {}; - sprite->maskName = ""; + if (sprite->maskResource.IsValid()) + { + wi::Archive& archive = editor->AdvanceHistory(); + archive << EditorComponent::HISTORYOP_COMPONENT_DATA; + editor->RecordEntity(archive, entity); - editor->RecordEntity(archive, entity); + sprite->maskResource = {}; + sprite->maskName = ""; + + editor->RecordEntity(archive, entity); + } + else + { + wi::helper::FileDialogParams params; + params.type = wi::helper::FileDialogParams::OPEN; + params.description = "Texture"; + params.extensions = wi::resourcemanager::GetSupportedImageExtensions(); + wi::helper::FileDialog(params, [=](std::string fileName) { + sprite->maskResource = wi::resourcemanager::Load(fileName); + sprite->maskName = fileName; + maskButton.SetImage(sprite->maskResource); + }); + } } - else - { - wi::helper::FileDialogParams params; - params.type = wi::helper::FileDialogParams::OPEN; - params.description = "Texture"; - params.extensions = wi::resourcemanager::GetSupportedImageExtensions(); - wi::helper::FileDialog(params, [=](std::string fileName) { - sprite->maskResource = wi::resourcemanager::Load(fileName); - sprite->maskName = fileName; - maskButton.SetImage(sprite->maskResource); - }); - } - }); + }); AddWidget(&maskButton); pivotXSlider.Create(0, 1, 0, 10000, "Pivot X: "); pivotXSlider.SetTooltip("Horizontal pivot: 0: left, 0.5: center, 1: right"); pivotXSlider.OnSlide([=](wi::gui::EventArgs args) { - wi::Sprite* sprite = editor->GetCurrentScene().sprites.GetComponent(entity); - if (sprite == nullptr) - return; - sprite->params.pivot.x = args.fValue; - }); + wi::scene::Scene& scene = editor->GetCurrentScene(); + for (auto& x : editor->translator.selected) + { + wi::Sprite* sprite = scene.sprites.GetComponent(x.entity); + if (sprite == nullptr) + continue; + sprite->params.pivot.x = args.fValue; + } + }); AddWidget(&pivotXSlider); pivotYSlider.Create(0, 1, 0, 10000, "Pivot Y: "); pivotYSlider.SetTooltip("Vertical pivot: 0: top, 0.5: center, 1: bottom"); pivotYSlider.OnSlide([=](wi::gui::EventArgs args) { - wi::Sprite* sprite = editor->GetCurrentScene().sprites.GetComponent(entity); - if (sprite == nullptr) - return; - sprite->params.pivot.y = args.fValue; - }); + wi::scene::Scene& scene = editor->GetCurrentScene(); + for (auto& x : editor->translator.selected) + { + wi::Sprite* sprite = scene.sprites.GetComponent(x.entity); + if (sprite == nullptr) + continue; + sprite->params.pivot.y = args.fValue; + } + }); AddWidget(&pivotYSlider); intensitySlider.Create(0, 100, 1, 10000, "Intensity: "); intensitySlider.SetTooltip("Color multiplier"); intensitySlider.OnSlide([=](wi::gui::EventArgs args) { - wi::Sprite* sprite = editor->GetCurrentScene().sprites.GetComponent(entity); - if (sprite == nullptr) - return; - sprite->params.intensity = args.fValue; - }); + wi::scene::Scene& scene = editor->GetCurrentScene(); + for (auto& x : editor->translator.selected) + { + wi::Sprite* sprite = scene.sprites.GetComponent(x.entity); + if (sprite == nullptr) + continue; + sprite->params.intensity = args.fValue; + } + }); AddWidget(&intensitySlider); rotationSlider.Create(0, 360, 0, 10000, "Rotation: "); rotationSlider.SetTooltip("Z Rotation around pivot point. The editor input is in degrees."); rotationSlider.OnSlide([=](wi::gui::EventArgs args) { - wi::Sprite* sprite = editor->GetCurrentScene().sprites.GetComponent(entity); - if (sprite == nullptr) - return; - sprite->params.rotation = wi::math::DegreesToRadians(args.fValue); - }); + wi::scene::Scene& scene = editor->GetCurrentScene(); + for (auto& x : editor->translator.selected) + { + wi::Sprite* sprite = scene.sprites.GetComponent(x.entity); + if (sprite == nullptr) + continue; + sprite->params.rotation = wi::math::DegreesToRadians(args.fValue); + } + }); AddWidget(&rotationSlider); alphaStartSlider.Create(0, 1, 0, 10000, "Mask Alpha Start: "); alphaStartSlider.SetTooltip("Constrain mask alpha to not go below this level."); alphaStartSlider.OnSlide([=](wi::gui::EventArgs args) { - wi::Sprite* sprite = editor->GetCurrentScene().sprites.GetComponent(entity); - if (sprite == nullptr) - return; - sprite->params.mask_alpha_range_start = args.fValue; - }); + wi::scene::Scene& scene = editor->GetCurrentScene(); + for (auto& x : editor->translator.selected) + { + wi::Sprite* sprite = scene.sprites.GetComponent(x.entity); + if (sprite == nullptr) + continue; + sprite->params.mask_alpha_range_start = args.fValue; + } + }); AddWidget(&alphaStartSlider); alphaEndSlider.Create(0, 1, 1, 10000, "Mask Alpha End: "); alphaEndSlider.SetTooltip("Constrain mask alpha to not go above this level."); alphaEndSlider.OnSlide([=](wi::gui::EventArgs args) { - wi::Sprite* sprite = editor->GetCurrentScene().sprites.GetComponent(entity); - if (sprite == nullptr) - return; - sprite->params.mask_alpha_range_end = args.fValue; - }); + wi::scene::Scene& scene = editor->GetCurrentScene(); + for (auto& x : editor->translator.selected) + { + wi::Sprite* sprite = scene.sprites.GetComponent(x.entity); + if (sprite == nullptr) + continue; + sprite->params.mask_alpha_range_end = args.fValue; + } + }); AddWidget(&alphaEndSlider); borderSoftenSlider.Create(0, 1, 0, 10000, "Border Soften: "); borderSoftenSlider.SetTooltip("Soften the borders of the sprite."); borderSoftenSlider.OnSlide([=](wi::gui::EventArgs args) { - wi::Sprite* sprite = editor->GetCurrentScene().sprites.GetComponent(entity); - if (sprite == nullptr) - return; - sprite->params.border_soften = args.fValue; - }); + wi::scene::Scene& scene = editor->GetCurrentScene(); + for (auto& x : editor->translator.selected) + { + wi::Sprite* sprite = scene.sprites.GetComponent(x.entity); + if (sprite == nullptr) + continue; + sprite->params.border_soften = args.fValue; + } + }); AddWidget(&borderSoftenSlider); cornerRounding0Slider.Create(0, 0.5f, 1, 10000, "Rounding 0: "); cornerRounding0Slider.SetTooltip("Enable corner rounding for the lop left corner."); cornerRounding0Slider.OnSlide([=](wi::gui::EventArgs args) { - wi::Sprite* sprite = editor->GetCurrentScene().sprites.GetComponent(entity); - if (sprite == nullptr) - return; - sprite->params.corners_rounding[0].radius = args.fValue; - }); + wi::scene::Scene& scene = editor->GetCurrentScene(); + for (auto& x : editor->translator.selected) + { + wi::Sprite* sprite = scene.sprites.GetComponent(x.entity); + if (sprite == nullptr) + continue; + sprite->params.corners_rounding[0].radius = args.fValue; + } + }); AddWidget(&cornerRounding0Slider); cornerRounding1Slider.Create(0, 0.5f, 0, 10000, "Rounding 1: "); cornerRounding1Slider.SetTooltip("Enable corner rounding for the lop right corner."); cornerRounding1Slider.OnSlide([=](wi::gui::EventArgs args) { - wi::Sprite* sprite = editor->GetCurrentScene().sprites.GetComponent(entity); - if (sprite == nullptr) - return; - sprite->params.corners_rounding[1].radius = args.fValue; - }); + wi::scene::Scene& scene = editor->GetCurrentScene(); + for (auto& x : editor->translator.selected) + { + wi::Sprite* sprite = scene.sprites.GetComponent(x.entity); + if (sprite == nullptr) + continue; + sprite->params.corners_rounding[1].radius = args.fValue; + } + }); AddWidget(&cornerRounding1Slider); cornerRounding2Slider.Create(0, 0.5f, 0, 10000, "Rounding 2: "); cornerRounding2Slider.SetTooltip("Enable corner rounding for the bottom left corner."); cornerRounding2Slider.OnSlide([=](wi::gui::EventArgs args) { - wi::Sprite* sprite = editor->GetCurrentScene().sprites.GetComponent(entity); - if (sprite == nullptr) - return; - sprite->params.corners_rounding[2].radius = args.fValue; - }); + wi::scene::Scene& scene = editor->GetCurrentScene(); + for (auto& x : editor->translator.selected) + { + wi::Sprite* sprite = scene.sprites.GetComponent(x.entity); + if (sprite == nullptr) + continue; + sprite->params.corners_rounding[2].radius = args.fValue; + } + }); AddWidget(&cornerRounding2Slider); cornerRounding3Slider.Create(0, 0.5f, 0, 10000, "Rounding 3: "); cornerRounding3Slider.SetTooltip("Enable corner rounding for the bottom right corner."); cornerRounding3Slider.OnSlide([=](wi::gui::EventArgs args) { - wi::Sprite* sprite = editor->GetCurrentScene().sprites.GetComponent(entity); - if (sprite == nullptr) - return; - sprite->params.corners_rounding[3].radius = args.fValue; - }); + wi::scene::Scene& scene = editor->GetCurrentScene(); + for (auto& x : editor->translator.selected) + { + wi::Sprite* sprite = scene.sprites.GetComponent(x.entity); + if (sprite == nullptr) + continue; + sprite->params.corners_rounding[3].radius = args.fValue; + } + }); AddWidget(&cornerRounding3Slider); qualityCombo.Create("Filtering: "); @@ -226,11 +278,15 @@ void SpriteWindow::Create(EditorComponent* _editor) qualityCombo.AddItem("Linear", wi::image::QUALITY_LINEAR); qualityCombo.AddItem("Anisotropic", wi::image::QUALITY_ANISOTROPIC); qualityCombo.OnSelect([=](wi::gui::EventArgs args) { - wi::Sprite* sprite = editor->GetCurrentScene().sprites.GetComponent(entity); - if (sprite == nullptr) - return; - sprite->params.quality = (wi::image::QUALITY)args.userdata; - }); + wi::scene::Scene& scene = editor->GetCurrentScene(); + for (auto& x : editor->translator.selected) + { + wi::Sprite* sprite = scene.sprites.GetComponent(x.entity); + if (sprite == nullptr) + continue; + sprite->params.quality = (wi::image::QUALITY)args.userdata; + } + }); AddWidget(&qualityCombo); samplemodeCombo.Create("Sampling: "); @@ -238,11 +294,15 @@ void SpriteWindow::Create(EditorComponent* _editor) samplemodeCombo.AddItem("Mirror", wi::image::SAMPLEMODE_MIRROR); samplemodeCombo.AddItem("Wrap", wi::image::SAMPLEMODE_WRAP); samplemodeCombo.OnSelect([=](wi::gui::EventArgs args) { - wi::Sprite* sprite = editor->GetCurrentScene().sprites.GetComponent(entity); - if (sprite == nullptr) - return; - sprite->params.sampleFlag = (wi::image::SAMPLEMODE)args.userdata; - }); + wi::scene::Scene& scene = editor->GetCurrentScene(); + for (auto& x : editor->translator.selected) + { + wi::Sprite* sprite = scene.sprites.GetComponent(x.entity); + if (sprite == nullptr) + continue; + sprite->params.sampleFlag = (wi::image::SAMPLEMODE)args.userdata; + } + }); AddWidget(&samplemodeCombo); blendModeCombo.Create("Blending: "); @@ -252,169 +312,229 @@ void SpriteWindow::Create(EditorComponent* _editor) blendModeCombo.AddItem("Additive", wi::enums::BLENDMODE_ADDITIVE); blendModeCombo.AddItem("Multiply", wi::enums::BLENDMODE_MULTIPLY); blendModeCombo.OnSelect([=](wi::gui::EventArgs args) { - wi::Sprite* sprite = editor->GetCurrentScene().sprites.GetComponent(entity); - if (sprite == nullptr) - return; - sprite->params.blendFlag = (wi::enums::BLENDMODE)args.userdata; - }); + wi::scene::Scene& scene = editor->GetCurrentScene(); + for (auto& x : editor->translator.selected) + { + wi::Sprite* sprite = scene.sprites.GetComponent(x.entity); + if (sprite == nullptr) + continue; + sprite->params.blendFlag = (wi::enums::BLENDMODE)args.userdata; + } + }); AddWidget(&blendModeCombo); hiddenCheckBox.Create("Hidden: "); hiddenCheckBox.SetTooltip("Hide / unhide the sprite"); hiddenCheckBox.OnClick([=](wi::gui::EventArgs args) { - wi::Sprite* sprite = editor->GetCurrentScene().sprites.GetComponent(entity); - if (sprite == nullptr) - return; - sprite->SetHidden(args.bValue); - }); + wi::scene::Scene& scene = editor->GetCurrentScene(); + for (auto& x : editor->translator.selected) + { + wi::Sprite* sprite = scene.sprites.GetComponent(x.entity); + if (sprite == nullptr) + continue; + sprite->SetHidden(args.bValue); + } + }); AddWidget(&hiddenCheckBox); cameraFacingCheckBox.Create("Camera Facing: "); cameraFacingCheckBox.SetTooltip("Camera facing sprites will always rotate towards the camera."); cameraFacingCheckBox.OnClick([=](wi::gui::EventArgs args) { - wi::Sprite* sprite = editor->GetCurrentScene().sprites.GetComponent(entity); - if (sprite == nullptr) - return; - sprite->SetCameraFacing(args.bValue); - }); + wi::scene::Scene& scene = editor->GetCurrentScene(); + for (auto& x : editor->translator.selected) + { + wi::Sprite* sprite = scene.sprites.GetComponent(x.entity); + if (sprite == nullptr) + continue; + sprite->SetCameraFacing(args.bValue); + } + }); AddWidget(&cameraFacingCheckBox); cameraScalingCheckBox.Create("Camera Scaling: "); cameraScalingCheckBox.SetTooltip("Camera scaling sprites will always keep the same size on screen, irrespective of the distance to the camera."); cameraScalingCheckBox.OnClick([=](wi::gui::EventArgs args) { - wi::Sprite* sprite = editor->GetCurrentScene().sprites.GetComponent(entity); - if (sprite == nullptr) - return; - sprite->SetCameraScaling(args.bValue); - }); + wi::scene::Scene& scene = editor->GetCurrentScene(); + for (auto& x : editor->translator.selected) + { + wi::Sprite* sprite = scene.sprites.GetComponent(x.entity); + if (sprite == nullptr) + continue; + sprite->SetCameraScaling(args.bValue); + } + }); AddWidget(&cameraScalingCheckBox); depthTestCheckBox.Create("Depth Test: "); depthTestCheckBox.SetTooltip("Depth tested sprites will be clipped against geometry."); depthTestCheckBox.OnClick([=](wi::gui::EventArgs args) { - wi::Sprite* sprite = editor->GetCurrentScene().sprites.GetComponent(entity); - if (sprite == nullptr) - return; - if (args.bValue) + wi::scene::Scene& scene = editor->GetCurrentScene(); + for (auto& x : editor->translator.selected) { - sprite->params.enableDepthTest(); + wi::Sprite* sprite = scene.sprites.GetComponent(x.entity); + if (sprite == nullptr) + continue; + if (args.bValue) + { + sprite->params.enableDepthTest(); + } + else + { + sprite->params.disableDepthTest(); + } } - else - { - sprite->params.disableDepthTest(); - } - }); + }); AddWidget(&depthTestCheckBox); distortionCheckBox.Create("Distortion: "); distortionCheckBox.SetTooltip("The distortion effect will use the sprite as a normal map to distort the rendered image.\nUse the color alpha to control distortion amount."); distortionCheckBox.OnClick([=](wi::gui::EventArgs args) { - wi::Sprite* sprite = editor->GetCurrentScene().sprites.GetComponent(entity); - if (sprite == nullptr) - return; - if (args.bValue) + wi::scene::Scene& scene = editor->GetCurrentScene(); + for (auto& x : editor->translator.selected) { - sprite->params.enableExtractNormalMap(); + wi::Sprite* sprite = scene.sprites.GetComponent(x.entity); + if (sprite == nullptr) + continue; + if (args.bValue) + { + sprite->params.enableExtractNormalMap(); + } + else + { + sprite->params.disableExtractNormalMap(); + } } - else - { - sprite->params.disableExtractNormalMap(); - } - }); + }); AddWidget(&distortionCheckBox); colorPicker.Create("Color", wi::gui::Window::WindowControls::NONE); colorPicker.OnColorChanged([&](wi::gui::EventArgs args) { - wi::Sprite* sprite = editor->GetCurrentScene().sprites.GetComponent(entity); - if (sprite == nullptr) - return; - sprite->params.color = args.color; + wi::scene::Scene& scene = editor->GetCurrentScene(); + for (auto& x : editor->translator.selected) + { + wi::Sprite* sprite = scene.sprites.GetComponent(x.entity); + if (sprite == nullptr) + continue; + sprite->params.color = args.color; + } }); AddWidget(&colorPicker); movingTexXSlider.Create(-1000, 1000, 0, 10000, "Scrolling X: "); movingTexXSlider.SetTooltip("Scrolling animation's speed in X direction."); movingTexXSlider.OnSlide([=](wi::gui::EventArgs args) { - wi::Sprite* sprite = editor->GetCurrentScene().sprites.GetComponent(entity); - if (sprite == nullptr) - return; - sprite->anim.movingTexAnim.speedX = args.fValue; - }); + wi::scene::Scene& scene = editor->GetCurrentScene(); + for (auto& x : editor->translator.selected) + { + wi::Sprite* sprite = scene.sprites.GetComponent(x.entity); + if (sprite == nullptr) + continue; + sprite->anim.movingTexAnim.speedX = args.fValue; + } + }); AddWidget(&movingTexXSlider); movingTexYSlider.Create(-1000, 1000, 0, 10000, "Scrolling Y: "); movingTexYSlider.SetTooltip("Scrolling animation's speed in Y direction."); movingTexYSlider.OnSlide([=](wi::gui::EventArgs args) { - wi::Sprite* sprite = editor->GetCurrentScene().sprites.GetComponent(entity); - if (sprite == nullptr) - return; - sprite->anim.movingTexAnim.speedY = args.fValue; - }); + wi::scene::Scene& scene = editor->GetCurrentScene(); + for (auto& x : editor->translator.selected) + { + wi::Sprite* sprite = scene.sprites.GetComponent(x.entity); + if (sprite == nullptr) + continue; + sprite->anim.movingTexAnim.speedY = args.fValue; + } + }); AddWidget(&movingTexYSlider); drawrectFrameRateSlider.Create(0, 60, 0, 60, "Spritesheet FPS: "); drawrectFrameRateSlider.SetTooltip("Sprite Sheet animation's frame rate per second."); drawrectFrameRateSlider.OnSlide([=](wi::gui::EventArgs args) { - wi::Sprite* sprite = editor->GetCurrentScene().sprites.GetComponent(entity); - if (sprite == nullptr) - return; - sprite->anim.drawRectAnim.frameRate = args.fValue; - UpdateSpriteDrawRectParams(sprite); - }); + wi::scene::Scene& scene = editor->GetCurrentScene(); + for (auto& x : editor->translator.selected) + { + wi::Sprite* sprite = scene.sprites.GetComponent(x.entity); + if (sprite == nullptr) + continue; + sprite->anim.drawRectAnim.frameRate = args.fValue; + UpdateSpriteDrawRectParams(sprite); + } + }); AddWidget(&drawrectFrameRateSlider); drawrectFrameCountInput.Create(""); drawrectFrameCountInput.SetDescription("frames: "); drawrectFrameCountInput.SetTooltip("Set the total frame count of the sprite sheet animation (1 = only 1 frame, no animation)."); drawrectFrameCountInput.OnInputAccepted([=](wi::gui::EventArgs args) { - wi::Sprite* sprite = editor->GetCurrentScene().sprites.GetComponent(entity); - if (sprite == nullptr) - return; - sprite->anim.drawRectAnim.frameCount = args.iValue; - UpdateSpriteDrawRectParams(sprite); - }); + wi::scene::Scene& scene = editor->GetCurrentScene(); + for (auto& x : editor->translator.selected) + { + wi::Sprite* sprite = scene.sprites.GetComponent(x.entity); + if (sprite == nullptr) + continue; + sprite->anim.drawRectAnim.frameCount = args.iValue; + UpdateSpriteDrawRectParams(sprite); + } + }); AddWidget(&drawrectFrameCountInput); drawrectHorizontalFrameCountInput.Create(""); drawrectHorizontalFrameCountInput.SetDescription("Horiz. frames: "); drawrectHorizontalFrameCountInput.SetTooltip("Set the horizontal frame count of the sprite sheet animation.\n(optional, use if sprite sheet contains multiple rows, default = 0)."); drawrectHorizontalFrameCountInput.OnInputAccepted([=](wi::gui::EventArgs args) { - wi::Sprite* sprite = editor->GetCurrentScene().sprites.GetComponent(entity); - if (sprite == nullptr) - return; - sprite->anim.drawRectAnim.horizontalFrameCount = args.iValue; - UpdateSpriteDrawRectParams(sprite); - }); + wi::scene::Scene& scene = editor->GetCurrentScene(); + for (auto& x : editor->translator.selected) + { + wi::Sprite* sprite = scene.sprites.GetComponent(x.entity); + if (sprite == nullptr) + continue; + sprite->anim.drawRectAnim.horizontalFrameCount = args.iValue; + UpdateSpriteDrawRectParams(sprite); + } + }); AddWidget(&drawrectHorizontalFrameCountInput); wobbleXSlider.Create(0, 1, 0, 10000, "Wobble X: "); wobbleXSlider.SetTooltip("Wobble animation's amount in X direction."); wobbleXSlider.OnSlide([=](wi::gui::EventArgs args) { - wi::Sprite* sprite = editor->GetCurrentScene().sprites.GetComponent(entity); - if (sprite == nullptr) - return; - sprite->anim.wobbleAnim.amount.x = args.fValue; - }); + wi::scene::Scene& scene = editor->GetCurrentScene(); + for (auto& x : editor->translator.selected) + { + wi::Sprite* sprite = scene.sprites.GetComponent(x.entity); + if (sprite == nullptr) + continue; + sprite->anim.wobbleAnim.amount.x = args.fValue; + } + }); AddWidget(&wobbleXSlider); wobbleYSlider.Create(0, 1, 0, 10000, "Wobble Y: "); wobbleYSlider.SetTooltip("Wobble animation's amount in X direction."); wobbleYSlider.OnSlide([=](wi::gui::EventArgs args) { - wi::Sprite* sprite = editor->GetCurrentScene().sprites.GetComponent(entity); - if (sprite == nullptr) - return; - sprite->anim.wobbleAnim.amount.y = args.fValue; - }); + wi::scene::Scene& scene = editor->GetCurrentScene(); + for (auto& x : editor->translator.selected) + { + wi::Sprite* sprite = scene.sprites.GetComponent(x.entity); + if (sprite == nullptr) + continue; + sprite->anim.wobbleAnim.amount.y = args.fValue; + } + }); AddWidget(&wobbleYSlider); wobbleSpeedSlider.Create(0, 4, 0, 10000, "Wobble Speed: "); wobbleSpeedSlider.SetTooltip("Wobble animation's speed."); wobbleSpeedSlider.OnSlide([=](wi::gui::EventArgs args) { - wi::Sprite* sprite = editor->GetCurrentScene().sprites.GetComponent(entity); - if (sprite == nullptr) - return; - sprite->anim.wobbleAnim.speed = args.fValue; - }); + wi::scene::Scene& scene = editor->GetCurrentScene(); + for (auto& x : editor->translator.selected) + { + wi::Sprite* sprite = scene.sprites.GetComponent(x.entity); + if (sprite == nullptr) + continue; + sprite->anim.wobbleAnim.speed = args.fValue; + } + }); AddWidget(&wobbleSpeedSlider); SetMinimized(true); diff --git a/Editor/TransformWindow.cpp b/Editor/TransformWindow.cpp index 750e40c97..8ec2fc823 100644 --- a/Editor/TransformWindow.cpp +++ b/Editor/TransformWindow.cpp @@ -22,7 +22,7 @@ void TransformWindow::Create(EditorComponent* _editor) editor->RecordEntity(archive, entity); editor->componentsWnd.RefreshEntityTree(); - }); + }); float x = 80; float xx = x;