package gui

import "core:fmt"
import "../core"

collect_script_panels :: proc(script: core.Comic_Script) -> []core.Panel {
	out: [dynamic]core.Panel
	for p in script.pages {
		for pan in p.panels {
			append(&out, pan)
		}
	}
	return out[:]
}

count_script_panels :: proc(script: core.Comic_Script) -> int {
	count := 0
	for p in script.pages {
		count += len(p.panels)
	}
	return count
}

local_panel_id_by_index :: proc(i: int) -> string {
	switch i {
	case 0: return "panel_local_001"
	case 1: return "panel_local_002"
	case 2: return "panel_local_003"
	case 3: return "panel_local_004"
	case 4: return "panel_local_005"
	case 5: return "panel_local_006"
	}
	return fmt.tprintf("panel_local_overflow_%d", i)
}

append_char :: proc(dst: ^string, ch: rune) {
	dst^ = fmt.aprintf("%s%c", dst^, ch)
}

pop_char :: proc(dst: ^string) {
	if len(dst^) == 0 {
		return
	}
	dst^ = dst^[:len(dst^)-1]
}
