Skip to content

Commit f5fd76e

Browse files
committed
Multiple improvements to converter 3 to 4.
Catch get_network peer. Thread.is_active() to is_alive(). String.plus_file() to path_join() Signal "idle_frame" to "process_frame" Settings for Window size width/height to viewport_width/height. OS.real_window_size(), get_screen_size(), get_window_size() to DisplayServer equivalents. OS.get_system_time_secs() to Time.get_time_dict_from_system()['seconds'].
1 parent 2846ea1 commit f5fd76e

File tree

1 file changed

+42
-1
lines changed

1 file changed

+42
-1
lines changed

editor/project_converter_3_to_4.cpp

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@ static const char *gdscript_function_renames[][2] = {
340340
{ "get_neighbor_dist", "get_neighbor_distance" }, // NavigationAgent2D, NavigationAgent3D
341341
{ "get_network_connected_peers", "get_peers" }, // Multiplayer API
342342
{ "get_network_master", "get_multiplayer_authority" }, // Node
343-
{ "get_network_peer", "get_multiplayer_peer" }, // Multiplayer API
343+
//{ "get_network_peer", "get_multiplayer().get_multiplayer_peer" }, // Multiplayer API
344344
{ "get_network_unique_id", "get_unique_id" }, // Multiplayer API
345345
{ "get_ok", "get_ok_button" }, // AcceptDialog
346346
{ "get_oneshot", "get_one_shot" }, // AnimatedTexture
@@ -581,6 +581,8 @@ static const char *gdscript_function_renames[][2] = {
581581
{ "get_shader_param", "get_shader_parameter" }, // ShaderMaterial
582582
{ "set_uniform_name", "set_parameter_name" }, // ParameterRef
583583
{ "get_uniform_name", "get_parameter_name" }, // ParameterRef
584+
{ "is_active", "is_alive" }, // Thread.is_active() removed.
585+
//{ "plus_file", "path_join" }, //String, Checks state this is not a valid function. But I disagree.
584586

585587
// Builtin types
586588
// Remember to add them to builtin_types_excluded_functions variable, because for now this functions cannot be listed
@@ -1271,6 +1273,7 @@ static const char *gdscript_signals_renames[][2] = {
12711273
// {"changed","settings_changed"}, // EditorSettings
12721274
{ "about_to_show", "about_to_popup" }, // Popup
12731275
{ "button_release", "button_released" }, // XRController3D
1276+
{ "idle_frame", "process_frame" },
12741277
{ "network_peer_connected", "peer_connected" }, // MultiplayerAPI
12751278
{ "network_peer_disconnected", "peer_disconnected" }, // MultiplayerAPI
12761279
{ "network_peer_packet", "peer_packet" }, // MultiplayerAPI
@@ -1321,6 +1324,8 @@ static const char *project_settings_renames[][2] = {
13211324
{ "audio/output_latency", "audio/driver/output_latency" },
13221325
{ "audio/output_latency.web", "audio/driver/output_latency.web" },
13231326
{ "audio/video_delay_compensation_ms", "audio/video/video_delay_compensation_ms" },
1327+
{ "display/window/size/width", "display/window/size/viewport_width" },
1328+
{ "display/window/size/height", "display/window/size/viewport_height" },
13241329
{ "display/window/vsync/use_vsync", "display/window/vsync/vsync_mode" },
13251330
{ "editor/main_run_args", "editor/run/main_run_args" },
13261331
{ "gui/common/swap_ok_cancel", "gui/common/swap_cancel_ok" },
@@ -3586,6 +3591,39 @@ void ProjectConverter3To4::process_gdscript_line(String &line, const RegExContai
35863591
}
35873592
}
35883593
}
3594+
// OS.get_real_window_size() -> DisplayServer.window_get_real_size()
3595+
if (line.contains("OS.get_real_window_size(")) {
3596+
int start = line.find("OS.get_real_window_size(");
3597+
int end = get_end_parenthesis(line.substr(start)) + 1;
3598+
if (end > -1) {
3599+
Vector<String> parts = parse_arguments(line.substr(start, end));
3600+
if (parts.size() == 0) {
3601+
line = line.substr(0, start) + "DisplayServer.window_get_real_size()" + line.substr(end + start);
3602+
}
3603+
}
3604+
}
3605+
// OS.get_screen_size() -> DisplayServer.screen_get_size()
3606+
if (line.contains("OS.get_screen_size(")) {
3607+
int start = line.find("OS.get_screen_size(");
3608+
int end = get_end_parenthesis(line.substr(start)) + 1;
3609+
if (end > -1) {
3610+
Vector<String> parts = parse_arguments(line.substr(start, end));
3611+
if (parts.size() == 0) {
3612+
line = line.substr(0, start) + "DisplayServer.screen_get_size()" + line.substr(end + start);
3613+
}
3614+
}
3615+
}
3616+
// OS.get_window_size() -> DisplayServer.window_get_size()
3617+
if (line.contains("OS.get_window_size(")) {
3618+
int start = line.find("OS.get_window_size(");
3619+
int end = get_end_parenthesis(line.substr(start)) + 1;
3620+
if (end > -1) {
3621+
Vector<String> parts = parse_arguments(line.substr(start, end));
3622+
if (parts.size() == 0) {
3623+
line = line.substr(0, start) + "DisplayServer.window_get_size()" + line.substr(end + start);
3624+
}
3625+
}
3626+
}
35893627
// draw_rect(a,b,c,d,e) -> draw_rect(a,b,c,d)#e) TODOGODOT4 Antialiasing argument is missing
35903628
if (line.contains("draw_rect(")) {
35913629
int start = line.find("draw_rect(");
@@ -3658,6 +3696,9 @@ void ProjectConverter3To4::process_gdscript_line(String &line, const RegExContai
36583696
if (line.contains("OS.get_datetime")) {
36593697
line = line.replace("OS.get_datetime", "Time.get_datetime_dict_from_system");
36603698
}
3699+
if (line.contains("OS.get_system_time_secs()")) {
3700+
line = line.replace("OS.get_system_time_secs()", "Time.get_time_dict_from_system()['second']");
3701+
}
36613702
}
36623703

36633704
void ProjectConverter3To4::process_csharp_line(String &line, const RegExContainer &reg_container) {

0 commit comments

Comments
 (0)