Update CARM SUI-Inv and add SUI-Rads

This commit is contained in:
davidh
2022-05-11 03:16:11 -05:00
parent d742e5fad1
commit d9f4c8bd13
48 changed files with 5225 additions and 95 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 480 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 782 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

View File

@@ -0,0 +1,596 @@
------------------------------------------
-- SpiffUI Main Library
------------------------------------------
-- Authors:
---- @dhert (2022)
------------------------------------------
-- Permission is hereby granted, free of charge, to any person obtaining a copy
-- of this software and associated documentation files (the "Software"), to deal
-- in the Software without restriction, including without limitation the rights
-- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-- copies of the Software, and to permit persons to whom the Software is
-- furnished to do so, subject to the following conditions:
-- The above copyright notice and this permission notice shall be included in all
-- copies or substantial portions of the Software.
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-- SOFTWARE.
------------------------------------------
------------------------------------------
-- Set the SpiffUI lib version
local SPIFFUI_VERSION = 2 --<<< DO NOT CHANGE UNLESS YOU KNOW WHAT YOU'RE DOING
if SpiffUI then
if SpiffUI.Version >= SPIFFUI_VERSION then
return -- Don't do anything else
else
-- We only want the newest version, and this is it
Events.OnGameBoot.Remove(SpiffUI.firstBoot)
SpiffUI = nil
end
end
------------------------------------------
-- Start SpiffUI
SpiffUI = {}
SpiffUI.Version = SPIFFUI_VERSION
------------------------------------------
-- Register Module
function SpiffUI:Register(name)
if not SpiffUI[name] then
-- Add Key for our module
table.insert(SpiffUI, name)
-- Add module
SpiffUI[name] = {}
end
return SpiffUI[name]
end
------------------------------------------
-- Overrides for already-defined keys
SpiffUI.KeyDefaults = {}
-- Add a new Key Default
function SpiffUI:AddKeyDefault(name, key)
SpiffUI.KeyDefaults[name] = tonumber(key)
end
-- Add an array of keys
---- Expected:
---- binds {
---- ["Name"] = key,
---- }
function SpiffUI:AddKeyDefaults(binds)
for i,j in pairs(binds) do
self:AddKeyDefault(i,j)
end
end
------------------------------------------
-- Keys that will be removed from the binds
SpiffUI.KeyDisables = {}
-- Add a new Key Disable
function SpiffUI:AddKeyDisable(name)
-- We do it where the name is the index to avoid dupes
SpiffUI.KeyDisables[name] = true
end
-- Add an array of keys
---- Expected:
---- binds {
---- ["Name"] = true,
---- }
function SpiffUI:AddKeyDisables(binds)
for i,_ in pairs(binds) do
self:AddKeyDisable(i)
end
end
------------------------------------------
-- New Keys to Add
SpiffUI.KeyBinds = {
{
name = '[SpiffUI]', -- Title
}
}
-- Add a new Key Bind
---- Expected:
---- bind = {
---- name = 'KeyBind', -- Name of Key
---- key = Keyboard.KEY, -- Key
---- qBlock = true, -- Don't perform key action with queue
---- Down = actionDown, -- Action on Down -- Receives playerObj -- Optional
---- Hold = actionHold, -- Action on Hold -- Receives playerObj -- Optional
---- Up = actionUp -- Action on Up -- Receives playerObj -- Optional
---- }
function SpiffUI:AddKeyBind(bind)
--SpiffUI.KeyDefaults[name] = tonumber(key)
table.insert(SpiffUI.KeyBinds, bind)
end
-- Add an array of keys
---- Expected:
---- binds = {
---- {
---- name = 'KeyBind', -- Name of Key
---- key = Keyboard.KEY, -- Key
---- qBlock = true, -- Don't perform key action with queue
---- Down = actionDown, -- Action on Down -- Receives playerObj -- Optional
---- Hold = actionHold, -- Action on Hold -- Receives playerObj -- Optional
---- Up = actionUp -- Action on Up -- Receives playerObj -- Optional
---- },
---- }
function SpiffUI:AddKeyBinds(binds)
for _,j in ipairs(binds) do
self:AddKeyBind(j)
end
end
------------------------------------------
-- Key Handlers
-- Common things to check for when checking a key
---- Returns the player object if successful
SpiffUI.preCheck = function()
local player = getSpecificPlayer(0)
if not player or player:isDead() or player:isAsleep() then
return nil
end
if UIManager.getSpeedControls() and (UIManager.getSpeedControls():getCurrentGameSpeed() == 0) then
return nil
end
return player
end
local function keyDown(key)
--print("Pressed: " .. getKeyName(key) .. " | " .. key)
local player = SpiffUI.preCheck(key)
if not player then return end
for _,bind in ipairs(SpiffUI.KeyBinds) do
if key == getCore():getKey(bind.name) then
if bind.Down then
local queue = ISTimedActionQueue.queues[player]
if bind.qBlock and queue and #queue.queue > 0 then
return
end
bind.Down(player)
end
break
end
end
end
local function keyHold(key)
local player = SpiffUI.preCheck(key)
if not player then return end
for _,bind in ipairs(SpiffUI.KeyBinds) do
if key == getCore():getKey(bind.name) then
if bind.Hold then
local queue = ISTimedActionQueue.queues[player]
if bind.qBlock and queue and #queue.queue > 0 then
return
end
bind.Hold(player)
end
break
end
end
end
local function keyRelease(key)
local player = SpiffUI.preCheck(key)
if not player then return end
for _,bind in ipairs(SpiffUI.KeyBinds) do
if key == getCore():getKey(bind.name) then
if bind.Up then
local queue = ISTimedActionQueue.queues[player]
if bind.qBlock and queue and #queue.queue > 0 then
return
end
bind.Up(player)
end
break
end
end
end
------------------------------------------
-- Key Action Handlers
---- used mostly for radials
SpiffUI.action = {
ticks = 0,
delay = 500,
ready = true,
wasVisible = false
}
-- onKeyDown starts an action
SpiffUI.onKeyDown = function(player)
-- The radial menu will also close without updating me
---- So we need to catch this
local radialMenu = getPlayerRadialMenu(0)
if SpiffUI.action.ready and (not radialMenu:isReallyVisible() and SpiffUI.action.wasVisible) then
SpiffUI.action.ready = true
end
-- True means we're not doing another action
if SpiffUI.action.ready then
-- Hide Radial Menu on Press if applicable
if radialMenu:isReallyVisible() and getCore():getOptionRadialMenuKeyToggle() then
radialMenu:removeFromUIManager()
setJoypadFocus(player:getPlayerNum(), nil)
SpiffUI.action.wasVisible = false
SpiffUI.action.ready = true
return
end
SpiffUI.action.ticks = getTimestampMs()
SpiffUI.action.ready = false
SpiffUI.action.wasVisible = false
end
end
-- We check here and set our state if true on hold
SpiffUI.holdTime = function()
if SpiffUI.action.ready then return false end
SpiffUI.action.ready = (getTimestampMs() - SpiffUI.action.ticks) >= SpiffUI.action.delay
return SpiffUI.action.ready
end
-- We check here and set our state if true on release
SpiffUI.releaseTime = function()
if SpiffUI.action.ready then return false end
SpiffUI.action.ready = (getTimestampMs() - SpiffUI.action.ticks) < SpiffUI.action.delay
return SpiffUI.action.ready
end
SpiffUI.resetKey = function()
SpiffUI.action.ready = true
end
------------------------------------------
-- ISEquippedItem Buttons
SpiffUI.equippedItem = {
["Inventory"] = true,
["Health"] = true,
["Craft"] = true,
["Movable"] = true,
["Search"] = true,
["Map"] = true,
["MiniMap"] = true,
["Debug"] = true,
["Client"] = true,
["Admin"] = true
}
function SpiffUI:updateEquippedItem()
-- Redo the ISEquippedItem tree based on what we set
local player = getPlayerData(0)
local y = player.equipped.invBtn:getY()
for i,v in pairs(SpiffUI.equippedItem) do
if i == "Inventory" then
player.equipped.invBtn:setVisible(v)
if v then
y = player.equipped.invBtn:getY() + player.equipped.inventoryTexture:getHeightOrig() + 5
end
elseif i == "Health" then
player.equipped.healthBtn:setVisible(v)
player.equipped.healthBtn:setY(y)
if v then
y = player.equipped.healthBtn:getY() + player.equipped.heartIcon:getHeightOrig() + 5
end
elseif i == "Craft" then
player.equipped.craftingBtn:setVisible(v)
player.equipped.craftingBtn:setY(y)
if v then
y = player.equipped.craftingBtn:getY() + player.equipped.craftingIcon:getHeightOrig() + 5
end
elseif i == "Movable" then
player.equipped.movableBtn:setVisible(v)
player.equipped.movableBtn:setY(y)
player.equipped.movableTooltip:setY(y)
player.equipped.movablePopup:setY(y)
if v then
y = player.equipped.movableBtn:getBottom() + 5
end
elseif i == "Search" then
player.equipped.searchBtn:setVisible(v)
player.equipped.searchBtn:setY(y)
if v then
y = player.equipped.searchBtn:getY() + player.equipped.searchIconOff:getHeightOrig() + 5
end
elseif i == "Map" then
if ISWorldMap.IsAllowed() then
player.equipped.mapBtn:setVisible(v)
player.equipped.mapBtn:setY(y)
if ISMiniMap.IsAllowed() then
player.equipped.mapPopup:setY(10 + y)
end
if v then
y = player.equipped.mapBtn:getBottom() + 5
end
end
elseif i == "Debug" then
if getCore():getDebug() or (ISDebugMenu.forceEnable and not isClient()) then
player.equipped.debugBtn:setVisible(v)
player.equipped.debugBtn:setY(y)
if v then
y = player.equipped.debugBtn:getY() + player.equipped.debugIcon:getHeightOrig() + 5
end
end
elseif i == "Client" then
if isClient() then
player.equipped.clientBtn:setVisible(v)
player.equipped.clientBtn:setY(y)
if v then
y = player.equipped.clientBtn:getY() + player.equipped.clientIcon:getHeightOrig() + 5
end
end
elseif i == "Admin" then
if isClient() then
player.equipped.adminBtn:setVisible(v)
player.equipped.adminBtn:setY(y)
end
end
end
end
------------------------------------------
function SpiffUI:OnGameStart()
for _,j in ipairs(SpiffUI) do
local mod = SpiffUI[j]
if mod and mod.Start then
mod.Start()
end
end
Events.OnKeyStartPressed.Add(keyDown)
Events.OnKeyKeepPressed.Add(keyHold)
Events.OnKeyPressed.Add(keyRelease)
self:updateEquippedItem()
end
function SpiffUI:ModOptions()
SpiffUI.config = {}
if ModOptions and ModOptions.getInstance then
local function apply(data)
local options = data.settings.options
-- Set options
end
local SPIFFCONFIG = {
options_data = {
applyNewKeybinds = {
name = "UI_ModOptions_SpiffUI_applyNewKeybinds",
default = false
},
runAllResets = {
name = "UI_ModOptions_SpiffUI_runAllResets",
default = false,
tooltip = "UI_ModOptions_SpiffUI_tooltip_runResets"
}
},
mod_id = "SpiffUI",
mod_shortname = "SpiffUI",
mod_fullname = getText("UI_Name_SpiffUI")
}
local optionsInstance = ModOptions:getInstance(SPIFFCONFIG)
ModOptions:loadFile()
-- Modal for our Apply Defaults key
local applyKeys = optionsInstance:getData("applyNewKeybinds")
function applyKeys:buildString(text,h)
for name,key in pairs(SpiffUI.KeyDefaults) do
text = text .. getText("UI_ModOptions_SpiffUI_Modal_aNKChild", getText("UI_optionscreen_binding_" .. name), getKeyName(key))
h = h + 20
end
return text,h
end
function applyKeys:onUpdate(newValue)
if newValue then
applyKeys:set(false)
local w,h = 350,120
local text = getText("UI_ModOptions_SpiffUI_Modal_applyNewKeybinds")
text,h = self:buildString(text,h)
SpiffUI.settingsModal(w, h, text, self, applyKeys.apply)
end
end
function applyKeys:apply(button)
self.modal = nil
if button.internal == "NO" then
return
end
for name,key in pairs(SpiffUI.KeyDefaults) do
for i,v in ipairs(MainOptions.keyText) do
if not v.value then
if v.txt:getName() == name then
v.keyCode = key
v.btn:setTitle(getKeyName(key))
break
end
end
end
end
getCore():saveOptions()
MainOptions.instance.gameOptions.changed = false
end
local runResets = optionsInstance:getData("runAllResets")
function runResets:buildString(text,h)
for _,j in ipairs(SpiffUI) do
local mod = SpiffUI[j]
if mod and mod.Reset then
if mod.resetDesc then
text = text .. mod.resetDesc
else
text = text .. " <LINE> " .. j
end
h = h + 20
end
end
return text,h
end
function runResets:onUpdate(newValue)
if newValue then
runResets:set(false)
-- quick check if we're in game
local player = getPlayerData(0)
if not player then return end
local w,h = 350,120
local text = getText("UI_ModOptions_SpiffUI_Modal_runResets")
text,h = self:buildString(text,h)
SpiffUI.settingsModal(w, h, text, self, runResets.apply)
end
end
function runResets:apply(button)
self.modal = nil
if button.internal == "NO" then
return
end
for _,j in ipairs(SpiffUI) do
local mod = SpiffUI[j]
if mod and mod.Reset then
mod.Reset()
end
end
MainOptions.instance.gameOptions.changed = false
end
Events.OnPreMapLoad.Add(function()
apply({settings = SPIFFCONFIG})
end)
end
end
-- At first I had this run only once, but apparently when there's only 1 mod this breaks
---- So, OnPostBoot is added to run things last
SpiffUI.firstBoot = function()
Events.OnGameBoot.Add(function()
SpiffUI:OnPostBoot()
end)
--Events.OnGameBoot.Remove(SpiffUI.firstBoot)
SpiffUI:OnGameBoot()
end
function SpiffUI:OnGameBoot()
self:ModOptions()
for _,j in ipairs(SpiffUI) do
local mod = SpiffUI[j]
if mod and mod.Boot then
mod.Boot()
end
end
-- Let's Remove some keys
for name,_ in pairs(SpiffUI.KeyDisables) do
local found = false
for i = 1, #keyBinding do
if keyBinding[i].value == name then
table.remove(keyBinding, i)
--print("Removed Keybind: " .. name)
found = true
break
end
end
-- We may have a SpiffUI key we want to remove
if not found then
for i,bind in ipairs(SpiffUI.KeyBinds) do
if bind.name == name then
table.remove(SpiffUI.KeyBinds, i)
--print("Removed SpiffUI Keybind: " .. name)
break
end
end
end
end
-- Now let's add ours!
for _, bind in ipairs(SpiffUI.KeyBinds) do
table.insert(keyBinding, { value = bind.name, key = bind.key })
end
-- Events
Events.OnGameStart.Add(function()
SpiffUI:OnGameStart()
end)
Events.OnCreatePlayer.Add(function(id)
SpiffUI:OnCreatePlayer(id)
end)
end
function SpiffUI:OnPostBoot()
-- Let's Remove some keys possibly added by mods
for name,_ in pairs(SpiffUI.KeyDisables) do
local found = false
for i = 1, #keyBinding do
if keyBinding[i].value == name then
table.remove(keyBinding, i)
--print("Removed Keybind: " .. name)
found = true
break
end
end
end
end
function SpiffUI:OnCreatePlayer(id)
for _,j in ipairs(SpiffUI) do
local mod = SpiffUI[j]
if mod and mod.CreatePlayer then
mod.CreatePlayer(id)
end
end
end
------------------------------------------
SpiffUI.settingsModal = function(w, h, text, key, callback)
key.modal = ISModalRichText:new((getCore():getScreenWidth() / 2) - w / 2,
(getCore():getScreenHeight() / 2) - h / 2, w, h,
text, true, MainOptions.instance, callback)
key.modal:initialise()
key.modal:setCapture(true)
key.modal:setAlwaysOnTop(true)
key.modal:addToUIManager()
if MainOptions.joyfocus then
MainOptions.joyfocus.focus = key.modal
updateJoypadFocus(key.joyfocus)
end
end
------------------------------------------
Events.OnGameBoot.Add(SpiffUI.firstBoot)
-- Hello SpiffUI :)
print(getText("UI_Hello_SpiffUI"))

View File

@@ -0,0 +1,15 @@
------------------------------------------
-- SpiffUI Radials
---- ISFirearmRadialMenu getWeapon hack
------------------------------------------
-- This lets us set call the radial without having the wepaon in-hand
---- You must have the weapon equipped in primary in order to do an action though
---- Useful as we can inject a weapon to show
local _ISFirearmRadialMenu_getWeapon = ISFirearmRadialMenu.getWeapon
function ISFirearmRadialMenu:getWeapon()
if not self.weapon then
return _ISFirearmRadialMenu_getWeapon(self)
end
return self.weapon
end

View File

