luapower / support

Luapower support forum
0 stars 1 forks source link

setting text color? #4

Open PhilMo6 opened 4 years ago

PhilMo6 commented 4 years ago

Im working on making a twitch chat overlay with luapower and so far its been easy going but I cannot seem to figure out how to set color of text at all. Background color of the main window is fairly easy but otherwise iv had no luck...

capr commented 4 years ago

Hi,

What library are you using for rendering text?

PhilMo6 commented 4 years ago

Honestly I was just using winapi.Label, might not be possable to change text color using this from what I can see. The tr0 library might be better for my needs. I should probably sleep more, it helps when trying to figure stuff out!

capr commented 4 years ago

Make sure to check on the lib's status before using it. Many libs in here are quite low level and some are not even finished. Generally speaking, you need to know what you're doing and understand the trade-offs of different approaches (eg. doing your own text rendering vs using WinAPI, etc).

PhilMo6 commented 4 years ago

I was thinking about using the tr0 library even though its unmaintained. Looks like itll support emojis as well as colored text.

On Tue, Nov 3, 2020, 9:41 AM Cosmin Apreutesei notifications@github.com wrote:

Make sure to check on the lib's status before using it. Many libs in here are quite low level and some are not even finished. Generally speaking, you need to know what you're doing and understand the trade-offs of different approaches (eg. doing your own text rendering vs using WinAPI, etc).

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/luapower/support/issues/4#issuecomment-721278458, or unsubscribe https://github.com/notifications/unsubscribe-auth/AFMUSQOMC7JJ7SWKNY633MLSOA6FZANCNFSM4TILFOAQ .

PhilMo6 commented 4 years ago

So using ui0 iv gotten things working but now I am trying to use a text tree to have better control over text coloration. I'm having an issue when I update the content of the scrollbox that's my main chat layer. I'm trying to just set the contents text with the updated text tree to cause it to rebuild the text the segments its actually drawing. If I replace it with a string it works fine but if I replace the contents text with the updated text tree it throws an Assertion failed! message and crashes. I'm hoping that I am just failing figure out how I am actually supposed to update the text tree of the scrollbox contents.

The important part of the error is

D:\gcc-lua\luapower\bin\mingw64....\utf8.lua:44: attempt to compare number with nil stack traceback: D:\gcc-lua\luapower\bin\mingw64....\utf8.lua:44: in function 'next' D:\gcc-lua\luapower\bin\mingw64....\utf8.lua:139: in function 'decode' D:\gcc-lua\luapower\bin\mingw64....\tr0.lua:1948: in function 'insert' D:\gcc-lua\luapower\bin\mingw64....\tr0.lua:2015: in function 'replace' .\ui0.lua:4214: in function 'set' D:\gcc-lua\luapower\bin\mingw64....\oo.lua:113: in function '__newindex' main.lua:194: in function 'updateChatbox' main.lua:430: in function

My code is here if you want to check it out. The error happens when I update the chat window so you just enter some text into the edit box. https://github.com/PhilMo6/TwitchChatOverlay

PhilMo6 commented 4 years ago

Ah figured it out! Had to do chatBoxContent._text = false chatBoxContent._text_tree = false chatBoxContent.text_segments = false first. Now it works perfect! Gotta say its been rather easy to work with for the most part so thanks for all the effort you have put into this project!