Update ClothingActionsv2

This commit is contained in:
davidh
2022-04-02 04:05:38 -05:00
parent 917d3a88a6
commit af774cf5ae
3 changed files with 47 additions and 23 deletions

View File

@@ -3,6 +3,7 @@
------------------------------------------ ------------------------------------------
CARadialMenu = ISBaseObject:derive("CARadialMenu") CARadialMenu = ISBaseObject:derive("CARadialMenu")
activeMenu = nil
------------------------------------------ ------------------------------------------
local CACommand = ISBaseObject:derive("CACommand") local CACommand = ISBaseObject:derive("CACommand")
@@ -87,13 +88,12 @@ function CARadialMenu:display()
self:center() self:center()
menu:addToUIManager() menu:addToUIManager()
if JoypadState.players[self.playerNum+1] then if JoypadState.players[self.playerNum+1] then
menu:setHideWhenButtonReleased(Joypad.RBumper) menu:setHideWhenButtonReleased(Joypad.DPadUp)
setJoypadFocus(self.playerNum, menu) setJoypadFocus(self.playerNum, menu)
self.player:setJoypadIgnoreAimUntilCentered(true) self.player:setJoypadIgnoreAimUntilCentered(true)
end end
end end
function CARadialMenu:new(player) function CARadialMenu:new(player)
local o = ISBaseObject.new(self) local o = ISBaseObject.new(self)
o.player = player o.player = player
@@ -132,6 +132,39 @@ function CARadialMenu.checkKey(key)
return true return true
end end
------------------------------------------
--- For the DPad
function CARadialMenu.showRadialMenu(player)
if UIManager.getSpeedControls() and (UIManager.getSpeedControls():getCurrentGameSpeed() == 0) then
return
end
if not player or player:isDead() then
return
end
local queue = ISTimedActionQueue.queues[player]
if queue and #queue.queue > 0 then
return false
end
local menu = CARadialMenu:new(player)
menu:fillMenu()
menu:display()
activeMenu = menu
end
---- Show the Radial Menu on the Up DPad when there's not a car around
local _ISDPadWheels_onDisplayUp = ISDPadWheels.onDisplayUp
function ISDPadWheels.onDisplayUp(joypadData)
local player = getSpecificPlayer(joypadData.player)
if not player:getVehicle() and not ISVehicleMenu.getVehicleToInteractWith(player) then
CARadialMenu.showRadialMenu(player)
else
_ISDPadWheels_onDisplayUp(joypadData)
end
end
------------------------------------------
function CARadialMenu.onKeyPress(key) function CARadialMenu.onKeyPress(key)
if not CARadialMenu.checkKey(key) then if not CARadialMenu.checkKey(key) then
return return
@@ -140,6 +173,8 @@ function CARadialMenu.onKeyPress(key)
if radialMenu:isReallyVisible() and getCore():getOptionRadialMenuKeyToggle() then if radialMenu:isReallyVisible() and getCore():getOptionRadialMenuKeyToggle() then
wasVisible = true wasVisible = true
radialMenu:removeFromUIManager() radialMenu:removeFromUIManager()
setJoypadFocus(activeMenu.playerNum, nil)
activeMenu = nil
return return
end end
ticks = getTimestampMs() ticks = getTimestampMs()
@@ -163,27 +198,12 @@ function CARadialMenu.onKeyHold(key)
local menu = CARadialMenu:new(getSpecificPlayer(0)) local menu = CARadialMenu:new(getSpecificPlayer(0))
menu:fillMenu() menu:fillMenu()
menu:display() menu:display()
activeMenu = menu
end end
end end
function CARadialMenu.onKeyRelease(key)
if not CARadialMenu.checkKey(key) then
return
end
local radialMenu = getPlayerRadialMenu(0)
if (radialMenu:isReallyVisible() or wasVisible) then
if not getCore():getOptionRadialMenuKeyToggle() then
radialMenu:removeFromUIManager()
end
return
end
end
Events.OnGameStart.Add(function() Events.OnGameStart.Add(function()
Events.OnKeyStartPressed.Add(CARadialMenu.onKeyPress) Events.OnKeyStartPressed.Add(CARadialMenu.onKeyPress)
Events.OnKeyKeepPressed.Add(CARadialMenu.onKeyHold) Events.OnKeyKeepPressed.Add(CARadialMenu.onKeyHold)
Events.OnKeyPressed.Add(CARadialMenu.onKeyRelease)
end) end)

View File

@@ -4,5 +4,5 @@ UI_EN = {
UI_optionscreen_binding_CARM = "Show Clothing Actions Radial Menu", UI_optionscreen_binding_CARM = "Show Clothing Actions Radial Menu",
UI_optionscreen_binding_CARMMK = "Show Clothing Actions Radial Menu", UI_optionscreen_binding_CARMMK = "Show Clothing Actions Radial Menu",
UI_ModOptions_CARMfilter = "Disable Clothing Filter (Shows bags, watches, etc)", UI_ModOptions_CARMfilter = "Disable Clothing Filter (Shows bags, watches, etc)",
UI_ModOptions_CARMdelay = "Show Radial Menu Immediately on Press" UI_ModOptions_CARMdelay = "Show Radial Menu Immediately on Key Press"
} }

View File

@@ -16,8 +16,11 @@ description=[url=https://steamcommunity.com/sharedfiles/filedetails/?id=26842855
description= description=
description=Should work with any other mods that add ExtraClothingOptions to item definitions too. description=Should work with any other mods that add ExtraClothingOptions to item definitions too.
description= description=
description=I'm not sure if this will work with controllers as this is not how I play Project Zomboid. Also, not sure if this will work for other local players (shared screen co-op) description=UPDATE 04/02/2022: Added support for controllers
description=This RadialMenu is now bound to the UP-DPad; this cannot be changed. Select what you want with the right thumbstick and release to perform the action.
description=Don't worry, when the player is near a car the Vehicle Menu will appear as expected.
description= description=
description=This mod is now compatible with local co-op as well.
description=[h2]Configuration[/h2] description=[h2]Configuration[/h2]
description= description=
description=Default keybind is to the "Z" key. Configurable in the "Keybinds" menu. description=Default keybind is to the "Z" key. Configurable in the "Keybinds" menu.
@@ -38,12 +41,13 @@ description=[/tr]
description=[tr] description=[tr]
description=[td]Show Radial Menu Immediately on Press[/td] description=[td]Show Radial Menu Immediately on Press[/td]
description=[td]Disabled[/td] description=[td]Disabled[/td]
description=[td]Shows Radial Menu when key is pressed. By default, a press and hold is required[/td] description=[td]Shows Radial Menu when key is pressed. By default, a press and hold is required.[/td]
description=[/tr] description=[/tr]
description=[/table] description=[/table]
description= description=
description=[h2]Translations[/h2] description=[h2]Translations[/h2]
description= description=
description=This mod is currently only in English. If you would like to contribute a translation, please submit a pull request on [url=https://github.com/hlfstr/pz-mods]GitHub![/url] I will happily give credit! description=This mod is currently only in English, but Actions in the Radial Menu will be translated (modded actions must include their own translations).
description=If you would like to contribute a translation, please submit a pull request on [url=https://github.com/hlfstr/pz-mods]GitHub![/url] I will happily give credit!
tags=Build 41;Interface;Realistic tags=Build 41;Interface;Realistic
visibility=friendsOnly visibility=public