Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Idea: port some useful controls from min-shaping branch #14

Closed
mrezai opened this issue Oct 29, 2019 · 3 comments
Closed

Idea: port some useful controls from min-shaping branch #14

mrezai opened this issue Oct 29, 2019 · 3 comments

Comments

@mrezai
Copy link
Contributor

mrezai commented Oct 29, 2019

I think it's a good idea to port some useful controls from min-shaping branch to this repository. I really lost my hope that your incredible work finally merged even in Godot 4!
If we have a simple multi language game as demo we can identify which controls are most useful.
these are some controls that seems as good candidate to port:

  • LineEdit (ported, create user profile, sing in etc..)
  • Label (ported, show score, help etc...)
  • Button
  • Checkbox
  • OptionButton (select language)
  • Sliders (set sound volume etc..)
  • Dialogs (confirm, errors etc...)
@bruvzg
Copy link
Owner

bruvzg commented Oct 29, 2019

All Godot controls can act as a container, for the buttons (and similar controls) you can always add TLLabel as a child, set it to fill parent control size and ignore mouse input and get fully functional controls.


Another option without porting controls (this will work as module, won't work as GDNative and essentially what was done in shaping PRs) is to add a wrapper for the new font system, most controls draw text by calling .draw(text) from the font and do not care about font internals.

Here's test branch: https://github.com/bruvzg/godot_tl/tree/font_wrapper, but it requires tiny change to the core engine:

diff --git a/scene/resources/font.h b/scene/resources/font.h
index 9b99b85d22..dcedc602ee 100644
--- a/scene/resources/font.h
+++ b/scene/resources/font.h
@@ -49,12 +49,12 @@ public:
 	virtual float get_descent() const = 0;
 
 	virtual Size2 get_char_size(CharType p_char, CharType p_next = 0) const = 0;
-	Size2 get_string_size(const String &p_string) const;
+	virtual Size2 get_string_size(const String &p_string) const;
 	Size2 get_wordwrap_string_size(const String &p_string, float p_width) const;
 
 	virtual bool is_distance_field_hint() const = 0;
 
-	void draw(RID p_canvas_item, const Point2 &p_pos, const String &p_text, const Color &p_modulate = Color(1, 1, 1), int p_clip_w = -1, const Color &p_outline_modulate = Color(1, 1, 1)) const;
+	virtual void draw(RID p_canvas_item, const Point2 &p_pos, const String &p_text, const Color &p_modulate = Color(1, 1, 1), int p_clip_w = -1, const Color &p_outline_modulate = Color(1, 1, 1)) const;
 	void draw_halign(RID p_canvas_item, const Point2 &p_pos, HAlign p_align, float p_width, const String &p_text, const Color &p_modulate = Color(1, 1, 1), const Color &p_outline_modulate = Color(1, 1, 1)) const;
 
 	virtual bool has_outline() const { return false; }

This should work with everything except ItemList in the icon view mode, Label, LineEdit, TextEdit and RichTextLabel.

@mrezai
Copy link
Contributor Author

mrezai commented Oct 29, 2019

You are very productive, I'm speechless so I'm typing:)
I will test font_wrapper branch tomorrow.
Thanks

@mrezai
Copy link
Contributor Author

mrezai commented Oct 30, 2019

I tested font_wrapper branch and I got these errors when I want to set custom fonts but text rendered fine:

ERROR: set_base_font: Type mismatch
   At: modules/godot_tl/src/resources/tl_shaped_string.cpp:838.
ERROR: load: Can't open dynamic font file: ""
   At: modules/godot_tl/src/resources/tl_dynamic_font.cpp:466.

Maybe it's a good idea to mention this branch in README of project because I think using libgdtl as module with this patch is best option for someone that want support CTL languages in games.

@mrezai mrezai closed this as completed Jan 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants