Advertisement
Guest User

sw_theme.lua

a guest
Dec 30th, 2019
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.89 KB | None | 0 0
  1. MCS.Themes["Star Wars"] = {}
  2.  
  3. local Image_top = "mcs_ui/hn_top.png"
  4. local Image_but = "mcs_ui/hn_but.png"
  5. local Image_opt = "mcs_ui/hn_opt.png"
  6.  
  7. MCS.Themes["Star Wars"].Menu = function(npc, test)
  8.  
  9. if !IsValid(npc) and !test then return end
  10. // Fonts
  11. local AnswersFont, NPCFont, AnswersAlign = "MCS_HKMain", "MCS_HKSub", TEXT_ALIGN_CENTER
  12. // Colors
  13. local NPCTextColor, TextColor, HighlightColor = MCS.Config.NPCTextColor, MCS.Config.TextColor, MCS.Config.HighlightColor
  14.  
  15. local dialogs = (test and test.dialogs) or MCS.Spawns[npc:GetUID()].dialogs
  16.  
  17. local dialog = dialogs[1]
  18.  
  19. local textt = dialog["Line"]
  20. local time = CurTime()
  21. local pos, showhint = 0, true
  22. local fade, fade2 = 0, 0
  23.  
  24. local subf
  25. local subl
  26.  
  27. local mainf = vgui.Create( "DFrame" )
  28. mainf:SetSize( ScrW(), ScrH() )
  29. mainf:Center()
  30. mainf:MakePopup()
  31. mainf:SetDraggable( false )
  32. mainf:ShowCloseButton( MCS.Config.DebugMode )
  33. mainf:SetTitle( "" )
  34. mainf.OnClose = function()
  35. if subf then
  36. subf:OnClose()
  37. end
  38. if npc and npc:GetInputLimit() then
  39. net.Start( "CloseMCSMenu" )
  40. net.WriteEntity(npc)
  41. net.SendToServer()
  42. end
  43. end
  44. mainf.Paint = function(self, w, h)
  45. if test then Derma_DrawBackgroundBlur( self, self.startTime ) end
  46. if fade < 255 then
  47. fade = Lerp(FrameTime() * 3, fade, 255)
  48. end
  49. surface.SetFont("MCS_HKBIG")
  50. local tw, th = surface.GetTextSize((npc and npc:GetNamer()) or test.name)
  51.  
  52. surface.SetDrawColor(0,0,0,math.Clamp(fade,0,120))
  53. surface.SetMaterial(Material("gui/center_gradient.vtf"))
  54. surface.DrawTexturedRect(50,h-120-th/2,tw,th-20)
  55.  
  56. draw.SimpleTextOutlined( (npc and npc:GetNamer()) or test.name , "MCS_HKBIG", 50, h-130, Color(255,255,255,fade), TEXT_ALIGN_LEFT, 1, 1, Color(0,0,0,fade))
  57.  
  58.  
  59. surface.SetDrawColor(0,0,0,math.Clamp(fade,0,250))
  60. surface.SetMaterial(Material("gui/center_gradient.vtf"))
  61. surface.DrawTexturedRect(w/8,h/8,w-w/4,h/4-10)
  62.  
  63.  
  64. surface.SetDrawColor(255,255,255,math.Clamp(fade,0,255))
  65. surface.SetMaterial(Material(Image_top))
  66. surface.DrawTexturedRect(w/8+((w-w/4)/2-300),h/8-50,600,80)
  67. surface.SetMaterial(Material(Image_but))
  68. surface.DrawTexturedRect(w/8+((w-w/4)/2-200),h/8+(h/4-40),400,60)
  69.  
  70. if showhint then
  71. local skipb = TextColor
  72. skipb.a = 100+math.sin( CurTime()*5)*55
  73. draw.SimpleTextOutlined( MCS.Config.SkipButton , AnswersFont, w/2, h/8+(h/4+60), skipb, TEXT_ALIGN_CENTER, 1, 1, Color(0,0,0,100))
  74. end
  75.  
  76. if (!self.NextThing or self.NextThing < CurTime()) and !LocalPlayer():Alive() then
  77. self.NextThing = CurTime() + 1
  78. self:Close()
  79. end
  80. end
  81.  
  82. local function OpenDialogue(dialog)
  83.  
  84. if subf then subf:Close() end
  85. if subl then subl:Remove() end
  86. fade2, showhint = 0, 0, true
  87.  
  88. textt = dialog["Line"]
  89. time = CurTime()
  90. pos = 0
  91.  
  92. local snd
  93. local textspd = math.Clamp(MCS.Config.TextSpeed, 1, 10)
  94.  
  95. if dialog["Sound"] then
  96. snd = CreateSound(LocalPlayer(), dialog["Sound"])
  97. end
  98.  
  99. subf = vgui.Create( "DFrame", mainf )
  100. subf:SetSize( mainf:GetWide()-mainf:GetWide()/4, mainf:GetTall()/4-10 )
  101. subf:SetPos(mainf:GetWide()/8,mainf:GetTall()/8)
  102. subf:SetDraggable( false )
  103. subf:ShowCloseButton( false )
  104. subf:SetTitle( "" )
  105. subf.OnClose = function()
  106. if snd then
  107. snd:Stop()
  108. end
  109. end
  110. subf.Paint = function(self, w, h)
  111. if pos >= string.len(textt) then
  112. fade2 = Lerp(FrameTime() * 3, fade2, 255)
  113. showhint = false
  114. end
  115. end
  116.  
  117. local npctext = vgui.Create( "RichText", subf )
  118. npctext:SetSize( subf:GetWide(), subf:GetTall()-40 )
  119. npctext:SetPos( 20,20)
  120. npctext.Paint = function(self, w, h)
  121. self:SetFontInternal( NPCFont )
  122. self:SetFGColor( NPCTextColor )
  123.  
  124. if (CurTime() > time) and pos < string.len(textt) and fade > 150 then
  125. pos = pos + 1
  126. time = CurTime() + FrameTime() * textspd
  127.  
  128. if MCSruscheck(string.sub(textt, pos, pos+1)) then
  129. pos = pos + 1
  130. local addtext = string.sub(textt, pos-1, pos)
  131. self:AppendText(addtext)
  132. else
  133.  
  134. self:AppendText(string.sub(textt, pos, pos))
  135. end
  136.  
  137.  
  138. if input.IsMouseDown( MOUSE_FIRST ) then
  139. time = CurTime() + 10
  140. pos = string.len(textt)
  141. self:SetText(textt)
  142. showhint = false
  143. end
  144. if snd then
  145. snd:Play()
  146. end
  147.  
  148. end
  149.  
  150. end
  151.  
  152. subl = vgui.Create( "DFrame", mainf )
  153. subl:SetSize( mainf:GetWide()-mainf:GetWide()/4, mainf:GetTall()/4-60 )
  154. subl:SetPos(mainf:GetWide()/8,mainf:GetTall()/8+mainf:GetTall()/4+60)
  155. subl:SetDraggable( false )
  156. subl:ShowCloseButton( false )
  157. subl:SetTitle( "" )
  158. subl.Paint = function( self, w, h )
  159. surface.SetDrawColor(0,0,0,math.Clamp(fade2,0,250))
  160. surface.SetMaterial(Material("gui/center_gradient.vtf"))
  161. surface.DrawTexturedRect(0,0,w,h)
  162. end
  163.  
  164. local slist = vgui.Create( "DPanelList", subl )
  165. slist:SetSize( subl:GetWide()-40, subl:GetTall()-40 )
  166. slist:SetPos(20,20)
  167. slist:EnableVerticalScrollbar( true )
  168. slist:EnableHorizontal( false )
  169. slist:SetSpacing( 5 )
  170. slist.Paint = function( self, w, h ) end
  171. slist.VBar.Paint = function( s, w, h ) draw.RoundedBox( 4, 3, 13, 8, h-24, Color(0,0,0,70)) end
  172. slist.VBar.btnUp.Paint = function( s, w, h ) end
  173. slist.VBar.btnDown.Paint = function( s, w, h ) end
  174. slist.VBar.btnGrip.Paint = function( s, w, h )draw.RoundedBox( 4, 5, 0, 4, h+22, Color(0,0,0,70)) end
  175.  
  176. local function OpenDialogueLine(k, ans)
  177.  
  178. local ab = vgui.Create( "DButton", bg )
  179. ab:SetSize( slist:GetWide()-10, 35 )
  180. ab:SetText( "" )
  181. ab:SetTextColor( Color( 255, 255, 255, 255 ) )
  182. ab.fade = 0
  183. ab.Paint = function( self, w, h )
  184.  
  185. if fade2 < 1 then return end
  186.  
  187. if self.hover then
  188. self.fade = Lerp(FrameTime() * 3, self.fade, 255)
  189. else
  190. self.fade = 0
  191. end
  192.  
  193. local x = 0
  194.  
  195. if AnswersAlign == TEXT_ALIGN_CENTER then
  196. x = w/2
  197. elseif AnswersAlign == TEXT_ALIGN_RIGHT then
  198. x = w
  199. end
  200.  
  201. if self.hover then
  202. surface.SetFont(AnswersFont)
  203. local tw, th = surface.GetTextSize(ans[1])
  204.  
  205. surface.SetDrawColor(255,255,255,math.Clamp(self.fade,0,110))
  206. surface.SetMaterial(Material("gui/center_gradient.vtf"))
  207. surface.DrawTexturedRect(w/2-tw/2-24,0,tw+48,h)
  208.  
  209. surface.SetDrawColor(255,255,255,math.Clamp(self.fade,0,255))
  210. surface.SetMaterial(Material(Image_opt))
  211. surface.DrawTexturedRectRotated(w/2-tw/2-30,h/2,44,35,180)
  212. surface.DrawTexturedRect(w/2+tw/2+8,0,44,35)
  213. end
  214.  
  215. draw.SimpleTextOutlined( ans[1] , AnswersFont, w/2, h/2, Color(255,255,255,fade2), TEXT_ALIGN_CENTER, 1, 1, Color(0,0,0,fade2))
  216.  
  217. end
  218. ab.DoClick = function()
  219. if fade2 > 200 then
  220. if isnumber(ans[2]) and dialogs[ans[2]] then
  221. OpenDialogue(dialogs[ans[2]])
  222. else
  223. if MCS.AddonList[ans[2]] and MCS.AddonList[ans[2]]["enabled"] then
  224. if MCS.AddonList[ans[2]]["function"] then
  225. MCS.AddonList[ans[2]]["function"]()
  226. end
  227.  
  228. if MCS.AddonList[ans[2]]["function_sv"] then
  229. net.Start( "StartMCSSvFunc" )
  230. net.WriteString(ans[2])
  231. net.SendToServer()
  232. end
  233. end
  234.  
  235. mainf:Close()
  236. end
  237.  
  238. if ans[3] then
  239. ans[3](npc)
  240. end
  241.  
  242. if npc and npc:GetInputLimit() and ans[5] and isstring(ans[5]) then
  243. net.Start( "StartMCSAnimation" )
  244. net.WriteEntity(npc)
  245. net.WriteString(ans[5])
  246. net.SendToServer()
  247. end
  248.  
  249. end
  250. end
  251. ab.OnCursorEntered = function( self ) self.hover = true end
  252. ab.OnCursorExited = function( self ) self.hover = false end
  253.  
  254. slist:AddItem(ab)
  255.  
  256. end
  257.  
  258. if table.IsEmpty(dialog["Answers"]) then
  259. OpenDialogueLine(1, {"...", "close"})
  260. else
  261. for k,ans in pairs(dialog["Answers"]) do
  262.  
  263. if ans[4] and !ans[4]() then
  264. continue
  265. end
  266.  
  267. OpenDialogueLine(k, ans)
  268. end
  269. end
  270. end
  271.  
  272. OpenDialogue(dialogs[1])
  273.  
  274. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement