From 17505f0864f0cb596009aef41e8f7406085642dd Mon Sep 17 00:00:00 2001 From: FireSiku Date: Wed, 6 Jun 2018 23:18:42 -0400 Subject: [PATCH] Fix line length errors across the entire project. Modules include: Commands, UIScaling, Core Functions, Keybindings, Network, Settings, Dump, Custom Menus, Custom Textures, CommandList, ChatActions, VMFOptions Extra: UIScaling: Fix _internals and remove single-letter vars --- .../mods/vmf/modules/core/commands.lua | 6 ++- .../mods/vmf/modules/core/core_functions.lua | 3 +- .../mods/vmf/modules/core/keybindings.lua | 20 ++++++-- vmf/scripts/mods/vmf/modules/core/network.lua | 15 ++++-- .../mods/vmf/modules/core/settings.lua | 8 ++-- .../mods/vmf/modules/debug/table_dump.lua | 5 +- .../mods/vmf/modules/gui/custom_menus.lua | 11 +++-- .../mods/vmf/modules/gui/custom_textures.lua | 41 +++++++++++------ .../mods/vmf/modules/gui/ui_scaling.lua | 25 +++++----- .../mods/vmf/modules/ui/chat/chat_actions.lua | 25 ++++++---- .../vmf/modules/ui/chat/commands_list_gui.lua | 46 +++++++++++++------ vmf/scripts/mods/vmf/modules/vmf_options.lua | 4 +- 12 files changed, 140 insertions(+), 69 deletions(-) diff --git a/vmf/scripts/mods/vmf/modules/core/commands.lua b/vmf/scripts/mods/vmf/modules/core/commands.lua index a22b4c7..0fb9667 100644 --- a/vmf/scripts/mods/vmf/modules/core/commands.lua +++ b/vmf/scripts/mods/vmf/modules/core/commands.lua @@ -31,7 +31,8 @@ VMFMod.command = function (self, command_name, command_description, command_func command_name = command_name:lower() if _commands[command_name] and _commands[command_name].mod ~= self then - self:error("(command): command name '%s' is already used by another mod '%s'", command_name, _commands[command_name].mod:get_name()) + self:error("(command): command name '%s' is already used by another mod '%s'", + command_name, _commands[command_name].mod:get_name()) return end @@ -123,7 +124,8 @@ vmf.get_commands_list = function(name_contains, exact_match) break end else - if string.sub(command_name, 1, string.len(name_contains)) == name_contains and command_entry.is_enabled and command_entry.mod:is_enabled() then + local command_match = ( string.sub(command_name, 1, string.len(name_contains)) == name_contains ) + if command_match and command_entry.is_enabled and command_entry.mod:is_enabled() then table.insert(commands_list, {name = command_name, description = command_entry.description}) end end diff --git a/vmf/scripts/mods/vmf/modules/core/core_functions.lua b/vmf/scripts/mods/vmf/modules/core/core_functions.lua index 834ce31..01906fe 100644 --- a/vmf/scripts/mods/vmf/modules/core/core_functions.lua +++ b/vmf/scripts/mods/vmf/modules/core/core_functions.lua @@ -112,7 +112,8 @@ vmf.check_wrong_argument_type = function(mod, vmf_function_name, argument_name, end end - mod:error("(%s): argument '%s' should have the '%s' type, not '%s'", vmf_function_name, argument_name, table.concat(allowed_types, "/"), argument_type) + mod:error("(%s): argument '%s' should have the '%s' type, not '%s'", + vmf_function_name, argument_name, table.concat(allowed_types, "/"), argument_type) return true end diff --git a/vmf/scripts/mods/vmf/modules/core/keybindings.lua b/vmf/scripts/mods/vmf/modules/core/keybindings.lua index d54600c..18ef0f2 100644 --- a/vmf/scripts/mods/vmf/modules/core/keybindings.lua +++ b/vmf/scripts/mods/vmf/modules/core/keybindings.lua @@ -9,10 +9,19 @@ VMFModsKeyMap = { xb1 = {} } --- ["mod_name"]["setting_name"] = {"action_name", {"primary_key", "special_key", "special_key", "special_key"}} (special_key - "ctrl"/"shift"/"alt") +-- ["mod_name"]["setting_name"] = { +-- "action_name", +-- {"primary_key", "special_key", "special_key", "special_key"} +-- } +-- Special Keys: "ctrl" / "shift" / "alt" local _raw_keybinds = {} --- ["primary_key"] = {{"mod_name", "action_name", ctrl_used(bool), alt_used(bool), shift_used(bool)}, {}, {}, ...} +-- ["primary_key"] = { +-- {"mod_name", "action_name", ctrl_used(bool), alt_used(bool), shift_used(bool)}, +-- {}, +-- {}, +-- ... +-- } local _optimized_keybinds = {} local _activated_pressed_key @@ -47,7 +56,12 @@ local function apply_keybinds() end _optimized_keybinds[primary_key] = _optimized_keybinds[primary_key] or {} - table.insert(_optimized_keybinds[primary_key], {mod_name, action_name, special_keys["ctrl"], special_keys["alt"], special_keys["shift"]}) + table.insert(_optimized_keybinds[primary_key], { + mod_name, action_name, + special_keys["ctrl"], + special_keys["alt"], + special_keys["shift"] + }) end end end diff --git a/vmf/scripts/mods/vmf/modules/core/network.lua b/vmf/scripts/mods/vmf/modules/core/network.lua index 4317b87..95bdadd 100644 --- a/vmf/scripts/mods/vmf/modules/core/network.lua +++ b/vmf/scripts/mods/vmf/modules/core/network.lua @@ -85,12 +85,16 @@ local function network_debug(rpc_type, action_type, peer_id, mod_name, rpc_name, if _network_debug then - local debug_message = nil + local debug_message if action_type == "local" then debug_message = "[NETWORK][LOCAL]" else - debug_message = "[NETWORK][" .. peer_id .. " (" .. tostring(Managers.player:player_from_peer_id(peer_id)) .. ")]" .. (action_type == "sent" and "<-" or "->") + local msg_direction = (action_type == "sent" and "<-" or "->") + local player_string = tostring(Managers.player:player_from_peer_id(peer_id)) + --NOTE (Siku): Multiple concatenation requires the creation of multiple strings, look into it. + --debug_message = string.format("[NETWORK][%s (%s)] %s", peer_id, player_string, msg_direction) + debug_message = "[NETWORK][" .. peer_id .. " (" .. player_string .. ")]" .. msg_direction end if rpc_type == "ping" then @@ -103,6 +107,7 @@ local function network_debug(rpc_type, action_type, peer_id, mod_name, rpc_name, elseif rpc_type == "data" then + --debug_message = string.format("%s[DATA][%s][%s]: ", debug_message, mod_name, rpc_name) debug_message = debug_message .. "[DATA][" .. mod_name .. "][" .. rpc_name .. "]: " if type(data) == "string" then @@ -217,7 +222,8 @@ end -- ##### Hooks ######################################################################################################## -- #################################################################################################################### -vmf:hook("ChatManager.rpc_chat_message", function(func, self, sender, channel_id, message_sender, message, localization_param, ...) +vmf:hook("ChatManager.rpc_chat_message", + function(func, self, sender, channel_id, message_sender, message, localization_param, ...) if channel_id == 1 then @@ -234,7 +240,8 @@ vmf:hook("ChatManager.rpc_chat_message", function(func, self, sender, channel_id send_rpc_vmf_pong(sender) - elseif channel_id == 4 then -- rpc_vmf_responce (@TODO: maybe I should protect it from sending by the player who's not in the game?) + elseif channel_id == 4 then -- rpc_vmf_responce + -- @TODO: maybe I should protect it from sending by the player who's not in the game? network_debug("pong", "received", sender) if _network_debug then diff --git a/vmf/scripts/mods/vmf/modules/core/settings.lua b/vmf/scripts/mods/vmf/modules/core/settings.lua index 136ea59..0c3428b 100644 --- a/vmf/scripts/mods/vmf/modules/core/settings.lua +++ b/vmf/scripts/mods/vmf/modules/core/settings.lua @@ -29,9 +29,11 @@ end -- #################################################################################################################### --[[ - * setting_name [string] : setting name, can contain any characters lua-string can - * setting_value [anything]: setting value, will be serialized to SJSON format, so you can save whole tables - * call_setting_changed_event [bool] : if 'true', when some setting will be changed, 'setting_changed' event will be called (if mod defined one) + * setting_name [string] : setting name, can contain any characters lua-string can + * setting_value [anything]: setting value, will be serialized to SJSON format, so you can save whole tables + + * call_setting_changed_event [bool]: + if 'true', when some setting will be changed, 'setting_changed' event will be called (if mod defined one) --]] VMFMod.set = function (self, setting_name, setting_value, call_setting_changed_event) diff --git a/vmf/scripts/mods/vmf/modules/debug/table_dump.lua b/vmf/scripts/mods/vmf/modules/debug/table_dump.lua index 149f040..5999d07 100644 --- a/vmf/scripts/mods/vmf/modules/debug/table_dump.lua +++ b/vmf/scripts/mods/vmf/modules/debug/table_dump.lua @@ -187,8 +187,9 @@ local function table_dump_to_file(dumped_table, dumped_table_name, max_depth) table_entry[key] = "[" .. value_type .. "]" else - - table_entry[key] = tostring(value):gsub('\\','\\\\'):gsub('\"','\\\"'):gsub('\t','\\t'):gsub('\n','\\n') .. " (" .. value_type .. ")" + + value = tostring(value):gsub('\\','\\\\'):gsub('\"','\\\"'):gsub('\t','\\t'):gsub('\n','\\n') + table_entry[key] = value .. " (" .. value_type .. ")" end end end diff --git a/vmf/scripts/mods/vmf/modules/gui/custom_menus.lua b/vmf/scripts/mods/vmf/modules/gui/custom_menus.lua index 5d5d06b..cdd069b 100644 --- a/vmf/scripts/mods/vmf/modules/gui/custom_menus.lua +++ b/vmf/scripts/mods/vmf/modules/gui/custom_menus.lua @@ -37,7 +37,8 @@ VMFMod.register_new_view = function (self, new_view_data) and not ingame_ui.menu_active and not ingame_ui.leave_game and not ingame_ui.return_to_title_screen - and not (ingame_ui.popup_join_lobby_handler and ingame_ui.popup_join_lobby_handler.visible) -- V2 doesn't have 'popup_join_lobby_handler' + -- V2 doesn't have 'popup_join_lobby_handler' + and not (ingame_ui.popup_join_lobby_handler and ingame_ui.popup_join_lobby_handler.visible) then ingame_ui:handle_transition(new_view_data.view_settings.hotkey_transition_name) end @@ -188,9 +189,13 @@ end local ingame_ui_exists, ingame_ui_return if VT1 then - ingame_ui_exists, ingame_ui_return = pcall(function () return Managers.player.network_manager.matchmaking_manager.matchmaking_ui.ingame_ui end) + ingame_ui_exists, ingame_ui_return = pcall(function() + return Managers.player.network_manager.matchmaking_manager.matchmaking_ui.ingame_ui + end) else - ingame_ui_exists, ingame_ui_return = pcall(function () return Managers.player.network_manager.matchmaking_manager._ingame_ui end) + ingame_ui_exists, ingame_ui_return = pcall(function() + return Managers.player.network_manager.matchmaking_manager._ingame_ui + end) end -- if VMF is reloaded mid-game diff --git a/vmf/scripts/mods/vmf/modules/gui/custom_textures.lua b/vmf/scripts/mods/vmf/modules/gui/custom_textures.lua index 067a71d..4946f9b 100644 --- a/vmf/scripts/mods/vmf/modules/gui/custom_textures.lua +++ b/vmf/scripts/mods/vmf/modules/gui/custom_textures.lua @@ -20,22 +20,26 @@ local function check_texture_availability(mod, texture_name) if texture_exists then if type(texture_settings) == "nil" then - mod:error("(custom texture/atlas): texture name '%s' is already used by Fatshark in 'none_atlas_textures'", texture_name) + mod:error("(custom texture/atlas): texture name '%s' is already used by Fatshark in 'none_atlas_textures'", + texture_name) else - mod:error("(custom texture/atlas): texture name '%s' is already used by Fatshark in atlas '%s'", texture_name, tostring(texture_settings.material_name)) + mod:error("(custom texture/atlas): texture name '%s' is already used by Fatshark in atlas '%s'", + texture_name, tostring(texture_settings.material_name)) end return false end if _custom_none_atlas_textures[texture_name] then - mod:error("(custom texture/atlas): texture name '%s' is already used by the mod '%s' as none atlas texture", texture_name, _custom_none_atlas_textures[texture_name]) + mod:error("(custom texture/atlas): texture name '%s' is already used by the mod '%s' as none atlas texture", + texture_name, _custom_none_atlas_textures[texture_name]) return false end if _custom_ui_atlas_settings[texture_name] then texture_settings = _custom_ui_atlas_settings[texture_name] - mod:error("(custom texture/atlas): texture name '%s' is already used by the mod '%s' in atlas '%s'", texture_name, texture_settings.mod_name, tostring(texture_settings.material_name)) + mod:error("(custom texture/atlas): texture name '%s' is already used by the mod '%s' in atlas '%s'", + texture_name, texture_settings.mod_name, tostring(texture_settings.material_name)) return false end @@ -54,20 +58,28 @@ vmf.custom_textures = function (mod, ...) _custom_none_atlas_textures[texture_name] = mod:get_name() end else - mod:error("(custom_textures): all arguments should have the string type, but the argument #%s is %s", i, type(texture_name)) + mod:error("(custom_textures): all arguments should have the string type, but the argument #%s is %s", + i, type(texture_name)) end end end -vmf.custom_atlas = function (mod, material_settings_file, material_name, masked_material_name, point_sample_material_name, - masked_point_sample_material_name, saturated_material_name) +vmf.custom_atlas = function (mod, material_settings_file, material_name, masked_material_name, + point_sample_material_name, masked_point_sample_material_name, + saturated_material_name) - if vmf.check_wrong_argument_type(mod, "custom_atlas", "material_settings_file", material_settings_file, "string") or - vmf.check_wrong_argument_type(mod, "custom_atlas", "material_name", material_name, "string", "nil") or - vmf.check_wrong_argument_type(mod, "custom_atlas", "masked_material_name", masked_material_name, "string", "nil") or - vmf.check_wrong_argument_type(mod, "custom_atlas", "point_sample_material_name", point_sample_material_name, "string", "nil") or - vmf.check_wrong_argument_type(mod, "custom_atlas", "masked_point_sample_material_name", masked_point_sample_material_name, "string", "nil") or - vmf.check_wrong_argument_type(mod, "custom_atlas", "saturated_material_name", saturated_material_name, "string", "nil") then + if vmf.check_wrong_argument_type(mod, "custom_atlas", "material_settings_file", + material_settings_file, "string") or + vmf.check_wrong_argument_type(mod, "custom_atlas", "material_name", + material_name, "string", "nil") or + vmf.check_wrong_argument_type(mod, "custom_atlas", "masked_material_name", + masked_material_name, "string", "nil") or + vmf.check_wrong_argument_type(mod, "custom_atlas", "point_sample_material_name", + point_sample_material_name, "string", "nil") or + vmf.check_wrong_argument_type(mod, "custom_atlas", "masked_point_sample_material_name", + masked_point_sample_material_name, "string", "nil") or + vmf.check_wrong_argument_type(mod, "custom_atlas", "saturated_material_name", + saturated_material_name, "string", "nil") then return end @@ -122,7 +134,8 @@ vmf.inject_materials = function (mod, ui_renderer_creator, ...) end else - mod:error("(inject_materials): all arguments should have the string type, but the argument #%s is %s", i + 1, type(new_injected_material)) + mod:error("(inject_materials): all arguments should have the string type, but the argument #%s is %s", + i + 1, type(new_injected_material) ) end end diff --git a/vmf/scripts/mods/vmf/modules/gui/ui_scaling.lua b/vmf/scripts/mods/vmf/modules/gui/ui_scaling.lua index 725170f..3895b2b 100644 --- a/vmf/scripts/mods/vmf/modules/gui/ui_scaling.lua +++ b/vmf/scripts/mods/vmf/modules/gui/ui_scaling.lua @@ -1,12 +1,8 @@ --- If enabled, scale UI for resolutions greater than 1080p when necessary. Reports to a global when active, so that existing scaling can be disabled. +-- If enabled, scale UI for resolutions greater than 1080p when necessary. +-- Reports to a global when active, so that existing scaling can be disabled. local vmf = get_mod("VMF") -local _UI_RESOLUTION = UIResolution -local _UI_RESOLUTION_WIDTH_FRAGMENTS = UIResolutionWidthFragments -local _UI_RESOLUTION_HEIGHT_FRAGMENTS = UIResolutionHeightFragments -local _MATH_MIN = math.min - -local _UI_SCALING_ENABLED +local _ui_scaling_enabled -- #################################################################################################################### -- ##### Hooks ######################################################################################################## @@ -14,16 +10,17 @@ local _UI_SCALING_ENABLED vmf:hook("UIResolutionScale", function (func, ...) - local w, h = _UI_RESOLUTION() + local width, height = UIResolution() - if (w > _UI_RESOLUTION_WIDTH_FRAGMENTS() and h > _UI_RESOLUTION_HEIGHT_FRAGMENTS() and _UI_SCALING_ENABLED) then + if (width > UIResolutionWidthFragments() and height > UIResolutionHeightFragments() and _ui_scaling_enabled) then local max_scaling_factor = 4 - local width_scale = _MATH_MIN(w / _UI_RESOLUTION_WIDTH_FRAGMENTS(), max_scaling_factor) -- Changed to allow scaling up to quadruple the original max scale (1 -> 4) - local height_scale = _MATH_MIN(h / _UI_RESOLUTION_HEIGHT_FRAGMENTS(), max_scaling_factor) -- Changed to allow scaling up to quadruple the original max scale (1 -> 4) + -- Changed to allow scaling up to quadruple the original max scale (1 -> 4) + local width_scale = math.min(width / UIResolutionWidthFragments(), max_scaling_factor) + local height_scale = math.min(height / UIResolutionHeightFragments(), max_scaling_factor) - return _MATH_MIN(width_scale, height_scale) + return math.min(width_scale, height_scale) else return func(...) end @@ -34,8 +31,8 @@ end) -- #################################################################################################################### vmf.load_ui_scaling_settings = function () - _UI_SCALING_ENABLED = vmf:get("ui_scaling") - if _UI_SCALING_ENABLED then + _ui_scaling_enabled = vmf:get("ui_scaling") + if _ui_scaling_enabled then RESOLUTION_LOOKUP.ui_scaling = true else RESOLUTION_LOOKUP.ui_scaling = false diff --git a/vmf/scripts/mods/vmf/modules/ui/chat/chat_actions.lua b/vmf/scripts/mods/vmf/modules/ui/chat/chat_actions.lua index 5123e33..8031f87 100644 --- a/vmf/scripts/mods/vmf/modules/ui/chat/chat_actions.lua +++ b/vmf/scripts/mods/vmf/modules/ui/chat/chat_actions.lua @@ -117,7 +117,8 @@ vmf:hook("ChatGui._update_input", function(func, self, input_service, menu_input local old_chat_message = self.chat_message - local chat_focused, chat_closed, chat_close_time = func(self, input_service, menu_input_service, dt, no_unblock, chat_enabled) + local chat_focused, chat_closed, chat_close_time = func(self, input_service, menu_input_service, + dt, no_unblock, chat_enabled) if chat_closed then set_chat_message(self, "") @@ -143,7 +144,8 @@ vmf:hook("ChatGui._update_input", function(func, self, input_service, menu_input for _, stroke in ipairs(Keyboard.keystrokes()) do if stroke == Keyboard.TAB then tab_pressed = true - -- game considers some "ctrl + [something]" combinations as arrow buttons, so I have to check for ctrl not pressed + -- game considers some "ctrl + [something]" combinations as arrow buttons, + -- so I have to check for ctrl not pressed elseif stroke == Keyboard.UP and Keyboard.button(Keyboard.button_index("left ctrl")) == 0 then arrow_up_pressed = true elseif stroke == Keyboard.DOWN and Keyboard.button(Keyboard.button_index("left ctrl")) == 0 then @@ -155,7 +157,8 @@ vmf:hook("ChatGui._update_input", function(func, self, input_service, menu_input if _chat_history_enabled then -- reverse result of native chat history in VT2 - if not VT1 and input_service.get(input_service, "chat_next_old_message") or input_service.get(input_service, "chat_previous_old_message") then + if not VT1 and input_service.get(input_service, "chat_next_old_message") or + input_service.get(input_service, "chat_previous_old_message") then set_chat_message(self, old_chat_message) end @@ -185,7 +188,8 @@ vmf:hook("ChatGui._update_input", function(func, self, input_service, menu_input -- ctrl + v if Keyboard.pressed(Keyboard.button_index("v")) and Keyboard.button(Keyboard.button_index("left ctrl")) == 1 then - local new_chat_message = self.chat_message .. tostring(Clipboard.get()):gsub(string.char(0x0D), "") -- remove CR characters + -- remove CR characters + local new_chat_message = self.chat_message .. tostring(Clipboard.get()):gsub(string.char(0x0D), "") set_chat_message(self, new_chat_message) end @@ -197,10 +201,12 @@ vmf:hook("ChatGui._update_input", function(func, self, input_service, menu_input -- entered chat message starts with "/" if string.sub(self.chat_message, 1, 1) == "/" then - if not string.find(self.chat_message, " ") -- if there's no space after '/part_of_command_name' - and tab_pressed -- if TAB was pressed - and (string.len(self.chat_message) + 1) == self.chat_index -- if TAB was pressed with caret at the end of the string - and (#_commands_list > 0) then -- if there are any commands matching entered '/part_of_command_name' + -- if there's no space after '/part_of_command_name' and if TAB was pressed + if not string.find(self.chat_message, " ") and tab_pressed and + -- if TAB was pressed with caret at the end of the string + (string.len(self.chat_message) + 1) == self.chat_index and + -- if there are any commands matching entered '/part_of_command_name + (#_commands_list > 0) then _command_index = _command_index % #_commands_list + 1 @@ -254,7 +260,8 @@ vmf.load_chat_history_settings = function(clean_chat_history_) _chat_history_save = vmf:get("chat_history_save") _chat_history_max = vmf:get("chat_history_buffer_size") _chat_history_remove_dups_last = vmf:get("chat_history_remove_dups") - _chat_history_remove_dups_all = vmf:get("chat_history_remove_dups") and (vmf:get("chat_history_remove_dups_mode") == "all") + _chat_history_remove_dups_all = vmf:get("chat_history_remove_dups") and + (vmf:get("chat_history_remove_dups_mode") == "all") _chat_history_save_commands_only = vmf:get("chat_history_commands_only") if _chat_history_enabled then diff --git a/vmf/scripts/mods/vmf/modules/ui/chat/commands_list_gui.lua b/vmf/scripts/mods/vmf/modules/ui/chat/commands_list_gui.lua index 02ef10f..0fcab2a 100644 --- a/vmf/scripts/mods/vmf/modules/ui/chat/commands_list_gui.lua +++ b/vmf/scripts/mods/vmf/modules/ui/chat/commands_list_gui.lua @@ -4,12 +4,16 @@ local _gui if VT1 then -- @TODO: I don't think I need the 2nd texture - _gui = World.create_screen_gui(Managers.world:world("top_ingame_view"), "immediate", "material", "materials/fonts/gw_fonts", "material", "materials/ui/ui_1080p_ingame_common") + _gui = World.create_screen_gui(Managers.world:world("top_ingame_view"), "immediate", + "material", "materials/fonts/gw_fonts", + "material", "materials/ui/ui_1080p_ingame_common") else - _gui = World.create_screen_gui(Managers.world:world("top_ingame_view"), "material", "materials/fonts/gw_fonts", "immediate") + _gui = World.create_screen_gui(Managers.world:world("top_ingame_view"), + "material", "materials/fonts/gw_fonts", "immediate") end --- DebugScreen.gui = World.create_screen_gui(world, "material", "materials/fonts/gw_fonts", "material", "materials/menu/debug_screen", "immediate") +-- DebugScreen.gui = World.create_screen_gui(world, "material", "materials/fonts/gw_fonts", +-- "material", "materials/menu/debug_screen", "immediate") local _FONT_TYPE = "hell_shark_arial" @@ -45,7 +49,8 @@ local function word_wrap(text, font_material, font_size, max_width) local reuse_global_table = true local scale = RESOLUTION_LOOKUP.scale - return Gui.word_wrap(_gui, text, font_material, font_size, max_width * scale, whitespace, soft_dividers, return_dividers, reuse_global_table) + return Gui.word_wrap(_gui, text, font_material, font_size, max_width * scale, whitespace, + soft_dividers, return_dividers, reuse_global_table) end local function draw(commands_list, selected_command_index) @@ -80,7 +85,12 @@ local function draw(commands_list, selected_command_index) for i, command in ipairs(displayed_commands) do -- draw "/command_name" text - local string_position = Vector3((_OFFSET_X + _STRING_X_MARGIN) * scale, (_OFFSET_Y - _STRING_HEIGHT * (i + selected_strings_number - 1) + _STRING_Y_OFFSET) * scale, _OFFSET_Z + 2) + local scaled_offet_x = (_OFFSET_X + _STRING_X_MARGIN) * scale + + local selected_string_height = _STRING_HEIGHT * (i + selected_strings_number - 1) + _STRING_Y_OFFSET + local scaled_offset_y = (_OFFSET_Y - selected_string_height) * scale + + local string_position = Vector3(scaled_offet_x, scaled_offset_y, _OFFSET_Z + 2) Gui.text(_gui, command.name, font_material, font_size, font_name, string_position, Color(255, 100, 255, 100)) local command_text_strings = word_wrap(command.full_text, font_material, font_size, _WIDTH - _STRING_X_MARGIN * 2) @@ -91,11 +101,14 @@ local function draw(commands_list, selected_command_index) selected_strings_number = #command_text_strings else local multistring_indicator_width = get_text_width(_MULTISTRING_INDICATOR_TEXT, font_material, font_size) - command_text_strings = word_wrap(command.full_text, font_material, font_size, _WIDTH - _STRING_X_MARGIN * 2 - (multistring_indicator_width / scale)) + local command_text_width = _WIDTH - _STRING_X_MARGIN * 2 - (multistring_indicator_width / scale) + command_text_strings = word_wrap(command.full_text, font_material, font_size, command_text_width) -- draw that [...] thing - local multistring_indicator_position = Vector3((_OFFSET_X + _WIDTH) * scale - multistring_indicator_width, string_position.y, string_position.z) - Gui.text(_gui, _MULTISTRING_INDICATOR_TEXT, font_material, font_size, font_name, multistring_indicator_position, Color(255, 100, 100, 100)) + local multistring_offset_x = (_OFFSET_X + _WIDTH) * scale - multistring_indicator_width + local multistring_indicator_position = Vector3(multistring_offset_x, string_position.y, string_position.z) + Gui.text(_gui, _MULTISTRING_INDICATOR_TEXT, font_material, font_size, font_name, + multistring_indicator_position, Color(255, 100, 100, 100)) end first_description_string = string.sub(command_text_strings[1], #command.name + 2) else @@ -104,14 +117,18 @@ local function draw(commands_list, selected_command_index) -- draw command description text (1st string) local first_description_string_width = get_text_width(command.name, font_material, font_size) - local first_description_string_position = Vector3(string_position.x + first_description_string_width, string_position.y, string_position.z) - Gui.text(_gui, first_description_string, font_material, font_size, font_name, first_description_string_position, Color(255, 255, 255, 255)) + + local first_description_pos_x = string_position.x + first_description_string_width + local first_description_string_position = Vector3(first_description_pos_x, string_position.y, string_position.z) + Gui.text(_gui, first_description_string, font_material, font_size, font_name, + first_description_string_position, Color(255, 255, 255, 255)) -- draw command description text (2+ strings) if command.selected and multistring then for j = 2, selected_strings_number do string_position.y = string_position.y - _STRING_HEIGHT * scale - Gui.text(_gui, command_text_strings[j], font_material, font_size, font_name, string_position, Color(255, 255, 255, 255)) + Gui.text(_gui, command_text_strings[j], font_material, font_size, font_name, + string_position, Color(255, 255, 255, 255)) end end end @@ -143,8 +160,11 @@ local function draw(commands_list, selected_command_index) total_number_indicator = selected_command_index .. "/" .. total_number_indicator end local total_number_indicator_width = get_text_width(total_number_indicator, font_material, font_size) - local total_number_indicator_position = Vector3((_WIDTH) * scale - total_number_indicator_width, (_OFFSET_Y + _STRING_Y_OFFSET) * scale, _OFFSET_Z + 2) - Gui.text(_gui, total_number_indicator, font_material, font_size, font_name, total_number_indicator_position, Color(255, 100, 100, 100)) + local total_number_indicator_x = (_WIDTH) * scale - total_number_indicator_width + local total_number_indicator_y = (_OFFSET_Y + _STRING_Y_OFFSET) * scale + local total_number_indicator_position = Vector3(total_number_indicator_x, total_number_indicator_y, _OFFSET_Z + 2) + Gui.text(_gui, total_number_indicator, font_material, font_size, font_name, + total_number_indicator_position, Color(255, 100, 100, 100)) end --end) end diff --git a/vmf/scripts/mods/vmf/modules/vmf_options.lua b/vmf/scripts/mods/vmf/modules/vmf_options.lua index 34f1245..10cd09d 100644 --- a/vmf/scripts/mods/vmf/modules/vmf_options.lua +++ b/vmf/scripts/mods/vmf/modules/vmf_options.lua @@ -257,7 +257,9 @@ vmf.on_setting_changed = function (setting_name) or setting_name == "chat_history_remove_dups_mode" or setting_name == "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_name == "chat_history_enable" or + setting_name == "chat_history_buffer_size" or + setting_name == "chat_history_commands_only") end end