Advertisement
Guest User

Untitled

a guest
Jun 6th, 2013
1,458
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 11.45 KB | None | 0 0
  1. --[[
  2. to do:
  3. 1) dynamically scale the tabs to the text width
  4. --]]
  5.  
  6.  
  7. -- I like to set the unused space to a dark red
  8. -- it's Red Green Blue, from 1-255, so change as you prefer!
  9. -- 0,0,0 is black
  10. setBorderColor (25, 0, 0)
  11.  
  12. -- and let's begin by creating the UI table
  13. moonlightUI = moonlightUI or {}
  14.  
  15. -- we'll set the dimensions so the screen can dynamically scale
  16. -- adjust these as you prefer, as well!
  17. moonlightUI.dimensions = {}
  18. moonlightUI.rightbar = 350
  19. moonlightUI.bottombar = 15
  20. -- oh, and set the font size for the chat windows
  21. moonlightUI.fontsize = 8
  22.  
  23. -- now, we move that pesky main window!
  24. setBorderTop (5)
  25. setBorderLeft (5)
  26. setBorderRight (moonlightUI.rightbar + 10)
  27. setBorderBottom (moonlightUI.bottombar + 4)
  28.  
  29.  
  30.  
  31.  
  32. -- ==================
  33. --  Mapper Container
  34. -- ==================
  35.  
  36. -- make a container to hold the map window
  37. moonlightUI.mappercontainer = Geyser.Container:new ({
  38.   x=0,y=0,width="100%",height="100%",name="mapper container"
  39.   })
  40. -- and put the map window in it!
  41. moonlightUI.mapper = Geyser.Mapper:new ({
  42.   name = "mapper",
  43.   x = "-" .. tostring (moonlightUI.rightbar + 5),
  44.   y = "5",
  45.   width = moonlightUI.rightbar,
  46.   height = moonlightUI.rightbar - 50,
  47.   }, moonlightUI.mappercontainer)
  48.  
  49.  
  50.  
  51. -- ==================
  52. --  Gauges Container
  53. -- ==================
  54.  
  55. -- make a container for gauges
  56. moonlightUI.gauges = Geyser.Container:new ({
  57.   name = "gauges",
  58.   x="5",
  59.   y = "-" .. tostring (moonlightUI.bottombar + 2),
  60.   width = getMainConsoleWidth (),
  61.   height= moonlightUI.bottombar,
  62.   })
  63.  
  64. -- here's your health bar
  65. moonlightUI.hpbar = Geyser.Gauge:new ({name="hpbar",x="0", y="0",width="20%", height="100%"},moonlightUI.gauges)
  66. moonlightUI.hpbar.front:setStyleSheet (
  67. [[background-color: QLinearGradient( x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #FF0000, stop: 0.2 #FF0000, stop: 0.8 #660000, stop: 1 #990000);
  68.   border-width: 1px;
  69.   border-color: black;
  70.   border-style: solid;
  71.   border-radius: 6;
  72.   ]])
  73. moonlightUI.hpbar.back:setStyleSheet (
  74. [[background-color: QLinearGradient( x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #AA0000, stop: 0.2 #AA0000, stop: 0.9 #440000, stop: 1 #660000);
  75.   border-width: 2px;
  76.   border-color: black;
  77.   border-style: solid;
  78.   border-radius: 6;
  79.   ]])
  80.  
  81. -- here's your mana bar
  82. moonlightUI.mpbar = Geyser.Gauge:new ({name="mpbar",x="20%",y="0",width="20%",height="100%"},moonlightUI.gauges)
  83. moonlightUI.mpbar.front:setStyleSheet (
  84. [[background-color: QLinearGradient( x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #4C4CFF, stop: 0.2 #4C4CFF, stop: 0.8 #1E1E66, stop: 1 #2D2D99);
  85.   border-width: 1px;
  86.   border-color: black;
  87.   border-style: solid;
  88.   border-radius: 7;
  89.   ]])
  90. moonlightUI.mpbar.back:setStyleSheet (
  91. [[background-color: QLinearGradient( x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #3131AA, stop: 0.2 #333399, stop: 0.8 #131344, stop: 1 #1D1D66);
  92.   border-width: 2px;
  93.   border-color: black;
  94.   border-style: solid;
  95.   border-radius: 7;
  96.   ]])
  97.  
  98. -- here's your endurance bar
  99. moonlightUI.edbar = Geyser.Gauge:new ({name="edbar",x="40%",y="0",width="20%",height="100%"},moonlightUI.gauges)
  100. moonlightUI.edbar.front:setStyleSheet (
  101. [[background-color: QLinearGradient( x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #FFFF38, stop: 0.2 #FFFF38, stop: 0.9 #666616, stop: 1 #999921);
  102.   border-width: 1px;
  103.   border-color: black;
  104.   border-style: solid;
  105.   border-radius: 7;
  106.   ]])
  107. moonlightUI.edbar.back:setStyleSheet (
  108. [[background-color: QLinearGradient( x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #AAAA25, stop: 0.2 #777700, stop: 0.9 #44440F, stop: 1 #666616);
  109.   border-width: 2px;
  110.   border-color: black;
  111.   border-style: solid;
  112.   border-radius: 7;
  113.   ]])
  114.  
  115. -- here's youre willpower bar
  116. moonlightUI.wpbar = Geyser.Gauge:new ({name="wpbar",x="60%",y="0",width="20%",height="100%"},moonlightUI.gauges)
  117. moonlightUI.wpbar.front:setStyleSheet (
  118. [[background-color: QLinearGradient( x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #FF00FF, stop: 0.2 #FF00FF, stop: 0.9 #660066, stop: 1 #990099);
  119.   border-width: 1px;
  120.   border-color: black;
  121.   border-style: solid;
  122.   border-radius: 7;
  123.   ]])
  124. moonlightUI.wpbar.back:setStyleSheet (
  125. [[background-color: QLinearGradient( x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #AA00AA, stop: 0.2 #AA00AA, stop: 0.9 #440044, stop: 1 #660066);
  126.   border-width: 2px;
  127.   border-color: black;
  128.   border-style: solid;
  129.   border-radius: 7;
  130.   ]])
  131.  
  132. -- and here's your xp bar
  133. moonlightUI.xpbar = Geyser.Gauge:new ({name="xpbar",x="82%",y="0",width="18%", height="100%"}, moonlightUI.gauges)
  134. moonlightUI.xpbar.front:setStyleSheet (
  135. [[background-color: QLinearGradient( x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #C8C8C8, stop: 0.2 #C8C8C8, stop: 0.9 #515151, stop: 1 #7A7A7A);
  136.   border-width: 1px;
  137.   border-color: black;
  138.   border-style: solid;
  139.   border-radius: 7;
  140.   ]])
  141. moonlightUI.xpbar.back:setStyleSheet (
  142. [[background-color: QLinearGradient( x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #898989, stop: 0.2 #898989, stop: 0.9 #383838, stop: 1 #515151);
  143.   border-width: 2px;
  144.   border-color: black;
  145.   border-style: solid;
  146.   border-radius: 7;
  147.   ]])
  148.  
  149. -- let's set some base values
  150. -- this is also your example of how to update them
  151. -- just copy to a trigger and replace the 50 with your health percent
  152. moonlightUI.hpbar:setValue (50, 100)
  153. moonlightUI.mpbar:setValue (50, 100)
  154. moonlightUI.edbar:setValue (50, 100)
  155. moonlightUI.wpbar:setValue (50, 100)
  156. moonlightUI.xpbar:setValue (50, 100)
  157.  
  158.  
  159.  
  160.  
  161. -- ================
  162. --  Chat Container
  163. -- ================
  164.  
  165. -- let's make the chat container
  166. moonlightUI.chatcontainer = Geyser.Container:new ({
  167.   name = "chatcontainer",
  168.   x = "-" .. tostring (moonlightUI.rightbar + 5),
  169.   y = -355,
  170.   width = moonlightUI.rightbar,
  171.   height = 350,
  172.   })
  173.  
  174.  
  175. -- here's something to hold the names of chat containers
  176. moonlightUI.chatcontainers = {}
  177.  
  178. -- important part: function to create a new chat window
  179. moonlightUI.createchat = function (chatname, buttoncolor)
  180.   -- prepend 'ChatBox' to the name
  181.   local chatboxname = "ChatBox" .. chatname
  182.   -- save that name in the list of chat boxes
  183.   moonlightUI.chatcontainers[#moonlightUI.chatcontainers+1] = chatboxname
  184.   -- and make the chat box!
  185.   moonlightUI[chatboxname] = Geyser.MiniConsole:new ({
  186.     name=chatboxname,
  187.     -- we'll set it against the left, 30px from the top to give room for the tabs,
  188.     -- and as wide as the chat container
  189.     x = 0, y = 30, width = "100%",
  190.     -- the height is set this way so it actually adheres to the height of the chat container
  191.     -- if you just set 100% it actually overflows by an amount equal to the chatbox 'y' value
  192.     height = tonumber((moonlightUI.chatcontainer.height:gsub("px",""))) - 30,
  193.     }, moonlightUI.chatcontainer)
  194.   -- set the buffer, wrap, and background color of the chatbox
  195.   moonlightUI[chatboxname]:setBufferSize (500000, 100)
  196.   local fontwidth, fontheight = calcFontSize (moonlightUI.fontsize)
  197.   moonlightUI[chatboxname]:setWrap (math.floor (moonlightUI.rightbar/fontwidth))
  198.   moonlightUI[chatboxname]:setColor ("black")
  199.   -- set the font size
  200.   setMiniConsoleFontSize (chatboxname, moonlightUI.fontsize)
  201.   -- prepend 'ChatButton' to the name
  202.   local chatbuttonname = "ChatButton" .. chatname
  203.   -- figure out where the button should sit
  204.   local buttonstart = (#moonlightUI.chatcontainers - 1) * 47
  205.   -- and make the chat button!
  206.   moonlightUI[chatbuttonname] = Geyser.Label:new ({
  207.     name = chatbuttonname,
  208.     -- we'll offset the buttons so they don't overlap, and set them against the top
  209.     x = buttonstart, y = 0,
  210.     -- give it some space (needs to be udpated to dynamically scale)
  211.     width = 45, height = 25,
  212.     -- set the font to black
  213.     fgColor = "black",
  214.     -- and the background to the color they wanted!
  215.     color = buttoncolor,
  216.     -- oh, don't forget the text...
  217.     message = [[<center>]] .. chatname .. [[</center>]]
  218.     }, moonlightUI.chatcontainer)
  219.   -- this is so when we click it...
  220.   moonlightUI[chatbuttonname]:setClickCallback ("moonlightUI." .. chatbuttonname .. "_press")
  221.   -- ...we call this function to switch chat windows!
  222.   moonlightUI[chatbuttonname .. "_press"] = function ()
  223.     moonlightUI.chatpress (chatboxname)
  224.   end -- func
  225.   -- now, let's make a tiny tab to indicate which is current
  226.   -- prepend 'CurrentTab' to the name
  227.   local currenttabname = "CurrentTab" .. chatname
  228.   -- now, let's make a tiny tab to indicate which is current
  229.   -- and make the chat button!
  230.   moonlightUI[currenttabname] = Geyser.Label:new ({
  231.     name = currenttabname,
  232.     -- we'll offset the buttons so they don't overlap, and set them against the top
  233.     x = buttonstart, y = 26,
  234.     -- give it some space (needs to be udpated to dynamically scale)
  235.     width = 45, height = 3,
  236.     -- and the background to the color they wanted!
  237.     color = buttoncolor,
  238.     }, moonlightUI.chatcontainer)
  239. end -- func
  240.  
  241. -- here's that function to switch chat windows
  242. moonlightUI.chatpress = function (chatname)
  243.   -- first, hide them all
  244.   for k, v in ipairs (moonlightUI.chatcontainers) do
  245.       moonlightUI[v]:hide ()
  246.       moonlightUI["CurrentTab" .. string.sub(v, 8)]:hide ()
  247.   end -- func
  248.   -- then show the one we want
  249.   moonlightUI[chatname]:show ()
  250.   moonlightUI["CurrentTab" .. string.sub(chatname, 8)]:show ()
  251. end -- func
  252.  
  253. -- and another function to send chat to window
  254. moonlightUI.sendChat = function (chatwindow, fcolor, bcolor)
  255.   -- add a newline, to avoid overcrowding
  256.   moonlightUI["ChatBox" .. chatwindow]:echo ("\n")
  257.   -- and paste in the text!
  258.   selectCurrentLine ()
  259.   -- set fcolor/bcolor 'or' to "nochange" to leave the colors as they are
  260.   -- or set fcolor/bcolor 'or' to {r,g,b} to set your own defaults
  261.   local fcolor = fcolor or "nochange"
  262.   local bcolor = bcolor or "nochange"
  263.   local _br,_bg,_bb = getBgColor ()
  264.   local _fr,_fg,_fb = getFgColor ()
  265.   if fcolor ~= "nochange" then setFgColor(fcolor[1],fcolor[2],fcolor[3]) end
  266.   if bcolor ~= "nochange" then setBgColor(bcolor[1],bcolor[2],bcolor[3]) end
  267.   copy ()
  268.   setBgColor(_br,_bg,_bb)
  269.   setFgColor(_fr,_fg,_fb)
  270.   appendBuffer ("ChatBox" .. chatwindow)
  271.   appendBuffer ("ChatBoxAll")
  272.   resetFormat ()
  273. end -- func
  274.  
  275. moonlightUI.speak = function (chatwindow, text)
  276.   cecho ("ChatBox" .. chatwindow, text)
  277. end -- func
  278.  
  279. -- finally, here we make some chat windows
  280. moonlightUI.createchat ("All", "green")
  281. moonlightUI.createchat ("Order", "red")
  282. moonlightUI.createchat ("City", "white")
  283. moonlightUI.createchat ("Tells", "yellow")
  284. moonlightUI.createchat ("Party", "brown")
  285. moonlightUI.createchat ("Combat", "grey")
  286.  
  287.  
  288.  
  289. -- this goes at the end to hide the chat windows
  290. for k, v in ipairs (moonlightUI.chatcontainers) do
  291.     moonlightUI[v]:hide ()
  292.     moonlightUI["CurrentTab" .. string.sub(v, 8)]:hide ()
  293. end -- for
  294. -- then show the first one
  295. moonlightUI[moonlightUI.chatcontainers[1]]:show ()
  296. moonlightUI["CurrentTab" .. string.sub(moonlightUI.chatcontainers[1], 8)]:show ()
  297.  
  298.  
  299. -- the following comment is how to send a trigger match to the a window
  300. --   moonlightUI.sendChat ("Order")
  301. -- the following comment is how to send it with colors specified: foreground
  302. -- is declared first, anything missing is assumed, and "nochange" means don't
  303. -- change the colors
  304. --   moonlightUI.sendChat ("Order", {255,255,255})
  305. --   moonlightUI.sendChat ("Order", {255,255,255}, {0,0,0})
  306. --   moonlightUI.sendChat ("Order", "nochange", {0,0,0})
  307.  
  308. -- the following comment is how to replace long text with a shorter version
  309. -- (this will replace it in the main window as well as the miniconsole)
  310. --[[
  311. selectString("(this is a very long clan name)", 1)
  312. setBgColor(getBgColor())
  313. setFgColor(getFgColor())
  314. replace("(shortclanname)")
  315. resetFormat ()
  316. --]]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement