Update All of the mods to the latest versions

This commit is contained in:
hlfstr
2022-12-23 01:26:54 -06:00
parent 15c7f6d92b
commit 5d5972ec3b
164 changed files with 185630 additions and 445 deletions

View File

@@ -0,0 +1,661 @@
------------------------------------------
-- 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 = 3 --<<< 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
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
if bind.allowPause or not (UIManager.getSpeedControls() and (UIManager.getSpeedControls():getCurrentGameSpeed() == 0)) then
bind.Down(player)
end
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
if bind.allowPause or not (UIManager.getSpeedControls() and (UIManager.getSpeedControls():getCurrentGameSpeed() == 0)) then
bind.Hold(player)
end
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
if bind.allowPause or not (UIManager.getSpeedControls() and (UIManager.getSpeedControls():getCurrentGameSpeed() == 0)) then
bind.Up(player)
end
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:undisplay()
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,
["QOLEquip"] = 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()
-- Add support for the QOL Equipment mod's icon
SpiffUI.equippedItem["QOLEquip"] = (SETTINGS_QOLMT and SETTINGS_QOLMT.options and SETTINGS_QOLMT.options.useIcon) or false
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
-- Add support for the QOL Equipment mod's icon
elseif i == "QOLEquip" and player.equipped.equipButton then
player.equipped.equipButton:setVisible(v)
player.equipped.equipButton:setY(y)
if v then
y = player.equipped.equipButton:getY() + player.equipped.equipmentIconOFF: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
if isDebugEnabled() then
SpiffUI.config.debug = options.debug
else
SpiffUI.config.debug = false
end
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")
}
if isDebugEnabled() then
SPIFFCONFIG.options_data.debug = {
name = "Enable Debug",
default = false,
OnApplyMainMenu = apply,
OnApplyInGame = apply
}
end
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
-- Adapted from: https://www.rosettacode.org/wiki/Word_wrap#Lua
SpiffUI.textwrap = function(text, linewidth)
-- if its already wrapped, do nothing
if text:contains("\n") then
return text
end
local function splittokens(s)
local res = {}
for w in s:gmatch("%S+") do
res[#res+1] = w
end
return res
end
if not linewidth then
linewidth = 75
end
local spaceleft = linewidth
local res = {}
local line = {}
for _, word in ipairs(splittokens(text)) do
if #word + 1 > spaceleft then
table.insert(res, table.concat(line, ' '))
line = {word}
spaceleft = linewidth - #word
else
table.insert(line, word)
spaceleft = spaceleft - (#word + 1)
end
end
table.insert(res, table.concat(line, ' '))
return table.concat(res, '\n')
end
------------------------------------------
Events.OnGameBoot.Add(SpiffUI.firstBoot)
-- Hello SpiffUI :)
print(getText("UI_Hello_SpiffUI"))

View File

@@ -0,0 +1,139 @@
------------------------------------------
-- spiff
--- ISButton
------------------------------------------
SpiffUI = SpiffUI or {}
-- Register our Radials
local spiff = SpiffUI:Register("themes")
local _ISButton_setEnable = ISButton.setEnable
function ISButton:setEnable(bEnabled)
if not spiff.config.enabled then
_ISButton_setEnable(self, bEnabled)
return
end
self.enable = bEnabled;
if not self.borderColorEnabled then
self.borderColorEnabled = { r = self.borderColor.r, g = self.borderColor.g, b = self.borderColor.b, a = self.borderColor.a }
end
if bEnabled then
self:setTextureRGBA(1, 1, 1, 1)
self:setBorderRGBA(
self.borderColorEnabled.r,
self.borderColorEnabled.g,
self.borderColorEnabled.b,
self.borderColorEnabled.a)
else
self:setTextureRGBA(0.3, 0.3, 0.3, 1.0)
--self:setBorderRGBA(0.7, 0.1, 0.1, 0.7)
end
end
local _ISButton_render = ISButton.render
function ISButton:render()
if not spiff.config.enabled then
_ISButton_render(self)
return
end
if self.image ~= nil then
local alpha = self.textureColor.a;
if self.blinkImage then
if not self.blinkImageAlpha then
self.blinkImageAlpha = 1;
self.blinkImageAlphaIncrease = false;
end
if not self.blinkImageAlphaIncrease then
self.blinkImageAlpha = self.blinkImageAlpha - 0.1 * (UIManager.getMillisSinceLastRender() / 33.3);
if self.blinkImageAlpha < 0 then
self.blinkImageAlpha = 0;
self.blinkImageAlphaIncrease = true;
end
else
self.blinkImageAlpha = self.blinkImageAlpha + 0.1 * (UIManager.getMillisSinceLastRender() / 33.3);
if self.blinkImageAlpha > 1 then
self.blinkImageAlpha = 1;
self.blinkImageAlphaIncrease = false;
end
end
alpha = self.blinkImageAlpha;
end
if self.forcedWidthImage and self.forcedHeightImage then
self:drawTextureScaledAspect(self.image, (self.width / 2) - (self.forcedWidthImage / 2), (self.height / 2) - (self.forcedHeightImage / 2),self.forcedWidthImage,self.forcedHeightImage, alpha, self.textureColor.r, self.textureColor.g, self.textureColor.b);
elseif self.image:getWidthOrig() <= self.width and self.image:getHeightOrig() <= self.height then
self:drawTexture(self.image, (self.width / 2) - (self.image:getWidthOrig() / 2), (self.height / 2) - (self.image:getHeightOrig() / 2), alpha, self.textureColor.r, self.textureColor.g, self.textureColor.b);
else
self:drawTextureScaledAspect(self.image, 0, 0, self.width, self.height, alpha, self.textureColor.r, self.textureColor.g, self.textureColor.b);
end
end
local textW = getTextManager():MeasureStringX(self.font, self.title)
local height = getTextManager():MeasureStringY(self.font, self.title)
local x = self.width / 2 - textW / 2;
if self.isJoypad and self.joypadTexture then
local texWH = self.joypadTextureWH
local texX = x - 5 - texWH
local texY = self.height / 2 - 20 / 2
texX = math.max(5, texX)
x = texX + texWH + 5
self:drawTextureScaled(self.joypadTexture,texX,texY,texWH,texWH,1,1,1,1);
end
if self.enable then
self:drawText(self.title, x, (self.height / 2) - (height/2) + self.yoffset, self.textColor.r, self.textColor.g, self.textColor.b, self.textColor.a, self.font);
elseif self.displayBackground and not self.isJoypad and self.joypadFocused then
self:drawText(self.title, x, (self.height / 2) - (height/2) + self.yoffset, self.stextColor.r, self.stextColor.g, self.stextColor.b, self.stextColor.a, self.font);
else
self:drawText(self.title, x, (self.height / 2) - (height/2) + self.yoffset, self.stextColor.r, self.stextColor.g, self.stextColor.b, self.stextColor.a, self.font);
end
if self.overlayText then
self:drawTextRight(self.overlayText, self.width, self.height - 10, self.textColor.r, self.textColor.g, self.textColor.b, 0.5, UIFont.Small);
end
-- call the onMouseOverFunction
if (self.mouseOver and self.onmouseover) then
self.onmouseover(self.target, self, x, y);
end
if self.textureOverride then
self:drawTexture(self.textureOverride, (self.width /2) - (self.textureOverride:getWidth() / 2), (self.height /2) - (self.textureOverride:getHeight() / 2), 1, 1, 1, 1);
end
if false and self.mouseOver and self.tooltip then
self:drawRect(self:getMouseX() + 23, self:getMouseY() + 23, getTextManager():MeasureStringX(UIFont.Small, self.tooltip) + 24, 32+24, self.backgroundColor.r, self.backgroundColor.g, self.backgroundColor.b, self.backgroundColor.a);
self:drawRectBorder(self:getMouseX() + 23, self:getMouseY() + 23, getTextManager():MeasureStringX(UIFont.Small, self.tooltip) + 24, 32+24, self.borderColor.r, self.borderColor.g, self.borderColor.b, self.borderColor.a);
self:drawText(self.tooltip, self:getMouseX() + 23 + 12, self:getMouseY() + 23 + 12, self.textColor.r, self.textColor.g, self.textColor.b, self.textColor.a);
end
end
--local _ISButton_createChildren = ISButton.createChildren
function ISButton:createChildren()
--_ISButton_createChildren(self)
if not spiff.config.enabled then
return
end
-- o.borderColor = {r=0.7, g=0.7, b=0.7, a=1};
-- o.backgroundColor = {r=0, g=0, b=0, a=1.0};
-- o.backgroundColorMouseOver = {r=0.3, g=0.3, b=0.3, a=1.0}
local theme = spiff.GetTheme()
self.backgroundColor = spiff.GetColor(theme.Background.Option)
if spiff.config.Theme == "Project Zomboid" then
self.backgroundColorMouseOver = {r=0.3, g=0.3, b=0.3, a=1.0}
self.backgroundColorPressed = spiff.GetColorMod(self.backgroundColorMouseOver, 0.5)
else
self.backgroundColorMouseOver = spiff.GetColorMod(theme.Background.Option, 2)
self.backgroundColorPressed = spiff.GetColorMod(theme.Background.Option, 0.5)
end
self.borderColor = spiff.GetColor(theme.Border.Option)
self.textColor = spiff.GetColor(theme.Text.Option)
self.stextColor = spiff.GetColor(theme.Text.Secondary)
if self.image or self.textureOverride then
self.backgroundColor.a = 0
self.borderColor.a = 0
end
end

View File

@@ -0,0 +1,50 @@
SpiffUI = SpiffUI or {}
-- Register our Radials
local spiff = SpiffUI:Register("themes")
local _ISCollapsableWindow_createChildren = ISCollapsableWindow.createChildren
function ISCollapsableWindow:createChildren()
_ISCollapsableWindow_createChildren(self)
if not spiff.config.enabled then
return
end
local theme = spiff.GetTheme()
self.backgroundColor = spiff.GetColor(theme.Background.Primary)
self.borderColor = spiff.GetColor(theme.Border.Primary)
self.hborderColor = spiff.GetColor(theme.Border.Header)
self.hbackgroundColor = spiff.GetColor(theme.Background.Header)
--o.widgetTextureColor = {r = 1, g = 0, b = 0, a = 1};
return o
end
function ISCollapsableWindow:prerender()
local height = self:getHeight();
local th = self:titleBarHeight()
if self.isCollapsed then
height = th;
end
if self.drawFrame then
self:drawRect(0, 0, self:getWidth(), th, self.hbackgroundColor.a, self.hbackgroundColor.r, self.hbackgroundColor.g, self.hbackgroundColor.b);
--self:drawTextureScaled(self.titlebarbkg, 2, 1, self:getWidth() - 4, th - 2, 1, 1, 1, 1);
self:drawRectBorder(0, 0, self:getWidth(), th, self.hborderColor.a, self.hborderColor.r, self.hborderColor.g, self.hborderColor.b);
end
if self.background and not self.isCollapsed then
local rh = self:resizeWidgetHeight()
if not self.resizable or not self.resizeWidget:getIsVisible() then rh = 0 end
self:drawRect(0, th, self:getWidth(), self.height - th - rh, self.backgroundColor.a, self.backgroundColor.r, self.backgroundColor.g, self.backgroundColor.b);
end
if self.clearStentil then
self:setStencilRect(0,0,self.width, height);
end
if self.title ~= nil and self.drawFrame then
self:drawTextCentre(self.title, self:getWidth() / 2, 1, 1, 1, 1, 1, self.titleBarFont);
end
end

View File

@@ -0,0 +1,18 @@
SpiffUI = SpiffUI or {}
-- Register our Radials
local spiff = SpiffUI:Register("themes")
local _ISDuplicateKeybindDialog_createChildren = ISDuplicateKeybindDialog.createChildren
function ISDuplicateKeybindDialog:createChildren()
_ISDuplicateKeybindDialog_createChildren(self)
if not spiff.config.enabled then
return
end
local theme = spiff.GetTheme()
self.clear.borderColor = spiff.GetColor(theme.Border.Option)
self.keep.borderColor = spiff.GetColor(theme.Border.Option)
self.cancel.borderColor = spiff.GetColor(theme.Border.Option)
end

View File

@@ -0,0 +1,20 @@
SpiffUI = SpiffUI or {}
-- Register our Radials
local spiff = SpiffUI:Register("themes")
local _ISHotbar_createChildren = ISHotbar.createChildren
function ISHotbar:createChildren()
_ISHotbar_createChildren(self)
if not spiff.config.enabled then
return
end
local theme = spiff.GetTheme()
self.backgroundColor = spiff.GetColor(theme.Background.Primary)
self.backgroundColor.a = self.backgroundColor.a/2
self.borderColor = spiff.GetColor(theme.Border.Option)
self.textColor = spiff.GetColor(theme.Text.Primary)
end

View File

@@ -0,0 +1,214 @@
-- Add module
SpiffUI = SpiffUI or {}
-- Register our Radials
local spiff = SpiffUI:Register("themes")
--- 1 loot/transfer button
--- 2 oven button (turn on)
--- 3 - 5 custom buttons
function ISInventoryPage:getBestButtonX(num)
-- idk man, people try things
if num > 5 then
num = 5
end
if num < 1 then
num = 1
end
return self.buttonsX[num]
end
function ISInventoryPage:RegisterButton(extra)
if not extra then
return
end
if not self.headerButtons then
self.headerButtons = {}
end
table.insert(self.headerButtons, extra)
end
function ISInventoryPage:syncButtonsLoc()
local visible = 1
if not self.onCharacter then
if self.lootAll:isVisible() then
self.lootAll:setX(self:getBestButtonX(visible))
--print("Setting lootAll to: " .. self:getBestButtonX(visible))
visible = visible + 1
end
if self.removeAll:isVisible() then
self.removeAll:setX(self:getBestButtonX(visible))
--print("Setting removeAll to: " .. self:getBestButtonX(visible))
visible = visible + 1
end
if self.toggleStove:isVisible() then
self.toggleStove:setX(self:getBestButtonX(visible))
--print("Setting toggleStove to: " .. self:getBestButtonX(visible))
visible = visible + 1
end
else
if self.transferAll:isVisible() then
self.transferAll:setX(self:getBestButtonX(visible))
visible = visible + 1
end
end
if self.headerButtons then
for _,j in ipairs(self.headerButtons) do
if visible > 5 then break end
if j and j:isVisible() then
j:setX(self:getBestButtonX(visible))
--print("Setting extra to: " .. self:getBestButtonX(visible))
visible = visible + 1
end
end
end
end
local _ISInventoryPage_prerender = ISInventoryPage.prerender
function ISInventoryPage:prerender()
if not spiff.config.enabled then
_ISInventoryPage_prerender(self)
return
end
local titleBarHeight = self:titleBarHeight()
local height = self:getHeight()-titleBarHeight
if self.isCollapsed then
height = titleBarHeight
end
if not self.isCollapsed then
-- Draw the main background
self:drawRect(0, titleBarHeight, self:getWidth(), height, self.backgroundColor.a, self.backgroundColor.r, self.backgroundColor.g, self.backgroundColor.b)
-- Draw backpack area
self:drawRect(self:getWidth()-self.buttonSize, titleBarHeight, self.buttonSize, height, self.sbackgroundColor.a, self.sbackgroundColor.r, self.sbackgroundColor.g, self.sbackgroundColor.b)
end
if ISInventoryPage.renderDirty then
ISInventoryPage.renderDirty = false;
ISInventoryPage.dirtyUI();
end
-- self.closeButton:setVisible(false)
-- self.infoButton:setVisible(false)
-- self.collapseButton:setVisible(false)
-- self.pinButton:setVisible(false)
-- self.resizeWidget:setVisible(false)
-- Draw Titlebar
self:drawRect(0, 0, self:getWidth(), titleBarHeight, self.hbackgroundColor.a, self.hbackgroundColor.r, self.hbackgroundColor.g, self.hbackgroundColor.b)
-- Draw Titlebar border
self:drawRectBorder(0, 0, self:getWidth(), titleBarHeight, self.hborderColor.a, self.hborderColor.r, self.hborderColor.g, self.hborderColor.b)
-- Draw the title on the left
if self.title then
self:drawText(self.title, self.titleLoc, 0, 1,1,1,1)
end
-- load the current weight of the container
self.totalWeight = ISInventoryPage.loadWeight(self.inventoryPane.inventory)
local roundedWeight = round(self.totalWeight, 2)
local textLoc = self.width - titleBarHeight - 3
if self.capacity then
if self.inventoryPane.inventory == getSpecificPlayer(self.player):getInventory() then
self:drawTextRight(roundedWeight .. " / " .. getSpecificPlayer(self.player):getMaxWeight(), textLoc, 0, 1,1,1,1)
else
self:drawTextRight(roundedWeight .. " / " .. self.capacity, textLoc, 0, 1,1,1,1)
end
else
self:drawTextRight(roundedWeight .. "", self.width - 20, 0, 1,1,1,1)
end
self:setStencilRect(0,0,self.width, height)
self:syncButtonsLoc()
end
------------------------------------------
-- ISInventoryPage:createChildren
local _ISInventoryPage_createChildren = ISInventoryPage.createChildren
function ISInventoryPage:createChildren()
_ISInventoryPage_createChildren(self)
self.headerButtons = nil
-- Buttons
self.buttonsX = {}
-- assign button locations
for i=1, 5 do
if i == 1 then
local textWid = getTextManager():MeasureStringX(UIFont.Small, getText("IGUI_invpage_Transfer_all"))
local weightWid = getTextManager():MeasureStringX(UIFont.Small, "99.99 / 99.99")
self.buttonsX[i] = (self:getWidth() - self:titleBarHeight() - 3 - math.max(90, weightWid + 10) - textWid)
else
self.buttonsX[i] = (self.buttonsX[i-1] - self.transferAll:getWidth()) - 16
end
--print("ButtonsX[" .. i .. "]: " .. self.buttonsX[i])
end
self.theme = spiff.GetTheme()
self.borderColor = spiff.GetColor(self.theme.Border.Primary)
self.hborderColor = spiff.GetColor(self.theme.Border.Header)
self.sborderColor = spiff.GetColor(self.theme.Border.Secondary)
self.oborderColor = spiff.GetColor(self.theme.Border.Option)
self.hbackgroundColor = spiff.GetColor(self.theme.Background.Header)
self.backgroundColor = spiff.GetColor(self.theme.Background.Primary)
self.sbackgroundColor = spiff.GetColor(self.theme.Background.Secondary)
self.obackgroundColor = spiff.GetColor(self.theme.Background.Option)
self.htextColor = spiff.GetColor(self.theme.Text.Header)
self.textColor = spiff.GetColor(self.theme.Text.Primary)
self.stextColor = spiff.GetColor(self.theme.Text.Secondary)
self.titleLoc = self.infoButton:getX() + self.infoButton:getWidth() + 4
end
local _ISInventoryPage_render = ISInventoryPage.render
function ISInventoryPage:render()
if not spiff.config.enabled then
_ISInventoryPage_render(self)
return
end
local titleBarHeight = self:titleBarHeight()
local height = self:getHeight() - titleBarHeight
if self.isCollapsed then
height = titleBarHeight
end
if not self.isCollapsed then
-- Draw Main Frame
--self:drawRectBorder(0, titleBarHeight, self:getWidth(), height, self.borderColor.a, self.borderColor.r, self.borderColor.g, self.borderColor.b)
-- Draw backpack Frame
self:drawRectBorder(self:getWidth()-self.buttonSize, titleBarHeight, self.buttonSize, height, self.sborderColor.a, self.sborderColor.r, self.sborderColor.g, self.sborderColor.b)
end
self:clearStencilRect()
if not self.isCollapsed then
-- Draw Main Frame
self:drawRectBorder(0, titleBarHeight-1, self:getWidth(), height, self.borderColor.a, self.borderColor.r, self.borderColor.g, self.borderColor.b)
local yBottom = self:getHeight() - self.resizeWidget2:getHeight() --titleBarHeight
-- Draw BottomBar
self:drawRect(0, yBottom, self:getWidth(), self.resizeWidget2:getHeight(), self.obackgroundColor.a, self.obackgroundColor.r, self.obackgroundColor.g, self.obackgroundColor.b)
-- Draw BottomBar border
self:drawRectBorder(0, yBottom, self:getWidth(), self.resizeWidget2:getHeight(), self.oborderColor.a, self.oborderColor.r, self.oborderColor.g, self.oborderColor.b)
end
if self.joyfocus then
self:drawRectBorder(0, 0, self:getWidth(), self:getHeight(), 0.4, 0.2, 1.0, 1.0);
self:drawRectBorder(1, 1, self:getWidth()-2, self:getHeight()-2, 0.4, 0.2, 1.0, 1.0);
end
if self.render3DItems and #self.render3DItems > 0 then
self:render3DItemPreview();
end
end

View File

@@ -0,0 +1,533 @@
-- Add module
SpiffUI = SpiffUI or {}
-- Register our Radials
local spiff = SpiffUI:Register("themes")
local _ISInventoryPane_renderdetails = ISInventoryPane.renderdetails
function ISInventoryPane:renderdetails2(doDragged)
if not spiff.config.enabled then
_ISInventoryPane_renderdetails(self, doDragged)
return
end
self:updateScrollbars();
if doDragged == false then
table.wipe(self.items)
if self.inventory:isDrawDirty() then
self:refreshContainer()
end
end
local player = getSpecificPlayer(self.player)
local checkDraggedItems = false
if doDragged and self.dragging ~= nil and self.dragStarted then
self.draggedItems:update()
checkDraggedItems = true
end
local catW = (self.column2/5)
local xoff2 = (catW/2)
-- First set the background color
if not doDragged then
-- background of item icon
self:drawRectStatic(0, 0, self.column2, self.height, self.backgroundColor.a, self.backgroundColor.r, self.backgroundColor.g, self.backgroundColor.b);
self:drawRectStatic(0, 0, catW, self.height, self.obackgroundColor.a, self.obackgroundColor.r, self.obackgroundColor.g, self.obackgroundColor.b);
--self:drawRectBorder(0, 0, self.column2, self.height, self.borderColor.a, self.borderColor.r, self.borderColor.g, self.borderColor.b);
end
local y = 0;
local alt = false;
if self.itemslist == nil then
self:refreshContainer();
end
local MOUSEX = self:getMouseX()
local MOUSEY = self:getMouseY()
local YSCROLL = self:getYScroll()
local HEIGHT = self:getHeight()
local equippedLine = false
local all3D = true;
local yoff = 0
local idivX = (self.column4/4) - (self.column4/8)
local idivW = idivX + (self.column4/2)
-- self.inventoryPage.render3DItems = {};
-- Go through all the stacks of items.
for k, v in ipairs(self.itemslist) do
local count = 1;
-- Go through each item in stack..
for k2, v2 in ipairs(v.items) do
-- --print("trace:a");
local item = v2;
local doIt = true;
local xoff = 0;
yoff = 0;
if doDragged == false then
-- if it's the first item, then store the category, otherwise the item
if count == 1 then
table.insert(self.items, v);
else
table.insert(self.items, item);
end
if instanceof(item, 'InventoryItem') then
item:updateAge()
end
if instanceof(item, 'Clothing') then
item:updateWetness()
end
end
-- --print("trace:b");
local isDragging = false
if self.dragging ~= nil and self.selected[y+1] ~= nil and self.dragStarted then
xoff = MOUSEX - self.draggingX;
yoff = MOUSEY - self.draggingY;
if not doDragged then
doIt = false;
else
self:suspendStencil();
isDragging = true
end
else
if doDragged then
doIt = false;
end
end
local topOfItem = y * self.itemHgt + YSCROLL
if not isDragging and ((topOfItem + self.itemHgt < 0) or (topOfItem > HEIGHT)) then
doIt = false
end
-- --print("trace:c");
if doIt == true then
-- --print("trace:cc");
-- --print(count);
if count == 1 then
-- rect over the whole item line
--self:drawRect(1+xoff, (y*self.itemHgt)+self.headerHgt+yoff, self:getWidth(), 1, 0.3, 0.0, 0.0, 0.8);
end
-- --print("trace:d");
-- do controller selection.
if self.joyselection ~= nil and self.doController then
-- if self.joyselection < 0 then self.joyselection = (#self.itemslist) - 1; end
-- if self.joyselection >= #self.itemslist then self.joyselection = 0; end
if self.joyselection == y then
self:drawRect(1+xoff, (y*self.itemHgt)+self.headerHgt+yoff, self:getWidth()-1, self.itemHgt, 0.2, 0.2, 1.0, 1.0);
end
end
-- --print("trace:e");
-- only do icon if header or dragging sub items without header.
local tex = item:getTex();
if tex ~= nil then
local texDY = 1
local texWH = math.min(self.itemHgt-2,32)
local auxDXY = math.ceil(20 * self.texScale)
if count == 1 then
self:drawTextureScaledAspect(tex, 10+xoff+xoff2, (y*self.itemHgt)+self.headerHgt+texDY+yoff, texWH, texWH, 1, item:getR(), item:getG(), item:getB());
if player:isEquipped(item) then
self:drawTexture(self.equippedItemIcon, (10+auxDXY+xoff+xoff2), (y*self.itemHgt)+self.headerHgt+auxDXY+yoff, 1, 1, 1, 1);
end
if not self.hotbar then
self.hotbar = getPlayerHotbar(self.player);
end
if not player:isEquipped(item) and self.hotbar and self.hotbar:isInHotbar(item) then
self:drawTexture(self.equippedInHotbar, (10+auxDXY+xoff+xoff2), (y*self.itemHgt)+self.headerHgt+auxDXY+yoff, 1, 1, 1, 1);
end
if item:isBroken() then
self:drawTexture(self.brokenItemIcon, (10+auxDXY+xoff+xoff2), (y*self.itemHgt)+self.headerHgt+auxDXY-1+yoff, 1, 1, 1, 1);
end
if instanceof(item, "Food") and item:isFrozen() then
self:drawTexture(self.frozenItemIcon, (10+auxDXY+xoff+xoff2), (y*self.itemHgt)+self.headerHgt+auxDXY-1+yoff, 1, 1, 1, 1);
end
if item:isTaintedWater() or player:isKnownPoison(item) then
self:drawTexture(self.poisonIcon, (10+auxDXY+xoff+xoff2), (y*self.itemHgt)+self.headerHgt+auxDXY-1+yoff, 1, 1, 1, 1);
end
if item:isFavorite() then
self:drawTexture(self.favoriteStar, (13+auxDXY+xoff+xoff2), (y*self.itemHgt)+self.headerHgt-1+yoff, 1, 1, 1, 1);
end
if not doDragged then
-- local catCol = item:getDisplayCategory() or item:getCategory()
-- if self.catColors[catCol] then
-- self:drawRect(0, (y*self.itemHgt)+self.headerHgt, catW, texWH+2, self.catColors[catCol].a, self.catColors[catCol].r, self.catColors[catCol].g, self.catColors[catCol].b);
-- --self:drawRectBorder(0, (y*self.itemHgt)+self.headerHgt, (self.column2/5), texWH+2, self.borderColor.a, self.borderColor.r, self.borderColor.g, self.borderColor.b)
-- end
if not self.collapsed[v.name] then
self:drawTexture( self.treeexpicon, 2, (y*self.itemHgt)+self.headerHgt+5+yoff, 1, 1, 1, 1);
else
self:drawTexture( self.treecolicon, 2, (y*self.itemHgt)+self.headerHgt+5+yoff, 1, 1, 1, 1);
end
end
elseif v.count > 2 or (doDragged and count > 1 and self.selected[(y+1) - (count-1)] == nil) then
--self:drawRect(0, (y*self.itemHgt)+self.headerHgt, self.column2-1, texWH, self.borderColor.a, 0, 1, 0);
self:drawTextureScaledAspect(tex, 10+16+xoff, (y*self.itemHgt)+self.headerHgt+texDY+yoff, texWH, texWH, 0.3, item:getR(), item:getG(), item:getB());
if player:isEquipped(item) then
self:drawTexture(self.equippedItemIcon, (10+auxDXY+16+xoff+xoff2), (y*self.itemHgt)+self.headerHgt+auxDXY+yoff, 1, 1, 1, 1);
end
if item:isBroken() then
self:drawTexture(self.brokenItemIcon, (10+auxDXY+16+xoff+xoff2), (y*self.itemHgt)+self.headerHgt+auxDXY-1+yoff, 1, 1, 1, 1);
end
if instanceof(item, "Food") and item:isFrozen() then
self:drawTexture(self.frozenItemIcon, (10+auxDXY+16+xoff+xoff2), (y*self.itemHgt)+self.headerHgt+auxDXY-1+yoff, 1, 1, 1, 1);
end
if item:isFavorite() then
self:drawTexture(self.favoriteStar, (13+auxDXY+16+xoff+xoff2), (y*self.itemHgt)+self.headerHgt-1+yoff, 1, 1, 1, 1);
end
end
-- -- Put a smaller category color here too
-- if v.count > 2 and not doDragged then
-- local catCol = item:getDisplayCategory() or item:getCategory()
-- if self.catColors[catCol] then
-- self:drawRect(0, (y*self.itemHgt)+self.headerHgt, xoff2, texWH+2, self.catColors[catCol].a, self.catColors[catCol].r, self.catColors[catCol].g, self.catColors[catCol].b);
-- --self:drawRectBorder(0, (y*self.itemHgt)+self.headerHgt, (self.column2/5), texWH+2, self.borderColor.a, self.borderColor.r, self.borderColor.g, self.borderColor.b)
-- end
-- end
end
-- --print("trace:g");
if self.selected[y+1] ~= nil and not self.highlightItem then -- clicked/dragged item
if checkDraggedItems and self.draggedItems:cannotDropItem(item) then
self:drawRect(1+xoff, (y*self.itemHgt)+self.headerHgt+yoff, self:getWidth()-1, self.itemHgt, 0.20, 1.0, 0.0, 0.0);
elseif false and (((instanceof(item,"Food") or instanceof(item,"DrainableComboItem")) and item:getHeat() ~= 1) or item:getItemHeat() ~= 1) then
if (((instanceof(item,"Food") or instanceof(item,"DrainableComboItem")) and item:getHeat() > 1) or item:getItemHeat() > 1) then
self:drawRect(1+xoff, (y*self.itemHgt)+self.headerHgt+yoff, self.column4, self.itemHgt, 0.5, math.abs(item:getInvHeat()), 0.0, 0.0);
else
self:drawRect(1+xoff, (y*self.itemHgt)+self.headerHgt+yoff, self.column4, self.itemHgt, 0.5, 0.0, 0.0, math.abs(item:getInvHeat()));
end
else
self:drawRect(1+xoff, (y*self.itemHgt)+self.headerHgt+yoff, self:getWidth()-1, self.itemHgt, 0.20, 1.0, 1.0, 1.0);
end
elseif self.mouseOverOption == y+1 and not self.highlightItem then -- called when you mose over an element
if(((instanceof(item,"Food") or instanceof(item,"DrainableComboItem")) and item:getHeat() ~= 1) or item:getItemHeat() ~= 1) then
if (((instanceof(item,"Food") or instanceof(item,"DrainableComboItem")) and item:getHeat() > 1) or item:getItemHeat() > 1) then
self:drawRect(1+xoff, (y*self.itemHgt)+self.headerHgt+yoff, self.column4, self.itemHgt, 0.3, math.abs(item:getInvHeat()), 0.0, 0.0);
else
self:drawRect(1+xoff, (y*self.itemHgt)+self.headerHgt+yoff, self.column4, self.itemHgt, 0.3, 0.0, 0.0, math.abs(item:getInvHeat()));
end
else
self:drawRect(1+xoff, (y*self.itemHgt)+self.headerHgt+yoff, self:getWidth()-1, self.itemHgt, 0.05, 1.0, 1.0, 1.0);
end
else
if count == 1 then -- normal background (no selected, no dragging..)
-- background of item line
if self.highlightItem and self.highlightItem == item:getType() then
if not self.blinkAlpha then self.blinkAlpha = 0.5; end
self:drawRect(1+xoff, (y*self.itemHgt)+self.headerHgt+yoff, self.column4, self.itemHgt, self.blinkAlpha, 1, 1, 1);
if not self.blinkAlphaIncrease then
self.blinkAlpha = self.blinkAlpha - 0.05 * (UIManager.getMillisSinceLastRender() / 33.3);
if self.blinkAlpha < 0 then
self.blinkAlpha = 0;
self.blinkAlphaIncrease = true;
end
else
self.blinkAlpha = self.blinkAlpha + 0.05 * (UIManager.getMillisSinceLastRender() / 33.3);
if self.blinkAlpha > 0.5 then
self.blinkAlpha = 0.5;
self.blinkAlphaIncrease = false;
end
end
else
if (((instanceof(item,"Food") or instanceof(item,"DrainableComboItem")) and item:getHeat() ~= 1) or item:getItemHeat() ~= 1) then
if (((instanceof(item,"Food") or instanceof(item,"DrainableComboItem")) and item:getHeat() > 1) or item:getItemHeat() > 1) then
self:drawRect(1+xoff, (y*self.itemHgt)+self.headerHgt+yoff, self.column4, self.itemHgt, 0.15, math.abs(item:getInvHeat()), 0.0, 0.0)
else
self:drawRect(1+xoff, (y*self.itemHgt)+self.headerHgt+yoff, self.column4, self.itemHgt, 0.15, 0.0, 0.0, math.abs(item:getInvHeat()))
end
end
end
else
if (((instanceof(item,"Food") or instanceof(item,"DrainableComboItem")) and item:getHeat() ~= 1) or item:getItemHeat() ~= 1) then
if (((instanceof(item,"Food") or instanceof(item,"DrainableComboItem")) and item:getHeat() > 1) or item:getItemHeat() > 1) then
self:drawRect(1+xoff, (y*self.itemHgt)+self.headerHgt+yoff, self.column4, self.itemHgt, 0.2, math.abs(item:getInvHeat()), 0.0, 0.0);
else
self:drawRect(1+xoff, (y*self.itemHgt)+self.headerHgt+yoff, self.column4, self.itemHgt, 0.2, 0.0, 0.0, math.abs(item:getInvHeat()));
end
else
self:drawRect(1+xoff, (y*self.itemHgt)+self.headerHgt+yoff, self.column4, self.itemHgt, 0.4, 0.0, 0.0, 0.0);
end
end
end
-- --print("trace:h");
-- divider between equipped and unequipped items
if k > 1 then
if v.equipped then
if not doDragged and not equippedLine and y > 0 then
self:drawTextureScaled(self.lineTex, idivX, ((y+1)*self.itemHgt)+self.headerHgt-2-self.itemHgt, idivW, 2, self.oborderColor.a, self.oborderColor.r, self.oborderColor.g, self.oborderColor.b)
--self:drawRect(1, ((y+1)*self.itemHgt)+self.headerHgt-1-self.itemHgt, self.column4, 2, 0.2, 1, 1, 1);
else
self:drawTextureScaled(self.lineTex, idivX, ((y+1)*self.itemHgt)+self.headerHgt-self.itemHgt, idivW, 1, self.sborderColor.a, self.sborderColor.r, self.sborderColor.g, self.sborderColor.b)
end
equippedLine = true
else
self:drawTextureScaled(self.lineTex, idivX, ((y+1)*self.itemHgt)+self.headerHgt-self.itemHgt, idivW, 1, self.sborderColor.a, self.sborderColor.r, self.sborderColor.g, self.sborderColor.b)
end
end
if item:getJobDelta() > 0 and (count > 1 or self.collapsed[v.name]) then
local scrollBarWid = self:isVScrollBarVisible() and 13 or 0
local displayWid = self.column4 - scrollBarWid - catW
self:drawRect(1+xoff+catW, (y*self.itemHgt)+self.headerHgt+yoff, displayWid * item:getJobDelta(), self.itemHgt, 0.2, 0.4, 1.0, 0.3);
end
-- --print("trace:i");
local textDY = (self.itemHgt - self.fontHgt) / 2
--~ local redDetail = false;
local itemName = item:getName();
if count == 1 then
-- if we're dragging something and want to put it in a container wich is full
if doDragged and ISMouseDrag.dragging and #ISMouseDrag.dragging > 0 then
local red = false;
if red then
if v.count > 2 then
self:drawText(itemName.." ("..(v.count-1)..")", self.column2+8+xoff, (y*self.itemHgt)+self.headerHgt+textDY+yoff, 0.7, 0.0, 0.0, 1.0, self.font);
else
self:drawText(itemName, self.column2+8+xoff, (y*self.itemHgt)+self.headerHgt+textDY+yoff, 0.7, 0.0, 0.0, 1.0, self.font);
end
else
if v.count > 2 then
self:drawText(itemName.." ("..(v.count-1)..")", self.column2+8+xoff, (y*self.itemHgt)+self.headerHgt+textDY+yoff, 0.7, 0.7, 0.7, 1.0, self.font);
else
self:drawText(itemName, self.column2+8+xoff, (y*self.itemHgt)+self.headerHgt+textDY+yoff, 0.7, 0.7, 0.7, 1.0, self.font);
end
end
else
local clipX = math.max(0, self.column2+xoff)
local clipY = math.max(0, (y*self.itemHgt)+self.headerHgt+yoff+self:getYScroll())
local clipX2 = math.min(clipX + self.column3-self.column2, self.width)
local clipY2 = math.min(clipY + self.itemHgt, self.height)
if clipX < clipX2 and clipY < clipY2 then
self:setStencilRect(clipX, clipY, clipX2 - clipX, clipY2 - clipY)
if v.count > 2 then
self:drawText(itemName.." ("..(v.count-1)..")", self.column2+8+xoff, (y*self.itemHgt)+self.headerHgt+textDY+yoff, 0.7, 0.7, 0.7, 1.0, self.font);
else
self:drawText(itemName, self.column2+8+xoff, (y*self.itemHgt)+self.headerHgt+textDY+yoff, 0.7, 0.7, 0.7, 1.0, self.font);
end
self:clearStencilRect()
self:repaintStencilRect(clipX, clipY, clipX2 - clipX, clipY2 - clipY)
end
end
end
-- --print("trace:j");
--~ if self.mouseOverOption == y+1 and self.dragging and not self.parent:canPutIn(item) then
--~ self:drawText(item:getName(), self.column2+8+xoff, (y*18)+16+1+yoff, 0.7, 0.0, 0.0, 1.0);
--~ else
if item:getJobDelta() > 0 then
if (count > 1 or self.collapsed[v.name]) then
if self.dragging == count then
self:drawText(item:getJobType(), self.column3+8+xoff, (y*self.itemHgt)+self.headerHgt+textDY+yoff, 0.7, 0.0, 0.0, 1.0, self.font);
else
self:drawText(item:getJobType(), self.column3+8+xoff, (y*self.itemHgt)+self.headerHgt+textDY+yoff, 0.7, 0.7, 0.7, 1.0, self.font);
end
end
else
if count == 1 then
if doDragged then
-- Don't draw the category when dragging
elseif item:getDisplayCategory() then -- display the custom category set in items.txt
self:drawText(getText("IGUI_ItemCat_" .. item:getDisplayCategory()), self.column3+8+xoff, (y*self.itemHgt)+self.headerHgt+textDY+yoff, 0.6, 0.6, 0.8, 1.0, self.font);
else
self:drawText(getText("IGUI_ItemCat_" .. item:getCategory()), self.column3+8+xoff, (y*self.itemHgt)+self.headerHgt+textDY+yoff, 0.6, 0.6, 0.8, 1.0, self.font);
end
else
local redDetail = false;
self:drawItemDetails(item, y, xoff, yoff, redDetail);
end
end
if self.selected ~= nil and self.selected[y+1] ~= nil then
self:resumeStencil();
end
end
if count == 1 then
if alt == nil then alt = false; end
alt = not alt;
end
y = y + 1;
if count == 1 and self.collapsed ~= nil and v.name ~= nil and self.collapsed[v.name] then
if instanceof(item, "Food") then
-- Update all food items in a collapsed stack so they separate when freshness changes.
for k3,v3 in ipairs(v.items) do
v3:updateAge()
end
end
break
end
if count == 51 then
break
end
count = count + 1;
-- --print("trace:zz");
end
end
self:setScrollHeight(((y+1)*self.itemHgt)-self.parent:titleBarHeight()+2);
self:setScrollWidth(0);
-- if self.draggingMarquis then
-- local w = self:getMouseX() - self.draggingMarquisX;
-- local h = self:getMouseY() - self.draggingMarquisY;
-- self:drawRectBorder(self.draggingMarquisX, self.draggingMarquisY, w, h, 0.4, 0.9, 0.9, 1);
-- end
if not doDragged then
self:drawRectStatic(1, 0, self.width-2, self.headerHgt, self.obackgroundColor.a, self.obackgroundColor.r, self.obackgroundColor.g, self.obackgroundColor.b);
end
end
local _ISInventoryPane_createChildren = ISInventoryPane.createChildren
function ISInventoryPane:createChildren()
_ISInventoryPane_createChildren(self)
if not spiff.config.enabled then
return
end
-- self.catColors = {
-- -- 546E7A
-- ["Furniture"] = {r=0.32, g=0.43, b=0.47, a=0.4},
-- ["Household"] = {r=0.32, g=0.43, b=0.47, a=0.4},
-- ["Junk"] = {r=0.32, g=0.43, b=0.47, a=0.4},
-- ["Item"] = {r=0.32, g=0.43, b=0.47, a=0.4},
-- -- 757575
-- ["Security"] = {r=0.45, g=0.45, b=0.45, a=0.4},
-- -- 7B1FA2
-- ["Appearance"] = {r=0.48, g=0.12, b=0.63, a=0.4},
-- ["Accessory"] = {r=0.48, g=0.12, b=0.63, a=0.4},
-- ["MakeUp"] = {r=0.48, g=0.12, b=0.63, a=0.4},
-- ["Clothing"] = {r=0.48, g=0.12, b=0.63, a=0.4},
-- ["Raccoon"] = {r=0.48, g=0.12, b=0.63, a=0.4},
-- -- 512DA8
-- ["Bag"] = {r=0.31, g=0.17, b=0.66, a=0.4},
-- ["Container"] = {r=0.31, g=0.17, b=0.66, a=0.4},
-- ["WaterContainer"] = {r=0.31, g=0.17, b=0.66, a=0.4},
-- -- FBC02D
-- ["Communications"] = {r=0.98, g=0.75, b=0.17, a=0.4},
-- ["Devices"] = {r=0.98, g=0.75, b=0.17, a=0.4},
-- ["LightSource"] = {r=0.98, g=0.75, b=0.17, a=0.4},
-- -- D32F2F
-- ["Bandage"] = {r=0.82, g=0.18, b=0.18, a=0.4},
-- ["FirstAid"] = {r=0.82, g=0.18, b=0.18, a=0.4},
-- ["Wound"] = {r=0.82, g=0.18, b=0.18, a=0.4},
-- ["ZedDmg"] = {r=0.82, g=0.18, b=0.18, a=0.4},
-- ["Corpse"] = {r=0.82, g=0.18, b=0.18, a=0.4},
-- -- 0288D1
-- ["Food"] = {r=0.01, g=0.53, b=0.82, a=0.4},
-- ["Cooking"] = {r=0.01, g=0.53, b=0.82, a=0.4},
-- ["Water"] = {r=0.01, g=0.53, b=0.82, a=0.4},
-- -- 00796B
-- ["Camping"] = {r=0.0, g=0.47, b=0.42, a=0.4},
-- ["Fishing"] = {r=0.0, g=0.47, b=0.42, a=0.4},
-- ["Trapping"] = {r=0.0, g=0.47, b=0.42, a=0.4},
-- ["Gardening"] = {r=0.0, g=0.47, b=0.42, a=0.4},
-- -- 455A64
-- ["Ammo"] = {r=0.27, g=0.35, b=0.39, a=0.4},
-- ["Tool"] = {r=0.27, g=0.35, b=0.39, a=0.4},
-- ["ToolWeapon"] = {r=0.27, g=0.35, b=0.39, a=0.4},
-- ["Sports"] = {r=0.27, g=0.35, b=0.39, a=0.4},
-- ["Weapon"] = {r=0.27, g=0.35, b=0.39, a=0.4},
-- ["WeaponCrafted"] = {r=0.27, g=0.35, b=0.39, a=0.4},
-- ["Instrument"] = {r=0.27, g=0.35, b=0.39, a=0.4},
-- -- 388E3C
-- ["Cartography"] = {r=0.22, g=0.55, b=0.23, a=0.4},
-- ["SkillBook"] = {r=0.22, g=0.55, b=0.23, a=0.4},
-- ["Literature"] = {r=0.22, g=0.55, b=0.23, a=0.4},
-- -- FFA000
-- ["Electronics"] = {r=1.0, g=0.62, b=0, a=0.4},
-- ["Paint"] = {r=1.0, g=0.62, b=0, a=0.4},
-- ["Material"] = {r=1.0, g=0.62, b=0, a=0.4},
-- ["WeaponPart"] = {r=1.0, g=0.62, b=0, a=0.4},
-- ["VehicleMaintenance"] = {r=1.0, g=0.62, b=0, a=0.4},
-- }
local theme = spiff.GetTheme()
--o.borderColor = {r=0.4, g=0.4, b=0.4, a=1};
--o.backgroundColor = {r=0, g=0, b=0, a=0.5};
self.hborderColor = spiff.GetColor(theme.Border.Header)
self.borderColor = spiff.GetColor(theme.Border.Primary)
self.sborderColor = spiff.GetColor(theme.Border.Secondary)
self.oborderColor = spiff.GetColor(theme.Border.Option)
self.hbackgroundColor = spiff.GetColor(theme.Background.Header)
self.backgroundColor = spiff.GetColor(theme.Background.Primary)
self.sbackgroundColor = spiff.GetColor(theme.Background.Secondary)
self.obackgroundColor = spiff.GetColor(theme.Background.Option)
self.htextColor = spiff.GetColor(theme.Text.Header)
self.textColor = spiff.GetColor(theme.Text.Primary)
self.stextColor = spiff.GetColor(theme.Text.Secondary)
-- Reset to the theme
---- Since we're not doing everything anymore, gotta do it all here
self.nameHeader.backgroundColor = spiff.GetColor(theme.Background.Option)
self.nameHeader.backgroundColorMouseOver = spiff.GetColorMod(theme.Background.Option, 2)
self.nameHeader.backgroundColorPressed = spiff.GetColorMod(theme.Background.Option, 0.5)
self.nameHeader.borderColor = spiff.GetColor(theme.Border.Option)
self.nameHeader.textColor = spiff.GetColor(theme.Text.Option)
self.typeHeader.backgroundColor = spiff.GetColor(theme.Background.Option)
self.typeHeader.backgroundColorMouseOver = spiff.GetColorMod(theme.Background.Option, 2)
self.typeHeader.backgroundColorPressed = spiff.GetColorMod(theme.Background.Option, 0.5)
self.typeHeader.borderColor = spiff.GetColor(theme.Border.Option)
self.typeHeader.textColor = spiff.GetColor(theme.Text.Option)
self.contextButton1.backgroundColor = spiff.GetColor(theme.Background.Option)
self.contextButton1.backgroundColorMouseOver = spiff.GetColorMod(theme.Background.Option, 2)
self.contextButton1.backgroundColorPressed = spiff.GetColorMod(theme.Background.Option, 0.5)
self.contextButton1.borderColor = spiff.GetColor(theme.Border.Option)
self.contextButton1.textColor = spiff.GetColor(theme.Text.Option)
self.contextButton2.backgroundColor = spiff.GetColor(theme.Background.Option)
self.contextButton2.backgroundColorMouseOver = spiff.GetColorMod(theme.Background.Option, 2)
self.contextButton2.backgroundColorPressed = spiff.GetColorMod(theme.Background.Option, 0.5)
self.contextButton2.borderColor = spiff.GetColor(theme.Border.Option)
self.contextButton2.textColor = spiff.GetColor(theme.Text.Option)
self.contextButton3.backgroundColor = spiff.GetColor(theme.Background.Option)
self.contextButton3.backgroundColorMouseOver = spiff.GetColorMod(theme.Background.Option, 2)
self.contextButton3.backgroundColorPressed = spiff.GetColorMod(theme.Background.Option, 0.5)
self.contextButton3.borderColor = spiff.GetColor(theme.Border.Option)
self.contextButton3.textColor = spiff.GetColor(theme.Text.Option)
-- ScrollBar
self.vscroll.backgroundColor = spiff.GetColor(theme.Background.Option)
self.vscroll.borderColor = spiff.GetColor(theme.Background.Option)
-- Fix this spacing and height, its not obvious when its all black :)
self.expandAll:setHeight(15)
self.collapseAll:setHeight(15)
self.filterMenu:setHeight(15)
self.expandAll:setX(self.expandAll:getX() + 2)
self.collapseAll:setX(self.collapseAll:getX() + 2)
self.filterMenu:setX(self.filterMenu:getX() + 2)
-- self.expandAll.textureColor = spiff.GetColor(theme.Background.Primary)
-- self.collapseAll.textureColor = spiff.GetColor(theme.Background.Primary)
-- self.filterMenu.textureColor = spiff.GetColor(theme.Background.Primary)
self.lineTex = getTexture("media/UI/line.png")
end

View File

@@ -0,0 +1,23 @@
SpiffUI = SpiffUI or {}
-- Register our Radials
local spiff = SpiffUI:Register("themes")
local _ISLabel_createChildren = ISLabel.createChildren
function ISLabel:createChildren()
_ISLabel_createChildren(self)
if not spiff.config.enabled then
return
end
local theme = spiff.GetTheme()
self.backgroundColor = spiff.GetColor(theme.Background.Primary)
self.borderColor = spiff.GetColor(theme.Border.Primary)
local c = spiff.GetColor(theme.Text.Primary)
self.r = c.r
self.g = c.g
self.b = c.b
self.a = c.a
end

View File

@@ -0,0 +1,28 @@
SpiffUI = SpiffUI or {}
-- Register our Radials
local spiff = SpiffUI:Register("themes")
local _ISModalDialog_initialise = ISModalDialog.initialise
function ISModalDialog:initialise()
_ISModalDialog_initialise(self)
if not spiff.config.enabled then
return
end
local theme = spiff.GetTheme()
self.backgroundColor = spiff.GetColor(theme.Background.Primary)
self.borderColor = spiff.GetColor(theme.Border.Primary)
-- For the buttons
self.oborderColor = spiff.GetColor(theme.Border.Option)
-- Resync the theme
if self.yesno then
self.yes.borderColor = spiff.GetColor(self.oborderColor)
self.no.borderColor = spiff.GetColor(self.oborderColor)
else
self.ok.borderColor = spiff.GetColor(self.oborderColor)
end
end

View File

@@ -0,0 +1,28 @@
SpiffUI = SpiffUI or {}
-- Register our Radials
local spiff = SpiffUI:Register("themes")
local _ISModalRichText_initialise = ISModalRichText.initialise
function ISModalRichText:initialise()
_ISModalRichText_initialise(self)
if not spiff.config.enabled then
return
end
local theme = spiff.GetTheme()
self.backgroundColor = spiff.GetColor(theme.Background.Primary)
self.borderColor = spiff.GetColor(theme.Border.Primary)
-- For the buttons
self.oborderColor = spiff.GetColor(theme.Border.Option)
-- Resync the theme
if self.yesno then
self.yes.borderColor = spiff.GetColor(self.oborderColor)
self.no.borderColor = spiff.GetColor(self.oborderColor)
else
self.ok.borderColor = spiff.GetColor(self.oborderColor)
end
end

View File

@@ -0,0 +1,17 @@
SpiffUI = SpiffUI or {}
-- Register our Radials
local spiff = SpiffUI:Register("themes")
local _ISOptionPanel_createChildren = ISOptionPanel.createChildren
function ISOptionPanel:createChildren()
_ISOptionPanel_createChildren(self)
if not spiff.config.enabled then
return
end
local theme = spiff.GetTheme()
self.backgroundColor = spiff.GetColor(theme.Background.Primary)
self.borderColor = spiff.GetColor(theme.Border.Primary)
end

View File

@@ -0,0 +1,18 @@
SpiffUI = SpiffUI or {}
-- Register our Radials
local spiff = SpiffUI:Register("themes")
--local _ISPanel_createChildren = ISPanel.createChildren
function ISPanel:createChildren()
--_ISPanel_createChildren(self)
if not spiff.config.enabled then
return
end
-- The ISPanel is commonly used to make child items within a window or joypad panel
local theme = spiff.GetTheme()
self.backgroundColor = spiff.GetColor(theme.Background.Option)
self.borderColor = spiff.GetColor(theme.Border.Option)
end

View File

@@ -0,0 +1,23 @@
SpiffUI = SpiffUI or {}
-- Register our Radials
local spiff = SpiffUI:Register("themes")
local _ISPanelJoypad_createChildren = ISPanelJoypad.createChildren
function ISPanelJoypad:createChildren()
_ISPanelJoypad_createChildren(self)
if not spiff.config.enabled then
return
end
local theme = spiff.GetTheme()
local zAlpha = self.backgroundColor.a == 0
self.backgroundColor = spiff.GetColor(theme.Background.Primary)
self.borderColor = spiff.GetColor(theme.Border.Primary)
if zAlpha then
self.backgroundColor.a = 0
self.borderColor.a = 0
end
end

View File

@@ -0,0 +1,19 @@
SpiffUI = SpiffUI or {}
-- Register our Radials
local spiff = SpiffUI:Register("themes")
local _ISScrollBar_createChildren = ISScrollBar.createChildren
function ISScrollBar:createChildren()
_ISScrollBar_createChildren(self)
if not spiff.config.enabled then
return
end
-- o.backgroundColor = {r=0, g=0, b=0, a=1.0};
-- o.borderColor = {r=0.4, g=0.4, b=0.4, a=1};
local theme = spiff.GetTheme()
self.backgroundColor = spiff.GetColor(theme.Background.Option)
self.borderColor = spiff.GetColor(theme.Background.Option)
end

View File

@@ -0,0 +1,171 @@
SpiffUI = SpiffUI or {}
-- Register our Radials
local spiff = SpiffUI:Register("themes")
local _ISTabPanel_createChildren = ISTabPanel.createChildren
function ISTabPanel:createChildren()
_ISTabPanel_createChildren(self)
if not spiff.config.enabled then
return
end
local theme = spiff.GetTheme()
self.backgroundColor = spiff.GetColor(theme.Background.Secondary)
self.borderColor = spiff.GetColor(theme.Border.Secondary)
self.textColor = spiff.GetColor(theme.Text.Primary)
self.selBackgroundColor = spiff.GetColor(theme.Background.Option)
self.selBorderColor = spiff.GetColor(theme.Border.Option)
if spiff.config.Theme == "Project Zomboid" then
self.selBackgroundColor = {r=0.3, g=0.3, b=0.3, a=1.0}
end
--self.
end
function ISTabPanel:render()
local newViewList = {};
local tabDragSelected = -1;
if self.draggingTab and not self.isDragging and ISTabPanel.xMouse > -1 and ISTabPanel.xMouse ~= self:getMouseX() then -- do we move the mouse since we have let the left button down ?
self.isDragging = self.allowDraggingTabs;
end
local tabWidth = self.maxLength
local inset = 1 -- assumes a 1-pixel window border on the left to avoid
local gap = 1 -- gap between tabs
if self.isDragging and not ISTabPanel.mouseOut then
-- we fetch all our view to remove the tab of the view we're dragging
for i,viewObject in ipairs(self.viewList) do
if i ~= (self.draggingTab + 1) then
table.insert(newViewList, viewObject);
else
ISTabPanel.viewDragging = viewObject;
end
end
-- in wich tab slot are we dragging our tab
tabDragSelected = self:getTabIndexAtX(self:getMouseX()) - 1;
tabDragSelected = math.min(#self.viewList - 1, math.max(tabDragSelected, 0))
-- we draw a white rectangle to show where our tab is going to be
self:drawRectBorder(inset + (tabDragSelected * (tabWidth + gap)), 0, tabWidth, self.tabHeight - 1, 1,1,1,1);
else -- no dragging, we display all our tabs
newViewList = self.viewList;
end
-- our principal rect, wich display our different view
---- I don't think this is ever used, and really it shouldn't be. its an overlay that gets put on top of the child panel. most things i see set this to 0 alpha
--self:drawRect(0, self.tabHeight, self.width, self.height - self.tabHeight, self.backgroundColor.a, self.backgroundColor.r, self.backgroundColor.g, self.backgroundColor.b);
--self:drawRectBorder(0, self.tabHeight, self.width, self.height - self.tabHeight, self.borderColor.a, self.borderColor.r, self.borderColor.g, self.borderColor.b);
local x = inset;
if self.centerTabs and (self:getWidth() >= self:getWidthOfAllTabs()) then
x = (self:getWidth() - self:getWidthOfAllTabs()) / 2
else
x = x + self.scrollX
end
local widthOfAllTabs = self:getWidthOfAllTabs()
local overflowLeft = self.scrollX < 0
local overflowRight = x + widthOfAllTabs > self.width
local blinkTabsAlphaNotUpdated = true;
if widthOfAllTabs > self.width then
self:setStencilRect(0, 0, self.width, self.tabHeight)
end
for i,viewObject in ipairs(newViewList) do
tabWidth = self.equalTabWidth and self.maxLength or viewObject.tabWidth
-- if we drag a tab over an existing one, we move the other
if tabDragSelected ~= -1 and i == (tabDragSelected + 1) then
x = x + tabWidth + gap;
end
-- if this tab is the active one, we make the tab btn lighter
if viewObject.name == self.activeView.name and not self.isDragging and not ISTabPanel.mouseOut then
--self:drawTextureScaled(ISTabPanel.tabSelected, x, 0, tabWidth, self.tabHeight - 1, self.tabTransparency,1,1,1);
self:drawRect(x, 0, tabWidth, self.tabHeight - 1, self.selBackgroundColor.a, self.selBackgroundColor.r, self.selBackgroundColor.g, self.selBackgroundColor.b);
self:drawRectBorder(x, 0, tabWidth, self.tabHeight - 1, self.selBorderColor.a, self.selBorderColor.r, self.selBorderColor.g, self.selBorderColor.b);
else
local alpha = self.tabTransparency;
local shouldBlink = false;
if self.blinkTabs then
for j,tab in ipairs(self.blinkTabs) do
if tab and tab == viewObject.name then
shouldBlink = true;
end
end
end
if (self.blinkTab and self.blinkTab == viewObject.name) or (shouldBlink and blinkTabsAlphaNotUpdated) then
blinkTabsAlphaNotUpdated = false;
if not self.blinkTabAlpha then
self.blinkTabAlpha = self.tabTransparency;
self.blinkTabAlphaIncrease = false;
end
if not self.blinkTabAlphaIncrease then
self.blinkTabAlpha = self.blinkTabAlpha - 0.1 * self.tabTransparency * (UIManager.getMillisSinceLastRender() / 33.3);
if self.blinkTabAlpha < 0 then
self.blinkTabAlpha = 0;
self.blinkTabAlphaIncrease = true;
end
else
self.blinkTabAlpha = self.blinkTabAlpha + 0.1 * self.tabTransparency * (UIManager.getMillisSinceLastRender() / 33.3);
if self.blinkTabAlpha > self.tabTransparency then
self.blinkTabAlpha = self.tabTransparency;
self.blinkTabAlphaIncrease = false;
end
end
alpha = self.blinkTabAlpha;
--self:drawTextureScaled(ISTabPanel.tabUnSelected, x, 0, tabWidth, self.tabHeight - 1, self.tabTransparency,1,1,1);
self:drawRect(x, 0, tabWidth, self.tabHeight - 1, alpha, self.backgroundColor.r, self.backgroundColor.g, self.backgroundColor.b);
self:drawRectBorder(x, 0, tabWidth, self.tabHeight - 1, self.borderColor.a, self.borderColor.r, self.borderColor.g, self.borderColor.b);
--self:drawRect(x, 0, tabWidth, self.tabHeight - 1, alpha, 1, 1, 1);
elseif shouldBlink then
alpha = self.blinkTabAlpha;
--self:drawTextureScaled(ISTabPanel.tabUnSelected, x, 0, tabWidth, self.tabHeight - 1, self.tabTransparency,1,1,1);
self:drawRect(x, 0, tabWidth, self.tabHeight - 1, alpha, self.backgroundColor.r, self.backgroundColor.g, self.backgroundColor.b);
self:drawRectBorder(x, 0, tabWidth, self.tabHeight - 1, self.borderColor.a, self.borderColor.r, self.borderColor.g, self.borderColor.b);
else
self:drawRect(x, 0, tabWidth, self.tabHeight - 1, self.backgroundColor.a, self.backgroundColor.r, self.backgroundColor.g, self.backgroundColor.b)
self:drawRectBorder(x, 0, tabWidth, self.tabHeight - 1, self.borderColor.a, self.borderColor.r, self.borderColor.g, self.borderColor.b)
--self:drawTextureScaled(ISTabPanel.tabUnSelected, x, 0, tabWidth, self.tabHeight - 1, self.tabTransparency,1,1,1);
if self:getMouseY() >= 0 and self:getMouseY() < self.tabHeight and self:isMouseOver() and self:getTabIndexAtX(self:getMouseX()) == i then
viewObject.fade:setFadeIn(true)
else
viewObject.fade:setFadeIn(false)
end
viewObject.fade:update()
--self:drawRect(x, 0, tabWidth, self.tabHeight - 1, self.selBackgroundColor.a, self.selBackgroundColor.r, self.selBackgroundColor.g, self.selBackgroundColor.b)
--self:drawRectBorder(x, 0, tabWidth, self.tabHeight - 1, self.selBorderColor.a, self.selBorderColor.r, self.selBorderColor.g, self.selBorderColor.b)
--self:drawTextureScaled(ISTabPanel.tabSelected, x, 0, tabWidth, self.tabHeight - 1, 0.2 * viewObject.fade:fraction(),1,1,1);
end
end
self:drawTextCentre(viewObject.name, x + (tabWidth / 2), 3, self.textColor.r, self.textColor.g, self.textColor.b, self.textTransparency, UIFont.Small);
x = x + tabWidth + gap;
end
local butPadX = 3
if overflowLeft then
local tex = getTexture("media/ui/ArrowLeft.png")
local butWid = tex:getWidthOrig() + butPadX * 2
self:drawRect(inset, 0, butWid, self.tabHeight, 1, 0, 0, 0)
self:drawRectBorder(inset, 0, butWid, self.tabHeight, 1, 1, 1, 1)
self:drawTexture(tex, inset + butPadX, (self.tabHeight - tex:getHeight()) / 2, 1, 1, 1, 1)
end
if overflowRight then
local tex = getTexture("media/ui/ArrowRight.png")
local butWid = tex:getWidthOrig() + butPadX * 2
self:drawRect(self.width - inset - butWid, 0, butWid, self.tabHeight, 1, 0, 0, 0)
self:drawRectBorder(self.width - inset - butWid, 0, butWid, self.tabHeight, 1, 1, 1, 1)
self:drawTexture(tex, self.width - butWid + butPadX, (self.tabHeight - tex:getHeight()) / 2, 1, 1, 1, 1)
end
if widthOfAllTabs > self.width then
self:clearStencilRect()
end
-- we draw a ghost of our tab we currently dragging
if self.draggingTab and self.isDragging and not ISTabPanel.mouseOut then
if self.draggingTab > 0 then
--self:drawTextureScaled(ISTabPanel.tabSelected, inset + (self.draggingTab * (tabWidth + gap)) + (self:getMouseX() - ISTabPanel.xMouse), 0, tabWidth, self.tabHeight - 1, 0.8,1,1,1);
self:drawTextCentre(ISTabPanel.viewDragging.name, inset + (self.draggingTab * (tabWidth + gap)) + (self:getMouseX() - ISTabPanel.xMouse) + (tabWidth / 2), 3, 1, 1, 1, 1, UIFont.Normal);
else
--self:drawTextureScaled(ISTabPanel.tabSelected, inset + (self:getMouseX() - ISTabPanel.xMouse), 0, tabWidth, self.tabHeight - 1, 0.8,1,1,1);
self:drawTextCentre(ISTabPanel.viewDragging.name, inset + (self:getMouseX() - ISTabPanel.xMouse) + (tabWidth / 2), 3, 1, 1, 1, 1, UIFont.Normal);
end
end
end

View File

@@ -0,0 +1,22 @@
SpiffUI = SpiffUI or {}
-- Register our Radials
local spiff = SpiffUI:Register("themes")
local _ISToolTip_createChildren = ISToolTip.createChildren
function ISToolTip:createChildren()
_ISToolTip_createChildren(self)
if not spiff.config.enabled then
return
end
local theme = spiff.GetTheme()
self.backgroundColor = {r=0, g=0, b=0, a=0}
self.borderColor = {r=0, g=0, b=0, a=0}
self.descriptionPanel.backgroundColor = spiff.GetColor(theme.Background.Option)
self.descriptionPanel.borderColor = spiff.GetColor(theme.Border.Option)
self:noBackground()
end

View File

@@ -0,0 +1,18 @@
SpiffUI = SpiffUI or {}
-- Register our Radials
local spiff = SpiffUI:Register("themes")
local _ISWindow_createChildren = ISWindow.createChildren
function ISWindow:createChildren ()
_ISWindow_createChildren(self)
if not spiff.config.enabled then
return
end
local theme = spiff.GetTheme()
self.backgroundColor = spiff.GetColor(theme.Background.Primary)
self.borderColor = spiff.GetColor(theme.Border.Primary)
end

View File

@@ -0,0 +1,204 @@
------------------------------------------
-- spiff -- Main
------------------------------------------
SpiffUI = SpiffUI or {}
-- Register our Radials
local spiff = SpiffUI:Register("themes")
------------------------------------------
-- Theme Definition
------------------------------------------
---- Theme = {
---- Name = "",
---- Background = {
---- Header = 0,
---- Primary = 0,
---- Secondary = 0
---- },
---- Border = {
---- Header = 0,
---- Primary = 0,
---- Secondary = 0
---- }
---- }
------------------------------------------
spiff.config = {
enabled = true,
Theme = "Blue Steel"
}
spiff.Color = function(r1,g1,b1,a1)
return {
r = r1,
g = g1,
b = b1,
a = a1
}
end
local Themes = {
-- The look I'm best known for is
["Blue Steel"] = {
Background = {
Header = spiff.Color(0.17, 0.20, 0.23, 0.8),
Primary = spiff.Color(0.11, 0.12, 0.15, 0.8),
Secondary = spiff.Color(0.13, 0.14, 0.18, 0.8),
Option = spiff.Color(0.21, 0.24, 0.27, 0.8)
},
Border = {
Header = spiff.Color(0.21, 0.24, 0.27, 0.8),
Primary = spiff.Color(0.07, 0.08, 0.17, 0.8),
Secondary = spiff.Color(0.34, 0.38, 0.48, 0.6),
Option = spiff.Color(0.26, 0.29, 0.33, 0.8)
},
Text = {
Header = spiff.Color(1, 1, 1, 1),
Primary = spiff.Color(1, 1, 1, 1),
Secondary = spiff.Color(0.4, 0.4, 0.4, 1),
Option = spiff.Color(0.8, 0.8, 0.8, 1)
}
},
-- And then there's
["Ferrari"] = {
Background = {
Header = spiff.Color(0.14, 0.14, 0.14, 0.8),
Primary = spiff.Color(0.11, 0.11, 0.11, 0.8),
Secondary = spiff.Color(0.14, 0.14, 0.14, 0.8),
Option = spiff.Color(0.17, 0.17, 0.17, 0.8)
},
Border = {
Header = spiff.Color(0.2, 0.2, 0.2, 0.8),
Primary = spiff.Color(0.08, 0.08, 0.08, 0.8),
Secondary = spiff.Color(0.11, 0.11, 0.11, 0.6),
Option = spiff.Color(0.14, 0.14, 0.14, 0.8)
},
Text = {
Header = spiff.Color(1, 1, 1, 1),
Primary = spiff.Color(1, 1, 1, 1),
Secondary = spiff.Color(0.4, 0.4, 0.4, 1),
Option = spiff.Color(0.8, 0.8, 0.8, 1)
}
},
-- Le Tigre's a lot softer. It's a little bit more of a catalog look.
--- I use it for footware sometimes...
-- ["Le Tigre"] = {
-- Background = {
-- Header = spiff.Color(0.14, 0.14, 0.14, 0.8),
-- Primary = spiff.Color(0.11, 0.11, 0.11, 0.8),
-- Secondary = spiff.Color(0.14, 0.14, 0.14, 0.6),
-- Option = spiff.Color(0.17, 0.17, 0.17, 0.8)
-- },
-- Border = {
-- Header = spiff.Color(0.2, 0.2, 0.2, 0.8),
-- Primary = spiff.Color(0.08, 0.08, 0.08, 0.6),
-- Secondary = spiff.Color(0.11, 0.11, 0.11, 0.6),
-- Option = spiff.Color(0.14, 0.14, 0.14, 0.8)
-- },
-- Text = {
-- Header = spiff.Color(1, 1, 1, 1),
-- Primary = spiff.Color(1, 1, 1, 1),
-- Secondary = spiff.Color(0.4, 0.4, 0.4, 1),
-- Option = spiff.Color(0.8, 0.8, 0.8, 1)
-- }
-- },
-- And then the default theme for boring mode
["Project Zomboid"] = {
Background = {
Header = spiff.Color(0, 0, 0, 0.8),
Primary = spiff.Color(0, 0, 0, 0.8),
Secondary = spiff.Color(0, 0, 0, 0.8),
Option = spiff.Color(0, 0, 0, 0.8)
},
Border = {
Header = spiff.Color(0.4, 0.4, 0.4, 1),
Primary = spiff.Color(0.4, 0.4, 0.4, 1),
Secondary = spiff.Color(0.4, 0.4, 0.4, 1),
Option = spiff.Color(0.4, 0.4, 0.4, 0.8)
},
Text = {
Header = spiff.Color(1, 1, 1, 1),
Primary = spiff.Color(1, 1, 1, 1),
Secondary = spiff.Color(1, 1, 1, 1),
Option = spiff.Color(1, 1, 1, 1)
}
}
}
spiff.GetTheme = function()
return Themes[spiff.config.Theme]
end
spiff.AddTheme = function(name, theme)
Themes[name] = theme
end
-- We do it this way because we have to make a copy of each subcolor to make a new table
---- If we don't, then a change to one of these colors would change ALL
spiff.GetColor = function(color)
return { r = color.r, g = color.g, b = color.b, a = color.a }
end
spiff.GetColorMod = function(color, mod)
return { r = color.r * mod, g = color.g * mod, b = color.b * mod, a = color.a * mod }
end
local themeCab = {}
local function spiffInit()
local tcIndex = 1
for n,_ in pairs(Themes) do
themeCab[tcIndex] = n
--table.insert(themeCab, n)
tcIndex = tcIndex + 1
end
if ModOptions and ModOptions.getInstance then
local function apply(data)
local options = data.settings.options
spiff.config.enabled = options.enabled
spiff.config.Theme = themeCab[options.theme]
end
local SETTINGS = {
options_data = {
enabled = {
name = "UI_ModOptions_SpiffUIThemes_Enable",
default = true,
tooltip = getText("UI_ModOptions_SpiffUIThemes_ToolTip"),
OnApplyMainMenu = apply,
OnApplyInGame = apply,
},
theme = {
name = "UI_ModOptions_SpiffUIThemes_Theme",
default = 1,
tooltip = getText("UI_ModOptions_SpiffUIThemes_ToolTip"),
OnApplyMainMenu = apply,
OnApplyInGame = applyGame,
}
},
mod_id = "SpiffUI-Themes",
mod_shortname = "SpiffUI-Themes",
mod_fullname = getText("UI_Name_SpiffUI_Themes")
}
for i,v in ipairs(themeCab) do
SETTINGS.options_data.theme[i] = v
end
local oInstance = ModOptions:getInstance(SETTINGS)
ModOptions:loadFile()
apply({settings = SETTINGS})
Events.OnPreMapLoad.Add(function()
apply({settings = SETTINGS})
end)
end
print(getText("UI_Init_SpiffUI_Themes"))
end
spiff.Boot = spiffInit

View File

@@ -0,0 +1,24 @@
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 - Themes
UI_Init_SpiffUI_Themes = "Hello SpiffUI Themes!",
UI_Name_SpiffUI_Themes = "SpiffUI Themes",
UI_ModOptions_SpiffUIThemes_Enable = "Enable Themes",
UI_ModOptions_SpiffUIThemes_Theme = "Current Theme",
UI_ModOptions_SpiffUIThemes_EnableToolTip = "Disables all Theme Rendering. A full game restart is required.",
UI_ModOptions_SpiffUIThemes_ThemeToolTip = "Select theme to use. A full game restart is required.",
}

View File

@@ -0,0 +1,11 @@
name=SpiffUI-Themes
id=SUI_Theme
authors=dhert
description=An overhaul for the Project Zomboid UI to apply custom coloring
description=
pzversion=41
tags=Interface;Framework;Misc
poster=poster.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 131 KiB