From ede53b3ef5b364931149bdfb253ae9d3da8381c5 Mon Sep 17 00:00:00 2001 From: Darth Predator Date: Sat, 1 Apr 2017 12:21:47 +0300 Subject: [PATCH] Tag lib --- ElvUI_SLE/libs/Lib_SLETags-1.0/Lib_SLETags-1.0.lua | 64 ++++++++++++++++++++ ElvUI_SLE/libs/Lib_SLETags-1.0/Lib_SLETags-1.0.toc | 8 +++ ElvUI_SLE/libs/load_libs.xml | 2 +- 3 files changed, 73 insertions(+), 1 deletion(-) create mode 100644 ElvUI_SLE/libs/Lib_SLETags-1.0/Lib_SLETags-1.0.lua create mode 100644 ElvUI_SLE/libs/Lib_SLETags-1.0/Lib_SLETags-1.0.toc diff --git a/ElvUI_SLE/libs/Lib_SLETags-1.0/Lib_SLETags-1.0.lua b/ElvUI_SLE/libs/Lib_SLETags-1.0/Lib_SLETags-1.0.lua new file mode 100644 index 0000000..a3c7154 --- /dev/null +++ b/ElvUI_SLE/libs/Lib_SLETags-1.0/Lib_SLETags-1.0.lua @@ -0,0 +1,64 @@ +local MAJOR, MINOR = "Lib_SLETags-1.0", 1 +local lib, oldminor = LibStub:NewLibrary(MAJOR, MINOR) +--GLOBALS: CreateFrame +if not lib then return end + +local _G = _G +local tinsert, ipairs = tinsert, ipairs + +lib.TagsTable = {} + +function lib:ComplexTags_Process(module, msg) + local pattern = "%[(.-)%]([^;]+)" + local data = {} + local split_msg = { (";"):split(msg) } + + for i, v in ipairs(split_msg) do + local split = split_msg[i] + local condition, option = split:match(pattern) + if (condition and option) then + local cnd_table = { (","):split(condition) } + local parsed_cmds = {}; + for j = 1, #cnd_table do + local cnd = cnd_table[j]; + if cnd then + local command, argument = (":"):split(cnd) + tinsert(parsed_cmds, { cmd = command:match("^%s*(.+)%s*$"), arg = argument }) + end + end + tinsert(data, { option = option, cmds = parsed_cmds, module = module }) + end + end + + return data +end + +function lib:SimpleTags_Process(module, msg) + local pattern = "%[(.-)%]%([^;]+)" + local data = {} + local split_msg = { (";"):split(msg) } + + for i, v in ipairs(split_msg) do + local split = split_msg[i] + + end +end + +function lib:ComplexTags_ConditionsCheck(data) + for index,tagInfo in ipairs(data) do + local module = tagInfo.module + local ok = true + for conditionIndex,conditionInfo in ipairs(tagInfo.cmds) do + local func = conditionInfo["cmd"] + local arg = conditionInfo["arg"] + local result = lib.TagsTable[module][func](arg) + if not result then + ok = false + break + end + end + if ok then + return tagInfo.option + end + end +end \ No newline at end of file diff --git a/ElvUI_SLE/libs/Lib_SLETags-1.0/Lib_SLETags-1.0.toc b/ElvUI_SLE/libs/Lib_SLETags-1.0/Lib_SLETags-1.0.toc new file mode 100644 index 0000000..cddff9e --- /dev/null +++ b/ElvUI_SLE/libs/Lib_SLETags-1.0/Lib_SLETags-1.0.toc @@ -0,0 +1,8 @@ +## Interface: 70200 +## Title: Lib_SLETags-1.0 +## Notes: Tag system for S&L. +## Author: Darth Predator, sortokk +## Version: 1.0.0 +## Dependencies: oUF + +Lib_SLETags-1.0.lua \ No newline at end of file diff --git a/ElvUI_SLE/libs/load_libs.xml b/ElvUI_SLE/libs/load_libs.xml index ff6b904..5fcda03 100644 --- a/ElvUI_SLE/libs/load_libs.xml +++ b/ElvUI_SLE/libs/load_libs.xml @@ -1 +1 @@ -