97 lines
2.5 KiB
Lua
97 lines
2.5 KiB
Lua
function CreateInputMenu(identifier)
|
|
local self = {}
|
|
self.isOpen_ = false
|
|
local _menuTitle = "RCORE"
|
|
self.identifier_ = identifier
|
|
local _properties = {
|
|
float = "middle_screen",
|
|
position = "middle_screen",
|
|
ChooseText = "Accepter",
|
|
CloseText = "Luk",
|
|
}
|
|
--------------
|
|
self.GetIdentifier = function()
|
|
return self.identifier_
|
|
end
|
|
|
|
self.IsOpen = function()
|
|
return self.isOpen_
|
|
end
|
|
--------------
|
|
self.SetMenuTitle = function(title)
|
|
_menuTitle = title
|
|
end
|
|
|
|
self.GetMenuTitle = function()
|
|
return _menuTitle
|
|
end
|
|
--------------
|
|
self.SetProperties = function(properties)
|
|
_properties = {
|
|
float = properties.float or "middle_screen",
|
|
position = properties.position or "middle_screen",
|
|
ChooseText = properties.ChooseText or "Accepter",
|
|
CloseText = properties.CloseText or "Luk",
|
|
}
|
|
end
|
|
|
|
self.GetProperties = function()
|
|
return _properties
|
|
end
|
|
--------------
|
|
self.OnCloseEvent = function(cb)
|
|
On(identifier, "close", cb)
|
|
end
|
|
|
|
self.OnOpenEvent = function(cb)
|
|
On(identifier, "open", cb)
|
|
end
|
|
|
|
self.OnExitEvent = function(cb)
|
|
On(identifier, "exit", cb)
|
|
end
|
|
|
|
self.OnInputText = function(cb)
|
|
On(identifier, "inputtext", cb)
|
|
end
|
|
|
|
self.On = function(eventName, cb)
|
|
On(identifier, eventName, cb)
|
|
end
|
|
--------------
|
|
self.Open = function()
|
|
if not CachedMenu[identifier] then
|
|
CachedMenu[identifier] = {}
|
|
end
|
|
CachedMenu[identifier] = {
|
|
MenuTitle = _menuTitle,
|
|
Properties = _properties,
|
|
self = self,
|
|
}
|
|
|
|
SendNUIMessage({ type = "title_input", title = _menuTitle })
|
|
SendNUIMessage({ type = "ui_input", identifier = identifier, properties = _properties, status = true })
|
|
|
|
CallOn(identifier, "open")
|
|
self.isOpen_ = true
|
|
SetNuiFocus(true, true)
|
|
end
|
|
--------------
|
|
self.Close = function()
|
|
SendNUIMessage({ type = "ui_input", status = false })
|
|
CallOn(identifier, "close")
|
|
self.isOpen_ = false
|
|
SetNuiFocus(false, false)
|
|
end
|
|
--------------
|
|
self.Destroy = function()
|
|
SendNUIMessage({ type = "ui_input", status = false })
|
|
CallOn(identifier, "exit")
|
|
CachedMenu[identifier] = nil
|
|
Events[identifier] = nil
|
|
SetNuiFocus(false, false)
|
|
end
|
|
return self
|
|
end
|
|
|
|
exports("CreateInputMenu", CreateInputMenu) |