Condemned

Help with colors on LogToChat

5 posts in this topic

I want to add a different color to the LogToChat(message, color, toWW) but I don't know what colors I can use or how to type the actual color in. Is there a way to use these Globals?

Global("tierColors", {
	 ["White"] = {a = 1, r = 0.86274516582489, g = 0.86274516582489, b = 0.86274516582489 },
	 ["Green"] = {a = 1, r = 0, g = 0.89803928136826, b = 0.14901961386204 },
	 ["Blue"] = {a = 1, r = 0.12549020349979, g = 0.50196081399918, b = 1 },
	 ["Epic"] = {a = 1, r = 0.75294125080109, g = 0.25098040699959, b = 1 },
	 ["Legendary"] = {a = 1, r = 1, g = 0.50196081399918, b = 0 },
	 ["Mythical"] = {a = 1, r = 0, g = 1, b = 0.58823531866074 },
	 ["Relic"] = {a = 1, r = 0.87843143939972, g = 1, b = 0.25098040699959 }
	 }
)

If so how do I use them I try with LogToChat("Message", tierColors['Relic']) and it doens't work. If this doesn't work how do I change colors for LogToChat?

Share this post


Link to post
Share on other sites

It's the logToChatLib.lua a library file that is in the documents I think or I got it from another addon can't remember.

 

local valuedText = common.CreateValuedText()
local formatVT = "<html fontname='AllodsSystem' shadow='1'><rs class='color'><r name='addon'/><r name='text'/></rs></html>"
valuedText:SetFormat(userMods.ToWString(formatVT))
local ADDONname = common.GetAddonName()
------------------------------------------------------------------
------ Loging To Chat
------------------------------------------------------------------
---- output in Chat. created by icreator(EDS) 2011/01/23
--- initial ref
--- Chat...Chat
local wtChat
local chatRows = 0 --- for clear buffer after show messages

--- ����� ���� ���������� ����
--- ������ ��������� ���� � ������� ��� ����
function GetSysChatContainer()
	--- ������ ���� ����
	--- Chat..Chat
	---local w = getNamedChild(stateMainForm, "Chat", false)
	local parents = 2
	local w = stateMainForm:GetChildUnchecked("Chat", false)
	if not w then
		--- ������ ����� �� ������� - ������ �� �������
		w = stateMainForm:GetChildUnchecked("Chat", true)
	else
		w = w:GetChildUnchecked("Chat", true)
	end
	if not w then ---- 2.0.06.13 [26.05.2011] 
		w = stateMainForm:GetChildUnchecked("ChatLog", false)
		---getAllChildrensOfWidget("ChatLog",w, "PushBack")
		w = w:GetChildUnchecked("Container", true)
		if w then parents = 3 end
	end
	
	return w, wtGetNumParents(w, parents)
end

function LogToChatVT(valuedText, name, toWW)
--- ����� � ��� ValuedText
	name = name or ADDONname
	--- ������� � WhisperWindow
	if toWW then LogToChatWWVT(valuedText, name) end
	--- � ��������� ������� � ��������� ���
	if not wtChat then wtChat = GetSysChatContainer() end
	if wtChat and wtChat.PushFrontValuedText then
		--- �������� ��� 1 ������� � ��������� ��� ��������
		chatRows =  chatRows + 1
		valuedText:SetVal( "addon", userMods.ToWString(name..": ") )
		wtChat:PushFrontValuedText( valuedText )
	end
end
function LogToChatWWVT(valuedText, name)

	local sender = name or ADDONname --- object.GetName(avatar.GetId())
	if not common.IsWString(sender) then sender = userMods.ToWString(sender) end
	local senderId = avatar.IsExist() and avatar.GetId()
	local chatType = CHAT_TYPE_NOTICE --- -1 ---CHAT_TYPE_NOTICE ---CHAT_TYPE_WHISPER --- = -1 --- �� �������
	local recipient = sender
	userMods.SendEvent("EVENT_CHAT_MESSAGE_WITH_OBJECTS", { msg = valuedText, chatType = chatType, sender = sender, isEcho=true, isAlive=true, recipient = recipient, senderId = senderId})

end

--[[ semd message to chat and WishperWindow chat
 message , color,
 toWW = true|false|nil
]]
function LogToChat(message, color, toWW)
	local valuedText = common.CreateValuedText()
	valuedText:SetFormat(userMods.ToWString(formatVT))
	valuedText:ClearValues() --- ����������� �������
	valuedText:SetClassVal( "color", color or "LogColorYellow" )
	if not common.IsWString( message ) then	message = userMods.ToWString(message) end
	valuedText:SetVal( "text", message )
	LogToChatVT(valuedText, ADDONname, toWW)

