diff options
author | Spartan322 <Megacake1234@gmail.com> | 2023-12-30 06:32:13 +0100 |
---|---|---|
committer | Spartan322 <Megacake1234@gmail.com> | 2024-05-07 00:07:50 +0200 |
commit | 7def4dd2e7987c20163c6a419bcc0506b5a670d9 (patch) | |
tree | 671f5b94ab2f0d9d1a59b7fa11ac393e93101958 /extension/src/openvic-extension/classes/GUINode.hpp | |
parent | bf3df0ee900f406a5a2aa56609ecb89c67055351 (diff) |
Improve map view and game panel user experience
Minimizes panel mouse obstruction to scripted panel images
Prevents map view from hovering inside UI elements
Unsets province hover when not over provinces
Add `GUINode.click_mask`
Prevents mouse interactions not within click_mask
Add `GUINode.set_click_mask_from_nodepaths`
Generates click_mask from paths relating to GUINode textures
Sets nodepaths to MOUSE_FILTER_IGNORE
Add CanvasLayer parent to GameSession UI nodes
Set mouse_force_pass_scroll_events to GameSession UI nodes
Set MapControlPanel mouse_filter to default (MOUSE_FILTER_STOP)
Move MapView mouse viewport changes to _input
Move MapView _action_drag released check to _input
Move MapView processing to _process
Remove viewport and window notifications
Disable if window is not focused or input is handled:
MapView mouse interactions (including edge scrolling and drag panning)
MapView province hover
Set mouse_filter to MOUSE_FILTER_IGNORE for ProvinceOverviewPanel province_view panel
Set ProvinceOverviewPanel click_mask path to `province_view/background`
Set mouse_filter to MOUSE_FILTER_IGNORE for Topbar topbar panel
Set Topbar click_mask path to `topbar/topbar_bg` and `topbar/topbar_paper`
Diffstat (limited to 'extension/src/openvic-extension/classes/GUINode.hpp')
-rw-r--r-- | extension/src/openvic-extension/classes/GUINode.hpp | 30 |
1 files changed, 27 insertions, 3 deletions
diff --git a/extension/src/openvic-extension/classes/GUINode.hpp b/extension/src/openvic-extension/classes/GUINode.hpp index 3dbe403..8d926cc 100644 --- a/extension/src/openvic-extension/classes/GUINode.hpp +++ b/extension/src/openvic-extension/classes/GUINode.hpp @@ -1,17 +1,27 @@ #pragma once +#include <godot_cpp/classes/bit_map.hpp> #include <godot_cpp/classes/button.hpp> #include <godot_cpp/classes/check_box.hpp> +#include <godot_cpp/classes/control.hpp> +#include <godot_cpp/classes/image.hpp> +#include <godot_cpp/classes/input_event.hpp> #include <godot_cpp/classes/label.hpp> +#include <godot_cpp/classes/node.hpp> #include <godot_cpp/classes/panel.hpp> +#include <godot_cpp/classes/ref.hpp> +#include <godot_cpp/classes/texture2d.hpp> #include <godot_cpp/classes/texture_progress_bar.hpp> #include <godot_cpp/classes/texture_rect.hpp> +#include <godot_cpp/templates/vector.hpp> +#include <godot_cpp/variant/node_path.hpp> +#include <godot_cpp/variant/rect2.hpp> +#include <godot_cpp/variant/string.hpp> +#include <godot_cpp/variant/vector2.hpp> -#include <openvic-simulation/interface/GUI.hpp> - -#include "openvic-extension/classes/GFXSpriteTexture.hpp" #include "openvic-extension/classes/GFXMaskedFlagTexture.hpp" #include "openvic-extension/classes/GFXPieChartTexture.hpp" +#include "openvic-extension/classes/GFXSpriteTexture.hpp" #include "openvic-extension/classes/GUIListBox.hpp" #include "openvic-extension/classes/GUIOverlappingElementsBox.hpp" #include "openvic-extension/classes/GUIScrollbar.hpp" @@ -20,6 +30,11 @@ namespace OpenVic { class GUINode : public godot::Control { GDCLASS(GUINode, godot::Control) + godot::Ref<godot::BitMap> _click_mask; + godot::Vector<Control*> _mask_controls; + godot::Rect2 _texture_region; + godot::Rect2 _position_rect; + protected: static void _bind_methods(); @@ -73,5 +88,14 @@ namespace OpenVic { static godot::String int_to_formatted_string(int64_t val); static godot::String float_to_formatted_string(float val, int32_t decimal_places); static godot::String format_province_name(godot::String const& province_identifier); + + godot::Ref<godot::BitMap> get_click_mask() const; + void set_click_mask(godot::Ref<godot::BitMap> const& mask); + + void set_click_mask_from_nodepaths(godot::TypedArray<godot::NodePath> const& paths); + bool _update_click_mask_for(godot::Ref<godot::Image> const& img, int index); + void update_click_mask(); + + bool _has_point(godot::Vector2 const& point) const override; }; } |