@@ -0,0 +1,435 @@
------------------------------------------
-- SpiffUI Radials
---- Add tooltip to Radial
------------------------------------------
SpiffUI = SpiffUI or {}
-- Register our inventory
local spiff = SpiffUI:Register("radials")
local SpiffUIRadialRecipeTooltip = ISRecipeTooltip:derive("SpiffUIRadialRecipeTooltip")
function SpiffUIRadialRecipeTooltip:new()
return ISRecipeTooltip.new(self)
end
-- Taken from the base game's ISInventoryPaneContextMenu.lua
---- CraftTooltip:layoutContents(x, y)
----- This fixes the lag spike by limiting the number of sources we parse
------ We also force-add our item if missing to ensure it shows :)
function SpiffUIRadialRecipeTooltip:layoutContents(x, y)
if self.contents then
return self.contentsWidth, self.contentsHeight
end
self:getContainers()
self:getAvailableItemsType()
local FONT_HGT_SMALL = getTextManager():getFontHeight(UIFont.Small)
local IMAGE_SIZE = 20
self.contents = {}
local marginLeft = 20
local marginTop = 10
local marginBottom = 10
local y1 = y + marginTop
local lineHeight = math.max(FONT_HGT_SMALL, 20 + 2)
local textDY = (lineHeight - FONT_HGT_SMALL) / 2
local imageDY = (lineHeight - IMAGE_SIZE) / 2
local singleSources = {}
local multiSources = {}
local allSources = {}
for j=0,self.recipe:getSource():size()-1 do
local source = self.recipe:getSource():get(j)
if source:getItems():size() == 1 then
table.insert(singleSources, source)
else
table.insert(multiSources, source)
end
end
-- Display singleSources before multiSources
for _,source in ipairs(singleSources) do
table.insert(allSources, source)
end
for _,source in ipairs(multiSources) do
table.insert(allSources, source)
end
local maxSingleSourceLabelWidth = 0
for _,source in ipairs(singleSources) do
local txt = self:getSingleSourceText(source)
local width = getTextManager():MeasureStringX(UIFont.Small, txt)
maxSingleSourceLabelWidth = math.max(maxSingleSourceLabelWidth, width)
end
for scount,source in ipairs(allSources) do
local txt = ""
local x1 = x + marginLeft
if source:getItems():size() > 1 then
if source:isDestroy() then
txt = getText("IGUI_CraftUI_SourceDestroyOneOf")
elseif source:isKeep() then
txt = getText("IGUI_CraftUI_SourceKeepOneOf")
else
txt = getText("IGUI_CraftUI_SourceUseOneOf")
end
self:addText(x1, y1 + textDY, txt)
y1 = y1 + lineHeight
else
txt = self:getSingleSourceText(source)
self:addText(x1, y1 + textDY, txt)
x1 = x1 + maxSingleSourceLabelWidth + 10
end
local itemDataList = {}
local searching = {}
-- Get 10 more items from our item's recipe
---- This should cover all of the required items
----- And give us some candy for the UI. :)
------ Why 10? The UI stops at 10 sooooooooo.......
local loopLength = 10
if source:getItems():size() < loopLength then
loopLength = source:getItems():size()
end
-- on our first run
---- The first iteration will be the item itself ("use one item", etc)
if scount == 1 then
local found = false
-- We first need to check if our item is part of the 10
for s=0,loopLength - 1 do
found = (source:getItems():get(s) == self.item:getFullType())
end
-- if our item was not part of the 10 then we add it first
if not found then
searching[self.item:getFullType()] = true
end
end
-- Add our items
for s=0,loopLength - 1 do
searching[source:getItems():get(s)] = true
end
for fType,_ in pairs(searching) do
local itemData = {}
itemData.fullType = fType
itemData.available = true
local item = nil
if itemData.fullType == "Water" then
item = ISInventoryPaneContextMenu.getItemInstance("Base.WaterDrop")
else
if instanceof(self.recipe, "MovableRecipe") and (itemData.fullType == "Base."..self.recipe:getWorldSprite()) then
item = ISInventoryPaneContextMenu.getItemInstance("Moveables.Moveable")
else
item = ISInventoryPaneContextMenu.getItemInstance(itemData.fullType)
end
--this reads the worldsprite so the generated item will have correct icon
if instanceof(item, "Moveable") and instanceof(self.recipe, "MovableRecipe") then
item:ReadFromWorldSprite(self.recipe:getWorldSprite());
end
end
itemData.texture = ""
if item then
itemData.texture = item:getTex():getName()
if itemData.fullType == "Water" then
if source:getCount() == 1 then
itemData.name = getText("IGUI_CraftUI_CountOneUnit", getText("ContextMenu_WaterName"))
else
itemData.name = getText("IGUI_CraftUI_CountUnits", getText("ContextMenu_WaterName"), source:getCount())
end
elseif source:getItems():size() > 1 then -- no units
itemData.name = item:getDisplayName()
elseif not source:isDestroy() and item:IsDrainable() then
if source:getCount() == 1 then
itemData.name = getText("IGUI_CraftUI_CountOneUnit", item:getDisplayName())
else
itemData.name = getText("IGUI_CraftUI_CountUnits", item:getDisplayName(), source:getCount())
end
elseif not source:isDestroy() and source:getUse() > 0 then -- food
if source:getUse() == 1 then
itemData.name = getText("IGUI_CraftUI_CountOneUnit", item:getDisplayName())
else
itemData.name = getText("IGUI_CraftUI_CountUnits", item:getDisplayName(), source:getUse())
end
elseif source:getCount() > 1 then
itemData.name = getText("IGUI_CraftUI_CountNumber", item:getDisplayName(), source:getCount())
else
itemData.name = item:getDisplayName()
end
else
itemData.name = itemData.fullType
end
local countAvailable = self.typesAvailable[itemData.fullType] or 0
if countAvailable < source:getCount() and itemData.fullType ~= self.item:getFullType() then
itemData.available = false
itemData.r = 0.54
itemData.g = 0.54
itemData.b = 0.54
end
table.insert(itemDataList, itemData)
end
-- Hack for "Dismantle Digital Watch" and similar recipes.
-- Recipe sources include both left-hand and right-hand versions of the same item.
-- We only want to display one of them.
---[[
for j=1,#itemDataList do
local item = itemDataList[j]
for k=#itemDataList,j+1,-1 do
local item2 = itemDataList[k]
if self:isExtraClothingItemOf(item, item2) then
table.remove(itemDataList, k)
end
end
end
--]]
for i,itemData in ipairs(itemDataList) do
local x2 = x1
if source:getItems():size() > 1 then
x2 = x2 + 20
if source:getCount() > 1 then
itemData.name = getText("IGUI_CraftUI_CountNumber", itemData.name, source:getCount())
end
end
if itemData.texture ~= "" then
self:addImage(x2, y1 + imageDY, itemData.texture)
x2 = x2 + IMAGE_SIZE + 6
end
self:addText(x2, y1 + textDY, itemData.name, itemData.r, itemData.g, itemData.b)
y1 = y1 + lineHeight
if i == 10 and i < source:getItems():size() then
self:addText(x2, y1 + textDY, getText("Tooltip_AndNMore", source:getItems():size() - i))
y1 = y1 + lineHeight
break
end
end
end
if self.recipe:getTooltip() then
local x1 = x + marginLeft
local tooltip = getText(self.recipe:getTooltip())
self:addText(x1, y1 + 8, tooltip)
end
self.contentsX = x
self.contentsY = y
self.contentsWidth = 0
self.contentsHeight = 0
for _,v in ipairs(self.contents) do
self.contentsWidth = math.max(self.contentsWidth, v.x + v.width - x)
self.contentsHeight = math.max(self.contentsHeight, v.y + v.height + marginBottom - y)
end
return self.contentsWidth, self.contentsHeight
end
function ISRadialMenu:makeToolTip()
local player = getSpecificPlayer(self.playerNum)
self.toolRender = ISToolTipInv:new()
self.toolRender:initialise()
self.toolRender:setCharacter(player)
self.craftRender = SpiffUIRadialRecipeTooltip:new()
self.craftRender:initialise()
self.craftRender.character = player
self.invRender = ISToolTip:new()
self.invRender:initialise()
if JoypadState.players[self.playerNum+1] then
local x = getPlayerScreenLeft(self.playerNum) + 60
local y = getPlayerScreenTop(self.playerNum) + 60
self.invRender.followMouse = false
self.invRender.desiredX = x
self.invRender.desiredY = y
self.toolRender.followMouse = false
self.toolRender:setX(x)
self.toolRender:setY(y)
self.craftRender.followMouse = false
self.craftRender.desiredX = x
self.craftRender.desiredY = y
end
end
function ISRadialMenu:getSliceTooltipJoyPad()
if not self.joyfocus or not self.joyfocus.id then return nil end
local sliceIndex = self.javaObject:getSliceIndexFromJoypad(self.joyfocus.id)
if sliceIndex == -1 then return nil end
local command = self:getSliceCommand(sliceIndex + 1)
if command and command[2] and command[2].tooltip then
return command[2].tooltip
end
return nil
end
function ISRadialMenu:getSliceTooltipMouse(x, y)
local sliceIndex = self.javaObject:getSliceIndexFromMouse(x, y)
local command = self:getSliceCommand(sliceIndex + 1)
if command and command[2] and command[2].tooltip then
return command[2].tooltip
end
return nil
end
function ISRadialMenu:showTooltip(item)
if item and spiff.config.showTooltips then
if self.prev == item and (self.toolRender:getIsVisible()
or self.craftRender:getIsVisible()
or self.invRender:getIsVisible()) then return end
if self.toolRender:getIsVisible() then
self.toolRender:removeFromUIManager()
self.toolRender:setVisible(false)
end
if self.craftRender:getIsVisible() then
self.craftRender:removeFromUIManager()
self.craftRender:setVisible(false)
end
if self.invRender:getIsVisible() then
self.invRender:removeFromUIManager()
self.invRender:setVisible(false)
end
self.prev = item
if instanceof(item, "InventoryItem") then
self.toolRender:setItem(item)
self.toolRender:setVisible(true)
self.toolRender:addToUIManager()
self.toolRender:bringToTop()
elseif item.isRecipe then
-- We have to run the reset so the recipe is updated
self.craftRender:reset()
-- Reset annoyingly changes this stuff..
if JoypadState.players[self.playerNum+1] then
self.craftRender.followMouse = false
self.craftRender.desiredX = getPlayerScreenLeft(self.playerNum) + 60
self.craftRender.desiredY = getPlayerScreenTop(self.playerNum) + 60
end
self.craftRender.recipe = item.recipe
self.craftRender.item = item.item
self.craftRender:setName(item.recipe:getName())
if item.item:getTexture() and item.item:getTexture():getName() ~= "Question_On" then
self.craftRender:setTexture(item.item:getTexture():getName())
end
self.craftRender:setVisible(true)
self.craftRender:addToUIManager()
self.craftRender:bringToTop()
elseif item.isFix then
self.invRender:setName(item.name)
self.invRender.texture = item.texture
self.invRender.description = item.description
self.invRender:setVisible(true)
self.invRender:addToUIManager()
self.invRender:bringToTop()
end
else
if self.toolRender and self.toolRender:getIsVisible() then
self.toolRender:removeFromUIManager()
self.toolRender:setVisible(false)
end
if self.craftRender and self.craftRender:getIsVisible() then
self.craftRender:removeFromUIManager()
self.craftRender:setVisible(false)
end
if self.invRender and self.invRender:getIsVisible() then
self.invRender:removeFromUIManager()
self.invRender:setVisible(false)
end
end
end
-- Derived from ISPanelJoypad
function ISRadialMenu:onMouseMove(dx, dy)
if self.playerNum ~= 0 then return end
ISPanelJoypad.onMouseMove(self, dx, dy)
local x = self:getMouseX()
local y = self:getMouseY()
self:showTooltip(self:getSliceTooltipMouse(x, y))
end
-- Derived from ISPanelJoypad
function ISRadialMenu:onMouseMoveOutside(dx, dy)
if self.playerNum ~= 0 then return end
ISPanelJoypad.onMouseMoveOutside(self, dx, dy)
if self.toolRender and self.toolRender:getIsVisible() then
self.toolRender:removeFromUIManager()
self.toolRender:setVisible(false)
end
if self.craftRender and self.craftRender:getIsVisible() then
self.craftRender:removeFromUIManager()
self.craftRender:setVisible(false)
end
if self.invRender and self.invRender:getIsVisible() then
self.invRender:removeFromUIManager()
self.invRender:setVisible(false)
end
end
local _ISRadialMenu_undisplay = ISRadialMenu.undisplay
function ISRadialMenu:undisplay()
_ISRadialMenu_undisplay(self)
if self.toolRender and self.toolRender:getIsVisible() then
self.toolRender:removeFromUIManager()
self.toolRender:setVisible(false)
end
if self.craftRender and self.craftRender:getIsVisible() then
self.craftRender:removeFromUIManager()
self.craftRender:setVisible(false)
end
if self.invRender and self.invRender:getIsVisible() then
self.invRender:removeFromUIManager()
self.invRender:setVisible(false)
end
end
function ISRadialMenu:RadialTick()
if self:isReallyVisible() then
self:showTooltip(self:getSliceTooltipJoyPad())
end
end
local _ISRadialMenu_new = ISRadialMenu.new
function ISRadialMenu:new(...)
local o = _ISRadialMenu_new(self, ...)
o:makeToolTip()
if JoypadState.players[o.playerNum+1] then
Events.OnRenderTick.Add(function()
o:RadialTick()
end)
end
return o
end

View File

@@ -0,0 +1,247 @@
------------------------------------------
-- SpiffUI Radials
---- Radial Menu Functions
------------------------------------------
SpiffUI = SpiffUI or {}
-- Register our Radials
local spiff = SpiffUI:Register("radials")
-- Base SpiffUI Radial Menu
local SpiffUIRadialMenu = ISBaseObject:derive("SpiffUIRadialMenu")
-- Base Radial Command
local SpiffUIRadialCommand = ISBaseObject:derive("SpiffUIRadialCommand")
-- Radial Command for asking amount
local SpiffUIRadialCommandAsk = SpiffUIRadialCommand:derive("SpiffUIRadialCommandAsk")
-- Radial Command for Next Page
local SpiffUIRadialCommandNext = SpiffUIRadialCommand:derive("SpiffUIRadialCommandNext")
-- Radial Command for Prev Page
local SpiffUIRadialCommandPrev = SpiffUIRadialCommand:derive("SpiffUIRadialCommandPrev")
------------------------------------------
function SpiffUIRadialCommand:new(menu, text, texture, tooltip)
local o = ISBaseObject.new(self)
o.menu = menu
o.rmenu = menu.rmenu
o.player = menu.player
o.playerNum = menu.playerNum
o.tooltip = tooltip
o.text = text
o.texture = texture
o.shouldAsk = 0
o.amount = 0
return o
end
function SpiffUIRadialCommand:fillMenu()
if spiff.config.showTooltips and self.tooltip then
if self.forceText then
self.rmenu:addSlice(self.text, self.texture, self.invoke, self)
else
self.rmenu:addSlice("", self.texture, self.invoke, self)
end
else
self.rmenu:addSlice(self.text, self.texture, self.invoke, self)
end
end
function SpiffUIRadialCommand:Action()
print("Base SpiffUIRadialCommand Action -- Override me!")
end
function SpiffUIRadialCommand:invoke()
if self.shouldAsk > 0 then
self.menu.command = self
self.menu:askAmount()
return
end
self:Action()
end
-- Add Definition
spiff.radialcommand = SpiffUIRadialCommand
------------------------------------------
function SpiffUIRadialCommandAsk:invoke()
self.menu.command.amount = self.amount
self.menu.command:Action()
end
function SpiffUIRadialCommandAsk:new(menu, text, texture, amount)
local o = spiff.radialcommand.new(self, menu, text, texture, nil)
o.amount = amount
return o
end
------------------------------------------
function SpiffUIRadialCommandNext:invoke()
self.menu.page = self.menu.page + 1
self.menu:show()
end
function SpiffUIRadialCommandNext:new(menu, text, texture)
return spiff.radialcommand.new(self, menu, text, texture, nil)
end
------------------------------------------
function SpiffUIRadialCommandPrev:invoke()
self.menu.page = self.menu.page - 1
if self.menu.pageReset then
self.menu.maxPage = self.menu.page
end
self.menu:show()
end
function SpiffUIRadialCommandPrev:new(menu, text, texture)
return spiff.radialcommand.new(self, menu, text, texture, nil)
end
------------------------------------------
function SpiffUIRadialMenu:build()
print("Base SpiffUIRadialMenu build -- Override me!")
end
function SpiffUIRadialMenu:askAmount()
self.rmenu:clear()
--table.wipe(self.commands)
local askCommands = {}
if self.command.shouldAsk == 1 then -- Consume: 1 (all), 1/2, 1/4, Dieter
table.insert(askCommands, SpiffUIRadialCommandAsk:new(self, self.command.item:getName(), spiff.icons[4], 1))
table.insert(askCommands, SpiffUIRadialCommandAsk:new(self, self.command.item:getName(), spiff.icons[2], 0.5))
table.insert(askCommands, SpiffUIRadialCommandAsk:new(self, self.command.item:getName(), spiff.icons[3], 0.25))
table.insert(askCommands, SpiffUIRadialCommandAsk:new(self, self.command.item:getName(), spiff.icons[5], -1))
elseif self.command.shouldAsk == 2 then -- Crafting, all or 1
table.insert(askCommands, SpiffUIRadialCommandAsk:new(self, self.command.recipe:getName(), spiff.icons[4], true))
table.insert(askCommands, SpiffUIRadialCommandAsk:new(self, self.command.recipe:getName(), spiff.icons[1], false))
end
for _,command in ipairs(askCommands) do
local count = #self.rmenu.slices
command:fillMenu()
if count == #self.rmenu.slices then
self.rmenu:addSlice(nil, nil, nil)
end
end
self.rmenu:center()
self.rmenu:addToUIManager()
self.rmenu:setVisible(true)
SpiffUI.action.wasVisible = true
if JoypadState.players[self.playerNum+1] then
self.rmenu:setHideWhenButtonReleased(Joypad.DPadUp)
setJoypadFocus(self.playerNum, self.rmenu)
self.player:setJoypadIgnoreAimUntilCentered(true)
end
end
function SpiffUIRadialMenu:display()
self:build()
self.page = 1
self:show()
end
function SpiffUIRadialMenu:show()
self.rmenu:clear()
local hasCommands = false
-- Add the next page
if self.maxPage > 1 and self.page < self.maxPage then
local nextp = SpiffUIRadialCommandNext:new(self, "Next", self.nextTex)
local count = #self.rmenu.slices
nextp:fillMenu()
if count == #self.rmenu.slices then
self.rmenu:addSlice(nil, nil, nil)
end
end
if self.commands[self.page] then
for _,command in ipairs(self.commands[self.page]) do
local count = #self.rmenu.slices
command:fillMenu()
if count == #self.rmenu.slices then
self.rmenu:addSlice(nil, nil, nil)
end
hasCommands = true
end
end
-- Add the previous page
if self.maxPage > 1 and self.page > 1 then
local nextp = SpiffUIRadialCommandPrev:new(self, "Previous", self.prevTex)
local count = #self.rmenu.slices
nextp:fillMenu()
if count == #self.rmenu.slices then
self.rmenu:addSlice(nil, nil, nil)
end
end
if hasCommands then
self.rmenu:center()
self.rmenu:addToUIManager()
self.rmenu:setVisible(true)
SpiffUI.action.wasVisible = true
if JoypadState.players[self.playerNum+1] then
self.rmenu:setHideWhenButtonReleased(Joypad.DPadUp)
setJoypadFocus(self.playerNum, self.rmenu)
self.player:setJoypadIgnoreAimUntilCentered(true)
end
else
-- If no commands, just close the radial
self.rmenu:undisplay()
end
end
function SpiffUIRadialMenu:AddCommand(command)
if self.cCount == self.cMax then
--print("Adding New Page: " .. self.cCount)
self.cCount = 0
self.page = self.page + 1
self.maxPage = self.page
end
if not self.commands[self.page] then
self.commands[self.page] = {}
end
table.insert(self.commands[self.page], command)
self.cCount = self.cCount + 1
--print("Count: " .. self.cCount)
end
function SpiffUIRadialMenu:new(player)
local o = ISBaseObject.new(self)
o.player = player
o.playerNum = player:getPlayerNum()
o.rmenu = getPlayerRadialMenu(o.playerNum)
o.commands = {}
o.cCount = 0
o.cMax = 16
o.page = 1
o.maxPage = 1
o.nextTex = getTexture("media/SpiffUI/nextpage.png")
o.prevTex = getTexture("media/SpiffUI/prevpage.png")
return o
end
spiff.radialmenu = SpiffUIRadialMenu

