PSOBB Addon Plugin (Lua UI addons)

I am not sure if ill be able to figure that out maybe @Ender has an idea I think the way my current name coloring works doesnt allow for that.
Nah no idea. Looks like this is how imgui just renders text when it starts at a specific X pos. The highlighted lines are a single text call so it wraps back to the beginning.

You would probably have to add something new to the base plugin to get around this that specifies the cursor's X position for lines after the wrap.

Maybe there's a way to calculate the text extent and split it into two strings--one for the first part and then a new line that starts with X pos == 0 for the wrapped text call. But I don't know if Imgui provides the text extent somewhere and the font size isn't really the width of the text.
 
I am not sure if ill be able to figure that out maybe @Ender has an idea I think the way my current name coloring works doesnt allow for that.

Also after enders PR ill prob add a setting so players can choose their highlight color.
I've figured out how to get the text to wrap the way I want it to but I don't use github. I also wouldn't say that its a good solution.
local namePadding = ""
while imgui.CalcTextSize(namePadding) < imgui.CalcTextSize(nameFormat)-imgui.CalcTextSize(" ") do
namePadding = namePadding .. " "
end
imgui.SetCursorPos(imgui.GetCursorPosX()-imgui.CalcTextSize(namePadding), imgui.GetCursorPosY())
imgui.TextWrapped(namePadding .. options.clMessageSeparator .. formattedText)
The idea is to start the text portion of the message at the same place as the name starts so the line wrap starts at the far left and just add spaces to the beginning so that the messages text doesn't overlap the name.
One issue is that a bunch of spaces won't always line up nicely with the end of the name to place the separator so I've dynamically moved the starting position so that the separator does line up but the wrapped text might be a tiny bit indented. I couldn't figure out a way to get both to line up every time so I had to pick one.
 
I've found another issue. It appears that if you've used /modname on a character it won't highlight anymore.
you sure it isnt due to character name length? It looks like Enders code only allowed up to named 7 characters long the issue was
return read_pso_str(player + CHARACTERNAME_OFFSET, 20)
each letter of a characters name is 2 bytes so 20 would in theory work but the issue is there are some characters prior to the character name which we skip but still use part of that 20, I increased it to 24 and it seems to read them all now. (10 letter max)

I just pushed a fix for that as well as a few other things, Let me know more into on your word wrap and I can make it into a toggle setting.
433053974-d8a8045d-ab3b-41b3-af7e-5634acb46129.png
 
you sure it isnt due to character name length? It looks like Enders code only allowed up to named 7 characters long the issue was
return read_pso_str(player + CHARACTERNAME_OFFSET, 20)
each letter of a characters name is 2 bytes so 20 would in theory work but the issue is there are some characters prior to the character name which we skip but still use part of that 20, I increased it to 24 and it seems to read them all now. (10 letter max)

I just pushed a fix for that as well as a few other things, Let me know more into on your word wrap and I can make it into a toggle setting.
View attachment 24129
Still doesn't seem to fix it
YlnNiBe.png
 
  • Like
Reactions: Esc
Hi folks! I'm a newbie lua programmer and I really wished for this addon to have a toggle for coloring player's names according to their section ID, so I modified it to do just that! In the get_chat_log() function, It matches the sanitizedName of a message to the player's pointer in memory, then gets their section ID off of that and attaches it as the 4th row of the message. Then, if the option is toggled on, it bases the coloring of nameFormat off the sectionID instead of the options.clNameColor values in the final part of the DoChat() function.

This method has the major flaw that if two players are present with the exact same name but different section IDs, the section ID of whichever player happens to be loaded first in memory will be used for both their messages. However, it has otherwise worked wonderfully in the little testing I've done.

Would this kind of addition be welcome to the project's github? I'd welcome any and all feedback with the edits should I submit them; my inexperience means that there might be bugs or inefficiency issues I'm not aware of.
 
Back
Top