mirror of
https://github.com/GreenComfyTea/MHR-Overlay.git
synced 2026-01-24 04:18:11 -08:00
Add Customization Menu status, position and size to config
+ Customization Menu bugfixes
This commit is contained in:
@@ -361,16 +361,14 @@ end
|
|||||||
-- #region
|
-- #region
|
||||||
re.on_draw_ui(function()
|
re.on_draw_ui(function()
|
||||||
if imgui.button(language.current_language.customization_menu.mod_name .. " v" .. config.current_config.version) then
|
if imgui.button(language.current_language.customization_menu.mod_name .. " v" .. config.current_config.version) then
|
||||||
customization_menu.is_opened = not customization_menu.is_opened;
|
local cached_config = config.current_config.customization_menu;
|
||||||
|
cached_config.visible = not cached_config.visible;
|
||||||
|
config.save_current();
|
||||||
end
|
end
|
||||||
end);
|
end);
|
||||||
|
|
||||||
re.on_frame(function()
|
re.on_frame(function()
|
||||||
if not reframework:is_drawing_ui() then
|
if reframework:is_drawing_ui() then
|
||||||
customization_menu.is_opened = false;
|
|
||||||
end
|
|
||||||
|
|
||||||
if customization_menu.is_opened then
|
|
||||||
pcall(customization_menu.draw);
|
pcall(customization_menu.draw);
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -476,6 +476,11 @@ function this.init_default()
|
|||||||
x = 10,
|
x = 10,
|
||||||
y = 40
|
y = 40
|
||||||
},
|
},
|
||||||
|
|
||||||
|
relative_offset = {
|
||||||
|
x = 0,
|
||||||
|
y = 45
|
||||||
|
},
|
||||||
|
|
||||||
spacing = {
|
spacing = {
|
||||||
x = 0,
|
x = 0,
|
||||||
@@ -7569,6 +7574,25 @@ function this.init_default()
|
|||||||
|
|
||||||
debug = {
|
debug = {
|
||||||
history_size = 64
|
history_size = 64
|
||||||
|
},
|
||||||
|
|
||||||
|
customization_menu = {
|
||||||
|
visible = false,
|
||||||
|
|
||||||
|
position = {
|
||||||
|
x = 360,
|
||||||
|
y = 50
|
||||||
|
},
|
||||||
|
|
||||||
|
size = {
|
||||||
|
width = 785,
|
||||||
|
height = 610
|
||||||
|
},
|
||||||
|
|
||||||
|
pivot = {
|
||||||
|
x = 0,
|
||||||
|
y = 0
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ local displayed_directions = {};
|
|||||||
function this.init()
|
function this.init()
|
||||||
local default = language.default_language.customization_menu;
|
local default = language.default_language.customization_menu;
|
||||||
local current = language.current_language.customization_menu;
|
local current = language.current_language.customization_menu;
|
||||||
|
|
||||||
outline_styles = {
|
outline_styles = {
|
||||||
default.inside,
|
default.inside,
|
||||||
default.center,
|
default.center,
|
||||||
@@ -150,15 +150,13 @@ function this.draw(bar_name, bar)
|
|||||||
bar.outline.offset, 0.1, -screen.height, screen.height, "%.1f");
|
bar.outline.offset, 0.1, -screen.height, screen.height, "%.1f");
|
||||||
bar_changed = bar_changed or changed;
|
bar_changed = bar_changed or changed;
|
||||||
|
|
||||||
|
|
||||||
changed, index = imgui.combo(cached_language.style,
|
changed, index = imgui.combo(cached_language.style,
|
||||||
utils.table.find_index(this.outline_styles,
|
utils.table.find_index(outline_styles, bar.outline.style),
|
||||||
bar.outline.style),
|
displayed_outline_styles);
|
||||||
this.displayed_outline_styles);
|
|
||||||
bar_changed = bar_changed or changed;
|
bar_changed = bar_changed or changed;
|
||||||
|
|
||||||
if changed then
|
if changed then
|
||||||
bar.outline.style = this.outline_styles[index];
|
bar.outline.style = outline_styles[index];
|
||||||
end
|
end
|
||||||
|
|
||||||
imgui.tree_pop();
|
imgui.tree_pop();
|
||||||
|
|||||||
@@ -65,7 +65,6 @@ local package = package;
|
|||||||
|
|
||||||
this.font = nil;
|
this.font = nil;
|
||||||
this.full_font_range = {0x1, 0xFFFF, 0};
|
this.full_font_range = {0x1, 0xFFFF, 0};
|
||||||
this.is_opened = false;
|
|
||||||
|
|
||||||
this.window_position = Vector2f.new(480, 200);
|
this.window_position = Vector2f.new(480, 200);
|
||||||
this.window_pivot = Vector2f.new(0, 0);
|
this.window_pivot = Vector2f.new(0, 0);
|
||||||
@@ -326,21 +325,33 @@ function this.init()
|
|||||||
end
|
end
|
||||||
|
|
||||||
function this.draw()
|
function this.draw()
|
||||||
imgui.set_next_window_pos(this.window_position, 1 << 3, this.window_pivot);
|
if not config.current_config.customization_menu.visible then
|
||||||
imgui.set_next_window_size(this.window_size, 1 << 3);
|
|
||||||
|
|
||||||
imgui.push_font(this.font);
|
|
||||||
|
|
||||||
this.is_opened = imgui.begin_window(
|
|
||||||
language.current_language.customization_menu.mod_name .. " v" .. config.current_config.version, this.is_opened,
|
|
||||||
this.window_flags);
|
|
||||||
|
|
||||||
if not this.is_opened then
|
|
||||||
imgui.pop_font();
|
|
||||||
imgui.end_window();
|
|
||||||
return;
|
return;
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local window_position = Vector2f.new(config.current_config.customization_menu.position.x, config.current_config.customization_menu.position.y);
|
||||||
|
local window_pivot = Vector2f.new(config.current_config.customization_menu.pivot.x, config.current_config.customization_menu.pivot.y);
|
||||||
|
local window_size = Vector2f.new(config.current_config.customization_menu.size.width, config.current_config.customization_menu.size.height);
|
||||||
|
|
||||||
|
imgui.set_next_window_pos(window_position, 1 << 3, window_pivot);
|
||||||
|
imgui.set_next_window_size(window_size, 1 << 3);
|
||||||
|
|
||||||
|
imgui.push_font(this.font);
|
||||||
|
|
||||||
|
config.current_config.customization_menu.visible = imgui.begin_window(
|
||||||
|
string.format("%s v%s", language.current_language.customization_menu.mod_name, config.current_config.version),
|
||||||
|
config.current_config.customization_menu.visible,
|
||||||
|
this.window_flags);
|
||||||
|
|
||||||
|
|
||||||
|
if not config.current_config.customization_menu.visible then
|
||||||
|
imgui.pop_font();
|
||||||
|
imgui.end_window();
|
||||||
|
config.save_current();
|
||||||
|
return;
|
||||||
|
end
|
||||||
|
|
||||||
|
local window_changed = false;
|
||||||
local config_changed = false;
|
local config_changed = false;
|
||||||
local language_changed = false;
|
local language_changed = false;
|
||||||
local modifiers_changed = false;
|
local modifiers_changed = false;
|
||||||
@@ -357,6 +368,28 @@ function this.draw()
|
|||||||
local debug_changed = false;
|
local debug_changed = false;
|
||||||
local apply_font_requested = false;
|
local apply_font_requested = false;
|
||||||
|
|
||||||
|
local new_window_position = imgui.get_window_pos();
|
||||||
|
if window_position.x ~= new_window_position.x or window_position.y ~= new_window_position.y then
|
||||||
|
window_changed = window_changed or true;
|
||||||
|
|
||||||
|
config.current_config.customization_menu.position.x = new_window_position.x;
|
||||||
|
config.current_config.customization_menu.position.y = new_window_position.y;
|
||||||
|
end
|
||||||
|
|
||||||
|
local new_window_size = imgui.get_window_size();
|
||||||
|
if window_size.x ~= new_window_size.x or window_size.y ~= new_window_size.y then
|
||||||
|
window_changed = window_changed or true;
|
||||||
|
|
||||||
|
config.current_config.customization_menu.size.width = new_window_size.x;
|
||||||
|
config.current_config.customization_menu.size.height = new_window_size.y;
|
||||||
|
end
|
||||||
|
|
||||||
|
xy = string.format("%s", utils.vec2.tostring(window_position));
|
||||||
|
|
||||||
|
local new_window_size = imgui.get_window_size();
|
||||||
|
window_changed = window_changed or new_window_size.x ~= window_size.x or new_window_size.y ~= window_size.y;
|
||||||
|
xy = xy .. string.format("\n%s", utils.vec2.tostring(window_size));
|
||||||
|
|
||||||
config_changed, apply_font_requested = this.draw_config();
|
config_changed, apply_font_requested = this.draw_config();
|
||||||
modules_changed = this.draw_modules();
|
modules_changed = this.draw_modules();
|
||||||
this.draw_hotkeys();
|
this.draw_hotkeys();
|
||||||
@@ -446,11 +479,12 @@ function this.draw()
|
|||||||
this.reload_font();
|
this.reload_font();
|
||||||
end
|
end
|
||||||
|
|
||||||
if modules_changed or global_settings_changed or small_monster_UI_changed or large_monster_dynamic_UI_changed or
|
if window_changed or modules_changed or global_settings_changed or small_monster_UI_changed or large_monster_dynamic_UI_changed or
|
||||||
large_monster_static_UI_changed or large_monster_highlighted_UI_changed or time_UI_changed or damage_meter_UI_changed or
|
large_monster_static_UI_changed or large_monster_highlighted_UI_changed or time_UI_changed or damage_meter_UI_changed or
|
||||||
endemic_life_UI_changed or buff_UI_changed or modifiers_changed or config_changed or debug_changed then
|
endemic_life_UI_changed or buff_UI_changed or modifiers_changed or config_changed or debug_changed then
|
||||||
config.save_current();
|
config.save_current();
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function this.draw_config()
|
function this.draw_config()
|
||||||
@@ -2143,7 +2177,7 @@ function this.draw_endemic_life_UI()
|
|||||||
end
|
end
|
||||||
|
|
||||||
changed = label_customization.draw(
|
changed = label_customization.draw(
|
||||||
language.current_language.customization_menu.creature_name_label, cached_config.creature_name_label.visibility);
|
language.current_language.customization_menu.creature_name_label, cached_config.creature_name_label);
|
||||||
|
|
||||||
config_changed = config_changed or changed;
|
config_changed = config_changed or changed;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user