View File

@@ -0,0 +1,186 @@
------------------------------------------
-- SpiffUI Crafting Radial Actions
---- Radial Menu for Crafting
------------------------------------------
SpiffUI = SpiffUI or {}
-- Register our Radials
local spiff = SpiffUI:Register("radials")
local SpiffUICraftingRadial = spiff.radialmenu:derive("SpiffUICraftingRadial")
if not spiff.radials then spiff.radials = {} end
spiff.radials[0] = SpiffUICraftingRadial
------------------------------------------
local SpiffUICraftingRadialCommand = spiff.radialcommand:derive("SpiffUICraftingRadialCommand")
function SpiffUICraftingRadialCommand:Action()
ISInventoryPaneContextMenu.OnCraft(self.item, self.recipe, self.player:getPlayerNum(), self.amount)
end
function SpiffUICraftingRadialCommand:new(menu, recipe)
local texture = InventoryItemFactory.CreateItem(recipe.recipe:getResult():getFullType()):getTexture()
local tooltip = {
recipe = recipe.recipe,
item = recipe.item,
isRecipe = true
}
local o = spiff.radialcommand.new(self, menu, recipe.recipe:getName(), texture, tooltip)
o.recipe = recipe.recipe
o.item = recipe.item
if spiff.config.craftAmount == -1 and recipe.num > 1 then
-- Ask
o.shouldAsk = 2
elseif spiff.config.craftAmount == 1 then
-- Craft All
o.amount = true
end
return o
end
local function getRecipes(packs, player)
local items = {}
local recipes = {}
for p = 0, packs:size() - 1 do
local pack = packs:get(p)
local ps = pack:getAllEval(function(item)
return instanceof(item, "InventoryItem")
end)
if ps and ps:size() > 0 then
for i = 0, ps:size() - 1 do
local item = ps:get(i)
if item then
if not items[item:getType()] then
items[item:getType()] = item
end
end
end
end
end
if not spiff.config.craftShowSmokeables then
for i,item in pairs(items) do
if spiff.filters.smokeables[item:getType()] or item:getCustomMenuOption() == "Smoke" then
items[item:getType()] = nil
end
end
end
if not spiff.config.craftShowMedical then
for i,item in pairs(items) do
if spiff.filters.firstAidCraft[item:getType()] or item:getStringItemType() == "Medical" then
items[item:getType()] = nil
end
end
end
if not spiff.config.craftShowEquipped then
for i,item in pairs(items) do
if player:isEquipped(item) and (player:getPrimaryHandItem() ~= item and player:getSecondaryHandItem() ~= item) then
items[item:getType()] = nil
end
end
end
local count = 0
for _,item in pairs(items) do
local recs = RecipeManager.getUniqueRecipeItems(item, player, packs)
for i = 0, recs:size() - 1 do
local recipe = recs:get(i)
local key
if spiff.config.craftFilterUnique then
key = recipe:getName()
else
key = count
end
if not recipes[key] then
recipes[key] = {
recipe = recipe,
num = RecipeManager.getNumberOfTimesRecipeCanBeDone(recipe, player, packs, item),
item = item
}
count = count + 1
end
end
end
return recipes
end
------------------------------------------
function SpiffUICraftingRadial:build()
local bags = ISInventoryPaneContextMenu.getContainers(self.player)
local recipes = getRecipes(bags, self.player)
local hasRecipes = false
for i,j in pairs(recipes) do
self:AddCommand(SpiffUICraftingRadialCommand:new(self, j))
hasRecipes = true
end
if not hasRecipes then
self.player:Say(getText("UI_character_SpiffUI_noCraft"))
end
end
function SpiffUICraftingRadial:new(player)
return spiff.radialmenu.new(self, player)
end
local function SpiffUICraftDown(player)
SpiffUI.onKeyDown(player)
if not SpiffUI.action.ready then
local ui = getPlayerCraftingUI(player:getPlayerNum())
if ui:getIsVisible() then
ui:setVisible(false)
ui:removeFromUIManager()
-- Ready for another action
SpiffUI.action.ready = true
end
end
end
local function SpiffUICraftHold(player)
if SpiffUI.holdTime() then
if spiff.config.craftSwitch then
ISCraftingUI.toggleCraftingUI()
else
-- Create Menu
local menu = SpiffUICraftingRadial:new(player)
menu:display()
end
end
end
local function SpiffUICraftRelease(player)
if SpiffUI.releaseTime() then
if spiff.config.craftSwitch then
-- Create Menu
local menu = SpiffUICraftingRadial:new(player)
menu:display()
else
ISCraftingUI.toggleCraftingUI()
end
end
end
local function actionInit()
local bind = {
name = 'SpiffUICraftWheel',
key = Keyboard.KEY_B,
queue = false,
Down = SpiffUICraftDown,
Hold = SpiffUICraftHold,
Up = SpiffUICraftRelease
}
SpiffUI:AddKeyBind(bind)
end
actionInit()

View File

@@ -0,0 +1,246 @@
------------------------------------------
-- SpiffUI Drink Actions
---- Radial Menu for drinks
------------------------------------------
SpiffUI = SpiffUI or {}
-- Register our Radials
local spiff = SpiffUI:Register("radials")
local SpiffUIDrinkRadial = spiff.radialmenu:derive("SpiffUIDrinkRadial")
if not spiff.radials then spiff.radials = {} end
spiff.radials[1] = SpiffUIDrinkRadial
------------------------------------------
local SpiffUIDrinkThirstRadialCommand = spiff.radialcommand:derive("SpiffUIDrinkThirstRadialCommand")
function SpiffUIDrinkThirstRadialCommand:Action()
ISInventoryPaneContextMenu.onDrinkForThirst(self.item, self.player)
-- Return from whence it came...
if self.item:getContainer() ~= self.player:getInventory() then
ISTimedActionQueue.add(ISInventoryTransferAction:new(self.player, self.item, self.player:getInventory(), self.item:getContainer()))
end
end
function SpiffUIDrinkThirstRadialCommand:new(menu, item)
local o = spiff.radialcommand.new(self, menu, item:getName(), item:getTexture(), item)
o.item = item
return o
end
------------------------------------------
local SpiffUIDrinkRadialCommand = spiff.radialcommand:derive("SpiffUIDrinkRadialCommand")
-- Code below is adapted from the "Dieter" feature of the excellent ExtraSauce Quality of Life mod by MonsterSauce
local function round(num)
return math.floor(num * 100 + 0.5) / 100;
end
local function doDrink(item, player, amount)
-- If we don't specify an amount, then figure it out
if amount == -1 then
local itemThirst = 0
if (item.getThirstChange and item:getThirstChange()) then
itemThirst = round(item:getThirstChange())
end
local charThirst = round(player:getStats():getThirst())
if itemThirst < 0 and charThirst >= 0.1 then
local percentage = 1
if (charThirst + itemThirst < 0) then
percentage = -1 * round(charThirst / itemThirst)
if (percentage > 0.95) then percentage = 1.0 end
end
amount = percentage
end
end
if amount ~= -1 then
ISInventoryPaneContextMenu.eatItem(item, amount, player:getPlayerNum())
else
player:Say(getText("UI_character_SpiffUI_notThirsty"))
end
end
function SpiffUIDrinkRadialCommand:Action()
doDrink(self.item, self.player, self.amount)
--ISInventoryPaneContextMenu.eatItem(self.item, self.amount, self.playerNum)
-- Return from whence it came...
if self.item:getContainer() ~= self.player:getInventory() then
ISTimedActionQueue.add(ISInventoryTransferAction:new(self.player, self.item, self.player:getInventory(), self.item:getContainer()))
end
end
function SpiffUIDrinkRadialCommand:new(menu, item)
local o = spiff.radialcommand.new(self, menu, item:getName(), item:getTexture(), item)
o.amount = spiff.config.drinkAmount
o.item = item
if spiff.config.drinkAmount == 0 then
o.shouldAsk = 1
end
return o
end
local function getItems(packs, player)
local items = {}
for p = 0, packs:size() - 1 do
local pack = packs:get(p)
local ps = pack:getAllEval(function(item)
return not player:isKnownPoison(item) and (item:getCustomMenuOption() and item:getCustomMenuOption() == "Drink") or item:isWaterSource()
end)
if ps and ps:size() > 0 then
for i = 0, ps:size() - 1 do
local item = ps:get(i)
if item then
if item:isWaterSource() then
if not items[item:getType()] or items[item:getType()]:getUsedDelta() > item:getUsedDelta() then
items[item:getType()] = item
end
else
if not items[item:getType()] or items[item:getType()]:getThirstChange() < item:getThirstChange() then
items[item:getType()] = item
end
end
end
end
end
end
local drinks = nil
for _,j in pairs(items) do
if not drinks then drinks = {} end
table.insert(drinks, j)
end
if drinks then
table.sort(drinks, function(a,b)
if a:isWaterSource() then
return true
end
if b:isWaterSource() then
return false
end
return a:getThirstChange() > b:getThirstChange()
end)
end
return drinks
end
------------------------------------------
function SpiffUIDrinkRadial:build()
local packs = ISInventoryPaneContextMenu.getContainers(self.player)
local drinks = getItems(packs, self.player)
if not drinks then
self.player:Say(getText("UI_character_SpiffUI_noDrinks"))
return
end
local hasCmd = false
-- Build
for _,j in ipairs(drinks) do
if j:isWaterSource() then
if self.player:getStats():getThirst() > 0.1 then
self:AddCommand(SpiffUIDrinkThirstRadialCommand:new(self, j))
hasCmd = true
end
else
self:AddCommand(SpiffUIDrinkRadialCommand:new(self, j))
hasCmd = true
end
end
if not hasCmd then
self.player:Say(getText("UI_character_SpiffUI_noDrinks"))
end
end
function SpiffUIDrinkRadial:new(player)
return spiff.radialmenu.new(self, player)
end
local function quickDrink(player)
if player:getStats():getThirst() < 0.1 then
player:Say(getText("UI_character_SpiffUI_notThirsty"))
return
end
local packs = ISInventoryPaneContextMenu.getContainers(player)
local items = getItems(packs, player)
if items then
for _,item in ipairs(items) do
if item:isWaterSource() then
ISInventoryPaneContextMenu.onDrinkForThirst(item, player)
else
local amount = spiff.config.drinkQuickAmount
if amount == 0 then amount = -1 end
doDrink(item, player, amount)
end
-- Return from whence it came...
if item:getContainer() ~= player:getInventory() then
ISTimedActionQueue.add(ISInventoryTransferAction:new(player, item, player:getInventory(), item:getContainer()))
end
-- Just do the first
return
end
else
player:Say(getText("UI_character_SpiffUI_noDrinks"))
end
end
local function DrinksDown(player)
SpiffUI.onKeyDown(player)
-- If showNow and we're doing an action, do it now
if spiff.config.drinkShowNow and not SpiffUI.action.ready then
-- Create Menu
local menu = SpiffUIDrinkRadial:new(player)
menu:display()
-- Ready for another action
SpiffUI.action.ready = true
end
end
local function DrinksHold(player)
if SpiffUI.holdTime() then
-- Create Menu
local menu = SpiffUIDrinkRadial:new(getSpecificPlayer(0))
menu:display()
end
end
local function DrinksRelease(player)
if SpiffUI.releaseTime() then
quickDrink(player)
end
end
local function actionInit()
local bind = {
name = 'SpiffUIDrinkWheel',
key = 26, -- {
queue = true,
Down = DrinksDown,
Hold = DrinksHold,
Up = DrinksRelease
}
SpiffUI:AddKeyBind(bind)
end
actionInit()

View File

@@ -0,0 +1,199 @@
------------------------------------------
-- SpiffUI Eat Actions
---- Radial Menu for food
------------------------------------------
SpiffUI = SpiffUI or {}
-- Register our Radials
local spiff = SpiffUI:Register("radials")
local SpiffUIEatRadial = spiff.radialmenu:derive("SpiffUIEatRadial")
if not spiff.radials then spiff.radials = {} end
spiff.radials[2] = SpiffUIEatRadial
------------------------------------------
local SpiffUIEatRadialCommand = spiff.radialcommand:derive("SpiffUIEatRadialCommand")
-- Code below is adapted from the excellent ExtraSauce Quality of Life mod by MonsterSauce
local function round(num)
return math.floor(num * 100 + 0.5) / 100;
end
local function doEat(item, player, amount)
-- If we don't specify an amount, then figure it out
if amount == -1 then
local itemHunger = 0
if (item.getBaseHunger and item:getBaseHunger()) then
itemHunger = round(item:getBaseHunger())
end
local charHunger = round(player:getStats():getHunger())
if itemHunger < 0 and charHunger >= 0.1 then
local percentage = 1
if (charHunger + itemHunger < 0) then
percentage = -1 * round(charHunger / itemHunger)
if (percentage > 0.95) then percentage = 1.0 end
end
amount = percentage
end
end
if amount ~= -1 then
ISInventoryPaneContextMenu.eatItem(item, amount, player:getPlayerNum())
else
player:Say(getText("UI_character_SpiffUI_notHungry"))
end
end
------------------------------------------
function SpiffUIEatRadialCommand:Action()
doEat(self.item, self.player, self.amount)
-- Return from whence it came...
if self.item:getContainer() ~= self.player:getInventory() then
ISTimedActionQueue.add(ISInventoryTransferAction:new(self.player, self.item, self.player:getInventory(), self.item:getContainer()))
end
end
function SpiffUIEatRadialCommand:new(menu, item)
local o = spiff.radialcommand.new(self, menu, item:getName(), item:getTexture(), item)
o.amount = spiff.config.eatAmount
o.item = item
if spiff.config.eatAmount == 0 then
o.shouldAsk = 1
end
return o
end
local function getItems(packs)
local items = {}
for p = 0, packs:size() - 1 do
local pack = packs:get(p)
local ps = pack:getAllEval(function(item)
return instanceof(item, "Food") and item:getHungChange() < 0 and not item:getScriptItem():isCantEat() and not item:getCustomMenuOption()
end)
if ps and ps:size() > 0 then
for i = 0, ps:size() - 1 do
local item = ps:get(i)
if item then
if not items then items = {} end
if not items[item:getType()] or items[item:getType()]:getHungChange() < item:getHungChange() then
items[item:getType()] = item
end
end
end
end
end
local food = nil
for _,j in pairs(items) do
if not food then food = {} end
table.insert(food, j)
end
if food then
table.sort(food, function(a,b)
return a:getHungChange() > b:getHungChange()
end)
end
return food
end
------------------------------------------
function SpiffUIEatRadial:build()
local packs = ISInventoryPaneContextMenu.getContainers(self.player)
local food = getItems(packs)
if not food then
self.player:Say(getText("UI_character_SpiffUI_noFood"))
return
end
-- Build
for _,j in ipairs(food) do
self:AddCommand(SpiffUIEatRadialCommand:new(self, j))
end
end
function SpiffUIEatRadial:new(player)
return spiff.radialmenu.new(self, player)
end
local function quickEat(player)
if player:getStats():getHunger() < 0.1 then
player:Say(getText("UI_character_SpiffUI_notHungry"))
return
end
local packs = ISInventoryPaneContextMenu.getContainers(player)
local food = getItems(packs)
if not food then
player:Say(getText("UI_character_SpiffUI_noFood"))
return
end
for _,item in ipairs(food) do
-- Just do the first thing
local amount = spiff.config.eatQuickAmount
if amount == 0 then amount = -1 end
doEat(item, player, amount)
--ISInventoryPaneContextMenu.eatItem(item, spiff.config.eatQuickAmount, player:getPlayerNum())
-- Return from whence it came...
if item:getContainer() ~= player:getInventory() then
ISTimedActionQueue.add(ISInventoryTransferAction:new(player, item, player:getInventory(), item:getContainer()))
end
return
end
end
local function EatDown(player)
SpiffUI.onKeyDown(player)
-- If showNow and we're doing an action, do it now
if spiff.config.eatShowNow and not SpiffUI.action.ready then
-- Create Menu
local menu = SpiffUIEatRadial:new(player)
menu:display()
-- Ready for another action
SpiffUI.action.ready = true
end
end
local function EatHold(player)
if SpiffUI.holdTime() then
-- Create Menu
local menu = SpiffUIEatRadial:new(getSpecificPlayer(0))
menu:display()
end
end
local function EatRelease(player)
if SpiffUI.releaseTime() then
quickEat(player)
end
end
local function actionInit()
local bind = {
name = 'SpiffUIEatWheel',
key = 27, -- }
queue = true,
Down = EatDown,
Hold = EatHold,
Up = EatRelease
}
SpiffUI:AddKeyBind(bind)
end
actionInit()

View File

