1require
"ISUI/ISToolTipInv"
8 local maxLineLength = 28
14 for word in
string.gmatch(text,
"%S+")
do
22 if lineLength +
wordLength <= maxLineLength then
23 line = line ..
" " ..
word
26 table.insert(lines, line)
32 table.insert(lines, line)
42 local textureWidth, textureHeight = 64, 64
43 local
font = objTooltip:getFont()
44 local lineSpace = objTooltip:getLineSpacing()
51 objTooltip:DrawText(
font, itemName, 5.0,
yOffset, 1.0, 1.0, 0.8, 1.0)
52 objTooltip:adjustWidth(5, itemName)
55 local yTextureOffset = textureHeight + 10
56 objTooltip:DrawTextureScaled(
item:getTexture(), panel:getWidth() - textureWidth - 15, 5, textureWidth, textureHeight, 0.75)
62 objTooltip:adjustWidth(5,
v)
66 if yTextureOffset >
yOffset then
70 panel:drawRect(0,
yOffset, panel:getWidth(), 1, panel.borderColor.
a, panel.borderColor.r, panel.borderColor.g, panel.borderColor.b)
74 objTooltip:DrawText(
font,
item:getDisplayName(), 5.0,
yOffset, 1.0, 1.0, 0.8, 1.0)
75 objTooltip:adjustWidth(5,
item:getDisplayName())
78 local yTextureOffset = textureHeight + 10
79 objTooltip:DrawTextureScaled(
item:getTexture(), panel:getWidth() - textureWidth - 15, 5, textureWidth, textureHeight, 0.75)
86 objTooltip:adjustWidth(5,
v)
91 if yTextureOffset >
yOffset then
95 panel:drawRect(0,
yOffset, panel:getWidth(), 1, panel.borderColor.
a, panel.borderColor.r, panel.borderColor.g, panel.borderColor.b)
100 local layoutTooltip = objTooltip:beginLayout()
101 layoutTooltip:setMinLabelWidth(128)
108 for k,
v in pairs(itemCustomFields) do
109 layout = layoutTooltip:addItem()
110 layout:setLabel(k .. ":", 1, 1, 0.8, 1)
112 if
type(
v) == "
boolean" then
114 layout:setValue("Yes", 1, 1, 1, 1)
116 layout:setValue("No", 1, 1, 1, 1)
122 layout:setValue(
v, 1, 1, 1, 1)
128 local weightEquipped =
item:getCleanString(
item:getEquippedWeight())
129 local weightUnequipped =
item:getUnequippedWeight()
130 layout = layoutTooltip:addItem()
131 layout:setLabel("Weight (Unequipped):", 1, 1, 0.8, 1)
133 if weightUnequipped > 0 and weightUnequipped < 0.01 then
134 weightUnequipped = "<0.01"
136 weightUnequipped =
item:getCleanString(weightUnequipped)
139 if not
item:isEquipped() then
140 layout:setValue("*" .. tostring(weightUnequipped) .. "*", 1, 1, 1, 1)
142 layout:setValue(tostring(weightUnequipped), 1, 1, 1, 1)
145 layout = layoutTooltip:addItem()
146 layout:setLabel("Weight (Equipped):", 1, 1, 0.8, 1)
148 if
item:isEquipped() then
149 layout:setValue("*" .. tostring(weightEquipped) .. "*", 1, 1, 1, 1)
151 layout:setValue(tostring(weightEquipped), 1, 1, 1, 1)
155 if not
item:IsWeapon() and not
item:IsClothing() and not
item:IsDrainable() and not
string.match(
item:getFullType(), "Walkie") then
156 local unequippedWeight =
item:getUnequippedWeight()
158 if unequippedWeight > 0 and unequippedWeight < 0.01 then
159 unequippedWeight = 0.01
162 layout:setValueRightNoPlus(unequippedWeight)
163 elseif
item:isEquipped() then
164 local equippedWeight =
item:getCleanString(
item:getEquippedWeight())
166 layout:setValue(equippedWeight .. " (" ..
item:getCleanString(
item:getUnequippedWeight()) .. " " .. getText("Tooltip_item_Unequipped") .. ")", 1.0, 1.0, 1.0, 1.0)
167 elseif
item:getAttachedSlot() > -1 then
168 local hotbarEquippedWeight =
item:getCleanString(
item:getHotbarEquippedWeight())
170 layout:setValue(hotbarEquippedWeight .. " (" ..
item:getCleanString(
item:getUnequippedWeight()) .. " " .. getText("Tooltip_item_Unequipped") .. ")", 1.0, 1.0, 1.0, 1.0)
172 local unequippedWeight =
item:getCleanString(
item:getUnequippedWeight())
174 layout:setValue(unequippedWeight .. " (" ..
item:getCleanString(
item:getEquippedWeight()) .. " " .. getText("Tooltip_item_Equipped") .. ")", 1.0, 1.0, 1.0, 1.0)
178 if
item:getTooltip() ~=
nil then
179 layout = layoutTooltip:addItem()
180 layout:setLabel(getText(
item:getTooltip()), 1, 1, 0.8, 1)
184 objTooltip:endLayout(layoutTooltip)
188 if objTooltip:getWidth() < 256 then
189 objTooltip:setWidth(256)
193ISToolTipInv.render = function(
self)
194 local mx = getMouseX() + 24
195 local my = getMouseY() + 24
197 if not
self.followMouse then
200 if
self.anchorBottomLeft then
201 mx =
self.anchorBottomLeft.
x
202 my =
self.anchorBottomLeft.
y
222 local myCore = getCore();
223 local maxX = myCore:getScreenWidth();
224 local maxY = myCore:getScreenHeight();
229 self.
tooltip:setX(math.max(0, math.min(mx + 11, maxX - tw - 1)));
231 if not
self.followMouse and
self.anchorBottomLeft then
232 self.
tooltip:setY(math.max(0, math.min(my - th, maxY - th - 1)));
234 self.
tooltip:setY(math.max(0, math.min(my, maxY - th - 1)));
239 self:setWidth(tw + 11);
242 if
self.followMouse then
243 self:adjustPositionToAvoidOverlap({
void if self initialFaction and v()
void local itemInstance()
void self createCharacterButton font()
void if not description or description()
void processingNotification backgroundColor a()
void DoTooltip(objTooltip, item, panel)