diff options
Diffstat (limited to 'Data/BuiltIn/Libraries/lua-addons/addons/bluguide/ui')
5 files changed, 649 insertions, 0 deletions
diff --git a/Data/BuiltIn/Libraries/lua-addons/addons/bluguide/ui/buttons.lua b/Data/BuiltIn/Libraries/lua-addons/addons/bluguide/ui/buttons.lua new file mode 100644 index 0000000..98c52ef --- /dev/null +++ b/Data/BuiltIn/Libraries/lua-addons/addons/bluguide/ui/buttons.lua @@ -0,0 +1,119 @@ +local texts = require('texts') + +local buttons = {} +local buttonlist = {} + +function buttons.new(label, settings) + label = label or "" + settings = settings or {} + + settings.flags = settings.flags or {} + settings.flags.draggable = false + + local button = {} + + button.left_click = settings.left_click + button.hover_on = settings.hover_on + button.hover_off = settings.hover_off + + button.text = texts.new(label, settings) + button.destroy = function() buttons.destroy(button) end + + setmetatable(button, {__index = function(t, k) + if t.text[k] ~= nil then + return function(...) + return t.text[k](t.text, ...) + end + end + end }) + + buttonlist[#buttonlist +1] = button + return button +end + +function buttons.destroy(me) + for k, v in pairs(buttonlist) do + if v == me then + buttonlist[k] = nil + end + end + me.text.destroy(me.text) +end + +local mousemoved = true +local ignorerelease = false + +windower.register_event('mouse', function(eventtype, x, y, delta, blocked) + if blocked then + return + end + + -- Mouse drag + if eventtype == 0 then + mousemoved = true + + for _, button in pairs(buttonlist) do + if type(button.hover_on) == "function" and type(button.hover_off) == "function" then + if button.text:hover(x, y) then + button:hover_on() + else + button:hover_off() + end + end + end + + -- Mouse left click + elseif eventtype == 1 then + mousemoved = false + for _, button in pairs(buttonlist) do + if button.text:hover(x, y) then + ignorerelease = true + return true + end + end + ignorerelease = false + + -- Mouse left release + elseif eventtype == 2 then + for _, button in pairs(buttonlist) do + if button.text:hover(x, y) and button.text:visible() and not mousemoved and type(button.left_click) == "function" then + button:left_click() + return true + end + end + + if ignorerelease then + return true + end + end + + return false +end) + +return buttons + +--Copyright © 2015, Anissa +--All rights reserved. + +--Redistribution and use in source and binary forms, with or without +--modification, are permitted provided that the following conditions are met: + +-- * Redistributions of source code must retain the above copyright +-- notice, this list of conditions and the following disclaimer. +-- * Redistributions in binary form must reproduce the above copyright +-- notice, this list of conditions and the following disclaimer in the +-- documentation and/or other materials provided with the distribution. +-- * Neither the name of bluGuide nor the +-- names of its contributors may be used to endorse or promote products +-- derived from this software without specific prior written permission. + +--THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +--ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +--WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +--DISCLAIMED. IN NO EVENT SHALL ANISSA BE LIABLE FOR ANY +--DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +--(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +--LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +--ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +--(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +--SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
\ No newline at end of file diff --git a/Data/BuiltIn/Libraries/lua-addons/addons/bluguide/ui/pages.lua b/Data/BuiltIn/Libraries/lua-addons/addons/bluguide/ui/pages.lua new file mode 100644 index 0000000..8e170b4 --- /dev/null +++ b/Data/BuiltIn/Libraries/lua-addons/addons/bluguide/ui/pages.lua @@ -0,0 +1,67 @@ +local pgs = {} + +function pgs.new(x, y) + return setmetatable({ x = x, y = y, boxlist = {} }, {__index = pgs}) +end + +function pgs.add(me, newbox) + if newbox then + me.boxlist[#me.boxlist+1] = newbox + end + me:update() +end + +function pgs.update(me) + for i = 1, #me.boxlist do + me.boxlist[i]:update() + if i > 1 then + me.boxlist[i]:pos(me.boxlist[i - 1]:left(), me.boxlist[i - 1]:bottom() + lineheight) + local info = windower.get_windower_settings() + if me.boxlist[i]:bottom() > info.ui_y_res - 150 then + me.boxlist[i]:pos(me.boxlist[i]:left() + 240, me.y) + end + else + me.boxlist[i]:pos(me.x, me.y) + end + end +end + +function pgs.show(me) + for _, v in pairs(me.boxlist) do + v:show() + end +end + +function pgs.hide(me) + for _, v in pairs(me.boxlist) do + v:hide() + end +end + +return pgs + +--Copyright © 2015, Anissa +--All rights reserved. + +--Redistribution and use in source and binary forms, with or without +--modification, are permitted provided that the following conditions are met: + +-- * Redistributions of source code must retain the above copyright +-- notice, this list of conditions and the following disclaimer. +-- * Redistributions in binary form must reproduce the above copyright +-- notice, this list of conditions and the following disclaimer in the +-- documentation and/or other materials provided with the distribution. +-- * Neither the name of bluGuide nor the +-- names of its contributors may be used to endorse or promote products +-- derived from this software without specific prior written permission. + +--THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +--ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +--WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +--DISCLAIMED. IN NO EVENT SHALL ANISSA BE LIABLE FOR ANY +--DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +--(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +--LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +--ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +--(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +--SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
\ No newline at end of file diff --git a/Data/BuiltIn/Libraries/lua-addons/addons/bluguide/ui/spellboxes.lua b/Data/BuiltIn/Libraries/lua-addons/addons/bluguide/ui/spellboxes.lua new file mode 100644 index 0000000..4f8b910 --- /dev/null +++ b/Data/BuiltIn/Libraries/lua-addons/addons/bluguide/ui/spellboxes.lua @@ -0,0 +1,157 @@ +local sbx = {} +buttons = require("ui/buttons") +texts = require("texts") +spellbuttons = require("ui/spellbuttons") + + +local default_settings = { + text = { size = 10, font = 'Lucida Console' }, + bg = { alpha = 120, red = 0, green = 0, blue = 0, visible = true }, + flags = {draggable = false} +} + +local header_settings = { + text = { size = 10, font = 'Lucida Console',}, + bg = { alpha = 200, red = 0, green = 100, blue = 100, visible = false }, +} + +function sbx.new(name, filter, namefn) + local me = { name = name, x = 0, y = 0, splist = {}, collapsed = false} + + me.bg = texts.new(" ", default_settings) + + me.header = buttons.new(string.format('- %-24s', me.name), header_settings) + me.header.bold(false) + me.header.color(255, 255, 255) + me.header.bg_color(0, 100, 100) + me.header.left_click = function() collapse(me) end + me.header.hover_on = function() show_bg(me) end + me.header.hover_off = function() hide_bg(me) end + + local linenum = 1 + local totalpoints = 0 + for k, v in pairs(spellinfo) do + if filter(v) and v.level <= setspells.limits.level then + local buttonname = nil + if namefn ~= nil then + buttonname = namefn(v) + end + buttonname = buttonname or v.name + me.splist[#me.splist+1] = spellbuttons.new(string.format(' %-22s %i', buttonname, v.cost), v.id, v.cost, me.x, me.y + (linenum * lineheight)) + me.splist[#me.splist]:update() + linenum = linenum + 1 + end + end + + if #me.splist > 0 then return setmetatable(me, {__index = sbx}) end +end + +function sbx.update(me) + local vspace = " " + for _, v in pairs(me.splist) do + v:update() + if not me.collapsed then + vspace = vspace.."\n " + end + end + + me.bg:text(vspace) +end + +function sbx.bottom(me) + if not me.collapsed then + return me.y + ((1 + #me.splist) * lineheight) + else + return me.y + lineheight + end +end + +function sbx.left(me) + return me.x +end + +function sbx.show(me) + if not me.collapsed then + for _, v in pairs(me.splist) do + v:show() + end + end + me.bg:show() + me.header.show() +end + +function sbx.pos(me, x, y) + me.x = x + me.y = y + me.bg:pos(x, y) + me.header.pos(x, y) + local by = 0 + for i = 1, #me.splist do + by = by + lineheight + me.splist[i]:pos(x, y+by) + end +end + +function sbx.hide(me) + for _, v in pairs(me.splist) do + v:hide() + end + me.header.hide() + me.bg:hide() +end + +function show_bg(me) + me.header.bg_visible(true) +end + +function hide_bg(me) + me.header.bg_visible(false) +end + +function collapse(me) + me.collapsed = not me.collapsed + if me.collapsed then + me.header.text:text(string.format('+ %-24s', me.name)) + me.header.bold(true) + for _, v in pairs(me.splist) do + v:hide() + end + me:update() + else + me.header.text:text(string.format('- %-24s', me.name)) + me.header.bold(false) + for _, v in pairs(me.splist) do + v:show() + end + end + update() +end + +return sbx + +--Copyright © 2015, Anissa +--All rights reserved. + +--Redistribution and use in source and binary forms, with or without +--modification, are permitted provided that the following conditions are met: + +-- * Redistributions of source code must retain the above copyright +-- notice, this list of conditions and the following disclaimer. +-- * Redistributions in binary form must reproduce the above copyright +-- notice, this list of conditions and the following disclaimer in the +-- documentation and/or other materials provided with the distribution. +-- * Neither the name of bluGuide nor the +-- names of its contributors may be used to endorse or promote products +-- derived from this software without specific prior written permission. + +--THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +--ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +--WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +--DISCLAIMED. IN NO EVENT SHALL ANISSA BE LIABLE FOR ANY +--DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +--(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +--LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +--ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +--(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +--SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. (c) 2015, Anissa +--All rights reserved.
\ No newline at end of file diff --git a/Data/BuiltIn/Libraries/lua-addons/addons/bluguide/ui/spellbuttons.lua b/Data/BuiltIn/Libraries/lua-addons/addons/bluguide/ui/spellbuttons.lua new file mode 100644 index 0000000..c853921 --- /dev/null +++ b/Data/BuiltIn/Libraries/lua-addons/addons/bluguide/ui/spellbuttons.lua @@ -0,0 +1,102 @@ +local spbt = {} +buttons = require("ui/buttons") + +local default_settings = { + text = { size = 10, font = 'Lucida Console',}, + bg = { alpha = 200, red = 0, green = 100, blue = 100, visible = false }, +} + +function spbt.new(label, spell, cost, x, y) + local me = { spell = spell, cost = cost} + me.settings = default_settings + me.settings.pos = { x = x, y = y } + me.set = {red = 100, green = 255, blue = 100 } + me.disabled = true + me.button = buttons.new(label, me.settings) + me.button.left_click = function() toggle_spell(me) end + me.button.hover_on = function() hover_on(me) end + me.button.hover_off = function() hover_off(me) end + return setmetatable(me, {__index = spbt}) +end + +function spbt.update(me) + if setspells[me.spell] ~= nil then + me.button.color(me.set.red, me.set.green, me.set.blue) + me.disabled = false + elseif not setspells.learned[me.spell] then + me.button.color(150, 150, 150) + me.disabled = true + elseif setspells.limits.points - setspells.points < me.cost or setspells.slots == setspells.limits.slots then + me.button.color(255, 100, 100) + me.disabled = true + else + me.button.color(255, 255, 255) + me.disabled = false + end +end + +function spbt.show(me) + me.button.show() +end + +function spbt.hide(me) + me.button.hide() +end + +function spbt.destroy(me) + me.button.destroy(me.button) + me = nil +end + +function spbt.pos(me, x, y) + me.button.pos(x, y) +end + +function hover_on(me) + me.button.bg_visible(true) +end + +function hover_off(me) + me.button.bg_visible(false) +end + +function spbt.color(me,r,g,b) + me.button.color(r,g,b) + me.set.red = r + me.set.green = g + me.set.blue = b +end + +function toggle_spell(me) + if not me.disabled then + setspells.toggle(me.spell) + end +end + +return spbt + +--Copyright © 2015, Anissa +--All rights reserved. + +--Redistribution and use in source and binary forms, with or without +--modification, are permitted provided that the following conditions are met: + +-- * Redistributions of source code must retain the above copyright +-- notice, this list of conditions and the following disclaimer. +-- * Redistributions in binary form must reproduce the above copyright +-- notice, this list of conditions and the following disclaimer in the +-- documentation and/or other materials provided with the distribution. +-- * Neither the name of bluGuide nor the +-- names of its contributors may be used to endorse or promote products +-- derived from this software without specific prior written permission. + +--THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +--ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +--WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +--DISCLAIMED. IN NO EVENT SHALL ANISSA BE LIABLE FOR ANY +--DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +--(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +--LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +--ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +--(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +--SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
\ No newline at end of file diff --git a/Data/BuiltIn/Libraries/lua-addons/addons/bluguide/ui/traitboxes.lua b/Data/BuiltIn/Libraries/lua-addons/addons/bluguide/ui/traitboxes.lua new file mode 100644 index 0000000..85edb30 --- /dev/null +++ b/Data/BuiltIn/Libraries/lua-addons/addons/bluguide/ui/traitboxes.lua @@ -0,0 +1,204 @@ +local tbx = {} +buttons = require("ui/buttons") +texts = require("texts") +spellbuttons = require("ui/spellbuttons") + +local default_settings = { + text = { size = 10, font = 'Lucida Console' }, + bg = { alpha = 120, red = 0, green = 0, blue = 0, visible = false }, + flags = {draggable = false} +} + +local header_settings = { + text = { size = 10, font = 'Lucida Console',}, + bg = { alpha = 200, red = 0, green = 100, blue = 100, visible = false }, +} + +function tbx.new(trait) + local me = { trait = trait, x = 0, y = 0, splist = {}, collapsed = false} + + me.greybox = texts.new("", default_settings) + me.greenbox = texts.new("", default_settings) + me.greybox:color(190, 190, 190) + me.greenbox:color(50, 255, 50) + me.greenbox:bg_visible(true) + me.greybox:bg_visible(false) + + me.header = buttons.new(string.format('- %-24s', trait.name), header_settings) + me.header.bold(false) + me.header.color(255, 255, 255) + me.header.bg_color(0, 100, 100) + me.header.left_click = function() collapsetrait(me) end + me.header.hover_on = function() show_bg(me) end + me.header.hover_off = function() hide_bg(me) end + + local linenum = 1 + local totalpoints = 0 + for k, v in pairs(trait.spells) do + if spellinfo[v.id].level <= setspells.limits.level then + me.splist[#me.splist+1] = spellbuttons.new(string.format(' %-20s %i %i', v.name, v.cost, v.points), v.id, v.cost, me.x, me.y + (linenum * lineheight)) + me.splist[#me.splist]:update() + linenum = linenum + 1 + totalpoints = totalpoints + v.points + end + end + + if totalpoints >= 8 then return setmetatable(me, {__index = tbx}) end + + for _, v in pairs(me.splist) do + v:destroy() + end + return nil +end + +function tbx.update(me) + local vspace = " \n " + for _, v in pairs(me.splist) do + v:update() + if not me.collapsed then + vspace = vspace.."\n " + end + end + + local traitpoints = 0 + for k, v in pairs(me.trait.spells) do + if setspells[v.id] then + traitpoints = traitpoints + v.points + end + end + + if traitpoints > 7 and giftexempttraits[me.trait.name] == nil then + traitpoints = traitpoints + (8 * setspells.gifts) + end + + me.greybox:text(vspace) + me.greenbox:text(vspace) + + for v = 8, 48 do + if me.trait.tiers[v] ~= nil then + if me.trait.name == "Double/Triple Attack" then + if v == 8 then + if traitpoints == 8 or traitpoints == 12 or sub == 'WAR' then + me.greenbox:append(string.format('%s ', me.trait.tiers[v])) + me.greybox:append(string.gsub(me.trait.tiers[v], ".", " ").." ") + else + me.greybox:append(string.format('%s ', me.trait.tiers[v])) + me.greenbox:append(string.gsub(me.trait.tiers[v], ".", " ").." ") + end + elseif traitpoints >= 16 or sub == "THF" then + me.greenbox:append(string.format('%s ', me.trait.tiers[v])) + me.greybox:append(string.gsub(me.trait.tiers[v], ".", " ").." ") + else + me.greybox:append(string.format('%s ', me.trait.tiers[v])) + me.greenbox:append(string.gsub(me.trait.tiers[v], ".", " ").." ") + end + elseif v <= traitpoints or (me.trait.subs[sub] and me.trait.subs[sub] >= v) then + me.greenbox:append(string.format('%s ', me.trait.tiers[v])) + me.greybox:append(string.gsub(me.trait.tiers[v], ".", " ").." ") + else + me.greybox:append(string.format('%s ', me.trait.tiers[v])) + me.greenbox:append(string.gsub(me.trait.tiers[v], ".", " ").." ") + end + end + end +end + +function tbx.bottom(me) + if not me.collapsed then + return me.y + ((2 + #me.splist) * lineheight) + else + return me.y + (2 * lineheight) + end +end + +function tbx.left(me) + return me.x +end + +function tbx.show(me) + if not me.collapsed then + for _, v in pairs(me.splist) do + v:show() + end + end + me.greenbox:show() + me.greybox:show() + me.header.show() +end + +function tbx.pos(me, x, y) + me.x = x + me.y = y + me.greybox:pos(x, y) + me.greenbox:pos(x, y) + me.header.pos(x, y) + local by = 0 + for i = 1, #me.splist do + by = by + lineheight + me.splist[i]:pos(x, y+by) + end +end + +function tbx.hide(me) + for _, v in pairs(me.splist) do + v:hide() + end + me.greenbox:hide() + me.greybox:hide() + me.header.hide() +end + +function show_bg(me) + me.header.bg_visible(true) +end + +function hide_bg(me) + me.header.bg_visible(false) +end + +function collapsetrait(me) + me.collapsed = not me.collapsed + if me.collapsed then + me.header.text:text(string.format('+ %-24s', me.trait.name)) + me.header.bold(true) + for _, v in pairs(me.splist) do + v:hide() + end + me:update() + else + me.header.text:text(string.format('- %-24s', me.trait.name)) + me.header.bold(false) + for _, v in pairs(me.splist) do + v:show() + end + end + update() +end + +return tbx + +--Copyright © 2015, Anissa +--All rights reserved. + +--Redistribution and use in source and binary forms, with or without +--modification, are permitted provided that the following conditions are met: + +-- * Redistributions of source code must retain the above copyright +-- notice, this list of conditions and the following disclaimer. +-- * Redistributions in binary form must reproduce the above copyright +-- notice, this list of conditions and the following disclaimer in the +-- documentation and/or other materials provided with the distribution. +-- * Neither the name of bluGuide nor the +-- names of its contributors may be used to endorse or promote products +-- derived from this software without specific prior written permission. + +--THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +--ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +--WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +--DISCLAIMED. IN NO EVENT SHALL ANISSA BE LIABLE FOR ANY +--DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +--(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +--LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +--ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +--(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +--SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
\ No newline at end of file |