@@ -0,0 +1,607 @@
------------------------------------------
-- SpiffUI Equipment Actions
---- Radial Menu for Equipment
------------------------------------------
SpiffUI = SpiffUI or {}
-- Register our Radials
local spiff = SpiffUI:Register("radials")
local SpiffUIEquipmentRadial = spiff.radialmenu:derive("SpiffUIEquipmentRadial")
if not spiff.radials then spiff.radials = {} end
spiff.radials[3] = SpiffUIEquipmentRadial
------------------------------------------
local SpiffUIEquipmentRadialCommand = spiff.radialcommand:derive("SpiffUIEquipmentRadialCommand")
local SpiffUIEquipmentItemRadialCommand = spiff.radialcommand:derive("SpiffUIEquipmentItemRadialCommand")
local function returnItem(item, player)
if item:getContainer() ~= player:getInventory() then
ISTimedActionQueue.add(ISInventoryTransferAction:new(player, item, player:getInventory(), item:getContainer()))
end
end
local function returnItems(items, player)
for i=0,items:size() - 1 do
local item = items:get(i)
returnItem(item, player)
end
end
------------------------------------------
function SpiffUIEquipmentItemRadialCommand:Action()
if self.mode == 0 then -- "Inspect"
ISInventoryPaneContextMenu.onInspectClothing(self.player, self.item.item)
elseif self.mode == 1 then -- "Unequip"
if self.item.inHotbar then
-- We Detach it
ISTimedActionQueue.add(ISDetachItemHotbar:new(self.player, self.item.item))
end
ISInventoryPaneContextMenu.unequipItem(self.item.item, self.playerNum)
elseif self.mode == 2 then -- "Transfer To"
ISTimedActionQueue.add(ISInventoryTransferAction:new(self.player, self.item.item, self.player:getInventory(), self.item.inv))
elseif self.mode == 3 then -- "Drop"
ISInventoryPaneContextMenu.dropItem(self.item.item, self.playerNum)
elseif self.mode == 4 then -- Clothing Items Extra
ISTimedActionQueue.add(ISClothingExtraAction:new(self.player, self.item.item, self.item.itype))
elseif self.mode == 5 then --Recipes
ISInventoryPaneContextMenu.OnCraft(self.item.item, self.item.recipe, self.playerNum, false)
elseif self.mode == 6 then -- Item Repairs
if not self.item.unavailable then
local items = self.item.fixing:getRequiredItems(self.player, self.item.fixer, self.item.item)
ISInventoryPaneContextMenu.onFix(self.item.item, self.playerNum, self.item.fixing, self.item.fixer)
returnItems(items, self.player)
else
self.player:Say(getText("UI_character_SpiffUI_noRepairItems"))
end
elseif self.mode == 7 then -- Guns!
if self.item.item ~= self.player:getPrimaryHandItem() then
-- The gun has to be equipped in order for the radial menu to work
ISInventoryPaneContextMenu.equipWeapon(self.item.item, true, self.item.item:isTwoHandWeapon(), self.playerNum)
end
local frm = ISFirearmRadialMenu:new(self.player)
frm.weapon = self.item.item
frm:fillMenu()
frm:display()
else
self.player:Say("OOPS! I don't know how to do that. That's not supposed to happen!")
end
end
function SpiffUIEquipmentItemRadialCommand:new(menu, stuff)
local o = spiff.radialcommand.new(self, menu, stuff.label, stuff.texture, stuff.tooltip)
o.item = stuff
o.mode = stuff.mode
o.forceText = true
return o
end
------------------------------------------
function SpiffUIEquipmentRadialCommand:Action()
self.menu.page = self.menu.page + 1
self.menu.maxPage = self.menu.page
if self.mode == 0 then
-- base menu, show item
self.menu:itemOptions(self.item)
elseif self.mode == 1 then
-- show accessories
self.menu:accessories()
elseif self.mode == 2 then
-- show accessories
self.menu:hotbar()
end
end
function SpiffUIEquipmentRadialCommand:new(menu, item, mode)
local o
if mode == 0 then
o = spiff.radialcommand.new(self, menu, item:getName(), item:getTexture(), item)
else
o = spiff.radialcommand.new(self, menu, item.label, item.texture, nil)
end
o.item = item
o.mode = mode
return o
end
------------------------------------------
local clothesSort = {
["Hat"] = 0,
["FullHat"] = 1,
["FullHelmet"] = 2,
["FullSuit"] = 3,
["FullSuitHead"] = 4,
["FullTop"] = 5,
["JacketHat"] = 6,
["SweaterHat"] = 7,
["Ears"] = 108,
["EarTop"] = 109,
["Eyes"] = 110,
["MakeUp_Eyes"] = 111,
["MakeUp_EyesShadow"] = 112,
["MaskEyes"] = 113,
["RightEye"] = 114,
["LeftEye"] = 115,
["Nose"] = 116,
["MakeUp_Lips"] = 117,
["MakeUp_FullFace"] = 118,
["Mask"] = 119,
["MaskFull"] = 120,
["Neck"] = 121,
["Necklace"] = 122,
["Necklace_Long"] = 123,
["Scarf"] = 24,
["Jacket"] = 25,
["Sweater"] = 26,
["JacketHat"] = 27,
["SweaterHat"] = 28,
["Dress"] = 29,
["BathRobe"] = 30,
["Shirt"] = 31,
["TankTop"] = 32,
["TorsoExtra"] = 33,
["Tshirt"] = 34,
["ShortSleeveShirt"] = 35,
["Sweater"] = 36,
["AmmoStrap"] = 137,
["BellyButton"] = 138,
["Belt"] = 39,
["Holster"] = 139,
["BeltExtra"] = 140,
["FannyPackBack"] = 41,
["FannyPackFront"] = 42,
["Hands"] = 43,
["Left_MiddleFinger"] = 144,
["Left_RingFinger"] = 145,
["LeftWrist"] = 146,
["Right_MiddleFinger"] = 147,
["Right_RingFinger"] = 148,
["RightWrist"] = 149,
["Tail"] = 150,
["Underwear"] = 51,
["UnderwearBottom"] = 52,
["UnderwearExtra1"] = 53,
["UnderwearExtra2"] = 54,
["UnderwearInner"] = 55,
["UnderwearTop"] = 56,
["Skirt"] = 57,
["Torso1Legs1"] = 58,
["Legs1"] = 59,
["Pants"] = 60,
["Socks"] = 61,
["Shoes"] = 62,
[""] = 99
}
local clothesFilter = {
["Bandage"] = true,
["Wound"] = true,
["ZedDmg"] = true
}
local function getItems(packs, player)
local items = nil
-- First get worn items
local clothes = player:getWornItems()
for i=0, clothes:size() - 1 do
if not items then items = {} end
local item = clothes:get(i):getItem()
if item and not clothesFilter[item:getBodyLocation()] then
table.insert(items, item)
end
end
-- Add any equipped items in our hands too
local primary = player:getPrimaryHandItem()
local secondary = player:getSecondaryHandItem()
if primary then
if not items then items = {} end
table.insert(items, primary)
end
if secondary and secondary ~= primary then
if not items then items = {} end
table.insert(items, secondary)
end
if items then
-- order our clothes from head to toe
table.sort(items, function(a,b)
if not clothesSort[a:getBodyLocation()] or not clothesSort[b:getBodyLocation()] then return false end
return clothesSort[a:getBodyLocation()] < clothesSort[b:getBodyLocation()]
end)
end
return items
end
-- This is mostly a combination function that reimplements 'ISInventoryPaneContextMenu.addFixerSubOption'
---- The tooltip is used in our radial override tooltip
---- returns a "stuff" table that is used to build a radial command
local function fixerStuff(item, fixing, fixer, player)
local unavailable = false
local tooltip = {
description = "",
texture = item:getTex(),
name = item:getName(),
isFix = true
}
local fixerItem = fixing:haveThisFixer(player, fixer, item)
local usedItem = InventoryItemFactory.CreateItem(fixing:getModule():getName() .. "." .. fixer:getFixerName())
local itemName
if usedItem then
tooltip.texture = usedItem:getTex()
itemName = getItemNameFromFullType(usedItem:getFullType())
else
itemName = fixer:getFixerName()
end
tooltip.name = itemName
local condPercentRepaired = FixingManager.getCondRepaired(item, player, fixing, fixer)
local color1 = "<RED>";
if condPercentRepaired > 15 and condPercentRepaired <= 25 then
color1 = "<ORANGE>";
elseif condPercentRepaired > 25 then
color1 = "<GREEN>";
end
local chanceOfSucess = 100 - FixingManager.getChanceOfFail(item, player, fixing, fixer)
local color2 = "<RED>";
if chanceOfSucess > 15 and chanceOfSucess <= 40 then
color2 = "<ORANGE>";
elseif chanceOfSucess > 40 then
color2 = "<GREEN>";
end
tooltip.description = " " .. color1 .. " " .. getText("Tooltip_potentialRepair") .. " " .. math.ceil(condPercentRepaired) .. "%"
tooltip.description = tooltip.description .. " <LINE> " .. color2 .. " " .. getText("Tooltip_chanceSuccess") .. " " .. math.ceil(chanceOfSucess) .. "%"
tooltip.description = tooltip.description .. " <LINE> <LINE> <RGB:1,1,1> " .. getText("Tooltip_craft_Needs") .. ": <LINE> "
if fixing:getGlobalItem() then
local globalItem = fixing:haveGlobalItem(player);
local uses = fixing:countUses(player, fixing:getGlobalItem(), nil)
if globalItem then
tooltip.description = tooltip.description .. " <LINE> " .. globalItem:getName() .. " " .. uses .. "/" .. fixing:getGlobalItem():getNumberOfUse() .. " <LINE> "
else
local globalItem = InventoryItemFactory.CreateItem(fixing:getModule():getName() .. "." .. fixing:getGlobalItem():getFixerName())
local name = fixing:getGlobalItem():getFixerName();
if globalItem then name = globalItem:getName(); end
tooltip.description = tooltip.description .. " <LINE> <RGB:1,0,0> " .. name .. " " .. uses .. "/" .. fixing:getGlobalItem():getNumberOfUse() .. " <LINE> "
unavailable = true
end
end
local uses = fixing:countUses(player, fixer, item)
if uses >= fixer:getNumberOfUse() then
color1 = " <RGB:1,1,1> "
else
color1 = " <RED> "
unavailable = true
end
tooltip.description = tooltip.description .. color1 .. itemName .. " " .. uses .. "/" .. fixer:getNumberOfUse()
if fixer:getFixerSkills() then
local skills = fixer:getFixerSkills()
for j=0,skills:size()-1 do
local skill = skills:get(j)
local perk = Perks.FromString(skill:getSkillName())
local perkLvl = player:getPerkLevel(perk)
if perkLvl >= skill:getSkillLevel() then
color1 = " <RGB:1,1,1> "
else
color1 = " <RED> "
unavailable = true
end
tooltip.description = tooltip.description .. " <LINE> " .. color1 .. PerkFactory.getPerk(perk):getName() .. " " .. perkLvl .. "/" .. skill:getSkillLevel()
end
end
if unavailable then
tooltip.description = tooltip.description .. " <LINE> <RED> " .. "**FUCK YOU, ASSHOLE**"
end
return {
fixing = fixing,
fixer = fixer,
item = item,
tooltip = tooltip,
label = getText("ContextMenu_Repair") .. getItemNameFromFullType(item:getFullType()),
texture = tooltip.texture,
unavailable = unavailable,
mode = 6
}
end
-- spiff.functions = {}
-- spiff.functions.FixerStuff = fixerStuff
function SpiffUIEquipmentRadial:itemOptions(item)
if not self.commands[self.page] then
self.commands[self.page] = {}
else
table.wipe(self.commands[self.page])
end
if not item then return end
-- Get Hotbar
local hotbar = getPlayerHotbar(self.player:getPlayerNum())
-- Add "Inspect"
if item:getCategory() == "Clothing" and item:getCoveredParts():size() > 0 then
local stuff = {
item = item,
label = getText("IGUI_invpanel_Inspect"),
texture = item:getTexture(),
tooltip = item,
mode = 0
}
table.insert(self.commands[self.page], SpiffUIEquipmentItemRadialCommand:new(self, stuff))
end
do -- Add "Unequip"
local stuff = {
item = item,
label = getText("ContextMenu_Unequip"),
texture = spiff.icons["unequip"],
tooltip = item,
inHotbar = hotbar:isInHotbar(item) and not self.player:isEquipped(item), -- Trigger a remove from hotbar if item is not equipped
mode = 1
}
table.insert(self.commands[self.page], SpiffUIEquipmentItemRadialCommand:new(self, stuff))
end
local loot = getPlayerLoot(self.playerNum)
if loot.inventory:getType() ~= "floor" then
local stuff = {
item = item,
label = getText("UI_radial_SpiffUI_Transfer") .. loot.title,
texture = ContainerButtonIcons[loot.inventory:getType()],
inv = loot.inventory,
tooltip = item,
mode = 2
}
table.insert(self.commands[self.page], SpiffUIEquipmentItemRadialCommand:new(self, stuff))
end
-- Add "Drop"
if spiff.config.equipShowDrop then
local stuff = {
item = item,
label = getText("ContextMenu_Drop"),
texture = spiff.icons["drop"],
tooltip = item,
mode = 3
}
table.insert(self.commands[self.page], SpiffUIEquipmentItemRadialCommand:new(self, stuff))
end
-- Add Clothing Items Extra
if item.getClothingItemExtraOption and item:getClothingItemExtraOption() and spiff.config.equipShowClothingActions then
for i=0,item:getClothingItemExtraOption():size()-1 do
local action = item:getClothingItemExtraOption():get(i)
local itemType = moduleDotType(item:getModule(), item:getClothingItemExtra():get(i))
local stuff = {
item = item,
itype = itemType,
label = getText("ContextMenu_" .. action),
texture = InventoryItemFactory.CreateItem(itemType):getTexture(),
tooltip = item,
mode = 4
}
table.insert(self.commands[self.page], SpiffUIEquipmentItemRadialCommand:new(self, stuff))
end
end
--Add Recipes
if spiff.config.equipShowRecipes then
local recs = RecipeManager.getUniqueRecipeItems(item, self.player, self.packs)
for i = 0, recs:size() - 1 do
local recipe = recs:get(i)
local stuff = {
item = item,
recipe = recipe,
label = recipe:getName(),
texture = InventoryItemFactory.CreateItem(recipe:getResult():getFullType()):getTexture(),
tooltip = {
recipe = recipe,
item = item,
isRecipe = true
},
mode = 5
}
table.insert(self.commands[self.page], SpiffUIEquipmentItemRadialCommand:new(self, stuff))
end
end
-- Add Item Repairs
if item:isBroken() or item:getCondition() < item:getConditionMax() then
local fixingList = FixingManager.getFixes(item)
if not fixingList:isEmpty() then
for i=0,fixingList:size()-1 do
local fixing = fixingList:get(i)
for j=0,fixing:getFixers():size()-1 do
local fixer = fixing:getFixers():get(j)
local stuff = fixerStuff(item, fixing, fixer, self.player)
if stuff.unavailable then
if spiff.config.equipShowAllRepairs then
table.insert(self.commands[self.page], SpiffUIEquipmentItemRadialCommand:new(self, stuff))
end
else
table.insert(self.commands[self.page], SpiffUIEquipmentItemRadialCommand:new(self, stuff))
end
end
end
end
end
-- Guns!
if item.isRanged and item:isRanged() then
local stuff = {
item = item,
label = "Firearm Radial",
texture = item:getTexture(),
tooltip = item,
mode = 7
}
table.insert(self.commands[self.page], SpiffUIEquipmentItemRadialCommand:new(self, stuff))
end
self:show()
end
function SpiffUIEquipmentRadial:accessories()
if not self.commands[self.page] then
self.commands[self.page] = {}
else
table.wipe(self.commands[self.page])
end
for _,j in ipairs(self.items) do
if not clothesSort[j:getBodyLocation()] or clothesSort[j:getBodyLocation()] > 100 then
-- Add our items to page 2
table.insert(self.commands[self.page], SpiffUIEquipmentRadialCommand:new(self, j, 0))
end
end
self:show()
end
function SpiffUIEquipmentRadial:hotbar()
if not self.commands[self.page] then
self.commands[self.page] = {}
else
table.wipe(self.commands[self.page])
end
local hotbar = getPlayerHotbar(self.playerNum)
for i,item in pairs(hotbar.attachedItems) do
table.insert(self.commands[self.page], SpiffUIEquipmentRadialCommand:new(self, item, 0))
end
self:show()
end
function SpiffUIEquipmentRadial:build()
self.packs = ISInventoryPaneContextMenu.getContainers(self.player)
self.items = getItems(self.packs, self.player)
self.page = 1
self.maxPage = 1
local haveAccs = false
local accTex
local hasItems = false
if self.items then
for _,j in ipairs(self.items) do
if clothesSort[j:getBodyLocation()] and clothesSort[j:getBodyLocation()] < 100 then
-- Add our items to page 1
if not self.commands[1] then
self.commands[1] = {}
end
table.insert(self.commands[1], SpiffUIEquipmentRadialCommand:new(self, j, 0))
hasItems = true
else
haveAccs = true
if not accTex then
accTex = j:getTexture()
end
end
end
if haveAccs then
local stuff = {
label = getText("UI_radial_SpiffUI_Accessories"),
texture = accTex
}
table.insert(self.commands[1], SpiffUIEquipmentRadialCommand:new(self, stuff, 1))
hasItems = true
end
end
do
local hotbar = getPlayerHotbar(self.playerNum)
for _,item in pairs(hotbar.attachedItems) do
if item then
local stuff = {
label = getText("UI_radial_SpiffUI_Hotbar"),
texture = item:getTexture()
}
table.insert(self.commands[1], SpiffUIEquipmentRadialCommand:new(self, stuff, 2))
hasItems = true
break
end
end
end
if not hasItems then
self.player:Say(getText("UI_character_SpiffUI_noEquip"))
end
end
function SpiffUIEquipmentRadial:new(player)
local o = spiff.radialmenu.new(self, player)
-- If we end up back at page 1, then we're at the main menu
o.pageReset = true
return o
end
local function EquipDown(player)
SpiffUI.onKeyDown(player)
-- If showNow and we're doing an action, do it now
if not SpiffUI.action.ready then
if getPlayerInventory(0):getIsVisible() then
if SpiffUI["inventory"] then
ISInventoryPage.SpiffOnKey(player)
else
getPlayerInventory(0):setVisible(false)
getPlayerLoot(0):setVisible(false)
end
SpiffUI.action.wasVisible = true
end
end
end
local function EquipHold(player)
if SpiffUI.holdTime() then
-- Create Menu
local menu = SpiffUIEquipmentRadial:new(player)
menu:display()
end
end
local function EquipRelease(player)
if SpiffUI.releaseTime() then
if not SpiffUI.action.wasVisible then
if SpiffUI["inventory"] then
ISInventoryPage.SpiffOnKey(player)
else
local toggle = getPlayerInventory(0):getIsVisible()
getPlayerInventory(0):setVisible(not toggle)
getPlayerLoot(0):setVisible(not toggle)
end
end
SpiffUI.action.wasVisible = false
end
end
local function actionInit()
local bind = {
name = 'SpiffUIEquipmentWheel',
key = Keyboard.KEY_TAB,
queue = false,
Down = EquipDown,
Hold = EquipHold,
Up = EquipRelease
}
SpiffUI:AddKeyBind(bind)
end
actionInit()

