mirror of
https://github.com/GreenComfyTea/MHR-Overlay.git
synced 2026-01-24 20:38:03 -08:00
Refactored into modules.
This commit is contained in:
2369
MHR_Overlay/UI/customization_menu.lua
Normal file
2369
MHR_Overlay/UI/customization_menu.lua
Normal file
File diff suppressed because it is too large
Load Diff
249
MHR_Overlay/UI/damage_meter_UI.lua
Normal file
249
MHR_Overlay/UI/damage_meter_UI.lua
Normal file
@@ -0,0 +1,249 @@
|
||||
local damage_meter_UI = {};
|
||||
local singletons;
|
||||
local config;
|
||||
local customization_menu;
|
||||
local player;
|
||||
local quest_status;
|
||||
local screen;
|
||||
local drawing;
|
||||
|
||||
damage_meter_UI.last_displayed_players = {};
|
||||
|
||||
function damage_meter_UI.draw()
|
||||
|
||||
if player.total.display.total_damage == 0 and config.current_config.damage_meter_UI.settings.hide_module_if_total_damage_is_zero then
|
||||
return;
|
||||
end
|
||||
|
||||
if singletons.lobby_manager == nil then
|
||||
return;
|
||||
end
|
||||
|
||||
if singletons.progress_manager == nil then
|
||||
return;
|
||||
end
|
||||
|
||||
-- myself player
|
||||
local myself_player_info = singletons.lobby_manager:get_field("_myHunterInfo");
|
||||
if myself_player_info == nil then
|
||||
customization_menu.status = "No myself player info list";
|
||||
return;
|
||||
end
|
||||
|
||||
local myself_player_name = myself_player_info:get_field("_name");
|
||||
if myself_player_name == nil then
|
||||
customization_menu.status = "No myself player name";
|
||||
return;
|
||||
end
|
||||
|
||||
if quest_status.is_online then
|
||||
player.myself_id = singletons.lobby_manager:get_field("_myselfQuestIndex");
|
||||
if player.myself_id == nil then
|
||||
customization_menu.status = "No myself player id";
|
||||
return;
|
||||
end
|
||||
else
|
||||
player.myself_id = singletons.lobby_manager:get_field("_myselfIndex");
|
||||
if player.myself_id == nil then
|
||||
customization_menu.status = "No myself player id";
|
||||
return;
|
||||
end
|
||||
end
|
||||
|
||||
local myself_hunter_rank = singletons.progress_manager:call("get_HunterRank");
|
||||
if myself_hunter_rank == nil then
|
||||
customization_menu.status = "No myself hunter rank";
|
||||
myself_hunter_rank = 0;
|
||||
end
|
||||
|
||||
if player.list[player.myself_id] == nil then
|
||||
player.list[player.myself_id] = player.new(player.myself_id, myself_player_name, myself_hunter_rank);
|
||||
player.myself = player.list[player.myself_id];
|
||||
end
|
||||
|
||||
local quest_players = {};
|
||||
|
||||
if quest_status.index > 2 then
|
||||
quest_players = damage_meter_UI.last_displayed_players;
|
||||
else
|
||||
-- other players
|
||||
local player_info_list = singletons.lobby_manager:get_field("_questHunterInfo");
|
||||
if player_info_list == nil then
|
||||
customization_menu.status = "No player info list";
|
||||
end
|
||||
|
||||
local count = player_info_list:call("get_Count");
|
||||
if count == nil then
|
||||
customization_menu.status = "No player info list count";
|
||||
return;
|
||||
end
|
||||
|
||||
for i = 0, count - 1 do
|
||||
|
||||
local player_info = player_info_list:call("get_Item", i);
|
||||
if player_info == nil then
|
||||
goto continue
|
||||
end
|
||||
|
||||
local player_id = player_info:get_field("_memberIndex");
|
||||
if player_id == nil then
|
||||
|
||||
goto continue
|
||||
end
|
||||
|
||||
local player_hunter_rank = player_info:get_field("_hunterRank");
|
||||
if player_hunter_rank == nil then
|
||||
goto continue
|
||||
end
|
||||
|
||||
if player_id == player.myself_id and config.current_config.damage_meter_UI.settings.my_damage_bar_location ~= "Normal" then
|
||||
player.list[player.myself_id].hunter_rank = player_hunter_rank;
|
||||
goto continue
|
||||
end
|
||||
|
||||
local player_name = player_info:get_field("_name");
|
||||
if player_name == nil then
|
||||
goto continue
|
||||
end
|
||||
|
||||
if player.list[player_id] == nil then
|
||||
player.list[player_id] = player.new(player_id, player_name, player_hunter_rank);
|
||||
elseif player.list[player_id].name ~= player_name then
|
||||
player.list[player_id] = player.new(player_id, player_name, player_hunter_rank);
|
||||
end
|
||||
|
||||
table.insert(quest_players, player.list[player_id]);
|
||||
|
||||
::continue::
|
||||
end
|
||||
|
||||
-- sort here
|
||||
if config.current_config.damage_meter_UI.sorting.type == "Normal" and config.current_config.damage_meter_UI.sorting.reversed_order then
|
||||
|
||||
local reversed_quest_players = {};
|
||||
for i = #quest_players, 1, -1 do
|
||||
table.insert(reversed_quest_players, quest_players[i]);
|
||||
end
|
||||
quest_players = reversed_quest_players;
|
||||
elseif config.current_config.damage_meter_UI.sorting.type == "Damage" then
|
||||
if config.current_config.damage_meter_UI.sorting.reversed_order then
|
||||
table.sort(quest_players, function(left, right)
|
||||
return left.display.total_damage < right.display.total_damage;
|
||||
end);
|
||||
else
|
||||
table.sort(quest_players, function(left, right)
|
||||
return left.display.total_damage > right.display.total_damage;
|
||||
end);
|
||||
end
|
||||
end
|
||||
|
||||
if config.current_config.damage_meter_UI.settings.my_damage_bar_location == "First" then
|
||||
table.insert(quest_players, 1, player.list[player.myself_id]);
|
||||
elseif config.current_config.damage_meter_UI.settings.my_damage_bar_location == "Last" then
|
||||
table.insert(quest_players, #quest_players + 1, player.list[player.myself_id]);
|
||||
elseif #quest_players == 0 then
|
||||
table.insert(quest_players, 1, player.list[player.myself_id]);
|
||||
end
|
||||
|
||||
damage_meter_UI.last_displayed_players = quest_players;
|
||||
end
|
||||
|
||||
local top_damage = 0;
|
||||
for _, _player in ipairs(quest_players) do
|
||||
if _player.display.total_damage > top_damage then
|
||||
top_damage = _player.display.total_damage;
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
-- draw
|
||||
local position_on_screen = screen.calculate_absolute_coordinates(config.current_config.damage_meter_UI.position);
|
||||
for _, _player in ipairs(quest_players) do
|
||||
|
||||
if _player.display.total_damage == 0 and config.current_config.damage_meter_UI.settings.hide_player_if_player_damage_is_zero then
|
||||
goto continue1
|
||||
end
|
||||
|
||||
local player_damage_percentage = 0;
|
||||
if player.total.display.total_damage ~= 0 then
|
||||
player_damage_percentage = _player.display.total_damage / player.total.display.total_damage;
|
||||
end
|
||||
|
||||
local player_damage_bar_percentage = 0;
|
||||
if config.current_config.damage_meter_UI.settings.damage_bar_relative_to == "Total Damage" then
|
||||
if player.total.display.total_damage ~= 0 then
|
||||
player_damage_bar_percentage = _player.display.total_damage / player.total.display.total_damage;
|
||||
end
|
||||
else
|
||||
if top_damage ~= 0 then
|
||||
player_damage_bar_percentage = _player.display.total_damage / top_damage;
|
||||
end
|
||||
end
|
||||
|
||||
if _player.id == player.myself_id and config.current_config.damage_meter_UI.settings.highlighted_bar == "Me" then
|
||||
drawing.draw_bar(config.current_config.damage_meter_UI.highlighted_damage_bar, position_on_screen, player_damage_bar_percentage);
|
||||
elseif config.current_config.damage_meter_UI.settings.highlighted_bar == "Top Damage" and _player.display.total_damage == top_damage then
|
||||
drawing.draw_bar(config.current_config.damage_meter_UI.highlighted_damage_bar, position_on_screen, player_damage_bar_percentage);
|
||||
else
|
||||
drawing.draw_bar(config.current_config.damage_meter_UI.damage_bar, position_on_screen, player_damage_bar_percentage);
|
||||
end
|
||||
|
||||
|
||||
local player_include = config.current_config.damage_meter_UI.player_name_label.include.others;
|
||||
if _player.id == player.myself_id then
|
||||
player_include = config.current_config.damage_meter_UI.player_name_label.include.myself;
|
||||
end
|
||||
|
||||
local player_name_text = "";
|
||||
if player_include.hunter_rank then
|
||||
player_name_text = string.format("[%d] ", _player.hunter_rank);
|
||||
end
|
||||
|
||||
if player_include.word_player then
|
||||
player_name_text = player_name_text .. "Player ";
|
||||
end
|
||||
|
||||
if player_include.player_id then
|
||||
player_name_text = player_name_text .. string.format("%d ", _player.id);
|
||||
end
|
||||
|
||||
if player_include.player_name then
|
||||
player_name_text = player_name_text .. _player.name;
|
||||
end
|
||||
|
||||
drawing.draw_label(config.current_config.damage_meter_UI.player_name_label, position_on_screen, player_name_text);
|
||||
drawing.draw_label(config.current_config.damage_meter_UI.damage_value_label, position_on_screen, _player.display.total_damage);
|
||||
drawing.draw_label(config.current_config.damage_meter_UI.damage_percentage_label, position_on_screen, 100 * player_damage_percentage);
|
||||
|
||||
if config.current_config.damage_meter_UI.settings.orientation == "Horizontal" then
|
||||
position_on_screen.x = position_on_screen.x + config.current_config.damage_meter_UI.spacing.x;
|
||||
else
|
||||
position_on_screen.y = position_on_screen.y + config.current_config.damage_meter_UI.spacing.y;
|
||||
end
|
||||
|
||||
::continue1::
|
||||
|
||||
end
|
||||
|
||||
-- draw total damage
|
||||
if not config.current_config.damage_meter_UI.settings.total_damage_offset_is_relative then
|
||||
position_on_screen = screen.calculate_absolute_coordinates(config.current_config.damage_meter_UI.position);
|
||||
end
|
||||
|
||||
drawing.draw_label(config.current_config.damage_meter_UI.total_damage_label, position_on_screen);
|
||||
drawing.draw_label(config.current_config.damage_meter_UI.total_damage_value_label, position_on_screen, player.total.display.total_damage);
|
||||
|
||||
end
|
||||
|
||||
function damage_meter_UI.init_module()
|
||||
singletons = require("MHR_Overlay.Game_Handler.singletons");
|
||||
config = require("MHR_Overlay.Misc.config");
|
||||
customization_menu = require("MHR_Overlay.UI.customization_menu");
|
||||
player = require("MHR_Overlay.Damage_Meter.player");
|
||||
quest_status = require("MHR_Overlay.Game_Handler.quest_status");
|
||||
screen = require("MHR_Overlay.Game_Handler.screen");
|
||||
drawing = require("MHR_Overlay.UI.drawing");
|
||||
end
|
||||
|
||||
return damage_meter_UI;
|
||||
100
MHR_Overlay/UI/drawing.lua
Normal file
100
MHR_Overlay/UI/drawing.lua
Normal file
@@ -0,0 +1,100 @@
|
||||
local drawing = {};
|
||||
local config;
|
||||
|
||||
drawing.font = nil;
|
||||
|
||||
function drawing.init_font()
|
||||
drawing.font = d2d.create_font(config.current_config.global_settings.font.family, config.current_config.global_settings.font.size, config.current_config.global_settings.font.bold, config.current_config.global_settings.font.italic);
|
||||
end
|
||||
|
||||
function drawing.color_to_argb(color)
|
||||
local alpha = (color >> 24) & 0xFF;
|
||||
local red = (color >> 16) & 0xFF;
|
||||
local green = (color >> 8) & 0xFF;
|
||||
local blue = color & 0xFF;
|
||||
|
||||
return alpha, red, green, blue;
|
||||
end
|
||||
|
||||
function drawing.argb_to_color(alpha, red, green, blue)
|
||||
return 0x1000000 * alpha + 0x10000 * red + 0x100 * green + blue;
|
||||
end
|
||||
|
||||
function drawing.scale_color_opacity(color, scale)
|
||||
local alpha, red, green, blue = drawing.color_to_argb(color);
|
||||
local new_alpha = math.floor(alpha * scale);
|
||||
if new_alpha < 0 then new_alpha = 0; end
|
||||
if new_alpha > 255 then new_alpha = 255; end
|
||||
|
||||
return drawing.argb_to_color(new_alpha, red, green, blue);
|
||||
end
|
||||
|
||||
function drawing.scale_bar_opacity(bar, scale)
|
||||
if bar == nil or scale == nil then
|
||||
return;
|
||||
end
|
||||
|
||||
if not bar.visibility then
|
||||
return;
|
||||
end
|
||||
|
||||
bar.colors.foreground = drawing.scale_color_opacity(bar.colors.foreground, scale);
|
||||
bar.colors.background = drawing.scale_color_opacity(bar.colors.background, scale);
|
||||
end
|
||||
|
||||
function drawing.scale_label_opacity(label, scale)
|
||||
if label == nil or scale == nil then
|
||||
return;
|
||||
end
|
||||
|
||||
if not label.visibility then
|
||||
return;
|
||||
end
|
||||
|
||||
label.color = drawing.scale_color_opacity(label.color, scale);
|
||||
label.shadow.color = drawing.scale_color_opacity(label.shadow.color, scale);
|
||||
end
|
||||
|
||||
function drawing.draw_label(label, position, ...)
|
||||
if label == nil or not label.visibility then
|
||||
return;
|
||||
end
|
||||
|
||||
local text = string.format(label.text, table.unpack({...}));
|
||||
if label.shadow.visibility then
|
||||
d2d.text(drawing.font, text, position.x + label.offset.x + label.shadow.offset.x,
|
||||
position.y + label.offset.y + label.shadow.offset.y, label.shadow.color);
|
||||
end
|
||||
d2d.text(drawing.font, text, position.x + label.offset.x, position.y + label.offset.y, label.color);
|
||||
end
|
||||
|
||||
function drawing.draw_bar(bar, position, percentage)
|
||||
if bar == nil then
|
||||
return;
|
||||
end
|
||||
|
||||
if not bar.visibility then
|
||||
return;
|
||||
end
|
||||
|
||||
if percentage > 1 then
|
||||
percentage = 1;
|
||||
end
|
||||
|
||||
local foreground_width = bar.size.width * percentage;
|
||||
local background_width = bar.size.width - foreground_width;
|
||||
|
||||
-- foreground
|
||||
d2d.fill_rect(position.x + bar.offset.x, position.y + bar.offset.y, foreground_width, bar.size.height,
|
||||
bar.colors.foreground);
|
||||
|
||||
-- background
|
||||
d2d.fill_rect(position.x + foreground_width + bar.offset.x, position.y + bar.offset.y, background_width,
|
||||
bar.size.height, bar.colors.background);
|
||||
end
|
||||
|
||||
function drawing.init_module()
|
||||
config = require("MHR_Overlay.Misc.config");
|
||||
end
|
||||
|
||||
return drawing;
|
||||
238
MHR_Overlay/UI/large_monster_UI.lua
Normal file
238
MHR_Overlay/UI/large_monster_UI.lua
Normal file
@@ -0,0 +1,238 @@
|
||||
local large_monster_UI = {};
|
||||
local singletons;
|
||||
local config;
|
||||
local customization_menu;
|
||||
local large_monster;
|
||||
local screen;
|
||||
local player;
|
||||
local drawing;
|
||||
local table_helpers;
|
||||
|
||||
function large_monster_UI.draw()
|
||||
if singletons.enemy_manager == nil then
|
||||
return;
|
||||
end
|
||||
|
||||
local displayed_monsters = {};
|
||||
|
||||
local enemy_count = singletons.enemy_manager:call("getBossEnemyCount");
|
||||
if enemy_count == nil then
|
||||
return;
|
||||
end
|
||||
|
||||
for i = 0, enemy_count - 1 do
|
||||
local enemy = singletons.enemy_manager:call("getBossEnemy", i);
|
||||
if enemy == nil then
|
||||
customization_menu.status = "No enemy";
|
||||
break
|
||||
end
|
||||
|
||||
local monster = large_monster.list[enemy];
|
||||
if monster == nil then
|
||||
customization_menu.status = "No monster hp entry";
|
||||
break
|
||||
end
|
||||
|
||||
table.insert(displayed_monsters, monster);
|
||||
end
|
||||
|
||||
if not config.current_config.large_monster_UI.dynamic_positioning.enabled then
|
||||
-- sort here
|
||||
|
||||
if config.current_config.large_monster_UI.sorting.type == "Normal" and config.current_config.large_monster_UI.sorting.reversed_order then
|
||||
local reversed_monsters = {};
|
||||
for i = #displayed_monsters, 1, -1 do
|
||||
table.insert(reversed_monsters, displayed_monsters[i]);
|
||||
end
|
||||
|
||||
displayed_monsters = reversed_monsters;
|
||||
|
||||
elseif config.current_config.large_monster_UI.sorting.type == "Health" then
|
||||
if config.current_config.large_monster_UI.sorting.reversed_order then
|
||||
table.sort(displayed_monsters, function(left, right)
|
||||
return left.health > right.health;
|
||||
end);
|
||||
else
|
||||
table.sort(displayed_monsters, function(left, right)
|
||||
return left.health < right.health;
|
||||
end);
|
||||
end
|
||||
elseif config.current_config.large_monster_UI.sorting.type == "Health Percentage" then
|
||||
if config.current_config.large_monster_UI.sorting.reversed_order then
|
||||
table.sort(displayed_monsters, function(left, right)
|
||||
return left.health_percentage > right.health_percentage;
|
||||
end);
|
||||
else
|
||||
table.sort(displayed_monsters, function(left, right)
|
||||
return left.health_percentage < right.health_percentage;
|
||||
end);
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local i = 0;
|
||||
for _, monster in ipairs(displayed_monsters) do
|
||||
local position_on_screen;
|
||||
|
||||
if config.current_config.large_monster_UI.dynamic_positioning.enabled then
|
||||
|
||||
local world_offset = Vector3f.new(config.current_config.large_monster_UI.dynamic_positioning.world_offset.x, config.current_config.large_monster_UI.dynamic_positioning.world_offset.y, config.current_config.large_monster_UI.dynamic_positioning.world_offset.z);
|
||||
|
||||
position_on_screen = draw.world_to_screen(monster.position + world_offset);
|
||||
|
||||
if position_on_screen == nil then
|
||||
goto continue
|
||||
end
|
||||
|
||||
position_on_screen.x = position_on_screen.x + config.current_config.large_monster_UI.dynamic_positioning.viewport_offset.x;
|
||||
position_on_screen.y = position_on_screen.y + config.current_config.large_monster_UI.dynamic_positioning.viewport_offset.y;
|
||||
|
||||
|
||||
else
|
||||
position_on_screen = screen.calculate_absolute_coordinates(config.current_config.large_monster_UI.position);
|
||||
|
||||
if config.current_config.large_monster_UI.settings.orientation == "Horizontal" then
|
||||
position_on_screen.x = position_on_screen.x + config.current_config.large_monster_UI.spacing.x * i;
|
||||
else
|
||||
position_on_screen.y = position_on_screen.y + config.current_config.large_monster_UI.spacing.y * i;
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
local monster_name_label = config.current_config.large_monster_UI.monster_name_label;
|
||||
|
||||
local health_bar = table_helpers.deep_copy(config.current_config.large_monster_UI.health.bar);
|
||||
local health_label = config.current_config.large_monster_UI.health.text_label;
|
||||
local health_value_label = config.current_config.large_monster_UI.health.value_label;
|
||||
local health_percentage_label = config.current_config.large_monster_UI.health.percentage_label;
|
||||
|
||||
local stamina_bar = config.current_config.large_monster_UI.stamina.bar;
|
||||
local stamina_label = config.current_config.large_monster_UI.stamina.text_label;
|
||||
local stamina_value_label = config.current_config.large_monster_UI.stamina.value_label;
|
||||
local stamina_percentage_label = config.current_config.large_monster_UI.stamina.percentage_label;
|
||||
|
||||
local rage_bar = config.current_config.large_monster_UI.rage.bar;
|
||||
local rage_label = config.current_config.large_monster_UI.rage.text_label;
|
||||
local rage_value_label = table_helpers.deep_copy(config.current_config.large_monster_UI.rage.value_label);
|
||||
local rage_percentage_label = table_helpers.deep_copy(config.current_config.large_monster_UI.rage.percentage_label);
|
||||
|
||||
if monster.health <= monster.capture_health then
|
||||
health_bar.colors = health_bar.colors.capture;
|
||||
end
|
||||
|
||||
local monster_name_text = "";
|
||||
if config.current_config.large_monster_UI.monster_name_label.include.monster_name then
|
||||
monster_name_text = string.format("%s ", monster.name);
|
||||
end
|
||||
|
||||
if config.current_config.large_monster_UI.monster_name_label.include.crown and monster.crown ~= "" then
|
||||
monster_name_text = monster_name_text .. string.format("%s ", monster.crown);
|
||||
end
|
||||
if config.current_config.large_monster_UI.monster_name_label.include.size then
|
||||
monster_name_text = monster_name_text .. string.format("#%.0f ", 100 * monster.size);
|
||||
end
|
||||
|
||||
if config.current_config.large_monster_UI.monster_name_label.include.scrown_thresholds then
|
||||
monster_name_text = monster_name_text .. string.format("<=%.0f >=%.0f >=%.0f", 100 * monster.small_border,
|
||||
100 * monster.big_border, 100 * monster.king_border);
|
||||
end
|
||||
|
||||
local rage_bar_percentage = monster.rage_percentage;
|
||||
if monster.is_in_rage then
|
||||
rage_bar_percentage = monster.rage_timer_percentage;
|
||||
end
|
||||
|
||||
if config.current_config.large_monster_UI.dynamic_positioning.enabled then
|
||||
|
||||
if config.current_config.large_monster_UI.dynamic_positioning.max_distance == 0 then
|
||||
return;
|
||||
end
|
||||
|
||||
local distance = (player.myself_position - monster.position):length();
|
||||
|
||||
if distance > config.current_config.large_monster_UI.dynamic_positioning.max_distance then
|
||||
goto continue;
|
||||
end
|
||||
|
||||
if config.current_config.large_monster_UI.dynamic_positioning.opacity_falloff then
|
||||
|
||||
local opacity_falloff = 1 - (distance / config.current_config.large_monster_UI.dynamic_positioning.max_distance);
|
||||
|
||||
monster_name_label = table_helpers.deep_copy(config.current_config.large_monster_UI.monster_name_label);
|
||||
|
||||
health_label = table_helpers.deep_copy(config.current_config.large_monster_UI.health.text_label);
|
||||
health_value_label = table_helpers.deep_copy(config.current_config.large_monster_UI.health.value_label);
|
||||
health_percentage_label = table_helpers.deep_copy(config.current_config.large_monster_UI.health.percentage_label);
|
||||
|
||||
stamina_bar = table_helpers.deep_copy(config.current_config.large_monster_UI.stamina.bar);
|
||||
stamina_label = table_helpers.deep_copy(config.current_config.large_monster_UI.stamina.text_label);
|
||||
stamina_value_label = table_helpers.deep_copy(config.current_config.large_monster_UI.stamina.value_label);
|
||||
stamina_percentage_label = table_helpers.deep_copy(config.current_config.large_monster_UI.stamina.percentage_label);
|
||||
|
||||
rage_bar = table_helpers.deep_copy(config.current_config.large_monster_UI.rage.bar);
|
||||
rage_label = table_helpers.deep_copy(config.current_config.large_monster_UI.rage.text_label);
|
||||
|
||||
drawing.scale_label_opacity(monster_name_label, opacity_falloff);
|
||||
|
||||
drawing.scale_bar_opacity(health_bar, opacity_falloff);
|
||||
drawing.scale_label_opacity(health_label, opacity_falloff);
|
||||
drawing.scale_label_opacity(health_value_label, opacity_falloff);
|
||||
drawing.scale_label_opacity(health_percentage_label, opacity_falloff);
|
||||
|
||||
drawing.scale_bar_opacity(stamina_bar, opacity_falloff);
|
||||
drawing.scale_label_opacity(stamina_label, opacity_falloff);
|
||||
drawing.scale_label_opacity(stamina_value_label, opacity_falloff);
|
||||
drawing.scale_label_opacity(stamina_percentage_label, opacity_falloff);
|
||||
|
||||
drawing.scale_bar_opacity(rage_bar, opacity_falloff);
|
||||
drawing.scale_label_opacity(rage_label, opacity_falloff);
|
||||
drawing.scale_label_opacity(rage_value_label, opacity_falloff);
|
||||
drawing.scale_label_opacity(rage_percentage_label, opacity_falloff);
|
||||
end
|
||||
end
|
||||
|
||||
if monster.is_in_rage then
|
||||
rage_value_label.visibility = false;
|
||||
rage_percentage_label.text = "%.0f:%04.1f";
|
||||
end
|
||||
|
||||
drawing.draw_bar(health_bar, position_on_screen, monster.health_percentage);
|
||||
drawing.draw_bar(stamina_bar, position_on_screen, monster.stamina_percentage);
|
||||
drawing.draw_bar(rage_bar, position_on_screen, rage_bar_percentage);
|
||||
|
||||
drawing.draw_label(monster_name_label, position_on_screen, monster_name_text);
|
||||
|
||||
drawing.draw_label(health_label, position_on_screen);
|
||||
drawing.draw_label(health_value_label, position_on_screen, monster.health, monster.max_health);
|
||||
drawing.draw_label(health_percentage_label, position_on_screen, 100 * monster.health_percentage);
|
||||
|
||||
drawing.draw_label(stamina_label, position_on_screen);
|
||||
drawing.draw_label(stamina_value_label, position_on_screen, monster.stamina, monster.max_stamina);
|
||||
drawing.draw_label(stamina_percentage_label, position_on_screen, 100 * monster.stamina_percentage);
|
||||
|
||||
drawing.draw_label(rage_label, position_on_screen);
|
||||
drawing.draw_label(rage_value_label, position_on_screen, monster.rage_point, monster.rage_limit);
|
||||
|
||||
if monster.is_in_rage then
|
||||
drawing.draw_label(rage_percentage_label, position_on_screen, monster.rage_minutes_left, monster.rage_seconds_left);
|
||||
else
|
||||
drawing.draw_label(rage_percentage_label, position_on_screen, 100 * monster.rage_percentage);
|
||||
end
|
||||
|
||||
i = i + 1;
|
||||
::continue::
|
||||
end
|
||||
end
|
||||
|
||||
function large_monster_UI.init_module()
|
||||
singletons = require("MHR_Overlay.Game_Handler.singletons");
|
||||
config = require("MHR_Overlay.Misc.config");
|
||||
customization_menu = require("MHR_Overlay.UI.customization_menu");
|
||||
large_monster = require("MHR_Overlay.Monsters.large_monster");
|
||||
screen = require("MHR_Overlay.Game_Handler.screen");
|
||||
player = require("MHR_Overlay.Damage_Meter.player");
|
||||
drawing = require("MHR_Overlay.UI.drawing");
|
||||
table_helpers = require("MHR_Overlay.Misc.table_helpers");
|
||||
end
|
||||
|
||||
return large_monster_UI;
|
||||
181
MHR_Overlay/UI/small_monster_UI.lua
Normal file
181
MHR_Overlay/UI/small_monster_UI.lua
Normal file
@@ -0,0 +1,181 @@
|
||||
local small_monster_UI = {};
|
||||
local singletons;
|
||||
local config;
|
||||
local small_monster;
|
||||
local customization_menu;
|
||||
local screen;
|
||||
local player;
|
||||
local drawing;
|
||||
local table_helpers;
|
||||
|
||||
function small_monster_UI.draw()
|
||||
if singletons.enemy_manager == nil then
|
||||
return;
|
||||
end
|
||||
|
||||
local displayed_monsters = {};
|
||||
|
||||
local enemy_count = singletons.enemy_manager:call("getZakoEnemyCount");
|
||||
if enemy_count == nil then
|
||||
customization_menu.status = "No enemy count";
|
||||
return;
|
||||
end
|
||||
|
||||
for i = 0, enemy_count - 1 do
|
||||
local enemy = singletons.enemy_manager:call("getZakoEnemy", i);
|
||||
if enemy == nil then
|
||||
customization_menu.status = "No enemy";
|
||||
break
|
||||
end
|
||||
|
||||
local monster = small_monster.list[enemy];
|
||||
if monster == nil then
|
||||
customization_menu.status = "No monster hp entry";
|
||||
break
|
||||
end
|
||||
|
||||
table.insert(displayed_monsters, monster);
|
||||
end
|
||||
|
||||
if not config.current_config.small_monster_UI.dynamic_positioning.enabled then
|
||||
-- sort here
|
||||
if config.current_config.small_monster_UI.sorting.type == "Normal" and config.current_config.small_monster_UI.sorting.reversed_order then
|
||||
local reversed_monsters = {};
|
||||
for i = #displayed_monsters, 1, -1 do
|
||||
table.insert(reversed_monsters, displayed_monsters[i]);
|
||||
end
|
||||
displayed_monsters = reversed_monsters;
|
||||
|
||||
elseif config.current_config.small_monster_UI.sorting.type == "Health" then
|
||||
if config.current_config.small_monster_UI.sorting.reversed_order then
|
||||
table.sort(displayed_monsters, function(left, right)
|
||||
return left.health > right.health;
|
||||
end);
|
||||
else
|
||||
table.sort(displayed_monsters, function(left, right)
|
||||
return left.health < right.health;
|
||||
end);
|
||||
end
|
||||
|
||||
elseif config.current_config.small_monster_UI.sorting.type == "Health Percentage" then
|
||||
if config.current_config.small_monster_UI.sorting.reversed_order then
|
||||
table.sort(displayed_monsters, function(left, right)
|
||||
return left.health_percentage > right.health_percentage;
|
||||
end);
|
||||
else
|
||||
table.sort(displayed_monsters, function(left, right)
|
||||
return left.health_percentage < right.health_percentage;
|
||||
end);
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
x = "";
|
||||
local i = 0;
|
||||
for _, monster in ipairs(displayed_monsters) do
|
||||
local position_on_screen;
|
||||
|
||||
if config.current_config.small_monster_UI.dynamic_positioning.enabled then
|
||||
local world_offset = Vector3f.new(config.current_config.small_monster_UI.dynamic_positioning.world_offset.x, config.current_config.small_monster_UI.dynamic_positioning.world_offset.y, config.current_config.small_monster_UI.dynamic_positioning.world_offset.z);
|
||||
|
||||
position_on_screen = draw.world_to_screen(monster.position + world_offset);
|
||||
|
||||
if position_on_screen == nil then
|
||||
goto continue
|
||||
end
|
||||
|
||||
position_on_screen.x = position_on_screen.x + config.current_config.small_monster_UI.dynamic_positioning.viewport_offset.x;
|
||||
position_on_screen.y = position_on_screen.y + config.current_config.small_monster_UI.dynamic_positioning.viewport_offset.y;
|
||||
else
|
||||
position_on_screen = screen.calculate_absolute_coordinates(config.current_config.small_monster_UI.position);
|
||||
if config.current_config.small_monster_UI.settings.orientation == "Horizontal" then
|
||||
position_on_screen.x = position_on_screen.x + config.current_config.small_monster_UI.spacing.x * i;
|
||||
|
||||
else
|
||||
position_on_screen.y = position_on_screen.y + config.current_config.small_monster_UI.spacing.y * i;
|
||||
end
|
||||
end
|
||||
|
||||
local monster_name_label = config.current_config.small_monster_UI.monster_name_label;
|
||||
|
||||
local health_bar = config.current_config.small_monster_UI.health.bar;
|
||||
local health_label = config.current_config.small_monster_UI.health.text_label;
|
||||
local health_value_label = config.current_config.small_monster_UI.health.value_label;
|
||||
local health_percentage_label = config.current_config.small_monster_UI.health.percentage_label;
|
||||
|
||||
local stamina_bar = config.current_config.small_monster_UI.stamina.bar;
|
||||
local stamina_label = config.current_config.small_monster_UI.stamina.text_label;
|
||||
local stamina_value_label = config.current_config.small_monster_UI.stamina.value_label;
|
||||
local stamina_percentage_label = config.current_config.small_monster_UI.stamina.percentage_label;
|
||||
|
||||
if config.current_config.small_monster_UI.dynamic_positioning.enabled then
|
||||
if config.current_config.small_monster_UI.dynamic_positioning.max_distance == 0 then
|
||||
return;
|
||||
end
|
||||
|
||||
local distance = (player.myself_position - monster.position):length();
|
||||
|
||||
if distance > config.current_config.small_monster_UI.dynamic_positioning.max_distance then
|
||||
goto continue;
|
||||
end
|
||||
|
||||
if config.current_config.small_monster_UI.dynamic_positioning.opacity_falloff then
|
||||
local opacity_falloff = 1 - (distance / config.current_config.small_monster_UI.dynamic_positioning.max_distance);
|
||||
|
||||
monster_name_label = table_helpers.deep_copy(config.current_config.small_monster_UI.monster_name_label);
|
||||
|
||||
health_bar = table_helpers.deep_copy(config.current_config.small_monster_UI.health.bar);
|
||||
health_label = table_helpers.deep_copy(config.current_config.small_monster_UI.health.text_label);
|
||||
health_value_label = table_helpers.deep_copy(config.current_config.small_monster_UI.health.value_label);
|
||||
health_percentage_label = table_helpers.deep_copy(config.current_config.small_monster_UI.health.percentage_label);
|
||||
|
||||
stamina_bar = table_helpers.deep_copy(config.current_config.small_monster_UI.stamina.bar);
|
||||
stamina_label = table_helpers.deep_copy(config.current_config.small_monster_UI.stamina.text_label);
|
||||
stamina_value_label = table_helpers.deep_copy(config.current_config.small_monster_UI.stamina.value_label);
|
||||
stamina_percentage_label = table_helpers.deep_copy(config.current_config.small_monster_UI.stamina.percentage_label);
|
||||
|
||||
drawing.scale_bar_opacity(health_bar, opacity_falloff);
|
||||
drawing.scale_bar_opacity(stamina_bar, opacity_falloff)
|
||||
|
||||
drawing.scale_label_opacity(monster_name_label, opacity_falloff);
|
||||
|
||||
drawing.scale_label_opacity(health_label, opacity_falloff);
|
||||
drawing.scale_label_opacity(health_value_label, opacity_falloff);
|
||||
drawing.scale_label_opacity(health_percentage_label, opacity_falloff);
|
||||
|
||||
drawing.scale_label_opacity(stamina_label, opacity_falloff);
|
||||
drawing.scale_label_opacity(stamina_value_label, opacity_falloff);
|
||||
drawing.scale_label_opacity(stamina_percentage_label, opacity_falloff);
|
||||
end
|
||||
end
|
||||
|
||||
drawing.draw_bar(health_bar, position_on_screen, monster.health_percentage);
|
||||
drawing.draw_bar(stamina_bar, position_on_screen, monster.stamina_percentage);
|
||||
|
||||
drawing.draw_label(monster_name_label, position_on_screen, monster.name);
|
||||
|
||||
drawing.draw_label(health_label, position_on_screen);
|
||||
drawing.draw_label(health_value_label, position_on_screen, monster.health, monster.max_health);
|
||||
drawing.draw_label(health_percentage_label, position_on_screen, 100 * monster.health_percentage);
|
||||
|
||||
drawing.draw_label(stamina_label, position_on_screen);
|
||||
drawing.draw_label(stamina_value_label, position_on_screen, monster.stamina, monster.max_stamina);
|
||||
drawing.draw_label(stamina_percentage_label, position_on_screen, 100 * monster.stamina_percentage);
|
||||
|
||||
i = i + 1;
|
||||
::continue::
|
||||
end
|
||||
end
|
||||
|
||||
function small_monster_UI.init_module()
|
||||
singletons = require("MHR_Overlay.Game_Handler.singletons");
|
||||
config = require("MHR_Overlay.Misc.config");
|
||||
customization_menu = require("MHR_Overlay.UI.customization_menu");
|
||||
small_monster = require("MHR_Overlay.Monsters.small_monster");
|
||||
screen = require("MHR_Overlay.Game_Handler.screen");
|
||||
player = require("MHR_Overlay.Damage_Meter.player");
|
||||
drawing = require("MHR_Overlay.UI.drawing");
|
||||
table_helpers = require("MHR_Overlay.Misc.table_helpers");
|
||||
end
|
||||
|
||||
return small_monster_UI;
|
||||
46
MHR_Overlay/UI/time_UI.lua
Normal file
46
MHR_Overlay/UI/time_UI.lua
Normal file
@@ -0,0 +1,46 @@
|
||||
local time_UI = {};
|
||||
local singletons;
|
||||
local customization_menu;
|
||||
local screen;
|
||||
local config;
|
||||
local drawing;
|
||||
|
||||
function time_UI.draw()
|
||||
if singletons.quest_manager == nil then
|
||||
return;
|
||||
end
|
||||
|
||||
|
||||
|
||||
local quest_time_elapsed_minutes = singletons.quest_manager:call("getQuestElapsedTimeMin");
|
||||
if quest_time_elapsed_minutes == nil then
|
||||
customization_menu.status = "No quest time elapsed minutes";
|
||||
return;
|
||||
end
|
||||
|
||||
local quest_time_total_elapsed_seconds = singletons.quest_manager:call("getQuestElapsedTimeSec");
|
||||
if quest_time_total_elapsed_seconds == nil then
|
||||
customization_menu.status = "No quest time total elapsed seconds";
|
||||
return;
|
||||
end
|
||||
|
||||
if quest_time_total_elapsed_seconds == 0 then
|
||||
return;
|
||||
end
|
||||
|
||||
local quest_time_elapsed_seconds = quest_time_total_elapsed_seconds - quest_time_elapsed_minutes * 60;
|
||||
|
||||
local position_on_screen = screen.calculate_absolute_coordinates(config.current_config.time_UI.position);
|
||||
|
||||
drawing.draw_label(config.current_config.time_UI.time_label, position_on_screen, quest_time_elapsed_minutes, quest_time_elapsed_seconds);
|
||||
end
|
||||
|
||||
function time_UI.init_module()
|
||||
singletons = require("MHR_Overlay.Game_Handler.singletons");
|
||||
customization_menu = require("MHR_Overlay.UI.customization_menu");
|
||||
screen = require("MHR_Overlay.Game_Handler.screen");
|
||||
config = require("MHR_Overlay.Misc.config");
|
||||
drawing = require("MHR_Overlay.UI.drawing");
|
||||
end
|
||||
|
||||
return time_UI;
|
||||
Reference in New Issue
Block a user