-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPrinter.gd
More file actions
37 lines (28 loc) · 901 Bytes
/
Printer.gd
File metadata and controls
37 lines (28 loc) · 901 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
extends Control
var _messages: PoolStringArray = []
var _screen_messages = []
func _ready():
_clear_prints()
func add_print(msg: String) -> void:
_messages.push_back(msg)
update()
func add_print_screen(msg: String, pos: Vector2) -> void:
_screen_messages.push_back({position = pos, message = msg})
update()
func _clear_prints() -> void:
_messages.resize(0)
_screen_messages.resize(0)
func _draw() -> void:
var y: float = 0.0 # relative to rect
var x: float = 0.0 # ^^
var font: Font = get_font("")
var line_height: float = font.get_height()
# print normal messages in single block
for msg in _messages:
draw_string(font, Vector2(x,y), msg, Color(1.0,1.0,1.0,0.5))
y += line_height
# draw positioned prints
for scr_msg in _screen_messages:
draw_string(font, scr_msg.position, scr_msg.message, Color(1.0,1.0,1.0,0.5))
# current state drawn, clear arrays
_clear_prints()