# Duane's Dungeon - a rogue-like game # Copyright (C) 2023 Duane Robertson # global.gd - global work-around # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # You should have received a copy of the GNU General Public License # along with this program. If not, see . extends Node2D const TXT_COL = false var font:FontFile var game:Node2D var sprite_sheet:SpriteSheet var t_escape = PackedByteArray([0x1b]).get_string_from_ascii() var t_normal = t_escape + '[0m' func _ready(): font = load('res://art/DejaVuSans.ttf') func debug(msg): if TXT_COL: var color = t_escape + '[90m' print(color, msg, t_normal) else: print(msg) func warn(msg): if TXT_COL: var color = t_escape + '[93m' print(color, msg, t_normal) else: print(msg) func error(msg): if TXT_COL: var color = t_escape + '[91m' print(color, msg, t_normal) else: print(msg) var watches = [] func stopwatch(msg := '', stop := false): var t2 = Time.get_ticks_msec() var t1 = watches[-1] if not watches.is_empty() else t2 if msg: debug('%s: %dms' % [msg, t2 - t1]) watches[-1] = t2 else: watches.push_back(t2) if stop: watches.pop_back()