From 4786c15d7c3b5c56b14d94fcbd849936ec62f8f0 Mon Sep 17 00:00:00 2001 From: codereader Date: Sun, 24 Jan 2021 05:32:49 +0100 Subject: [PATCH] #5501: Add checkbox to toggle "ai_see" to Light Inspector --- install/games/darkmod.game | 2 + install/ui/lightinspector.fbp | 64 ++++++++++++++++++++ install/ui/lightinspector.xrc | 10 +++ radiant/ui/lightinspector/LightInspector.cpp | 53 ++++++++++------ radiant/ui/lightinspector/LightInspector.h | 2 + 5 files changed, 113 insertions(+), 18 deletions(-) diff --git a/install/games/darkmod.game b/install/games/darkmod.game index 9c14f7f7a5..23949230bc 100644 --- a/install/games/darkmod.game +++ b/install/games/darkmod.game @@ -233,6 +233,8 @@ fogs + + diff --git a/install/ui/lightinspector.fbp b/install/ui/lightinspector.fbp index e2cc0c15e0..ffc8c44a6a 100644 --- a/install/ui/lightinspector.fbp +++ b/install/ui/lightinspector.fbp @@ -777,6 +777,70 @@ + + 5 + wxALL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Affects Lightgem and AI + + 0 + + + 0 + + 1 + LightInspectorAiSee + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + Whether the light affects the player's light gem and AI ability to see other things + + wxFILTER_NONE + wxDefaultValidator + + + + + + diff --git a/install/ui/lightinspector.xrc b/install/ui/lightinspector.xrc index ddd14c6c84..89ef588553 100644 --- a/install/ui/lightinspector.xrc +++ b/install/ui/lightinspector.xrc @@ -125,6 +125,16 @@ 0 + + + wxALL + 5 + + Whether the light affects the player's light gem and AI ability to see other things + + 0 + + diff --git a/radiant/ui/lightinspector/LightInspector.cpp b/radiant/ui/lightinspector/LightInspector.cpp index b519ef8068..73a2be0f56 100644 --- a/radiant/ui/lightinspector/LightInspector.cpp +++ b/radiant/ui/lightinspector/LightInspector.cpp @@ -19,6 +19,8 @@ #include #include "ui/common/ShaderChooser.h" // for static displayLightInfo() function +#include "util/ScopedBoolLock.h" +#include "gamelib.h" namespace ui { @@ -56,11 +58,12 @@ namespace } // Private constructor sets up dialog -LightInspector::LightInspector() -: wxutil::TransientWindow(_(LIGHTINSPECTOR_TITLE), GlobalMainFrame().getWxTopLevelWindow(), true), - _isProjected(false), - _texSelector(NULL), - _updateActive(false) +LightInspector::LightInspector() : + wxutil::TransientWindow(_(LIGHTINSPECTOR_TITLE), GlobalMainFrame().getWxTopLevelWindow(), true), + _isProjected(false), + _texSelector(nullptr), + _updateActive(false), + _supportsAiSee(game::current::getValue("/light/supportsAiSeeSpawnarg", false)) { loadNamedPanel(this, "LightInspectorMainPanel"); @@ -142,17 +145,23 @@ void LightInspector::setupLightShapeOptions() // Connect the options checkboxes void LightInspector::setupOptionsPanel() { - findNamedObject(this, "LightInspectorColour")->Connect( - wxEVT_COLOURPICKER_CHANGED, wxColourPickerEventHandler(LightInspector::_onColourChange), NULL, this); - - findNamedObject(this, "LightInspectorParallel")->Connect( - wxEVT_CHECKBOX, wxCommandEventHandler(LightInspector::_onOptionsToggle), NULL, this); - findNamedObject(this, "LightInspectorNoShadows")->Connect( - wxEVT_CHECKBOX, wxCommandEventHandler(LightInspector::_onOptionsToggle), NULL, this); - findNamedObject(this, "LightInspectorSkipSpecular")->Connect( - wxEVT_CHECKBOX, wxCommandEventHandler(LightInspector::_onOptionsToggle), NULL, this); - findNamedObject(this, "LightInspectorSkipDiffuse")->Connect( - wxEVT_CHECKBOX, wxCommandEventHandler(LightInspector::_onOptionsToggle), NULL, this); + findNamedObject(this, "LightInspectorColour")->Bind( + wxEVT_COLOURPICKER_CHANGED, &LightInspector::_onColourChange, this); + + findNamedObject(this, "LightInspectorParallel")->Bind(wxEVT_CHECKBOX, &LightInspector::_onOptionsToggle, this); + findNamedObject(this, "LightInspectorNoShadows")->Bind(wxEVT_CHECKBOX, &LightInspector::_onOptionsToggle, this); + findNamedObject(this, "LightInspectorSkipSpecular")->Bind(wxEVT_CHECKBOX, &LightInspector::_onOptionsToggle, this); + findNamedObject(this, "LightInspectorSkipDiffuse")->Bind(wxEVT_CHECKBOX, &LightInspector::_onOptionsToggle, this); + + if (_supportsAiSee) + { + findNamedObject(this, "LightInspectorAiSee")->Show(); + findNamedObject(this, "LightInspectorAiSee")->Bind(wxEVT_CHECKBOX, &LightInspector::_onOptionsToggle, this); + } + else + { + findNamedObject(this, "LightInspectorAiSee")->Hide(); + } } // Create the texture widgets @@ -313,7 +322,7 @@ void LightInspector::_onProjToggle(wxCommandEvent& ev) void LightInspector::getValuesFromEntity() { // Disable unwanted callbacks - _updateActive = true; + util::ScopedBoolLock updateLock(_updateActive); // Read values from the first entity in the list of lights (we have to pick // one, so might as well use the first). @@ -386,7 +395,10 @@ void LightInspector::getValuesFromEntity() findNamedObject(this, "LightInspectorSkipDiffuse")->SetValue(entity->getKeyValue("nodiffuse") == "1"); findNamedObject(this, "LightInspectorNoShadows")->SetValue(entity->getKeyValue("noshadows") == "1"); - _updateActive = false; + if (_supportsAiSee) + { + findNamedObject(this, "LightInspectorAiSee")->SetValue(entity->getKeyValue("ai_see") == "1"); + } } // Write to all entities @@ -472,6 +484,11 @@ void LightInspector::setValuesOnEntity(Entity* entity) setEntityValueIfDifferent(entity, "nospecular", findNamedObject(this, "LightInspectorSkipSpecular")->GetValue() ? "1" : "0"); setEntityValueIfDifferent(entity, "nodiffuse", findNamedObject(this, "LightInspectorSkipDiffuse")->GetValue() ? "1" : "0"); setEntityValueIfDifferent(entity, "noshadows", findNamedObject(this, "LightInspectorNoShadows")->GetValue() ? "1" : "0"); + + if (_supportsAiSee) + { + setEntityValueIfDifferent(entity, "ai_see", findNamedObject(this, "LightInspectorAiSee")->GetValue() ? "1" : "0"); + } } void LightInspector::_onOptionsToggle(wxCommandEvent& ev) diff --git a/radiant/ui/lightinspector/LightInspector.h b/radiant/ui/lightinspector/LightInspector.h index 453127f11c..ad941f489f 100644 --- a/radiant/ui/lightinspector/LightInspector.h +++ b/radiant/ui/lightinspector/LightInspector.h @@ -48,6 +48,8 @@ class LightInspector : // Disables callbacks if set to TRUE (during widget updates) bool _updateActive; + bool _supportsAiSee; + sigc::connection _selectionChanged; sigc::connection _undoHandler; sigc::connection _redoHandler;