Feature Complete Shipping V1.0

This commit is contained in:
2026-08-12 22:57:52 -04:00
parent 19e4ac0cce
commit 56b6a46811
30 changed files with 9934 additions and 9361 deletions
@@ -4,6 +4,7 @@ require "ISUI/ISButton"
require "Vehicles/TimedActions/ISPathFindAction"
require "PaintMyKI5/PaintRequirements"
require "PaintMyKI5/PaintInventory"
require "PaintMyKI5/TextureName"
require "PaintMyKI5/TimedActions/ISPaintMyKI5Vehicle"
ISPaintMyKI5UI = ISCollapsableWindow:derive("ISPaintMyKI5UI")
@@ -14,9 +15,9 @@ local FONT_MEDIUM = UIFont.Medium
local SMALL_HEIGHT = getTextManager():getFontHeight(FONT_SMALL)
local MEDIUM_HEIGHT = getTextManager():getFontHeight(FONT_MEDIUM)
local function textureLabel(textureData)
local name = string.match(textureData.texture or "", "([^/]+)$") or ""
return getText("IGUI_PaintMyKI5_Skin", textureData.skinIndex + 1) .. " - " .. name
local function textureLabel(textureData, displayName)
return getText("IGUI_PaintMyKI5_Skin", textureData.skinIndex + 1)
.. " - " .. displayName
end
local function getPaletteColor(itemType)
@@ -28,6 +29,24 @@ local function getPaletteColor(itemType)
return 0.5, 0.5, 0.5
end
local function buildMissingTooltip(missingPaint, missingTools)
local lines = { getText("IGUI_PaintMyKI5_MissingRequirements") }
for _, missing in ipairs(missingTools or {}) do
table.insert(lines, getText(
"IGUI_PaintMyKI5_MissingTool",
getItemNameFromFullType(missing.item)
))
end
for _, missing in ipairs(missingPaint or {}) do
local available = math.floor(missing.available * 100 + 0.5) / 100
table.insert(lines, getText(
"IGUI_PaintMyKI5_MissingPaint",
getItemNameFromFullType(missing.item), missing.required, available
))
end
return table.concat(lines, "\n")
end
function ISPaintMyKI5UI.drawSkinItem(list, y, item, alt)
if item.itemindex == list.selected then
list:drawRect(0, y, list:getWidth(), item.height, 0.25, 0.3, 0.7, 1.0)
@@ -49,8 +68,10 @@ function ISPaintMyKI5UI:createChildren()
self.skinList.drawBorder = true
self:addChild(self.skinList)
for _, textureData in ipairs(self.vehicleData.textures or {}) do
self.skinList:addItem(textureLabel(textureData), textureData)
local textures = self.vehicleData.textures or {}
local textureNames = PaintMyKI5.TextureName.buildLabels(textures)
for index, textureData in ipairs(textures) do
self.skinList:addItem(textureLabel(textureData, textureNames[index]), textureData)
end
local currentIndex = self.vehicle:getSkinIndex()
for index, row in ipairs(self.skinList.items) do
@@ -84,6 +105,8 @@ function ISPaintMyKI5UI:prerender()
ISCollapsableWindow.prerender(self)
local textureData = self:getSelectedTexture()
local enabled = false
local missingPaint = {}
local missingTools = {}
if textureData then
local area = PaintMyKI5.PaintRequirements.findInteractionArea(
self.vehicle, self.character
@@ -91,13 +114,26 @@ function ISPaintMyKI5UI:prerender()
local requirements = PaintMyKI5.PaintRequirements.getRequirements(
self.vehicle, textureData.skinIndex
)
enabled = requirements ~= nil
and PaintMyKI5.PaintRequirements.isValidTarget(
self.character, self.vehicle, textureData.skinIndex, area
local ready = false
if requirements then
ready, missingPaint, missingTools =
PaintMyKI5.PaintInventory.checkPaintingRequirements(
self.character, requirements
)
end
enabled = ready and area ~= nil
and PaintMyKI5.PaintRequirements.isValidSelection(
self.character, self.vehicle, textureData.skinIndex
)
and PaintMyKI5.PaintInventory.checkRequirements(self.character, requirements)
end
self.paintButton:setEnable(enabled)
if enabled then
self.paintButton:setTooltip(nil)
elseif #missingPaint > 0 or #missingTools > 0 then
self.paintButton:setTooltip(buildMissingTooltip(missingPaint, missingTools))
else
self.paintButton:setTooltip(getText("IGUI_PaintMyKI5_Unavailable"))
end
end
function ISPaintMyKI5UI:render()
@@ -162,12 +198,14 @@ function ISPaintMyKI5UI:onPaint()
self.vehicle, textureData.skinIndex
)
if not requirements then return end
local enough = PaintMyKI5.PaintInventory.checkRequirements(self.character, requirements)
local enough = PaintMyKI5.PaintInventory.checkPaintingRequirements(
self.character, requirements
)
if not enough then return end
local area = PaintMyKI5.PaintRequirements.findInteractionArea(self.vehicle, self.character)
if not area then return end
if not PaintMyKI5.PaintRequirements.isValidTarget(
self.character, self.vehicle, textureData.skinIndex, area
if not PaintMyKI5.PaintRequirements.isValidSelection(
self.character, self.vehicle, textureData.skinIndex
) then return end
ISTimedActionQueue.add(ISPathFindAction:pathToVehicleArea(self.character, self.vehicle, area))
@@ -38,7 +38,7 @@ function PaintVehicleContextMenu.onFillWorldObjectContextMenu(player, context, w
PaintVehicleContextMenu.open,
vehicle
)
option.iconTexture = getTexture("media/textures/PaintBrush.png")
option.iconTexture = getTexture("media/textures/PaintMyKI5_ContextMenu.png")
return true
end