Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Add Godot 4 compatible branch #30

Open
kelteseth opened this issue Apr 16, 2022 · 18 comments
Open

Add Godot 4 compatible branch #30

kelteseth opened this issue Apr 16, 2022 · 18 comments

Comments

@kelteseth
Copy link

kelteseth commented Apr 16, 2022

Hi,
I adapted most of the API changes in my fork of godobuf. It is not ready yet to be merged but you can take a look at the changes

https://github.com/kelteseth/godobuf

Godot API Changes:

  • tool -> @tool
  • PoolByteArray -> PackedByteArray
  • String(myInt) -> str(myInt)
  • empty() -> is_empty()
  • remove() -> remove_at(index)
  • dialog.get_rect().size.x -> dialog.size.x
  • .instance() -> .instantiate()
  • funcref(self, "desc_enum"), -> self.desc_enum,
  • template[0].call_func(importance, settings) -> template[0].call(importance, settings)

Buggy:

  • Dialogs open on the wrong screen. Might be Godot 4 bug?
  • When selecting .proto files it asks to override them. Still works though...

Not working:
protobuf_core.gd line 106 and 109 error when using const with []. No idea how to solve this.

const DEFAULT_VALUES_3 = {
        [...]
	#PB_DATA_TYPE.BYTES: [],
	PB_DATA_TYPE.MESSAGE: null,
	#PB_DATA_TYPE.MAP: []
}

This next one looks similar to #26

Parse Error: Identifier "PROTO_VERSION" not declared in the current scope.
  res://addons/protobuf/protobuf_core.gd:533 - Parse Error: Identifier "PROTO_VERSION" not declared in the current scope.`
@kelteseth
Copy link
Author

@oniksan Could you help me to fix the last few bits? :)

@oniksan
Copy link
Owner

oniksan commented May 21, 2022

@kelteseth, Hi!

Sorry, I have not studied Godot 4 and don't know what changes have been made regarding the language constructs of GDScript, therefore, I cannot answer your question now.
Maybe when I migrate to stable Godot 4, I will have to figure it out.
When I ported code from v2 to v3 of Godot, there were also similar incompatibility problems that were simply not solved.

Unfortunately, the Godot developers for some reason do not think about backward compatibility at all.
On the one hand, this is correct - new code will be clean, but on the other hand - what to do with existing large projects.

Regarding Parse Error: Identifier "PROTO_VERSION", it's not an error, I already wrote about it in 26.
Godot IDE is trying to parse data that has not yet been generated. The core file should not be parsed separately from generated code.
I could change extension of the file, but then it would be inconvenient to type it in IDE, so I don't do it.
This "error" does not break anything, because this file is not involved in the plugin. Text in this file only works in generated code of your program.

@kelteseth
Copy link
Author

@oniksan I just tested it with the current Godot nightly from https://hugo.pro/projects/godot-builds/ and it seems that DEFAULT_VALUES_3 issue is fixed :). So it looks like only some UI design improvements are left:
image

image

@kelteseth
Copy link
Author

kelteseth commented May 25, 2022

godot_LjbHsKtXl6.mp4

@oniksan should be all fixed now. Should I create a PR? kelteseth@7e501da

@oniksan
Copy link
Owner

oniksan commented May 26, 2022

This is wrong fix, because generated code will contain two constants:
изображение
Read my previous post carefully.

@kelteseth
Copy link
Author

I fixed the duplicate PROTO_VERSION and ported some unit tests. Not sure how to port:

	var test_func = funcref(test, test_name[FUNC_NAME])

because Godot 4 required actual object references (not sure if this is true). @oniksan would you be willing to help me so we can merge this?

@oniksan
Copy link
Owner

oniksan commented Aug 16, 2022

Hi, @kelteseth

I think that before the release of stable version 4, it's not worth changing anything and people are using the stable version of Godot and want to use the appropriate stable Godobuf version.
I have not yet studied the documentation on changes in GDScript for Godot 4, so I'm unlikely to be of any help now.
After the stable version of Godot is released, and I will definitely look at your code. You can do PR if you want when the stable version comes out.

@MadFlyFish
Copy link

Hello,Godot 4.0 RC is released. Is there any plan to add Godot 4 compatible branch? Thanks.

@oniksan
Copy link
Owner

oniksan commented Feb 11, 2023

Hi, rather yes than no :)

@cmdrk
Copy link

cmdrk commented Mar 3, 2023

Just wanted to 👍 this issue, now that Godot 4.0 has released.

Is there anything the community can do to contribute? Thanks!

@TheDarkUndoing
Copy link

I am willing to help if needed. @kelteseth does your branch still work with 4.0 stable?

@kelteseth
Copy link
Author

@TheDarkUndoing I will have to test it again and probably with teste changes https://github.com/kelteseth/godobuf/pulls

@kelteseth
Copy link
Author

kelteseth commented May 1, 2023

@oniksan Godot 4 fork is now ready. Thanks to @xiyoo0812 & @cmdrk for their fixes. Should I create a PR now? Also can I update the logo to include the protobof logo with the Godot mascot? 😊

@oniksan
Copy link
Owner

oniksan commented May 2, 2023

Sorry, I don't have time yet, you can do a PR, I'll see how it will be possible.

@kelteseth
Copy link
Author

@oniksan Godot 4 Object now also has as to_string function:

image

What should we name it? message_to_string?

@oniksan
Copy link
Owner

oniksan commented May 27, 2023

@kelteseth We should override the object's to_sting() if possible. Or does the to_string object's method have a different purpose?

@Sammyjroberts
Copy link

Can I help with porting this to gd4 somehow?

oniksan added a commit that referenced this issue Jun 12, 2023
@oniksan
Copy link
Owner

oniksan commented Jun 12, 2023

Hi all.
@Sammyjroberts New version is available.
@kelteseth I couldn't wait for the pull request from you and fixed everything myself.

https://github.com/oniksan/godobuf/releases/tag/v0.6.0
If you find bug, create an issue please.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants