Files
Diabolo/tools/implement_v16.py

52 lines
4.1 KiB
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
from pathlib import Path
root=Path(__file__).resolve().parent.parent/'Demon_v0.16'
p=root/'workshop.gd';s=p.read_text(encoding='utf-8-sig')
s=s.replace('var dialogue_clock=6.0','const DIALOGUE_INTERVAL=30.0\nconst HERO_INTERVAL=100.0\nvar dialogue_clock=0.0')
s=s.replace('var build_button: Button','var build_button: Button\nvar grimoire_button: Button\nvar buy_labels=[]')
s=s.replace('g.development.action_bar.hide()','g.development.action_bar.hide()\n\tg.development.action_bar.reparent(g.ui_compat)\n\tg.development.tree_icon.reparent(g.ui_compat)')
start=s.index('func make_ui():');end=s.index('\tcatalogue=make_panel(',start)
s=s[:start]+'''func icon_button(kind,tooltip,pos,callback):
var b=action(g.hud,"",callback);b.custom_minimum_size=Vector2(64,64);b.size=Vector2(64,64);b.position=pos
b.tooltip_text=tooltip;b.toggle_mode=true;b.focus_mode=Control.FOCUS_NONE
b.add_theme_stylebox_override("pressed",style(Color("3b2d3e"),Color("d5b878")))
var icon=Icon.new();icon.kind=kind;b.add_child(icon);icon.set_anchors_and_offsets_preset(Control.PRESET_FULL_RECT)
icon.offset_left=9;icon.offset_top=9;icon.offset_right=-9;icon.offset_bottom=-9
return b
func make_ui():
shade=ColorRect.new();g.hud.add_child(shade);shade.set_anchors_and_offsets_preset(Control.PRESET_FULL_RECT)
shade.color=Color(0.08,0,0.025,0);shade.mouse_filter=Control.MOUSE_FILTER_IGNORE;shade.z_index=-3
panel=PanelContainer.new();g.ui_compat.add_child(panel)
var hidden=VBoxContainer.new();panel.add_child(hidden)
info=text(hidden,"");timer_label=text(hidden,"");pressure=text(hidden,"")
help_primary=text(hidden,"");help_secondary=text(hidden,"");notice=text(hidden,"")
build_button=icon_button("build","Строительство [B]",Vector2(1432,812),toggle_build)
build_button.name="BuildIconButton"
grimoire_button=icon_button("book","Гримуар [T]",Vector2(1512,812),toggle_tree)
grimoire_button.name="GrimoireIconButton"
var v: VBoxContainer
var row: HBoxContainer
''' +s[end:]
old=''' for i in range(TITLES.size()):
buy_buttons.append(action(v,"",func():begin_purchase(i)))'''
new=''' for i in range(TITLES.size()):
var b=action(v,"",func():begin_purchase(i));buy_buttons.append(b)
var margin=MarginContainer.new();b.add_child(margin);margin.set_anchors_and_offsets_preset(Control.PRESET_FULL_RECT);margin.mouse_filter=Control.MOUSE_FILTER_IGNORE
for side in ["left","right"]:margin.add_theme_constant_override("margin_"+side,12)
for side in ["top","bottom"]:margin.add_theme_constant_override("margin_"+side,6)
var entry=HBoxContainer.new();margin.add_child(entry);entry.mouse_filter=Control.MOUSE_FILTER_IGNORE;entry.add_theme_constant_override("separation",12)
var icon=Icon.new();icon.kind=Icon.APPARATUS[i];icon.custom_minimum_size=Vector2(40,40);entry.add_child(icon)
var l=text(entry,"",16);l.mouse_filter=Control.MOUSE_FILTER_IGNORE;buy_labels.append(l)'''
assert old in s;s=s.replace(old,new)
s=s.replace('v=VBoxContainer.new();context.add_child(v);context_title=text(v,"",19,Color("e1bd82"))','v=VBoxContainer.new();context.add_child(v);context_title=text(v,"",19,Color("e1bd82"))')
s=s.replace('g.hud.add_child(bar);','g.ui_compat.add_child(bar);')
s=s.replace('dialogue_clock=6;dialogue_turn=0','dialogue_clock=0;dialogue_turn=0')
s=s.replace('buy_buttons[i].text="%s · %d золота · %d×%d%s"','buy_labels[i].text="%s\\n%d золота · %d×%d%s"')
s=s.replace('build_button.text="Завершить [B]" if build_mode else "Строительство [B]"','build_button.text="";build_button.set_pressed_no_signal(build_mode)\n\tgrimoire_button.text="";grimoire_button.set_pressed_no_signal(tree.visible)')
s=s.replace('if override_text.is_empty() and dialogue_clock<2:return','if dialogue_clock<DIALOGUE_INTERVAL:return')
s=s.replace('if dialogue_clock<6:return','if dialogue_clock<DIALOGUE_INTERVAL:return')
s=s.replace('if g.talk_clock>20:','if g.talk_clock>HERO_INTERVAL:')
s=s.replace('\tif g.paused:return\n\tif is_instance_valid(g.development.bubble):','\tsentences.update_icons()\n\tif g.paused:return\n\tif is_instance_valid(g.development.bubble):')
p.write_text(s,encoding='utf-8')
print('Minimal HUD and 5x dialogue throttling applied')