diff --git a/vmf/scripts/mods/vmf/modules/core/events.lua b/vmf/scripts/mods/vmf/modules/core/events.lua index 5b5ae84..0ba7c2b 100644 --- a/vmf/scripts/mods/vmf/modules/core/events.lua +++ b/vmf/scripts/mods/vmf/modules/core/events.lua @@ -70,17 +70,17 @@ end --[[ - EVENT: on_setting_changed (setting_name) + EVENT: on_setting_changed (setting_id) Is called on `mod:set` call with the 3rd parameter set to 'true'. All the mod's settings changes done under the VMF's hood call this event. - * setting_name [string]: name of the setting that was changed + * setting_id [string]: name of the setting that was changed --]] -function vmf.mod_setting_changed_event(mod, setting_name) +function vmf.mod_setting_changed_event(mod, setting_id) local event_name = "on_setting_changed" - run_event(mod, event_name, setting_name) + run_event(mod, event_name, setting_id) end diff --git a/vmf/scripts/mods/vmf/modules/core/keybindings.lua b/vmf/scripts/mods/vmf/modules/core/keybindings.lua index cbafbc8..b3c6ccc 100644 --- a/vmf/scripts/mods/vmf/modules/core/keybindings.lua +++ b/vmf/scripts/mods/vmf/modules/core/keybindings.lua @@ -9,7 +9,7 @@ VMFModsKeyMap = { xb1 = {} } --- ["mod_name"]["setting_name"] = { +-- ["mod_name"]["setting_id"] = { -- "action_name", -- {"primary_key", "special_key", "special_key", "special_key"} -- } @@ -71,25 +71,25 @@ end -- #################################################################################################################### -- use it directly only for dedugging purposes, otherwise use keybind widget --- setting_name [string] - keybind identifyer for certain mod +-- setting_id [string] - keybind identifyer for certain mod -- action_name [string] - name of some mod.function which will be called when keybind is pressed -- keys [table] = {"primary_key", "2nd_key" [optional], "3rd_key" [optional], "4th_key" [optional]} -- 2, 3, 4 keys can contain words "ctrl", "alt", "shift" (lowercase) -VMFMod.keybind = function (self, setting_name, action_name, keys) +VMFMod.keybind = function (self, setting_id, action_name, keys) if keys[1] then local mod_keybinds = _raw_keybinds[self:get_name()] or {} - mod_keybinds[setting_name] = {action_name, keys} + mod_keybinds[setting_id] = {action_name, keys} _raw_keybinds[self:get_name()] = mod_keybinds else local mod_keybinds = _raw_keybinds[self:get_name()] - if mod_keybinds and mod_keybinds[setting_name] then - mod_keybinds[setting_name] = nil + if mod_keybinds and mod_keybinds[setting_id] then + mod_keybinds[setting_id] = nil end end diff --git a/vmf/scripts/mods/vmf/modules/core/settings.lua b/vmf/scripts/mods/vmf/modules/core/settings.lua index 9691aa9..cc131ed 100644 --- a/vmf/scripts/mods/vmf/modules/core/settings.lua +++ b/vmf/scripts/mods/vmf/modules/core/settings.lua @@ -39,11 +39,11 @@ end --[[ Sets mod's setting to a given value. If setting is used in some option widget, make sure given value matches one of the predefined values in this widget. - * setting_name [string] : setting name (can contain any characters lua-string can) + * setting_id [string] : setting's identifier * setting_value [anything]: setting value (can be any SJSON serializable format) * notify_mod [bool] : if 'true', calls 'mod.on_setting_changed' event --]] -function VMFMod:set(setting_name, setting_value, notify_mod) +function VMFMod:set(setting_id, setting_value, notify_mod) local mod_name = self:get_name() if not _mods_settings[mod_name] then @@ -51,12 +51,12 @@ function VMFMod:set(setting_name, setting_value, notify_mod) end local mod_settings = _mods_settings[mod_name] - mod_settings[setting_name] = type(setting_value) == "table" and table.clone(setting_value) or setting_value + mod_settings[setting_id] = type(setting_value) == "table" and table.clone(setting_value) or setting_value _there_are_unsaved_changes = true if notify_mod then - vmf.mod_setting_changed_event(self, setting_name) + vmf.mod_setting_changed_event(self, setting_id) end end @@ -64,12 +64,12 @@ end --[[ Returns a mod's setting. Don't call this method for table settings very frequently, because tables are cloned on every call. - * setting_name [string]: setting name (can contain any characters lua-string can) + * setting_id [string]: setting's identifier --]] -function VMFMod:get(setting_name) +function VMFMod:get(setting_id) local mod_name = self:get_name() local mod_settings = _mods_settings[mod_name] - local setting_value = mod_settings and mod_settings[setting_name] + local setting_value = mod_settings and mod_settings[setting_id] return type(setting_value) == "table" and table.clone(setting_value) or setting_value end diff --git a/vmf/scripts/mods/vmf/modules/ui/options/vmf_options_view.lua b/vmf/scripts/mods/vmf/modules/ui/options/vmf_options_view.lua index 9de43d6..3967434 100644 --- a/vmf/scripts/mods/vmf/modules/ui/options/vmf_options_view.lua +++ b/vmf/scripts/mods/vmf/modules/ui/options/vmf_options_view.lua @@ -1262,13 +1262,13 @@ local function create_checkbox_widget(widget_definition, scenegraph_id) end local mod_name = content.mod_name - local setting_name = content.setting_name + local setting_id = content.setting_id local old_value = content.is_checkbox_checked local new_value = not old_value content.is_checkbox_checked = new_value - content.callback_setting_changed(mod_name, setting_name, old_value, new_value) + content.callback_setting_changed(mod_name, setting_id, old_value, new_value) end end @@ -1334,7 +1334,7 @@ local function create_checkbox_widget(widget_definition, scenegraph_id) tooltip_text = widget_definition.tooltip, mod_name = widget_definition.mod_name, - setting_name = widget_definition.setting_id, + setting_id = widget_definition.setting_id, widget_type = widget_definition.type, default_value = widget_definition.default_value, parent_widget_number = widget_definition.parent_index, @@ -1549,7 +1549,7 @@ local function create_group_widget(widget_definition, scenegraph_id) mod_name = widget_definition.mod_name, - setting_name = widget_definition.setting_id, + setting_id = widget_definition.setting_id, widget_type = widget_definition.type, parent_widget_number = widget_definition.parent_index, show_widget_condition = show_widget_condition @@ -1841,10 +1841,10 @@ local function create_dropdown_widget(widget_definition, scenegraph_id, scenegra end local mod_name = content.mod_name - local setting_name = content.setting_name + local setting_id = content.setting_id local new_value = content.options_values[content.current_option_number] - content.callback_setting_changed(mod_name, setting_name, old_value, new_value) + content.callback_setting_changed(mod_name, setting_id, old_value, new_value) end end @@ -1911,7 +1911,7 @@ local function create_dropdown_widget(widget_definition, scenegraph_id, scenegra tooltip_text = widget_definition.tooltip, mod_name = widget_definition.mod_name, - setting_name = widget_definition.setting_id, + setting_id = widget_definition.setting_id, widget_type = widget_definition.type, options_texts = options_texts, @@ -2298,10 +2298,10 @@ local function create_numeric_widget(widget_definition, scenegraph_id, scenegrap if content.callback_draw_numeric_menu(content) then local mod_name = content.mod_name - local setting_name = content.setting_name + local setting_id = content.setting_id local new_value = content.current_value - content.callback_setting_changed(mod_name, setting_name, old_value, new_value) + content.callback_setting_changed(mod_name, setting_id, old_value, new_value) end end @@ -2369,7 +2369,7 @@ local function create_numeric_widget(widget_definition, scenegraph_id, scenegrap right_bracket = "]", mod_name = widget_definition.mod_name, - setting_name = widget_definition.setting_id, + setting_id = widget_definition.setting_id, widget_type = widget_definition.type, current_value_text = "whatever", @@ -2588,7 +2588,7 @@ local function create_keybind_widget(widget_definition, scenegraph_id) if content.is_setting_keybind then if content.callback_setting_keybind(content) then - content.callback_setting_changed(content.mod_name, content.setting_name, nil, content.keys) + content.callback_setting_changed(content.mod_name, content.setting_id, nil, content.keys) return end end @@ -2651,7 +2651,7 @@ local function create_keybind_widget(widget_definition, scenegraph_id) tooltip_text = widget_definition.tooltip, mod_name = widget_definition.mod_name, - setting_name = widget_definition.setting_id, + setting_id = widget_definition.setting_id, widget_type = widget_definition.type, action = widget_definition.action_name, @@ -3044,10 +3044,10 @@ end -- #################################################################################################################### -VMFOptionsView.callback_setting_changed = function (self, mod_name, setting_name, old_value, new_value) +VMFOptionsView.callback_setting_changed = function (self, mod_name, setting_id, old_value, new_value) if self.is_setting_changes_applied_immidiately and old_value ~= new_value then - get_mod(mod_name):set(setting_name, new_value, true) + get_mod(mod_name):set(setting_id, new_value, true) end WwiseWorld.trigger_event(self.wwise_world, "Play_hud_select") @@ -3189,10 +3189,10 @@ end VMFOptionsView.callback_hide_sub_widgets = function (self, widget_content) local mod_name = widget_content.mod_name - local setting_name = widget_content.setting_name + local setting_id = widget_content.setting_id local is_widget_collapsed = widget_content.is_widget_collapsed - local widget_number = not setting_name and 1 -- if (setting_name == nil) -> it's header -> #1 + local widget_number = not setting_id and 1 -- if (setting_id == nil) -> it's header -> #1 local are_there_visible_sub_widgets = false @@ -3209,7 +3209,7 @@ VMFOptionsView.callback_hide_sub_widgets = function (self, widget_content) are_there_visible_sub_widgets = are_there_visible_sub_widgets or widget.content.is_widget_visible end else - if widget.content.setting_name == setting_name then + if widget.content.setting_id == setting_id then widget_number = i end end @@ -3229,7 +3229,7 @@ VMFOptionsView.callback_hide_sub_widgets = function (self, widget_content) widget_content.is_widget_collapsed = is_widget_collapsed_new - if setting_name then + if setting_id then local all_collapsed_widgets = vmf:get("options_menu_collapsed_widgets") @@ -3238,12 +3238,12 @@ VMFOptionsView.callback_hide_sub_widgets = function (self, widget_content) if widget_content.is_widget_collapsed then mod_collapsed_widgets = mod_collapsed_widgets or {} - mod_collapsed_widgets[setting_name] = true + mod_collapsed_widgets[setting_id] = true all_collapsed_widgets[mod_name] = mod_collapsed_widgets else if mod_collapsed_widgets then - mod_collapsed_widgets[setting_name] = nil + mod_collapsed_widgets[setting_id] = nil local is_collapsed_widgets_list_empty = true @@ -3369,7 +3369,7 @@ VMFOptionsView.callback_setting_keybind = function (self, widget_content) widget_content.first_pressed_button_type = nil if widget_content.action then - get_mod(widget_content.mod_name):keybind(widget_content.setting_name, widget_content.action, widget_content.keys) + get_mod(widget_content.mod_name):keybind(widget_content.setting_id, widget_content.action, widget_content.keys) end self:callback_change_setting_keybind_state(widget_content) @@ -3384,7 +3384,7 @@ VMFOptionsView.callback_setting_keybind = function (self, widget_content) widget_content.keybind_text = build_keybind_string(widget_content.keys) if widget_content.action then - get_mod(widget_content.mod_name):keybind(widget_content.setting_name, widget_content.action, widget_content.keys) + get_mod(widget_content.mod_name):keybind(widget_content.setting_id, widget_content.action, widget_content.keys) end self:callback_change_setting_keybind_state(widget_content) @@ -3805,7 +3805,7 @@ VMFOptionsView.update_picked_option_for_settings_list_widgets = function (self) if widget_type == "checkbox" then - loaded_setting_value = get_mod(widget_content.mod_name):get(widget_content.setting_name) + loaded_setting_value = get_mod(widget_content.mod_name):get(widget_content.setting_id) if type(loaded_setting_value) == "boolean" then widget_content.is_checkbox_checked = loaded_setting_value @@ -3815,12 +3815,12 @@ VMFOptionsView.update_picked_option_for_settings_list_widgets = function (self) --end widget_content.is_checkbox_checked = widget_content.default_value - get_mod(widget_content.mod_name):set(widget_content.setting_name, widget_content.default_value) + get_mod(widget_content.mod_name):set(widget_content.setting_id, widget_content.default_value) end elseif widget_type == "dropdown" then - loaded_setting_value = get_mod(widget_content.mod_name):get(widget_content.setting_name) + loaded_setting_value = get_mod(widget_content.mod_name):get(widget_content.setting_id) local setting_not_found = true for i, option_value in ipairs(widget_content.options_values) do @@ -3846,7 +3846,7 @@ VMFOptionsView.update_picked_option_for_settings_list_widgets = function (self) widget_content.current_option_number = i widget_content.current_option_text = widget_content.options_texts[i] widget_content.current_shown_widgets = widget_content.options_shown_widgets[i] - get_mod(widget_content.mod_name):set(widget_content.setting_name, widget_content.default_value) + get_mod(widget_content.mod_name):set(widget_content.setting_id, widget_content.default_value) end end end @@ -3857,7 +3857,7 @@ VMFOptionsView.update_picked_option_for_settings_list_widgets = function (self) elseif widget_type == "keybind" then - loaded_setting_value = get_mod(widget_content.mod_name):get(widget_content.setting_name) + loaded_setting_value = get_mod(widget_content.mod_name):get(widget_content.setting_id) if type(loaded_setting_value) == "table" then widget_content.keys = loaded_setting_value @@ -3870,7 +3870,7 @@ VMFOptionsView.update_picked_option_for_settings_list_widgets = function (self) elseif widget_type == "numeric" then - loaded_setting_value = get_mod(widget_content.mod_name):get(widget_content.setting_name) + loaded_setting_value = get_mod(widget_content.mod_name):get(widget_content.setting_id) if type(loaded_setting_value) == "number" then @@ -3920,7 +3920,7 @@ VMFOptionsView.update_settings_list_widgets_visibility = function (self, mod_nam -- Usually it had to throw an error by this point, but now it's another part of compatibility else widget.content.is_widget_visible = parent_widget.content.current_shown_widgets[i] and parent_widget.content.is_widget_visible and not parent_widget.content.is_widget_collapsed - --get_mod(widget.content.mod_name):error("(vmf_options_view): the dropdown widget in the options menu has sub_widgets, but some of its sub_widgets doesn't have 'show_widget_condition' (%s)" , widget.content.setting_name) + --get_mod(widget.content.mod_name):error("(vmf_options_view): the dropdown widget in the options menu has sub_widgets, but some of its sub_widgets doesn't have 'show_widget_condition' (%s)" , widget.content.setting_id) end -- if 'group' else diff --git a/vmf/scripts/mods/vmf/modules/vmf_options.lua b/vmf/scripts/mods/vmf/modules/vmf_options.lua index 8e3cdb8..5498391 100644 --- a/vmf/scripts/mods/vmf/modules/vmf_options.lua +++ b/vmf/scripts/mods/vmf/modules/vmf_options.lua @@ -166,54 +166,54 @@ vmf_mod_data.options = { -- ##### VMF internal functions and variables ######################################################################### -- #################################################################################################################### -vmf.on_setting_changed = function (setting_name) +vmf.on_setting_changed = function (setting_id) - if setting_name == "vmf_options_scrolling_speed" then + if setting_id == "vmf_options_scrolling_speed" then vmf.load_vmf_options_view_settings() - elseif setting_name == "developer_mode" then + elseif setting_id == "developer_mode" then vmf.load_developer_mode_settings() vmf.load_network_settings() vmf.load_custom_textures_settings() vmf.load_dev_console_settings() - elseif setting_name == "show_developer_console" then + elseif setting_id == "show_developer_console" then vmf.load_dev_console_settings() - elseif setting_name == "show_network_debug_info" then + elseif setting_id == "show_network_debug_info" then vmf.load_network_settings() - elseif setting_name == "log_ui_renderers_info" then + elseif setting_id == "log_ui_renderers_info" then vmf.load_custom_textures_settings() - elseif setting_name == "ui_scaling" then + elseif setting_id == "ui_scaling" then vmf.load_ui_scaling_settings() - elseif setting_name == "logging_mode" - or setting_name == "output_mode_echo" - or setting_name == "output_mode_error" - or setting_name == "output_mode_warning" - or setting_name == "output_mode_info" - or setting_name == "output_mode_debug" then + elseif setting_id == "logging_mode" + or setting_id == "output_mode_echo" + or setting_id == "output_mode_error" + or setting_id == "output_mode_warning" + or setting_id == "output_mode_info" + or setting_id == "output_mode_debug" then vmf.load_logging_settings() - elseif setting_name == "chat_history_enable" - or setting_name == "chat_history_save" - or setting_name == "chat_history_buffer_size" - or setting_name == "chat_history_remove_dups" - or setting_name == "chat_history_remove_dups_mode" - or setting_name == "chat_history_commands_only" then + elseif setting_id == "chat_history_enable" + or setting_id == "chat_history_save" + or setting_id == "chat_history_buffer_size" + or setting_id == "chat_history_remove_dups" + or setting_id == "chat_history_remove_dups_mode" + or setting_id == "chat_history_commands_only" then - vmf.load_chat_history_settings(setting_name == "chat_history_enable" or - setting_name == "chat_history_buffer_size" or - setting_name == "chat_history_commands_only") + vmf.load_chat_history_settings(setting_id == "chat_history_enable" or + setting_id == "chat_history_buffer_size" or + setting_id == "chat_history_commands_only") end end