VMF Mod Data: got rid of 'is_togglable' and 'is_mutator' methods

This commit is contained in:
bi 2018-06-21 09:40:02 +03:00
parent a172f72c0a
commit 13727c1adc
5 changed files with 7 additions and 13 deletions

View file

@ -141,7 +141,7 @@ vmf.check_pressed_keybinds = function()
local mod = get_mod(binding_info[1])
if binding_info[2] == "toggle_mod_state" and not mod:is_mutator() then
if binding_info[2] == "toggle_mod_state" and not mod:get_internal_data("is_mutator") then
vmf.mod_state_changed(mod:get_name(), not mod:is_enabled())

View file

@ -18,7 +18,7 @@ vmf.set_mod_state = function (mod, is_enabled, initial_call)
vmf.mod_disabled_event(mod, initial_call)
end
if not (initial_call or mod:is_mutator()) then
if not (initial_call or mod:get_internal_data("is_mutator")) then
if is_enabled then
_disabled_mods[mod:get_name()] = nil
else
@ -32,7 +32,7 @@ end
vmf.initialize_mod_state = function (mod)
local state
if mod:is_mutator() then
if mod:get_internal_data("is_mutator") then
-- if VMF was reloaded and mutator was activated
if vmf.is_mutator_enabled(mod:get_name()) then
state = true
@ -50,11 +50,11 @@ vmf.mod_state_changed = function (mod_name, is_enabled)
local mod = get_mod(mod_name)
if not mod:is_togglable() or is_enabled == mod:is_enabled() then
if not mod:get_internal_data("is_togglable") or is_enabled == mod:is_enabled() then
return
end
if mod:is_mutator() then
if mod:get_internal_data("is_mutator") then
vmf.set_mutator_state(mod, is_enabled, false)
else
vmf.set_mod_state(mod, is_enabled, false)

View file

@ -4324,7 +4324,7 @@ vmf.create_options = function (mod, widgets_definition)
new_widget_definition.readable_mod_name = mod:get_readable_name()
new_widget_definition.tooltip = mod:get_description()
new_widget_definition.default = true
new_widget_definition.is_mod_toggable = mod:is_togglable() and not mod:is_mutator()
new_widget_definition.is_mod_toggable = mod:get_internal_data("is_togglable") and not mod:get_internal_data("is_mutator")
if mod_collapsed_widgets then
new_widget_definition.is_widget_collapsed = mod_collapsed_widgets[mod:get_name()]

View file

@ -70,9 +70,3 @@ end
function VMFMod:is_enabled()
return self._data.is_enabled
end
function VMFMod:is_togglable()
return self._data.is_togglable
end
function VMFMod:is_mutator()
return self._data.is_mutator
end

View file

@ -79,7 +79,7 @@ function new_mod(mod_name, mod_resources)
end
-- Initialize mod state
if mod:is_togglable() then
if mod:get_internal_data("is_togglable") then
vmf.initialize_mod_state(mod)
end
end