end
--- call by "EVENT_SECOND_TIMER" - for clear messages from chat
function ClearChat( size )
--- ������� ���������� �� ���������� ���� ����� - ����� �� �� ������������
-- � �� �������� �����
	if chatRows < 1 then return end
	if wtChat then
		for _=1, size or math.ceil( chatRows / 30 ) + 1 do
			if chatRows < 1 then return end
			chatRows = chatRows - 1
			wtChat:PopBack()
		end
	else
		wtChat = GetSysChatContainer()
	end
end
------------------------------------------------------------------------------------

--- Log error mess to Chat
function ErrToChat(mess)
	LogToChat("ERROR: "..mess, "LogColorRed", 18)
end


function getAllChildrensOfWidget(tab,widget, metod)
	local childrens = widget:GetNamedChildren()
	for _, w in childrens do
		local tab1 = tab .. ":" .. w:GetName()
		if metod and w[metod] then tab1 = tab1 .. " proc.".. metod end
		LogInfo (tab1)
		getAllChildrensOfWidget(tab1,w)
	end
end

function testAllMainForms()
	local childrens = stateMainForm:GetNamedChildren()
	for _, w in childrens do
		if string.lower(w:GetName()) == "mainform" then getAllChildrensOfWidget("+",w) end
	end
end

function getNamedChild( w, name, recursive )
	local ch = w:GetChildUnchecked(name, recursive )
	if ch then
		return ch
	else
		LogInfo(" ERROR: can't find widget \"", name,"\" in parent \"", w:GetName(), "\"" )
		LogInfo( w:GetName(), " childs:" )
		for _, ww in w:GetNamedChildren() do
			LogInfo (ww:GetName())
		end
	end
end

wtGetAllParents = function(w)
	if w.GetParent then
		local pr = w:GetParent()
		if pr then
			return wtGetAllParents(pr)..":"..w:GetName()
		end
	end
	if w.GetName then return w:GetName() end
	return ""

end

--- ���������� �������� ���� �� �����
wtGetNumParents = function(w, parents)
	if parents > 0 and w.GetParent then
		local pr = w:GetParent()
		---LogInfo( pr:GetName() )
		if pr then
			return wtGetNumParents(pr, parents-1)
		end
	end
	return w
end

 

Share this post


Link to post
Share on other sites
Guest СладкийПирожок

Не проще ли использовать просто функцию:

local wtChat = nil
local valuedText = common.CreateValuedText()
function LogToChat(text)
	if not wtChat then ---- 2.0.06.13 [26.05.2011]
		wtChat = stateMainForm:GetChildUnchecked("ChatLog", false)
		wtChat = wtChat:GetChildUnchecked("Container", true)
		local formatVT = "<html fontname='AllodsFantasy' fontsize='14' shadow='1'><rs class='color'><r name='addon'/><r name='text'/></rs></html>"
		valuedText:SetFormat(userMods.ToWString(formatVT))
	end
	if wtChat and wtChat.PushFrontValuedText then
		if not common.IsWString(text) then text = userMods.ToWString(text) end
		valuedText:ClearValues()
		valuedText:SetClassVal( "color", "LogColorYellow" )
		valuedText:SetVal( "text", text )
		valuedText:SetVal( "addon", userMods.ToWString(common.GetAddonName) )
		wtChat:PushFrontValuedText( valuedText )
	end
end

чем цеплять целую библиотеку, которая по сути и не нужна? Цвет текста можно выбрать один из следующих(тег color):

