Skip to content

Commit c140520

Browse files
authored
editor: fixes, random rotation func, getCurrentMapName func, updated scale func (#633)
* Added function getCurrentMapName() * Fix: Issue #603 * Fix: Issue #589 * Update scale functionality; remove deprecated functions setPedRotation/getPedRotation * Only one value should be returned for scale * Add advanced options for element scaling and random rotation functionality * Add check for loadedMap in passNewMapSettings function * Implement stripHexCode function and update output messages to remove hex codes from player names * Fix search being case sensitive * Fix search to handle special characters in resource names * Fix refreshGamemodeSettings to correctly handle new and existing settings * Quicktest F5 -> get last added gamemode * Fix: create missing entries; validate entries -> remove if invalid * Fix: #637 initalize currentMapSettings.addedGamemodes = {} outside setupMapSettings() * Fix: Update quickTest() to only update lastTestGamemode when GridList changes * Add support for scaling markers up/down via keybind as well * Fix: g_minZ = minZ -> g_minZ = minZ or 0 to fix vehicle element creation * Remove redundant code * Fix: Cloning -> Only set rotation when random rot is enabled * Revert check for creationParameters.position This just causes other issues and places elements at 0, 0, 0. It was intended to fix some bug related to peds, markers and edf elements porting back and forth between camera, and cursor position. * Reintroduce if check for creationParameters.position Main problem was the if check before with (~= string) which caused the fix to fail
1 parent d89bacc commit c140520

22 files changed

+355
-139
lines changed

[admin]/admin/conf/messages.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,10 @@
249249
<all>Chatbox cleared$by_admin_4all.</all>
250250
<log>ADMIN: $admin has cleared the chatbox.</log>
251251
</group>
252+
<group action="setfpslimit" r="225" g="170" b="90">
253+
<all>FPS limit set to '$data'$by_admin_4all.</all>
254+
<log>ADMIN: $admin has set FPS limit to '$data'</log>
255+
</group>
252256
</server>
253257
<bans>
254258

[admin]/admin/server/admin_server.lua

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -608,9 +608,9 @@ function aAction ( type, action, admin, player, data, more )
608608

609609
if ( node ) then
610610
local r, g, b = node["r"], node["g"], node["b"]
611-
if ( node["all"] ) then outputChatBox ( aStripString ( node["all"] ), root, r, g, b ) end
612-
if ( node["admin"] ) and ( admin ~= player ) then outputChatBox ( aStripString ( node["admin"] ), admin, r, g, b ) end
613-
if ( node["player"] ) then outputChatBox ( aStripString ( node["player"] ), player, r, g, b ) end
611+
if ( node["all"] ) then outputChatBox ( aStripString ( node["all"] ), root, r, g, b, true ) end
612+
if ( node["admin"] ) and ( admin ~= player ) then outputChatBox ( aStripString ( node["admin"] ), admin, r, g, b, true ) end
613+
if ( node["player"] ) then outputChatBox ( aStripString ( node["player"] ), player, r, g, b, true ) end
614614
if ( node["log"] ) then outputServerLog ( aStripString ( node["log"] ) ) end
615615
end
616616
end

[editor]/edf/edf.lua

Lines changed: 48 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -884,23 +884,29 @@ end
884884

885885
--Returns an element's scale, or its scale element data, or false
886886
function edfGetElementScale(element)
887-
local etype = getElementType(element)
888-
if etype == "object" then
889-
scale = getObjectScale(element)
890-
else
891-
local handle = edfGetHandle(element)
892-
if handle then
893-
scale = getObjectScale(handle)
894-
else
895-
scale = tonumber(getElementData(element,"scale"))
896-
end
897-
end
898-
899-
if scale then
900-
return scale
901-
else
902-
return false
903-
end
887+
local etype = getElementType(element)
888+
if etype == "object" then
889+
scale = getObjectScale(element)
890+
if type(scale) ~= "table" then
891+
scale = select(1, scale) or 1
892+
end
893+
else
894+
local handle = edfGetHandle(element)
895+
if handle then
896+
scale = getObjectScale(handle)
897+
if type(scale) == "table" then
898+
scale = select(1, scale) or 1
899+
end
900+
else
901+
scale = tonumber(getElementData(element,"scale"))
902+
end
903+
end
904+
905+
if scale then
906+
return scale
907+
else
908+
return false
909+
end
904910
end
905911

906912
--Sets an element's position, or its posX/Y/Z element data
@@ -965,28 +971,31 @@ end
965971

966972
--Sets an element's scale, or its scale element data
967973
function edfSetElementScale(element, scale)
968-
local ancestor = edfGetAncestor(element) or element
969-
setElementData(ancestor, "scale", scale)
970-
local etype = getElementType(element)
971-
if etype == "object" then
972-
if setObjectScale(element, scale) then
973-
triggerEvent ( "onElementPropertyChanged", ancestor, "scale" )
974-
return true
975-
end
976-
else
977-
local handle = edfGetHandle(element)
978-
if handle then
979-
if setObjectScale(handle, scale) then
980-
triggerEvent ( "onElementPropertyChanged", ancestor, "scale" )
981-
return true
982-
end
983-
else
984-
setElementData(element, "scale", scale or 1)
985-
triggerEvent ( "onElementPropertyChanged", ancestor, "scale" )
986-
return true
987-
end
988-
end
989-
return false
974+
local ancestor = edfGetAncestor(element) or element
975+
setElementData(ancestor, "scale", scale)
976+
local etype = getElementType(element)
977+
if type(scale) == "table" then
978+
scale = scale[1]
979+
end
980+
if etype == "object" then
981+
if setObjectScale(element, scale) then
982+
triggerEvent ( "onElementPropertyChanged", ancestor, "scale" )
983+
return true
984+
end
985+
else
986+
local handle = edfGetHandle(element)
987+
if handle then
988+
if setObjectScale(handle, scale) then
989+
triggerEvent ( "onElementPropertyChanged", ancestor, "scale" )
990+
return true
991+
end
992+
else
993+
setElementData(element, "scale", scale or 1)
994+
triggerEvent ( "onElementPropertyChanged", ancestor, "scale" )
995+
return true
996+
end
997+
end
998+
return false
990999
end
9911000

9921001
function edfGetElementInterior(element)

[editor]/edf/edf_client.lua

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,9 @@ end
189189
--Sets an element's scale, or its scale element data
190190
function edfSetElementScale(element, scale)
191191
if scale then
192+
if type(scale) == "table" then
193+
scale = scale[1]
194+
end
192195
if isBasic[getElementType(element)] then
193196
return setElementData(element, "scale", scale)
194197
else

[editor]/editor_gui/client/elementproperties.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,7 @@ local function addPropertyControl( controlType, controlLabelName, controlDescrip
448448
if selectedElement then
449449
if newControl:getLabel() == "model" and (elementType == "object" or elementType == "vehicle") then
450450
local minX, minY, minZ = getElementBoundingBox(selectedElement)
451-
g_minZ = minZ
451+
g_minZ = minZ or 0
452452
local handlerFunction = function ()
453453
local minX2, minY2, minZ2 = getElementBoundingBox(selectedElement)
454454
if minX2 and minY2 and minZ2 then

[editor]/editor_gui/client/load.lua

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,9 @@ function openSearch()
7575
guiGridListSetItemText ( loadDialog.mapsList, row, 3, res["version"], false, false )
7676
end
7777
else
78+
local escapedText = string.gsub(string.lower(text), "([%-%.%+%*%?%[%]%^%$%(%)%%])", "%%%1")
7879
for i,res in ipairs(openResources) do
79-
if string.find(res["friendlyName"],text) then
80+
if string.find(res["friendlyName"], escapedText) then
8081
local row = guiGridListAddRow ( loadDialog.mapsList )
8182
guiGridListSetItemText ( loadDialog.mapsList, row, 1, res["friendlyName"], false, false )
8283
guiGridListSetItemText ( loadDialog.mapsList, row, 2, res["gamemodes"], false, false )

[editor]/editor_gui/client/mapsettings_gamemodesettings.lua

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,10 @@ function refreshGamemodeSettings()
4545
mapsettings.rowValues[subRow] = dataInfo.default
4646
if currentMapSettings.newSettings and currentMapSettings.newSettings[dataName] then
4747
mapsettings.rowValues[subRow] = currentMapSettings.newSettings[dataName]
48-
mapsettings.gamemodeSettings = copyTable ( mapsettings.rowValues )
48+
end
49+
50+
if currentMapSettings.gamemodeSettings and currentMapSettings.gamemodeSettings[subRow] then
51+
mapsettings.rowValues[subRow] = currentMapSettings.gamemodeSettings[subRow]
4952
end
5053
end
5154
if count == 0 then
@@ -58,7 +61,7 @@ function refreshGamemodeSettings()
5861
local row = guiGridListAddRow ( mapsettings.settingsList )
5962
guiGridListSetItemText ( mapsettings.settingsList, row, 1, "No Settings definitions", true, false )
6063
end
61-
currentMapSettings.newSettings = nil
64+
mapsettings.gamemodeSettings = copyTable ( mapsettings.rowValues )
6265
end
6366

6467
local requiredText = { [true]="REQUIRED" }

[editor]/editor_gui/client/options_action.lua

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,14 @@ function optionsActions.elemScalingSnap(value)
3535
optionsData.elemScalingSnap = tonumber(value)
3636
end
3737

38+
function optionsActions.randomizeRotation(value)
39+
optionsData.randomizeRotation = value
40+
end
41+
42+
function optionsActions.randomizeRotationAxis(value)
43+
optionsData.randomizeRotationAxis = value
44+
end
45+
3846
function optionsActions.enableColPatch(value)
3947
local success, isLoaded = editor_main.toggleColPatch(value)
4048
if success then
@@ -170,7 +178,7 @@ function setEditorMoveSpeeds()
170178
move_cursor.setRotateSpeeds ( dialog.slowElemRotate:getValue(), dialog.normalElemRotate:getValue(), dialog.fastElemRotate:getValue() )
171179
move_freecam.setRotateSpeeds ( dialog.slowElemRotate:getValue(), dialog.normalElemRotate:getValue(), dialog.fastElemRotate:getValue() )
172180

173-
move_keyboard.setScaleIncrement ( dialog.elemScaling:getValue() )
181+
move_keyboard.setScalingSpeeds ( dialog.slowElemScale:getValue(), dialog.normalElemScale:getValue(), dialog.fastElemScale:getValue() )
174182

175183
move_keyboard.toggleAxesLock ( dialog.lockToAxes:getValue() )
176184
end

0 commit comments

Comments
 (0)