diff --git a/Editor/CMakeLists.txt b/Editor/CMakeLists.txt
index f8b8b86d3b..70de52e93d 100644
--- a/Editor/CMakeLists.txt
+++ b/Editor/CMakeLists.txt
@@ -14,6 +14,7 @@ set (SOURCE_FILES
LayerWindow.cpp
LightWindow.cpp
MaterialWindow.cpp
+ MaterialPickerWindow.cpp
MeshWindow.cpp
ModelImporter_GLTF.cpp
ModelImporter_OBJ.cpp
diff --git a/Editor/Editor.cpp b/Editor/Editor.cpp
index 430feb8c40..46ad27ad97 100644
--- a/Editor/Editor.cpp
+++ b/Editor/Editor.cpp
@@ -28,7 +28,7 @@ void Editor::Initialize()
wi::resourcemanager::SetMode(wi::resourcemanager::Mode::ALLOW_RETAIN_FILEDATA);
infoDisplay.active = true;
- infoDisplay.watermark = true;
+ infoDisplay.watermark = false; // can be toggled instead on gui
//infoDisplay.fpsinfo = true;
//infoDisplay.resolution = true;
//infoDisplay.logical_size = true;
@@ -244,23 +244,26 @@ void EditorComponent::ResizeLayout()
float hei = 25;
- saveButton.SetPos(XMFLOAT2(screenW - 50 - 55 - 105 * 3, 0));
+ saveButton.SetPos(XMFLOAT2(screenW - 40 - 44 - 44 - 104 * 3, 0));
saveButton.SetSize(XMFLOAT2(100, hei));
- openButton.SetPos(XMFLOAT2(screenW - 50 - 55 - 105 * 2, 0));
+ openButton.SetPos(XMFLOAT2(screenW - 40 - 44 - 44 - 104 * 2, 0));
openButton.SetSize(XMFLOAT2(100, hei));
- closeButton.SetPos(XMFLOAT2(screenW - 50 - 55 - 105 * 1, 0));
+ closeButton.SetPos(XMFLOAT2(screenW - 40 - 44 - 44 - 104 * 1, 0));
closeButton.SetSize(XMFLOAT2(100, hei));
- aboutButton.SetPos(XMFLOAT2(screenW - 50 - 55, 0));
- aboutButton.SetSize(XMFLOAT2(50, hei));
+ logButton.SetPos(XMFLOAT2(screenW - 40 - 44 - 44, 0));
+ logButton.SetSize(XMFLOAT2(40, hei));
+
+ aboutButton.SetPos(XMFLOAT2(screenW - 40 - 44, 0));
+ aboutButton.SetSize(XMFLOAT2(40, hei));
aboutLabel.SetSize(XMFLOAT2(screenW / 2.0f, screenH / 1.5f));
aboutLabel.SetPos(XMFLOAT2(screenW / 2.0f - aboutLabel.scale.x / 2.0f, screenH / 2.0f - aboutLabel.scale.y / 2.0f));
- exitButton.SetPos(XMFLOAT2(screenW - 50, 0));
- exitButton.SetSize(XMFLOAT2(50, hei));
+ exitButton.SetPos(XMFLOAT2(screenW - 40, 0));
+ exitButton.SetSize(XMFLOAT2(40, hei));
}
void EditorComponent::Load()
{
@@ -272,6 +275,7 @@ void EditorComponent::Load()
saveButton.Create(ICON_SAVE " Save");
saveButton.font.params.shadowColor = wi::Color::Transparent();
+ saveButton.SetShadowRadius(2);
saveButton.SetTooltip("Save the current scene to a new file (Ctrl + Shift + S)");
saveButton.SetColor(wi::Color(50, 180, 100, 180), wi::gui::WIDGETSTATE::IDLE);
saveButton.SetColor(wi::Color(50, 220, 140, 255), wi::gui::WIDGETSTATE::FOCUS);
@@ -282,6 +286,7 @@ void EditorComponent::Load()
openButton.Create(ICON_OPEN " Open");
+ openButton.SetShadowRadius(2);
openButton.font.params.shadowColor = wi::Color::Transparent();
openButton.SetTooltip("Open a scene, import a model or execute a Lua script...");
openButton.SetColor(wi::Color(50, 100, 255, 180), wi::gui::WIDGETSTATE::IDLE);
@@ -373,6 +378,7 @@ void EditorComponent::Load()
closeButton.Create(ICON_CLOSE " Close");
+ closeButton.SetShadowRadius(2);
closeButton.font.params.shadowColor = wi::Color::Transparent();
closeButton.SetTooltip("Close the current scene.\nThis will clear everything from the currently selected scene, and delete the scene.\nThis operation cannot be undone!");
closeButton.SetColor(wi::Color(255, 130, 100, 180), wi::gui::WIDGETSTATE::IDLE);
@@ -419,7 +425,20 @@ void EditorComponent::Load()
GetGUI().AddWidget(&closeButton);
+ logButton.Create(ICON_BACKLOG);
+ logButton.SetShadowRadius(2);
+ logButton.font.params.shadowColor = wi::Color::Transparent();
+ logButton.SetTooltip("Open the backlog");
+ logButton.SetColor(wi::Color(50, 160, 200, 180), wi::gui::WIDGETSTATE::IDLE);
+ logButton.SetColor(wi::Color(120, 200, 200, 255), wi::gui::WIDGETSTATE::FOCUS);
+ logButton.OnClick([&](wi::gui::EventArgs args) {
+ wi::backlog::Toggle();
+ });
+ GetGUI().AddWidget(&logButton);
+
+
aboutButton.Create(ICON_HELP);
+ aboutButton.SetShadowRadius(2);
aboutButton.font.params.shadowColor = wi::Color::Transparent();
aboutButton.SetTooltip("About...");
aboutButton.SetColor(wi::Color(50, 160, 200, 180), wi::gui::WIDGETSTATE::IDLE);
@@ -486,6 +505,7 @@ void EditorComponent::Load()
}
exitButton.Create(ICON_EXIT);
+ exitButton.SetShadowRadius(2);
exitButton.font.params.shadowColor = wi::Color::Transparent();
exitButton.SetTooltip("Exit");
exitButton.SetColor(wi::Color(160, 50, 50, 180), wi::gui::WIDGETSTATE::IDLE);
@@ -503,7 +523,7 @@ void EditorComponent::Load()
optionsWnd.Create("Options", wi::gui::Window::WindowControls::RESIZE_TOPRIGHT);
optionsWnd.SetPos(XMFLOAT2(100, 120));
- optionsWnd.SetSize(XMFLOAT2(340, 400));
+ optionsWnd.SetSize(XMFLOAT2(340, 500));
optionsWnd.SetShadowRadius(2);
GetGUI().AddWidget(&optionsWnd);
@@ -578,20 +598,19 @@ void EditorComponent::Load()
}
GetGUI().SetVisible(false);
wi::profiler::SetEnabled(false);
- main->infoDisplay.active = false;
});
optionsWnd.AddWidget(&cinemaModeCheckBox);
- infoDisplayCheckBox.Create("Info Display: ");
- infoDisplayCheckBox.SetTooltip("Toggle the information display (the text in top left corner).");
- infoDisplayCheckBox.OnClick([&](wi::gui::EventArgs args) {
- main->infoDisplay.active = args.bValue;
+ versionCheckBox.Create("Version: ");
+ versionCheckBox.SetTooltip("Toggle the engine version display text in top left corner.");
+ versionCheckBox.OnClick([&](wi::gui::EventArgs args) {
+ main->infoDisplay.watermark = args.bValue;
});
- optionsWnd.AddWidget(&infoDisplayCheckBox);
- infoDisplayCheckBox.SetCheck(main->infoDisplay.active);
+ optionsWnd.AddWidget(&versionCheckBox);
+ versionCheckBox.SetCheck(main->infoDisplay.watermark);
fpsCheckBox.Create("FPS: ");
- fpsCheckBox.SetTooltip("Toggle the FPS display.");
+ fpsCheckBox.SetTooltip("Toggle the FPS display text in top left corner.");
fpsCheckBox.OnClick([&](wi::gui::EventArgs args) {
main->infoDisplay.fpsinfo = args.bValue;
});
@@ -599,7 +618,7 @@ void EditorComponent::Load()
fpsCheckBox.SetCheck(main->infoDisplay.fpsinfo);
otherinfoCheckBox.Create("Advanced: ");
- otherinfoCheckBox.SetTooltip("Toggle advanced data in the info display.");
+ otherinfoCheckBox.SetTooltip("Toggle advanced data in the info display text in top left corner.");
otherinfoCheckBox.OnClick([&](wi::gui::EventArgs args) {
main->infoDisplay.heap_allocation_counter = args.bValue;
main->infoDisplay.vram_usage = args.bValue;
@@ -615,6 +634,9 @@ void EditorComponent::Load()
newCombo.Create("New: ");
+ newCombo.selected_font.anim.typewriter.looped = true;
+ newCombo.selected_font.anim.typewriter.time = 2;
+ newCombo.selected_font.anim.typewriter.character_start = 1;
newCombo.AddItem("...", ~0ull);
newCombo.AddItem("Transform", 0);
newCombo.AddItem("Material", 1);
@@ -849,6 +871,9 @@ void EditorComponent::Load()
GetGUI().AddWidget(&componentWindow);
newComponentCombo.Create("Add: ");
+ newComponentCombo.selected_font.anim.typewriter.looped = true;
+ newComponentCombo.selected_font.anim.typewriter.time = 2;
+ newComponentCombo.selected_font.anim.typewriter.character_start = 1;
newComponentCombo.SetTooltip("Add a component to the first selected entity.");
newComponentCombo.AddItem("...", ~0ull);
newComponentCombo.AddItem("Name", 0);
@@ -1076,6 +1101,8 @@ void EditorComponent::Load()
paintToolWnd.SetCollapsed(true);
optionsWnd.AddWidget(&paintToolWnd);
+ materialPickerWnd.Create(this);
+ optionsWnd.AddWidget(&materialPickerWnd);
sceneComboBox.Create("Scene: ");
@@ -1264,7 +1291,7 @@ void EditorComponent::Load()
wi::gui::Theme theme;
theme.image.background = true;
theme.image.blendFlag = wi::enums::BLENDMODE_OPAQUE;
- theme.font.color = wi::Color(160, 240, 250, 255);
+ theme.font.color = wi::Color(130, 210, 220, 255);
theme.shadow_color = wi::Color(80, 140, 180, 100);
switch ((Theme)args.userdata)
@@ -1401,7 +1428,6 @@ void EditorComponent::Update(float dt)
renderPath->GetGUI().SetVisible(true);
}
GetGUI().SetVisible(true);
- main->infoDisplay.active = infoDisplayCheckBox.GetCheck();
wi::profiler::SetEnabled(profilerEnabledCheckBox.GetCheck());
cinemaModeCheckBox.SetCheck(false);
@@ -2087,7 +2113,6 @@ void EditorComponent::Update(float dt)
hairWnd.SetEntity(INVALID_ENTITY);
meshWnd.SetEntity(INVALID_ENTITY, -1);
materialWnd.SetEntity(INVALID_ENTITY);
- lightWnd.SetEntity(INVALID_ENTITY);
soundWnd.SetEntity(INVALID_ENTITY);
decalWnd.SetEntity(INVALID_ENTITY);
envProbeWnd.SetEntity(INVALID_ENTITY);
@@ -2242,6 +2267,7 @@ void EditorComponent::Update(float dt)
RenderPath2D::Update(dt);
RefreshComponentWindow();
RefreshOptionsWindow();
+ materialPickerWnd.Update();
translator.Update(camera, *this);
@@ -2860,10 +2886,10 @@ void EditorComponent::RefreshOptionsWindow()
pos.y += translatorCheckBox.GetSize().y;
pos.y += padding;
- infoDisplayCheckBox.SetPos(XMFLOAT2(pos.x + x_off, pos.y));
+ versionCheckBox.SetPos(XMFLOAT2(pos.x + x_off, pos.y));
fpsCheckBox.SetPos(XMFLOAT2(pos.x + x_off + 80, pos.y));
otherinfoCheckBox.SetPos(XMFLOAT2(pos.x + x_off + 60 * 3, pos.y));
- pos.y += infoDisplayCheckBox.GetSize().y;
+ pos.y += versionCheckBox.GetSize().y;
pos.y += padding;
cinemaModeCheckBox.SetPos(XMFLOAT2(pos.x + x_off, pos.y));
@@ -2923,6 +2949,11 @@ void EditorComponent::RefreshOptionsWindow()
pos.y += cameraWnd.GetSize().y;
pos.y += padding;
+ materialPickerWnd.SetPos(pos);
+ materialPickerWnd.SetSize(XMFLOAT2(width, materialPickerWnd.GetScale().y));
+ pos.y += materialPickerWnd.GetSize().y;
+ pos.y += padding;
+
paintToolWnd.SetPos(pos);
paintToolWnd.SetSize(XMFLOAT2(width, paintToolWnd.GetScale().y));
pos.y += paintToolWnd.GetSize().y;
@@ -3086,6 +3117,7 @@ void EditorComponent::PushToEntityTree(wi::ecs::Entity entity, int level)
void EditorComponent::RefreshEntityTree()
{
const Scene& scene = GetCurrentScene();
+ materialPickerWnd.RecreateButtons();
for (int i = 0; i < entityTree.GetItemCount(); ++i)
{
diff --git a/Editor/Editor.h b/Editor/Editor.h
index 861d731cfa..7e387f7fba 100644
--- a/Editor/Editor.h
+++ b/Editor/Editor.h
@@ -5,6 +5,7 @@
#include "wiScene_BindLua.h"
#include "MaterialWindow.h"
+#include "MaterialPickerWindow.h"
#include "PostprocessWindow.h"
#include "WeatherWindow.h"
#include "ObjectWindow.h"
@@ -43,6 +44,7 @@ class EditorComponent : public wi::RenderPath2D
{
public:
MaterialWindow materialWnd;
+ MaterialPickerWindow materialPickerWnd;
PostprocessWindow postprocessWnd;
WeatherWindow weatherWnd;
ObjectWindow objectWnd;
@@ -70,6 +72,7 @@ class EditorComponent : public wi::RenderPath2D
wi::gui::Button saveButton;
wi::gui::Button openButton;
wi::gui::Button closeButton;
+ wi::gui::Button logButton;
wi::gui::Button aboutButton;
wi::gui::Button exitButton;
wi::gui::Label aboutLabel;
@@ -82,7 +85,7 @@ class EditorComponent : public wi::RenderPath2D
wi::gui::CheckBox profilerEnabledCheckBox;
wi::gui::CheckBox physicsEnabledCheckBox;
wi::gui::CheckBox cinemaModeCheckBox;
- wi::gui::CheckBox infoDisplayCheckBox;
+ wi::gui::CheckBox versionCheckBox;
wi::gui::CheckBox fpsCheckBox;
wi::gui::CheckBox otherinfoCheckBox;
wi::gui::ComboBox themeCombo;
diff --git a/Editor/Editor_SOURCE.vcxitems b/Editor/Editor_SOURCE.vcxitems
index 4a826905ba..e7d74d72b3 100644
--- a/Editor/Editor_SOURCE.vcxitems
+++ b/Editor/Editor_SOURCE.vcxitems
@@ -25,6 +25,7 @@
+
NotUsing
@@ -137,6 +138,7 @@
+
diff --git a/Editor/Editor_SOURCE.vcxitems.filters b/Editor/Editor_SOURCE.vcxitems.filters
index 0b0e35bbc4..fe8b93d73c 100644
--- a/Editor/Editor_SOURCE.vcxitems.filters
+++ b/Editor/Editor_SOURCE.vcxitems.filters
@@ -74,6 +74,7 @@
meshoptimizer
+
@@ -112,6 +113,7 @@
+
diff --git a/Editor/IconDefinitions.h b/Editor/IconDefinitions.h
index f362f25d6f..11bd2d79bb 100644
--- a/Editor/IconDefinitions.h
+++ b/Editor/IconDefinitions.h
@@ -29,5 +29,6 @@
#define ICON_SAVE ICON_FA_FLOPPY_DISK
#define ICON_OPEN ICON_FA_FOLDER_OPEN
#define ICON_CLOSE ICON_FA_TRASH
+#define ICON_BACKLOG ICON_FA_BOOK
#define ICON_HELP ICON_FA_CIRCLE_QUESTION
#define ICON_EXIT ICON_FA_CIRCLE_XMARK
diff --git a/Editor/MaterialPickerWindow.cpp b/Editor/MaterialPickerWindow.cpp
new file mode 100644
index 0000000000..e7d5cfa6b7
--- /dev/null
+++ b/Editor/MaterialPickerWindow.cpp
@@ -0,0 +1,165 @@
+#include "stdafx.h"
+#include "MaterialWindow.h"
+#include "Editor.h"
+
+using namespace wi::graphics;
+using namespace wi::ecs;
+using namespace wi::scene;
+
+void MaterialPickerWindow::Create(EditorComponent* _editor)
+{
+ editor = _editor;
+ wi::gui::Window::Create("Materials", wi::gui::Window::WindowControls::COLLAPSE);
+ SetSize(XMFLOAT2(300, 400));
+
+ zoomSlider.Create(10, 100, 100, 100 - 10, "Zoom: ");
+ AddWidget(&zoomSlider);
+
+ SetCollapsed(true);
+}
+
+
+void MaterialPickerWindow::RecreateButtons()
+{
+ if (editor == nullptr)
+ return;
+ const wi::scene::Scene& scene = editor->GetCurrentScene();
+ for (auto& x : buttons)
+ {
+ RemoveWidget(&x);
+ }
+ buttons.resize(scene.materials.GetCount());
+
+ for (size_t i = 0; i < scene.materials.GetCount(); ++i)
+ {
+ Entity entity = scene.materials.GetEntity(i);
+
+ wi::gui::Button& button = buttons[i];
+ button.Create("");
+ AddWidget(&button);
+ button.SetVisible(false);
+
+ button.OnClick([entity, this](wi::gui::EventArgs args) {
+
+ wi::Archive& archive = editor->AdvanceHistory();
+ archive << EditorComponent::HISTORYOP_SELECTION;
+ // record PREVIOUS selection state...
+ editor->RecordSelection(archive);
+
+ if (!editor->translator.selected.empty() && wi::input::Down(wi::input::KEYBOARD_BUTTON_LSHIFT))
+ {
+ // Union selection:
+ wi::vector saved = editor->translator.selected;
+ editor->translator.selected.clear();
+ for (const wi::scene::PickResult& picked : saved)
+ {
+ editor->AddSelected(picked);
+ }
+ editor->AddSelected(entity);
+ }
+ else
+ {
+ // Replace selection:
+ editor->translator.selected.clear();
+ editor->AddSelected(entity);
+ }
+
+ // record NEW selection state...
+ editor->RecordSelection(archive);
+ });
+ }
+
+ Update();
+}
+
+void MaterialPickerWindow::Update()
+{
+ if (editor == nullptr || IsCollapsed() || !IsVisible())
+ {
+ return;
+ }
+
+ const wi::scene::Scene& scene = editor->GetCurrentScene();
+ if (buttons.size() != scene.materials.GetCount())
+ {
+ RecreateButtons();
+ return;
+ }
+
+ zoomSlider.SetPos(XMFLOAT2(55, 0));
+ zoomSlider.SetSize(XMFLOAT2(GetWidgetAreaSize().x - 100 - 5, 20));
+
+ wi::gui::Theme theme;
+ theme.image.CopyFrom(sprites[wi::gui::IDLE].params);
+ theme.image.background = false;
+ theme.image.blendFlag = wi::enums::BLENDMODE_ALPHA;
+ theme.font.CopyFrom(font.params);
+ theme.shadow_color = wi::Color::lerp(theme.font.color, wi::Color::Transparent(), 0.25f);
+ theme.tooltipFont.CopyFrom(tooltipFont.params);
+ theme.tooltipImage.CopyFrom(tooltipSprite.params);
+
+ const float preview_size = zoomSlider.GetValue();
+ const float border = 20 * preview_size / 100.0f;
+ int cells = std::max(1, int(GetWidgetAreaSize().x / (preview_size + border)));
+ float offset_y = border + zoomSlider.GetSize().y;
+
+ for (size_t i = 0; i < scene.materials.GetCount(); ++i)
+ {
+ const MaterialComponent& material = scene.materials[i];
+ Entity entity = scene.materials.GetEntity(i);
+
+ wi::gui::Button& button = buttons[i];
+ button.SetVisible(IsVisible() && !IsCollapsed());
+
+ button.SetTheme(theme);
+ button.SetColor(wi::Color::White());
+ button.SetColor(wi::Color(255, 255, 255, 150), wi::gui::IDLE);
+ button.SetShadowRadius(0);
+
+ for (auto& picked : editor->translator.selected)
+ {
+ if (picked.entity == entity)
+ {
+ button.SetColor(wi::Color::White());
+ button.SetShadowRadius(3);
+ break;
+ }
+ }
+
+ // find first good texture that we can show:
+ button.SetImage({});
+ for (auto& slot : material.textures)
+ {
+ if (slot.resource.IsValid())
+ {
+ button.SetImage(slot.resource);
+ break;
+ }
+ }
+
+ const NameComponent* name = scene.names.GetComponent(entity);
+ if (name != nullptr)
+ {
+ if (preview_size >= 75)
+ {
+ button.SetText(name->name);
+ }
+ else
+ {
+ button.SetText("");
+ }
+ button.SetTooltip(name->name);
+ }
+ button.font.params.h_align = wi::font::WIFALIGN_CENTER;
+ button.font.params.v_align = wi::font::WIFALIGN_BOTTOM;
+
+ button.SetSize(XMFLOAT2(preview_size, preview_size));
+ button.SetPos(XMFLOAT2((i % cells) * (preview_size + border) + border, offset_y));
+ if ((i % cells) == (cells - 1))
+ {
+ offset_y += preview_size + border;
+ }
+ }
+
+ wi::gui::Window::Update(*editor, 0);
+}
diff --git a/Editor/MaterialPickerWindow.h b/Editor/MaterialPickerWindow.h
new file mode 100644
index 0000000000..d05f5e9f67
--- /dev/null
+++ b/Editor/MaterialPickerWindow.h
@@ -0,0 +1,22 @@
+#pragma once
+#include "WickedEngine.h"
+
+class EditorComponent;
+
+class MaterialPickerWindow : public wi::gui::Window
+{
+public:
+ void Create(EditorComponent* editor);
+
+ EditorComponent* editor = nullptr;
+
+ wi::vector buttons;
+
+ wi::gui::Slider zoomSlider;
+
+ void Update();
+
+ // Recreating buttons shouldn't be done every frame because interaction states need multi-frame execution
+ void RecreateButtons();
+};
+
diff --git a/WickedEngine/wiGUI.cpp b/WickedEngine/wiGUI.cpp
index c74bea9571..cc8f5c2138 100644
--- a/WickedEngine/wiGUI.cpp
+++ b/WickedEngine/wiGUI.cpp
@@ -287,6 +287,9 @@ namespace wi::gui
{
tooltipTimer = 0;
}
+
+ sprites[state].Update(dt);
+ font.Update(dt);
}
void Widget::RenderTooltip(const wi::Canvas& canvas, CommandList cmd) const
{
@@ -775,6 +778,32 @@ namespace wi::gui
font_description.params.posX = translation.x - 2;
font_description.params.posY = translation.y + scale.y * 0.5f;
+ switch (font_description.params.h_align)
+ {
+ case wi::font::WIFALIGN_LEFT:
+ font_description.params.posX = translation.x + scale.x;
+ break;
+ case wi::font::WIFALIGN_RIGHT:
+ font_description.params.posX = translation.x;
+ break;
+ case wi::font::WIFALIGN_CENTER:
+ default:
+ font_description.params.posX = translation.x + scale.x * 0.5f;
+ break;
+ }
+ switch (font_description.params.v_align)
+ {
+ case wi::font::WIFALIGN_TOP:
+ font_description.params.posY = translation.y + scale.y;
+ break;
+ case wi::font::WIFALIGN_BOTTOM:
+ font_description.params.posY = translation.y;
+ break;
+ case wi::font::WIFALIGN_CENTER:
+ default:
+ font_description.params.posY = translation.y + scale.y * 0.5f;
+ break;
+ }
}
void Button::Render(const wi::Canvas& canvas, CommandList cmd) const
{
@@ -1269,6 +1298,32 @@ namespace wi::gui
font.params.posY = translation.y + scale.y * 0.5f;
font_description.params.posX = translation.x - 2;
font_description.params.posY = translation.y + scale.y * 0.5f;
+ switch (font_description.params.h_align)
+ {
+ case wi::font::WIFALIGN_LEFT:
+ font_description.params.posX = translation.x + scale.x;
+ break;
+ case wi::font::WIFALIGN_RIGHT:
+ font_description.params.posX = translation.x;
+ break;
+ case wi::font::WIFALIGN_CENTER:
+ default:
+ font_description.params.posX = translation.x + scale.x * 0.5f;
+ break;
+ }
+ switch (font_description.params.v_align)
+ {
+ case wi::font::WIFALIGN_TOP:
+ font_description.params.posY = translation.y + scale.y;
+ break;
+ case wi::font::WIFALIGN_BOTTOM:
+ font_description.params.posY = translation.y;
+ break;
+ case wi::font::WIFALIGN_CENTER:
+ default:
+ font_description.params.posY = translation.y + scale.y * 0.5f;
+ break;
+ }
if (state == ACTIVE)
{
@@ -1732,6 +1787,10 @@ namespace wi::gui
font.params.h_align = wi::font::WIFALIGN_RIGHT;
font.params.v_align = wi::font::WIFALIGN_CENTER;
+
+ selected_font = font;
+ selected_font.params.h_align = wi::font::WIFALIGN_CENTER;
+ selected_font.params.v_align = wi::font::WIFALIGN_CENTER;
}
float ComboBox::GetDropOffset(const wi::Canvas& canvas) const
{
@@ -1906,6 +1965,14 @@ namespace wi::gui
font.params.posY = translation.y + sprites[state].params.siz.y * 0.5f;
selected = std::min((int)items.size(), selected);
+
+ if (selected >= 0)
+ {
+ selected_font.SetText(items[selected].name);
+ selected_font.params.posX = translation.x + scale.x * 0.5f;
+ selected_font.params.posY = translation.y + scale.y * 0.5f;
+ selected_font.Update(dt);
+ }
}
void ComboBox::Render(const wi::Canvas& canvas, CommandList cmd) const
{
@@ -1989,17 +2056,7 @@ namespace wi::gui
if (selected >= 0)
{
- wi::font::Params fp = wi::font::Params(
- translation.x + scale.x * 0.5f,
- translation.y + scale.y * 0.5f,
- wi::font::WIFONTSIZE_DEFAULT,
- wi::font::WIFALIGN_CENTER,
- wi::font::WIFALIGN_CENTER,
- font.params.color,
- font.params.shadowColor
- );
- fp.style = font.params.style;
- wi::font::Draw(items[selected].name, fp, cmd);
+ selected_font.Draw(cmd);
}
// drop-down
@@ -2221,6 +2278,7 @@ namespace wi::gui
{
drop_color = wi::Color::fromFloat4(theme.image.color);
}
+ theme.font.Apply(selected_font.params);
}
diff --git a/WickedEngine/wiGUI.h b/WickedEngine/wiGUI.h
index 8059dc15f5..4b1c48f57f 100644
--- a/WickedEngine/wiGUI.h
+++ b/WickedEngine/wiGUI.h
@@ -109,6 +109,21 @@ namespace wi::gui
params.disableBackground();
}
}
+ void CopyFrom(const wi::image::Params& params)
+ {
+ color = params.color;
+ blendFlag = params.blendFlag;
+ sampleFlag = params.sampleFlag;
+ quality = params.quality;
+ if (params.isBackgroundEnabled())
+ {
+ background = true;
+ }
+ else
+ {
+ background = false;
+ }
+ }
} image;
// Reduced version of wi::font::Params, excluding position, alignment, etc.
@@ -136,6 +151,18 @@ namespace wi::gui
params.shadow_offset_x = shadow_offset_x;
params.shadow_offset_y = shadow_offset_y;
}
+ void CopyFrom(const wi::font::Params& params)
+ {
+ color = params.color;
+ shadow_color = params.shadowColor;
+ style = params.style;
+ softness = params.softness;
+ bolden = params.bolden;
+ shadow_softness = params.shadow_softness;
+ shadow_bolden = params.shadow_bolden;
+ shadow_offset_x = params.shadow_offset_x;
+ shadow_offset_y = params.shadow_offset_y;
+ }
} font;
wi::Color shadow_color = wi::Color::Shadow(); // shadow color for whole widget
@@ -484,6 +511,8 @@ namespace wi::gui
void SetTheme(const Theme& theme, int id = -1) override;
void OnSelect(std::function func);
+
+ wi::SpriteFont selected_font;
};
// Widget container
diff --git a/WickedEngine/wiVersion.cpp b/WickedEngine/wiVersion.cpp
index 4c5f9745ba..d44fcadc4d 100644
--- a/WickedEngine/wiVersion.cpp
+++ b/WickedEngine/wiVersion.cpp
@@ -9,7 +9,7 @@ namespace wi::version
// minor features, major updates, breaking compatibility changes
const int minor = 70;
// minor bug fixes, alterations, refactors, updates
- const int revision = 16;
+ const int revision = 17;
const std::string version_string = std::to_string(major) + "." + std::to_string(minor) + "." + std::to_string(revision);