Advertisement
Guest User

Untitled

a guest
Sep 29th, 2016
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 24.39 KB | None | 0 0
  1. local land_up = UIUtil.UIFile('/icons/units/land_up.dds')
  2. local land_down = UIUtil.UIFile('/icons/units/land_down.dds')
  3. local land_over = UIUtil.UIFile('/icons/units/land_over.dds')
  4. local divider_horizontal_bmp = UIUtil.UIFile('/game/c-q-e-panel/divider_horizontal_bmp.dds')
  5. local divider_bmp = UIUtil.UIFile('/game/c-q-e-panel/divider_bmp.dds')
  6. local arrow_vert_bmp = UIUtil.UIFile('/game/c-q-e-panel/arrow_vert_bmp.dds')
  7. local arrow_bmp = UIUtil.UIFile('/game/c-q-e-panel/arrow_bmp.dds')
  8. local selection_brackets_player_highlighted = UIUtil.UIFile('/game/selection/selection_brackets_player_highlighted.dds')
  9. local fuel = UIUtil.UIFile('/game/unit_view_icons/fuel.dds')
  10. local default_icon = UIUtil.UIFile('/icons/units/default_icon.dds')
  11. local glow = UIUtil.UIFile('/game/units_bmp/glow.dds')
  12. local OldFormatData = FormatData
  13.  
  14. local techCats = {
  15. [1] = "TECH1",
  16. [2] = "TECH2",
  17. [3] = "TECH3",
  18. [4] = "EXPERIMENTAL",
  19. }
  20.  
  21. function FormatData(unitData, type)
  22. if type == 'selection' then
  23. local retData = {}
  24.  
  25. local sortedUnits = {
  26. [1] = {cat = "ALLUNITS", units = {}},
  27. [2] = {cat = "LAND", units = {}},
  28. [3] = {cat = "AIR", units = {}},
  29. [4] = {cat = "NAVAL", units = {}},
  30. [5] = {cat = "STRUCTURE", units = {}},
  31. [6] = {cat = "SORTCONSTRUCTION", units = {}},
  32. }
  33. local lowFuelUnits = {}
  34. local idleConsUnits = {}
  35. for _, unit in unitData do
  36. local id = unit:GetBlueprint().BlueprintId
  37.  
  38. if unit:IsInCategory('AIR') and unit:GetFuelRatio() < .2 and unit:GetFuelRatio() > -1 then
  39. if not lowFuelUnits[id] then
  40. lowFuelUnits[id] = {}
  41. end
  42. table.insert(lowFuelUnits[id], unit)
  43. elseif options.gui_seperate_idle_builders ~= 0 and unit:IsInCategory('CONSTRUCTION') and unit:IsIdle() then
  44. if not idleConsUnits[id] then
  45. idleConsUnits[id] = {}
  46. end
  47. table.insert(idleConsUnits[id], unit)
  48. else
  49. local cat = 0
  50. for i, t in sortedUnits do
  51. if unit:IsInCategory(t.cat) then
  52. cat = i
  53. end
  54. end
  55. if not sortedUnits[cat].units[id] then
  56. sortedUnits[cat].units[id] = {}
  57. end
  58. table.insert(sortedUnits[cat].units[id], unit)
  59. end
  60. end
  61.  
  62. local didPutUnits = false
  63. for _, t in sortedUnits do
  64. if didPutUnits then
  65. table.insert(retData, { type = 'spacer' })
  66. didPutUnits = false
  67. end
  68. retData, didPutUnits = insertIntoTableLowestTechFirst(t.units, retData, false, false)
  69. end
  70.  
  71. if didPutUnits then
  72. table.insert(retData, { type = 'spacer' })
  73. didPutUnits = false
  74. end
  75. retData, didPutUnits = insertIntoTableLowestTechFirst(lowFuelUnits, retData, true, false)
  76.  
  77. if didPutUnits then
  78. table.insert(retData, { type = 'spacer' })
  79. didPutUnits = false
  80. end
  81. retData, didPutUnits = insertIntoTableLowestTechFirst(idleConsUnits, retData, false, true)
  82.  
  83. if retData[table.getn(retData)].type == 'spacer' then
  84. table.remove(retData, table.getn(retData))
  85. end
  86.  
  87. CreateExtraControls('selection')
  88. SetSecondaryDisplay('attached')
  89.  
  90. import(UIUtil.GetLayoutFilename('construction')).OnTabChangeLayout(type)
  91. return retData
  92. end
  93.  
  94. return OldFormatData(unitData, type)
  95. end
  96.  
  97. function insertIntoTableLowestTechFirst(units, t, isLowFuel, isIdleCon)
  98. local didInsert = false
  99. local isPut = false
  100. for _, tech in techCats do
  101. for i, v in units do
  102. if v[1]:IsInCategory(tech) then
  103. table.insert(t, { type = 'unitstack', id = i, units = v, lowFuel = isLowFuel, idleCon = isIdleCon })
  104. units[i] = nil
  105. isPut = true
  106. didInsert = true
  107. end
  108. end
  109. end
  110. --adding units without TECH category
  111. for i, v in units do
  112. table.insert(t, { type = 'unitstack', id = i, units = v, lowFuel = isLowFuel, idleCon = isIdleCon })
  113. end
  114. return t, didInsert
  115. end
  116.  
  117. function CommonLogic()
  118. controls.choices:SetupScrollControls(controls.scrollMin, controls.scrollMax, controls.pageMin, controls.pageMax)
  119. controls.secondaryChoices:SetupScrollControls(controls.secondaryScrollMin, controls.secondaryScrollMax, controls.secondaryPageMin, controls.secondaryPageMax)
  120.  
  121. controls.secondaryProgress:SetNeedsFrameUpdate(true)
  122. controls.secondaryProgress.OnFrame = function(self, delta)
  123. local frontOfQueue = sortedOptions.selection[1]
  124. if not frontOfQueue or frontOfQueue:IsDead() then
  125. return
  126. end
  127.  
  128. controls.secondaryProgress:SetValue(frontOfQueue:GetWorkProgress() or 0)
  129. if controls.secondaryChoices.top == 1 and not controls.selectionTab:IsChecked() and not controls.constructionGroup:IsHidden() then
  130. self:SetAlpha(1, true)
  131. else
  132. self:SetAlpha(0, true)
  133. end
  134. end
  135.  
  136. controls.secondaryChoices.SetControlToType = function(control, type)
  137. local function SetIconTextures(control)
  138. if DiskGetFileInfo(UIUtil.UIFile('/icons/units/' .. control.Data.id .. '_icon.dds', true)) then
  139. control.Icon:SetTexture(UIUtil.UIFile('/icons/units/' .. control.Data.id .. '_icon.dds', true))
  140. else
  141. control.Icon:SetTexture(UIUtil.UIFile('/icons/units/default_icon.dds'))
  142. end
  143. if __blueprints[control.Data.id].StrategicIconName then
  144. local iconName = __blueprints[control.Data.id].StrategicIconName
  145. if DiskGetFileInfo('/textures/ui/common/game/strategicicons/' .. iconName .. '_rest.dds') then
  146. control.StratIcon:SetTexture('/textures/ui/common/game/strategicicons/' .. iconName .. '_rest.dds')
  147. control.StratIcon.Height:Set(control.StratIcon.BitmapHeight)
  148. control.StratIcon.Width:Set(control.StratIcon.BitmapWidth)
  149. else
  150. control.StratIcon:SetSolidColor('ff00ff00')
  151. end
  152. else
  153. control.StratIcon:SetSolidColor('00000000')
  154. end
  155. end
  156.  
  157. if type == 'spacer' then
  158. if controls.secondaryChoices._vertical then
  159. control.Icon:SetTexture(UIUtil.UIFile('/game/c-q-e-panel/divider_horizontal_bmp.dds'))
  160. control.Width:Set(48)
  161. control.Height:Set(20)
  162. else
  163. control.Icon:SetTexture(UIUtil.UIFile('/game/c-q-e-panel/divider_bmp.dds'))
  164. control.Width:Set(20)
  165. control.Height:Set(48)
  166. end
  167. control.Icon.Width:Set(control.Icon.BitmapWidth)
  168. control.Icon.Height:Set(control.Icon.BitmapHeight)
  169. control.Count:SetText('')
  170. control:Disable()
  171. control.StratIcon:SetSolidColor('00000000')
  172. control:SetSolidColor('00000000')
  173. control.BuildKey = nil
  174. elseif type == 'queuestack' or type == 'attachedunit' then
  175. SetIconTextures(control)
  176. local up, down, over, dis = GetBackgroundTextures(control.Data.id)
  177. control:SetNewTextures(up, down, over, dis)
  178. control:SetOverrideTexture(down)
  179. control.tooltipID = LOC(__blueprints[control.Data.id].Description) or 'no description'
  180. control:DisableOverride()
  181. control.Height:Set(48)
  182. control.Width:Set(48)
  183. control.Icon.Height:Set(48)
  184. control.Icon.Width:Set(48)
  185. control.BuildKey = nil
  186. if control.Data.count > 1 then
  187. control.Count:SetText(control.Data.count)
  188. control.Count:SetColor('ffffffff')
  189. else
  190. control.Count:SetText('')
  191. end
  192. control.Icon:Show()
  193. control:Enable()
  194. end
  195. end
  196.  
  197. controls.secondaryChoices.CreateElement = function()
  198. local btn = FixableButton(controls.choices)
  199.  
  200. btn.Icon = Bitmap(btn)
  201. btn.Icon:DisableHitTest()
  202. LayoutHelpers.AtCenterIn(btn.Icon, btn)
  203.  
  204. btn.StratIcon = Bitmap(btn.Icon)
  205. btn.StratIcon:DisableHitTest()
  206. LayoutHelpers.AtTopIn(btn.StratIcon, btn.Icon, 4)
  207. LayoutHelpers.AtLeftIn(btn.StratIcon, btn.Icon, 4)
  208.  
  209. btn.Count = UIUtil.CreateText(btn.Icon, '', 20, UIUtil.bodyFont)
  210. btn.Count:SetColor('ffffffff')
  211. btn.Count:SetDropShadow(true)
  212. btn.Count:DisableHitTest()
  213. LayoutHelpers.AtBottomIn(btn.Count, btn, 4)
  214. LayoutHelpers.AtRightIn(btn.Count, btn, 3)
  215. btn.Count.Depth:Set(function() return btn.Icon.Depth() + 10 end)
  216.  
  217. btn.HandleEvent = function(self, event)
  218. if event.Type == 'MouseEnter' then
  219. Tooltip.CreateMouseoverDisplay(self, self.tooltipID, nil, false)
  220. elseif event.Type == 'MouseExit' then
  221. Tooltip.DestroyMouseoverDisplay()
  222. end
  223. return CustomHandleEvent(self, event)
  224. end
  225.  
  226. btn.OnRolloverEvent = OnRolloverHandler
  227. btn.OnClick = OnClickHandler
  228.  
  229. return btn
  230. end
  231.  
  232. controls.choices.CreateElement = function()
  233. local btn = FixableButton(controls.choices)
  234.  
  235. btn.Icon = Bitmap(btn)
  236. btn.Icon:DisableHitTest()
  237. LayoutHelpers.AtCenterIn(btn.Icon, btn)
  238.  
  239. btn.StratIcon = Bitmap(btn.Icon)
  240. btn.StratIcon:DisableHitTest()
  241. LayoutHelpers.AtTopIn(btn.StratIcon, btn.Icon, 4)
  242. LayoutHelpers.AtLeftIn(btn.StratIcon, btn.Icon, 4)
  243.  
  244. btn.Count = UIUtil.CreateText(btn.Icon, '', 20, UIUtil.bodyFont)
  245. btn.Count:SetColor('ffffffff')
  246. btn.Count:SetDropShadow(true)
  247. btn.Count:DisableHitTest()
  248. LayoutHelpers.AtBottomIn(btn.Count, btn)
  249. LayoutHelpers.AtRightIn(btn.Count, btn)
  250. btn.LowFuel = Bitmap(btn)
  251. btn.LowFuel:SetSolidColor('ffff0000')
  252. btn.LowFuel:DisableHitTest()
  253. LayoutHelpers.FillParent(btn.LowFuel, btn)
  254. btn.LowFuel:SetAlpha(0)
  255. btn.LowFuel:DisableHitTest()
  256. btn.LowFuel.Incrementing = 1
  257.  
  258. btn.LowFuelIcon = Bitmap(btn.LowFuel, UIUtil.UIFile('/game/unit_view_icons/fuel.dds'))
  259. LayoutHelpers.AtLeftIn(btn.LowFuelIcon, btn, 4)
  260. LayoutHelpers.AtBottomIn(btn.LowFuelIcon, btn, 4)
  261. btn.LowFuelIcon:DisableHitTest()
  262.  
  263. btn.LowFuel.OnFrame = function(glow, elapsedTime)
  264. local curAlpha = glow:GetAlpha()
  265. curAlpha = curAlpha + (elapsedTime * glow.Incrementing)
  266. if curAlpha > .4 then
  267. curAlpha = .4
  268. glow.Incrementing = -1
  269. elseif curAlpha < 0 then
  270. curAlpha = 0
  271. glow.Incrementing = 1
  272. end
  273. glow:SetAlpha(curAlpha)
  274. end
  275.  
  276. btn.HandleEvent = function(self, event)
  277. if event.Type == 'MouseEnter' then
  278. Tooltip.CreateMouseoverDisplay(self, self.tooltipID, nil, false)
  279. elseif event.Type == 'MouseExit' then
  280. Tooltip.DestroyMouseoverDisplay()
  281. end
  282. return CustomHandleEvent(self, event)
  283. end
  284.  
  285. btn.OnRolloverEvent = OnRolloverHandler
  286. btn.OnClick = OnClickHandler
  287.  
  288. return btn
  289. end
  290.  
  291. controls.choices.SetControlToType = function(control, type)
  292. local function SetIconTextures(control, optID)
  293. local id = optID or control.Data.id
  294. if DiskGetFileInfo(UIUtil.UIFile('/icons/units/' .. id .. '_icon.dds', true)) then
  295. control.Icon:SetTexture(UIUtil.UIFile('/icons/units/' .. id .. '_icon.dds', true))
  296. else
  297. control.Icon:SetTexture(UIUtil.UIFile('/icons/units/default_icon.dds'))
  298. end
  299. if __blueprints[id].StrategicIconName then
  300. local iconName = __blueprints[id].StrategicIconName
  301. if DiskGetFileInfo('/textures/ui/common/game/strategicicons/' .. iconName .. '_rest.dds') then
  302. control.StratIcon:SetTexture('/textures/ui/common/game/strategicicons/' .. iconName .. '_rest.dds')
  303. control.StratIcon.Height:Set(control.StratIcon.BitmapHeight)
  304. control.StratIcon.Width:Set(control.StratIcon.BitmapWidth)
  305. else
  306. control.StratIcon:SetSolidColor('ff00ff00')
  307. end
  308. else
  309. control.StratIcon:SetSolidColor('00000000')
  310. end
  311. end
  312.  
  313. if type == 'arrow' then
  314. control.Count:SetText('')
  315. control:Disable()
  316. control:SetSolidColor('00000000')
  317. if controls.choices._vertical then
  318. control.Icon:SetTexture(UIUtil.UIFile('/game/c-q-e-panel/arrow_vert_bmp.dds'))
  319. control.Width:Set(48)
  320. control.Height:Set(20)
  321. else
  322. control.Icon:SetTexture(UIUtil.UIFile('/game/c-q-e-panel/arrow_bmp.dds'))
  323. control.Width:Set(20)
  324. control.Height:Set(48)
  325. end
  326. control.Icon.Depth:Set(function() return control.Depth() + 5 end)
  327. control.Icon.Height:Set(control.Icon.BitmapHeight)
  328. control.Icon.Width:Set(30)
  329. control.Icon:Show()
  330. control.StratIcon:SetSolidColor('00000000')
  331. control.StratIcon:Hide()
  332. control.LowFuel:SetAlpha(0, true)
  333. control.LowFuel:SetNeedsFrameUpdate(false)
  334. control.BuildKey = nil
  335. elseif type == 'spacer' then
  336. if controls.choices._vertical then
  337. control.Icon:SetTexture(UIUtil.UIFile('/game/c-q-e-panel/divider_horizontal_bmp.dds'))
  338. control.Width:Set(48)
  339. control.Height:Set(20)
  340. else
  341. control.Icon:SetTexture(UIUtil.UIFile('/game/c-q-e-panel/divider_bmp.dds'))
  342. control.Width:Set(20)
  343. control.Height:Set(48)
  344. end
  345. control.Icon.Width:Set(control.Icon.BitmapWidth)
  346. control.Icon.Height:Set(control.Icon.BitmapHeight)
  347. control.Count:SetText('')
  348. control:Disable()
  349. control.StratIcon:SetSolidColor('00000000')
  350. control:SetSolidColor('00000000')
  351. control.LowFuel:SetAlpha(0, true)
  352. control.LowFuel:SetNeedsFrameUpdate(false)
  353. control.BuildKey = nil
  354. elseif type == 'enhancement' then
  355. control.Icon:SetSolidColor('00000000')
  356. local up, down, over, _, selected = GetEnhancementTextures(control.Data.unitID, control.Data.icon)
  357. control:SetNewTextures(up, down, over, up)
  358. control:SetOverrideTexture(selected)
  359. control.tooltipID = LOC(control.Data.enhTable.Name) or 'no description'
  360. control:SetOverrideEnabled(control.Data.Selected)
  361. control.Height:Set(48)
  362. control.Width:Set(48)
  363. control.Icon.Height:Set(48)
  364. control.Icon.Width:Set(48)
  365. control.Icon.Depth:Set(function() return control.Depth() + 1 end)
  366. control.Count:SetText('')
  367. control.StratIcon:SetSolidColor('00000000')
  368. control.LowFuel:SetAlpha(0, true)
  369. control.LowFuel:SetNeedsFrameUpdate(false)
  370. control.BuildKey = nil
  371. if control.Data.Disabled then
  372. control:Enable()
  373. control.Data.TooltipOnly = true
  374. if not control.Data.Selected then
  375. control.Icon:SetSolidColor('aa000000')
  376. end
  377. else
  378. control.Data.TooltipOnly = false
  379. control:Enable()
  380. end
  381. elseif type == 'templates' then
  382. control:DisableOverride()
  383. SetIconTextures(control, control.Data.template.icon)
  384. control:SetNewTextures(GetBackgroundTextures(control.Data.template.icon))
  385. control.Height:Set(48)
  386. control.Width:Set(48)
  387. if control.Data.template.icon then
  388. control.Icon:SetTexture(UIUtil.UIFile('/icons/units/' .. control.Data.template.icon .. '_icon.dds', true))
  389. else
  390. control.Icon:SetTexture('/textures/ui/common/icons/units/default_icon.dds')
  391. end
  392. control.Icon.Height:Set(48)
  393. control.Icon.Width:Set(48)
  394. control.Icon.Depth:Set(function() return control.Depth() + 1 end)
  395. control.StratIcon:SetSolidColor('00000000')
  396. control.tooltipID = control.Data.template.name or 'no description'
  397. control.BuildKey = control.Data.template.key
  398. if showBuildIcons and control.Data.template.key then
  399. control.Count:SetText(string.char(control.Data.template.key) or '')
  400. control.Count:SetColor('ffff9000')
  401. else
  402. control.Count:SetText('')
  403. end
  404. control.Icon:Show()
  405. control:Enable()
  406. control.LowFuel:SetAlpha(0, true)
  407. control.LowFuel:SetNeedsFrameUpdate(false)
  408. elseif type == 'item' then
  409. SetIconTextures(control)
  410. control:SetNewTextures(GetBackgroundTextures(control.Data.id))
  411. local _, down = GetBackgroundTextures(control.Data.id)
  412. control.tooltipID = LOC(__blueprints[control.Data.id].Description) or 'no description'
  413. control:SetOverrideTexture(down)
  414. control:DisableOverride()
  415. control.Height:Set(48)
  416. control.Width:Set(48)
  417. control.Icon.Height:Set(48)
  418. control.Icon.Width:Set(48)
  419. control.Icon.Depth:Set(function() return control.Depth() + 1 end)
  420. control.BuildKey = nil
  421. if showBuildIcons then
  422. local unitBuildKeys = BuildMode.GetUnitKeys(sortedOptions.selection[1]:GetBlueprint().BlueprintId, GetCurrentTechTab())
  423. control.Count:SetText(unitBuildKeys[control.Data.id] or '')
  424. control.Count:SetColor('ffff9000')
  425. else
  426. control.Count:SetText('')
  427. end
  428. control.Icon:Show()
  429. control:Enable()
  430. control.LowFuel:SetAlpha(0, true)
  431. control.LowFuel:SetNeedsFrameUpdate(false)
  432. elseif type == 'unitstack' then
  433. SetIconTextures(control)
  434. control:SetNewTextures(GetBackgroundTextures(control.Data.id))
  435. control.tooltipID = LOC(__blueprints[control.Data.id].Description) or 'no description'
  436. control:DisableOverride()
  437. control.Height:Set(48)
  438. control.Width:Set(48)
  439. control.Icon.Height:Set(48)
  440. control.Icon.Width:Set(48)
  441. control.LowFuel:SetAlpha(0, true)
  442. control.BuildKey = nil
  443. if control.Data.lowFuel then
  444. control.LowFuel:SetNeedsFrameUpdate(true)
  445. control.LowFuelIcon:SetAlpha(1)
  446. else
  447. control.LowFuel:SetNeedsFrameUpdate(false)
  448. end
  449. if table.getn(control.Data.units) > 1 then
  450. control.Count:SetText(table.getn(control.Data.units))
  451. control.Count:SetColor('ffffffff')
  452. else
  453. control.Count:SetText('')
  454. end
  455. control.Icon:Show()
  456. control:Enable()
  457. end
  458. end
  459. if options.gui_bigger_strat_build_icons ~= 0 then
  460. local oldSecondary = controls.secondaryChoices.SetControlToType
  461. local oldPrimary = controls.choices.SetControlToType
  462. -- norem add idle icon to buttons
  463. local oldPrimaryCreate = controls.choices.CreateElement
  464. controls.choices.CreateElement = function()
  465. local btn = oldPrimaryCreate()
  466. btn.IdleIcon = Bitmap(btn.Icon, UIUtil.SkinnableFile('/game/idle_mini_icon/idle_icon.dds'))
  467. LayoutHelpers.AtBottomIn(btn.IdleIcon, btn)
  468. LayoutHelpers.AtLeftIn(btn.IdleIcon, btn)
  469. btn.IdleIcon:DisableHitTest()
  470. btn.IdleIcon:SetAlpha(0)
  471. return btn
  472. end
  473. controls.secondaryChoices.SetControlToType = function(control, type)
  474. oldSecondary(control, type)
  475. if control.StratIcon.Underlay then
  476. control.StratIcon.Underlay:Hide()
  477. end
  478. StratIconReplacement(control)
  479. end
  480. controls.choices.SetControlToType = function(control, type)
  481. oldPrimary(control, type)
  482. if control.StratIcon.Underlay then
  483. control.StratIcon.Underlay:Hide()
  484. end
  485. StratIconReplacement(control)
  486.  
  487. -- AZ improved selection code
  488. if type == 'unitstack' and control.Data.idleCon then
  489. control.IdleIcon:SetAlpha(1)
  490. end
  491. end
  492. else -- If we dont have bigger strat icons selected, just do the idle icon
  493. local oldSecondary = controls.secondaryChoices.SetControlToType
  494. local oldPrimary = controls.choices.SetControlToType
  495. -- norem add idle icon to buttons
  496. local oldPrimaryCreate = controls.choices.CreateElement
  497. controls.choices.CreateElement = function()
  498. local btn = oldPrimaryCreate()
  499. btn.IdleIcon = Bitmap(btn.Icon, UIUtil.SkinnableFile('/game/idle_mini_icon/idle_icon.dds'))
  500. LayoutHelpers.AtBottomIn(btn.IdleIcon, btn)
  501. LayoutHelpers.AtLeftIn(btn.IdleIcon, btn)
  502. btn.IdleIcon:DisableHitTest()
  503. btn.IdleIcon:SetAlpha(0)
  504. return btn
  505. end
  506. controls.secondaryChoices.SetControlToType = function(control, type)
  507. oldSecondary(control, type)
  508. end
  509. controls.choices.SetControlToType = function(control, type)
  510. oldPrimary(control, type)
  511. -- AZ improved selection code
  512. if type == 'unitstack' and control.Data.idleCon then
  513. control.IdleIcon:SetAlpha(1)
  514. end
  515. end
  516. end
  517.  
  518. if options.gui_visible_template_names ~= 0 then
  519. local oldSecondary = controls.secondaryChoices.SetControlToType
  520. local oldPrimary = controls.choices.SetControlToType
  521. local oldPrimaryCreate = controls.choices.CreateElement
  522. controls.choices.CreateElement = function()
  523. local btn = oldPrimaryCreate()
  524. -- creating the display area
  525. btn.Tmplnm = UIUtil.CreateText(btn.Icon, '', 11, UIUtil.bodyFont)
  526. btn.Tmplnm:SetColor('ffffff00')
  527. btn.Tmplnm:DisableHitTest()
  528. btn.Tmplnm:SetDropShadow(true)
  529. btn.Tmplnm:SetCenteredHorizontally(true)
  530. LayoutHelpers.CenteredBelow(btn.Tmplnm, btn, 0)
  531. btn.Tmplnm.Depth:Set(function() return btn.Icon.Depth() + 10 end)
  532. return btn
  533. end
  534. controls.secondaryChoices.SetControlToType = function(control, type)
  535. oldSecondary(control, type)
  536. end
  537. controls.choices.SetControlToType = function(control, type)
  538. oldPrimary(control, type)
  539. -- the text
  540. if type == 'templates' and 'templates' then
  541. control.Tmplnm.Width:Set(48)
  542. control.Tmplnm:SetText(string.sub(control.Data.template.name, cutA, cutB))
  543. end
  544. end
  545. end
  546. end
  547. function CustomHandleEvent(self, event)
  548. local eventHandled = false
  549.  
  550. if event.Type == 'MouseEnter' then
  551. if self.mAltToggledFlag then
  552. self:SetTexture(self.mAltHighlight)
  553. else
  554. self:SetTexture(self.mHighlight)
  555. end
  556. self:OnRolloverEvent('enter')
  557. self:Play()
  558. self.mMouseOver = true
  559. eventHandled = true
  560. elseif event.Type == 'MouseExit' then
  561. if self.mAltToggledFlag then
  562. self:SetTexture(self.mAltNormal)
  563. else
  564. self:SetTexture(self.mNormal)
  565. end
  566. self:OnRolloverEvent('exit')
  567. self:Play()
  568. self.mMouseOver = false
  569. eventHandled = true
  570. elseif event.Type == 'ButtonPress' or event.Type == 'ButtonDClick' then
  571. self:OnClick(event.Modifiers)
  572. self:Play()
  573. eventHandled = true
  574. end
  575.  
  576. return eventHandled
  577. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement