jakub742
Active Member
Hi, I recently started to implement item tooltip into my server and i would like to share my current progress. Maybe it will help some people.
Tfs source changes: Added tooltips for inventory items · OTCv8/forgottenserver@7f5b4fb (https://github.com/OTCv8/forgottenserver/commit/7f5b4fbc08711124dec86b0fcd7bfd78dd1165c4)
Otclientv8:
How can I add colors to the sqm of rare, epic, legendary items? OTclient (https://otland.net/threads/how-can-i-add-colors-to-the-sqm-of-rare-epic-legendary-items-otclient.287456/#post-2741182)
From this post i edited containers.lua with "setFrames()" function.
Rarity frames worked in containers, however i wanted to have rarity frames in inventory aswell.
EDIT: there was bug in containers.lua that was causing frames to be still visible in containers after moving them to another container. (Thanks @Mateus Robeerto) updates are present in the PR link below.
Inventory frames:
To show rarity frame inside inventory add following function in modules/game_inventory/inventory.lua:
above function
inside onInventoryChange add
after

After this frames are visible in inventory

Tooltip different color for item name based on rarity:
Next i tried to change the color of text in modules/corelib/ui/tooltip.lua
I wanted different color in tooltips based on item rarity.
My first attempt resulted in full text in color similar to @Itutorial in OTClient - Where are otclient's tooltips handled? (https://otland.net/threads/where-are-otclients-tooltips-handled.290034/)

(maybe u can use this as example
)
In tooltip.lua i made second label widget toolTipLabel2.
toolTipLabel - contains item name (split after first new line \n)
toolTipLabel2 - contains rest of text
So we can set different colors for those 2 labels by :setColor()
Color codes used for "rare", "epic" and "legendary" used from WoW wiki: API GetItemQualityColor (https://wowpedia.fandom.com/wiki/API_GetItemQualityColor)
You can use this example to create another widget that will hold bonus stats, for example that can have different color.
Video:
If you hate my code dont hesitate to comment
Using this for rarity drops - [TFS 1.X] Rarity Rolls & Custom Attributes Library
Full commit with changes for OTclientV8 - Itemtooltip + rarity frames + name by jakub742 · Pull Request #1 · jakub742/otclientv8 (https://github.com/jakub742/otclientv8/pull/1/files)
Hope it will help someone
(Tested in Nekiro TFS 1.5 Downgrade)
Tfs source changes: Added tooltips for inventory items · OTCv8/forgottenserver@7f5b4fb (https://github.com/OTCv8/forgottenserver/commit/7f5b4fbc08711124dec86b0fcd7bfd78dd1165c4)
Otclientv8:
How can I add colors to the sqm of rare, epic, legendary items? OTclient (https://otland.net/threads/how-can-i-add-colors-to-the-sqm-of-rare-epic-legendary-items-otclient.287456/#post-2741182)
From this post i edited containers.lua with "setFrames()" function.
Rarity frames worked in containers, however i wanted to have rarity frames in inventory aswell.
EDIT: there was bug in containers.lua that was causing frames to be still visible in containers after moving them to another container. (Thanks @Mateus Robeerto) updates are present in the PR link below.
Inventory frames:
To show rarity frame inside inventory add following function in modules/game_inventory/inventory.lua:
LUA:
local function setFrames(item, itemWidget)
local name = item:getTooltip()
if (name) then
if (string.find(name, "legendary")) then
itemWidget:setImageSource('/images/ui/rarity_gold')
elseif (string.find(name, "epic")) then
itemWidget:setImageSource('/images/ui/rarity_purple')
elseif (string.find(name, "rare")) then
itemWidget:setImageSource('/images/ui/rarity_blue')
end
end
end
above function
Code:
onInventoryChange(player, slot, item, oldItem)
inside onInventoryChange add
Code:
setFrames(item, itemWidget)
Code:
itemWidget:setItem(item)

After this frames are visible in inventory

Tooltip different color for item name based on rarity:
Next i tried to change the color of text in modules/corelib/ui/tooltip.lua
I wanted different color in tooltips based on item rarity.
My first attempt resulted in full text in color similar to @Itutorial in OTClient - Where are otclient's tooltips handled? (https://otland.net/threads/where-are-otclients-tooltips-handled.290034/)

(maybe u can use this as example

In tooltip.lua i made second label widget toolTipLabel2.
toolTipLabel - contains item name (split after first new line \n)
toolTipLabel2 - contains rest of text
So we can set different colors for those 2 labels by :setColor()
Color codes used for "rare", "epic" and "legendary" used from WoW wiki: API GetItemQualityColor (https://wowpedia.fandom.com/wiki/API_GetItemQualityColor)
You can use this example to create another widget that will hold bonus stats, for example that can have different color.
Video:
If you hate my code dont hesitate to comment

Using this for rarity drops - [TFS 1.X] Rarity Rolls & Custom Attributes Library
Full commit with changes for OTclientV8 - Itemtooltip + rarity frames + name by jakub742 · Pull Request #1 · jakub742/otclientv8 (https://github.com/jakub742/otclientv8/pull/1/files)
Hope it will help someone

Last edited: