Advertisement
SmokeDelsin

roblox insert tool script

May 25th, 2015
10,568
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 41.92 KB | None | 0 0
  1. local Tool = script.Parent
  2.  
  3. --game:GetService("InsertService"):SetCollectionUrl("http://test.roblox.com/Game/Tools/insertasset.ashx?sid=%d")
  4. --game:GetService("InsertService"):SetBaseCategoryUrl("http://test.roblox.com/Game/Tools/insertasset.ashx?nsets=10")
  5. --game:GetService("InsertService"):SetAssetUrl("http://test.roblox.com/Asset/?id=%d")
  6.  
  7. enabled = true
  8. local origTexture = Tool.TextureId
  9. game:GetService("ContentProvider"):Preload("rbxasset://icons/insert_sel.png")
  10.  
  11. local height = 20
  12. local width = UDim.new(0.25, 0)
  13. local height = 20
  14. local buttonTransparency = 0.1
  15. local insertButtonTransparency = 0.25
  16. local transparency = 0.25
  17.  
  18. local selectedButtonColor = Color3.new(.1255, .4078, .1961)
  19. local selectedButtonTextColor = Color3.new(1.0,1.0,1.0)
  20.  
  21. local buttonColor = Color3.new(0.0898, 0.2148, .2344)
  22. local buttonTextColor = Color3.new(1.0,1.0,1.0)
  23.  
  24. local frameColor = Color3.new(.1255, .4078, .1961)
  25. local frameTextColor = Color3.new(1.0,1.0,1.0)
  26.  
  27. local titleColor = Color3.new(0.6289, 0.8398, 0)
  28. local titleTextColor = Color3.new(0.0,0.0,0.0)
  29.  
  30. local Window
  31. local Data
  32. local Mouse
  33.  
  34. local SetCache = {}
  35.  
  36. local soloGame = game:FindFirstChild("NetworkClient") == nil
  37.  
  38. --Constants
  39. local useAssetVersionId = true
  40. local BaseUrl = game:GetService("ContentProvider").BaseUrl
  41. local ThumbnailUrl;
  42. if useAssetVersionId then
  43. ThumbnailUrl = BaseUrl .. "Game/Tools/ThumbnailAsset.ashx?fmt=png&wd=110&ht=110&assetversionid="
  44. else
  45. ThumbnailUrl = BaseUrl .. "Game/Tools/ThumbnailAsset.ashx?fmt=png&wd=110&ht=110&aid="
  46. end
  47.  
  48. local InsertRows = 4
  49. local InsertColumns = 8
  50.  
  51. --Static variables used for creating sizes
  52. function getPlayer()
  53. local character = script.Parent.Parent
  54. return game.Players:GetPlayerFromCharacter(character)
  55. end
  56.  
  57. function minimize()
  58. if Window.Stamp.Frame.Visible then
  59. cancelAssetPlacement()
  60. elseif Window.Main.Frame.Visible then
  61. Window.Main.Frame.Visible = false
  62. Window.Minimized.Frame.Visible = true
  63. end
  64. end
  65.  
  66. function buildImageButton(image)
  67. local buttonFrame = Instance.new("Frame")
  68. buttonFrame.BackgroundTransparency = 1.0
  69.  
  70. local button = Instance.new("ImageButton")
  71. button.Name = "Button"
  72. button.Parent = buttonFrame
  73. button.Image = image
  74. button.Size = UDim2.new(1.0, 0, 1.0, 0)
  75. button.Position = UDim2.new(0.0, 0, 0.0, 0)
  76. button.BorderSizePixel = 1
  77. button.Parent = buttonFrame
  78. button.BackgroundTransparency = 0
  79.  
  80. return buttonFrame
  81.  
  82. end
  83. function buildTextButton(text)
  84.  
  85. local buttonFrame = Instance.new("Frame")
  86. buttonFrame.BackgroundTransparency = 1.0
  87. local button = Instance.new("TextButton")
  88. button.Name = "Button"
  89. button.Parent = buttonFrame
  90. button.Text = text
  91. button.Size = UDim2.new(1.0, 0, 1.0, 0)
  92. button.TextWrap = true
  93. button.Position = UDim2.new(0.0, 0, 0.0, 0)
  94. button.BorderSizePixel = 1
  95. button.BackgroundTransparency = buttonTransparency
  96. button.Parent = buttonFrame
  97.  
  98. return buttonFrame
  99. end
  100.  
  101. function mouseEnterInsertButton(insertFrame)
  102. if insertFrame ~= Data.CurrentRolloverInsertButton then
  103. insertFrame.Button.Transparency = 0.0
  104. Data.CurrentRolloverInsertButton = insertFrame
  105. Window.Main.RolloverText.Text = Data.CurrentRolloverInsertButton.AssetName.Value
  106. end
  107. end
  108.  
  109. function mouseLeaveInsertButton(insertFrame)
  110. if insertFrame == Data.CurrentRolloverInsertButton then
  111. Window.Main.RolloverText.Text = ""
  112. Data.CurrentRolloverInsertButton = nil
  113.  
  114. end
  115. insertFrame.Button.Transparency = insertButtonTransparency
  116. end
  117.  
  118. function buildInsertButton(position, size)
  119. local insertFrame = buildImageButton("")
  120. insertFrame.Name = "InsertAssetButton"
  121. insertFrame.Position = position
  122. insertFrame.Size = size
  123. insertFrame.Button.BackgroundColor3 = Color3.new(1.0,1.0,1.0)
  124. insertFrame.Button.Transparency = insertButtonTransparency
  125. insertFrame.Visible = false
  126.  
  127. local assetId = Instance.new("IntValue")
  128. assetId.Name = "AssetId"
  129. assetId.Value = -1
  130. assetId.Parent = insertFrame
  131.  
  132. local assetName = Instance.new("StringValue")
  133. assetName.Name = "AssetName"
  134. assetName.Value = ""
  135. assetName.Parent = insertFrame
  136.  
  137. insertFrame.Button.MouseButton1Click:connect(function() mouseLeaveInsertButton(insertFrame) beginInsertAsset(insertFrame.AssetName.Value, insertFrame.AssetId.Value, insertFrame.Button.Image, false) end)
  138. insertFrame.Button.MouseButton2Click:connect(function() mouseLeaveInsertButton(insertFrame) beginInsertAsset(insertFrame.AssetName.Value, insertFrame.AssetId.Value, insertFrame.Button.Image, true) end)
  139. insertFrame.Button.MouseEnter:connect(function() mouseEnterInsertButton(insertFrame) end)
  140. insertFrame.Button.MouseLeave:connect(function() mouseLeaveInsertButton(insertFrame) end)
  141.  
  142. return insertFrame
  143. end
  144.  
  145. function setInsertButtonImageBehavior(insertFrame, visible, name, assetId)
  146. if visible then
  147. insertFrame.AssetName.Value = name
  148. insertFrame.AssetId.Value = assetId
  149. insertFrame.Button.Image = ThumbnailUrl .. assetId
  150. insertFrame.Button.BackgroundColor3 = Color3.new(1.0,1.0,1.0)
  151. insertFrame.Visible = true
  152. else
  153. insertFrame.Visible = false
  154. end
  155. end
  156.  
  157. function mouseEnterSetButton(setFrame)
  158. if setFrame.Button.AutoButtonColor then
  159. setFrame.Button.Icon.Transparency = 0.0
  160. end
  161. end
  162. function mouseLeaveSetButton(setFrame)
  163. if setFrame.Button.AutoButtonColor then
  164. setFrame.Button.Icon.Transparency = insertButtonTransparency
  165. end
  166. end
  167.  
  168. function buildSetButton(name, setId, setImageId, i, count)
  169. local buttonFrame = buildTextButton("")
  170. buttonFrame.Name = "SetButton"
  171. buttonFrame.Size = UDim2.new(1.0, 0, 0.0, height*2)
  172. buttonFrame.Position = UDim2.new(0.0, 0, 0.0, (i-1)*height*2)
  173. buttonFrame.Button.BackgroundColor3 = buttonColor
  174. buttonFrame.Button.TextColor3 = buttonTextColor
  175. buttonFrame.Visible = false
  176.  
  177. local setNameLabel = Instance.new("TextLabel")
  178. setNameLabel.Name = "Name"
  179. setNameLabel.Text = name
  180. setNameLabel.TextColor3 = buttonTextColor
  181. setNameLabel.BackgroundTransparency = 1.0
  182. setNameLabel.Size = UDim2.new(1.0, -height*2, 1.0, 0.0)
  183. setNameLabel.Position = UDim2.new(0.0, height*2, 0.0, 0)
  184. setNameLabel.TextWrap = true
  185. setNameLabel.TextXAlignment = Enum.TextXAlignment.Left
  186. setNameLabel.Parent = buttonFrame.Button
  187.  
  188. local iconLabel = Instance.new("ImageLabel")
  189. iconLabel.Name = "Icon"
  190. iconLabel.Image = BaseUrl .. "asset/?id=" .. setImageId
  191. iconLabel.Size = UDim2.new(0.0, height*2 - 4, 0.0, height*2 -4)
  192. iconLabel.Position = UDim2.new(0.0, 2, 0.0, 2)
  193. iconLabel.Transparency = insertButtonTransparency
  194. iconLabel.Parent = buttonFrame.Button
  195.  
  196. local setValue = Instance.new("IntValue")
  197. setValue.Name = "SetId"
  198. setValue.Value = setId
  199. setValue.Parent = buttonFrame
  200.  
  201. local setName = Instance.new("StringValue")
  202. setName.Name = "SetName"
  203. setName.Value = name
  204. setName.Parent = buttonFrame
  205.  
  206. buttonFrame.Button.MouseButton1Click:connect(function() selectSet(buttonFrame, buttonFrame.SetName.Value, buttonFrame.SetId.Value, 0) end)
  207. buttonFrame.Button.MouseEnter:connect(function() mouseEnterSetButton(buttonFrame) end)
  208. buttonFrame.Button.MouseLeave:connect(function() mouseLeaveSetButton(buttonFrame) end)
  209.  
  210. --print("Built button " .. i .. " SetId=" .. setId .. " SetName=" .. name)
  211.  
  212. return buttonFrame
  213. end
  214.  
  215. function previousSetPage()
  216. local newIndex = math.max(1, Data.Category[Data.CurrentCategory].Index - (Data.Main.InsertRows * Data.Main.InsertColumns))
  217. setSetIndex(newIndex)
  218. end
  219.  
  220. function nextSetPage()
  221. local newIndex = math.max(0, Data.Category[Data.CurrentCategory].Index + (Data.Main.InsertRows * Data.Main.InsertColumns))
  222. setSetIndex(newIndex)
  223. end
  224.  
  225. function setSetIndex(dataOffset)
  226. Data.Category[Data.CurrentCategory].Index = dataOffset
  227.  
  228. local PageSize = Data.Main.InsertRows*Data.Main.InsertColumns
  229. local contents = Data.Category[Data.CurrentCategory].Contents
  230. if contents then
  231. for index = 1, PageSize do
  232. if Data.InsertButtons[index] then
  233. if contents[index + dataOffset] then
  234. --for key, value in pairs(contents[index+dataOffset]) do
  235. -- print("key=" .. key .. ", value=" .. value)
  236. --end
  237.  
  238. local assetId
  239. if useAssetVersionId then
  240. assetId = contents[index + dataOffset].AssetVersionId
  241. else
  242. assetId = contents[index + dataOffset].AssetId
  243. end
  244. setInsertButtonImageBehavior(Data.InsertButtons[index], true, contents[index + dataOffset].Name, assetId)
  245. else
  246. setInsertButtonImageBehavior(Data.InsertButtons[index], false)
  247. end
  248. end
  249. end
  250. Window.Main.PreviousPageButton.Visible = dataOffset > 0
  251. Window.Main.NextPageButton.Visible = (dataOffset + PageSize) < (#contents)
  252. else
  253. Window.Main.PreviousPageButton.Visible = false
  254. Window.Main.NextPageButton.Visible = false
  255. end
  256. end
  257.  
  258. function previousCategoryPage()
  259. local newIndex = math.max(0, Data.Category[Data.CurrentCategory].SetIndex - Data.Main.InsertSets)
  260. setCategoryIndex(newIndex)
  261. end
  262.  
  263. function nextCategoryPage()
  264. local newIndex = math.max(0, Data.Category[Data.CurrentCategory].SetIndex + Data.Main.InsertSets)
  265. setCategoryIndex(newIndex)
  266. end
  267.  
  268. function setCategoryIndex(setIndex)
  269. Data.Category[Data.CurrentCategory].SetIndex = setIndex
  270. --This is how many vertical items we can display
  271.  
  272. --Layout all buttons in this setoh
  273. if #Data.CurrentCategory > Data.Main.InsertSets then
  274. --Steal one for use by the layout buttons, when it rains it pours
  275.  
  276. --We can't fit all the buttons
  277. local heightUsed = 0
  278.  
  279. local index = 1
  280. if index < setIndex then
  281. heightUsed = height
  282. Window.Main.PreviousSetButton.Visible = true
  283. while index < setIndex do
  284. Data.CurrentCategory[index].Visible = false
  285. index = index + 1
  286. end
  287. else
  288. Window.Main.PreviousSetButton.Visible = false
  289. end
  290.  
  291. local offset = 0
  292. while offset < Data.Main.InsertSets and index + offset <= #Data.CurrentCategory do
  293. Data.CurrentCategory[index + offset].Size = UDim2.new(1.0, 0, 0.0, height*2)
  294. Data.CurrentCategory[index + offset].Position = UDim2.new(0.0, 0, 0.0, height*2*offset + heightUsed)
  295. Data.CurrentCategory[index + offset].Visible = true
  296. offset = offset + 1
  297. end
  298. index = index + offset
  299. heightUsed = heightUsed + Data.Main.InsertSets*height*2
  300.  
  301. if index <= #Data.CurrentCategory then
  302. Window.Main.NextSetButton.Position = UDim2.new(0.0, 0, 0.0, heightUsed)
  303. Window.Main.NextSetButton.Size = UDim2.new(1.0, 0, 1.0, -heightUsed)
  304. Window.Main.NextSetButton.Visible = true
  305. while index <= #Data.CurrentCategory do
  306. Data.CurrentCategory[index].Visible = false
  307. index = index + 1
  308. end
  309. else
  310. Window.Main.NextSetButton.Visible = false
  311. end
  312. --Window.Main.Frame.SetTab.SetFiller.Size = UDim2.new(0.0, 0, 0.0, 0)
  313. else
  314. Window.Main.PreviousSetButton.Visible = false
  315. Window.Main.NextSetButton.Visible = false
  316.  
  317. for key, buttonFrame in pairs(Data.CurrentCategory) do
  318. buttonFrame.Size = UDim2.new(1.0, 0, 0.0, height*2)
  319. buttonFrame.Position = UDim2.new(0.0, 0, 0.0, height*2*(key-1))
  320. buttonFrame.Visible = true
  321. end
  322.  
  323. --Then expand this to fill the remaining space at the bottom
  324. --Window.Main.Frame.SetTab.SetFiller.Position = UDim2.new(0.0, 0, 0.0, height*2*#Data.CurrentCategory)
  325. --Window.Main.Frame.SetTab.SetFiller.Size = UDim2.new(1.0, 0, 0.0, frameHeight - height*2*#Data.CurrentCategory)
  326. end
  327. end
  328.  
  329. function selectCategoryPage(buttons, page)
  330. if buttons ~= Data.CurrentCategory then
  331. if Data.CurrentCategory then
  332. for key, button in pairs(Data.CurrentCategory) do
  333. button.Visible = false
  334. end
  335. end
  336.  
  337. Data.CurrentCategory = buttons
  338. if Data.Category[Data.CurrentCategory] == nil then
  339. Data.Category[Data.CurrentCategory] = {}
  340. if #buttons > 0 then
  341. selectSet(buttons[1], buttons[1].SetName.Value, buttons[1].SetId.Value, 0)
  342. end
  343. else
  344. Data.Category[Data.CurrentCategory].Button = nil
  345. selectSet(Data.Category[Data.CurrentCategory].ButtonFrame, Data.Category[Data.CurrentCategory].SetName, Data.Category[Data.CurrentCategory].SetId, Data.Category[Data.CurrentCategory].Index)
  346. end
  347. if Data.Main.FrameHeight then
  348. if Data.Category[Data.CurrentCategory].SetIndex then
  349. layoutSetButtons(Data.Main.FrameHeight, Data.Category[Data.CurrentCategory].SetIndex)
  350. else
  351. layoutSetButtons(Data.Main.FrameHeight, 1)
  352. end
  353. end
  354.  
  355.  
  356. end
  357. end
  358. function filterSet(set)
  359. if soloGame then
  360. return set
  361. end
  362.  
  363. local result = {}
  364. for pos, object in pairs(set) do
  365. if object.IsTrusted then
  366. result[#result+1] = object
  367. end
  368. end
  369. return result
  370. end
  371. function selectSet(buttonFrame, setName, setId, setIndex)
  372. if buttonFrame then
  373. if buttonFrame.Button ~= Data.Category[Data.CurrentCategory].Button then
  374. if Data.Category[Data.CurrentCategory].Button ~= nil then
  375. Data.Category[Data.CurrentCategory].Button.BackgroundColor3 = buttonColor
  376. Data.Category[Data.CurrentCategory].Button.TextColor3 = buttonTextColor
  377. Data.Category[Data.CurrentCategory].Button.Icon.Transparency = insertButtonTransparency
  378. Data.Category[Data.CurrentCategory].Button.AutoButtonColor = true
  379. end
  380.  
  381. Data.Category[Data.CurrentCategory].Button = buttonFrame.Button
  382. Data.Category[Data.CurrentCategory].Button.BackgroundColor3 = selectedButtonColor
  383. Data.Category[Data.CurrentCategory].Button.TextColor3 = selectedButtonTextColor
  384. Data.Category[Data.CurrentCategory].Button.Icon.Transparency = 0.0
  385. Data.Category[Data.CurrentCategory].Button.AutoButtonColor = false
  386.  
  387. if SetCache[setId] == nil then
  388. SetCache[setId] = filterSet(game:GetService("InsertService"):GetCollection(setId))
  389. end
  390. Data.Category[Data.CurrentCategory].Contents = SetCache[setId]
  391. Window.Main.Title.Text = setName
  392.  
  393. Data.Category[Data.CurrentCategory].SetName = setName
  394. Data.Category[Data.CurrentCategory].SetId = setId
  395. Data.Category[Data.CurrentCategory].ButtonFrame = buttonFrame
  396. end
  397.  
  398. setSetIndex (setIndex)
  399. end
  400. end
  401.  
  402. function selectCategory(button, category)
  403. if Data.CurrentCategory ~= category then
  404. if Data.CurrentCategoryButton then
  405. Data.CurrentCategoryButton.BackgroundColor3 = buttonColor
  406. Data.CurrentCategoryButton.TextColor3 = buttonTextColor
  407. Data.CurrentCategoryButton.AutoButtonColor = true
  408. end
  409. end
  410. selectCategoryPage(category, 0)
  411.  
  412. Data.CurrentCategoryButton = button
  413. Data.CurrentCategoryButton.BackgroundColor3 = selectedButtonColor
  414. Data.CurrentCategoryButton.TextColor3 = selectedButtonTextColor
  415. Data.CurrentCategoryButton.AutoButtonColor = false
  416. end
  417.  
  418. function processCategory(sets, setPanel)
  419. local setButtons = {}
  420. for index, object in pairs(sets) do
  421. --for key, value in pairs(object) do
  422. -- print("key=" .. key .. ", value=" .. value)
  423. --end
  424. setButtons[index] = buildSetButton(object.Name, object.CategoryId, object.ImageAssetId, index, #sets)
  425. setButtons[index].Parent = setPanel
  426. end
  427. return setButtons
  428. end
  429.  
  430. function buildMainGui(root, userId)
  431. Window.Main = {}
  432. Data.Main = {}
  433. Data.Category = {}
  434.  
  435. local mainFrame = Instance.new("Frame")
  436. mainFrame.Name = "InsertMainDialog"
  437. mainFrame.Position = UDim2.new(0.0, 0, 0.25, 0)
  438. mainFrame.Size = UDim2.new(0.75, 0, 0.75, 0)
  439. mainFrame.Transparency = 1.0
  440. mainFrame.Active = true
  441. mainFrame.Parent = root
  442. Window.Main.Frame = mainFrame
  443.  
  444. local setTab = Instance.new("Frame")
  445. setTab.Position = UDim2.new(0.0, 0, 0.0, 0)
  446. setTab.Size = UDim2.new(0.15, 0, 1.0, 0)
  447. setTab.BackgroundTransparency = 1.0
  448. setTab.Name = "SetTab"
  449. setTab.Parent = mainFrame
  450.  
  451. local setPanel = Instance.new("Frame")
  452. setPanel.Position = UDim2.new(0.0, 0, 0.0, 0)
  453. setPanel.Size = UDim2.new(1.0, 0, 1.0, 0)
  454. setPanel.BackgroundTransparency = 1.0
  455. setPanel.Name = "SetPanel"
  456. setPanel.Parent = setTab
  457.  
  458. local setFiller = Instance.new("Frame")
  459. setFiller.Name = "SetFiller"
  460. setFiller.Size = UDim2.new(0.0, 0, 0.0, 0)
  461. setFiller.Position = UDim2.new(0.0, 0, 0.0, 0)
  462. setFiller.BackgroundColor3 = frameColor
  463. setFiller.BackgroundTransparency = transparency*.5
  464. setFiller.Parent = setTab
  465.  
  466. local previousSetButton = Instance.new("TextButton")
  467. previousSetButton.Name = "PreviousSetButton"
  468. previousSetButton.Size = UDim2.new(1.0, 0, 0, height)
  469. previousSetButton.Position = UDim2.new(0.0, 0, 0.0, 0)
  470. previousSetButton.BackgroundColor3 = buttonColor
  471. previousSetButton.TextColor3 = buttonTextColor
  472. previousSetButton.BackgroundTransparency = transparency
  473. previousSetButton.Text = "..."
  474. previousSetButton.MouseButton1Click:connect(previousCategoryPage)
  475. previousSetButton.Parent = setTab
  476. previousSetButton.Visible = false
  477. Window.Main.PreviousSetButton = previousSetButton
  478.  
  479. local nextSetButton = Instance.new("TextButton")
  480. nextSetButton.Name = "NextSetButton"
  481. nextSetButton.Size = UDim2.new(1.0, 0, 0.0, height)
  482. nextSetButton.Position = UDim2.new(0.0, 0, 1.0, -height)
  483. nextSetButton.BackgroundColor3 = buttonColor
  484. nextSetButton.TextColor3 = buttonTextColor
  485. nextSetButton.BackgroundTransparency = transparency
  486. nextSetButton.Text = "..."
  487. nextSetButton.MouseButton1Click:connect(nextCategoryPage)
  488. nextSetButton.Parent = setTab
  489. nextSetButton.Visible = false
  490. Window.Main.NextSetButton = nextSetButton
  491.  
  492. local insertTab = Instance.new("Frame")
  493. insertTab.Name = "InsertTab"
  494. insertTab.Position = UDim2.new(0.15, 0, 0.0, 0)
  495. insertTab.Size = UDim2.new(0.85, 0, 1.0, 0)
  496. insertTab.BackgroundTransparency = 1.0
  497. insertTab.Parent = mainFrame
  498.  
  499. Data.BaseCategoryButtons = processCategory(game:GetService("InsertService"):GetBaseCategories(), setPanel)
  500. local userData = game:GetService("InsertService"):GetUserCategories(userId)
  501. if userData then
  502. Data.UserCategoryButtons = processCategory(userData, setPanel)
  503.  
  504. local userCategoryButton = Instance.new("TextButton")
  505. userCategoryButton.Name = "UserCategoryButton"
  506. userCategoryButton.Size = UDim2.new(0.25, 0, 0, height)
  507. userCategoryButton.Position = UDim2.new(0.25, 0, 0.0, -height)
  508. userCategoryButton.BackgroundColor3 = buttonColor
  509. userCategoryButton.TextColor3 = buttonTextColor
  510. userCategoryButton.BackgroundTransparency = transparency*.5
  511. userCategoryButton.Text = "User Sets"
  512. userCategoryButton.MouseButton1Click:connect(function() selectCategory(userCategoryButton, Data.UserCategoryButtons) end)
  513. userCategoryButton.Parent = insertTab
  514. end
  515. --Data.UserCategoryButtons = processCategory(game:GetService("InsertService"):GetBaseCategories(), setPanel)
  516.  
  517. local baseCategoryButton = Instance.new("TextButton")
  518. baseCategoryButton.Name = "RobloxCategoryButton"
  519. baseCategoryButton.Size = UDim2.new(0.25, 0, 0, height)
  520. baseCategoryButton.Position = UDim2.new(0.0, 0, 0.0, -height)
  521. baseCategoryButton.BackgroundColor3 = buttonColor
  522. baseCategoryButton.TextColor3 = buttonTextColor
  523. baseCategoryButton.BackgroundTransparency = transparency *.5
  524. baseCategoryButton.Text = "Roblox Sets"
  525. baseCategoryButton.MouseButton1Click:connect(function() selectCategory(baseCategoryButton, Data.BaseCategoryButtons) end)
  526. baseCategoryButton.Parent = insertTab
  527.  
  528. local titleFrame = Instance.new("TextLabel")
  529. titleFrame.Name = "Title"
  530. titleFrame.Position = UDim2.new(0.0, 0, 0.0, 0)
  531. titleFrame.Size = UDim2.new(1.0, 0, 0.0, height)
  532. titleFrame.TextWrap = true
  533. titleFrame.BackgroundColor3 = titleColor
  534. titleFrame.TextColor3 = titleTextColor
  535. titleFrame.BackgroundTransparency = .1
  536. titleFrame.Text = "Set Foo"
  537. titleFrame.Parent = insertTab
  538. Window.Main.Title = titleFrame
  539.  
  540. local minimizeButton = Instance.new("ImageButton")
  541. minimizeButton.Name = "Minimize"
  542. minimizeButton.Position = UDim2.new(1.0, -height + 1, 0.0, 1)
  543. minimizeButton.Size = UDim2.new(0.0, height-2, 0.0, height-2)
  544. minimizeButton.Image = BaseUrl .. "asset?id=20889725"
  545. minimizeButton.MouseButton1Click:connect(minimize)
  546. minimizeButton.Parent = titleFrame
  547.  
  548. local insertPanel = Instance.new("Frame")
  549. insertPanel.Name = "InsertPanel"
  550. insertPanel.Position = UDim2.new(0.0, 0, 0.0, height)
  551. insertPanel.Size = UDim2.new(1.0, 0, 1.0, -2*height)
  552. insertPanel.BackgroundColor3 = frameColor
  553. insertPanel.BackgroundTransparency = transparency
  554. insertPanel.Parent = insertTab
  555.  
  556. local footerPanel = Instance.new("Frame")
  557. footerPanel.Name = "Footer"
  558. footerPanel.Size = UDim2.new(1.0, 0, 0, height)
  559. footerPanel.Position = UDim2.new(0.0, 0, 1.0, -height)
  560. footerPanel.BackgroundTransparency = transparency
  561. footerPanel.BackgroundColor3 = frameColor
  562. footerPanel.Parent = insertTab
  563.  
  564. local rolloverText = Instance.new("TextLabel")
  565. rolloverText.Name = "RolloverText"
  566. rolloverText.Size = UDim2.new(0.8, 0, 1.0, 0)
  567. rolloverText.Position = UDim2.new(0.1, 0, 0.0, 0)
  568. rolloverText.TextColor3 = frameTextColor
  569. rolloverText.BackgroundColor3 = frameColor
  570. rolloverText.BackgroundTransparency = transparency
  571. rolloverText.Text = ""
  572. rolloverText.TextWrap = true
  573. rolloverText.Parent = footerPanel
  574. Window.Main.RolloverText = rolloverText
  575.  
  576. local previousButton = Instance.new("TextButton")
  577. previousButton.Name = "PreviousPageButton"
  578. previousButton.Size = UDim2.new(0.1, 0, 1.0, 0)
  579. previousButton.Position = UDim2.new(0.0, 0, 0.0, 0)
  580. previousButton.BackgroundColor3 = buttonColor
  581. previousButton.TextColor3 = buttonTextColor
  582. previousButton.BackgroundTransparency = transparency
  583. previousButton.Text = "<--"
  584. previousButton.MouseButton1Click:connect(previousSetPage)
  585. previousButton.Parent = footerPanel
  586. previousButton.Visible = false
  587. Window.Main.PreviousPageButton = previousButton
  588.  
  589. local nextButton = Instance.new("TextButton")
  590. nextButton.Name = "NextPageButton"
  591. nextButton.Size = UDim2.new(0.1, 0, 1.0, 0)
  592. nextButton.Position = UDim2.new(0.9, 0, 0.0, 0)
  593. nextButton.BackgroundColor3 = buttonColor
  594. nextButton.TextColor3 = buttonTextColor
  595. nextButton.BackgroundTransparency = transparency
  596. nextButton.Text = "-->"
  597. nextButton.MouseButton1Click:connect(nextSetPage)
  598. nextButton.Parent = footerPanel
  599. nextButton.Visible = false
  600. Window.Main.NextPageButton = nextButton
  601.  
  602. local insertButtons = {}
  603. for y = 1, InsertRows do
  604. for x = 1, InsertColumns do
  605. insertButtons[x + (y - 1) * InsertColumns] = buildInsertButton(UDim2.new(.125*(x-1), 2, 0.25*(y-1), 2), UDim2.new(.125, -4, .25, -4))
  606. insertButtons[x + (y - 1) * InsertColumns].Parent = insertPanel
  607. end
  608. end
  609. Data.InsertButtons = insertButtons
  610. Data.Main.InsertRows = InsertRows
  611. Data.Main.InsertColumns = InsertColumns
  612.  
  613. selectCategory(baseCategoryButton, Data.BaseCategoryButtons)
  614. end
  615.  
  616. function layoutInsertButtons(guiMain)
  617. local size = guiMain.AbsoluteSize
  618.  
  619. local frameSize = 0.75 * size
  620. local frameSizeUsed = Vector2.new(0, height*2)
  621.  
  622. --We want 15% or 100 pixels, which ever is smaller
  623. if frameSize.x * .15 < 100 then
  624. local oldSize = Window.Main.Frame.SetTab.Size
  625. Window.Main.Frame.SetTab.Size = UDim2.new(0.0, 100, oldSize.Y.Scale, oldSize.Y.Offset)
  626. Window.Main.Frame.InsertTab.Position = UDim2.new(0.0, 100, 0.0, 0)
  627. frameSizeUsed = Vector2.new(frameSizeUsed.x + 100, frameSizeUsed.y)
  628. else
  629. local oldSize = Window.Main.Frame.SetTab.Size
  630. Window.Main.Frame.SetTab.Size = UDim2.new(0.15, 0, oldSize.Y.Scale, oldSize.Y.Offset)
  631. Window.Main.Frame.InsertTab.Position = UDim2.new(0.15, 0, 0.0, 0)
  632. frameSizeUsed = Vector2.new(frameSizeUsed.x + .15*frameSize.x, frameSizeUsed.y)
  633. end
  634.  
  635. --Decide how many buttons we can fit, and what size to make the insert buttons
  636. --2 sizes of insert buttons, 50x50 and 100x100
  637.  
  638. local buttonSize = 110
  639. while buttonSize > 70 and math.floor((frameSize - frameSizeUsed).x/buttonSize) * math.floor((frameSize - frameSizeUsed).y/buttonSize) < 32 do
  640. buttonSize = buttonSize - 10
  641. end
  642.  
  643. Data.Main.InsertColumns = math.min(math.max(1, math.floor((frameSize - frameSizeUsed).x/buttonSize)), InsertColumns)
  644. Data.Main.InsertRows = math.min(math.max(1, math.floor((frameSize - frameSizeUsed).y/buttonSize)), InsertRows)
  645.  
  646. for index, button in pairs(Data.InsertButtons) do
  647. if index <= Data.Main.InsertRows * Data.Main.InsertColumns then
  648. button.Visible = true
  649. button.Size = UDim2.new(0, buttonSize-4, 0, buttonSize-4)
  650. button.Position = UDim2.new(0, buttonSize * ((index-1)%Data.Main.InsertColumns) + 2 + 2,
  651. 0, buttonSize * math.floor((index-1)/Data.Main.InsertColumns) + 2 + 2)
  652. else
  653. button.Visible = false
  654. end
  655. end
  656. Window.Main.Frame.InsertTab.Size = UDim2.new(0.0, buttonSize * Data.Main.InsertColumns + 4, 0.0, buttonSize * Data.Main.InsertRows + height*2 + 4)
  657.  
  658. if Data.Category[Data.CurrentCategory].Index == nil then
  659. setSetIndex(0)
  660. else
  661. setSetIndex(Data.Category[Data.CurrentCategory].Index)
  662. end
  663.  
  664. local finalFrameHeight = frameSizeUsed.y + Data.Main.InsertRows*buttonSize + 4
  665. Window.Main.Frame.Size = UDim2.new(0, frameSizeUsed.x + Data.Main.InsertColumns*buttonSize + 4, 0, finalFrameHeight)
  666. Window.Main.Frame.Position = UDim2.new(0.0, 0, 1.0, -Window.Main.Frame.Size.Y.Offset)
  667.  
  668. if Data.Category[Data.CurrentCategory].SetIndex == nil then
  669. layoutSetButtons(finalFrameHeight, 1)
  670. else
  671. layoutSetButtons(finalFrameHeight, Data.Category[Data.CurrentCategory].SetIndex)
  672. end
  673. end
  674.  
  675. function layoutSetButtons(frameHeight, setIndex)
  676. Data.Main.FrameHeight = frameHeight
  677. Data.Main.InsertSets = math.floor(frameHeight / (height*2))
  678. if #Data.CurrentCategory > Data.Main.InsertSets then
  679. --Steal one entry since we have two many things
  680. Data.Main.InsertSets = Data.Main.InsertSets - 1
  681. end
  682.  
  683. print("Layout Set Buttons index=" .. setIndex .. ", InsertSets="..Data.Main.InsertSets)
  684.  
  685. setCategoryIndex(setIndex)
  686. end
  687.  
  688.  
  689. function insertComplete()
  690. Window.Loading.Frame.Visible = false
  691. Window.Stamp.Frame.Visible = false
  692. Window.Main.Frame.Visible = true
  693. end
  694.  
  695. function UnlockInstances(object)
  696. if object:IsA("BasePart") then
  697. object.Locked = false
  698. end
  699. for index,child in pairs(object:GetChildren()) do
  700. UnlockInstances(child)
  701. end
  702. end
  703.  
  704. function beginInsertDecal(decal)
  705.  
  706. Data.Stamp.DecalSelection = Instance.new("SurfaceSelection")
  707. Data.Stamp.DecalSelection.Color = BrickColor.new("Bright orange")
  708. Data.Stamp.DecalSelection.archivable = false
  709. Data.Stamp.DecalSelection.Parent = getPlayer().PlayerGui
  710.  
  711. --Save the decal in our Lua code for later use
  712. Data.Stamp.Decal = decal
  713. Data.Stamp.Decal.Parent = nil
  714. end
  715.  
  716. function beginInsertAsset(assetName, assetId, image, stampMode)
  717. --Copy over details into dialog window
  718. Window.Loading.AssetThumbLabel.Image = image
  719. Window.Loading.AssetNameLabel.Text = assetName
  720.  
  721. Window.Stamp.AssetThumbLabel.Image = image
  722. Window.Stamp.AssetNameLabel.Text = assetName
  723. Data.Stamp.StampMode = stampMode
  724.  
  725. --Hide the main window
  726. Window.Main.Frame.Visible = false
  727. --Show the dialog window
  728. Window.Loading.Frame.Visible = true
  729. Data.Loading.Cancelled = false
  730.  
  731. --This call will cause a "wait" until the data comes back
  732. local root
  733. if useAssetVersionId then
  734. root = game:GetService("InsertService"):LoadAssetVersion(assetId)
  735. else
  736. root = game:GetService("InsertService"):LoadAsset(assetId)
  737. end
  738.  
  739. if Data.Loading.Cancelled then
  740. --The user got bored and wandered off
  741.  
  742. --Just delete the model from the world... a shame we loaded it when they got bored
  743. root:Remove()
  744. else
  745. Window.Loading.Frame.Visible = false
  746.  
  747. local instances = root:GetChildren()
  748. if #instances == 0 then
  749. root:Remove()
  750. insertComplete()
  751. return
  752. end
  753.  
  754. --Unlock all parts that are inserted, to make sure they are editable
  755. UnlockInstances(root)
  756.  
  757. --Continue the insert process
  758. root.Name = "InsertedObject" .. assetId
  759.  
  760. --Examine the contents and decide what it looks like
  761. for pos, instance in pairs(instances) do
  762. --Single instance objects might be treated special, decals/skyboxes
  763. if instance:IsA("Decal") then
  764. --Current system here stops after finding one Decal (and gives you Decal tool)
  765. --We should do the same (probably)
  766. beginInsertDecal(instance)
  767. root:Remove()
  768.  
  769. Window.Stamp.Frame.Visible = true
  770. return
  771. elseif instance:IsA("Team") then
  772. instance.Parent = game:GetService("Teams")
  773. elseif instance:IsA("SpawnLocation") then
  774.  
  775. elseif instance:IsA("HopperBin") then
  776. -- Must go into the starterPack, prompt user?
  777. elseif instance:IsA("Tool") then
  778. -- Ask them if it should go in StarterPack?
  779. elseif instance:IsA("Sky") then
  780. local lightingService = game:GetService("Lighting")
  781. for index,child in pairs(lightingService:GetChildren()) do
  782. if child:IsA("Sky") then
  783. child:Remove();
  784. end
  785. end
  786. instance.Parent = lightingService
  787. return
  788. else
  789.  
  790. end
  791. end
  792.  
  793. if #root:GetChildren() == 0 then
  794. root:Remove()
  795. insertComplete()
  796. return
  797. end
  798.  
  799. Window.Stamp.Frame.Visible = true
  800. Data.Stamp.Model = root
  801. end
  802. end
  803.  
  804. function cancelAssetLoad()
  805. Data.Loading.Cancelled = true
  806. insertComplete()
  807. end
  808.  
  809. function buildLoadingDialogGui(root)
  810. Window.Loading = {}
  811. Data.Loading = {}
  812.  
  813. local dialogFrame = Instance.new("Frame")
  814. dialogFrame.Name = "InsertLoadingDialog"
  815. dialogFrame.Size = UDim2.new(0.0, height*10, 0, height*5)
  816. dialogFrame.Position = UDim2.new(0.5, -height*5, 0.5, -height*2.5)
  817. dialogFrame.BackgroundColor3 = frameColor
  818. dialogFrame.Active = true
  819. dialogFrame.Parent = root
  820. dialogFrame.Visible = false
  821. Window.Loading.Frame = dialogFrame
  822.  
  823. local assetThumb = Instance.new("ImageLabel")
  824. assetThumb.Position = UDim2.new(0.0, 2, 0.0, 2)
  825. assetThumb.Size = UDim2.new(0.5, -4, 1.0, -4)
  826. assetThumb.Parent = dialogFrame
  827. Window.Loading.AssetThumbLabel = assetThumb
  828.  
  829. local descriptionFrame = Instance.new("Frame")
  830. descriptionFrame.Name = "Description"
  831. descriptionFrame.Size = UDim2.new(0.5, 0, 1.0, 0)
  832. descriptionFrame.Position = UDim2.new(0.5, 0, 0.0, 0)
  833. descriptionFrame.Transparency = 1
  834. descriptionFrame.Parent = dialogFrame
  835.  
  836. local label = Instance.new("TextLabel")
  837. label.Text = "Loading..."
  838. label.Position = UDim2.new(0.5, 0, 0, 0);
  839. label.Size = UDim2.new(0.0, 0, 0.0, height)
  840. label.BorderSizePixel = 0
  841. label.TextColor3 = frameTextColor
  842. label.Parent = descriptionFrame
  843.  
  844. local assetLabel = Instance.new("TextLabel")
  845. assetLabel.Text = "Your Asset Here"
  846. assetLabel.Position = UDim2.new(0.0, 0, 0.0, height)
  847. assetLabel.Size = UDim2.new(1.0, 0, 1.0, -2*height)
  848. assetLabel.BorderSizePixel = 0
  849. assetLabel.BackgroundTransparency = 1.0
  850. assetLabel.Parent = descriptionFrame
  851. assetLabel.TextColor3 = frameTextColor
  852. assetLabel.TextWrap = true
  853. Window.Loading.AssetNameLabel = assetLabel
  854.  
  855. local cancelButton = Instance.new("TextButton")
  856. cancelButton.Name = "PreviousPageButton"
  857. cancelButton.Size = UDim2.new(0, height*3, 0, height)
  858. cancelButton.Position = UDim2.new(0.5, -height*1.5, 1.0, -height*1.2)
  859. cancelButton.BackgroundColor3 = buttonColor
  860. cancelButton.TextColor3 = buttonTextColor
  861. cancelButton.Text = "Cancel"
  862. cancelButton.MouseButton1Click:connect(cancelAssetLoad)
  863. cancelButton.Parent = descriptionFrame
  864. end
  865.  
  866.  
  867.  
  868. function cancelAssetPlacement()
  869. Data.Stamp.Cancelled = true
  870. Data.Stamp.Dragger = nil
  871. if Data.Stamp.Model then
  872. Data.Stamp.Model:Remove()
  873. Data.Stamp.Model = nil
  874. end
  875. if Data.Stamp.CurrentParts then
  876. for index, object in pairs(Data.Stamp.CurrentParts) do
  877. object:Remove()
  878. end
  879. Data.Stamp.CurrentParts = nil
  880. end
  881.  
  882. if Data.Stamp.DecalSelection then
  883. Data.Stamp.DecalSelection:Remove()
  884. Data.Stamp.DecalSelection = nil
  885. end
  886. if Data.Stamp.Decal then
  887. Data.Stamp.Decal:Remove()
  888. Data.Stamp.Decal = nil
  889. end
  890.  
  891. if Mouse then
  892. Mouse.Icon ="rbxasset://textures\\ArrowCursor.png"
  893. end
  894. insertComplete()
  895. end
  896.  
  897. function onInsertKeyDown(key)
  898. if Data.Stamp.Dragger then
  899. if key == 'R' or key == 'r' then
  900. Data.Stamp.Dragger:AxisRotate(Enum.Axis.Y)
  901. elseif key == 'T' or key == 't' then
  902. Data.Stamp.Dragger:AxisRotate(Enum.Axis.Z)
  903. end
  904. end
  905. if key == '' then
  906. minimize()
  907. end
  908. end
  909.  
  910.  
  911. function canSelectObject(part)
  912. return part and not (part.Locked) and part:IsA("BasePart") and (part.Position - Tool.Parent.Head.Position).Magnitude < 60
  913. end
  914.  
  915. function setSelectionSurface(part, surface)
  916. if Data.Stamp.DecalSelection.Adornee == part and Data.Stamp.DecalSelection.TargetSurface == surface then
  917. return
  918. end
  919. unsetSelectionSurface()
  920. Data.Stamp.DecalSelection.Adornee = part
  921. Data.Stamp.DecalSelection.TargetSurface = surface
  922. --selectionLasso.Part = part
  923.  
  924. local decalFound = false
  925. for index,child in pairs(part:GetChildren()) do
  926. if child:IsA("Decal") and child.Face == surface then
  927. decalFound = true
  928. break
  929. end
  930. end
  931.  
  932. if not(decalFound) then
  933. Data.Stamp.Decal.Parent = part
  934. Data.Stamp.Decal.Face = surface
  935. end
  936. end
  937.  
  938. function unsetSelectionSurface()
  939. Data.Stamp.DecalSelection.Adornee = nil
  940. --selectionLasso.Part = nil
  941. Data.Stamp.Decal.Parent = nil
  942. end
  943.  
  944. function onInsertMouseMove()
  945. if Data.Stamp.MovingLock then
  946. return
  947. end
  948.  
  949. local newCursor = "rbxasset://textures\\ArrowCursor.png"
  950. Data.Stamp.MovingLock = true
  951. if Data.Stamp.Decal then
  952. local part = Mouse.Target
  953. if canSelectObject(part) then
  954. setSelectionSurface(part, Mouse.TargetSurface)
  955. else
  956. unsetSelectionSurface()
  957. newCursor = BaseUrl .. "asset?id=20715642"
  958. end
  959. elseif Data.Stamp.Dragger == nil then
  960. if Data.Stamp.Model ~= nil then
  961. Mouse.Icon ="rbxasset://textures//GrabRotateCursor.png"
  962. setupDraggableClone()
  963. end
  964. else
  965. Data.Stamp.Dragger:MouseMove(Mouse.UnitRay)
  966. end
  967. Mouse.Icon = newCursor
  968.  
  969. Data.Stamp.MovingLock = false
  970. end
  971.  
  972. function onInsertMouseButton1Down()
  973. if Data.Stamp.Dragger or Data.Stamp.Decal then
  974. Data.Stamp.MouseDown = true
  975. end
  976. end
  977.  
  978. function onInsertMouseButton1Up()
  979. if Data.Stamp.MouseDown then
  980. Data.Stamp.MouseDown = false
  981. if Data.Stamp.Decal then
  982. local part = Mouse.Target
  983. if canSelectObject(part) and Instance.Lock(part) then
  984. local surface = Mouse.TargetSurface
  985. for index,child in pairs(part:GetChildren()) do
  986. if child:IsA("Decal") and child.Face == surface then
  987. child:Remove()
  988. end
  989. end
  990.  
  991. local newDecal = Data.Stamp.Decal:Clone()
  992. newDecal.Face = surface
  993. newDecal.Parent = part
  994. Instance.Unlock(part)
  995.  
  996. if Data.Stamp.StampMode then
  997. else
  998. Instance.Unlock(part)
  999. cancelAssetPlacement()
  1000. end
  1001. end
  1002. elseif Data.Stamp.Dragger then
  1003. --Place the object where the mouse is currently positioned
  1004. Data.Stamp.Dragger:MouseUp()
  1005.  
  1006. --Fix the transparency of all the parts
  1007. for part, transparency in pairs(Data.Stamp.TransparencyTable) do
  1008. part.Transparency = transparency
  1009. end
  1010. Data.Stamp.TransparencyTable = nil
  1011.  
  1012. --Re-enable the scripts
  1013. for index,script in pairs(Data.Stamp.DisabledScripts) do
  1014. script.Disabled = false
  1015. end
  1016. --Now that they are all marked enabled, reinsert them into the world so they start running
  1017. for index,script in pairs(Data.Stamp.DisabledScripts) do
  1018. local oldParent = script.Parent
  1019. script.Parent = nil
  1020. script:Clone().Parent = oldParent
  1021. end
  1022. Data.Stamp.DisabledScripts = nil
  1023.  
  1024. Data.Stamp.Dragger = nil
  1025. Data.Stamp.CurrentParts = nil
  1026.  
  1027. if Data.Stamp.StampMode then
  1028. --Now set up a new instance of the object to allow a second copy to be stamped down
  1029. setupDraggableClone()
  1030. else
  1031. cancelAssetPlacement()
  1032. end
  1033. end
  1034. end
  1035. end
  1036.  
  1037.  
  1038. function collectParts(object, baseParts, scripts)
  1039. if object:IsA("BasePart") then
  1040. baseParts[#baseParts+1] = object
  1041. elseif object:IsA("Script") then
  1042. scripts[#scripts+1] = object
  1043. end
  1044.  
  1045. for index,child in pairs(object:GetChildren()) do
  1046. collectParts(child, baseParts, scripts)
  1047. end
  1048. end
  1049.  
  1050.  
  1051.  
  1052. function setupDraggableClone()
  1053. local clone = Data.Stamp.Model:Clone()
  1054. local scripts = {}
  1055. local parts = {}
  1056.  
  1057. collectParts(clone, parts, scripts)
  1058.  
  1059. if #parts > 0 then
  1060. Data.Stamp.DisabledScripts = {}
  1061. Data.Stamp.TransparencyTable = {}
  1062.  
  1063. for index,script in pairs(scripts) do
  1064. if not(script.Disabled) then
  1065. script.Disabled = true
  1066. Data.Stamp.DisabledScripts[#Data.Stamp.DisabledScripts +1] = script
  1067. end
  1068. end
  1069. for index, part in pairs(parts) do
  1070. Data.Stamp.TransparencyTable[part] = part.Transparency
  1071. part.Transparency = 0.5
  1072. end
  1073.  
  1074. game:GetService("InsertService"):Insert(clone)
  1075.  
  1076. Data.Stamp.CurrentParts = clone:GetChildren();
  1077. for index, object in pairs(Data.Stamp.CurrentParts) do
  1078. object.Parent = clone.Parent
  1079. end
  1080. clone:Remove();
  1081.  
  1082. Data.Stamp.Dragger = Instance.new("Dragger")
  1083. --Begin a movement by faking a MouseDown signal
  1084. Data.Stamp.Dragger:MouseDown(parts[1], Vector3.new(0,0,0), parts)
  1085. Data.Stamp.Dragger:MouseMove(Mouse.UnitRay)
  1086. else
  1087. --Nothing draggable in the Model
  1088. Data.Stamp.Model:Remove()
  1089. Data.Stamp.Model = nil
  1090. Data.Stamp.TransparencyTable = nil
  1091. Data.Stamp.DisabledScripts = nil
  1092. end
  1093. end
  1094. function buildStampDialogGui(root)
  1095. Window.Stamp = {}
  1096. Data.Stamp = {}
  1097.  
  1098. local dialogFrame = Instance.new("Frame")
  1099. dialogFrame.Name = "InsertStampDialog"
  1100. dialogFrame.Size = UDim2.new(0.0, height*10, 0, height*5)
  1101. dialogFrame.Position = UDim2.new(0.0, 0, 1.0, -height*5)
  1102. dialogFrame.BackgroundColor3 = frameColor
  1103. dialogFrame.Active = true
  1104. dialogFrame.Parent = root
  1105. dialogFrame.Visible = false
  1106. Window.Stamp.Frame = dialogFrame
  1107.  
  1108. local assetThumb = Instance.new("ImageLabel")
  1109. assetThumb.Position = UDim2.new(0.0, 2, 0.0, 2)
  1110. assetThumb.Size = UDim2.new(0.5, -4, 1.0, -4)
  1111. assetThumb.Parent = dialogFrame
  1112. Window.Stamp.AssetThumbLabel = assetThumb
  1113.  
  1114. local descriptionFrame = Instance.new("Frame")
  1115. descriptionFrame.Name = "Description"
  1116. descriptionFrame.Size = UDim2.new(0.5, 0, 1.0, 0)
  1117. descriptionFrame.Position = UDim2.new(0.5, 0, 0.0, 0)
  1118. descriptionFrame.Transparency = 1
  1119. descriptionFrame.Parent = dialogFrame
  1120.  
  1121. local assetLabel = Instance.new("TextLabel")
  1122. assetLabel.Text = "Your Asset Here"
  1123. assetLabel.Position = UDim2.new(0.0, 0, 0.0, 0)
  1124. assetLabel.Size = UDim2.new(1.0, 0, 1.0, -height)
  1125. assetLabel.BorderSizePixel = 0
  1126. assetLabel.BackgroundTransparency = 1.0
  1127. assetLabel.Parent = descriptionFrame
  1128. assetLabel.TextColor3 = frameTextColor
  1129. assetLabel.TextWrap = true
  1130. Window.Stamp.AssetNameLabel = assetLabel
  1131.  
  1132. local cancelButton = Instance.new("TextButton")
  1133. cancelButton.Name = "CancelButton"
  1134. cancelButton.Size = UDim2.new(0, height*4.5, 0, height)
  1135. cancelButton.Position = UDim2.new(0.5, -height*2.25, 1.0, -height*1.2)
  1136. cancelButton.BackgroundColor3 = buttonColor
  1137. cancelButton.TextColor3 = buttonTextColor
  1138. cancelButton.Text = "Back to Toolbox"
  1139. cancelButton.MouseButton1Click:connect(cancelAssetPlacement)
  1140. cancelButton.Parent = descriptionFrame
  1141.  
  1142. Data.Stamp.MovingLock = false
  1143. end
  1144.  
  1145. function buildInitialLoadScreen(root)
  1146. local dialogFrame = Instance.new("Frame")
  1147. dialogFrame.Name = "InsertLoadingScreen"
  1148. dialogFrame.Size = UDim2.new(0.0, height*10, 0, height*5)
  1149. dialogFrame.Position = UDim2.new(0.5, -height*5, 0.5, -height*2.5)
  1150. dialogFrame.BackgroundColor3 = frameColor
  1151. dialogFrame.Active = true
  1152. dialogFrame.Visible = true
  1153. dialogFrame.Parent = root
  1154.  
  1155. local label = Instance.new("TextLabel")
  1156. label.Text = "Loading"
  1157. label.Position = UDim2.new(0.0, 0, 0, 0)
  1158. label.Size = UDim2.new(1.0, 0, 0.0, height)
  1159. label.BorderSizePixel = 1
  1160. label.TextColor3 = titleTextColor
  1161. label.BackgroundColor3 = titleColor
  1162. label.Parent = dialogFrame
  1163.  
  1164. local assetLabel = Instance.new("TextLabel")
  1165. assetLabel.Text = "Please Wait"
  1166. assetLabel.Position = UDim2.new(0.0, 0, 0.0, height)
  1167. assetLabel.Size = UDim2.new(1.0, 0, 1.0, -2*height)
  1168. assetLabel.BorderSizePixel = 1
  1169. assetLabel.BackgroundTransparency = 1.0
  1170. assetLabel.TextColor3 = frameTextColor
  1171. assetLabel.TextWrap = true
  1172. assetLabel.Parent = dialogFrame
  1173. end
  1174.  
  1175. function buildMinimizedGui(root)
  1176. Window.Minimized = {}
  1177. Data.Minimized = {}
  1178. local minimizeButton = Instance.new("TextButton")
  1179. minimizeButton.Name = "MinimizeButton"
  1180. minimizeButton.Size = UDim2.new(0, height*4.5, 0, height)
  1181. minimizeButton.Position = UDim2.new(0.0, 0, 1.0, -height)
  1182. minimizeButton.BackgroundColor3 = buttonColor
  1183. minimizeButton.TextColor3 = buttonTextColor
  1184. minimizeButton.Text = "Toolbox"
  1185. minimizeButton.MouseButton1Click:connect(function() Window.Minimized.Frame.Visible = false Window.Main.Frame.Visible = true end)
  1186. minimizeButton.Visible = false
  1187. minimizeButton.Parent = root
  1188.  
  1189. Window.Minimized.Frame = minimizeButton
  1190. end
  1191.  
  1192.  
  1193. local CancelDuringLoad
  1194. local LoadScreen
  1195. function onEquippedLocal(mouse)
  1196. Tool.TextureId = "rbxasset://icons/insert_sel.png"
  1197.  
  1198. Mouse = mouse
  1199. if Tool.SavedState.Value and Tool.PlayerOwner.Value == getPlayer() and Data and Data.FullyLoaded then
  1200. guiMain = Tool.SavedState.Value
  1201. guiMain.Parent = getPlayer().PlayerGui
  1202.  
  1203. Window.Stamp.Frame.Visible = false
  1204. Window.Minimized.Frame.Visible = false
  1205. Window.Loading.Frame.Visible = false
  1206. Window.Main.Frame.Visible = true
  1207.  
  1208. --Window = Tool.SavedState.Value.Window
  1209. --Data = Tool.SavedState.Value.Window
  1210. else
  1211. CancelDuringLoad = false
  1212.  
  1213. LoadScreen = Instance.new("ScreenGui")
  1214. LoadScreen.Name = "InsertToolLoading"
  1215. buildInitialLoadScreen(LoadScreen)
  1216. LoadScreen.Parent = getPlayer().PlayerGui
  1217.  
  1218. guiMain = Instance.new("ScreenGui")
  1219. guiMain.Name = "InsertToolboxMain"
  1220. Window = {}
  1221. Data = {}
  1222. Data.FullyLoaded = false
  1223.  
  1224. buildMainGui(guiMain, getPlayer().userId)
  1225. buildLoadingDialogGui(guiMain)
  1226. buildStampDialogGui(guiMain)
  1227. buildMinimizedGui(guiMain)
  1228.  
  1229. LoadScreen:Remove()
  1230. LoadScreen = nil
  1231.  
  1232. if not(CancelDuringLoad) then
  1233. guiMain.Changed:connect(function(property) if property == "AbsoluteSize" then layoutInsertButtons(guiMain) end end)
  1234. guiMain.Parent = getPlayer().PlayerGui
  1235.  
  1236. Tool.SavedState.Value = guiMain
  1237. Tool.PlayerOwner.Value = getPlayer()
  1238. end
  1239.  
  1240. Data.FullyLoaded = true
  1241. end
  1242.  
  1243. Mouse.Move:connect(onInsertMouseMove)
  1244. Mouse.Button1Down:connect(onInsertMouseButton1Down)
  1245. Mouse.Button1Up:connect(onInsertMouseButton1Up)
  1246. Mouse.KeyDown:connect(onInsertKeyDown)
  1247.  
  1248. end
  1249.  
  1250. function onUnequippedLocal()
  1251. Tool.TextureId = origTexture
  1252.  
  1253. pcall(function()
  1254. cancelAssetPlacement()
  1255. cancelAssetLoad()
  1256. guiMain.Parent = nil
  1257. end)
  1258.  
  1259. CancelDuringLoad = true
  1260.  
  1261. if LoadScreen then
  1262. LoadScreen:Remove()
  1263. end
  1264. end
  1265.  
  1266. function onAncestryChanged(child,parent)
  1267. if Tool.PlayerOwner.Value and not Tool:IsDescendantOf(Tool.PlayerOwner.Value) and not Tool:IsDescendantOf(Tool.PlayerOwner.Value.Character) then
  1268. --Tool was dropped in some way, so we need to nuke our external state
  1269. Tool.SavedState.Value = nil
  1270. Tool.PlayerOwner.Value = nil
  1271. end
  1272.  
  1273. pcall(cancelAssetPlacement)
  1274. pcall(cancelAssetLoad)
  1275. end
  1276.  
  1277.  
  1278. Tool.Equipped:connect(onEquippedLocal)
  1279. Tool.Unequipped:connect(onUnequippedLocal)
  1280. Tool.AncestryChanged:connect(onAncestryChanged)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement