package gui

import "../core"

bubble_type_name :: proc(t: core.Bubble_Type) -> string {
	switch t {
	case .Normal: return "Normal"
	case .Thought: return "Thought"
	case .Shout: return "Shout"
	case .Whisper: return "Whisper"
	case .Narration: return "Narration"
	case .Sound_Effect: return "SFX"
	}
	return "Normal"
}

bubble_type_from_name :: proc(name: string) -> core.Bubble_Type {
	switch name {
	case "Normal": return .Normal
	case "Thought": return .Thought
	case "Shout": return .Shout
	case "Whisper": return .Whisper
	case "Narration": return .Narration
	case "SFX": return .Sound_Effect
	}
	return .Normal
}

clamp_bubble_cursor :: proc(count, cursor: int) -> int {
	if count <= 0 {
		return 0
	}
	if cursor < 0 {
		return 0
	}
	if cursor >= count {
		return count - 1
	}
	return cursor
}

count_bubbles_for_panel :: proc(bubbles: map[string][]core.Speech_Bubble, panel_id: string) -> int {
	if bubbles == nil {
		return 0
	}
	if slice, ok := bubbles[panel_id]; ok {
		return len(slice)
	}
	return 0
}

collect_layout_panels_for_page :: proc(layouts: []core.Page_Layout, page_cursor: int) -> []core.Page_Layout_Panel {
	if len(layouts) == 0 || page_cursor < 0 || page_cursor >= len(layouts) {
		return nil
	}
	return layouts[page_cursor].panels[:]
}