tavurth / godot-radial-menu

A radial menu for Godot, supports Mobile & Desktop

Home Page:https://godotengine.org/asset-library/asset/1885

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Issues if I scale the TextureButtons and with small numbers of options

nextonphotos opened this issue · comments

Hi, I've spent some time today playing around with your radial menu and I encountered a couple problems.

The first happened when I tried to make the menu much smaller. Instead of creating smaller sprites for the TextureButtons, I just modified the scale in their control->rect properties. This caused the circle of buttons to offset from the selection circle. I resolved this by changing line 119 in RadialMenu.gd to button.get_size() * button.rect_scale / 2. I also changed line 129 to var corner_pos = Vector2(x, -y) - size.

These two changes seemed to work without issue.

The second problem came when I tried to reduce the number of options down to three. The selection when moving the mouse completely breaks. One of the three options isn't selectable at all and the other two are selected at incorrect positions. Similar is also true for other smaller numbers of options. I'm not sure if I'm doing something wrong, or if there is a bug in the code and I haven't been able to resolve this one. Any ideas?

Thanks!

commented

Hey, thanks for leaving a comment! :)

I built this one pretty quickly but didn't use it in my project finally which is why it may not be super streamlined.

The mouse selection background is inside the selector.shader file, this basically handles the visual background color change.

I will try to take a look at this when I have a moment over the next few days and see if I can come up with a fix for you. If you have any PRs you'd like to create feel free also :)

Thanks for the quick response :)

I don't think the selection shader is the issue here. The hover and selected events don't fire properly in the situation where there are fewer options. The events fire on the visually selected buttons, but the selected buttons aren't synced with the mouse position. I'm assuming the problem is in CursorPos.gd, but it's been a long time since I've done circle math so I'm not sure if the issue is there or not :)

I don't actually use github much, so I don't know how to do PRs. I'd be happy to contribute any solutions I manage to come up with though.

commented

So I quickly re-wrote a little code to handle your case. When there are many many items in the circle it seems that the math may still be a small amount off, maybe I will take another look when I have a little more time.

For now your two & three item case should be working, you can find the commit here fb12e09

That's awesome, thanks!

I think there's a little typo/bug in the commit though. On line 32 there is just angle / index_offset hanging out all lonely. If I move that up to line 24 to make it var to_return = angle / index_offset, then everything looks like it's working as expected.

Thanks for helping out so quickly!

Weird, just ignore my bug fix above, I rechecked the commit and the code doesn't have the issue I encountered. I must have done something wrong. Anyway, thanks again!

commented

Yep, you just saw the code too quickly, I caught that bug and force-pushed again 🤣

Everything working ok now?

Hahaha, whoops!

Yeah, so far everything is looking good. At the moment I'm just playing around with possible tool selector methods for a game I'm in very early days with. I really like the radial selection concept, so I'm heading in that direction at the moment. It'll be a while before I can actually plug stuff together and get it all working, but I'll let you know if I encounter any other issues.

Thanks a lot for the help!

commented

Thanks a lot for the bug report!