Rename all VMF references to DMF

This commit is contained in:
Aussiemon 2023-01-06 03:21:52 -07:00
parent 8ffe6471ab
commit efc10fcb63
41 changed files with 727 additions and 727 deletions

View file

@ -1,5 +1,5 @@
return { return {
run = function() run = function()
return Mods.file.dofile("dmf/scripts/mods/vmf/vmf_loader") return Mods.file.dofile("dmf/scripts/mods/dmf/dmf_loader")
end end
} }

View file

@ -4,17 +4,17 @@ return {
es = "Configuración de mods", es = "Configuración de mods",
ru = "Настройки модов", ru = "Настройки модов",
}, },
open_vmf_options = { open_dmf_options = {
en = "Open Options Menu", en = "Open Options Menu",
es = "Abrir el menu de configuración", es = "Abrir el menu de configuración",
ru = "Открыть меню настроек", ru = "Открыть меню настроек",
}, },
open_vmf_options_description = { open_dmf_options_description = {
en = "Keybind for opening and closing mods options menu.", en = "Keybind for opening and closing mods options menu.",
es = "Atajo para abrir/cerrar el menu de configuración de mods.", es = "Atajo para abrir/cerrar el menu de configuración de mods.",
ru = "Клавиша / сочетание клавиш для открытия и закрытия меню настроек модов.", ru = "Клавиша / сочетание клавиш для открытия и закрытия меню настроек модов.",
}, },
vmf_options_scrolling_speed = { dmf_options_scrolling_speed = {
en = "Options Menu Scrolling Speed", en = "Options Menu Scrolling Speed",
es = "Velocidad de desplazamiento en el menu", es = "Velocidad de desplazamiento en el menu",
ru = "Скорость прокрутки меню", ru = "Скорость прокрутки меню",
@ -38,9 +38,9 @@ return {
ru = "Режим разработчика", ru = "Режим разработчика",
}, },
developer_mode_description = { developer_mode_description = {
en = "Allows you to reload VMF and mods (CTRL+SHIFT+R), gives you access to some debug features.", en = "Allows you to reload DMF and mods (CTRL+SHIFT+R), gives you access to some debug features.",
es = "Permite recargar los mods (CTRL+SHIFT+R) y configurar herramientas de depuración.", es = "Permite recargar los mods (CTRL+SHIFT+R) y configurar herramientas de depuración.",
ru = "Позволяет перезагружать VMF и моды (CTRL+SHIFT+R), даёт доступ к инструментам отладки.", ru = "Позволяет перезагружать DMF и моды (CTRL+SHIFT+R), даёт доступ к инструментам отладки.",
}, },
show_developer_console = { show_developer_console = {
en = "Show Developer Console", en = "Show Developer Console",
@ -63,11 +63,11 @@ return {
ru = "Логирование сетевых вызовов", ru = "Логирование сетевых вызовов",
}, },
show_network_debug_info_description = { show_network_debug_info_description = {
en = "Log all the VMF network calls and all the data transfered with them.\n\n" .. en = "Log all the DMF network calls and all the data transfered with them.\n\n" ..
"The method 'info' is used for the logging.", "The method 'info' is used for the logging.",
es = "Escribe en el registro todas las llamadas de red (RPCs) que se ejecuten a través de VMF.\n\n" .. es = "Escribe en el registro todas las llamadas de red (RPCs) que se ejecuten a través de DMF.\n\n" ..
"Esta información se registra en el nivel 'info'.", "Esta información se registra en el nivel 'info'.",
ru = "Логирование всех сетевых вызовов VMF и передаваемых с ними данных.\n\n" .. ru = "Логирование всех сетевых вызовов DMF и передаваемых с ними данных.\n\n" ..
"Для логирования используется метод 'info'.", "Для логирования используется метод 'info'.",
}, },
log_ui_renderers_info = { log_ui_renderers_info = {
@ -177,9 +177,9 @@ return {
ru = "Сохранять историю ввода между сеансами игры", ru = "Сохранять историю ввода между сеансами игры",
}, },
chat_history_save_description = { chat_history_save_description = {
en = "Your chat input history will be saved even after reloading your game (or just VMF).", en = "Your chat input history will be saved even after reloading your game (or just DMF).",
es = "El texto que introduzcas en el chat se guardara incluso al recargar el juego (o solo VMF)", es = "El texto que introduzcas en el chat se guardara incluso al recargar el juego (o solo DMF)",
ru = "Когда игрок выключает игру (или перезагружает VMF), VMF cохраняет историю ввода в файл настроек, чтобы загрузить её при следующем запуске игры.", ru = "Когда игрок выключает игру (или перезагружает DMF), DMF cохраняет историю ввода в файл настроек, чтобы загрузить её при следующем запуске игры.",
}, },
chat_history_buffer_size = { chat_history_buffer_size = {
en = "Input History Buffer Size", en = "Input History Buffer Size",

View file

@ -0,0 +1,112 @@
local dmf
-- Global variable indicating which version of the game is currently running
VT1 = false
-- Native mod object used by Fatshark mod manager
local dmf_mod_object = {}
-- Global method to load a file through iowith a return
local mod_dofile = Mods.file.dofile
-- #####################################################################################################################
-- ##### Initialization ################################################################################################
-- #####################################################################################################################
function dmf_mod_object:init()
mod_dofile("dmf/scripts/mods/dmf/modules/dmf_mod_data")
mod_dofile("dmf/scripts/mods/dmf/modules/dmf_mod_manager")
--mod_dofile("dmf/scripts/mods/dmf/modules/dmf_dummy")
mod_dofile("dmf/scripts/mods/dmf/modules/dmf_package_manager")
mod_dofile("dmf/scripts/mods/dmf/modules/core/safe_calls")
mod_dofile("dmf/scripts/mods/dmf/modules/core/events")
mod_dofile("dmf/scripts/mods/dmf/modules/core/settings")
mod_dofile("dmf/scripts/mods/dmf/modules/core/logging")
mod_dofile("dmf/scripts/mods/dmf/modules/core/misc")
mod_dofile("dmf/scripts/mods/dmf/modules/core/persistent_tables")
mod_dofile("dmf/scripts/mods/dmf/modules/debug/dev_console")
mod_dofile("dmf/scripts/mods/dmf/modules/debug/table_dump")
mod_dofile("dmf/scripts/mods/dmf/modules/core/hooks")
mod_dofile("dmf/scripts/mods/dmf/modules/core/require")
mod_dofile("dmf/scripts/mods/dmf/modules/core/toggling")
mod_dofile("dmf/scripts/mods/dmf/modules/core/keybindings")
mod_dofile("dmf/scripts/mods/dmf/modules/core/chat")
mod_dofile("dmf/scripts/mods/dmf/modules/core/localization")
mod_dofile("dmf/scripts/mods/dmf/modules/core/options")
mod_dofile("dmf/scripts/mods/dmf/modules/core/network")
mod_dofile("dmf/scripts/mods/dmf/modules/core/commands")
mod_dofile("dmf/scripts/mods/dmf/modules/gui/custom_textures")
mod_dofile("dmf/scripts/mods/dmf/modules/gui/custom_views")
mod_dofile("dmf/scripts/mods/dmf/modules/ui/chat/chat_actions")
mod_dofile("dmf/scripts/mods/dmf/modules/ui/options/mod_options")
mod_dofile("dmf/scripts/mods/dmf/modules/dmf_options")
mod_dofile("dmf/scripts/mods/dmf/modules/core/mutators/mutators_manager")
dmf = get_mod("DMF")
dmf.delayed_chat_messages_hook()
dmf:hook(ModManager, "destroy", function(func, ...)
dmf.mods_unload_event(true)
func(...)
end)
end
-- #####################################################################################################################
-- ##### Events ########################################################################################################
-- #####################################################################################################################
function dmf_mod_object:update(dt)
dmf.update_package_manager()
dmf.mods_update_event(dt)
dmf.check_keybinds()
dmf.execute_queued_chat_command()
if not dmf.all_mods_were_loaded and Managers.mod._state == "done" then
dmf.generate_keybinds()
dmf.initialize_dmf_options_view()
dmf.create_network_dictionary()
dmf.ping_dmf_users()
dmf.all_mods_loaded_event()
dmf.all_mods_were_loaded = true
end
end
function dmf_mod_object:on_unload()
print("DMF:ON_UNLOAD()")
dmf.save_chat_history()
dmf.save_unsaved_settings_to_file()
dmf.destroy_command_gui()
end
function dmf_mod_object:on_reload()
print("DMF:ON_RELOAD()")
dmf.mods_unload_event(false)
dmf.remove_custom_views()
dmf.unload_all_resource_packages()
dmf.hooks_unload()
dmf.reset_guis()
dmf.destroy_command_gui()
end
function dmf_mod_object:on_game_state_changed(status, state)
print("DMF:ON_GAME_STATE_CHANGED(), status: " .. tostring(status) .. ", state: " .. tostring(state))
dmf.mods_game_state_changed_event(status, state)
dmf.save_unsaved_settings_to_file()
dmf.apply_delayed_hooks(status, state)
dmf.destroy_command_gui()
if status == "enter" and state == "StateIngame" then
dmf.create_keybinds_input_service()
end
end
-- #####################################################################################################################
-- ##### Return ########################################################################################################
-- #####################################################################################################################
return dmf_mod_object

View file

@ -1,4 +1,4 @@
local vmf = get_mod("VMF") local dmf = get_mod("DMF")
-- ##################################################################################################################### -- #####################################################################################################################
-- ##### Local functions ############################################################################################### -- ##### Local functions ###############################################################################################
@ -17,7 +17,7 @@ local function broadcast_message(message, channel_tag)
end end
-- ##################################################################################################################### -- #####################################################################################################################
-- ##### VMFMod ######################################################################################################## -- ##### DMFMod ########################################################################################################
-- ##################################################################################################################### -- #####################################################################################################################
--[[ --[[
@ -25,7 +25,7 @@ end
* message [string]: message to broadcast * message [string]: message to broadcast
* channel_tag [string]: tag of target chat channel * channel_tag [string]: tag of target chat channel
--]] --]]
function VMFMod:chat_broadcast(message, channel_tag) function DMFMod:chat_broadcast(message, channel_tag)
broadcast_message(message, channel_tag) broadcast_message(message, channel_tag)
end end
@ -34,7 +34,7 @@ end
* peer_id [peer_id]: peer_id of the player who will recieve the message (can't be host's peer_id) * peer_id [peer_id]: peer_id of the player who will recieve the message (can't be host's peer_id)
* message [string] : message to send * message [string] : message to send
--]] --]]
function VMFMod:chat_whisper(peer_id, message) function DMFMod:chat_whisper(peer_id, message)
-- @TODO: Rewrite for Darktide -- @TODO: Rewrite for Darktide
vmf:notify("Chat whisper is not yet implemented!") dmf:notify("Chat whisper is not yet implemented!")
end end

View file

@ -1,9 +1,9 @@
local vmf = get_mod("VMF") local dmf = get_mod("DMF")
local _commands = {} local _commands = {}
-- ##################################################################################################################### -- #####################################################################################################################
-- ##### VMFMod ######################################################################################################## -- ##### DMFMod ########################################################################################################
-- ##################################################################################################################### -- #####################################################################################################################
--[[ --[[
@ -12,10 +12,10 @@ local _commands = {}
* command_description [string] : (optional) command's decription; can be multiline * command_description [string] : (optional) command's decription; can be multiline
* command_function [function]: function, that will be executed, when chat command is activated; supports arguments * command_function [function]: function, that will be executed, when chat command is activated; supports arguments
--]] --]]
function VMFMod:command(command_name, command_description, command_function) function DMFMod:command(command_name, command_description, command_function)
if vmf.check_wrong_argument_type(self, "command", "command_name", command_name, "string") or if dmf.check_wrong_argument_type(self, "command", "command_name", command_name, "string") or
vmf.check_wrong_argument_type(self, "command", "command_description", command_description, "string", "nil") or dmf.check_wrong_argument_type(self, "command", "command_description", command_description, "string", "nil") or
vmf.check_wrong_argument_type(self, "command", "command_function", command_function, "function") dmf.check_wrong_argument_type(self, "command", "command_function", command_function, "function")
then then
return return
end end
@ -47,8 +47,8 @@ end
Removes registered chat command. Removes registered chat command.
* command_name [string]: command's name * command_name [string]: command's name
--]] --]]
function VMFMod:command_remove(command_name) function DMFMod:command_remove(command_name)
if vmf.check_wrong_argument_type(self, "command_remove", "command_name", command_name, "string") then if dmf.check_wrong_argument_type(self, "command_remove", "command_name", command_name, "string") then
return return
end end
@ -60,8 +60,8 @@ end
Disables registered chat command so it can be enabled later. Disables registered chat command so it can be enabled later.
* command_name [string]: command's name * command_name [string]: command's name
--]] --]]
function VMFMod:command_disable(command_name) function DMFMod:command_disable(command_name)
if vmf.check_wrong_argument_type(self, "command_disable", "command_name", command_name, "string") then if dmf.check_wrong_argument_type(self, "command_disable", "command_name", command_name, "string") then
return return
end end
@ -75,8 +75,8 @@ end
Enables disabled chat command. Enables disabled chat command.
* command_name [string]: command's name * command_name [string]: command's name
--]] --]]
function VMFMod:command_enable(command_name) function DMFMod:command_enable(command_name)
if vmf.check_wrong_argument_type(self, "command_enable", "command_name", command_name, "string") then if dmf.check_wrong_argument_type(self, "command_enable", "command_name", command_name, "string") then
return return
end end
@ -89,7 +89,7 @@ end
--[[ --[[
Removes all registered chat commands for the mod. Removes all registered chat commands for the mod.
--]] --]]
function VMFMod:remove_all_commands() function DMFMod:remove_all_commands()
for command_name, command_data in pairs(_commands) do for command_name, command_data in pairs(_commands) do
if command_data.mod == self then if command_data.mod == self then
_commands[command_name] = nil _commands[command_name] = nil
@ -101,7 +101,7 @@ end
--[[ --[[
Disables all registered chat commands for the mod. Disables all registered chat commands for the mod.
--]] --]]
function VMFMod:disable_all_commands() function DMFMod:disable_all_commands()
for _, command_data in pairs(_commands) do for _, command_data in pairs(_commands) do
if command_data.mod == self then if command_data.mod == self then
command_data.is_enabled = false command_data.is_enabled = false
@ -113,7 +113,7 @@ end
--[[ --[[
Enables all disabled chat commands for the mod. Enables all disabled chat commands for the mod.
--]] --]]
function VMFMod:enable_all_commands() function DMFMod:enable_all_commands()
for _, command_data in pairs(_commands) do for _, command_data in pairs(_commands) do
if command_data.mod == self then if command_data.mod == self then
command_data.is_enabled = true command_data.is_enabled = true
@ -122,13 +122,13 @@ function VMFMod:enable_all_commands()
end end
-- ##################################################################################################################### -- #####################################################################################################################
-- ##### VMF internal functions and variables ########################################################################## -- ##### DMF internal functions and variables ##########################################################################
-- ##################################################################################################################### -- #####################################################################################################################
-- Returns a table with command data entries whose name contains 'name_contains' string. If `exact_match` is set -- Returns a table with command data entries whose name contains 'name_contains' string. If `exact_match` is set
-- to 'true', it will return a table with only one command, whose name fully matches 'name_contains' string. Returns -- to 'true', it will return a table with only one command, whose name fully matches 'name_contains' string. Returns
-- empty table if nothing is found. -- empty table if nothing is found.
function vmf.get_commands_list(name_contains, exact_match) function dmf.get_commands_list(name_contains, exact_match)
name_contains = name_contains:lower() name_contains = name_contains:lower()
local commands_list = {} local commands_list = {}
for command_name, command_data in pairs(_commands) do for command_name, command_data in pairs(_commands) do
@ -150,12 +150,12 @@ end
-- Safely executes function bound to a command with a set name -- Safely executes function bound to a command with a set name
function vmf.run_command(command_name, ...) function dmf.run_command(command_name, ...)
local command_data = _commands[command_name] local command_data = _commands[command_name]
if command_data then if command_data then
local error_prefix = "(commands) " .. tostring(command_name) local error_prefix = "(commands) " .. tostring(command_name)
vmf.safe_call_nr(command_data.mod, error_prefix, command_data.exec_function, ...) dmf.safe_call_nr(command_data.mod, error_prefix, command_data.exec_function, ...)
else else
vmf:error("(commands): command '%s' wasn't found.", command_name) -- Should never see this dmf:error("(commands): command '%s' wasn't found.", command_name) -- Should never see this
end end
end end

View file

@ -1,7 +1,7 @@
local vmf = get_mod("VMF") local dmf = get_mod("DMF")
local _mods = vmf.mods local _mods = dmf.mods
local _mods_unloading_order = vmf.mods_unloading_order local _mods_unloading_order = dmf.mods_unloading_order
-- ##################################################################################################################### -- #####################################################################################################################
-- ##### Local functions ############################################################################################### -- ##### Local functions ###############################################################################################
@ -10,12 +10,12 @@ local _mods_unloading_order = vmf.mods_unloading_order
local function run_event(mod, event_name, ...) local function run_event(mod, event_name, ...)
local event = mod[event_name] local event = mod[event_name]
if event then if event then
vmf.safe_call_nr(mod, "(event) " .. event_name, event, ...) dmf.safe_call_nr(mod, "(event) " .. event_name, event, ...)
end end
end end
-- ##################################################################################################################### -- #####################################################################################################################
-- ##### VMF internal functions and variables ########################################################################## -- ##### DMF internal functions and variables ##########################################################################
-- ##################################################################################################################### -- #####################################################################################################################
--[[ --[[
@ -24,7 +24,7 @@ end
Is called every time the game unloads mods, which happends in 2 cases: mods reloading and exiting the game. Is called every time the game unloads mods, which happends in 2 cases: mods reloading and exiting the game.
* exit_game [boolean]: 'true' if it's unloading before game exit * exit_game [boolean]: 'true' if it's unloading before game exit
--]] --]]
function vmf.mods_unload_event(exit_game) function dmf.mods_unload_event(exit_game)
local event_name = "on_unload" local event_name = "on_unload"
@ -41,7 +41,7 @@ end
Is called every game tick. Is called every game tick.
* dt [float]: time passed since the last 'update' call (measured in seconds, but obvisouly, it never has integer part) * dt [float]: time passed since the last 'update' call (measured in seconds, but obvisouly, it never has integer part)
--]] --]]
function vmf.mods_update_event(dt) function dmf.mods_update_event(dt)
local event_name = "update" local event_name = "update"
@ -57,9 +57,9 @@ end
Is called every time game enters or exits game state. Is called every time game enters or exits game state.
* status [string]: "enter" or "exit" * status [string]: "enter" or "exit"
* state_name [string]: readable state name, which you can get by searching game log files * state_name [string]: readable state name, which you can get by searching game log files
for "VMF:ON_GAME_STATE_CHANGED()" string after launching and closing the game with active VMF for "DMF:ON_GAME_STATE_CHANGED()" string after launching and closing the game with active DMF
--]] --]]
function vmf.mods_game_state_changed_event(status, state_name) function dmf.mods_game_state_changed_event(status, state_name)
local event_name = "on_game_state_changed" local event_name = "on_game_state_changed"
@ -73,10 +73,10 @@ end
EVENT: on_setting_changed (setting_id) 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 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. the DMF's hood call this event.
* setting_id [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_id) function dmf.mod_setting_changed_event(mod, setting_id)
local event_name = "on_setting_changed" local event_name = "on_setting_changed"
@ -91,7 +91,7 @@ end
in their 'mod_data' to 'true'. in their 'mod_data' to 'true'.
* initial_call [boolean]: 'true' if this is the first call right after mod's initialization * initial_call [boolean]: 'true' if this is the first call right after mod's initialization
--]] --]]
function vmf.mod_enabled_event(mod, initial_call) function dmf.mod_enabled_event(mod, initial_call)
local event_name = "on_enabled" local event_name = "on_enabled"
@ -106,7 +106,7 @@ end
in their 'mod_data' to 'true'. in their 'mod_data' to 'true'.
* initial_call [boolean]: 'true' if this is the first call right after mod's initialization * initial_call [boolean]: 'true' if this is the first call right after mod's initialization
--]] --]]
function vmf.mod_disabled_event(mod, initial_call) function dmf.mod_disabled_event(mod, initial_call)
local event_name = "on_disabled" local event_name = "on_disabled"
@ -121,7 +121,7 @@ end
only for mods which registered at least 1 network call. only for mods which registered at least 1 network call.
* player [player]: player object of the player who joined the game * player [player]: player object of the player who joined the game
--]] --]]
function vmf.mod_user_joined_the_game(mod, player) function dmf.mod_user_joined_the_game(mod, player)
local event_name = "on_user_joined" local event_name = "on_user_joined"
@ -136,7 +136,7 @@ end
called only for mods which registered at least 1 network call. called only for mods which registered at least 1 network call.
* player [player]: player object of the player who is about to leave the game * player [player]: player object of the player who is about to leave the game
--]] --]]
function vmf.mod_user_left_the_game(mod, player) function dmf.mod_user_left_the_game(mod, player)
local event_name = "on_user_left" local event_name = "on_user_left"
@ -147,9 +147,9 @@ end
--[[ --[[
EVENT: on_all_mods_loaded () EVENT: on_all_mods_loaded ()
Is called when Vermintide mod manager finishes mods loading. Is called when Darktide mod manager finishes mods loading.
--]] --]]
function vmf.all_mods_loaded_event() function dmf.all_mods_loaded_event()
local event_name = "on_all_mods_loaded" local event_name = "on_all_mods_loaded"

View file

