
local GUIEditor

function getTurretUserInterface ()
    return GUIEditor
end

addEventHandler("onClientResourceStart", resourceRoot,
function()
    guiSetVisible(GUIEditor.mainWindow, false)
    guiSetEnabled(GUIEditor.scrollpane[1], false)
    guiSetVisible(GUIEditor.loadingStatus, false)
end, false, "low") -- lower the addEventHandler priority, so that the code below has ran first.

--[[
    GUI code past below
]]

GUIEditor = {
    radiobutton = {},
    scrollpane = {}
}
addEventHandler("onClientResourceStart", resourceRoot,
    function()
        local screenW, screenH = guiGetScreenSize()
        GUIEditor.mainWindow = guiCreateWindow(screenW / 2 - 300, screenH / 2 - 300, 600, 600, "Turret creator", false)
        guiWindowSetSizable(GUIEditor.mainWindow, false)
        guiSetAlpha(GUIEditor.mainWindow, 0.94)

        GUIEditor.turretList = guiCreateGridList(9, 28, 290, 519, false, GUIEditor.mainWindow)
        guiGridListAddColumn(GUIEditor.turretList, "Turrets", 0.9)
        GUIEditor.addTurretButton = guiCreateButton(9, 555, 290, 35, "Add turret", false, GUIEditor.mainWindow)
        guiSetProperty(GUIEditor.addTurretButton, "NormalTextColour", "FFAAAAAA")
        GUIEditor.scrollpane[1] = guiCreateScrollPane(310, 60, 280, 531, false, GUIEditor.mainWindow)

        GUIEditor.loadingStatus = guiCreateLabel(310, 28, 183, 18, "Loading...", false, GUIEditor.mainWindow)
        guiSetProperty(GUIEditor.loadingStatus, "NormalTextColour", "FF09AA0F")
        guiSetFont(GUIEditor.loadingStatus, "default-bold-small")

        GUIEditor.closeTurretPanel = guiCreateButton(562, 28, 27, 27, "X", false, GUIEditor.mainWindow)
        guiSetProperty(GUIEditor.closeTurretPanel, "NormalTextColour", "FFAAAAAA")

        local propertieSectionStartY = 15

        GUIEditor.turretNameLabel = guiCreateLabel(0, propertieSectionStartY, 183, 18, "Name (optional)", false, GUIEditor.scrollpane[1])
        GUIEditor.turretNameInput = guiCreateEdit(0, propertieSectionStartY + 23, 255, 27, "", false, GUIEditor.scrollpane[1])

        GUIEditor.turretDescriptionLabel = guiCreateLabel(0, propertieSectionStartY + 60, 183, 18, "Description (optional)", false, GUIEditor.scrollpane[1])
        GUIEditor.turretDescriptionInput = guiCreateEdit(0, propertieSectionStartY + 83, 255, 27, "", false, GUIEditor.scrollpane[1])
        
        GUIEditor.turretPositionLabel = guiCreateLabel(0, propertieSectionStartY + 120, 183, 18, "Position", false, GUIEditor.scrollpane[1])

        GUIEditor.turretPositionLabelX = guiCreateLabel(0, propertieSectionStartY + 148, 15, 21, "X", false, GUIEditor.scrollpane[1])
        guiLabelSetColor(GUIEditor.turretPositionLabelX, 150, 150, 150)
        GUIEditor.turretPositionInputX = guiCreateEdit(15, propertieSectionStartY + 142, 55, 27, "", false, GUIEditor.scrollpane[1])

        
        GUIEditor.turretPositionLabelY = guiCreateLabel(90, propertieSectionStartY + 148, 15, 21, "Y", false, GUIEditor.scrollpane[1])
        guiLabelSetColor(GUIEditor.turretPositionLabelY, 150, 150, 150)
        GUIEditor.turretPositionInputY = guiCreateEdit(105, propertieSectionStartY + 142, 55, 27, "", false, GUIEditor.scrollpane[1])

        GUIEditor.turretPositionLabelZ = guiCreateLabel(185, propertieSectionStartY + 148, 15, 21, "Z", false, GUIEditor.scrollpane[1])
        guiLabelSetColor(GUIEditor.turretPositionLabelZ, 150, 150, 150)
        GUIEditor.turretPositionInputZ = guiCreateEdit(200, propertieSectionStartY + 142, 55, 27, "", false, GUIEditor.scrollpane[1])

        GUIEditor.turretRotationLabel = guiCreateLabel(0, propertieSectionStartY + 183, 183, 18, "Rotation (0 > 360)", false, GUIEditor.scrollpane[1])
        GUIEditor.turretRotationLabelAdditional = guiCreateLabel(0, propertieSectionStartY + 211, 66, 21, "Z", false, GUIEditor.scrollpane[1])
        guiLabelSetColor(GUIEditor.turretRotationLabelAdditional, 150, 150, 150)
        GUIEditor.turretRotationInput = guiCreateEdit(20, propertieSectionStartY + 205, 85, 27, "", false, GUIEditor.scrollpane[1])

        GUIEditor.setCurrentOrientation = guiCreateButton(130, propertieSectionStartY + 205, 125, 27, "Current orientation", false, GUIEditor.scrollpane[1])

        local ownerSectionStartY = 262

        GUIEditor.turretOwnerLabel = guiCreateLabel(0, ownerSectionStartY, 183, 18, "Owners (account name)", false, GUIEditor.scrollpane[1])
        GUIEditor.turretOwnerList = guiCreateGridList(0, ownerSectionStartY + 20, 255, 122, false, GUIEditor.scrollpane[1])
        guiGridListAddColumn(GUIEditor.turretOwnerList, "Account name", 0.9)

        GUIEditor.turretOwnerInput = guiCreateEdit(0, ownerSectionStartY + 146, 253, 27, "", false, GUIEditor.scrollpane[1])

        GUIEditor.turretOwnerAddButton = guiCreateButton(0, ownerSectionStartY + 179, 125, 27, "Add owner", false, GUIEditor.scrollpane[1])
        guiSetProperty(GUIEditor.turretOwnerAddButton, "NormalTextColour", "FFAAAAAA")

        GUIEditor.turretOwnerDeleteButton = guiCreateButton(130, ownerSectionStartY + 179, 125, 27, "Remove owner", false, GUIEditor.scrollpane[1])
        guiSetEnabled(GUIEditor.turretOwnerDeleteButton, false)
        guiSetProperty(GUIEditor.turretOwnerDeleteButton, "NormalTextColour", "FFAAAAAA")

        GUIEditor.turretBecomeOwnerButton = guiCreateButton(0, ownerSectionStartY + 210, 125, 27, "Become owner", false, GUIEditor.scrollpane[1])
        guiSetProperty(GUIEditor.turretBecomeOwnerButton, "NormalTextColour", "FFAAAAAA")



        GUIEditor.deleteTurretButton = guiCreateButton(0, 509, 255, 35, "Delete turret", false, GUIEditor.scrollpane[1])
        guiSetProperty(GUIEditor.deleteTurretButton, "NormalTextColour", "FFAAAAAA")

        --[[
        GUIEditor.turretTypeLabel = guiCreateLabel(0, 259, 183, 18, "Type", false, GUIEditor.scrollpane[1])
        GUIEditor.radiobutton[1] = guiCreateRadioButton(0, 282, 103, 23, "SAM Turret", false, GUIEditor.scrollpane[1])
        GUIEditor.radiobutton[2] = guiCreateRadioButton(145, 282, 103, 23, "TOW Launcher", false, GUIEditor.scrollpane[1]) 
        ]]

    end
)
