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
This commit is contained in:
parent
38af31d854
commit
17505f0864
12 changed files with 140 additions and 69 deletions
|
@ -31,7 +31,8 @@ VMFMod.command = function (self, command_name, command_description, command_func
|
||||||
command_name = command_name:lower()
|
command_name = command_name:lower()
|
||||||
|
|
||||||
if _commands[command_name] and _commands[command_name].mod ~= self then
|
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
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -123,7 +124,8 @@ vmf.get_commands_list = function(name_contains, exact_match)
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
else
|
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})
|
table.insert(commands_list, {name = command_name, description = command_entry.description})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -112,7 +112,8 @@ vmf.check_wrong_argument_type = function(mod, vmf_function_name, argument_name,
|
||||||
end
|
end
|
||||||
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
|
return true
|
||||||
end
|
end
|
||||||
|
|
|
@ -9,10 +9,19 @@ VMFModsKeyMap = {
|
||||||
xb1 = {}
|
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 = {}
|
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 _optimized_keybinds = {}
|
||||||
|
|
||||||
local _activated_pressed_key
|
local _activated_pressed_key
|
||||||
|
@ -47,7 +56,12 @@ local function apply_keybinds()
|
||||||
end
|
end
|
||||||
|
|
||||||
_optimized_keybinds[primary_key] = _optimized_keybinds[primary_key] or {}
|
_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
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -85,12 +85,16 @@ local function network_debug(rpc_type, action_type, peer_id, mod_name, rpc_name,
|
||||||
|
|
||||||
if _network_debug then
|
if _network_debug then
|
||||||
|
|
||||||
local debug_message = nil
|
local debug_message
|
||||||
|
|
||||||
if action_type == "local" then
|
if action_type == "local" then
|
||||||
debug_message = "[NETWORK][LOCAL]"
|
debug_message = "[NETWORK][LOCAL]"
|
||||||
else
|
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
|
end
|
||||||
|
|
||||||
if rpc_type == "ping" then
|
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
|
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 .. "]: "
|
debug_message = debug_message .. "[DATA][" .. mod_name .. "][" .. rpc_name .. "]: "
|
||||||
|
|
||||||
if type(data) == "string" then
|
if type(data) == "string" then
|
||||||
|
@ -217,7 +222,8 @@ end
|
||||||
-- ##### Hooks ########################################################################################################
|
-- ##### 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
|
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)
|
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)
|
network_debug("pong", "received", sender)
|
||||||
if _network_debug then
|
if _network_debug then
|
||||||
|
|
|
@ -29,9 +29,11 @@ end
|
||||||
-- ####################################################################################################################
|
-- ####################################################################################################################
|
||||||
|
|
||||||
--[[
|
--[[
|
||||||
* setting_name [string] : setting name, can contain any characters lua-string can
|
* 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
|
* 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)
|
|
||||||
|
* 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)
|
VMFMod.set = function (self, setting_name, setting_value, call_setting_changed_event)
|
||||||
|
|
||||||
|
|
|
@ -187,8 +187,9 @@ local function table_dump_to_file(dumped_table, dumped_table_name, max_depth)
|
||||||
|
|
||||||
table_entry[key] = "[" .. value_type .. "]"
|
table_entry[key] = "[" .. value_type .. "]"
|
||||||
else
|
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
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -37,7 +37,8 @@ VMFMod.register_new_view = function (self, new_view_data)
|
||||||
and not ingame_ui.menu_active
|
and not ingame_ui.menu_active
|
||||||
and not ingame_ui.leave_game
|
and not ingame_ui.leave_game
|
||||||
and not ingame_ui.return_to_title_screen
|
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
|
then
|
||||||
ingame_ui:handle_transition(new_view_data.view_settings.hotkey_transition_name)
|
ingame_ui:handle_transition(new_view_data.view_settings.hotkey_transition_name)
|
||||||
end
|
end
|
||||||
|
@ -188,9 +189,13 @@ end
|
||||||
|
|
||||||
local ingame_ui_exists, ingame_ui_return
|
local ingame_ui_exists, ingame_ui_return
|
||||||
if VT1 then
|
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
|
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
|
end
|
||||||
|
|
||||||
-- if VMF is reloaded mid-game
|
-- if VMF is reloaded mid-game
|
||||||
|
|
|
@ -20,22 +20,26 @@ local function check_texture_availability(mod, texture_name)
|
||||||
if texture_exists then
|
if texture_exists then
|
||||||
|
|
||||||
if type(texture_settings) == "nil" 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
|
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
|
end
|
||||||
|
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
if _custom_none_atlas_textures[texture_name] then
|
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
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
if _custom_ui_atlas_settings[texture_name] then
|
if _custom_ui_atlas_settings[texture_name] then
|
||||||
texture_settings = _custom_ui_atlas_settings[texture_name]
|
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
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -54,20 +58,28 @@ vmf.custom_textures = function (mod, ...)
|
||||||
_custom_none_atlas_textures[texture_name] = mod:get_name()
|
_custom_none_atlas_textures[texture_name] = mod:get_name()
|
||||||
end
|
end
|
||||||
else
|
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
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
vmf.custom_atlas = function (mod, material_settings_file, material_name, masked_material_name, point_sample_material_name,
|
vmf.custom_atlas = function (mod, material_settings_file, material_name, masked_material_name,
|
||||||
masked_point_sample_material_name, saturated_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
|
if vmf.check_wrong_argument_type(mod, "custom_atlas", "material_settings_file",
|
||||||
vmf.check_wrong_argument_type(mod, "custom_atlas", "material_name", material_name, "string", "nil") or
|
material_settings_file, "string") 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", "material_name",
|
||||||
vmf.check_wrong_argument_type(mod, "custom_atlas", "point_sample_material_name", point_sample_material_name, "string", "nil") or
|
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", "masked_material_name",
|
||||||
vmf.check_wrong_argument_type(mod, "custom_atlas", "saturated_material_name", saturated_material_name, "string", "nil") then
|
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
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -122,7 +134,8 @@ vmf.inject_materials = function (mod, ui_renderer_creator, ...)
|
||||||
end
|
end
|
||||||
|
|
||||||
else
|
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
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -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 vmf = get_mod("VMF")
|
||||||
|
|
||||||
local _UI_RESOLUTION = UIResolution
|
local _ui_scaling_enabled
|
||||||
local _UI_RESOLUTION_WIDTH_FRAGMENTS = UIResolutionWidthFragments
|
|
||||||
local _UI_RESOLUTION_HEIGHT_FRAGMENTS = UIResolutionHeightFragments
|
|
||||||
local _MATH_MIN = math.min
|
|
||||||
|
|
||||||
local _UI_SCALING_ENABLED
|
|
||||||
|
|
||||||
-- ####################################################################################################################
|
-- ####################################################################################################################
|
||||||
-- ##### Hooks ########################################################################################################
|
-- ##### Hooks ########################################################################################################
|
||||||
|
@ -14,16 +10,17 @@ local _UI_SCALING_ENABLED
|
||||||
|
|
||||||
vmf:hook("UIResolutionScale", function (func, ...)
|
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 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)
|
-- 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)
|
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
|
else
|
||||||
return func(...)
|
return func(...)
|
||||||
end
|
end
|
||||||
|
@ -34,8 +31,8 @@ end)
|
||||||
-- ####################################################################################################################
|
-- ####################################################################################################################
|
||||||
|
|
||||||
vmf.load_ui_scaling_settings = function ()
|
vmf.load_ui_scaling_settings = function ()
|
||||||
_UI_SCALING_ENABLED = vmf:get("ui_scaling")
|
_ui_scaling_enabled = vmf:get("ui_scaling")
|
||||||
if _UI_SCALING_ENABLED then
|
if _ui_scaling_enabled then
|
||||||
RESOLUTION_LOOKUP.ui_scaling = true
|
RESOLUTION_LOOKUP.ui_scaling = true
|
||||||
else
|
else
|
||||||
RESOLUTION_LOOKUP.ui_scaling = false
|
RESOLUTION_LOOKUP.ui_scaling = false
|
||||||
|
|
|
@ -117,7 +117,8 @@ vmf:hook("ChatGui._update_input", function(func, self, input_service, menu_input
|
||||||
|
|
||||||
local old_chat_message = self.chat_message
|
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
|
if chat_closed then
|
||||||
set_chat_message(self, "")
|
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
|
for _, stroke in ipairs(Keyboard.keystrokes()) do
|
||||||
if stroke == Keyboard.TAB then
|
if stroke == Keyboard.TAB then
|
||||||
tab_pressed = true
|
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
|
elseif stroke == Keyboard.UP and Keyboard.button(Keyboard.button_index("left ctrl")) == 0 then
|
||||||
arrow_up_pressed = true
|
arrow_up_pressed = true
|
||||||
elseif stroke == Keyboard.DOWN and Keyboard.button(Keyboard.button_index("left ctrl")) == 0 then
|
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
|
if _chat_history_enabled then
|
||||||
|
|
||||||
-- reverse result of native chat history in VT2
|
-- 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)
|
set_chat_message(self, old_chat_message)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -185,7 +188,8 @@ vmf:hook("ChatGui._update_input", function(func, self, input_service, menu_input
|
||||||
|
|
||||||
-- ctrl + v
|
-- ctrl + v
|
||||||
if Keyboard.pressed(Keyboard.button_index("v")) and Keyboard.button(Keyboard.button_index("left ctrl")) == 1 then
|
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)
|
set_chat_message(self, new_chat_message)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -197,10 +201,12 @@ vmf:hook("ChatGui._update_input", function(func, self, input_service, menu_input
|
||||||
-- entered chat message starts with "/"
|
-- entered chat message starts with "/"
|
||||||
if string.sub(self.chat_message, 1, 1) == "/" then
|
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'
|
-- if there's no space after '/part_of_command_name' and if TAB was pressed
|
||||||
and tab_pressed -- if TAB was pressed
|
if not string.find(self.chat_message, " ") and tab_pressed and
|
||||||
and (string.len(self.chat_message) + 1) == self.chat_index -- if TAB was pressed with caret at the end of the string
|
-- 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'
|
(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
|
_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_save = vmf:get("chat_history_save")
|
||||||
_chat_history_max = vmf:get("chat_history_buffer_size")
|
_chat_history_max = vmf:get("chat_history_buffer_size")
|
||||||
_chat_history_remove_dups_last = vmf:get("chat_history_remove_dups")
|
_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")
|
_chat_history_save_commands_only = vmf:get("chat_history_commands_only")
|
||||||
|
|
||||||
if _chat_history_enabled then
|
if _chat_history_enabled then
|
||||||
|
|
|
@ -4,12 +4,16 @@ local _gui
|
||||||
|
|
||||||
if VT1 then
|
if VT1 then
|
||||||
-- @TODO: I don't think I need the 2nd texture
|
-- @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
|
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
|
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"
|
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 reuse_global_table = true
|
||||||
local scale = RESOLUTION_LOOKUP.scale
|
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
|
end
|
||||||
|
|
||||||
local function draw(commands_list, selected_command_index)
|
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
|
for i, command in ipairs(displayed_commands) do
|
||||||
|
|
||||||
-- draw "/command_name" text
|
-- 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))
|
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)
|
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
|
selected_strings_number = #command_text_strings
|
||||||
else
|
else
|
||||||
local multistring_indicator_width = get_text_width(_MULTISTRING_INDICATOR_TEXT, font_material, font_size)
|
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
|
-- draw that [...] thing
|
||||||
local multistring_indicator_position = Vector3((_OFFSET_X + _WIDTH) * scale - multistring_indicator_width, string_position.y, string_position.z)
|
local multistring_offset_x = (_OFFSET_X + _WIDTH) * scale - multistring_indicator_width
|
||||||
Gui.text(_gui, _MULTISTRING_INDICATOR_TEXT, font_material, font_size, font_name, multistring_indicator_position, Color(255, 100, 100, 100))
|
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
|
end
|
||||||
first_description_string = string.sub(command_text_strings[1], #command.name + 2)
|
first_description_string = string.sub(command_text_strings[1], #command.name + 2)
|
||||||
else
|
else
|
||||||
|
@ -104,14 +117,18 @@ local function draw(commands_list, selected_command_index)
|
||||||
|
|
||||||
-- draw command description text (1st string)
|
-- draw command description text (1st string)
|
||||||
local first_description_string_width = get_text_width(command.name, font_material, font_size)
|
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)
|
-- draw command description text (2+ strings)
|
||||||
if command.selected and multistring then
|
if command.selected and multistring then
|
||||||
for j = 2, selected_strings_number do
|
for j = 2, selected_strings_number do
|
||||||
string_position.y = string_position.y - _STRING_HEIGHT * scale
|
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
|
end
|
||||||
end
|
end
|
||||||
|
@ -143,8 +160,11 @@ local function draw(commands_list, selected_command_index)
|
||||||
total_number_indicator = selected_command_index .. "/" .. total_number_indicator
|
total_number_indicator = selected_command_index .. "/" .. total_number_indicator
|
||||||
end
|
end
|
||||||
local total_number_indicator_width = get_text_width(total_number_indicator, font_material, font_size)
|
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)
|
local total_number_indicator_x = (_WIDTH) * scale - total_number_indicator_width
|
||||||
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_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)
|
--end)
|
||||||
end
|
end
|
||||||
|
|
|
@ -257,7 +257,9 @@ vmf.on_setting_changed = function (setting_name)
|
||||||
or setting_name == "chat_history_remove_dups_mode"
|
or setting_name == "chat_history_remove_dups_mode"
|
||||||
or setting_name == "chat_history_commands_only" then
|
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
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue