Skada 修改數值單位 & DPS統計移除小數點 for 1.4-10

最新版的Skada有修正一些東西,舊的改法不能用了,一樣是改Skada:FormatNumber(number)這個函式,改法如下,主要是最後return內容不一樣:

function Skada:FormatNumber(number)
	if number then
		if self.db.profile.numberformat == 1 then
			if number > 100000000 then
				return 	("%02.2f億"):format(number / 100000000)
			elseif number > 1000000 then
				return		("%d萬"):format(number / 10000)
			elseif number > 100000 then
				return		("%02.1f萬"):format(number / 10000)
			elseif number > 10000 then
				return ("%02.2f萬"):format(number / 10000)
			else
				return math.floor(number)
			end
		else
			return math.floor(number)
		end
	end
end

另外Skada的DPS統計值會有小數,個人覺得那小數點佔空間又沒啥意思也一併改掉。
主要會修改的檔案有Damage.lua、DamageTaken.lua和Healing.lua這三個檔案,找到類似下面內容的函式,

d.valuetext = Skada:FormatValueText(
								Skada:FormatNumber(totalhealing), self.metadata.columns.Healing,
								string.format("%02.1f", getHPSByValue(set, player, totalhealing)), self.metadata.columns.HPS,
								string.format("%02.1f%%", totalhealing / set.healing * 100), self.metadata.columns.Percent
				)

可以直接用 %02.1f 當關鍵字快速出來。但不要為了求方便把所有的 %02.1f 換成 %d ,反而會造成問題:

d.valuetext = Skada:FormatValueText(
								Skada:FormatNumber(totalhealing), self.metadata.columns.Healing,
								string.format("%d", getHPSByValue(set, player, totalhealing)), self.metadata.columns.HPS,
								string.format("%02.1f%%", totalhealing / set.healing * 100), self.metadata.columns.Percent
				)

還有在Tooltip顯示的DPS值也要一起改,在Damage.lua,如下所示在248行將數值型態改為%d:

-- Tooltip for a specific player.
local function dps_tooltip(win, id, label, tooltip)
	local set = win:get_selected_set()
	local player = Skada:find_player(set, id)
	if player then

		local activetime = Skada:PlayerActiveTime(set, player)
		local totaltime = Skada:GetSetTime(set)
		tooltip:AddLine(player.name.." - "..L["DPS"])
		tooltip:AddDoubleLine(L["Segment time"], totaltime.."s", 255,255,255,255,255,255)
		tooltip:AddDoubleLine(L["Active time"], activetime.."s", 255,255,255,255,255,255)
		tooltip:AddDoubleLine(L["Damage done"], Skada:FormatNumber(player.damage), 255,255,255,255,255,255)
		tooltip:AddDoubleLine(Skada:FormatNumber(player.damage) .. " / " .. activetime .. ":", ("%d"):format(player.damage / math.max(1,activetime)), 255,255,255,255,255,255)

	end
end

還有這裡,還459行:

-- DPS-only view
function dpsmod:GetSetSummary(set)
	return Skada:FormatNumber(getRaidDPS(set))
end

function dpsmod:Update(win, set)
	local max = 0
	local nr = 1

	for i, player in ipairs(set.players) do
		local dps = getDPS(set, player)

		if dps > 0 then
			local d = win.dataset[nr] or {}
			win.dataset[nr] = d
			d.label = player.name
			d.id = player.id
			d.value = dps
			d.class = player.class
			d.valuetext = ("%d"):format(dps)
			if dps > max then
				max = dps
			end

			nr = nr + 1
		end
	end

	win.metadata.maxvalue = max
end

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *

這個網站採用 Akismet 服務減少垃圾留言。進一步了解 Akismet 如何處理網站訪客的留言資料