Randoloot/tmp/update_ring.cjs
2026-10-19 22:33:24 +02:00

30 lines
2.3 KiB
JavaScript

const fs=require('fs');const p='scripts/ui/ship_profile.gd';let s=fs.readFileSync(p,'utf8').replace(/\r\n/g,'\n');
s=s.replace('var _ship_name := ""\n','').replace('\t_ship_name = ship["name"]\n','');
s=s.replace('ship_status_frame.png','ship_ring_bars.png').replace(/\t# Exclude[^\n]*\n\t_frame_region = Rect2\(12, 90, 2170, 534\)/,'\t_frame_region = Rect2(Vector2.ZERO, _frame_texture.get_size())');
const start=s.indexOf('\tvar accent :=',s.indexOf('func _draw()'));const end=s.indexOf('\nfunc _bar(',start);
s=s.slice(0,start)+`\tvar portrait := Vector2(185, 35.5)
\tdraw_circle(portrait, 26, Color("0a141b66"))
\tif _texture != null:
\t\tvar dimensions := _texture.get_size()
\t\tvar extent := dimensions * (44.0 / maxf(dimensions.x, dimensions.y))
\t\tdraw_texture_rect(_texture, Rect2(portrait - extent * 0.5, extent), false)
\t_bar(Rect2(12, 15, 126, 7), player.hull, player.max_hull, _display.x, Color("e88972"), "KADŁUB")
\t_bar(Rect2(12, 32, 126, 7), player.shields, player.max_shields, _display.y, Color("79bde5"), "TARCZE")
\t_bar(Rect2(12, 49, 126, 7), player.energy, player.max_energy, _display.z, Color("87cfb1"), "ENERGIA")
\tif _frame_texture != null:
\t\tdraw_texture_rect_region(_frame_texture, Rect2(Vector2.ZERO, size), _frame_region, Color(1, 1, 1, 1.0 if is_hovered() else 0.88))
\t_bar_caption(Vector2(13, 21), player.hull, player.max_hull, "KADŁUB")
\t_bar_caption(Vector2(13, 38), player.shields, player.max_shields, "TARCZE")
\t_bar_caption(Vector2(13, 55), player.energy, player.max_energy, "ENERGIA")
func _bar_caption(point: Vector2, value: float, maximum: float, caption: String) -> void:
\tvar font := ThemeDB.fallback_font
\tvar values := "%.0f / %.0f" % [value, maximum]
\tdraw_string_outline(font, point, caption, HORIZONTAL_ALIGNMENT_LEFT, 58, 7, 2, Color("071117"))
\tdraw_string_outline(font, point, values, HORIZONTAL_ALIGNMENT_RIGHT, 123, 7, 2, Color("071117"))
\tdraw_string(font, point, caption, HORIZONTAL_ALIGNMENT_LEFT, 58, 7, TEXT)
\tdraw_string(font, point, values, HORIZONTAL_ALIGNMENT_RIGHT, 123, 7, TEXT)
`+s.slice(end);
s=s.replace(/\tvar font := ThemeDB.fallback_font\n\tdraw_string\(font, rect.position[^\n]*\n\tdraw_string\(font, rect.position[^\n]*\n/,'');
s=s.replace('color: Color, caption: String) -> void:', 'color: Color, _caption: String) -> void:');fs.writeFileSync(p,s);