diff --git a/[editor]/editor_gui/client/buttonclicked.lua b/[editor]/editor_gui/client/buttonclicked.lua
index 5a6d6e81c..c6880752d 100644
--- a/[editor]/editor_gui/client/buttonclicked.lua
+++ b/[editor]/editor_gui/client/buttonclicked.lua
@@ -55,18 +55,19 @@ function elementIcons_Clicked ( source, mouseButton )
end
end
+function newCallback(callbackResult)
+ if callbackResult == "YES" then
+ editor_main.newResource()
+ end
+
+ guiSetInputEnabled(false)
+end
+
--These are individual functions for each topmenu button
function topMenuClicked.new ()
editor_main.dropElement ()
guiSetInputEnabled(true)
- local yes,no = guiShowMessageBox ( "Are you sure you want to create a new map?\nAny unsaved data will be lost.", "info", "New", true, "Yes", "No" )
- addEventHandler ( "onClientGUIClick",yes,function()
- editor_main.newResource()
- guiSetInputEnabled(false)
- end,false )
- addEventHandler ( "onClientGUIClick",no,function()
- guiSetInputEnabled(false)
- end,false )
+ exports.dialogs:messageBox("New", "Are you sure you want to create a new map? Any unsaved data will be lost.", "newCallback", "QUESTION", "YESNO")
end
function topMenuClicked.open ()
diff --git a/[editor]/editor_gui/client/interface.lua b/[editor]/editor_gui/client/interface.lua
index f7eee626d..ea459fbe0 100644
--- a/[editor]/editor_gui/client/interface.lua
+++ b/[editor]/editor_gui/client/interface.lua
@@ -7,7 +7,7 @@ local interface = {
move_cursor = NOT_REQUIRED,
move_freecam = NOT_REQUIRED,
move_keyboard = NOT_REQUIRED,
- msgbox = NOT_REQUIRED,
+ dialogs = NOT_REQUIRED,
tooltip = NOT_REQUIRED,
freeroam = NOT_REQUIRED,
}
diff --git a/[editor]/editor_gui/client/load.lua b/[editor]/editor_gui/client/load.lua
index 5898a29fd..f5756e2ac 100644
--- a/[editor]/editor_gui/client/load.lua
+++ b/[editor]/editor_gui/client/load.lua
@@ -34,12 +34,13 @@ function openMap()
local row = guiGridListGetSelectedItem ( loadDialog.mapsList )
if row == -1 then return end
mapName = guiGridListGetItemText ( loadDialog.mapsList, row, 1 )
- open = guiShowMessageBox ( "Are you sure you want to load map \""..mapName.."\"?\nAny unsaved changes will be lost.", "info", "Are you sure?", true, "Open", "Cancel" )
- addEventHandler ( "onClientGUIClick", open, openButton, false )
+ exports.dialogs:messageBox("Are you sure?", "Are you sure you want to load map \""..mapName.."\"?\nAny unsaved changes will be lost.", "openCallback", "QUESTION", "YESNO")
end
-function openButton ()
- editor_main.openResource ( mapName )
+function openCallback(callbackResult)
+ if callbackResult == "YES" then
+ editor_main.openResource ( mapName )
+ end
end
addEvent ( "openShowDialog",true )
diff --git a/[editor]/editor_gui/client/locations.lua b/[editor]/editor_gui/client/locations.lua
index 4061b407d..ac085aa8e 100644
--- a/[editor]/editor_gui/client/locations.lua
+++ b/[editor]/editor_gui/client/locations.lua
@@ -102,11 +102,11 @@ function addBookmark ()
local z = locations.z:getValue()
local world = locations.world:getValue()
if name == "" then
- guiShowMessageBox ( 'No location name was specified!', "error", "Bad value", true )
+ exports.dialogs:messageBox("Bad value", "No location name was specified!", false, "ERROR", "OK")
return
end
if bookmarksTable[name] then
- guiShowMessageBox ( 'A location of name "'..name..'" already exists!', "error", "Conflict", true )
+ exports.dialogs:messageBox("Bad value", "A location of name \"" .. name .."\" already exists!", false, "ERROR", "OK")
return
end
bookmarksTable[name] = {}
@@ -192,15 +192,15 @@ end
function setLocation ( x,y,z,world )
if not x then
- local button = guiShowMessageBox ( "Invalid \"x position\" specified", "error", "Bad Value", true )
+ exports.dialogs:messageBox("Bad value", "Invalid \"x position\" specified", false, "ERROR", "OK")
return
end
if not y then
- local button = guiShowMessageBox ( "Invalid \"y position\" specified", "error", "Bad Value", true )
+ exports.dialogs:messageBox("Bad value", "Invalid \"y position\" specified", false, "ERROR", "OK")
return
end
if not z then
- local button = guiShowMessageBox ( "Invalid \"z position\" specified", "error", "Bad Value", true )
+ exports.dialogs:messageBox("Bad value", "Invalid \"z position\" specified", false, "ERROR", "OK")
return
end
if not world then
diff --git a/[editor]/editor_gui/client/mapsettings_gui.lua b/[editor]/editor_gui/client/mapsettings_gui.lua
index 8d520e1a9..f25aba5e7 100644
--- a/[editor]/editor_gui/client/mapsettings_gui.lua
+++ b/[editor]/editor_gui/client/mapsettings_gui.lua
@@ -170,29 +170,29 @@ end
function confirmMapSettings ()
local versionText = mapsettings.metaVersion:getValue()
if not versionText or not (( string.match (versionText, "^%d+$") ) or ( string.match (versionText, "^%d+%.%d+$") ) or ( string.match (versionText, "^%d+%.%d+%.%d+$") )) then
- guiShowMessageBox ( "Invalid META \"Version\" specified", "error", "Bad Value", true )
+ exports.dialogs:messageBox("Bad value", "Invalid META \"Version\" specified", false, "ERROR", "OK")
return
end
if not mapsettings.timeHour:getValue() or not mapsettings.timeMinute:getValue()
or mapsettings.timeHour:getValue() > 23 or mapsettings.timeMinute:getValue() > 59 then
- guiShowMessageBox ( "Invalid Time specified", "error", "Bad Value", true )
+ exports.dialogs:messageBox("Bad value", "Invalid time specified", false, "ERROR", "OK")
return
end
-- if mapsettings.metaAuthor:getValue() == "" then
- -- guiShowMessageBox ( "Invalid META \"Author\" specified", "error", "Bad Value", true )
+ -- exports.dialogs:messageBox("Bad value", "Invalid META \"Author\" specified", false, "ERROR", "OK")
-- return
-- end
if not tonumber(mapsettings.maxplayers:getValue()) then
- guiShowMessageBox ( 'Invalid "Maximum Players" specified', "error", "Bad Value", true )
+ exports.dialogs:messageBox("Bad value", "Invalid \"Maximum Players\" specified", false, "ERROR", "OK")
return
end
if not tonumber(mapsettings.minplayers:getValue()) then
- guiShowMessageBox ( 'Invalid "Minimum Players" specified', "error", "Bad Value", true )
+ exports.dialogs:messageBox("Bad value", "Invalid \"Maximum Players\" specified", false, "ERROR", "OK")
return
end
if mapsettings.minplayers:getValue() >= mapsettings.maxplayers:getValue() then
- guiShowMessageBox ( 'Invalid "Minimum Players" specified', "error", "Bad Value", true )
+ exports.dialogs:messageBox("Bad value", "Invalid \"Maximum Players\" specified", false, "ERROR", "OK")
return
end
if not tonumber(mapsettings.gamespeed:getValue()) then
diff --git a/[editor]/editor_gui/client/me_gui.lua b/[editor]/editor_gui/client/me_gui.lua
index e7477c8f3..92626c09e 100644
--- a/[editor]/editor_gui/client/me_gui.lua
+++ b/[editor]/editor_gui/client/me_gui.lua
@@ -370,12 +370,6 @@ function playSoundFrontEnd ( sound )
return returnValue
end
-function guiShowMessageBox ( message, boxType, title, forced, button1, button2, button3 )
- playSoundFrontEnd ( 5 )
- local a1,a2,a3 = msgbox.guiShowMessageBox ( message, boxType, title, forced, button1, button2, button3 )
- return a1,a2,a3
-end
-
function clearNonCreatableElements(elementTable)
for elementName,data in pairs(elementTable) do
if not data.createable then
diff --git a/[editor]/editor_gui/client/save.lua b/[editor]/editor_gui/client/save.lua
index b82508a9d..8fb6a2d62 100644
--- a/[editor]/editor_gui/client/save.lua
+++ b/[editor]/editor_gui/client/save.lua
@@ -54,33 +54,24 @@ function saveMap()
mapName = guiGetText ( saveDialog.mapName )
if mapName == "" then return end
if mapsInfo[string.lower(mapName)] then
- local save,cancel = guiShowMessageBox ( "Are you sure you want to overwrite map \""..mapName.."\"?\n" ..
- "This will cause original map data to be lost.",
- "info", "Are you sure?", true, "Save", "Cancel" )
- addEventHandler ( "onClientGUIClick", save, saveButton, false )
- addEventHandler ( "onClientGUIClick", cancel, restoreSaveDialog, false )
+ exports.dialogs:messageBox("Are you sure?", "Are you sure you want to overwrite map \""..mapName.."\"? This will cause original map data to be lost.", "saveCallback", "QUESTION", "YESNO")
guiSetProperty(saveDialog.window, "Disabled", "True")
elseif resourcesInfo[string.lower(mapName)] then
- guiShowMessageBox ( "Unable to save to \""..mapName.."\". \n" ..
- "You cannot overwrite non-map resources.",
- "error", "Cannot save", true )
+ exports.dialogs:messageBox("Cannot save", "Unable to save to \""..mapName.."\" You cannot overwrite non-map resources.", false, "ERROR", "OK")
else
- local save,cancel = guiShowMessageBox ( "Are you sure you want to save to \""..mapName.."\"?",
- "info", "Are you sure?", true, "Save", "Cancel" )
- addEventHandler ( "onClientGUIClick", save, saveButton, false )
- addEventHandler ( "onClientGUIClick", cancel, restoreSaveDialog, false )
+ exports.dialogs:messageBox("Are you sure?", "Are you sure you want to save to \""..mapName.."\"?", "saveCallback", "QUESTION", "YESNO")
guiSetProperty(saveDialog.window, "Disabled", "True")
end
end
-function saveButton()
- local resourceName = guiGetText ( saveDialog.mapName )
- local directory = guiGetText ( saveDialog.directory )
- editor_main.saveResource ( resourceName, directory )
-end
-
-function restoreSaveDialog()
- guiSetProperty(saveDialog.window, "Disabled", "False")
+function saveCallback(callbackResult)
+ if callbackResult == "YES" then
+ local resourceName = guiGetText ( saveDialog.mapName )
+ local directory = guiGetText ( saveDialog.directory )
+ editor_main.saveResource ( resourceName, directory )
+ else
+ guiSetProperty(saveDialog.window, "Disabled", "False")
+ end
end
addEvent ( "saveAsShowDialog", true )
diff --git a/[editor]/editor_gui/meta.xml b/[editor]/editor_gui/meta.xml
index 1397a1888..3d9269496 100644
--- a/[editor]/editor_gui/meta.xml
+++ b/[editor]/editor_gui/meta.xml
@@ -2,7 +2,7 @@
-
+
@@ -53,12 +53,16 @@
-
+
+
+
+
+
diff --git a/[editor]/editor_main/client/saveloadtest_client.lua b/[editor]/editor_main/client/saveloadtest_client.lua
index 028c158da..88f043768 100644
--- a/[editor]/editor_main/client/saveloadtest_client.lua
+++ b/[editor]/editor_main/client/saveloadtest_client.lua
@@ -17,22 +17,22 @@ addEventHandler ( "saveloadtest_return", root,
end
editor_gui.closeLoadDialog()
else
- editor_gui.guiShowMessageBox ( "Map resource could not be started!", "error", "Error", true )
+ exports.dialogs:messageBox("Error", "Map resource could not be started!", false, "ERROR", "OK")
end
elseif ( command ) == "save" then
if ( returnValue ) then
editor_gui.closeSaveDialog()
else
- editor_gui.guiShowMessageBox ( "Map resource could not be saved! "..reason, "error", "Error", true )
+ exports.dialogs:messageBox("Error", "Map resource could not be saved! " .. reason, false, "ERROR", "OK")
editor_gui.restoreSaveDialog()
end
elseif ( command ) == "quickSave" then
reason = reason or "The target resource may be in .zip format or corrupted."
- editor_gui.guiShowMessageBox ( "Map resource could not be saved! "..reason, "error", "Error", true )
+ exports.dialogs:messageBox("Error", "Map resource could not be saved! " .. reason, false, "ERROR", "OK")
editor_gui.restoreSaveDialog()
elseif ( command ) == "test" then
reason = reason or ""
- editor_gui.guiShowMessageBox ( "Test could not be started! "..reason, "error", "Error", true )
+ exports.dialogs:messageBox("Error", "Test resource could not be started! " .. reason, false, "ERROR", "OK")
editor_gui.stopTest()
elseif ( command == "close" ) then
editor_gui.closeSaveDialog()
diff --git a/[editor]/msgbox/script.lua b/[editor]/msgbox/script.lua
index 72f364870..17c15da53 100644
--- a/[editor]/msgbox/script.lua
+++ b/[editor]/msgbox/script.lua
@@ -1,4 +1,7 @@
--[[-----------DOCUMENTATION---------------
+WARNING:
+This resource is deprecated as the new 'dialogs' resource replaces it.
+
SYNTAX:
guibutton,guibutton,guibutton = guiShowMessageBox ( string message, string boxType, string title [, string button1, string button2, stringbutton3] )
REQUIRED ARGUMENTS
@@ -111,6 +114,9 @@ function guiShowMessageBox ( message, boxType, title, forceShowing, button1, but
if ( forceShowing ) then
guiAttached[cover] = aMessage.Form
end
+
+ outputDebugString("This resource is deprecated as the new 'dialogs' resource replaces it.", 2)
+
return guiButton1, guiButton2, guiButton3
end
diff --git a/[gameplay]/dialogs/files/error.png b/[gameplay]/dialogs/files/error.png
new file mode 100644
index 000000000..18e838824
Binary files /dev/null and b/[gameplay]/dialogs/files/error.png differ
diff --git a/[gameplay]/dialogs/files/info.png b/[gameplay]/dialogs/files/info.png
new file mode 100644
index 000000000..6524cba60
Binary files /dev/null and b/[gameplay]/dialogs/files/info.png differ
diff --git a/[gameplay]/dialogs/files/question.png b/[gameplay]/dialogs/files/question.png
new file mode 100644
index 000000000..85c6f44cb
Binary files /dev/null and b/[gameplay]/dialogs/files/question.png differ
diff --git a/[gameplay]/dialogs/files/warning.png b/[gameplay]/dialogs/files/warning.png
new file mode 100644
index 000000000..46aaa5384
Binary files /dev/null and b/[gameplay]/dialogs/files/warning.png differ
diff --git a/[gameplay]/dialogs/meta.xml b/[gameplay]/dialogs/meta.xml
new file mode 100644
index 000000000..b4b3e3a94
--- /dev/null
+++ b/[gameplay]/dialogs/meta.xml
@@ -0,0 +1,16 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/[gameplay]/dialogs/readme.md b/[gameplay]/dialogs/readme.md
new file mode 100644
index 000000000..1a94dbb38
--- /dev/null
+++ b/[gameplay]/dialogs/readme.md
@@ -0,0 +1,230 @@
+# Dialogs
+
+## Description
+Create and manage dialogs with callbacks.
+
+## Pictures
+![img](https://i.imgur.com/yawOkA6.png)
+
+## Functions
+
+### MessageBeep
+
+**Description**
+This function plays a sound from the **messageSounds** table.
+
+**Syntax**
+```lua
+messageBeep( string soundType, [ int soundVolume ] )
+```
+
+**Example**
+> This example plays an info sound with the default volume (1)
+```lua
+messageBeep("INFO")
+```
+
+
+
+> This example plays a question sound with specified volume (0.5)
+```lua
+messageBeep("QUESTION", 0.5)
+```
+
+**Arguments**
+> - soundType: A string specifying the sound data, which is in the **messageSounds** table.
+> - soundVolume: An integer between 1 and 0 that specifies the volume. (optional)
+
+
+
+**Returns**
+Returns the sound element.
+
+### MessageBox
+
+**Description**
+This function creates a dialog box with a callback function.
+
+**Syntax**
+```lua
+messageBox( string messageTitle, string messageContent, string messageCallback, [ string messageIcon, string messageButton, int messageButtonDefault, string messageSound, int messageSoundVolume] )
+```
+
+**Example**
+> This example creates a dialog containing an information.
+```lua
+messageBox("Welcome", "Multi Theft Auto provides the best online Grand Theft Auto experience there is.", "callbackFunction", "INFO", "OK")
+```
+
+```lua
+function callbackFunction(callbackResult)
+ if callbackResult == "OK" then
+ print("Read")
+ end
+end
+```
+
+
+
+> This example creates a dialog containing a question.
+```lua
+messageBox("Save", "Are you sure you want to save your changes? This action will overwrite your previous saves.", "callbackFunction", "QUESTION", "YESNOCANCEL")
+```
+
+```lua
+function callbackFunction(callbackResult)
+ if callbackResult == "YES" then
+ print("Save")
+ elseif callbackResult == "NO" then
+ print("Undo")
+ else
+ print("Cancel")
+ end
+end
+```
+
+
+
+> This example creates a dialog containing a warning.
+```lua
+messageBox("Mismatch", "The selected file does not exist. Would you like to try the download again?", "callbackFunction", "WARNING", "ABORTRETRYIGNORE")
+```
+
+```lua
+function callbackFunction(callbackResult)
+ if callbackResult == "ABORT" then
+ print("Abort")
+ elseif callbackResult == "RETRY" then
+ print("Retry")
+ else
+ print("Ignore")
+ end
+end
+```
+
+
+
+> This example creates a dialog containing an error.
+```lua
+messageBox("Your wallet is empty", "You do not have enough money to purchase the selected vehicle.", "callbackFunction", "ERROR", "OK")
+```
+
+```lua
+function callbackFunction(callbackResult)
+ if callbackResult == "OK" then
+ print("Read")
+ end
+end
+```
+
+**Arguments**
+> - messageTitle: A string specifing the title of the message (note that it will be always uppercase)
+> - messageContent: A string specifing the content of the message
+> - messageCallback: A string specifying the name of the function that will be exported when a button is pressed. (Note that you must specify the function name as a string and specify the function as exportable in the meta.xml of the source.)
+> - messageIcon: A string specifing the icon of the message, which is in the **messageIcons** table.
+> - messageButton: A string specifing the button(s) of the message, which is in the **messageButtons** table.
+> - messageButtonDefault: An integer specifing the default button (note that it will receive a bolder font)
+> - messageSound: A string specifing the sound of the message, which is in the **messageSounds** table.
+> - messageSoundVolume: An integer between 1 and 0 specifing the volume of the sound.
+
+
+**Returns**
+This function does not contain returns because it uses a callback function.
+
+### MessageBoxEx
+
+**Description**
+This function creates a dialog box without a callback function.
+
+**Syntax**
+```lua
+messageBoxEx( string messageTitle, string messageContent, [ string messageIcon, string messageButton, int messageButtonDefault, string messageSound, int messageSoundVolume] )
+```
+
+**Example**
+> This example creates a dialog containing an information.
+```lua
+local buttonOK = messageBoxEx("Welcome", "Multi Theft Auto provides the best online Grand Theft Auto experience there is.", "INFO", "OK")
+
+addEventHandler("onClientGUIClick", buttonOK,
+ function()
+ print("Read")
+ end
+)
+```
+
+
+
+> This example creates a dialog containing a question.
+```lua
+local buttonYes, buttonNo, buttonCancel = messageBoxEx("Save", "Are you sure you want to save your changes? This action will overwrite your previous saves.", "QUESTION", "YESNOCANCEL")
+
+addEventHandler("onClientGUIClick", buttonYes,
+ function()
+ print("Save")
+ end
+)
+
+addEventHandler("onClientGUIClick", buttonNo,
+ function()
+ print("Undo")
+ end
+)
+
+addEventHandler("onClientGUIClick", buttonCancel,
+ function()
+ print("Cancel")
+ end
+)
+```
+
+
+
+> This example creates a dialog containing a warning.
+```lua
+local buttonAbort, buttonRetry, buttonIgnore = messageBoxEx("Save", "Are you sure you want to save your changes? This action will overwrite your previous saves.", "QUESTION", "YESNOCANCEL")
+
+addEventHandler("onClientGUIClick", buttonAbort,
+ function()
+ print("Abort")
+ end
+)
+
+addEventHandler("onClientGUIClick", buttonRetry,
+ function()
+ print("Retry")
+ end
+)
+
+addEventHandler("onClientGUIClick", buttonIgnore,
+ function()
+ print("Ignore")
+ end
+)
+```
+
+
+
+> This example creates a dialog containing an error.
+```lua
+local buttonOK = messageBoxEx("Your wallet is empty", "You do not have enough money to purchase the selected vehicle.", "ERROR", "OK")
+
+addEventHandler("onClientGUIClick", buttonOK,
+ function()
+ print("Read")
+ end
+)
+```
+
+**Arguments**
+> - messageTitle: A string specifing the title of the message (note that it will be always uppercase)
+> - messageContent: A string specifing the content of the message
+> - messageIcon: A string specifing the icon of the message, which is in the **messageIcons** table.
+> - messageButton: A string specifing the button(s) of the message, which is in the **messageButtons** table.
+> - messageButtonDefault: An integer specifing the default button (note that it will receive a bolder font)
+> - messageSound: A string specifing the sound of the message, which is in the **messageSounds** table.
+> - messageSoundVolume: An integer between 1 and 0 specifing the volume of the sound.
+
+
+**Returns**
+Returns as many buttons in order as specified in the messageButton argument.
\ No newline at end of file
diff --git a/[gameplay]/dialogs/sourceC.lua b/[gameplay]/dialogs/sourceC.lua
new file mode 100644
index 000000000..d59c6b6f2
--- /dev/null
+++ b/[gameplay]/dialogs/sourceC.lua
@@ -0,0 +1,310 @@
+local screenX, screenY = guiGetScreenSize()
+
+local messageBoxWindows = {}
+local messageBoxCallbacks = {}
+
+function messageBeep(soundType, soundVolume)
+ if not soundType or type(soundType) ~= "string" then
+ error("Bad argument @ 'messageBeep' [Expected string at argument 1, got " .. type(soundType) .. "]")
+ end
+
+ soundType = utf8.upper(soundType)
+
+ if not messageSounds[soundType] then
+ error("Bad argument @ 'messageBeep' [Invalid type at argument 1, got '" .. tostring(soundType) .. "']")
+ end
+
+ if not soundVolume or soundVolume > 1 or type(soundVolume) ~= "number" then
+ soundVolume = 1
+ end
+
+ local soundID = messageSounds[soundType].soundID
+ local soundElement = playSoundFrontEnd(soundID)
+
+ if soundElement and isElement(soundElement) then
+ setSoundVolume(soundElement, soundVolume)
+ end
+
+ return soundElement
+end
+
+function messageClick()
+ local elementParent = getElementParent(source)
+
+ if elementParent then
+ local elementBox = messageBoxWindows[elementParent]
+
+ if elementBox then
+ local elementCallback = messageBoxCallbacks[elementParent][1]
+ local elementCallbackSource = messageBoxCallbacks[elementParent][2]
+ local elementCallbackResult = guiGetText(source)
+
+ elementCallbackResult = utf8.upper(elementCallbackResult)
+
+ if elementCallback and type(elementCallback) == "string" then
+ if elementCallbackSource and getResourceState(elementCallbackSource) == "running" then
+ call(elementCallbackSource, elementCallback, elementCallbackResult)
+ end
+ end
+
+ destroyElement(elementParent)
+
+ messageBoxWindows[elementParent] = nil
+ messageBoxCallbacks[elementParent] = nil
+ end
+ end
+end
+
+function messageClickEx()
+ local elementParent = getElementParent(source)
+
+ if elementParent then
+ local elementBox = messageBoxWindows[elementParent]
+
+ if elementBox then
+ destroyElement(elementParent)
+ messageBoxWindows[elementParent] = nil
+ end
+ end
+end
+
+function messageBox(messageTitle, messageContent, messageCallback, messageIcon, messageButton, messageButtonDefault, messageSound, messageSoundVolume)
+ if not messageTitle or type(messageTitle) ~= "string" then
+ error("Bad argument @ 'messageBox' [Expected string at argument 1, got " .. type(messageTitle) .. "]")
+ end
+
+ messageTitle = utf8.upper(messageTitle)
+
+ if not messageContent or type(messageContent) ~= "string" then
+ error("Bad argument @ 'messageBox' [Expected string at argument 2, got " .. type(messageContent) .. "]")
+ end
+
+ if not messageIcon or type(messageIcon) ~= "string" then
+ messageIcon = "INFO"
+ end
+
+ messageIcon = utf8.upper(messageIcon)
+
+ if not messageIcons[messageIcon] then
+ error("Bad argument @ 'messageBox' [Invalid type at argument 4, got '" .. tostring(messageIcon) .. "']")
+ end
+
+ if not messageButton or type(messageButton) ~= "string" then
+ messageButton = "OK"
+ end
+
+ messageButton = utf8.upper(messageButton)
+
+ if not messageButtons[messageButton] then
+ error("Bad argument @ 'messageBox' [Invalid type at argument 5, got '" .. tostring(messageButton) .. "']")
+ end
+
+ if messageButtonDefault then
+ if type(messageButtonDefault) ~= "number" then
+ error("Bad argument @ 'messageBox' [Expected number at argument 6, got " .. type(messageButtonDefault) .. "]")
+ elseif #messageButtons[messageButton] < messageButtonDefault then
+ error("Bad argument @ 'messageBox' [Invalid default at argument 6, " .. messageButton .. " only have " .. tostring(#messageButtons[messageButon]) .. " buttons.]")
+ end
+ else
+ messageButtonDefault = 1
+ end
+
+ if messageSound then
+ if type(messageSound) ~= "string" then
+ error("Bad argument @ 'messageBox' [Expected string at argument 7, got " .. type(messageSound) .. "]")
+ elseif not messageSounds[messageSound] then
+ error("Bad argument @ 'messageBox' [Invalid type at argument 7, got '" .. messageSound .. "']")
+ end
+ else
+ messageSound = messageIcon
+ end
+
+ if messageSoundVolume then
+ if type(messageSoundVolume) ~= "number" then
+ error("Bad argument @ 'messageBox' [Expected number at argument 8, got " .. type(messageSoundVolume) .. "]")
+ elseif messageSoundVolume > 1 or messageSoundVolume < 1 then
+ error("Bad argument @ 'messageBox' [Invalid volume at argument 8, got '" .. tostring(messageSoundVolume) .. "']")
+ end
+ else
+ messageSoundVolume = 1
+ end
+
+ messageBeep(messageSound, messageSoundVolume)
+
+ local messageWindowWidth = 400
+ local messageWindowHeight = 200
+
+ local messageWindowPosX = (screenX - messageWindowWidth) / 2
+ local messageWindowPosY = (screenY - messageWindowHeight) / 2
+ local messageWindowElement = guiCreateWindow(messageWindowPosX, messageWindowPosY, messageWindowWidth, messageWindowHeight, messageTitle)
+
+ guiWindowSetSizable(messageWindowElement, false)
+
+ local messageIconWidth = 42
+ local messageIconHeight = 42
+
+ local messageIconPosX = (messageWindowWidth - messageIconWidth) / 8
+ local messageIconPosY = (messageWindowHeight - messageIconHeight) / 2
+
+ guiCreateStaticImage(messageIconPosX, messageIconPosY, messageIconWidth, messageIconHeight, messageIcons[messageIcon].iconPath, false, messageWindowElement)
+
+ local messageCaptionWidth = messageWindowWidth - (messageIconPosX + messageIconWidth + 10 + 5)
+ local messageCaptionHeight = 16
+
+ local messageContentWidth = messageWindowWidth - (messageIconPosX + messageIconWidth + 10 + 5)
+ local messageContentHeight = 18
+
+ local messageCaptionPosX = messageIconPosX + messageIconWidth + 10
+ local messageCaptionPosY = messageIconPosY + (messageIconHeight - messageCaptionHeight - messageContentHeight) / 2
+ local messageCaptionElement = guiCreateLabel(messageCaptionPosX, messageCaptionPosY, messageCaptionWidth, messageCaptionHeight, messageIcons[messageIcon].iconCaption, false, messageWindowElement)
+
+ guiSetFont(messageCaptionElement, "default-bold-small")
+
+ local messageContentPosX = messageIconPosX + messageIconWidth + 10
+ local messageContentPosY = messageIconPosY + (messageIconHeight - messageContentHeight) - 5
+ local messageContentElement = guiCreateLabel(messageContentPosX, messageContentPosY, messageContentWidth, messageContentHeight * 4 , messageContent, false, messageWindowElement)
+
+ guiLabelSetHorizontalAlign(messageContentElement, "left", true)
+
+ local messageButtonWidth = 50
+ local messageButtonHeight = 30
+
+ local messageButtonPosX = (messageWindowWidth - 5) - (messageButtonWidth + 5) * #messageButtons[messageButton]
+ local messageButtonPosY = (messageWindowHeight - 10) - messageButtonHeight
+
+ for i, v in ipairs(messageButtons[messageButton]) do
+ local messageButtonElement = guiCreateButton(messageButtonPosX, messageButtonPosY, messageButtonWidth, messageButtonHeight, v, false, messageWindowElement)
+
+ if i == messageButtonDefault then
+ guiSetFont(messageButtonElement, "default-bold-small")
+ end
+
+ addEventHandler("onClientGUIClick", messageButtonElement, messageClick, false)
+ messageButtonPosX = messageButtonPosX + messageButtonWidth + 5
+ end
+
+ messageBoxWindows[messageWindowElement] = {messageTitle, messageContent, messageIcon, messageButton}
+ messageBoxCallbacks[messageWindowElement] = {messageCallback, sourceResource}
+end
+
+function messageBoxEx(messageTitle, messageContent, messageIcon, messageButton, messageButtonDefault, messageSound, messageSoundVolume)
+ if not messageTitle or type(messageTitle) ~= "string" then
+ error("Bad argument @ 'messageBoxEx' [Expected string at argument 1, got " .. type(messageTitle) .. "]")
+ end
+
+ messageTitle = utf8.upper(messageTitle)
+
+ if not messageContent or type(messageContent) ~= "string" then
+ error("Bad argument @ 'messageBoxEx' [Expected string at argument 2, got " .. type(messageContent) .. "]")
+ end
+
+ if not messageIcon or type(messageIcon) ~= "string" then
+ messageIcon = "INFO"
+ end
+
+ messageIcon = utf8.upper(messageIcon)
+
+ if not messageIcons[messageIcon] then
+ error("Bad argument @ 'messageBoxEx' [Invalid type at argument 3, got '" .. tostring(messageIcon) .. "']")
+ end
+
+ if not messageButton or type(messageButton) ~= "string" then
+ messageButton = "OK"
+ end
+
+ messageButton = utf8.upper(messageButton)
+
+ if not messageButtons[messageButton] then
+ error("Bad argument @ 'messageBoxEx' [Invalid type at argument 4, got '" .. tostring(messageButton) .. "']")
+ end
+
+ if messageButtonDefault then
+ if type(messageButtonDefault) ~= "number" then
+ error("Bad argument @ 'messageBoxEx' [Expected number at argument 5, got " .. type(messageButtonDefault) .. "]")
+ elseif #messageButtons[messageButton] < messageButtonDefault then
+ error("Bad argument @ 'messageBoxEx' [Invalid default at argument 5, " .. messageButton .. " only have " .. tostring(#messageButtons[messageButon]) .. " buttons.]")
+ end
+ else
+ messageButtonDefault = 1
+ end
+
+ if messageSound then
+ if type(messageSound) ~= "string" then
+ error("Bad argument @ 'messageBoxEx' [Expected string at argument 6, got " .. type(messageSound) .. "]")
+ elseif not messageSounds[messageSound] then
+ error("Bad argument @ 'messageBoxEx' [Invalid type at argument 6, got '" .. messageSound .. "']")
+ end
+ else
+ messageSound = messageIcon
+ end
+
+ if messageSoundVolume then
+ if type(messageSoundVolume) ~= "number" then
+ error("Bad argument @ 'messageBoxEx' [Expected number at argument 7, got " .. type(messageSoundVolume) .. "]")
+ elseif messageSoundVolume > 1 or messageSoundVolume < 1 then
+ error("Bad argument @ 'messageBoxEx' [Invalid volume at argument 7, got '" .. tostring(messageSoundVolume) .. "']")
+ end
+ else
+ messageSoundVolume = 1
+ end
+
+ messageBeep(messageSound, messageSoundVolume)
+
+ local messageWindowWidth = 400
+ local messageWindowHeight = 200
+
+ local messageWindowPosX = (screenX - messageWindowWidth) / 2
+ local messageWindowPosY = (screenY - messageWindowHeight) / 2
+ local messageWindowElement = guiCreateWindow(messageWindowPosX, messageWindowPosY, messageWindowWidth, messageWindowHeight, messageTitle)
+
+ guiWindowSetSizable(messageWindowElement, false)
+
+ local messageIconWidth = 42
+ local messageIconHeight = 42
+
+ local messageIconPosX = (messageWindowWidth - messageIconWidth) / 8
+ local messageIconPosY = (messageWindowHeight - messageIconHeight) / 2
+
+ guiCreateStaticImage(messageIconPosX, messageIconPosY, messageIconWidth, messageIconHeight, messageIcons[messageIcon].iconPath, false, messageWindowElement)
+
+ local messageCaptionWidth = messageWindowWidth - (messageIconPosX + messageIconWidth + 10 + 5)
+ local messageCaptionHeight = 16
+
+ local messageContentWidth = messageWindowWidth - (messageIconPosX + messageIconWidth + 10 + 5)
+ local messageContentHeight = 18
+
+ local messageCaptionPosX = messageIconPosX + messageIconWidth + 10
+ local messageCaptionPosY = messageIconPosY + (messageIconHeight - messageCaptionHeight - messageContentHeight) / 2
+ local messageCaptionElement = guiCreateLabel(messageCaptionPosX, messageCaptionPosY, messageCaptionWidth, messageCaptionHeight, messageIcons[messageIcon].iconCaption, false, messageWindowElement)
+
+ guiSetFont(messageCaptionElement, "default-bold-small")
+
+ local messageContentPosX = messageIconPosX + messageIconWidth + 10
+ local messageContentPosY = messageIconPosY + (messageIconHeight - messageContentHeight) - 5
+ local messageContentElement = guiCreateLabel(messageContentPosX, messageContentPosY, messageContentWidth, messageContentHeight * 4 , messageContent, false, messageWindowElement)
+
+ guiLabelSetHorizontalAlign(messageContentElement, "left", true)
+
+ local messageButtonWidth = 50
+ local messageButtonHeight = 30
+
+ local messageButtonPosX = (messageWindowWidth - 5) - (messageButtonWidth + 5) * #messageButtons[messageButton]
+ local messageButtonPosY = (messageWindowHeight - 10) - messageButtonHeight
+ local messageButtonElements = {}
+
+ for i, v in ipairs(messageButtons[messageButton]) do
+ local messageButtonElement = guiCreateButton(messageButtonPosX, messageButtonPosY, messageButtonWidth, messageButtonHeight, v, false, messageWindowElement)
+
+ if i == messageButtonDefault then
+ guiSetFont(messageButtonElement, "default-bold-small")
+ end
+
+ addEventHandler("onClientGUIClick", messageButtonElement, messageClickEx, false)
+ messageButtonElements[i] = messageButtonElement
+ messageButtonPosX = messageButtonPosX + messageButtonWidth + 5
+ end
+
+ messageBoxWindows[messageWindowElement] = {messageTitle, messageContent, messageIcon, messageButton}
+
+ return messageButtonElements[1], messageButtonElements[2], messageButtonElements[3]
+end
\ No newline at end of file
diff --git a/[gameplay]/dialogs/sourceG.lua b/[gameplay]/dialogs/sourceG.lua
new file mode 100644
index 000000000..68332177d
--- /dev/null
+++ b/[gameplay]/dialogs/sourceG.lua
@@ -0,0 +1,77 @@
+messageButtons = {
+ ["ABORTRETRYIGNORE"] = {
+ [1] = "Abort",
+ [2] = "Retry",
+ [3] = "Ignore"
+ },
+ ["CANCELTRYCONTINUE"] = {
+ [1] = "Cancel",
+ [2] = "Try",
+ [3] = "Continue"
+ },
+ ["HELP"] = {
+ [1] = "Help"
+ },
+ ["OK"] = {
+ [1] = "OK"
+ },
+ ["OKCANCEL"] = {
+ [1] = "OK",
+ [2] = "Cancel"
+ },
+ ["RETRYCANCEL"] = {
+ [1] = "Retry",
+ [2] = "Cancel"
+ },
+ ["YESNO"] = {
+ [1] = "Yes",
+ [2] = "No"
+ },
+ ["YESNOCANCEL"] = {
+ [1] = "Yes",
+ [2] = "No",
+ [3] = "Cancel"
+ }
+}
+
+messageSounds = {
+ ["INFO"] = {
+ soundID = 20,
+ soundName = "Information",
+ },
+ ["QUESTION"] = {
+ soundID = 10,
+ soundName = "Question",
+ },
+ ["WARNING"] = {
+ soundID = 17,
+ soundName = "Warning",
+ },
+ ["ERROR"] = {
+ soundID = 4,
+ soundName = "Error",
+ },
+}
+
+messageIcons = {
+ ["INFO"] = {
+ iconCaption = "Information",
+ iconSound = "INFO",
+ iconPath = "files/info.png"
+ },
+ ["QUESTION"] = {
+ iconCaption = "Question",
+ iconSound = "QUESTION",
+ iconPath = "files/question.png"
+ },
+ ["WARNING"] = {
+ iconCaption = "Warning",
+ iconSound = "WARNING",
+ iconPath = "files/warning.png"
+ },
+ ["ERROR"] = {
+ iconCaption = "Error",
+ iconSound = "ERROR",
+ iconPath = "files/error.png"
+ }
+}
\ No newline at end of file
diff --git a/[gameplay]/webbrowser/WebBrowserGUI.lua b/[gameplay]/webbrowser/WebBrowserGUI.lua
index 6e82888a3..92e879f5b 100644
--- a/[gameplay]/webbrowser/WebBrowserGUI.lua
+++ b/[gameplay]/webbrowser/WebBrowserGUI.lua
@@ -107,7 +107,7 @@ end
function WebBrowserGUI:DevButton_Click(button, state)
if button == "left" and state == "up" then
if not getDevelopmentMode() then
- exports.msgbox:guiShowMessageBox("You have to enable the development using setDevelopmentMode", "error", "Development mode required", false)
+ exports.dialogs:messageBox("Development mode required", "You have to enable the development mode using setDevelopmentMode()", false, "ERROR", "OK")
return
end
diff --git a/[gameplay]/webbrowser/meta.xml b/[gameplay]/webbrowser/meta.xml
index a18dd2bc6..9909af87d 100644
--- a/[gameplay]/webbrowser/meta.xml
+++ b/[gameplay]/webbrowser/meta.xml
@@ -2,7 +2,7 @@
true
-
+