Divergent/mods/Show All Faction Relations .../gamedata/scripts/ui_pda_relations_tab.script

946 lines
32 KiB
Plaintext
Raw Normal View History

2024-03-17 20:18:03 -04:00
-- ======================================================================
--[[ Show All Faction Relations in PDA
-- ======================================================================
Adapted version of ui_pda_relations_tab.script
Editor: dEmergence (dEmergence @ ModDB)
Source: https://www.moddb.com/mods/stalker-anomaly/addons/show-all-faction-relation-in-pda-except-monolith
Version: 6.2
Updated: 20231220
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License
-- ===================================================================--]]
local SINGLETON = nil
function get_ui()
-- SINGLETON = SINGLETON or pda_relations_tab()
SINGLETON = pda_relations_tab()
SINGLETON:Reset()
return SINGLETON
end
-- SAFR faction code reference lists unlocalized to allow for patching:
enc_ref_list = {
"loner",
"duty",
"freedom",
"clear_sky",
"ecologist",
"mercenary",
"military",
"isg",
"renegade",
"bandit",
"greh",
"monolith",
"zombified"
}
faction_code_list = {
"stalker",
"dolg",
"freedom",
"csky",
"ecolog",
"killer",
"army",
"isg",
"renegade",
"bandit",
"greh",
"monolith",
"zombied"
}
-- Reference List for comparison to vanilla settings
local vanilla_faction_code_list = {
"stalker",
"dolg",
"freedom",
"csky",
"ecolog",
"killer",
"army",
"bandit",
"monolith"
}
function d_printf( debugtxt )
if user_debug_log then
printf(tostring( debugtxt ))
end
end
function list_contains(t,value)
for i = 1,#t do
if t[i] == value then
return true
end
end
return false
end
function SetFalse(t)
local s = {}
for _,v in pairs(t) do s[v] = false end
return s
end
function setup_faction_discovery_state_var()
printf("SAFR initializing discovered_factions checklist")
local m_data = alife_storage_manager.get_state()
m_data.SAFR_discovered_factions = SetFalse(game_relations.factions_table)
end
function get_faction_discovery_state(faction)
local m_data = alife_storage_manager.get_state()
if not (m_data.SAFR_discovered_factions) then
setup_faction_discovery_state_var()
end
return m_data.SAFR_discovered_factions[faction]
end
function set_faction_discovery_state(faction)
local m_data = alife_storage_manager.get_state()
if not (m_data.SAFR_discovered_factions) then
setup_faction_discovery_state_var()
end
m_data.SAFR_discovered_factions[faction] = true
end
-- monkeypatching function ui_pda_encyclopedia_tab.detect_intereaction(typ, obj, name)
local originalDIFunction = ui_pda_encyclopedia_tab.detect_intereaction
function ui_pda_encyclopedia_tab.detect_intereaction(typ, obj, name)
--"factions", nil, character_community(obj)
if typ == "factions" and not get_faction_discovery_state(name) then
set_faction_discovery_state(name)
printf("SAFR updated discovered_factions: "..name)
end
originalDIFunction(typ, obj, name)
end
class "pda_relations_tab" (CUIScriptWnd)
-- dmg: moved to access via other functions
local iobj = {}
local kobj = {}
-- dmg: fetch this from MCM settings later
local user_obscure_enemy_squad_count = true
local user_disable_squad_count = true
function pda_relations_tab:__init() super()
-- dmg: Moved self.list code to "pda_relations_tab:Refresh_relations_list()". It is not used until InitControls anyway.
self.clr_red = utils_xml.get_color("red",true) -- GetARGB(255, 255, 1, 1)
self.clr_green = utils_xml.get_color("green",true) -- GetARGB(255, 1, 255, 1)
self.clr_yellow = utils_xml.get_color("yellow",true) -- GetARGB(255, 255, 255, 1)
self.clr_white = utils_xml.get_color("white",true)
self.clr_pda_blue = utils_xml.get_color("pda_blue",true)
self.clr_cyan = utils_xml.get_color("d_cyan",true)
self.clr_orange = utils_xml.get_color("orange",true)
self.clr_pda_green = utils_xml.get_color("pda_green",true)
self.clr_gray = utils_xml.get_color("ui_gray_2",true)
self.clr_d_red = utils_xml.get_color("d_red",true)
-- dmg: Tronex faction column swap code moved and repurposed
self.color_codes = {
GetARGB(255,255,255,255),
GetARGB(255,255,128,0),
GetARGB(255,0,255,255),
GetARGB(255,0,255,128),
GetARGB(255,0,128,255),
GetARGB(255,255,0,128),
GetARGB(255,128,255,0),
GetARGB(255,255,0,0),
GetARGB(255,0,255,0),
GetARGB(255,0,0,255),
GetARGB(255,128,0,255),
}
self.companion_info = {}
self.to_text = true
self._tmr = time_global()
self:InitControls()
end
function pda_relations_tab:__finalize()
end
-- dEmergence: function to refresh self.list
function pda_relations_tab:RefreshKnownFactionsList()
self.list = {}
self.list_squad_count = {}
self.list_squad_count_local = {}
self.list_is_enemy = {}
-- Checking if faction entries in encyclopedia are unlocked to determine relations shown
-- Should never remain empty because own faction should be automatically be unlocked.
-- faction unlocked when encyclopedia article unlocked
local faction_is_unlocked = false
-- vars holding settings from MCM
local user_preset = 2
local user_show_eliminated_factions = true
local user_debug_log = false
local user_use_encyclopedia_discovery = false
if ui_mcm then
printf("ShowAllRelationsPDA: Loading Settings from MCM")
user_debug_log = ui_mcm.get("dmg_safr_pda/debug_log")
d_printf(" Debug Log Enabled: "..tostring(user_debug_log))
user_preset = tonumber(ui_mcm.get("dmg_safr_pda/user_preset"))
d_printf(" MCM User Preset: "..tostring(user_preset))
user_show_eliminated_factions = ui_mcm.get("dmg_safr_pda/show_eliminated")
user_obscure_enemy_squad_count = ui_mcm.get("dmg_safr_pda/obscure_enemy_squad_count")
user_disable_squad_count = ui_mcm.get("dmg_safr_pda/disable_squad_count")
show_mutant_faction = ui_mcm.get("dmg_safr_pda/show_mutant_faction")
user_show_local_squad_count = ui_mcm.get("dmg_safr_pda/show_local_squad_count")
user_use_encyclopedia_discovery = ui_mcm.get("dmg_safr_pda/use_encyclopedia_discovery")
end
printf("")
if show_mutant_faction then
-- modify reference lists accordingly
if not list_contains(faction_code_list,"monster") then
-- assume the others do not contain it either
table.insert(faction_code_list,"monster")
end
end
-- Get number of Squads per faction
local faction_squad_count = {}
local faction_squad_count_local = {}
local on_act_lvl = simulation_objects.is_on_the_actor_level
--if not user_disable_squad_count then
for id,v in pairs( SIMBOARD.squads ) do
local squad = alife_object(id)
for i=1, #faction_code_list do
if (faction_squad_count[i] == nil) then
faction_squad_count[i] = 0
faction_squad_count_local[i] = 0
end
if (squad.player_id == faction_code_list[i]) then
faction_squad_count[i] = faction_squad_count[i] + 1
-- is squad on the same level as actor?
if on_act_lvl(squad) then
faction_squad_count_local[i] = faction_squad_count_local[i] + 1
end
end
end
end
-- debug output
if not user_obscure_enemy_squad_count then
d_printf(" Total Squad Count by Faction:")
for i=1, #faction_code_list do
d_printf(" "..faction_code_list[i].." : "..faction_squad_count[i])
end
d_printf("")
d_printf(" Total Squad Count by Faction on current level:")
for i=1, #faction_code_list do
d_printf(" "..faction_code_list[i].." : "..faction_squad_count_local[i])
end
end
--end
d_printf("")
d_printf(" Checking which factions should be shown by unlocked encyclopedia article:")
local actor_comm = get_actor_true_community()
local actor_is_vanilla_faction = list_contains(vanilla_faction_code_list, actor_comm)
local r_val = 0
local is_enemy = false
for i=1, #enc_ref_list do
d_printf(" Faction: "..game.translate_string(faction_code_list[i]))
if user_use_encyclopedia_discovery then
-- Get info if article is unlocked in encyclopedia instead of discovery state var (required for existing saves w/o all articles unlocked)
faction_is_unlocked = ui_pda_encyclopedia_tab.is_unlocked_article("encyclopedia_factions_"..enc_ref_list[i])
else
faction_is_unlocked = ui_pda_relations_tab.get_faction_discovery_state(faction_code_list[i])
end
if faction_is_unlocked then
d_printf(" encyclopedia_factions_"..enc_ref_list[i].." is unlocked")
end
-- Apply MCM Override values if applicable
if ui_mcm then
if (tonumber(ui_mcm.get("dmg_safr_pda/"..faction_code_list[i])) == 2) then
faction_is_unlocked = true
elseif (tonumber(ui_mcm.get("dmg_safr_pda/"..faction_code_list[i])) == 0) then
faction_is_unlocked = false
end
if (user_preset == 0) then
-- actor faction is automatically unlocked
if (not actor_is_vanilla_faction) and (faction_code_list[i] == actor_comm) then
faction_is_unlocked = true
if user_debug_log then
d_printf(" Preset 0: Set to true - Player is Renegade")
end
end
elseif (user_preset == 1) then
faction_is_unlocked = true
end
if (faction_squad_count[i] == 0) and (user_show_eliminated_factions == false) then
faction_is_unlocked = false
end
else
faction_is_unlocked = true
d_printf(" No MCM: Default to true")
end
if faction_is_unlocked then
self.list[#self.list+1] = faction_code_list[i]
self.list_squad_count[#self.list_squad_count+1] = faction_squad_count[i]
self.list_squad_count_local[#self.list_squad_count_local+1] = faction_squad_count_local[i]
-- Check if enemy to player
r_val = relation_registry.community_relation(actor_comm, faction_code_list[i])
d_printf(" Relation to Player: "..r_val)
is_enemy = (r_val <= game_relations.ENEMIES)
self.list_is_enemy[#self.list_is_enemy+1] = is_enemy
d_printf(" Is Enemy: "..tostring(is_enemy))
end
end
if show_mutant_faction then
self.list[#self.list+1] = "monster"
end
end
function pda_relations_tab:on_option_change()
self:Reset()
end
function pda_relations_tab:on_game_start()
RegisterScriptCallback("on_option_change",self:on_option_change())
end
function pda_relations_tab:RefreshRelationsMatrix()
-- dEmergence: Refresh Known Faction List first
-- self:RefreshKnownFactionsList()
local max_i_index = #self.list
local max_k_index = #self.list + 1
if user_disable_squad_count then
max_k_index = max_i_index
end
local k_index = 0
local actor_comm = get_actor_true_community()
for i=1, max_i_index do
-- dmg : catch possibility of all factions being set to "never_show"
if max_i_index > 0 and i <= max_i_index then
if not user_disable_squad_count then
if (self.list_squad_count[i] == 0) or (self.list_is_enemy[i] and user_obscure_enemy_squad_count) then
iobj[i]:SetTextColor(self.clr_gray)
end
end
if (self.list[i] == actor_comm) then
iobj[i]:SetTextColor(self.clr_pda_blue)
end
iobj[i]:SetText(game.translate_string(self.list[i]))
else
iobj[i]:SetText("")
end
for k=0, max_k_index do
if (i == 1) then
if (k == 0) and not user_disable_squad_count then
--if user_disable_squad_count then
-- kobj[k]:SetTextColor(self.clr_gray)
--else
kobj[k]:SetTextColor(self.clr_cyan)
--end
kobj[k]:SetText(game.translate_string("st_ui_dmg_safr_pda_squadcount"))
elseif (k == 1 and not user_disable_squad_count) or (k == 0 and user_disable_squad_count) then
kobj[k]:SetTextColor(self.clr_pda_green)
kobj[k]:SetText(game.translate_string("st_ui_goodwill_name"))
else
-- dmg : catch possibility of all factions being set to "never_show"
if max_i_index > 0 and k <= max_k_index then
if not user_disable_squad_count then
k_index = k - 1
else
k_index = k
end
if not user_disable_squad_count then
if (self.list_squad_count[k_index] == 0) or (self.list_is_enemy[k_index] and user_obscure_enemy_squad_count) then
kobj[k]:SetTextColor(self.clr_gray)
end
end
if (self.list[k_index] == actor_comm) then
kobj[k]:SetTextColor(self.clr_pda_blue)
end
kobj[k]:SetText(game.translate_string(self.list[k_index]))
else
kobj[k]:SetText("")
end
end
end
end
end
end
function pda_relations_tab:InitControls()
-- SAFR: Call early to get # of factions to show
self:RefreshKnownFactionsList()
self:SetWndRect(Frect():set(0, 0, 1024, 768))
local xml = CScriptXmlInit()
if #self.list < 10 then
if not user_disable_squad_count then
xml:ParseFile("pda_relations_f9.xml")
else
xml:ParseFile("pda_relations_f9x.xml")
end
elseif #self.list == 10 then
if not user_disable_squad_count then
xml:ParseFile("pda_relations_f10.xml")
else
xml:ParseFile("pda_relations_f10x.xml")
end
elseif #self.list == 11 then
if not user_disable_squad_count then
xml:ParseFile("pda_relations_f11.xml")
else
xml:ParseFile("pda_relations_f11x.xml")
end
elseif #self.list == 12 then
if not user_disable_squad_count then
xml:ParseFile("pda_relations_f12.xml")
else
xml:ParseFile("pda_relations_f12x.xml")
end
elseif #self.list == 13 then
if not user_disable_squad_count then
xml:ParseFile("pda_relations_f13.xml")
else
xml:ParseFile("pda_relations_f13x.xml")
end
else
if not user_disable_squad_count then
xml:ParseFile("pda_relations_f14.xml")
else
xml:ParseFile("pda_relations_f14x.xml")
end
end
xml:InitFrame("frame",self)
xml:InitStatic("center_background", self)
self.tab = xml:InitStatic("tab", self)
xml:InitStatic("tab:caption", self.tab)
self.btn = xml:Init3tButton("btn_to_text", self)
self:Register(self.btn, "btn")
self:AddCallback("btn", ui_events.BUTTON_CLICKED, self.btn_to_text, self)
-- dEmergence: Relation Matrix XML Setup only. Modified code to create objects for all col and row objects (13x14) that fit the template.
self.relations = {}
local is_widescreen = true --utils_xml.is_widescreen()
local x = is_widescreen and 40 or 55
local c_width = is_widescreen and 75 or 90
local c_height = 31.81
local c_count_h = #self.list
local c_count_v = #self.list + 2
if user_disable_squad_count then
c_height = 35
c_count_v = #self.list + 1
end
if #self.list > 9 then
c_width = is_widescreen and ( 675 / c_count_h ) or ( 90 / (75 / ( 675 / c_count_h )))
c_height = (350 / ( c_count_v ))
end
local x_offset = 0
for i=1, c_count_h do
x = x + c_width
if (i == 1) then
-- x_offset = x + 10
if c_count_h > 9 then
x_offset = x + ((c_count_h - 9) * 2.75)
else
x_offset = x
end
else
x_offset = x
end
iobj[i] = xml:InitTextWnd("tab:faction", self.tab)
iobj[i]:SetWndPos(vector2():set(x_offset,65))
iobj[i]:SetText("")
self.relations[i] = {}
-- local y = 65
local y = 60
if c_count_h > 9 then
y = y + ((c_count_h - 9) * 1.7)
end
for k=0, (c_count_v - 1) do
y = y + c_height
if (i == 1) then
kobj[k] = xml:InitTextWnd("tab:faction", self.tab)
kobj[k]:SetWndPos(vector2():set(x - c_width, y))
kobj[k]:SetText("")
end
self.relations[i][k] = xml:InitTextWnd("tab:cell",self.tab)
self.relations[i][k]:SetWndPos(vector2():set(x_offset,y))
self.relations[i][k]:SetText("")
end
if (i == 1) then
x = x_offset
end
end
-- Companion ListView
xml:InitFrame("companion_frame",self)
xml:InitStatic("companion_background",self)
self.companion_listbox = xml:InitListBox("companion_wnd",self)
self.companion_listbox:SetItemHeight(140)
self.auto_chk = xml:InitCheck("auto_check",self)
self.auto_chk:SetCheck(false)
for row=1,4 do
local row_form = ui_companion_row(self,row,xml)
row_form:SetWndSize(vector2():set(740,140))
self.companion_listbox:AddExistingItem(row_form)
end
-- Hint Window
self.hint_wnd = utils_ui.UIHint(self)
-- self:Reset()
end
function pda_relations_tab:Update()
CUIScriptWnd.Update(self)
-- option to auto update values
if self.auto_chk:GetCheck() then
local tg = time_global()
if self._tmr < tg then
self._tmr = tg + 2000
self:autoupdate()
end
end
if not (self.disabled) then
for i=1, 24 do -- should be row*col from ui_companion_row
if (self.companion_info[i].icon_wnd:IsShown()) then
local pos = GetCursorPosition()
local rect = Frect():set(0,0,0,0)
self.companion_info[i].icon_wnd:GetAbsoluteRect(rect)
if (utils_data.pos_in_rect(pos,rect)) then
self.hint_wnd:Update(self.companion_info[i].hint)
self.mouse_over_id = i
return
end
end
end
end
self.mouse_over_id = nil
self.hint_wnd:Update()
end
function pda_relations_tab:autoupdate()
local id_to_code = {}
local clist = axr_companions.list_actor_squad_by_id()
local sim = alife()
for i=1,24 do -- should be row*col from ui_companion_row
local se_obj = clist[i] and alife_object(clist[i])
if (se_obj and IsStalker(nil,se_obj:clsid()) and se_obj:alive()) then
local full_name = se_obj:character_name()
local name = string.gsub(full_name,"Junior","Jr.")
name = string.gsub(name,"Senior","Sr.")
name = string.gsub(name,"Master ","M")
name = string.gsub(name,"Private","PVT")
name = string.gsub(name,"Sergeant","SGT")
name = string.gsub(name,"Lieutenant","LT")
name = string.gsub(name,"Captain","CPT")
local name = string.len(name) <= 22 and name or string.sub(name, 0, 19) .. "..."
self.companion_info[i].id = se_obj.id
local st = db.storage[se_obj.id]
local npc = st and st.object
local icon_name = npc and npc:character_icon() or se_obj:character_icon()
icon_name = icon_name and icon_name ~= "" and icon_name or "ui\\ui_noise"
self.companion_info[i].icon_wnd:InitTexture(icon_name)
self.companion_info[i].icon_wnd:Show(true)
self.companion_info[i].name_wnd:SetText(name)
self.companion_info[i].comm_wnd:SetText(game.translate_string(se_obj:community()))
self.companion_info[i].rank_wnd:SetText(game.translate_string("st_rank_"..ranks.get_se_obj_rank_name(se_obj)).." ("..se_obj:rank()..")")
self.companion_info[i].dist_wnd:SetText(string.format(game.translate_string("st_distance_to")..": %.2f", se_obj.position:distance_to(db.actor:position())))
-- leader and relation status
local squad = se_obj.group_id and se_obj.group_id ~= 65535 and alife_object(se_obj.group_id)
if (squad and squad:commander_id() == se_obj.id) then
self.companion_info[i].leader_wnd:Show(true)
self.companion_info[i].leader_wnd:InitTexture("ui_minimap_squad_leader")
else
self.companion_info[i].leader_wnd:Show(true)
self.companion_info[i].leader_wnd:InitTexture("ui_minimap_point")
end
-- Set color code
if not (id_to_code[se_obj.group_id]) then
local n = 1
for k,v in pairs(id_to_code) do
n = n + 1
end
id_to_code[se_obj.group_id] = self.color_codes[n] or self.color_codes[1]
end
self.companion_info[i].leader_wnd:SetTextureColor(id_to_code[se_obj.group_id])
-- health status
if (npc) then
local hp = math.floor(npc.health*100)
self.companion_info[i].health_wnd:SetText(hp.."%")
if (hp > 70) then
self.companion_info[i].health_wnd:SetTextColor(GetARGB(200, 0, 255, 0))
elseif (hp < 30) then
self.companion_info[i].health_wnd:SetTextColor(GetARGB(200, 255, 0, 0))
else
self.companion_info[i].health_wnd:SetTextColor(GetARGB(200, 255, 255, 255))
end
end
-- Hint
local s_move,s_combat,s_gather,s_loot,s_dist,s_stealth,s_arte,s_stalker,s_mutant,s_wounded,s_corpse,s_dismiss,s_tele
local state_str = [[
%c[255,255,215,255]%c[default]%s \n
\n%c[255,215,215,215]st_mm_pda_location:%c[default] %s \n
\n%c[255,215,215,215]st_mm_pda_states:%c[default] \n
%c[255,160,160,160]st_mm_pda_movement:%c[default] %s \n
%c[255,160,160,160]st_mm_pda_combat:%c[default] %s \n
%c[255,160,160,160]st_mm_pda_pickup_items:%c[default] %s \n
%c[255,160,160,160]st_mm_pda_loot_corpses:%c[default] %s \n
%c[255,160,160,160]st_mm_pda_keep_distance:%c[default] %s \n
%c[255,160,160,160]st_mm_pda_stealth:%c[default] %s \n
%c[255,160,160,160]st_mm_pda_dismissable:%c[default] %s \n
%c[255,160,160,160]st_mm_pda_level_travel:%c[default] %s \n
\n%c[255,215,215,215]st_mm_pda_statistics:%c[default] \n
%c[255,160,160,160]st_mm_pda_stalkers_killed:%c[default] %s \n
%c[255,160,160,160]st_mm_pda_mutants_killed:%c[default] %s \n
%c[255,160,160,160]st_mm_pda_artes_found:%c[default] %s \n
%c[255,160,160,160]st_mm_pda_wounded_helped:%c[default] %s \n
%c[255,160,160,160]st_mm_pda_corpse_looted:%c[default] %s \n
]]
if (sim:has_info(se_obj.id,"npcx_beh_wait")) then
s_move = game.translate_string("st_set_companion_to_wait_state")
elseif (sim:has_info(se_obj.id,"npcx_beh_patrol_mode")) then
s_move = game.translate_string("st_set_companion_to_patrol_state")
else
s_move = game.translate_string("st_set_companion_to_follow_state")
end
if (sim:has_info(se_obj.id,"npcx_beh_ignore_actor_enemies") and sim:has_info(se_obj.id,"npcx_beh_ignore_combat")) then
s_combat = game.translate_string("st_set_companion_to_ignore_combat_state")
elseif (sim:has_info(se_obj.id,"npcx_beh_ignore_combat")) then
s_combat = game.translate_string("st_set_companion_to_attack_only_actor_combat_enemy_state")
else
s_combat = game.translate_string("st_set_companion_to_attack_state")
end
local can_gather = sim:has_info(se_obj.id,"npcx_beh_gather_items")
local can_loot = sim:has_info(se_obj.id,"npcx_beh_loot_corpses")
s_gather = can_gather and game.translate_string("st_pda_mode_on") or game.translate_string("st_pda_mode_off")
s_loot = can_loot and game.translate_string("st_pda_mode_on") or game.translate_string("st_pda_mode_off")
if (npc) then
-- If looting is set false in logic
if (can_gather and st.gather_items and st.gather_items.gather_items_enabled and xr_logic.pick_section_from_condlist(db.actor, npc, st.gather_items.gather_items_enabled) == "false") then
s_gather = game.translate_string("st_pda_mode_disabled")
end
if (can_loot and st.corpse_detection and st.corpse_detection.corpse_detection_enabled and xr_logic.pick_section_from_condlist(db.actor, npc, st.corpse_detection.corpse_detection_enabled) == "false") then
s_loot = game.translate_string("st_pda_mode_disabled")
end
end
s_dist = sim:has_info(se_obj.id,"npcx_beh_distance_far") and game.translate_string("st_pda_mode_dist_far") or game.translate_string("st_pda_mode_dist_near")
s_stealth = sim:has_info(se_obj.id,"npcx_beh_substate_stealth") and game.translate_string("st_pda_mode_on") or game.translate_string("st_pda_mode_off")
local m_data = alife_storage_manager.get_se_obj_state(se_obj)
if (m_data) then
s_stalker = m_data["killed_stalkers"] or 0
s_mutant = m_data["killed_monsters"] or 0
s_arte = m_data["artefacts_found"] or 0
s_wounded = m_data["wounded_helped"] or 0
s_corpse = m_data["corpse_looted"] or 0
end
s_dismiss = se_load_var(se_obj.id,se_obj:name(),"companion_cannot_dismiss") and game.translate_string("st_pda_mode_false") or game.translate_string("st_pda_mode_true")
s_tele = se_load_var(se_obj.id,se_obj:name(),"companion_cannot_teleport") and game.translate_string("st_pda_mode_disabled") or game.translate_string("st_pda_mode_enabled")
local s_location = game.translate_string(sim:level_name(game_graph():vertex(se_obj.m_game_vertex_id):level_id()))
for s in string.gmatch(state_str,"(st_mm_pda_[%w%d_]*)") do
state_str = string.gsub(state_str,s,game.translate_string(s))
end
state_str = strformat(state_str,full_name,s_location,s_move,s_combat,s_gather,s_loot,s_dist,s_stealth,s_dismiss,s_tele,s_stalker,s_mutant,s_arte,s_wounded,s_corpse)
self.companion_info[i].hint = state_str
else
self.companion_info[i].id = nil
self.companion_info[i].icon_wnd:Show(false)
self.companion_info[i].leader_wnd:Show(false)
self.companion_info[i].health_wnd:SetText("")
self.companion_info[i].name_wnd:SetText("")
self.companion_info[i].comm_wnd:SetText("")
self.companion_info[i].rank_wnd:SetText("")
self.companion_info[i].dist_wnd:SetText("")
end
end
end
function pda_relations_tab:Reset()
-- dEmergence: Refresh Relations Matrix
self:RefreshRelationsMatrix()
local max_i_index = #self.list
local max_k_index = #self.list + 1
if user_disable_squad_count then
max_k_index = max_i_index
end
local k_index = 0
for i=1, max_i_index do
for k=0, max_k_index do
-- dmg : catch possibility of all factions being set to "never_show"
if max_i_index > 0 and i <= max_i_index and k <= max_k_index then
if not user_disable_squad_count then
k_index = k - 1
else
k_index = k
end
local r_val = 0
local r_val2 = 0
if (k > 0 and not user_disable_squad_count) or (user_disable_squad_count) then
local comm = self.list[k_index] or db.actor:character_community()
r_val = relation_registry.community_relation(comm, self.list[i])
end
if (k == 0) and not user_disable_squad_count then
-- if first row then squad count
r_val = self.list_squad_count[i] or 0
r_val2 = self.list_squad_count_local[i] or 0
if self.list_is_enemy[i] then
if user_obscure_enemy_squad_count then
self.relations[i][k]:SetTextColor(self.clr_gray)
self.relations[i][k]:SetText(game.translate_string("st_ui_dmg_safr_pda_squadsize_na"))
else
if r_val >= 25 then
self.relations[i][k]:SetTextColor(self.clr_red)
self.relations[i][k]:SetText(game.translate_string("st_ui_dmg_safr_pda_squadsize_5"))
elseif r_val < 25 and r_val >= 15 then
self.relations[i][k]:SetTextColor(self.clr_d_red)
self.relations[i][k]:SetText(game.translate_string("st_ui_dmg_safr_pda_squadsize_4"))
elseif r_val < 15 and r_val >= 10 then
self.relations[i][k]:SetTextColor(self.clr_orange)
self.relations[i][k]:SetText(game.translate_string("st_ui_dmg_safr_pda_squadsize_3"))
elseif r_val < 10 and r_val >= 6 then
self.relations[i][k]:SetTextColor(self.clr_yellow)
self.relations[i][k]:SetText(game.translate_string("st_ui_dmg_safr_pda_squadsize_2"))
elseif r_val < 6 and r_val > 0 then
self.relations[i][k]:SetTextColor(self.clr_yellow)
self.relations[i][k]:SetText(game.translate_string("st_ui_dmg_safr_pda_squadsize_1"))
else
self.relations[i][k]:SetTextColor(self.clr_gray)
self.relations[i][k]:SetText(game.translate_string("st_ui_dmg_safr_pda_squadsize_0"))
end
end
else
if r_val >= 25 then
self.relations[i][k]:SetTextColor(self.clr_green)
self.relations[i][k]:SetText(game.translate_string("st_ui_dmg_safr_pda_squadsize_5"))
elseif r_val < 25 and r_val >= 15 then
self.relations[i][k]:SetTextColor(self.clr_pda_green)
self.relations[i][k]:SetText(game.translate_string("st_ui_dmg_safr_pda_squadsize_4"))
elseif r_val < 15 and r_val >= 10 then
self.relations[i][k]:SetTextColor(self.clr_yellow)
self.relations[i][k]:SetText(game.translate_string("st_ui_dmg_safr_pda_squadsize_3"))
elseif r_val < 10 and r_val >= 6 then
self.relations[i][k]:SetTextColor(self.clr_orange)
self.relations[i][k]:SetText(game.translate_string("st_ui_dmg_safr_pda_squadsize_2"))
elseif r_val < 6 and r_val > 0 then
self.relations[i][k]:SetTextColor(self.clr_red)
self.relations[i][k]:SetText(game.translate_string("st_ui_dmg_safr_pda_squadsize_1"))
else
self.relations[i][k]:SetTextColor(self.clr_gray)
self.relations[i][k]:SetText(game.translate_string("st_ui_dmg_safr_pda_squadsize_0"))
end
end
elseif (k == 1 and not user_disable_squad_count) or (k == 0 and user_disable_squad_count) then
-- if second row (or first and squad count disabled) then goodwill
r_val = relation_registry.community_goodwill(self.list[i],AC_ID)
if r_val >= 2000 then
self.relations[i][k]:SetTextColor(self.clr_green)
self.relations[i][k]:SetText(game.translate_string("st_ui_goodwill_5"))
elseif r_val < 2000 and r_val >= 1500 then
self.relations[i][k]:SetTextColor(self.clr_yellow)
self.relations[i][k]:SetText(game.translate_string("st_ui_goodwill_4"))
elseif r_val < 1500 and r_val >= 1000 then
self.relations[i][k]:SetTextColor(self.clr_yellow)
self.relations[i][k]:SetText(game.translate_string("st_ui_goodwill_3"))
elseif r_val < 1000 and r_val >= 500 then
self.relations[i][k]:SetTextColor(self.clr_yellow)
self.relations[i][k]:SetText(game.translate_string("st_ui_goodwill_2"))
else
self.relations[i][k]:SetTextColor(self.clr_red)
self.relations[i][k]:SetText(game.translate_string("st_ui_goodwill_1"))
end
else
if r_val >= game_relations.FRIENDS then
self.relations[i][k]:SetTextColor(self.clr_green)
self.relations[i][k]:SetText(game.translate_string("st_goodwill_friendly"))
elseif r_val <= game_relations.ENEMIES then
self.relations[i][k]:SetTextColor(self.clr_red)
self.relations[i][k]:SetText(game.translate_string("st_goodwill_enemy"))
else
self.relations[i][k]:SetTextColor(self.clr_yellow)
self.relations[i][k]:SetText(game.translate_string("st_goodwill_indifferent"))
end
end
if not (self.to_text) then
if k > 0 then
self.relations[i][k]:SetText(tostring(r_val))
else
if not user_disable_squad_count then
--self.relations[i][k]:SetText("-")
if (self.list_is_enemy[i] and user_obscure_enemy_squad_count) then
self.relations[i][k]:SetText(game.translate_string("st_ui_dmg_safr_pda_squadsize_na"))
elseif user_show_local_squad_count then
self.relations[i][k]:SetText(tostring(r_val).." ("..tostring(r_val2)..")")
else
self.relations[i][k]:SetText(tostring(r_val))
end
else
self.relations[i][k]:SetText(tostring(r_val))
end
end
end
else
self.relations[i][k]:SetText("")
end
end
end
self:autoupdate()
end
function pda_relations_tab:btn_to_text()
self.to_text = not self.to_text
if self.to_text then
self.btn:TextControl():SetText(game.translate_string("pda_table_value_off"))
else
self.btn:TextControl():SetText(game.translate_string("pda_table_value_on"))
end
self:Reset()
end
---------------------------------------------------------------------------------------------------
--
---------------------------------------------------------------------------------------------------
class "ui_companion_row" (CUIListBoxItem)
function ui_companion_row:__init(owner,row,xml) super(owner,row,xml)
self:GetTextItem():SetText("")
local is_widescreen = true --utils_xml.is_widescreen()
local x = is_widescreen and 20 or 35
local y = 0
for i=1,6 do
local n = i+(6*(row-1))
owner.companion_info[n] = {
["id"] = nil,
["icon_wnd"] = self:AddIconField(1),
["leader_wnd"] = self:AddIconField(1),
["name_wnd"] = self:AddTextField("",1),
["comm_wnd"] = self:AddTextField("",1),
["rank_wnd"] = self:AddTextField("",1),
["health_wnd"] = self:AddTextField("",1),
["dist_wnd"] = self:AddTextField("",1),
["hint"] = ""
}
owner.companion_info[n].icon_wnd:InitTexture("ui\\ui_noise")
owner.companion_info[n].icon_wnd:SetStretchTexture(true)
owner.companion_info[n].icon_wnd:SetWndSize(vector2():set(64,64))
owner.companion_info[n].icon_wnd:SetWndPos(vector2():set(x,y))
owner.companion_info[n].leader_wnd:InitTexture("ui_minimap_squad_leader")
owner.companion_info[n].leader_wnd:SetStretchTexture(true)
owner.companion_info[n].leader_wnd:SetWndSize(vector2():set(is_widescreen and 8 or 10,10))
owner.companion_info[n].leader_wnd:SetWndPos(vector2():set(x,y))
owner.companion_info[n].name_wnd:SetFont(GetFontLetterica18Russian())
owner.companion_info[n].name_wnd:SetWndSize(vector2():set(120,22))
owner.companion_info[n].name_wnd:SetWndPos(vector2():set(x,y+65))
owner.companion_info[n].comm_wnd:SetFont(GetFontLetterica16Russian())
owner.companion_info[n].comm_wnd:SetWndSize(vector2():set(120,20))
owner.companion_info[n].comm_wnd:SetWndPos(vector2():set(x,y+90))
owner.companion_info[n].rank_wnd:SetFont(GetFontLetterica16Russian())
owner.companion_info[n].rank_wnd:SetWndSize(vector2():set(120,20))
owner.companion_info[n].rank_wnd:SetWndPos(vector2():set(x,y+105))
owner.companion_info[n].health_wnd:SetFont(GetFontSmall())
owner.companion_info[n].health_wnd:SetWndSize(vector2():set(50,10))
owner.companion_info[n].health_wnd:SetWndPos(vector2():set(x+50,y+55))
owner.companion_info[n].dist_wnd:SetFont(GetFontLetterica16Russian())
owner.companion_info[n].dist_wnd:SetWndSize(vector2():set(120,20))
owner.companion_info[n].dist_wnd:SetWndPos(vector2():set(x,y+120))
x = x + (is_widescreen and 125 or 155)
end
end