refactor(resource/zoneCreator): last zone and axis mode tweaks

- don't cancel command if last zone is invalid for selected zone type
- change movement mode key to C to be with most of the other controls
- display current axis mode
- display camera-aligned axes in addition to grid axes for display mode 3 & 4
This commit is contained in:
DokaDoka
2023-01-07 17:45:25 +11:00
parent 4794af7ae0
commit 0284e646a7

View File

@@ -27,6 +27,7 @@ local function updateText()
if zoneType == 'poly' then if zoneType == 'poly' then
text[#text + 1] = ('Height [Shift + Scroll]: %s \n'):format(height) text[#text + 1] = ('Height [Shift + Scroll]: %s \n'):format(height)
text[#text + 1] = ('Cycle display mode [G]: %s \n'):format(firstToUpper(displayModes[displayMode])) text[#text + 1] = ('Cycle display mode [G]: %s \n'):format(firstToUpper(displayModes[displayMode]))
text[#text + 1] = ('Toggle Axis mode [C]: %s \n'):format(alignMovementWithCamera and 'Camera' or 'Grid')
text[#text + 1] = 'Create new point - [Space] \n' text[#text + 1] = 'Create new point - [Space] \n'
elseif zoneType == 'box' then elseif zoneType == 'box' then
text[#text + 1] = ('Heading [Q/E]: %s° \n'):format(heading) text[#text + 1] = ('Heading [Q/E]: %s° \n'):format(heading)
@@ -34,14 +35,15 @@ local function updateText()
text[#text + 1] = ('Width [Ctrl + Scroll]: %s \n'):format(width) text[#text + 1] = ('Width [Ctrl + Scroll]: %s \n'):format(width)
text[#text + 1] = ('Length [Alt + Scroll]: %s \n'):format(length) text[#text + 1] = ('Length [Alt + Scroll]: %s \n'):format(length)
text[#text + 1] = ('Cycle display mode [G]: %s \n'):format(firstToUpper(displayModes[displayMode])) text[#text + 1] = ('Cycle display mode [G]: %s \n'):format(firstToUpper(displayModes[displayMode]))
text[#text + 1] = ('Toggle Axis mode [C]: %s \n'):format(alignMovementWithCamera and 'Camera' or 'Grid')
text[#text + 1] = 'Recenter - [Space] \n' text[#text + 1] = 'Recenter - [Space] \n'
elseif zoneType == 'sphere' then elseif zoneType == 'sphere' then
text[#text + 1] = ('Size [Shift + Scroll]: %s \n'):format(height) text[#text + 1] = ('Size [Shift + Scroll]: %s \n'):format(height)
text[#text + 1] = ('Toggle Axis mode [C]: %s \n'):format(alignMovementWithCamera and 'Camera' or 'Grid')
text[#text + 1] = 'Recenter - [Space] \n' text[#text + 1] = 'Recenter - [Space] \n'
end end
text[#text + 1] = 'Toggle controls - [X] \n' text[#text + 1] = 'Toggle controls - [X] \n'
text[#text + 1] = 'Toggle movement mode - [M] \n'
text[#text + 1] = 'Save - [Enter] \n' text[#text + 1] = 'Save - [Enter] \n'
text[#text + 1] = 'Cancel - [Esc]' text[#text + 1] = 'Cancel - [Esc]'
@@ -192,13 +194,15 @@ local function startCreator(arg, useLast)
controlsActive = not controlsActive controlsActive = not controlsActive
end end
if IsDisabledControlJustReleased(0, 301) then -- m
if creatorActive then
alignMovementWithCamera = not alignMovementWithCamera
end
end
if displayMode == 3 or displayMode == 4 then if displayMode == 3 or displayMode == 4 then
if alignMovementWithCamera then
local rightX, rightY = getRelativePos(vec2(xCoord, yCoord), vec2(xCoord + 2, yCoord), GetGameplayCamRot(2).z)
local forwardX, forwardY = getRelativePos(vec2(xCoord, yCoord), vec2(xCoord, yCoord + 2), GetGameplayCamRot(2).z)
DrawLine(xCoord, yCoord, zCoord, rightX, rightY, zCoord, 0, 255, 0, 225)
DrawLine(xCoord, yCoord, zCoord, forwardX, forwardY, zCoord, 0, 255, 0, 225)
end
DrawLine(xCoord, yCoord, zCoord, xCoord + 2, yCoord, zCoord, 0, 0, 255, 225) DrawLine(xCoord, yCoord, zCoord, xCoord + 2, yCoord, zCoord, 0, 0, 255, 225)
DrawLine(xCoord, yCoord, zCoord, xCoord, yCoord + 2, zCoord, 0, 0, 255, 225) DrawLine(xCoord, yCoord, zCoord, xCoord, yCoord + 2, zCoord, 0, 0, 255, 225)
DrawLine(xCoord, yCoord, zCoord, xCoord, yCoord, zCoord + 2, 0, 0, 255, 225) DrawLine(xCoord, yCoord, zCoord, xCoord, yCoord, zCoord + 2, 0, 0, 255, 225)
@@ -417,6 +421,9 @@ local function startCreator(arg, useLast)
else else
displayMode += 1 displayMode += 1
end end
elseif IsDisabledControlJustReleased(0, 26) then -- c
change = true
alignMovementWithCamera = not alignMovementWithCamera
elseif IsDisabledControlJustReleased(0, 22) then -- space elseif IsDisabledControlJustReleased(0, 22) then -- space
change = true change = true
@@ -455,13 +462,12 @@ RegisterCommand('zone', function(source, args, rawCommand)
local useLast = args[2] and not useLastZoneFalsyInputs[args[2]] local useLast = args[2] and not useLastZoneFalsyInputs[args[2]]
if useLast then if useLast then
if not lastZone[args[1]] then
lib.notify({title = 'No last zone to duplicate', type = 'error'})
return
end
if args[1] == 'poly' then if args[1] == 'poly' then
lib.notify({title = 'Cannot duplicate a poly zone', type = 'error'}) lib.notify({title = 'Cannot duplicate a poly zone', type = 'error'})
return useLast = false
elseif not lastZone[args[1]] then
lib.notify({title = ('No previous %s zone to duplicate'):format(args[1]), type = 'error'})
useLast = false
end end
end end