56 lines
3.0 KiB
Python
56 lines
3.0 KiB
Python
from pathlib import Path
|
|
root=Path(__file__).resolve().parent.parent/'Demon_v0.16'
|
|
p=root/'judgement.gd';s=p.read_text(encoding='utf-8-sig')
|
|
start=s.index('func update_label(');end=s.index('\nfunc complete_stage(',start)
|
|
s=s[:start]+'''func update_label(s):
|
|
s.label.text="";s.label.hide()
|
|
if not s.has("task_badge") or not is_instance_valid(s.task_badge):
|
|
var badge=PanelContainer.new();g.hud.add_child(badge);badge.name="PunishmentIcons";badge.z_index=3
|
|
badge.mouse_filter=Control.MOUSE_FILTER_IGNORE
|
|
var style=StyleBoxFlat.new();style.bg_color=Color(.07,.055,.09,.90);style.border_color=Color("796749");style.set_border_width_all(1)
|
|
style.content_margin_left=3;style.content_margin_right=3;style.content_margin_top=3;style.content_margin_bottom=3
|
|
badge.add_theme_stylebox_override("panel",style)
|
|
var row=HBoxContainer.new();badge.add_child(row);row.mouse_filter=Control.MOUSE_FILTER_IGNORE;row.add_theme_constant_override("separation",3)
|
|
s["task_badge"]=badge;s["task_row"]=row;s["task_icon_nodes"]=[]
|
|
s.node.tree_exiting.connect(func():
|
|
if is_instance_valid(badge):badge.queue_free()
|
|
)
|
|
var rebuild=s.task_icon_nodes.size()!=s.required.size()
|
|
if not rebuild:
|
|
for i in range(s.required.size()):
|
|
if s.task_icon_nodes[i].kind!=w.Icon.APPARATUS[s.required[i]]:rebuild=true
|
|
if rebuild:
|
|
for icon in s.task_icon_nodes:s.task_row.remove_child(icon);icon.queue_free()
|
|
s.task_icon_nodes.clear()
|
|
for kind in s.required:
|
|
var icon=w.Icon.new();icon.kind=w.Icon.APPARATUS[kind];icon.custom_minimum_size=Vector2(24,24);s.task_row.add_child(icon)
|
|
s.task_icon_nodes.append(icon)
|
|
for i in range(s.required.size()):
|
|
var done=s.required[i] in s.served
|
|
s.task_icon_nodes[i].completed=done;s.task_icon_nodes[i].tint=Color("a1dfa9") if done else Color("ddbd7b")
|
|
|
|
func update_icons():
|
|
for s in g.souls:
|
|
if not s.has("task_badge") or not is_instance_valid(s.task_badge):continue
|
|
var show=not g.paused and not s.entering and not g.camera.is_position_behind(s.node.position)
|
|
s.task_badge.visible=show
|
|
if not show:continue
|
|
var size=s.task_badge.get_combined_minimum_size()
|
|
s.task_badge.size=size
|
|
var point=g.camera.unproject_position(s.node.position+Vector3(0,3.15,0))
|
|
s.task_badge.position=point-Vector2(size.x/2,size.y+5)
|
|
for i in range(s.required.size()):
|
|
var progress=-1.0
|
|
if s.state=="mounted" and s.assigned>=0 and s.assigned<w.stations.size():
|
|
var d=w.stations[s.assigned]
|
|
if d.selected==s.required[i] and not s.required[i] in s.served:progress=d.bar.value/100.0
|
|
if not is_equal_approx(s.task_icon_nodes[i].progress,progress):s.task_icon_nodes[i].progress=progress
|
|
''' + s[end:]
|
|
p.write_text(s,encoding='utf-8')
|
|
p=root/'workshop.gd';s=p.read_text(encoding='utf-8-sig')
|
|
s=s.replace('\tg.life.burn(soul);g.souls.remove_at(index)','\tif soul.has("task_badge"):soul.task_badge.hide()\n\tg.life.burn(soul);g.souls.remove_at(index)')
|
|
start=s.index('\tg.floating("+%d ЗОЛОТА');end=s.index('\n',start)
|
|
s=s[:start]+s[end:]
|
|
p.write_text(s,encoding='utf-8')
|
|
print('Shared punishment badges and progress rings implemented')
|