Skip to content

Commit

Permalink
#5532: Start with lighting mode enabled and time running, if we have …
Browse files Browse the repository at this point in the history
…a material to show in the first place
  • Loading branch information
codereader committed Mar 7, 2021
1 parent c5625e6 commit 7579979
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
14 changes: 14 additions & 0 deletions libs/wxutil/preview/RenderPreview.cpp
Expand Up @@ -251,6 +251,20 @@ void RenderPreview::setLightingModeEnabled(bool enabled)
_renderSystem->setShaderProgram(RenderSystem::SHADER_PROGRAM_NONE);
queueDraw();
}

// Synchronise the button state, if necessary
auto* toolbar = static_cast<wxToolBar*>(_mainPanel->FindWindow("RenderPreviewRenderModeToolbar"));
auto* textureButton = getToolBarToolByLabel(toolbar, "texturedModeButton");
auto* lightingButton = getToolBarToolByLabel(toolbar, "lightingModeButton");

if (!enabled && !textureButton->IsToggled())
{
toolbar->ToggleTool(textureButton->GetId(), true);
}
else if (enabled && !lightingButton->IsToggled())
{
toolbar->ToggleTool(lightingButton->GetId(), true);
}
}

const scene::GraphPtr& RenderPreview::getScene()
Expand Down
12 changes: 12 additions & 0 deletions radiant/ui/materials/MaterialPreview.cpp
Expand Up @@ -48,6 +48,8 @@ const MaterialPtr& MaterialPreview::getMaterial()

void MaterialPreview::setMaterial(const MaterialPtr& material)
{
bool hadMaterial = _material != nullptr;

_material = material;
_sceneIsReady = false;

Expand All @@ -61,6 +63,16 @@ void MaterialPreview::setMaterial(const MaterialPtr& material)
}
}

if (!hadMaterial && _material)
{
setLightingModeEnabled(true);
startPlayback();
}
else if (hadMaterial && !_material)
{
stopPlayback();
}

queueDraw();
}

Expand Down

0 comments on commit 7579979

Please sign in to comment.