-- UI Radiation Mod -- by sokol_jack (sokol_jack@mail.ru) -- version 0.3 local posx = 0 local posy = 0 local width = 0 local height = 0 local p_dx = 0 local p_dy =0 local p_width = 0 local p_height = 0 local saved_aspect = 0 local saved_width = -1 function Update(bShow) bShow = bShow or true if (db.actor == nil) then return end if (db.actor.radiation == nil) then return end local hud_rad = get_hud() local wnd_ if (hud_rad) then local custom_static_rad_back = hud_rad:GetCustomStatic("hud_rad_back") local custom_static_rad = hud_rad:GetCustomStatic("hud_rad_level") if (device().aspect_ratio ~= saved_aspect) then local asp = device().aspect_ratio if (math.abs(asp - saved_aspect) > 0.01) then saved_aspect = device().aspect_ratio if(custom_static_rad_back) then hud_rad:RemoveCustomStatic("hud_rad_back") end if(custom_static_rad) then hud_rad:RemoveCustomStatic("hud_rad_level") end custom_static_rad_back = nil custom_static_rad = nil end end local bDetected = false if tBeltSection["dev_rad"] then bDetected = true end if (bDetected == false or bShow == false) then if (custom_static_rad_back) then hud_rad:RemoveCustomStatic("hud_rad_back") end if (custom_static_rad) then hud_rad:RemoveCustomStatic("hud_rad_level") end return end if (custom_static_rad_back == nil or custom_static_rad == nil) then if (device().aspect_ratio < 0.75) then --widescreen. Use coords from maingame_16.xml read_params(true) else --normal -- Use coords from maingame.xml read_params() end if custom_static_rad_back == nil then hud_rad:AddCustomStatic("hud_rad_back", true) custom_static_rad_back = hud_rad:GetCustomStatic("hud_rad_back") if (custom_static_rad_back and custom_static_rad_back.wnd) then wnd_ = custom_static_rad_back:wnd() if (wnd_) then wnd_:SetWndPos(posx, posy) wnd_:SetHeight(height) wnd_:SetWidth(width) end end end if custom_static_rad == nil then hud_rad:AddCustomStatic("hud_rad_level", true) custom_static_rad = hud_rad:GetCustomStatic("hud_rad_level") if (custom_static_rad and custom_static_rad.wnd) then wnd_ = custom_static_rad:wnd() if(wnd_) then wnd_:SetWndPos(posx + p_dx, posy + p_dy) wnd_:SetHeight(p_height) wnd_:SetWidth(p_width) end end end end local new_width = db.actor.radiation * p_width if (saved_width ~= new_width) then if db.actor.radiation > 0.0 then custom_static_rad:wnd():SetWidth(new_width) else custom_static_rad:wnd():SetWidth(new_width) --hud_rad:RemoveCustomStatic("hud_rad_level") end end end end function read_params(bWide) local section = "" local ui_rad_ini = ini_file("ui_radiation.ltx") local id, value = "", "", result local n = 0 section = "ui_rad" if bWide == true then section = "ui_rad_wide" end if (ui_rad_ini and ui_rad_ini:section_exist(section)) then n = ui_rad_ini:line_count(section) for i=0, n-1 do result, id, value = ui_rad_ini:r_line(section, i, "", "") if (id == "x") then posx = value elseif(id == "y") then posy = value elseif(id == "width") then width = value elseif(id == "height") then height = value end end end section = "ui_rad_progress" if bWide == true then section = "ui_rad_progress_wide" end if (ui_rad_ini and ui_rad_ini:section_exist(section)) then n = ui_rad_ini:line_count(section) for i=0, n-1 do result, id, value = ui_rad_ini:r_line(section, i, "", "") if (id == "dx") then p_dx = value elseif(id == "dy") then p_dy = value elseif(id == "width") then p_width = value elseif(id == "height") then p_height = value end end end end