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 screen = {};
local this = {};
local config;
local singletons;
@@ -35,25 +35,25 @@ local os = os;
local ValueType = ValueType;
local package = package;
screen.width = 1920;
screen.height = 1080;
this.width = 1920;
this.height = 1080;
function screen.update_window_size()
function this.update_window_size()
local width;
local height;
if d2d ~= nil and config.current_config.global_settings.renderer.use_d2d_if_available then
width, height = d2d.surface_size();
else
width, height = screen.get_game_window_size();
width, height = this.get_game_window_size();
end
if width ~= nil then
screen.width = width;
this.width = width;
end
if height ~= nil then
screen.height = height;
this.height = height;
end
end
@@ -65,7 +65,7 @@ local size_type = get_size_method:get_return_type();
local width_field = size_type:get_field("w");
local height_field = size_type:get_field("h");
function screen.get_game_window_size()
function this.get_game_window_size()
if scene_view == nil then
scene_view = sdk.call_native_func(singletons.scene_manager, sdk.find_type_definition("via.SceneManager") , "get_MainView");
@@ -96,7 +96,7 @@ function screen.get_game_window_size()
return screen_width, screen_height;
end
function screen.calculate_absolute_coordinates(position)
function this.calculate_absolute_coordinates(position)
local global_position_modifier = config.current_config.global_settings.modifiers.global_position_modifier;
local _position = {
@@ -111,29 +111,29 @@ function screen.calculate_absolute_coordinates(position)
-- top right
if position.anchor == "Top-Right" then
local screen_x = screen.width - _position.x;
local screen_x = this.width - _position.x;
return { x = screen_x, y = _position.y };
end
-- bottom left
if position.anchor == "Bottom-Left" then
local screen_y = screen.height - _position.y;
local screen_y = this.height - _position.y;
return { x = _position.x, y = screen_y };
end
-- bottom right
if position.anchor == "Bottom-Right" then
local screen_x = screen.width - _position.x;
local screen_y = screen.height - _position.y;
local screen_x = this.width - _position.x;
local screen_y = this.height - _position.y;
return { x = screen_x, y = screen_y };
end
return { x = _position.x, y = _position.y };
end
function screen.init_module()
function this.init_module()
config = require("MHR_Overlay.Misc.config");
singletons = require("MHR_Overlay.Game_Handler.singletons");
end
return screen;
return this;