View File

@@ -0,0 +1,130 @@
------------------------------------------
-- SpiffUI First Aid Craft Actions
---- Radial Menu for First Aid Crafting
------------------------------------------
SpiffUI = SpiffUI or {}
-- Register our Radials
local spiff = SpiffUI:Register("radials")
local SpiffUIFirstAidCraftRadial = spiff.radialmenu:derive("SpiffUIFirstAidCraftRadial")
if not spiff.radials then spiff.radials = {} end
spiff.radials[4] = SpiffUIFirstAidCraftRadial
------------------------------------------
local SpiffUIFirstAidCraftRadialCommand = spiff.radialcommand:derive("SpiffUIFirstAidCraftRadialCommand")
function SpiffUIFirstAidCraftRadialCommand:Action()
ISInventoryPaneContextMenu.OnCraft(self.item, self.recipe, self.player:getPlayerNum(), self.amount)
end
function SpiffUIFirstAidCraftRadialCommand:new(menu, recipe)
local texture = InventoryItemFactory.CreateItem(recipe.recipe:getResult():getFullType()):getTexture()
local tooltip = {
recipe = recipe.recipe,
item = recipe.item,
isRecipe = true
}
local o = spiff.radialcommand.new(self, menu, recipe.recipe:getName(), texture, tooltip)
o.recipe = recipe.recipe
o.item = recipe.item
o.amount = false
-- If we should and and we can make more than 1
if spiff.config.firstAidCraftAmount == -1 and recipe.num > 1 then
-- Ask
o.shouldAsk = 2
elseif spiff.config.firstAidCraftAmount == 1 then
-- Craft All
o.amount = true
end
return o
end
local function getRecipes(packs, player)
local items = {}
local recipes = {}
for p = 0, packs:size() - 1 do
local pack = packs:get(p)
local ps = pack:getAllEval(function(item)
return spiff.filters.firstAidCraft[item:getType()] or item:getStringItemType() == "Medical"
end)
if ps and ps:size() > 0 then
for i = 0, ps:size() - 1 do
local item = ps:get(i)
if item then
if not items[item:getType()] then
items[item:getType()] = item
end
end
end
end
end
for _,item in pairs(items) do
local recs = RecipeManager.getUniqueRecipeItems(item, player, packs)
for i = 0, recs:size() - 1 do
local recipe = recs:get(i)
local key = recipe:getResult():getFullType()
recipes[key] = {
recipe = recipe,
num = RecipeManager.getNumberOfTimesRecipeCanBeDone(recipe, player, packs, item),
item = item
}
end
end
return recipes
end
function SpiffUIFirstAidCraftRadial:build()
local recipes = {}
local bags = ISInventoryPaneContextMenu.getContainers(self.player)
local recipes = getRecipes(bags, self.player)
local hasCraft = false
-- Build Smokeables
for i,j in pairs(recipes) do
self:AddCommand(SpiffUIFirstAidCraftRadialCommand:new(self, j))
hasCraft = true
end
if not hasCraft then
self.player:Say(getText("UI_character_SpiffUI_noCraft"))
end
end
function SpiffUIFirstAidCraftRadial:new(player)
return spiff.radialmenu.new(self, player)
end
local function FirstAidCraftDown(player)
SpiffUI.onKeyDown(player)
-- if we're not ready, then we're doing an action.
---- do it now
if not SpiffUI.action.ready then
-- Create Menu
local menu = SpiffUIFirstAidCraftRadial:new(player)
menu:display()
-- Ready for another action
SpiffUI.action.ready = true
end
end
local function actionInit()
local bind = {
name = 'SpiffUIFirstAidCraftWheel',
key = 39, -- ;
queue = true,
Down = FirstAidCraftDown
}
SpiffUI:AddKeyBind(bind)
end
actionInit()

View File

@@ -0,0 +1,121 @@
------------------------------------------
-- SpiffUI First Aid Craft Actions
---- Radial Menu for First Aid Crafting
------------------------------------------
SpiffUI = SpiffUI or {}
-- Register our Radials
local spiff = SpiffUI:Register("radials")
local SpiffUIOneRadial = spiff.radialmenu:derive("SpiffUIOneRadial")
------------------------------------------
local SpiffUIOneRadialCommand = spiff.radialcommand:derive("SpiffUIOneRadialCommand")
function SpiffUIOneRadialCommand:Action()
local radial = spiff.radials[self.mode]
if radial then
local menu = radial:new(self.player)
menu:display()
end
end
function SpiffUIOneRadialCommand:new(menu, name, texture, mode)
local o = spiff.radialcommand.new(self, menu, name, texture, nil)
o.mode = mode
return o
end
function SpiffUIOneRadial:build()
-- Crafting
self:AddCommand(SpiffUIOneRadialCommand:new(self, "Crafting",getTexture("media/SpiffUI/crafting.png"), 0))
-- Drink
self:AddCommand(SpiffUIOneRadialCommand:new(self, "Drink", InventoryItemFactory.CreateItem("Base.WaterBottleFull"):getTexture(), 1))
-- Eat
self:AddCommand(SpiffUIOneRadialCommand:new(self, "Eat", InventoryItemFactory.CreateItem("Base.ChickenFried"):getTexture(), 2))
-- Equipment
self:AddCommand(SpiffUIOneRadialCommand:new(self, "Equipment", getTexture("media/SpiffUI/inventory.png"), 3))
-- First Aid Craft
self:AddCommand(SpiffUIOneRadialCommand:new(self, "First Aid Craft", InventoryItemFactory.CreateItem("Base.Bandage"):getTexture(), 4))
-- Pills
self:AddCommand(SpiffUIOneRadialCommand:new(self, "Pills", InventoryItemFactory.CreateItem("Base.PillsAntiDep"):getTexture(), 5))
-- Repair
self:AddCommand(SpiffUIOneRadialCommand:new(self, "Repair",InventoryItemFactory.CreateItem("Base.Hammer"):getTexture(), 6))
-- Smoke Craft
if getActivatedMods():contains('jiggasGreenfireMod') then
self:AddCommand(SpiffUIOneRadialCommand:new(self, "Smoke Craft", InventoryItemFactory.CreateItem("Greenfire.SmokingPipe"):getTexture(), 7))
elseif getActivatedMods():contains('Smoker') then
self:AddCommand(SpiffUIOneRadialCommand:new(self, "Smoke Craft", InventoryItemFactory.CreateItem("SM.SMSmokingBlend"):getTexture(), 7))
elseif getActivatedMods():contains('MoreCigsMod') then
self:AddCommand(SpiffUIOneRadialCommand:new(self, "Smoke Craft", InventoryItemFactory.CreateItem("Cigs.CigsOpenPackReg"):getTexture(), 7))
else
self:AddCommand(SpiffUIOneRadialCommand:new(self, "Smoke Craft", InventoryItemFactory.CreateItem("Base.Cigarettes"):getTexture(), 7))
end
-- Smoke
self:AddCommand(SpiffUIOneRadialCommand:new(self, "Smoke",InventoryItemFactory.CreateItem("Base.Cigarettes"):getTexture(), 8))
if spiff.radials[9] then
self:AddCommand(SpiffUIOneRadialCommand:new(self, "Clothing Action Radial Menu",InventoryItemFactory.CreateItem("Base.Hat_BaseballCapGreen"):getTexture(), 9))
end
end
function SpiffUIOneRadial:new(player)
return spiff.radialmenu.new(self, player)
end
local function OneDown(player)
SpiffUI.onKeyDown(player)
-- if we're not ready, then we're doing an action.
---- do it now
if not SpiffUI.action.ready then
-- Create Menu
local menu = SpiffUIOneRadial:new(player)
menu:display()
-- Ready for another action
SpiffUI.action.ready = true
end
end
------------------------------------------
--- For the DPad
local function 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 = SpiffUIOneRadial:new(player)
menu:display()
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
showRadialMenu(player)
else
_ISDPadWheels_onDisplayUp(joypadData)
end
end
local function actionInit()
local bind = {
name = 'SpiffUIOneWheel',
key = Keyboard.KEY_CAPITAL, -- ;
queue = true,
Down = OneDown
}
SpiffUI:AddKeyBind(bind)
end
actionInit()

View File

@@ -0,0 +1,212 @@
------------------------------------------
-- SpiffUI Pills Actions
---- Radial Menu for pills
------------------------------------------
SpiffUI = SpiffUI or {}
-- Register our Radials
local spiff = SpiffUI:Register("radials")
local SpiffUIPillsRadial = spiff.radialmenu:derive("SpiffUIPillsRadial")
if not spiff.radials then spiff.radials = {} end
spiff.radials[5] = SpiffUIPillsRadial
------------------------------------------
local SpiffUIPillsRadialCommand = spiff.radialcommand:derive("SpiffUIPillsRadialCommand")
local function takePill(item, player)
ISInventoryPaneContextMenu.takePill(item, player:getPlayerNum())
-- Return from whence it came...
if item:getContainer() ~= player:getInventory() then
ISTimedActionQueue.add(ISInventoryTransferAction:new(player, item, player:getInventory(), item:getContainer()))
end
end
function SpiffUIPillsRadialCommand:Action()
takePill(self.item, self.player)
end
function SpiffUIPillsRadialCommand:new(menu, item)
local o = spiff.radialcommand.new(self, menu, item:getName(), item:getTexture(), item)
o.item = item
return o
end
------------------------------------------
local function getItems(packs, pills)
for p = 0, packs:size() - 1 do
local pack = packs:get(p)
local ps = pack:getAllEval(function(item)
return luautils.stringStarts(item:getType(), "Pills") or item:getType() == "Antibiotics" -- special case
end)
if ps and ps:size() > 0 then
for i = 0, ps:size() - 1 do
local pill = ps:get(i)
if pill then
-- If not found or has less pills
if not pills[pill:getType()] or pills[pill:getType()]:getUsedDelta() > pill:getUsedDelta() then
pills[pill:getType()] = pill
end
end
end
end
end
return pills
end
function SpiffUIPillsRadial:build()
local pills = {}
local packs = ISInventoryPaneContextMenu.getContainers(self.player)
pills = getItems(packs, pills)
local hasPills = false
-- Build
for i,j in pairs(pills) do
self:AddCommand(SpiffUIPillsRadialCommand:new(self, j))
hasPills = true
end
if not hasPills then
self.player:Say(getText("UI_character_SpiffUI_noPills"))
end
end
function SpiffUIPillsRadial:new(player)
return spiff.radialmenu.new(self, player)
end
------------------------------------------
local function getPillsQuick(player, ptype)
return player:getInventory():getFirstEvalRecurse(function(item)
return item:getType() == ptype
end)
end
local function takePills(items, player)
-- First we'll take all our pills
for _,item in ipairs(items) do
ISInventoryPaneContextMenu.takePill(item, player:getPlayerNum())
end
-- Then we send them back
for _,item in ipairs(items) do
if item:getContainer() ~= player:getInventory() then
ISTimedActionQueue.add(ISInventoryTransferAction:new(player, item, player:getInventory(), item:getContainer()))
end
end
end
local function quickPills(player)
local tried = ""
local pills = nil
if player:getMoodles():getMoodleLevel(MoodleType.Pain) >= 1 then
tried = getItemNameFromFullType("Base.Pills")
-- Take Painpills
local pill = getPillsQuick(player, "Pills")
if pill then
--print("Pain Pills")
if not pills then pills = {} end
table.insert(pills, pill)
end
end
if player:getMoodles():getMoodleLevel(MoodleType.Tired) >= 1 then
local name = getItemNameFromFullType("Base.PillsVitamins")
if tried ~= "" then
tried = tried .. ", " .. name
else
tried = name
end
-- Take Vitamins
local pill = getPillsQuick(player, "PillsVitamins")
if pill then
--print("Vitamins")
if not pills then pills = {} end
table.insert(pills, pill)
end
end
if player:getMoodles():getMoodleLevel(MoodleType.Panic) >= 1 then
local name = getItemNameFromFullType("Base.PillsBeta")
if tried ~= "" then
tried = tried .. ", " .. name
else
tried = name
end
-- Take Beta Blockers
local pill = getPillsQuick(player, "PillsBeta")
if pill then
--print("Beta Blockers")
if not pills then pills = {} end
table.insert(pills, pill)
end
end
if player:getMoodles():getMoodleLevel(MoodleType.Unhappy) >= 1 then
local name = getItemNameFromFullType("Base.PillsAntiDep")
if tried ~= "" then
tried = tried .. ", " .. name
else
tried = name
end
-- Take Antidepressents
local pill = getPillsQuick(player, "PillsAntiDep")
if pill then
--print("Antidepressents")
if not pills then pills = {} end
table.insert(pills, pill)
end
end
if tried ~= "" then
if not pills then
player:Say(getText("UI_character_SpiffUI_noPillsQuick") .. tried)
else
takePills(pills, player)
end
else
player:Say(getText("UI_character_SpiffUI_noPillsNeed"))
end
end
local function PillsDown(player)
SpiffUI.onKeyDown(player)
-- If showNow and we're doing an action, do it now
if spiff.config.pillsShowNow and not SpiffUI.action.ready then
-- Create Menu
local menu = SpiffUIPillsRadial:new(player)
menu:display()
-- Ready for another action
SpiffUI.action.ready = true
end
end
local function PillsHold(player)
if SpiffUI.holdTime() then
-- Create Menu
local menu = SpiffUIPillsRadial:new(player)
menu:display()
end
end
local function PillsRelease(player)
if SpiffUI.releaseTime() then
quickPills(player)
end
end
local function actionInit()
local bind = {
name = 'SpiffUIPillWheel',
key = 40, -- '
queue = true,
Down = PillsDown,
Hold = PillsHold,
Up = PillsRelease
}
SpiffUI:AddKeyBind(bind)
end
actionInit()

View File

