Added Rich Text to SimpleTextArea!!!!#1654
Conversation
|
(also i didnt try this on any platform other than windows so idk if this works on others but i think it should be fine :)) |
|
Also, imo it would be convenient if there was a separate type of TextArea specifically for rich text, kinda like Especially since now the |
|
alrighty i committed changes yay :D |
loader/include/Geode/ui/TextArea.hpp
Outdated
| * @param applyToSprite Function to apply the parsed value to a font sprite (optional) | ||
| * @param stringAddition Function to add a new string at the point where the key is (optional) | ||
| */ | ||
| RichTextKey(std::string key, geode::Function<Result<T>(const std::string& value)> validCheck, geode::Function<void(const T& value, cocos2d::CCFontSprite* sprite)> applyToSprite = NULL, geode::Function<std::string(const T& value)> stringAddition = NULL) |
There was a problem hiding this comment.
Maybe this constructor could get cleaned up a bit?
RichTextKey(
std::string key,
geode::Function<Result<T>(const std::string& value)> validCheck,
geode::Function<void(const T& value, cocos2d::CCFontSprite* sprite)> applyToSprite = NULL,
geode::Function<std::string(const T& value)> stringAddition = NULL
)And also, idk how to feel about applyToSprite and stringAddition both having NULL as a default value.
I would have personally defined it something like:
RichTextKey(
std::string key,
geode::Function<Result<T>(const std::string& value)> validCheck,
) : m_key(std::move(key)), m_validCheck(std::move(validCheck)) {}
RichTextKey(
std::string key,
geode::Function<Result<T>(const std::string& value)> validCheck,
geode::Function<void(const T& value, cocos2d::CCFontSprite* sprite)> applyToSprite,
) : m_key(std::move(key), m_validCheck(std::move(validCheck)), m_applyToSprite(std::move(applyToSprite)) {}
RichTextKey(
std::string key,
geode::Function<Result<T>(const std::string& value)> validCheck,
geode::Function<void(const T& value, cocos2d::CCFontSprite* sprite)> applyToSprite,
geode::Function<std::string(const T& value)> stringAddition
) : m_key(std::move(key), m_validCheck(std::move(validCheck)), m_applyToSprite(std::move(applyToSprite)), m_stringAddition(std::move(stringAddition)) {}There was a problem hiding this comment.
Alright :D thats cool i wasent sure of what a good way of writing that was :) ill improve !
|
I still think it would be better to have a separate sorta Final thing I'll say is to make sure the code fits into the code styling guidelines and double check CONTRIBUTING.md while on that. |
|
Also whenever I have time I can try and test it on macOS |
|
Cool ty for telling me about the guidlines and stuff i didnt know about them (im noob) ill try my best to improve this code with everything in here :D will update later dw :DD |
|
well ive attempted to apply some things said in the styling guidelines :D there might be more that i forgot but i still feel like the way i placed my classes or the classes themselves is messy, i dont know why :( |
|
Also i never thought of SimpleTextArea as a "text area thats simple in implementation" cz it always looked so much more complex then the normal TextArea i though of it like "simple text area makes it simple for me to do whatever i want" unlike actual TextArea lol |
|
this might be better as smth that subclasses simpletextarea |
|
Oof :( i really dont understand the problem with it being on the simpletextarea i think its just fine but i respect the opinion and will do something whenever i have the time ig |
|
there have been some updates done to SimpleTextArea that i dont really understand and making it a harder time implementing this cz idk how this works lol, whats the Impl thing you use to separate some things in SimpleTextArea? i thought i would inhairate SimpleTextArea and make a RichTextArea and do what i did before over there but i cant because the charIteration is over at the Impl, how should i go about this? |
|
|
|
I want to see if I can try changing it to have in mind the pimpl changes. I also want to see if I can try and add stuff like links for example so it can "compete" better with I don't promise anything, it's just an idea I have. I want to help, but if I can't or don't have the time or if @abb2k prefers to go solo then I wont. |
|
i wanna add the rich text if u wanna add links using that rich text stuff later u can :D:D |
|
@abb2k Well I don't fully know what the issue is, I will say tho, it'll maybe help if the constructor for Like the destructor's defined but not the constructor somehow |
|
While on that, please resolve the merge conflicts |
|
ye i resolved the merge conflicts ofc and now it builds but also now the rich text isnt working? the functions seem to run but it doesnt update the text at all :( |
|
@abb2k I'll try and fix that in a bit, I'm writing this from my phone so I can't properly check the code rn |
|
thats alright :) im gonna go sleep now so ill see what u do whenever i wake up :D u can do !! :D |
…lol (please tell me if i did this right :D)
|
Ok i fixed the issue but i dont know if this is a good fix for it or if this breaks pimpl so let me know :D |
|
still has random changes like in platform.hpp or loader for example, could you fix those too |
|
@abb2k I can fix those things if you want |
|
ye can you fix any other issues that i know of and can fix :D:D that would be really awesome :D:D:D:D |
|
I am trying to polish the pimpl stuff to try and help, part of me wishes that either the rich text formatting was still in And considering I'm new to both pimpl and ABI... it's a nightmare. But I'll try. |
|
i thought i already fixed it to work just fine :( why is it not good at this point? all we need is to fix the extra issues alk talked about |
|
Really my issues are just code structuring and polish. It's functional but I just wanted to try and make the code cleaner. |
|
This is not to make you feel bad or anything, I am just trying to help (it's ok if you don't want me to do anything). And tbf idk why inheritance with pimpl has to be this hard lol |
|
Im not feeling bad the help is awesome i appreciate it :D what u did helped and fixed the issues alk talked about i think but now for some reason the rich text isnt working :( i didnt have time to test at all but your changes dont seem like they should break anything so idk what happened |
|
alright i fixed rich text it fully works now :D (also i added a wave effect text key and a action for it i hope its ok that i added this i just think this is super duper cool :D:D:D:D) |
| float m_phase; | ||
| float m_baseX; | ||
| float m_baseY; | ||
| }; No newline at end of file |
| ~RichTextArea(); | ||
|
|
||
| class RichImpl; | ||
| std::unique_ptr<SimpleTextAreaImpl> createImpl() override; |
There was a problem hiding this comment.
is this really needed instead of just exposing protected methods to simpletextarea for richtextarea to use
| if (keyDown){ | ||
| for (const auto& linkCharacter : wordClicked) | ||
| { | ||
| castedImpl->m_ogColorForLink.insert({linkCharacter, linkCharacter->getColor()}); |
There was a problem hiding this comment.
can you expose a method for this instead
| @@ -0,0 +1,190 @@ | |||
| #include <Geode/DefaultInclude.hpp> | |||
There was a problem hiding this comment.
these can be just moved to simpletextarea as protected functions
|
|
||
| using namespace geode::prelude; | ||
|
|
||
| class SimpleTextAreaImpl { |
There was a problem hiding this comment.
ideally this class should just not exist in the first place


HIII :D:D:DD
ive wanted this for a while now so i decided to make it myself :D you can now add rich text keys into a SimpleTextArea! :D
you can do so by using
registerRichTextKeyon your SimpleTextArea to add a key and tell iti think this is really cool and i hope u like what i made :D
this might not be the best implementation but u can polish it if you want ofc !!!! i tried my best :D (if you think i did anything wrong or bad i would be happy if you told me i wanna learn!! :D)