Untitled

mail@pastecode.io avatar
unknown
plain_text
a month ago
5.6 kB
6
Indexable
Never
local function Create_ConfigWriteOut_UI() -- 导出配置
        UI.Basic_UI.ConfigWriteOut = {}
		UI.Basic_UI.ConfigWriteOut.Py = -10
		local function Frame_Create()
			UI.Basic_UI.ConfigWriteOut.frame = CreateFrame('frame',"UI.Basic_UI.ConfigWriteOut.frame",UI.Basic_UI.Panel, BackdropTemplateMixin and "BackdropTemplate")
			UI.Basic_UI.ConfigWriteOut.frame:SetPoint("TopLeft")
			UI.Basic_UI.ConfigWriteOut.frame:SetSize(772,530)
			UI.Basic_UI.ConfigWriteOut.frame:SetBackdrop({_,edgeFile = "Interface\\Tooltips\\UI-Tooltip-Border",_,_,edgeSize = 15,_})
			UI.Basic_UI.ConfigWriteOut.frame:SetBackdropColor(0.1,0.1,0.1,0)
			UI.Basic_UI.ConfigWriteOut.frame:SetBackdropBorderColor(0.1,0.1,0.1,0)
			UI.Basic_UI.ConfigWriteOut.frame:Hide()
			UI.Basic_UI.ConfigWriteOut.frame:SetFrameStrata('FULLSCREEN_DIALOG')
		end
		Frame_Create()

		Panel_List[#Panel_List + 1] = {display = Check_UI("导入/导出设置","Write/Load Config"), Show = function() UI.Basic_UI.ConfigWriteOut.frame:Show() end, Hide = function() UI.Basic_UI.ConfigWriteOut.frame:Hide() end}

		Update_Basic_Panel_List()

		local function Minus_Y(num)
			UI.Basic_UI.ConfigWriteOut.Py = UI.Basic_UI.ConfigWriteOut.Py - num
		end

		CreateLine(UI.Basic_UI.ConfigWriteOut.frame, UI.Basic_UI.ConfigWriteOut.Py, Check_UI("字符串导出", "Config output"))

		Minus_Y(30)
		UI.Basic_UI.ConfigWriteOut["正常字符串"] = Create_Scroll_Edit(UI.Basic_UI.ConfigWriteOut.frame,"Top",0,UI.Basic_UI.ConfigWriteOut.Py,"",720,150)
		Minus_Y(180)


		local header = Create_Header(UI.Basic_UI.ConfigWriteOut.frame,"Top",0,UI.Basic_UI.ConfigWriteOut.Py,Check_UI("加密字符串", "Encrypted String"))

		Minus_Y(20)
		UI.Basic_UI.ConfigWriteOut["加密字符串"] = Create_Scroll_Edit(UI.Basic_UI.ConfigWriteOut.frame,"Top",0,UI.Basic_UI.ConfigWriteOut.Py,"",720,150)


		Minus_Y(160)
		UI.Basic_UI.ConfigWriteOut["导出设置"] = Create_Button(UI.Basic_UI.ConfigWriteOut.frame,"Top",0, UI.Basic_UI.ConfigWriteOut.Py, Check_UI("导出当前设置","Write out current config"), true)
		UI.Basic_UI.ConfigWriteOut["导出设置"]:SetSize(300,30)
		UI.Basic_UI.ConfigWriteOut["导出设置"]:SetScript("OnClick", function(self)
			local id, figure, account = awm.GetWowAccountId()
			local wow_path = awm.GetWowDirectory()
			local realm = GetRealmName()
			local level1_folder = GetDirectoryFolders(wow_path.."WTF\\Account\\")
			level1_folder = string.split(level1_folder, "|")
			local correct_realm = {}
			local account_path = ""
			for i = 1,#level1_folder do

				local level2_fodlder = GetDirectoryFolders(wow_path.."WTF\\Account\\"..level1_folder[i])
				level2_fodlder = string.split(level2_fodlder, "|")
				for j = 1,#level2_fodlder do
					local path = wow_path.."WTF\\Account\\"..level1_folder[i].."\\"..realm.."\\"..UnitName("player").."\\SavedVariables\\"..Cur_Addon_Name..".lua"
					if level2_fodlder[j] == realm and FileExists(path) == 1 then
						account_path = path
					end
				end
			end

			if FileExists(account_path) == 1 then
				local content = awm.ReadFile(account_path)
				
				CreateDirectory(GetExeDirectory().."Saved_Vars\\")

				WriteFile(GetExeDirectory().."Saved_Vars\\"..UnitName("player")..".lua",content,false)

				textout(Check_UI("字符串已复制到面板", "Encrypted string already been copied"))
				content = string.gsub(content, "\t", "")
				local encrypt_str = Str2Hex(DF_Base64.encode(content))
				awm.CopyToClipboard(encrypt_str)
				UI.Basic_UI.ConfigWriteOut["加密字符串"]:SetText(encrypt_str)
				UI.Basic_UI.ConfigWriteOut["正常字符串"]:SetText(content)
			else
				message(Check_UI("变量不存在", "Vars not exists"))
			end
		end)



		Minus_Y(50)
		CreateLine(UI.Basic_UI.ConfigWriteOut.frame, UI.Basic_UI.ConfigWriteOut.Py, Check_UI("字符串导入", "Config Load In"))

		Minus_Y(30)
		UI.Basic_UI.ConfigWriteOut["导入加密字符串"] = Create_Scroll_Edit(UI.Basic_UI.ConfigWriteOut.frame,"Top",0,UI.Basic_UI.ConfigWriteOut.Py,"",720,150)

		Minus_Y(160)
		UI.Basic_UI.ConfigWriteOut["导入设置"] = Create_Button(UI.Basic_UI.ConfigWriteOut.frame,"Top",0, UI.Basic_UI.ConfigWriteOut.Py, Check_UI("导入加密字符串","Load Encrypted String"), true)
		UI.Basic_UI.ConfigWriteOut["导入设置"]:SetSize(300,30)
		UI.Basic_UI.ConfigWriteOut["导入设置"]:SetScript("OnClick", function(self)
			if UI.Basic_UI.ConfigWriteOut["导入加密字符串"]:GetText() ~= "" then
				local content = UI.Basic_UI.ConfigWriteOut["导入加密字符串"]:GetText()
				local decrypted = DF_Base64.decode(Hex2Str(content))
				loadstring(decrypted)()
				textout(Check_UI("导入成功", "Load Success"))
			end
		end)



		Minus_Y(50)
		UI.Basic_UI.ConfigWriteOut["导入正常字符串"] = Create_Scroll_Edit(UI.Basic_UI.ConfigWriteOut.frame,"Top",0,UI.Basic_UI.ConfigWriteOut.Py,"",720,150)

		Minus_Y(160)
		UI.Basic_UI.ConfigWriteOut["导入正常字符串按钮"] = Create_Button(UI.Basic_UI.ConfigWriteOut.frame,"Top",0, UI.Basic_UI.ConfigWriteOut.Py, Check_UI("导入正常字符串","Load Normal `Easy_Data` String"), true)
		UI.Basic_UI.ConfigWriteOut["导入正常字符串按钮"]:SetSize(300,30)
		UI.Basic_UI.ConfigWriteOut["导入正常字符串按钮"]:SetScript("OnClick", function(self)
			if UI.Basic_UI.ConfigWriteOut["导入正常字符串"]:GetText() ~= "" then
				local content = UI.Basic_UI.ConfigWriteOut["导入正常字符串"]:GetText()
				loadstring(content)()
				textout(Check_UI("导入成功", "Load Success"))
			end
		end)
	end
Leave a Comment