@@ -0,0 +1,234 @@
------------------------------------------
-- SpiffUI Repair Actions
---- Radial Menu for Repair
------------------------------------------
SpiffUI = SpiffUI or {}
-- Register our Radials
local spiff = SpiffUI:Register("radials")
local SpiffUIRepairRadial = spiff.radialmenu:derive("SpiffUIRepairRadial")
if not spiff.radials then spiff.radials = {} end
spiff.radials[6] = SpiffUIRepairRadial
------------------------------------------
local SpiffUIRepairRadialCommand = spiff.radialcommand:derive("SpiffUIRepairRadialCommand")
local function returnItems(items, player)
for i=0,items:size() - 1 do
local item = items:get(i)
if item:getContainer() ~= player:getInventory() then
ISTimedActionQueue.add(ISInventoryTransferAction:new(player, item, player:getInventory(), item:getContainer()))
end
end
end
function SpiffUIRepairRadialCommand:Action()
local items = self.item.fixing:getRequiredItems(self.player, self.item.fixer, self.item.item)
ISInventoryPaneContextMenu.onFix(self.item.item, self.playerNum, self.item.fixing, self.item.fixer)
returnItems(items, self.player)
end
function SpiffUIRepairRadialCommand:new(menu, stuff)
local o = spiff.radialcommand.new(self, menu, stuff.label, stuff.item:getTexture(), stuff.tooltip)
o.item = stuff
o.forceText = true
return o
end
-- This is mostly a combination function that reimplements 'ISInventoryPaneContextMenu.addFixerSubOption'
---- The tooltip is used in our radial override tooltip
---- returns a "stuff" table that is used to build a radial command
local function fixerStuff(item, fixing, fixer, player)
local unavailable = false
local tooltip = {
description = "",
texture = item:getTex(),
name = item:getName(),
isFix = true
}
local fixerItem = fixing:haveThisFixer(player, fixer, item)
local usedItem = InventoryItemFactory.CreateItem(fixing:getModule():getName() .. "." .. fixer:getFixerName())
local itemName
if usedItem then
tooltip.texture = usedItem:getTex()
itemName = getItemNameFromFullType(usedItem:getFullType())
else
itemName = fixer:getFixerName()
end
tooltip.name = itemName
local condPercentRepaired = FixingManager.getCondRepaired(item, player, fixing, fixer)
local color1 = "<RED>";
if condPercentRepaired > 15 and condPercentRepaired <= 25 then
color1 = "<ORANGE>";
elseif condPercentRepaired > 25 then
color1 = "<GREEN>";
end
local chanceOfSucess = 100 - FixingManager.getChanceOfFail(item, player, fixing, fixer)
local color2 = "<RED>";
if chanceOfSucess > 15 and chanceOfSucess <= 40 then
color2 = "<ORANGE>";
elseif chanceOfSucess > 40 then
color2 = "<GREEN>";
end
tooltip.description = " " .. color1 .. " " .. getText("Tooltip_potentialRepair") .. " " .. math.ceil(condPercentRepaired) .. "%"
tooltip.description = tooltip.description .. " <LINE> " .. color2 .. " " .. getText("Tooltip_chanceSuccess") .. " " .. math.ceil(chanceOfSucess) .. "%"
tooltip.description = tooltip.description .. " <LINE> <LINE> <RGB:1,1,1> " .. getText("Tooltip_craft_Needs") .. ": <LINE> "
if fixing:getGlobalItem() then
local globalItem = fixing:haveGlobalItem(player);
local uses = fixing:countUses(player, fixing:getGlobalItem(), nil)
if globalItem then
tooltip.description = tooltip.description .. " <LINE> " .. globalItem:getName() .. " " .. uses .. "/" .. fixing:getGlobalItem():getNumberOfUse() .. " <LINE> "
else
local globalItem = InventoryItemFactory.CreateItem(fixing:getModule():getName() .. "." .. fixing:getGlobalItem():getFixerName())
local name = fixing:getGlobalItem():getFixerName();
if globalItem then name = globalItem:getName(); end
tooltip.description = tooltip.description .. " <LINE> <RGB:1,0,0> " .. name .. " " .. uses .. "/" .. fixing:getGlobalItem():getNumberOfUse() .. " <LINE> "
unavailable = true
end
end
local uses = fixing:countUses(player, fixer, item)
if uses >= fixer:getNumberOfUse() then
color1 = " <RGB:1,1,1> "
else
color1 = " <RED> "
unavailable = true
end
tooltip.description = tooltip.description .. color1 .. itemName .. " " .. uses .. "/" .. fixer:getNumberOfUse()
if fixer:getFixerSkills() then
local skills = fixer:getFixerSkills()
for j=0,skills:size()-1 do
local skill = skills:get(j)
local perk = Perks.FromString(skill:getSkillName())
local perkLvl = player:getPerkLevel(perk)
if perkLvl >= skill:getSkillLevel() then
color1 = " <RGB:1,1,1> "
else
color1 = " <RED> "
unavailable = true
end
tooltip.description = tooltip.description .. " <LINE> " .. color1 .. PerkFactory.getPerk(perk):getName() .. " " .. perkLvl .. "/" .. skill:getSkillLevel()
end
end
if unavailable then
tooltip.description = tooltip.description .. " <LINE> <RED> " .. "**FUCK YOU, ASSHOLE**"
end
return {
fixing = fixing,
fixer = fixer,
item = item,
tooltip = tooltip,
label = getText("ContextMenu_Repair") .. getItemNameFromFullType(item:getFullType()),
texture = tooltip.texture,
unavailable = unavailable,
mode = 5
}
end
local function getItems(packs, player)
local items = {}
for p = 0, packs:size() - 1 do
local pack = packs:get(p)
local ps = pack:getAllEval(function(item)
return item:isBroken() or item:getCondition() < item:getConditionMax()
end)
if ps and ps:size() > 0 then
for i = 0, ps:size() - 1 do
local item = ps:get(i)
if item then
items[i] = item
end
end
end
end
if not spiff.config.repairShowEquipped then
for i,item in pairs(items) do
if player:isEquipped(item) then
items[i] = nil
end
end
end
if not spiff.config.repairShowHotbar then
local hotbar = getPlayerHotbar(player:getPlayerNum())
for i,item in pairs(items) do
if hotbar:isInHotbar(item) then
items[i] = nil
end
end
end
local repairs = nil
local count = 0
for _,item in pairs(items) do
local fixingList = FixingManager.getFixes(item)
if not fixingList:isEmpty() then
for i=0,fixingList:size()-1 do
local fixing = fixingList:get(i)
for j=0,fixing:getFixers():size()-1 do
local fixer = fixing:getFixers():get(j)
local stuff = fixerStuff(item, fixing, fixer, player)
if not stuff.unavailable then
if not repairs then repairs = {} end
table.insert(repairs, stuff)
end
end
end
end
end
return repairs
end
function SpiffUIRepairRadial:build()
local packs = ISInventoryPaneContextMenu.getContainers(self.player)
local items = getItems(packs, self.player)
-- Build
if items then
for _,stuff in ipairs(items) do
self:AddCommand(SpiffUIRepairRadialCommand:new(self, stuff))
end
else
self.player:Say(getText("UI_character_SpiffUI_noRepair"))
end
end
function SpiffUIRepairRadial:new(player)
return spiff.radialmenu.new(self, player)
end
local function RepairDown(player)
SpiffUI.onKeyDown(player)
-- If showNow and we're doing an action, do it now
if not SpiffUI.action.ready then
-- Create Menu
local menu = SpiffUIRepairRadial:new(player)
menu:display()
-- Ready for another action
SpiffUI.action.ready = true
end
end
local function actionInit()
local bind = {
name = 'SpiffUIRepairWheel',
key = Keyboard.KEY_N,
queue = true,
Down = RepairDown
}
SpiffUI:AddKeyBind(bind)
end
actionInit()

View File

@@ -0,0 +1,168 @@
------------------------------------------
-- SpiffUI Smoke Actions
---- Radial Menu for drinks
------------------------------------------
SpiffUI = SpiffUI or {}
-- Register our Radials
local spiff = SpiffUI:Register("radials")
local SpiffUISmokeCraftRadial = spiff.radialmenu:derive("SpiffUISmokeCraftRadial")
if not spiff.radials then spiff.radials = {} end
spiff.radials[7] = SpiffUISmokeCraftRadial
------------------------------------------
local SpiffUISmokeCraftRadialCommand = spiff.radialcommand:derive("SpiffUISmokeCraftRadialCommand")
function SpiffUISmokeCraftRadialCommand:Action()
ISInventoryPaneContextMenu.OnCraft(self.item, self.recipe, self.player:getPlayerNum(), self.amount)
end
function SpiffUISmokeCraftRadialCommand:new(menu, recipe)
local texture = InventoryItemFactory.CreateItem(recipe.recipe:getResult():getFullType()):getTexture()
local tooltip = {
recipe = recipe.recipe,
item = recipe.item,
isRecipe = true
}
local o = spiff.radialcommand.new(self, menu, recipe.recipe:getName(), texture, tooltip)
o.recipe = recipe.recipe
o.item = recipe.item
o.amount = false
-- If we should and and we can make more than 1
if spiff.config.smokeCraftAmount == -1 and recipe.num > 1 then
-- Ask
o.shouldAsk = 2
elseif spiff.config.smokeCraftAmount == 1 then
-- Craft All
o.amount = true
end
return o
end
local function getRecipes(packs, player)
local items = {}
local recipes = {}
-- This will get cigs, or
for p = 0, packs:size() - 1 do
local pack = packs:get(p)
local ps = pack:getAllEval(function(item)
return (spiff.filters.smokecraft[item:getType()] ~= nil or item:getCustomMenuOption() == "Smoke")
end)
if ps and ps:size() > 0 then
for i = 0, ps:size() - 1 do
local item = ps:get(i)
if item then
if not items[item:getType()] then
items[item:getType()] = {
item = item,
cat = spiff.filters.smokecraft[item:getType()] or "misc"
}
end
end
end
end
end
local count = 0
for _,item in pairs(items) do
local recs = RecipeManager.getUniqueRecipeItems(item.item, player, packs)
for i = 0, recs:size() - 1 do
local recipe = recs:get(i)
if item.cat == "misc" and item.item:getStressChange() > -0.01 then
item.cat = "butts"
end
recipes[count] = {
recipe = recipe,
num = RecipeManager.getNumberOfTimesRecipeCanBeDone(recipe, player, packs, item.item),
item = item.item,
cat = item.cat
}
count = count + 1
end
end
return recipes
end
function SpiffUISmokeCraftRadial:build()
local recipes = {}
local bags = ISInventoryPaneContextMenu.getContainers(self.player)
local recipes = getRecipes(bags, self.player)
-- Remove any breaking actions if applicable
if not spiff.config.smokeCraftShowDismantle then
for i,recipe in pairs(recipes) do
local first = luautils.split(recipe.recipe:getName(), " ")[1]
if spiff.rFilters.smokecraft.dismantle[first] then
recipes[i] = nil
end
end
end
-- Remove any cigpack actions if applicable
if not spiff.config.smokeCraftShowCigPacks then
for i,recipe in pairs(recipes) do
local first = luautils.split(recipe.recipe:getName(), " ")[1]
if spiff.rFilters.smokecraft.cigpacks[first] then
recipes[i] = nil
end
end
end
-- Always remove these ones
for i,recipe in pairs(recipes) do
local first = luautils.split(recipe.recipe:getName(), " ")[1]
if spiff.rFilters.smokecraft.always[first] then
recipes[i] = nil
end
end
local hasCraft = false
-- Build Smokeables
for i,j in pairs(recipes) do
self:AddCommand(SpiffUISmokeCraftRadialCommand:new(self, j))
hasCraft = true
end
if not hasCraft then
self.player:Say(getText("UI_character_SpiffUI_noCraft"))
end
end
function SpiffUISmokeCraftRadial:new(player)
return spiff.radialmenu.new(self, player)
end
local function SmokeCraftDown(player)
SpiffUI.onKeyDown(player)
-- if we're not ready, then we're doing an action.
---- do it now
if not SpiffUI.action.ready then
-- Create Menu
local menu = SpiffUISmokeCraftRadial:new(player)
menu:display()
-- Ready for another action
SpiffUI.action.ready = true
end
end
local function actionInit()
local bind = {
name = 'SpiffUISmokeCraftWheel',
key = 43, -- \
queue = true,
Down = SmokeCraftDown
}
SpiffUI:AddKeyBind(bind)
end
actionInit()

View File

@@ -0,0 +1,263 @@
------------------------------------------
-- SpiffUI Smoke Radial
---- Radial Menu for smoking
------------------------------------------
SpiffUI = SpiffUI or {}
-- Register our Radials
local spiff = SpiffUI:Register("radials")
local SpiffUISmokeRadial = spiff.radialmenu:derive("SpiffUISmokeRadial")
if not spiff.radials then spiff.radials = {} end
spiff.radials[8] = SpiffUISmokeRadial
------------------------------------------
local SpiffUISmokeRadialCommand = spiff.radialcommand:derive("SpiffUISmokeRadialCommand")
local function doSmokePack(pack, category, nextItem, player)
-- Smoking a pack requires AutoSmoke.
---- AutoSmoke already has support for various mods out there, and is very popular
---- All Credit to NoctisFalco for the original AutoSmoke code
if not AutoSmoke then return end
AutoSmoke.currentAction = AutoSmoke.activeMod.unpackAction(player, pack, pack:getContainer(), nextItem,
AutoSmoke.activeMod.actions[category].time, AutoSmoke.activeMod.actions[category].jobType, AutoSmoke.activeMod.actions[category].sound)
ISInventoryPaneContextMenu.transferIfNeeded(player, pack)
ISTimedActionQueue.add(AutoSmoke.currentAction)
end
function SpiffUISmokeRadialCommand:Action()
local lighterInv
-- let AutoSmoke handle the inventory for the lighter
---- It seems to break it otherwise
if not AutoSmoke then
-- First we handle the lighter
lighterInv = self.lighter:getContainer()
ISInventoryPaneContextMenu.transferIfNeeded(self.player, self.lighter)
end
-- If we have a "nextitem" its from a pack of something
if self.item.next then
doSmokePack(self.item.item, self.item.category, self.item.next, self.player)
else
ISInventoryPaneContextMenu.eatItem(self.item.item, 1, self.playerNum)
end
-- Return lighter whence it came if needed!
if lighterInv and lighterInv ~= self.player:getInventory() then
ISTimedActionQueue.add(ISInventoryTransferAction:new(self.player, self.lighter, self.player:getInventory(), lighterInv))
end
end
function SpiffUISmokeRadialCommand:new(menu, item, lighter)
local o = spiff.radialcommand.new(self, menu, item.item:getName(), item.item:getTexture(), item.item)
o.item = item
o.lighter = lighter
return o
end
local function getNext(item)
for i,_ in pairs(spiff.filters.smoke) do
local out = spiff.filters.smoke[i][item]
if out then
return out
end
end
return nil
end
local function getCat(item)
for i,_ in pairs(spiff.filters.smoke) do
local out = spiff.filters.smoke[i][item]
if out then
return i
end
end
return "misc"
end
local function findRecursive(item)
local found = false
local out
local i = 0
repeat
local iS = luautils.split(item, ".")[2]
if iS then
item = iS
end
local t = getNext(item)
if t and t ~= "" then
if not out then out = {} end
out[i] = t
i = i + 1
item = t
else
found = true
end
until(found)
return out
end
local function checkFilters(item)
if not AutoSmoke then return false end
for i,_ in pairs(spiff.filters.smoke) do
if spiff.filters.smoke[i][item] then
return true
end
end
return false
end
local function getItems(packs, lighter)
local items = {}
-- This will get any smokeables
for p = 0, packs:size() - 1 do
local pack = packs:get(p)
local ps = pack:getAllEval(function(item)
-- Our Filter is only active if AutoSmoke is enabled
return (checkFilters(item:getType()) or item:getCustomMenuOption() == "Smoke")
end)
if ps and ps:size() > 0 then
for i = 0, ps:size() - 1 do
local item = ps:get(i)
local stuff = {
item = item,
category = getCat(item:getType()),
next = nil,
nexti = nil
}
local nexti = findRecursive(item:getType())
if nexti then
stuff.nexti = nexti
stuff.next = nexti[0]
end
local addItem = false
if item then
if spiff.rFilters.smoke.butts[item:getType()] then
if spiff.config.smokeShowButts then
addItem = true
end
elseif spiff.rFilters.smoke.gum[item:getType()] then
if spiff.config.smokeShowGum then
addItem = true
end
else
-- Everything else
addItem = true
end
if addItem and lighter then
items[item:getFullType()] = stuff
end
end
end
end
end
-- Only keep the most relevant. Cigs > Open Pack > Closed Pack > Carton | Gum > Gum Pack > Gum Carton
for i,j in pairs(items) do
if j.nexti then
for _,m in pairs(j.nexti) do
if items[m] then
items[i] = nil
break
end
end
end
end
return items
end
local function getLighter(pack)
return pack:getFirstEvalRecurse(function(item)
return (item:getType() == "Matches") or (item:getType() == "Lighter" and item:getUsedDelta() > 0)
end)
end
function SpiffUISmokeRadial:build()
-- A lighter is required to be on you
local lighter = getLighter(self.player:getInventory())
local bags = ISInventoryPaneContextMenu.getContainers(self.player)
local items = getItems(bags, lighter)
local haveItems = false
for i,_ in pairs(items) do
haveItems = true
break
end
-- We may still have gum!
if not haveItems then
self.player:Say(getText("UI_character_SpiffUI_noSmokes"))
return
end
if not haveItems and not lighter then
self.player:Say(getText("UI_character_SpiffUI_noLighter"))
return
end
-- Build Smokeables
for _,j in pairs(items) do
self:AddCommand(SpiffUISmokeRadialCommand:new(self, j, lighter))
end
end
function SpiffUISmokeRadial:new(player)
return spiff.radialmenu.new(self, player)
end
local function SmokeDown(player)
SpiffUI.onKeyDown(player)
-- If showNow and we're doing an action, do it now
if spiff.config.smokeShowNow and not SpiffUI.action.ready then
-- Create Menu
local menu = SpiffUISmokeRadial:new(player)
menu:display()
-- Ready for another action
SpiffUI.action.ready = true
end
end
local function SmokeHold(player)
if SpiffUI.holdTime() then
-- Create Menu
local menu = SpiffUISmokeRadial:new(player)
menu:display()
end
end
local function SmokeRelease(player)
if SpiffUI.releaseTime() then
-- We do the AutoSmoke Stuff if we don't do the radial
---- From AutoSmoke
if AutoSmoke and AutoSmoke.player then
if AutoSmoke.Options.characterSpeaks then
AutoSmoke.pressedKey = true
end
AutoSmoke:checkInventory()
end
end
end
local function actionInit()
local bind = {
name = 'SpiffUISmokeWheel',
key = Keyboard.KEY_BACK,
queue = true,
Down = SmokeDown,
Hold = SmokeHold,
Up = SmokeRelease
}
SpiffUI:AddKeyBind(bind)
end
actionInit()

View File

