kameloov / Radial-progress-bar

Radial progress bar is a plugin for Godot game engine, it is simply a control that displays radial progress bar with many options
MIT License
9 stars 3 forks source link

Migration to Godot 4.0 #3

Open daveTheOldCoder opened 1 year ago

daveTheOldCoder commented 1 year ago

I successfully migrated this plugin to Godot 4.0. I'm posting the changes to the two files radial_progress.gd and RadialProgressBar.gd below, in diff format.

If you're not familiar with diff format: The lines in the Godot 3 files are prefixed with <, and the lines in the Godot 4 files are prefixed with >.

diff -r radial_progress.gd.3 radial_progress.gd.4
1c1
< tool 
---
> @tool 

diff -r RadialProgressBar.gd.3 RadialProgressBar.gd.4
1c1
< tool
---
> @tool
5,12c5,11
< export var max_value = 100;
< export var radius = 120; 
< export var progress = 0;
< export var thickness = 20 ;
< export var bg_color : Color  = Color(0.5,.5,0.5,1);
< export var bar_color :Color =  Color(0.2,.9,0.2,1);
< var angle = 0.0 ; 
< var tween = Tween.new();
---
> @export var max_value = 100;
> @export var radius = 120;
> @export var progress = 0;
> @export var thickness = 20 ;
> @export var bg_color : Color  = Color(0.5,.5,0.5,1);
> @export var bar_color :Color =  Color(0.2,.9,0.2,1);
> var angle = 0.0 ;
14d12
<   add_child(tween);
23c21
<   update();
---
>   queue_redraw();
28c26
<   update();
---
>   queue_redraw();
33c31
<   update();
---
>   queue_redraw();
43c41
<    update();
---
>   queue_redraw();
45a44
>   var tween: Tween = create_tween()
54c53
<   var points_arc = PoolVector2Array()
---
>   var points_arc = PackedVector2Array()
56c55
<   var colors = PoolColorArray([color])
---
>   var colors = PackedColorArray([color])
58,59c57,58
<       var angle_point = deg2rad(angle_from + i * (angle_to - angle_from) / nb_points - 90)
<       points_arc.push_back(center + Vector2(cos(angle_point), sin(angle_point)) * radius)
---
>       var angle_point = deg_to_rad(angle_from + i * (angle_to - angle_from) / nb_points - 90)
>       points_arc.push_back(center + Vector2(cos(angle_point), sin(angle_point)) * radius)
daveTheOldCoder commented 1 year ago

With the changes noted above, this plugin works correctly in Godot 4.2-dev5.

daveTheOldCoder commented 1 year ago

I submitted the Godot 4 version of this plugin to the Asset Library: https://godotengine.org/asset-library/asset/2193