Utilize this keyword everywhere

This commit is contained in:
GreenComfyTea
2023-04-21 10:19:12 +03:00
parent 94e9e5d18b
commit 9b1ff5b264
49 changed files with 1398 additions and 1403 deletions

View File

@@ -1,4 +1,4 @@
local buff_UI = {};
local this = {};
local buff_UI_entity;
local config;
@@ -37,7 +37,7 @@ local os = os;
local ValueType = ValueType;
local package = package;
function buff_UI.draw()
function this.draw()
local cached_config = config.current_config.buff_UI;
local global_scale_modifier = config.current_config.global_settings.modifiers.global_scale_modifier;
@@ -110,7 +110,7 @@ function buff_UI.draw()
end
end
function buff_UI.init_module()
function this.init_module()
config = require("MHR_Overlay.Misc.config");
buff_UI_entity = require("MHR_Overlay.UI.UI_Entities.buff_UI_entity");
buffs = require("MHR_Overlay.Buffs.buffs");
@@ -124,4 +124,4 @@ function buff_UI.init_module()
--drawing = require("MHR_Overlay.UI.drawing");
end
return buff_UI;
return this;

View File

@@ -1,4 +1,4 @@
local damage_meter_UI = {};
local this = {};
local singletons;
local config;
@@ -43,8 +43,8 @@ local os = os;
local ValueType = ValueType;
local package = package;
damage_meter_UI.last_displayed_players = {};
damage_meter_UI.freeze_displayed_players = false;
this.last_displayed_players = {};
this.freeze_displayed_players = false;
local lobby_manager_type_def = sdk.find_type_definition("snow.LobbyManager");
local quest_hunter_info_field = lobby_manager_type_def:get_field("_questHunterInfo");
@@ -57,7 +57,7 @@ local get_item_method = quest_hunter_info_type_def:get_method("get_Item");
local hunter_info_type_def = sdk.find_type_definition("snow.LobbyManager.HunterInfo");
local member_index_field = hunter_info_type_def:get_field("_memberIndex");
function damage_meter_UI.draw()
function this.draw()
local cached_config = config.current_config.damage_meter_UI;
local global_scale_modifier = config.current_config.global_settings.modifiers.global_scale_modifier;
@@ -67,13 +67,13 @@ function damage_meter_UI.draw()
local quest_players = {};
if damage_meter_UI.freeze_displayed_players and not utils.table.is_empty(damage_meter_UI.last_displayed_players) then
quest_players = damage_meter_UI.last_displayed_players;
if this.freeze_displayed_players and not utils.table.is_empty(this.last_displayed_players) then
quest_players = this.last_displayed_players;
else
quest_players = players.display_list;
end
damage_meter_UI.last_displayed_players = quest_players;
this.last_displayed_players = quest_players;
local top_damage = 0;
local top_dps = 0;
@@ -175,7 +175,7 @@ function damage_meter_UI.draw()
end
end
function damage_meter_UI.init_module()
function this.init_module()
singletons = require("MHR_Overlay.Game_Handler.singletons");
config = require("MHR_Overlay.Misc.config");
customization_menu = require("MHR_Overlay.UI.customization_menu");
@@ -188,4 +188,4 @@ function damage_meter_UI.init_module()
utils = require("MHR_Overlay.Misc.utils");
end
return damage_meter_UI;
return this;

View File

@@ -1,4 +1,4 @@
local env_creature_UI = {};
local this = {};
local singletons;
local config;
@@ -46,7 +46,7 @@ local package = package;
local enemy_manager_type_def = sdk.find_type_definition("snow.enemy.EnemyManager");
function env_creature_UI.draw()
function this.draw()
if singletons.enemy_manager == nil then
return;
end
@@ -94,7 +94,7 @@ function env_creature_UI.draw()
end
end
function env_creature_UI.init_module()
function this.init_module()
singletons = require("MHR_Overlay.Game_Handler.singletons");
config = require("MHR_Overlay.Misc.config");
customization_menu = require("MHR_Overlay.UI.customization_menu");
@@ -108,4 +108,4 @@ function env_creature_UI.init_module()
env_creature = require("MHR_Overlay.Endemic_Life.env_creature");
end
return env_creature_UI;
return this;

View File

