Advertisement
Guest User

PureConstants.lua

a guest
Nov 8th, 2018
169
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 5.78 KB | None | 0 0
  1. --[[
  2.     This application is free software: you can redistribute it and/or modify
  3.     it under the terms of the GNU General Public License as published by
  4.     the Free Software Foundation, either version 3 of the License, or
  5.     (at your option) any later version.
  6.  
  7.     The applications is distributed in the hope that it will be useful,
  8.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  9.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  10.     GNU General Public License for more details.
  11.  
  12.     You should have received a copy of the GNU General Public License
  13.     along with the applications.  If not, see <http://www.gnu.org/licenses/>.
  14. --]]
  15.  
  16. if not PureConstants then PureConstants = {} end
  17.  
  18. local PureConstants = PureConstants
  19. local pairs         = pairs
  20. local ipairs        = ipairs
  21. local tsort         = table.sort
  22. local tinsert       = table.insert
  23. local string_format = string.format
  24.  
  25. local T     = LibStub( "WAR-AceLocale-3.0" ) : GetLocale( "Pure" )
  26. local LSA   = LibStub( "LibSharedAssets" )
  27.  
  28. PureConstants.Layers        = {}
  29. PureConstants.Layers[1] = { value=Window.Layers.BACKGROUND,     locale=T["Background"] }
  30. PureConstants.Layers[2] = { value=Window.Layers.DEFAULT,        locale=T["Default"] }
  31. PureConstants.Layers[3] = { value=Window.Layers.SECONDARY,      locale=T["Secondary"] }
  32. PureConstants.Layers[4] = { value=Window.Layers.POPUP,          locale=T["Popup"] }
  33. PureConstants.Layers[5] = { value=Window.Layers.OVERLAY,        locale=T["Overlay"] }
  34.  
  35. -- Texture Configuration Information
  36. PureConstants.Textures      = {}
  37. PureConstants.TextureNames  = {}
  38.  
  39. if LSA then
  40.     -- Retrieve the textures from LSA
  41.     PureConstants.Textures = LSA:GetTextureList() or {}
  42.    
  43.     -- Sort the textures
  44.     tsort( PureConstants.Textures )
  45.    
  46.     -- Build the texture name table
  47.     for index, texture in ipairs( PureConstants.Textures )
  48.     do
  49.         -- Reverse the lookup
  50.         PureConstants.Textures[texture] = index
  51.        
  52.         -- Attempt to retrieve any meta data for the texture
  53.         local meta = LSA:GetMetadata( texture )
  54.        
  55.         if( meta and meta.displayname ) then
  56.             PureConstants.TextureNames[index] = meta.displayname
  57.         else
  58.             PureConstants.TextureNames[index] = towstring( texture )
  59.         end
  60.     end
  61. end
  62.  
  63. -- Anchor Configuration Information    ( "top", "bottom", "left", "right" )
  64. PureConstants.Anchors       = {}
  65. PureConstants.Anchors[1]    = { config="top",       locale=T["Top"] }
  66. PureConstants.Anchors[2]    = { config="bottom",    locale=T["Bottom"] }
  67. PureConstants.Anchors[3]    = { config="left",      locale=T["Left"] }
  68. PureConstants.Anchors[4]    = { config="right",     locale=T["Right"] }
  69.  
  70. PureConstants.AnchorsLookup = {}
  71. for k,v in ipairs( PureConstants.Anchors )
  72. do
  73.     PureConstants.AnchorsLookup[v.config] = k
  74. end
  75.  
  76. -- Growth Direction Configuration Information ( "up", "down", "left", "right" )
  77. PureConstants.GrowthDirections      = {}
  78. PureConstants.GrowthDirections[1]   = { config="up",        locale=T["Up"] }
  79. PureConstants.GrowthDirections[2]   = { config="down",      locale=T["Down"] }
  80. PureConstants.GrowthDirections[3]   = { config="left",      locale=T["Left"] }
  81. PureConstants.GrowthDirections[4]   = { config="right",     locale=T["Right"] }
  82.  
  83. PureConstants.GrowthDirectionsLookup    = {}
  84. for k,v in ipairs( PureConstants.GrowthDirections )
  85. do
  86.     PureConstants.GrowthDirectionsLookup[v.config] = k
  87. end
  88.  
  89. -- Player value replacement definitions
  90. PureConstants.PlayerHitPointReplacement = {
  91.     ["curhp"] = {
  92.         func = function()
  93.             return string_format( "%s",GameData.Player.hitPoints.current )
  94.         end,       
  95.     },
  96.    
  97.     ["curhpf"] = {
  98.         func = function()
  99.             return Pure.FormatLargeValue( GameData.Player.hitPoints.current )
  100.         end,       
  101.     },
  102.     ["maxhp"] = {
  103.         func = function()
  104.             return string_format( "%s",GameData.Player.hitPoints.maximum )
  105.         end,       
  106.     },
  107.     ["maxhpf"] = {
  108.         func = function()
  109.             return Pure.FormatLargeValue( GameData.Player.hitPoints.maximum )
  110.         end,       
  111.     },
  112.     ["ndefhp"] = {
  113.         func = function()
  114.             local def = GameData.Player.hitPoints.maximum - GameData.Player.hitPoints.current
  115.             if( def == 0 ) then return "" end
  116.             return string_format( "%s", def * -1 )
  117.         end,       
  118.     },
  119.     ["ndefhpf"] = {
  120.         func = function()
  121.             local def = GameData.Player.hitPoints.maximum - GameData.Player.hitPoints.current
  122.             if( def == 0 ) then return "" end
  123.             return "-" .. Pure.FormatLargeValue( GameData.Player.hitPoints.maximum - GameData.Player.hitPoints.current )
  124.         end,       
  125.     },
  126.     ["defhp"] = {
  127.         func = function()
  128.             local def = GameData.Player.hitPoints.maximum - GameData.Player.hitPoints.current
  129.             if( def == 0 ) then return "" end
  130.             return string_format( "%s", def )
  131.         end,       
  132.     },
  133.     ["defhpf"] = {
  134.         func = function()
  135.             local def = GameData.Player.hitPoints.maximum - GameData.Player.hitPoints.current
  136.             if( def == 0 ) then return "" end
  137.             return Pure.FormatLargeValue( GameData.Player.hitPoints.maximum - GameData.Player.hitPoints.current )
  138.         end,       
  139.     },
  140.     ["perhp"] = {
  141.     func = function()
  142.         return string_format( "%1.0f", ( GameData.Player.hitPoints.current / GameData.Player.hitPoints.maximum ) * 100 )
  143.     end,       
  144.     },
  145. }
  146.  
  147. PureConstants.PlayerActionPointReplacement = {
  148.     ["curap"] = {
  149.         func = function()
  150.             return string_format( "%s",GameData.Player.actionPoints.current )
  151.         end,       
  152.     },
  153.    
  154.     ["maxap"] = {
  155.         func = function()
  156.             return string_format( "%s",GameData.Player.actionPoints.maximum )
  157.         end,       
  158.     },
  159.     ["ndefap"] = {
  160.         func = function()
  161.             local def = GameData.Player.actionPoints.maximum - GameData.Player.actionPoints.current
  162.             if( def == 0 ) then return "" end
  163.             return string_format( "%s", def * -1 )
  164.         end,       
  165.     },
  166.     ["defap"] = {
  167.         func = function()
  168.             return string_format( "%s", GameData.Player.actionPoints.maximum - GameData.Player.actionPoints.current )
  169.         end,       
  170.     },
  171.     ["perap"] = {
  172.         func = function()
  173.             return string_format( "%1.0f", ( GameData.Player.actionPoints.current / GameData.Player.actionPoints.maximum ) * 100 )
  174.         end,       
  175.     },
  176. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement