project_converter_3_to_4.cpp 209 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965
  1. /*************************************************************************/
  2. /* project_converter_3_to_4.cpp */
  3. /*************************************************************************/
  4. /* This file is part of: */
  5. /* GODOT ENGINE */
  6. /* https://godotengine.org */
  7. /*************************************************************************/
  8. /* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
  9. /* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
  10. /* */
  11. /* Permission is hereby granted, free of charge, to any person obtaining */
  12. /* a copy of this software and associated documentation files (the */
  13. /* "Software"), to deal in the Software without restriction, including */
  14. /* without limitation the rights to use, copy, modify, merge, publish, */
  15. /* distribute, sublicense, and/or sell copies of the Software, and to */
  16. /* permit persons to whom the Software is furnished to do so, subject to */
  17. /* the following conditions: */
  18. /* */
  19. /* The above copyright notice and this permission notice shall be */
  20. /* included in all copies or substantial portions of the Software. */
  21. /* */
  22. /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
  23. /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
  24. /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
  25. /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
  26. /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
  27. /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
  28. /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
  29. /*************************************************************************/
  30. #include "project_converter_3_to_4.h"
  31. #include "modules/modules_enabled.gen.h"
  32. const int ERROR_CODE = 77;
  33. #ifdef MODULE_REGEX_ENABLED
  34. #include "modules/regex/regex.h"
  35. #include "core/io/dir_access.h"
  36. #include "core/os/time.h"
  37. #include "core/templates/hash_map.h"
  38. #include "core/templates/list.h"
  39. #include "core/templates/local_vector.h"
  40. static const char *enum_renames[][2] = {
  41. //// constants
  42. { "TYPE_COLOR_ARRAY", "TYPE_PACKED_COLOR_ARRAY" },
  43. { "TYPE_FLOAT64_ARRAY", "TYPE_PACKED_FLOAT64_ARRAY" },
  44. { "TYPE_INT64_ARRAY", "TYPE_PACKED_INT64_ARRAY" },
  45. { "TYPE_INT_ARRAY", "TYPE_PACKED_INT32_ARRAY" },
  46. { "TYPE_QUAT", "TYPE_QUATERNION" },
  47. { "TYPE_RAW_ARRAY", "TYPE_PACKED_BYTE_ARRAY" },
  48. { "TYPE_REAL", "TYPE_FLOAT" },
  49. { "TYPE_REAL_ARRAY", "TYPE_PACKED_FLOAT32_ARRAY" },
  50. { "TYPE_STRING_ARRAY", "TYPE_PACKED_STRING_ARRAY" },
  51. { "TYPE_TRANSFORM", "TYPE_TRANSFORM3D" },
  52. { "TYPE_VECTOR2_ARRAY", "TYPE_PACKED_VECTOR2_ARRAY" },
  53. { "TYPE_VECTOR3_ARRAY", "TYPE_PACKED_VECTOR3_ARRAY" },
  54. // {"FLAG_MAX", "PARTICLE_FLAG_MAX"}, // CPUParticles2D - used in more classes
  55. { "ALIGN_BEGIN", "ALIGNMENT_BEGIN" }, //AspectRatioContainer
  56. { "ALIGN_CENTER", "ALIGNMENT_CENTER" }, //AspectRatioContainer
  57. { "ALIGN_END", "ALIGNMENT_END" }, //AspectRatioContainer
  58. { "ARRAY_COMPRESS_BASE", "ARRAY_COMPRESS_FLAGS_BASE" }, // Mesh
  59. { "ARVR_AR", "XR_AR" }, // XRInterface
  60. { "ARVR_EXCESSIVE_MOTION", "XR_EXCESSIVE_MOTION" }, // XRInterface
  61. { "ARVR_EXTERNAL", "XR_EXTERNAL" }, // XRInterface
  62. { "ARVR_INSUFFICIENT_FEATURES", "XR_INSUFFICIENT_FEATURES" }, // XRInterface
  63. { "ARVR_MONO", "XR_MONO" }, // XRInterface
  64. { "ARVR_NONE", "XR_NONE" }, // XRInterface
  65. { "ARVR_NORMAL_TRACKING", "XR_NORMAL_TRACKING" }, // XRInterface
  66. { "ARVR_NOT_TRACKING", "XR_NOT_TRACKING" }, // XRInterface
  67. { "ARVR_STEREO", "XR_STEREO" }, // XRInterface
  68. { "ARVR_UNKNOWN_TRACKING", "XR_UNKNOWN_TRACKING" }, // XRInterface
  69. { "BAKE_ERROR_INVALID_MESH", "BAKE_ERROR_MESHES_INVALID" }, // LightmapGI
  70. { "BODY_MODE_CHARACTER", "BODY_MODE_RIGID_LINEAR" }, // PhysicsServer
  71. { "BUTTON_LEFT", "MOUSE_BUTTON_LEFT" }, // Globals
  72. { "BUTTON_MASK_LEFT", "MOUSE_BUTTON_MASK_LEFT" }, // Globals
  73. { "BUTTON_MASK_MIDDLE", "MOUSE_BUTTON_MASK_MIDDLE" }, // Globals
  74. { "BUTTON_MASK_RIGHT", "MOUSE_BUTTON_MASK_RIGHT" }, // Globals
  75. { "BUTTON_MASK_XBUTTON1", "MOUSE_BUTTON_MASK_XBUTTON1" }, // Globals
  76. { "BUTTON_MASK_XBUTTON2", "MOUSE_BUTTON_MASK_XBUTTON2" }, // Globals
  77. { "BUTTON_MIDDLE", "MOUSE_BUTTON_MIDDLE" }, // Globals
  78. { "BUTTON_RIGHT", "MOUSE_BUTTON_RIGHT" }, // Globals
  79. { "BUTTON_WHEEL_DOWN", "MOUSE_BUTTON_WHEEL_DOWN" }, // Globals
  80. { "BUTTON_WHEEL_LEFT", "MOUSE_BUTTON_WHEEL_LEFT" }, // Globals
  81. { "BUTTON_WHEEL_RIGHT", "MOUSE_BUTTON_WHEEL_RIGHT" }, // Globals
  82. { "BUTTON_WHEEL_UP", "MOUSE_BUTTON_WHEEL_UP" }, // Globals
  83. { "BUTTON_XBUTTON1", "MOUSE_BUTTON_XBUTTON1" }, // Globals
  84. { "BUTTON_XBUTTON2", "MOUSE_BUTTON_XBUTTON2" }, // Globals
  85. { "CLEAR_MODE_ONLY_NEXT_FRAME", "CLEAR_MODE_ONCE" }, // SubViewport
  86. { "COMPRESS_PVRTC4", "COMPRESS_PVRTC1_4" }, // Image
  87. { "CONNECT_ONESHOT", "CONNECT_ONE_SHOT" }, // Object
  88. { "CONTAINER_PROPERTY_EDITOR_BOTTOM", "CONTAINER_INSPECTOR_BOTTOM" }, // EditorPlugin
  89. { "CUBEMAP_BACK", "CUBEMAP_LAYER_BACK" }, // RenderingServer
  90. { "CUBEMAP_BOTTOM", "CUBEMAP_LAYER_BOTTOM" }, // RenderingServer
  91. { "CUBEMAP_FRONT", "CUBEMAP_LAYER_FRONT" }, // RenderingServer
  92. { "CUBEMAP_LEFT", "CUBEMAP_LAYER_LEFT" }, // RenderingServer
  93. { "CUBEMAP_RIGHT", "CUBEMAP_LAYER_RIGHT" }, // RenderingServer
  94. { "CUBEMAP_TOP", "CUBEMAP_LAYER_TOP" }, // RenderingServer
  95. { "DAMPED_STRING_DAMPING", "DAMPED_SPRING_DAMPING" }, // PhysicsServer2D
  96. { "DAMPED_STRING_REST_LENGTH", "DAMPED_SPRING_REST_LENGTH" }, // PhysicsServer2D
  97. { "DAMPED_STRING_STIFFNESS", "DAMPED_SPRING_STIFFNESS" }, // PhysicsServer2D
  98. { "FLAG_ALIGN_Y_TO_VELOCITY", "PARTICLE_FLAG_ALIGN_Y_TO_VELOCITY" }, // CPUParticles2D
  99. { "FLAG_DISABLE_Z", "PARTICLE_FLAG_DISABLE_Z" }, // CPUParticles2D
  100. { "FLAG_ROTATE_Y", "PARTICLE_FLAG_ROTATE_Y" }, // CPUParticles2D
  101. { "FLAG_USE_BAKED_LIGHT", "GI_MODE_BAKED" }, // GeometryInstance3D
  102. { "FORMAT_PVRTC2", "FORMAT_PVRTC1_2" }, // Image
  103. { "FORMAT_PVRTC2A", "FORMAT_PVRTC1_2A" }, // Image
  104. { "FORMAT_PVRTC4", "FORMAT_PVRTC1_4" }, // Image
  105. { "FORMAT_PVRTC4A", "FORMAT_PVRTC1_4A" }, // Image
  106. { "FUNC_FRAC", "FUNC_FRACT" }, // VisualShaderNodeVectorFunc
  107. { "INSTANCE_LIGHTMAP_CAPTURE", "INSTANCE_LIGHTMAP" }, // RenderingServer
  108. { "JOINT_6DOF", "JOINT_TYPE_6DOF" }, // PhysicsServer3D
  109. { "JOINT_CONE_TWIST", "JOINT_TYPE_CONE_TWIST" }, // PhysicsServer3D
  110. { "JOINT_DAMPED_SPRING", "JOINT_TYPE_DAMPED_SPRING" }, // PhysicsServer2D
  111. { "JOINT_GROOVE", "JOINT_TYPE_GROOVE" }, // PhysicsServer2D
  112. { "JOINT_HINGE", "JOINT_TYPE_HINGE" }, // PhysicsServer3D
  113. { "JOINT_PIN", "JOINT_TYPE_PIN" }, // PhysicsServer2D
  114. { "JOINT_SLIDER", "JOINT_TYPE_SLIDER" }, // PhysicsServer3D
  115. { "KEY_CONTROL", "KEY_CTRL" }, // Globals
  116. { "LOOP_PING_PONG", "LOOP_PINGPONG" }, // AudioStreamWAV
  117. { "MATH_RAND", "MATH_RANDF_RANGE" }, // VisualScriptBuiltinFunc
  118. { "MATH_RANDOM", "MATH_RANDI_RANGE" }, // VisualScriptBuiltinFunc
  119. { "MATH_STEPIFY", "MATH_STEP_DECIMALS" }, // VisualScriptBuiltinFunc
  120. { "MODE_KINEMATIC", "FREEZE_MODE_KINEMATIC" }, // RigidBody
  121. { "MODE_OPEN_ANY", "FILE_MODE_OPEN_ANY" }, // FileDialog
  122. { "MODE_OPEN_DIR", "FILE_MODE_OPEN_DIR" }, // FileDialog
  123. { "MODE_OPEN_FILE", "FILE_MODE_OPEN_FILE" }, // FileDialog
  124. { "MODE_OPEN_FILES", "FILE_MODE_OPEN_FILES" }, // FileDialog
  125. { "MODE_SAVE_FILE", "FILE_MODE_SAVE_FILE" }, // FileDialog
  126. { "MODE_STATIC", "FREEZE_MODE_STATIC" }, // RigidBody
  127. { "NOTIFICATION_APP_PAUSED", "NOTIFICATION_APPLICATION_PAUSED" }, // MainLoop
  128. { "NOTIFICATION_APP_RESUMED", "NOTIFICATION_APPLICATION_RESUMED" }, // MainLoop
  129. { "NOTIFICATION_INSTANCED", "NOTIFICATION_SCENE_INSTANTIATED" }, // Node
  130. { "NOTIFICATION_PATH_CHANGED", "NOTIFICATION_PATH_RENAMED" }, //Node
  131. { "NOTIFICATION_WM_FOCUS_IN", "NOTIFICATION_APPLICATION_FOCUS_IN" }, // MainLoop
  132. { "NOTIFICATION_WM_FOCUS_OUT", "NOTIFICATION_APPLICATION_FOCUS_OUT" }, // MainLoop
  133. { "NOTIFICATION_WM_UNFOCUS_REQUEST", "NOTIFICATION_WM_WINDOW_FOCUS_OUT" }, //Node
  134. { "PAUSE_MODE_INHERIT", "PROCESS_MODE_INHERIT" }, // Node
  135. { "PAUSE_MODE_PROCESS", "PROCESS_MODE_ALWAYS" }, // Node
  136. { "PAUSE_MODE_STOP", "PROCESS_MODE_PAUSABLE" }, // Node
  137. { "RENDER_DRAW_CALLS_IN_FRAME", "RENDER_TOTAL_DRAW_CALLS_IN_FRAME" }, // Performance
  138. { "RENDER_OBJECTS_IN_FRAME", "RENDER_TOTAL_OBJECTS_IN_FRAME" }, // Performance
  139. { "SIDE_BOTTOM", "MARGIN_BOTTOM" }, // Globals
  140. { "SIDE_LEFT", "MARGIN_LEFT" }, // Globals
  141. { "SIDE_RIGHT", "MARGIN_RIGHT" }, // Globals
  142. { "SIDE_TOP", "MARGIN_TOP" }, // Globals
  143. { "TEXTURE_TYPE_2D_ARRAY", "TEXTURE_LAYERED_2D_ARRAY" }, // RenderingServer
  144. { "TEXTURE_TYPE_CUBEMAP", "TEXTURE_LAYERED_CUBEMAP_ARRAY" }, // RenderingServer
  145. { "TRACKER_LEFT_HAND", "TRACKER_HAND_LEFT" }, // XRPositionalTracker
  146. { "TRACKER_RIGHT_HAND", "TRACKER_HAND_RIGHT" }, // XRPositionalTracker
  147. { "TYPE_NORMALMAP", "TYPE_NORMAL_MAP" }, // VisualShaderNodeCubemap
  148. /// enums
  149. { "AlignMode", "AlignmentMode" }, //AspectRatioContainer
  150. { "AnimationProcessMode", "AnimationProcessCallback" }, // AnimationTree, AnimationPlayer
  151. { "Camera2DProcessMode", "Camera2DProcessCallback" }, // Camera2D
  152. { "CubeMapSide", "CubeMapLayer" }, // RenderingServer
  153. { "DampedStringParam", "DampedSpringParam" }, // PhysicsServer2D
  154. { "FFT_Size", "FFTSize" }, // AudioEffectPitchShift,AudioEffectSpectrumAnalyzer
  155. { "PauseMode", "ProcessMode" }, // Node
  156. { "TimerProcessMode", "TimerProcessCallback" }, // Timer
  157. { "Tracking_status", "TrackingStatus" }, // XRInterface
  158. { nullptr, nullptr },
  159. };
  160. static const char *gdscript_function_renames[][2] = {
  161. // { "_set_name", "get_tracker_name"}, // XRPositionalTracker - CameraFeed use this
  162. // { "_unhandled_input", "_unhandled_key_input"}, // BaseButton, ViewportContainer broke Node, FileDialog,SubViewportContainer
  163. // { "create_gizmo", "_create_gizmo"}, // EditorNode3DGizmoPlugin - may be used
  164. // { "get_dependencies", "_get_dependencies" }, // ResourceFormatLoader broke ResourceLoader
  165. // { "get_extents", "get_size" }, // BoxShape, RectangleShape broke Decal, VoxelGI, GPUParticlesCollisionBox, GPUParticlesCollisionSDF, GPUParticlesCollisionHeightField, GPUParticlesAttractorBox, GPUParticlesAttractorVectorField, FogVolume
  166. // { "get_h_offset", "get_drag_horizontal_offset"}, // Camera2D, broke PathFollow, Camera
  167. // { "get_mode", "get_file_mode"}, // FileDialog broke Panel, Shader, CSGPolygon, Tilemap
  168. // { "get_motion", "get_travel"}, // PhysicsTestMotionResult2D broke ParalaxLayer
  169. // { "get_name", "get_tracker_name"}, // XRPositionalTracker broke OS, Node
  170. // { "get_network_connected_peers", "get_peers"}, // MultiplayerAPI broke SceneTree
  171. // { "get_network_peer", "has_multiplayer_peer"}, // MultiplayerAPI broke SceneTree
  172. // { "get_network_unique_id", "get_unique_id"}, // MultiplayerAPI broke SceneTree
  173. // { "get_offset", "get_position_offset" }, // GraphNode broke Gradient
  174. // { "get_peer_port", "get_peer" }, // ENetMultiplayerPeer broke WebSocketServer
  175. // { "get_process_mode", "get_process_callback" }, // ClippedCamera3D broke Node, Sky
  176. // { "get_render_info", "get_rendering_info" }, // RenderingServer broke Viewport
  177. // { "get_type", "get_tracker_type"}, // XRPositionalTracker broke GLTFAccessor, GLTFLight
  178. // { "get_v_offset", "get_drag_vertical_offset"}, // Camera2D, broke PathFollow, Camera
  179. // { "has_network_peer", "has_multiplayer_peer"}, // MultiplayerAPI broke SceneTree
  180. // { "instance", "instantiate" }, // PackedScene, ClassDB - Broke FileSystemDock signal and also tscn files - [instance=ExtResource( 17 )] - this is implemented as custom rule
  181. // { "is_listening", "is_bound"}, // PacketPeerUDP broke TCPServer, UDPServer
  182. // { "is_refusing_new_network_connections", "is_refusing_new_connections"}, // MultiplayerAPI broke SceneTree
  183. // { "is_valid", "has_valid_event" }, // Shortcut broke e.g. Callable
  184. // { "listen", "bound"}, // PacketPeerUDP broke TCPServer, UDPServer
  185. // { "load", "_load"}, // ResourceFormatLoader broke ConfigFile, Image, StreamTexture2D
  186. // { "make_current", "set_current" }, // Camera2D broke Camera3D, Listener2D
  187. // { "process", "_process" }, // AnimationNode - This word is commonly used
  188. // { "save", "_save"}, // ResourceFormatLoader broke ConfigFile, Image, StreamTexture2D
  189. // { "set_autowrap", "set_autowrap_mode" }, // AcceptDialog broke Label - Cyclic Rename
  190. // { "set_color", "surface_set_color"}, // ImmediateMesh broke Light2D, Theme, SurfaceTool
  191. // { "set_event", "set_shortcut" }, // BaseButton - Cyclic Rename
  192. // { "set_extents", "set_size"}, // BoxShape, RectangleShape broke ReflectionProbe
  193. // { "set_flag", "set_particle_flag"}, // ParticleProcessMaterial broke Window, HingeJoint3D
  194. // { "set_h_offset", "set_drag_horizontal_offset" }, // Camera2D broke Camera3D, PathFollow3D, PathFollow2D
  195. // { "set_margin", "set_offset" }, // Control broke Shape3D, AtlasTexture
  196. // { "set_mode", "set_mode_file_mode" }, // FileDialog broke Panel, Shader, CSGPolygon, Tilemap
  197. // { "set_normal", "surface_set_normal"}, // ImmediateGeometry broke SurfaceTool, WorldMarginShape2D
  198. // { "set_offset", "set_progress" }, // PathFollow2D, PathFollow3D - Too common
  199. // { "set_process_mode", "set_process_callback" }, // AnimationTree broke Node, Tween, Sky
  200. // { "set_refuse_new_network_connections", "set_refuse_new_connections"}, // MultiplayerAPI broke SceneTree
  201. // { "set_tooltip", "set_tooltip_text" }, // Control, breaks TreeItem, at least for now.
  202. // { "set_uv", "surface_set_uv" }, // ImmediateMesh broke Polygon2D
  203. // { "set_v_offset", "set_drag_vertical_offset" }, // Camera2D broke Camera3D, PathFollow3D, PathFollow2D
  204. // {"get_points","get_points_id"},// Astar, broke Line2D, Convexpolygonshape
  205. // {"get_v_scroll","get_v_scroll_bar"},//ItemList, broke TextView
  206. { "_about_to_show", "_about_to_popup" }, // ColorPickerButton
  207. { "_get_configuration_warning", "_get_configuration_warnings" }, // Node
  208. { "_set_current", "set_current" }, // Camera2D
  209. { "_set_editor_description", "set_editor_description" }, // Node
  210. { "_toplevel_raise_self", "_top_level_raise_self" }, // CanvasItem
  211. { "_update_wrap_at", "_update_wrap_at_column" }, // TextEdit
  212. { "add_animation", "add_animation_library" }, // AnimationPlayer
  213. { "add_cancel", "add_cancel_button" }, // AcceptDialog
  214. { "add_central_force", "apply_central_force" }, //RigidBody2D
  215. { "add_child_below_node", "add_sibling" }, // Node
  216. { "add_color_override", "add_theme_color_override" }, // Control
  217. { "add_constant_override", "add_theme_constant_override" }, // Control
  218. { "add_font_override", "add_theme_font_override" }, // Control
  219. { "add_force", "apply_force" }, //RigidBody2D
  220. { "add_icon_override", "add_theme_icon_override" }, // Control
  221. { "add_scene_import_plugin", "add_scene_format_importer_plugin" }, //EditorPlugin
  222. { "add_stylebox_override", "add_theme_stylebox_override" }, // Control
  223. { "add_torque", "apply_torque" }, //RigidBody2D
  224. { "apply_changes", "_apply_changes" }, // EditorPlugin
  225. { "body_add_force", "body_apply_force" }, // PhysicsServer2D
  226. { "body_add_torque", "body_apply_torque" }, // PhysicsServer2D
  227. { "bumpmap_to_normalmap", "bump_map_to_normal_map" }, // Image
  228. { "can_be_hidden", "_can_be_hidden" }, // EditorNode3DGizmoPlugin
  229. { "can_drop_data_fw", "_can_drop_data_fw" }, // ScriptEditor
  230. { "can_generate_small_preview", "_can_generate_small_preview" }, // EditorResourcePreviewGenerator
  231. { "can_instance", "can_instantiate" }, // PackedScene, Script
  232. { "canvas_light_set_scale", "canvas_light_set_texture_scale" }, // RenderingServer
  233. { "center_viewport_to_cursor", "center_viewport_to_caret" }, // TextEdit
  234. { "change_scene", "change_scene_to_file" }, // SceneTree
  235. { "change_scene_to", "change_scene_to_packed" }, // SceneTree
  236. { "clip_polygons_2d", "clip_polygons" }, // Geometry2D
  237. { "clip_polyline_with_polygon_2d", "clip_polyline_with_polygon" }, //Geometry2D
  238. { "commit_handle", "_commit_handle" }, // EditorNode3DGizmo
  239. { "convex_hull_2d", "convex_hull" }, // Geometry2D
  240. { "create_gizmo", "_create_gizmo" }, // EditorNode3DGizmoPlugin
  241. { "cursor_get_blink_speed", "get_caret_blink_interval" }, // TextEdit
  242. { "cursor_get_column", "get_caret_column" }, // TextEdit
  243. { "cursor_get_line", "get_caret_line" }, // TextEdit
  244. { "cursor_set_blink_enabled", "set_caret_blink_enabled" }, // TextEdit
  245. { "cursor_set_blink_speed", "set_caret_blink_interval" }, // TextEdit
  246. { "cursor_set_column", "set_caret_column" }, // TextEdit
  247. { "cursor_set_line", "set_caret_line" }, // TextEdit
  248. { "damped_spring_joint_create", "joint_make_damped_spring" }, // PhysicsServer2D
  249. { "damped_string_joint_get_param", "damped_spring_joint_get_param" }, // PhysicsServer2D
  250. { "damped_string_joint_set_param", "damped_spring_joint_set_param" }, // PhysicsServer2D
  251. { "dectime", "move_toward" }, // GDScript, Math functions
  252. { "delete_char_at_cursor", "delete_char_at_caret" }, // LineEdit
  253. { "deselect_items", "deselect_all" }, // FileDialog
  254. { "disable_plugin", "_disable_plugin" }, // EditorPlugin
  255. { "drop_data_fw", "_drop_data_fw" }, // ScriptEditor
  256. { "exclude_polygons_2d", "exclude_polygons" }, // Geometry2D
  257. { "find_node", "find_child" }, // Node
  258. { "find_scancode_from_string", "find_keycode_from_string" }, // OS
  259. { "forward_canvas_draw_over_viewport", "_forward_canvas_draw_over_viewport" }, // EditorPlugin
  260. { "forward_canvas_force_draw_over_viewport", "_forward_canvas_force_draw_over_viewport" }, // EditorPlugin
  261. { "forward_canvas_gui_input", "_forward_canvas_gui_input" }, // EditorPlugin
  262. { "forward_spatial_draw_over_viewport", "_forward_3d_draw_over_viewport" }, // EditorPlugin
  263. { "forward_spatial_force_draw_over_viewport", "_forward_3d_force_draw_over_viewport" }, // EditorPlugin
  264. { "forward_spatial_gui_input", "_forward_3d_gui_input" }, // EditorPlugin
  265. { "generate_from_path", "_generate_from_path" }, // EditorResourcePreviewGenerator
  266. { "generate_small_preview_automatically", "_generate_small_preview_automatically" }, // EditorResourcePreviewGenerator
  267. { "get_action_list", "action_get_events" }, // InputMap
  268. { "get_alt", "is_alt_pressed" }, // InputEventWithModifiers
  269. { "get_animation_process_mode", "get_process_callback" }, // AnimationPlayer
  270. { "get_applied_force", "get_constant_force" }, //RigidBody2D
  271. { "get_applied_torque", "get_constant_torque" }, //RigidBody2D
  272. { "get_audio_bus", "get_audio_bus_name" }, // Area3D
  273. { "get_bound_child_nodes_to_bone", "get_bone_children" }, // Skeleton3D
  274. { "get_camera", "get_camera_3d" }, // Viewport -> this is also convertable to get_camera_2d, broke GLTFNode
  275. { "get_cancel", "get_cancel_button" }, // ConfirmationDialog
  276. { "get_caption", "_get_caption" }, // AnimationNode
  277. { "get_cast_to", "get_target_position" }, // RayCast2D, RayCast3D
  278. { "get_child_by_name", "_get_child_by_name" }, // AnimationNode
  279. { "get_child_nodes", "_get_child_nodes" }, // AnimationNode
  280. { "get_closest_point_to_segment_2d", "get_closest_point_to_segment" }, // Geometry2D
  281. { "get_closest_point_to_segment_uncapped_2d", "get_closest_point_to_segment_uncapped" }, // Geometry2D
  282. { "get_closest_points_between_segments_2d", "get_closest_point_to_segment" }, // Geometry2D
  283. { "get_collision_layer_bit", "get_collision_layer_value" }, // CSGShape3D and a lot of others like GridMap
  284. { "get_collision_mask_bit", "get_collision_mask_value" }, // CSGShape3D and a lot of others like GridMap
  285. { "get_color_types", "get_color_type_list" }, // Theme
  286. { "get_command", "is_command_or_control_pressed" }, // InputEventWithModifiers
  287. { "get_constant_types", "get_constant_type_list" }, // Theme
  288. { "get_control", "is_ctrl_pressed" }, // InputEventWithModifiers
  289. { "get_cull_mask_bit", "get_cull_mask_value" }, // Camera3D
  290. { "get_cursor_position", "get_caret_column" }, // LineEdit
  291. { "get_d", "get_distance" }, // LineShape2D
  292. { "get_drag_data", "_get_drag_data" }, // Control
  293. { "get_drag_data_fw", "_get_drag_data_fw" }, // ScriptEditor
  294. { "get_editor_viewport", "get_editor_main_screen" }, // EditorPlugin
  295. { "get_enabled_focus_mode", "get_focus_mode" }, // BaseButton
  296. { "get_endian_swap", "is_big_endian" }, // File
  297. { "get_error_string", "get_error_message" }, // JSON
  298. { "get_filename", "get_scene_file_path" }, // Node, WARNING, this may be used in a lot of other places
  299. { "get_focus_neighbour", "get_focus_neighbor" }, // Control
  300. { "get_font_types", "get_font_type_list" }, // Theme
  301. { "get_frame_color", "get_color" }, // ColorRect
  302. { "get_global_rate_scale", "get_playback_speed_scale" }, // AudioServer
  303. { "get_gravity_distance_scale", "get_gravity_point_distance_scale" }, //Area2D
  304. { "get_gravity_vector", "get_gravity_direction" }, //Area2D
  305. { "get_h_scrollbar", "get_h_scroll_bar" }, //ScrollContainer
  306. { "get_hand", "get_tracker_hand" }, // XRPositionalTracker
  307. { "get_handle_name", "_get_handle_name" }, // EditorNode3DGizmo
  308. { "get_handle_value", "_get_handle_value" }, // EditorNode3DGizmo
  309. { "get_icon_align", "get_icon_alignment" }, // Button
  310. { "get_icon_types", "get_icon_type_list" }, // Theme
  311. { "get_idle_frames", "get_process_frames" }, // Engine
  312. { "get_import_options", "_get_import_options" }, // EditorImportPlugin
  313. { "get_import_order", "_get_import_order" }, // EditorImportPlugin
  314. { "get_importer_name", "_get_importer_name" }, // EditorImportPlugin
  315. { "get_interior_ambient", "get_ambient_color" }, // ReflectionProbe
  316. { "get_interior_ambient_energy", "get_ambient_color_energy" }, // ReflectionProbe
  317. { "get_iterations_per_second", "get_physics_ticks_per_second" }, // Engine
  318. { "get_last_mouse_speed", "get_last_mouse_velocity" }, // Input
  319. { "get_layer_mask_bit", "get_layer_mask_value" }, // VisualInstance3D
  320. { "get_len", "get_length" }, // File
  321. { "get_max_atlas_size", "get_max_texture_size" }, // LightmapGI
  322. { "get_metakey", "is_meta_pressed" }, // InputEventWithModifiers
  323. { "get_mid_height", "get_height" }, // CapsuleMesh
  324. { "get_motion_remainder", "get_remainder" }, // PhysicsTestMotionResult2D
  325. { "get_network_connected_peers", "get_peers" }, // Multiplayer API
  326. { "get_network_master", "get_multiplayer_authority" }, // Node
  327. { "get_network_peer", "get_multiplayer_peer" }, // Multiplayer API
  328. { "get_network_unique_id", "get_unique_id" }, // Multiplayer API
  329. { "get_ok", "get_ok_button" }, // AcceptDialog
  330. { "get_oneshot", "get_one_shot" }, // AnimatedTexture
  331. { "get_option_visibility", "_get_option_visibility" }, // EditorImportPlugin
  332. { "get_parameter_default_value", "_get_parameter_default_value" }, // AnimationNode
  333. { "get_parameter_list", "_get_parameter_list" }, // AnimationNode
  334. { "get_parent_spatial", "get_parent_node_3d" }, // Node3D
  335. { "get_pause_mode", "get_process_mode" }, // Node
  336. { "get_physical_scancode", "get_physical_keycode" }, // InputEventKey
  337. { "get_physical_scancode_with_modifiers", "get_physical_keycode_with_modifiers" }, // InputEventKey
  338. { "get_plugin_icon", "_get_plugin_icon" }, // EditorPlugin
  339. { "get_plugin_name", "_get_plugin_name" }, // EditorPlugin
  340. { "get_preset_count", "_get_preset_count" }, // EditorImportPlugin
  341. { "get_preset_name", "_get_preset_name" }, // EditorImportPlugin
  342. { "get_recognized_extensions", "_get_recognized_extensions" }, // ResourceFormatLoader, EditorImportPlugin broke ResourceSaver
  343. { "get_render_info", "get_rendering_info" }, // RenderingServer
  344. { "get_render_targetsize", "get_render_target_size" }, // XRInterface
  345. { "get_resource_type", "_get_resource_type" }, // ResourceFormatLoader
  346. { "get_result", "get_data" }, //JSON
  347. { "get_rpc_sender_id", "get_remote_sender_id" }, // Multiplayer API
  348. { "get_save_extension", "_get_save_extension" }, // EditorImportPlugin
  349. { "get_scancode", "get_keycode" }, // InputEventKey
  350. { "get_scancode_string", "get_keycode_string" }, // OS
  351. { "get_scancode_with_modifiers", "get_keycode_with_modifiers" }, // InputEventKey
  352. { "get_shift", "is_shift_pressed" }, // InputEventWithModifiers
  353. { "get_size_override", "get_size_2d_override" }, // SubViewport
  354. { "get_slide_count", "get_slide_collision_count" }, // CharacterBody2D, CharacterBody3D
  355. { "get_slips_on_slope", "get_slide_on_slope" }, // SeparationRayShape2D, SeparationRayShape3D
  356. { "get_space_override_mode", "get_gravity_space_override_mode" }, // Area2D
  357. { "get_speed", "get_velocity" }, // InputEventMouseMotion
  358. { "get_stylebox_types", "get_stylebox_type_list" }, // Theme
  359. { "get_surface_material", "get_surface_override_material" }, // MeshInstance3D broke ImporterMesh
  360. { "get_surface_material_count", "get_surface_override_material_count" }, // MeshInstance3D
  361. { "get_tab_disabled", "is_tab_disabled" }, // Tab
  362. { "get_tab_hidden", "is_tab_hidden" }, // Tab
  363. { "get_text_align", "get_text_alignment" }, // Button
  364. { "get_theme_item_types", "get_theme_item_type_list" }, // Theme
  365. { "get_timer_process_mode", "get_timer_process_callback" }, // Timer
  366. { "get_translation", "get_position" }, // Node3D broke GLTFNode which is used rarely
  367. { "get_unit_offset", "get_progress_ratio" }, // PathFollow2D, PathFollow3D
  368. { "get_use_in_baked_light", "is_baking_navigation" }, // GridMap
  369. { "get_used_cells_by_id", "get_used_cells" }, // TileMap
  370. { "get_v_scrollbar", "get_v_scroll_bar" }, //ScrollContainer
  371. { "get_visible_name", "_get_visible_name" }, // EditorImportPlugin
  372. { "get_window_layout", "_get_window_layout" }, // EditorPlugin
  373. { "get_word_under_cursor", "get_word_under_caret" }, // TextEdit
  374. { "get_world", "get_world_3d" }, // Viewport, Spatial
  375. { "get_zfar", "get_far" }, // Camera3D broke GLTFCamera
  376. { "get_znear", "get_near" }, // Camera3D broke GLTFCamera
  377. { "groove_joint_create", "joint_make_groove" }, // PhysicsServer2D
  378. { "handle_menu_selected", "_handle_menu_selected" }, // EditorResourcePicker
  379. { "handles_type", "_handles_type" }, // ResourceFormatLoader
  380. { "has_color", "has_theme_color" }, // Control broke Theme
  381. { "has_color_override", "has_theme_color_override" }, // Control broke Theme
  382. { "has_constant", "has_theme_constant" }, // Control
  383. { "has_constant_override", "has_theme_constant_override" }, // Control
  384. { "has_filter", "_has_filter" }, // AnimationNode
  385. { "has_font", "has_theme_font" }, // Control broke Theme
  386. { "has_font_override", "has_theme_font_override" }, // Control
  387. { "has_icon", "has_theme_icon" }, // Control broke Theme
  388. { "has_icon_override", "has_theme_icon_override" }, // Control
  389. { "has_main_screen", "_has_main_screen" }, // EditorPlugin
  390. { "has_network_peer", "has_multiplayer_peer" }, // Multiplayer API
  391. { "has_stylebox", "has_theme_stylebox" }, // Control broke Theme
  392. { "has_stylebox_override", "has_theme_stylebox_override" }, // Control
  393. { "http_escape", "uri_encode" }, // String
  394. { "http_unescape", "uri_decode" }, // String
  395. { "import_scene_from_other_importer", "_import_scene" }, //EditorSceneFormatImporter
  396. { "instance_set_surface_material", "instance_set_surface_override_material" }, // RenderingServer
  397. { "interpolate", "sample" }, // Curve, Curve2D, Curve3D, Gradient
  398. { "intersect_polygons_2d", "intersect_polygons" }, // Geometry2D
  399. { "intersect_polyline_with_polygon_2d", "intersect_polyline_with_polygon" }, // Geometry2D
  400. { "is_a_parent_of", "is_ancestor_of" }, // Node
  401. { "is_commiting_action", "is_committing_action" }, // UndoRedo
  402. { "is_doubleclick", "is_double_click" }, // InputEventMouseButton
  403. { "is_draw_red", "is_draw_warning" }, // EditorProperty
  404. { "is_h_drag_enabled", "is_drag_horizontal_enabled" }, // Camera2D
  405. { "is_handle_highlighted", "_is_handle_highlighted" }, // EditorNode3DGizmo, EditorNode3DGizmoPlugin
  406. { "is_inverting_faces", "get_flip_faces" }, // CSGPrimitive3D
  407. { "is_network_master", "is_multiplayer_authority" }, // Node
  408. { "is_network_server", "is_server" }, // Multiplayer API
  409. { "is_normalmap", "is_normal_map" }, // NoiseTexture
  410. { "is_refusing_new_network_connections", "is_refusing_new_connections" }, // Multiplayer API
  411. { "is_region", "is_region_enabled" }, // Sprite2D
  412. { "is_scancode_unicode", "is_keycode_unicode" }, // OS
  413. { "is_selectable_when_hidden", "_is_selectable_when_hidden" }, // EditorNode3DGizmoPlugin
  414. { "is_set_as_toplevel", "is_set_as_top_level" }, // CanvasItem
  415. { "is_shortcut", "matches_event" }, // Shortcut
  416. { "is_size_override_stretch_enabled", "is_size_2d_override_stretch_enabled" }, // SubViewport
  417. { "is_sort_enabled", "is_y_sort_enabled" }, // Node2D
  418. { "is_static_body", "is_able_to_sleep" }, // PhysicalBone3D - TODO - not sure
  419. { "is_v_drag_enabled", "is_drag_vertical_enabled" }, // Camera2D
  420. { "joint_create_cone_twist", "joint_make_cone_twist" }, // PhysicsServer3D
  421. { "joint_create_generic_6dof", "joint_make_generic_6dof" }, // PhysicsServer3D
  422. { "joint_create_hinge", "joint_make_hinge" }, // PhysicsServer3D
  423. { "joint_create_pin", "joint_make_pin" }, // PhysicsServer3D
  424. { "joint_create_slider", "joint_make_slider" }, // PhysicsServer3D
  425. { "line_intersects_line_2d", "line_intersects_line" }, // Geometry2D
  426. { "load_from_globals", "load_from_project_settings" }, // InputMap
  427. { "load_interactive", "load_threaded_request" }, // ResourceLoader - load_threaded_request is alternative, but is used differently
  428. { "make_convex_from_brothers", "make_convex_from_siblings" }, // CollisionShape3D
  429. { "make_visible", "_make_visible" }, // EditorPlugin
  430. { "merge_polygons_2d", "merge_polygons" }, // Geometry2D
  431. { "mesh_surface_get_format", "mesh_surface_get_format_attribute_stride" }, // RenderingServer
  432. { "mesh_surface_update_region", "mesh_surface_update_attribute_region" }, // RenderingServer
  433. { "move_to_bottom", "move_after" }, // Skeleton3D
  434. { "move_to_top", "move_before" }, // Skeleton3D
  435. { "multimesh_allocate", "multimesh_allocate_data" }, // RenderingServer
  436. { "normalmap_to_xy", "normal_map_to_xy" }, // Image
  437. { "offset_polygon_2d", "offset_polygon" }, // Geometry2D
  438. { "offset_polyline_2d", "offset_polyline" }, // Geometry2D
  439. { "percent_decode", "uri_decode" }, // String
  440. { "percent_encode", "uri_encode" }, // String
  441. { "pin_joint_create", "joint_make_pin" }, // PhysicsServer2D
  442. { "popup_centered_minsize", "popup_centered_clamped" }, // Window
  443. { "post_import", "_post_import" }, // EditorScenePostImport
  444. { "print_stray_nodes", "print_orphan_nodes" }, // Node
  445. { "property_list_changed_notify", "notify_property_list_changed" }, // Object
  446. { "recognize", "_recognize" }, // ResourceFormatLoader
  447. { "regen_normalmaps", "regen_normal_maps" }, // ArrayMesh
  448. { "remove", "remove_at" }, // Array, broke Directory
  449. { "remove_animation", "remove_animation_library" }, // AnimationPlayer
  450. { "remove_color_override", "remove_theme_color_override" }, // Control
  451. { "remove_constant_override", "remove_theme_constant_override" }, // Control
  452. { "remove_font_override", "remove_theme_font_override" }, // Control
  453. { "remove_icon_override", "remove_theme_icon_override" }, // Control
  454. { "remove_scene_import_plugin", "remove_scene_format_importer_plugin" }, //EditorPlugin
  455. { "remove_stylebox_override", "remove_theme_stylebox_override" }, // Control
  456. { "rename_animation", "rename_animation_library" }, // AnimationPlayer
  457. { "rename_dependencies", "_rename_dependencies" }, // ResourceFormatLoader
  458. { "save_external_data", "_save_external_data" }, // EditorPlugin
  459. { "segment_intersects_segment_2d", "segment_intersects_segment" }, // Geometry2D
  460. { "set_adjustment_enable", "set_adjustment_enabled" }, // Environment
  461. { "set_alt", "set_alt_pressed" }, // InputEventWithModifiers
  462. { "set_anchor_and_margin", "set_anchor_and_offset" }, // Control
  463. { "set_anchors_and_margins_preset", "set_anchors_and_offsets_preset" }, // Control
  464. { "set_animation_process_mode", "set_process_callback" }, // AnimationPlayer
  465. { "set_as_bulk_array", "set_buffer" }, // MultiMesh
  466. { "set_as_normalmap", "set_as_normal_map" }, // NoiseTexture
  467. { "set_as_toplevel", "set_as_top_level" }, // CanvasItem
  468. { "set_audio_bus", "set_audio_bus_name" }, // Area3D
  469. { "set_autowrap", "set_autowrap_mode" }, // Label broke AcceptDialog
  470. { "set_cast_to", "set_target_position" }, // RayCast2D, RayCast3D
  471. { "set_collision_layer_bit", "set_collision_layer_value" }, // CSGShape3D and a lot of others like GridMap
  472. { "set_collision_mask_bit", "set_collision_mask_value" }, // CSGShape3D and a lot of others like GridMap
  473. { "set_column_min_width", "set_column_custom_minimum_width" }, // Tree
  474. { "set_command", "set_meta_pressed" }, // InputEventWithModifiers
  475. { "set_control", "set_ctrl_pressed" }, // InputEventWithModifiers
  476. { "set_create_options", "_set_create_options" }, // EditorResourcePicker
  477. { "set_cull_mask_bit", "set_cull_mask_value" }, // Camera3D
  478. { "set_cursor_position", "set_caret_column" }, // LineEdit
  479. { "set_d", "set_distance" }, // WorldMarginShape2D
  480. { "set_doubleclick", "set_double_click" }, // InputEventMouseButton
  481. { "set_draw_red", "set_draw_warning" }, // EditorProperty
  482. { "set_enabled_focus_mode", "set_focus_mode" }, // BaseButton
  483. { "set_endian_swap", "set_big_endian" }, // File
  484. { "set_expand_to_text_length", "set_expand_to_text_length_enabled" }, // LineEdit
  485. { "set_filename", "set_scene_file_path" }, // Node, WARNING, this may be used in a lot of other places
  486. { "set_focus_neighbour", "set_focus_neighbor" }, // Control
  487. { "set_frame_color", "set_color" }, // ColorRect
  488. { "set_global_rate_scale", "set_playback_speed_scale" }, // AudioServer
  489. { "set_gravity_distance_scale", "set_gravity_point_distance_scale" }, // Area2D
  490. { "set_gravity_vector", "set_gravity_direction" }, // Area2D
  491. { "set_h_drag_enabled", "set_drag_horizontal_enabled" }, // Camera2D
  492. { "set_icon_align", "set_icon_alignment" }, // Button
  493. { "set_interior_ambient", "set_ambient_color" }, // ReflectionProbe
  494. { "set_interior_ambient_energy", "set_ambient_color_energy" }, // ReflectionProbe
  495. { "set_invert_faces", "set_flip_faces" }, // CSGPrimitive3D
  496. { "set_is_initialized", "_is_initialized" }, // XRInterface
  497. { "set_is_primary", "set_primary" }, // XRInterface
  498. { "set_iterations_per_second", "set_physics_ticks_per_second" }, // Engine
  499. { "set_layer_mask_bit", "set_layer_mask_value" }, // VisualInstance3D
  500. { "set_margins_preset", "set_offsets_preset" }, // Control
  501. { "set_max_atlas_size", "set_max_texture_size" }, // LightmapGI
  502. { "set_metakey", "set_meta_pressed" }, // InputEventWithModifiers
  503. { "set_mid_height", "set_height" }, // CapsuleMesh
  504. { "set_network_master", "set_multiplayer_authority" }, // Node
  505. { "set_network_peer", "set_multiplayer_peer" }, // Multiplayer API
  506. { "set_oneshot", "set_one_shot" }, // AnimatedTexture
  507. { "set_pause_mode", "set_process_mode" }, // Node
  508. { "set_physical_scancode", "set_physical_keycode" }, // InputEventKey
  509. { "set_refuse_new_network_connections", "set_refuse_new_connections" }, // Multiplayer API
  510. { "set_region", "set_region_enabled" }, // Sprite2D, Sprite broke AtlasTexture
  511. { "set_region_filter_clip", "set_region_filter_clip_enabled" }, // Sprite2D
  512. { "set_rotate", "set_rotates" }, // PathFollow2D
  513. { "set_scancode", "set_keycode" }, // InputEventKey
  514. { "set_shift", "set_shift_pressed" }, // InputEventWithModifiers
  515. { "set_size_override", "set_size_2d_override" }, // SubViewport broke ImageTexture
  516. { "set_size_override_stretch", "set_size_2d_override_stretch" }, // SubViewport
  517. { "set_slips_on_slope", "set_slide_on_slope" }, // SeparationRayShape2D, SeparationRayShape3D
  518. { "set_sort_enabled", "set_y_sort_enabled" }, // Node2D
  519. { "set_space_override_mode", "set_gravity_space_override_mode" }, // Area2D
  520. { "set_speed", "set_velocity" }, // InputEventMouseMotion
  521. { "set_ssao_edge_sharpness", "set_ssao_sharpness" }, // Environment
  522. { "set_surface_material", "set_surface_override_material" }, // MeshInstance3D broke ImporterMesh
  523. { "set_tab_align", "set_tab_alignment" }, //TabContainer
  524. { "set_tangent", "surface_set_tangent" }, // ImmediateGeometry broke SurfaceTool
  525. { "set_text_align", "set_text_alignment" }, // Button
  526. { "set_timer_process_mode", "set_timer_process_callback" }, // Timer
  527. { "set_translation", "set_position" }, // Node3D - this broke GLTFNode which is used rarely
  528. { "set_unit_offset", "set_progress_ratio" }, // PathFollow2D, PathFollow3D
  529. { "set_uv2", "surface_set_uv2" }, // ImmediateMesh broke Surffacetool
  530. { "set_v_drag_enabled", "set_drag_vertical_enabled" }, // Camera2D
  531. { "set_valign", "set_vertical_alignment" }, // Label
  532. { "set_window_layout", "_set_window_layout" }, // EditorPlugin
  533. { "set_zfar", "set_far" }, // Camera3D broke GLTFCamera
  534. { "set_znear", "set_near" }, // Camera3D broke GLTFCamera
  535. { "shortcut_match", "is_match" }, // InputEvent
  536. { "skeleton_allocate", "skeleton_allocate_data" }, // RenderingServer
  537. { "surface_update_region", "surface_update_attribute_region" }, // ArrayMesh
  538. { "targeting_method", "tween_method" }, // Tween
  539. { "targeting_property", "tween_property" }, // Tween
  540. { "track_remove_key_at_position", "track_remove_key_at_time" }, // Animation
  541. { "triangulate_delaunay_2d", "triangulate_delaunay" }, // Geometry2D
  542. { "unselect", "deselect" }, // ItemList
  543. { "unselect_all", "deselect_all" }, // ItemList
  544. { "update_configuration_warning", "update_configuration_warnings" }, // Node
  545. { "update_gizmo", "update_gizmos" }, // Node3D
  546. { "viewport_set_use_arvr", "viewport_set_use_xr" }, // RenderingServer
  547. { "warp_mouse_position", "warp_mouse" }, // Input
  548. { "world_to_map", "local_to_map" }, // TileMap, GridMap
  549. { "set_shader_param", "set_shader_parameter" }, // ShaderMaterial
  550. { "get_shader_param", "get_shader_parameter" }, // ShaderMaterial
  551. { "set_uniform_name", "set_parameter_name" }, // ParameterRef
  552. { "get_uniform_name", "get_parameter_name" }, // ParameterRef
  553. // Builtin types
  554. // Remember to add them to builtin_types_excluded_functions variable, because for now this functions cannot be listed
  555. // { "empty", "is_empty" }, // Array - Used as custom rule // Be careful, this will be used everywhere
  556. { "clamped", "clamp" }, // Vector2 // Be careful, this will be used everywhere
  557. { "get_rotation_quat", "get_rotation_quaternion" }, // Basis
  558. { "grow_margin", "grow_side" }, // Rect2
  559. { "invert", "reverse" }, // Array - TODO check // Be careful, this will be used everywhere
  560. { "is_abs_path", "is_absolute_path" }, // String
  561. { "is_valid_integer", "is_valid_int" }, // String
  562. { "linear_interpolate", "lerp" }, // Color
  563. { "to_ascii", "to_ascii_buffer" }, // String
  564. { "to_utf8", "to_utf8_buffer" }, // String
  565. { "to_wchar", "to_utf32_buffer" }, // String // TODO - utf32 or utf16?
  566. // @GlobalScope
  567. // Remember to add them to builtin_types_excluded_functions variable, because for now this functions cannot be listed
  568. { "bytes2var", "bytes_to_var" },
  569. { "bytes2var_with_objects", "bytes_to_var_with_objects" },
  570. { "db2linear", "db_to_linear" },
  571. { "deg2rad", "deg_to_rad" },
  572. { "linear2db", "linear_to_db" },
  573. { "rad2deg", "rad_to_deg" },
  574. { "rand_range", "randf_range" },
  575. { "range_lerp", "remap" },
  576. { "stepify", "snapped" },
  577. { "str2var", "str_to_var" },
  578. { "var2str", "var_to_str" },
  579. { "var2bytes", "var_to_bytes" },
  580. { "var2bytes_with_objects", "var_to_bytes_with_objects" },
  581. // @GDScript
  582. // Remember to add them to builtin_types_excluded_functions variable, because for now this functions cannot be listed
  583. { "dict2inst", "dict_to_inst" },
  584. { "inst2dict", "inst_to_dict" },
  585. { nullptr, nullptr },
  586. };
  587. // gdscript_function_renames clone with CamelCase
  588. static const char *csharp_function_renames[][2] = {
  589. // { "_SetName", "GetTrackerName"}, // XRPositionalTracker - CameraFeed use this
  590. // { "_UnhandledInput", "_UnhandledKeyInput"}, // BaseButton, ViewportContainer broke Node, FileDialog,SubViewportContainer
  591. // { "CreateGizmo", "_CreateGizmo"}, // EditorNode3DGizmoPlugin - may be used
  592. // { "GetDependencies", "_GetDependencies" }, // ResourceFormatLoader broke ResourceLoader
  593. // { "GetExtents", "GetSize" }, // BoxShape, RectangleShape broke Decal, VoxelGI, GPUParticlesCollisionBox, GPUParticlesCollisionSDF, GPUParticlesCollisionHeightField, GPUParticlesAttractorBox, GPUParticlesAttractorVectorField, FogVolume
  594. // { "GetHOffset", "GetDragHorizontalOffset"}, // Camera2D, broke PathFollow, Camera
  595. // { "GetMode", "GetFileMode"}, // FileDialog broke Panel, Shader, CSGPolygon, Tilemap
  596. // { "GetMotion", "GetTravel"}, // PhysicsTestMotionResult2D broke ParalaxLayer
  597. // { "GetName", "GetTrackerName"}, // XRPositionalTracker broke OS, Node
  598. // { "GetNetworkConnectedPeers", "GetPeers"}, // MultiplayerAPI broke SceneTree
  599. // { "GetNetworkPeer", "HasMultiplayerPeer"}, // MultiplayerAPI broke SceneTree
  600. // { "GetNetworkUniqueId", "GetUniqueId"}, // MultiplayerAPI broke SceneTree
  601. // { "GetOffset", "GetPositionOffset" }, // GraphNode broke Gradient
  602. // { "GetPeerPort", "GetPeer" }, // ENetMultiplayerPeer broke WebSocketServer
  603. // { "GetProcessMode", "GetProcessCallback" }, // ClippedCamera3D broke Node, Sky
  604. // { "GetRenderInfo", "GetRenderingInfo" }, // RenderingServer broke Viewport
  605. // { "GetType", "GetTrackerType"}, // XRPositionalTracker broke GLTFAccessor, GLTFLight
  606. // { "GetVOffset", "GetDragVerticalOffset"}, // Camera2D, broke PathFollow, Camera
  607. // { "HasNetworkPeer", "HasMultiplayerPeer"}, // MultiplayerAPI broke SceneTree
  608. // { "Instance", "Instantiate" }, // PackedScene, ClassDB - Broke FileSystemDock signal and also tscn files - [instance=ExtResource( 17 )] - this is implemented as custom rule
  609. // { "IsListening", "IsBound"}, // PacketPeerUDP broke TCPServer, UDPServer
  610. // { "IsRefusingNewNetworkConnections", "IsRefusingNewConnections"}, // MultiplayerAPI broke SceneTree
  611. // { "IsValid", "HasValidEvent" }, // Shortcut broke e.g. Callable
  612. // { "Listen", "Bound"}, // PacketPeerUDP broke TCPServer, UDPServer
  613. // { "Load", "_Load"}, // ResourceFormatLoader broke ConfigFile, Image, StreamTexture2D
  614. // { "MakeCurrent", "SetCurrent" }, // Camera2D broke Camera3D, Listener2D
  615. // { "Process", "_Process" }, // AnimationNode - This word is commonly used
  616. // { "Save", "_Save"}, // ResourceFormatLoader broke ConfigFile, Image, StreamTexture2D
  617. // { "SetAutowrap", "SetAutowrapMode" }, // AcceptDialog broke Label - Cyclic Rename
  618. // { "SetColor", "SurfaceSetColor"}, // ImmediateMesh broke Light2D, Theme, SurfaceTool
  619. // { "SetEvent", "SetShortcut" }, // BaseButton - Cyclic Rename
  620. // { "SetExtents", "SetSize"}, // BoxShape, RectangleShape broke ReflectionProbe
  621. // { "SetFlag", "SetParticleFlag"}, // ParticleProcessMaterial broke Window, HingeJoint3D
  622. // { "SetHOffset", "SetDragHorizontalOffset" }, // Camera2D broke Camera3D, PathFollow3D, PathFollow2D
  623. // { "SetMargin", "SetOffset" }, // Control broke Shape3D, AtlasTexture
  624. // { "SetMode", "SetModeFileMode" }, // FileDialog broke Panel, Shader, CSGPolygon, Tilemap
  625. // { "SetNormal", "SurfaceSetNormal"}, // ImmediateGeometry broke SurfaceTool, WorldMarginShape2D
  626. // { "SetOffset", "SetProgress" }, // PathFollow2D, PathFollow3D - Too common
  627. // { "SetProcessMode", "SetProcessCallback" }, // AnimationTree broke Node, Tween, Sky
  628. // { "SetRefuseNewNetworkConnections", "SetRefuseNewConnections"}, // MultiplayerAPI broke SceneTree
  629. // { "SetTooltip", "SetTooltipText" }, // Control, breaks TreeItem, at least for now.
  630. // { "SetUv", "SurfaceSetUv" }, // ImmediateMesh broke Polygon2D
  631. // { "SetVOffset", "SetDragVerticalOffset" }, // Camera2D broke Camera3D, PathFollow3D, PathFollow2D
  632. // {"GetPoints","GetPointsId"},// Astar, broke Line2D, Convexpolygonshape
  633. // {"GetVScroll","GetVScrollBar"},//ItemList, broke TextView
  634. { "RenderingServer", "GetTabAlignment" }, // Tab
  635. { "_AboutToShow", "_AboutToPopup" }, // ColorPickerButton
  636. { "_GetConfigurationWarning", "_GetConfigurationWarnings" }, // Node
  637. { "_SetCurrent", "SetCurrent" }, // Camera2D
  638. { "_SetEditorDescription", "SetEditorDescription" }, // Node
  639. { "_ToplevelRaiseSelf", "_TopLevelRaiseSelf" }, // CanvasItem
  640. { "_UpdateWrapAt", "_UpdateWrapAtColumn" }, // TextEdit
  641. { "AddAnimation", "AddAnimationLibrary" }, // AnimationPlayer
  642. { "AddCancel", "AddCancelButton" }, // AcceptDialog
  643. { "AddCentralForce", "AddConstantCentralForce" }, //RigidBody2D
  644. { "AddChildBelowNode", "AddSibling" }, // Node
  645. { "AddColorOverride", "AddThemeColorOverride" }, // Control
  646. { "AddConstantOverride", "AddThemeConstantOverride" }, // Control
  647. { "AddFontOverride", "AddThemeFontOverride" }, // Control
  648. { "AddForce", "AddConstantForce" }, //RigidBody2D
  649. { "AddIconOverride", "AddThemeIconOverride" }, // Control
  650. { "AddSceneImportPlugin", "AddSceneFormatImporterPlugin" }, //EditorPlugin
  651. { "AddStyleboxOverride", "AddThemeStyleboxOverride" }, // Control
  652. { "AddTorque", "AddConstantTorque" }, //RigidBody2D
  653. { "BindChildNodeToBone", "SetBoneChildren" }, // Skeleton3D
  654. { "BumpmapToNormalmap", "BumpMapToNormalMap" }, // Image
  655. { "CanBeHidden", "_CanBeHidden" }, // EditorNode3DGizmoPlugin
  656. { "CanDropDataFw", "_CanDropDataFw" }, // ScriptEditor
  657. { "CanGenerateSmallPreview", "_CanGenerateSmallPreview" }, // EditorResourcePreviewGenerator
  658. { "CanInstance", "CanInstantiate" }, // PackedScene, Script
  659. { "CanvasLightSetScale", "CanvasLightSetTextureScale" }, // RenderingServer
  660. { "CenterViewportToCursor", "CenterViewportToCaret" }, // TextEdit
  661. { "ChangeScene", "ChangeSceneToFile" }, // SceneTree
  662. { "ChangeSceneTo", "ChangeSceneToPacked" }, // SceneTree
  663. { "ClipPolygons2d", "ClipPolygons" }, // Geometry2D
  664. { "ClipPolylineWithPolygon2d", "ClipPolylineWithPolygon" }, //Geometry2D
  665. { "CommitHandle", "_CommitHandle" }, // EditorNode3DGizmo
  666. { "ConvexHull2d", "ConvexHull" }, // Geometry2D
  667. { "CursorGetBlinkSpeed", "GetCaretBlinkInterval" }, // TextEdit
  668. { "CursorGetColumn", "GetCaretColumn" }, // TextEdit
  669. { "CursorGetLine", "GetCaretLine" }, // TextEdit
  670. { "CursorSetBlinkEnabled", "SetCaretBlinkEnabled" }, // TextEdit
  671. { "CursorSetBlinkSpeed", "SetCaretBlinkInterval" }, // TextEdit
  672. { "CursorSetColumn", "SetCaretColumn" }, // TextEdit
  673. { "CursorSetLine", "SetCaretLine" }, // TextEdit
  674. { "DampedSpringJointCreate", "JointMakeDampedSpring" }, // PhysicsServer2D
  675. { "DampedStringJointGetParam", "DampedSpringJointGetParam" }, // PhysicsServer2D
  676. { "DampedStringJointSetParam", "DampedSpringJointSetParam" }, // PhysicsServer2D
  677. { "DeleteCharAtCursor", "DeleteCharAtCaret" }, // LineEdit
  678. { "DeselectItems", "DeselectAll" }, // FileDialog
  679. { "DropDataFw", "_DropDataFw" }, // ScriptEditor
  680. { "ExcludePolygons2d", "ExcludePolygons" }, // Geometry2D
  681. { "FindScancodeFromString", "FindKeycodeFromString" }, // OS
  682. { "ForwardCanvasDrawOverViewport", "_ForwardCanvasDrawOverViewport" }, // EditorPlugin
  683. { "ForwardCanvasForceDrawOverViewport", "_ForwardCanvasForceDrawOverViewport" }, // EditorPlugin
  684. { "ForwardCanvasGuiInput", "_ForwardCanvasGuiInput" }, // EditorPlugin
  685. { "ForwardSpatialDrawOverViewport", "_Forward3dDrawOverViewport" }, // EditorPlugin
  686. { "ForwardSpatialForceDrawOverViewport", "_Forward3dForceDrawOverViewport" }, // EditorPlugin
  687. { "ForwardSpatialGuiInput", "_Forward3dGuiInput" }, // EditorPlugin
  688. { "GenerateFromPath", "_GenerateFromPath" }, // EditorResourcePreviewGenerator
  689. { "GenerateSmallPreviewAutomatically", "_GenerateSmallPreviewAutomatically" }, // EditorResourcePreviewGenerator
  690. { "GetActionList", "ActionGetEvents" }, // InputMap
  691. { "GetAlt", "IsAltPressed" }, // InputEventWithModifiers
  692. { "GetAnimationProcessMode", "GetProcessCallback" }, // AnimationPlayer
  693. { "GetAppliedForce", "GetConstantForce" }, //RigidBody2D
  694. { "GetAppliedTorque", "GetConstantTorque" }, //RigidBody2D
  695. { "GetAudioBus", "GetAudioBusName" }, // Area3D
  696. { "GetBoundChildNodesToBone", "GetBoneChildren" }, // Skeleton3D
  697. { "GetCamera", "GetCamera3d" }, // Viewport -> this is also convertable to getCamera2d, broke GLTFNode
  698. { "GetCancel", "GetCancelButton" }, // ConfirmationDialog
  699. { "GetCaption", "_GetCaption" }, // AnimationNode
  700. { "GetCastTo", "GetTargetPosition" }, // RayCast2D, RayCast3D
  701. { "GetChildByName", "_GetChildByName" }, // AnimationNode
  702. { "GetChildNodes", "_GetChildNodes" }, // AnimationNode
  703. { "GetClosestPointToSegment2d", "GetClosestPointToSegment" }, // Geometry2D
  704. { "GetClosestPointToSegmentUncapped2d", "GetClosestPointToSegmentUncapped" }, // Geometry2D
  705. { "GetClosestPointsBetweenSegments2d", "GetClosestPointToSegment" }, // Geometry2D
  706. { "GetCollisionLayerBit", "GetCollisionLayerValue" }, // CSGShape3D and a lot of others like GridMap
  707. { "GetCollisionMaskBit", "GetCollisionMaskValue" }, // CSGShape3D and a lot of others like GridMap
  708. { "GetColorTypes", "GetColorTypeList" }, // Theme
  709. { "GetCommand", "IsCommandPressed" }, // InputEventWithModifiers
  710. { "GetConstantTypes", "GetConstantTypeList" }, // Theme
  711. { "GetControl", "IsCtrlPressed" }, // InputEventWithModifiers
  712. { "GetCullMaskBit", "GetCullMaskValue" }, // Camera3D
  713. { "GetCursorPosition", "GetCaretColumn" }, // LineEdit
  714. { "GetD", "GetDistance" }, // LineShape2D
  715. { "GetDragDataFw", "_GetDragDataFw" }, // ScriptEditor
  716. { "GetEditorViewport", "GetViewport" }, // EditorPlugin
  717. { "GetEnabledFocusMode", "GetFocusMode" }, // BaseButton
  718. { "GetEndianSwap", "IsBigEndian" }, // File
  719. { "GetErrorString", "GetErrorMessage" }, // JSON
  720. { "GetFocusNeighbour", "GetFocusNeighbor" }, // Control
  721. { "GetFontTypes", "GetFontTypeList" }, // Theme
  722. { "GetFrameColor", "GetColor" }, // ColorRect
  723. { "GetGlobalRateScale", "GetPlaybackSpeedScale" }, // AudioServer
  724. { "GetGravityDistanceScale", "GetGravityPointDistanceScale" }, //Area2D
  725. { "GetGravityVector", "GetGravityDirection" }, //Area2D
  726. { "GetHScrollbar", "GetHScrollBar" }, //ScrollContainer
  727. { "GetHand", "GetTrackerHand" }, // XRPositionalTracker
  728. { "GetHandleName", "_GetHandleName" }, // EditorNode3DGizmo
  729. { "GetHandleValue", "_GetHandleValue" }, // EditorNode3DGizmo
  730. { "GetIconAlign", "GetIconAlignment" }, // Button
  731. { "GetIconTypes", "GetIconTypeList" }, // Theme
  732. { "GetIdleFrames", "GetProcessFrames" }, // Engine
  733. { "GetImportOptions", "_GetImportOptions" }, // EditorImportPlugin
  734. { "GetImportOrder", "_GetImportOrder" }, // EditorImportPlugin
  735. { "GetImporterName", "_GetImporterName" }, // EditorImportPlugin
  736. { "GetInteriorAmbient", "GetAmbientColor" }, // ReflectionProbe
  737. { "GetInteriorAmbientEnergy", "GetAmbientColorEnergy" }, // ReflectionProbe
  738. { "GetIterationsPerSecond", "GetPhysicsTicksPerSecond" }, // Engine
  739. { "GetLastMouseSpeed", "GetLastMouseVelocity" }, // Input
  740. { "GetLayerMaskBit", "GetLayerMaskValue" }, // VisualInstance3D
  741. { "GetLen", "GetLength" }, // File
  742. { "GetMaxAtlasSize", "GetMaxTextureSize" }, // LightmapGI
  743. { "GetMetakey", "IsMetaPressed" }, // InputEventWithModifiers
  744. { "GetMidHeight", "GetHeight" }, // CapsuleMesh
  745. { "GetMotionRemainder", "GetRemainder" }, // PhysicsTestMotionResult2D
  746. { "GetNetworkConnectedPeers", "GetPeers" }, // Multiplayer API
  747. { "GetNetworkMaster", "GetMultiplayerAuthority" }, // Node
  748. { "GetNetworkPeer", "GetMultiplayerPeer" }, // Multiplayer API
  749. { "GetNetworkUniqueId", "GetUniqueId" }, // Multiplayer API
  750. { "GetOneshot", "GetOneShot" }, // AnimatedTexture
  751. { "GetOk", "GetOkButton" }, // AcceptDialog
  752. { "GetOptionVisibility", "_GetOptionVisibility" }, // EditorImportPlugin
  753. { "GetParameterDefaultValue", "_GetParameterDefaultValue" }, // AnimationNode
  754. { "GetParameterList", "_GetParameterList" }, // AnimationNode
  755. { "GetParentSpatial", "GetParentNode3d" }, // Node3D
  756. { "GetPhysicalScancode", "GetPhysicalKeycode" }, // InputEventKey
  757. { "GetPhysicalScancodeWithModifiers", "GetPhysicalKeycodeWithModifiers" }, // InputEventKey
  758. { "GetPluginIcon", "_GetPluginIcon" }, // EditorPlugin
  759. { "GetPluginName", "_GetPluginName" }, // EditorPlugin
  760. { "GetPresetCount", "_GetPresetCount" }, // EditorImportPlugin
  761. { "GetPresetName", "_GetPresetName" }, // EditorImportPlugin
  762. { "GetRecognizedExtensions", "_GetRecognizedExtensions" }, // ResourceFormatLoader, EditorImportPlugin broke ResourceSaver
  763. { "GetRenderInfo", "GetRenderingInfo" }, // RenderingServer
  764. { "GetRenderTargetsize", "GetRenderTargetSize" }, // XRInterface
  765. { "GetResourceType", "_GetResourceType" }, // ResourceFormatLoader
  766. { "GetResult", "GetData" }, //JSON
  767. { "GetRpcSenderId", "GetRemoteSenderId" }, // Multiplayer API
  768. { "GetSaveExtension", "_GetSaveExtension" }, // EditorImportPlugin
  769. { "GetScancode", "GetKeycode" }, // InputEventKey
  770. { "GetScancodeString", "GetKeycodeString" }, // OS
  771. { "GetScancodeWithModifiers", "GetKeycodeWithModifiers" }, // InputEventKey
  772. { "GetShift", "IsShiftPressed" }, // InputEventWithModifiers
  773. { "GetSizeOverride", "GetSize2dOverride" }, // SubViewport
  774. { "GetSlipsOnSlope", "GetSlideOnSlope" }, // SeparationRayShape2D, SeparationRayShape3D
  775. { "GetSpaceOverrideMode", "GetGravitySpaceOverrideMode" }, // Area2D
  776. { "GetSpeed", "GetVelocity" }, // InputEventMouseMotion
  777. { "GetStyleboxTypes", "GetStyleboxTypeList" }, // Theme
  778. { "GetSurfaceMaterial", "GetSurfaceOverrideMaterial" }, // MeshInstance3D broke ImporterMesh
  779. { "GetSurfaceMaterialCount", "GetSurfaceOverrideMaterialCount" }, // MeshInstance3D
  780. { "GetTabDisabled", "IsTabDisabled" }, // Tab
  781. { "GetTabHidden", "IsTabHidden" }, // Tab
  782. { "GetTextAlign", "GetTextAlignment" }, // Button
  783. { "GetThemeItemTypes", "GetThemeItemTypeList" }, // Theme
  784. { "GetTimerProcessMode", "GetTimerProcessCallback" }, // Timer
  785. { "GetTranslation", "GetPosition" }, // Node3D broke GLTFNode which is used rarely
  786. { "GetUnitOffset", "GetProgressRatio" }, // PathFollow2D, PathFollow3D
  787. { "GetUseInBakedLight", "IsBakingNavigation" }, // GridMap
  788. { "GetUsedCellsById", "GetUsedCells" }, // TileMap
  789. { "GetVScrollbar", "GetVScrollBar" }, //ScrollContainer
  790. { "GetVisibleName", "_GetVisibleName" }, // EditorImportPlugin
  791. { "GetWindowLayout", "_GetWindowLayout" }, // EditorPlugin
  792. { "GetWordUnderCursor", "GetWordUnderCaret" }, // TextEdit
  793. { "GetWorld", "GetWorld3d" }, // Viewport, Spatial
  794. { "GetZfar", "GetFar" }, // Camera3D broke GLTFCamera
  795. { "GetZnear", "GetNear" }, // Camera3D broke GLTFCamera
  796. { "GrooveJointCreate", "JointMakeGroove" }, // PhysicsServer2D
  797. { "HandleMenuSelected", "_HandleMenuSelected" }, // EditorResourcePicker
  798. { "HandlesType", "_HandlesType" }, // ResourceFormatLoader
  799. { "HasColor", "HasThemeColor" }, // Control broke Theme
  800. { "HasColorOverride", "HasThemeColorOverride" }, // Control broke Theme
  801. { "HasConstant", "HasThemeConstant" }, // Control
  802. { "HasConstantOverride", "HasThemeConstantOverride" }, // Control
  803. { "HasFilter", "_HasFilter" }, // AnimationNode
  804. { "HasFont", "HasThemeFont" }, // Control broke Theme
  805. { "HasFontOverride", "HasThemeFontOverride" }, // Control
  806. { "HasIcon", "HasThemeIcon" }, // Control broke Theme
  807. { "HasIconOverride", "HasThemeIconOverride" }, // Control
  808. { "HasMainScreen", "_HasMainScreen" }, // EditorPlugin
  809. { "HasNetworkPeer", "HasMultiplayerPeer" }, // Multiplayer API
  810. { "HasStylebox", "HasThemeStylebox" }, // Control broke Theme
  811. { "HasStyleboxOverride", "HasThemeStyleboxOverride" }, // Control
  812. { "HttpEscape", "UriEncode" }, // String
  813. { "HttpUnescape", "UriDecode" }, // String
  814. { "ImportAnimationFromOtherImporter", "_ImportAnimation" }, //EditorSceneFormatImporter
  815. { "ImportSceneFromOtherImporter", "_ImportScene" }, //EditorSceneFormatImporter
  816. { "InstanceSetSurfaceMaterial", "InstanceSetSurfaceOverrideMaterial" }, // RenderingServer
  817. { "IntersectPolygons2d", "IntersectPolygons" }, // Geometry2D
  818. { "IntersectPolylineWithPolygon2d", "IntersectPolylineWithPolygon" }, // Geometry2D
  819. { "IsAParentOf", "IsAncestorOf" }, // Node
  820. { "IsCommitingAction", "IsCommittingAction" }, // UndoRedo
  821. { "IsDoubleclick", "IsDoubleClick" }, // InputEventMouseButton
  822. { "IsHDragEnabled", "IsDragHorizontalEnabled" }, // Camera2D
  823. { "IsHandleHighlighted", "_IsHandleHighlighted" }, // EditorNode3DGizmo, EditorNode3DGizmoPlugin
  824. { "IsNetworkMaster", "IsMultiplayerAuthority" }, // Node
  825. { "IsNetworkServer", "IsServer" }, // Multiplayer API
  826. { "IsNormalmap", "IsNormalMap" }, // NoiseTexture
  827. { "IsRefusingNewNetworkConnections", "IsRefusingNewConnections" }, // Multiplayer API
  828. { "IsRegion", "IsRegionEnabled" }, // Sprite2D
  829. { "IsScancodeUnicode", "IsKeycodeUnicode" }, // OS
  830. { "IsSelectableWhenHidden", "_IsSelectableWhenHidden" }, // EditorNode3DGizmoPlugin
  831. { "IsSetAsToplevel", "IsSetAsTopLevel" }, // CanvasItem
  832. { "IsShortcut", "MatchesEvent" }, // Shortcut
  833. { "IsSizeOverrideStretchEnabled", "IsSize2dOverrideStretchEnabled" }, // SubViewport
  834. { "IsSortEnabled", "IsYSortEnabled" }, // Node2D
  835. { "IsStaticBody", "IsAbleToSleep" }, // PhysicalBone3D - TODO - not sure
  836. { "IsVDragEnabled", "IsDragVerticalEnabled" }, // Camera2D
  837. { "JointCreateConeTwist", "JointMakeConeTwist" }, // PhysicsServer3D
  838. { "JointCreateGeneric6dof", "JointMakeGeneric6dof" }, // PhysicsServer3D
  839. { "JointCreateHinge", "JointMakeHinge" }, // PhysicsServer3D
  840. { "JointCreatePin", "JointMakePin" }, // PhysicsServer3D
  841. { "JointCreateSlider", "JointMakeSlider" }, // PhysicsServer3D
  842. { "LineIntersectsLine2d", "LineIntersectsLine" }, // Geometry2D
  843. { "LoadFromGlobals", "LoadFromProjectSettings" }, // InputMap
  844. { "MakeConvexFromBrothers", "MakeConvexFromSiblings" }, // CollisionShape3D
  845. { "MergePolygons2d", "MergePolygons" }, // Geometry2D
  846. { "MeshSurfaceGetFormat", "MeshSurfaceGetFormatAttributeStride" }, // RenderingServer
  847. { "MeshSurfaceUpdateRegion", "MeshSurfaceUpdateAttributeRegion" }, // RenderingServer
  848. { "MoveToBottom", "MoveAfter" }, // Skeleton3D
  849. { "MoveToTop", "MoveBefore" }, // Skeleton3D
  850. { "MultimeshAllocate", "MultimeshAllocateData" }, // RenderingServer
  851. { "NormalmapToXy", "NormalMapToXy" }, // Image
  852. { "OffsetPolygon2d", "OffsetPolygon" }, // Geometry2D
  853. { "OffsetPolyline2d", "OffsetPolyline" }, // Geometry2D
  854. { "PercentDecode", "UriDecode" }, // String
  855. { "PercentEncode", "UriEncode" }, // String
  856. { "PinJointCreate", "JointMakePin" }, // PhysicsServer2D
  857. { "PopupCenteredMinsize", "PopupCenteredClamped" }, // Window
  858. { "PostImport", "_PostImport" }, // EditorScenePostImport
  859. { "PrintStrayNodes", "PrintOrphanNodes" }, // Node
  860. { "PropertyListChangedNotify", "NotifyPropertyListChanged" }, // Object
  861. { "Recognize", "_Recognize" }, // ResourceFormatLoader
  862. { "RegenNormalmaps", "RegenNormalMaps" }, // ArrayMesh
  863. { "Remove", "RemoveAt" }, // Array, broke Directory
  864. { "RemoveAnimation", "RemoveAnimationLibrary" }, // AnimationPlayer
  865. { "RemoveColorOverride", "RemoveThemeColorOverride" }, // Control
  866. { "RemoveConstantOverride", "RemoveThemeConstantOverride" }, // Control
  867. { "RemoveFontOverride", "RemoveThemeFontOverride" }, // Control
  868. { "RemoveSceneImportPlugin", "RemoveSceneFormatImporterPlugin" }, //EditorPlugin
  869. { "RemoveStyleboxOverride", "RemoveThemeStyleboxOverride" }, // Control
  870. { "RenameAnimation", "RenameAnimationLibrary" }, // AnimationPlayer
  871. { "RenameDependencies", "_RenameDependencies" }, // ResourceFormatLoader
  872. { "SaveExternalData", "_SaveExternalData" }, // EditorPlugin
  873. { "SegmentIntersectsSegment2d", "SegmentIntersectsSegment" }, // Geometry2D
  874. { "SetAdjustmentEnable", "SetAdjustmentEnabled" }, // Environment
  875. { "SetAlt", "SetAltPressed" }, // InputEventWithModifiers
  876. { "SetAnchorAndMargin", "SetAnchorAndOffset" }, // Control
  877. { "SetAnchorsAndMarginsPreset", "SetAnchorsAndOffsetsPreset" }, // Control
  878. { "SetAnimationProcessMode", "SetProcessCallback" }, // AnimationPlayer
  879. { "SetAsBulkArray", "SetBuffer" }, // MultiMesh
  880. { "SetAsNormalmap", "SetAsNormalMap" }, // NoiseTexture
  881. { "SetAsToplevel", "SetAsTopLevel" }, // CanvasItem
  882. { "SetAudioBus", "SetAudioBusName" }, // Area3D
  883. { "SetAutowrap", "SetAutowrapMode" }, // Label broke AcceptDialog
  884. { "SetCastTo", "SetTargetPosition" }, // RayCast2D, RayCast3D
  885. { "SetCollisionLayerBit", "SetCollisionLayerValue" }, // CSGShape3D and a lot of others like GridMap
  886. { "SetCollisionMaskBit", "SetCollisionMaskValue" }, // CSGShape3D and a lot of others like GridMap
  887. { "SetColumnMinWidth", "SetColumnCustomMinimumWidth" }, // Tree
  888. { "SetCommand", "SetCommandPressed" }, // InputEventWithModifiers
  889. { "SetControl", "SetCtrlPressed" }, // InputEventWithModifiers
  890. { "SetCreateOptions", "_SetCreateOptions" }, // EditorResourcePicker
  891. { "SetCullMaskBit", "SetCullMaskValue" }, // Camera3D
  892. { "SetCursorPosition", "SetCaretColumn" }, // LineEdit
  893. { "SetD", "SetDistance" }, // WorldMarginShape2D
  894. { "SetDoubleclick", "SetDoubleClick" }, // InputEventMouseButton
  895. { "SetEnabledFocusMode", "SetFocusMode" }, // BaseButton
  896. { "SetEndianSwap", "SetBigEndian" }, // File
  897. { "SetExpandToTextLength", "SetExpandToTextLengthEnabled" }, // LineEdit
  898. { "SetFocusNeighbour", "SetFocusNeighbor" }, // Control
  899. { "SetFrameColor", "SetColor" }, // ColorRect
  900. { "SetGlobalRateScale", "SetPlaybackSpeedScale" }, // AudioServer
  901. { "SetGravityDistanceScale", "SetGravityPointDistanceScale" }, // Area2D
  902. { "SetGravityVector", "SetGravityDirection" }, // Area2D
  903. { "SetHDragEnabled", "SetDragHorizontalEnabled" }, // Camera2D
  904. { "SetIconAlign", "SetIconAlignment" }, // Button
  905. { "SetInteriorAmbient", "SetAmbientColor" }, // ReflectionProbe
  906. { "SetInteriorAmbientEnergy", "SetAmbientColorEnergy" }, // ReflectionProbe
  907. { "SetIsInitialized", "_IsInitialized" }, // XRInterface
  908. { "SetIsPrimary", "SetPrimary" }, // XRInterface
  909. { "SetIterationsPerSecond", "SetPhysicsTicksPerSecond" }, // Engine
  910. { "SetLayerMaskBit", "SetLayerMaskValue" }, // VisualInstance3D
  911. { "SetMarginsPreset", "SetOffsetsPreset" }, // Control
  912. { "SetMaxAtlasSize", "SetMaxTextureSize" }, // LightmapGI
  913. { "SetMetakey", "SetMetaPressed" }, // InputEventWithModifiers
  914. { "SetMidHeight", "SetHeight" }, // CapsuleMesh
  915. { "SetNetworkMaster", "SetMultiplayerAuthority" }, // Node
  916. { "SetNetworkPeer", "SetMultiplayerPeer" }, // Multiplayer API
  917. { "SetOneshot", "SetOneShot" }, // AnimatedTexture
  918. { "SetPhysicalScancode", "SetPhysicalKeycode" }, // InputEventKey
  919. { "SetRefuseNewNetworkConnections", "SetRefuseNewConnections" }, // Multiplayer API
  920. { "SetRegion", "SetRegionEnabled" }, // Sprite2D, Sprite broke AtlasTexture
  921. { "SetRegionFilterClip", "SetRegionFilterClipEnabled" }, // Sprite2D
  922. { "SetRotate", "SetRotates" }, // PathFollow2D
  923. { "SetScancode", "SetKeycode" }, // InputEventKey
  924. { "SetShift", "SetShiftPressed" }, // InputEventWithModifiers
  925. { "SetSizeOverride", "SetSize2dOverride" }, // SubViewport broke ImageTexture
  926. { "SetSizeOverrideStretch", "SetSize2dOverrideStretch" }, // SubViewport
  927. { "SetSlipsOnSlope", "SetSlideOnSlope" }, // SeparationRayShape2D, SeparationRayShape3D
  928. { "SetSortEnabled", "SetYSortEnabled" }, // Node2D
  929. { "SetSpaceOverrideMode", "SetGravitySpaceOverrideMode" }, // Area2D
  930. { "SetSpeed", "SetVelocity" }, // InputEventMouseMotion
  931. { "SetSsaoEdgeSharpness", "SetSsaoSharpness" }, // Environment
  932. { "SetSurfaceMaterial", "SetSurfaceOverrideMaterial" }, // MeshInstance3D broke ImporterMesh
  933. { "SetTabAlign", "SetTabAlignment" }, //TabContainer
  934. { "SetTangent", "SurfaceSetTangent" }, // ImmediateGeometry broke SurfaceTool
  935. { "SetTextAlign", "SetTextAlignment" }, // Button
  936. { "SetTimerProcessMode", "SetTimerProcessCallback" }, // Timer
  937. { "SetTonemapAutoExposure", "SetTonemapAutoExposureEnabled" }, // Environment
  938. { "SetTranslation", "SetPosition" }, // Node3D - this broke GLTFNode which is used rarely
  939. { "SetUnitOffset", "SetProgressRatio" }, // PathFollow2D, PathFollow3D
  940. { "SetUv2", "SurfaceSetUv2" }, // ImmediateMesh broke Surffacetool
  941. { "SetVDragEnabled", "SetDragVerticalEnabled" }, // Camera2D
  942. { "SetValign", "SetVerticalAlignment" }, // Label
  943. { "SetWindowLayout", "_SetWindowLayout" }, // EditorPlugin
  944. { "SetZfar", "SetFar" }, // Camera3D broke GLTFCamera
  945. { "SetZnear", "SetNear" }, // Camera3D broke GLTFCamera
  946. { "ShortcutMatch", "IsMatch" }, // InputEvent
  947. { "SkeletonAllocate", "SkeletonAllocateData" }, // RenderingServer
  948. { "SurfaceUpdateRegion", "SurfaceUpdateAttributeRegion" }, // ArrayMesh
  949. { "TargetingMethod", "TweenMethod" }, // Tween
  950. { "TargetingProperty", "TweenProperty" }, // Tween
  951. { "TrackRemoveKeyAtPosition", "TrackRemoveKeyAtTime" }, // Animation
  952. { "TriangulateDelaunay2d", "TriangulateDelaunay" }, // Geometry2D
  953. { "UnbindChildNodeFromBone", "RemoveBoneChild" }, // Skeleton3D
  954. { "Unselect", "Deselect" }, // ItemList
  955. { "UnselectAll", "DeselectAll" }, // ItemList
  956. { "UpdateConfigurationWarning", "UpdateConfigurationWarnings" }, // Node
  957. { "UpdateGizmo", "UpdateGizmos" }, // Node3D
  958. { "ViewportSetUseArvr", "ViewportSetUseXr" }, // RenderingServer
  959. { "WarpMousePosition", "WarpMouse" }, // Input
  960. { "WorldToMap", "LocalToMap" }, // TileMap, GridMap
  961. { "SetShaderParam", "SetShaderParameter" }, // ShaderMaterial
  962. { "GetShaderParam", "GetShaderParameter" }, // ShaderMaterial
  963. { "SetUniformName", "SetParameterName" }, // ParameterRef
  964. { "GetUniformName", "GetParameterName" }, // ParameterRef
  965. // Builtin types
  966. // { "Empty", "IsEmpty" }, // Array - Used as custom rule // Be careful, this will be used everywhere
  967. { "Clamped", "Clamp" }, // Vector2 // Be careful, this will be used everywhere
  968. { "GetRotationQuat", "GetRotationQuaternion" }, // Basis
  969. { "GrowMargin", "GrowSide" }, // Rect2
  970. { "Invert", "Reverse" }, // Array - TODO check // Be careful, this will be used everywhere
  971. { "IsAbsPath", "IsAbsolutePath" }, // String
  972. { "IsValidInteger", "IsValidInt" }, // String
  973. { "LinearInterpolate", "Lerp" }, // Color
  974. { "ToAscii", "ToAsciiBuffer" }, // String
  975. { "ToUtf8", "ToUtf8Buffer" }, // String
  976. { "ToWchar", "ToUtf32Buffer" }, // String // TODO - utf32 or utf16?
  977. // @GlobalScope
  978. { "Bytes2Var", "BytesToVar" },
  979. { "Bytes2VarWithObjects", "BytesToVarWithObjects" },
  980. { "Db2Linear", "DbToLinear" },
  981. { "Deg2Rad", "DegToRad" },
  982. { "Linear2Db", "LinearToDb" },
  983. { "Rad2Deg", "RadToDeg" },
  984. { "RandRange", "RandfRange" },
  985. { "RangeLerp", "Remap" },
  986. { "Stepify", "Snapped" },
  987. { "Str2Var", "StrToVar" },
  988. { "Var2Str", "VarToStr" },
  989. { "Var2Bytes", "VarToBytes" },
  990. { "Var2BytesWithObjects", "VarToBytesWithObjects" },
  991. // @GDScript
  992. { "Dict2Inst", "DictToInst" },
  993. { "Inst2Dict", "InstToDict" },
  994. { nullptr, nullptr },
  995. };
  996. // Some needs to be disabled, because users can use this names as variables
  997. static const char *gdscript_properties_renames[][2] = {
  998. // // { "d", "distance" }, //WorldMarginShape2D - TODO, looks that polish letters ą ę are treaten as space, not as letter, so `będą` are renamed to `będistanceą`
  999. // // {"alt","alt_pressed"}, // This may broke a lot of comments and user variables
  1000. // // {"command","command_pressed"},// This may broke a lot of comments and user variables
  1001. // // {"control","ctrl_pressed"},// This may broke a lot of comments and user variables
  1002. // // {"extends","size"}, // BoxShape3D, LightmapGI broke ReflectionProbe
  1003. // // {"meta","meta_pressed"},// This may broke a lot of comments and user variables
  1004. // // {"pause_mode","process_mode"}, // Node - Cyclic rename, look for others
  1005. // // {"rotate","rotates"}, // PathFollow2D - probably function exists with same name
  1006. // // {"offset","progress"}, // PathFollow2D, PathFollow3D - Name is way too vague
  1007. // // {"shift","shift_pressed"},// This may broke a lot of comments and user variables
  1008. // { "autowrap", "autowrap_mode" }, // Label
  1009. // { "cast_to", "target_position" }, // RayCast2D, RayCast3D
  1010. // { "doubleclick", "double_click" }, // InputEventMouseButton
  1011. // { "group", "button_group" }, // BaseButton
  1012. // { "process_mode", "process_callback" }, // AnimationTree, Camera2D
  1013. // { "scancode", "keycode" }, // InputEventKey
  1014. // { "toplevel", "top_level" }, // Node
  1015. // { "window_title", "title" }, // Window
  1016. // { "wrap_enabled", "wrap_mode" }, // TextEdit
  1017. // { "zfar", "far" }, // Camera3D
  1018. // { "znear", "near" }, // Camera3D
  1019. // { "filename", "scene_file_path" }, // Node
  1020. { "as_normalmap", "as_normal_map" }, // NoiseTexture
  1021. { "bbcode_text", "text" }, // RichTextLabel
  1022. { "bg", "panel" }, // Theme
  1023. { "bg_focus", "focus" }, // Theme
  1024. { "caret_blink_speed", "caret_blink_interval" }, // TextEdit, LineEdit
  1025. { "caret_moving_by_right_click", "caret_move_on_right_click" }, // TextEdit
  1026. { "caret_position", "caret_column" }, // LineEdit
  1027. { "check_vadjust", "check_v_offset" }, // Theme
  1028. { "close_h_ofs", "close_h_offset" }, // Theme
  1029. { "close_v_ofs", "close_v_offset" }, // Theme
  1030. { "commentfocus", "comment_focus" }, // Theme
  1031. { "contacts_reported", "max_contacts_reported" }, // RigidBody
  1032. { "drag_margin_bottom", "drag_bottom_margin" }, // Camera2D
  1033. { "drag_margin_h_enabled", "drag_horizontal_enabled" }, // Camera2D
  1034. { "drag_margin_left", "drag_left_margin" }, // Camera2D
  1035. { "drag_margin_right", "drag_right_margin" }, // Camera2D
  1036. { "drag_margin_top", "drag_top_margin" }, // Camera2D
  1037. { "drag_margin_v_enabled", "drag_vertical_enabled" }, // Camera2D
  1038. { "enabled_focus_mode", "focus_mode" }, // BaseButton - Removed
  1039. { "extra_spacing_bottom", "spacing_bottom" }, // Font
  1040. { "extra_spacing_top", "spacing_top" }, // Font
  1041. { "focus_neighbour_bottom", "focus_neighbor_bottom" }, // Control
  1042. { "focus_neighbour_left", "focus_neighbor_left" }, // Control
  1043. { "focus_neighbour_right", "focus_neighbor_right" }, // Control
  1044. { "focus_neighbour_top", "focus_neighbor_top" }, // Control
  1045. { "file_icon_modulate", "file_icon_color" }, // Theme
  1046. { "files_disabled", "file_disabled_color" }, // Theme
  1047. { "folder_icon_modulate", "folder_icon_color" }, // Theme
  1048. { "global_rate_scale", "playback_speed_scale" }, // AudioServer
  1049. { "gravity_distance_scale", "gravity_point_distance_scale" }, // Area2D
  1050. { "gravity_vec", "gravity_direction" }, // Area2D
  1051. { "hint_tooltip", "tooltip_text" }, // Control
  1052. { "hseparation", "h_separation" }, // Theme
  1053. { "iterations_per_second", "physics_ticks_per_second" }, // Engine
  1054. { "invert_enable", "invert_enabled" }, // Polygon2D
  1055. { "margin_bottom", "offset_bottom" }, // Control broke NinePatchRect, StyleBox
  1056. { "margin_left", "offset_left" }, // Control broke NinePatchRect, StyleBox
  1057. { "margin_right", "offset_right" }, // Control broke NinePatchRect, StyleBox
  1058. { "margin_top", "offset_top" }, // Control broke NinePatchRect, StyleBox
  1059. { "mid_height", "height" }, // CapsuleMesh
  1060. { "offset_h", "drag_horizontal_offset" }, // Camera2D
  1061. { "offset_v", "drag_vertical_offset" }, // Camera2D
  1062. { "off", "unchecked" }, // Theme
  1063. { "off_disabled", "unchecked_disabled" }, // Theme
  1064. { "ofs", "offset" }, // Theme
  1065. { "on", "checked" }, // Theme
  1066. { "on_disabled", "checked_disabled" }, // Theme
  1067. { "oneshot", "one_shot" }, // AnimatedTexture
  1068. { "out_of_range_mode", "max_polyphony" }, // AudioStreamPlayer3D
  1069. { "pause_mode", "process_mode" }, // Node
  1070. { "physical_scancode", "physical_keycode" }, // InputEventKey
  1071. { "popup_exclusive", "exclusive" }, // Window
  1072. { "rect_position", "position" }, // Control
  1073. { "rect_global_position", "global_position" }, // Control
  1074. { "rect_size", "size" }, // Control
  1075. { "rect_min_size", "minimum_size" }, // Control
  1076. { "rect_rotation", "rotation" }, // Control
  1077. { "rect_scale", "scale" }, // Control
  1078. { "rect_pivot_offset", "pivot_offset" }, // Control
  1079. { "rect_clip_content", "clip_contents" }, // Control
  1080. { "refuse_new_network_connections", "refuse_new_connections" }, // MultiplayerAPI
  1081. { "region_filter_clip", "region_filter_clip_enabled" }, // Sprite2D
  1082. { "selectedframe", "selected_frame" }, // Theme
  1083. { "size_override_stretch", "size_2d_override_stretch" }, // SubViewport
  1084. { "slips_on_slope", "slide_on_slope" }, // SeparationRayShape2D
  1085. { "ss_reflections_depth_tolerance", "ssr_depth_tolerance" }, // Environment
  1086. { "ss_reflections_enabled", "ssr_enabled" }, // Environment
  1087. { "ss_reflections_fade_in", "ssr_fade_in" }, // Environment
  1088. { "ss_reflections_fade_out", "ssr_fade_out" }, // Environment
  1089. { "ss_reflections_max_steps", "ssr_max_steps" }, // Environment
  1090. { "state_machine_selectedframe", "state_machine_selected_frame" }, // Theme
  1091. { "syntax_highlighting", "syntax_highlighter" }, // TextEdit
  1092. { "tab_align", "tab_alignment" }, // TabContainer
  1093. { "table_hseparation", "table_h_separation" }, // Theme
  1094. { "table_vseparation", "table_v_separation" }, // Theme
  1095. { "translation", "position" }, // Node3D - broke GLTFNode
  1096. { "unit_offset", "progress_ratio" }, // PathFollow2D, PathFollow3D
  1097. { "vseparation", "v_separation" }, // Theme
  1098. { nullptr, nullptr },
  1099. };
  1100. // Some needs to be disabled, because users can use this names as variables
  1101. static const char *csharp_properties_renames[][2] = {
  1102. // // { "D", "Distance" }, //WorldMarginShape2D - TODO, looks that polish letters ą ę are treaten as space, not as letter, so `będą` are renamed to `będistanceą`
  1103. // // {"Alt","AltPressed"}, // This may broke a lot of comments and user variables
  1104. // // {"Command","CommandPressed"},// This may broke a lot of comments and user variables
  1105. // // {"Control","CtrlPressed"},// This may broke a lot of comments and user variables
  1106. // // {"Extends","Size"}, // BoxShape3D, LightmapGI broke ReflectionProbe
  1107. // // {"Meta","MetaPressed"},// This may broke a lot of comments and user variables
  1108. // // {"PauseMode","ProcessMode"}, // Node - Cyclic rename, look for others
  1109. // // {"Rotate","Rotates"}, // PathFollow2D - probably function exists with same name
  1110. // // {"Offset","Progress"}, // PathFollow2D, PathFollow3D - Name is way too vague
  1111. // // {"Shift","ShiftPressed"},// This may broke a lot of comments and user variables
  1112. // { "Autowrap", "AutowrapMode" }, // Label
  1113. // { "CastTo", "TargetPosition" }, // RayCast2D, RayCast3D
  1114. // { "Doubleclick", "DoubleClick" }, // InputEventMouseButton
  1115. // { "Group", "ButtonGroup" }, // BaseButton
  1116. // { "PercentVisible, "ShowPercentage}, // ProgressBar, conflicts with Label and RichTextLabel, but may be a worth it.
  1117. // { "ProcessMode", "ProcessCallback" }, // AnimationTree, Camera2D
  1118. // { "Scancode", "Keycode" }, // InputEventKey
  1119. // { "Toplevel", "TopLevel" }, // Node
  1120. // { "WindowTitle", "Title" }, // Window
  1121. // { "WrapEnabled", "WrapMode" }, // TextEdit
  1122. // { "Zfar", "Far" }, // Camera3D
  1123. // { "Znear", "Near" }, // Camera3D
  1124. { "AsNormalmap", "AsNormalMap" }, // NoiseTexture
  1125. { "BbcodeText", "Text" }, // RichTextLabel
  1126. { "CaretBlinkSpeed", "CaretBlinkInterval" }, // TextEdit, LineEdit
  1127. { "CaretMovingByRightClick", "CaretMoveOnRightClick" }, // TextEdit
  1128. { "CaretPosition", "CaretColumn" }, // LineEdit
  1129. { "CheckVadjust", "CheckVAdjust" }, // Theme
  1130. { "CloseHOfs", "CloseHOffset" }, // Theme
  1131. { "CloseVOfs", "CloseVOffset" }, // Theme
  1132. { "Commentfocus", "CommentFocus" }, // Theme
  1133. { "DragMarginBottom", "DragBottomMargin" }, // Camera2D
  1134. { "DragMarginHEnabled", "DragHorizontalEnabled" }, // Camera2D
  1135. { "DragMarginLeft", "DragLeftMargin" }, // Camera2D
  1136. { "DragMarginRight", "DragRightMargin" }, // Camera2D
  1137. { "DragMarginTop", "DragTopMargin" }, // Camera2D
  1138. { "DragMarginVEnabled", "DragVerticalEnabled" }, // Camera2D
  1139. { "EnabledFocusMode", "FocusMode" }, // BaseButton - Removed
  1140. { "ExtraSpacingBottom", "SpacingBottom" }, // Font
  1141. { "ExtraSpacingTop", "SpacingTop" }, // Font
  1142. { "FocusNeighbourBottom", "FocusNeighborBottom" }, // Control
  1143. { "FocusNeighbourLeft", "FocusNeighborLeft" }, // Control
  1144. { "FocusNeighbourRight", "FocusNeighborRight" }, // Control
  1145. { "FocusNeighbourTop", "FocusNeighborTop" }, // Control
  1146. { "GlobalRateScale", "PlaybackSpeedScale" }, // AudioServer
  1147. { "GravityDistanceScale", "GravityPointDistanceScale" }, // Area2D
  1148. { "GravityVec", "GravityDirection" }, // Area2D
  1149. { "HintTooltip", "TooltipText" }, // Control
  1150. { "Hseparation", "HSeparation" }, // Theme
  1151. { "IterationsPerSecond", "PhysicsTicksPerSecond" }, // Engine
  1152. { "InvertEnable", "InvertEnabled" }, // Polygon2D
  1153. { "MarginBottom", "OffsetBottom" }, // Control broke NinePatchRect, StyleBox
  1154. { "MarginLeft", "OffsetLeft" }, // Control broke NinePatchRect, StyleBox
  1155. { "MarginRight", "OffsetRight" }, // Control broke NinePatchRect, StyleBox
  1156. { "MarginTop", "OffsetTop" }, // Control broke NinePatchRect, StyleBox
  1157. { "MidHeight", "Height" }, // CapsuleMesh
  1158. { "OffsetH", "DragHorizontalOffset" }, // Camera2D
  1159. { "OffsetV", "DragVerticalOffset" }, // Camera2D
  1160. { "Ofs", "Offset" }, // Theme
  1161. { "Oneshot", "OneShot" }, // AnimatedTexture
  1162. { "OutOfRangeMode", "MaxPolyphony" }, // AudioStreamPlayer3D
  1163. { "PauseMode", "ProcessMode" }, // Node
  1164. { "PhysicalScancode", "PhysicalKeycode" }, // InputEventKey
  1165. { "PopupExclusive", "Exclusive" }, // Window
  1166. { "RefuseNewNetworkConnections", "RefuseNewConnections" }, // MultiplayerAPI
  1167. { "RegionFilterClip", "RegionFilterClipEnabled" }, // Sprite2D
  1168. { "Selectedframe", "SelectedFrame" }, // Theme
  1169. { "SizeOverrideStretch", "Size2dOverrideStretch" }, // SubViewport
  1170. { "SlipsOnSlope", "SlideOnSlope" }, // SeparationRayShape2D
  1171. { "SsReflectionsDepthTolerance", "SsrDepthTolerance" }, // Environment
  1172. { "SsReflectionsEnabled", "SsrEnabled" }, // Environment
  1173. { "SsReflectionsFadeIn", "SsrFadeIn" }, // Environment
  1174. { "SsReflectionsFadeOut", "SsrFadeOut" }, // Environment
  1175. { "SsReflectionsMaxSteps", "SsrMaxSteps" }, // Environment
  1176. { "StateMachineSelectedframe", "StateMachineSelectedFrame" }, // Theme
  1177. { "SyntaxHighlighting", "SyntaxHighlighter" }, // TextEdit
  1178. { "TabAlign", "TabAlignment" }, // TabContainer
  1179. { "TableHseparation", "TableHSeparation" }, // Theme
  1180. { "TableVseparation", "TableVSeparation" }, // Theme
  1181. { "Translation", "Position" }, // Node3D - broke GLTFNode
  1182. { "UnitOffset", "ProgressRatio" }, // PathFollow2D, PathFollow3D
  1183. { "Vseparation", "VSeparation" }, // Theme
  1184. { nullptr, nullptr },
  1185. };
  1186. static const char *gdscript_signals_renames[][2] = {
  1187. // {"instantiate","instance"}, // FileSystemDock
  1188. // { "hide", "hidden" }, // CanvasItem - function with same name exists
  1189. // { "tween_all_completed","loop_finished"}, // Tween - TODO, not sure
  1190. // {"changed","settings_changed"}, // EditorSettings
  1191. { "about_to_show", "about_to_popup" }, // Popup
  1192. { "button_release", "button_released" }, // XRController3D
  1193. { "network_peer_connected", "peer_connected" }, // MultiplayerAPI
  1194. { "network_peer_disconnected", "peer_disconnected" }, // MultiplayerAPI
  1195. { "network_peer_packet", "peer_packet" }, // MultiplayerAPI
  1196. { "node_unselected", "node_deselected" }, // GraphEdit
  1197. { "offset_changed", "position_offset_changed" }, // GraphNode
  1198. { "settings_changed", "changed" }, // TileMap broke EditorSettings
  1199. { "skeleton_updated", "pose_updated" }, //
  1200. { "tab_close", "tab_closed" }, // TextEdit
  1201. { "tab_hover", "tab_hovered" }, // TextEdit
  1202. { "text_entered", "text_submitted" }, // LineEdit
  1203. { "tween_completed", "finished" }, // Tween
  1204. { "tween_step", "step_finished" }, // Tween
  1205. { nullptr, nullptr },
  1206. };
  1207. static const char *csharp_signals_renames[][2] = {
  1208. // {"Instantiate","Instance"}, // FileSystemDock
  1209. // { "Hide", "Hidden" }, // CanvasItem - function with same name exists
  1210. // { "TweenAllCompleted","LoopFinished"}, // Tween - TODO, not sure
  1211. // {"Changed","SettingsChanged"}, // EditorSettings
  1212. { "AboutToShow", "AboutToPopup" }, // Popup
  1213. { "ButtonRelease", "ButtonReleased" }, // XRController3D
  1214. { "NetworkPeerConnected", "PeerConnected" }, // MultiplayerAPI
  1215. { "NetworkPeerDisconnected", "PeerDisconnected" }, // MultiplayerAPI
  1216. { "NetworkPeerPacket", "PeerPacket" }, // MultiplayerAPI
  1217. { "NodeUnselected", "NodeDeselected" }, // GraphEdit
  1218. { "OffsetChanged", "PositionOffsetChanged" }, // GraphNode
  1219. { "SettingsChanged", "Changed" }, // TileMap broke EditorSettings
  1220. { "SkeletonUpdated", "PoseUpdated" }, //
  1221. { "TabClose", "TabClosed" }, // TextEdit
  1222. { "TabHover", "TabHovered" }, // TextEdit
  1223. { "TextEntered", "TextSubmitted" }, // LineEdit
  1224. { "TweenCompleted", "Finished" }, // Tween
  1225. { "TweenStep", "StepFinished" }, // Tween
  1226. { nullptr, nullptr },
  1227. };
  1228. static const char *project_settings_renames[][2] = {
  1229. { "audio/channel_disable_threshold_db", "audio/buses/channel_disable_threshold_db" },
  1230. { "audio/channel_disable_time", "audio/buses/channel_disable_time" },
  1231. { "audio/default_bus_layout", "audio/buses/default_bus_layout" },
  1232. { "audio/driver", "audio/driver/driver" },
  1233. { "audio/enable_audio_input", "audio/driver/enable_input" },
  1234. { "audio/mix_rate", "audio/driver/mix_rate" },
  1235. { "audio/output_latency", "audio/driver/output_latency" },
  1236. { "audio/output_latency.web", "audio/driver/output_latency.web" },
  1237. { "audio/video_delay_compensation_ms", "audio/video/video_delay_compensation_ms" },
  1238. { "display/window/vsync/use_vsync", "display/window/vsync/vsync_mode" },
  1239. { "editor/main_run_args", "editor/run/main_run_args" },
  1240. { "gui/common/swap_ok_cancel", "gui/common/swap_cancel_ok" },
  1241. { "network/limits/debugger_stdout/max_chars_per_second", "network/limits/debugger/max_chars_per_second" },
  1242. { "network/limits/debugger_stdout/max_errors_per_second", "network/limits/debugger/max_errors_per_second" },
  1243. { "network/limits/debugger_stdout/max_messages_per_frame", "network/limits/debugger/max_queued_messages" },
  1244. { "network/limits/debugger_stdout/max_warnings_per_second", "network/limits/debugger/max_warnings_per_second" },
  1245. { "network/ssl/certificates", "network/tls/certificate_bundle_override" },
  1246. { "physics/2d/thread_model", "physics/2d/run_on_thread" }, // TODO not sure
  1247. { "rendering/environment/default_clear_color", "rendering/environment/defaults/default_clear_color" },
  1248. { "rendering/environment/default_environment", "rendering/environment/defaults/default_environment" },
  1249. { "rendering/quality/depth_prepass/disable_for_vendors", "rendering/driver/depth_prepass/disable_for_vendors" },
  1250. { "rendering/quality/depth_prepass/enable", "rendering/driver/depth_prepass/enable" },
  1251. { "rendering/quality/shading/force_blinn_over_ggx", "rendering/shading/overrides/force_blinn_over_ggx" },
  1252. { "rendering/quality/shading/force_blinn_over_ggx.mobile", "rendering/shading/overrides/force_blinn_over_ggx.mobile" },
  1253. { "rendering/quality/shading/force_lambert_over_burley", "rendering/shading/overrides/force_lambert_over_burley" },
  1254. { "rendering/quality/shading/force_lambert_over_burley.mobile", "rendering/shading/overrides/force_lambert_over_burley.mobile" },
  1255. { "rendering/quality/shading/force_vertex_shading", "rendering/shading/overrides/force_vertex_shading" },
  1256. { "rendering/quality/shading/force_vertex_shading.mobile", "rendering/shading/overrides/force_vertex_shading.mobile" },
  1257. { "rendering/quality/shadow_atlas/quadrant_0_subdiv", "rendering/lights_and_shadows/shadow_atlas/quadrant_0_subdiv" },
  1258. { "rendering/quality/shadow_atlas/quadrant_1_subdiv", "rendering/lights_and_shadows/shadow_atlas/quadrant_1_subdiv" },
  1259. { "rendering/quality/shadow_atlas/quadrant_2_subdiv", "rendering/lights_and_shadows/shadow_atlas/quadrant_2_subdiv" },
  1260. { "rendering/quality/shadow_atlas/quadrant_3_subdiv", "rendering/lights_and_shadows/shadow_atlas/quadrant_3_subdiv" },
  1261. { "rendering/quality/shadow_atlas/size", "rendering/lights_and_shadows/shadow_atlas/size" },
  1262. { "rendering/quality/shadow_atlas/size.mobile", "rendering/lights_and_shadows/shadow_atlas/size.mobile" },
  1263. { "rendering/vram_compression/import_bptc", "rendering/textures/vram_compression/import_bptc" },
  1264. { "rendering/vram_compression/import_etc", "rendering/textures/vram_compression/import_etc" },
  1265. { "rendering/vram_compression/import_etc2", "rendering/textures/vram_compression/import_etc2" },
  1266. { "rendering/vram_compression/import_pvrtc", "rendering/textures/vram_compression/import_pvrtc" },
  1267. { "rendering/vram_compression/import_s3tc", "rendering/textures/vram_compression/import_s3tc" },
  1268. { nullptr, nullptr },
  1269. };
  1270. static const char *builtin_types_renames[][2] = {
  1271. { "PoolByteArray", "PackedByteArray" },
  1272. { "PoolColorArray", "PackedColorArray" },
  1273. { "PoolIntArray", "PackedInt32Array" },
  1274. { "PoolRealArray", "PackedFloat32Array" },
  1275. { "PoolStringArray", "PackedStringArray" },
  1276. { "PoolVector2Array", "PackedVector2Array" },
  1277. { "PoolVector3Array", "PackedVector3Array" },
  1278. { "Quat", "Quaternion" },
  1279. { "Transform", "Transform3D" },
  1280. { nullptr, nullptr },
  1281. };
  1282. static const char *shaders_renames[][2] = {
  1283. { "ALPHA_SCISSOR", "ALPHA_SCISSOR_THRESHOLD" },
  1284. { "CAMERA_MATRIX", "INV_VIEW_MATRIX" },
  1285. { "INV_CAMERA_MATRIX", "VIEW_MATRIX" },
  1286. { "NORMALMAP", "NORMAL_MAP" },
  1287. { "NORMALMAP_DEPTH", "NORMAL_MAP_DEPTH" },
  1288. { "TRANSMISSION", "BACKLIGHT" },
  1289. { "WORLD_MATRIX", "MODEL_MATRIX" },
  1290. { "depth_draw_alpha_prepass", "depth_draw_opaque" },
  1291. { "hint_albedo", "source_color" },
  1292. { "hint_aniso", "hint_anisotropy" },
  1293. { "hint_black", "hint_default_black" },
  1294. { "hint_black_albedo", "hint_default_black" },
  1295. { "hint_color", "source_color" },
  1296. { "hint_white", "hint_default_white" },
  1297. { nullptr, nullptr },
  1298. };
  1299. static const char *class_renames[][2] = {
  1300. // { "BulletPhysicsDirectBodyState", "BulletPhysicsDirectBodyState3D" }, // Class is not visible in ClassDB
  1301. // { "BulletPhysicsServer", "BulletPhysicsServer3D" }, // Class is not visible in ClassDB
  1302. // { "GDScriptFunctionState", "Node3D" }, // TODO - not sure to which should be changed
  1303. // { "GDScriptNativeClass", "Node3D" }, // TODO - not sure to which should be changed
  1304. // { "InputDefault",""}, // TODO ?
  1305. // { "Physics2DDirectBodyStateSW", "GodotPhysicsDirectBodyState2D" }, // Class is not visible in ClassDB
  1306. // { "Physics2DShapeQueryResult", "PhysicsShapeQueryResult2D" }, // Class is not visible in ClassDB
  1307. // { "PhysicsShapeQueryResult", "PhysicsShapeQueryResult3D" }, // Class is not visible in ClassDB
  1308. // { "NativeScript","NativeExtension"}, ??
  1309. { "ARVRAnchor", "XRAnchor3D" },
  1310. { "ARVRCamera", "XRCamera3D" },
  1311. { "ARVRController", "XRController3D" },
  1312. { "ARVRInterface", "XRInterface" },
  1313. { "ARVRInterfaceGDNative", "Node3D" },
  1314. { "ARVROrigin", "XROrigin3D" },
  1315. { "ARVRPositionalTracker", "XRPositionalTracker" },
  1316. { "ARVRServer", "XRServer" },
  1317. { "AStar", "AStar3D" },
  1318. { "AnimatedSprite", "AnimatedSprite2D" },
  1319. { "AnimationTreePlayer", "AnimationTree" },
  1320. { "Area", "Area3D" }, // Be careful, this will be used everywhere
  1321. { "AudioStreamOGGVorbis", "AudioStreamOggVorbis" },
  1322. { "AudioStreamRandomPitch", "AudioStreamRandomizer" },
  1323. { "AudioStreamSample", "AudioStreamWAV" },
  1324. { "BakedLightmap", "LightmapGI" },
  1325. { "BakedLightmapData", "LightmapGIData" },
  1326. { "BitmapFont", "FontFile" },
  1327. { "BoneAttachment", "BoneAttachment3D" },
  1328. { "BoxShape", "BoxShape3D" },
  1329. { "CPUParticles", "CPUParticles3D" },
  1330. { "CSGBox", "CSGBox3D" },
  1331. { "CSGCombiner", "CSGCombiner3D" },
  1332. { "CSGCylinder", "CSGCylinder3D" },
  1333. { "CSGMesh", "CSGMesh3D" },
  1334. { "CSGPolygon", "CSGPolygon3D" },
  1335. { "CSGPrimitive", "CSGPrimitive3D" },
  1336. { "CSGShape", "CSGShape3D" },
  1337. { "CSGSphere", "CSGSphere3D" },
  1338. { "CSGTorus", "CSGTorus3D" },
  1339. { "Camera", "Camera3D" }, // Be careful, this will be used everywhere
  1340. { "CapsuleShape", "CapsuleShape3D" },
  1341. { "ClippedCamera", "Camera3D" },
  1342. { "CollisionObject", "CollisionObject3D" },
  1343. { "CollisionPolygon", "CollisionPolygon3D" },
  1344. { "CollisionShape", "CollisionShape3D" },
  1345. { "ConcavePolygonShape", "ConcavePolygonShape3D" },
  1346. { "ConeTwistJoint", "ConeTwistJoint3D" },
  1347. { "ConvexPolygonShape", "ConvexPolygonShape3D" },
  1348. { "CubeMap", "Cubemap" },
  1349. { "CubeMesh", "BoxMesh" },
  1350. { "CylinderShape", "CylinderShape3D" },
  1351. { "DirectionalLight", "DirectionalLight3D" },
  1352. { "DynamicFont", "FontFile" },
  1353. { "DynamicFontData", "FontFile" },
  1354. { "EditorNavigationMeshGenerator", "NavigationMeshGenerator" },
  1355. { "EditorSceneImporter", "EditorSceneFormatImporter" },
  1356. { "EditorSceneImporterFBX", "EditorSceneFormatImporterFBX" },
  1357. { "EditorSceneImporterGLTF", "EditorSceneFormatImporterGLTF" },
  1358. { "EditorSpatialGizmo", "EditorNode3DGizmo" },
  1359. { "EditorSpatialGizmoPlugin", "EditorNode3DGizmoPlugin" },
  1360. { "ExternalTexture", "ImageTexture" },
  1361. { "FuncRef", "Callable" },
  1362. { "GIProbe", "VoxelGI" },
  1363. { "GIProbeData", "VoxelGIData" },
  1364. { "Generic6DOFJoint", "Generic6DOFJoint3D" },
  1365. { "Geometry", "Geometry2D" }, // Geometry class is split between Geometry2D and Geometry3D so we need to choose one
  1366. { "GeometryInstance", "GeometryInstance3D" },
  1367. { "GradientTexture", "GradientTexture2D" },
  1368. { "HeightMapShape", "HeightMapShape3D" },
  1369. { "HingeJoint", "HingeJoint3D" },
  1370. { "IP_Unix", "IPUnix" },
  1371. { "ImmediateGeometry", "ImmediateMesh" },
  1372. { "ImmediateGeometry3D", "ImmediateMesh" },
  1373. { "InterpolatedCamera", "Camera3D" },
  1374. { "InterpolatedCamera3D", "Camera3D" },
  1375. { "JSONParseResult", "JSON" },
  1376. { "Joint", "Joint3D" },
  1377. { "KinematicBody", "CharacterBody3D" },
  1378. { "KinematicBody2D", "CharacterBody2D" },
  1379. { "KinematicCollision", "KinematicCollision3D" },
  1380. { "LargeTexture", "ImageTexture" },
  1381. { "Light", "Light3D" },
  1382. { "Light2D", "PointLight2D" },
  1383. { "LineShape2D", "WorldBoundaryShape2D" },
  1384. { "Listener", "AudioListener3D" },
  1385. { "Listener2D", "AudioListener2D" },
  1386. { "MeshInstance", "MeshInstance3D" },
  1387. { "MultiMeshInstance", "MultiMeshInstance3D" },
  1388. { "MultiplayerPeerGDNative", "MultiplayerPeerExtension" },
  1389. { "Navigation", "Node3D" },
  1390. { "Navigation2D", "Node2D" },
  1391. { "Navigation2DServer", "NavigationServer2D" },
  1392. { "Navigation3D", "Node3D" },
  1393. { "NavigationAgent", "NavigationAgent3D" },
  1394. { "NavigationMeshInstance", "NavigationRegion3D" },
  1395. { "NavigationObstacle", "NavigationObstacle3D" },
  1396. { "NavigationPolygonInstance", "NavigationRegion2D" },
  1397. { "NavigationRegion", "NavigationRegion3D" },
  1398. { "NavigationServer", "NavigationServer3D" },
  1399. { "NetworkedMultiplayerENet", "ENetMultiplayerPeer" },
  1400. { "NetworkedMultiplayerPeer", "MultiplayerPeer" },
  1401. { "Occluder", "OccluderInstance3D" },
  1402. { "OmniLight", "OmniLight3D" },
  1403. { "PHashTranslation", "OptimizedTranslation" },
  1404. { "PacketPeerGDNative", "PacketPeerExtension" },
  1405. { "PanoramaSky", "Sky" },
  1406. { "Particles", "GPUParticles3D" }, // Be careful, this will be used everywhere
  1407. { "Particles2D", "GPUParticles2D" },
  1408. { "ParticlesMaterial", "ParticleProcessMaterial" },
  1409. { "Path", "Path3D" }, // Be careful, this will be used everywhere
  1410. { "PathFollow", "PathFollow3D" },
  1411. { "PhysicalBone", "PhysicalBone3D" },
  1412. { "Physics2DDirectBodyState", "PhysicsDirectBodyState2D" },
  1413. { "Physics2DDirectSpaceState", "PhysicsDirectSpaceState2D" },
  1414. { "Physics2DServer", "PhysicsServer2D" },
  1415. { "Physics2DServerSW", "GodotPhysicsServer2D" },
  1416. { "Physics2DShapeQueryParameters", "PhysicsShapeQueryParameters2D" },
  1417. { "Physics2DTestMotionResult", "PhysicsTestMotionResult2D" },
  1418. { "PhysicsBody", "PhysicsBody3D" },
  1419. { "PhysicsDirectBodyState", "PhysicsDirectBodyState3D" },
  1420. { "PhysicsDirectSpaceState", "PhysicsDirectSpaceState3D" },
  1421. { "PhysicsServer", "PhysicsServer3D" },
  1422. { "PhysicsShapeQueryParameters", "PhysicsShapeQueryParameters3D" },
  1423. { "PhysicsTestMotionResult", "PhysicsTestMotionResult3D" },
  1424. { "PinJoint", "PinJoint3D" },
  1425. { "PlaneShape", "WorldBoundaryShape3D" },
  1426. { "PopupDialog", "Popup" },
  1427. { "Position2D", "Marker2D" },
  1428. { "Position3D", "Marker3D" },
  1429. { "ProceduralSky", "Sky" },
  1430. { "RayCast", "RayCast3D" },
  1431. { "RayShape", "SeparationRayShape3D" },
  1432. { "RayShape2D", "SeparationRayShape2D" },
  1433. { "Reference", "RefCounted" }, // Be careful, this will be used everywhere
  1434. { "RemoteTransform", "RemoteTransform3D" },
  1435. { "ResourceInteractiveLoader", "ResourceLoader" },
  1436. { "RigidBody", "RigidBody3D" },
  1437. { "SceneTreeTween", "Tween" },
  1438. { "Shape", "Shape3D" }, // Be careful, this will be used everywhere
  1439. { "ShortCut", "Shortcut" },
  1440. { "Skeleton", "Skeleton3D" },
  1441. { "SkeletonIK", "SkeletonIK3D" },
  1442. { "SliderJoint", "SliderJoint3D" },
  1443. { "SoftBody", "SoftBody3D" },
  1444. { "Spatial", "Node3D" },
  1445. { "SpatialGizmo", "Node3DGizmo" },
  1446. { "SpatialMaterial", "StandardMaterial3D" },
  1447. { "SphereShape", "SphereShape3D" },
  1448. { "SpotLight", "SpotLight3D" },
  1449. { "SpringArm", "SpringArm3D" },
  1450. { "Sprite", "Sprite2D" },
  1451. { "StaticBody", "StaticBody3D" },
  1452. { "StreamCubemap", "CompressedCubemap" },
  1453. { "StreamCubemapArray", "CompressedCubemapArray" },
  1454. { "StreamPeerGDNative", "StreamPeerExtension" },
  1455. { "StreamPeerSSL", "StreamPeerTLS" },
  1456. { "StreamTexture", "CompressedTexture2D" },
  1457. { "StreamTexture2D", "CompressedTexture2D" },
  1458. { "StreamTexture2DArray", "CompressedTexture2DArray" },
  1459. { "StreamTextureLayered", "CompressedTextureLayered" },
  1460. { "TCP_Server", "TCPServer" },
  1461. { "Tabs", "TabBar" }, // Be careful, this will be used everywhere
  1462. { "TextFile", "Node3D" },
  1463. { "Texture", "Texture2D" }, // May broke TextureRect
  1464. { "TextureArray", "Texture2DArray" },
  1465. { "TextureProgress", "TextureProgressBar" },
  1466. { "ToolButton", "Button" },
  1467. { "VehicleBody", "VehicleBody3D" },
  1468. { "VehicleWheel", "VehicleWheel3D" },
  1469. { "VideoPlayer", "VideoStreamPlayer" },
  1470. { "Viewport", "SubViewport" },
  1471. { "ViewportContainer", "SubViewportContainer" },
  1472. { "VisibilityEnabler", "VisibleOnScreenEnabler3D" },
  1473. { "VisibilityEnabler2D", "VisibleOnScreenEnabler2D" },
  1474. { "VisibilityNotifier", "VisibleOnScreenNotifier3D" },
  1475. { "VisibilityNotifier2D", "VisibleOnScreenNotifier2D" },
  1476. { "VisibilityNotifier3D", "VisibleOnScreenNotifier3D" },
  1477. { "VisualInstance", "VisualInstance3D" },
  1478. { "VisualServer", "RenderingServer" },
  1479. { "VisualShaderNodeCubeMap", "VisualShaderNodeCubemap" },
  1480. { "VisualShaderNodeScalarClamp", "VisualShaderNodeClamp" },
  1481. { "VisualShaderNodeScalarConstant", "VisualShaderNodeFloatConstant" },
  1482. { "VisualShaderNodeScalarFunc", "VisualShaderNodeFloatFunc" },
  1483. { "VisualShaderNodeScalarInterp", "VisualShaderNodeMix" },
  1484. { "VisualShaderNodeScalarOp", "VisualShaderNodeFloatOp" },
  1485. { "VisualShaderNodeScalarSmoothStep", "VisualShaderNodeSmoothStep" },
  1486. { "VisualShaderNodeScalarSwitch", "VisualShaderNodeSwitch" },
  1487. { "VisualShaderNodeScalarTransformMult", "VisualShaderNodeTransformOp" },
  1488. { "VisualShaderNodeTransformMult", "VisualShaderNode" },
  1489. { "VisualShaderNodeVectorClamp", "VisualShaderNodeClamp" },
  1490. { "VisualShaderNodeVectorInterp", "VisualShaderNodeMix" },
  1491. { "VisualShaderNodeVectorScalarMix", "VisualShaderNodeMix" },
  1492. { "VisualShaderNodeVectorScalarSmoothStep", "VisualShaderNodeSmoothStep" },
  1493. { "VisualShaderNodeVectorScalarStep", "VisualShaderNodeStep" },
  1494. { "VisualShaderNodeVectorSmoothStep", "VisualShaderNodeSmoothStep" },
  1495. { "VisualShaderNodeBooleanUniform", "VisualShaderNodeBooleanParameter" },
  1496. { "VisualShaderNodeColorUniform", "VisualShaderNodeColorParameter" },
  1497. { "VisualShaderNodeScalarUniform", "VisualShaderNodeFloatParameter" },
  1498. { "VisualShaderNodeCubemapUniform", "VisualShaderNodeCubemapParameter" },
  1499. { "VisualShaderNodeTextureUniform", "VisualShaderNodeTexture2DParameter" },
  1500. { "VisualShaderNodeTextureUniformTriplanar", "VisualShaderNodeTextureParameterTriplanar" },
  1501. { "VisualShaderNodeTransformUniform", "VisualShaderNodeTransformParameter" },
  1502. { "VisualShaderNodeVec3Uniform", "VisualShaderNodeVec3Parameter" },
  1503. { "VisualShaderNodeUniform", "VisualShaderNodeParameter" },
  1504. { "VisualShaderNodeUniformRef", "VisualShaderNodeParameterRef" },
  1505. { "WebRTCDataChannelGDNative", "WebRTCDataChannelExtension" },
  1506. { "WebRTCMultiplayer", "WebRTCMultiplayerPeer" },
  1507. { "WebRTCPeerConnectionGDNative", "WebRTCPeerConnectionExtension" },
  1508. { "WindowDialog", "Window" },
  1509. { "World", "World3D" }, // Be careful, this will be used everywhere
  1510. { "XRAnchor", "XRAnchor3D" },
  1511. { "XRController", "XRController3D" },
  1512. { "XROrigin", "XROrigin3D" },
  1513. { "YSort", "Node2D" },
  1514. { "CullInstance", "Node3D" }, // Probably this type needs to be added to Godot 4.0, since it is for now only available only in Godot 3.x
  1515. { "RoomGroup", "Node3D" }, // Probably this type needs to be added to Godot 4.0, since it is for now only available only in Godot 3.x
  1516. { "Room", "Node3D" }, // Probably this type needs to be added to Godot 4.0, since it is for now only available only in Godot 3.x
  1517. { "RoomManager", "Node3D" }, // Probably this type needs to be added to Godot 4.0, since it is for now only available only in Godot 3.x
  1518. { "Portal", "Node3D" }, // Probably this type needs to be added to Godot 4.0, since it is for now only available only in Godot 3.x
  1519. { nullptr, nullptr },
  1520. };
  1521. static const char *color_renames[][2] = {
  1522. { "aliceblue", "ALICE_BLUE" },
  1523. { "antiquewhite", "ANTIQUE_WHITE" },
  1524. { "aqua", "AQUA" },
  1525. { "aquamarine", "AQUAMARINE" },
  1526. { "azure", "AZURE" },
  1527. { "beige", "BEIGE" },
  1528. { "bisque", "BISQUE" },
  1529. { "black", "BLACK" },
  1530. { "blanchedalmond", "BLANCHED_ALMOND" },
  1531. { "blue", "BLUE" },
  1532. { "blueviolet", "BLUE_VIOLET" },
  1533. { "brown", "BROWN" },
  1534. { "burlywood", "BURLYWOOD" },
  1535. { "cadetblue", "CADET_BLUE" },
  1536. { "chartreuse", "CHARTREUSE" },
  1537. { "chocolate", "CHOCOLATE" },
  1538. { "coral", "CORAL" },
  1539. { "cornflowerblue", "CORNFLOWER_BLUE" },
  1540. { "cornsilk", "CORNSILK" },
  1541. { "crimson", "CRIMSON" },
  1542. { "cyan", "CYAN" },
  1543. { "darkblue", "DARK_BLUE" },
  1544. { "darkcyan", "DARK_CYAN" },
  1545. { "darkgoldenrod", "DARK_GOLDENROD" },
  1546. { "darkgray", "DARK_GRAY" },
  1547. { "darkgreen", "DARK_GREEN" },
  1548. { "darkkhaki", "DARK_KHAKI" },
  1549. { "darkmagenta", "DARK_MAGENTA" },
  1550. { "darkolivegreen", "DARK_OLIVE_GREEN" },
  1551. { "darkorange", "DARK_ORANGE" },
  1552. { "darkorchid", "DARK_ORCHID" },
  1553. { "darkred", "DARK_RED" },
  1554. { "darksalmon", "DARK_SALMON" },
  1555. { "darkseagreen", "DARK_SEA_GREEN" },
  1556. { "darkslateblue", "DARK_SLATE_BLUE" },
  1557. { "darkslategray", "DARK_SLATE_GRAY" },
  1558. { "darkturquoise", "DARK_TURQUOISE" },
  1559. { "darkviolet", "DARK_VIOLET" },
  1560. { "deeppink", "DEEP_PINK" },
  1561. { "deepskyblue", "DEEP_SKY_BLUE" },
  1562. { "dimgray", "DIM_GRAY" },
  1563. { "dodgerblue", "DODGER_BLUE" },
  1564. { "firebrick", "FIREBRICK" },
  1565. { "floralwhite", "FLORAL_WHITE" },
  1566. { "forestgreen", "FOREST_GREEN" },
  1567. { "fuchsia", "FUCHSIA" },
  1568. { "gainsboro", "GAINSBORO" },
  1569. { "ghostwhite", "GHOST_WHITE" },
  1570. { "gold", "GOLD" },
  1571. { "goldenrod", "GOLDENROD" },
  1572. { "gray", "GRAY" },
  1573. { "green", "GREEN" },
  1574. { "greenyellow", "GREEN_YELLOW" },
  1575. { "honeydew", "HONEYDEW" },
  1576. { "hotpink", "HOT_PINK" },
  1577. { "indianred", "INDIAN_RED" },
  1578. { "indigo", "INDIGO" },
  1579. { "ivory", "IVORY" },
  1580. { "khaki", "KHAKI" },
  1581. { "lavender", "LAVENDER" },
  1582. { "lavenderblush", "LAVENDER_BLUSH" },
  1583. { "lawngreen", "LAWN_GREEN" },
  1584. { "lemonchiffon", "LEMON_CHIFFON" },
  1585. { "lightblue", "LIGHT_BLUE" },
  1586. { "lightcoral", "LIGHT_CORAL" },
  1587. { "lightcyan", "LIGHT_CYAN" },
  1588. { "lightgoldenrod", "LIGHT_GOLDENROD" },
  1589. { "lightgray", "LIGHT_GRAY" },
  1590. { "lightgreen", "LIGHT_GREEN" },
  1591. { "lightpink", "LIGHT_PINK" },
  1592. { "lightsalmon", "LIGHT_SALMON" },
  1593. { "lightseagreen", "LIGHT_SEA_GREEN" },
  1594. { "lightskyblue", "LIGHT_SKY_BLUE" },
  1595. { "lightslategray", "LIGHT_SLATE_GRAY" },
  1596. { "lightsteelblue", "LIGHT_STEEL_BLUE" },
  1597. { "lightyellow", "LIGHT_YELLOW" },
  1598. { "lime", "LIME" },
  1599. { "limegreen", "LIME_GREEN" },
  1600. { "linen", "LINEN" },
  1601. { "magenta", "MAGENTA" },
  1602. { "maroon", "MAROON" },
  1603. { "mediumaquamarine", "MEDIUM_AQUAMARINE" },
  1604. { "mediumblue", "MEDIUM_BLUE" },
  1605. { "mediumorchid", "MEDIUM_ORCHID" },
  1606. { "mediumpurple", "MEDIUM_PURPLE" },
  1607. { "mediumseagreen", "MEDIUM_SEA_GREEN" },
  1608. { "mediumslateblue", "MEDIUM_SLATE_BLUE" },
  1609. { "mediumspringgreen", "MEDIUM_SPRING_GREEN" },
  1610. { "mediumturquoise", "MEDIUM_TURQUOISE" },
  1611. { "mediumvioletred", "MEDIUM_VIOLET_RED" },
  1612. { "midnightblue", "MIDNIGHT_BLUE" },
  1613. { "mintcream", "MINT_CREAM" },
  1614. { "mistyrose", "MISTY_ROSE" },
  1615. { "moccasin", "MOCCASIN" },
  1616. { "navajowhite", "NAVAJO_WHITE" },
  1617. { "navyblue", "NAVY_BLUE" },
  1618. { "oldlace", "OLD_LACE" },
  1619. { "olive", "OLIVE" },
  1620. { "olivedrab", "OLIVE_DRAB" },
  1621. { "orange", "ORANGE" },
  1622. { "orangered", "ORANGE_RED" },
  1623. { "orchid", "ORCHID" },
  1624. { "palegoldenrod", "PALE_GOLDENROD" },
  1625. { "palegreen", "PALE_GREEN" },
  1626. { "paleturquoise", "PALE_TURQUOISE" },
  1627. { "palevioletred", "PALE_VIOLET_RED" },
  1628. { "papayawhip", "PAPAYA_WHIP" },
  1629. { "peachpuff", "PEACH_PUFF" },
  1630. { "peru", "PERU" },
  1631. { "pink", "PINK" },
  1632. { "plum", "PLUM" },
  1633. { "powderblue", "POWDER_BLUE" },
  1634. { "purple", "PURPLE" },
  1635. { "rebeccapurple", "REBECCA_PURPLE" },
  1636. { "red", "RED" },
  1637. { "rosybrown", "ROSY_BROWN" },
  1638. { "royalblue", "ROYAL_BLUE" },
  1639. { "saddlebrown", "SADDLE_BROWN" },
  1640. { "salmon", "SALMON" },
  1641. { "sandybrown", "SANDY_BROWN" },
  1642. { "seagreen", "SEA_GREEN" },
  1643. { "seashell", "SEASHELL" },
  1644. { "sienna", "SIENNA" },
  1645. { "silver", "SILVER" },
  1646. { "skyblue", "SKY_BLUE" },
  1647. { "slateblue", "SLATE_BLUE" },
  1648. { "slategray", "SLATE_GRAY" },
  1649. { "snow", "SNOW" },
  1650. { "springgreen", "SPRING_GREEN" },
  1651. { "steelblue", "STEEL_BLUE" },
  1652. { "tan", "TAN" },
  1653. { "teal", "TEAL" },
  1654. { "thistle", "THISTLE" },
  1655. { "tomato", "TOMATO" },
  1656. { "transparent", "TRANSPARENT" },
  1657. { "turquoise", "TURQUOISE" },
  1658. { "violet", "VIOLET" },
  1659. { "webgray", "WEB_GRAY" },
  1660. { "webgreen", "WEB_GREEN" },
  1661. { "webmaroon", "WEB_MAROON" },
  1662. { "webpurple", "WEB_PURPLE" },
  1663. { "wheat", "WHEAT" },
  1664. { "white", "WHITE" },
  1665. { "whitesmoke", "WHITE_SMOKE" },
  1666. { "yellow", "YELLOW" },
  1667. { "yellowgreen", "YELLOW_GREEN" },
  1668. { nullptr, nullptr },
  1669. };
  1670. class ProjectConverter3To4::RegExContainer {
  1671. public:
  1672. // Custom GDScript.
  1673. RegEx reg_is_empty = RegEx("\\bempty\\(");
  1674. RegEx reg_super = RegEx("([\t ])\\.([a-zA-Z_])");
  1675. RegEx reg_json_to = RegEx("\\bto_json\\b");
  1676. RegEx reg_json_parse = RegEx("([\t ]{0,})([^\n]+)parse_json\\(([^\n]+)");
  1677. RegEx reg_json_non_new = RegEx("([\t ]{0,})([^\n]+)JSON\\.parse\\(([^\n]+)");
  1678. RegEx reg_export = RegEx("export\\(([a-zA-Z0-9_]+)\\)[ ]+var[ ]+([a-zA-Z0-9_]+)");
  1679. RegEx reg_export_advanced = RegEx("export\\(([^)^\n]+)\\)[ ]+var[ ]+([a-zA-Z0-9_]+)([^\n]+)");
  1680. RegEx reg_setget_setget = RegEx("var[ ]+([a-zA-Z0-9_]+)([^\n]+)setget[ \t]+([a-zA-Z0-9_]+)[ \t]*,[ \t]*([a-zA-Z0-9_]+)");
  1681. RegEx reg_setget_set = RegEx("var[ ]+([a-zA-Z0-9_]+)([^\n]+)setget[ \t]+([a-zA-Z0-9_]+)[ \t]*[,]*[^a-z^A-Z^0-9^_]*$");
  1682. RegEx reg_setget_get = RegEx("var[ ]+([a-zA-Z0-9_]+)([^\n]+)setget[ \t]+,[ \t]*([a-zA-Z0-9_]+)[ \t]*$");
  1683. RegEx reg_join = RegEx("([\\(\\)a-zA-Z0-9_]+)\\.join\\(([^\n^\\)]+)\\)");
  1684. RegEx reg_image_lock = RegEx("([a-zA-Z0-9_\\.]+)\\.lock\\(\\)");
  1685. RegEx reg_image_unlock = RegEx("([a-zA-Z0-9_\\.]+)\\.unlock\\(\\)");
  1686. RegEx reg_os_fullscreen = RegEx("OS.window_fullscreen[= ]+([^#^\n]+)");
  1687. RegEx reg_instantiate = RegEx("\\.instance\\(([^\\)]*)\\)");
  1688. // GDScript keywords.
  1689. RegEx keyword_gdscript_tool = RegEx("^tool");
  1690. RegEx keyword_gdscript_export_single = RegEx("^export");
  1691. RegEx keyword_gdscript_export_mutli = RegEx("([\t]+)export\\b");
  1692. RegEx keyword_gdscript_onready = RegEx("^onready");
  1693. RegEx keyword_gdscript_remote = RegEx("^remote func");
  1694. RegEx keyword_gdscript_remotesync = RegEx("^remotesync func");
  1695. RegEx keyword_gdscript_sync = RegEx("^sync func");
  1696. RegEx keyword_gdscript_slave = RegEx("^slave func");
  1697. RegEx keyword_gdscript_puppet = RegEx("^puppet func");
  1698. RegEx keyword_gdscript_puppetsync = RegEx("^puppetsync func");
  1699. RegEx keyword_gdscript_master = RegEx("^master func");
  1700. RegEx keyword_gdscript_mastersync = RegEx("^mastersync func");
  1701. // CSharp keywords.
  1702. RegEx keyword_csharp_remote = RegEx("\\[Remote(Attribute)?(\\(\\))?\\]");
  1703. RegEx keyword_csharp_remotesync = RegEx("\\[(Remote)?Sync(Attribute)?(\\(\\))?\\]");
  1704. RegEx keyword_csharp_puppet = RegEx("\\[(Puppet|Slave)(Attribute)?(\\(\\))?\\]");
  1705. RegEx keyword_csharp_puppetsync = RegEx("\\[PuppetSync(Attribute)?(\\(\\))?\\]");
  1706. RegEx keyword_csharp_master = RegEx("\\[Master(Attribute)?(\\(\\))?\\]");
  1707. RegEx keyword_csharp_mastersync = RegEx("\\[MasterSync(Attribute)?(\\(\\))?\\]");
  1708. // Colors.
  1709. LocalVector<RegEx *> color_regexes;
  1710. LocalVector<String> color_renamed;
  1711. // Classes.
  1712. LocalVector<RegEx *> class_tscn_regexes;
  1713. LocalVector<RegEx *> class_gd_regexes;
  1714. LocalVector<RegEx *> class_shader_regexes;
  1715. LocalVector<RegEx *> class_regexes;
  1716. RegEx class_temp_tscn = RegEx("\\bTEMP_RENAMED_CLASS.tscn\\b");
  1717. RegEx class_temp_gd = RegEx("\\bTEMP_RENAMED_CLASS.gd\\b");
  1718. RegEx class_temp_shader = RegEx("\\bTEMP_RENAMED_CLASS.shader\\b");
  1719. LocalVector<String> class_temp_tscn_renames;
  1720. LocalVector<String> class_temp_gd_renames;
  1721. LocalVector<String> class_temp_shader_renames;
  1722. // Common.
  1723. LocalVector<RegEx *> enum_regexes;
  1724. LocalVector<RegEx *> gdscript_function_regexes;
  1725. LocalVector<RegEx *> project_settings_regexes;
  1726. LocalVector<RegEx *> gdscript_properties_regexes;
  1727. LocalVector<RegEx *> gdscript_signals_regexes;
  1728. LocalVector<RegEx *> shaders_regexes;
  1729. LocalVector<RegEx *> builtin_types_regexes;
  1730. LocalVector<RegEx *> csharp_function_regexes;
  1731. LocalVector<RegEx *> csharp_properties_regexes;
  1732. LocalVector<RegEx *> csharp_signal_regexes;
  1733. RegExContainer() {
  1734. // Common.
  1735. {
  1736. // Enum.
  1737. for (unsigned int current_index = 0; enum_renames[current_index][0]; current_index++) {
  1738. enum_regexes.push_back(memnew(RegEx(String("\\b") + enum_renames[current_index][0] + "\\b")));
  1739. }
  1740. // GDScript functions.
  1741. for (unsigned int current_index = 0; gdscript_function_renames[current_index][0]; current_index++) {
  1742. gdscript_function_regexes.push_back(memnew(RegEx(String("\\b") + gdscript_function_renames[current_index][0] + "\\b")));
  1743. }
  1744. // Project Settings.
  1745. for (unsigned int current_index = 0; project_settings_renames[current_index][0]; current_index++) {
  1746. project_settings_regexes.push_back(memnew(RegEx(String("\\b") + project_settings_renames[current_index][0] + "\\b")));
  1747. }
  1748. // GDScript properties.
  1749. for (unsigned int current_index = 0; gdscript_properties_renames[current_index][0]; current_index++) {
  1750. gdscript_properties_regexes.push_back(memnew(RegEx(String("\\b") + gdscript_properties_renames[current_index][0] + "\\b")));
  1751. }
  1752. // GDScript Signals.
  1753. for (unsigned int current_index = 0; gdscript_signals_renames[current_index][0]; current_index++) {
  1754. gdscript_signals_regexes.push_back(memnew(RegEx(String("\\b") + gdscript_signals_renames[current_index][0] + "\\b")));
  1755. }
  1756. // Shaders.
  1757. for (unsigned int current_index = 0; shaders_renames[current_index][0]; current_index++) {
  1758. shaders_regexes.push_back(memnew(RegEx(String("\\b") + shaders_renames[current_index][0] + "\\b")));
  1759. }
  1760. // Builtin types.
  1761. for (unsigned int current_index = 0; builtin_types_renames[current_index][0]; current_index++) {
  1762. builtin_types_regexes.push_back(memnew(RegEx(String("\\b") + builtin_types_renames[current_index][0] + "\\b")));
  1763. }
  1764. // CSharp function renames.
  1765. for (unsigned int current_index = 0; csharp_function_renames[current_index][0]; current_index++) {
  1766. csharp_function_regexes.push_back(memnew(RegEx(String("\\b") + csharp_function_renames[current_index][0] + "\\b")));
  1767. }
  1768. // CSharp properties renames.
  1769. for (unsigned int current_index = 0; csharp_properties_renames[current_index][0]; current_index++) {
  1770. csharp_properties_regexes.push_back(memnew(RegEx(String("\\b") + csharp_properties_renames[current_index][0] + "\\b")));
  1771. }
  1772. // CSharp signals renames.
  1773. for (unsigned int current_index = 0; csharp_signals_renames[current_index][0]; current_index++) {
  1774. csharp_signal_regexes.push_back(memnew(RegEx(String("\\b") + csharp_signals_renames[current_index][0] + "\\b")));
  1775. }
  1776. }
  1777. // Colors.
  1778. {
  1779. for (unsigned int current_index = 0; color_renames[current_index][0]; current_index++) {
  1780. color_regexes.push_back(memnew(RegEx(String("\\bColor.") + color_renames[current_index][0] + "\\b")));
  1781. color_renamed.push_back(String("Color.") + color_renames[current_index][1]);
  1782. }
  1783. }
  1784. // Classes.
  1785. {
  1786. for (unsigned int current_index = 0; class_renames[current_index][0]; current_index++) {
  1787. class_tscn_regexes.push_back(memnew(RegEx(String("\\b") + class_renames[current_index][0] + ".tscn\\b")));
  1788. class_gd_regexes.push_back(memnew(RegEx(String("\\b") + class_renames[current_index][0] + ".gd\\b")));
  1789. class_shader_regexes.push_back(memnew(RegEx(String("\\b") + class_renames[current_index][0] + ".shader\\b")));
  1790. class_regexes.push_back(memnew(RegEx(String("\\b") + class_renames[current_index][0] + "\\b")));
  1791. class_temp_tscn_renames.push_back(String(class_renames[current_index][0]) + ".tscn");
  1792. class_temp_gd_renames.push_back(String(class_renames[current_index][0]) + ".gd");
  1793. class_temp_shader_renames.push_back(String(class_renames[current_index][0]) + ".shader");
  1794. }
  1795. }
  1796. }
  1797. ~RegExContainer() {
  1798. for (unsigned int i = 0; i < color_regexes.size(); i++) {
  1799. memdelete(color_regexes[i]);
  1800. }
  1801. for (unsigned int i = 0; i < class_tscn_regexes.size(); i++) {
  1802. memdelete(class_tscn_regexes[i]);
  1803. memdelete(class_gd_regexes[i]);
  1804. memdelete(class_shader_regexes[i]);
  1805. memdelete(class_regexes[i]);
  1806. }
  1807. for (unsigned int i = 0; i < enum_regexes.size(); i++) {
  1808. memdelete(enum_regexes[i]);
  1809. }
  1810. for (unsigned int i = 0; i < gdscript_function_regexes.size(); i++) {
  1811. memdelete(gdscript_function_regexes[i]);
  1812. }
  1813. for (unsigned int i = 0; i < project_settings_regexes.size(); i++) {
  1814. memdelete(project_settings_regexes[i]);
  1815. }
  1816. for (unsigned int i = 0; i < gdscript_properties_regexes.size(); i++) {
  1817. memdelete(gdscript_properties_regexes[i]);
  1818. }
  1819. for (unsigned int i = 0; i < gdscript_signals_regexes.size(); i++) {
  1820. memdelete(gdscript_signals_regexes[i]);
  1821. }
  1822. for (unsigned int i = 0; i < shaders_regexes.size(); i++) {
  1823. memdelete(shaders_regexes[i]);
  1824. }
  1825. for (unsigned int i = 0; i < builtin_types_regexes.size(); i++) {
  1826. memdelete(builtin_types_regexes[i]);
  1827. }
  1828. for (unsigned int i = 0; i < csharp_function_regexes.size(); i++) {
  1829. memdelete(csharp_function_regexes[i]);
  1830. }
  1831. for (unsigned int i = 0; i < csharp_properties_regexes.size(); i++) {
  1832. memdelete(csharp_properties_regexes[i]);
  1833. }
  1834. for (unsigned int i = 0; i < csharp_signal_regexes.size(); i++) {
  1835. memdelete(csharp_signal_regexes[i]);
  1836. }
  1837. }
  1838. };
  1839. ProjectConverter3To4::ProjectConverter3To4(int p_maximum_file_size_kb, int p_maximum_line_length) {
  1840. maximum_file_size = p_maximum_file_size_kb * 1024;
  1841. maximum_line_length = p_maximum_line_length;
  1842. }
  1843. // Function responsible for converting project.
  1844. int ProjectConverter3To4::convert() {
  1845. print_line("Starting conversion.");
  1846. uint64_t conversion_start_time = Time::get_singleton()->get_ticks_msec();
  1847. RegExContainer reg_container = RegExContainer();
  1848. int cached_maximum_line_length = maximum_line_length;
  1849. maximum_line_length = 10000; // Use only for tests bigger value, to not break them.
  1850. ERR_FAIL_COND_V_MSG(!test_array_names(), ERROR_CODE, "Cannot start converting due to problems with data in arrays.");
  1851. ERR_FAIL_COND_V_MSG(!test_conversion(reg_container), ERROR_CODE, "Cannot start converting due to problems with converting arrays.");
  1852. maximum_line_length = cached_maximum_line_length;
  1853. // Checking if folder contains valid Godot 3 project.
  1854. // Project should not be converted more than once.
  1855. {
  1856. String converter_text = "; Project was converted by built-in tool to Godot 4.0";
  1857. ERR_FAIL_COND_V_MSG(!FileAccess::exists("project.godot"), ERROR_CODE, "Current working directory doesn't contain a \"project.godot\" file for a Godot 3 project.");
  1858. Error err = OK;
  1859. String project_godot_content = FileAccess::get_file_as_string("project.godot", &err);
  1860. ERR_FAIL_COND_V_MSG(err != OK, ERROR_CODE, "Unable to read \"project.godot\".");
  1861. ERR_FAIL_COND_V_MSG(project_godot_content.contains(converter_text), ERROR_CODE, "Project was already converted with this tool.");
  1862. Ref<FileAccess> file = FileAccess::open("project.godot", FileAccess::WRITE);
  1863. ERR_FAIL_COND_V_MSG(file.is_null(), ERROR_CODE, "Unable to open \"project.godot\".");
  1864. file->store_string(converter_text + "\n" + project_godot_content);
  1865. }
  1866. Vector<String> collected_files = check_for_files();
  1867. uint32_t converted_files = 0;
  1868. // Check file by file.
  1869. for (int i = 0; i < collected_files.size(); i++) {
  1870. String file_name = collected_files[i];
  1871. Vector<String> lines;
  1872. uint32_t ignored_lines = 0;
  1873. {
  1874. Ref<FileAccess> file = FileAccess::open(file_name, FileAccess::READ);
  1875. ERR_CONTINUE_MSG(file.is_null(), vformat("Unable to read content of \"%s\".", file_name));
  1876. while (!file->eof_reached()) {
  1877. String line = file->get_line();
  1878. lines.append(line);
  1879. }
  1880. }
  1881. String file_content_before = collect_string_from_vector(lines);
  1882. uint64_t hash_before = file_content_before.hash();
  1883. uint64_t file_size = file_content_before.size();
  1884. print_line(vformat("Trying to convert\t%d/%d file - \"%s\" with size - %d KB", i + 1, collected_files.size(), file_name.trim_prefix("res://"), file_size / 1024));
  1885. Vector<String> reason;
  1886. bool is_ignored = false;
  1887. uint64_t start_time = Time::get_singleton()->get_ticks_msec();
  1888. if (file_name.ends_with(".shader")) {
  1889. DirAccess::remove_file_or_error(file_name.trim_prefix("res://"));
  1890. file_name = file_name.replace(".shader", ".gdshader");
  1891. }
  1892. if (file_size < uint64_t(maximum_file_size)) {
  1893. // ".tscn" must work exactly the same as ".gd" files because they may contain built-in Scripts.
  1894. if (file_name.ends_with(".gd")) {
  1895. rename_classes(lines, reg_container); // Using only specialized function.
  1896. rename_common(enum_renames, reg_container.enum_regexes, lines);
  1897. rename_colors(lines, reg_container); // Require to additional rename.
  1898. rename_common(gdscript_function_renames, reg_container.gdscript_function_regexes, lines);
  1899. rename_gdscript_functions(lines, reg_container, false); // Require to additional rename.
  1900. rename_common(project_settings_renames, reg_container.project_settings_regexes, lines);
  1901. rename_gdscript_keywords(lines, reg_container);
  1902. rename_common(gdscript_properties_renames, reg_container.gdscript_properties_regexes, lines);
  1903. rename_common(gdscript_signals_renames, reg_container.gdscript_signals_regexes, lines);
  1904. rename_common(shaders_renames, reg_container.shaders_regexes, lines);
  1905. rename_common(builtin_types_renames, reg_container.builtin_types_regexes, lines);
  1906. custom_rename(lines, "\\.shader", ".gdshader");
  1907. } else if (file_name.ends_with(".tscn")) {
  1908. rename_classes(lines, reg_container); // Using only specialized function.
  1909. rename_common(enum_renames, reg_container.enum_regexes, lines);
  1910. rename_colors(lines, reg_container); // Require to do additional renames.
  1911. rename_common(gdscript_function_renames, reg_container.gdscript_function_regexes, lines);
  1912. rename_gdscript_functions(lines, reg_container, true); // Require to do additional renames.
  1913. rename_common(project_settings_renames, reg_container.project_settings_regexes, lines);
  1914. rename_gdscript_keywords(lines, reg_container);
  1915. rename_common(gdscript_properties_renames, reg_container.gdscript_properties_regexes, lines);
  1916. rename_common(gdscript_signals_renames, reg_container.gdscript_signals_regexes, lines);
  1917. rename_common(shaders_renames, reg_container.shaders_regexes, lines);
  1918. rename_common(builtin_types_renames, reg_container.builtin_types_regexes, lines);
  1919. custom_rename(lines, "\\.shader", ".gdshader");
  1920. } else if (file_name.ends_with(".cs")) { // TODO, C# should use different methods.
  1921. rename_classes(lines, reg_container); // Using only specialized function.
  1922. rename_common(csharp_function_renames, reg_container.csharp_function_regexes, lines);
  1923. rename_common(builtin_types_renames, reg_container.builtin_types_regexes, lines);
  1924. rename_common(csharp_properties_renames, reg_container.csharp_properties_regexes, lines);
  1925. rename_common(csharp_signals_renames, reg_container.csharp_signal_regexes, lines);
  1926. rename_csharp_functions(lines, reg_container);
  1927. rename_csharp_attributes(lines, reg_container);
  1928. custom_rename(lines, "public class ", "public partial class ");
  1929. } else if (file_name.ends_with(".gdshader") || file_name.ends_with(".shader")) {
  1930. rename_common(shaders_renames, reg_container.shaders_regexes, lines);
  1931. } else if (file_name.ends_with("tres")) {
  1932. rename_classes(lines, reg_container); // Using only specialized function.
  1933. rename_common(shaders_renames, reg_container.shaders_regexes, lines);
  1934. rename_common(builtin_types_renames, reg_container.builtin_types_regexes, lines);
  1935. custom_rename(lines, "\\.shader", ".gdshader");
  1936. } else if (file_name.ends_with("project.godot")) {
  1937. rename_common(project_settings_renames, reg_container.project_settings_regexes, lines);
  1938. rename_common(builtin_types_renames, reg_container.builtin_types_regexes, lines);
  1939. } else if (file_name.ends_with(".csproj")) {
  1940. // TODO
  1941. } else {
  1942. ERR_PRINT(file_name + " is not supported!");
  1943. continue;
  1944. }
  1945. for (String &line : lines) {
  1946. if (uint64_t(line.length()) > maximum_line_length) {
  1947. ignored_lines += 1;
  1948. }
  1949. }
  1950. } else {
  1951. reason.append(vformat(" ERROR: File has exceeded the maximum size allowed - %d KB", maximum_file_size / 1024));
  1952. is_ignored = true;
  1953. }
  1954. uint64_t end_time = Time::get_singleton()->get_ticks_msec();
  1955. if (is_ignored) {
  1956. String end_message = vformat(" Checking file took %d ms.", end_time - start_time);
  1957. print_line(end_message);
  1958. } else {
  1959. String file_content_after = collect_string_from_vector(lines);
  1960. uint64_t hash_after = file_content_after.hash64();
  1961. // Don't need to save file without any changes.
  1962. // Save if this is a shader, because it was renamed.
  1963. if (hash_before != hash_after || file_name.ends_with(".gdshader")) {
  1964. converted_files++;
  1965. Ref<FileAccess> file = FileAccess::open(file_name, FileAccess::WRITE);
  1966. ERR_CONTINUE_MSG(file.is_null(), vformat("Unable to apply changes to \"%s\", no writing access.", file_name));
  1967. file->store_string(file_content_after);
  1968. reason.append(vformat(" File was changed, conversion took %d ms.", end_time - start_time));
  1969. } else {
  1970. reason.append(vformat(" File was left unchanged, checking took %d ms.", end_time - start_time));
  1971. }
  1972. if (ignored_lines != 0) {
  1973. reason.append(vformat(" Ignored %d lines, because their length exceeds maximum allowed characters - %d.", ignored_lines, maximum_line_length));
  1974. }
  1975. }
  1976. for (int k = 0; k < reason.size(); k++) {
  1977. print_line(reason[k]);
  1978. }
  1979. }
  1980. print_line(vformat("Conversion ended - all files(%d), converted files: (%d), not converted files: (%d).", collected_files.size(), converted_files, collected_files.size() - converted_files));
  1981. uint64_t conversion_end_time = Time::get_singleton()->get_ticks_msec();
  1982. print_line(vformat("Conversion of all files took %10.3f seconds.", (conversion_end_time - conversion_start_time) / 1000.0));
  1983. return 0;
  1984. };
  1985. // Function responsible for validating project conversion.
  1986. int ProjectConverter3To4::validate_conversion() {
  1987. print_line("Starting checking if project conversion can be done.");
  1988. uint64_t conversion_start_time = Time::get_singleton()->get_ticks_msec();
  1989. RegExContainer reg_container = RegExContainer();
  1990. int cached_maximum_line_length = maximum_line_length;
  1991. maximum_line_length = 10000; // To avoid breaking the tests, only use this for the their larger value.
  1992. ERR_FAIL_COND_V_MSG(!test_array_names(), ERROR_CODE, "Cannot start converting due to problems with data in arrays.");
  1993. ERR_FAIL_COND_V_MSG(!test_conversion(reg_container), ERROR_CODE, "Cannot start converting due to problems with converting arrays.");
  1994. maximum_line_length = cached_maximum_line_length;
  1995. // Checking if folder contains valid Godot 3 project.
  1996. // Project should not be converted more than once.
  1997. {
  1998. String conventer_text = "; Project was converted by built-in tool to Godot 4.0";
  1999. ERR_FAIL_COND_V_MSG(!FileAccess::exists("project.godot"), ERROR_CODE, "Current directory doesn't contains any Godot 3 project");
  2000. Error err = OK;
  2001. String project_godot_content = FileAccess::get_file_as_string("project.godot", &err);
  2002. ERR_FAIL_COND_V_MSG(err != OK, ERROR_CODE, "Failed to read content of \"project.godot\" file.");
  2003. ERR_FAIL_COND_V_MSG(project_godot_content.contains(conventer_text), ERROR_CODE, "Project already was converted with this tool.");
  2004. }
  2005. Vector<String> collected_files = check_for_files();
  2006. uint32_t converted_files = 0;
  2007. // Check file by file.
  2008. for (int i = 0; i < collected_files.size(); i++) {
  2009. String file_name = collected_files[i];
  2010. Vector<String> lines;
  2011. uint32_t ignored_lines = 0;
  2012. uint64_t file_size = 0;
  2013. {
  2014. Ref<FileAccess> file = FileAccess::open(file_name, FileAccess::READ);
  2015. ERR_CONTINUE_MSG(file.is_null(), vformat("Unable to read content of \"%s\".", file_name));
  2016. while (!file->eof_reached()) {
  2017. String line = file->get_line();
  2018. file_size += line.size();
  2019. lines.append(line);
  2020. }
  2021. }
  2022. print_line(vformat("Checking for conversion - %d/%d file - \"%s\" with size - %d KB"), i + 1, collected_files.size(), file_name.trim_prefix("res://"), file_size / 1024);
  2023. Vector<String> changed_elements;
  2024. Vector<String> reason;
  2025. bool is_ignored = false;
  2026. uint64_t start_time = Time::get_singleton()->get_ticks_msec();
  2027. if (file_name.ends_with(".shader")) {
  2028. reason.append("\tFile extension will be renamed from \"shader\" to \"gdshader\".");
  2029. }
  2030. if (file_size < uint64_t(maximum_file_size)) {
  2031. if (file_name.ends_with(".gd")) {
  2032. changed_elements.append_array(check_for_rename_classes(lines, reg_container));
  2033. changed_elements.append_array(check_for_rename_common(enum_renames, reg_container.enum_regexes, lines));
  2034. changed_elements.append_array(check_for_rename_colors(lines, reg_container));
  2035. changed_elements.append_array(check_for_rename_common(gdscript_function_renames, reg_container.gdscript_function_regexes, lines));
  2036. changed_elements.append_array(check_for_rename_gdscript_functions(lines, reg_container, false));
  2037. changed_elements.append_array(check_for_rename_common(project_settings_renames, reg_container.project_settings_regexes, lines));
  2038. changed_elements.append_array(check_for_rename_gdscript_keywords(lines, reg_container));
  2039. changed_elements.append_array(check_for_rename_common(gdscript_properties_renames, reg_container.gdscript_properties_regexes, lines));
  2040. changed_elements.append_array(check_for_rename_common(gdscript_signals_renames, reg_container.gdscript_signals_regexes, lines));
  2041. changed_elements.append_array(check_for_rename_common(shaders_renames, reg_container.shaders_regexes, lines));
  2042. changed_elements.append_array(check_for_rename_common(builtin_types_renames, reg_container.builtin_types_regexes, lines));
  2043. changed_elements.append_array(check_for_custom_rename(lines, "\\.shader", ".gdshader"));
  2044. } else if (file_name.ends_with(".tscn")) {
  2045. changed_elements.append_array(check_for_rename_classes(lines, reg_container));
  2046. changed_elements.append_array(check_for_rename_common(enum_renames, reg_container.enum_regexes, lines));
  2047. changed_elements.append_array(check_for_rename_colors(lines, reg_container));
  2048. changed_elements.append_array(check_for_rename_common(gdscript_function_renames, reg_container.gdscript_function_regexes, lines));
  2049. changed_elements.append_array(check_for_rename_gdscript_functions(lines, reg_container, true));
  2050. changed_elements.append_array(check_for_rename_common(project_settings_renames, reg_container.project_settings_regexes, lines));
  2051. changed_elements.append_array(check_for_rename_gdscript_keywords(lines, reg_container));
  2052. changed_elements.append_array(check_for_rename_common(gdscript_properties_renames, reg_container.gdscript_properties_regexes, lines));
  2053. changed_elements.append_array(check_for_rename_common(gdscript_signals_renames, reg_container.gdscript_signals_regexes, lines));
  2054. changed_elements.append_array(check_for_rename_common(shaders_renames, reg_container.shaders_regexes, lines));
  2055. changed_elements.append_array(check_for_rename_common(builtin_types_renames, reg_container.builtin_types_regexes, lines));
  2056. changed_elements.append_array(check_for_custom_rename(lines, "\\.shader", ".gdshader"));
  2057. } else if (file_name.ends_with(".cs")) {
  2058. changed_elements.append_array(check_for_rename_classes(lines, reg_container));
  2059. changed_elements.append_array(check_for_rename_common(csharp_function_renames, reg_container.csharp_function_regexes, lines));
  2060. changed_elements.append_array(check_for_rename_common(builtin_types_renames, reg_container.builtin_types_regexes, lines));
  2061. changed_elements.append_array(check_for_rename_common(csharp_properties_renames, reg_container.csharp_properties_regexes, lines));
  2062. changed_elements.append_array(check_for_rename_common(csharp_signals_renames, reg_container.csharp_signal_regexes, lines));
  2063. changed_elements.append_array(check_for_rename_csharp_functions(lines, reg_container));
  2064. changed_elements.append_array(check_for_rename_csharp_attributes(lines, reg_container));
  2065. changed_elements.append_array(check_for_custom_rename(lines, "public class ", "public partial class "));
  2066. } else if (file_name.ends_with(".gdshader") || file_name.ends_with(".shader")) {
  2067. changed_elements.append_array(check_for_rename_common(shaders_renames, reg_container.shaders_regexes, lines));
  2068. } else if (file_name.ends_with("tres")) {
  2069. changed_elements.append_array(check_for_rename_classes(lines, reg_container));
  2070. changed_elements.append_array(check_for_rename_common(shaders_renames, reg_container.shaders_regexes, lines));
  2071. changed_elements.append_array(check_for_rename_common(builtin_types_renames, reg_container.builtin_types_regexes, lines));
  2072. changed_elements.append_array(check_for_custom_rename(lines, "\\.shader", ".gdshader"));
  2073. } else if (file_name.ends_with("project.godot")) {
  2074. changed_elements.append_array(check_for_rename_common(project_settings_renames, reg_container.project_settings_regexes, lines));
  2075. changed_elements.append_array(check_for_rename_common(builtin_types_renames, reg_container.builtin_types_regexes, lines));
  2076. } else if (file_name.ends_with(".csproj")) {
  2077. // TODO
  2078. } else {
  2079. ERR_PRINT(vformat("\"%s\", is not supported!", file_name));
  2080. continue;
  2081. }
  2082. for (String &line : lines) {
  2083. if (uint64_t(line.length()) > maximum_line_length) {
  2084. ignored_lines += 1;
  2085. }
  2086. }
  2087. } else {
  2088. reason.append(vformat("\tERROR: File has exceeded the maximum size allowed - %d KB.", maximum_file_size / 1024));
  2089. is_ignored = true;
  2090. }
  2091. uint64_t end_time = Time::get_singleton()->get_ticks_msec();
  2092. String end_message = vformat(" Checking file took %10.3f ms.", (end_time - start_time) / 1000.0);
  2093. if (ignored_lines != 0) {
  2094. end_message += vformat(" Ignored %d lines, because their length exceeds maximum allowed characters - %d.", ignored_lines, maximum_line_length);
  2095. }
  2096. print_line(end_message);
  2097. for (int k = 0; k < reason.size(); k++) {
  2098. print_line(reason[k]);
  2099. }
  2100. if (changed_elements.size() > 0 && !is_ignored) {
  2101. converted_files++;
  2102. for (int k = 0; k < changed_elements.size(); k++) {
  2103. print_line(String("\t\t") + changed_elements[k]);
  2104. }
  2105. }
  2106. }
  2107. print_line(vformat("Checking for valid conversion ended - all files(%d), files which would be converted(%d), files which would not be converted(%d).", collected_files.size(), converted_files, collected_files.size() - converted_files));
  2108. uint64_t conversion_end_time = Time::get_singleton()->get_ticks_msec();
  2109. print_line(vformat("Conversion of all files took %10.3f seconds.", (conversion_end_time - conversion_start_time) / 1000.0));
  2110. return 0;
  2111. }
  2112. // Collect files which will be checked, excluding ".txt", ".mp4", ".wav" etc. files.
  2113. Vector<String> ProjectConverter3To4::check_for_files() {
  2114. Vector<String> collected_files = Vector<String>();
  2115. Vector<String> directories_to_check = Vector<String>();
  2116. directories_to_check.push_back("res://");
  2117. while (!directories_to_check.is_empty()) {
  2118. String path = directories_to_check.get(directories_to_check.size() - 1); // Is there any pop_back function?
  2119. directories_to_check.resize(directories_to_check.size() - 1); // Remove last element
  2120. Ref<DirAccess> dir = DirAccess::create_for_path(path);
  2121. if (dir.is_valid()) {
  2122. dir->set_include_hidden(true);
  2123. dir->list_dir_begin();
  2124. String current_dir = dir->get_current_dir();
  2125. String file_name = dir->_get_next();
  2126. while (file_name != "") {
  2127. if (file_name == ".git" || file_name == ".import" || file_name == ".godot") {
  2128. file_name = dir->_get_next();
  2129. continue;
  2130. }
  2131. if (dir->current_is_dir()) {
  2132. directories_to_check.append(current_dir.path_join(file_name) + "/");
  2133. } else {
  2134. bool proper_extension = false;
  2135. if (file_name.ends_with(".gd") || file_name.ends_with(".shader") || file_name.ends_with(".tscn") || file_name.ends_with(".tres") || file_name.ends_with(".godot") || file_name.ends_with(".cs") || file_name.ends_with(".csproj"))
  2136. proper_extension = true;
  2137. if (proper_extension) {
  2138. collected_files.append(current_dir.path_join(file_name));
  2139. }
  2140. }
  2141. file_name = dir->_get_next();
  2142. }
  2143. } else {
  2144. print_verbose("Failed to open " + path);
  2145. }
  2146. }
  2147. return collected_files;
  2148. }
  2149. // Test expected results of gdscript
  2150. bool ProjectConverter3To4::test_conversion_gdscript_builtin(String name, String expected, void (ProjectConverter3To4::*func)(Vector<String> &, const RegExContainer &, bool), String what, const RegExContainer &reg_container, bool builtin_script) {
  2151. Vector<String> got = name.split("\n");
  2152. (this->*func)(got, reg_container, builtin_script);
  2153. String got_str = collect_string_from_vector(got);
  2154. ERR_FAIL_COND_V_MSG(expected != got_str, false, vformat("Failed to convert %s \"%s\" to \"%s\", got instead \"%s\"", what, name, expected, got_str));
  2155. return true;
  2156. }
  2157. bool ProjectConverter3To4::test_conversion_with_regex(String name, String expected, void (ProjectConverter3To4::*func)(Vector<String> &, const RegExContainer &), String what, const RegExContainer &reg_container) {
  2158. Vector<String> got = name.split("\n");
  2159. (this->*func)(got, reg_container);
  2160. String got_str = collect_string_from_vector(got);
  2161. ERR_FAIL_COND_V_MSG(expected != got_str, false, vformat("Failed to convert %s \"%s\" to \"%s\", got instead \"%s\"", what, name, expected, got_str));
  2162. return true;
  2163. }
  2164. bool ProjectConverter3To4::test_conversion_basic(String name, String expected, const char *array[][2], LocalVector<RegEx *> &regex_cache, String what) {
  2165. Vector<String> got = name.split("\n");
  2166. rename_common(array, regex_cache, got);
  2167. String got_str = collect_string_from_vector(got);
  2168. ERR_FAIL_COND_V_MSG(expected != got_str, false, vformat("Failed to convert %s \"%s\" to \"%s\", got instead \"%s\"", what, name, expected, got_str));
  2169. return true;
  2170. }
  2171. // Validate if conversions are proper.
  2172. bool ProjectConverter3To4::test_conversion(RegExContainer &reg_container) {
  2173. bool valid = true;
  2174. valid = valid && test_conversion_basic("TYPE_REAL", "TYPE_FLOAT", enum_renames, reg_container.enum_regexes, "enum");
  2175. valid = valid && test_conversion_basic("can_instance", "can_instantiate", gdscript_function_renames, reg_container.gdscript_function_regexes, "gdscript function");
  2176. valid = valid && test_conversion_basic("CanInstance", "CanInstantiate", csharp_function_renames, reg_container.csharp_function_regexes, "csharp function");
  2177. valid = valid && test_conversion_basic("translation", "position", gdscript_properties_renames, reg_container.gdscript_properties_regexes, "gdscript property");
  2178. valid = valid && test_conversion_basic("Translation", "Position", csharp_properties_renames, reg_container.csharp_properties_regexes, "csharp property");
  2179. valid = valid && test_conversion_basic("NORMALMAP", "NORMAL_MAP", shaders_renames, reg_container.shaders_regexes, "shader");
  2180. valid = valid && test_conversion_basic("text_entered", "text_submitted", gdscript_signals_renames, reg_container.gdscript_signals_regexes, "gdscript signal");
  2181. valid = valid && test_conversion_basic("TextEntered", "TextSubmitted", csharp_signals_renames, reg_container.csharp_signal_regexes, "csharp signal");
  2182. valid = valid && test_conversion_basic("audio/channel_disable_threshold_db", "audio/buses/channel_disable_threshold_db", project_settings_renames, reg_container.project_settings_regexes, "project setting");
  2183. valid = valid && test_conversion_basic("Transform", "Transform3D", builtin_types_renames, reg_container.builtin_types_regexes, "builtin type");
  2184. // Custom Renames.
  2185. valid = valid && test_conversion_with_regex("(Connect(A,B,C,D,E,F,G) != OK):", "(Connect(A,new Callable(B,C),D,E,F,G) != OK):", &ProjectConverter3To4::rename_csharp_functions, "custom rename csharp", reg_container);
  2186. valid = valid && test_conversion_with_regex("(Disconnect(A,B,C) != OK):", "(Disconnect(A,new Callable(B,C)) != OK):", &ProjectConverter3To4::rename_csharp_functions, "custom rename csharp", reg_container);
  2187. valid = valid && test_conversion_with_regex("(IsConnected(A,B,C) != OK):", "(IsConnected(A,new Callable(B,C)) != OK):", &ProjectConverter3To4::rename_csharp_functions, "custom rename", reg_container);
  2188. valid = valid && test_conversion_with_regex("[Remote]", "[RPC(MultiplayerAPI.RPCMode.AnyPeer)]", &ProjectConverter3To4::rename_csharp_attributes, "custom rename csharp", reg_container);
  2189. valid = valid && test_conversion_with_regex("[RemoteSync]", "[RPC(MultiplayerAPI.RPCMode.AnyPeer, CallLocal = true)]", &ProjectConverter3To4::rename_csharp_attributes, "custom rename csharp", reg_container);
  2190. valid = valid && test_conversion_with_regex("[Sync]", "[RPC(MultiplayerAPI.RPCMode.AnyPeer, CallLocal = true)]", &ProjectConverter3To4::rename_csharp_attributes, "custom rename csharp", reg_container);
  2191. valid = valid && test_conversion_with_regex("[Slave]", "[RPC]", &ProjectConverter3To4::rename_csharp_attributes, "custom rename csharp", reg_container);
  2192. valid = valid && test_conversion_with_regex("[Puppet]", "[RPC]", &ProjectConverter3To4::rename_csharp_attributes, "custom rename csharp", reg_container);
  2193. valid = valid && test_conversion_with_regex("[PuppetSync]", "[RPC(CallLocal = true)]", &ProjectConverter3To4::rename_csharp_attributes, "custom rename csharp", reg_container);
  2194. valid = valid && test_conversion_with_regex("[Master]", "The master and mastersync rpc behavior is not officially supported anymore. Try using another keyword or making custom logic using Multiplayer.GetRemoteSenderId()\n[RPC]", &ProjectConverter3To4::rename_csharp_attributes, "custom rename csharp", reg_container);
  2195. valid = valid && test_conversion_with_regex("[MasterSync]", "The master and mastersync rpc behavior is not officially supported anymore. Try using another keyword or making custom logic using Multiplayer.GetRemoteSenderId()\n[RPC(CallLocal = true)]", &ProjectConverter3To4::rename_csharp_attributes, "custom rename csharp", reg_container);
  2196. valid = valid && test_conversion_gdscript_builtin("OS.window_fullscreen = Settings.fullscreen", "ProjectSettings.set(\"display/window/size/fullscreen\", Settings.fullscreen)", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false);
  2197. valid = valid && test_conversion_gdscript_builtin("OS.window_fullscreen = Settings.fullscreen", "ProjectSettings.set(\\\"display/window/size/fullscreen\\\", Settings.fullscreen)", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, true);
  2198. valid = valid && test_conversion_gdscript_builtin("OS.get_window_safe_area()", "DisplayServer.get_display_safe_area()", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false);
  2199. valid = valid && test_conversion_gdscript_builtin("\tvar aa = roman(r.move_and_slide( a, b, c, d, e, f )) # Roman", "\tr.set_velocity(a)\n\tr.set_up_direction(b)\n\tr.set_floor_stop_on_slope_enabled(c)\n\tr.set_max_slides(d)\n\tr.set_floor_max_angle(e)\n\t# TODOConverter40 infinite_inertia were removed in Godot 4.0 - previous value `f`\n\tr.move_and_slide()\n\tvar aa = roman(r.velocity) # Roman", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false);
  2200. valid = valid && test_conversion_gdscript_builtin("\tvar aa = roman(r.move_and_slide_with_snap( a, g, b, c, d, e, f )) # Roman", "\tr.set_velocity(a)\n\t# TODOConverter40 looks that snap in Godot 4.0 is float, not vector like in Godot 3 - previous value `g`\n\tr.set_up_direction(b)\n\tr.set_floor_stop_on_slope_enabled(c)\n\tr.set_max_slides(d)\n\tr.set_floor_max_angle(e)\n\t# TODOConverter40 infinite_inertia were removed in Godot 4.0 - previous value `f`\n\tr.move_and_slide()\n\tvar aa = roman(r.velocity) # Roman", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false);
  2201. valid = valid && test_conversion_gdscript_builtin("list_dir_begin( a , b )", "list_dir_begin() # TODOGODOT4 fill missing arguments https://github.com/godotengine/godot/pull/40547", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false);
  2202. valid = valid && test_conversion_gdscript_builtin("list_dir_begin( a )", "list_dir_begin() # TODOGODOT4 fill missing arguments https://github.com/godotengine/godot/pull/40547", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false);
  2203. valid = valid && test_conversion_gdscript_builtin("list_dir_begin( )", "list_dir_begin() # TODOGODOT4 fill missing arguments https://github.com/godotengine/godot/pull/40547", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false);
  2204. valid = valid && test_conversion_gdscript_builtin("sort_custom( a , b )", "sort_custom(Callable(a,b))", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false);
  2205. valid = valid && test_conversion_gdscript_builtin("func c(var a, var b)", "func c(a, b)", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false);
  2206. valid = valid && test_conversion_gdscript_builtin("draw_line(1, 2, 3, 4, 5)", "draw_line(1,2,3,4)", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false);
  2207. valid = valid && test_conversion_gdscript_builtin("\timage.lock()", "\tfalse # image.lock() # TODOConverter40, Image no longer requires locking, `false` helps to not break one line if/else, so it can freely be removed", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false);
  2208. valid = valid && test_conversion_gdscript_builtin("\timage.unlock()", "\tfalse # image.unlock() # TODOConverter40, Image no longer requires locking, `false` helps to not break one line if/else, so it can freely be removed", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false);
  2209. valid = valid && test_conversion_gdscript_builtin("\troman.image.unlock()", "\tfalse # roman.image.unlock() # TODOConverter40, Image no longer requires locking, `false` helps to not break one line if/else, so it can freely be removed", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false);
  2210. valid = valid && test_conversion_gdscript_builtin("\tmtx.lock()", "\tmtx.lock()", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false);
  2211. valid = valid && test_conversion_gdscript_builtin("\tmutex.unlock()", "\tmutex.unlock()", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false);
  2212. valid = valid && test_conversion_with_regex("extends CSGBox", "extends CSGBox3D", &ProjectConverter3To4::rename_classes, "classes", reg_container);
  2213. valid = valid && test_conversion_with_regex("CSGBox", "CSGBox3D", &ProjectConverter3To4::rename_classes, "classes", reg_container);
  2214. valid = valid && test_conversion_with_regex("Spatial", "Node3D", &ProjectConverter3To4::rename_classes, "classes", reg_container);
  2215. valid = valid && test_conversion_with_regex("Spatial.tscn", "Spatial.tscn", &ProjectConverter3To4::rename_classes, "classes", reg_container);
  2216. valid = valid && test_conversion_with_regex("Spatial.gd", "Spatial.gd", &ProjectConverter3To4::rename_classes, "classes", reg_container);
  2217. valid = valid && test_conversion_with_regex("Spatial.shader", "Spatial.shader", &ProjectConverter3To4::rename_classes, "classes", reg_container);
  2218. valid = valid && test_conversion_with_regex("Spatial.other", "Node3D.other", &ProjectConverter3To4::rename_classes, "classes", reg_container);
  2219. valid = valid && test_conversion_with_regex("\nonready", "\n@onready", &ProjectConverter3To4::rename_gdscript_keywords, "gdscript keyword", reg_container);
  2220. valid = valid && test_conversion_with_regex("onready", "@onready", &ProjectConverter3To4::rename_gdscript_keywords, "gdscript keyword", reg_container);
  2221. valid = valid && test_conversion_with_regex(" onready", " onready", &ProjectConverter3To4::rename_gdscript_keywords, "gdscript keyword", reg_container);
  2222. valid = valid && test_conversion_with_regex("\nexport", "\n@export", &ProjectConverter3To4::rename_gdscript_keywords, "gdscript keyword", reg_container);
  2223. valid = valid && test_conversion_with_regex("\texport", "\t@export", &ProjectConverter3To4::rename_gdscript_keywords, "gdscript keyword", reg_container);
  2224. valid = valid && test_conversion_with_regex("\texport_dialog", "\texport_dialog", &ProjectConverter3To4::rename_gdscript_keywords, "gdscript keyword", reg_container);
  2225. valid = valid && test_conversion_with_regex("export", "@export", &ProjectConverter3To4::rename_gdscript_keywords, "gdscript keyword", reg_container);
  2226. valid = valid && test_conversion_with_regex(" export", " export", &ProjectConverter3To4::rename_gdscript_keywords, "gdscript keyword", reg_container);
  2227. valid = valid && test_conversion_with_regex("tool", "@tool", &ProjectConverter3To4::rename_gdscript_keywords, "gdscript keyword", reg_container);
  2228. valid = valid && test_conversion_with_regex("\n tool", "\n tool", &ProjectConverter3To4::rename_gdscript_keywords, "gdscript keyword", reg_container);
  2229. valid = valid && test_conversion_with_regex("\n\ntool", "\n\n@tool", &ProjectConverter3To4::rename_gdscript_keywords, "gdscript keyword", reg_container);
  2230. valid = valid && test_conversion_with_regex("\n\nremote func", "\n\n@rpc(any_peer) func", &ProjectConverter3To4::rename_gdscript_keywords, "gdscript keyword", reg_container);
  2231. valid = valid && test_conversion_with_regex("\n\nremotesync func", "\n\n@rpc(any_peer, call_local) func", &ProjectConverter3To4::rename_gdscript_keywords, "gdscript keyword", reg_container);
  2232. valid = valid && test_conversion_with_regex("\n\nsync func", "\n\n@rpc(any_peer, call_local) func", &ProjectConverter3To4::rename_gdscript_keywords, "gdscript keyword", reg_container);
  2233. valid = valid && test_conversion_with_regex("\n\nslave func", "\n\n@rpc func", &ProjectConverter3To4::rename_gdscript_keywords, "gdscript keyword", reg_container);
  2234. valid = valid && test_conversion_with_regex("\n\npuppet func", "\n\n@rpc func", &ProjectConverter3To4::rename_gdscript_keywords, "gdscript keyword", reg_container);
  2235. valid = valid && test_conversion_with_regex("\n\npuppetsync func", "\n\n@rpc(call_local) func", &ProjectConverter3To4::rename_gdscript_keywords, "gdscript keyword", reg_container);
  2236. valid = valid && test_conversion_with_regex("\n\nmaster func", "\n\nThe master and mastersync rpc behavior is not officially supported anymore. Try using another keyword or making custom logic using get_multiplayer().get_remote_sender_id()\n@rpc func", &ProjectConverter3To4::rename_gdscript_keywords, "gdscript keyword", reg_container);
  2237. valid = valid && test_conversion_with_regex("\n\nmastersync func", "\n\nThe master and mastersync rpc behavior is not officially supported anymore. Try using another keyword or making custom logic using get_multiplayer().get_remote_sender_id()\n@rpc(call_local) func", &ProjectConverter3To4::rename_gdscript_keywords, "gdscript keyword", reg_container);
  2238. valid = valid && test_conversion_gdscript_builtin("var size : Vector2 = Vector2() setget set_function , get_function", "var size : Vector2 = Vector2() :\n get:\n return size # TODOConverter40 Copy here content of get_function\n set(mod_value):\n mod_value # TODOConverter40 Copy here content of set_function", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false);
  2239. valid = valid && test_conversion_gdscript_builtin("var size : Vector2 = Vector2() setget set_function , ", "var size : Vector2 = Vector2() :\n get:\n return size # TODOConverter40 Non existent get function \n set(mod_value):\n mod_value # TODOConverter40 Copy here content of set_function", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false);
  2240. valid = valid && test_conversion_gdscript_builtin("var size : Vector2 = Vector2() setget set_function", "var size : Vector2 = Vector2() :\n get:\n return size # TODOConverter40 Non existent get function \n set(mod_value):\n mod_value # TODOConverter40 Copy here content of set_function", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false);
  2241. valid = valid && test_conversion_gdscript_builtin("var size : Vector2 = Vector2() setget , get_function", "var size : Vector2 = Vector2() :\n get:\n return size # TODOConverter40 Copy here content of get_function \n set(mod_value):\n mod_value # TODOConverter40 Non existent set function", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false);
  2242. valid = valid && test_conversion_gdscript_builtin("get_node(@", "get_node(", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false);
  2243. valid = valid && test_conversion_gdscript_builtin("yield(this, \"timeout\")", "await this.timeout", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false);
  2244. valid = valid && test_conversion_gdscript_builtin("yield(this, \\\"timeout\\\")", "await this.timeout", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, true);
  2245. valid = valid && test_conversion_gdscript_builtin(" Transform.xform(Vector3(a,b,c)) ", " Transform * Vector3(a,b,c) ", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false);
  2246. valid = valid && test_conversion_gdscript_builtin(" Transform.xform_inv(Vector3(a,b,c)) ", " Vector3(a,b,c) * Transform ", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false);
  2247. valid = valid && test_conversion_gdscript_builtin("export(float) var lifetime = 3.0", "export var lifetime: float = 3.0", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false);
  2248. valid = valid && test_conversion_gdscript_builtin("export(String, 'AnonymousPro', 'CourierPrime') var _font_name = 'AnonymousPro'", "export var _font_name = 'AnonymousPro' # (String, 'AnonymousPro', 'CourierPrime')", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false); // TODO, this is only a workaround
  2249. valid = valid && test_conversion_gdscript_builtin("export(PackedScene) var mob_scene", "export var mob_scene: PackedScene", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false);
  2250. valid = valid && test_conversion_gdscript_builtin("var d = parse_json(roman(sfs))", "var test_json_conv = JSON.new()\ntest_json_conv.parse(roman(sfs))\nvar d = test_json_conv.get_data()", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false);
  2251. valid = valid && test_conversion_gdscript_builtin("to_json( AA ) szon", "JSON.new().stringify( AA ) szon", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false);
  2252. valid = valid && test_conversion_gdscript_builtin("s to_json", "s JSON.new().stringify", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false);
  2253. valid = valid && test_conversion_gdscript_builtin("AF to_json2", "AF to_json2", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false);
  2254. valid = valid && test_conversion_gdscript_builtin("var rr = JSON.parse(a)", "var test_json_conv = JSON.new()\ntest_json_conv.parse(a)\nvar rr = test_json_conv.get_data()", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false);
  2255. valid = valid && test_conversion_gdscript_builtin("empty()", "is_empty()", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false);
  2256. valid = valid && test_conversion_gdscript_builtin(".empty", ".empty", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false);
  2257. valid = valid && test_conversion_gdscript_builtin(").roman(", ").roman(", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false);
  2258. valid = valid && test_conversion_gdscript_builtin("\t.roman(", "\tsuper.roman(", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false);
  2259. valid = valid && test_conversion_gdscript_builtin(" .roman(", " super.roman(", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false);
  2260. valid = valid && test_conversion_gdscript_builtin(".1", ".1", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false);
  2261. valid = valid && test_conversion_gdscript_builtin(" .1", " .1", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false);
  2262. valid = valid && test_conversion_gdscript_builtin("'.'", "'.'", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false);
  2263. valid = valid && test_conversion_gdscript_builtin("'.a'", "'.a'", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false);
  2264. valid = valid && test_conversion_gdscript_builtin("\t._input(_event)", "\tsuper._input(_event)", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false);
  2265. valid = valid && test_conversion_gdscript_builtin("(connect(A,B,C) != OK):", "(connect(A,Callable(B,C)) != OK):", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false);
  2266. valid = valid && test_conversion_gdscript_builtin("(connect(A,B,C,D) != OK):", "(connect(A,Callable(B,C).bind(D)) != OK):", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false);
  2267. valid = valid && test_conversion_gdscript_builtin("(connect(A,B,C,[D]) != OK):", "(connect(A,Callable(B,C).bind(D)) != OK):", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false);
  2268. valid = valid && test_conversion_gdscript_builtin("(connect(A,B,C,[D,E]) != OK):", "(connect(A,Callable(B,C).bind(D,E)) != OK):", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false);
  2269. valid = valid && test_conversion_gdscript_builtin("(connect(A,B,C,[D,E],F) != OK):", "(connect(A,Callable(B,C).bind(D,E),F) != OK):", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false);
  2270. valid = valid && test_conversion_gdscript_builtin("(connect(A,B,C,D,E) != OK):", "(connect(A,Callable(B,C).bind(D),E) != OK):", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false);
  2271. valid = valid && test_conversion_gdscript_builtin("(start(A,B) != OK):", "(start(Callable(A,B)) != OK):", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false);
  2272. valid = valid && test_conversion_gdscript_builtin("func start(A,B):", "func start(A,B):", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false);
  2273. valid = valid && test_conversion_gdscript_builtin("(start(A,B,C,D,E,F,G) != OK):", "(start(Callable(A,B).bind(C),D,E,F,G) != OK):", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false);
  2274. valid = valid && test_conversion_gdscript_builtin("disconnect(A,B,C) != OK):", "disconnect(A,Callable(B,C)) != OK):", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false);
  2275. valid = valid && test_conversion_gdscript_builtin("is_connected(A,B,C) != OK):", "is_connected(A,Callable(B,C)) != OK):", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false);
  2276. valid = valid && test_conversion_gdscript_builtin("is_connected(A,B,C))", "is_connected(A,Callable(B,C)))", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false);
  2277. valid = valid && test_conversion_gdscript_builtin("(tween_method(A,B,C,D,E).foo())", "(tween_method(Callable(A,B),C,D,E).foo())", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false);
  2278. valid = valid && test_conversion_gdscript_builtin("(tween_method(A,B,C,D,E,[F,G]).foo())", "(tween_method(Callable(A,B).bind(F,G),C,D,E).foo())", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false);
  2279. valid = valid && test_conversion_gdscript_builtin("(tween_callback(A,B).foo())", "(tween_callback(Callable(A,B)).foo())", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false);
  2280. valid = valid && test_conversion_gdscript_builtin("(tween_callback(A,B,[C,D]).foo())", "(tween_callback(Callable(A,B).bind(C,D)).foo())", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false);
  2281. valid = valid && test_conversion_gdscript_builtin("func _init(", "func _init(", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false);
  2282. valid = valid && test_conversion_gdscript_builtin("func _init(p_x:int)->void:", "func _init(p_x:int):", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false);
  2283. valid = valid && test_conversion_gdscript_builtin("q_PackedDataContainer._iter_init(variable1)", "q_PackedDataContainer._iter_init(variable1)", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false);
  2284. valid = valid && test_conversion_gdscript_builtin("assert(speed < 20, str(randi()%10))", "assert(speed < 20) #,str(randi()%10))", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false);
  2285. valid = valid && test_conversion_gdscript_builtin("assert(speed < 2)", "assert(speed < 2)", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false);
  2286. valid = valid && test_conversion_gdscript_builtin("assert(false, \"Missing type --\" + str(argument.type) + \"--, needs to be added to project\")", "assert(false) #,\"Missing type --\" + str(argument.type) + \"--, needs to be added to project\")", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false);
  2287. valid = valid && test_conversion_gdscript_builtin("create_from_image(aa, bb)", "create_from_image(aa) #,bb", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false);
  2288. valid = valid && test_conversion_gdscript_builtin("q_ImageTexture.create_from_image(variable1, variable2)", "q_ImageTexture.create_from_image(variable1) #,variable2", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false);
  2289. valid = valid && test_conversion_gdscript_builtin("set_cell_item(a, b, c, d ,e) # AA", "set_cell_item( Vector3(a,b,c) ,d,e) # AA", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false);
  2290. valid = valid && test_conversion_gdscript_builtin("set_cell_item(a, b)", "set_cell_item(a, b)", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false);
  2291. valid = valid && test_conversion_gdscript_builtin("get_cell_item_orientation(a, b,c)", "get_cell_item_orientation(Vector3i(a,b,c))", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false);
  2292. valid = valid && test_conversion_gdscript_builtin("get_cell_item(a, b,c)", "get_cell_item(Vector3i(a,b,c))", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false);
  2293. valid = valid && test_conversion_gdscript_builtin("map_to_world(a, b,c)", "map_to_local(Vector3i(a,b,c))", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false);
  2294. valid = valid && test_conversion_gdscript_builtin("PackedStringArray(req_godot).join('.')", "'.'.join(PackedStringArray(req_godot))", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false);
  2295. valid = valid && test_conversion_gdscript_builtin("=PackedStringArray(req_godot).join('.')", "='.'.join(PackedStringArray(req_godot))", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false);
  2296. valid = valid && test_conversion_gdscript_builtin("apply_force(position, impulse)", "apply_force(impulse, position)", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false);
  2297. valid = valid && test_conversion_gdscript_builtin("apply_impulse(position, impulse)", "apply_impulse(impulse, position)", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false);
  2298. valid = valid && test_conversion_gdscript_builtin("draw_rect(a,b,c,d,e).abc", "draw_rect(a,b,c,d).abc# e) TODOGODOT4 Antialiasing argument is missing", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false);
  2299. valid = valid && test_conversion_gdscript_builtin("get_focus_owner()", "get_viewport().gui_get_focus_owner()", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false);
  2300. valid = valid && test_conversion_gdscript_builtin("button.pressed = 1", "button.button_pressed = 1", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false);
  2301. valid = valid && test_conversion_gdscript_builtin("button.pressed=1", "button.button_pressed=1", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false);
  2302. valid = valid && test_conversion_gdscript_builtin("button.pressed SF", "button.pressed SF", &ProjectConverter3To4::rename_gdscript_functions, "custom rename", reg_container, false);
  2303. valid = valid && test_conversion_with_regex("AAA Color.white AF", "AAA Color.WHITE AF", &ProjectConverter3To4::rename_colors, "custom rename", reg_container);
  2304. // Custom rule conversion
  2305. {
  2306. String from = "instance";
  2307. String to = "instantiate";
  2308. String name = "AA.instance()";
  2309. Vector<String> got = String("AA.instance()").split("\n");
  2310. String expected = "AA.instantiate()";
  2311. custom_rename(got, from, to);
  2312. String got_str = collect_string_from_vector(got);
  2313. if (got_str != expected) {
  2314. ERR_PRINT(vformat("Failed to convert custom rename \"%s\" to \"%s\", got \"%s\", instead.", name, expected, got_str));
  2315. }
  2316. valid = valid && (got_str == expected);
  2317. }
  2318. // get_object_of_execution
  2319. {
  2320. { String base = "var roman = kieliszek.";
  2321. String expected = "kieliszek.";
  2322. String got = get_object_of_execution(base);
  2323. if (got != expected) {
  2324. ERR_PRINT(vformat("Failed to get proper data from get_object_of_execution. \"%s\" should return \"%s\"(%d), got \"%s\"(%d), instead.", base, expected, expected.size(), got, got.size()));
  2325. }
  2326. valid = valid && (got == expected);
  2327. }
  2328. {
  2329. String base = "r.";
  2330. String expected = "r.";
  2331. String got = get_object_of_execution(base);
  2332. if (got != expected) {
  2333. ERR_PRINT(vformat("Failed to get proper data from get_object_of_execution. \"%s\" should return \"%s\"(%d), got \"%s\"(%d), instead.", base, expected, expected.size(), got, got.size()));
  2334. }
  2335. valid = valid && (got == expected);
  2336. }
  2337. {
  2338. String base = "mortadela(";
  2339. String expected = "";
  2340. String got = get_object_of_execution(base);
  2341. if (got != expected) {
  2342. ERR_PRINT(vformat("Failed to get proper data from get_object_of_execution. \"%s\" should return \"%s\"(%d), got \"%s\"(%d), instead.", base, expected, expected.size(), got, got.size()));
  2343. }
  2344. valid = valid && (got == expected);
  2345. }
  2346. {
  2347. String base = "var node = $world/ukraine/lviv.";
  2348. String expected = "$world/ukraine/lviv.";
  2349. String got = get_object_of_execution(base);
  2350. if (got != expected) {
  2351. ERR_PRINT(vformat("Failed to get proper data from get_object_of_execution. \"%s\" should return \"%s\"(%d), got \"%s\"(%d), instead.", base, expected, expected.size(), got, got.size()));
  2352. }
  2353. valid = valid && (got == expected);
  2354. }
  2355. }
  2356. // get_starting_space
  2357. {
  2358. String base = "\t\t\t var roman = kieliszek.";
  2359. String expected = "\t\t\t";
  2360. String got = get_starting_space(base);
  2361. if (got != expected) {
  2362. ERR_PRINT(vformat("Failed to get proper data from get_object_of_execution. \"%s\" should return \"%s\"(%d), got \"%s\"(%d), instead.", base, expected, expected.size(), got, got.size()));
  2363. }
  2364. valid = valid && (got == expected);
  2365. }
  2366. // Parse Arguments
  2367. {
  2368. String line = "( )";
  2369. Vector<String> got_vector = parse_arguments(line);
  2370. String got = "";
  2371. String expected = "";
  2372. for (String &part : got_vector) {
  2373. got += part + "|||";
  2374. }
  2375. if (got != expected) {
  2376. ERR_PRINT(vformat("Failed to get proper data from parse_arguments. \"%s\" should return \"%s\"(%d), got \"%s\"(%d), instead.", line, expected, expected.size(), got, got.size()));
  2377. }
  2378. valid = valid && (got == expected);
  2379. }
  2380. {
  2381. String line = "(a , b , c)";
  2382. Vector<String> got_vector = parse_arguments(line);
  2383. String got = "";
  2384. String expected = "a|||b|||c|||";
  2385. for (String &part : got_vector) {
  2386. got += part + "|||";
  2387. }
  2388. if (got != expected) {
  2389. ERR_PRINT(vformat("Failed to get proper data from parse_arguments. \"%s\" should return \"%s\"(%d), got \"%s\"(%d), instead.", line, expected, expected.size(), got, got.size()));
  2390. }
  2391. valid = valid && (got == expected);
  2392. }
  2393. {
  2394. String line = "(a , \"b,\" , c)";
  2395. Vector<String> got_vector = parse_arguments(line);
  2396. String got = "";
  2397. String expected = "a|||\"b,\"|||c|||";
  2398. for (String &part : got_vector) {
  2399. got += part + "|||";
  2400. }
  2401. if (got != expected) {
  2402. ERR_PRINT(vformat("Failed to get proper data from parse_arguments. \"%s\" should return \"%s\"(%d), got \"%s\"(%d), instead.", line, expected, expected.size(), got, got.size()));
  2403. }
  2404. valid = valid && (got == expected);
  2405. }
  2406. {
  2407. String line = "(a , \"(,),,,,\" , c)";
  2408. Vector<String> got_vector = parse_arguments(line);
  2409. String got = "";
  2410. String expected = "a|||\"(,),,,,\"|||c|||";
  2411. for (String &part : got_vector) {
  2412. got += part + "|||";
  2413. }
  2414. if (got != expected) {
  2415. ERR_PRINT(vformat("Failed to get proper data from parse_arguments. \"%s\" should return \"%s\"(%d), got \"%s\"(%d), instead.", line, expected, expected.size(), got, got.size()));
  2416. }
  2417. valid = valid && (got == expected);
  2418. }
  2419. return valid;
  2420. }
  2421. // Validate in all arrays if names don't do cyclic renames "Node" -> "Node2D" | "Node2D" -> "2DNode"
  2422. bool ProjectConverter3To4::test_array_names() {
  2423. bool valid = true;
  2424. Vector<String> names = Vector<String>();
  2425. // Validate if all classes are valid.
  2426. {
  2427. for (unsigned int current_index = 0; class_renames[current_index][0]; current_index++) {
  2428. const String old_class = class_renames[current_index][0];
  2429. const String new_class = class_renames[current_index][1];
  2430. // Light2D, Texture, Viewport are special classes(probably virtual ones).
  2431. if (ClassDB::class_exists(StringName(old_class)) && old_class != "Light2D" && old_class != "Texture" && old_class != "Viewport") {
  2432. ERR_PRINT(vformat("Class \"%s\" exists in Godot 4.0, so it cannot be renamed to something else.", old_class));
  2433. valid = false; // This probably should be only a warning, but not 100% sure - this would need to be added to CI.
  2434. }
  2435. // Callable is special class, to which normal classes may be renamed.
  2436. if (!ClassDB::class_exists(StringName(new_class)) && new_class != "Callable") {
  2437. ERR_PRINT(vformat("Class \"%s\" does not exist in Godot 4.0, so it cannot be used in the conversion.", old_class));
  2438. valid = false; // This probably should be only a warning, but not 100% sure - this would need to be added to CI.
  2439. }
  2440. }
  2441. }
  2442. {
  2443. HashSet<String> all_functions;
  2444. // List of excluded functions from builtin types and global namespace, because currently it is not possible to get list of functions from them.
  2445. // This will be available when https://github.com/godotengine/godot/pull/49053 or similar will be included into Godot.
  2446. static const char *builtin_types_excluded_functions[] = { "dict_to_inst", "inst_to_dict", "bytes_to_var", "bytes_to_var_with_objects", "db_to_linear", "deg_to_rad", "linear_to_db", "rad_to_deg", "randf_range", "snapped", "str_to_var", "var_to_str", "var_to_bytes", "var_to_bytes_with_objects", "move_toward", "uri_encode", "uri_decode", "remove_at", "get_rotation_quaternion", "clamp", "grow_side", "is_absolute_path", "is_valid_int", "lerp", "to_ascii_buffer", "to_utf8_buffer", "to_utf32_buffer", "snapped", "remap", nullptr };
  2447. for (int current_index = 0; builtin_types_excluded_functions[current_index]; current_index++) {
  2448. all_functions.insert(builtin_types_excluded_functions[current_index]);
  2449. }
  2450. // for (int type = Variant::Type::NIL + 1; type < Variant::Type::VARIANT_MAX; type++) {
  2451. // List<MethodInfo> method_list;
  2452. // Variant::get_method_list_by_type(&method_list, Variant::Type(type));
  2453. // for (MethodInfo &function_data : method_list) {
  2454. // if (!all_functions.has(function_data.name)) {
  2455. // all_functions.insert(function_data.name);
  2456. // }
  2457. // }
  2458. // }
  2459. List<StringName> classes_list;
  2460. ClassDB::get_class_list(&classes_list);
  2461. for (StringName &name_of_class : classes_list) {
  2462. List<MethodInfo> method_list;
  2463. ClassDB::get_method_list(name_of_class, &method_list, true);
  2464. for (MethodInfo &function_data : method_list) {
  2465. if (!all_functions.has(function_data.name)) {
  2466. all_functions.insert(function_data.name);
  2467. }
  2468. }
  2469. }
  2470. int current_element = 0;
  2471. while (gdscript_function_renames[current_element][0] != nullptr) {
  2472. String name_3_x = gdscript_function_renames[current_element][0];
  2473. String name_4_0 = gdscript_function_renames[current_element][1];
  2474. if (!all_functions.has(gdscript_function_renames[current_element][1])) {
  2475. ERR_PRINT(vformat("Missing GDScript function in pair (%s - ===> %s <===)", name_3_x, name_4_0));
  2476. valid = false;
  2477. }
  2478. current_element++;
  2479. }
  2480. }
  2481. if (!valid) {
  2482. ERR_PRINT("Found function which is used in the converter, but it cannot be found in Godot 4. Rename this element or remove its entry if it's obsolete.");
  2483. }
  2484. valid = valid && test_single_array(enum_renames);
  2485. valid = valid && test_single_array(class_renames, true);
  2486. valid = valid && test_single_array(gdscript_function_renames, true);
  2487. valid = valid && test_single_array(csharp_function_renames, true);
  2488. valid = valid && test_single_array(gdscript_properties_renames, true);
  2489. valid = valid && test_single_array(csharp_properties_renames);
  2490. valid = valid && test_single_array(shaders_renames, true);
  2491. valid = valid && test_single_array(gdscript_signals_renames);
  2492. valid = valid && test_single_array(project_settings_renames);
  2493. valid = valid && test_single_array(builtin_types_renames);
  2494. valid = valid && test_single_array(color_renames);
  2495. return valid;
  2496. }
  2497. // Validates the array to prevent cyclic renames, such as `Node` -> `Node2D`, then `Node2D` -> `2DNode`.
  2498. // Also checks if names contain leading or trailing spaces.
  2499. bool ProjectConverter3To4::test_single_array(const char *p_array[][2], bool p_ignore_4_0_name) {
  2500. bool valid = true;
  2501. Vector<String> names = Vector<String>();
  2502. for (unsigned int current_index = 0; p_array[current_index][0]; current_index++) {
  2503. String name_3_x = p_array[current_index][0];
  2504. String name_4_0 = p_array[current_index][1];
  2505. if (name_3_x != name_3_x.strip_edges()) {
  2506. ERR_PRINT(vformat("Invalid Entry \"%s\" contains leading or trailing spaces.", name_3_x));
  2507. valid = false;
  2508. }
  2509. if (names.has(name_3_x)) {
  2510. ERR_PRINT(vformat("Found duplicated entry, pair ( -> %s , %s)", name_3_x, name_4_0));
  2511. valid = false;
  2512. }
  2513. names.append(name_3_x);
  2514. if (name_4_0 != name_4_0.strip_edges()) {
  2515. ERR_PRINT(vformat("Invalid Entry \"%s\" contains leading or trailing spaces.", name_3_x));
  2516. valid = false;
  2517. }
  2518. if (names.has(name_4_0)) {
  2519. ERR_PRINT(vformat("Found duplicated entry, pair ( -> %s , %s)", name_3_x, name_4_0));
  2520. valid = false;
  2521. }
  2522. if (!p_ignore_4_0_name) {
  2523. names.append(name_4_0);
  2524. }
  2525. }
  2526. return valid;
  2527. };
  2528. // Returns arguments from given function execution, this cannot be really done as regex.
  2529. // `abc(d,e(f,g),h)` -> [d], [e(f,g)], [h]
  2530. Vector<String> ProjectConverter3To4::parse_arguments(const String &line) {
  2531. Vector<String> parts;
  2532. int string_size = line.length();
  2533. int start_part = 0; // Index of beginning of start part.
  2534. int parts_counter = 0;
  2535. char32_t previous_character = '\0';
  2536. bool is_inside_string = false; // If true, it ignores these 3 characters ( , ) inside string.
  2537. ERR_FAIL_COND_V_MSG(line.count("(") != line.count(")"), parts, vformat("Converter internal bug: substring should have equal number of open and close parentheses in line - \"%s\".", line));
  2538. for (int current_index = 0; current_index < string_size; current_index++) {
  2539. char32_t character = line.get(current_index);
  2540. switch (character) {
  2541. case '(': {
  2542. parts_counter++;
  2543. if (parts_counter == 1 && !is_inside_string) {
  2544. start_part = current_index;
  2545. }
  2546. break;
  2547. };
  2548. case ')': {
  2549. parts_counter--;
  2550. if (parts_counter == 0 && !is_inside_string) {
  2551. parts.append(line.substr(start_part + 1, current_index - start_part - 1));
  2552. start_part = current_index;
  2553. }
  2554. break;
  2555. };
  2556. case '[': {
  2557. parts_counter++;
  2558. if (parts_counter == 1 && !is_inside_string) {
  2559. start_part = current_index;
  2560. }
  2561. break;
  2562. };
  2563. case ']': {
  2564. parts_counter--;
  2565. if (parts_counter == 0 && !is_inside_string) {
  2566. parts.append(line.substr(start_part, current_index - start_part));
  2567. start_part = current_index;
  2568. }
  2569. break;
  2570. };
  2571. case ',': {
  2572. if (parts_counter == 1 && !is_inside_string) {
  2573. parts.append(line.substr(start_part + 1, current_index - start_part - 1));
  2574. start_part = current_index;
  2575. }
  2576. break;
  2577. };
  2578. case '"': {
  2579. if (previous_character != '\\')
  2580. is_inside_string = !is_inside_string;
  2581. }
  2582. }
  2583. previous_character = character;
  2584. }
  2585. Vector<String> clean_parts;
  2586. for (String &part : parts) {
  2587. part = part.strip_edges();
  2588. if (!part.is_empty()) {
  2589. clean_parts.append(part);
  2590. }
  2591. }
  2592. return clean_parts;
  2593. }
  2594. // Finds latest parenthesis owned by function.
  2595. // `function(abc(a,b),DD)):` finds this parenthess `function(abc(a,b),DD => ) <= ):`
  2596. int ProjectConverter3To4::get_end_parenthesis(const String &line) const {
  2597. int current_state = 0;
  2598. for (int current_index = 0; line.length() > current_index; current_index++) {
  2599. char32_t character = line.get(current_index);
  2600. if (character == '(') {
  2601. current_state++;
  2602. }
  2603. if (character == ')') {
  2604. current_state--;
  2605. if (current_state == 0) {
  2606. return current_index;
  2607. }
  2608. }
  2609. }
  2610. return -1;
  2611. }
  2612. // Merges multiple arguments into a single String.
  2613. // Needed when after processing e.g. 2 arguments, later arguments are not changed in any way.
  2614. String ProjectConverter3To4::connect_arguments(const Vector<String> &arguments, int from, int to) const {
  2615. if (to == -1) {
  2616. to = arguments.size();
  2617. }
  2618. String value;
  2619. if (arguments.size() > 0 && from != 0 && from < to) {
  2620. value = ",";
  2621. }
  2622. for (int i = from; i < to; i++) {
  2623. value += arguments[i];
  2624. if (i != to - 1) {
  2625. value += ',';
  2626. }
  2627. }
  2628. return value;
  2629. }
  2630. // Returns the indentation (spaces and tabs) at the start of the line e.g. `\t\tmove_this` returns `\t\t`.
  2631. String ProjectConverter3To4::get_starting_space(const String &line) const {
  2632. String empty_space;
  2633. int current_character = 0;
  2634. if (line.is_empty()) {
  2635. return empty_space;
  2636. }
  2637. if (line[0] == ' ') {
  2638. while (current_character < line.size()) {
  2639. if (line[current_character] == ' ') {
  2640. empty_space += ' ';
  2641. current_character++;
  2642. } else {
  2643. break;
  2644. }
  2645. }
  2646. }
  2647. if (line[0] == '\t') {
  2648. while (current_character < line.size()) {
  2649. if (line[current_character] == '\t') {
  2650. empty_space += '\t';
  2651. current_character++;
  2652. } else {
  2653. break;
  2654. }
  2655. }
  2656. }
  2657. return empty_space;
  2658. }
  2659. // Returns the object that’s executing the function in the line.
  2660. // e.g. Passing the line "var roman = kieliszek.funkcja()" to this function returns "kieliszek".
  2661. String ProjectConverter3To4::get_object_of_execution(const String &line) const {
  2662. int end = line.size() - 1; // Last one is \0
  2663. int variable_start = end - 1;
  2664. int start = end - 1;
  2665. bool is_possibly_nodepath = false;
  2666. bool is_valid_nodepath = false;
  2667. while (start >= 0) {
  2668. char32_t character = line[start];
  2669. bool is_variable_char = (character >= 'A' && character <= 'Z') || (character >= 'a' && character <= 'z') || character == '.' || character == '_';
  2670. bool is_nodepath_start = character == '$';
  2671. bool is_nodepath_sep = character == '/';
  2672. if (is_variable_char || is_nodepath_start || is_nodepath_sep) {
  2673. if (start == 0) {
  2674. break;
  2675. } else if (is_nodepath_sep) {
  2676. // Freeze variable_start, try to fetch more chars since this might be a Node path literal.
  2677. is_possibly_nodepath = true;
  2678. } else if (is_nodepath_start) {
  2679. // Found $, this is a Node path literal.
  2680. is_valid_nodepath = true;
  2681. break;
  2682. }
  2683. if (!is_possibly_nodepath) {
  2684. variable_start--;
  2685. }
  2686. start--;
  2687. continue;
  2688. } else {
  2689. // Abandon all hope, this is neither a variable nor a Node path literal.
  2690. variable_start++; // Found invalid character, needs to be ignored.
  2691. break;
  2692. }
  2693. }
  2694. if (is_valid_nodepath) {
  2695. variable_start = start;
  2696. }
  2697. return line.substr(variable_start, (end - variable_start));
  2698. }
  2699. void ProjectConverter3To4::rename_colors(Vector<String> &lines, const RegExContainer &reg_container) {
  2700. for (String &line : lines) {
  2701. if (uint64_t(line.length()) <= maximum_line_length) {
  2702. if (line.contains("Color.")) {
  2703. for (unsigned int current_index = 0; color_renames[current_index][0]; current_index++) {
  2704. line = reg_container.color_regexes[current_index]->sub(line, reg_container.color_renamed[current_index], true);
  2705. }
  2706. }
  2707. }
  2708. }
  2709. };
  2710. Vector<String> ProjectConverter3To4::check_for_rename_colors(Vector<String> &lines, const RegExContainer &reg_container) {
  2711. Vector<String> found_renames;
  2712. int current_line = 1;
  2713. for (String &line : lines) {
  2714. if (uint64_t(line.length()) <= maximum_line_length) {
  2715. if (line.contains("Color.")) {
  2716. for (unsigned int current_index = 0; color_renames[current_index][0]; current_index++) {
  2717. TypedArray<RegExMatch> reg_match = reg_container.color_regexes[current_index]->search_all(line);
  2718. if (reg_match.size() > 0) {
  2719. found_renames.append(line_formatter(current_line, color_renames[current_index][0], color_renames[current_index][1], line));
  2720. }
  2721. }
  2722. }
  2723. }
  2724. current_line++;
  2725. }
  2726. return found_renames;
  2727. }
  2728. void ProjectConverter3To4::rename_classes(Vector<String> &lines, const RegExContainer &reg_container) {
  2729. for (String &line : lines) {
  2730. if (uint64_t(line.length()) <= maximum_line_length) {
  2731. for (unsigned int current_index = 0; class_renames[current_index][0]; current_index++) {
  2732. if (line.contains(class_renames[current_index][0])) {
  2733. bool found_ignored_items = false;
  2734. // Renaming Spatial.tscn to TEMP_RENAMED_CLASS.tscn.
  2735. if (line.contains(String(class_renames[current_index][0]) + ".")) {
  2736. found_ignored_items = true;
  2737. line = reg_container.class_tscn_regexes[current_index]->sub(line, "TEMP_RENAMED_CLASS.tscn", true);
  2738. line = reg_container.class_gd_regexes[current_index]->sub(line, "TEMP_RENAMED_CLASS.gd", true);
  2739. line = reg_container.class_shader_regexes[current_index]->sub(line, "TEMP_RENAMED_CLASS.shader", true);
  2740. }
  2741. // Causal renaming Spatial -> Node3D.
  2742. line = reg_container.class_regexes[current_index]->sub(line, class_renames[current_index][1], true);
  2743. // Restore Spatial.tscn from TEMP_RENAMED_CLASS.tscn.
  2744. if (found_ignored_items) {
  2745. line = reg_container.class_temp_tscn.sub(line, reg_container.class_temp_tscn_renames[current_index], true);
  2746. line = reg_container.class_temp_gd.sub(line, reg_container.class_temp_gd_renames[current_index], true);
  2747. line = reg_container.class_temp_shader.sub(line, reg_container.class_temp_shader_renames[current_index], true);
  2748. }
  2749. }
  2750. }
  2751. }
  2752. }
  2753. };
  2754. Vector<String> ProjectConverter3To4::check_for_rename_classes(Vector<String> &lines, const RegExContainer &reg_container) {
  2755. Vector<String> found_renames;
  2756. int current_line = 1;
  2757. for (String &line : lines) {
  2758. if (uint64_t(line.length()) <= maximum_line_length) {
  2759. for (unsigned int current_index = 0; class_renames[current_index][0]; current_index++) {
  2760. if (line.contains(class_renames[current_index][0])) {
  2761. String old_line = line;
  2762. bool found_ignored_items = false;
  2763. // Renaming Spatial.tscn to TEMP_RENAMED_CLASS.tscn.
  2764. if (line.contains(String(class_renames[current_index][0]) + ".")) {
  2765. found_ignored_items = true;
  2766. line = reg_container.class_tscn_regexes[current_index]->sub(line, "TEMP_RENAMED_CLASS.tscn", true);
  2767. line = reg_container.class_gd_regexes[current_index]->sub(line, "TEMP_RENAMED_CLASS.gd", true);
  2768. line = reg_container.class_shader_regexes[current_index]->sub(line, "TEMP_RENAMED_CLASS.shader", true);
  2769. }
  2770. // Causal renaming Spatial -> Node3D.
  2771. TypedArray<RegExMatch> reg_match = reg_container.class_regexes[current_index]->search_all(line);
  2772. if (reg_match.size() > 0) {
  2773. found_renames.append(line_formatter(current_line, class_renames[current_index][0], class_renames[current_index][1], old_line));
  2774. }
  2775. // Restore Spatial.tscn from TEMP_RENAMED_CLASS.tscn.
  2776. if (found_ignored_items) {
  2777. line = reg_container.class_temp_tscn.sub(line, reg_container.class_temp_tscn_renames[current_index], true);
  2778. line = reg_container.class_temp_gd.sub(line, reg_container.class_temp_gd_renames[current_index], true);
  2779. line = reg_container.class_temp_shader.sub(line, reg_container.class_temp_shader_renames[current_index], true);
  2780. }
  2781. }
  2782. }
  2783. }
  2784. current_line++;
  2785. }
  2786. return found_renames;
  2787. }
  2788. void ProjectConverter3To4::rename_gdscript_functions(Vector<String> &lines, const RegExContainer &reg_container, bool builtin) {
  2789. for (String &line : lines) {
  2790. if (uint64_t(line.length()) <= maximum_line_length) {
  2791. process_gdscript_line(line, reg_container, builtin);
  2792. }
  2793. }
  2794. };
  2795. Vector<String> ProjectConverter3To4::check_for_rename_gdscript_functions(Vector<String> &lines, const RegExContainer &reg_container, bool builtin) {
  2796. int current_line = 1;
  2797. Vector<String> found_renames;
  2798. for (String &line : lines) {
  2799. if (uint64_t(line.length()) <= maximum_line_length) {
  2800. String old_line = line;
  2801. process_gdscript_line(line, reg_container, builtin);
  2802. if (old_line != line) {
  2803. found_renames.append(simple_line_formatter(current_line, old_line, line));
  2804. }
  2805. }
  2806. }
  2807. return found_renames;
  2808. }
  2809. // TODO, this function should run only on all ".gd" files and also on lines in ".tscn" files which are parts of built-in Scripts.
  2810. void ProjectConverter3To4::process_gdscript_line(String &line, const RegExContainer &reg_container, bool builtin) {
  2811. // In this and other functions, reg.sub() is used only after checking lines with str.contains().
  2812. // With longer lines, doing so can sometimes be significantly faster.
  2813. if ((line.contains(".lock") || line.contains(".unlock")) && !line.contains("mtx") && !line.contains("mutex") && !line.contains("Mutex")) {
  2814. line = reg_container.reg_image_lock.sub(line, "false # $1.lock() # TODOConverter40, Image no longer requires locking, `false` helps to not break one line if/else, so it can freely be removed", true);
  2815. line = reg_container.reg_image_unlock.sub(line, "false # $1.unlock() # TODOConverter40, Image no longer requires locking, `false` helps to not break one line if/else, so it can freely be removed", true);
  2816. }
  2817. // PackedStringArray(req_godot).join('.') -> '.'.join(PackedStringArray(req_godot)) PoolStringArray
  2818. if (line.contains(".join")) {
  2819. line = reg_container.reg_join.sub(line, "$2.join($1)", true);
  2820. }
  2821. // -- empty() -> is_empty() Pool*Array
  2822. if (line.contains("empty")) {
  2823. line = reg_container.reg_is_empty.sub(line, "is_empty(", true);
  2824. }
  2825. // -- \t.func() -> \tsuper.func() Object
  2826. if (line.contains("(") && line.contains(".")) {
  2827. line = reg_container.reg_super.sub(line, "$1super.$2", true); // TODO, not sure if possible, but for now this broke String text e.g. "Choosen .gitignore" -> "Choosen super.gitignore"
  2828. }
  2829. // -- JSON.parse(a) -> JSON.new().parse(a) etc. JSON
  2830. if (line.contains("parse")) {
  2831. line = reg_container.reg_json_non_new.sub(line, "$1var test_json_conv = JSON.new()\n$1test_json_conv.parse($3\n$1$2test_json_conv.get_data()", true);
  2832. }
  2833. // -- to_json(a) -> JSON.new().stringify(a) Object
  2834. if (line.contains("to_json")) {
  2835. line = reg_container.reg_json_to.sub(line, "JSON.new().stringify", true);
  2836. }
  2837. // -- parse_json(a) -> JSON.get_data() etc. Object
  2838. if (line.contains("parse_json")) {
  2839. line = reg_container.reg_json_parse.sub(line, "$1var test_json_conv = JSON.new()\n$1test_json_conv.parse($3\n$1$2test_json_conv.get_data()", true);
  2840. }
  2841. // -- get_node(@ -> get_node( Node
  2842. if (line.contains("get_node")) {
  2843. line = line.replace("get_node(@", "get_node(");
  2844. }
  2845. // export(float) var lifetime = 3.0 -> export var lifetime: float = 3.0 GDScript
  2846. if (line.contains("export")) {
  2847. line = reg_container.reg_export.sub(line, "export var $2: $1");
  2848. }
  2849. // export(String, 'AnonymousPro', 'CourierPrime') var _font_name = 'AnonymousPro' -> export var _font_name = 'AnonymousPro' #(String, 'AnonymousPro', 'CourierPrime') GDScript
  2850. if (line.contains("export")) {
  2851. line = reg_container.reg_export_advanced.sub(line, "export var $2$3 # ($1)");
  2852. }
  2853. // Setget Setget
  2854. if (line.contains("setget")) {
  2855. line = reg_container.reg_setget_setget.sub(line, "var $1$2:\n\tget:\n\t\treturn $1 # TODOConverter40 Copy here content of $4\n\tset(mod_value):\n\t\tmod_value # TODOConverter40 Copy here content of $3", true);
  2856. }
  2857. // Setget set
  2858. if (line.contains("setget")) {
  2859. line = reg_container.reg_setget_set.sub(line, "var $1$2:\n\tget:\n\t\treturn $1 # TODOConverter40 Non existent get function \n\tset(mod_value):\n\t\tmod_value # TODOConverter40 Copy here content of $3", true);
  2860. }
  2861. // Setget get
  2862. if (line.contains("setget")) {
  2863. line = reg_container.reg_setget_get.sub(line, "var $1$2:\n\tget:\n\t\treturn $1 # TODOConverter40 Copy here content of $3 \n\tset(mod_value):\n\t\tmod_value # TODOConverter40 Non existent set function", true);
  2864. }
  2865. // OS.window_fullscreen = true -> ProjectSettings.set("display/window/size/fullscreen",true)
  2866. if (line.contains("window_fullscreen")) {
  2867. if (builtin) {
  2868. line = reg_container.reg_os_fullscreen.sub(line, "ProjectSettings.set(\\\"display/window/size/fullscreen\\\", $1)", true);
  2869. } else {
  2870. line = reg_container.reg_os_fullscreen.sub(line, "ProjectSettings.set(\"display/window/size/fullscreen\", $1)", true);
  2871. }
  2872. }
  2873. // Instantiate
  2874. if (line.contains("instance")) {
  2875. line = reg_container.reg_instantiate.sub(line, ".instantiate($1)", true);
  2876. }
  2877. // -- r.move_and_slide( a, b, c, d, e ) -> r.set_velocity(a) ... r.move_and_slide() KinematicBody
  2878. if (line.contains(("move_and_slide("))) {
  2879. int start = line.find("move_and_slide(");
  2880. int end = get_end_parenthesis(line.substr(start)) + 1;
  2881. if (end > -1) {
  2882. String base_obj = get_object_of_execution(line.substr(0, start));
  2883. String starting_space = get_starting_space(line);
  2884. Vector<String> parts = parse_arguments(line.substr(start, end));
  2885. if (parts.size() >= 1) {
  2886. String line_new;
  2887. // motion_velocity
  2888. line_new += starting_space + base_obj + "set_velocity(" + parts[0] + ")\n";
  2889. // up_direction
  2890. if (parts.size() >= 2) {
  2891. line_new += starting_space + base_obj + "set_up_direction(" + parts[1] + ")\n";
  2892. }
  2893. // stop_on_slope
  2894. if (parts.size() >= 3) {
  2895. line_new += starting_space + base_obj + "set_floor_stop_on_slope_enabled(" + parts[2] + ")\n";
  2896. }
  2897. // max_slides
  2898. if (parts.size() >= 4) {
  2899. line_new += starting_space + base_obj + "set_max_slides(" + parts[3] + ")\n";
  2900. }
  2901. // floor_max_angle
  2902. if (parts.size() >= 5) {
  2903. line_new += starting_space + base_obj + "set_floor_max_angle(" + parts[4] + ")\n";
  2904. }
  2905. // infiinite_interia
  2906. if (parts.size() >= 6) {
  2907. line_new += starting_space + "# TODOConverter40 infinite_inertia were removed in Godot 4.0 - previous value `" + parts[5] + "`\n";
  2908. }
  2909. line_new += starting_space + base_obj + "move_and_slide()\n";
  2910. line = line_new + line.substr(0, start) + "velocity" + line.substr(end + start);
  2911. }
  2912. }
  2913. }
  2914. // -- r.move_and_slide_with_snap( a, b, c, d, e ) -> r.set_velocity(a) ... r.move_and_slide() KinematicBody
  2915. if (line.contains("move_and_slide_with_snap(")) {
  2916. int start = line.find("move_and_slide_with_snap(");
  2917. int end = get_end_parenthesis(line.substr(start)) + 1;
  2918. if (end > -1) {
  2919. String base_obj = get_object_of_execution(line.substr(0, start));
  2920. String starting_space = get_starting_space(line);
  2921. Vector<String> parts = parse_arguments(line.substr(start, end));
  2922. if (parts.size() >= 1) {
  2923. String line_new;
  2924. // motion_velocity
  2925. line_new += starting_space + base_obj + "set_velocity(" + parts[0] + ")\n";
  2926. // snap
  2927. if (parts.size() >= 2) {
  2928. line_new += starting_space + "# TODOConverter40 looks that snap in Godot 4.0 is float, not vector like in Godot 3 - previous value `" + parts[1] + "`\n";
  2929. }
  2930. // up_direction
  2931. if (parts.size() >= 3) {
  2932. line_new += starting_space + base_obj + "set_up_direction(" + parts[2] + ")\n";
  2933. }
  2934. // stop_on_slope
  2935. if (parts.size() >= 4) {
  2936. line_new += starting_space + base_obj + "set_floor_stop_on_slope_enabled(" + parts[3] + ")\n";
  2937. }
  2938. // max_slides
  2939. if (parts.size() >= 5) {
  2940. line_new += starting_space + base_obj + "set_max_slides(" + parts[4] + ")\n";
  2941. }
  2942. // floor_max_angle
  2943. if (parts.size() >= 6) {
  2944. line_new += starting_space + base_obj + "set_floor_max_angle(" + parts[5] + ")\n";
  2945. }
  2946. // infiinite_interia
  2947. if (parts.size() >= 7) {
  2948. line_new += starting_space + "# TODOConverter40 infinite_inertia were removed in Godot 4.0 - previous value `" + parts[6] + "`\n";
  2949. }
  2950. line_new += starting_space + base_obj + "move_and_slide()\n";
  2951. line = line_new + line.substr(0, start) + "velocity" + line.substr(end + start); // move_and_slide used to return velocity
  2952. }
  2953. }
  2954. }
  2955. // -- sort_custom( a , b ) -> sort_custom(Callable( a , b )) Object
  2956. if (line.contains("sort_custom(")) {
  2957. int start = line.find("sort_custom(");
  2958. int end = get_end_parenthesis(line.substr(start)) + 1;
  2959. if (end > -1) {
  2960. Vector<String> parts = parse_arguments(line.substr(start, end));
  2961. if (parts.size() == 2) {
  2962. line = line.substr(0, start) + "sort_custom(Callable(" + parts[0] + "," + parts[1] + "))" + line.substr(end + start);
  2963. }
  2964. }
  2965. }
  2966. // -- list_dir_begin( ) -> list_dir_begin() Object
  2967. if (line.contains("list_dir_begin(")) {
  2968. int start = line.find("list_dir_begin(");
  2969. int end = get_end_parenthesis(line.substr(start)) + 1;
  2970. if (end > -1) {
  2971. line = line.substr(0, start) + "list_dir_begin() " + line.substr(end + start) + "# TODOGODOT4 fill missing arguments https://github.com/godotengine/godot/pull/40547";
  2972. }
  2973. }
  2974. // -- draw_line(1,2,3,4,5) -> draw_line(1,2,3,4) CanvasItem
  2975. if (line.contains("draw_line(")) {
  2976. int start = line.find("draw_line(");
  2977. int end = get_end_parenthesis(line.substr(start)) + 1;
  2978. if (end > -1) {
  2979. Vector<String> parts = parse_arguments(line.substr(start, end));
  2980. if (parts.size() == 5) {
  2981. line = line.substr(0, start) + "draw_line(" + parts[0] + "," + parts[1] + "," + parts[2] + "," + parts[3] + ")" + line.substr(end + start);
  2982. }
  2983. }
  2984. }
  2985. // -- func c(var a, var b) -> func c(a, b)
  2986. if (line.contains("func ") && line.contains("var ")) {
  2987. int start = line.find("func ");
  2988. start = line.substr(start).find("(") + start;
  2989. int end = get_end_parenthesis(line.substr(start)) + 1;
  2990. if (end > -1) {
  2991. Vector<String> parts = parse_arguments(line.substr(start, end));
  2992. String start_string = line.substr(0, start) + "(";
  2993. for (int i = 0; i < parts.size(); i++) {
  2994. start_string += parts[i].strip_edges().trim_prefix("var ");
  2995. if (i != parts.size() - 1) {
  2996. start_string += ", ";
  2997. }
  2998. }
  2999. line = start_string + ")" + line.substr(end + start);
  3000. }
  3001. }
  3002. // -- yield(this, \"timeout\") -> await this.timeout GDScript
  3003. if (line.contains("yield(")) {
  3004. int start = line.find("yield(");
  3005. int end = get_end_parenthesis(line.substr(start)) + 1;
  3006. if (end > -1) {
  3007. Vector<String> parts = parse_arguments(line.substr(start, end));
  3008. if (parts.size() == 2) {
  3009. if (builtin) {
  3010. line = line.substr(0, start) + "await " + parts[0] + "." + parts[1].replace("\\\"", "").replace("\\'", "").replace(" ", "") + line.substr(end + start);
  3011. } else {
  3012. line = line.substr(0, start) + "await " + parts[0] + "." + parts[1].replace("\"", "").replace("\'", "").replace(" ", "") + line.substr(end + start);
  3013. }
  3014. }
  3015. }
  3016. }
  3017. // -- parse_json( AA ) -> TODO Object
  3018. if (line.contains("parse_json(")) {
  3019. int start = line.find("parse_json(");
  3020. int end = get_end_parenthesis(line.substr(start)) + 1;
  3021. if (end > -1) {
  3022. Vector<String> parts = parse_arguments(line.substr(start, end));
  3023. line = line.substr(0, start) + "JSON.new().stringify(" + connect_arguments(parts, 0) + ")" + line.substr(end + start);
  3024. }
  3025. }
  3026. // -- .xform(Vector3(a,b,c)) -> * Vector3(a,b,c) Transform
  3027. if (line.contains(".xform(")) {
  3028. int start = line.find(".xform(");
  3029. int end = get_end_parenthesis(line.substr(start)) + 1;
  3030. if (end > -1) {
  3031. Vector<String> parts = parse_arguments(line.substr(start, end));
  3032. if (parts.size() == 1) {
  3033. line = line.substr(0, start) + " * " + parts[0] + line.substr(end + start);
  3034. }
  3035. }
  3036. }
  3037. // -- .xform_inv(Vector3(a,b,c)) -> * Vector3(a,b,c) Transform
  3038. if (line.contains(".xform_inv(")) {
  3039. int start = line.find(".xform_inv(");
  3040. int end = get_end_parenthesis(line.substr(start)) + 1;
  3041. if (end > -1) {
  3042. String object_exec = get_object_of_execution(line.substr(0, start));
  3043. if (line.contains(object_exec + ".xform")) {
  3044. int start2 = line.find(object_exec + ".xform");
  3045. Vector<String> parts = parse_arguments(line.substr(start, end));
  3046. if (parts.size() == 1) {
  3047. line = line.substr(0, start2) + parts[0] + " * " + object_exec + line.substr(end + start);
  3048. }
  3049. }
  3050. }
  3051. }
  3052. // -- "(connect(A,B,C,D,E) != OK):", "(connect(A,Callable(B,C).bind(D),E) Object
  3053. if (line.contains("connect(")) {
  3054. int start = line.find("connect(");
  3055. // Protection from disconnect
  3056. if (start == 0 || line.get(start - 1) != 's') {
  3057. int end = get_end_parenthesis(line.substr(start)) + 1;
  3058. if (end > -1) {
  3059. Vector<String> parts = parse_arguments(line.substr(start, end));
  3060. if (parts.size() == 3) {
  3061. line = line.substr(0, start) + "connect(" + parts[0] + ",Callable(" + parts[1] + "," + parts[2] + "))" + line.substr(end + start);
  3062. } else if (parts.size() >= 4) {
  3063. line = line.substr(0, start) + "connect(" + parts[0] + ",Callable(" + parts[1] + "," + parts[2] + ").bind(" + parts[3].lstrip("[").rstrip("]") + ")" + connect_arguments(parts, 4) + ")" + line.substr(end + start);
  3064. }
  3065. }
  3066. }
  3067. }
  3068. // -- disconnect(a,b,c) -> disconnect(a,Callable(b,c)) Object
  3069. if (line.contains("disconnect(")) {
  3070. int start = line.find("disconnect(");
  3071. int end = get_end_parenthesis(line.substr(start)) + 1;
  3072. if (end > -1) {
  3073. Vector<String> parts = parse_arguments(line.substr(start, end));
  3074. if (parts.size() == 3) {
  3075. line = line.substr(0, start) + "disconnect(" + parts[0] + ",Callable(" + parts[1] + "," + parts[2] + "))" + line.substr(end + start);
  3076. }
  3077. }
  3078. }
  3079. // -- is_connected(a,b,c) -> is_connected(a,Callable(b,c)) Object
  3080. if (line.contains("is_connected(")) {
  3081. int start = line.find("is_connected(");
  3082. int end = get_end_parenthesis(line.substr(start)) + 1;
  3083. if (end > -1) {
  3084. Vector<String> parts = parse_arguments(line.substr(start, end));
  3085. if (parts.size() == 3) {
  3086. line = line.substr(0, start) + "is_connected(" + parts[0] + ",Callable(" + parts[1] + "," + parts[2] + "))" + line.substr(end + start);
  3087. }
  3088. }
  3089. }
  3090. // -- "(tween_method(A,B,C,D,E) != OK):", "(tween_method(Callable(A,B),C,D,E) Object
  3091. // -- "(tween_method(A,B,C,D,E,[F,G]) != OK):", "(tween_method(Callable(A,B).bind(F,G),C,D,E) Object
  3092. if (line.contains("tween_method(")) {
  3093. int start = line.find("tween_method(");
  3094. int end = get_end_parenthesis(line.substr(start)) + 1;
  3095. if (end > -1) {
  3096. Vector<String> parts = parse_arguments(line.substr(start, end));
  3097. if (parts.size() == 5) {
  3098. line = line.substr(0, start) + "tween_method(Callable(" + parts[0] + "," + parts[1] + ")," + parts[2] + "," + parts[3] + "," + parts[4] + ")" + line.substr(end + start);
  3099. } else if (parts.size() >= 6) {
  3100. line = line.substr(0, start) + "tween_method(Callable(" + parts[0] + "," + parts[1] + ").bind(" + connect_arguments(parts, 5).substr(1).lstrip("[").rstrip("]") + ")," + parts[2] + "," + parts[3] + "," + parts[4] + ")" + line.substr(end + start);
  3101. }
  3102. }
  3103. }
  3104. // -- "(tween_callback(A,B,[C,D]) != OK):", "(connect(Callable(A,B).bind(C,D)) Object
  3105. if (line.contains("tween_callback(")) {
  3106. int start = line.find("tween_callback(");
  3107. int end = get_end_parenthesis(line.substr(start)) + 1;
  3108. if (end > -1) {
  3109. Vector<String> parts = parse_arguments(line.substr(start, end));
  3110. if (parts.size() == 2) {
  3111. line = line.substr(0, start) + "tween_callback(Callable(" + parts[0] + "," + parts[1] + "))" + line.substr(end + start);
  3112. } else if (parts.size() >= 3) {
  3113. line = line.substr(0, start) + "tween_callback(Callable(" + parts[0] + "," + parts[1] + ").bind(" + connect_arguments(parts, 2).substr(1).lstrip("[").rstrip("]") + "))" + line.substr(end + start);
  3114. }
  3115. }
  3116. }
  3117. // -- start(a,b) -> start(Callable(a,b)) Thread
  3118. // -- start(a,b,c,d) -> start(Callable(a,b).bind(c),d) Thread
  3119. if (line.contains("start(")) {
  3120. int start = line.find("start(");
  3121. int end = get_end_parenthesis(line.substr(start)) + 1;
  3122. // Protection from 'func start'
  3123. if (!line.begins_with("func ")) {
  3124. if (end > -1) {
  3125. Vector<String> parts = parse_arguments(line.substr(start, end));
  3126. if (parts.size() == 2) {
  3127. line = line.substr(0, start) + "start(Callable(" + parts[0] + "," + parts[1] + "))" + line.substr(end + start);
  3128. } else if (parts.size() >= 3) {
  3129. line = line.substr(0, start) + "start(Callable(" + parts[0] + "," + parts[1] + ").bind(" + parts[2] + ")" + connect_arguments(parts, 3) + ")" + line.substr(end + start);
  3130. }
  3131. }
  3132. }
  3133. }
  3134. // -- func _init(p_x:int)->void: -> func _init(p_x:int): Object # https://github.com/godotengine/godot/issues/50589
  3135. if (line.contains(" _init(")) {
  3136. int start = line.find(" _init(");
  3137. if (line.contains(":")) {
  3138. int end = line.rfind(":") + 1;
  3139. if (end > -1) {
  3140. Vector<String> parts = parse_arguments(line.substr(start, end));
  3141. line = line.substr(0, start) + " _init(" + connect_arguments(parts, 0) + "):" + line.substr(end + start);
  3142. }
  3143. }
  3144. }
  3145. // assert(speed < 20, str(randi()%10)) -> assert(speed < 20) #,str(randi()%10)) GDScript - GDScript bug constant message
  3146. if (line.contains("assert(")) {
  3147. int start = line.find("assert(");
  3148. int end = get_end_parenthesis(line.substr(start)) + 1;
  3149. if (end > -1) {
  3150. Vector<String> parts = parse_arguments(line.substr(start, end));
  3151. if (parts.size() == 2) {
  3152. line = line.substr(0, start) + "assert(" + parts[0] + ") " + line.substr(end + start) + "#," + parts[1] + ")";
  3153. }
  3154. }
  3155. }
  3156. // create_from_image(aa, bb) -> create_from_image(aa) #, bb ImageTexture
  3157. if (line.contains("create_from_image(")) {
  3158. int start = line.find("create_from_image(");
  3159. int end = get_end_parenthesis(line.substr(start)) + 1;
  3160. if (end > -1) {
  3161. Vector<String> parts = parse_arguments(line.substr(start, end));
  3162. if (parts.size() == 2) {
  3163. line = line.substr(0, start) + "create_from_image(" + parts[0] + ") " + "#," + parts[1] + line.substr(end + start);
  3164. }
  3165. }
  3166. }
  3167. // set_cell_item(a, b, c, d ,e) -> set_cell_item(Vector3(a, b, c), d ,e)
  3168. if (line.contains("set_cell_item(")) {
  3169. int start = line.find("set_cell_item(");
  3170. int end = get_end_parenthesis(line.substr(start)) + 1;
  3171. if (end > -1) {
  3172. Vector<String> parts = parse_arguments(line.substr(start, end));
  3173. if (parts.size() > 2) {
  3174. line = line.substr(0, start) + "set_cell_item( Vector3(" + parts[0] + "," + parts[1] + "," + parts[2] + ") " + connect_arguments(parts, 3) + ")" + line.substr(end + start);
  3175. }
  3176. }
  3177. }
  3178. // get_cell_item(a, b, c) -> get_cell_item(Vector3i(a, b, c))
  3179. if (line.contains("get_cell_item(")) {
  3180. int start = line.find("get_cell_item(");
  3181. int end = get_end_parenthesis(line.substr(start)) + 1;
  3182. if (end > -1) {
  3183. Vector<String> parts = parse_arguments(line.substr(start, end));
  3184. if (parts.size() == 3) {
  3185. line = line.substr(0, start) + "get_cell_item(Vector3i(" + parts[0] + "," + parts[1] + "," + parts[2] + "))" + line.substr(end + start);
  3186. }
  3187. }
  3188. }
  3189. // get_cell_item_orientation(a, b, c) -> get_cell_item_orientation(Vector3i(a, b, c))
  3190. if (line.contains("get_cell_item_orientation(")) {
  3191. int start = line.find("get_cell_item_orientation(");
  3192. int end = get_end_parenthesis(line.substr(start)) + 1;
  3193. if (end > -1) {
  3194. Vector<String> parts = parse_arguments(line.substr(start, end));
  3195. if (parts.size() == 3) {
  3196. line = line.substr(0, start) + "get_cell_item_orientation(Vector3i(" + parts[0] + "," + parts[1] + "," + parts[2] + "))" + line.substr(end + start);
  3197. }
  3198. }
  3199. }
  3200. // apply_impulse(A, B) -> apply_impulse(B, A)
  3201. if (line.contains("apply_impulse(")) {
  3202. int start = line.find("apply_impulse(");
  3203. int end = get_end_parenthesis(line.substr(start)) + 1;
  3204. if (end > -1) {
  3205. Vector<String> parts = parse_arguments(line.substr(start, end));
  3206. if (parts.size() == 2) {
  3207. line = line.substr(0, start) + "apply_impulse(" + parts[1] + ", " + parts[0] + ")" + line.substr(end + start);
  3208. }
  3209. }
  3210. }
  3211. // apply_force(A, B) -> apply_force(B, A)
  3212. if (line.contains("apply_force(")) {
  3213. int start = line.find("apply_force(");
  3214. int end = get_end_parenthesis(line.substr(start)) + 1;
  3215. if (end > -1) {
  3216. Vector<String> parts = parse_arguments(line.substr(start, end));
  3217. if (parts.size() == 2) {
  3218. line = line.substr(0, start) + "apply_force(" + parts[1] + ", " + parts[0] + ")" + line.substr(end + start);
  3219. }
  3220. }
  3221. }
  3222. // map_to_world(a, b, c) -> map_to_local(Vector3i(a, b, c))
  3223. if (line.contains("map_to_world(")) {
  3224. int start = line.find("map_to_world(");
  3225. int end = get_end_parenthesis(line.substr(start)) + 1;
  3226. if (end > -1) {
  3227. Vector<String> parts = parse_arguments(line.substr(start, end));
  3228. if (parts.size() == 3) {
  3229. line = line.substr(0, start) + "map_to_local(Vector3i(" + parts[0] + "," + parts[1] + "," + parts[2] + "))" + line.substr(end + start);
  3230. } else if (parts.size() == 1) {
  3231. line = line.substr(0, start) + "map_to_local(" + parts[0] + ")" + line.substr(end + start);
  3232. }
  3233. }
  3234. }
  3235. // OS.get_window_safe_area() -> DisplayServer.get_display_safe_area()
  3236. if (line.contains("OS.get_window_safe_area(")) {
  3237. int start = line.find("OS.get_window_safe_area(");
  3238. int end = get_end_parenthesis(line.substr(start)) + 1;
  3239. if (end > -1) {
  3240. Vector<String> parts = parse_arguments(line.substr(start, end));
  3241. if (parts.size() == 0) {
  3242. line = line.substr(0, start) + "DisplayServer.get_display_safe_area()" + line.substr(end + start);
  3243. }
  3244. }
  3245. }
  3246. // draw_rect(a,b,c,d,e) -> draw_rect(a,b,c,d)#e) TODOGODOT4 Antialiasing argument is missing
  3247. if (line.contains("draw_rect(")) {
  3248. int start = line.find("draw_rect(");
  3249. int end = get_end_parenthesis(line.substr(start)) + 1;
  3250. if (end > -1) {
  3251. Vector<String> parts = parse_arguments(line.substr(start, end));
  3252. if (parts.size() == 5) {
  3253. line = line.substr(0, start) + "draw_rect(" + parts[0] + "," + parts[1] + "," + parts[2] + "," + parts[3] + ")" + line.substr(end + start) + "# " + parts[4] + ") TODOGODOT4 Antialiasing argument is missing";
  3254. }
  3255. }
  3256. }
  3257. // get_focus_owner() -> get_viewport().gui_get_focus_owner()
  3258. if (line.contains("get_focus_owner()")) {
  3259. line = line.replace("get_focus_owner()", "get_viewport().gui_get_focus_owner()");
  3260. }
  3261. // button.pressed = 1 -> button.button_pressed = 1
  3262. if (line.contains(".pressed")) {
  3263. int start = line.find(".pressed");
  3264. bool foundNextEqual = false;
  3265. String line_to_check = line.substr(start + String(".pressed").length());
  3266. for (int current_index = 0; line_to_check.length() > current_index; current_index++) {
  3267. char32_t chr = line_to_check.get(current_index);
  3268. if (chr == '\t' || chr == ' ') {
  3269. continue;
  3270. } else if (chr == '=') {
  3271. foundNextEqual = true;
  3272. } else {
  3273. break;
  3274. }
  3275. }
  3276. if (foundNextEqual) {
  3277. line = line.substr(0, start) + ".button_pressed" + line.substr(start + String(".pressed").length());
  3278. }
  3279. }
  3280. // OS -> Time functions
  3281. if (line.contains("OS.get_ticks_msec")) {
  3282. line = line.replace("OS.get_ticks_msec", "Time.get_ticks_msec");
  3283. }
  3284. if (line.contains("OS.get_ticks_usec")) {
  3285. line = line.replace("OS.get_ticks_usec", "Time.get_ticks_usec");
  3286. }
  3287. if (line.contains("OS.get_unix_time")) {
  3288. line = line.replace("OS.get_unix_time", "Time.get_unix_time_from_system");
  3289. }
  3290. }
  3291. void ProjectConverter3To4::process_csharp_line(String &line, const RegExContainer &reg_container) {
  3292. line = line.replace("OS.GetWindowSafeArea()", "DisplayServer.ScreenGetUsableRect()");
  3293. // -- Connect(,,,things) -> Connect(,Callable(,),things) Object
  3294. if (line.contains("Connect(")) {
  3295. int start = line.find("Connect(");
  3296. // Protection from disconnect
  3297. if (start == 0 || line.get(start - 1) != 's') {
  3298. int end = get_end_parenthesis(line.substr(start)) + 1;
  3299. if (end > -1) {
  3300. Vector<String> parts = parse_arguments(line.substr(start, end));
  3301. if (parts.size() >= 3) {
  3302. line = line.substr(0, start) + "Connect(" + parts[0] + ",new Callable(" + parts[1] + "," + parts[2] + ")" + connect_arguments(parts, 3) + ")" + line.substr(end + start);
  3303. }
  3304. }
  3305. }
  3306. }
  3307. // -- Disconnect(a,b,c) -> Disconnect(a,Callable(b,c)) Object
  3308. if (line.contains("Disconnect(")) {
  3309. int start = line.find("Disconnect(");
  3310. int end = get_end_parenthesis(line.substr(start)) + 1;
  3311. if (end > -1) {
  3312. Vector<String> parts = parse_arguments(line.substr(start, end));
  3313. if (parts.size() == 3) {
  3314. line = line.substr(0, start) + "Disconnect(" + parts[0] + ",new Callable(" + parts[1] + "," + parts[2] + "))" + line.substr(end + start);
  3315. }
  3316. }
  3317. }
  3318. // -- IsConnected(a,b,c) -> IsConnected(a,Callable(b,c)) Object
  3319. if (line.contains("IsConnected(")) {
  3320. int start = line.find("IsConnected(");
  3321. int end = get_end_parenthesis(line.substr(start)) + 1;
  3322. if (end > -1) {
  3323. Vector<String> parts = parse_arguments(line.substr(start, end));
  3324. if (parts.size() == 3) {
  3325. line = line.substr(0, start) + "IsConnected(" + parts[0] + ",new Callable(" + parts[1] + "," + parts[2] + "))" + line.substr(end + start);
  3326. }
  3327. }
  3328. }
  3329. }
  3330. void ProjectConverter3To4::rename_csharp_functions(Vector<String> &lines, const RegExContainer &reg_container) {
  3331. for (String &line : lines) {
  3332. if (uint64_t(line.length()) <= maximum_line_length) {
  3333. process_csharp_line(line, reg_container);
  3334. }
  3335. }
  3336. };
  3337. Vector<String> ProjectConverter3To4::check_for_rename_csharp_functions(Vector<String> &lines, const RegExContainer &reg_container) {
  3338. int current_line = 1;
  3339. Vector<String> found_renames;
  3340. for (String &line : lines) {
  3341. if (uint64_t(line.length()) <= maximum_line_length) {
  3342. String old_line = line;
  3343. process_csharp_line(line, reg_container);
  3344. if (old_line != line) {
  3345. found_renames.append(simple_line_formatter(current_line, old_line, line));
  3346. }
  3347. }
  3348. }
  3349. return found_renames;
  3350. }
  3351. void ProjectConverter3To4::rename_csharp_attributes(Vector<String> &lines, const RegExContainer &reg_container) {
  3352. static String error_message = "The master and mastersync rpc behavior is not officially supported anymore. Try using another keyword or making custom logic using Multiplayer.GetRemoteSenderId()\n";
  3353. for (String &line : lines) {
  3354. if (uint64_t(line.length()) <= maximum_line_length) {
  3355. line = reg_container.keyword_csharp_remote.sub(line, "[RPC(MultiplayerAPI.RPCMode.AnyPeer)]", true);
  3356. line = reg_container.keyword_csharp_remotesync.sub(line, "[RPC(MultiplayerAPI.RPCMode.AnyPeer, CallLocal = true)]", true);
  3357. line = reg_container.keyword_csharp_puppet.sub(line, "[RPC]", true);
  3358. line = reg_container.keyword_csharp_puppetsync.sub(line, "[RPC(CallLocal = true)]", true);
  3359. line = reg_container.keyword_csharp_master.sub(line, error_message + "[RPC]", true);
  3360. line = reg_container.keyword_csharp_mastersync.sub(line, error_message + "[RPC(CallLocal = true)]", true);
  3361. }
  3362. }
  3363. }
  3364. Vector<String> ProjectConverter3To4::check_for_rename_csharp_attributes(Vector<String> &lines, const RegExContainer &reg_container) {
  3365. int current_line = 1;
  3366. Vector<String> found_renames;
  3367. for (String &line : lines) {
  3368. if (uint64_t(line.length()) <= maximum_line_length) {
  3369. String old;
  3370. old = line;
  3371. line = reg_container.keyword_csharp_remote.sub(line, "[RPC(MultiplayerAPI.RPCMode.AnyPeer)]", true);
  3372. if (old != line) {
  3373. found_renames.append(line_formatter(current_line, "[Remote]", "[RPC(MultiplayerAPI.RPCMode.AnyPeer)]", line));
  3374. }
  3375. old = line;
  3376. line = reg_container.keyword_csharp_remotesync.sub(line, "[RPC(MultiplayerAPI.RPCMode.AnyPeer, CallLocal = true)]", true);
  3377. if (old != line) {
  3378. found_renames.append(line_formatter(current_line, "[RemoteSync]", "[RPC(MultiplayerAPI.RPCMode.AnyPeer, CallLocal = true)]", line));
  3379. }
  3380. old = line;
  3381. line = reg_container.keyword_csharp_puppet.sub(line, "[RPC]", true);
  3382. if (old != line) {
  3383. found_renames.append(line_formatter(current_line, "[Puppet]", "[RPC]", line));
  3384. }
  3385. old = line;
  3386. line = reg_container.keyword_csharp_puppetsync.sub(line, "[RPC(CallLocal = true)]", true);
  3387. if (old != line) {
  3388. found_renames.append(line_formatter(current_line, "[PuppetSync]", "[RPC(CallLocal = true)]", line));
  3389. }
  3390. old = line;
  3391. line = reg_container.keyword_csharp_master.sub(line, "[RPC]", true);
  3392. if (old != line) {
  3393. found_renames.append(line_formatter(current_line, "[Master]", "[RPC]", line));
  3394. }
  3395. old = line;
  3396. line = reg_container.keyword_csharp_mastersync.sub(line, "[RPC(CallLocal = true)]", true);
  3397. if (old != line) {
  3398. found_renames.append(line_formatter(current_line, "[MasterSync]", "[RPC(CallLocal = true)]", line));
  3399. }
  3400. }
  3401. current_line++;
  3402. }
  3403. return found_renames;
  3404. }
  3405. void ProjectConverter3To4::rename_gdscript_keywords(Vector<String> &lines, const RegExContainer &reg_container) {
  3406. static String error_message = "The master and mastersync rpc behavior is not officially supported anymore. Try using another keyword or making custom logic using get_multiplayer().get_remote_sender_id()\n";
  3407. for (String &line : lines) {
  3408. if (uint64_t(line.length()) <= maximum_line_length) {
  3409. if (line.contains("tool")) {
  3410. line = reg_container.keyword_gdscript_tool.sub(line, "@tool", true);
  3411. }
  3412. if (line.contains("export")) {
  3413. line = reg_container.keyword_gdscript_export_single.sub(line, "@export", true);
  3414. }
  3415. if (line.contains("export")) {
  3416. line = reg_container.keyword_gdscript_export_mutli.sub(line, "$1@export", true);
  3417. }
  3418. if (line.contains("onready")) {
  3419. line = reg_container.keyword_gdscript_onready.sub(line, "@onready", true);
  3420. }
  3421. if (line.contains("remote")) {
  3422. line = reg_container.keyword_gdscript_remote.sub(line, "@rpc(any_peer) func", true);
  3423. }
  3424. if (line.contains("remote")) {
  3425. line = reg_container.keyword_gdscript_remotesync.sub(line, "@rpc(any_peer, call_local) func", true);
  3426. }
  3427. if (line.contains("sync")) {
  3428. line = reg_container.keyword_gdscript_sync.sub(line, "@rpc(any_peer, call_local) func", true);
  3429. }
  3430. if (line.contains("slave")) {
  3431. line = reg_container.keyword_gdscript_slave.sub(line, "@rpc func", true);
  3432. }
  3433. if (line.contains("puppet")) {
  3434. line = reg_container.keyword_gdscript_puppet.sub(line, "@rpc func", true);
  3435. }
  3436. if (line.contains("puppet")) {
  3437. line = reg_container.keyword_gdscript_puppetsync.sub(line, "@rpc(call_local) func", true);
  3438. }
  3439. if (line.contains("master")) {
  3440. line = reg_container.keyword_gdscript_master.sub(line, error_message + "@rpc func", true);
  3441. }
  3442. if (line.contains("master")) {
  3443. line = reg_container.keyword_gdscript_mastersync.sub(line, error_message + "@rpc(call_local) func", true);
  3444. }
  3445. }
  3446. }
  3447. }
  3448. Vector<String> ProjectConverter3To4::check_for_rename_gdscript_keywords(Vector<String> &lines, const RegExContainer &reg_container) {
  3449. Vector<String> found_renames;
  3450. int current_line = 1;
  3451. for (String &line : lines) {
  3452. if (uint64_t(line.length()) <= maximum_line_length) {
  3453. String old;
  3454. if (line.contains("tool")) {
  3455. old = line;
  3456. line = reg_container.keyword_gdscript_tool.sub(line, "@tool", true);
  3457. if (old != line) {
  3458. found_renames.append(line_formatter(current_line, "tool", "@tool", line));
  3459. }
  3460. }
  3461. if (line.contains("export")) {
  3462. old = line;
  3463. line = reg_container.keyword_gdscript_export_single.sub(line, "$1@export", true);
  3464. if (old != line) {
  3465. found_renames.append(line_formatter(current_line, "export", "@export", line));
  3466. }
  3467. }
  3468. if (line.contains("export")) {
  3469. old = line;
  3470. line = reg_container.keyword_gdscript_export_mutli.sub(line, "@export", true);
  3471. if (old != line) {
  3472. found_renames.append(line_formatter(current_line, "export", "@export", line));
  3473. }
  3474. }
  3475. if (line.contains("onready")) {
  3476. old = line;
  3477. line = reg_container.keyword_gdscript_tool.sub(line, "@onready", true);
  3478. if (old != line) {
  3479. found_renames.append(line_formatter(current_line, "onready", "@onready", line));
  3480. }
  3481. }
  3482. if (line.contains("remote")) {
  3483. old = line;
  3484. line = reg_container.keyword_gdscript_remote.sub(line, "@rpc(any_peer) func", true);
  3485. if (old != line) {
  3486. found_renames.append(line_formatter(current_line, "remote func", "@rpc(any_peer) func", line));
  3487. }
  3488. }
  3489. if (line.contains("remote")) {
  3490. old = line;
  3491. line = reg_container.keyword_gdscript_remotesync.sub(line, "@rpc(any_peer, call_local)) func", true);
  3492. if (old != line) {
  3493. found_renames.append(line_formatter(current_line, "remotesync func", "@rpc(any_peer, call_local)) func", line));
  3494. }
  3495. }
  3496. if (line.contains("sync")) {
  3497. old = line;
  3498. line = reg_container.keyword_gdscript_sync.sub(line, "@rpc(any_peer, call_local)) func", true);
  3499. if (old != line) {
  3500. found_renames.append(line_formatter(current_line, "sync func", "@rpc(any_peer, call_local)) func", line));
  3501. }
  3502. }
  3503. if (line.contains("slave")) {
  3504. old = line;
  3505. line = reg_container.keyword_gdscript_slave.sub(line, "@rpc func", true);
  3506. if (old != line) {
  3507. found_renames.append(line_formatter(current_line, "slave func", "@rpc func", line));
  3508. }
  3509. }
  3510. if (line.contains("puppet")) {
  3511. old = line;
  3512. line = reg_container.keyword_gdscript_puppet.sub(line, "@rpc func", true);
  3513. if (old != line) {
  3514. found_renames.append(line_formatter(current_line, "puppet func", "@rpc func", line));
  3515. }
  3516. }
  3517. if (line.contains("puppet")) {
  3518. old = line;
  3519. line = reg_container.keyword_gdscript_puppetsync.sub(line, "@rpc(call_local) func", true);
  3520. if (old != line) {
  3521. found_renames.append(line_formatter(current_line, "puppetsync func", "@rpc(call_local) func", line));
  3522. }
  3523. }
  3524. if (line.contains("master")) {
  3525. old = line;
  3526. line = reg_container.keyword_gdscript_master.sub(line, "@rpc func", true);
  3527. if (old != line) {
  3528. found_renames.append(line_formatter(current_line, "master func", "@rpc func", line));
  3529. }
  3530. }
  3531. if (line.contains("master")) {
  3532. old = line;
  3533. line = reg_container.keyword_gdscript_master.sub(line, "@rpc(call_local) func", true);
  3534. if (old != line) {
  3535. found_renames.append(line_formatter(current_line, "mastersync func", "@rpc(call_local) func", line));
  3536. }
  3537. }
  3538. }
  3539. current_line++;
  3540. }
  3541. return found_renames;
  3542. }
  3543. void ProjectConverter3To4::custom_rename(Vector<String> &lines, String from, String to) {
  3544. RegEx reg = RegEx(String("\\b") + from + "\\b");
  3545. CRASH_COND(!reg.is_valid());
  3546. for (String &line : lines) {
  3547. if (uint64_t(line.length()) <= maximum_line_length) {
  3548. line = reg.sub(line, to, true);
  3549. }
  3550. }
  3551. };
  3552. Vector<String> ProjectConverter3To4::check_for_custom_rename(Vector<String> &lines, String from, String to) {
  3553. Vector<String> found_renames;
  3554. RegEx reg = RegEx(String("\\b") + from + "\\b");
  3555. CRASH_COND(!reg.is_valid());
  3556. int current_line = 1;
  3557. for (String &line : lines) {
  3558. if (uint64_t(line.length()) <= maximum_line_length) {
  3559. TypedArray<RegExMatch> reg_match = reg.search_all(line);
  3560. if (reg_match.size() > 0) {
  3561. found_renames.append(line_formatter(current_line, from.replace("\\.", "."), to, line)); // Without replacing it will print "\.shader" instead ".shader".
  3562. }
  3563. }
  3564. current_line++;
  3565. }
  3566. return found_renames;
  3567. }
  3568. void ProjectConverter3To4::rename_common(const char *array[][2], LocalVector<RegEx *> &cached_regexes, Vector<String> &lines) {
  3569. for (String &line : lines) {
  3570. if (uint64_t(line.length()) <= maximum_line_length) {
  3571. for (unsigned int current_index = 0; current_index < cached_regexes.size(); current_index++) {
  3572. if (line.contains(array[current_index][0])) {
  3573. line = cached_regexes[current_index]->sub(line, array[current_index][1], true);
  3574. }
  3575. }
  3576. }
  3577. }
  3578. }
  3579. Vector<String> ProjectConverter3To4::check_for_rename_common(const char *array[][2], LocalVector<RegEx *> &cached_regexes, Vector<String> &lines) {
  3580. Vector<String> found_renames;
  3581. int current_line = 1;
  3582. for (String &line : lines) {
  3583. if (uint64_t(line.length()) <= maximum_line_length) {
  3584. for (unsigned int current_index = 0; current_index < cached_regexes.size(); current_index++) {
  3585. if (line.contains(array[current_index][0])) {
  3586. TypedArray<RegExMatch> reg_match = cached_regexes[current_index]->search_all(line);
  3587. if (reg_match.size() > 0) {
  3588. found_renames.append(line_formatter(current_line, array[current_index][0], array[current_index][1], line));
  3589. }
  3590. }
  3591. }
  3592. }
  3593. current_line++;
  3594. }
  3595. return found_renames;
  3596. }
  3597. // Prints full info about renamed things e.g.:
  3598. // Line (67) remove -> remove_at - LINE """ doubler._blacklist.remove(0) """
  3599. String ProjectConverter3To4::line_formatter(int current_line, String from, String to, String line) {
  3600. if (from.size() > 200) {
  3601. from = from.substr(0, 197) + "...";
  3602. }
  3603. if (to.size() > 200) {
  3604. to = to.substr(0, 197) + "...";
  3605. }
  3606. if (line.size() > 400) {
  3607. line = line.substr(0, 397) + "...";
  3608. }
  3609. from = from.strip_escapes();
  3610. to = to.strip_escapes();
  3611. line = line.replace("\r", "").replace("\n", "").strip_edges();
  3612. return vformat("Line(%d), %s -> %s - LINE \"\"\" %s \"\"\"", current_line, from, to, line);
  3613. }
  3614. // Prints only full lines e.g.:
  3615. // Line (1) - FULL LINES - """yield(get_tree().create_timer(3), 'timeout')""" =====> """ await get_tree().create_timer(3).timeout """
  3616. String ProjectConverter3To4::simple_line_formatter(int current_line, String old_line, String new_line) {
  3617. if (old_line.size() > 1000) {
  3618. old_line = old_line.substr(0, 997) + "...";
  3619. }
  3620. if (new_line.size() > 1000) {
  3621. new_line = new_line.substr(0, 997) + "...";
  3622. }
  3623. old_line = old_line.replace("\r", "").replace("\n", "").strip_edges();
  3624. new_line = new_line.replace("\r", "").replace("\n", "").strip_edges();
  3625. return vformat("Line (%d) - FULL LINES - \"\"\" %s \"\"\" =====> \"\"\" %s \"\"\"", current_line, old_line, new_line);
  3626. }
  3627. // Collects string from vector strings
  3628. String ProjectConverter3To4::collect_string_from_vector(Vector<String> &vector) {
  3629. String string = "";
  3630. for (int i = 0; i < vector.size(); i++) {
  3631. string += vector[i];
  3632. if (i != vector.size() - 1) {
  3633. string += "\n";
  3634. }
  3635. }
  3636. return string;
  3637. }
  3638. #else // No RegEx.
  3639. ProjectConverter3To4::ProjectConverter3To4(int _p_maximum_file_size_kb, int _p_maximum_line_length) {}
  3640. int ProjectConverter3To4::convert() {
  3641. ERR_FAIL_V_MSG(ERROR_CODE, "Can't run converter for Godot 3.x projects, because RegEx module is disabled.");
  3642. }
  3643. int ProjectConverter3To4::validate_conversion() {
  3644. ERR_FAIL_V_MSG(ERROR_CODE, "Can't validate conversion for Godot 3.x projects, because RegEx module is disabled.");
  3645. }
  3646. #endif // MODULE_REGEX_ENABLED