@ -1,4 +1,4 @@
local vmf = get_mod("VMF") local dmf = get_mod("DMF")
-- #################################################################################################################### -- ####################################################################################################################
-- ##### Locals and Variables ######################################################################################### -- ##### Locals and Variables #########################################################################################
@ -8,7 +8,7 @@ local vmf = get_mod("VMF")
local HOOK_TYPES = { local HOOK_TYPES = {
hook = 1, hook = 1,
hook_safe = 2, hook_safe = 2,
hook_origin = 3 hook_origin = 3,
} }
-- Constants to ease on table lookups when not needed -- Constants to ease on table lookups when not needed
@ -163,7 +163,7 @@ local function create_specialized_hook(mod, unique_id, hook_type)
elseif hook_type == HOOK_TYPE_SAFE then elseif hook_type == HOOK_TYPE_SAFE then
func = function(...) func = function(...)
if hook_data.active then if hook_data.active then
vmf.safe_call_nr(mod, "(safe_hook)", hook_data.handler, ...) dmf.safe_call_nr(mod, "(safe_hook)", hook_data.handler, ...)
end end
end end
end end
@ -241,7 +241,7 @@ end
-- #################################################################################################################### -- ####################################################################################################################
-- ##### GENERIC API ################################################################################################## -- ##### GENERIC API ##################################################################################################
-- #################################################################################################################### -- ####################################################################################################################
-- Singular functions that works on a generic basis so the VMFMod API can be tailored for user simplicity. -- Singular functions that works on a generic basis so the DMFMod API can be tailored for user simplicity.
-- These functions are mostly used for type-checking before sending the data to the appropriate internal functions. -- These functions are mostly used for type-checking before sending the data to the appropriate internal functions.
-- Valid styles: -- Valid styles:
@ -254,9 +254,9 @@ end
-- mod, string (method), function (handler), nil, string (func_name) -- mod, string (method), function (handler), nil, string (func_name)
local function generic_hook(mod, obj, method, handler, func_name) local function generic_hook(mod, obj, method, handler, func_name)
if vmf.check_wrong_argument_type(mod, func_name, "obj", obj, "string", "table") or if dmf.check_wrong_argument_type(mod, func_name, "obj", obj, "string", "table") or
vmf.check_wrong_argument_type(mod, func_name, "method", method, "string", "function") or dmf.check_wrong_argument_type(mod, func_name, "method", method, "string", "function") or
vmf.check_wrong_argument_type(mod, func_name, "handler", handler, "function", "nil") dmf.check_wrong_argument_type(mod, func_name, "handler", handler, "function", "nil")
then then
return return
end end
@ -314,8 +314,8 @@ end
local function generic_hook_toggle(mod, obj, method, enabled_state) local function generic_hook_toggle(mod, obj, method, enabled_state)
local func_name = (enabled_state and "hook_enable") or "hook_disable" local func_name = (enabled_state and "hook_enable") or "hook_disable"
if vmf.check_wrong_argument_type(mod, func_name, "obj", obj, "string", "table") or if dmf.check_wrong_argument_type(mod, func_name, "obj", obj, "string", "table") or
vmf.check_wrong_argument_type(mod, func_name, "method", method, "string", "nil") then dmf.check_wrong_argument_type(mod, func_name, "method", method, "string", "nil") then
return return
end end
@ -362,14 +362,14 @@ local function toggle_all_hooks_for_mod(mod, enabled_state)
end end
-- #################################################################################################################### -- ####################################################################################################################
-- ##### VMFMod ####################################################################################################### -- ##### DMFMod #######################################################################################################
-- #################################################################################################################### -- ####################################################################################################################
-- :hook_safe() provides callback after a function is called. You have no control over the execution of the -- :hook_safe() provides callback after a function is called. You have no control over the execution of the
-- original function, nor can you change its return values, making it much safer to use. -- original function, nor can you change its return values, making it much safer to use.
-- The handler is never given the a "func" parameter. -- The handler is never given the a "func" parameter.
-- These will always be executed the original function and the hook chain. -- These will always be executed the original function and the hook chain.
function VMFMod:hook_safe(obj, method, handler) function DMFMod:hook_safe(obj, method, handler)
return generic_hook(self, obj, method, handler, "hook_safe") return generic_hook(self, obj, method, handler, "hook_safe")
end end
@ -377,7 +377,7 @@ end
-- and control its execution. All hooks on the same function will be part of a chain, with the -- and control its execution. All hooks on the same function will be part of a chain, with the
-- original function at the end. Your handler has to call the next function in the chain manually. -- original function at the end. Your handler has to call the next function in the chain manually.
-- The chain of event is determined by mod load order. -- The chain of event is determined by mod load order.
function VMFMod:hook(obj, method, handler) function DMFMod:hook(obj, method, handler)
return generic_hook(self, obj, method, handler, "hook") return generic_hook(self, obj, method, handler, "hook")
end end
@ -387,7 +387,7 @@ end
-- The handler is never given the a "func" parameter. -- The handler is never given the a "func" parameter.
-- This there is a limit of a single origin hook for any given function. -- This there is a limit of a single origin hook for any given function.
-- This should only be used as a last resort due to its limitation and its potential to break the game if not careful. -- This should only be used as a last resort due to its limitation and its potential to break the game if not careful.
function VMFMod:hook_origin(obj, method, handler) function DMFMod:hook_origin(obj, method, handler)
return generic_hook(self, obj, method, handler, "hook_origin") return generic_hook(self, obj, method, handler, "hook_origin")
end end
@ -396,19 +396,19 @@ end
-- and control its execution. All hooks on the same function will be part of a chain, with the -- and control its execution. All hooks on the same function will be part of a chain, with the
-- original function at the end. Your handler has to call the next function in the chain manually. -- original function at the end. Your handler has to call the next function in the chain manually.
-- The chain of event is determined by mod load order. -- The chain of event is determined by mod load order.
function VMFMod:hook_file(obj_str, method_str, handler) function DMFMod:hook_file(obj_str, method_str, handler)
-- Add hook create function to list for the file -- Add hook create function to list for the file
_hooks_by_file[obj_str] = _hooks_by_file[obj_str] or {} _hooks_by_file[obj_str] = _hooks_by_file[obj_str] or {}
local hook_create_func = function(this_filepath, this_index) local hook_create_func = function(this_filepath, this_index)
local dynamic_obj = local dynamic_obj =
"vmf:get_require_store(\"" .. this_filepath .. "\")[" .. tostring(this_index) .. "]" "dmf:get_require_store(\"" .. this_filepath .. "\")[" .. tostring(this_index) .. "]"
return generic_hook(self, dynamic_obj, method_str, handler, "hook") return generic_hook(self, dynamic_obj, method_str, handler, "hook")
end end
table.insert(_hooks_by_file[obj_str], hook_create_func) table.insert(_hooks_by_file[obj_str], hook_create_func)
-- Add the new hook to every instance of the file -- Add the new hook to every instance of the file
local all_file_instances = vmf:get_require_store(obj_str) local all_file_instances = dmf:get_require_store(obj_str)
if all_file_instances then if all_file_instances then
for i, item in ipairs(all_file_instances) do for i, item in ipairs(all_file_instances) do
if item then if item then
@ -419,28 +419,28 @@ function VMFMod:hook_file(obj_str, method_str, handler)
end end
-- Enable/disable functions for all hook types: -- Enable/disable functions for all hook types:
function VMFMod:hook_enable(obj, method) function DMFMod:hook_enable(obj, method)
generic_hook_toggle(self, obj, method, true) generic_hook_toggle(self, obj, method, true)
end end
function VMFMod:hook_disable(obj, method) function DMFMod:hook_disable(obj, method)
generic_hook_toggle(self, obj, method, false) generic_hook_toggle(self, obj, method, false)
end end
function VMFMod:enable_all_hooks() function DMFMod:enable_all_hooks()
toggle_all_hooks_for_mod(self, true) toggle_all_hooks_for_mod(self, true)
end end
function VMFMod:disable_all_hooks() function DMFMod:disable_all_hooks()
toggle_all_hooks_for_mod(self, false) toggle_all_hooks_for_mod(self, false)
end end
-- #################################################################################################################### -- ####################################################################################################################
-- ##### VMF internal functions and variables ######################################################################### -- ##### DMF internal functions and variables #########################################################################
-- #################################################################################################################### -- ####################################################################################################################
-- Remove all hooks when VMF is about to be reloaded -- Remove all hooks when DMF is about to be reloaded
vmf.hooks_unload = function() dmf.hooks_unload = function()
for key, value in pairs(_origs) do for key, value in pairs(_origs) do
-- origs[method] = orig -- origs[method] = orig
if type(value) == "function" then if type(value) == "function" then
@ -454,12 +454,12 @@ vmf.hooks_unload = function()
end end
end end
vmf.apply_delayed_hooks = function(status, state) dmf.apply_delayed_hooks = function(status, state)
if status == "enter" and state == "StateIngame" then if status == "enter" and state == "StateIngame" then
_delaying_enabled = false _delaying_enabled = false
end end
if #_delayed > 0 then if #_delayed > 0 then
vmf:info("Attempt to hook %s delayed hooks", #_delayed) dmf:info("Attempt to hook %s delayed hooks", #_delayed)
-- Go through the table in reverse so we don't get any issues removing entries inside the loop -- Go through the table in reverse so we don't get any issues removing entries inside the loop
for i = #_delayed, 1, -1 do for i = #_delayed, 1, -1 do
_delayed[i]() _delayed[i]()
@ -468,8 +468,8 @@ vmf.apply_delayed_hooks = function(status, state)
end end
end end
vmf.apply_hooks_to_file = function(filepath, store_index) dmf.apply_hooks_to_file = function(filepath, store_index)
local all_file_instances = vmf:get_require_store(filepath) local all_file_instances = dmf:get_require_store(filepath)
local file_instance = all_file_instances and all_file_instances[store_index] local file_instance = all_file_instances and all_file_instances[store_index]
local all_file_hooks = _hooks_by_file[filepath] local all_file_hooks = _hooks_by_file[filepath]

View file

@ -1,4 +1,4 @@
local vmf = get_mod("VMF") local dmf = get_mod("DMF")
local PRIMARY_BINDABLE_KEYS = { local PRIMARY_BINDABLE_KEYS = {
KEYBOARD = { KEYBOARD = {
@ -152,7 +152,7 @@ local OTHER_KEYS = {
["shift"] = {160, "Shift", "KEYBOARD", 161}, ["shift"] = {160, "Shift", "KEYBOARD", 161},
["ctrl"] = {162, "Ctrl", "KEYBOARD", 163}, ["ctrl"] = {162, "Ctrl", "KEYBOARD", 163},
["alt"] = {164, "Alt", "KEYBOARD", 165}, ["alt"] = {164, "Alt", "KEYBOARD", 165},
-- hack for 'vmf.build_keybind_string' function -- hack for 'dmf.build_keybind_string' function
["no_button"] = {-1, ""} ["no_button"] = {-1, ""}
} }
@ -196,8 +196,8 @@ local ERRORS = {
-- ##### Local functions ############################################################################################### -- ##### Local functions ###############################################################################################
-- ##################################################################################################################### -- #####################################################################################################################
local function is_vmf_input_service_active() local function is_dmf_input_service_active()
-- @TODO: Implement check for active VMF input service -- @TODO: Implement check for active DMF input service
return true return true
end end
@ -205,7 +205,7 @@ end
-- Executes function for 'function_call' keybinds. -- Executes function for 'function_call' keybinds.
local function call_function(mod, function_name, keybind_is_pressed) local function call_function(mod, function_name, keybind_is_pressed)
if type(mod[function_name]) == "function" then if type(mod[function_name]) == "function" then
vmf.safe_call_nr(mod, {ERRORS.PREFIX["function_call"], function_name}, mod[function_name], keybind_is_pressed) dmf.safe_call_nr(mod, {ERRORS.PREFIX["function_call"], function_name}, mod[function_name], keybind_is_pressed)
else else
mod:error(ERRORS.PREFIX["function_not_found"], function_name) mod:error(ERRORS.PREFIX["function_not_found"], function_name)
end end
@ -214,22 +214,22 @@ end
-- If check of keybind's conditions is successful, performs keybind's action and returns 'true'. -- If check of keybind's conditions is successful, performs keybind's action and returns 'true'.
local function perform_keybind_action(data, is_pressed) local function perform_keybind_action(data, is_pressed)
local can_perform_action = is_vmf_input_service_active() or data.global or data.release_action local can_perform_action = is_dmf_input_service_active() or data.global or data.release_action
if data.type == "mod_toggle" and can_perform_action and not data.mod:get_internal_data("is_mutator") then if data.type == "mod_toggle" and can_perform_action and not data.mod:get_internal_data("is_mutator") then
vmf.mod_state_changed(data.mod:get_name(), not data.mod:is_enabled()) dmf.mod_state_changed(data.mod:get_name(), not data.mod:is_enabled())
return true return true
elseif data.type == "function_call" and can_perform_action and data.mod:is_enabled() then elseif data.type == "function_call" and can_perform_action and data.mod:is_enabled() then
call_function(data.mod, data.function_name, is_pressed) call_function(data.mod, data.function_name, is_pressed)
return true return true
elseif data.type == "view_toggle" and data.mod:is_enabled() then elseif data.type == "view_toggle" and data.mod:is_enabled() then
vmf.keybind_toggle_view(data.mod, data.view_name, data.transition_data, can_perform_action, is_pressed) dmf.keybind_toggle_view(data.mod, data.view_name, data.transition_data, can_perform_action, is_pressed)
return true return true
end end
end end
-- ##################################################################################################################### -- #####################################################################################################################
-- ##### VMF internal functions and variables ########################################################################## -- ##### DMF internal functions and variables ##########################################################################
-- ##################################################################################################################### -- #####################################################################################################################
-- Checks for pressed and released keybinds, performs keybind actions. -- Checks for pressed and released keybinds, performs keybind actions.
@ -237,7 +237,7 @@ end
-- * If some keybind is pressed, won't check for other keybinds until this keybing is released. -- * If some keybind is pressed, won't check for other keybinds until this keybing is released.
-- * If several mods bound the same keys, keybind action will be performed for all of them, when keybind is pressed. -- * If several mods bound the same keys, keybind action will be performed for all of them, when keybind is pressed.
-- * Keybind is considered released, when its primary key is released. -- * Keybind is considered released, when its primary key is released.
function vmf.check_keybinds() function dmf.check_keybinds()
local ctrl_pressed = (Keyboard.button(KEYS_INFO["ctrl"][1]) + Keyboard.button(KEYS_INFO["ctrl"][4])) > 0 local ctrl_pressed = (Keyboard.button(KEYS_INFO["ctrl"][1]) + Keyboard.button(KEYS_INFO["ctrl"][4])) > 0
local alt_pressed = (Keyboard.button(KEYS_INFO["alt"][1]) + Keyboard.button(KEYS_INFO["alt"][4])) > 0 local alt_pressed = (Keyboard.button(KEYS_INFO["alt"][1]) + Keyboard.button(KEYS_INFO["alt"][4])) > 0
local shift_pressed = (Keyboard.button(KEYS_INFO["shift"][1]) + Keyboard.button(KEYS_INFO["shift"][4])) > 0 local shift_pressed = (Keyboard.button(KEYS_INFO["shift"][1]) + Keyboard.button(KEYS_INFO["shift"][4])) > 0
@ -281,7 +281,7 @@ end
-- Converts managable (raw) table of keybinds data to the table designed for the function checking for pressed and -- Converts managable (raw) table of keybinds data to the table designed for the function checking for pressed and
-- released keybinds. After initial call requires to be called every time some keybind is added/removed. -- released keybinds. After initial call requires to be called every time some keybind is added/removed.
function vmf.generate_keybinds() function dmf.generate_keybinds()
_keybinds = {} _keybinds = {}
for mod, mod_keybinds in pairs(_raw_keybinds_data) do for mod, mod_keybinds in pairs(_raw_keybinds_data) do
@ -318,7 +318,7 @@ end
-- Adds/removes keybinds. -- Adds/removes keybinds.
function vmf.add_mod_keybind(mod, setting_id, raw_keybind_data) function dmf.add_mod_keybind(mod, setting_id, raw_keybind_data)
if #raw_keybind_data.keys > 0 then if #raw_keybind_data.keys > 0 then
_raw_keybinds_data[mod] = _raw_keybinds_data[mod] or {} _raw_keybinds_data[mod] = _raw_keybinds_data[mod] or {}
_raw_keybinds_data[mod][setting_id] = raw_keybind_data _raw_keybinds_data[mod][setting_id] = raw_keybind_data
@ -327,29 +327,29 @@ function vmf.add_mod_keybind(mod, setting_id, raw_keybind_data)
end end
-- Keybind is changed from Mod Options. -- Keybind is changed from Mod Options.
if vmf.all_mods_were_loaded then if dmf.all_mods_were_loaded then
vmf.generate_keybinds() dmf.generate_keybinds()
end end
end end
-- Creates VMF input service. It is required to know when non-global keybinds can be triggered. -- Creates DMF input service. It is required to know when non-global keybinds can be triggered.
-- (Called every time a level is loaded, or on mods reload) -- (Called every time a level is loaded, or on mods reload)
function vmf.create_keybinds_input_service() function dmf.create_keybinds_input_service()
-- @TODO: Link this input service to the player's input service and find some way to see if it's blocked -- @TODO: Link this input service to the player's input service and find some way to see if it's blocked
--[[ --[[
-- To create the VMF input service in Darktide -- To create the DMF input service in Darktide
local input_manager = Managers.input local input_manager = Managers.input
local service_type = "VMF" local service_type = "DMF"
input_manager:add_setting(service_type, aliases, raw_key_table, filter_table, default_devices) input_manager:add_setting(service_type, aliases, raw_key_table, filter_table, default_devices)
input_manager:get_input_service(service_type) input_manager:get_input_service(service_type)
--]] --]]
end end
-- Converts key_index to readable key_id, which is used by VMF to idenify keys. -- Converts key_index to readable key_id, which is used by DMF to idenify keys.
-- (Used for capturing keybinds) -- (Used for capturing keybinds)
function vmf.get_key_id(device, key_index) function dmf.get_key_id(device, key_index)
local key_info = PRIMARY_BINDABLE_KEYS[device][key_index] local key_info = PRIMARY_BINDABLE_KEYS[device][key_index]
return key_info and key_info[2] return key_info and key_info[2]
end end
@ -357,14 +357,14 @@ end
-- Simply tells if key with key_id can be binded as primary key. -- Simply tells if key with key_id can be binded as primary key.
-- (Used for verifying keybind widgets) -- (Used for verifying keybind widgets)
function vmf.can_bind_as_primary_key(key_id) function dmf.can_bind_as_primary_key(key_id)
return KEYS_INFO[key_id] and not OTHER_KEYS[key_id] return KEYS_INFO[key_id] and not OTHER_KEYS[key_id]
end end
-- Builds string with readable keys' names to look like "Primary Key + Ctrl + Alt + Shift". -- Builds string with readable keys' names to look like "Primary Key + Ctrl + Alt + Shift".
-- (Used in keybind widget) -- (Used in keybind widget)
function vmf.build_keybind_string(keys) function dmf.build_keybind_string(keys)
local readable_key_names = {} local readable_key_names = {}
for _, key_id in ipairs(keys) do for _, key_id in ipairs(keys) do
table.insert(readable_key_names, KEYS_INFO[key_id][2]) table.insert(readable_key_names, KEYS_INFO[key_id][2])
@ -377,4 +377,4 @@ end
-- ##################################################################################################################### -- #####################################################################################################################
-- In case mods reloading was performed right at the moment of entering 'StateInGame'. -- In case mods reloading was performed right at the moment of entering 'StateInGame'.
vmf.create_keybinds_input_service() dmf.create_keybinds_input_service()

View file

@ -1,4 +1,4 @@
local vmf = get_mod("VMF") local dmf = get_mod("DMF")
--[[ --[[
English (en) English (en)
@ -30,7 +30,7 @@ local function safe_string_format(mod, str, ...)
elseif mod then elseif mod then
mod:error("(localize) \"%s\": %s", tostring(str), tostring(message)) mod:error("(localize) \"%s\": %s", tostring(str), tostring(message))
else else
vmf:error("(localize) \"%s\": %s", tostring(str), tostring(message)) dmf:error("(localize) \"%s\": %s", tostring(str), tostring(message))
end end
end end
@ -60,10 +60,10 @@ local function get_translated_or_english_message(mod, text_translations, ...)
end end
-- #################################################################################################################### -- ####################################################################################################################
-- ##### VMFMod ####################################################################################################### -- ##### DMFMod #######################################################################################################
-- #################################################################################################################### -- ####################################################################################################################
VMFMod.localize = function (self, text_id, ...) DMFMod.localize = function (self, text_id, ...)
local message local message
local mod_localization_table = _localization_database[self:get_name()] local mod_localization_table = _localization_database[self:get_name()]
@ -79,7 +79,7 @@ VMFMod.localize = function (self, text_id, ...)
end end
VMFMod.add_global_localize_strings = function (self, text_translations) DMFMod.add_global_localize_strings = function (self, text_translations)
for text_id, translations in ipairs(text_translations) do for text_id, translations in ipairs(text_translations) do
if not _global_localization_database[text_id] then if not _global_localization_database[text_id] then
_global_localization_database[text_id] = translations _global_localization_database[text_id] = translations
@ -88,11 +88,11 @@ VMFMod.add_global_localize_strings = function (self, text_translations)
end end
-- #################################################################################################################### -- ####################################################################################################################
-- ##### VMF internal functions and variables ######################################################################### -- ##### DMF internal functions and variables #########################################################################
-- #################################################################################################################### -- ####################################################################################################################
-- Handles the return of global localize text_ids -- Handles the return of global localize text_ids
vmf:hook(_G, "Localize", function (func, text_id, ...) dmf:hook(_G, "Localize", function (func, text_id, ...)
local text_translations = text_id and _global_localization_database[text_id] local text_translations = text_id and _global_localization_database[text_id]
local message = get_translated_or_english_message(nil, text_translations, ...) local message = get_translated_or_english_message(nil, text_translations, ...)
@ -101,10 +101,10 @@ vmf:hook(_G, "Localize", function (func, text_id, ...)
end) end)
-- #################################################################################################################### -- ####################################################################################################################
-- ##### VMF internal functions and variables ######################################################################### -- ##### DMF internal functions and variables #########################################################################
-- #################################################################################################################### -- ####################################################################################################################
vmf.initialize_mod_localization = function (mod, localization_table) dmf.initialize_mod_localization = function (mod, localization_table)
if type(localization_table) ~= "table" then if type(localization_table) ~= "table" then
mod:error("(localization): localization file should return table") mod:error("(localization): localization file should return table")
@ -121,7 +121,7 @@ vmf.initialize_mod_localization = function (mod, localization_table)
end end
-- Localize without parameters and return nil instead of <text_id> if nothing found -- Localize without parameters and return nil instead of <text_id> if nothing found
vmf.quick_localize = function (mod, text_id) dmf.quick_localize = function (mod, text_id)
local mod_localization_table = _localization_database[mod:get_name()] local mod_localization_table = _localization_database[mod:get_name()]
@ -139,5 +139,5 @@ end
-- ##### Script ####################################################################################################### -- ##### Script #######################################################################################################
-- #################################################################################################################### -- ####################################################################################################################
local localization_table = vmf:dofile("dmf/localization/vmf") local localization_table = dmf:dofile("dmf/localization/dmf")
vmf.initialize_mod_localization(vmf, localization_table) dmf.initialize_mod_localization(dmf, localization_table)

View file

@ -1,4 +1,4 @@
local vmf = get_mod("VMF") local dmf = get_mod("DMF")
local _unsent_chat_messages = {} local _unsent_chat_messages = {}
local _logging_settings local _logging_settings
@ -104,63 +104,63 @@ local function log_message(self, msg_type, message, ...)
end end
-- ##################################################################################################################### -- #####################################################################################################################
-- ##### VMFMod ######################################################################################################## -- ##### DMFMod ########################################################################################################
-- ##################################################################################################################### -- #####################################################################################################################
function VMFMod:notify(message, ...) function DMFMod:notify(message, ...)
if _logging_settings.notification.enabled then if _logging_settings.notification.enabled then
log_message(self, "notification", message, ...) log_message(self, "notification", message, ...)
end end
end end
function VMFMod:echo(message, ...) function DMFMod:echo(message, ...)
if _logging_settings.echo.enabled then if _logging_settings.echo.enabled then
log_message(self, "echo", message, ...) log_message(self, "echo", message, ...)
end end
end end
function VMFMod:echo_localized(localization_id, ...) function DMFMod:echo_localized(localization_id, ...)
if _logging_settings.echo.enabled then if _logging_settings.echo.enabled then
log_message(self, "echo", self:localize(localization_id, ...)) log_message(self, "echo", self:localize(localization_id, ...))
end end
end end
function VMFMod:error(message, ...) function DMFMod:error(message, ...)
if _logging_settings.error.enabled then if _logging_settings.error.enabled then
log_message(self, "error", message, ...) log_message(self, "error", message, ...)
end end
end end
function VMFMod:warning(message, ...) function DMFMod:warning(message, ...)
if _logging_settings.warning.enabled then if _logging_settings.warning.enabled then
log_message(self, "warning", message, ...) log_message(self, "warning", message, ...)
end end
end end
function VMFMod:info(message, ...) function DMFMod:info(message, ...)
if _logging_settings.info.enabled then if _logging_settings.info.enabled then
log_message(self, "info", message, ...) log_message(self, "info", message, ...)
end end
end end
function VMFMod:debug(message, ...) function DMFMod:debug(message, ...)
if _logging_settings.debug.enabled then if _logging_settings.debug.enabled then
log_message(self, "debug", message, ...) log_message(self, "debug", message, ...)
end end
end end
-- ##################################################################################################################### -- #####################################################################################################################
-- ##### VMF internal functions and variables ########################################################################## -- ##### DMF internal functions and variables ##########################################################################
-- ##################################################################################################################### -- #####################################################################################################################
-- Can't be hooked right away, since hooking module is not initialized yet -- Can't be hooked right away, since hooking module is not initialized yet
-- Sends unsent messages to chat when chat channel is finally created -- Sends unsent messages to chat when chat channel is finally created
function vmf.delayed_chat_messages_hook() function dmf.delayed_chat_messages_hook()
vmf:hook_safe("VivoxManager", "join_chat_channel", function (self) dmf:hook_safe("VivoxManager", "join_chat_channel", function (self)
if #_unsent_chat_messages > 0 and #self:connected_chat_channels() > 0 then if #_unsent_chat_messages > 0 and #self:connected_chat_channels() > 0 then
for _, message in ipairs(_unsent_chat_messages) do for _, message in ipairs(_unsent_chat_messages) do
add_chat_message(message) add_chat_message(message)
@ -173,15 +173,15 @@ function vmf.delayed_chat_messages_hook()
end) end)
end end
function vmf.load_logging_settings() function dmf.load_logging_settings()
_logging_settings = { _logging_settings = {
notification = vmf:get("logging_mode") == "custom" and vmf:get("output_mode_notification") or 5, notification = dmf:get("logging_mode") == "custom" and dmf:get("output_mode_notification") or 5,
echo = vmf:get("logging_mode") == "custom" and vmf:get("output_mode_echo") or 4, echo = dmf:get("logging_mode") == "custom" and dmf:get("output_mode_echo") or 4,
error = vmf:get("logging_mode") == "custom" and vmf:get("output_mode_error") or 4, error = dmf:get("logging_mode") == "custom" and dmf:get("output_mode_error") or 4,
warning = vmf:get("logging_mode") == "custom" and vmf:get("output_mode_warning") or 4, warning = dmf:get("logging_mode") == "custom" and dmf:get("output_mode_warning") or 4,
info = vmf:get("logging_mode") == "custom" and vmf:get("output_mode_info") or 1, info = dmf:get("logging_mode") == "custom" and dmf:get("output_mode_info") or 1,
debug = vmf:get("logging_mode") == "custom" and vmf:get("output_mode_debug") or 0, debug = dmf:get("logging_mode") == "custom" and dmf:get("output_mode_debug") or 0,
} }
for method_name, logging_mode in pairs(_logging_settings) do for method_name, logging_mode in pairs(_logging_settings) do
@ -198,4 +198,4 @@ end
-- ##### Script ######################################################################################################## -- ##### Script ########################################################################################################
-- ##################################################################################################################### -- #####################################################################################################################
vmf.load_logging_settings() dmf.load_logging_settings()

View file

@ -1,10 +1,10 @@
local vmf = get_mod("VMF") local dmf = get_mod("DMF")
-- ##################################################################################################################### -- #####################################################################################################################
-- ##### VMF internal functions and variables ########################################################################## -- ##### DMF internal functions and variables ##########################################################################
-- ##################################################################################################################### -- #####################################################################################################################
function vmf.check_wrong_argument_type(mod, vmf_function_name, argument_name, argument, ...) function dmf.check_wrong_argument_type(mod, dmf_function_name, argument_name, argument, ...)
local allowed_types = {...} local allowed_types = {...}
local argument_type = type(argument) local argument_type = type(argument)
@ -14,7 +14,7 @@ function vmf.check_wrong_argument_type(mod, vmf_function_name, argument_name, ar
end end
end end
mod:error("(%s): argument '%s' should have the '%s' type, not '%s'", vmf_function_name, argument_name, mod:error("(%s): argument '%s' should have the '%s' type, not '%s'", dmf_function_name, argument_name,
table.concat(allowed_types, "/"), argument_type) table.concat(allowed_types, "/"), argument_type)
return true return true
end end

View file

@ -1,7 +1,7 @@
--[[ --[[
Notify players of enabled mutators via chat and tab menu Notify players of enabled mutators via chat and tab menu
--]] --]]
local vmf = get_mod("VMF") local dmf = get_mod("DMF")
-- ##################################################################################################################### -- #####################################################################################################################
-- ##### Local functions ############################################################################################### -- ##### Local functions ###############################################################################################
@ -10,12 +10,12 @@ local vmf = get_mod("VMF")
-- Assembles a list of enabled mutators -- Assembles a list of enabled mutators
local function add_enabled_mutators_titles_to_string(separator, is_short) local function add_enabled_mutators_titles_to_string(separator, is_short)
local enabled_mutators = {} local enabled_mutators = {}
for _, mutator in ipairs(vmf.mutators) do for _, mutator in ipairs(dmf.mutators) do
if mutator:is_enabled() then if mutator:is_enabled() then
table.insert(enabled_mutators, mutator) table.insert(enabled_mutators, mutator)
end end
end end
return vmf.add_mutator_titles_to_string(enabled_mutators, separator, is_short) return dmf.add_mutator_titles_to_string(enabled_mutators, separator, is_short)
end end

View file

@ -1,7 +1,7 @@
--[[ --[[
Manages everything related to mutators: loading order, enabling/disabling process, giving extra rewards etc. Manages everything related to mutators: loading order, enabling/disabling process, giving extra rewards etc.
--]] --]]
local vmf = get_mod("VMF") local dmf = get_mod("DMF")
-- List of mods that are also mutators in order in which they should be enabled -- List of mods that are also mutators in order in which they should be enabled
local _mutators = {} local _mutators = {}
@ -23,14 +23,14 @@ local _mutators_sorted = false
local _all_mutators_disabled = false local _all_mutators_disabled = false
-- External modules -- External modules
local reward_manager = vmf:dofile("dmf/scripts/mods/vmf/modules/core/mutators/mutators_reward") local reward_manager = dmf:dofile("dmf/scripts/mods/dmf/modules/core/mutators/mutators_reward")
local set_lobby_data = vmf:dofile("dmf/scripts/mods/vmf/modules/core/mutators/mutators_info") local set_lobby_data = dmf:dofile("dmf/scripts/mods/dmf/modules/core/mutators/mutators_info")
-- Get default configuration -- Get default configuration
local _default_config = vmf:dofile("dmf/scripts/mods/vmf/modules/core/mutators/mutators_default_config") local _default_config = dmf:dofile("dmf/scripts/mods/dmf/modules/core/mutators/mutators_default_config")
-- List of enabled mutators in case VMF is reloaded in the middle of the game -- List of enabled mutators in case DMF is reloaded in the middle of the game
local _enabled_mutators = vmf:persistent_table("enabled_mutators") local _enabled_mutators = dmf:persistent_table("enabled_mutators")
-- ##################################################################################################################### -- #####################################################################################################################
-- ##### Local functions ############################################################################################### -- ##### Local functions ###############################################################################################
@ -91,7 +91,7 @@ local function sort_mutators()
--[[ --[[
-- LOG -- -- LOG --
vmf:dump(_mutators_sequence, "seq", 5) dmf:dump(_mutators_sequence, "seq", 5)
for i, v in ipairs(mutators) do for i, v in ipairs(mutators) do
print(i, v:get_name()) print(i, v:get_name())
end end
@ -170,18 +170,18 @@ local function disable_impossible_mutators(is_broadcast, reason_text_id)
for i = #_mutators, 1, -1 do for i = #_mutators, 1, -1 do
local mutator = _mutators[i] local mutator = _mutators[i]
if mutator:is_enabled() and not mutator_can_be_enabled(mutator) then if mutator:is_enabled() and not mutator_can_be_enabled(mutator) then
vmf.mod_state_changed(mutator:get_name(), false) dmf.mod_state_changed(mutator:get_name(), false)
table.insert(disabled_mutators, mutator) table.insert(disabled_mutators, mutator)
end end
end end
if #disabled_mutators > 0 then if #disabled_mutators > 0 then
local disabled_mutators_text_id = is_broadcast and "broadcast_disabled_mutators" or "local_disabled_mutators" local disabled_mutators_text_id = is_broadcast and "broadcast_disabled_mutators" or "local_disabled_mutators"
local message = vmf:localize(disabled_mutators_text_id) .. " " .. vmf:localize(reason_text_id) .. ":" local message = dmf:localize(disabled_mutators_text_id) .. " " .. dmf:localize(reason_text_id) .. ":"
message = message .. " " .. vmf.add_mutator_titles_to_string(disabled_mutators, ", ", false) message = message .. " " .. dmf.add_mutator_titles_to_string(disabled_mutators, ", ", false)
if is_broadcast then if is_broadcast then
vmf:chat_broadcast(message) dmf:chat_broadcast(message)
else else
vmf:echo(message) dmf:echo(message)
end end
end end
end end
@ -204,7 +204,7 @@ local function update_mutators_sequence(mutator)
for _, other_mutator_name in ipairs(enable_before_these) do for _, other_mutator_name in ipairs(enable_before_these) do
if _mutators_sequence[other_mutator_name] and if _mutators_sequence[other_mutator_name] and
table.contains(_mutators_sequence[other_mutator_name], mutator_name) then table.contains(_mutators_sequence[other_mutator_name], mutator_name) then
vmf:error("(mutators): Mutators '%s' and '%s' are both set to load after each other.", mutator_name, dmf:error("(mutators): Mutators '%s' and '%s' are both set to load after each other.", mutator_name,
other_mutator_name) other_mutator_name)
elseif not table.contains(_mutators_sequence[mutator_name], other_mutator_name) then elseif not table.contains(_mutators_sequence[mutator_name], other_mutator_name) then
table.insert(_mutators_sequence[mutator_name], other_mutator_name) table.insert(_mutators_sequence[mutator_name], other_mutator_name)
@ -217,7 +217,7 @@ local function update_mutators_sequence(mutator)
_mutators_sequence[other_mutator_name] = _mutators_sequence[other_mutator_name] or {} _mutators_sequence[other_mutator_name] = _mutators_sequence[other_mutator_name] or {}
if _mutators_sequence[mutator_name] and table.contains(_mutators_sequence[mutator_name], other_mutator_name) then if _mutators_sequence[mutator_name] and table.contains(_mutators_sequence[mutator_name], other_mutator_name) then
vmf:error("(mutators): Mutators '%s' and '%s' are both set to load after each other.", mutator_name, dmf:error("(mutators): Mutators '%s' and '%s' are both set to load after each other.", mutator_name,
other_mutator_name) other_mutator_name)
elseif not table.contains(_mutators_sequence[other_mutator_name], mutator_name) then elseif not table.contains(_mutators_sequence[other_mutator_name], mutator_name) then
table.insert(_mutators_sequence[other_mutator_name], mutator_name) table.insert(_mutators_sequence[other_mutator_name], mutator_name)
@ -339,7 +339,7 @@ local function initialize_mutator_config(mutator, _raw_config)
end end
if raw_config.short_title == "" then raw_config.short_title = nil end if raw_config.short_title == "" then raw_config.short_title = nil end
vmf.set_internal_data(mutator, "mutator_config", {}) dmf.set_internal_data(mutator, "mutator_config", {})
local config = mutator:get_internal_data("mutator_config") local config = mutator:get_internal_data("mutator_config")
@ -359,14 +359,14 @@ local function initialize_mutator_config(mutator, _raw_config)
end end
-- ##################################################################################################################### -- #####################################################################################################################
-- ##### VMF internal functions and variables ########################################################################## -- ##### DMF internal functions and variables ##########################################################################
-- ##################################################################################################################### -- #####################################################################################################################
vmf.mutators = _mutators dmf.mutators = _mutators
-- Appends, prepends and replaces the string with mutator titles -- Appends, prepends and replaces the string with mutator titles
function vmf.add_mutator_titles_to_string(mutators, separator, is_short) function dmf.add_mutator_titles_to_string(mutators, separator, is_short)
if #mutators == 0 then if #mutators == 0 then
return "" return ""
@ -411,7 +411,7 @@ end
-- Turns a mod into a mutator -- Turns a mod into a mutator
function vmf.register_mod_as_mutator(mod, raw_config) function dmf.register_mod_as_mutator(mod, raw_config)
initialize_mutator_config(mod, raw_config) initialize_mutator_config(mod, raw_config)
@ -422,7 +422,7 @@ end
-- Enables/disables mutator while preserving the sequence in which they were enabled -- Enables/disables mutator while preserving the sequence in which they were enabled
function vmf.set_mutator_state(mutator, state, initial_call) function dmf.set_mutator_state(mutator, state, initial_call)
-- Sort mutators if this is the first call -- Sort mutators if this is the first call
if not _mutators_sorted then if not _mutators_sorted then
@ -441,7 +441,7 @@ function vmf.set_mutator_state(mutator, state, initial_call)
for j = #_mutators, i + 1, -1 do for j = #_mutators, i + 1, -1 do
if _mutators[j]:is_enabled() and table.contains(enable_these_after, _mutators[j]:get_name()) then if _mutators[j]:is_enabled() and table.contains(enable_these_after, _mutators[j]:get_name()) then
--print("Disabled ", _mutators[j]:get_name()) --print("Disabled ", _mutators[j]:get_name())
vmf.set_mutator_state(_mutators[j], false, false) dmf.set_mutator_state(_mutators[j], false, false)
table.insert(disabled_mutators, 1, _mutators[j]) table.insert(disabled_mutators, 1, _mutators[j])
end end
end end
@ -449,7 +449,7 @@ function vmf.set_mutator_state(mutator, state, initial_call)
-- Enable/disable current mutator -- Enable/disable current mutator
-- We're calling methods on the class object because we've overwritten them on the current one -- We're calling methods on the class object because we've overwritten them on the current one
vmf.set_mod_state(mutator, state, initial_call) dmf.set_mod_state(mutator, state, initial_call)
if state then if state then
_all_mutators_disabled = false _all_mutators_disabled = false
on_enabled(mutator) on_enabled(mutator)
@ -462,14 +462,14 @@ function vmf.set_mutator_state(mutator, state, initial_call)
if #disabled_mutators > 0 then if #disabled_mutators > 0 then
for j = #disabled_mutators, 1, -1 do for j = #disabled_mutators, 1, -1 do
--print("Enabled ", disabled_mutators[j]:get_name()) --print("Enabled ", disabled_mutators[j]:get_name())
vmf.set_mutator_state(disabled_mutators[j], true, false) dmf.set_mutator_state(disabled_mutators[j], true, false)
end end
end end
end end
-- Checks if player is still hosting (on update) -- Checks if player is still hosting (on update)
function vmf.check_mutators_state() function dmf.check_mutators_state()
if not _all_mutators_disabled and not player_is_server() then if not _all_mutators_disabled and not player_is_server() then
disable_impossible_mutators(false, "disabled_reason_not_server") disable_impossible_mutators(false, "disabled_reason_not_server")
_all_mutators_disabled = true _all_mutators_disabled = true
@ -477,14 +477,14 @@ function vmf.check_mutators_state()
end end
-- Is called only after VMF reloading to check if some mutators were enabled before reloading -- Is called only after DMF reloading to check if some mutators were enabled before reloading
function vmf.is_mutator_enabled(mutator_name) function dmf.is_mutator_enabled(mutator_name)
return _enabled_mutators[mutator_name] return _enabled_mutators[mutator_name]
end end
-- Removes all raw_configs which won't be used anymore -- Removes all raw_configs which won't be used anymore
function vmf.mutators_delete_raw_config() function dmf.mutators_delete_raw_config()
for _, mutator in ipairs(_mutators) do for _, mutator in ipairs(_mutators) do
mutator:get_internal_data("mutator_config").raw_config = nil mutator:get_internal_data("mutator_config").raw_config = nil
end end
@ -501,4 +501,4 @@ end
-- ##################################################################################################################### -- #####################################################################################################################
-- Testing -- Testing
--vmf:dofile("dmf/scripts/mods/vmf/modules/core/mutators/test/mutators_test") --dmf:dofile("dmf/scripts/mods/dmf/modules/core/mutators/test/mutators_test")

View file

@ -1,7 +1,7 @@
--[[ --[[
Add additional reward to end game results Add additional reward to end game results
--]] --]]
local vmf = get_mod("VMF") local dmf = get_mod("DMF")
-- Amounts of additional rewards to be added at level completion -- Amounts of additional rewards to be added at level completion
local _num_reward = { local _num_reward = {

View file

@ -1,4 +1,4 @@
local vmf = get_mod("VMF") local dmf = get_mod("DMF")
local function create_test_mutator(mod_name, mod_data) local function create_test_mutator(mod_name, mod_data)
return new_mod(mod_name, { return new_mod(mod_name, {

View file

@ -1,4 +1,4 @@
local vmf = get_mod("VMF") local dmf = get_mod("DMF")
local _network_debug = false local _network_debug = false
@ -7,7 +7,7 @@ local _network_debug = false
-- #################################################################################################################### -- ####################################################################################################################
-- #################################################################################################################### -- ####################################################################################################################
-- ##### VMFMod ####################################################################################################### -- ##### DMFMod #######################################################################################################
-- #################################################################################################################### -- ####################################################################################################################
-- #################################################################################################################### -- ####################################################################################################################
@ -15,23 +15,23 @@ local _network_debug = false
-- #################################################################################################################### -- ####################################################################################################################
-- #################################################################################################################### -- ####################################################################################################################
-- ##### VMF internal functions and variables ######################################################################### -- ##### DMF internal functions and variables #########################################################################
-- #################################################################################################################### -- ####################################################################################################################
vmf.create_network_dictionary = function() dmf.create_network_dictionary = function()
-- @TODO: Not implemented -- @TODO: Not implemented
end end
vmf.ping_vmf_users = function() dmf.ping_dmf_users = function()
-- @TODO: Not implemented -- @TODO: Not implemented
end end
vmf.load_network_settings = function() dmf.load_network_settings = function()
_network_debug = vmf:get("developer_mode") and vmf:get("show_network_debug_info") _network_debug = dmf:get("developer_mode") and dmf:get("show_network_debug_info")
end end
-- #################################################################################################################### -- ####################################################################################################################
-- ##### Script ####################################################################################################### -- ##### Script #######################################################################################################
-- #################################################################################################################### -- ####################################################################################################################
vmf.load_network_settings() dmf.load_network_settings()

View file

@ -1,4 +1,4 @@
local vmf = get_mod("VMF") local dmf = get_mod("DMF")
-- This variable is defined here and not in widget data initialization function because some error messages -- This variable is defined here and not in widget data initialization function because some error messages
-- require it to be dumped to game log. -- require it to be dumped to game log.
@ -23,13 +23,13 @@ local function initialize_collapsed_widgets(mod, collapsed_widgets)
if type(collapsed_widget_name) == "string" then if type(collapsed_widget_name) == "string" then
new_collapsed_widgets[collapsed_widget_name] = true new_collapsed_widgets[collapsed_widget_name] = true
else else
vmf.throw_error("'collapsed_widgets[%d]' is not a string", i) dmf.throw_error("'collapsed_widgets[%d]' is not a string", i)
end end
end end
local options_menu_collapsed_widgets = vmf:get("options_menu_collapsed_widgets") local options_menu_collapsed_widgets = dmf:get("options_menu_collapsed_widgets")
options_menu_collapsed_widgets[mod:get_name()] = new_collapsed_widgets options_menu_collapsed_widgets[mod:get_name()] = new_collapsed_widgets
vmf:set("options_menu_collapsed_widgets", options_menu_collapsed_widgets) dmf:set("options_menu_collapsed_widgets", options_menu_collapsed_widgets)
end end
-- ################ -- ################
@ -48,9 +48,9 @@ local function initialize_header_data(mod, data)
new_data.readable_mod_name = mod:get_readable_name() new_data.readable_mod_name = mod:get_readable_name()
new_data.tooltip = mod:get_description() new_data.tooltip = mod:get_description()
new_data.is_togglable = mod:get_internal_data("is_togglable") and not mod:get_internal_data("is_mutator") new_data.is_togglable = mod:get_internal_data("is_togglable") and not mod:get_internal_data("is_mutator")
new_data.is_collapsed = vmf:get("options_menu_collapsed_mods")[mod:get_name()] new_data.is_collapsed = dmf:get("options_menu_collapsed_mods")[mod:get_name()]
for _, favorited_mod_name in ipairs(vmf:get("options_menu_favorite_mods")) do for _, favorited_mod_name in ipairs(dmf:get("options_menu_favorite_mods")) do
if favorited_mod_name == new_data.mod_name then if favorited_mod_name == new_data.mod_name then
new_data.is_favorited = true new_data.is_favorited = true
end end
@ -67,26 +67,26 @@ local function validate_generic_widget_data(data)
local setting_id = data.setting_id local setting_id = data.setting_id
if type(setting_id) ~= "string" then if type(setting_id) ~= "string" then
vmf:dump(_unfolded_raw_widgets_data, "widgets", 1) dmf:dump(_unfolded_raw_widgets_data, "widgets", 1)
vmf.throw_error("[widget#%d (%s)]: 'setting_id' field is required and must have 'string' type. " .. dmf.throw_error("[widget#%d (%s)]: 'setting_id' field is required and must have 'string' type. " ..
"See dumped table in game log for reference.", data.index, data.type) "See dumped table in game log for reference.", data.index, data.type)
end end
if not data.localize and not data.title then if not data.localize and not data.title then
vmf.throw_error("[widget \"%s\" (%s)]: lacks 'title' field (localization is disabled)", setting_id, data.type) dmf.throw_error("[widget \"%s\" (%s)]: lacks 'title' field (localization is disabled)", setting_id, data.type)
end end
if data.title and type(data.title) ~= "string" then if data.title and type(data.title) ~= "string" then
vmf.throw_error("[widget \"%s\" (%s)]: 'title' field must have 'string' type", setting_id, data.type) dmf.throw_error("[widget \"%s\" (%s)]: 'title' field must have 'string' type", setting_id, data.type)
end end
if data.tooltip and type(data.tooltip) ~= "string" then if data.tooltip and type(data.tooltip) ~= "string" then
vmf.throw_error("[widget \"%s\" (%s)]: 'tooltip' field must have 'string' type", setting_id, data.type) dmf.throw_error("[widget \"%s\" (%s)]: 'tooltip' field must have 'string' type", setting_id, data.type)
end end
if _defined_mod_settings[setting_id] then if _defined_mod_settings[setting_id] then
vmf:dump(_unfolded_raw_widgets_data, "widgets", 1) dmf:dump(_unfolded_raw_widgets_data, "widgets", 1)
vmf.throw_error("Widgets %d and %d have the same setting_id (\"%s\"). See dumped table in game log for reference.", dmf.throw_error("Widgets %d and %d have the same setting_id (\"%s\"). See dumped table in game log for reference.",
_defined_mod_settings[setting_id], data.index, setting_id) _defined_mod_settings[setting_id], data.index, setting_id)
else else
_defined_mod_settings[setting_id] = data.index _defined_mod_settings[setting_id] = data.index
@ -100,7 +100,7 @@ local function localize_generic_widget_data(mod, data)
if data.tooltip then if data.tooltip then
data.tooltip = mod:localize(data.tooltip) data.tooltip = mod:localize(data.tooltip)
else else
data.tooltip = vmf.quick_localize(mod, data.setting_id .. "_description") data.tooltip = dmf.quick_localize(mod, data.setting_id .. "_description")
end end
end end
end end
@ -146,7 +146,7 @@ local function initialize_group_data(mod, data, localize, collapsed_widgets)
local new_data = initialize_generic_widget_data(mod, data, localize) local new_data = initialize_generic_widget_data(mod, data, localize)
if not data.sub_widgets or not (#data.sub_widgets > 0) then if not data.sub_widgets or not (#data.sub_widgets > 0) then
vmf.throw_error("[widget \"%s\" (group)]: must have at least 1 sub_widget", data.setting_id) dmf.throw_error("[widget \"%s\" (group)]: must have at least 1 sub_widget", data.setting_id)
end end
new_data.is_collapsed = collapsed_widgets[data.setting_id] new_data.is_collapsed = collapsed_widgets[data.setting_id]
@ -160,7 +160,7 @@ end
local function validate_checkbox_data(data) local function validate_checkbox_data(data)
if type(data.default_value) ~= "boolean" then if type(data.default_value) ~= "boolean" then
vmf.throw_error("[widget \"%s\" (checkbox)]: 'default_value' field is required and must have 'boolean' type", dmf.throw_error("[widget \"%s\" (checkbox)]: 'default_value' field is required and must have 'boolean' type",
data.setting_id) data.setting_id)
end end
end end
@ -188,17 +188,17 @@ local allowed_dropdown_values = {
local function validate_dropdown_data(data) local function validate_dropdown_data(data)
if not allowed_dropdown_values[type(data.default_value)] then if not allowed_dropdown_values[type(data.default_value)] then
vmf.throw_error("[widget \"%s\" (dropdown)]: 'default_value' field is required and must have 'string', " .. dmf.throw_error("[widget \"%s\" (dropdown)]: 'default_value' field is required and must have 'string', " ..
"'number' or 'boolean' type", data.setting_id) "'number' or 'boolean' type", data.setting_id)
end end
if type(data.options) ~= "table" then if type(data.options) ~= "table" then
vmf.throw_error("[widget \"%s\" (dropdown)]: 'options' field is required and must have 'table' type", dmf.throw_error("[widget \"%s\" (dropdown)]: 'options' field is required and must have 'table' type",
data.setting_id) data.setting_id)
end end
if #data.options < 2 then if #data.options < 2 then
vmf.throw_error("[widget \"%s\" (dropdown)]: 'options' table must have at least 2 elements", data.setting_id) dmf.throw_error("[widget \"%s\" (dropdown)]: 'options' table must have at least 2 elements", data.setting_id)
end end
local default_value = data.default_value local default_value = data.default_value
@ -208,22 +208,22 @@ local function validate_dropdown_data(data)
local option_value = option.value local option_value = option.value
if type(option.text) ~= "string" then if type(option.text) ~= "string" then
vmf.throw_error("[widget \"%s\" (dropdown)]: 'options[%d]'-> 'text' field is required and must have " .. dmf.throw_error("[widget \"%s\" (dropdown)]: 'options[%d]'-> 'text' field is required and must have " ..
"'string' type", data.setting_id, i) "'string' type", data.setting_id, i)
end end
if not allowed_dropdown_values[type(option_value)] then if not allowed_dropdown_values[type(option_value)] then
vmf.throw_error("[widget \"%s\" (dropdown)]: 'options[%d]'-> 'value' field is required and must have " .. dmf.throw_error("[widget \"%s\" (dropdown)]: 'options[%d]'-> 'value' field is required and must have " ..
"'string', 'number' or 'boolean' type", data.setting_id, i) "'string', 'number' or 'boolean' type", data.setting_id, i)
end end
if option.show_widgets and type(option.show_widgets) ~= "table" then if option.show_widgets and type(option.show_widgets) ~= "table" then
vmf.throw_error("[widget \"%s\" (dropdown)]: 'options[%d]'-> 'show_widgets' field must have 'table' type", dmf.throw_error("[widget \"%s\" (dropdown)]: 'options[%d]'-> 'show_widgets' field must have 'table' type",
data.setting_id, i) data.setting_id, i)
end end
if used_values[option_value] then if used_values[option_value] then
vmf.throw_error("[widget \"%s\" (dropdown)]: 'options[%d]' has 'value' field set to the same value " .. dmf.throw_error("[widget \"%s\" (dropdown)]: 'options[%d]' has 'value' field set to the same value " ..
"as one of previous options", data.setting_id, i) "as one of previous options", data.setting_id, i)
end end
@ -235,7 +235,7 @@ local function validate_dropdown_data(data)
end end
if not default_value_match then if not default_value_match then
vmf.throw_error("[widget \"%s\" (dropdown)]: 'default_value' field contains value not defined in 'options' field", dmf.throw_error("[widget \"%s\" (dropdown)]: 'default_value' field contains value not defined in 'options' field",
data.setting_id) data.setting_id)
end end
end end
@ -264,7 +264,7 @@ local function initialize_dropdown_data(mod, data, localize, collapsed_widgets)
validate_dropdown_data(new_data) validate_dropdown_data(new_data)
localize_dropdown_data(mod, new_data) localize_dropdown_data(mod, new_data)
-- Converting show_widgets from human-readable form to vmf-options-readable -- Converting show_widgets from human-readable form to dmf-options-readable
-- i.e. {[1] = 2, [2] = 3, [3] = 5} -> {[113] = true, [114] = true, [116] = true} -- i.e. {[1] = 2, [2] = 3, [3] = 5} -> {[113] = true, [114] = true, [116] = true}
-- Where the 2nd set of numbers are the real widget numbers of subwidgets -- Where the 2nd set of numbers are the real widget numbers of subwidgets
if data.sub_widgets ~= nil then if data.sub_widgets ~= nil then
@ -275,7 +275,7 @@ local function initialize_dropdown_data(mod, data, localize, collapsed_widgets)
if data.sub_widgets[sub_widget_index] then if data.sub_widgets[sub_widget_index] then
new_show_widgets[data.sub_widgets[sub_widget_index].index] = true new_show_widgets[data.sub_widgets[sub_widget_index].index] = true
else else
vmf.throw_error("[widget \"%s\" (dropdown)]: 'options -> [%d] -> show_widgets -> [%d] \"%s\"' points " .. dmf.throw_error("[widget \"%s\" (dropdown)]: 'options -> [%d] -> show_widgets -> [%d] \"%s\"' points " ..
"to non-existing sub_widget", data.setting_id, i, j, sub_widget_index) "to non-existing sub_widget", data.setting_id, i, j, sub_widget_index)
end end
end end
@ -307,54 +307,54 @@ local allowed_modifier_keys = {
} }
local function validate_keybind_data(data) local function validate_keybind_data(data)
if data.keybind_global and type(data.keybind_global) ~= "boolean" then if data.keybind_global and type(data.keybind_global) ~= "boolean" then
vmf.throw_error("[widget \"%s\" (keybind)]: 'keybind_global' field must have 'boolean' type", data.setting_id) dmf.throw_error("[widget \"%s\" (keybind)]: 'keybind_global' field must have 'boolean' type", data.setting_id)
end end
if not allowed_keybind_triggers[data.keybind_trigger] then if not allowed_keybind_triggers[data.keybind_trigger] then
vmf.throw_error("[widget \"%s\" (keybind)]: 'keybind_trigger' field is required and must contain string " .. dmf.throw_error("[widget \"%s\" (keybind)]: 'keybind_trigger' field is required and must contain string " ..
"\"pressed\" or \"held\"", data.setting_id) "\"pressed\" or \"held\"", data.setting_id)
end end
local keybind_type = data.keybind_type local keybind_type = data.keybind_type
if not allowed_keybind_types[keybind_type] then if not allowed_keybind_types[keybind_type] then
vmf.throw_error("[widget \"%s\" (keybind)]: 'keybind_type' field is required and must contain string " .. dmf.throw_error("[widget \"%s\" (keybind)]: 'keybind_type' field is required and must contain string " ..
"\"function_call\", \"view_toggle\" or \"mod_toggle\"", data.setting_id) "\"function_call\", \"view_toggle\" or \"mod_toggle\"", data.setting_id)
end end
if keybind_type == "function_call" and type(data.function_name) ~= "string" then if keybind_type == "function_call" and type(data.function_name) ~= "string" then
vmf.throw_error("[widget \"%s\" (keybind)]: 'keybind_type' is set to \"function_call\" so 'function_name' " .. dmf.throw_error("[widget \"%s\" (keybind)]: 'keybind_type' is set to \"function_call\" so 'function_name' " ..
"field is required and must have 'string' type", data.setting_id) "field is required and must have 'string' type", data.setting_id)
end end
if keybind_type == "view_toggle" then if keybind_type == "view_toggle" then
if type(data.view_name) ~= "string" then if type(data.view_name) ~= "string" then
vmf.throw_error("[widget \"%s\" (keybind)]: 'keybind_type' is set to \"view_toggle\" so 'view_name' " .. dmf.throw_error("[widget \"%s\" (keybind)]: 'keybind_type' is set to \"view_toggle\" so 'view_name' " ..
"field is required and must have 'string' type", data.setting_id) "field is required and must have 'string' type", data.setting_id)
end end
end end
local default_value = data.default_value local default_value = data.default_value
if type(default_value) ~= "table" then if type(default_value) ~= "table" then
vmf.throw_error("[widget \"%s\" (keybind)]: 'default_value' field is required and must have 'table' type", dmf.throw_error("[widget \"%s\" (keybind)]: 'default_value' field is required and must have 'table' type",
data.setting_id) data.setting_id)
end end
if #default_value > 4 then if #default_value > 4 then
vmf.throw_error("[widget \"%s\" (keybind)]: table stored in 'default_value' field can't exceed 4 elements", dmf.throw_error("[widget \"%s\" (keybind)]: table stored in 'default_value' field can't exceed 4 elements",
data.setting_id) data.setting_id)
end end
if default_value[1] and not vmf.can_bind_as_primary_key(default_value[1]) then if default_value[1] and not dmf.can_bind_as_primary_key(default_value[1]) then
vmf.throw_error("[widget \"%s\" (keybind)]: 'default_value[1]' must be a valid key name", data.setting_id) dmf.throw_error("[widget \"%s\" (keybind)]: 'default_value[1]' must be a valid key name", data.setting_id)
end end
if default_value[2] and not allowed_modifier_keys[default_value[2]] or if default_value[2] and not allowed_modifier_keys[default_value[2]] or
default_value[3] and not allowed_modifier_keys[default_value[3]] or default_value[3] and not allowed_modifier_keys[default_value[3]] or
default_value[4] and not allowed_modifier_keys[default_value[4]] default_value[4] and not allowed_modifier_keys[default_value[4]]
then then
vmf.throw_error("[widget \"%s\" (keybind)]: 'default_value [2], [3] and [4]' can be only strings: \"ctrl\", " .. dmf.throw_error("[widget \"%s\" (keybind)]: 'default_value [2], [3] and [4]' can be only strings: \"ctrl\", " ..
"\"alt\" and \"shift\" (in no particular order)", data.setting_id) "\"alt\" and \"shift\" (in no particular order)", data.setting_id)
end end
local used_keys = {} local used_keys = {}
for _, key in ipairs(default_value) do for _, key in ipairs(default_value) do
if used_keys[key] then if used_keys[key] then
vmf.throw_error("[widget \"%s\" (keybind)]: you can't define the same key in 'default_value' table twice", dmf.throw_error("[widget \"%s\" (keybind)]: you can't define the same key in 'default_value' table twice",
data.setting_id) data.setting_id)
end end
used_keys[key] = true used_keys[key] = true
@ -382,41 +382,41 @@ end
local function validate_numeric_data(data) local function validate_numeric_data(data)
if data.unit_text and type(data.unit_text) ~= "string" then if data.unit_text and type(data.unit_text) ~= "string" then
vmf.throw_error("[widget \"%s\" (numeric)]: 'unit_text' field must have 'string' type", data.setting_id) dmf.throw_error("[widget \"%s\" (numeric)]: 'unit_text' field must have 'string' type", data.setting_id)
end end
if type(data.decimals_number) ~= "number" then if type(data.decimals_number) ~= "number" then
vmf.throw_error("[widget \"%s\" (numeric)]: 'decimals_number' field must have 'number' type", data.setting_id) dmf.throw_error("[widget \"%s\" (numeric)]: 'decimals_number' field must have 'number' type", data.setting_id)
end end
if data.decimals_number < 0 then -- @TODO: eventually do max cap as well if data.decimals_number < 0 then -- @TODO: eventually do max cap as well
vmf.throw_error("[widget \"%s\" (numeric)]: 'decimals_number' value can't be lower than zero", data.setting_id) dmf.throw_error("[widget \"%s\" (numeric)]: 'decimals_number' value can't be lower than zero", data.setting_id)
end end
local range = data.range local range = data.range
if type(range) ~= "table" then if type(range) ~= "table" then
vmf.throw_error("[widget \"%s\" (numeric)]: 'range' field is required and must have 'table' type", data.setting_id) dmf.throw_error("[widget \"%s\" (numeric)]: 'range' field is required and must have 'table' type", data.setting_id)
end end
if #range ~= 2 then if #range ~= 2 then
vmf.throw_error("[widget \"%s\" (numeric)]: 'range' field must contain an array-like table with 2 elements", dmf.throw_error("[widget \"%s\" (numeric)]: 'range' field must contain an array-like table with 2 elements",
data.setting_id) data.setting_id)
end end
local range_min = range[1] local range_min = range[1]
local range_max = range[2] local range_max = range[2]
if type(range_min) ~= "number" or type(range_max) ~= "number" then if type(range_min) ~= "number" or type(range_max) ~= "number" then
vmf.throw_error("[widget \"%s\" (numeric)]: table stored in 'range' field must contain only numbers", dmf.throw_error("[widget \"%s\" (numeric)]: table stored in 'range' field must contain only numbers",
data.setting_id) data.setting_id)
end end
if range_min > range_max then if range_min > range_max then
vmf.throw_error("[widget \"%s\" (numeric)]: 'range[2]' must be bigger than 'range[1]'", data.setting_id) dmf.throw_error("[widget \"%s\" (numeric)]: 'range[2]' must be bigger than 'range[1]'", data.setting_id)
end end
local default_value = data.default_value local default_value = data.default_value
if type(default_value) ~= "number" then if type(default_value) ~= "number" then
vmf.throw_error("[widget \"%s\" (numeric)]: 'default_value' field is required and must have 'number' type", dmf.throw_error("[widget \"%s\" (numeric)]: 'default_value' field is required and must have 'number' type",
data.setting_id) data.setting_id)
end end
if default_value < range_min or default_value > range_max then if default_value < range_min or default_value > range_max then
vmf.throw_error("[widget \"%s\" (numeric)]: 'default_value' field must contain number fitting set 'range'", dmf.throw_error("[widget \"%s\" (numeric)]: 'default_value' field must contain number fitting set 'range'",
data.setting_id) data.setting_id)
end end
end end
@ -483,14 +483,14 @@ local function unfold_table(unfolded_table, unfoldable_table, parent_index, dept
if type(nested_table_sub_widgets) == "table" then if type(nested_table_sub_widgets) == "table" then
unfold_table(unfolded_table, nested_table_sub_widgets, #unfolded_table, depth + 1) unfold_table(unfolded_table, nested_table_sub_widgets, #unfolded_table, depth + 1)
else else
vmf:dump(unfolded_table, "widgets", 1) dmf:dump(unfolded_table, "widgets", 1)
vmf.throw_error("'sub_widgets' field of widget [%d] is not a table, it's %s. See dumped table in game log " .. dmf.throw_error("'sub_widgets' field of widget [%d] is not a table, it's %s. See dumped table in game log " ..
"for reference.", #unfolded_table, type(nested_table_sub_widgets)) "for reference.", #unfolded_table, type(nested_table_sub_widgets))
end end
end end
else else
vmf:dump(unfolded_table, "widgets", 1) dmf:dump(unfolded_table, "widgets", 1)
vmf.throw_error("sub_widget#%d of widget [%d] is not a table, it's %s. " .. dmf.throw_error("sub_widget#%d of widget [%d] is not a table, it's %s. " ..
"See dumped table in game log for reference.", i, parent_index, type(nested_table)) "See dumped table in game log for reference.", i, parent_index, type(nested_table))
end end
end end
@ -513,7 +513,7 @@ local function initialize_mod_options_widgets_data(mod, widgets_data, localize)
-- Put data of all widgets in one-dimensional array in order they will be displayed in mod options. -- Put data of all widgets in one-dimensional array in order they will be displayed in mod options.
_unfolded_raw_widgets_data = unfold_table({header_widget_data}, widgets_data, 1, base_depth) _unfolded_raw_widgets_data = unfold_table({header_widget_data}, widgets_data, 1, base_depth)
-- Load info about widgets previously collapsed by user -- Load info about widgets previously collapsed by user
local collapsed_widgets = vmf:get("options_menu_collapsed_widgets")[mod:get_name()] or {} local collapsed_widgets = dmf:get("options_menu_collapsed_widgets")[mod:get_name()] or {}
-- Before starting widgets data initialization, clear this table. It's used to detect if 2 widgets -- Before starting widgets data initialization, clear this table. It's used to detect if 2 widgets
-- defined the same setting_id. -- defined the same setting_id.
@ -524,8 +524,8 @@ local function initialize_mod_options_widgets_data(mod, widgets_data, localize)
if initialized_widget_data then if initialized_widget_data then
table.insert(initialized_data, initialized_widget_data) table.insert(initialized_data, initialized_widget_data)
else else
vmf:dump(_unfolded_raw_widgets_data, "widgets", 1) dmf:dump(_unfolded_raw_widgets_data, "widgets", 1)
vmf.throw_error("[widget#%d]: 'type' field must contain valid widget type name. " .. dmf.throw_error("[widget#%d]: 'type' field must contain valid widget type name. " ..
"See dumped table in game log for reference.", widget_data.index, widget_data.type) "See dumped table in game log for reference.", widget_data.index, widget_data.type)
end end
end end
@ -544,7 +544,7 @@ local function initialize_default_settings_and_keybinds(mod, initialized_widgets
mod:set(data.setting_id, data.default_value) mod:set(data.setting_id, data.default_value)
end end
if data.type == "keybind" then if data.type == "keybind" then
vmf.add_mod_keybind( dmf.add_mod_keybind(
mod, mod,
data.setting_id, data.setting_id,
{ {
@ -561,19 +561,19 @@ local function initialize_default_settings_and_keybinds(mod, initialized_widgets
end end
-- ##################################################################################################################### -- #####################################################################################################################
-- ##### VMF internal functions and variables ########################################################################## -- ##### DMF internal functions and variables ##########################################################################
-- ##################################################################################################################### -- #####################################################################################################################
-- Is used in Mod Options to create options widgets -- Is used in Mod Options to create options widgets
vmf.options_widgets_data = {} dmf.options_widgets_data = {}
-- Initializes mod's options data. If this function is called with 'options.widgets' not specified, it just creates -- Initializes mod's options data. If this function is called with 'options.widgets' not specified, it just creates
-- widget data with single header with checkbox. -- widget data with single header with checkbox.
function vmf.initialize_mod_options(mod, options) function dmf.initialize_mod_options(mod, options)
options = options or {} options = options or {}
-- If this is the first time user launches this mod, set collapsed widgets list to default one. -- If this is the first time user launches this mod, set collapsed widgets list to default one.
if options.collapsed_widgets and not vmf.mod_has_settings(mod) then if options.collapsed_widgets and not dmf.mod_has_settings(mod) then
initialize_collapsed_widgets(mod, options.collapsed_widgets) initialize_collapsed_widgets(mod, options.collapsed_widgets)
end end
@ -586,21 +586,21 @@ function vmf.initialize_mod_options(mod, options)
-- Insert initialized widgets data to the table which will be used by Mod Options to built options widgets list -- Insert initialized widgets data to the table which will be used by Mod Options to built options widgets list
-- for this mod. -- for this mod.
table.insert(vmf.options_widgets_data, initialized_widgets_data) table.insert(dmf.options_widgets_data, initialized_widgets_data)
end end
-- ##################################################################################################################### -- #####################################################################################################################
-- ##### Script ######################################################################################################## -- ##### Script ########################################################################################################
-- ##################################################################################################################### -- #####################################################################################################################
if type(vmf:get("options_menu_favorite_mods")) ~= "table" then if type(dmf:get("options_menu_favorite_mods")) ~= "table" then
vmf:set("options_menu_favorite_mods", {}) dmf:set("options_menu_favorite_mods", {})
end end
if type(vmf:get("options_menu_collapsed_mods")) ~= "table" then if type(dmf:get("options_menu_collapsed_mods")) ~= "table" then
vmf:set("options_menu_collapsed_mods", {}) dmf:set("options_menu_collapsed_mods", {})
end end
if type(vmf:get("options_menu_collapsed_widgets")) ~= "table" then if type(dmf:get("options_menu_collapsed_widgets")) ~= "table" then
vmf:set("options_menu_collapsed_widgets", {}) dmf:set("options_menu_collapsed_widgets", {})
end end

View file

@ -1,17 +1,17 @@
local vmf = get_mod("VMF") local dmf = get_mod("DMF")
-- @TODO: move it to on_reload when it will be implemented in vt1 -- @TODO: move it to on_reload when it will be implemented in vt1
Managers.vmf = Managers.vmf or { Managers.dmf = Managers.dmf or {
delete = function() delete = function()
return return
end end
} }
Managers.vmf.persistent_tables = Managers.vmf.persistent_tables or {} Managers.dmf.persistent_tables = Managers.dmf.persistent_tables or {}
local _persistent_tables = Managers.vmf.persistent_tables local _persistent_tables = Managers.dmf.persistent_tables
-- ##################################################################################################################### -- #####################################################################################################################
-- ##### VMFMod ######################################################################################################## -- ##### DMFMod ########################################################################################################
-- ##################################################################################################################### -- #####################################################################################################################
--[[ --[[
@ -22,10 +22,10 @@ local _persistent_tables = Managers.vmf.persistent_tables
tables when using the same table_name tables when using the same table_name
* default_table [table] : (optional) table that will replace empty table created by default (on the 1st call) * default_table [table] : (optional) table that will replace empty table created by default (on the 1st call)
--]] --]]
function VMFMod:persistent_table(table_name, default_table) function DMFMod:persistent_table(table_name, default_table)
if vmf.check_wrong_argument_type(self, "persistent_table", "table_name", table_name, "string") or if dmf.check_wrong_argument_type(self, "persistent_table", "table_name", table_name, "string") or
vmf.check_wrong_argument_type(self, "persistent_table", "default_table", default_table, "table", "nil") dmf.check_wrong_argument_type(self, "persistent_table", "default_table", default_table, "table", "nil")
then then
return return
end end

View file

@ -1,4 +1,4 @@
local vmf = get_mod("VMF") local dmf = get_mod("DMF")
local _io_requires = {} local _io_requires = {}
@ -32,29 +32,29 @@ local function original_require(path, ...)
end end
-- ##################################################################################################################### -- #####################################################################################################################
-- ##### VMFMod ######################################################################################################## -- ##### DMFMod ########################################################################################################
-- ##################################################################################################################### -- #####################################################################################################################
-- Add a file path to be loaded through io instead of require() -- Add a file path to be loaded through io instead of require()
function VMFMod:add_require_path(path) function DMFMod:add_require_path(path)
add_io_require_path(path) add_io_require_path(path)
end end
-- Remove a file path that was previously loaded through io instead of require() -- Remove a file path that was previously loaded through io instead of require()
function VMFMod:remove_require_path(path) function DMFMod:remove_require_path(path)
remove_io_require_path(path) remove_io_require_path(path)
end end
-- Get all instances of a file created through require() -- Get all instances of a file created through require()
function VMFMod:get_require_store(path) function DMFMod:get_require_store(path)
return get_require_store(path) return get_require_store(path)
end end
-- Get a file through the original, unhooked require() function -- Get a file through the original, unhooked require() function
function VMFMod:original_require(path, ...) function DMFMod:original_require(path, ...)
return original_require(path, ...) return original_require(path, ...)
end end
@ -63,16 +63,16 @@ end
-- ##################################################################################################################### -- #####################################################################################################################
-- Handles the swap to io for registered files -- Handles the swap to io for registered files
vmf:hook(_G, "require", function (func, path, ...) dmf:hook(_G, "require", function (func, path, ...)
if _io_requires[path] then if _io_requires[path] then
return vmf:dofile(path) return dmf:dofile(path)
else else
return func(path, ...) return func(path, ...)
end end
end) end)
-- ##################################################################################################################### -- #####################################################################################################################
-- ##### VMF internal functions and variables ########################################################################## -- ##### DMF internal functions and variables ##########################################################################
-- ##################################################################################################################### -- #####################################################################################################################
-- ##################################################################################################################### -- #####################################################################################################################

View file

@ -1,4 +1,4 @@
local vmf = get_mod("VMF") local dmf = get_mod("DMF")
-- Global method to load a file through io with a return -- Global method to load a file through io with a return
local mod_dofile = Mods.file.dofile local mod_dofile = Mods.file.dofile
@ -33,25 +33,25 @@ local function show_error(mod, error_prefix_data, error_message)
end end
-- ##################################################################################################################### -- #####################################################################################################################
-- ##### VMFMod ######################################################################################################## -- ##### DMFMod ########################################################################################################
-- ##################################################################################################################### -- #####################################################################################################################
function VMFMod:pcall(...) function DMFMod:pcall(...)
return vmf.safe_call(self, "(pcall)", ...) return dmf.safe_call(self, "(pcall)", ...)
end end
function VMFMod:dofile(file_path) function DMFMod:dofile(file_path)
local _, return_values = pack_pcall(vmf.safe_call_dofile(self, "(dofile)", file_path)) local _, return_values = pack_pcall(dmf.safe_call_dofile(self, "(dofile)", file_path))
return unpack(return_values, 1, return_values.n) return unpack(return_values, 1, return_values.n)
end end
-- ##################################################################################################################### -- #####################################################################################################################
-- ##### VMF internal functions and variables ########################################################################## -- ##### DMF internal functions and variables ##########################################################################
-- ##################################################################################################################### -- #####################################################################################################################
-- Safe Call -- Safe Call
function vmf.safe_call(mod, error_prefix_data, func, ...) function dmf.safe_call(mod, error_prefix_data, func, ...)
local success, return_values = pack_pcall(xpcall(func, print_error_callstack, ...)) local success, return_values = pack_pcall(xpcall(func, print_error_callstack, ...))
if not success then if not success then
show_error(mod, error_prefix_data, return_values[1]) show_error(mod, error_prefix_data, return_values[1])
@ -62,7 +62,7 @@ end
-- Safe Call [No return values] -- Safe Call [No return values]
function vmf.safe_call_nr(mod, error_prefix_data, func, ...) function dmf.safe_call_nr(mod, error_prefix_data, func, ...)
local success, error_message = xpcall(func, print_error_callstack, ...) local success, error_message = xpcall(func, print_error_callstack, ...)
if not success then if not success then
show_error(mod, error_prefix_data, error_message) show_error(mod, error_prefix_data, error_message)
@ -72,7 +72,7 @@ end
-- Safe Call [No return values and error callstack] -- Safe Call [No return values and error callstack]
function vmf.safe_call_nrc(mod, error_prefix_data, func, ...) function dmf.safe_call_nrc(mod, error_prefix_data, func, ...)
local success, error_message = pcall(func, ...) local success, error_message = pcall(func, ...)
if not success then if not success then
show_error(mod, error_prefix_data, error_message) show_error(mod, error_prefix_data, error_message)
@ -82,16 +82,16 @@ end
-- Safe Call [dofile] -- Safe Call [dofile]
function vmf.safe_call_dofile(mod, error_prefix_data, file_path) function dmf.safe_call_dofile(mod, error_prefix_data, file_path)
if type(file_path) ~= "string" then if type(file_path) ~= "string" then
show_error(mod, error_prefix_data, "file path should be a string.") show_error(mod, error_prefix_data, "file path should be a string.")
return false return false
end end
return vmf.safe_call(mod, error_prefix_data, mod_dofile, file_path) return dmf.safe_call(mod, error_prefix_data, mod_dofile, file_path)
end end
-- Format error message and throw error. -- Format error message and throw error.
function vmf.throw_error(error_message, ...) function dmf.throw_error(error_message, ...)
error(string.format(error_message, ...), 0) error(string.format(error_message, ...), 0)
end end

View file

@ -1,11 +1,11 @@
--[[ --[[
Settings manager. Settings manager.
* Operates settings within the mod namespace (you can define settings with the same name for different mods) * Operates settings within the mod namespace (you can define settings with the same name for different mods)
* Settings location: "%AppData%\Roaming\Fatshark\Warhammer End Times Vermintide\user_settings.config" * Settings location: "%AppData%\Roaming\Fatshark\Warhammer End Times Darktide\user_settings.config"
* All settings are saved to the settings-file when game state changes, when options menu is closed, and on reload * All settings are saved to the settings-file when game state changes, when options menu is closed, and on reload
* Serializable settings types: number, string, boolean, table (array-like and map-like, but not mixed) * Serializable settings types: number, string, boolean, table (array-like and map-like, but not mixed)
--]] --]]
local vmf = get_mod("VMF") local dmf = get_mod("DMF")
local _mods_settings = Application.user_setting("mods_settings") or {} local _mods_settings = Application.user_setting("mods_settings") or {}
@ -23,7 +23,7 @@ local function save_all_settings()
if string.find(error, "number expected, got string") then if string.find(error, "number expected, got string") then
error = "one of mods tried to save a mixed table" error = "one of mods tried to save a mixed table"
end end
vmf:error("Vermintide Mod Framework failed to save mods settings: %s", tostring(error)) dmf:error("Darktide Mod Framework failed to save mods settings: %s", tostring(error))
return return
end end
@ -33,7 +33,7 @@ local function save_all_settings()
end end
-- ##################################################################################################################### -- #####################################################################################################################
-- ##### VMFMod ######################################################################################################## -- ##### DMFMod ########################################################################################################
-- ##################################################################################################################### -- #####################################################################################################################
--[[ --[[
@ -43,7 +43,7 @@ end
* setting_value [anything]: setting value (can be any SJSON serializable format) * setting_value [anything]: setting value (can be any SJSON serializable format)
* notify_mod [bool] : if 'true', calls 'mod.on_setting_changed' event * notify_mod [bool] : if 'true', calls 'mod.on_setting_changed' event
--]] --]]
function VMFMod:set(setting_id, setting_value, notify_mod) function DMFMod:set(setting_id, setting_value, notify_mod)
local mod_name = self:get_name() local mod_name = self:get_name()
if not _mods_settings[mod_name] then if not _mods_settings[mod_name] then
@ -56,7 +56,7 @@ function VMFMod:set(setting_id, setting_value, notify_mod)
_there_are_unsaved_changes = true _there_are_unsaved_changes = true
if notify_mod then if notify_mod then
vmf.mod_setting_changed_event(self, setting_id) dmf.mod_setting_changed_event(self, setting_id)
end end
end end
@ -66,7 +66,7 @@ end
call. call.
* setting_id [string]: setting's identifier * setting_id [string]: setting's identifier
--]] --]]
function VMFMod:get(setting_id) function DMFMod:get(setting_id)
local mod_name = self:get_name() local mod_name = self:get_name()
local mod_settings = _mods_settings[mod_name] local mod_settings = _mods_settings[mod_name]
local setting_value = mod_settings and mod_settings[setting_id] local setting_value = mod_settings and mod_settings[setting_id]
@ -75,14 +75,14 @@ function VMFMod:get(setting_id)
end end
-- ##################################################################################################################### -- #####################################################################################################################
-- ##### VMF internal functions and variables ########################################################################## -- ##### DMF internal functions and variables ##########################################################################
-- ##################################################################################################################### -- #####################################################################################################################
function vmf.save_unsaved_settings_to_file() function dmf.save_unsaved_settings_to_file()
save_all_settings() save_all_settings()
end end
function vmf.mod_has_settings(mod) function dmf.mod_has_settings(mod)
if _mods_settings[mod:get_name()] then if _mods_settings[mod:get_name()] then
return true return true
end end

View file

@ -1,21 +1,21 @@
local vmf = get_mod("VMF") local dmf = get_mod("DMF")
local _disabled_mods = vmf:get("disabled_mods_list") or {} local _disabled_mods = dmf:get("disabled_mods_list") or {}
-- #################################################################################################################### -- ####################################################################################################################
-- ##### VMF internal functions and variables ######################################################################### -- ##### DMF internal functions and variables #########################################################################
-- #################################################################################################################### -- ####################################################################################################################
vmf.set_mod_state = function (mod, is_enabled, initial_call) dmf.set_mod_state = function (mod, is_enabled, initial_call)
vmf.set_internal_data(mod, "is_enabled", is_enabled) dmf.set_internal_data(mod, "is_enabled", is_enabled)
if is_enabled then if is_enabled then
mod:enable_all_hooks() mod:enable_all_hooks()
vmf.mod_enabled_event(mod, initial_call) dmf.mod_enabled_event(mod, initial_call)
else else
mod:disable_all_hooks() mod:disable_all_hooks()
vmf.mod_disabled_event(mod, initial_call) dmf.mod_disabled_event(mod, initial_call)
end end
if not (initial_call or mod:get_internal_data("is_mutator")) then if not (initial_call or mod:get_internal_data("is_mutator")) then
@ -24,29 +24,29 @@ vmf.set_mod_state = function (mod, is_enabled, initial_call)
else else
_disabled_mods[mod:get_name()] = true _disabled_mods[mod:get_name()] = true
end end
vmf:set("disabled_mods_list", _disabled_mods) dmf:set("disabled_mods_list", _disabled_mods)
end end
end end
-- Called when mod is loaded for the first time using mod:initialize() -- Called when mod is loaded for the first time using mod:initialize()
vmf.initialize_mod_state = function (mod) dmf.initialize_mod_state = function (mod)
local state local state
if mod:get_internal_data("is_mutator") then if mod:get_internal_data("is_mutator") then
-- if VMF was reloaded and mutator was activated -- if DMF was reloaded and mutator was activated
if vmf.is_mutator_enabled(mod:get_name()) then if dmf.is_mutator_enabled(mod:get_name()) then
state = true state = true
else else
state = false state = false
end end
vmf.set_mutator_state(mod, state, true) dmf.set_mutator_state(mod, state, true)
else else
state = not _disabled_mods[mod:get_name()] state = not _disabled_mods[mod:get_name()]
vmf.set_mod_state(mod, state, true) dmf.set_mod_state(mod, state, true)
end end
end end
vmf.mod_state_changed = function (mod_name, is_enabled) dmf.mod_state_changed = function (mod_name, is_enabled)
local mod = get_mod(mod_name) local mod = get_mod(mod_name)
@ -55,8 +55,8 @@ vmf.mod_state_changed = function (mod_name, is_enabled)
end end
if mod:get_internal_data("is_mutator") then if mod:get_internal_data("is_mutator") then
vmf.set_mutator_state(mod, is_enabled, false) dmf.set_mutator_state(mod, is_enabled, false)
else else
vmf.set_mod_state(mod, is_enabled, false) dmf.set_mod_state(mod, is_enabled, false)
end end
end end

View file

@ -1,4 +1,4 @@
local vmf = get_mod("VMF") local dmf = get_mod("DMF")
-- Note(Siku): This file could definitely use the hooking system if we could figure out a way. -- Note(Siku): This file could definitely use the hooking system if we could figure out a way.
-- It would requires hooks to be pushed higher in the loading order, but then we lose hooks printing to console -- It would requires hooks to be pushed higher in the loading order, but then we lose hooks printing to console
@ -7,7 +7,7 @@ local vmf = get_mod("VMF")
-- Global backup of the ffi library -- Global backup of the ffi library
local _ffi = Mods.lua.ffi local _ffi = Mods.lua.ffi
local _console_data = vmf:persistent_table("dev_console_data") local _console_data = dmf:persistent_table("dev_console_data")
if not _console_data.enabled then _console_data.enabled = false end if not _console_data.enabled then _console_data.enabled = false end
if not _console_data.original_print then _console_data.original_print = print end if not _console_data.original_print then _console_data.original_print = print end
@ -46,7 +46,7 @@ local function close_dev_console()
CommandWindow.close() CommandWindow.close()
-- CommandWindow won't close by itself, so it have to be closed manually -- CommandWindow won't close by itself, so it have to be closed manually
vmf:pcall(function() dmf:pcall(function()
_ffi.cdef([[ _ffi.cdef([[
void* FindWindowA(const char* lpClassName, const char* lpWindowName); void* FindWindowA(const char* lpClassName, const char* lpWindowName);
int64_t SendMessageA(void* hWnd, unsigned int Msg, uint64_t wParam, int64_t lParam); int64_t SendMessageA(void* hWnd, unsigned int Msg, uint64_t wParam, int64_t lParam);
@ -61,29 +61,29 @@ local function close_dev_console()
end end
-- #################################################################################################################### -- ####################################################################################################################
-- ##### VMF internal functions and variables ######################################################################### -- ##### DMF internal functions and variables #########################################################################
-- #################################################################################################################### -- ####################################################################################################################
vmf.toggle_developer_console = function () dmf.toggle_developer_console = function ()
if vmf:get("developer_mode") then if dmf:get("developer_mode") then
local show_console = not vmf:get("show_developer_console") local show_console = not dmf:get("show_developer_console")
vmf:set("show_developer_console", show_console) dmf:set("show_developer_console", show_console)
vmf.load_dev_console_settings() dmf.load_dev_console_settings()
if show_console then if show_console then
vmf:echo(vmf:localize("dev_console_opened")) dmf:echo(dmf:localize("dev_console_opened"))
else else
vmf:echo(vmf:localize("dev_console_closed")) dmf:echo(dmf:localize("dev_console_closed"))
end end
end end
end end
vmf.load_dev_console_settings = function() dmf.load_dev_console_settings = function()
if vmf:get("developer_mode") and vmf:get("show_developer_console") then if dmf:get("developer_mode") and dmf:get("show_developer_console") then
open_dev_console() open_dev_console()
else else
close_dev_console() close_dev_console()
@ -94,4 +94,4 @@ end
-- ##### Script ####################################################################################################### -- ##### Script #######################################################################################################
-- #################################################################################################################### -- ####################################################################################################################
vmf.load_dev_console_settings() dmf.load_dev_console_settings()

View file

@ -1,4 +1,4 @@
local vmf = get_mod("VMF") -- @TODO: remove it? local dmf = get_mod("DMF") -- @TODO: remove it?
-- Global backup of the io library -- Global backup of the io library
@ -45,10 +45,10 @@ local function table_dump(key, value, depth, max_depth)
end end
end end
VMFMod.dump = function (self, dumped_object, dumped_object_name, max_depth) DMFMod.dump = function (self, dumped_object, dumped_object_name, max_depth)
if vmf.check_wrong_argument_type(self, "dump", "dumped_object_name", dumped_object_name, "string", "nil") or if dmf.check_wrong_argument_type(self, "dump", "dumped_object_name", dumped_object_name, "string", "nil") or
vmf.check_wrong_argument_type(self, "dump", "max_depth", max_depth, "number") dmf.check_wrong_argument_type(self, "dump", "max_depth", max_depth, "number")
then then
return return
end end
@ -332,10 +332,10 @@ local function table_dump_to_file(dumped_table, dumped_table_name, max_depth)
end end
VMFMod.dump_to_file = function (self, dumped_object, object_name, max_depth) DMFMod.dump_to_file = function (self, dumped_object, object_name, max_depth)
if vmf.check_wrong_argument_type(self, "dump_to_file", "object_name", object_name, "string") or if dmf.check_wrong_argument_type(self, "dump_to_file", "object_name", object_name, "string") or
vmf.check_wrong_argument_type(self, "dump_to_file", "max_depth", max_depth, "number") dmf.check_wrong_argument_type(self, "dump_to_file", "max_depth", max_depth, "number")
then then
return return
end end
@ -359,6 +359,6 @@ VMFMod.dump_to_file = function (self, dumped_object, object_name, max_depth)
end end
end end
VMFMod.dtf = VMFMod.dump_to_file DMFMod.dtf = DMFMod.dump_to_file
-- Managers.curl._requests crashes the game -- Managers.curl._requests crashes the game

View file

@ -0,0 +1,4 @@
local dmf = get_mod("DMF")
-- Add dmf functions with a value of dummy_func if they need to be defined while a module is disabled.
local dummy_func = function() return end

View file

@ -7,15 +7,15 @@ local function set_internal_data(mod, key, value)
end end
-- ##################################################################################################################### -- #####################################################################################################################
-- ##### VMFMod (not API) ############################################################################################## -- ##### DMFMod (not API) ##############################################################################################
-- ##################################################################################################################### -- #####################################################################################################################
-- Defining VMFMod class. -- Defining DMFMod class.
VMFMod = class("VMFMod") DMFMod = class("DMFMod")
-- Creating mod data table when object of VMFMod class is created. -- Creating mod data table when object of DMFMod class is created.
function VMFMod:init(mod_name) function DMFMod:init(mod_name)
if mod_name == "VMF" then if mod_name == "DMF" then
self.set_internal_data = set_internal_data self.set_internal_data = set_internal_data
end end
@ -36,17 +36,17 @@ function VMFMod:init(mod_name)
set_internal_data(self, "workshop_name", vanilla_mod_data.name) set_internal_data(self, "workshop_name", vanilla_mod_data.name)
set_internal_data(self, "mod_handle", vanilla_mod_data.handle) set_internal_data(self, "mod_handle", vanilla_mod_data.handle)
print(string.format("Init VMF mod '%s' [workshop_name: '%s', workshop_id: %s]", mod_name, vanilla_mod_data.name, print(string.format("Init DMF mod '%s' [workshop_name: '%s', workshop_id: %s]", mod_name, vanilla_mod_data.name,
vanilla_mod_data.id)) vanilla_mod_data.id))
end end
-- ##################################################################################################################### -- #####################################################################################################################
-- ##### VMFMod ######################################################################################################## -- ##### DMFMod ########################################################################################################
-- ##################################################################################################################### -- #####################################################################################################################
--[[ --[[
Universal function for retrieving any internal mod data. Returned table values shouldn't be modified, because it can Universal function for retrieving any internal mod data. Returned table values shouldn't be modified, because it can
lead to unexpected VMF behaviour. lead to unexpected DMF behaviour.
* key [string]: data entry name * key [string]: data entry name
Possible entry names: Possible entry names:
@ -58,7 +58,7 @@ end
- is_mutator (if the mod is mutator) - is_mutator (if the mod is mutator)
- mutator_config (mutator config) - mutator_config (mutator config)
--]] --]]
function VMFMod:get_internal_data(key) function DMFMod:get_internal_data(key)
return self._data[key] return self._data[key]
end end
@ -66,15 +66,15 @@ end
--[[ --[[
Predefined functions for retrieving specific internal mod data. Predefined functions for retrieving specific internal mod data.
--]] --]]
function VMFMod:get_name() function DMFMod:get_name()
return self._data.name return self._data.name
end end
function VMFMod:get_readable_name() function DMFMod:get_readable_name()
return self._data.readable_name return self._data.readable_name
end end
function VMFMod:get_description() function DMFMod:get_description()
return self._data.description return self._data.description
end end
function VMFMod:is_enabled() function DMFMod:is_enabled()
return self._data.is_enabled return self._data.is_enabled
end end

View file

@ -1,4 +1,4 @@
local vmf = nil local dmf = nil
local _mods = {} local _mods = {}
local _mods_unloading_order = {} local _mods_unloading_order = {}
@ -6,24 +6,24 @@ local _mods_unloading_order = {}
local ERRORS = { local ERRORS = {
REGULAR = { REGULAR = {
-- create_mod: -- create_mod:
duplicate_mod_name = "[VMF Mod Manager] (new_mod) Creating mod object: you can't use name '%s' for your mod " .. duplicate_mod_name = "[DMF Mod Manager] (new_mod) Creating mod object: you can't use name '%s' for your mod " ..
"because mod with the same name already exists.", "because mod with the same name already exists.",
-- new_mod: -- new_mod:
mod_name_wrong_type = "[VMF Mod Manager] (new_mod): first argument ('mod_name') should be a string, not %s.", mod_name_wrong_type = "[DMF Mod Manager] (new_mod): first argument ('mod_name') should be a string, not %s.",
mod_resources_wrong_type = "[VMF Mod Manager] (new_mod) '%s': second argument ('mod_resources') should be a " .. mod_resources_wrong_type = "[DMF Mod Manager] (new_mod) '%s': second argument ('mod_resources') should be a " ..
"table, not %s.", "table, not %s.",
too_late_for_mod_creation = "[VMF Mod Manager] (new_mod) '%s': you can't create mods after vanilla mod manager " .. too_late_for_mod_creation = "[DMF Mod Manager] (new_mod) '%s': you can't create mods after vanilla mod manager " ..
"finishes loading mod bundles.", "finishes loading mod bundles.",
-- vmf.initialize_mod_data: -- dmf.initialize_mod_data:
mod_data_wrong_type = "[VMF Mod Manager] (new_mod) 'mod_data' initialization: mod_data file should return " .. mod_data_wrong_type = "[DMF Mod Manager] (new_mod) 'mod_data' initialization: mod_data file should return " ..
"table, not %s.", "table, not %s.",
mod_options_initializing_failed = "[VMF Mod Manager] (new_mod) mod options initialization: could not initialize " .. mod_options_initializing_failed = "[DMF Mod Manager] (new_mod) mod options initialization: could not initialize " ..
"mod's options. %s", "mod's options. %s",
}, },
PREFIX = { PREFIX = {
mod_localization_initialization = "[VMF Mod Manager] (new_mod) 'mod_localization' initialization", mod_localization_initialization = "[DMF Mod Manager] (new_mod) 'mod_localization' initialization",
mod_data_initialization = "[VMF Mod Manager] (new_mod) 'mod_data' initialization", mod_data_initialization = "[DMF Mod Manager] (new_mod) 'mod_data' initialization",
mod_script_initialization = "[VMF Mod Manager] (new_mod) 'mod_script' initialization", mod_script_initialization = "[DMF Mod Manager] (new_mod) 'mod_script' initialization",
}, },
} }
@ -33,13 +33,13 @@ local ERRORS = {
local function create_mod(mod_name) local function create_mod(mod_name)
if _mods[mod_name] then if _mods[mod_name] then
vmf:error(ERRORS.REGULAR.duplicate_mod_name, mod_name) dmf:error(ERRORS.REGULAR.duplicate_mod_name, mod_name)
return return
end end
table.insert(_mods_unloading_order, 1, mod_name) table.insert(_mods_unloading_order, 1, mod_name)
local mod = VMFMod:new(mod_name) local mod = DMFMod:new(mod_name)
_mods[mod_name] = mod _mods[mod_name] = mod
return mod return mod
@ -50,9 +50,9 @@ local function resolve_resource(mod, error_prefix_data, resource, resource_value
local type_value = type(resource_value) local type_value = type(resource_value)
if type_value == "string" then if type_value == "string" then
return vmf.safe_call_dofile(mod, error_prefix_data, resource_value) return dmf.safe_call_dofile(mod, error_prefix_data, resource_value)
elseif type_value == "function" then elseif type_value == "function" then
return vmf.safe_call(mod, error_prefix_data, resource_value, mod) return dmf.safe_call(mod, error_prefix_data, resource_value, mod)
elseif type_value == "table" then elseif type_value == "table" then
return true, type_value return true, type_value
end end
@ -79,13 +79,13 @@ local function load_mod_resource(mod, mod_resources, resource)
return false return false
end end
-- Check if there's a VMF initializator for this resource, and execute it if it exists. -- Check if there's a DMF initializator for this resource, and execute it if it exists.
local vmf_initializator = vmf["initialize_mod_" .. resource] local dmf_initializator = dmf["initialize_mod_" .. resource]
if not vmf_initializator then if not dmf_initializator then
return true return true
end end
return vmf_initializator(mod, return_value) return dmf_initializator(mod, return_value)
end end
-- ##################################################################################################################### -- #####################################################################################################################
@ -94,16 +94,16 @@ end
function new_mod(mod_name, mod_resources) function new_mod(mod_name, mod_resources)
if type(mod_name) ~= "string" then if type(mod_name) ~= "string" then
vmf:error(ERRORS.REGULAR.mod_name_wrong_type, type(mod_name)) dmf:error(ERRORS.REGULAR.mod_name_wrong_type, type(mod_name))
return return
end end
if type(mod_resources) ~= "table" then if type(mod_resources) ~= "table" then
vmf:error(ERRORS.REGULAR.mod_resources_wrong_type, mod_name, type(mod_resources)) dmf:error(ERRORS.REGULAR.mod_resources_wrong_type, mod_name, type(mod_resources))
return return
end end
if vmf.all_mods_were_loaded then if dmf.all_mods_were_loaded then
vmf:error(ERRORS.REGULAR.too_late_for_mod_creation, mod_name) dmf:error(ERRORS.REGULAR.too_late_for_mod_creation, mod_name)
return return
end end
@ -125,7 +125,7 @@ function new_mod(mod_name, mod_resources)
-- Initialize mod state -- Initialize mod state
if mod:get_internal_data("is_togglable") then if mod:get_internal_data("is_togglable") then
vmf.initialize_mod_state(mod) dmf.initialize_mod_state(mod)
end end
return mod return mod
@ -137,18 +137,18 @@ function get_mod(mod_name)
end end
-- ##################################################################################################################### -- #####################################################################################################################
-- ##### VMF Initialization ############################################################################################ -- ##### DMF Initialization ############################################################################################
-- ##################################################################################################################### -- #####################################################################################################################
vmf = create_mod("VMF") dmf = create_mod("DMF")
-- ##################################################################################################################### -- #####################################################################################################################
-- ##### VMF internal functions and variables ########################################################################## -- ##### DMF internal functions and variables ##########################################################################
-- ##################################################################################################################### -- #####################################################################################################################
-- MOD DATA INITIALIZATION -- MOD DATA INITIALIZATION
function vmf.initialize_mod_data(mod, mod_data) function dmf.initialize_mod_data(mod, mod_data)
if type(mod_data) ~= "table" then if type(mod_data) ~= "table" then
mod:error(ERRORS.REGULAR.mod_data_wrong_type, type(mod_data)) mod:error(ERRORS.REGULAR.mod_data_wrong_type, type(mod_data))
return return
@ -156,21 +156,21 @@ function vmf.initialize_mod_data(mod, mod_data)
-- Set internal mod data -- Set internal mod data
if mod_data.name then if mod_data.name then
vmf.set_internal_data(mod, "readable_name", mod_data.name) dmf.set_internal_data(mod, "readable_name", mod_data.name)
end end
vmf.set_internal_data(mod, "description", mod_data.description) dmf.set_internal_data(mod, "description", mod_data.description)
vmf.set_internal_data(mod, "is_togglable", mod_data.is_togglable or mod_data.is_mutator) dmf.set_internal_data(mod, "is_togglable", mod_data.is_togglable or mod_data.is_mutator)
vmf.set_internal_data(mod, "is_mutator", mod_data.is_mutator) dmf.set_internal_data(mod, "is_mutator", mod_data.is_mutator)
vmf.set_internal_data(mod, "allow_rehooking", mod_data.allow_rehooking) dmf.set_internal_data(mod, "allow_rehooking", mod_data.allow_rehooking)
-- Register mod as mutator @TODO: calling this after options initialization would be better, I guess? -- Register mod as mutator @TODO: calling this after options initialization would be better, I guess?
if mod_data.is_mutator then if mod_data.is_mutator then
vmf.register_mod_as_mutator(mod, mod_data.mutator_settings) dmf.register_mod_as_mutator(mod, mod_data.mutator_settings)
end end
-- Mod's options initialization -- Mod's options initialization
if mod_data.options or ((mod_data.is_togglable and not mod_data.is_mutator) and not mod_data.options_widgets) then if mod_data.options or ((mod_data.is_togglable and not mod_data.is_mutator) and not mod_data.options_widgets) then
local success, error_message = pcall(vmf.initialize_mod_options, mod, mod_data.options) local success, error_message = pcall(dmf.initialize_mod_options, mod, mod_data.options)
if not success then if not success then
mod:error(ERRORS.REGULAR.mod_options_initializing_failed, error_message) mod:error(ERRORS.REGULAR.mod_options_initializing_failed, error_message)
return return
@ -187,5 +187,5 @@ end
-- VARIABLES -- VARIABLES
vmf.mods = _mods dmf.mods = _mods
vmf.mods_unloading_order = _mods_unloading_order dmf.mods_unloading_order = _mods_unloading_order

View file

@ -1,19 +1,19 @@
local vmf = get_mod("VMF") local dmf = get_mod("DMF")
local vmf_mod_data = {} local dmf_mod_data = {}
vmf_mod_data.name = "Darktide Mod Framework" dmf_mod_data.name = "Darktide Mod Framework"
vmf_mod_data.options = { dmf_mod_data.options = {
widgets = { widgets = {
{ {
setting_id = "open_vmf_options", setting_id = "open_dmf_options",
type = "keybind", type = "keybind",
default_value = {"f4"}, default_value = {"f4"},
keybind_trigger = "pressed", keybind_trigger = "pressed",
keybind_type = "view_toggle", keybind_type = "view_toggle",
view_name = "vmf_options_view" view_name = "dmf_options_view"
}, },
{ {
setting_id = "vmf_options_scrolling_speed", setting_id = "dmf_options_scrolling_speed",
type = "numeric", type = "numeric",
default_value = 100, default_value = 100,
range = {1, 1000}, range = {1, 1000},
@ -194,36 +194,36 @@ vmf_mod_data.options = {
} }
-- #################################################################################################################### -- ####################################################################################################################
-- ##### VMF internal functions and variables ######################################################################### -- ##### DMF internal functions and variables #########################################################################
-- #################################################################################################################### -- ####################################################################################################################
vmf.on_setting_changed = function (setting_id) dmf.on_setting_changed = function (setting_id)
if setting_id == "vmf_options_scrolling_speed" then if setting_id == "dmf_options_scrolling_speed" then
-- Not necessary until the view is loaded -- Not necessary until the view is loaded
if vmf.load_vmf_options_view_settings then if dmf.load_dmf_options_view_settings then
vmf.load_vmf_options_view_settings() dmf.load_dmf_options_view_settings()
end end
elseif setting_id == "developer_mode" then elseif setting_id == "developer_mode" then
vmf.load_developer_mode_settings() dmf.load_developer_mode_settings()
vmf.load_network_settings() dmf.load_network_settings()
vmf.load_custom_textures_settings() dmf.load_custom_textures_settings()
vmf.load_dev_console_settings() dmf.load_dev_console_settings()
elseif setting_id == "show_developer_console" then elseif setting_id == "show_developer_console" then
vmf.load_dev_console_settings() dmf.load_dev_console_settings()
elseif setting_id == "show_network_debug_info" then elseif setting_id == "show_network_debug_info" then
vmf.load_network_settings() dmf.load_network_settings()
elseif setting_id == "log_ui_renderers_info" then elseif setting_id == "log_ui_renderers_info" then
vmf.load_custom_textures_settings() dmf.load_custom_textures_settings()
elseif setting_id == "logging_mode" elseif setting_id == "logging_mode"
or setting_id == "output_mode_notification" or setting_id == "output_mode_notification"
@ -233,7 +233,7 @@ vmf.on_setting_changed = function (setting_id)
or setting_id == "output_mode_info" or setting_id == "output_mode_info"
or setting_id == "output_mode_debug" then or setting_id == "output_mode_debug" then
vmf.load_logging_settings() dmf.load_logging_settings()
elseif setting_id == "chat_history_enable" elseif setting_id == "chat_history_enable"
or setting_id == "chat_history_save" or setting_id == "chat_history_save"
@ -242,14 +242,14 @@ vmf.on_setting_changed = function (setting_id)
or setting_id == "chat_history_remove_dups_mode" or setting_id == "chat_history_remove_dups_mode"
or setting_id == "chat_history_commands_only" then or setting_id == "chat_history_commands_only" then
vmf.load_chat_history_settings(setting_id == "chat_history_enable" or dmf.load_chat_history_settings(setting_id == "chat_history_enable" or
setting_id == "chat_history_buffer_size" or setting_id == "chat_history_buffer_size" or
setting_id == "chat_history_commands_only") setting_id == "chat_history_commands_only")
end end
end end
vmf.load_developer_mode_settings = function () --@TODO: maybe move it to somewhere else? dmf.load_developer_mode_settings = function () --@TODO: maybe move it to somewhere else?
Managers.mod._settings.developer_mode = vmf:get("developer_mode") Managers.mod._settings.developer_mode = dmf:get("developer_mode")
Application.set_user_setting("mod_settings", Managers.mod._settings) Application.set_user_setting("mod_settings", Managers.mod._settings)
end end
@ -257,23 +257,23 @@ end
-- ##### Script ####################################################################################################### -- ##### Script #######################################################################################################
-- #################################################################################################################### -- ####################################################################################################################
vmf.initialize_mod_data(vmf, vmf_mod_data) dmf.initialize_mod_data(dmf, dmf_mod_data)
-- first VMF initialization -- first DMF initialization
-- it will be run only 1 time, when the player launch the game with VMF for the first time -- it will be run only 1 time, when the player launch the game with DMF for the first time
if not vmf:get("vmf_initialized") then if not dmf:get("dmf_initialized") then
vmf.load_logging_settings() dmf.load_logging_settings()
vmf.load_developer_mode_settings() dmf.load_developer_mode_settings()
vmf.load_network_settings() dmf.load_network_settings()
vmf.load_custom_textures_settings() dmf.load_custom_textures_settings()
vmf.load_dev_console_settings() dmf.load_dev_console_settings()
vmf.load_chat_history_settings() dmf.load_chat_history_settings()
-- Not necessary until the view is loaded -- Not necessary until the view is loaded
if vmf.load_vmf_options_view_settings then if dmf.load_dmf_options_view_settings then
vmf.load_vmf_options_view_settings() dmf.load_dmf_options_view_settings()
end end
vmf:set("vmf_initialized", true) dmf:set("dmf_initialized", true)
end end

View file

@ -1,4 +1,4 @@
local vmf = get_mod("VMF") local dmf = get_mod("DMF")
local _packages = {} local _packages = {}
local _queued_packages = {} local _queued_packages = {}
@ -12,25 +12,25 @@ local PUBLIC_STATUSES = {
local ERRORS = { local ERRORS = {
REGULAR = { REGULAR = {
-- VMFMod:load_package: -- DMFMod:load_package:
package_already_loaded = "[VMF Package Manager] (load_package): package '%s' has already been loaded.", package_already_loaded = "[DMF Package Manager] (load_package): package '%s' has already been loaded.",
package_not_found = "[VMF Package Manager] (load_package): could not find package '%s'.", package_not_found = "[DMF Package Manager] (load_package): could not find package '%s'.",
package_already_queued = "[VMF Package Manager] (load_package): package '%s' is already queued for loading.", package_already_queued = "[DMF Package Manager] (load_package): package '%s' is already queued for loading.",
-- VMFMod:unload_package: -- DMFMod:unload_package:
package_not_loaded = "[VMF Package Manager] (unload_package): package '%s' has not been loaded.", package_not_loaded = "[DMF Package Manager] (unload_package): package '%s' has not been loaded.",
cant_unload_loading_package = "[VMF Package Manager] (unload_package): package '%s' can't be unloaded because " .. cant_unload_loading_package = "[DMF Package Manager] (unload_package): package '%s' can't be unloaded because " ..
"it's currently loading." "it's currently loading."
}, },
PREFIX = { PREFIX = {
package_loaded_callback = "[VMF Package Manager] '%s' package loaded callback execution" package_loaded_callback = "[DMF Package Manager] '%s' package loaded callback execution"
} }
} }
local WARNINGS = { local WARNINGS = {
force_unloading_package = "[VMF Package Manager] Force-unloading package '%s'. Please make sure to properly " .. force_unloading_package = "[DMF Package Manager] Force-unloading package '%s'. Please make sure to properly " ..
"release packages when the mod is unloaded", "release packages when the mod is unloaded",
still_loading_package = "[VMF Package Manager] Still loading package '%s'. Memory leaks may occur when unloading " .. still_loading_package = "[DMF Package Manager] Still loading package '%s'. Memory leaks may occur when unloading " ..
"while a package is loading." "while a package is loading."
} }
@ -51,7 +51,7 @@ local function flush_package(package_name)
package_data.status = "loaded" package_data.status = "loaded"
local callback = package_data.callback local callback = package_data.callback
if callback then if callback then
vmf.safe_call_nr(package_data.mod, {ERRORS.PREFIX.package_loaded_callback, package_name}, callback, package_name) dmf.safe_call_nr(package_data.mod, {ERRORS.PREFIX.package_loaded_callback, package_name}, callback, package_name)
end end
end end
end end
@ -67,7 +67,7 @@ local function remove_package_from_queue(package_name)
end end
-- ##################################################################################################################### -- #####################################################################################################################
-- ##### VMFMod ######################################################################################################## -- ##### DMFMod ########################################################################################################
-- ##################################################################################################################### -- #####################################################################################################################
--[[ --[[
@ -76,10 +76,10 @@ end
* callback [function]: (optional) callback for when loading is done * callback [function]: (optional) callback for when loading is done
* sync [boolean] : (optional) load the packages synchronously, freezing the game until it is loaded * sync [boolean] : (optional) load the packages synchronously, freezing the game until it is loaded
--]] --]]
function VMFMod:load_package(package_name, callback, sync) function DMFMod:load_package(package_name, callback, sync)
if vmf.check_wrong_argument_type(self, "load_package", "package_name", package_name, "string") or if dmf.check_wrong_argument_type(self, "load_package", "package_name", package_name, "string") or
vmf.check_wrong_argument_type(self, "load_package", "callback", callback, "function", "nil") or dmf.check_wrong_argument_type(self, "load_package", "callback", callback, "function", "nil") or
vmf.check_wrong_argument_type(self, "load_package", "sync", sync, "boolean", "nil") dmf.check_wrong_argument_type(self, "load_package", "sync", sync, "boolean", "nil")
then then
return return
end end
@ -137,8 +137,8 @@ end
Unloads a loaded mod package. Unloads a loaded mod package.
* package_name [string]: package name. needs to be the full path to the `.package` file without the extension * package_name [string]: package name. needs to be the full path to the `.package` file without the extension
--]] --]]
function VMFMod:unload_package(package_name) function DMFMod:unload_package(package_name)
if vmf.check_wrong_argument_type(self, "unload_package", "package_name", package_name, "string") if dmf.check_wrong_argument_type(self, "unload_package", "package_name", package_name, "string")
then then
return return
end end
@ -165,8 +165,8 @@ end
Returns package status string. Returns package status string.
* package_name [string]: package name. needs to be the full path to the `.package` file without the extension * package_name [string]: package name. needs to be the full path to the `.package` file without the extension
--]] --]]
function VMFMod:package_status(package_name) function DMFMod:package_status(package_name)
if vmf.check_wrong_argument_type(self, "package_status", "package_name", package_name, "string") if dmf.check_wrong_argument_type(self, "package_status", "package_name", package_name, "string")
then then
return return
end end
@ -178,11 +178,11 @@ function VMFMod:package_status(package_name)
end end
-- ##################################################################################################################### -- #####################################################################################################################
-- ##### VMF internal functions and variables ########################################################################## -- ##### DMF internal functions and variables ##########################################################################
-- ##################################################################################################################### -- #####################################################################################################################
-- Loads queued packages one at a time. -- Loads queued packages one at a time.
function vmf.update_package_manager() function dmf.update_package_manager()
local queued_package_name = _queued_packages[1] local queued_package_name = _queued_packages[1]
if queued_package_name then if queued_package_name then
local package_data = _packages[queued_package_name] local package_data = _packages[queued_package_name]
@ -202,7 +202,7 @@ end
-- Forcefully unloads all not unloaded packages. -- Forcefully unloads all not unloaded packages.
function vmf.unload_all_resource_packages() function dmf.unload_all_resource_packages()
for package_name, package_data in pairs(_packages) do for package_name, package_data in pairs(_packages) do
local package_status = package_data.status local package_status = package_data.status

View file

@ -1,4 +1,4 @@
local vmf = get_mod("VMF") local dmf = get_mod("DMF")
local _show_debug_info = false local _show_debug_info = false
@ -11,18 +11,18 @@ local function check_texture_availability(mod, texture_name)
end end
-- #################################################################################################################### -- ####################################################################################################################
-- ##### VMFMod ####################################################################################################### -- ##### DMFMod #######################################################################################################
-- #################################################################################################################### -- ####################################################################################################################
vmf.custom_textures = function (mod, ...) dmf.custom_textures = function (mod, ...)
-- @TODO: Not implemented -- @TODO: Not implemented
end end
vmf.custom_atlas = function (mod, ...) dmf.custom_atlas = function (mod, ...)
-- @TODO: Not implemented -- @TODO: Not implemented
end end
vmf.inject_materials = function (mod, ...) dmf.inject_materials = function (mod, ...)
-- @TODO: Not implemented -- @TODO: Not implemented
end end
@ -31,19 +31,19 @@ end
-- #################################################################################################################### -- ####################################################################################################################
-- #################################################################################################################### -- ####################################################################################################################
-- ##### VMF internal functions and variables ######################################################################### -- ##### DMF internal functions and variables #########################################################################
-- #################################################################################################################### -- ####################################################################################################################
vmf.load_custom_textures_settings = function() dmf.load_custom_textures_settings = function()
_show_debug_info = vmf:get("developer_mode") and vmf:get("log_ui_renderers_info") _show_debug_info = dmf:get("developer_mode") and dmf:get("log_ui_renderers_info")
end end
vmf.reset_guis = function() dmf.reset_guis = function()
-- @TODO: Method to reset VMF-spawned guis -- @TODO: Method to reset DMF-spawned guis
end end
-- #################################################################################################################### -- ####################################################################################################################
-- ##### Script ####################################################################################################### -- ##### Script #######################################################################################################
-- #################################################################################################################### -- ####################################################################################################################
vmf.load_custom_textures_settings() dmf.load_custom_textures_settings()

View file

@ -1,6 +1,6 @@
local vmf = get_mod("VMF") local dmf = get_mod("DMF")
local _custom_view_data = vmf:persistent_table("custom_view_data") local _custom_view_data = dmf:persistent_table("custom_view_data")
local _ingame_ui local _ingame_ui
local _views_data = {} local _views_data = {}
@ -75,21 +75,21 @@ local function inject_view(view_name)
-- Check for collisions. @TODO: Check for collisions by mod -- Check for collisions. @TODO: Check for collisions by mod
--if _ingame_ui._view_list[view_name] then --if _ingame_ui._view_list[view_name] then
-- vmf.throw_error(ERRORS.THROWABLE.view_already_exists, view_name) -- dmf.throw_error(ERRORS.THROWABLE.view_already_exists, view_name)
--end --end
--for transition_name, _ in pairs(transitions) do --for transition_name, _ in pairs(transitions) do
-- if _ingame_ui_transitions[transition_name] then -- if _ingame_ui_transitions[transition_name] then
-- vmf.throw_error(ERRORS.THROWABLE.transition_already_exists, transition_name) -- dmf.throw_error(ERRORS.THROWABLE.transition_already_exists, transition_name)
-- end -- end
--end --end
-- Initialize and inject view. -- Initialize and inject view.
local success = vmf.safe_call(mod, ERRORS.PREFIX.view_initializing, init_view_function, local success = dmf.safe_call(mod, ERRORS.PREFIX.view_initializing, init_view_function,
view_settings, {}) view_settings, {})
if success then if success then
_ingame_ui._view_list[view_name] = view_settings _ingame_ui._view_list[view_name] = view_settings
else else
vmf.throw_error(ERRORS.THROWABLE.view_initializing_failed) dmf.throw_error(ERRORS.THROWABLE.view_initializing_failed)
end end
-- Inject view transitions. -- Inject view transitions.
@ -133,13 +133,13 @@ end
local function validate_view_data(view_data) local function validate_view_data(view_data)
-- Basic checks. -- Basic checks.
if type(view_data.view_name) ~= "string" then if type(view_data.view_name) ~= "string" then
vmf.throw_error(ERRORS.THROWABLE.view_name_wrong_type, type(view_data.view_name)) dmf.throw_error(ERRORS.THROWABLE.view_name_wrong_type, type(view_data.view_name))
end end
if type(view_data.view_transitions) ~= "table" then if type(view_data.view_transitions) ~= "table" then
vmf.throw_error(ERRORS.THROWABLE.view_transitions_wrong_type, type(view_data.view_transitions)) dmf.throw_error(ERRORS.THROWABLE.view_transitions_wrong_type, type(view_data.view_transitions))
end end
if type(view_data.view_settings) ~= "table" then if type(view_data.view_settings) ~= "table" then
vmf.throw_error(ERRORS.THROWABLE.view_settings_wrong_type, type(view_data.view_settings)) dmf.throw_error(ERRORS.THROWABLE.view_settings_wrong_type, type(view_data.view_settings))
end end
-- VIEW TRANSITIONS -- VIEW TRANSITIONS
@ -147,12 +147,12 @@ local function validate_view_data(view_data)
local view_transitions = view_data.view_transitions local view_transitions = view_data.view_transitions
for transition_name, transition_function in pairs(view_transitions) do for transition_name, transition_function in pairs(view_transitions) do
if type(transition_function) ~= "function" then if type(transition_function) ~= "function" then
vmf.throw_error(ERRORS.THROWABLE.transition_wrong_type, transition_name, type(transition_function)) dmf.throw_error(ERRORS.THROWABLE.transition_wrong_type, transition_name, type(transition_function))
end end
for another_view_name, another_view_data in pairs(_views_data) do for another_view_name, another_view_data in pairs(_views_data) do
for another_transition_name, _ in pairs(another_view_data.view_transitions) do for another_transition_name, _ in pairs(another_view_data.view_transitions) do
if transition_name == another_transition_name then if transition_name == another_transition_name then
vmf.throw_error(ERRORS.THROWABLE.transition_name_taken, transition_name, another_view_data.mod:get_name(), dmf.throw_error(ERRORS.THROWABLE.transition_name_taken, transition_name, another_view_data.mod:get_name(),
another_view_name) another_view_name)
end end
end end
@ -168,24 +168,24 @@ local function validate_view_data(view_data)
-- Verify everything. -- Verify everything.
if type(view_settings.init_view_function) ~= "function" then if type(view_settings.init_view_function) ~= "function" then
vmf.throw_error(ERRORS.THROWABLE.init_view_function_wrong_type, type(view_settings.init_view_function)) dmf.throw_error(ERRORS.THROWABLE.init_view_function_wrong_type, type(view_settings.init_view_function))
end end
-- Verify active if present -- Verify active if present
local active = view_settings.active local active = view_settings.active
if active then if active then
if type(active) ~= "table" then if type(active) ~= "table" then
vmf.throw_error(ERRORS.THROWABLE.active_wrong_type, type(active)) dmf.throw_error(ERRORS.THROWABLE.active_wrong_type, type(active))
end end
if active.inn == nil or active.ingame == nil then if active.inn == nil or active.ingame == nil then
vmf.throw_error(ERRORS.THROWABLE.active_missing_element) dmf.throw_error(ERRORS.THROWABLE.active_missing_element)
end end
for level_name, value in pairs(active) do for level_name, value in pairs(active) do
if level_name ~= "inn" and level_name ~= "ingame" then if level_name ~= "inn" and level_name ~= "ingame" then
vmf.throw_error(ERRORS.THROWABLE.active_element_wrong_name, level_name) dmf.throw_error(ERRORS.THROWABLE.active_element_wrong_name, level_name)
end end
if type(value) ~= "boolean" then if type(value) ~= "boolean" then
vmf.throw_error(ERRORS.THROWABLE.active_element_wrong_type, level_name, type(value)) dmf.throw_error(ERRORS.THROWABLE.active_element_wrong_type, level_name, type(value))
end end
end end
end end
@ -194,25 +194,25 @@ local function validate_view_data(view_data)
local blocked_transitions = view_settings.blocked_transitions local blocked_transitions = view_settings.blocked_transitions
if blocked_transitions then if blocked_transitions then
if type(blocked_transitions) ~= "table" then if type(blocked_transitions) ~= "table" then
vmf.throw_error(ERRORS.THROWABLE.blocked_transitions_wrong_type, type(blocked_transitions)) dmf.throw_error(ERRORS.THROWABLE.blocked_transitions_wrong_type, type(blocked_transitions))
end end
if not blocked_transitions.inn or not blocked_transitions.ingame then if not blocked_transitions.inn or not blocked_transitions.ingame then
vmf.throw_error(ERRORS.THROWABLE.blocked_transitions_missing_element) dmf.throw_error(ERRORS.THROWABLE.blocked_transitions_missing_element)
end end
for level_name, level_blocked_transitions in pairs(blocked_transitions) do for level_name, level_blocked_transitions in pairs(blocked_transitions) do
if level_name ~= "inn" and level_name ~= "ingame" then if level_name ~= "inn" and level_name ~= "ingame" then
vmf.throw_error(ERRORS.THROWABLE.blocked_transitions_element_wrong_name, level_name) dmf.throw_error(ERRORS.THROWABLE.blocked_transitions_element_wrong_name, level_name)
end end
if type(level_blocked_transitions) ~= "table" then if type(level_blocked_transitions) ~= "table" then
vmf.throw_error(ERRORS.THROWABLE.blocked_transitions_element_wrong_type, level_name, dmf.throw_error(ERRORS.THROWABLE.blocked_transitions_element_wrong_type, level_name,
type(level_blocked_transitions)) type(level_blocked_transitions))
end end
for transition_name, value in pairs(level_blocked_transitions) do for transition_name, value in pairs(level_blocked_transitions) do
if not view_transitions[transition_name] then if not view_transitions[transition_name] then
vmf.throw_error(ERRORS.THROWABLE.blocked_transition_invalid, transition_name, level_name) dmf.throw_error(ERRORS.THROWABLE.blocked_transition_invalid, transition_name, level_name)
end end
if value ~= true then if value ~= true then
vmf.throw_error(ERRORS.THROWABLE.blocked_transition_wrong_value, level_name, transition_name) dmf.throw_error(ERRORS.THROWABLE.blocked_transition_wrong_value, level_name, transition_name)
end end
end end
end end
@ -256,7 +256,7 @@ local function can_open_view(view_name)
end end
-- ##################################################################################################################### -- #####################################################################################################################
-- ##### VMFMod ######################################################################################################## -- ##### DMFMod ########################################################################################################
-- ##################################################################################################################### -- #####################################################################################################################
--[[ --[[
@ -267,7 +267,7 @@ end
* transition_params [anything]: parameter, which will be passed to callable transition function, 'on_exit' method of * transition_params [anything]: parameter, which will be passed to callable transition function, 'on_exit' method of
the old view and 'on_enter' method of the new view the old view and 'on_enter' method of the new view
--]] --]]
function VMFMod:handle_transition() function DMFMod:handle_transition()
return true return true
end end
@ -276,8 +276,8 @@ end
Opens a file with a view data and validates it. Registers the view and returns 'true' if everything is correct. Opens a file with a view data and validates it. Registers the view and returns 'true' if everything is correct.
* view_data_file_path [string]: path to a file returning view_data table * view_data_file_path [string]: path to a file returning view_data table
--]] --]]
function VMFMod:register_view(view_data) function DMFMod:register_view(view_data)
if vmf.check_wrong_argument_type(self, "register_view", "view_data", view_data, "table") then if dmf.check_wrong_argument_type(self, "register_view", "view_data", view_data, "table") then
return return
end end
@ -290,7 +290,7 @@ function VMFMod:register_view(view_data)
view_data.view_settings.close_on_hotkey_pressed = true view_data.view_settings.close_on_hotkey_pressed = true
end end
if not vmf.safe_call_nrc(self, {ERRORS.PREFIX.register_view_validation, view_name}, validate_view_data, if not dmf.safe_call_nrc(self, {ERRORS.PREFIX.register_view_validation, view_name}, validate_view_data,
view_data) then view_data) then
return return
end end
@ -303,7 +303,7 @@ function VMFMod:register_view(view_data)
} }
if _ingame_ui then if _ingame_ui then
if not vmf.safe_call_nrc(self, {ERRORS.PREFIX.register_view_injection, view_name}, inject_view, view_name) then if not dmf.safe_call_nrc(self, {ERRORS.PREFIX.register_view_injection, view_name}, inject_view, view_name) then
_views_data[view_data.view_name] = nil _views_data[view_data.view_name] = nil
end end
end end
@ -317,18 +317,18 @@ end
-- Track the creation of the view loader -- Track the creation of the view loader
vmf:hook_safe(ViewLoader, "init", function() dmf:hook_safe(ViewLoader, "init", function()
_custom_view_data.loader_initialized = true _custom_view_data.loader_initialized = true
end) end)
-- Track the deletion of the view loader -- Track the deletion of the view loader
vmf:hook_safe(ViewLoader, "destroy", function() dmf:hook_safe(ViewLoader, "destroy", function()
_custom_view_data.loader_initialized = false _custom_view_data.loader_initialized = false
end) end)
-- Track the loading of views, set the loader flag if class selection is reached -- Track the loading of views, set the loader flag if class selection is reached
vmf:hook_safe(UIManager, "load_view", function(self, view_name) dmf:hook_safe(UIManager, "load_view", function(self, view_name)
if view_name == "class_selection_view" then if view_name == "class_selection_view" then
_custom_view_data.loader_initialized = true _custom_view_data.loader_initialized = true
end end
@ -336,26 +336,26 @@ vmf:hook_safe(UIManager, "load_view", function(self, view_name)
end) end)
-- Track the unloading of views -- Track the unloading of views
vmf:hook_safe(UIManager, "unload_view", function(self, view_name) dmf:hook_safe(UIManager, "unload_view", function(self, view_name)
_loaded_views[view_name] = nil _loaded_views[view_name] = nil
end) end)
-- Store the view handler for later use and inject views -- Store the view handler for later use and inject views
vmf:hook_safe(UIViewHandler, "init", function(self) dmf:hook_safe(UIViewHandler, "init", function(self)
_ingame_ui = self _ingame_ui = self
for view_name, _ in pairs(_views_data) do for view_name, _ in pairs(_views_data) do
if not vmf.safe_call_nrc(self, {ERRORS.PREFIX.ingameui_hook_injection, view_name}, inject_view, view_name) then if not dmf.safe_call_nrc(self, {ERRORS.PREFIX.ingameui_hook_injection, view_name}, inject_view, view_name) then
_views_data[view_name] = nil _views_data[view_name] = nil
end end
end end
end) end)
-- ##################################################################################################################### -- #####################################################################################################################
-- ##### VMF internal functions and variables ########################################################################## -- ##### DMF internal functions and variables ##########################################################################
-- ##################################################################################################################### -- #####################################################################################################################
function vmf.remove_custom_views() function dmf.remove_custom_views()
if _ingame_ui then if _ingame_ui then
remove_injected_views(true) remove_injected_views(true)
end end
@ -364,7 +364,7 @@ end
-- Opens/closes a view if all conditions are met. Since keybinds module can't do UI-related checks, all the cheks are -- Opens/closes a view if all conditions are met. Since keybinds module can't do UI-related checks, all the cheks are
-- done in this function. This function is called every time some view-toggling keybind is pressed. -- done in this function. This function is called every time some view-toggling keybind is pressed.
function vmf.keybind_toggle_view(mod, view_name, keybind_transition_data, can_perform_action, is_keybind_pressed) function dmf.keybind_toggle_view(mod, view_name, keybind_transition_data, can_perform_action, is_keybind_pressed)
--[[ --[[
if _ingame_ui then if _ingame_ui then
local view_data = _views_data[view_name] local view_data = _views_data[view_name]
@ -456,5 +456,5 @@ end
-- ##### Script ######################################################################################################## -- ##### Script ########################################################################################################
-- ##################################################################################################################### -- #####################################################################################################################
-- If VMF is reloaded mid-game, get ingame_ui. -- If DMF is reloaded mid-game, get ingame_ui.
_ingame_ui = Managers.ui and Managers.ui._view_handler _ingame_ui = Managers.ui and Managers.ui._view_handler

View file

@ -3,7 +3,7 @@
* chat history * chat history
* ctrl + c, ctrl + v * ctrl + c, ctrl + v
]] ]]
local vmf = get_mod("VMF") local dmf = get_mod("DMF")
local _chat_opened = false local _chat_opened = false
@ -32,7 +32,7 @@ local _queued_command
local function initialize_drawing_function() local function initialize_drawing_function()
if not _commands_list_gui_draw then if not _commands_list_gui_draw then
local commands_list_gui = vmf:dofile("dmf/scripts/mods/vmf/modules/ui/chat/commands_list_gui") local commands_list_gui = dmf:dofile("dmf/scripts/mods/dmf/modules/ui/chat/commands_list_gui")
_commands_list_gui_draw = commands_list_gui.draw _commands_list_gui_draw = commands_list_gui.draw
_commands_list_gui_destroy = commands_list_gui.destroy _commands_list_gui_destroy = commands_list_gui.destroy
end end
@ -76,7 +76,7 @@ end
-- #################################################################################################################### -- ####################################################################################################################
-- Handle chat actions when the chat window is active -- Handle chat actions when the chat window is active
vmf:hook("ConstantElementChat", "_handle_active_chat_input", function(func, self, input_service, ui_renderer, ...) dmf:hook("ConstantElementChat", "_handle_active_chat_input", function(func, self, input_service, ui_renderer, ...)
initialize_drawing_function() initialize_drawing_function()
local command_executed = false local command_executed = false
@ -130,7 +130,7 @@ vmf:hook("ConstantElementChat", "_handle_active_chat_input", function(func, self
command_executed = true command_executed = true
elseif string.sub(_chat_message, 1, 1) == "/" then elseif string.sub(_chat_message, 1, 1) == "/" then
vmf:notify(vmf:localize("chat_command_not_recognized") .. ": " .. _chat_message) dmf:notify(dmf:localize("chat_command_not_recognized") .. ": " .. _chat_message)
set_chat_message(self, "") set_chat_message(self, "")
return return
end end
@ -224,14 +224,14 @@ vmf:hook("ConstantElementChat", "_handle_active_chat_input", function(func, self
end end
if not autocompleting or not vmf._commands_list_gui_draw then if not autocompleting or not dmf._commands_list_gui_draw then
-- get '/part_of_command_name' without '/' -- get '/part_of_command_name' without '/'
local command_name_contains = _chat_message:match("%S+"):sub(2, -1) local command_name_contains = _chat_message:match("%S+"):sub(2, -1)
if string.find(_chat_message, " ") then if string.find(_chat_message, " ") then
_commands_list = vmf.get_commands_list(command_name_contains, true) _commands_list = dmf.get_commands_list(command_name_contains, true)
else else
_commands_list = vmf.get_commands_list(command_name_contains) _commands_list = dmf.get_commands_list(command_name_contains)
end end
_command_index = 0 _command_index = 0
@ -257,27 +257,27 @@ vmf:hook("ConstantElementChat", "_handle_active_chat_input", function(func, self
end) end)
-- #################################################################################################################### -- ####################################################################################################################
-- ##### VMF internal functions and variables ######################################################################### -- ##### DMF internal functions and variables #########################################################################
-- #################################################################################################################### -- ####################################################################################################################
vmf.load_chat_history_settings = function(clean_chat_history_) dmf.load_chat_history_settings = function(clean_chat_history_)
_chat_history_enabled = vmf:get("chat_history_enable") _chat_history_enabled = dmf:get("chat_history_enable")
_chat_history_save = vmf:get("chat_history_save") _chat_history_save = dmf:get("chat_history_save")
_chat_history_max = vmf:get("chat_history_buffer_size") _chat_history_max = dmf:get("chat_history_buffer_size")
_chat_history_remove_dups_last = vmf:get("chat_history_remove_dups") _chat_history_remove_dups_last = dmf:get("chat_history_remove_dups")
_chat_history_remove_dups_all = vmf:get("chat_history_remove_dups") and _chat_history_remove_dups_all = dmf:get("chat_history_remove_dups") and
(vmf:get("chat_history_remove_dups_mode") == "all") (dmf:get("chat_history_remove_dups_mode") == "all")
_chat_history_save_commands_only = vmf:get("chat_history_commands_only") _chat_history_save_commands_only = dmf:get("chat_history_commands_only")
if _chat_history_enabled then if _chat_history_enabled then
vmf:command("clean_chat_history", vmf:localize("clean_chat_history"), clean_chat_history) dmf:command("clean_chat_history", dmf:localize("clean_chat_history"), clean_chat_history)
else else
vmf:command_remove("clean_chat_history") dmf:command_remove("clean_chat_history")
end end
if not _chat_history_save then if not _chat_history_save then
vmf:set("chat_history", nil) dmf:set("chat_history", nil)
end end
if clean_chat_history_ then if clean_chat_history_ then
@ -285,20 +285,20 @@ vmf.load_chat_history_settings = function(clean_chat_history_)
end end
end end
vmf.save_chat_history = function() dmf.save_chat_history = function()
if _chat_history_save then if _chat_history_save then
vmf:set("chat_history", _chat_history) dmf:set("chat_history", _chat_history)
end end
end end
vmf.execute_queued_chat_command = function() dmf.execute_queued_chat_command = function()
if _queued_command then if _queued_command then
vmf.run_command(_queued_command.name, unpack(_queued_command.args)) dmf.run_command(_queued_command.name, unpack(_queued_command.args))
_queued_command = nil _queued_command = nil
end end
end end
vmf.destroy_command_gui = function() dmf.destroy_command_gui = function()
destroy_command_gui() destroy_command_gui()
end end
@ -306,11 +306,11 @@ end
-- ##### Script ####################################################################################################### -- ##### Script #######################################################################################################
-- #################################################################################################################### -- ####################################################################################################################
vmf.load_chat_history_settings() dmf.load_chat_history_settings()
vmf:command("clean_chat_notifications", vmf:localize("clean_chat_notifications"), clean_chat_notifications) dmf:command("clean_chat_notifications", dmf:localize("clean_chat_notifications"), clean_chat_notifications)
if _chat_history_save then if _chat_history_save then
_chat_history = vmf:get("chat_history") or _chat_history _chat_history = dmf:get("chat_history") or _chat_history
end end
initialize_drawing_function() initialize_drawing_function()

View file

@ -1,4 +1,4 @@
local vmf = get_mod("VMF") local dmf = get_mod("DMF")
local MULTISTRING_INDICATOR_TEXT = "[...]" local MULTISTRING_INDICATOR_TEXT = "[...]"
@ -241,12 +241,12 @@ local function draw(commands_list, selected_command_index)
end end
-- ##################################################################################################################### -- #####################################################################################################################
-- ##### VMF internal functions ######################################################################################## -- ##### DMF internal functions ########################################################################################
-- ##################################################################################################################### -- #####################################################################################################################
-- A way for modders to change definitions. No safety checks. No guarantees definitions won't change. At least until -- A way for modders to change definitions. No safety checks. No guarantees definitions won't change. At least until
-- global refactoring. -- global refactoring.
function vmf.update_commands_list_gui_definitions(new_definitions) function dmf.update_commands_list_gui_definitions(new_definitions)
MULTISTRING_INDICATOR_TEXT = new_definitions.MULTISTRING_INDICATOR_TEXT or MULTISTRING_INDICATOR_TEXT MULTISTRING_INDICATOR_TEXT = new_definitions.MULTISTRING_INDICATOR_TEXT or MULTISTRING_INDICATOR_TEXT
FONT_TYPE = new_definitions.FONT_TYPE or FONT_TYPE FONT_TYPE = new_definitions.FONT_TYPE or FONT_TYPE
FONT_SIZE = new_definitions.FONT_SIZE or FONT_SIZE FONT_SIZE = new_definitions.FONT_SIZE or FONT_SIZE

View file

@ -1,4 +1,4 @@
local vmf = get_mod("VMF") local dmf = get_mod("DMF")
local _widgets_by_name local _widgets_by_name
@ -7,25 +7,25 @@ local _widgets_by_name
-- #################################################################################################################### -- ####################################################################################################################
local function load_scrolling_speed_setting() local function load_scrolling_speed_setting()
if vmf:get("vmf_options_scrolling_speed") and _widgets_by_name and _widgets_by_name["scrollbar"] then if dmf:get("dmf_options_scrolling_speed") and _widgets_by_name and _widgets_by_name["scrollbar"] then
_widgets_by_name["scrollbar"].content.scroll_speed = vmf:get("vmf_options_scrolling_speed") _widgets_by_name["scrollbar"].content.scroll_speed = dmf:get("dmf_options_scrolling_speed")
end end
end end
-- #################################################################################################################### -- ####################################################################################################################
-- ##### VMF internal functions and variables ######################################################################### -- ##### DMF internal functions and variables #########################################################################
-- #################################################################################################################### -- ####################################################################################################################
vmf.load_vmf_options_view_settings = function() dmf.load_dmf_options_view_settings = function()
load_scrolling_speed_setting() load_scrolling_speed_setting()
end end
-- #################################################################################################################### -- ####################################################################################################################
-- ##### VMF Options View Class ####################################################################################### -- ##### DMF Options View Class #######################################################################################
-- #################################################################################################################### -- ####################################################################################################################
local _content_blueprints = vmf:dofile("dmf/scripts/mods/vmf/modules/ui/options/vmf_options_view_content_blueprints") local _content_blueprints = dmf:dofile("dmf/scripts/mods/dmf/modules/ui/options/dmf_options_view_content_blueprints")
local _view_settings = vmf:dofile("dmf/scripts/mods/vmf/modules/ui/options/vmf_options_view_settings") local _view_settings = dmf:dofile("dmf/scripts/mods/dmf/modules/ui/options/dmf_options_view_settings")
local InputUtils = require("scripts/managers/input/input_utils") local InputUtils = require("scripts/managers/input/input_utils")
local ScriptWorld = require("scripts/foundation/utilities/script_world") local ScriptWorld = require("scripts/foundation/utilities/script_world")
@ -39,19 +39,19 @@ local ViewElementKeybindPopup = require("scripts/ui/view_elements/view_element_k
local CATEGORIES_GRID = 1 local CATEGORIES_GRID = 1
local SETTINGS_GRID = 2 local SETTINGS_GRID = 2
local VMFOptionsView = class("VMFOptionsView", "BaseView") local DMFOptionsView = class("DMFOptionsView", "BaseView")
VMFOptionsView.init = function (self, settings) DMFOptionsView.init = function (self, settings)
local definitions = vmf:dofile("dmf/scripts/mods/vmf/modules/ui/options/vmf_options_view_definitions") local definitions = dmf:dofile("dmf/scripts/mods/dmf/modules/ui/options/dmf_options_view_definitions")
VMFOptionsView.super.init(self, definitions, settings) DMFOptionsView.super.init(self, definitions, settings)
self._pass_draw = false self._pass_draw = false
self:_setup_offscreen_gui() self:_setup_offscreen_gui()
end end
VMFOptionsView.on_enter = function (self) DMFOptionsView.on_enter = function (self)
_widgets_by_name = self._widgets_by_name _widgets_by_name = self._widgets_by_name
if not self._options_templates then if not self._options_templates then
@ -59,9 +59,9 @@ VMFOptionsView.on_enter = function (self)
settings = {}, settings = {},
categories = {} categories = {}
} }
vmf:create_mod_options_settings(self._options_templates) dmf:create_mod_options_settings(self._options_templates)
end end
VMFOptionsView.super.on_enter(self) DMFOptionsView.super.on_enter(self)
self._default_category = nil self._default_category = nil
self._using_cursor_navigation = Managers.ui:using_cursor_navigation() self._using_cursor_navigation = Managers.ui:using_cursor_navigation()
@ -74,7 +74,7 @@ VMFOptionsView.on_enter = function (self)
self:_update_grid_navigation_selection() self:_update_grid_navigation_selection()
end end
VMFOptionsView._map_validations = function (self, config) DMFOptionsView._map_validations = function (self, config)
local config_categories = config.categories local config_categories = config.categories
local categories = {} local categories = {}
@ -111,7 +111,7 @@ VMFOptionsView._map_validations = function (self, config)
return categories return categories
end end
VMFOptionsView.on_exit = function (self) DMFOptionsView.on_exit = function (self)
Managers.event:trigger("event_on_input_settings_changed") Managers.event:trigger("event_on_input_settings_changed")
if self._input_legend_element then if self._input_legend_element then
@ -140,10 +140,10 @@ VMFOptionsView.on_exit = function (self)
self._offscreen_world = nil self._offscreen_world = nil
end end
VMFOptionsView.super.on_exit(self) DMFOptionsView.super.on_exit(self)
end end
VMFOptionsView.cb_on_back_pressed = function (self) DMFOptionsView.cb_on_back_pressed = function (self)
local selected_navigation_column = self._selected_navigation_column_index local selected_navigation_column = self._selected_navigation_column_index
local selected_settings_widget = self._selected_settings_widget local selected_settings_widget = self._selected_settings_widget
@ -152,12 +152,12 @@ VMFOptionsView.cb_on_back_pressed = function (self)
elseif selected_navigation_column == SETTINGS_GRID then elseif selected_navigation_column == SETTINGS_GRID then
self:_change_navigation_column(selected_navigation_column - 1) self:_change_navigation_column(selected_navigation_column - 1)
else else
local view_name = "vmf_options_view" local view_name = "dmf_options_view"
Managers.ui:close_view(view_name) Managers.ui:close_view(view_name)
end end
end end
VMFOptionsView.cb_reset_category_to_default = function (self) DMFOptionsView.cb_reset_category_to_default = function (self)
local selected_category = self._selected_category local selected_category = self._selected_category
local reset_functions_by_category = self._reset_functions_by_category local reset_functions_by_category = self._reset_functions_by_category
local reset_function = reset_functions_by_category[selected_category] local reset_function = reset_functions_by_category[selected_category]
@ -207,7 +207,7 @@ VMFOptionsView.cb_reset_category_to_default = function (self)
end) end)
end end
VMFOptionsView._setup_input_legend = function (self) DMFOptionsView._setup_input_legend = function (self)
self._input_legend_element = self:_add_element(ViewElementInputLegend, "input_legend", 10) self._input_legend_element = self:_add_element(ViewElementInputLegend, "input_legend", 10)
local legend_inputs = self._definitions.legend_inputs local legend_inputs = self._definitions.legend_inputs
@ -219,7 +219,7 @@ VMFOptionsView._setup_input_legend = function (self)
end end
end end
VMFOptionsView._setup_content_grid_scrollbar = function (self, grid, widget_id, grid_scenegraph_id, grid_pivot_scenegraph_id) DMFOptionsView._setup_content_grid_scrollbar = function (self, grid, widget_id, grid_scenegraph_id, grid_pivot_scenegraph_id)
local widgets_by_name = self._widgets_by_name local widgets_by_name = self._widgets_by_name
local scrollbar_widget = widgets_by_name[widget_id] local scrollbar_widget = widgets_by_name[widget_id]
@ -229,7 +229,7 @@ VMFOptionsView._setup_content_grid_scrollbar = function (self, grid, widget_id,
grid:set_scrollbar_progress(0) grid:set_scrollbar_progress(0)
end end
VMFOptionsView._setup_offscreen_gui = function (self) DMFOptionsView._setup_offscreen_gui = function (self)
local ui_manager = Managers.ui local ui_manager = Managers.ui
local class_name = self.__class_name local class_name = self.__class_name
local timer_name = "ui" local timer_name = "ui"
@ -246,7 +246,7 @@ VMFOptionsView._setup_offscreen_gui = function (self)
self._ui_offscreen_renderer = ui_manager:create_renderer(class_name .. "_ui_offscreen_renderer", self._offscreen_world) self._ui_offscreen_renderer = ui_manager:create_renderer(class_name .. "_ui_offscreen_renderer", self._offscreen_world)
end end
VMFOptionsView._setup_content_widgets = function (self, content, scenegraph_id, callback_name) DMFOptionsView._setup_content_widgets = function (self, content, scenegraph_id, callback_name)
local definitions = self._definitions local definitions = self._definitions
local widget_definitions = {} local widget_definitions = {}
local widgets = {} local widgets = {}
@ -298,7 +298,7 @@ VMFOptionsView._setup_content_widgets = function (self, content, scenegraph_id,
return widgets, alignment_list return widgets, alignment_list
end end
VMFOptionsView._draw_widgets = function (self, dt, t, input_service, ui_renderer) DMFOptionsView._draw_widgets = function (self, dt, t, input_service, ui_renderer)
local widgets_by_name = self._widgets_by_name local widgets_by_name = self._widgets_by_name
local scrollbar_widget = widgets_by_name.scrollbar local scrollbar_widget = widgets_by_name.scrollbar
scrollbar_widget.content.visible = self._category_content_grid:can_scroll() scrollbar_widget.content.visible = self._category_content_grid:can_scroll()
@ -310,19 +310,19 @@ VMFOptionsView._draw_widgets = function (self, dt, t, input_service, ui_renderer
ui_renderer.input_service = input_service ui_renderer.input_service = input_service
end end
VMFOptionsView.super._draw_widgets(self, dt, t, input_service, ui_renderer) DMFOptionsView.super._draw_widgets(self, dt, t, input_service, ui_renderer)
end end
VMFOptionsView._draw_elements = function (self, dt, t, ui_renderer, render_settings, input_service) DMFOptionsView._draw_elements = function (self, dt, t, ui_renderer, render_settings, input_service)
if self:_handling_keybinding() or self._selected_settings_widget then if self:_handling_keybinding() or self._selected_settings_widget then
input_service = input_service:null_service() input_service = input_service:null_service()
ui_renderer.input_service = input_service ui_renderer.input_service = input_service
end end
VMFOptionsView.super._draw_elements(self, dt, t, ui_renderer, render_settings, input_service) DMFOptionsView.super._draw_elements(self, dt, t, ui_renderer, render_settings, input_service)
end end
VMFOptionsView.draw = function (self, dt, t, input_service, layer) DMFOptionsView.draw = function (self, dt, t, input_service, layer)
if self:_handling_keybinding() then if self:_handling_keybinding() then
input_service = input_service:null_service() input_service = input_service:null_service()
end end
@ -338,10 +338,10 @@ VMFOptionsView.draw = function (self, dt, t, input_service, layer)
self:_draw_grid(self._settings_content_grid, self._settings_content_widgets, grid_interaction_widget, dt, t, input_service) self:_draw_grid(self._settings_content_grid, self._settings_content_widgets, grid_interaction_widget, dt, t, input_service)
end end
VMFOptionsView.super.draw(self, dt, t, input_service, layer) DMFOptionsView.super.draw(self, dt, t, input_service, layer)
end end
VMFOptionsView._draw_grid = function (self, grid, widgets, interaction_widget, dt, t, input_service) DMFOptionsView._draw_grid = function (self, grid, widgets, interaction_widget, dt, t, input_service)
local is_grid_hovered = not self._using_cursor_navigation or interaction_widget.content.hotspot.is_hover or false local is_grid_hovered = not self._using_cursor_navigation or interaction_widget.content.hotspot.is_hover or false
local null_input_service = input_service:null_service() local null_input_service = input_service:null_service()
local render_settings = self._render_settings local render_settings = self._render_settings
@ -379,7 +379,7 @@ VMFOptionsView._draw_grid = function (self, grid, widgets, interaction_widget, d
UIRenderer.end_pass(ui_renderer) UIRenderer.end_pass(ui_renderer)
end end
VMFOptionsView._setup_grid = function (self, widgets, alignment_list, grid_scenegraph_id, spacing, use_is_focused) DMFOptionsView._setup_grid = function (self, widgets, alignment_list, grid_scenegraph_id, spacing, use_is_focused)
local ui_scenegraph = self._ui_scenegraph local ui_scenegraph = self._ui_scenegraph
local direction = "down" local direction = "down"
local grid = UIWidgetGrid:new(widgets, alignment_list, ui_scenegraph, grid_scenegraph_id, direction, spacing, nil, use_is_focused) local grid = UIWidgetGrid:new(widgets, alignment_list, ui_scenegraph, grid_scenegraph_id, direction, spacing, nil, use_is_focused)
@ -390,8 +390,8 @@ VMFOptionsView._setup_grid = function (self, widgets, alignment_list, grid_scene
return grid return grid
end end
VMFOptionsView.set_render_scale = function (self, scale) DMFOptionsView.set_render_scale = function (self, scale)
VMFOptionsView.super.set_render_scale(self, scale) DMFOptionsView.super.set_render_scale(self, scale)
self._category_content_grid:set_render_scale(self._render_scale) self._category_content_grid:set_render_scale(self._render_scale)
if self._settings_content_grid then if self._settings_content_grid then
@ -399,7 +399,7 @@ VMFOptionsView.set_render_scale = function (self, scale)
end end
end end
VMFOptionsView.update = function (self, dt, t, input_service, view_data) DMFOptionsView.update = function (self, dt, t, input_service, view_data)
local drawing_view = view_data and view_data.drawing_view local drawing_view = view_data and view_data.drawing_view
local using_cursor_navigation = Managers.ui:using_cursor_navigation() local using_cursor_navigation = Managers.ui:using_cursor_navigation()
@ -484,11 +484,11 @@ VMFOptionsView.update = function (self, dt, t, input_service, view_data)
self._widgets_by_name.tooltip.content.visible = false self._widgets_by_name.tooltip.content.visible = false
end end
return VMFOptionsView.super.update(self, dt, t, input_service) return DMFOptionsView.super.update(self, dt, t, input_service)
end end
VMFOptionsView.on_resolution_modified = function (self) DMFOptionsView.on_resolution_modified = function (self)
VMFOptionsView.super.on_resolution_modified(self) DMFOptionsView.super.on_resolution_modified(self)
local scale = self._render_scale local scale = self._render_scale
@ -501,15 +501,15 @@ VMFOptionsView.on_resolution_modified = function (self)
self._grid_length = nil self._grid_length = nil
end end
VMFOptionsView._on_navigation_input_changed = function (self) DMFOptionsView._on_navigation_input_changed = function (self)
VMFOptionsView.super._on_navigation_input_changed(self) DMFOptionsView.super._on_navigation_input_changed(self)
if self._settings_content_widgets then if self._settings_content_widgets then
self:_update_grid_navigation_selection() self:_update_grid_navigation_selection()
end end
end end
VMFOptionsView._reset_options_view = function (self, reset_all) DMFOptionsView._reset_options_view = function (self, reset_all)
if reset_all then if reset_all then
self._selected_category = nil self._selected_category = nil
self._selected_settings_widget = nil self._selected_settings_widget = nil
@ -535,7 +535,7 @@ VMFOptionsView._reset_options_view = function (self, reset_all)
self:_update_grid_navigation_selection() self:_update_grid_navigation_selection()
end end
VMFOptionsView.settings_grid_length = function (self) DMFOptionsView.settings_grid_length = function (self)
local grid = self._settings_content_grid local grid = self._settings_content_grid
if grid then if grid then
@ -549,7 +549,7 @@ VMFOptionsView.settings_grid_length = function (self)
return 0 return 0
end end
VMFOptionsView.settings_scroll_amount = function (self) DMFOptionsView.settings_scroll_amount = function (self)
local grid = self._settings_content_grid local grid = self._settings_content_grid
if grid then if grid then
@ -562,11 +562,11 @@ VMFOptionsView.settings_scroll_amount = function (self)
return 0 return 0
end end
VMFOptionsView.set_exclusive_focus_on_grid_widget = function (self, widget_name) DMFOptionsView.set_exclusive_focus_on_grid_widget = function (self, widget_name)
self:_set_exclusive_focus_on_grid_widget(widget_name) self:_set_exclusive_focus_on_grid_widget(widget_name)
end end
VMFOptionsView._handle_input = function (self, input_service) DMFOptionsView._handle_input = function (self, input_service)
local selected_settings_widget = self._selected_settings_widget local selected_settings_widget = self._selected_settings_widget
if selected_settings_widget then if selected_settings_widget then
@ -597,7 +597,7 @@ VMFOptionsView._handle_input = function (self, input_service)
end end
end end
VMFOptionsView._update_grid_navigation_selection = function (self) DMFOptionsView._update_grid_navigation_selection = function (self)
local selected_column_index = self._selected_navigation_column_index local selected_column_index = self._selected_navigation_column_index
local selected_row_index = self._selected_navigation_row_index local selected_row_index = self._selected_navigation_row_index
@ -623,7 +623,7 @@ VMFOptionsView._update_grid_navigation_selection = function (self)
end end
end end
VMFOptionsView.present_category_widgets = function (self, category) DMFOptionsView.present_category_widgets = function (self, category)
self._selected_category = category self._selected_category = category
local settings_category_widgets = self._settings_category_widgets local settings_category_widgets = self._settings_category_widgets
local grid_data = settings_category_widgets[category] local grid_data = settings_category_widgets[category]
@ -656,7 +656,7 @@ VMFOptionsView.present_category_widgets = function (self, category)
end end
end end
VMFOptionsView._setup_category_config = function (self, config) DMFOptionsView._setup_category_config = function (self, config)
if self._category_content_widgets then if self._category_content_widgets then
for i = 1, #self._category_content_widgets do for i = 1, #self._category_content_widgets do
local widget = self._category_content_widgets[i] local widget = self._category_content_widgets[i]
@ -730,7 +730,7 @@ VMFOptionsView._setup_category_config = function (self, config)
} }
end end
VMFOptionsView._setup_settings_config = function (self, config) DMFOptionsView._setup_settings_config = function (self, config)
if self._settings_category_widgets then if self._settings_category_widgets then
for _, settings_data in pairs(self._settings_category_widgets) do for _, settings_data in pairs(self._settings_category_widgets) do
for i = 1, #settings_data do for i = 1, #settings_data do
@ -782,7 +782,7 @@ VMFOptionsView._setup_settings_config = function (self, config)
self._settings_category_widgets = category_widgets self._settings_category_widgets = category_widgets
end end
VMFOptionsView._update_category_content_widgets = function (self, dt, t) DMFOptionsView._update_category_content_widgets = function (self, dt, t)
local category_content_widgets = self._category_content_widgets local category_content_widgets = self._category_content_widgets
if category_content_widgets then if category_content_widgets then
@ -811,7 +811,7 @@ VMFOptionsView._update_category_content_widgets = function (self, dt, t)
end end
end end
VMFOptionsView._set_tooltip_data = function (self, widget) DMFOptionsView._set_tooltip_data = function (self, widget)
local current_widget = self._tooltip_data and self._tooltip_data.widget local current_widget = self._tooltip_data and self._tooltip_data.widget
local display_text = nil local display_text = nil
local tooltip_text = widget.content.entry.tooltip_text local tooltip_text = widget.content.entry.tooltip_text
@ -859,7 +859,7 @@ VMFOptionsView._set_tooltip_data = function (self, widget)
end end
end end
VMFOptionsView._update_settings_content_widgets = function (self, dt, t, input_service) DMFOptionsView._update_settings_content_widgets = function (self, dt, t, input_service)
local settings_content_widgets = self._settings_content_widgets local settings_content_widgets = self._settings_content_widgets
if settings_content_widgets then if settings_content_widgets then
@ -893,7 +893,7 @@ VMFOptionsView._update_settings_content_widgets = function (self, dt, t, input_s
end end
end end
VMFOptionsView._create_settings_widget_from_config = function (self, config, category, suffix, callback_name) DMFOptionsView._create_settings_widget_from_config = function (self, config, category, suffix, callback_name)
local scenegraph_id = "settings_grid_content_pivot" local scenegraph_id = "settings_grid_content_pivot"
local default_value = config.default_value local default_value = config.default_value
local default_value_type = type(default_value) local default_value_type = type(default_value)
@ -964,7 +964,7 @@ VMFOptionsView._create_settings_widget_from_config = function (self, config, cat
end end
end end
VMFOptionsView._handle_keybind_rebind = function (self, dt, t, input_service) DMFOptionsView._handle_keybind_rebind = function (self, dt, t, input_service)
if self._handling_keybind then if self._handling_keybind then
local input_manager = Managers.input local input_manager = Managers.input
local results = input_manager:key_watch_result() local results = input_manager:key_watch_result()
@ -991,11 +991,11 @@ VMFOptionsView._handle_keybind_rebind = function (self, dt, t, input_service)
end end
end end
VMFOptionsView._handling_keybinding = function (self) DMFOptionsView._handling_keybinding = function (self)
return self._handling_keybind or self._close_keybind_popup_duration ~= nil return self._handling_keybind or self._close_keybind_popup_duration ~= nil
end end
VMFOptionsView.show_keybind_popup = function (self, widget, entry) DMFOptionsView.show_keybind_popup = function (self, widget, entry)
if not self:_handling_keybinding() then if not self:_handling_keybinding() then
self._active_keybind_entry = entry self._active_keybind_entry = entry
self._active_keybind_widget = widget self._active_keybind_widget = widget
@ -1028,7 +1028,7 @@ VMFOptionsView.show_keybind_popup = function (self, widget, entry)
end end
end end
VMFOptionsView.close_keybind_popup = function (self, force_close) DMFOptionsView.close_keybind_popup = function (self, force_close)
if force_close then if force_close then
Managers.input:stop_key_watch() Managers.input:stop_key_watch()
@ -1046,7 +1046,7 @@ VMFOptionsView.close_keybind_popup = function (self, force_close)
self._active_keybind_widget = nil self._active_keybind_widget = nil
end end
VMFOptionsView._set_warning_text = function (self) DMFOptionsView._set_warning_text = function (self)
local widgets_by_name = self._widgets_by_name local widgets_by_name = self._widgets_by_name
local warning_text = widgets_by_name.warning_text local warning_text = widgets_by_name.warning_text
local action = "TEST" local action = "TEST"
@ -1055,7 +1055,7 @@ VMFOptionsView._set_warning_text = function (self)
warning_text.content.text = string.format("Warning! Input for action %s%s%s has been unassigned.", color_1, action, color_2) warning_text.content.text = string.format("Warning! Input for action %s%s%s has been unassigned.", color_1, action, color_2)
end end
VMFOptionsView.cb_on_category_pressed = function (self, widget, entry) DMFOptionsView.cb_on_category_pressed = function (self, widget, entry)
local pressed_function = entry.pressed_function local pressed_function = entry.pressed_function
if pressed_function then if pressed_function then
@ -1063,7 +1063,7 @@ VMFOptionsView.cb_on_category_pressed = function (self, widget, entry)
end end
end end
VMFOptionsView.cb_on_settings_pressed = function (self, widget, entry) DMFOptionsView.cb_on_settings_pressed = function (self, widget, entry)
if not self._can_close or self._selected_settings_widget or self._navigation_column_changed_this_frame then if not self._can_close or self._selected_settings_widget or self._navigation_column_changed_this_frame then
return return
end end
@ -1081,13 +1081,13 @@ VMFOptionsView.cb_on_settings_pressed = function (self, widget, entry)
end end
end end
VMFOptionsView._enable_settings_overlay = function (self, enable) DMFOptionsView._enable_settings_overlay = function (self, enable)
local widgets_by_name = self._widgets_by_name local widgets_by_name = self._widgets_by_name
local settings_overlay_widget = widgets_by_name.settings_overlay local settings_overlay_widget = widgets_by_name.settings_overlay
settings_overlay_widget.content.visible = enable settings_overlay_widget.content.visible = enable
end end
VMFOptionsView._set_exclusive_focus_on_grid_widget = function (self, widget_name) DMFOptionsView._set_exclusive_focus_on_grid_widget = function (self, widget_name)
local widgets = self._settings_content_widgets local widgets = self._settings_content_widgets
local selected_widget = nil local selected_widget = nil
@ -1116,7 +1116,7 @@ VMFOptionsView._set_exclusive_focus_on_grid_widget = function (self, widget_name
return selected_widget return selected_widget
end end
VMFOptionsView._change_navigation_column = function (self, column_index) DMFOptionsView._change_navigation_column = function (self, column_index)
local navigation_widgets = self._navigation_widgets local navigation_widgets = self._navigation_widgets
local num_columns = #navigation_widgets local num_columns = #navigation_widgets
local success = false local success = false
@ -1162,7 +1162,7 @@ VMFOptionsView._change_navigation_column = function (self, column_index)
end end
end end
VMFOptionsView._set_default_navigation_widget = function (self) DMFOptionsView._set_default_navigation_widget = function (self)
local navigation_widgets = self._navigation_widgets local navigation_widgets = self._navigation_widgets
for i = 1, #navigation_widgets do for i = 1, #navigation_widgets do
@ -1172,7 +1172,7 @@ VMFOptionsView._set_default_navigation_widget = function (self)
end end
end end
VMFOptionsView._set_selected_navigation_widget = function (self, widget) DMFOptionsView._set_selected_navigation_widget = function (self, widget)
local widget_name = widget and widget.name local widget_name = widget and widget.name
local selected_row, selected_column = nil local selected_row, selected_column = nil
local navigation_widgets = self._navigation_widgets local navigation_widgets = self._navigation_widgets
@ -1202,7 +1202,7 @@ VMFOptionsView._set_selected_navigation_widget = function (self, widget)
self._selected_navigation_column_index = selected_column self._selected_navigation_column_index = selected_column
end end
VMFOptionsView._set_focused_grid_widget = function (self, widgets, widget_name) DMFOptionsView._set_focused_grid_widget = function (self, widgets, widget_name)
local selected_widget, selected_widget_index = nil local selected_widget, selected_widget_index = nil
for i = 1, #widgets do for i = 1, #widgets do
@ -1224,7 +1224,7 @@ VMFOptionsView._set_focused_grid_widget = function (self, widgets, widget_name)
return selected_widget, selected_widget_index return selected_widget, selected_widget_index
end end
VMFOptionsView._set_selected_grid_widget = function (self, widgets, widget_name) DMFOptionsView._set_selected_grid_widget = function (self, widgets, widget_name)
local selected_widget, selected_widget_index = nil local selected_widget, selected_widget_index = nil
for i = 1, #widgets do for i = 1, #widgets do
@ -1246,4 +1246,4 @@ VMFOptionsView._set_selected_grid_widget = function (self, widgets, widget_name)
return selected_widget, selected_widget_index return selected_widget, selected_widget_index
end end
return VMFOptionsView return DMFOptionsView

View file

@ -1,6 +1,6 @@
local vmf = get_mod("VMF") local dmf = get_mod("DMF")
local _view_settings = vmf:dofile("dmf/scripts/mods/vmf/modules/ui/options/vmf_options_view_settings") local _view_settings = dmf:dofile("dmf/scripts/mods/dmf/modules/ui/options/dmf_options_view_settings")
local ButtonPassTemplates = require("scripts/ui/pass_templates/button_pass_templates") local ButtonPassTemplates = require("scripts/ui/pass_templates/button_pass_templates")
local CheckboxPassTemplates = require("scripts/ui/pass_templates/checkbox_pass_templates") local CheckboxPassTemplates = require("scripts/ui/pass_templates/checkbox_pass_templates")
@ -777,4 +777,4 @@ blueprints.description = {
end end
} }
return settings("VMFOptionsViewContentBlueprints", blueprints) return settings("DMFOptionsViewContentBlueprints", blueprints)

View file

@ -1,6 +1,6 @@
local vmf = get_mod("VMF") local dmf = get_mod("DMF")
local _view_settings = vmf:dofile("dmf/scripts/mods/vmf/modules/ui/options/vmf_options_view_settings") local _view_settings = dmf:dofile("dmf/scripts/mods/dmf/modules/ui/options/dmf_options_view_settings")
local ScrollbarPassTemplates = require("scripts/ui/pass_templates/scrollbar_pass_templates") local ScrollbarPassTemplates = require("scripts/ui/pass_templates/scrollbar_pass_templates")
local UIFontSettings = require("scripts/managers/ui/ui_font_settings") local UIFontSettings = require("scripts/managers/ui/ui_font_settings")
@ -317,7 +317,7 @@ local widget_definitions = {
value_id = "text", value_id = "text",
style_id = "text", style_id = "text",
pass_type = "text", pass_type = "text",
value = vmf:localize("mods_options"), value = dmf:localize("mods_options"),
style = table.clone(UIFontSettings.header_1) style = table.clone(UIFontSettings.header_1)
} }
}, "title_text"), }, "title_text"),
@ -445,10 +445,10 @@ local legend_inputs = {
} }
} }
local VMFOptionsViewDefinitions = { local DMFOptionsViewDefinitions = {
legend_inputs = legend_inputs, legend_inputs = legend_inputs,
widget_definitions = widget_definitions, widget_definitions = widget_definitions,
scenegraph_definition = scenegraph_definition scenegraph_definition = scenegraph_definition
} }
return settings("VMFOptionsViewDefinitions", VMFOptionsViewDefinitions) return settings("DMFOptionsViewDefinitions", DMFOptionsViewDefinitions)

View file

@ -1,4 +1,4 @@
local vmf_options_view_settings = { local dmf_options_view_settings = {
scrollbar_width = 10, scrollbar_width = 10,
max_visible_dropdown_options = 5, max_visible_dropdown_options = 5,
indentation_spacing = 40, indentation_spacing = 40,
@ -17,4 +17,4 @@ local vmf_options_view_settings = {
} }
} }
return settings("VMFOptionsViewSettings", vmf_options_view_settings) return settings("DMFOptionsViewSettings", dmf_options_view_settings)

View file

@ -1,4 +1,4 @@
local vmf = get_mod("VMF") local dmf = get_mod("DMF")
local OptionsUtilities = require("scripts/utilities/ui/options") local OptionsUtilities = require("scripts/utilities/ui/options")
local InputUtils = require("scripts/managers/input/input_utils") local InputUtils = require("scripts/managers/input/input_utils")
@ -145,7 +145,7 @@ _type_template_map["dropdown"] = create_dropdown_template
local set_new_keybind = function (self, keybind_widget_content) local set_new_keybind = function (self, keybind_widget_content)
vmf.add_mod_keybind( dmf.add_mod_keybind(
get_mod(keybind_widget_content.mod_name), get_mod(keybind_widget_content.mod_name),
keybind_widget_content.setting_id, keybind_widget_content.setting_id,
{ {
@ -196,7 +196,7 @@ local create_keybind_template = function (self, params)
if cancel_key == new_value.main then if cancel_key == new_value.main then
-- Prevent unbinding the mod options menu -- Prevent unbinding the mod options menu
if params.setting_id ~= "open_vmf_options" then if params.setting_id ~= "open_dmf_options" then
params.keybind_text = "" params.keybind_text = ""
params.keys = {} params.keys = {}
@ -250,8 +250,8 @@ local function widget_data_to_template(self, data)
if data and data.type and type(data.type) == "string" and _type_template_map[data.type] then if data and data.type and type(data.type) == "string" and _type_template_map[data.type] then
return _type_template_map[data.type](self, data) return _type_template_map[data.type](self, data)
else else
vmf:dump(data, "widget", 1) dmf:dump(data, "widget", 1)
vmf.throw_error("[widget \"%s\"]: 'type' field must contain valid widget type name.", data.setting_id) dmf.throw_error("[widget \"%s\"]: 'type' field must contain valid widget type name.", data.setting_id)
end end
end end
@ -273,16 +273,16 @@ end
-- #################################################################################################################### -- ####################################################################################################################
-- #################################################################################################################### -- ####################################################################################################################
-- ##### VMF internal functions and variables ######################################################################### -- ##### DMF internal functions and variables #########################################################################
-- #################################################################################################################### -- ####################################################################################################################
-- Add mod settings to options view -- Add mod settings to options view
vmf.create_mod_options_settings = function (self, options_templates) dmf.create_mod_options_settings = function (self, options_templates)
local categories = options_templates.categories local categories = options_templates.categories
local settings = options_templates.settings local settings = options_templates.settings
for _, mod_data in ipairs(vmf.options_widgets_data) do for _, mod_data in ipairs(dmf.options_widgets_data) do
local category = create_mod_category(self, categories, mod_data[1]) local category = create_mod_category(self, categories, mod_data[1])
for _, widget_data in ipairs(mod_data) do for _, widget_data in ipairs(mod_data) do
@ -341,26 +341,26 @@ vmf.create_mod_options_settings = function (self, options_templates)
end end
vmf.initialize_vmf_options_view = function () dmf.initialize_dmf_options_view = function ()
vmf:add_require_path("dmf/scripts/mods/vmf/modules/ui/options/vmf_options_view") dmf:add_require_path("dmf/scripts/mods/dmf/modules/ui/options/dmf_options_view")
vmf:add_require_path("dmf/scripts/mods/vmf/modules/ui/options/vmf_options_view_definitions") dmf:add_require_path("dmf/scripts/mods/dmf/modules/ui/options/dmf_options_view_definitions")
vmf:add_require_path("dmf/scripts/mods/vmf/modules/ui/options/vmf_options_view_settings") dmf:add_require_path("dmf/scripts/mods/dmf/modules/ui/options/dmf_options_view_settings")
vmf:add_require_path("dmf/scripts/mods/vmf/modules/ui/options/vmf_options_view_content_blueprints") dmf:add_require_path("dmf/scripts/mods/dmf/modules/ui/options/dmf_options_view_content_blueprints")
vmf:register_view({ dmf:register_view({
view_name = "vmf_options_view", view_name = "dmf_options_view",
view_settings = { view_settings = {
init_view_function = function (ingame_ui_context) init_view_function = function (ingame_ui_context)
return true return true
end, end,
class = "VMFOptionsView", class = "DMFOptionsView",
disable_game_world = false, disable_game_world = false,
display_name = "loc_options_view_display_name", display_name = "loc_options_view_display_name",
game_world_blur = 1.1, game_world_blur = 1.1,
load_always = true, load_always = true,
load_in_hub = true, load_in_hub = true,
package = "packages/ui/views/options_view/options_view", package = "packages/ui/views/options_view/options_view",
path = "dmf/scripts/mods/vmf/modules/ui/options/vmf_options_view", path = "dmf/scripts/mods/dmf/modules/ui/options/dmf_options_view",
state_bound = true, state_bound = true,
enter_sound_events = { enter_sound_events = {
"wwise/events/ui/play_ui_enter_short" "wwise/events/ui/play_ui_enter_short"
@ -381,7 +381,7 @@ vmf.initialize_vmf_options_view = function ()
} }
}) })
vmf:dofile("dmf/scripts/mods/vmf/modules/ui/options/vmf_options_view") dmf:dofile("dmf/scripts/mods/dmf/modules/ui/options/dmf_options_view")
end end
-- #################################################################################################################### -- ####################################################################################################################

View file

@ -1,4 +0,0 @@
local vmf = get_mod("VMF")
-- Add vmf functions with a value of dummy_func if they need to be defined while a module is disabled.
local dummy_func = function() return end

View file

@ -1,112 +0,0 @@
local vmf
-- Global variable indicating which version of the game is currently running
VT1 = false
-- Native mod object used by Fatshark mod manager
local vmf_mod_object = {}
-- Global method to load a file through iowith a return
local mod_dofile = Mods.file.dofile
-- #####################################################################################################################
-- ##### Initialization ################################################################################################
-- #####################################################################################################################
function vmf_mod_object:init()
mod_dofile("dmf/scripts/mods/vmf/modules/vmf_mod_data")
mod_dofile("dmf/scripts/mods/vmf/modules/vmf_mod_manager")
--mod_dofile("dmf/scripts/mods/vmf/modules/vmf_dummy")
mod_dofile("dmf/scripts/mods/vmf/modules/vmf_package_manager")
mod_dofile("dmf/scripts/mods/vmf/modules/core/safe_calls")
mod_dofile("dmf/scripts/mods/vmf/modules/core/events")
mod_dofile("dmf/scripts/mods/vmf/modules/core/settings")
mod_dofile("dmf/scripts/mods/vmf/modules/core/logging")
mod_dofile("dmf/scripts/mods/vmf/modules/core/misc")
mod_dofile("dmf/scripts/mods/vmf/modules/core/persistent_tables")
mod_dofile("dmf/scripts/mods/vmf/modules/debug/dev_console")
mod_dofile("dmf/scripts/mods/vmf/modules/debug/table_dump")
mod_dofile("dmf/scripts/mods/vmf/modules/core/hooks")
mod_dofile("dmf/scripts/mods/vmf/modules/core/require")
mod_dofile("dmf/scripts/mods/vmf/modules/core/toggling")
mod_dofile("dmf/scripts/mods/vmf/modules/core/keybindings")
mod_dofile("dmf/scripts/mods/vmf/modules/core/chat")
mod_dofile("dmf/scripts/mods/vmf/modules/core/localization")
mod_dofile("dmf/scripts/mods/vmf/modules/core/options")
mod_dofile("dmf/scripts/mods/vmf/modules/core/network")
mod_dofile("dmf/scripts/mods/vmf/modules/core/commands")
mod_dofile("dmf/scripts/mods/vmf/modules/gui/custom_textures")
mod_dofile("dmf/scripts/mods/vmf/modules/gui/custom_views")
mod_dofile("dmf/scripts/mods/vmf/modules/ui/chat/chat_actions")
mod_dofile("dmf/scripts/mods/vmf/modules/ui/options/mod_options")
mod_dofile("dmf/scripts/mods/vmf/modules/vmf_options")
mod_dofile("dmf/scripts/mods/vmf/modules/core/mutators/mutators_manager")
vmf = get_mod("VMF")
vmf.delayed_chat_messages_hook()
vmf:hook(ModManager, "destroy", function(func, ...)
vmf.mods_unload_event(true)
func(...)
end)
end
-- #####################################################################################################################
-- ##### Events ########################################################################################################
-- #####################################################################################################################
function vmf_mod_object:update(dt)
vmf.update_package_manager()
vmf.mods_update_event(dt)
vmf.check_keybinds()
vmf.execute_queued_chat_command()
if not vmf.all_mods_were_loaded and Managers.mod._state == "done" then
vmf.generate_keybinds()
vmf.initialize_vmf_options_view()
vmf.create_network_dictionary()
vmf.ping_vmf_users()
vmf.all_mods_loaded_event()
vmf.all_mods_were_loaded = true
end
end
function vmf_mod_object:on_unload()
print("VMF:ON_UNLOAD()")
vmf.save_chat_history()
vmf.save_unsaved_settings_to_file()
vmf.destroy_command_gui()
end
function vmf_mod_object:on_reload()
print("VMF:ON_RELOAD()")
vmf.mods_unload_event(false)
vmf.remove_custom_views()
vmf.unload_all_resource_packages()
vmf.hooks_unload()
vmf.reset_guis()
vmf.destroy_command_gui()
end
function vmf_mod_object:on_game_state_changed(status, state)
print("VMF:ON_GAME_STATE_CHANGED(), status: " .. tostring(status) .. ", state: " .. tostring(state))
vmf.mods_game_state_changed_event(status, state)
vmf.save_unsaved_settings_to_file()
vmf.apply_delayed_hooks(status, state)
vmf.destroy_command_gui()
if status == "enter" and state == "StateIngame" then
vmf.create_keybinds_input_service()
end
end
-- #####################################################################################################################
-- ##### Return ########################################################################################################
-- #####################################################################################################################
return vmf_mod_object