@@ -0,0 +1,599 @@
------------------------------------------
-- SpiffUI Radials Module
------------------------------------------
SpiffUI = SpiffUI or {}
-- Register our inventory
local spiff = SpiffUI:Register("radials")
local rOptions = {
consume = {
[1] = 1,
[2] = 0.5,
[3] = 0.25,
[4] = 0,
[5] = -1
},
craft = {
[1] = 0,
[2] = 1,
[3] = -1
}
}
------------------------------------------
-- Add functions
---- Used later
------------------------------------------
spiff.functions = {}
------------------------------------------
-- Main Functions
------------------------------------------
local function SpiffUIOnGameStart()
spiff.filters = {
smoke = {
["cigarettes"] = {
-- Smoker Homemade
["SMHomemadeCigarette2"] = "",
["SMHomemadeCigarette"] = "",
-- Smoker Cigs
["SMCigarette"] = "",
["SMCigaretteLight"] = "",
["SMPCigaretteMenthol"] = "",
["SMPCigaretteGold"] = "",
-- MCM Cigs
["CigsCigaretteReg"] = "",
["CigsCigaretteLite"] = "",
["CigsCigaretteReg"] = "",
["CigsCigaretteReg"] = "",
-- Greenfire Cigs
["GFCigarette"] = "",
},
["butts"] = {
-- Smoker Butts
["SMButt"] = "",
["SMButt2"] = "",
-- MCM Butts
["CigsButtReg"] = "",
["CigsButtLite"] = "",
["CigsButtMent"] = "",
["CigsButtGold"] = "",
},
["openedPacks"] = {
-- Smoker Open Pack
["SMPack"] = "SM.SMCigarette",
["SMPackLight"] = "SM.SMCigaretteLight",
["SMPackMenthol"] = "SM.SMPCigaretteMenthol",
["SMPackGold"] = "SM.SMPCigaretteGold",
-- MCM Open Pack
["CigsOpenPackReg"] = "Cigs.CigsCigaretteReg",
["CigsOpenPackLite"] = "Cigs.CigsCigaretteLite",
["CigsOpenPackMent"] = "Cigs.CigsCigaretteMent",
["CigsOpenPackGold"] = "Cigs.CigsCigaretteGold",
},
["closedIncompletePacks"] = {
-- Smoker Random Packs (Base.Cigarettes only)
-- MCM Random packs (also Base.Cigarettes)
["CigsSpawnPackLite"] = "Cigs.CigsOpenPackLite",
["CigsSpawnPackMent"] = "Cigs.CigsOpenPackMent",
["CigsSpawnPackGold"] = "Cigs.CigsOpenPackGold",
},
["closedPacks"] = {
--Smoker Full Pack
["SMFullPack"] = "SM.SMPack",
["SMFullPackLight"] = "SM.SMPackLight",
["SMFullPackMenthol"] = "SM.SMPackMenthol",
["SMFullPackGold"] = "SM.SMPackGold",
-- MCM Full Pack
["CigsClosedPackReg"] = "Cigs.CigsOpenPackReg",
["CigsClosedPackLite"] = "Cigs.CigsOpenPackLite",
["CigsClosedPackMent"] = "Cigs.CigsOpenPackMent",
["CigsClosedPackGold"] = "Cigs.CigsOpenPackGold",
--Greenfire Pack
["GFCigarettes"] = "Greenfire.GFCigarette",
},
["openedCartons"] = {
--Greenfire Cartons
["GFUsedCigaretteCarton"] = "Greenfire.GFCigarettes",
},
["cartons"] = {
--Smoker Carton
["SMCartonCigarettes"] = "SM.SMFullPack",
["SMCartonCigarettesLight"] = "SM.SMFullPackLight",
["SMCartonCigarettesMenthol"] = "SM.SMFullPackMenthol",
["SMCartonCigarettesGold"] = "SM.SMFullPackGold",
-- MCM Carton
["CigsCartonReg"] = "Cigs.CigsClosedPackReg",
["CigsCartonLite"] = "Cigs.CigsClosedPackLite",
["CigsCartonMent"] = "Cigs.CigsClosedPackMent",
["CigsCartonGold"] = "Cigs.CigsClosedPackGold",
--Greenfire Cartons
["GFCigaretteCarton"] = "Greenfire.GFCigarettes",
},
["gum"] = {
-- Smoker Gum
["SMGum"] = "",
},
["gumBlister"] = {
-- Smoker Gum pack
["SMNicorette"] = "SM.SMGum",
},
["gumPack"] = {
-- Smoker Gum Carton
["SMNicoretteBox"] = "SM.SMNicorette"
}
},
smokecraft = {
["Tobacco"] = "misc",
["Cannabis"] = "misc",
["CannabisShake"] = "misc",
["Hashish"] = "misc",
["CigarLeaf"] = "misc",
["SMPinchTobacco"] = "misc",
["SMSmallHandfulTobacco"] = "misc",
["SMHandfulTobacco"] = "misc",
["SMPileTobacco"] = "misc",
["SMBigPileTobacco"] = "misc",
["SMTobaccoPouches"] = "misc",
["FreshUnCanna"] = "misc",
["DryUnCanna"] = "misc",
["FreshTCanna"] = "misc",
["DryTCanna"] = "misc",
["FreshCannabisFanLeaf"] = "misc",
["DryCannabisFanLeaf"] = "misc",
["FreshCannabisSugarLeaf"] = "misc",
["DryCannabisSugarLeaf"] = "misc",
["CannaJar"] = "misc",
["CannaJar2"] = "misc",
["CannaJar3"] = "misc",
["CannaJar4"] = "misc",
["UnCannaJar"] = "misc",
["UnCannaJar2"] = "misc",
["UnCannaJar3"] = "misc",
["UnCannaJar4"] = "misc",
["Cannabis"] = "misc",
["OzCannabis"] = "misc",
["KgCannabis"] = "misc",
["CannabisShake"] = "misc",
["FreshBTobacco"] = "misc",
["DryBTobacco"] = "misc",
["SMSmokingBlend"] = "misc",
},
eat = {
["Cannabis"] = true
},
smokeables = {
["Bong"] = "misc",
["SmokingPipe"] = "misc",
["RollingPapers"] = "misc",
["GFGrinder"] = "misc",
["BluntWrap"] = "misc",
["SMFilter"] = "misc"
},
firstAid = {
["Bandage"] = true,
["Bandaid"] = true,
["RippedSheets"] = true,
["Disinfectant"] = true,
["Needle"] = true,
["Thread"] = true,
["SutureNeedle"] = true,
["Tweezers"] = true,
["SutureNeedleHolder"] = true,
["Splint"] = true,
["TreeBranch"] = true,
["WoodenStick"] = true,
["PlantainCataplasm"] = true,
["WildGarlicCataplasm"] = true,
["ComfreyCataplasm"] = true
},
firstAidCraft = {
["Bandage"] = true,
["BandageDirty"] = true,
["Bandaid"] = true,
["RippedSheets"] = true,
["RippedSheetsDirty"] = true,
["Disinfectant"] = true,
["Needle"] = true,
["Thread"] = true,
["SutureNeedle"] = true,
["Tweezers"] = true,
["SutureNeedleHolder"] = true,
["Splint"] = true,
["TreeBranch"] = true,
["WoodenStick"] = true,
["PlantainCataplasm"] = true,
["WildGarlicCataplasm"] = true,
["ComfreyCataplasm"] = true
}
}
-- Lets add the base Cigs
if getActivatedMods():contains('Smoker') then
spiff.filters.smoke["closedIncompletePacks"]["Cigarettes"] = "SM.SMPack"
elseif getActivatedMods():contains('MoreCigsMod') then
spiff.filters.smoke["closedIncompletePacks"]["Cigarettes"] = "Cigs.CigsOpenPackReg"
else
spiff.filters.smoke["cigarettes"]["Cigarettes"] = ""
end
-- Add Smokes to Smokeables
for i,_ in pairs(spiff.filters.smoke) do
for j,k in pairs(spiff.filters.smoke[i]) do
spiff.filters.smokeables[j] = k
end
end
-- Add Smoke Craft to Smokeables
for i,j in pairs(spiff.filters.smokecraft) do
spiff.filters.smokeables[i] = j
end
-- Add Smokes to Smoke Craft
for i,_ in pairs(spiff.filters.smoke) do
if not luautils.stringStarts(i, "gum") then
for j,_ in pairs(spiff.filters.smoke[i]) do
spiff.filters.smokecraft[j] = "cigs"
end
end
end
spiff.rFilters = {
smoke = {
butts = {
-- Smoker Butts
["SMButt"] = true,
["SMButt2"] = true,
-- MCM Butts
["CigsButtReg"] = true,
["CigsButtLite"] = true,
["CigsButtMent"] = true,
["CigsButtGold"] = true
},
gum = {
-- Smoker Gum
["SMGum"] = true,
-- Smoker Gum pack
["SMNicorette"] = true,
-- Smoker Gum Carton
["SMNicoretteBox"] = true
}
},
smokecraft = {
dismantle = {
["Unload"] = true,
["Dismantle"] = true,
["Break"] = true,
["Remove"] = true,
["Unpack"] = true
},
cigpacks = {
["Put"] = true,
["Take"] = true,
["Open"] = true,
["Close"] = true
},
always = {
["Convert"] = true
}
}
}
end
local function SpiffUIBoot()
spiff.config = {
showTooltips = true,
smokeShowButts = true,
smokeShowGum = true,
smokeCraftShowDismantle = true,
smokeCraftShowCigPacks = true,
smokeCraftAmount = -1,
craftShowEquipped = false,
craftShowSmokeables = false,
craftShowMedical = false,
craftAmount = -1,
craftSwitch = true,
craftFilterUnique = true,
equipShowDrop = true,
equipShowAllRepairs = false,
equipShowClothingActions = true,
equipShowRecipes = true,
repairShowEquipped = false,
repairShowHotbar = true,
firstAidCraftAmount = -1,
eatAmount = 0,
drinkAmount = 0,
eatQuickAmount = 1,
drinkQuickAmount = 1
}
if ModOptions and ModOptions.getInstance then
local function apply(data)
local options = data.settings.options
spiff.config.showTooltips = options.showTooltips
spiff.config.smokeShowNow = options.smokeShowNow
spiff.config.smokeShowButts = options.smokeShowButts
spiff.config.smokeShowGum = options.smokeShowGum
spiff.config.smokeCraftShowDismantle = options.smokeCraftShowDismantle
spiff.config.smokeCraftShowCigPacks = options.smokeCraftShowCigPacks
spiff.config.craftSwitch = options.craftSwitch
spiff.config.craftShowEquipped = options.craftShowEquipped
spiff.config.craftShowSmokeables = options.craftShowSmokeables
spiff.config.craftShowMedical = options.craftShowMedical
spiff.config.craftFilterUnique = options.craftFilterUnique
spiff.config.eatShowNow = options.eatShowNow
spiff.config.drinkShowNow = options.drinkShowNow
spiff.config.pillsShowNow = options.pillsShowNow
spiff.config.equipShowDrop = options.equipShowDrop
spiff.config.equipShowAllRepairs = options.equipShowAllRepairs
spiff.config.equipShowClothingActions = options.equipShowClothingActions
spiff.config.equipShowRecipes = options.equipShowRecipes
spiff.config.repairShowEquipped = options.repairShowEquipped
spiff.config.repairShowHotbar = options.repairShowHotbar
spiff.config.smokeCraftAmount = rOptions.craft[options.smokeCraftAmount]
spiff.config.craftAmount = rOptions.craft[options.craftAmount]
spiff.config.eatAmount = rOptions.consume[options.eatAmount]
spiff.config.eatQuickAmount = rOptions.consume[options.eatQuickAmount]
spiff.config.drinkAmount = rOptions.consume[options.drinkAmount]
spiff.config.drinkQuickAmount = rOptions.consume[options.drinkQuickAmount]
SpiffUI.equippedItem["Craft"] = not options.hideCraftButton
end
local function applyGame(data)
apply(data)
local options = data.settings.options
SpiffUI:updateEquippedItem()
end
local SETTINGS = {
options_data = {
showTooltips = {
name = "UI_ModOptions_SpiffUI_showTooltips",
default = true,
tooltip = getText("UI_ModOptions_SpiffUI_tooltip_showTooltips"),
OnApplyMainMenu = apply,
OnApplyInGame = apply,
},
hideCraftButton = {
name = "UI_ModOptions_SpiffUI_hideCraftButton",
default = true,
OnApplyMainMenu = apply,
OnApplyInGame = applyGame,
},
eatShowNow = {
name = "UI_ModOptions_SpiffUI_eatShowNow",
default = false,
tooltip = getText("UI_ModOptions_SpiffUI_tooltip_eatShowNow"),
OnApplyMainMenu = apply,
OnApplyInGame = apply,
},
eatAmount = {
getText("UI_amount_SpiffUI_One"), getText("UI_amount_SpiffUI_Half"),
getText("UI_amount_SpiffUI_Quarter"), getText("UI_amount_SpiffUI_Ask"),
getText("UI_amount_SpiffUI_Full"),
name = "UI_ModOptions_SpiffUI_eatAmount",
default = 4,
OnApplyMainMenu = apply,
OnApplyInGame = apply,
},
eatQuickAmount = {
getText("UI_amount_SpiffUI_One"), getText("UI_amount_SpiffUI_Half"),
getText("UI_amount_SpiffUI_Quarter"), getText("UI_amount_SpiffUI_Full"),
name = "UI_ModOptions_SpiffUI_eatQuickAmount",
default = 1,
OnApplyMainMenu = apply,
OnApplyInGame = apply,
},
drinkShowNow = {
name = "UI_ModOptions_SpiffUI_drinkShowNow",
default = false,
tooltip = getText("UI_ModOptions_SpiffUI_tooltip_drinkShowNow"),
OnApplyMainMenu = apply,
OnApplyInGame = apply,
},
drinkAmount = {
getText("UI_amount_SpiffUI_One"), getText("UI_amount_SpiffUI_Half"),
getText("UI_amount_SpiffUI_Quarter"), getText("UI_amount_SpiffUI_Ask"),
getText("UI_amount_SpiffUI_Full"),
name = "UI_ModOptions_SpiffUI_drinkAmount",
default = 4,
OnApplyMainMenu = apply,
OnApplyInGame = apply,
},
drinkQuickAmount = {
getText("UI_amount_SpiffUI_One"), getText("UI_amount_SpiffUI_Half"),
getText("UI_amount_SpiffUI_Quarter"), getText("UI_amount_SpiffUI_Full"),
name = "UI_ModOptions_SpiffUI_drinkQuickAmount",
default = 1,
OnApplyMainMenu = apply,
OnApplyInGame = apply,
},
pillsShowNow = {
name = "UI_ModOptions_SpiffUI_pillsShowNow",
default = false,
tooltip = getText("UI_ModOptions_SpiffUI_tooltip_pillsShowNow"),
OnApplyMainMenu = apply,
OnApplyInGame = apply,
},
smokeShowNow = {
name = "UI_ModOptions_SpiffUI_smokeShowNow",
default = false,
tooltip = getText("UI_ModOptions_SpiffUI_tooltip_smokeShowNow"),
OnApplyMainMenu = apply,
OnApplyInGame = apply,
},
smokeShowButts = {
name = "UI_ModOptions_SpiffUI_smokeShowButts",
default = true,
OnApplyMainMenu = apply,
OnApplyInGame = apply,
},
smokeShowGum = {
name = "UI_ModOptions_SpiffUI_smokeShowGum",
default = true,
OnApplyMainMenu = apply,
OnApplyInGame = apply,
},
smokeCraftShowDismantle = {
name = "UI_ModOptions_SpiffUI_smokeCraftShowDismantle",
default = true,
OnApplyMainMenu = apply,
OnApplyInGame = apply,
},
smokeCraftShowCigPacks = {
name = "UI_ModOptions_SpiffUI_smokeCraftShowCigPacks",
default = false,
OnApplyMainMenu = apply,
OnApplyInGame = apply,
},
smokeCraftAmount = {
getText("UI_amount_SpiffUI_One"), getText("UI_amount_SpiffUI_All"),
getText("UI_amount_SpiffUI_Ask"),
name = "UI_ModOptions_SpiffUI_smokeCraftAmount",
default = 3,
OnApplyMainMenu = apply,
OnApplyInGame = apply,
},
craftSwitch = {
name = "UI_ModOptions_SpiffUI_craftSwitch",
default = true,
tooltip = getText("UI_ModOptions_SpiffUI_tooltip_CraftingWheelSwitch"),
OnApplyMainMenu = apply,
OnApplyInGame = apply,
},
craftShowEquipped = {
name = "UI_ModOptions_SpiffUI_craftShowEquipped",
default = false,
tooltip = getText("UI_ModOptions_SpiffUI_tooltip_craftShowEquipped"),
OnApplyMainMenu = apply,
OnApplyInGame = apply,
},
craftShowSmokeables = {
name = "UI_ModOptions_SpiffUI_craftShowSmokeables",
default = false,
tooltip = getText("UI_ModOptions_SpiffUI_tooltip_craftShowSmokeables"),
OnApplyMainMenu = apply,
OnApplyInGame = apply,
},
craftShowMedical = {
name = "UI_ModOptions_SpiffUI_craftShowMedical",
default = false,
tooltip = getText("UI_ModOptions_SpiffUI_tooltip_craftShowMedical"),
OnApplyMainMenu = apply,
OnApplyInGame = apply,
},
craftFilterUnique = {
name = "UI_ModOptions_SpiffUI_craftFilterUnique",
default = true,
OnApplyMainMenu = apply,
OnApplyInGame = apply,
},
craftAmount = {
getText("UI_amount_SpiffUI_One"), getText("UI_amount_SpiffUI_All"),
getText("UI_amount_SpiffUI_Ask"),
name = "UI_ModOptions_SpiffUI_craftAmount",
default = 3,
OnApplyMainMenu = apply,
OnApplyInGame = apply,
},
equipShowDrop = {
name = "UI_ModOptions_SpiffUI_equipShowDrop",
default = true,
OnApplyMainMenu = apply,
OnApplyInGame = apply,
},
equipShowAllRepairs = {
name = "UI_ModOptions_SpiffUI_equipShowAllRepairs",
default = false,
tooltip = getText("UI_ModOptions_SpiffUI_tooltip_equipShowAllRepairs"),
OnApplyMainMenu = apply,
OnApplyInGame = apply,
},
equipShowClothingActions = {
name = "UI_ModOptions_SpiffUI_equipShowClothingActions",
default = true,
OnApplyMainMenu = apply,
OnApplyInGame = apply,
},
equipShowRecipes = {
name = "UI_ModOptions_SpiffUI_equipShowRecipes",
default = true,
OnApplyMainMenu = apply,
OnApplyInGame = apply,
},
repairShowEquipped = {
name = "UI_ModOptions_SpiffUI_repairShowEquipped",
default = false,
tooltip = getText("UI_ModOptions_SpiffUI_tooltip_repairShowEquipped"),
OnApplyMainMenu = apply,
OnApplyInGame = apply,
},
repairShowHotbar = {
name = "UI_ModOptions_SpiffUI_repairShowHotbar",
default = true,
OnApplyMainMenu = apply,
OnApplyInGame = apply,
},
firstAidCraftAmount = {
getText("UI_amount_SpiffUI_One"), getText("UI_amount_SpiffUI_All"),
getText("UI_amount_SpiffUI_Ask"),
name = "UI_ModOptions_SpiffUI_firstAidCraftAmount",
default = 3,
OnApplyMainMenu = apply,
OnApplyInGame = apply
}
},
mod_id = "SpiffUI-Rads",
mod_shortname = "SpiffUI-Rads",
mod_fullname = getText("UI_Name_SpiffUI_Radials")
}
local oInstance = ModOptions:getInstance(SETTINGS)
ModOptions:loadFile()
Events.OnPreMapLoad.Add(function()
apply({settings = SETTINGS})
end)
end
spiff.icons = {
[1] = getTexture("media/SpiffUI/1.png"),
[2] = getTexture("media/SpiffUI/1-2.png"),
[3] = getTexture("media/SpiffUI/1-4.png"),
[4] = getTexture("media/SpiffUI/ALL.png"),
[5] = getTexture("media/SpiffUI/FULL.png"),
["unequip"] = getTexture("media/ui/Icon_InventoryBasic.png"),
["drop"] = getTexture("media/ui/Container_Floor.png")
}
SpiffUI:AddKeyDisable("Toggle Inventory")
SpiffUI:AddKeyDisable("Crafting UI")
SpiffUI:AddKeyDisable("SpiffUI_Inv")
SpiffUI:AddKeyDisable("NF Smoke")
SpiffUI:AddKeyDefault("Toggle Moveable Panel Mode", 0)
SpiffUI:AddKeyDefault("Display FPS", 0)
print(getText("UI_Hello_SpiffUI_Radials"))
end
spiff.Boot = SpiffUIBoot
spiff.Start = SpiffUIOnGameStart

View File

