Skip to content

Commit

Permalink
feature(VEEditor): Add reset to default button
Browse files Browse the repository at this point in the history
  • Loading branch information
IllustrisJack committed Jan 23, 2022
1 parent 28cfcf6 commit 6a35f52
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 8 deletions.
1 change: 0 additions & 1 deletion ext/Client/EditorLayer.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

return [[
{
"CharacterLighting":{
Expand Down
51 changes: 45 additions & 6 deletions ext/Client/VEEditor.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
VEEditor = class 'VEEditor'

---@type Logger
local m_Logger = Logger("Editor", false)
local m_Logger = Logger("Editor", true)


function VEEditor:__init()
Expand Down Expand Up @@ -38,6 +38,7 @@ function VEEditor:RegisterVars()
}

self.m_CineState = nil
self.m_DefaultState = nil
self.m_CineVE = nil
self.m_CineEntityGUID = nil
self.m_CinePriority = 10000010
Expand All @@ -49,6 +50,7 @@ function VEEditor:RegisterVars()
self.VALUE_MIN = -25000
self.VALUE_MAX = 25000
self.m_CineStateReloaded = false
self.m_ResetConfirmed = false
end

function VEEditor:RegisterEvents()
Expand All @@ -68,6 +70,16 @@ function VEEditor:OnPresetsLoaded()
else
self:HideUI()
end

-- Get CineState & Default State
if self.m_CineState == nil then
self.m_CineState = self:GetVisualEnvironmentState(self.m_CinePriority)
m_Logger:Write('CineState Name: ' .. self.m_CineState.entityName)
m_Logger:Write('CineState ID: ' .. self.m_CineState.stateId)
m_Logger:Write('CineState Priority: ' .. self.m_CineState.priority)
self.m_CineState.excluded = false
VisualEnvironmentManager:SetDirty(true)
end
end

function VEEditor:OnVEGuidReceived(p_Guid)
Expand Down Expand Up @@ -112,11 +124,12 @@ function VEEditor:GetVisualEnvironmentState(...)
local states = VisualEnvironmentManager:GetStates()
--Loop through all states
for _, state in pairs(states) do
if state.entityName ~= "EffectEntity" then --sets main ve to 1
state.priority = 1
end
m_Logger:Write(state.priority .. ' | ' .. state.visibility .. ' | ' .. state.entityName)

m_Logger:Write(state.priority .. ' | ' .. state.visibility)
if string.find(state.entityName, 'VE') then --entityName e.g. Levels/XP1_001/Lighting/VE_XP_001
self.m_DefaultState = state
m_Logger:Write("Found Default Entity")
end

for i,priority in pairs(args) do
if state.priority == priority then
Expand Down Expand Up @@ -1194,9 +1207,35 @@ function VEEditor:CreateGUI()
self.m_PresetName = p_PresetName
end)

DebugGUI:Button('Print Preset', function(value)
DebugGUI:Button('Print Preset', function(p_Value)
print(self:ParseJSON())
end)

DebugGUI:Button('Reset to Default', function(p_Value)
if self.m_ResetConfirmed then
m_Logger:Write('CineState Name: ' .. self.m_CineState.entityName)
m_Logger:Write('CineState ID: ' .. self.m_CineState.stateId)
m_Logger:Write('CineState Priority: ' .. self.m_CineState.priority)

for l_Index, l_Class in pairs(self.m_SupportedClasses) do
m_Logger:Write("Class: " .. l_Class)
local s_LoweredClass = firstToLower(l_Class)
if self.m_DefaultState[s_LoweredClass] ~= nil and s_LoweredClass ~= 'enlighten' then
self.m_CineState[s_LoweredClass] = self.m_DefaultState[s_LoweredClass]:Clone()
elseif self.m_DefaultState[s_LoweredClass] == nil and s_LoweredClass == "characterLighting" then
self.m_CineState[s_LoweredClass].characterLightEnable = false
elseif self.m_DefaultState[s_LoweredClass] == nil and self.m_CineState[s_LoweredClass] ~= nil then
self.m_CineState[s_LoweredClass].enable = false
end
end
VisualEnvironmentManager:SetDirty(true)
end
end)

-- Reset Button
DebugGUI:Checkbox('Confirm Reset to Default', false, function(p_Value)
self.m_ResetConfirmed = p_Value
end)
end)
end

Expand Down
2 changes: 1 addition & 1 deletion mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"Authors": ["IllustrisJack", "Lesley", "GreatApo", "Breaknix"],
"Description": "Tool to edit & save visual environments",
"URL": "https://github.com/BF3RM/VEEditor",
"Version": "0.1.4",
"Version": "0.2.0",
"HasWebUI": true,
"HasVeniceEXT": true,
"Tags": ["ve-editor"],
Expand Down

0 comments on commit 6a35f52

Please sign in to comment.