mirror of
https://github.com/GreenComfyTea/MHR-Overlay.git
synced 2026-01-25 12:58:06 -08:00
Add use_d2d_if_available option
This commit is contained in:
@@ -184,17 +184,7 @@ local function main_loop()
|
||||
|
||||
player.update_player_list(quest_status.index >= 2);
|
||||
|
||||
if quest_status.flow_state == quest_status.flow_states.IN_LOBBY then
|
||||
|
||||
if config.current_config.endemic_life_UI.enabled and
|
||||
config.current_config.global_settings.module_visibility.in_lobby.endemic_life_UI then
|
||||
local success = pcall(env_creature_UI.draw);
|
||||
if not success then
|
||||
customization_menu.status = "[In Lobby] Endemic life drawing function threw an exception";
|
||||
end
|
||||
end
|
||||
|
||||
elseif quest_status.flow_state == quest_status.flow_states.IN_TRAINING_AREA then
|
||||
if quest_status.flow_state == quest_status.flow_states.IN_TRAINING_AREA then
|
||||
|
||||
local large_monster_UI_config = config.current_config.large_monster_UI;
|
||||
local module_visibility_config = config.current_config.global_settings.module_visibility.in_training_area;
|
||||
@@ -277,10 +267,18 @@ end);
|
||||
if d2d ~= nil then
|
||||
d2d.register(function()
|
||||
drawing.init_font();
|
||||
end, main_loop);
|
||||
else
|
||||
re.on_frame(main_loop);
|
||||
end, function()
|
||||
if config.current_config.global_settings.renderer.use_d2d_if_available then
|
||||
main_loop();
|
||||
end
|
||||
end);
|
||||
end
|
||||
|
||||
re.on_frame(function()
|
||||
if not config.current_config.global_settings.renderer.use_d2d_if_available then
|
||||
main_loop();
|
||||
end
|
||||
end);
|
||||
-- #endregion
|
||||
----------------------------D2D------------------------------
|
||||
|
||||
@@ -288,48 +286,27 @@ if debug.enabled then
|
||||
if d2d ~= nil then
|
||||
d2d.register(function()
|
||||
end, function()
|
||||
local is_ready_quest = singletons.quest_manager:call("isReadyQuest");
|
||||
local is_ready_play_quest = singletons.quest_manager:call("isReadyPlayQuest");
|
||||
local is_play_quest = singletons.quest_manager:call("isPlayQuest");
|
||||
local is_stay_quest = singletons.quest_manager:call("isStayQuest");
|
||||
local is_end_wait = singletons.quest_manager:call("isEndWait");
|
||||
local is_active_quest = singletons.quest_manager:call("isActiveQuest");
|
||||
local quest_clear = singletons.quest_manager:call("checkQuestClear");
|
||||
local is_result_demo_play_start = singletons.quest_manager:call("isResultDemoPlayStart");
|
||||
local isResultGuestDrawOff = singletons.quest_manager:call("isResultGuestDrawOff");
|
||||
|
||||
local game_manager = sdk.get_managed_singleton("snow.SnowGameManager");
|
||||
local current_status = game_manager:get_field("_CurrentStatus");
|
||||
|
||||
local demo_camera = sdk.get_managed_singleton("snow.camera.DemoCamera");
|
||||
local is_play_demo = demo_camera:call("IsPlayDemo");
|
||||
|
||||
--[[xy = "\nquest_status.index: " .. tostring(quest_status.index);
|
||||
xy = xy .. "\nis_ready_quest: " .. tostring(is_ready_quest);
|
||||
xy = xy .. "\nis_ready_play_quest: " .. tostring(is_ready_play_quest);
|
||||
xy = xy .. "\nis_play_quest: " .. tostring(is_play_quest);
|
||||
xy = xy .. "\nis_stay_quest: " .. tostring(is_stay_quest);
|
||||
xy = xy .. "\nis_end_wait: " .. tostring(is_end_wait);
|
||||
xy = xy .. "\nis_active_quest: " .. tostring(is_active_quest);
|
||||
xy = xy .. "\nquest_clear: " .. tostring(quest_clear);
|
||||
xy = xy .. "\nis_result_demo_play_start: " .. tostring(is_result_demo_play_start);
|
||||
xy = xy .. "\nisResultGuestDrawOff: " .. tostring(isResultGuestDrawOff);
|
||||
xy = xy .. "\ncurrent_status: " .. tostring(current_status);
|
||||
xy = xy .. "\nis_play_demo: " .. tostring(is_play_demo);--]]
|
||||
if not config.current_config.global_settings.renderer.use_d2d_if_available then
|
||||
return;
|
||||
end
|
||||
|
||||
if xy ~= "" then
|
||||
d2d.text(drawing.font, "xy:\n" .. tostring(xy), 551, 11, 0xFF000000);
|
||||
d2d.text(drawing.font, "xy:\n" .. tostring(xy), 550, 10, 0xFFFFFFFF);
|
||||
end
|
||||
end);
|
||||
else
|
||||
re.on_frame(function()
|
||||
if xy ~= "" then
|
||||
draw.text("xy:\n" .. tostring(xy), 550, 10, 0xFFFFFFFF);
|
||||
draw.text("xy:\n" .. tostring(xy), 551, 11, 0xFF000000);
|
||||
end
|
||||
end);
|
||||
end
|
||||
|
||||
re.on_frame(function()
|
||||
if config.current_config.global_settings.renderer.use_d2d_if_available and d2d ~= nil then
|
||||
return;
|
||||
end
|
||||
|
||||
if xy ~= "" then
|
||||
draw.text("xy:\n" .. tostring(xy), 551, 11, 0xFF000000);
|
||||
draw.text("xy:\n" .. tostring(xy), 550, 10, 0xFFFFFFFF);
|
||||
end
|
||||
end);
|
||||
end
|
||||
|
||||
if imgui.begin_table == nil then
|
||||
|
||||
@@ -98,7 +98,7 @@ function env_creature.update(REcreature, creature)
|
||||
end
|
||||
|
||||
function env_creature.draw(creature, position_on_screen, opacity_scale)
|
||||
if d2d ~= nil then
|
||||
if d2d ~= nil and config.current_config.global_settings.renderer.use_d2d_if_available then
|
||||
local text_width, text_height = drawing.font:measure(creature.name);
|
||||
position_on_screen.x = position_on_screen.x - text_width / 2;
|
||||
end
|
||||
|
||||
@@ -10,7 +10,7 @@ function screen.update_window_size()
|
||||
local width;
|
||||
local height;
|
||||
|
||||
if d2d ~= nil then
|
||||
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();
|
||||
|
||||
@@ -33,11 +33,11 @@ function config.init()
|
||||
prioritize_large_monsters = false
|
||||
},
|
||||
|
||||
module_visibility = {
|
||||
in_lobby = {
|
||||
endemic_life_UI = false
|
||||
},
|
||||
renderer = {
|
||||
use_d2d_if_available = true
|
||||
},
|
||||
|
||||
module_visibility = {
|
||||
in_training_area = {
|
||||
large_monster_dynamic_UI = true,
|
||||
large_monster_static_UI = true,
|
||||
|
||||
@@ -172,6 +172,9 @@ language.default_language = {
|
||||
bold = "Bold",
|
||||
italic = "Italic",
|
||||
|
||||
renderer = "Renderer",
|
||||
use_d2d_if_available = "Use Direct2D if available",
|
||||
|
||||
enabled = "Enabled",
|
||||
settings = "Settings",
|
||||
dynamic_positioning = "Dynamic Positioning",
|
||||
@@ -422,7 +425,7 @@ language.default_language = {
|
||||
lowest_health_percentage = "Lowest Health Percentage",
|
||||
highest_health_percentage = "Highest Health Percentage",
|
||||
|
||||
reframework_outdated = "Installed REFramework version is outdated. Please, update. Otherwise, MHR Overlay won't work correctly."
|
||||
reframework_outdated = "Installed REFramework version is outdated. Please, update. Otherwise, MHR Overlay won't work correctly.",
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -760,16 +760,17 @@ function customization_menu.draw_global_settings()
|
||||
imgui.tree_pop();
|
||||
end
|
||||
|
||||
if imgui.tree_node(language.current_language.customization_menu.renderer) then
|
||||
changed, cached_config.renderer.use_d2d_if_available =
|
||||
imgui.checkbox(language.current_language.customization_menu.use_d2d_if_available,
|
||||
cached_config.renderer.use_d2d_if_available);
|
||||
|
||||
config_changed = config_changed or changed;
|
||||
|
||||
imgui.tree_pop();
|
||||
end
|
||||
|
||||
if imgui.tree_node(language.current_language.customization_menu.module_visibility_based_on_game_state) then
|
||||
if imgui.tree_node(language.current_language.customization_menu.in_lobby) then
|
||||
|
||||
changed, cached_config.module_visibility.in_lobby.endemic_life_UI = imgui.checkbox(
|
||||
language.current_language.customization_menu.endemic_life_UI,
|
||||
cached_config.module_visibility.in_lobby.endemic_life_UI);
|
||||
|
||||
config_changed = config_changed or changed;
|
||||
imgui.tree_pop();
|
||||
end
|
||||
|
||||
if imgui.tree_node(language.current_language.customization_menu.in_training_area) then
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ function drawing.argb_to_color(alpha, red, green, blue)
|
||||
end
|
||||
|
||||
function drawing.limit_text_size(text, size_limit)
|
||||
if d2d == nil or size_limit <= 0 then
|
||||
if d2d == nil or not config.current_config.global_settings.renderer.use_d2d_if_available or size_limit <= 0 then
|
||||
return text;
|
||||
end
|
||||
|
||||
@@ -98,6 +98,8 @@ function drawing.draw_label(label, position, opacity_scale, ...)
|
||||
local position_x = position.x + label.offset.x;
|
||||
local position_y = position.y + label.offset.y;
|
||||
|
||||
local use_d2d = d2d ~= nil and config.current_config.global_settings.renderer.use_d2d_if_available;
|
||||
|
||||
if label.shadow.visibility then
|
||||
local new_shadow_color = label.shadow.color;
|
||||
|
||||
@@ -105,7 +107,7 @@ function drawing.draw_label(label, position, opacity_scale, ...)
|
||||
new_shadow_color = drawing.scale_color_opacity(new_shadow_color, opacity_scale);
|
||||
end
|
||||
|
||||
if d2d ~= nil then
|
||||
if use_d2d then
|
||||
d2d.text(drawing.font, text, position_x + label.shadow.offset.x, position_y + label.shadow.offset.y, new_shadow_color);
|
||||
else
|
||||
new_shadow_color = drawing.argb_color_to_abgr_color(new_shadow_color);
|
||||
@@ -118,7 +120,7 @@ function drawing.draw_label(label, position, opacity_scale, ...)
|
||||
new_color = drawing.scale_color_opacity(new_color, opacity_scale);
|
||||
end
|
||||
|
||||
if d2d ~= nil then
|
||||
if use_d2d then
|
||||
d2d.text(drawing.font, text, position_x, position_y, new_color);
|
||||
else
|
||||
new_color = drawing.argb_color_to_abgr_color(new_color);
|
||||
@@ -230,7 +232,7 @@ function drawing.draw_bar(bar, position, opacity_scale, percentage)
|
||||
outline_color = drawing.scale_color_opacity(outline_color, opacity_scale);
|
||||
end
|
||||
|
||||
local use_d2d = d2d ~= nil;
|
||||
local use_d2d = d2d ~= nil and config.current_config.global_settings.renderer.use_d2d_if_available;
|
||||
|
||||
-- outline
|
||||
if outline_thickness ~= 0 then
|
||||
@@ -281,7 +283,9 @@ function drawing.draw_capture_line(health_UI, position, opacity_scale, percentag
|
||||
color = drawing.scale_color_opacity(color, opacity_scale);
|
||||
end
|
||||
|
||||
if d2d ~= nil then
|
||||
local use_d2d = d2d ~= nil and config.current_config.global_settings.renderer.use_d2d_if_available;
|
||||
|
||||
if use_d2d then
|
||||
d2d.fill_rect(position_x, position_y, health_UI.bar.capture_line.size.width, health_UI.bar.capture_line.size.height,
|
||||
color);
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user