Domestic Science-Luxury Sliders made draggable - #979
Conversation
…t native HSlider.
ajhalme
left a comment
There was a problem hiding this comment.
Sliders are sliding great. In-scene texture embedding worth another look.
Added controllerId as a parameter to the MsgChangeSliders constructor so it can be fully independant. Added min/max values for science and luxury rates.
Removed (manually) previous refereneces to textures from the godot scene.
|
This looks like it works in the way we want (on my machine 😛) Please have a look and let me know. Thanks for the guidance and feedback to the both of you! |
|
I have another scene, with the exact same setup, and it seems that it doesn't work. The moment you save the .tscn for any reason, the textures are regenarated. I will try this in a while with this one too, because I think I only tested it with building and running the game, not altering and saving a scene. Sometimes, I 'll do the simplest thing, like turning the visibility of a node off, saving the scene, turn it on again, save again, then I will start getting the textures from Civ3TextureRect and Civ3TextureButton items, and it will get corrupted, throwing null pointers at literally stuff like, The struggle is real with this one, I feel like I keep fighting the engine... |
Existing or new? If existing, and these are the cases I manually "fixed", then this is kind of expected: texture loading isn't custom everywhere yet. |
It was actually the same scene, just on a different branch. It wasn't the textures you are referring to, because I took the packed array rgba data and displayed it, so i know that each and every one was one of mine. No matter, I have come up with a different approach, so it's mostly irrelevant now. |
ajhalme
left a comment
There was a problem hiding this comment.
LGTM.
The Godot editor event detection hack in Civ3HSlider is not to my liking, but at least it's neatly tucked away in that class. I suppose every engine has it's little quirks.
|
Leaving this comment here as it will be removed from the code, but I think it's still helpful. Unlike Civ3TextureButton or Civ3TextureRect where properties like Texture, TextureNormal, etc, are exposed in their parent classes, when we override a theme, godot seems to do some behind the scenes (pun not intended) magic . So it's not enough to expose our custom texture fields, and then use _ValidateProperty and Util.ApplyNoSaveFlag to prevent godot from serializing the image textures. We do this "hacky" thing where before godot saves the scene in the editor, we remove all the theme overrides, godot saves the scene, and re-applies them.It needs a bigger setup than I would prefer, but currently seems to be the most reliable way of preventing godot from serializing the textures. This is the post I found that helped with this (had to use some chatgpt help to translate it to c#): https://forum.godotengine.org/t/prevent-generated-resources-from-being-serialized-in-the-tscn/46562/3 |
|
Sorry for changing things again a little bit, but i think this is for the better, given the situation. You 'll see now that the Civ3HSlider (and while I was at it, I added the Civ3VSlider equivalent) has an interface, which might not make much sense now, but while I am working on the side on the custom scrollbar, I realised that I needed a way to get a generic ScrollBar node so I can apply the theme (I can't expose the interface to Godot). The Civ3RangeTheme is a way to have a centralized implementation for the various Civ3V-Range-Like and Civ3H-Range-Like stuff. I cycled through many different variations of this, and I had some back and forth with ChatGPT, which has helped a lot with the Godot UI stuff. This is far from vibe-coded, I haven't used any AI for this project in a long time, just making sure I am transparent I guess.. Let me know if you have any quiestions/suggestions. |
I don't like it much either, but as I said it seems to be the only way to not have theme overrides serialize the textures. |
ajhalme
left a comment
There was a problem hiding this comment.
Working fine, changes look reasonable. Left a renaming suggestion.
|
🚢 |
|
Ahoy! |
Made the icons for science and luxury sliders draggable using the godot native HSlider.
Update the plus/minus textures as they were using some other file, and removed the shadow which is causing some texture artefacts.
I am working on some bigger UI stuff, and I wanted to see how the draggable sliders work, so instead of creating a prototype just for this, I figured I'd use the opportunity to update the domistic advisor sliders.
I think I am going to update the scrollbar next, as this is mainly what I wanted to figure out in the first place.
EDIT:
Found this after pushing this, you can update the sliders by clicking on the (invisible) slider bar. I guess that's ok.
My only concern is that it extends a bit "outside" what looks like the bar in the UI so it might be confusing as to why it moves when you click a bit outside the bar?