@@ -0,0 +1,22 @@
------------------------------------------
-- SpiffUI Clothing Extra Action override
---- Adds time to the Clothing Extra Action
------------------------------------------
-- This is included with the Clothing Actions Radial Menu already
if getActivatedMods():contains('ClothingActionsRM') then return end
-- 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.stopOnAim = false
o.stopOnWalk = false
o.stopOnRun = true
o.maxTime = 25
o.useProgressBar = false
if o.character:isTimedActionInstant() then
o.maxTime = 1
end
return o
end

View File

@@ -0,0 +1,11 @@
------------------------------------------
-- SpiffUI ISFixAction
---- Adds an animation to ISFixAction
------------------------------------------
local _ISFixAction_start = ISFixAction.start
function ISFixAction:start()
_ISFixAction_start(self)
self:setActionAnim(CharacterActionAnims.Craft)
end

View File

@@ -0,0 +1,15 @@
------------------------------------------
-- SpiffUI ISWearClothing
---- Allows you to walk and put on clothes that makes sense
------------------------------------------
local _ISWearClothing_new = ISWearClothing.new
function ISWearClothing:new(...)
local o = _ISWearClothing_new(self, ...)
o.stopOnAim = false
o.stopOnWalk = false
o.stopOnRun = true
return o
end

View File

@@ -0,0 +1,119 @@
UI_EN = {
-- SpiffUI
UI_Hello_SpiffUI = "Hello SpiffUI!",
UI_Name_SpiffUI = "SpiffUI",
UI_optionscreen_binding_SpiffUI = "SpiffUI"
UI_ModOptions_SpiffUI_applyNewKeybinds = "Set SpiffUI Recommended Keybinds",
UI_ModOptions_SpiffUI_Modal_applyNewKeybinds = "<CENTRE><SIZE:medium> Set SpiffUI Keybinds <LINE><LINE><LEFT><SIZE:small> Sets the following Keybinds: <LINE>",
UI_ModOptions_SpiffUI_Modal_aNKChild = " <LINE> %1 to: [%2] ",
UI_ModOptions_SpiffUI_runAllResets = "Run All SpiffUI Resets",
UI_ModOptions_SpiffUI_tooltip_runResets = "Only works In-Game!",
UI_ModOptions_SpiffUI_Modal_runResets = "<CENTRE><SIZE:medium> SpiffUI Reset <LINE><LINE><LEFT><SIZE:small> The following will be reset: <LINE>",
-- SpiffUI -- Radials
UI_Hello_SpiffUI_Radials = "Hello SpiffUI - Radials",
UI_Name_SpiffUI_Radials = "SpiffUI - Radials",
UI_ModOptions_SpiffUI_showTooltips = "Show Tooltips",
UI_ModOptions_SpiffUI_hideCraftButton = "Hide Crafting Button",
UI_ModOptions_SpiffUI_smokeShowButts = "Show Cigarette Butts (Smoke)",
UI_ModOptions_SpiffUI_smokeShowGum = "Show Gum (Smoke)",
UI_ModOptions_SpiffUI_smokeShowNow = "Show Radial on Press (Smoke)",
UI_ModOptions_SpiffUI_pillsShowNow = "Show Radial on Press (Pills)",
UI_ModOptions_SpiffUI_eatAmount = "Amount to Eat (Food)",
UI_ModOptions_SpiffUI_eatQuickAmount = "Amount to Quick Eat (Food)",
UI_ModOptions_SpiffUI_eatShowNow = "Show Radial on Press (Food)",
UI_ModOptions_SpiffUI_drinkAmount = "Amount to Drink (Drink)",
UI_ModOptions_SpiffUI_drinkQuickAmount = "Amount to Quick Drink (Drink)",
UI_ModOptions_SpiffUI_drinkShowNow = "Show Radial on Press (Drink)",
UI_ModOptions_SpiffUI_smokeCraftShowDismantle = "Show Dismantle Recipes (Smoke Craft)",
UI_ModOptions_SpiffUI_smokeCraftShowCigPacks = "Show Cigarette Packs (Smoke Craft)",
UI_ModOptions_SpiffUI_smokeCraftAmount = "Amount To Craft (Smoke Craft)",
UI_ModOptions_SpiffUI_craftSwitch = "Show on Press (Crafting)",
UI_ModOptions_SpiffUI_craftShowEquipped = "Show Recipes on Equipped Items (Crafting)",
UI_ModOptions_SpiffUI_craftShowSmokeables = "Show Smokeable Recipes (Crafting)",
UI_ModOptions_SpiffUI_craftShowMedical = "Show Medical Recipes (Crafting)",
UI_ModOptions_SpiffUI_craftAmount = "Amount To Craft (Crafting)",
UI_ModOptions_SpiffUI_craftFilterUnique = "Filter Duplicate Recipes (Crafting)",
UI_ModOptions_SpiffUI_equipShowDrop = "Show Drop Action (Equipment)",
UI_ModOptions_SpiffUI_equipShowAllRepairs = "Show Unavailable Repair Options (Equipment)",
UI_ModOptions_SpiffUI_equipShowClothingActions = "Show Extra Clothing Actions (Equipment)",
UI_ModOptions_SpiffUI_equipShowRecipes = "Show Recipes (Equipment)",
UI_ModOptions_SpiffUI_repairShowEquipped = "Show Repairs on Equipped Items (Repair)",
UI_ModOptions_SpiffUI_repairShowHotbar = "Show Repairs for Items in Hotbar (Repair)",
UI_ModOptions_SpiffUI_firstAidCraftAmount = "Amount to Craft (Medical Craft)",
UI_ModOptions_SpiffUI_tooltip_showTooltips = "Show Tooltips in Radial Menus for Items, Recipes, and Repairs (Recommended)",
UI_ModOptions_SpiffUI_tooltip_pillsShowNow = "Note: Disables Quick Pills Action",
UI_ModOptions_SpiffUI_tooltip_drinkShowNow = "Note: Disables Quick Drink Water Action",
UI_ModOptions_SpiffUI_tooltip_eatShowNow = "Note: Disables Quick Eat Food Action",
UI_ModOptions_SpiffUI_tooltip_craftShowMedical = "Note: Some Recipes may still filter through. Consider using the First Aid Crafting Menu instead!",
UI_ModOptions_SpiffUI_tooltip_craftShowEquipped = "Note: Recipes on worn items can be done from the Equipment Menu. Items in your hand will still show recipes",
UI_ModOptions_SpiffUI_tooltip_craftShowSmokeables = "Consider using the Smoke Crafting Menu instead!"
UI_ModOptions_SpiffUI_tooltip_smokeShowNow = "Note: Disables AutoSmoke Quick Smoke",
UI_ModOptions_SpiffUI_tooltip_CraftingWheelSwitch = "Press Opens Radial Menu, Hold for Crafting Window",
UI_ModOptions_SpiffUI_tooltip_equipShowAllRepairs = "Show Repair Options even if the required items are not in your inventory",
UI_ModOptions_SpiffUI_tooltip_repairShowEquipped = "Repairs for Equipment can be done from the Equipment Menu",
UI_amount_SpiffUI_Ask = "Ask",
UI_amount_SpiffUI_All = "All",
UI_amount_SpiffUI_Full = "Dieter",
UI_amount_SpiffUI_One = "1",
UI_amount_SpiffUI_Half = "1/2",
UI_amount_SpiffUI_Quarter = "1/4",
UI_radial_SpiffUI_Accessories = "Accessories",
UI_radial_SpiffUI_Hotbar = "Hotbar",
UI_radial_SpiffUI_Transfer = "Transfer to ",
UI_optionscreen_binding_SpiffUIPillWheel = "Pill Radial",
UI_optionscreen_binding_SpiffUIDrinkWheel = "Drink Radial",
UI_optionscreen_binding_SpiffUIEatWheel = "Eat Radial",
UI_optionscreen_binding_SpiffUISmokeWheel = "Smoke Radial",
UI_optionscreen_binding_SpiffUISmokeCraftWheel = "Smoke Craft Radial",
UI_optionscreen_binding_SpiffUICraftWheel = "Crafting UI/Radial",
UI_optionscreen_binding_SpiffUIEquipmentWheel = "Inventory Toggle/Radial",
UI_optionscreen_binding_SpiffUIRepairWheel = "Repair Radial",
UI_optionscreen_binding_SpiffUIFirstAidCraftWheel = "First Aid Craft",
UI_optionscreen_binding_SpiffUIOneWheel = "SpiffUI Radial",
UI_character_SpiffUI_noLighter = "I need a lighter.",
UI_character_SpiffUI_noSmokes = "There's nothing to Smoke.",
UI_character_SpiffUI_noCraft = "There's nothing to Craft.",
UI_character_SpiffUI_noEquip = "I am Naked!",
UI_character_SpiffUI_notHungry = "I'm not Hungry.",
UI_character_SpiffUI_noFood = "There's no Food to Eat.",
UI_character_SpiffUI_notThirsty = "I'm not Thirsty.",
UI_character_SpiffUI_noDrinks = "There's nothing to Drink.",
UI_character_SpiffUI_noRepair = "There's nothing to Repair.",
UI_character_SpiffUI_noRepairItems = "I can't Reapir that.",
UI_character_SpiffUI_noPillsQuick = "I have no ",
UI_character_SpiffUI_noPills = "There's no pills",
UI_character_SpiffUI_noPillsNeed = "I'm not in any Mood."
}

View File

@@ -0,0 +1,122 @@
UI_RU = {
-- Translation By: fourteensix
-- Перевод: fourteensix
-- SpiffUI Radial
UI_Hello_SpiffUI = "Hello SpiffUI!",
UI_Name_SpiffUI = "SpiffUI",
UI_optionscreen_binding_SpiffUI = "SpiffUI"
UI_ModOptions_SpiffUI_applyNewKeybinds = "Установите рекомендуемые сочетания клавиш SpiffUI",
UI_ModOptions_SpiffUI_Modal_applyNewKeybinds = "<CENTRE><SIZE:medium> Установить привязки клавиш SpiffUI <LINE><LINE><LEFT><SIZE:small> Устанавливает следующие сочетания клавиш: <LINE>",
UI_ModOptions_SpiffUI_Modal_aNKChild = " <LINE> %1 для: [%2] ",
UI_ModOptions_SpiffUI_runAllResets = "Запустить полный сброс SpiffUI",
UI_ModOptions_SpiffUI_tooltip_runResets = "Работает только в игре!",
UI_ModOptions_SpiffUI_Modal_runResets = "<CENTRE><SIZE:medium> Сброс SpiffUI <LINE><LINE><LEFT><SIZE:small> Будет сброшено следующее: <LINE>",
-- SpiffUI -- Radials
UI_Hello_SpiffUI_Radials = "Hello SpiffUI - Radials",
UI_Name_SpiffUI_Radials = "SpiffUI - Radials",
UI_ModOptions_SpiffUI_showTooltips = "Показать подсказки",
UI_ModOptions_SpiffUI_hideCraftButton = "Скрыть кнопку крафта",
UI_ModOptions_SpiffUI_smokeShowButts = "Показать окурки (мод Smoke)",
UI_ModOptions_SpiffUI_smokeShowGum = "Показать жвачку (мод Smoke)",
UI_ModOptions_SpiffUI_smokeShowNow = "Показать радиальное меню при нажатии (мод Smoke)",
UI_ModOptions_SpiffUI_pillsShowNow = "Показать радиальное меню при нажатии (Таблетки)",
UI_ModOptions_SpiffUI_eatAmount = "Количество еды (Еда)",
UI_ModOptions_SpiffUI_eatQuickAmount = "Количество еды для быстрого перекуса (Еда)",
UI_ModOptions_SpiffUI_eatShowNow = "Показать радиальное меню при нажатии (Еда)",
UI_ModOptions_SpiffUI_drinkAmount = "Количество питья (Напитки)",
UI_ModOptions_SpiffUI_drinkQuickAmount = "Количество напитка для быстрого удаления жажды (Напитки)",
UI_ModOptions_SpiffUI_drinkShowNow = "Показать радиальное меню при нажатии (Напитки)",
UI_ModOptions_SpiffUI_smokeCraftShowDismantle = "Показать рецепты разборки (крафт мода Smoke)",
UI_ModOptions_SpiffUI_smokeCraftShowCigPacks = "Показать пачки сигарет (крафт мода Smoke)",
UI_ModOptions_SpiffUI_smokeCraftAmount = "Количество для создания (крафт мода Smoke)",
UI_ModOptions_SpiffUI_craftSwitch = "Показать радиальное меню при нажатии (Крафт)",
UI_ModOptions_SpiffUI_craftShowEquipped = "Показать рецепты на экипированных предметах (Крафт)",
UI_ModOptions_SpiffUI_craftShowSmokeables = "Показать рецепты для курения (Крафт)",
UI_ModOptions_SpiffUI_craftShowMedical = "Показать медицинские рецепты (Крафт)",
UI_ModOptions_SpiffUI_craftAmount = "Количество для крафта (Крафт)",
UI_ModOptions_SpiffUI_craftFilterUnique = "Фильтр повторяющихся рецептов (Крафт)",
UI_ModOptions_SpiffUI_equipShowDrop = "Показать действие дропа (Экипировка)",
UI_ModOptions_SpiffUI_equipShowAllRepairs = "Показать недоступные параметры ремонта (Экипировка)",
UI_ModOptions_SpiffUI_equipShowClothingActions = "Показать действия с дополнительной одеждой (Экипировка)",
UI_ModOptions_SpiffUI_equipShowRecipes = "Показать рецепты (Экипировка)",
UI_ModOptions_SpiffUI_repairShowEquipped = "Показать ремонт экипированных предметов (Ремонт)",
UI_ModOptions_SpiffUI_repairShowHotbar = "Показать ремонт предметов в хотбаре (Ремонт)",
UI_ModOptions_SpiffUI_firstAidCraftAmount = "Количество для крафта (Крафт медикаментов)",
UI_ModOptions_SpiffUI_tooltip_showTooltips = "Показывать всплывающие подсказки в радиальных меню для предметов, рецептов и ремонтов (Рекомендуется)",
UI_ModOptions_SpiffUI_tooltip_pillsShowNow = "Примечание: отключает действие *Быстрые таблетки*",
UI_ModOptions_SpiffUI_tooltip_drinkShowNow = "Примечание: отключает действие *Быстрое питьё воды*",
UI_ModOptions_SpiffUI_tooltip_eatShowNow = "Примечание: отключает действие *Быстро съесть еду*",
UI_ModOptions_SpiffUI_tooltip_craftShowMedical = "Примечание: некоторые рецепты могут по-прежнему фильтроваться. Вместо этого рассмотрите возможность использования меню крафта первой помощи!",
UI_ModOptions_SpiffUI_tooltip_craftShowEquipped = "Примечание: рецепты на изношенные предметы можно сделать из меню снаряжения. Предметы в вашей руке по-прежнему будут показывать рецепты",
UI_ModOptions_SpiffUI_tooltip_craftShowSmokeables = "Вместо этого рассмотрите возможность использования меню крафта мода Smoke!"
UI_ModOptions_SpiffUI_tooltip_smokeShowNow = "Примечание: отключает мод AutoSmoke для быстрого курения",
UI_ModOptions_SpiffUI_tooltip_CraftingWheelSwitch = "Нажмите, чтобы открыть радиальное меню, удерживайте, чтобы открыть окно крафта",
UI_ModOptions_SpiffUI_tooltip_equipShowAllRepairs = "Показать параметры ремонта, даже если требуемых предметов нет в вашем инвентаре",
UI_ModOptions_SpiffUI_tooltip_repairShowEquipped = "Ремонт снаряжения можно выполнить из меню снаряжения.",
UI_amount_SpiffUI_Ask = "Спросить",
UI_amount_SpiffUI_All = "Всё",
UI_amount_SpiffUI_Full = "Диетолог",
UI_amount_SpiffUI_One = "1",
UI_amount_SpiffUI_Half = "1/2",
UI_amount_SpiffUI_Quarter = "1/4",
UI_radial_SpiffUI_Accessories = "Аксессуары",
UI_radial_SpiffUI_Hotbar = "Хотбар",
UI_radial_SpiffUI_Transfer = "Переместить на ",
UI_optionscreen_binding_SpiffUIPillWheel = "Таблетки в меню",
UI_optionscreen_binding_SpiffUIDrinkWheel = "Напитки в меню",
UI_optionscreen_binding_SpiffUIEatWheel = "Еда в меню",
UI_optionscreen_binding_SpiffUISmokeWheel = "Курение в меню",
UI_optionscreen_binding_SpiffUISmokeCraftWheel = "Крафт мода Smoke в меню",
UI_optionscreen_binding_SpiffUICraftWheel = "Интерфейс крафта/радиальное меню",
UI_optionscreen_binding_SpiffUIEquipmentWheel = "Переключатель инвентаря/Радиальное меню",
UI_optionscreen_binding_SpiffUIRepairWheel = "Ремонт в радиальном меню",
UI_optionscreen_binding_SpiffUIFirstAidCraftWheel = "Крафт для первой помощи",
UI_optionscreen_binding_SpiffUIOneWheel = "SpiffUI Радиальное меню",
UI_character_SpiffUI_noLighter = "Мне нужна зажигалка.",
UI_character_SpiffUI_noSmokes = "Нечего курить.",
UI_character_SpiffUI_noCraft = "Крафтить нечего.",
UI_character_SpiffUI_noEquip = "Я Голый!",
UI_character_SpiffUI_notHungry = "Я не голоден.",
UI_character_SpiffUI_noFood = "Нет еды, чтобы поесть.",
UI_character_SpiffUI_notThirsty = "Я не хочу пить.",
UI_character_SpiffUI_noDrinks = "Пить нечего.",
UI_character_SpiffUI_noRepair = "Ремонтировать нечего.",
UI_character_SpiffUI_noRepairItems = "Я не могу отремонтировать это.",
UI_character_SpiffUI_noPillsQuick = "У меня нет ",
UI_character_SpiffUI_noPills = "Нет таблеток",
UI_character_SpiffUI_noPillsNeed = "Я не в настроении.",
}

View File

@@ -0,0 +1,10 @@
name=SpiffUI - Radials
id=SpiffUI-Rads
authors=dhert
description=Adds a bunch of Radial Menus for various things
pzversion=41
tags=Interface;Framework;Misc
poster=poster.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 188 KiB