<commit_before>---------------------------------------------------
-- @Author: <NAME> (<EMAIL>)
-- @Date:   2018-03-19 10:36:40
-- @Last Modified by:   <NAME> (<EMAIL>)
-- @Last Modified time: 2018-03-29 16:18:05
---------------------------------------------------
-----------------------------------------------------------------------------------------
-- these global functions are accessed all the time by the event handler
-- so caching them is worth the effort
-----------------------------------------------------------------------------------------
local setmetatable = setmetatable
local ipairs, pairs, next, pcall = ipairs, pairs, next, pcall
local sub, len, format, rep = string.sub, string.len, string.format, string.rep
local find, byte, char, gsub = string.find, string.byte, string.char, string.gsub
local type, tonumber, tostring = type, tonumber, tostring
local floor, min, max, ceil = math.floor, math.min, math.max, math.ceil
local huge, pi, sin, cos, tan = math.huge, math.pi, math.sin, math.cos, math.tan
local insert, remove, concat, sort = table.insert, table.remove, table.concat, table.sort
local pack, unpack = table.pack or function(...) return {...} end, table.unpack or unpack
-- jx3 apis caching
local wsub, wlen, wfind = wstring.sub, wstring.len, wstring.find
local GetTime, GetLogicFrameCount = GetTime, GetLogicFrameCount
local GetClientPlayer, GetPlayer, GetNpc = GetClientPlayer, GetPlayer, GetNpc
local GetClientTeam, UI_GetClientPlayerID = GetClientTeam, UI_GetClientPlayerID
local IsNil, IsNumber, IsFunction = MY.IsNil, MY.IsNumber, MY.IsFunction
local IsBoolean, IsString, IsTable = MY.IsBoolean, MY.IsString, MY.IsTable
-----------------------------------------------------------------------------------------
local Config = MY_LifeBar_Config
if not Config then
    return
end

local D = {
	Reset = MY_LifeBar.Reset,
	IsEnabled = MY_LifeBar.IsEnabled,
	IsShielded = MY_LifeBar.IsShielded,
}
local _L = MY.LoadLangPack(MY.GetAddonInfo().szRoot .. "MY_LifeBar/lang/")

local PS = {}
local function LoadUI(ui)
	ui:children("#WndSliderBox_LifeBarWidth"):value(Config.nLifeWidth)
	ui:children("#WndSliderBox_LifeBarHeight"):value(Config.nLifeHeight)
	ui:children("#WndSliderBox_LifeBarOffsetX"):value(Config.nLifeOffsetX)
	ui:children("#WndSliderBox_LifeBarOffsetY"):value(Config.nLifeOffsetY)
	ui:children("#WndSliderBox_TextOffsetY"):value(Config.nTextOffsetY)
	ui:children("#WndSliderBox_TextLineHeight"):value(Config.nTextLineHeight)
	ui:children("#WndSliderBox_LifePerOffsetX"):value(Config.nLifePerOffsetX)
	ui:children("#WndSliderBox_LifePerOffsetY"):value(Config.nLifePerOffsetY)
	ui:children("#WndSliderBox_Distance"):value(math.sqrt(Config.nDistance) / 64)
	ui:children("#WndSliderBox_Alpha"):value(Config.nAlpha)
	ui:children("#WndCheckBox_ShowSpecialNpc"):check(Config.bShowSpecialNpc)
	ui:children("#WndButton_Font"):text(_L("Font: %d", Config.nFont))
