Advertisement
Guest User

Untitled

a guest
Jun 25th, 2018
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 32.95 KB | None | 0 0
  1. --[[
  2.  
  3. _______ ______ ______ _____ _______ _______ ______ ______ _____ _______
  4. | |______ |_____] |_____/ | | |_____| |_____] |_____/ | | |
  5. |_____ |______ |_____] | \_ __|__ |_____ | | |_____] | \_ |_____| |_____
  6.  
  7.  
  8. MIT License
  9.  
  10. Copyright (c) 2018 BinarySpace
  11.  
  12. Permission is hereby granted, free of charge, to any person obtaining a copy
  13. of this software and associated documentation files (the "Software"), to deal
  14. in the Software without restriction, including without limitation the rights
  15. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  16. copies of the Software, and to permit persons to whom the Software is
  17. furnished to do so, subject to the following conditions:
  18.  
  19. The above copyright notice and this permission notice shall be included in all
  20. copies or substantial portions of the Software.
  21.  
  22. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  23. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  24. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  25. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  26. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  27. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  28. SOFTWARE.
  29.  
  30. --]]
  31.  
  32.  
  33. local Brikabrok = LibStub("AceAddon-3.0"):GetAddon("Brikabrok")
  34. local AceGUI = LibStub("AceGUI-3.0")
  35. local libSerializer = LibStub:GetLibrary("AceSerializer-3.0");
  36. local AceComm = LibStub("AceComm-3.0")
  37.  
  38.  
  39. function BrikabrokCONFIG:OnEnable()
  40.  
  41.  
  42. --[[
  43. ** DrawGroupDev1
  44. ** Draw the first tab for the secondary frame
  45. ** container: Which container hold this
  46. --]]
  47. function Brikabrok:DrawGroupDev1(container)
  48.  
  49. local addSpellsHeading = AceGUI:Create("Heading")
  50. addSpellsHeading:SetText("Ajouter des spells")
  51. addSpellsHeading:SetFullWidth(true)
  52. brikabrokDevScroll:AddChild(addSpellsHeading)
  53.  
  54. bkbICONSpells = AceGUI:Create("EditBox")
  55. bkbICONSpells:SetText("Interface\\Icons\\idicône")
  56. bkbICONSpells:SetPoint("CENTER")
  57. bkbICONSpells:SetLabel("Icône du spell")
  58. brikabrokDevScroll:AddChild(bkbICONSpells)
  59.  
  60. bkbSpellsICON = AceGUI:Create("Icon")
  61. bkbSpellsICON:SetImage("Interface\\Icons\\trade_engineering")
  62. bkbSpellsICON:SetImageSize(16,16)
  63. bkbSpellsICON:SetPoint("CENTER")
  64. bkbSpellsICON:SetLabel("Icône du spell")
  65. local callbacks = {
  66. OnClick = function (container, event, group)
  67. Brikabrok:ShowBrowserFrame("spells")
  68. end
  69. }
  70. Brikabrok:addCallbacks(bkbSpellsICON, callbacks)
  71. brikabrokDevScroll:AddChild(bkbSpellsICON)
  72.  
  73. local ebName = AceGUI:Create("EditBox")
  74. ebName:SetText("Nom du spell")
  75. ebName:SetPoint("CENTER")
  76. ebName:SetLabel("Nom du spell")
  77. brikabrokDevScroll:AddChild(ebName)
  78.  
  79. local ebContent = AceGUI:Create("EditBox")
  80. ebContent:SetText("Contenu ( ID Spell, Macro, ... )")
  81. ebContent:SetPoint("CENTER")
  82. ebContent:SetLabel("Contenu ( ID Spell, Macro, ... )")
  83. brikabrokDevScroll:AddChild(ebContent)
  84.  
  85. local cbCategorie = AceGUI:Create("CheckBox")
  86. cbCategorie:SetLabel("Catégorie")
  87. brikabrokDevScroll:AddChild(cbCategorie)
  88. --[[
  89. local ebType= AceGUI:Create("EditBox")
  90. ebType:SetText("rien si 'spell' 'aura' pour une aura 'cast' pour un cast 'casttr' pour un cast tr et "special" pour une macro extérieure et starterPack pour un starter pack ; "spellviskit" pour un spell visual.)
  91. ebType:SetPoint("CENTER")
  92. ebType:SetLabel("Type(semi-optionnel)")
  93. brikabrokDevScroll:AddChild(ebType)
  94. --]]
  95.  
  96. local spDataType = {
  97. spell = "Spells",
  98. aura = "Aura",
  99. cast = "Cast",
  100. casttr = "Casttr",
  101. special = "Macro",
  102. spellviskit = "Spellviskit"
  103. }
  104.  
  105.  
  106. local ebType= AceGUI:Create("Dropdown")
  107. ebType:SetList(spDataType)
  108. ebType:SetText("Type(semi-optionnel)")
  109. ebType:SetLabel("Type(semi-optionnel)")
  110. brikabrokDevScroll:AddChild(ebType)
  111. ebType:SetCallback("OnValueChanged", function(self,callback,key) keyDevDrop = key end)
  112.  
  113. local ebResult = AceGUI:Create("MultiLineEditBox")
  114. ebResult:SetText("Résultat")
  115. ebResult:SetPoint("CENTER")
  116. ebResult:SetLabel("Résultat")
  117. brikabrokDevScroll:AddChild(ebResult)
  118.  
  119. local ebButton = AceGUI:Create("Button")
  120. ebButton:SetText("Build")
  121. ebButton:SetWidth(200)
  122. ebButton:SetCallback("OnClick", function()
  123. if cbCategorie:GetValue() == true and keyDevDrop then
  124. ebResult:SetText('{"'..bkbICONSpells:GetText()..'","'..ebName:GetText()..'","'..'nil","'..ebContent:GetText()..'","'..keyDevDrop..'","categorie"} \n')
  125. table.insert(Brikabrok.db.profile.spells,{bkbICONSpells:GetText(),ebName:GetText(),nil,ebContent:GetText(),keyDevDrop,categorie})
  126. elseif cbCategorie:GetValue() == true and not keyDevDrop then
  127. Brikabrok.sendMessage("[Brikabrok] Veuillez sélectionner le type des données.","WARNING")
  128. elseif cbCategorie:GetValue() == false and keyDevDrop then
  129. ebResult:SetText('{"'..bkbICONSpells:GetText()..'","'..ebName:GetText()..'","'..'nil","'..ebContent:GetText()..'","'..keyDevDrop..'"} \n')
  130. table.insert(Brikabrok.db.profile.spells,{bkbICONSpells:GetText(),ebName:GetText(),nil,ebContent:GetText(),keyDevDrop})
  131. elseif cbCategorie:GetValue() == false and not keyDevDrop then
  132. Brikabrok.sendMessage("[Brikabrok] Veuillez sélectionner le type des données.","WARNING")
  133. end
  134. end)
  135. brikabrokDevScroll:AddChild(ebButton)
  136.  
  137.  
  138.  
  139. local DropdownSpells = {}
  140. function Brikabrok:buildTableSpells()
  141. for i=1,#Brikabrok.db.profile.spells do
  142. if not Brikabrok.db.profile.spells[i] then
  143. return false
  144. else
  145. local spName = Brikabrok.db.profile.spells[i][2]
  146. local spIcon = Brikabrok.db.profile.spells[i][1]
  147. if spIcon == nil then
  148. spIcon = "Interface\\Icons\\trade_engineering"
  149. end
  150. DropdownSpells[i] = "|T"..spIcon..":16|t "..spName
  151. end
  152. end
  153. end
  154.  
  155. local function refreshTable(widget,widget1)
  156. DropdownSpells = {}
  157. Brikabrok:buildTableSpells()
  158. end
  159.  
  160. local function tableSwap(table,firstValue,secondValue)
  161. local contentValue1 = table[firstValue]
  162. local contentValue2 = table[secondValue]
  163. table[firstValue] = contentValue2
  164. table[secondValue] = contentValue1
  165. end
  166.  
  167.  
  168. Brikabrok:buildTableSpells()
  169.  
  170.  
  171. local remSpellsHeading = AceGUI:Create("Heading")
  172. remSpellsHeading:SetText("Supprimer des spells")
  173. remSpellsHeading:SetFullWidth(true)
  174. brikabrokDevScroll:AddChild(remSpellsHeading)
  175.  
  176. local ebDelete= AceGUI:Create("Dropdown")
  177. ebDelete:SetList(DropdownSpells)
  178. ebDelete:SetText("Choissisez un spell")
  179. ebDelete:SetLabel("Choissisez un spell")
  180. brikabrokDevScroll:AddChild(ebDelete)
  181. ebDelete:SetCallback("OnValueChanged", function(self,callback,key) keyDevDrop6 = key end)
  182.  
  183. local ebButtonRemove = AceGUI:Create("Button")
  184. ebButtonRemove:SetText("Supprimer")
  185. ebButtonRemove:SetWidth(200)
  186. ebButtonRemove:SetCallback("OnClick", function() table.remove(Brikabrok.db.profile.spells,keyDevDrop6) refreshTable() ebDelete:SetList(DropdownSpells) ebDelete:SetText(DropdownSpells[keyDevDrop6+1]) end)
  187. brikabrokDevScroll:AddChild(ebButtonRemove)
  188.  
  189. local ebButtonRemoveAll = AceGUI:Create("Button")
  190. ebButtonRemoveAll:SetText("Supprimer tout")
  191. ebButtonRemoveAll:SetWidth(200)
  192. ebButtonRemoveAll:SetCallback("OnClick", function()
  193. StaticPopupDialogs["WarningDeleteSpell"] = {
  194. text = "Voulez-vous vraiment supprimer tout le contenu de vos spells ?",
  195. button1 = "Oui",
  196. button2 = "Non",
  197. OnAccept = function()
  198. wipe(Brikabrok.db.profile.spells)
  199. refreshTable()
  200. ebDelete:SetList(DropdownSpells)
  201. Brikabrok.sendMessage("[Brikabrok] Tout le contenu a été supprimé.")
  202. end,
  203. OnCancel = function()
  204. Brikabrok.sendMessage("[Brikabrok] Action annulé")
  205. end,
  206. timeout = 0,
  207. whileDead = true,
  208. hideOnEscape = true,
  209. preferredIndex = 3,
  210. }
  211. StaticPopup_Show("WarningDeleteSpell")
  212. end)
  213. brikabrokDevScroll:AddChild(ebButtonRemoveAll)
  214.  
  215. local movSpellsHeading = AceGUI:Create("Heading")
  216. movSpellsHeading:SetText("Déplacer des spells")
  217. movSpellsHeading:SetFullWidth(true)
  218. brikabrokDevScroll:AddChild(movSpellsHeading)
  219.  
  220. local ebSwap1 = AceGUI:Create("Dropdown")
  221. ebSwap1:SetList(DropdownSpells)
  222. ebSwap1:SetText("Choissisez un spell")
  223. ebSwap1:SetLabel("Premier spell")
  224. brikabrokDevScroll:AddChild(ebSwap1)
  225. ebSwap1:SetCallback("OnValueChanged", function(self,callback,key) keyDevDrop7 = key end)
  226.  
  227.  
  228. local ebSwap2 = AceGUI:Create("Dropdown")
  229. ebSwap2:SetList(DropdownSpells)
  230. ebSwap2:SetText("Choissisez un spell")
  231. ebSwap2:SetLabel("Deuxième Spell")
  232. brikabrokDevScroll:AddChild(ebSwap2)
  233. ebSwap2:SetCallback("OnValueChanged", function(self,callback,key) keyDevDrop8 = key end)
  234.  
  235. local ebButtonSwap = AceGUI:Create("Button")
  236. ebButtonSwap:SetText("Swap")
  237. ebButtonSwap:SetWidth(200)
  238. ebButtonSwap:SetCallback("OnClick", function()
  239. tableSwap(DropdownSpells,keyDevDrop7,keyDevDrop8)
  240. tableSwap(Brikabrok.db.profile.spells,keyDevDrop7,keyDevDrop8)
  241. refreshTable(ebSwap1,ebSwap2)
  242. ebSwap1:SetList(DropdownSpells)
  243. ebSwap2:SetList(DropdownSpells)
  244. ebSwap2:SetText(DropdownSpells[keyDevDrop8])
  245. ebSwap1:SetText(DropdownSpells[keyDevDrop7])
  246. end)
  247. brikabrokDevScroll:AddChild(ebButtonSwap)
  248.  
  249. local divSpellsHeading = AceGUI:Create("Heading")
  250. divSpellsHeading:SetText("Divers")
  251. divSpellsHeading:SetFullWidth(true)
  252. brikabrokDevScroll:AddChild(divSpellsHeading)
  253.  
  254. local ebButtonRefresh = AceGUI:Create("Button")
  255. ebButtonRefresh:SetText("Actualiser")
  256. ebButtonRefresh:SetWidth(200)
  257. ebButtonRefresh:SetCallback("OnClick", function() refreshTable() ebDelete:SetList(DropdownSpells) ebSwap1:SetList(DropdownSpells) ebSwap2:SetList(DropdownSpells) end)
  258. brikabrokDevScroll:AddChild(ebButtonRefresh)
  259.  
  260.  
  261.  
  262. end
  263.  
  264.  
  265. --[[
  266. ** DrawGroupDev2
  267. ** Draw the 2nd tab for the secondary frame
  268. ** container: Which container hold this
  269. --]]
  270. function Brikabrok:DrawGroupDev2(container)
  271.  
  272. local ebNameGob = AceGUI:Create("EditBox")
  273. ebNameGob:SetText("Nom du gob")
  274. ebNameGob:SetPoint("CENTER")
  275. ebNameGob:SetLabel("Nom du gob")
  276. brikabrokDevScroll:AddChild(ebNameGob)
  277.  
  278. local ebContentGob = AceGUI:Create("EditBox")
  279. ebContentGob:SetText("EntryID du Gob")
  280. ebContentGob:SetPoint("CENTER")
  281. ebContentGob:SetLabel("EntryID du Gob")
  282. brikabrokDevScroll:AddChild(ebContentGob)
  283.  
  284. bkbICONGob = AceGUI:Create("EditBox")
  285. bkbICONGob:SetText("Interface\\Icons\\idicône")
  286. bkbICONGob:SetPoint("CENTER")
  287. bkbICONGob:SetLabel("Icône du Gob")
  288. brikabrokDevScroll:AddChild(bkbICONGob)
  289.  
  290. bkbGobICON = AceGUI:Create("Icon")
  291. bkbGobICON:SetImage("Interface\\Icons\\trade_engineering")
  292. bkbGobICON:SetImageSize(16,16)
  293. bkbGobICON:SetPoint("CENTER")
  294. bkbGobICON:SetLabel("Icône du gob")
  295. local callbacks = {
  296. OnClick = function (container, event, group)
  297. Brikabrok:ShowBrowserFrame("gobs")
  298. end
  299. }
  300. Brikabrok:addCallbacks(bkbGobICON, callbacks)
  301. brikabrokDevScroll:AddChild(bkbGobICON)
  302.  
  303. --[[
  304. local ebType= AceGUI:Create("EditBox")
  305. ebType:SetText("rien si 'spell' 'aura' pour une aura 'cast' pour un cast 'casttr' pour un cast tr et "special" pour une macro extérieure et starterPack pour un starter pack ; "spellviskit" pour un spell visual.)
  306. ebType:SetPoint("CENTER")
  307. ebType:SetLabel("Type(semi-optionnel)")
  308. brikabrokDevScroll:AddChild(ebType)
  309. --]]
  310.  
  311. local gobDataType = {
  312. categorie = "Catégorie",
  313. other = "Autres",
  314. }
  315.  
  316. local ebTypeGob = AceGUI:Create("Dropdown")
  317. ebTypeGob:SetList(gobDataType)
  318. ebTypeGob:SetText("Type(semi-optionnel)")
  319. ebTypeGob:SetLabel("Type(semi-optionnel)")
  320. brikabrokDevScroll:AddChild(ebTypeGob)
  321. ebTypeGob:SetCallback("OnValueChanged", function(self,callback,key) keyDev2Drop = key end)
  322.  
  323. local ebResultGob = AceGUI:Create("MultiLineEditBox")
  324. ebResultGob:SetText("Résultat")
  325. ebResultGob:SetPoint("CENTER")
  326. ebResultGob:SetLabel("Résultat")
  327. brikabrokDevScroll:AddChild(ebResultGob)
  328.  
  329. local ebButtonGob = AceGUI:Create("Button")
  330. ebButtonGob:SetText("Build")
  331. ebButtonGob:SetWidth(200)
  332. ebButtonGob:SetCallback("OnClick", function()
  333. if keyDev2Drop then
  334. ebResultGob:SetText('{"'..ebNameGob:GetText()..'","'..ebContentGob:GetText()..'","'..'nil","'..bkbICONGob:GetText()..'","'..keyDev2Drop..'"} \n')
  335. table.insert(Brikabrok.db.profile.gobs,{ebNameGob:GetText(),ebContentGob:GetText(),nil,bkbICONGob:GetText(),keyDev2Drop})
  336. elseif not keyDev2Drop then
  337. Brikabrok.sendMessage("[Brikabrok] Veuillez sélectionner le type des données.","WARNING")
  338. end
  339. end)
  340. brikabrokDevScroll:AddChild(ebButtonGob)
  341.  
  342. local DropdownGobs = {}
  343. function Brikabrok:buildTableGobs()
  344. for i=1,#Brikabrok.db.profile.gobs do
  345. if not Brikabrok.db.profile.gobs[i] then
  346. return false
  347. else
  348. local gobName = Brikabrok.db.profile.gobs[i][1]
  349. local gobIcon = Brikabrok.db.profile.gobs[i][4]
  350. if gobIcon == nil then
  351. gobIcon = "Interface\\Icons\\trade_engineering"
  352. end
  353. DropdownGobs[i] = "|T"..gobIcon..":16|t "..gobName
  354. end
  355. end
  356. end
  357.  
  358. local function refreshTableGobs()
  359. DropdownGobs = {}
  360. Brikabrok:buildTableGobs()
  361. end
  362.  
  363. local function tableSwap(table,firstValue,secondValue)
  364. local contentValue1 = table[firstValue]
  365. local contentValue2 = table[secondValue]
  366. table[firstValue] = contentValue2
  367. table[secondValue] = contentValue1
  368. end
  369.  
  370.  
  371. Brikabrok:buildTableGobs()
  372.  
  373. local remGobsHeading = AceGUI:Create("Heading")
  374. remGobsHeading:SetText("Supprimer des gobs")
  375. remGobsHeading:SetFullWidth(true)
  376. brikabrokDevScroll:AddChild(remGobsHeading)
  377.  
  378. local ebDeleteGob = AceGUI:Create("Dropdown")
  379. ebDeleteGob:SetList(DropdownGobs)
  380. ebDeleteGob:SetText("Choissisez un gob")
  381. ebDeleteGob:SetLabel("Choissisez un gob")
  382. brikabrokDevScroll:AddChild(ebDeleteGob)
  383. ebDeleteGob:SetCallback("OnValueChanged", function(self,callback,key) keyDevDrop9 = key end)
  384.  
  385. local ebButtonRemoveGob = AceGUI:Create("Button")
  386. ebButtonRemoveGob:SetText("Supprimer")
  387. ebButtonRemoveGob:SetWidth(200)
  388. ebButtonRemoveGob:SetCallback("OnClick", function() table.remove(Brikabrok.db.profile.gobs,keyDevDrop9) refreshTableGobs() ebDeleteGob:SetList(DropdownGobs) ebDeleteGob:SetText(DropdownGobs[keyDevDrop9+1]) end)
  389. brikabrokDevScroll:AddChild(ebButtonRemoveGob)
  390.  
  391. local ebButtonRemoveAllGob = AceGUI:Create("Button")
  392. ebButtonRemoveAllGob:SetText("Supprimer tout")
  393. ebButtonRemoveAllGob:SetWidth(200)
  394. ebButtonRemoveAllGob:SetCallback("OnClick", function()
  395. StaticPopupDialogs["WarningDeleteGob"] = {
  396. text = "Voulez-vous vraiment supprimer tout le contenu de vos gobs ?",
  397. button1 = "Oui",
  398. button2 = "Non",
  399. OnAccept = function()
  400. wipe(Brikabrok.db.profile.gobs)
  401. refreshTableGobs()
  402. ebDeleteGob:SetList(DropdownGobs)
  403. Brikabrok.sendMessage("[Brikabrok] Tout le contenu a été supprimé.")
  404. end,
  405. OnCancel = function()
  406. Brikabrok.sendMessage("[Brikabrok] Action annulé")
  407. end,
  408. timeout = 0,
  409. whileDead = true,
  410. hideOnEscape = true,
  411. preferredIndex = 3,
  412. }
  413. StaticPopup_Show("WarningDeleteGob")
  414. end)
  415. brikabrokDevScroll:AddChild(ebButtonRemoveAllGob)
  416.  
  417. local movGobsHeading = AceGUI:Create("Heading")
  418. movGobsHeading:SetText("Déplacer des gobs")
  419. movGobsHeading:SetFullWidth(true)
  420. brikabrokDevScroll:AddChild(movGobsHeading)
  421.  
  422. local ebSwap1Gob = AceGUI:Create("Dropdown")
  423. ebSwap1Gob:SetList(DropdownGobs)
  424. ebSwap1Gob:SetText("Choissisez un gob")
  425. ebSwap1Gob:SetLabel("Premier Gob")
  426. brikabrokDevScroll:AddChild(ebSwap1Gob)
  427. ebSwap1Gob:SetCallback("OnValueChanged", function(self,callback,key) keyDevDrop10 = key end)
  428.  
  429. local ebSwap2Gob = AceGUI:Create("Dropdown")
  430. ebSwap2Gob:SetList(DropdownGobs)
  431. ebSwap2Gob:SetText("Choissisez un gob")
  432. ebSwap2Gob:SetLabel("Deuxième Gob")
  433. brikabrokDevScroll:AddChild(ebSwap2Gob)
  434. ebSwap2Gob:SetCallback("OnValueChanged", function(self,callback,key) keyDevDrop11 = key end)
  435.  
  436. local ebButtonSwapGob = AceGUI:Create("Button")
  437. ebButtonSwapGob:SetText("Swap")
  438. ebButtonSwapGob:SetWidth(200)
  439. ebButtonSwapGob:SetCallback("OnClick", function()
  440. tableSwap(DropdownGobs,keyDevDrop10,keyDevDrop11)
  441. tableSwap(Brikabrok.db.profile.gobs,keyDevDrop10,keyDevDrop11)
  442. refreshTableGobs()
  443. ebSwap1Gob:SetList(DropdownGobs)
  444. ebSwap2Gob:SetList(DropdownGobs)
  445. ebSwap2Gob:SetText(DropdownGobs[keyDevDrop11])
  446. ebSwap1Gob:SetText(DropdownGobs[keyDevDrop10])
  447. end)
  448. brikabrokDevScroll:AddChild(ebButtonSwapGob)
  449.  
  450. local divGobHeading = AceGUI:Create("Heading")
  451. divGobHeading:SetText("Divers")
  452. divGobHeading:SetFullWidth(true)
  453. brikabrokDevScroll:AddChild(divGobHeading)
  454.  
  455. local ebButtonRefreshGob = AceGUI:Create("Button")
  456. ebButtonRefreshGob:SetText("Actualiser")
  457. ebButtonRefreshGob:SetWidth(200)
  458. ebButtonRefreshGob:SetCallback("OnClick", function() refreshTableGobs() ebDeleteGob:SetList(DropdownGobs) ebSwap1Gob:SetList(DropdownGobs) ebSwap2Gob:SetList(DropdownGobs)end)
  459. brikabrokDevScroll:AddChild(ebButtonRefreshGob)
  460. end
  461.  
  462.  
  463.  
  464.  
  465.  
  466. function table.val_to_str ( v )
  467. if "string" == type( v ) then
  468. v = string.gsub( v, "\n", "\\n" )
  469. if string.match( string.gsub(v,"[^'\"]",""), '^"+$' ) then
  470. return "'" .. v .. "'"
  471. end
  472. return '"' .. string.gsub(v,'"', '\\"' ) .. '"'
  473. else
  474. return "table" == type( v ) and table.tostring( v ) or
  475. tostring( v )
  476. end
  477. end
  478.  
  479. function table.key_to_str ( k )
  480. if "string" == type( k ) and string.match( k, "^[_%a][_%a%d]*$" ) then
  481. return k
  482. else
  483. return "[" .. table.val_to_str( k ) .. "]"
  484. end
  485. end
  486.  
  487. function table.tostring( tbl )
  488. local result, done = {}, {}
  489. for k, v in ipairs( tbl ) do
  490. table.insert( result, table.val_to_str( v ) )
  491. done[ k ] = true
  492. end
  493. for k, v in pairs( tbl ) do
  494. if not done[ k ] then
  495. table.insert( result,
  496. table.key_to_str( k ) .. "=" .. table.val_to_str( v ) )
  497. end
  498. end
  499. return "{" .. table.concat( result, "," ) .. "}"
  500. end
  501.  
  502. --[[
  503. ** DrawGroupDev3
  504. ** Draw the 3rd tab for the secondary frame
  505. ** container: Which container hold this
  506. --]]
  507.  
  508.  
  509. function Brikabrok:DrawGroupDev3(container)
  510.  
  511. local ebContentAnim = AceGUI:Create("EditBox")
  512. ebContentAnim:SetText("ID de l'animkit")
  513. ebContentAnim:SetPoint("CENTER")
  514. ebContentAnim:SetLabel("ID de l'animkit")
  515. brikabrokDevScroll:AddChild(ebContentAnim)
  516.  
  517. local ebNameAnim = AceGUI:Create("EditBox")
  518. ebNameAnim:SetText("Nom de l'animation")
  519. ebNameAnim:SetPoint("CENTER")
  520. ebNameAnim:SetLabel("Nom de l'animation")
  521. brikabrokDevScroll:AddChild(ebNameAnim)
  522.  
  523. bkbICONAnim = AceGUI:Create("EditBox")
  524. bkbICONAnim:SetText("Interface\\Icons\\idicône")
  525. bkbICONAnim:SetPoint("CENTER")
  526. bkbICONAnim:SetLabel("Icône de l'anim")
  527. brikabrokDevScroll:AddChild(bkbICONAnim)
  528.  
  529. bkbAnimICON = AceGUI:Create("Icon")
  530. bkbAnimICON:SetImage("Interface\\Icons\\trade_engineering")
  531. bkbAnimICON:SetImageSize(16,16)
  532. bkbAnimICON:SetPoint("CENTER")
  533. bkbAnimICON:SetLabel("Icône de l'anim")
  534. local callbacks = {
  535. OnClick = function (container, event, group)
  536. Brikabrok:ShowBrowserFrame("anims")
  537. end
  538. }
  539. Brikabrok:addCallbacks(bkbAnimICON, callbacks)
  540. brikabrokDevScroll:AddChild(bkbAnimICON)
  541.  
  542. local animDataType = {
  543. categorie = "Catégorie",
  544. other = "Autres",
  545. }
  546.  
  547. local ebTypeAnim = AceGUI:Create("Dropdown")
  548. ebTypeAnim:SetList(animDataType)
  549. ebTypeAnim:SetText("Type(semi-optionnel)")
  550. ebTypeAnim:SetLabel("Type(semi-optionnel)")
  551. brikabrokDevScroll:AddChild(ebTypeAnim)
  552. ebTypeAnim:SetCallback("OnValueChanged", function(self,callback,key) keyDev3Drop = key if keyDev3Drop==other then keyDev3Drop="nil" end end)
  553.  
  554. local ebResultAnim = AceGUI:Create("MultiLineEditBox")
  555. ebResultAnim:SetText("Résultat")
  556. ebResultAnim:SetPoint("CENTER")
  557. ebResultAnim:SetLabel("Résultat")
  558. brikabrokDevScroll:AddChild(ebResultAnim)
  559.  
  560. local ebButtonAnim = AceGUI:Create("Button")
  561. ebButtonAnim:SetText("Build")
  562. ebButtonAnim:SetWidth(200)
  563. ebButtonAnim:SetCallback("OnClick", function() ebResultAnim:SetText('{"'..ebContentAnim:GetText()..'","'..ebNameAnim:GetText()..'","'..keyDev3Drop..'"}') table.insert(Brikabrok.db.profile.anim,{ebContentAnim:GetText(),ebNameAnim:GetText(),keyDev3Drop,bkbICONAnim:GetText()}) end)
  564. brikabrokDevScroll:AddChild(ebButtonAnim)
  565.  
  566. local DropdownAnims = {}
  567. function Brikabrok:buildTableAnims()
  568. for i=1,#Brikabrok.db.profile.anim do
  569. if not Brikabrok.db.profile.anim[i] then
  570. return false
  571. else
  572. local animName = Brikabrok.db.profile.anim[i][2]
  573. local animIcon = Brikabrok.db.profile.anim[i][4]
  574. if animIcon == nil then
  575. animIcon = "Interface\\Icons\\trade_engineering"
  576. end
  577. DropdownAnims[i] = "|T"..animIcon..":16|t "..animName
  578. end
  579. end
  580. end
  581.  
  582. local function refreshTableAnims()
  583. DropdownAnims = {}
  584. Brikabrok:buildTableAnims()
  585. end
  586.  
  587. local function tableSwap(table,firstValue,secondValue)
  588. local contentValue1 = table[firstValue]
  589. local contentValue2 = table[secondValue]
  590. table[firstValue] = contentValue2
  591. table[secondValue] = contentValue1
  592. end
  593.  
  594.  
  595. Brikabrok:buildTableAnims()
  596.  
  597. local remAnimHeading = AceGUI:Create("Heading")
  598. remAnimHeading:SetText("Supprimer des animations")
  599. remAnimHeading:SetFullWidth(true)
  600. brikabrokDevScroll:AddChild(remAnimHeading)
  601.  
  602. local ebDeleteAnim = AceGUI:Create("Dropdown")
  603. ebDeleteAnim:SetList(DropdownAnims)
  604. ebDeleteAnim:SetText("Choissisez un animkit")
  605. ebDeleteAnim:SetLabel("Choissisez un animkit")
  606. brikabrokDevScroll:AddChild(ebDeleteAnim)
  607. ebDeleteAnim:SetCallback("OnValueChanged", function(self,callback,key) keyDevDrop12 = key end)
  608.  
  609. local ebButtonRemoveAnim = AceGUI:Create("Button")
  610. ebButtonRemoveAnim:SetText("Supprimer")
  611. ebButtonRemoveAnim:SetWidth(200)
  612. ebButtonRemoveAnim:SetCallback("OnClick", function() table.remove(Brikabrok.db.profile.anim,keyDevDrop12) refreshTableAnims() ebDeleteAnim:SetList(DropdownAnims) ebDeleteAnim:SetText(DropdownAnims[keyDevDrop12+1]) end)
  613. brikabrokDevScroll:AddChild(ebButtonRemoveAnim)
  614.  
  615. local ebButtonRemoveAllAnim = AceGUI:Create("Button")
  616. ebButtonRemoveAllAnim:SetText("Supprimer tout")
  617. ebButtonRemoveAllAnim:SetWidth(200)
  618. ebButtonRemoveAllAnim:SetCallback("OnClick", function()
  619. StaticPopupDialogs["WarningDeleteAnim"] = {
  620. text = "Voulez-vous vraiment supprimer tout le contenu de vos animations ?",
  621. button1 = "Oui",
  622. button2 = "Non",
  623. OnAccept = function()
  624. wipe(Brikabrok.db.profile.anim)
  625. refreshTableAnims()
  626. ebDeleteAnim:SetList(DropdownAnims)
  627. Brikabrok.sendMessage("[Brikabrok] Tout le contenu a été supprimé.")
  628. end,
  629. OnCancel = function()
  630. Brikabrok.sendMessage("[Brikabrok] Action annulé")
  631. end,
  632. timeout = 0,
  633. whileDead = true,
  634. hideOnEscape = true,
  635. preferredIndex = 3,
  636. }
  637. StaticPopup_Show("WarningDeleteAnim")
  638. end)
  639. brikabrokDevScroll:AddChild(ebButtonRemoveAllAnim)
  640.  
  641. local movAnimsHeading = AceGUI:Create("Heading")
  642. movAnimsHeading:SetText("Déplacer des animkits")
  643. movAnimsHeading:SetFullWidth(true)
  644. brikabrokDevScroll:AddChild(movAnimsHeading)
  645.  
  646. local ebSwap1Anim = AceGUI:Create("Dropdown")
  647. ebSwap1Anim:SetList(DropdownAnims)
  648. ebSwap1Anim:SetText("Choissisez un animkit")
  649. ebSwap1Anim:SetLabel("Premier Animkit")
  650. brikabrokDevScroll:AddChild(ebSwap1Anim)
  651. ebSwap1Anim:SetCallback("OnValueChanged", function(self,callback,key) keyDevDrop13 = key end)
  652.  
  653. local ebSwap2Anim = AceGUI:Create("Dropdown")
  654. ebSwap2Anim:SetList(DropdownAnims)
  655. ebSwap2Anim:SetText("Choissisez un animkit")
  656. ebSwap2Anim:SetLabel("Deuxième Animkit")
  657. brikabrokDevScroll:AddChild(ebSwap2Anim)
  658. ebSwap2Anim:SetCallback("OnValueChanged", function(self,callback,key) keyDevDrop14 = key end)
  659.  
  660. local ebButtonSwapAnim = AceGUI:Create("Button")
  661. ebButtonSwapAnim:SetText("Swap")
  662. ebButtonSwapAnim:SetWidth(200)
  663. ebButtonSwapAnim:SetCallback("OnClick", function()
  664. tableSwap(DropdownAnims,keyDevDrop13,keyDevDrop14)
  665. tableSwap(Brikabrok.db.profile.anim,keyDevDrop13,keyDevDrop14)
  666. refreshTableAnims()
  667. ebSwap1Anim:SetList(DropdownAnims)
  668. ebSwap2Anim:SetList(DropdownAnims)
  669. ebSwap2Anim:SetText(DropdownAnims[keyDevDrop14])
  670. ebSwap1Anim:SetText(DropdownAnims[keyDevDrop13])
  671. end)
  672. brikabrokDevScroll:AddChild(ebButtonSwapAnim)
  673.  
  674. local divAnimHeading = AceGUI:Create("Heading")
  675. divAnimHeading:SetText("Divers")
  676. divAnimHeading:SetFullWidth(true)
  677. brikabrokDevScroll:AddChild(divAnimHeading)
  678.  
  679. local ebButtonRefreshAnim = AceGUI:Create("Button")
  680. ebButtonRefreshAnim:SetText("Actualiser")
  681. ebButtonRefreshAnim:SetWidth(200)
  682. ebButtonRefreshAnim:SetCallback("OnClick", function() refreshTableAnims() ebDeleteAnim:SetList(DropdownAnims) ebSwap1Anim:SetList(DropdownAnims) ebSwap2Anim:SetList(DropdownAnims)end)
  683. brikabrokDevScroll:AddChild(ebButtonRefreshAnim)
  684.  
  685. end
  686.  
  687. --[[
  688. ** DrawGroupDev4
  689. ** Draw the 4th tab for the secondary frame
  690. ** container: Which container hold this
  691. --]]
  692.  
  693.  
  694. function Brikabrok:DrawGroupDev4(container)
  695.  
  696. local headingExport = AceGUI:Create("Heading")
  697. headingExport:SetText("Exporter")
  698. headingExport:SetFullWidth(true)
  699. brikabrokDevScroll:AddChild(headingExport)
  700.  
  701.  
  702. local exportDataType = {
  703. spells = "Spells",
  704. gobs = "Gobs",
  705. anims = "Animations",
  706. }
  707.  
  708. local ebTypeDataS = AceGUI:Create("Dropdown")
  709. ebTypeDataS:SetList(exportDataType)
  710. ebTypeDataS:SetText("Type des données")
  711. ebTypeDataS:SetLabel("Type des données")
  712. brikabrokDevScroll:AddChild(ebTypeDataS)
  713. ebTypeDataS:SetCallback("OnValueChanged", function(self,callback,key) keyDev23Drop = key end)
  714.  
  715. local ebExportR = AceGUI:Create("MultiLineEditBox")
  716. ebExportR:SetText("Données à exporter")
  717. ebExportR:SetPoint("CENTER")
  718. ebExportR:SetLabel("Données à exporter")
  719. brikabrokDevScroll:AddChild(ebExportR)
  720.  
  721. local bExport = AceGUI:Create("Button")
  722. bExport:SetText("Récupérer")
  723. bExport:SetWidth(200)
  724. bExport:SetCallback("OnClick", function()
  725. if keyDev23Drop == "spells" then
  726. local serializedExport = Brikabrok:SerializeTable(Brikabrok.db.profile.spells)
  727. ebExportR:SetText(serializedExport)
  728. Brikabrok.sendMessage("[Brikabrok] Exportation des données réussis")
  729. elseif keyDev23Drop == "gobs" then
  730. local serializedExport = Brikabrok:SerializeTable(Brikabrok.db.profile.gobs)
  731. ebExportR:SetText(serializedExport)
  732. Brikabrok.sendMessage("[Brikabrok] Exportation des données réussis")
  733. elseif keyDev23Drop == "anims" then
  734. local serializedExport = Brikabrok:SerializeTable(Brikabrok.db.profile.anim)
  735. ebExportR:SetText(serializedExport)
  736. Brikabrok.sendMessage("[Brikabrok] Exportation des données réussis")
  737. else
  738. Brikabrok.sendMessage("[Brikabrok] Données non valides", "WARNING")
  739. end
  740. end)
  741. brikabrokDevScroll:AddChild(bExport)
  742.  
  743. local headingImport = AceGUI:Create("Heading")
  744. headingImport:SetText("Importer")
  745. headingImport:SetFullWidth(true)
  746. brikabrokDevScroll:AddChild(headingImport)
  747.  
  748. local ebImportR = AceGUI:Create("MultiLineEditBox")
  749. ebImportR:SetText("Données à importer")
  750. ebImportR:SetPoint("CENTER")
  751. ebImportR:SetLabel("Données à importer")
  752. brikabrokDevScroll:AddChild(ebImportR )
  753.  
  754. local importDataType = {
  755. spells = "Spells",
  756. gobs = "Gobs",
  757. anims = "Animations",
  758. }
  759.  
  760. local ebTypeData = AceGUI:Create("Dropdown")
  761. ebTypeData:SetList(importDataType)
  762. ebTypeData:SetText("Type des données")
  763. ebTypeData:SetLabel("Type des données")
  764. brikabrokDevScroll:AddChild(ebTypeData)
  765. ebTypeData:SetCallback("OnValueChanged", function(self,callback,key) keyDev4Drop = key end)
  766.  
  767. local ebImport = AceGUI:Create("Button")
  768. ebImport:SetText("Importer")
  769. ebImport:SetWidth(200)
  770. ebImport:SetCallback("OnClick", function()
  771. local code = ebImportR:GetText()
  772. local object = Brikabrok:safeDeserialize(code)
  773. if object and type(object) == "table" then
  774. print(keyDev4Drop)
  775. if keyDev4Drop == "spells" then
  776. Brikabrok.db.profile.spells = object
  777. Brikabrok.sendMessage("[Brikabrok] Importation des spells réussis")
  778. elseif keyDev4Drop == "gobs" then
  779. Brikabrok.db.profile.gobs = object
  780. Brikabrok.sendMessage("[Brikabrok] Importation des gobs réussis")
  781. elseif keyDev4Drop == "anims" then
  782. Brikabrok.db.profile.anim = object
  783. Brikabrok.sendMessage("[Brikabrok] Importation des animations réussis")
  784. else
  785. Brikabrok.sendMessage("[Brikabrok] Type de données non reconnues")
  786. end
  787. else
  788. Brikabrok.sendMessage("[Brikabrok] Échec de l'importation, veuillez vérifier l'intégrité des données.")
  789. end
  790. end)
  791. brikabrokDevScroll:AddChild(ebImport)
  792.  
  793. local headingShare = AceGUI:Create("Heading")
  794. headingShare:SetText("Partager avec un ami")
  795. headingShare:SetFullWidth(true)
  796. brikabrokDevScroll:AddChild(headingShare)
  797.  
  798. local ebShareType = AceGUI:Create("Dropdown")
  799. ebShareType:SetList(exportDataType)
  800. ebShareType:SetText("Type des données")
  801. ebShareType:SetLabel("Type des données")
  802. brikabrokDevScroll:AddChild(ebShareType)
  803. ebShareType:SetCallback("OnValueChanged", function(self,callback,key) keyDev28Drop = key end)
  804.  
  805. local ebImportS = AceGUI:Create("MultiLineEditBox")
  806. ebImportS:SetText("Veuillez être dans un groupe seul avec votre cible pour transférer vos données.")
  807. ebImportS:SetPoint("CENTER")
  808. ebImportS:SetLabel("Informations")
  809. brikabrokDevScroll:AddChild(ebImportS)
  810.  
  811. local ebShare = AceGUI:Create("Button")
  812. ebShare:SetText("Envoyer")
  813. ebShare:SetWidth(200)
  814. ebShare:SetCallback("OnClick", function()
  815. local playerName = UnitName("player")
  816. if UnitInParty("target") and GetNumGroupMembers() == 2 then
  817. if keyDev28Drop == "spells" then
  818. local dataTable = Brikabrok:SerializeTable(Brikabrok.db.profile.spells)
  819. local shortString = table
  820. AceComm:SendCommMessage("BKBShareData", dataTable, "PARTY", nil, "NORMAL")
  821. ebImportS:SetText(shortString)
  822. elseif keyDev28Drop == "gobs" then
  823. local dataTable = Brikabrok:SerializeTable(Brikabrok.db.profile.gobs)
  824. local shortString = table
  825. AceComm:SendCommMessage("BKBShareData", dataTable, "PARTY", nil, "NORMAL")
  826. ebImportS:SetText(shortString)
  827. elseif keyDev4Drop == "anims" then
  828. local dataTable = Brikabrok:SerializeTable(Brikabrok.db.profile.anim)
  829. local shortString = table
  830. AceComm:SendCommMessage("BKBShareData", dataTable, "PARTY", nil, "NORMAL")
  831. ebImportS:SetText(shortString)
  832. end
  833. Brikabrok.sendMessage("Données envoyé avec succès, en attente d'une réponse ... ( le transfert peut être relativement long en fonction de la taille des données ) :", "SUCCESS")
  834. else
  835. Brikabrok.sendMessage("Veuillez sélectionner votre cible et être dans un groupe à deux!", "WARNING")
  836. end
  837. end)
  838. brikabrokDevScroll:AddChild(ebShare)
  839.  
  840.  
  841.  
  842. end
  843.  
  844. --[[
  845. ** SelectGroupDev
  846. ** Callback function for OnGroupSelected
  847. ** container: Which container hold this
  848. ** event: ...
  849. ** group: ...
  850. --]]
  851. local function SelectGroupDev(container, event, group)
  852. container:ReleaseChildren()
  853. container:SetLayout("Flow")
  854.  
  855.  
  856. local scrollDevContainer = AceGUI:Create("SimpleGroup")
  857. scrollDevContainer:SetRelativeWidth(1)
  858. scrollDevContainer:SetFullHeight(true)
  859. scrollDevContainer:SetLayout("Fill")
  860. container:AddChild(scrollDevContainer)
  861.  
  862. brikabrokDevScroll = AceGUI:Create("ScrollFrame")
  863. brikabrokDevScroll:SetFullHeight(true)
  864. brikabrokDevScroll:SetLayout("Flow")
  865. scrollDevContainer:AddChild(brikabrokDevScroll)
  866.  
  867.  
  868. if group == "tab1" then
  869. Brikabrok:DrawGroupDev1(container)
  870. elseif group == "tab2" then
  871. Brikabrok:DrawGroupDev2(container)
  872. elseif group == "tab3" then
  873. Brikabrok:DrawGroupDev3(container)
  874. elseif group == "tab4" then
  875. Brikabrok:DrawGroupDev4(container)
  876. end
  877. end
  878.  
  879. -- Create secondary frame
  880. easyDev = AceGUI:Create("Brikabrok")
  881. easyDev:SetTitle("Brikabrok")
  882. easyDev:SetLayout("Fill")
  883. easyDev:SetWidth(400)
  884. easyDev:SetHeight(520)
  885.  
  886.  
  887. -- Add tabs here for the second frame
  888. local tabDev = AceGUI:Create("TabGroup")
  889. tabDev:SetLayout("Flow")
  890. tabDev:SetTabs({{text="Spells", value="tab1"},{text="Gobs", value="tab2"},{text="Anims", value="tab3"},{text="Export/Import", value="tab4"}})
  891. tabDev:SetCallback("OnGroupSelected", SelectGroupDev)
  892. tabDev:SelectTab("tab1")
  893. easyDev:AddChild(tabDev)
  894.  
  895. function Brikabrok:ShowDevFrame()
  896. easyDev:Show()
  897. end
  898.  
  899. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement