diff options
author | hop311 <hop3114@gmail.com> | 2023-12-30 15:59:20 +0100 |
---|---|---|
committer | hop311 <hop3114@gmail.com> | 2023-12-30 15:59:20 +0100 |
commit | c0cc6e202c33fb3889d0025b1b04148ae66545f2 (patch) | |
tree | 65ef49b0d12cf307269defeb0960f25ea442f777 /extension/src/openvic-extension/classes/GFXButtonStateTexture.hpp | |
parent | f2f42d1b65605876a6ec12626be55183b4681b88 (diff) |
Added button state textures + block colour progress bars
Diffstat (limited to 'extension/src/openvic-extension/classes/GFXButtonStateTexture.hpp')
-rw-r--r-- | extension/src/openvic-extension/classes/GFXButtonStateTexture.hpp | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/extension/src/openvic-extension/classes/GFXButtonStateTexture.hpp b/extension/src/openvic-extension/classes/GFXButtonStateTexture.hpp new file mode 100644 index 0000000..32f4087 --- /dev/null +++ b/extension/src/openvic-extension/classes/GFXButtonStateTexture.hpp @@ -0,0 +1,46 @@ +#pragma once + +#include <godot_cpp/classes/image_texture.hpp> + +#include <openvic-simulation/utility/Getters.hpp> + +namespace OpenVic { + class GFXButtonStateTexture : public godot::ImageTexture { + GDCLASS(GFXButtonStateTexture, godot::ImageTexture) + + public: + enum ButtonState { + HOVER, + PRESSED, + DISABLED + }; + + private: + ButtonState PROPERTY(button_state); + godot::Ref<godot::Image> state_image; + + protected: + static void _bind_methods(); + + public: + GFXButtonStateTexture(); + + /* Create a GFXButtonStateTexture using the specified godot::Image. Returns nullptr if generate_state_image fails. */ + static godot::Ref<GFXButtonStateTexture> make_gfx_button_state_texture( + ButtonState button_state, godot::Ref<godot::Image> const& source_image = nullptr + ); + + /* Set the ButtonState to be generated by this class (calling this does not trigger state image generation). */ + void set_button_state(ButtonState new_button_state); + + /* Generate a modified version of source_image and update the underlying godot::ImageTexture to use it. */ + godot::Error generate_state_image(godot::Ref<godot::Image> const& source_image); + + static godot::StringName const& get_generate_state_image_func_name(); + + static godot::StringName const& button_state_to_theme_name(ButtonState button_state); + godot::StringName const& get_button_state_theme() const; + }; +} + +VARIANT_ENUM_CAST(OpenVic::GFXButtonStateTexture::ButtonState); |