Refactoring

This commit is contained in:
GreenComfyTea
2022-07-26 19:27:37 +03:00
parent a20c458629
commit 2f9a8ac6a3
41 changed files with 5939 additions and 18587 deletions

View File

@@ -15,7 +15,7 @@ function screen.update_window_size()
else
width, height = screen.get_game_window_size();
end
if width ~= nil then
screen.width = width;
end
@@ -35,7 +35,9 @@ local height_field = size_type:get_field("h");
function screen.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");
scene_view = sdk.call_native_func(singletons.scene_manager,
sdk.find_type_definition("via.SceneManager")
, "get_MainView");
if scene_view == nil then
--log.error("[MHR_Overlay.lua] No scene view");
@@ -56,7 +58,7 @@ function screen.get_game_window_size()
end
local screen_height = height_field:get_data(size);
if screen_height == nil then
if screen_height == nil then
--log.error("[MHR_Overlay.lua] No screen height");
return;
end
@@ -71,32 +73,32 @@ function screen.calculate_absolute_coordinates(position)
x = position.x * global_position_modifier;
y = position.y * global_position_modifier;
}
-- top left
if position.anchor == "Top-Left" then
return {x = _position.x, y = _position.y};
return { x = _position.x, y = _position.y };
end
-- top right
if position.anchor == "Top-Right" then
local screen_x = screen.width - _position.x;
return {x = screen_x, y = _position.y};
return { x = screen_x, y = _position.y };
end
-- bottom left
if position.anchor == "Bottom-Left" then
local screen_y = screen.height - _position.y;
return {x = _position.x, y = screen_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;
return {x = screen_x, y = screen_y};
return { x = screen_x, y = screen_y };
end
return {x = _position.x, y = _position.y};
return { x = _position.x, y = _position.y };
end
function screen.init_module()