Import current DEMON v0.19 source, assets and development handoff
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
extends RefCounted
|
||||
var g
|
||||
var souls_enabled=false
|
||||
var player: AudioStreamPlayer
|
||||
var pending=[]
|
||||
var serial=0
|
||||
var last_kind=-1
|
||||
func setup(game):
|
||||
g=game;player=AudioStreamPlayer.new();g.add_child(player)
|
||||
player.finished.connect(next)
|
||||
func make_bubble(text,font_size=16):
|
||||
var panel=PanelContainer.new();g.hud.add_child(panel);panel.mouse_filter=Control.MOUSE_FILTER_IGNORE
|
||||
var style=preload("res://infernal_ui.gd").panel(true,16)
|
||||
for side in [SIDE_TOP,SIDE_BOTTOM]:
|
||||
style.set_texture_margin(side,14);style.set_content_margin(side,8)
|
||||
panel.add_theme_stylebox_override("panel",style)
|
||||
var line=g.label(text.replace("\n"," "),font_size,Color("252820"))
|
||||
line.autowrap_mode=TextServer.AUTOWRAP_OFF;line.vertical_alignment=VERTICAL_ALIGNMENT_CENTER
|
||||
line.mouse_filter=Control.MOUSE_FILTER_IGNORE;panel.add_child(line)
|
||||
panel.size=panel.get_combined_minimum_size()
|
||||
return panel
|
||||
func place_bubble(panel,point):
|
||||
panel.size=panel.get_combined_minimum_size()
|
||||
var viewport=g.get_viewport().get_visible_rect().size
|
||||
panel.position=Vector2(clampf(point.x-panel.size.x*.5,10,maxf(10,viewport.x-panel.size.x-10)),clampf(point.y-panel.size.y-12,10,maxf(10,viewport.y-panel.size.y-10)))
|
||||
func speak(kind):
|
||||
if kind<10 and not souls_enabled:return
|
||||
if g.paused or not g.game_started:return
|
||||
if pending.size()>1:pending.pop_front()
|
||||
pending.append(kind)
|
||||
if not player.playing:next()
|
||||
func next():
|
||||
if pending.is_empty():return
|
||||
last_kind=pending.pop_front()
|
||||
player.stream=load("res://audio/dialogue/voice_%02d_%d.ogg" % [last_kind,serial%2]);serial+=1
|
||||
if not g.test_mode and not g.capture_mode and not g.muted and g.voice_volume>0:player.play()
|
||||
func stop():
|
||||
pending.clear();player.stop()
|
||||
func update():
|
||||
player.volume_db=-10.0+linear_to_db(maxf(g.voice_volume,.0001))
|
||||
player.stream_paused=g.paused
|
||||
Reference in New Issue
Block a user