"DamageVisDp"
"Quest"
"CombatCyan"
"StatControl"
"WarningLogOrange"
"StatAdditionalColor"
"WarningLogYellow"
"EditLineCenterSmall"
"SecretCompleteFormat"
"EditLineGlobal"
"tip_blue"
"WarningLogBlue"
"StatFairyBonus"
"DamageVisMiss"
"log_blue"
"DamageVisBuffGain"
"WarningLogRed"
"CombatRed"
"ColorWarmYellow"
"DamageVisExpGain"
"LogColorBlue"
"CombatBlue"
"EditLineSelectionCenterSmall"
"ColorWarmGreen"
"StatDebuffed"
"log_orange"
"log_yellow"
"calendar"
"StatUselessColor"
"ColorYellow"
"p2p"
"EpicCursed"
"QuestLogRed"
"tutorRed"
"LogColorLightRed"
"Label"
"tip_purple"
"YellowQuestName"
"IMPriceLocked"
"YellowQuestTimer"
"StatDefenceColor"
"ReputationEnemy"
"tutorGold"
"WarningLogWhite"
"CreditsText"
"Raid"
"SecretIncompleteFormat"
"RepConfidential"
"ColorDarkWarmGreen"
"RelicWithoutShadow"
"OutlineOnPaper"
"EditLineMoneyCountSelection"
"log_magenta"
"IMPrice"
"nav_avatar"
"body"
"ColorBlack"
"CombatLightYellow"
"DamageWhite"
"QuestLogGray"
"LabelCenterSmall8"
"DamageVisEnergyDrain"
"EditLinePageCountSelection"
"ColorWarmRed"
"GrayQuestName"
"LabelCenterGoldSmall"
"tip_red"
"log_violet"
"DamageYellow"
"WarningLogGreen"
"DamageVisMpDrain"
"CoinSettings"
"nav_enemy"
"SubscribeNormal"
"StatPrimaryColor"
"QuestLogNormal"
"p"
"tip_base"
"tip_white"
"ColorMagenta"
"DamageVisBarrier"
"Rare"
"DamageGreen"
"DamageVisReputationDrain"
"LogColorPink"
"DamageVisBlock"
"log_brown"
"Common"
"RepKindly"
"DamageRed"
"Legendary"
"tutorGrey"
"WhiteQuestName"
"ReputationNeutral"
"default"
"ColorCian"
"StatUseless"
"CreditsHeader"
"ListItemSelected"
"LogColorMagenta"
"QuestFailedOnPaper"
"OnPaper"
"LogColorBlack"
"LegendaryCursed"
"tip_green"
"Subtitle"
"tutorCian"
"log_white"
"SecretInProgressFormat"
"ColorWhite"
"LogColorLightGreen"
"LegendaryWithoutShadow"
"QuestLogGreen"
"DamageBlue"
"RelicCursed"
"TabNormal"
"Golden"
"LabelCenterRedSmall8"
"DamageVisHpDrain"
"DamageVisHpGain"
"tutorLink"
"ColorMidWarmGreen"
"LabelCenterSmall"
"QuestLogBlue"
"tip_golden"
"ReputationKindly"
"log_light_yellow"
"ColorBlue"
"Goods"
"DamageVisBarrierGain"
"LogColorBrown"
"log_green"
"ColorGreen"
"LogColorSlateBlue"
"f2p"
"AllodsSystem"
"SubscribeWarning"
"tutorBlue"
"EditLineOnPaper"
"Neutral"
"QuestProgressPercent"
"DamageVisCriticalDrain"
"alignRight"
"RepEnemy"
"EditLineGlobalCenter"
"GoodsCursed"
"LogColorWhite"
"CombatWhite"
"html"
"QuestCompleteOnPaper"
"br"
"PartyQuestName"
"AllodsFantasy"
"label"
"ColorLightBrown"
"bodysmall"
"alignJustify"
"HeaderOnPaper"
"RaidQuestName"
"tutorWhite"
"FullCollectionColor"
"DamageVisMpGain"
"Outline"
"navigator"
"DamageVisReputationGain"
"RedQuestTimer"
"LogColorGreen"
"CombatGreen"
"log"
"Aggressive"
"EditLineMailOnPaper"
"tip_button"
"Spouse"
"log_red"
"CommonCursed"
"tutorPurple"
"LogColorRed"
"EditLineSelection"
"StatAdditional"
"StatControlColor"
"log_dark_white"
"alignLeft"
"tutorGreen"
"StatBuffed"
"DamageVisParry"
"nav_friend"
"button"
"WhiteSubtask"
"EditLinePageCount"
"StatNormal"
"BlueQuestTimer"
"RepNeutral"
"LogColorOrange"
"IMPriceDisabled"
"LogColorYellow"
"StatDefence"
"GraySubtask"
"Relic"
"CollectionColor"
"log_dark_green"
"LogColorGold"
"ColorGray40"
"shortcut"
"disabled"
"ColorLightBeige"
"ColorGray50"
"Uncommon"
"Friendly"
"QuestLogOrange"
"ColorGray60"
"QuestLogYellow"
"DamageVisEnergyGain"
"nav_dead"
"DamageVisDodge"
"RedQuestName"
"DamageVisAbsorb"
"CombatOrange"
"TabSelected"
"Party"
"CombatYellow"
"Dead"
"RareCursed"
"RepFriendly"
"RepHostility"
"LabelCenterRedSmall"
"ReputationFriendly"
"tip_grey"
"ReputationHostility"
"LogColorViolet"
"RepUnfriendly"
"alignCenter"
"UncommonCursed"
"DamageVisResist"
"QuestProgressFullPercent"
"Size10"
"Size11"
"Avatar"
"Size12"
"Size13"
"Size14"
"ListItemNormal"
"ColorRed"
"Size20"
"Size15"
"Size16"
"header"
"highlighted"
"Size22"
"Size17"
"TabDisabled"
"Size18"
"CoinSettingsRed"
"Size24"
"ReputationConfidential"
"EditLineMoneyCount"
"JunkCursed"
"GreenQuestName"
"DarkGreenQuestName"
"StatPrimary"
"Epic"
"log_cyan"
"LogColorCian"
"ReputationUnfriendly"
"nav_neutral"
"Junk"

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now