---------------------------------------------------- -- SamUI v0.3.3 -- Eine vollständige UI-Alternative -- WoW Classic Anniversary TBC -- Interface 20506 -- Build 69110 ---------------------------------------------------- local _, ns = ... local module = ns:new_module("palette") local palette_definitions = { samui = { colors = { ink = { r = 0.00, g = 0.00, b = 0.00, hex = "000000" }, bg_deep = { r = 0.05, g = 0.05, b = 0.05, hex = "0d0d0d" }, bg_base = { r = 0.10, g = 0.10, b = 0.10, hex = "1a1a1a" }, bg_bar = { r = 0.20, g = 0.20, b = 0.20, hex = "333333" }, border_soft = { r = 0.20, g = 0.20, b = 0.20, hex = "333333" }, border = { r = 0.30, g = 0.30, b = 0.30, hex = "4d4d4d" }, tint_neutral = { r = 0.78, g = 0.78, b = 0.78, hex = "c7c7c7" }, text_muted = { r = 0.62, g = 0.62, b = 0.62, hex = "9e9e9e" }, text = { r = 1.00, g = 1.00, b = 1.00, hex = "ffffff" }, gold = { r = 1.00, g = 0.82, b = 0.00, hex = "ffd100" }, orange = { r = 1.00, g = 0.50, b = 0.00, hex = "ff8000" }, red = { r = 0.90, g = 0.20, b = 0.20, hex = "e63333" }, green = { r = 0.20, g = 0.85, b = 0.20, hex = "33d933" }, blue = { r = 0.00, g = 0.44, b = 0.87, hex = "0070de" }, cyan = { r = 0.00, g = 0.80, b = 1.00, hex = "00ccff" }, teal = { r = 0.00, g = 0.80, b = 0.60, hex = "00cc99" }, purple = { r = 0.35, g = 0.27, b = 0.50, hex = "5a4680" }, quest = { r = 0.78, g = 0.62, b = 0.16, hex = "c79e28" }, copper = { r = 0.93, g = 0.65, b = 0.37, hex = "eda55f" }, }, alphas = { opaque = 1.00, panel = 0.70, bag_panel = 0.80, panel_pane = 0.50, hairline = 0.65, bar = 0.70, button = 0.70, slot = 0.20, special_slot = 0.20, dimmer = 0.78, out_of_range = 0.26, rested_xp = 0.25, }, }, } local surface_schema = { unit_bar = { color = "bg_bar", alpha = "bar" }, panel = { color = "bg_base", alpha = "panel" }, bag_panel = { color = "bg_base", alpha = "bag_panel" }, panel_solid = { color = "bg_base", alpha = "opaque" }, panel_pane = { color = "bg_base", alpha = "panel_pane" }, row = { color = "bg_deep", alpha = "panel" }, tooltip = { color = "bg_bar", alpha = "bar" }, slot = { color = "bg_bar", alpha = "slot" }, slot_special = { color = "green", alpha = "special_slot" }, button = { color = "bg_bar", alpha = "button" }, button_deep = { color = "bg_deep", alpha = "button" }, dimmer = { color = "ink", alpha = "dimmer" }, } local class_colors = { WARRIOR = { r = 0.78, g = 0.61, b = 0.43, a = 1.00 }, PALADIN = { r = 0.96, g = 0.55, b = 0.73, a = 1.00 }, HUNTER = { r = 0.67, g = 0.83, b = 0.45, a = 1.00 }, ROGUE = { r = 1.00, g = 0.96, b = 0.41, a = 1.00 }, PRIEST = { r = 1.00, g = 1.00, b = 1.00, a = 1.00 }, SHAMAN = { r = 0.00, g = 0.44, b = 0.87, a = 1.00 }, MAGE = { r = 0.41, g = 0.80, b = 0.94, a = 1.00 }, WARLOCK = { r = 0.58, g = 0.51, b = 0.79, a = 1.00 }, DRUID = { r = 1.00, g = 0.49, b = 0.04, a = 1.00 }, } local quality_colors = { [0] = { r = 0.616, g = 0.616, b = 0.616 }, [1] = { r = 1.000, g = 1.000, b = 1.000 }, [2] = { r = 0.118, g = 1.000, b = 0.000 }, [3] = { r = 0.000, g = 0.440, b = 0.870 }, [4] = { r = 0.640, g = 0.210, b = 0.930 }, [5] = { r = 1.000, g = 0.500, b = 0.000 }, [6] = { r = 0.900, g = 0.800, b = 0.500 }, [7] = { r = 0.000, g = 0.800, b = 1.000 }, } local callbacks = {} local active_palette_name = "samui" local function get_active_definition() return palette_definitions[active_palette_name] end function module:get(token) local definition = get_active_definition() return definition and definition.colors[token] or nil end function module:get_rgb(token) local color = self:get(token) if not color then return nil end return color.r, color.g, color.b end function module:get_rgba(token, alpha) local color = self:get(token) if not color then return nil end return color.r, color.g, color.b, alpha end function module:get_hex(token) local color = self:get(token) return color and color.hex or nil end function module:get_color_code(token) local hex = self:get_hex(token) return hex and "|cff" .. hex or nil end function module:wrap(token, text) local color_code = self:get_color_code(token) if not color_code then return text end return color_code .. tostring(text) .. "|r" end function module:get_alpha(key) local definition = get_active_definition() return definition and definition.alphas[key] or nil end function module:get_surface(name) local surface = surface_schema[name] if not surface then return nil end return self:get_rgba(surface.color, self:get_alpha(surface.alpha)) end function module:get_surface_color(name) local surface = surface_schema[name] if not surface then return nil end return self:get_rgb(surface.color) end function module:get_class_color(class) local color = class_colors[class] if not color then return nil end return color.r, color.g, color.b, color.a end function module:get_quality_color(quality) local color = quality_colors[quality] if not color then return nil end return color.r, color.g, color.b end function module:get_active() return active_palette_name end function module:set_active(name) if not palette_definitions[name] then return false end if active_palette_name == name then return true end active_palette_name = name for _, callback in pairs(callbacks) do callback(name) end return true end function module:register_callback(key, fn) if key == nil or type(fn) ~= "function" then return false end callbacks[key] = fn return true end function module:initialize() end ns.palette = module ns:register_initial_module("palette")