Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local WindowHandlerModule = {}
- local SaveFolder = game.Players.LocalPlayer:WaitForChild("2DGMProjects")
- local ContextMenu = script.Parent.Parent["2DGMContextMenu"]
- local SendCodeToServer = game.ReplicatedStorage.WebhookEvent
- local Mouse = game.Players.LocalPlayer:GetMouse()
- local DataModule = require(script.Parent.Parent.Parent.Parent.SystemFiles.DLLs.LimeDataModule)
- local LimeErrorModule = require(script.Parent.Parent.Parent.Parent.SystemFiles.DLLs.LimeErrorModule)
- local HTTPGuiEncoder = require(script.Parent.Parent.Parent.Parent.SystemFiles.DLLs.HTTPGuiEncoder)
- local LimeExplorer = require(script.Parent.Parent.Parent.Parent.SystemFiles.DLLs.LimeExplorer)
- local GameEditor = script.Parent.MainFrame.GameEditor
- local GameExplorer = GameEditor.Explorer
- local GameUI = GameEditor.GameUI
- local Props = GameEditor.Properties
- local SaveButton = GameEditor.Save
- local DeleteButton = GameEditor.Delete
- local Run = script.Parent.OptionsBar.Run
- local OCE = script.Parent.OptionsBar.OpenCodeEditor
- local SaveProButton = script.Parent.OptionsBar.Save
- local NewProjectPage = script.Parent.MainFrame.NewProject
- local LoadingScreen = script.Parent.MainFrame.LoadingScreen
- local GameEditorPage = script.Parent.MainFrame.GameEditor
- local CreateProjectPage = script.Parent.MainFrame.CreateProject
- local CodeEditorPage = script.Parent.MainFrame.CodeEditor
- local OpenProjectPage = script.Parent.MainFrame.OpenProject
- local GameName = "Default"
- local LoadedSave = nil
- --TODO////////////////////////////////////////////////////////////////////////////-- Publish Project
- local PublishProjectFunc = function(Data,ProjectScript)
- local EncodedData = HTTPGuiEncoder.Encrypt(Data)
- SendCodeToServer:FireServer(EncodedData,"2DGM",ProjectScript)
- end
- local PubButton = script.Parent.OptionsBar.Publish
- PubButton.MouseButton1Click:Connect(function()
- if LoadedSave == nil then
- warn("No save loaded cannot publish")
- elseif LoadedSave == "1" then
- print("1 is loaded")
- print(script.Parent.MainFrame.GameEditor.GameUI:GetChildren())
- PublishProjectFunc(script.Parent.MainFrame.GameEditor.GameUI:GetChildren(),SaveFolder.Project_1_Script.Value)
- elseif LoadedSave == "2" then
- print("2 is loaded")
- elseif LoadedSave == "3" then
- print("3 is loaded")
- elseif LoadedSave == "4" then
- print("4 is loaded")
- end
- end)
- --TODO////////////////////////////////////////////////////////////////////////////-- Open Project stuff
- local OpenProButton = script.Parent.OptionsBar.Open
- local OpenProButton2 = script.Parent.MainFrame.NewProject.OpenExistingProject
- local OpenButton1 = script.Parent.MainFrame.OpenProject.Project1.TextButton
- local OpenButton2 = script.Parent.MainFrame.OpenProject.Project2.TextButton
- local OpenButton3 = script.Parent.MainFrame.OpenProject.Project3.TextButton
- local OpenButton4 = script.Parent.MainFrame.OpenProject.Project4.TextButton
- local EraseButton1 = script.Parent.MainFrame.OpenProject.Project1.TextButton2
- local EraseButton2 = script.Parent.MainFrame.OpenProject.Project2.TextButton2
- local EraseButton3 = script.Parent.MainFrame.OpenProject.Project3.TextButton2
- local EraseButton4 = script.Parent.MainFrame.OpenProject.Project4.TextButton2
- local SaveInfo1 = script.Parent.MainFrame.OpenProject.Project1.TextLabel2
- local SaveInfo2 = script.Parent.MainFrame.OpenProject.Project2.TextLabel2
- local SaveInfo3 = script.Parent.MainFrame.OpenProject.Project3.TextLabel2
- local SaveInfo4 = script.Parent.MainFrame.OpenProject.Project4.TextLabel2
- local OpenOpen = false
- OpenProButton.MouseButton1Click:Connect(function()
- if OpenOpen == false then
- OpenProjectPage.Visible = true
- OpenProButton.Text = "Close"
- OpenOpen = true
- else
- OpenProjectPage.Visible = false
- OpenProButton.Text = "Open"
- OpenOpen = false
- end
- end)
- OpenProButton2.MouseButton1Click:Connect(function()
- OpenProjectPage.Visible = true
- OpenOpen = true
- OpenProButton.Text = "Close"
- end)
- if SaveFolder.Project_1.Value ~= "" then
- SaveInfo1.Text = "Savedata"
- SaveInfo1.TextColor3 = Color3.fromRGB(85, 170, 0)
- end
- if SaveFolder.Project_2.Value ~= "" then
- SaveInfo2.Text = "Savedata"
- SaveInfo2.TextColor3 = Color3.fromRGB(85, 170, 0)
- end
- if SaveFolder.Project_3.Value ~= "" then
- SaveInfo3.Text = "Savedata"
- SaveInfo3.TextColor3 = Color3.fromRGB(85, 170, 0)
- end
- if SaveFolder.Project_4.Value ~= "" then
- SaveInfo4.Text = "Savedata"
- SaveInfo4.TextColor3 = Color3.fromRGB(85, 170, 0)
- end
- OpenButton1.MouseButton1Click:Connect(function()
- OpenProjectPage.Visible = false
- OpenOpen = false
- OpenProButton.Text = "Open"
- for i,v in pairs(GameExplorer:GetChildren()) do
- if v:IsA("UIListLayout") then
- else
- v.Value.Value:Destroy()
- v:Destroy()
- end
- end
- GameEditor.Visible = false
- OpenProjectPage.Visible = false
- LoadingScreen.Visible = true
- wait(3)
- LoadingScreen.Visible = false
- GameEditor.Visible = true
- HTTPGuiEncoder.Decrypt(SaveFolder.Project_1.Value,GameUI)
- script.Parent.MainFrame.CodeEditor.Frame.Scroll.TextBox.Text = SaveFolder.Project_1_Script.Value
- Run.Visible = true
- OCE.Visible = true
- SaveProButton.Visible = true
- LoadedSave = "1"
- end)
- OpenButton2.MouseButton1Click:Connect(function()
- OpenProjectPage.Visible = false
- OpenOpen = false
- OpenProButton.Text = "Open"
- for i,v in pairs(GameExplorer:GetChildren()) do
- if v:IsA("UIListLayout") then
- else
- v.Value.Value:Destroy()
- v:Destroy()
- end
- end
- GameEditor.Visible = false
- OpenProjectPage.Visible = false
- LoadingScreen.Visible = true
- wait(3)
- LoadingScreen.Visible = false
- GameEditor.Visible = true
- HTTPGuiEncoder.Decrypt(SaveFolder.Project_2.Value,GameUI)
- script.Parent.MainFrame.CodeEditor.Frame.Scroll.TextBox.Text = SaveFolder.Project_2_Script.Value
- Run.Visible = true
- OCE.Visible = true
- SaveProButton.Visible = true
- LoadedSave = "2"
- end)
- OpenButton3.MouseButton1Click:Connect(function()
- OpenProjectPage.Visible = false
- OpenOpen = false
- OpenProButton.Text = "Open"
- for i,v in pairs(GameExplorer:GetChildren()) do
- if v:IsA("UIListLayout") then
- else
- v.Value.Value:Destroy()
- v:Destroy()
- end
- end
- GameEditor.Visible = false
- OpenProjectPage.Visible = false
- LoadingScreen.Visible = true
- wait(3)
- LoadingScreen.Visible = false
- GameEditor.Visible = true
- HTTPGuiEncoder.Decrypt(SaveFolder.Project_3.Value,GameUI)
- script.Parent.MainFrame.CodeEditor.Frame.Scroll.TextBox.Text = SaveFolder.Project_3_Script.Value
- Run.Visible = true
- OCE.Visible = true
- SaveProButton.Visible = true
- LoadedSave = "3"
- end)
- OpenButton4.MouseButton1Click:Connect(function()
- OpenProjectPage.Visible = false
- OpenOpen = false
- OpenProButton.Text = "Open"
- for i,v in pairs(GameExplorer:GetChildren()) do
- if v:IsA("UIListLayout") then
- else
- v.Value.Value:Destroy()
- v:Destroy()
- end
- end
- GameEditor.Visible = false
- OpenProjectPage.Visible = false
- LoadingScreen.Visible = true
- wait(3)
- LoadingScreen.Visible = false
- GameEditor.Visible = true
- HTTPGuiEncoder.Decrypt(SaveFolder.Project_4.Value,GameUI)
- script.Parent.MainFrame.CodeEditor.Frame.Scroll.TextBox.Text = SaveFolder.Project_4_Script.Value
- Run.Visible = true
- OCE.Visible = true
- SaveProButton.Visible = true
- LoadedSave = "4"
- end)
- EraseButton1.MouseButton1Click:Connect(function()
- DataModule.SendProjectDataToServer("1","","","")
- end)
- EraseButton2.MouseButton1Click:Connect(function()
- DataModule.SendProjectDataToServer("2","","","")
- end)
- EraseButton3.MouseButton1Click:Connect(function()
- DataModule.SendProjectDataToServer("3","","","")
- end)
- EraseButton4.MouseButton1Click:Connect(function()
- DataModule.SendProjectDataToServer("4","","","")
- end)
- --TODO////////////////////////////////////////////////////////////////////////////-- Save Project stuff
- local GuiData = GameUI:GetChildren()
- local SaveMenu = script.Parent.MainFrame.SaveMenu
- local SaveButton1 = script.Parent.MainFrame.SaveMenu.Project1.TextButton
- local SaveButton2 = script.Parent.MainFrame.SaveMenu.Project2.TextButton
- local SaveButton3 = script.Parent.MainFrame.SaveMenu.Project3.TextButton
- local SaveButton4 = script.Parent.MainFrame.SaveMenu.Project4.TextButton
- local Info1 = script.Parent.MainFrame.SaveMenu.Project1.TextLabel2
- local Info2 = script.Parent.MainFrame.SaveMenu.Project2.TextLabel2
- local Info3 = script.Parent.MainFrame.SaveMenu.Project3.TextLabel2
- local Info4 = script.Parent.MainFrame.SaveMenu.Project4.TextLabel2
- local SaveOpen = false
- if SaveFolder.Project_1.Value ~= "" then
- Info1.Text = "Savedata"
- Info1.TextColor3 = Color3.fromRGB(85, 170, 0)
- end
- if SaveFolder.Project_2.Value ~= "" then
- Info2.Text = "Savedata"
- Info2.TextColor3 = Color3.fromRGB(85, 170, 0)
- end
- if SaveFolder.Project_3.Value ~= "" then
- Info3.Text = "Savedata"
- Info3.TextColor3 = Color3.fromRGB(85, 170, 0)
- end
- if SaveFolder.Project_4.Value ~= "" then
- Info4.Text = "Savedata"
- Info4.TextColor3 = Color3.fromRGB(85, 170, 0)
- end
- local Save = function(Number)
- local HTTPEncodedData = HTTPGuiEncoder.Encrypt(script.Parent.MainFrame.GameEditor.GameUI:GetChildren())
- DataModule.SendProjectDataToServer(Number,HTTPEncodedData,script.Parent.MainFrame.CodeEditor.Frame.Scroll.TextBox.Text)
- end
- SaveProButton.MouseButton1Click:Connect(function()
- if SaveOpen == false then
- SaveMenu.Visible = true
- SaveProButton.Text = "Close"
- SaveOpen = true
- else
- SaveMenu.Visible = false
- SaveProButton.Text = "Save"
- SaveOpen = false
- end
- end)
- SaveButton1.MouseButton1Click:Connect(function()
- Save("1")
- Info1.Text = "Savedata"
- Info1.TextColor3 = Color3.fromRGB(85, 170, 0)
- end)
- SaveButton2.MouseButton1Click:Connect(function()
- Save("2")
- Info2.Text = "Savedata"
- Info2.TextColor3 = Color3.fromRGB(85, 170, 0)
- end)
- SaveButton3.MouseButton1Click:Connect(function()
- Save("3")
- Info3.Text = "Savedata"
- Info3.TextColor3 = Color3.fromRGB(85, 170, 0)
- end)
- SaveButton4.MouseButton1Click:Connect(function()
- Save("4")
- Info4.Text = "Savedata"
- Info4.TextColor3 = Color3.fromRGB(85, 170, 0)
- end)
- --TODO////////////////////////////////////////////////////////////////////////////-- Execute Game stuff
- local Open = false
- OCE.MouseButton1Click:Connect(function()
- if Open == false then
- CodeEditorPage.Visible = true
- OCE.Text = "Close Code Editor"
- Open = true
- else
- CodeEditorPage.Visible = false
- OCE.Text = "Open Code Editor"
- Open = false
- end
- end)
- Run.MouseButton1Click:Connect(function()
- wait(0.4)
- LimeExplorer.StartUserApp(script.Parent.Parent.Window, GameName)
- wait()
- local Window = script.Parent.Parent:FindFirstChild(GameName)
- for i,v in pairs(GameUI:GetChildren()) do
- local Clone = v:Clone()
- Clone.Parent = Window.MainFrame
- end
- local Code = script.Parent.MainFrame.CodeEditor.Frame.Scroll.TextBox
- local FormatedCode = Code.Text:gsub("<font.->",""):gsub("</font>","")
- local loadstring = require(script.Parent.Parent.Parent.Parent.SystemFiles.DLLs.Loadstring)
- local executable, compileFailReason = loadstring(FormatedCode)
- print(compileFailReason)
- executable()
- end)
- --TODO////////////////////////////////////////////////////////////////////////////-- Create Project stuff
- local StartNewProjectButton = script.Parent.MainFrame.NewProject.StartNewProject
- local GameNameBox = CreateProjectPage.TextBox
- local Next = CreateProjectPage.Next
- StartNewProjectButton.MouseButton1Click:Connect(function()
- LoadingScreen.Visible = true
- wait(2)
- LoadingScreen.Visible = false
- CreateProjectPage.Visible = true
- end)
- Next.MouseButton1Click:Connect(function()
- if GameNameBox.Text == "" then
- GameNameBox.PlaceholderText = "Please enter a project name"
- wait(2)
- GameNameBox.PlaceholderText = "Enter your project name here"
- else
- GameName = GameNameBox.Text
- CreateProjectPage.Visible = false
- LoadingScreen.Visible = true
- wait(2)
- LoadingScreen.Visible = false
- GameEditorPage.Visible = true
- Run.Visible = true
- OCE.Visible = true
- SaveProButton.Visible = true
- end
- end)
- --TODO////////////////////////////////////////////////////////////////////////////-- Game Editor stuff
- --Property Boxes
- local NameBox = Props.NameBox
- local SizeBox = Props.SizeBox
- local PositionBox = Props.PositionBox
- local TextColorBox = Props.TextColorBox
- local BGcolorBox = Props.BGcolorBox
- local TextColorBox = Props.TextColorBox
- local VisibleBox = Props.VisibleBox
- local TextScaledBox = Props.TextScaledBox
- local BorderColorBox = Props.BorderColorBox
- local TextSizeBox = Props.TextSizeBox
- local BorderSizeBox = Props.BorderSizeBox
- local TextBox = Props.TextBox
- local ZIndexBox = Props.ZIndexBox
- --Functions
- local ExplorerObjVar
- local SaveProperties = function(obj,ExplorerObj)
- local PosString = string.split(PositionBox.Text, ",")
- local SizeString = string.split(SizeBox.Text, ",")
- local BackGroundString = string.split(BGcolorBox.Text, ",")
- local TextColorString = string.split(TextColorBox.Text, ",")
- local BorderColorString = string.split(BorderColorBox.Text, ",")
- ExplorerObj.Name = NameBox.Text
- ExplorerObj.Text = NameBox.Text
- obj.Name = NameBox.Text
- obj.Position = UDim2.new(table.unpack(PosString))
- obj.Size = UDim2.new(table.unpack(SizeString))
- obj.BackgroundColor3 = Color3.fromRGB(table.unpack(BackGroundString))
- obj.BorderColor3 = Color3.fromRGB(table.unpack(BorderColorString))
- obj.BorderSizePixel = BorderSizeBox.Text
- obj.ZIndex = tostring(ZIndexBox.text)
- if obj:IsA("Frame") then
- else
- obj.TextColor3 = Color3.fromRGB(table.unpack(TextColorString))
- obj.TextSize = TextSizeBox.Text
- obj.Text = TextBox.Text
- if TextScaledBox.Text == "true" then
- obj.TextScaled = true
- else
- obj.TextScaled = false
- end
- end
- if VisibleBox.Text == "true" then
- obj.Visible = true
- else
- obj.Visible = false
- end
- end
- local SetPropertiesforPropertiesMenu = function(obj)
- local SizeProp1 = string.gsub(tostring(obj.Size), "{", "")
- local PosProp1 = string.gsub(tostring(obj.Position), "{", "")
- local BackProp1 = string.gsub(tostring(obj.BackgroundColor3), "{", "")
- local BorderColor1 = string.gsub(tostring(obj.BorderColor3), "{", "")
- local SizeProp2 = string.gsub(SizeProp1, "}", "")
- local PosProp2 = string.gsub(PosProp1, "}", "")
- local BackProp2 = string.gsub(BackProp1, "}", "")
- local BorderColor2 = string.gsub(BorderColor1, "}", "")
- local ToRGB = function(string)
- local strTable = string:split(",")
- local R = strTable[1]*255
- local G = strTable[2]*255
- local B = strTable[3]*255
- local FinalRGBValue = table.concat({R,G,B}, " ,")
- return FinalRGBValue
- end
- NameBox.Text = obj.Name
- SizeBox.Text = SizeProp2
- PositionBox.Text = PosProp2
- BGcolorBox.Text = ToRGB(BackProp2)
- BorderColorBox.Text = ToRGB(BorderColor2)
- BorderSizeBox.Text = obj.BorderSizePixel
- ZIndexBox.Text = obj.ZIndex
- if obj:IsA("Frame") then
- TextColorBox.Text = "N/A"
- TextSizeBox.Text = "N/A"
- TextScaledBox.Text = "N/A"
- TextBox.Text = "N/A"
- else
- local TextColor1 = string.gsub(tostring(obj.TextColor3), "{", "")
- local TextColor2 = string.gsub(TextColor1, "}", "")
- TextColorBox.Text = ToRGB(TextColor2)
- TextSizeBox.Text = obj.TextSize
- TextBox.Text = obj.Text
- if obj.TextScaled == true then
- TextScaledBox.Text = "true"
- else
- TextScaledBox.Text = "false"
- end
- end
- if obj.Visible == true then
- VisibleBox.Text = "true"
- else
- VisibleBox.Text = "false"
- end
- end
- local EnabelButtonPress = function()
- for i,v in pairs(GameExplorer:GetChildren()) do
- if v:IsA("UIListLayout") then
- else
- v.MouseButton1Click:Connect(function()
- SetPropertiesforPropertiesMenu(v.Value.Value)
- Props.SelectedInstance.Value = v.Value.Value
- ExplorerObjVar = v
- end)
- end
- end
- end
- local DeleteExplorerObjs = function(obj,ExplorerObj)
- ExplorerObj.Value.Value:Destroy()
- ExplorerObj:Destroy()
- end
- WindowHandlerModule.AddExplorerObjs = function(obj)
- local UIElement = Instance.new("TextButton",GameExplorer)
- local ObjectValue = Instance.new("ObjectValue",UIElement)
- ObjectValue.Value = obj
- UIElement.Name = obj.Name
- UIElement.Text = obj.Name
- UIElement.BackgroundTransparency = 1
- UIElement.TextScaled = true
- UIElement.Font = "Gotham"
- UIElement.Size = UDim2.fromScale(1,0.025)
- UIElement.TextXAlignment = "Left"
- EnabelButtonPress()
- end
- --Context Menu
- GameUI.MouseEnter:Connect(function()
- Mouse.Button2Down:Connect(function()
- ContextMenu.Visible = true
- ContextMenu.Position = UDim2.fromOffset(Mouse.X,Mouse.Y)
- end)
- end)
- ContextMenu.MouseEnter:Connect(function()
- ContextMenu.MouseLeave:Connect(function()
- ContextMenu.Visible = false
- end)
- end)
- DeleteButton.MouseButton1Click:Connect(function()
- DeleteExplorerObjs(Props.SelectedInstance.Value,ExplorerObjVar)
- end)
- SaveButton.MouseButton1Click:Connect(function()
- SaveProperties(Props.SelectedInstance.Value,ExplorerObjVar)
- end)
- --Add UI elements
- ContextMenu.MainFrame.TextLabel.MouseButton1Click:Connect(function()
- local UI = Instance.new("TextLabel",GameUI)
- UI.Size = UDim2.fromOffset(100,100)
- UI.BackgroundColor3 = Color3.fromRGB(255,255,255)
- WindowHandlerModule.AddExplorerObjs(UI)
- end)
- ContextMenu.MainFrame.TextButton.MouseButton1Click:Connect(function()
- local UI = Instance.new("TextButton",GameUI)
- UI.Size = UDim2.fromOffset(100,100)
- UI.BackgroundColor3 = Color3.fromRGB(255,255,255)
- WindowHandlerModule.AddExplorerObjs(UI)
- end)
- ContextMenu.MainFrame.TextBox.MouseButton1Click:Connect(function()
- local UI = Instance.new("TextBox",GameUI)
- UI.Size = UDim2.fromOffset(100,100)
- UI.BackgroundColor3 = Color3.fromRGB(255,255,255)
- WindowHandlerModule.AddExplorerObjs(UI)
- end)
- ContextMenu.MainFrame.Frame.MouseButton1Click:Connect(function()
- local UI = Instance.new("Frame",GameUI)
- UI.Size = UDim2.fromOffset(100,100)
- UI.BackgroundColor3 = Color3.fromRGB(255,255,255)
- WindowHandlerModule.AddExplorerObjs(UI)
- end)
- local X = script.Parent.TopBar.Z
- local O = script.Parent.TopBar.Y
- local min = script.Parent.TopBar.X
- local OGPos
- local fullScreen = false
- --TODO////////////////////////////////////////////////////////////////////////////-- Topbar stuff
- X.MouseButton1Click:Connect(function()
- GameEditor.Visible = false
- Run.Visible = false
- OCE.Visible = false
- SaveProButton.Visible = false
- for i,v in pairs(GameExplorer:GetChildren()) do
- if v:IsA("UIListLayout") then
- else
- v.Value.Value:Destroy()
- v:Destroy()
- end
- end
- local Module = require(script.Parent.Parent.Parent.Parent.SystemFiles.DLLs.LimeExplorer)
- Module.CloseApp("2D Game Maker")
- end)
- --[[
- O.MouseButton1Click:Connect(function()
- if fullScreen == true then
- script.Parent.Position = OGPos
- script.Parent.Size = UDim2.fromScale(0.25, 0.5)
- fullScreen = false
- else
- OGPos = script.Parent.Position
- script.Parent.Size = UDim2.fromScale(1, 0.95)
- script.Parent.Position = UDim2.fromScale(0, 0)
- fullScreen = true
- end
- end)
- ]]--
- min.MouseButton1Click:Connect(function()
- -- Mache ich gleich
- end)
- return WindowHandlerModule
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement