mirror of
https://github.com/APercy/airutils.git
synced 2025-03-21 10:31:22 +00:00
improved hud display
This commit is contained in:
parent
244288490a
commit
aebcdd95eb
3 changed files with 145 additions and 7 deletions
|
@ -454,12 +454,12 @@ function airutils.logic(self)
|
||||||
local speed_angle = airutils.get_gauge_angle(indicated_speed, -45)
|
local speed_angle = airutils.get_gauge_angle(indicated_speed, -45)
|
||||||
|
|
||||||
--adjust power indicator
|
--adjust power indicator
|
||||||
local power_indicator_angle = airutils.get_gauge_angle(self._power_lever/10)
|
local power_indicator_angle = airutils.get_gauge_angle(self._power_lever/10) + 90
|
||||||
--self.power_gauge:set_attach(self.object,'',ALBATROS_D5_GAUGE_POWER_POSITION,{x=0,y=0,z=power_indicator_angle})
|
local energy_indicator_angle = (airutils.get_gauge_angle((self._max_fuel - self._energy)*2)) - 90
|
||||||
|
|
||||||
if is_attached then
|
if is_attached then
|
||||||
if self._show_hud then
|
if self._show_hud then
|
||||||
airutils.update_hud(player, climb_angle, speed_angle)
|
airutils.update_hud(player, climb_angle, speed_angle, power_indicator_angle, energy_indicator_angle)
|
||||||
else
|
else
|
||||||
airutils.remove_hud(player)
|
airutils.remove_hud(player)
|
||||||
end
|
end
|
||||||
|
|
|
@ -28,21 +28,29 @@ function airutils.animate_gauge(player, ids, prefix, x, y, angle)
|
||||||
player:hud_change(ids[prefix .. "7"], "offset", {x = pos_x + x, y = pos_y + y})
|
player:hud_change(ids[prefix .. "7"], "offset", {x = pos_x + x, y = pos_y + y})
|
||||||
end
|
end
|
||||||
|
|
||||||
function airutils.update_hud(player, climb, speed)
|
function airutils.update_hud(player, climb, speed, power, fuel)
|
||||||
local player_name = player:get_player_name()
|
local player_name = player:get_player_name()
|
||||||
|
|
||||||
local screen_pos_y = -150
|
local screen_pos_y = -150
|
||||||
local screen_pos_x = 10
|
local screen_pos_x = 10
|
||||||
|
|
||||||
local clb_gauge_x = screen_pos_x + 80
|
local clb_gauge_x = screen_pos_x + 75
|
||||||
local clb_gauge_y = screen_pos_y + 5
|
local clb_gauge_y = screen_pos_y + 1
|
||||||
local sp_gauge_x = screen_pos_x + 180
|
local sp_gauge_x = screen_pos_x + 170
|
||||||
local sp_gauge_y = clb_gauge_y
|
local sp_gauge_y = clb_gauge_y
|
||||||
|
|
||||||
|
local pwr_gauge_x = screen_pos_x + 330
|
||||||
|
local pwr_gauge_y = clb_gauge_y
|
||||||
|
|
||||||
|
local fu_gauge_x = screen_pos_x + 340
|
||||||
|
local fu_gauge_y = clb_gauge_y
|
||||||
|
|
||||||
local ids = airutils.hud_list[player_name]
|
local ids = airutils.hud_list[player_name]
|
||||||
if ids then
|
if ids then
|
||||||
airutils.animate_gauge(player, ids, "clb_pt_", clb_gauge_x, clb_gauge_y, climb)
|
airutils.animate_gauge(player, ids, "clb_pt_", clb_gauge_x, clb_gauge_y, climb)
|
||||||
airutils.animate_gauge(player, ids, "sp_pt_", sp_gauge_x, sp_gauge_y, speed)
|
airutils.animate_gauge(player, ids, "sp_pt_", sp_gauge_x, sp_gauge_y, speed)
|
||||||
|
airutils.animate_gauge(player, ids, "pwr_pt_", pwr_gauge_x, pwr_gauge_y, power)
|
||||||
|
airutils.animate_gauge(player, ids, "fu_pt_", fu_gauge_x, fu_gauge_y, fuel)
|
||||||
else
|
else
|
||||||
ids = {}
|
ids = {}
|
||||||
|
|
||||||
|
@ -180,6 +188,122 @@ function airutils.update_hud(player, climb, speed)
|
||||||
alignment = { x = 1, y = 0 },
|
alignment = { x = 1, y = 0 },
|
||||||
})
|
})
|
||||||
|
|
||||||
|
ids["pwr_pt_1"] = player:hud_add({
|
||||||
|
hud_elem_type = "image",
|
||||||
|
position = {x = 0, y = 1},
|
||||||
|
offset = {x = pwr_gauge_x, y = pwr_gauge_y},
|
||||||
|
text = "airutils_ind_box.png",
|
||||||
|
scale = { x = 6, y = 6},
|
||||||
|
alignment = { x = 1, y = 0 },
|
||||||
|
})
|
||||||
|
|
||||||
|
ids["pwr_pt_2"] = player:hud_add({
|
||||||
|
hud_elem_type = "image",
|
||||||
|
position = {x = 0, y = 1},
|
||||||
|
offset = {x = pwr_gauge_x, y = pwr_gauge_y},
|
||||||
|
text = "airutils_ind_box.png",
|
||||||
|
scale = { x = 6, y = 6},
|
||||||
|
alignment = { x = 1, y = 0 },
|
||||||
|
})
|
||||||
|
ids["pwr_pt_3"] = player:hud_add({
|
||||||
|
hud_elem_type = "image",
|
||||||
|
position = {x = 0, y = 1},
|
||||||
|
offset = {x = pwr_gauge_x, y = pwr_gauge_y},
|
||||||
|
text = "airutils_ind_box.png",
|
||||||
|
scale = { x = 6, y = 6},
|
||||||
|
alignment = { x = 1, y = 0 },
|
||||||
|
})
|
||||||
|
ids["pwr_pt_4"] = player:hud_add({
|
||||||
|
hud_elem_type = "image",
|
||||||
|
position = {x = 0, y = 1},
|
||||||
|
offset = {x = pwr_gauge_x, y = pwr_gauge_y},
|
||||||
|
text = "airutils_ind_box.png",
|
||||||
|
scale = { x = 6, y = 6},
|
||||||
|
alignment = { x = 1, y = 0 },
|
||||||
|
})
|
||||||
|
ids["pwr_pt_5"] = player:hud_add({
|
||||||
|
hud_elem_type = "image",
|
||||||
|
position = {x = 0, y = 1},
|
||||||
|
offset = {x = pwr_gauge_x, y = pwr_gauge_y},
|
||||||
|
text = "airutils_ind_box.png",
|
||||||
|
scale = { x = 6, y = 6},
|
||||||
|
alignment = { x = 1, y = 0 },
|
||||||
|
})
|
||||||
|
ids["pwr_pt_6"] = player:hud_add({
|
||||||
|
hud_elem_type = "image",
|
||||||
|
position = {x = 0, y = 1},
|
||||||
|
offset = {x = pwr_gauge_x, y = pwr_gauge_y},
|
||||||
|
text = "airutils_ind_box.png",
|
||||||
|
scale = { x = 6, y = 6},
|
||||||
|
alignment = { x = 1, y = 0 },
|
||||||
|
})
|
||||||
|
ids["pwr_pt_7"] = player:hud_add({
|
||||||
|
hud_elem_type = "image",
|
||||||
|
position = {x = 0, y = 1},
|
||||||
|
offset = {x = pwr_gauge_x, y = pwr_gauge_y},
|
||||||
|
text = "airutils_ind_box.png",
|
||||||
|
scale = { x = 6, y = 6},
|
||||||
|
alignment = { x = 1, y = 0 },
|
||||||
|
})
|
||||||
|
|
||||||
|
ids["fu_pt_1"] = player:hud_add({
|
||||||
|
hud_elem_type = "image",
|
||||||
|
position = {x = 0, y = 1},
|
||||||
|
offset = {x = fu_gauge_x, y = fu_gauge_y},
|
||||||
|
text = "airutils_ind_box.png",
|
||||||
|
scale = { x = 6, y = 6},
|
||||||
|
alignment = { x = 1, y = 0 },
|
||||||
|
})
|
||||||
|
|
||||||
|
ids["fu_pt_2"] = player:hud_add({
|
||||||
|
hud_elem_type = "image",
|
||||||
|
position = {x = 0, y = 1},
|
||||||
|
offset = {x = fu_gauge_x, y = fu_gauge_y},
|
||||||
|
text = "airutils_ind_box.png",
|
||||||
|
scale = { x = 6, y = 6},
|
||||||
|
alignment = { x = 1, y = 0 },
|
||||||
|
})
|
||||||
|
ids["fu_pt_3"] = player:hud_add({
|
||||||
|
hud_elem_type = "image",
|
||||||
|
position = {x = 0, y = 1},
|
||||||
|
offset = {x = fu_gauge_x, y = fu_gauge_y},
|
||||||
|
text = "airutils_ind_box.png",
|
||||||
|
scale = { x = 6, y = 6},
|
||||||
|
alignment = { x = 1, y = 0 },
|
||||||
|
})
|
||||||
|
ids["fu_pt_4"] = player:hud_add({
|
||||||
|
hud_elem_type = "image",
|
||||||
|
position = {x = 0, y = 1},
|
||||||
|
offset = {x = fu_gauge_x, y = fu_gauge_y},
|
||||||
|
text = "airutils_ind_box.png",
|
||||||
|
scale = { x = 6, y = 6},
|
||||||
|
alignment = { x = 1, y = 0 },
|
||||||
|
})
|
||||||
|
ids["fu_pt_5"] = player:hud_add({
|
||||||
|
hud_elem_type = "image",
|
||||||
|
position = {x = 0, y = 1},
|
||||||
|
offset = {x = fu_gauge_x, y = fu_gauge_y},
|
||||||
|
text = "airutils_ind_box.png",
|
||||||
|
scale = { x = 6, y = 6},
|
||||||
|
alignment = { x = 1, y = 0 },
|
||||||
|
})
|
||||||
|
ids["fu_pt_6"] = player:hud_add({
|
||||||
|
hud_elem_type = "image",
|
||||||
|
position = {x = 0, y = 1},
|
||||||
|
offset = {x = fu_gauge_x, y = fu_gauge_y},
|
||||||
|
text = "airutils_ind_box.png",
|
||||||
|
scale = { x = 6, y = 6},
|
||||||
|
alignment = { x = 1, y = 0 },
|
||||||
|
})
|
||||||
|
ids["fu_pt_7"] = player:hud_add({
|
||||||
|
hud_elem_type = "image",
|
||||||
|
position = {x = 0, y = 1},
|
||||||
|
offset = {x = fu_gauge_x, y = fu_gauge_y},
|
||||||
|
text = "airutils_ind_box.png",
|
||||||
|
scale = { x = 6, y = 6},
|
||||||
|
alignment = { x = 1, y = 0 },
|
||||||
|
})
|
||||||
|
|
||||||
airutils.hud_list[player_name] = ids
|
airutils.hud_list[player_name] = ids
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -209,6 +333,20 @@ function airutils.remove_hud(player)
|
||||||
player:hud_remove(ids["sp_pt_3"])
|
player:hud_remove(ids["sp_pt_3"])
|
||||||
player:hud_remove(ids["sp_pt_2"])
|
player:hud_remove(ids["sp_pt_2"])
|
||||||
player:hud_remove(ids["sp_pt_1"])
|
player:hud_remove(ids["sp_pt_1"])
|
||||||
|
player:hud_remove(ids["pwr_pt_7"])
|
||||||
|
player:hud_remove(ids["pwr_pt_6"])
|
||||||
|
player:hud_remove(ids["pwr_pt_5"])
|
||||||
|
player:hud_remove(ids["pwr_pt_4"])
|
||||||
|
player:hud_remove(ids["pwr_pt_3"])
|
||||||
|
player:hud_remove(ids["pwr_pt_2"])
|
||||||
|
player:hud_remove(ids["pwr_pt_1"])
|
||||||
|
player:hud_remove(ids["fu_pt_7"])
|
||||||
|
player:hud_remove(ids["fu_pt_6"])
|
||||||
|
player:hud_remove(ids["fu_pt_5"])
|
||||||
|
player:hud_remove(ids["fu_pt_4"])
|
||||||
|
player:hud_remove(ids["fu_pt_3"])
|
||||||
|
player:hud_remove(ids["fu_pt_2"])
|
||||||
|
player:hud_remove(ids["fu_pt_1"])
|
||||||
end
|
end
|
||||||
airutils.hud_list[player_name] = nil
|
airutils.hud_list[player_name] = nil
|
||||||
end
|
end
|
||||||
|
|
BIN
textures/airutils_hud_panel.png
Executable file → Normal file
BIN
textures/airutils_hud_panel.png
Executable file → Normal file
Binary file not shown.
Before Width: | Height: | Size: 22 KiB After Width: | Height: | Size: 35 KiB |
Loading…
Add table
Reference in a new issue