Add ClothingActions
This commit is contained in:
@@ -0,0 +1,76 @@
|
||||
------------------------------------------
|
||||
-- Clothing Actions
|
||||
------------------------------------------
|
||||
|
||||
CARMconfig = {
|
||||
filter = false,
|
||||
delay = false
|
||||
}
|
||||
|
||||
local function ClothingActions()
|
||||
|
||||
local CARMbindings = {
|
||||
{
|
||||
name = '[ClothingActionsRM]'
|
||||
},
|
||||
{
|
||||
name = 'CARM',
|
||||
key = Keyboard.KEY_Z
|
||||
}
|
||||
}
|
||||
|
||||
for _, bind in ipairs(CARMbindings) do
|
||||
if (bind.key or not bind.action) then
|
||||
table.insert(keyBinding, { value = bind.name, key = bind.key })
|
||||
end
|
||||
end
|
||||
|
||||
if ModKey then
|
||||
local CARMMODbindings = {
|
||||
name = 'CARMMK',
|
||||
key = 0
|
||||
}
|
||||
ModKey:AddBinding(CARMMODbindings)
|
||||
end
|
||||
|
||||
if ModOptions and ModOptions.getInstance then
|
||||
local function apply(data)
|
||||
local player = getSpecificPlayer(0)
|
||||
local values = data.settings.options
|
||||
|
||||
CARMconfig.filter = values.filter
|
||||
CARMconfig.delay = values.delay
|
||||
end
|
||||
|
||||
local CARMCONFIG = {
|
||||
options_data = {
|
||||
filter = {
|
||||
default = false,
|
||||
name = getText("UI_ModOptions_CARMfilter"),
|
||||
OnApplyMainMenu = apply,
|
||||
OnApplyInGame = apply
|
||||
},
|
||||
delay = {
|
||||
default = false,
|
||||
name = getText("UI_ModOptions_CARMdelay"),
|
||||
OnApplyMainMenu = apply,
|
||||
OnApplyInGame = apply
|
||||
}
|
||||
},
|
||||
mod_id = "ClothingActionsRadialMenu",
|
||||
mod_shortname = "CARM",
|
||||
mod_fullname = getText("UI_optionscreen_binding_ClothingActionsRM")
|
||||
}
|
||||
|
||||
local optionsInstance = ModOptions:getInstance(CARMCONFIG)
|
||||
ModOptions:loadFile()
|
||||
|
||||
Events.OnGameStart.Add(function()
|
||||
apply({settings = CARMCONFIG})
|
||||
end)
|
||||
end
|
||||
|
||||
print(getText("UI_Init_ClothingActionsRM"))
|
||||
end
|
||||
|
||||
ClothingActions()
|
||||
@@ -0,0 +1,189 @@
|
||||
------------------------------------------
|
||||
-- Clothing Actions Radial Menu
|
||||
------------------------------------------
|
||||
|
||||
CARadialMenu = ISBaseObject:derive("CARadialMenu")
|
||||
|
||||
------------------------------------------
|
||||
local CACommand = ISBaseObject:derive("CACommand")
|
||||
|
||||
function CACommand:new(menu, item, text, itype, action)
|
||||
local o = ISBaseObject.new(self)
|
||||
o.menu = menu
|
||||
o.player = menu.player
|
||||
|
||||
o.item = item
|
||||
o.text = text
|
||||
o.itype = itype
|
||||
o.action = action
|
||||
|
||||
return o
|
||||
end
|
||||
|
||||
function CACommand:fillMenu(menu)
|
||||
menu:addSlice(self.text, self.item:getTexture(), self.invoke, self)
|
||||
end
|
||||
|
||||
function CACommand:invoke()
|
||||
ISTimedActionQueue.add(ISClothingExtraAction:new(self.player, self.item, self.itype))
|
||||
end
|
||||
|
||||
------------------------------------------
|
||||
|
||||
function CARadialMenu:center()
|
||||
local menu = getPlayerRadialMenu(self.playerNum)
|
||||
|
||||
local x = getPlayerScreenLeft(self.playerNum)
|
||||
local y = getPlayerScreenTop(self.playerNum)
|
||||
local w = getPlayerScreenWidth(self.playerNum)
|
||||
local h = getPlayerScreenHeight(self.playerNum)
|
||||
|
||||
x = x + w / 2
|
||||
y = y + h / 2
|
||||
|
||||
menu:setX(x - menu:getWidth() / 2)
|
||||
menu:setY(y - menu:getHeight() / 2)
|
||||
end
|
||||
|
||||
local function checkClothes(item)
|
||||
-- If there's extra options
|
||||
if item and item:getClothingItemExtraOption() then
|
||||
-- Check if we have the filter enabled or clothes, and, item is not watch or filter
|
||||
if (instanceof(item, "Clothing") or CARMconfig.filter) and (not instanceof(item, "AlarmClockClothing") or CARMconfig.filter) then
|
||||
return true
|
||||
end
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
function CARadialMenu:fillMenu()
|
||||
local menu = getPlayerRadialMenu(self.playerNum)
|
||||
menu:clear()
|
||||
|
||||
local commands = {}
|
||||
local clothes = self.player:getWornItems()
|
||||
for i=0, clothes:size() - 1 do
|
||||
local item = clothes:get(i):getItem()
|
||||
if checkClothes(item) then
|
||||
for i=0,item:getClothingItemExtraOption():size()-1 do
|
||||
local action = item:getClothingItemExtraOption():get(i)
|
||||
local itemType = moduleDotType(item:getModule(), item:getClothingItemExtra():get(i))
|
||||
table.insert(commands, CACommand:new(self, item, getText("ContextMenu_" .. action), itemType, action))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
for _,command in ipairs(commands) do
|
||||
local count = #menu.slices
|
||||
command:fillMenu(menu)
|
||||
if count == #menu.slices then
|
||||
menu:addSlice(nil, nil, nil)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function CARadialMenu:display()
|
||||
local menu = getPlayerRadialMenu(self.playerNum)
|
||||
self:center()
|
||||
menu:addToUIManager()
|
||||
if JoypadState.players[self.playerNum+1] then
|
||||
menu:setHideWhenButtonReleased(Joypad.RBumper)
|
||||
setJoypadFocus(self.playerNum, menu)
|
||||
self.player:setJoypadIgnoreAimUntilCentered(true)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
function CARadialMenu:new(player)
|
||||
local o = ISBaseObject.new(self)
|
||||
o.player = player
|
||||
o.playerNum = player:getPlayerNum()
|
||||
return o
|
||||
end
|
||||
|
||||
local ticks = 0
|
||||
local wasVisible = false
|
||||
|
||||
function CARadialMenu.checkKey(key)
|
||||
if key ~= getCore():getKey("CARM") then
|
||||
return false
|
||||
end
|
||||
|
||||
if UIManager.getSpeedControls() and (UIManager.getSpeedControls():getCurrentGameSpeed() == 0) then
|
||||
return false
|
||||
end
|
||||
|
||||
local player = getSpecificPlayer(0)
|
||||
if not player or player:isDead() then
|
||||
return false
|
||||
end
|
||||
|
||||
if player:isSeatedInVehicle() then
|
||||
return false
|
||||
end
|
||||
|
||||
local queue = ISTimedActionQueue.queues[player]
|
||||
if queue and #queue.queue > 0 then
|
||||
return false
|
||||
end
|
||||
if getCell():getDrag(0) then
|
||||
return false
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
function CARadialMenu.onKeyPress(key)
|
||||
if not CARadialMenu.checkKey(key) then
|
||||
return
|
||||
end
|
||||
local radialMenu = getPlayerRadialMenu(0)
|
||||
if radialMenu:isReallyVisible() and getCore():getOptionRadialMenuKeyToggle() then
|
||||
wasVisible = true
|
||||
radialMenu:removeFromUIManager()
|
||||
return
|
||||
end
|
||||
ticks = getTimestampMs()
|
||||
wasVisible = false
|
||||
end
|
||||
|
||||
function CARadialMenu.onKeyHold(key)
|
||||
if not CARadialMenu.checkKey(key) then
|
||||
return
|
||||
end
|
||||
if wasVisible then
|
||||
return
|
||||
end
|
||||
|
||||
local radialMenu = getPlayerRadialMenu(0)
|
||||
local delay = 500
|
||||
if CARMconfig.delay then
|
||||
delay = 0
|
||||
end
|
||||
if (getTimestampMs() - ticks >= delay) and not radialMenu:isReallyVisible() then
|
||||
local menu = CARadialMenu:new(getSpecificPlayer(0))
|
||||
menu:fillMenu()
|
||||
menu:display()
|
||||
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.OnKeyStartPressed.Add(CARadialMenu.onKeyPress)
|
||||
Events.OnKeyKeepPressed.Add(CARadialMenu.onKeyHold)
|
||||
Events.OnKeyPressed.Add(CARadialMenu.onKeyRelease)
|
||||
end)
|
||||
@@ -0,0 +1,16 @@
|
||||
------------------------------------------
|
||||
-- Clothing Actions Clothing Extra Action override
|
||||
------------------------------------------
|
||||
|
||||
-- I just want to change a few of the init things
|
||||
local _ISClothingExtraAction_new = ISClothingExtraAction.new
|
||||
function ISClothingExtraAction:new(...)
|
||||
local o = _ISClothingExtraAction_new(self, ...)
|
||||
o.stopOnWalk = false
|
||||
o.maxTime = 25
|
||||
o.useProgressBar = false
|
||||
if o.character:isTimedActionInstant() then
|
||||
o.maxTime = 1
|
||||
end
|
||||
return o
|
||||
end
|
||||
@@ -0,0 +1,8 @@
|
||||
UI_EN = {
|
||||
UI_Init_ClothingActionsRM = "Hello from Clothing Actions - Radial Menu!",
|
||||
UI_optionscreen_binding_ClothingActionsRM = "Clothing Actions - Radial Menu",
|
||||
UI_optionscreen_binding_CARM = "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_CARMdelay = "Show Radial Menu Immediately on Press"
|
||||
}
|
||||
10
ClothingActions/Contents/mods/ClothingActions/mod.info
Normal file
10
ClothingActions/Contents/mods/ClothingActions/mod.info
Normal file
@@ -0,0 +1,10 @@
|
||||
name=Clothing Actions - Radial Menu
|
||||
id=ClothingActionsRM
|
||||
authors=dhert
|
||||
|
||||
description=A Radial Menu for quick access to equipped clothing actions
|
||||
|
||||
pzversion=41
|
||||
tags=Immersion;Realistic
|
||||
|
||||
poster=poster.png
|
||||
BIN
ClothingActions/Contents/mods/ClothingActions/poster.png
Normal file
BIN
ClothingActions/Contents/mods/ClothingActions/poster.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 717 KiB |
Reference in New Issue
Block a user