Added New Mods; Swapped Mods and Removed Some
Removed EGUI in favor of UI Rework by Sota Added in GTR Optimized for higher res textures, over Zone Reality Remade and removed all files that conflicted from ZRR to save storage space.
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
<?xml version="1.0" encoding="windows-1251"?>
|
||||
|
||||
<string_table>
|
||||
|
||||
<string id="ui_mcm_demonized_dialog_fov_title">
|
||||
<text>Dialogs Dynamic UI</text>
|
||||
</string>
|
||||
<string id="ui_mcm_menu_demonized_dialog_fov">
|
||||
<text>Dialog UI</text>
|
||||
</string>
|
||||
|
||||
<string id="ui_mcm_demonized_dialog_fov_enabled">
|
||||
<text>Enable</text>
|
||||
</string>
|
||||
<string id="ui_mcm_demonized_dialog_fov_zoom_fov_enabled">
|
||||
<text>Enable zoom</text>
|
||||
</string>
|
||||
<string id="ui_mcm_demonized_dialog_fov_zoom_fov_modifier">
|
||||
<text>Zoom modifier</text>
|
||||
</string>
|
||||
<string id="ui_mcm_demonized_dialog_fov_min_zoom_fov">
|
||||
<text>Minimum zoom</text>
|
||||
</string>
|
||||
<string id="ui_mcm_demonized_dialog_fov_min_zoom_fov_desc">
|
||||
<text>With zoom enabled, the FOV will change to at least this value</text>
|
||||
</string>
|
||||
<string id="ui_mcm_demonized_dialog_fov_distance_fov">
|
||||
<text>Distance based zoom</text>
|
||||
</string>
|
||||
<string id="ui_mcm_demonized_dialog_fov_distance_fov_desc">
|
||||
<text>This changes the FOV so that the character is the same size no matter how far away they are from the player</text>
|
||||
</string>
|
||||
<string id="ui_mcm_demonized_dialog_fov_fov_smoothing">
|
||||
<text>Zoom smoothness</text>
|
||||
</string>
|
||||
<string id="ui_mcm_demonized_dialog_fov_track_npc">
|
||||
<text>Camera focus on NPC</text>
|
||||
</string>
|
||||
<string id="ui_mcm_demonized_dialog_fov_turn_modifier">
|
||||
<text>Camera rotation factor</text>
|
||||
</string>
|
||||
<string id="ui_mcm_demonized_dialog_fov_turn_modifier_desc">
|
||||
<text>Camera rotation factor for adjusting the position of the character, 0 means no rotation, negative values will rotate the camera in the other direction</text>
|
||||
</string>
|
||||
<string id="ui_mcm_demonized_dialog_fov_smoothing">
|
||||
<text>Smoothness of the camera focus</text>
|
||||
</string>
|
||||
|
||||
</string_table>
|
||||
@@ -0,0 +1,49 @@
|
||||
<?xml version="1.0" encoding="windows-1251"?>
|
||||
|
||||
<string_table>
|
||||
|
||||
<string id="ui_mcm_demonized_dialog_fov_title">
|
||||
<text>Äèíàìè÷åñêèé UI äèàëîãîâ</text>
|
||||
</string>
|
||||
<string id="ui_mcm_menu_demonized_dialog_fov">
|
||||
<text>UI äèàëîãîâ</text>
|
||||
</string>
|
||||
|
||||
<string id="ui_mcm_demonized_dialog_fov_enabled">
|
||||
<text>Âêëþ÷èòü</text>
|
||||
</string>
|
||||
<string id="ui_mcm_demonized_dialog_fov_zoom_fov_enabled">
|
||||
<text>Âêëþ÷èòü çóì</text>
|
||||
</string>
|
||||
<string id="ui_mcm_demonized_dialog_fov_zoom_fov_modifier">
|
||||
<text>Ìîäèôèêàòîð çóìà</text>
|
||||
</string>
|
||||
<string id="ui_mcm_demonized_dialog_fov_min_zoom_fov">
|
||||
<text>Ìèíèìàëüíûé çóì</text>
|
||||
</string>
|
||||
<string id="ui_mcm_demonized_dialog_fov_min_zoom_fov_desc">
|
||||
<text>Ïðè âêëþ÷åííîé îïöèè çóìà FOV èçìåíèòñÿ êàê ìèíèìóì äî ýòîãî çíà÷åíèÿ</text>
|
||||
</string>
|
||||
<string id="ui_mcm_demonized_dialog_fov_distance_fov">
|
||||
<text>Çóì â çàâèñèìîñòè îò äèñòàíöèè</text>
|
||||
</string>
|
||||
<string id="ui_mcm_demonized_dialog_fov_distance_fov_desc">
|
||||
<text>Ïðè äàííîé îïöèè FOV áóäåò ìåíÿòüñÿ òàêèì îáðàçîì, ÷òîáû ïåðñîíàæ áûë îäèíàêîâîãî ðàçìåðà íåçàâèñèìî îò ðàññòîÿíèÿ äî èãðîêà</text>
|
||||
</string>
|
||||
<string id="ui_mcm_demonized_dialog_fov_fov_smoothing">
|
||||
<text>Ïëàâíîñòü ñìåíû çóìà</text>
|
||||
</string>
|
||||
<string id="ui_mcm_demonized_dialog_fov_track_npc">
|
||||
<text>Ôîêóñ êàìåðû íà NPC</text>
|
||||
</string>
|
||||
<string id="ui_mcm_demonized_dialog_fov_turn_modifier">
|
||||
<text>Êîýôôèöèåíò ïîâîðîòà êàìåðû</text>
|
||||
</string>
|
||||
<string id="ui_mcm_demonized_dialog_fov_turn_modifier_desc">
|
||||
<text>Êîýôôèöèåíò ïîâîðîòà êàìåðû äëÿ íàñòðîéêè ïîëîæåíèÿ ïåðñîíàæà, 0 - îòêëþ÷åíèå ïîâîðîòà, îòðèöàòåëüíûå çíà÷åíèÿ ïîâåðíóò êàìåðó â äðóãóþ ñòîðîíó</text>
|
||||
</string>
|
||||
<string id="ui_mcm_demonized_dialog_fov_smoothing">
|
||||
<text>Ïëàâíîñòü ôîêóñà êàìåðû</text>
|
||||
</string>
|
||||
|
||||
</string_table>
|
||||
@@ -0,0 +1,88 @@
|
||||
<w>
|
||||
|
||||
<main x="0" y="0" width="1024" height="768">
|
||||
<auto_static x="400" y="4" width="634" height="760">
|
||||
<texture>ui_inGame2_dialog_main_window</texture>
|
||||
</auto_static>
|
||||
</main>
|
||||
|
||||
<!--button x="353" y="734" width="320" height="24" stretch="1" hint="ui_st_exit_hint"-->
|
||||
<button x="353" y="-666" width="320" height="24" stretch="1" hint="ui_st_exit_hint">
|
||||
<texture>ui_inGame2_big_inventory_button</texture>
|
||||
<text font="graffiti22" align="c">ui_st_trade</text>
|
||||
<text_color>
|
||||
<e color ="ui_6"/>
|
||||
<t color ="ui_black"/>
|
||||
<d color ="ui_5"/>
|
||||
<h color ="ui_black"/>
|
||||
</text_color>
|
||||
</button>
|
||||
|
||||
<answers_list x="468" y="63" width="546" height="423" always_show_scroll="1"/>
|
||||
<questions_list x="468" y="542" width="546" height="166" always_show_scroll="0"/>
|
||||
|
||||
<question_item width="527" height="20" min_height="13">
|
||||
<num_text x="0" y="3" width="10" height="20">
|
||||
<text font="letterica18" color="ui_2"/>
|
||||
</num_text>
|
||||
<content_text x="20" y="3" width="490" height="20">
|
||||
<text font="letterica18" color="ui_2" align="l" complex_mode="1"/>
|
||||
<text_color>
|
||||
<t r="231" g="168" b="12"/> <e color="ui_2"/> <h color="ui_1"/>
|
||||
</text_color>
|
||||
</content_text>
|
||||
</question_item>
|
||||
|
||||
<other_answer_item width="527" height="0" min_height="13" bottom_footer="5">
|
||||
<name_caption x="0" y="3" width="510" height="10">
|
||||
<text font="graffiti22" color="ui_7" complex_mode="0"/>
|
||||
</name_caption>
|
||||
|
||||
<content_text x="20" y="22" width="490" height="10" complex_mode="1">
|
||||
<text font="letterica18" color="ui_8"/>
|
||||
</content_text>
|
||||
</other_answer_item>
|
||||
|
||||
<actor_answer_item x="0" y="0" width="527" height="0" min_height="13" bottom_footer="10">
|
||||
<name_caption x="0" y="3" width="510" height="10">
|
||||
<text font="graffiti22" color="ui_lime" complex_mode="0"/>
|
||||
</name_caption>
|
||||
|
||||
<content_text x="20" y="22" width="490" height="10" complex_mode="1">
|
||||
<text font="letterica18" color="ui_2"/>
|
||||
</content_text>
|
||||
</actor_answer_item>
|
||||
|
||||
<iconed_answer_item x="0" y="0" width="527" height="0" min_height="30" bottom_footer="5">
|
||||
<name_caption x="0" y="0" width="0" height="0"/>
|
||||
|
||||
<content_text x="75" y="0" width="450" height="29" complex_mode="1">
|
||||
<text font="letterica18" color="ui_1"/>
|
||||
</content_text>
|
||||
<msg_icon x="20" y="3" width="49" height="29">
|
||||
</msg_icon>
|
||||
</iconed_answer_item>
|
||||
|
||||
<simple_answer_item x="0" y="0" width="527" height="0" min_height="13" bottom_footer="5">
|
||||
<name_caption x="0" y="0" width="0" height="0"/>
|
||||
|
||||
<content_text x="50" y="0" width="450" height="29" complex_mode="1">
|
||||
<text font="letterica18" color="ui_1"/>
|
||||
</content_text>
|
||||
|
||||
<msg_icon x="20" y="3" width="0" height="0">
|
||||
</msg_icon>
|
||||
</simple_answer_item>
|
||||
|
||||
<iconed_trade_info x="0" y="0" width="527" height="0" min_height="20" bottom_footer="5">
|
||||
<name_caption x="0" y="0" width="0" height="0"/>
|
||||
|
||||
<content_text x="65" y="2" width="460" height="20" complex_mode="1">
|
||||
<text font="letterica18" color="ui_8"/>
|
||||
</content_text>
|
||||
|
||||
<msg_icon x="20" y="0" width="34" height="20">
|
||||
</msg_icon>
|
||||
</iconed_trade_info>
|
||||
|
||||
</w>
|
||||
@@ -0,0 +1,88 @@
|
||||
<w>
|
||||
<main x="0" y="0" width="1024" height="768">
|
||||
<auto_static x="527" y="4" width="507" height="760" stretch="1">
|
||||
<texture>ui_inGame2_dialog_main_window</texture>
|
||||
</auto_static>
|
||||
</main>
|
||||
|
||||
<!--button x="384" y="734" width="256" height="24" stretch="1" hint="ui_st_exit_hint"-->
|
||||
<button x="384" y="-666" width="256" height="24" stretch="1" hint="ui_st_exit_hint">
|
||||
<texture>ui_inGame2_big_inventory_button</texture>
|
||||
<text font="graffiti22" align="c">ui_st_trade</text>
|
||||
<text_color>
|
||||
<e color ="ui_6"/>
|
||||
<t color ="ui_black"/>
|
||||
<d color ="ui_5"/>
|
||||
<h color ="ui_black"/>
|
||||
</text_color>
|
||||
</button>
|
||||
|
||||
<answers_list x="572" y="63" width="437" height="423" always_show_scroll="1"/>
|
||||
<questions_list x="572" y="542" width="437" height="166" always_show_scroll="0"/>
|
||||
|
||||
<question_item x="0" y="0" width="439" height="20" min_height="13">
|
||||
|
||||
<num_text x="0" y="3" width="8" height="20">
|
||||
<text font="letterica18" color="ui_2"/>
|
||||
</num_text>
|
||||
|
||||
<content_text x="15" y="2" width="410" height="20">
|
||||
<text font="letterica18" color="ui_2" align="l" complex_mode="1"/>
|
||||
<text_color>
|
||||
<t r="231" g="168" b="12"/>
|
||||
<e color="ui_2"/>
|
||||
<h color="ui_1"/>
|
||||
</text_color>
|
||||
</content_text>
|
||||
</question_item>
|
||||
|
||||
<other_answer_item x="0" y="0" width="439" height="0" min_height="13" bottom_footer="5">
|
||||
<name_caption x="0" y="2" width="425" height="10">
|
||||
<text font="graffiti22" color="ui_7" complex_mode="0"/>
|
||||
</name_caption>
|
||||
|
||||
<content_text x="17" y="22" width="408" height="10" complex_mode="1">
|
||||
<text font="letterica18" color="ui_8"/>
|
||||
</content_text>
|
||||
</other_answer_item>
|
||||
|
||||
<actor_answer_item x="0" y="0" width="439" height="0" min_height="13" bottom_footer="10">
|
||||
<name_caption x="0" y="2" width="425" height="10">
|
||||
<text font="graffiti22" color="ui_lime" complex_mode="0"/>
|
||||
</name_caption>
|
||||
|
||||
<content_text x="17" y="22" width="408" height="10" complex_mode="1">
|
||||
<text font="letterica18" color="ui_2"/>
|
||||
</content_text>
|
||||
</actor_answer_item>
|
||||
|
||||
<iconed_answer_item x="0" y="0" width="439" height="0" min_height="30" bottom_footer="5">
|
||||
<name_caption x="0" y="0" width="0" height="0"/>
|
||||
|
||||
<content_text x="63" y="0" width="375" height="29" complex_mode="1">
|
||||
<text font="letterica18" color="ui_1"/>
|
||||
</content_text>
|
||||
|
||||
<msg_icon x="17" y="3" width="41" height="29" stretch="1"/>
|
||||
</iconed_answer_item>
|
||||
|
||||
<simple_answer_item x="0" y="0" width="527" height="0" min_height="13" bottom_footer="5">
|
||||
<name_caption x="0" y="0" width="0" height="0"/>
|
||||
|
||||
<content_text x="50" y="0" width="450" height="29" complex_mode="1">
|
||||
<text font="letterica18" color="ui_1"/>
|
||||
</content_text>
|
||||
|
||||
<msg_icon x="20" y="3" width="0" height="0">
|
||||
</msg_icon>
|
||||
</simple_answer_item>
|
||||
<iconed_trade_info x="0" y="0" width="439" height="0" min_height="20" bottom_footer="5">
|
||||
<name_caption x="0" y="0" width="0" height="0"/>
|
||||
|
||||
<content_text x="54" y="2" width="383" height="20" complex_mode="1">
|
||||
<text font="letterica18" color="ui_8"/>
|
||||
</content_text>
|
||||
|
||||
<msg_icon x="17" y="0" width="28" height="20" stretch="1"/>
|
||||
</iconed_trade_info>
|
||||
</w>
|
||||
@@ -0,0 +1,382 @@
|
||||
-- UTILS
|
||||
-- Similar floats
|
||||
local function similar(f1, f2, e)
|
||||
return math.abs(f1 - f2) <= (e or 0.001)
|
||||
end
|
||||
|
||||
-- Truncate to a decimal
|
||||
local function trunc(float, decimal)
|
||||
local d = 10 ^ (decimal or 1)
|
||||
return math.floor(float * d) / d
|
||||
end
|
||||
|
||||
-- Linear inter/extrapolation
|
||||
local function lerp(a, b, f)
|
||||
if a and b and f then
|
||||
return a + f * (b - a)
|
||||
else
|
||||
return a or b or 0
|
||||
end
|
||||
end
|
||||
|
||||
-- Time delta
|
||||
local function time_delta()
|
||||
return math.min(50, device().time_delta)
|
||||
end
|
||||
|
||||
-- LUT Lookup
|
||||
local function array_keys(t, sorted, sort_func)
|
||||
local res = {}
|
||||
local res_count = 1
|
||||
for k, v in pairs(t) do
|
||||
res[res_count] = k
|
||||
res_count = res_count + 1
|
||||
end
|
||||
if sorted then
|
||||
if sort_func then
|
||||
table.sort(res, sort_func)
|
||||
else
|
||||
table.sort(res)
|
||||
end
|
||||
end
|
||||
return res
|
||||
end
|
||||
|
||||
local function bisect_left(a, x, lo, hi)
|
||||
local lo = lo or 1
|
||||
local hi = hi or #a
|
||||
|
||||
if lo < 0 then
|
||||
printf('bisect, lo must be non-negative')
|
||||
return
|
||||
end
|
||||
|
||||
while lo < hi do
|
||||
local mid = math.floor((lo + hi) * 0.5)
|
||||
if a[mid] < x then
|
||||
lo = mid+1
|
||||
else
|
||||
hi = mid
|
||||
end
|
||||
end
|
||||
|
||||
return lo
|
||||
end
|
||||
|
||||
local function lookup(t, key, tkeys)
|
||||
if is_empty(t) then return 0 end
|
||||
|
||||
if t[key] then return t[key] end
|
||||
|
||||
if not tkeys then
|
||||
tkeys = array_keys(t, true)
|
||||
end
|
||||
|
||||
local tkeys_len = #tkeys
|
||||
if key <= tkeys[1] then
|
||||
if key == tkeys[1] then
|
||||
return t[tkeys[1]]
|
||||
elseif not tkeys[2] then
|
||||
return t[tkeys[1]]
|
||||
else
|
||||
local hi = tkeys[2]
|
||||
local lo = tkeys[1]
|
||||
local k = (key - lo) / (hi - lo)
|
||||
return lerp(t[lo], t[hi], k)
|
||||
end
|
||||
end
|
||||
if key >= tkeys[tkeys_len] then
|
||||
if key == tkeys[tkeys_len] then
|
||||
return t[tkeys[tkeys_len]]
|
||||
elseif not tkeys[tkeys_len - 1] then
|
||||
return t[tkeys[tkeys_len]]
|
||||
else
|
||||
local hi = tkeys[tkeys_len]
|
||||
local lo = tkeys[tkeys_len - 1]
|
||||
local k = (key - lo) / (hi - lo)
|
||||
return lerp(t[lo], t[hi], k)
|
||||
end
|
||||
end
|
||||
|
||||
local where = bisect_left(tkeys, key)
|
||||
local lo = tkeys[where-1] or tkeys[where]
|
||||
local hi = tkeys[where]
|
||||
if lo == hi then return t[lo] end
|
||||
|
||||
local delta = (key - lo) / (hi - lo)
|
||||
local res = delta * t[hi] + (1 - delta) * t[lo]
|
||||
|
||||
--printf(res)
|
||||
return res
|
||||
end
|
||||
|
||||
-- EMA smoothing for changing values, frame independent
|
||||
local default_smoothing = 11.5
|
||||
local smoothed_values = {}
|
||||
|
||||
local function ema(key, value, def, steps, delta)
|
||||
local steps = steps or default_smoothing
|
||||
local delta = delta or steps
|
||||
local smoothing_alpha = 2.0 / (steps + 1)
|
||||
|
||||
smoothed_values[key] = smoothed_values[key] and smoothed_values[key] + math.min(smoothing_alpha * (delta / steps), 1) * (value - smoothed_values[key]) or def or value
|
||||
|
||||
--printf("EMA fired, key %s, target %s, current %s, going %s", key, value, smoothed_values[key], (value > smoothed_values[key] and "up" or "down"))
|
||||
return smoothed_values[key]
|
||||
end
|
||||
|
||||
special_characters = {
|
||||
["m_trader"] = "esc_2_12_stalker_trader",
|
||||
["m_lesnik"] = "red_forester_tech",
|
||||
["zat_a2_stalker_nimble"] = "esc_2_12_stalker_nimble",
|
||||
}
|
||||
|
||||
-- LUT for rotating camera to the angle depending on aspect ratio of display (device().width / device().height)
|
||||
local ratio_to_rotate = {
|
||||
[1.333] = -11,
|
||||
[1.600] = -13.5,
|
||||
[1.777] = -15.5,
|
||||
[2.370] = -21.5,
|
||||
[3.555] = -31,
|
||||
}
|
||||
local ratio_to_rotate_keys = array_keys(ratio_to_rotate, true)
|
||||
|
||||
-- Vars
|
||||
local saved_fov
|
||||
local zoom_fov_from
|
||||
local zoom_fov_to
|
||||
local zoom_fov_active = false
|
||||
local zoom_fov_active_always = false
|
||||
local saved_hud_fov
|
||||
local zoom_hud_fov_from
|
||||
local zoom_hud_fov_to
|
||||
|
||||
local saved_npc
|
||||
local saved_dist
|
||||
local saved_rotate
|
||||
|
||||
-- Get NPC actor talks to
|
||||
function valid_npc(npc)
|
||||
return npc and (special_characters[npc:section()] or IsStalker(npc) and npc:alive() and npc:is_talking() and npc:id() ~= AC_ID)
|
||||
end
|
||||
|
||||
function GetTalkingNpc()
|
||||
local npc = get_speaker()
|
||||
if valid_npc(npc) then
|
||||
return npc
|
||||
end
|
||||
|
||||
-- for i=1, #db.OnlineStalkers do
|
||||
-- local st = db.storage[db.OnlineStalkers[i]]
|
||||
-- local npc = st and st.object or level.object_by_id(db.OnlineStalkers[i])
|
||||
-- if valid_npc(npc) then
|
||||
-- return npc
|
||||
-- end
|
||||
-- end
|
||||
end
|
||||
|
||||
-- Move camera so the npc is in the left
|
||||
function move_camera()
|
||||
if not saved_npc then
|
||||
return stop_move_camera()
|
||||
end
|
||||
|
||||
-- Get look position and direction
|
||||
local look_pos = utils_obj.safe_bone_pos(saved_npc, "bip01_head")
|
||||
local look_dir = look_pos:sub(device().cam_pos):normalize()
|
||||
|
||||
-- Turn look direction depending on aspect ratio of display
|
||||
local rotate_deg
|
||||
if saved_rotate then
|
||||
rotate_deg = saved_rotate
|
||||
else
|
||||
local ratio = trunc(device().width / device().height, 3)
|
||||
rotate_deg = lookup(ratio_to_rotate, ratio, ratio_to_rotate_keys)
|
||||
saved_rotate = rotate_deg
|
||||
end
|
||||
if saved_dist and settings.zoom_fov_enabled and settings.distance_fov then
|
||||
rotate_deg = rotate_deg / saved_dist
|
||||
end
|
||||
rotate_deg = rotate_deg * settings.turn_modifier
|
||||
local new_look_dir = vector_rotate_y(look_dir, rotate_deg)
|
||||
|
||||
-- Smooth the turning for better effect
|
||||
local steps = settings.smoothing
|
||||
local delta = time_delta()
|
||||
local smoothed_look_dir = vector():set(
|
||||
ema("look_dir_x", new_look_dir.x, look_dir.x, steps, delta),
|
||||
ema("look_dir_y", new_look_dir.y, look_dir.y, steps, delta),
|
||||
ema("look_dir_z", new_look_dir.z, look_dir.z, steps, delta)
|
||||
)
|
||||
|
||||
-- Apply the turning
|
||||
local new_look_pos = vector():mad(device().cam_pos, smoothed_look_dir, 10)
|
||||
db.actor:actor_look_at_point(new_look_pos)
|
||||
end
|
||||
|
||||
function start_move_camera()
|
||||
RegisterScriptCallback("actor_on_update", move_camera)
|
||||
end
|
||||
|
||||
function stop_move_camera()
|
||||
UnregisterScriptCallback("actor_on_update", move_camera)
|
||||
if db.actor then
|
||||
if db.actor.actor_stop_look_at_point then
|
||||
db.actor:actor_stop_look_at_point()
|
||||
end
|
||||
end
|
||||
smoothed_values.look_dir_x = nil
|
||||
smoothed_values.look_dir_y = nil
|
||||
smoothed_values.look_dir_z = nil
|
||||
saved_rotate = nil
|
||||
saved_npc = nil
|
||||
saved_dist = nil
|
||||
end
|
||||
|
||||
function GUI_on_show(name)
|
||||
if name == "Dialog" then
|
||||
saved_npc = GetTalkingNpc()
|
||||
saved_dist = saved_npc and math.max(1, device().cam_pos:distance_to(utils_obj.safe_bone_pos(saved_npc, "bip01_head")) - 0.2)
|
||||
if settings.zoom_fov_enabled then
|
||||
saved_fov = zoom_fov_active and saved_fov or get_console_cmd(2, "fov")
|
||||
local new_fov = math.min(settings.min_zoom_fov, saved_fov / settings.zoom_fov_modifier)
|
||||
if saved_dist and settings.distance_fov then
|
||||
new_fov = math.atan(math.tan(new_fov * (0.5 * math.pi / 180)) / saved_dist) / (0.5 * math.pi / 180)
|
||||
end
|
||||
saved_hud_fov = zoom_fov_active and saved_hud_fov or get_console_cmd(2, "hud_fov")
|
||||
local new_hud_fov = saved_hud_fov / (saved_fov / new_fov)
|
||||
start_fov(saved_fov, new_fov, saved_hud_fov, new_hud_fov, true)
|
||||
end
|
||||
if settings.track_npc then
|
||||
start_move_camera()
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function GUI_on_hide(name)
|
||||
if name == "Dialog" then
|
||||
reset(true)
|
||||
end
|
||||
end
|
||||
|
||||
-- Smooth changing of FOV
|
||||
-- start_fov(fov_from, fov_to, fov_hud_from, fov_hud_to, active_always) initiate the changing procedure
|
||||
function change_fov()
|
||||
local steps = settings.fov_smoothing
|
||||
local delta = time_delta()
|
||||
local smoothed_fov = ema("fov", zoom_fov_to, zoom_fov_from, steps, delta)
|
||||
exec_console_cmd("fov " .. smoothed_fov)
|
||||
local smoothed_hud_fov = ema("hud_fov", zoom_hud_fov_to, zoom_hud_fov_from, steps, delta)
|
||||
exec_console_cmd("hud_fov " .. smoothed_hud_fov)
|
||||
if not zoom_fov_active_always and similar(smoothed_fov, zoom_fov_to, 0.02) then
|
||||
exec_console_cmd("fov " .. zoom_fov_to)
|
||||
exec_console_cmd("hud_fov " .. zoom_hud_fov_to)
|
||||
stop_fov()
|
||||
end
|
||||
end
|
||||
|
||||
function start_fov(fov_from, fov_to, fov_hud_from, fov_hud_to, active_always)
|
||||
zoom_fov_from = fov_from or get_console_cmd(2, "fov")
|
||||
zoom_fov_to = fov_to
|
||||
zoom_hud_fov_from = fov_hud_from or get_console_cmd(2, "hud_fov")
|
||||
zoom_hud_fov_to = fov_hud_to
|
||||
zoom_fov_active = true
|
||||
zoom_fov_active_always = active_always
|
||||
RegisterScriptCallback("actor_on_update", change_fov)
|
||||
end
|
||||
|
||||
function stop_fov()
|
||||
smoothed_values.fov = nil
|
||||
smoothed_values.hud_fov = nil
|
||||
zoom_fov_active = false
|
||||
zoom_fov_active_always = false
|
||||
UnregisterScriptCallback("actor_on_update", change_fov)
|
||||
end
|
||||
|
||||
function reset_fov()
|
||||
stop_fov()
|
||||
if not saved_fov then return end
|
||||
|
||||
exec_console_cmd("fov " .. saved_fov)
|
||||
exec_console_cmd("hud_fov " .. saved_hud_fov)
|
||||
saved_fov = nil
|
||||
saved_hud_fov = nil
|
||||
end
|
||||
|
||||
function reset(soft_fov)
|
||||
if soft_fov then
|
||||
if saved_fov then
|
||||
start_fov(zoom_fov_to, saved_fov, zoom_hud_fov_to, saved_hud_fov)
|
||||
end
|
||||
else
|
||||
reset_fov()
|
||||
end
|
||||
stop_move_camera()
|
||||
end
|
||||
|
||||
function hard_reset()
|
||||
reset()
|
||||
end
|
||||
|
||||
-- MCM
|
||||
function load_defaults()
|
||||
local t = {}
|
||||
local op = dialog_fov_mcm.op
|
||||
for i, v in ipairs(op.gr) do
|
||||
if v.def ~= nil then
|
||||
t[v.id] = v.def
|
||||
end
|
||||
end
|
||||
return t
|
||||
end
|
||||
|
||||
settings = load_defaults()
|
||||
|
||||
function load_settings()
|
||||
settings = load_defaults()
|
||||
if ui_mcm then
|
||||
for k, v in pairs(settings) do
|
||||
settings[k] = ui_mcm.get(dialog_fov_mcm.op_id .. "/" .. k)
|
||||
end
|
||||
end
|
||||
return settings
|
||||
end
|
||||
|
||||
function on_option_change()
|
||||
load_settings()
|
||||
switch_mod(settings.enabled)
|
||||
end
|
||||
|
||||
function switch_mod(enable)
|
||||
local funcs = {
|
||||
{"GUI_on_show", GUI_on_show},
|
||||
{"GUI_on_hide", GUI_on_hide},
|
||||
{"actor_on_net_destroy", hard_reset},
|
||||
{"actor_on_before_death", hard_reset},
|
||||
}
|
||||
if enable then
|
||||
for i, v in ipairs(funcs) do
|
||||
RegisterScriptCallback(v[1], v[2])
|
||||
end
|
||||
else
|
||||
for i, v in ipairs(funcs) do
|
||||
UnregisterScriptCallback(v[1], v[2])
|
||||
end
|
||||
reset()
|
||||
return
|
||||
end
|
||||
|
||||
if not settings.zoom_fov_enabled then
|
||||
reset_fov()
|
||||
end
|
||||
|
||||
if not settings.track_npc then
|
||||
stop_move_camera()
|
||||
end
|
||||
end
|
||||
|
||||
function on_game_start()
|
||||
RegisterScriptCallback("actor_on_first_update", on_option_change)
|
||||
RegisterScriptCallback("on_option_change", on_option_change)
|
||||
switch_mod(true)
|
||||
end
|
||||
@@ -0,0 +1,24 @@
|
||||
op_id = "demonized_dialog_fov"
|
||||
op_preset_id = "presets"
|
||||
|
||||
op = {
|
||||
id = op_id, sh = true, gr = {
|
||||
{id = "banner", type = "slide", text = "ui_mcm_" .. op_id .. "_title", size = {512, 50}, spacing = 20},
|
||||
|
||||
{id = "enabled", type = "check", val = 1, def = true},
|
||||
{id = "divider", type = "line"},
|
||||
{id = "zoom_fov_enabled", type = "check", val = 1, def = true},
|
||||
{id = "zoom_fov_modifier", type = "track", val = 2, min = 1, max = 3, step = 0.1, def = 1.3},
|
||||
{id = "min_zoom_fov", type = "track", val = 2, min = 15, max = 90, step = 1, def = 55},
|
||||
{id = "distance_fov", type = "check", val = 1, def = true},
|
||||
{id = "fov_smoothing", type = "track", val = 2, min = 1, max = 50, step = 1, def = 20},
|
||||
{id = "divider", type = "line"},
|
||||
{id = "track_npc", type = "check", val = 1, def = true},
|
||||
{id = "turn_modifier", type = "track", val = 2, min = -3, max = 3, step = 0.05, def = 1},
|
||||
{id = "smoothing", type = "track", val = 2, min = 1, max = 50, step = 1, def = 30},
|
||||
}
|
||||
}
|
||||
|
||||
function on_mcm_load()
|
||||
return op
|
||||
end
|
||||
Reference in New Issue
Block a user