end
function PS.OnPanelActive(wnd)
	local ui = MY.UI(wnd)
	local w, h = ui:size()

	local x, y = 10, 10
	local offsety = 40
	-- 
	ui:append("WndCheckBox", {
		x = x, y = y, text = _L["Enable"],
		checked = MY_LifeBar.bEnabled,
		oncheck = function(bChecked)
			MY_LifeBar.bEnabled = bChecked
			D.Reset(true)
		end,
		tip = function()
			if D.IsShielded() then
				return _L['Can not use in pubg map!']
			end
		end,
		autoenable = function() return not D.IsShielded() end,
	})
	x = x + 80
	-- ļ
	ui:append("WndEditBox", {
		x = x, y = y, w = 200, h = 25,
		placeholder = _L['Configure name'],
		text = MY_LifeBar.szConfig,
		onblur = function()
			local szConfig = XGUI(this):text():gsub("%s", "")
			if szConfig == "" then
				return
			end
			Config("load", szConfig)
			LoadUI(ui)
			D.Reset()
		end,
		autoenable = function() return D.IsEnabled() end,
	})
	x = x + 220
	ui:append("Text", {
		x = x + 5, y = y - 15,
		text = _L['only enable in those maps below'],
		autoenable = function() return D.IsEnabled() end,
	})
	ui:append("WndCheckBox", {
		x = x, y = y + 5, w = 80, text = _L['arena'],
		checked = Config.bOnlyInArena,
		oncheck = function(bChecked)
			Config.bOnlyInArena = bChecked
			D.Reset(true)
		end,
		autoenable = function() return D.IsEnabled() end,
	})
	x = x + 80
	ui:append("WndCheckBox", {
		x = x, y = y + 5, w = 70, text = _L['battlefield'],
		checked = Config.bOnlyInBattleField,
		oncheck = function(bChecked)
			Config.bOnlyInBattleField = bChecked
			D.Reset(true)
		end,
		autoenable = function() return D.IsEnabled() end,
	})
	x = x + 70
	ui:append("WndCheckBox", {
		x = x, y = y + 5, w = 70, text = _L['dungeon'],
		checked = Config.bOnlyInDungeon,
		oncheck = function(bChecked)
			Config.bOnlyInDungeon = bChecked
			D.Reset(true)
		end,
		autoenable = function() return D.IsEnabled() end,
	})
	y = y + offsety
	-- <hr />
	ui:append("Image", "Image_Spliter"):find('#Image_Spliter'):pos(10, y-7):size(w - 20, 2):image('UI/Image/UICommon/ScienceTreeNode.UITex',62)

	x, y = 15, 65
	offsety = 35
	ui:append("WndSliderBox", {
		name = "WndSliderBox_LifeBarWidth",
		x = x, y = y, sliderstyle = MY.Const.UI.Slider.SHOW_VALUE, range = { 5, 150 },
		text = function(value) return _L("lifebar width: %s px.", value) end, -- Ѫ
		value = Config.nLifeWidth,
		onchange = function(value)
			Config.nLifeWidth = value
			D.Reset()
		end,
		autoenable = function() return D.IsEnabled() end,
	})
	y = y + offsety

	ui:append("WndSliderBox", {
		name = "WndSliderBox_LifeBarHeight",
		x = x, y = y, sliderstyle = MY.Const.UI.Slider.SHOW_VALUE, range = { 5, 150 },
		text = function(value) return _L("lifebar height: %s px.", value) end, -- Ѫ߶
		value = Config.nLifeHeight,
		onchange = function(value)<commit_msg>微调设置界面<commit_after>---------------------------------------------------
-- @Author: <NAME> (<EMAIL>)
-- @Date:   2018-03-19 10:36:40
-- @Last Modified by:   <NAME> (<EMAIL>)
-- @Last Modified time: 2018-03-29 17:29:24
---------------------------------------------------
-----------------------------------------------------------------------------------------
-- these global functions are accessed all the time by the event handler
-- so caching them is worth the effort
-----------------------------------------------------------------------------------------
local setmetatable = setmetatable
local ipairs, pairs, next, pcall = ipairs, pairs, next, pcall
local sub, len, format, rep = string.sub, string.len, string.format, string.rep
local find, byte, char, gsub = string.find, string.byte, string.char, string.gsub
local type, tonumber, tostring = type, tonumber, tostring
local floor, min, max, ceil = math.floor, math.min, math.max, math.ceil
local huge, pi, sin, cos, tan = math.huge, math.pi, math.sin, math.cos, math.tan
local insert, remove, concat, sort = table.insert, table.remove, table.concat, table.sort
local pack, unpack = table.pack or function(...) return {...} end, table.unpack or unpack
-- jx3 apis caching
local wsub, wlen, wfind = wstring.sub, wstring.len, wstring.find
local GetTime, GetLogicFrameCount = GetTime, GetLogicFrameCount
local GetClientPlayer, GetPlayer, GetNpc = GetClientPlayer, GetPlayer, GetNpc
local GetClientTeam, UI_GetClientPlayerID = GetClientTeam, UI_GetClientPlayerID
local IsNil, IsNumber, IsFunction = MY.IsNil, MY.IsNumber, MY.IsFunction
local IsBoolean, IsString, IsTable = MY.IsBoolean, MY.IsString, MY.IsTable
-----------------------------------------------------------------------------------------
local Config = MY_LifeBar_Config
if not Config then
    return
end

local D = {
	Reset = MY_LifeBar.Reset,
	IsEnabled = MY_LifeBar.IsEnabled,
	IsShielded = MY_LifeBar.IsShielded,
}
local _L = MY.LoadLangPack(MY.GetAddonInfo().szRoot .. "MY_LifeBar/lang/")

local PS = {}
local function LoadUI(ui)
	ui:children("#WndSliderBox_LifeBarWidth"):value(Config.nLifeWidth)
	ui:children("#WndSliderBox_LifeBarHeight"):value(Config.nLifeHeight)
	ui:children("#WndSliderBox_LifeBarOffsetX"):value(Config.nLifeOffsetX)
	ui:children("#WndSliderBox_LifeBarOffsetY"):value(Config.nLifeOffsetY)
	ui:children("#WndSliderBox_TextOffsetY"):value(Config.nTextOffsetY)
	ui:children("#WndSliderBox_TextLineHeight"):value(Config.nTextLineHeight)
	ui:children("#WndSliderBox_LifePerOffsetX"):value(Config.nLifePerOffsetX)
	ui:children("#WndSliderBox_LifePerOffsetY"):value(Config.nLifePerOffsetY)
	ui:children("#WndSliderBox_Distance"):value(math.sqrt(Config.nDistance) / 64)
	ui:children("#WndSliderBox_Alpha"):value(Config.nAlpha)
	ui:children("#WndCheckBox_ShowSpecialNpc"):check(Config.bShowSpecialNpc)
	ui:children("#WndButton_Font"):text(_L("Font: %d", Config.nFont))
end
function PS.OnPanelActive(wnd)
	local ui = MY.UI(wnd)
	local w, h = ui:size()

	local x, y = 10, 15
	local offsety = 45
	-- 
	ui:append("WndCheckBox", {
		x = x, y = y, text = _L["Enable"],
		checked = MY_LifeBar.bEnabled,
		oncheck = function(bChecked)
			MY_LifeBar.bEnabled = bChecked
			D.Reset(true)
		end,
		tip = function()
			if D.IsShielded() then
				return _L['Can not use in pubg map!']
			end
		end,
		autoenable = function() return not D.IsShielded() end,
	})
	x = x + 80
	-- ļ
	ui:append("WndEditBox", {
		x = x, y = y, w = 200, h = 25,
		placeholder = _L['Configure name'],
		text = MY_LifeBar.szConfig,
		onblur = function()
			local szConfig = XGUI(this):text():gsub("%s", "")
			if szConfig == "" then
				return
			end
			Config("load", szConfig)
			LoadUI(ui)
			D.Reset()
		end,
		autoenable = function() return D.IsEnabled() end,
	})
	x = x + 220
	ui:append("Text", {
		x = x + 5, y = y - 18,
		text = _L['only enable in those maps below'],
		autoenable = function() return D.IsEnabled() end,
	})
	ui:append("WndCheckBox", {
		x = x, y = y + 8, w = 80, text = _L['arena'],
		checked = Config.bOnlyInArena,
		oncheck = function(bChecked)
			Config.bOnlyInArena = bChecked
			D.Reset(true)
		end,
		autoenable = function() return D.IsEnabled() end,
	})
	x = x + 80
	ui:append("WndCheckBox", {
		x = x, y = y + 8, w = 70, text = _L['battlefield'],
		checked = Config.bOnlyInBattleField,
		oncheck = function(bChecked)
			Config.bOnlyInBattleField = bChecked
			D.Reset(true)
		end,
		autoenable = function() return D.IsEnabled() end,
	})
	x = x + 70
	ui:append("WndCheckBox", {
		x = x, y = y + 8, w = 70, text = _L['dungeon'],
		checked = Config.bOnlyInDungeon,
		oncheck = function(bChecked)
			Config.bOnlyInDungeon = bChecked
			D.Reset(true)
		end,
		autoenable = function() return D.IsEnabled() end,
	})
	y = y + offsety
	-- <hr />
	ui:append("Image", "Image_Spliter"):find('#Image_Spliter'):pos(10, y-7):size(w - 20, 2):image('UI/Image/UICommon/ScienceTreeNode.UITex',62)

	x, y = 15, 70
	offsety = 32
	ui:append("WndSliderBox", {
		name = "WndSliderBox_LifeBarWidth",
		x = x, y = y, sliderstyle = MY.Const.UI.Slider.SHOW_VALUE, range = { 5, 150 },
		text = function(value) return _L("lifebar width: %s px.", value) end, -- Ѫ
		value = Config.nLifeWidth,
		onchange = function(value)
			Config.nLifeWidth = value
			D.Reset()
		end,
		autoenable = function() return D.IsEnabled() end,
	})
	y = y + offsety

	ui:append("WndSliderBox", {
		name = "WndSliderBox_LifeBarHeight",
		x = x, y = y, sliderstyle = MY.Const.UI.Slider.SHOW_VALUE, range = { 5, 150 },
		text = function(value) return _L("lifebar height: %s px.", value) end, -- Ѫ߶
		value = Config.nLifeHeight,
		onchange = function(value)
{'fraction_non_alphanumeric': 0.20232496228591712, 'fraction_numerical': 0.01508563315289733, 'mean_word_length': 3.241625893865262, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4205625', 'n_tokens_mistral': 4214, 'n_tokens_neox': 3920, 'n_words': 923}