diff options
Diffstat (limited to 'Data/BuiltIn/Libraries/lua-addons/addons/xivbar')
22 files changed, 630 insertions, 0 deletions
diff --git a/Data/BuiltIn/Libraries/lua-addons/addons/xivbar/README.md b/Data/BuiltIn/Libraries/lua-addons/addons/xivbar/README.md new file mode 100644 index 0000000..ec44b0b --- /dev/null +++ b/Data/BuiltIn/Libraries/lua-addons/addons/xivbar/README.md @@ -0,0 +1,44 @@ +# xivbar +This addon displays vital bars for easy tracking + + + +You can choose from 3 different styles 'ffxiv', 'ffxi' and 'ffxiv-legacy'. + + + +and you can use a compact version for a smaller resolution: + + +## Available Settings +##### Bars +* **Offset X** - moves the entire addon left (negative number) or right (positive number) the given number of pixels +* **Offset Y** - moves the entire addon up (negative number) or down (positive number) the given number of pixels + +##### Theme +* **Name** - Name of the theme to use - 'ffxi', 'ffxiv', 'ffxiv-legacy', or your own custom one +* **Compact** - Enables or disables compact mode +* **Bar** - Values for bar width, spacing, offset and compact mode. Useful for creating a custom theme. + +##### Texts +* **Color** - The font color for the HP, MP and TP numbers +* **Font** - The font for the HP, MP and TP numbers +* **Offset** - moves the HP, MP and TP numbers left (negative number) or right (positive number) the given number of pixels +* **Size** - The font size for the HP, MP and TP numbers +* **Stroke** - The font stroke the HP, MP and TP numbers +* **FullTpColor** - The font color for the TP numbers when the bar is full +* **DimTpBar** - dim the TP bar when not full + +## How to edit the settings +1. Login to your character in FFXI +2. Edit the addon's settings file: **_Windower4\addons\xivbar\data\settings.xml_** +3. Save the file +4. Press Insert in FFXI to access the windower console +5. Type ``` lua r xivbar ``` to reload the addon +6. Press Insert in FFXI again to close the windower console + +## How to create my own custom theme +1. Create a folder inside the *theme* directory of the addon: **_Windower4\addons\xivbar\themes\MY_CUSTOM_THEME_** +2. Create the necessary images. A theme is composed of 5 images: a background for the bars (*bar_bg.png*), a background for the compact mode (*bar_compact.png*), and one image for each bar (*hp_fg.png, mp_fg.png and tp_fg.png*). You can take a look at the default themes. +3. Edit the name of the theme in the settings to yours. This setting must match the name of the folder you just created. +4. Adjust the bar width, spacing and offset for your custom theme in the settings. diff --git a/Data/BuiltIn/Libraries/lua-addons/addons/xivbar/defaults.lua b/Data/BuiltIn/Libraries/lua-addons/addons/xivbar/defaults.lua new file mode 100644 index 0000000..641f9ad --- /dev/null +++ b/Data/BuiltIn/Libraries/lua-addons/addons/xivbar/defaults.lua @@ -0,0 +1,68 @@ +--[[ + Copyright © 2017, SirEdeonX + 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 xivbar 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 SirEdeonX 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. +]] + +local defaults = {} + +defaults.Bars = {} +defaults.Bars.OffsetX = 0 +defaults.Bars.OffsetY = 0 + +defaults.Theme = {} +defaults.Theme.Name = 'ffxiv' +defaults.Theme.Compact = false +defaults.Theme.Bar = {} +defaults.Theme.Bar.Width = 132 +defaults.Theme.Bar.Spacing = 18 +defaults.Theme.Bar.Offset = 0 +defaults.Theme.Bar.Compact = {} +defaults.Theme.Bar.Compact.Width = 116 +defaults.Theme.Bar.Compact.Spacing = 16 +defaults.Theme.Bar.Compact.Offset = 0 +defaults.Theme.DimTpBar = true + +defaults.Texts = {} +defaults.Texts.Font = 'sans-serif' +defaults.Texts.Size = 14 +defaults.Texts.Offset = 0 +defaults.Texts.Color = {} +defaults.Texts.Color.Alpha = 255 +defaults.Texts.Color.Red = 253 +defaults.Texts.Color.Green = 252 +defaults.Texts.Color.Blue = 250 +defaults.Texts.Stroke = {} +defaults.Texts.Stroke.Width = 2 +defaults.Texts.Stroke.Alpha = 200 +defaults.Texts.Stroke.Red = 50 +defaults.Texts.Stroke.Green = 50 +defaults.Texts.Stroke.Blue = 50 +defaults.Texts.FullTpColor = {} +defaults.Texts.FullTpColor.Red = 80 +defaults.Texts.FullTpColor.Green = 180 +defaults.Texts.FullTpColor.Blue = 250 + +return defaults
\ No newline at end of file diff --git a/Data/BuiltIn/Libraries/lua-addons/addons/xivbar/player.lua b/Data/BuiltIn/Libraries/lua-addons/addons/xivbar/player.lua new file mode 100644 index 0000000..e28a1a0 --- /dev/null +++ b/Data/BuiltIn/Libraries/lua-addons/addons/xivbar/player.lua @@ -0,0 +1,42 @@ +--[[ + Copyright © 2017, SirEdeonX + 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 xivbar 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 SirEdeonX 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. +]] + +local player = {} + +player.hpp = 0 +player.mpp = 0 +player.tpp = 0 +player.current_hp = 0 +player.current_mp = 0 +player.current_tp = 0 + +function player:calculate_tpp() + self.tpp = math.min(self.current_tp / 10, 100) +end + +return player
\ No newline at end of file diff --git a/Data/BuiltIn/Libraries/lua-addons/addons/xivbar/theme.lua b/Data/BuiltIn/Libraries/lua-addons/addons/xivbar/theme.lua new file mode 100644 index 0000000..4ef66ab --- /dev/null +++ b/Data/BuiltIn/Libraries/lua-addons/addons/xivbar/theme.lua @@ -0,0 +1,84 @@ +--[[ + Copyright © 2017, SirEdeonX + 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 xivbar 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 SirEdeonX 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. +]] + +local theme = {} + +theme.apply = function (settings) + local options = {} + + options.total_height = 8 + options.total_width = 472 + options.offset_x = settings.Bars.OffsetX + options.offset_y = settings.Bars.OffsetY + + options.bar_background = windower.addon_path .. 'themes/' .. settings.Theme.Name .. '/bar_bg.png' + options.bar_hp = windower.addon_path .. 'themes/' .. settings.Theme.Name .. '/hp_fg.png' + options.bar_mp = windower.addon_path .. 'themes/' .. settings.Theme.Name .. '/mp_fg.png' + options.bar_tp = windower.addon_path .. 'themes/' .. settings.Theme.Name .. '/tp_fg.png' + + options.font = settings.Texts.Font + options.font_size = settings.Texts.Size + options.font_alpha = settings.Texts.Color.Alpha + options.font_color_red = settings.Texts.Color.Red + options.font_color_green = settings.Texts.Color.Green + options.font_color_blue = settings.Texts.Color.Blue + options.font_stroke_width = settings.Texts.Stroke.Width + options.font_stroke_alpha = settings.Texts.Stroke.Alpha + options.font_stroke_color_red = settings.Texts.Stroke.Red + options.font_stroke_color_green = settings.Texts.Stroke.Green + options.font_stroke_color_blue = settings.Texts.Stroke.Blue + options.full_tp_color_red = settings.Texts.FullTpColor.Red + options.full_tp_color_green = settings.Texts.FullTpColor.Green + options.full_tp_color_blue = settings.Texts.FullTpColor.Blue + options.text_offset = settings.Texts.Offset + + options.bar_width = settings.Theme.Bar.Width + options.bar_spacing = settings.Theme.Bar.Spacing + options.bar_offset = settings.Theme.Bar.Offset + + options.dim_tp_bar = settings.Theme.DimTpBar + + if settings.Theme.Compact then + options.bar_background = windower.addon_path .. 'themes/' .. settings.Theme.Name .. '/bar_compact.png' + options.total_width = 422 + options.bar_width = settings.Theme.Bar.Compact.Width + options.bar_spacing = settings.Theme.Bar.Compact.Spacing + options.bar_offset = settings.Theme.Bar.Compact.Offset + end + + if settings.Theme.Name == 'ffxiv' then + options.font_stroke_alpha = 150 + options.font_stroke_color_red = 80 + options.font_stroke_color_green = 70 + options.font_stroke_color_blue = 30 + end + + return options +end + +return theme
\ No newline at end of file diff --git a/Data/BuiltIn/Libraries/lua-addons/addons/xivbar/themes/ffxi/bar_bg.png b/Data/BuiltIn/Libraries/lua-addons/addons/xivbar/themes/ffxi/bar_bg.png Binary files differnew file mode 100644 index 0000000..99f4acc --- /dev/null +++ b/Data/BuiltIn/Libraries/lua-addons/addons/xivbar/themes/ffxi/bar_bg.png diff --git a/Data/BuiltIn/Libraries/lua-addons/addons/xivbar/themes/ffxi/bar_compact.png b/Data/BuiltIn/Libraries/lua-addons/addons/xivbar/themes/ffxi/bar_compact.png Binary files differnew file mode 100644 index 0000000..0941f24 --- /dev/null +++ b/Data/BuiltIn/Libraries/lua-addons/addons/xivbar/themes/ffxi/bar_compact.png diff --git a/Data/BuiltIn/Libraries/lua-addons/addons/xivbar/themes/ffxi/hp_fg.png b/Data/BuiltIn/Libraries/lua-addons/addons/xivbar/themes/ffxi/hp_fg.png Binary files differnew file mode 100644 index 0000000..14e014d --- /dev/null +++ b/Data/BuiltIn/Libraries/lua-addons/addons/xivbar/themes/ffxi/hp_fg.png diff --git a/Data/BuiltIn/Libraries/lua-addons/addons/xivbar/themes/ffxi/mp_fg.png b/Data/BuiltIn/Libraries/lua-addons/addons/xivbar/themes/ffxi/mp_fg.png Binary files differnew file mode 100644 index 0000000..f130838 --- /dev/null +++ b/Data/BuiltIn/Libraries/lua-addons/addons/xivbar/themes/ffxi/mp_fg.png diff --git a/Data/BuiltIn/Libraries/lua-addons/addons/xivbar/themes/ffxi/tp_fg.png b/Data/BuiltIn/Libraries/lua-addons/addons/xivbar/themes/ffxi/tp_fg.png Binary files differnew file mode 100644 index 0000000..5d8c7fa --- /dev/null +++ b/Data/BuiltIn/Libraries/lua-addons/addons/xivbar/themes/ffxi/tp_fg.png diff --git a/Data/BuiltIn/Libraries/lua-addons/addons/xivbar/themes/ffxiv-legacy/bar_bg.png b/Data/BuiltIn/Libraries/lua-addons/addons/xivbar/themes/ffxiv-legacy/bar_bg.png Binary files differnew file mode 100644 index 0000000..c09f586 --- /dev/null +++ b/Data/BuiltIn/Libraries/lua-addons/addons/xivbar/themes/ffxiv-legacy/bar_bg.png diff --git a/Data/BuiltIn/Libraries/lua-addons/addons/xivbar/themes/ffxiv-legacy/bar_compact.png b/Data/BuiltIn/Libraries/lua-addons/addons/xivbar/themes/ffxiv-legacy/bar_compact.png Binary files differnew file mode 100644 index 0000000..c5b03b3 --- /dev/null +++ b/Data/BuiltIn/Libraries/lua-addons/addons/xivbar/themes/ffxiv-legacy/bar_compact.png diff --git a/Data/BuiltIn/Libraries/lua-addons/addons/xivbar/themes/ffxiv-legacy/hp_fg.png b/Data/BuiltIn/Libraries/lua-addons/addons/xivbar/themes/ffxiv-legacy/hp_fg.png Binary files differnew file mode 100644 index 0000000..543d608 --- /dev/null +++ b/Data/BuiltIn/Libraries/lua-addons/addons/xivbar/themes/ffxiv-legacy/hp_fg.png diff --git a/Data/BuiltIn/Libraries/lua-addons/addons/xivbar/themes/ffxiv-legacy/mp_fg.png b/Data/BuiltIn/Libraries/lua-addons/addons/xivbar/themes/ffxiv-legacy/mp_fg.png Binary files differnew file mode 100644 index 0000000..c49ceda --- /dev/null +++ b/Data/BuiltIn/Libraries/lua-addons/addons/xivbar/themes/ffxiv-legacy/mp_fg.png diff --git a/Data/BuiltIn/Libraries/lua-addons/addons/xivbar/themes/ffxiv-legacy/tp_fg.png b/Data/BuiltIn/Libraries/lua-addons/addons/xivbar/themes/ffxiv-legacy/tp_fg.png Binary files differnew file mode 100644 index 0000000..ccc24d5 --- /dev/null +++ b/Data/BuiltIn/Libraries/lua-addons/addons/xivbar/themes/ffxiv-legacy/tp_fg.png diff --git a/Data/BuiltIn/Libraries/lua-addons/addons/xivbar/themes/ffxiv/bar_bg.png b/Data/BuiltIn/Libraries/lua-addons/addons/xivbar/themes/ffxiv/bar_bg.png Binary files differnew file mode 100644 index 0000000..37c619f --- /dev/null +++ b/Data/BuiltIn/Libraries/lua-addons/addons/xivbar/themes/ffxiv/bar_bg.png diff --git a/Data/BuiltIn/Libraries/lua-addons/addons/xivbar/themes/ffxiv/bar_compact.png b/Data/BuiltIn/Libraries/lua-addons/addons/xivbar/themes/ffxiv/bar_compact.png Binary files differnew file mode 100644 index 0000000..8180072 --- /dev/null +++ b/Data/BuiltIn/Libraries/lua-addons/addons/xivbar/themes/ffxiv/bar_compact.png diff --git a/Data/BuiltIn/Libraries/lua-addons/addons/xivbar/themes/ffxiv/hp_fg.png b/Data/BuiltIn/Libraries/lua-addons/addons/xivbar/themes/ffxiv/hp_fg.png Binary files differnew file mode 100644 index 0000000..d3abc61 --- /dev/null +++ b/Data/BuiltIn/Libraries/lua-addons/addons/xivbar/themes/ffxiv/hp_fg.png diff --git a/Data/BuiltIn/Libraries/lua-addons/addons/xivbar/themes/ffxiv/mp_fg.png b/Data/BuiltIn/Libraries/lua-addons/addons/xivbar/themes/ffxiv/mp_fg.png Binary files differnew file mode 100644 index 0000000..b1f7bfa --- /dev/null +++ b/Data/BuiltIn/Libraries/lua-addons/addons/xivbar/themes/ffxiv/mp_fg.png diff --git a/Data/BuiltIn/Libraries/lua-addons/addons/xivbar/themes/ffxiv/tp_fg.png b/Data/BuiltIn/Libraries/lua-addons/addons/xivbar/themes/ffxiv/tp_fg.png Binary files differnew file mode 100644 index 0000000..49fd63f --- /dev/null +++ b/Data/BuiltIn/Libraries/lua-addons/addons/xivbar/themes/ffxiv/tp_fg.png diff --git a/Data/BuiltIn/Libraries/lua-addons/addons/xivbar/ui.lua b/Data/BuiltIn/Libraries/lua-addons/addons/xivbar/ui.lua new file mode 100644 index 0000000..6410885 --- /dev/null +++ b/Data/BuiltIn/Libraries/lua-addons/addons/xivbar/ui.lua @@ -0,0 +1,130 @@ +--[[ + Copyright © 2017, SirEdeonX + 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 xivbar 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 SirEdeonX 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. +]] + + +local ui = {} + +local text_setup = { + flags = { + draggable = false + } +} + +local images_setup = { + draggable = false +} + +-- ui variables +ui.background = images.new(images_setup) + +ui.hp_bar = images.new(images_setup) +ui.mp_bar = images.new(images_setup) +ui.tp_bar = images.new(images_setup) + +ui.hp_text = texts.new(text_setup) +ui.mp_text = texts.new(text_setup) +ui.tp_text = texts.new(text_setup) + +-- setup images +function setup_image(image, path) + image:path(path) + image:repeat_xy(1, 1) + image:draggable(false) + image:fit(true) + image:show() +end + +-- setup text +function setup_text(text, theme_options) + text:bg_alpha(0) + text:bg_visible(false) + text:font(theme_options.font) + text:size(theme_options.font_size) + text:color(theme_options.font_color_red, theme_options.font_color_green, theme_options.font_color_blue) + text:stroke_transparency(theme_options.font_stroke_alpha) + text:stroke_color(theme_options.font_stroke_color_red, theme_options.font_stroke_color_green, theme_options.font_stroke_color_blue) + text:stroke_width(theme_options.font_stroke_width) + text:right_justified() + text:show() +end + +-- load the images and text +function ui:load(theme_options) + setup_image(self.background, theme_options.bar_background) + setup_image(self.hp_bar, theme_options.bar_hp) + setup_image(self.mp_bar, theme_options.bar_mp) + setup_image(self.tp_bar, theme_options.bar_tp) + setup_text(self.hp_text, theme_options) + setup_text(self.mp_text, theme_options) + setup_text(self.tp_text, theme_options) + + self:position(theme_options) +end + +-- position the images and text +function ui:position(theme_options) + local x = windower.get_windower_settings().x_res / 2 - (theme_options.total_width / 2) + theme_options.offset_x + local y = windower.get_windower_settings().y_res - 60 + theme_options.offset_y + + self.background:pos(x, y) + + self.hp_bar:pos(x + 15 + theme_options.bar_offset, y + 2) + self.mp_bar:pos(x + 25 + theme_options.bar_offset + theme_options.bar_width + theme_options.bar_spacing, y + 2) + self.tp_bar:pos(x + 35 + theme_options.bar_offset + (theme_options.bar_width*2) + (theme_options.bar_spacing*2), y + 2) + self.hp_bar:width(0) + self.mp_bar:width(0) + self.tp_bar:width(0) + + self.hp_text:pos(x + 65 + theme_options.text_offset, self.background:pos_y() + 2) + self.mp_text:pos(x + 80 + theme_options.text_offset + theme_options.bar_width + theme_options.bar_spacing, self.background:pos_y() + 2) + self.tp_text:pos(x + 90 + theme_options.text_offset + (theme_options.bar_width*2) + (theme_options.bar_spacing*2), self.background:pos_y() + 2) +end + +-- hide ui +function ui:hide() + self.background:hide() + self.hp_bar:hide() + self.hp_text:hide() + self.mp_bar:hide() + self.mp_text:hide() + self.tp_bar:hide() + self.tp_text:hide() +end + +-- show ui +function ui:show() + self.background:show() + self.hp_bar:show() + self.hp_text:show() + self.mp_bar:show() + self.mp_text:show() + self.tp_bar:show() + self.tp_text:show() +end + +return ui
\ No newline at end of file diff --git a/Data/BuiltIn/Libraries/lua-addons/addons/xivbar/variables.lua b/Data/BuiltIn/Libraries/lua-addons/addons/xivbar/variables.lua new file mode 100644 index 0000000..bd6ff74 --- /dev/null +++ b/Data/BuiltIn/Libraries/lua-addons/addons/xivbar/variables.lua @@ -0,0 +1,42 @@ +--[[ + Copyright © 2017, SirEdeonX + 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 xivbar 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 SirEdeonX 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. +]] + +local control = {} + +control.initialized = false +control.ready = false +control.hide_bars = false + +control.update_hp = false +control.update_mp = false +control.update_tp = false +control.hp_bar_width = 0 +control.mp_bar_width = 0 +control.tp_bar_width = 0 + +return control
\ No newline at end of file diff --git a/Data/BuiltIn/Libraries/lua-addons/addons/xivbar/xivbar.lua b/Data/BuiltIn/Libraries/lua-addons/addons/xivbar/xivbar.lua new file mode 100644 index 0000000..066dc72 --- /dev/null +++ b/Data/BuiltIn/Libraries/lua-addons/addons/xivbar/xivbar.lua @@ -0,0 +1,220 @@ +--[[ + Copyright © 2017, SirEdeonX + 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 xivbar 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 SirEdeonX 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. +]] + +-- Addon description +_addon.name = 'XIV Bar' +_addon.author = 'Edeon' +_addon.version = '1.0' +_addon.language = 'english' + +-- Libs +config = require('config') +texts = require('texts') +images = require('images') + +-- User settings +local defaults = require('defaults') +local settings = config.load(defaults) +config.save(settings) + +-- Load theme options according to settings +local theme = require('theme') +local theme_options = theme.apply(settings) + +-- Addon Dependencies +local ui = require('ui') +local player = require('player') +local xivbar = require('variables') + +-- initialize addon +function initialize() + ui:load(theme_options) + + local windower_player = windower.ffxi.get_player() + + if windower_player ~= nil then + player.hpp = windower_player.vitals.hpp + player.mpp = windower_player.vitals.mpp + player.current_hp = windower_player.vitals.hp + player.current_mp = windower_player.vitals.mp + player.current_tp = windower_player.vitals.tp + + player:calculate_tpp() + end + + xivbar.initialized = true +end + +-- update a bar +function update_bar(bar, text, width, current, pp, flag) + local old_width = width + local new_width = math.floor((pp / 100) * theme_options.bar_width) + + if new_width ~= nil and new_width >= 0 then + if old_width == new_width then + if new_width == 0 then + bar:hide() + end + + if flag == 1 then + xivbar.hp_update = false + elseif flag == 2 then + xivbar.update_mp = false + elseif flag == 3 then + xivbar.update_tp = false + end + else + local x = old_width + + if old_width < new_width then + x = old_width + math.ceil((new_width - old_width) * 0.1) + + x = math.min(x, theme_options.bar_width) + elseif old_width > new_width then + x = old_width - math.ceil((old_width - new_width) * 0.1) + + x = math.max(x, 0) + end + + if flag == 1 then + xivbar.hp_bar_width = x + elseif flag == 2 then + xivbar.mp_bar_width = x + elseif flag == 3 then + xivbar.tp_bar_width = x + end + + bar:size(x, theme_options.total_height) + bar:show() + end + end + + if flag == 3 and current >= 1000 then + text:color(theme_options.full_tp_color_red, theme_options.full_tp_color_green, theme_options.full_tp_color_blue) + if theme_options.dim_tp_bar then bar:alpha(255) end + else + text:color(theme_options.font_color_red, theme_options.font_color_green, theme_options.font_color_blue) + if theme_options.dim_tp_bar then bar:alpha(180) end + end + + text:text(tostring(current)) +end + +-- hide the addon +function hide() + ui:hide() + xivbar.ready = false +end + +-- show the addon +function show() + if xivbar.initialized == false then + initialize() + end + + ui:show() + xivbar.ready = true + xivbar.update_hp = true + xivbar.update_mp = true + xivbar.update_tp = true +end + + +-- Bind Events +-- ON LOAD +windower.register_event('load', function() + if windower.ffxi.get_info().logged_in then + initialize() + show() + end +end) + +-- ON LOGIN +windower.register_event('login', function() + show() +end) + +-- ON LOGOUT +windower.register_event('logout', function() + hide() +end) + +-- BIND EVENTS +windower.register_event('hp change', function(new, old) + player.current_hp = new + xivbar.update_hp = true +end) + +windower.register_event('hpp change', function(new, old) + player.hpp = new + xivbar.update_hp = true +end) + +windower.register_event('mp change', function(new, old) + player.current_mp = new + xivbar.update_mp = true +end) + +windower.register_event('mpp change', function(new, old) + player.mpp = new + xivbar.update_mp = true +end) + +windower.register_event('tp change', function(new, old) + player.current_tp = new + player:calculate_tpp() + xivbar.update_tp = true +end) + +windower.register_event('prerender', function() + if xivbar.ready == false then + return + end + + if xivbar.update_hp then + update_bar(ui.hp_bar, ui.hp_text, xivbar.hp_bar_width, player.current_hp, player.hpp, 1) + end + + if xivbar.update_mp then + update_bar(ui.mp_bar, ui.mp_text, xivbar.mp_bar_width, player.current_mp, player.mpp, 2) + end + + if xivbar.update_tp then + update_bar(ui.tp_bar, ui.tp_text, xivbar.tp_bar_width, player.current_tp, player.tpp, 3) + end +end) + +windower.register_event('status change', function(new_status_id) + if xivbar.hide_bars == false and (new_status_id == 4) then + xivbar.hide_bars = true + hide() + elseif xivbar.hide_bars and new_status_id ~= 4 then + xivbar.hide_bars = false + show() + end +end)
\ No newline at end of file |