Skip to content

Commit

Permalink
Add GUITextLabel (colour code + currency icon support)
Browse files Browse the repository at this point in the history
  • Loading branch information
Hop311 committed Aug 14, 2024
1 parent 82b16bc commit 7c85ab1
Show file tree
Hide file tree
Showing 17 changed files with 704 additions and 313 deletions.
7 changes: 6 additions & 1 deletion extension/src/openvic-extension/classes/GUINode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ using namespace OpenVic;

#define APPLY_TO_CHILD_TYPES(F) \
F(Button, button) \
F(Label, label) \
F(GUITextLabel, gui_text_label) \
F(Panel, panel) \
F(TextureProgressBar, progress_bar) \
F(TextureRect, texture_rect) \
Expand Down Expand Up @@ -90,6 +90,7 @@ void GUINode::_bind_methods() {
OV_BIND_SMETHOD(int_to_string_suffixed, { "val" });
OV_BIND_SMETHOD(float_to_string_suffixed, { "val" });
OV_BIND_SMETHOD(float_to_string_dp, { "val", "decimal_places" });
OV_BIND_SMETHOD(float_to_string_dp_dynamic, { "val" });
OV_BIND_SMETHOD(format_province_name, { "province_identifier" });
}

Expand Down Expand Up @@ -266,6 +267,10 @@ String GUINode::float_to_string_dp(float val, int32_t decimal_places) {
return Utilities::float_to_string_dp(val, decimal_places);
}

String GUINode::float_to_string_dp_dynamic(float val) {
return Utilities::float_to_string_dp_dynamic(val);
}

String GUINode::format_province_name(String const& province_identifier) {
if (!province_identifier.is_empty()) {
static const String province_prefix = "PROV";
Expand Down
8 changes: 5 additions & 3 deletions extension/src/openvic-extension/classes/GUINode.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
#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/line_edit.hpp>
#include <godot_cpp/classes/node.hpp>
#include <godot_cpp/classes/panel.hpp>
Expand All @@ -25,6 +24,7 @@
#include "openvic-extension/classes/GUIListBox.hpp"
#include "openvic-extension/classes/GUIOverlappingElementsBox.hpp"
#include "openvic-extension/classes/GUIScrollbar.hpp"
#include "openvic-extension/classes/GUITextLabel.hpp"

namespace OpenVic {
class GUINode : public godot::Control {
Expand Down Expand Up @@ -52,7 +52,7 @@ namespace OpenVic {
static godot::Vector2 get_gui_position(godot::String const& gui_scene, godot::String const& gui_position);

static godot::Button* get_button_from_node(godot::Node* node);
static godot::Label* get_label_from_node(godot::Node* node);
static GUITextLabel* get_gui_text_label_from_node(godot::Node* node);
static godot::Panel* get_panel_from_node(godot::Node* node);
static godot::TextureProgressBar* get_progress_bar_from_node(godot::Node* node);
static godot::TextureRect* get_texture_rect_from_node(godot::Node* node);
Expand All @@ -62,7 +62,7 @@ namespace OpenVic {
static godot::LineEdit* get_line_edit_from_node(godot::Node* node);

godot::Button* get_button_from_nodepath(godot::NodePath const& path) const;
godot::Label* get_label_from_nodepath(godot::NodePath const& path) const;
GUITextLabel* get_gui_text_label_from_nodepath(godot::NodePath const& path) const;
godot::Panel* get_panel_from_nodepath(godot::NodePath const& path) const;
godot::TextureProgressBar* get_progress_bar_from_nodepath(godot::NodePath const& path) const;
godot::TextureRect* get_texture_rect_from_nodepath(godot::NodePath const& path) const;
Expand Down Expand Up @@ -91,6 +91,8 @@ namespace OpenVic {
static godot::String int_to_string_suffixed(int64_t val);
static godot::String float_to_string_suffixed(float val);
static godot::String float_to_string_dp(float val, int32_t decimal_places);
// 3dp if abs(val) < 2 else 2dp if abs(val) < 10 else 1dp
static godot::String float_to_string_dp_dynamic(float val);
static godot::String format_province_name(godot::String const& province_identifier);

godot::Ref<godot::BitMap> get_click_mask() const;
Expand Down
Loading

0 comments on commit 7c85ab1

Please sign in to comment.