@@ -1,4 +1,4 @@
local large_monster_UI = {};
local this = {};
local singletons;
local config;
@@ -53,7 +53,7 @@ local get_tg_camera_method = gui_manager_type_def:get_method("get_refGuiHud_TgCa
local tg_camera_type_def = get_tg_camera_method:get_return_type();
local get_targeting_enemy_index_field = tg_camera_type_def:get_field("OldTargetingEmIndex");
function large_monster_UI.draw(dynamic_enabled, static_enabled, highlighted_enabled)
function this.draw(dynamic_enabled, static_enabled, highlighted_enabled)
local cached_config = config.current_config.large_monster_UI;
if singletons.enemy_manager == nil then
@@ -153,27 +153,27 @@ function large_monster_UI.draw(dynamic_enabled, static_enabled, highlighted_enab
end
if dynamic_enabled then
local success = pcall(large_monster_UI.draw_dynamic, displayed_monsters, highlighted_monster, cached_config);
local success = pcall(this.draw_dynamic, displayed_monsters, highlighted_monster, cached_config);
if not success then
customization_menu.status = string.format("[%s] Dynamic Large Monster drawing function threw an exception");
end
end
if highlighted_enabled then
local success = pcall(large_monster_UI.draw_highlighted, highlighted_monster, cached_config);
local success = pcall(this.draw_highlighted, highlighted_monster, cached_config);
if not success then
customization_menu.status = string.format("[%s] Highlighted Large Monster drawing function threw an exception");
end
end
if static_enabled then
local success = pcall(large_monster_UI.draw_static, displayed_monsters, highlighted_monster, cached_config);
local success = pcall(this.draw_static, displayed_monsters, highlighted_monster, cached_config);
if not success then
customization_menu.status = string.format("[%s] Static Large Monster drawing function threw an exception");
end
end
end
function large_monster_UI.draw_dynamic(displayed_monsters, highlighted_monster, cached_config)
function this.draw_dynamic(displayed_monsters, highlighted_monster, cached_config)
cached_config = cached_config.dynamic;
local global_scale_modifier = config.current_config.global_settings.modifiers.global_scale_modifier;
@@ -230,7 +230,7 @@ function large_monster_UI.draw_dynamic(displayed_monsters, highlighted_monster,
end
end
function large_monster_UI.draw_static(displayed_monsters, highlighted_monster, cached_config)
function this.draw_static(displayed_monsters, highlighted_monster, cached_config)
cached_config = cached_config.static;
local global_scale_modifier = config.current_config.global_settings.modifiers.global_scale_modifier;
@@ -311,7 +311,7 @@ function large_monster_UI.draw_static(displayed_monsters, highlighted_monster, c
end
end
function large_monster_UI.draw_highlighted(monster, cached_config)
function this.draw_highlighted(monster, cached_config)
cached_config = cached_config.highlighted;
if monster == nil then
@@ -327,7 +327,7 @@ function large_monster_UI.draw_highlighted(monster, cached_config)
large_monster.draw(monster, "highlighted", cached_config, position_on_screen, 1);
end
function large_monster_UI.init_module()
function this.init_module()
singletons = require("MHR_Overlay.Game_Handler.singletons");
config = require("MHR_Overlay.Misc.config");
customization_menu = require("MHR_Overlay.UI.customization_menu");
@@ -340,4 +340,4 @@ function large_monster_UI.init_module()
rage_UI_entity = require("MHR_Overlay.UI.UI_Entities.rage_UI_entity");
end
return large_monster_UI;
return this;

View File

@@ -1,4 +1,4 @@
local small_monster_UI = {};
local this = {};
local singletons;
local config;
@@ -46,7 +46,7 @@ local enemy_manager_type_def = sdk.find_type_definition("snow.enemy.EnemyManager
local get_zako_enemy_count_method = enemy_manager_type_def:get_method("getZakoEnemyCount");
local get_zako_enemy_method = enemy_manager_type_def:get_method("getZakoEnemy");
function small_monster_UI.draw()
function this.draw()
if singletons.enemy_manager == nil then
return;
end
@@ -186,7 +186,7 @@ function small_monster_UI.draw()
end
end
function small_monster_UI.init_module()
function this.init_module()
singletons = require("MHR_Overlay.Game_Handler.singletons");
config = require("MHR_Overlay.Misc.config");
customization_menu = require("MHR_Overlay.UI.customization_menu");
@@ -198,4 +198,4 @@ function small_monster_UI.init_module()
stamina_UI_entity = require("MHR_Overlay.UI.UI_Entities.stamina_UI_entity");
end
return small_monster_UI;
return this;

View File

@@ -1,4 +1,4 @@
local time_UI = {};
local this = {};
local time;
local screen;
@@ -38,9 +38,9 @@ local os = os;
local ValueType = ValueType;
local package = package;
time_UI.label = nil;
this.label = nil;
function time_UI.draw()
function this.draw()
local elapsed_minutes = time.elapsed_minutes;
local elapsed_seconds = time.elapsed_seconds;
@@ -50,26 +50,26 @@ function time_UI.draw()
local position_on_screen = screen.calculate_absolute_coordinates(config.current_config.time_UI.position);
drawing.draw_label(time_UI.label, position_on_screen, 1, elapsed_minutes, elapsed_seconds);
drawing.draw_label(this.label, position_on_screen, 1, elapsed_minutes, elapsed_seconds);
end
function time_UI.init_UI()
time_UI.label = utils.table.deep_copy(config.current_config.time_UI.time_label);
function this.init_UI()
this.label = utils.table.deep_copy(config.current_config.time_UI.time_label);
local global_scale_modifier = config.current_config.global_settings.modifiers.global_scale_modifier;
time_UI.label.offset.x = time_UI.label.offset.x * global_scale_modifier;
time_UI.label.offset.y = time_UI.label.offset.y * global_scale_modifier;
this.label.offset.x = this.label.offset.x * global_scale_modifier;
this.label.offset.y = this.label.offset.y * global_scale_modifier;
end
function time_UI.init_module()
function this.init_module()
time = require("MHR_Overlay.Game_Handler.time");
screen = require("MHR_Overlay.Game_Handler.screen");
config = require("MHR_Overlay.Misc.config");
drawing = require("MHR_Overlay.UI.drawing");
utils = require("MHR_Overlay.Misc.utils");
time_UI.init_UI()
this.init_UI()
end
return time_UI;
return this;