GUI updates (#490)

This commit is contained in:
Turánszki János
2022-07-28 20:59:25 +02:00
committed by GitHub
parent 87f3287aaa
commit f277a00596
69 changed files with 18224 additions and 2995 deletions
+50 -81
View File
@@ -12,16 +12,51 @@ using namespace wi::scene;
void LightWindow::Create(EditorComponent* _editor)
{
editor = _editor;
wi::gui::Window::Create("Light Window");
SetSize(XMFLOAT2(650, 300));
wi::gui::Window::Create(ICON_POINTLIGHT " Light", wi::gui::Window::WindowControls::COLLAPSE | wi::gui::Window::WindowControls::CLOSE);
SetSize(XMFLOAT2(650, 700));
float x = 450;
closeButton.SetTooltip("Delete LightComponent");
OnClose([=](wi::gui::EventArgs args) {
wi::Archive& archive = editor->AdvanceHistory();
archive << EditorComponent::HISTORYOP_COMPONENT_DATA;
editor->RecordEntity(archive, entity);
editor->GetCurrentScene().lights.Remove(entity);
editor->GetCurrentScene().aabb_lights.Remove(entity);
editor->RecordEntity(archive, entity);
editor->RefreshEntityTree();
});
float x = 130;
float y = 0;
float hei = 18;
float step = hei + 2;
float wid = 130;
float mod_x = 10;
colorPicker.Create("Light Color", wi::gui::Window::WindowControls::NONE);
colorPicker.SetPos(XMFLOAT2(mod_x, y));
colorPicker.SetVisible(true);
colorPicker.SetEnabled(false);
colorPicker.OnColorChanged([&](wi::gui::EventArgs args) {
LightComponent* light = editor->GetCurrentScene().lights.GetComponent(entity);
if (light != nullptr)
{
light->color = args.color.toFloat3();
}
});
AddWidget(&colorPicker);
float mod_wid = colorPicker.GetScale().x;
y += colorPicker.GetScale().y + 5;
intensitySlider.Create(0, 1000, 0, 100000, "Intensity: ");
intensitySlider.SetSize(XMFLOAT2(100, hei));
intensitySlider.SetSize(XMFLOAT2(wid, hei));
intensitySlider.SetPos(XMFLOAT2(x, y));
intensitySlider.OnSlide([&](wi::gui::EventArgs args) {
LightComponent* light = editor->GetCurrentScene().lights.GetComponent(entity);
@@ -35,7 +70,7 @@ void LightWindow::Create(EditorComponent* _editor)
AddWidget(&intensitySlider);
rangeSlider.Create(1, 1000, 0, 100000, "Range: ");
rangeSlider.SetSize(XMFLOAT2(100, hei));
rangeSlider.SetSize(XMFLOAT2(wid, hei));
rangeSlider.SetPos(XMFLOAT2(x, y += step));
rangeSlider.OnSlide([&](wi::gui::EventArgs args) {
LightComponent* light = editor->GetCurrentScene().lights.GetComponent(entity);
@@ -49,7 +84,7 @@ void LightWindow::Create(EditorComponent* _editor)
AddWidget(&rangeSlider);
outerConeAngleSlider.Create(0.1f, XM_PIDIV2 - 0.01f, 0, 100000, "Outer Cone Angle: ");
outerConeAngleSlider.SetSize(XMFLOAT2(100, hei));
outerConeAngleSlider.SetSize(XMFLOAT2(wid, hei));
outerConeAngleSlider.SetPos(XMFLOAT2(x, y += step));
outerConeAngleSlider.OnSlide([&](wi::gui::EventArgs args) {
LightComponent* light = editor->GetCurrentScene().lights.GetComponent(entity);
@@ -63,7 +98,7 @@ void LightWindow::Create(EditorComponent* _editor)
AddWidget(&outerConeAngleSlider);
innerConeAngleSlider.Create(0, XM_PI - 0.01f, 0, 100000, "Inner Cone Angle: ");
innerConeAngleSlider.SetSize(XMFLOAT2(100, hei));
innerConeAngleSlider.SetSize(XMFLOAT2(wid, hei));
innerConeAngleSlider.SetPos(XMFLOAT2(x, y += step));
innerConeAngleSlider.OnSlide([&](wi::gui::EventArgs args) {
LightComponent* light = editor->GetCurrentScene().lights.GetComponent(entity);
@@ -132,68 +167,8 @@ void LightWindow::Create(EditorComponent* _editor)
staticCheckBox.SetTooltip("Static lights will only be used for baking into lightmaps.");
AddWidget(&staticCheckBox);
addLightButton.Create("Add Light");
addLightButton.SetPos(XMFLOAT2(x, y += step));
addLightButton.SetSize(XMFLOAT2(150, hei));
addLightButton.OnClick([=](wi::gui::EventArgs args) {
Entity entity = editor->GetCurrentScene().Entity_CreateLight("editorLight", XMFLOAT3(0, 3, 0), XMFLOAT3(1, 1, 1), 2, 60);
LightComponent* light = editor->GetCurrentScene().lights.GetComponent(entity);
if (light != nullptr)
{
light->type = (LightComponent::LightType)typeSelectorComboBox.GetSelected();
switch (light->type)
{
case LightComponent::LightType::DIRECTIONAL:
light->intensity = 10;
break;
case LightComponent::LightType::SPOT:
light->intensity = 100;
break;
case LightComponent::LightType::POINT:
light->intensity = 20;
break;
default:
break;
}
wi::Archive& archive = editor->AdvanceHistory();
archive << EditorComponent::HISTORYOP_ADD;
editor->RecordSelection(archive);
editor->ClearSelected();
editor->AddSelected(entity);
editor->RecordSelection(archive);
editor->RecordAddedEntity(archive, entity);
editor->RefreshEntityTree();
SetEntity(entity);
}
else
{
assert(0);
}
});
addLightButton.SetTooltip("Add a light to the scene.");
AddWidget(&addLightButton);
colorPicker.Create("Light Color", false);
colorPicker.SetPos(XMFLOAT2(10, 0));
colorPicker.SetVisible(true);
colorPicker.SetEnabled(false);
colorPicker.OnColorChanged([&](wi::gui::EventArgs args) {
LightComponent* light = editor->GetCurrentScene().lights.GetComponent(entity);
if (light != nullptr)
{
light->color = args.color.toFloat3();
}
});
AddWidget(&colorPicker);
typeSelectorComboBox.Create("Type: ");
typeSelectorComboBox.SetSize(XMFLOAT2(150, hei));
typeSelectorComboBox.SetSize(XMFLOAT2(wid, hei));
typeSelectorComboBox.SetPos(XMFLOAT2(x, y += step));
typeSelectorComboBox.OnSelect([&](wi::gui::EventArgs args) {
LightComponent* light = editor->GetCurrentScene().lights.GetComponent(entity);
@@ -206,17 +181,13 @@ void LightWindow::Create(EditorComponent* _editor)
typeSelectorComboBox.AddItem("Directional");
typeSelectorComboBox.AddItem("Point");
typeSelectorComboBox.AddItem("Spot");
//typeSelectorComboBox.AddItem("Sphere");
//typeSelectorComboBox.AddItem("Disc");
//typeSelectorComboBox.AddItem("Rectangle");
//typeSelectorComboBox.AddItem("Tube");
typeSelectorComboBox.SetTooltip("Choose the light source type...");
typeSelectorComboBox.SetSelected((int)LightComponent::POINT);
AddWidget(&typeSelectorComboBox);
shadowResolutionComboBox.Create("Shadow resolution: ");
shadowResolutionComboBox.SetTooltip("You can force a fixed resolution for this light's shadow map to avoid dynamic scaling.\nIf you leave it as dynamic, the resolution will be scaled between 0 and the max shadow resolution in the renderer for this light type, based on light's distance and size.");
shadowResolutionComboBox.SetSize(XMFLOAT2(150, hei));
shadowResolutionComboBox.SetSize(XMFLOAT2(wid, hei));
shadowResolutionComboBox.SetPos(XMFLOAT2(x, y += step));
shadowResolutionComboBox.AddItem("Dynamic", uint64_t(-1));
shadowResolutionComboBox.AddItem("32", 32);
@@ -235,12 +206,11 @@ void LightWindow::Create(EditorComponent* _editor)
shadowResolutionComboBox.SetSelected(0);
AddWidget(&shadowResolutionComboBox);
y += step;
x -= 100;
y += step * 0.5f;
lensflare_Label.Create("Lens flare textures: ");
lensflare_Label.SetPos(XMFLOAT2(x, y += step));
lensflare_Label.SetSize(XMFLOAT2(140, hei));
lensflare_Label.SetPos(XMFLOAT2(mod_x, y += step));
lensflare_Label.SetSize(XMFLOAT2(wid, hei));
AddWidget(&lensflare_Label);
for (size_t i = 0; i < arraysize(lensflare_Button); ++i)
@@ -248,8 +218,8 @@ void LightWindow::Create(EditorComponent* _editor)
lensflare_Button[i].Create("LensFlareSlot");
lensflare_Button[i].SetText("");
lensflare_Button[i].SetTooltip("Load a lensflare texture to this slot");
lensflare_Button[i].SetPos(XMFLOAT2(x, y += step));
lensflare_Button[i].SetSize(XMFLOAT2(260, hei));
lensflare_Button[i].SetPos(XMFLOAT2(mod_x, y += step));
lensflare_Button[i].SetSize(XMFLOAT2(mod_wid, hei));
lensflare_Button[i].OnClick([=](wi::gui::EventArgs args) {
LightComponent* light = editor->GetCurrentScene().lights.GetComponent(entity);
if (light == nullptr)
@@ -285,8 +255,7 @@ void LightWindow::Create(EditorComponent* _editor)
AddWidget(&lensflare_Button[i]);
}
Translate(XMFLOAT3(120, 30, 0));
SetMinimized(true);
SetVisible(false);
SetEntity(INVALID_ENTITY);