ESOUI

ESOUI (https://www.esoui.com/forums/index.php)
-   Tech Chat (https://www.esoui.com/forums/forumdisplay.php?f=168)
-   -   How to change object's title (Fishing)? (https://www.esoui.com/forums/showthread.php?t=7597)

zykis39 01/30/18 04:40 AM

How to change object's title (Fishing)?
 
Hello! I am kinda trying out making first addon.
I want a fishing bait to be named under each source of fish.
Instead of standard "Fishing Hole" -> "Fishing Hole (Crawlers)" for example.
So, the question is: can i change title of the fishing holes? If yes, how can i achieve that? Thanks in advance!

Shinni 01/30/18 05:55 AM

Think of your question in a different way. Instead of renaming the fishing hole, you actually just want to display a different text under the cursor.

You can find the code for the cursor here: https://github.com/esoui/esoui/blob/...le/reticle.lua
By looking at it (I haven't tested it) the reticle text is set in this line:
https://github.com/esoui/esoui/blob/...ticle.lua#L237

You see that the function returns true, if a new text was set to the reticle/cursor, so you can do the following to change the displayed text:
Lua Code:
  1. local originalFunction = ZO_Reticle.TryHandlingInteraction -- remember the original function
  2. function ZO_Reticle:TryHandlingInteraction(...) -- override the function because we want to change the text
  3.     local success = originalFunction(self, ...) -- change the text as originally intended
  4.     -- if a new text was set
  5.     if success then
  6.         -- check if target is a fishing hole
  7.         local additionalInfo = select(5, GetGameCameraInteractableActionInfo())
  8.         if additionalInfo == ADDITIONAL_INTERACT_INFO_FISHING_NODE then
  9.             -- add the crawler information
  10.             self.interactContext:SetText(self.interactContext:GetText() .. " (Crawler)")
  11.         end
  12.     end
  13. end

I have not tested this code, it's just what I would try after reading the source code of ZO_Reticle. So beware of bugs.

zykis39 01/30/18 06:52 AM

Quote:

Originally Posted by Shinni (Post 33774)
Think of your question in a different way. Instead of renaming the fishing hole, you actually just want to display a different text under the cursor.

You can find the code for the cursor here: https://github.com/esoui/esoui/blob/...le/reticle.lua
By looking at it (I haven't tested it) the reticle text is set in this line:
https://github.com/esoui/esoui/blob/...ticle.lua#L237

You see that the function returns true, if a new text was set to the reticle/cursor, so you can do the following to change the displayed text:
Lua Code:
  1. local originalFunction = ZO_Reticle.TryHandlingInteraction -- remember the original function
  2. function ZO_Reticle:TryHandlingInteraction(...) -- override the function because we want to change the text
  3.     local success = originalFunction(self, ...) -- change the text as originally intended
  4.     -- if a new text was set
  5.     if success then
  6.         -- check if target is a fishing hole
  7.         local additionalInfo = select(5, GetGameCameraInteractableActionInfo())
  8.         if additionalInfo == ADDITIONAL_INTERACT_INFO_FISHING_NODE then
  9.             -- add the crawler information
  10.             self.interactContext:SetText(self.interactContext:GetText() .. " (Crawler)")
  11.         end
  12.     end
  13. end

I have not tested this code, it's just what I would try after reading the source code of ZO_Reticle. So beware of bugs.

Wow! Looks like that's what i was looking for!
Would you suggest any resources, where i can grab a ZO_XXX class or functions descriptions? Didn't even knew of ZO_Reticle existance.

votan 01/30/18 07:50 AM

Quote:

Originally Posted by zykis39 (Post 33775)
Wow! Looks like that's what i was looking for!
Would you suggest any resources, where i can grab a ZO_XXX class or functions descriptions? Didn't even knew of ZO_Reticle existance.

Look here: http://www.esoui.com/downloads/info1...ourcecode.html
Source Code Documentation
Documentation Source Code


All times are GMT -6. The time now is 11:24 PM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2014 - 2022 MMOUI