Not logged inOpenClonk Forum
Up Topic Development / Scenario & Object Development / Ringmenu and how it works
- - By MimmoO Date 2010-03-21 23:11 Edited 2010-03-21 23:15
The ringmenu. It is not like a normal menu, more like a ring-shaped menu. You can choose the point you like with the mouse/gamepad by clicking in a certain direction.

the menu consists of two parts,
1. the ringmenu itself
2. the entrys of the menu.


the ringmenu itself is the object that controls everything and gives commands. it is visualized by a grey 32x32 circle with a picture on it (optional).
the entrys are also grey 32x32 circles which are placed in a ring around the main object. they have a picture on them, a red number for hotkeys and white smaller numbers for the amount.

so how do you create and control a ringmenu? therefore we have different commands:

global func CreateRingMenu(id symbol, int x, int y, object commander) this creates a ringmenu at the position x/y with a symbol (optional)(backpack, clonk, hut etc) for the calling object, which has to be a crew member. the command object is the object, at which the ringmenu will send the information, what has been selected.

public func SetMenu(object menuobject, object commandobject) re-set the menuobject (crewmember) and the commandobject.
func SetMenuIcon(id symbol) re-set or erase the icon shown.

public func AddItem(id new_item, int amount, extra) on of the most important functions. as the name may hints at, it adds an entry for the menu. new_item is the picture shown, the amount is the number that is shown next to the picture and extra can be anything you like, a string, numbers, an array, which is saved in the entry but not shown.

public func Select(int angle, bool alt) you send this to the menu to tell it what angle you have selected. alt is a bool, set it true if you have selected something on a different way (rightclick etc).
the menu will now send Selected(object this,object entry, bool alt) to the commandobject. this is the menu itself, the entry is the menupoint which was selected, and bool is the same as in above. if that call returns true, the menu is closed automatically.

public func SelectHotkey(int key, bool alt) same as above, the hotkey is the number shown in red next to the entry. only accepts 0-9.

public func Show() makes the menu visible/updates it.
public func Hide() makes the menu invisible, but does not remove it. can be shown again with Show().
public func Close() closes the menu, removing all entrys and the menuobject itself.
public func IsVisible() returns true if the menu is visible.

thats it. now to the entrys.

public func SetSymbol(id symbol) sets a new picture for the entry.
public func SetHotkey(int hotkey) sets a new hotkey fot the entry. only 0-9
public func SetAmount(int amount) sets a new amount for the entry.
public func SetExtraData(any extra) sets a new extradata for the entry.

GetSymbol() GetHotkey() GetAmount() GetExtraData() you know what they do

thats all with them.

heres an example of how the script could look like:

      menuitem=clonk->CreateRingMenu(Clonk,0,0,this);
      menuitem->AddItem(Bow);
      menuitem->AddItem(Arrow);
      menuitem->AddItem(Musket);
      menuitem->AddItem(LeadShot);


this creates a menu with a bow, arrows, musket and bullets, the menu itself looks like a clonk.
public func Selected(object menu, object selector, bool alt)
{
  for(var i=0; i<(selector->GetAmount()); i++)
  {
  var newobj=CreateObject(selector->GetSymbol());
  newobj->Enter(Contents());
  }
  selector->RemoveObject();
  menu->Show();
  if(choses==2) return 1;
  return 0;
}


this gives the contents of the command object, at which Selected was sent, items. after the selection, that menupoint is removed.

additional information: ill add the menu tomorrow, when i have debugged everything and cleaned up. also, the menu is getting really small with 30+ entrys

ringemenu looks like this:
Parent - By Ringwaul [ca] Date 2010-03-21 23:53
Excellent! :D I'm eager to test this.
Reply
Parent - - By Newton [de] Date 2010-03-22 00:02
Very good! One thing: If only e.g. four items are shown, the icons could be much bigger. The icons could scale if there are not so many items.
Parent - By MimmoO Date 2010-03-22 18:12
because it is not that important, ill go that later
Parent - - By AlteredARMOR [ua] Date 2010-03-22 07:57
Very nice!

Though I think of making ring menu more 3-dimensional which can be done in several steps:
1) Make the ring more elliptic by shrinking it vertically:

___
/      \
\___/

2) Make front images (the ones that are on the lower part of the ellipse) bigger than the back images (on the upper part)

  o o o
0         0
  O O O

3) Maybe make back images a bit grayscale/blurry/pale

That will make the menu feel like it is rotating over Z-axis (not Y-axis).


From the second thought this will visually make only the front image active (so you have to circle through the menu to make the desired option appear at the front) while from your current system any option can be selected right away.

So... it is nice as it is - no changes are probably needed
Reply
Parent - - By MimmoO Date 2010-03-22 12:46
i dont really understand what you wanted to say me, but it seems you abandoned your ideas..?
Parent - - By AlteredARMOR [ua] Date 2010-03-22 16:59
Have you played Gothic ?
Reply
Parent - - By MimmoO Date 2010-03-22 17:43
no.
Parent - By AlteredARMOR [ua] Date 2010-03-22 18:50
Then we should probably end this discussion for good =)
(Really, can not think of any other game where I saw similar system to the one I tried to describe... it would not fit for OC anyway).
Reply
Parent - - By AlteredARMOR [ua] Date 2010-03-22 19:51
Hmm. Some strange things happened during ringmenu test.
1) First of all this #169 bug (or #142 or #147) when pictures that are 3D renders (not sprites) are drawn misplaced from the circles they should be at. (Some items are drawn one over another... well, this is actually not your fault so do not mind it).
2) In the begginning not menu/clonk is visible until you press LMB (or RMB probably - haven't tried). Then the menu appears. But the very same click also makes the item at which the cursor points (at it will most like point at some circle) be selected. Thus you can not see the first item you select.
3) When you selected three items the menu is still visible "asking" you to make another click which is totally meaningless for it does not choose anything.
4) I believe the numbers in the lower-right corner are the quantity of items. Do not know if we have already agreed on how the inventory should work (three slots again? interesting...) but having 5 flint stones in one slot without any number near this slot saying how many of them are still left seemed "a bit" weird.
5) For some reason it happened to me that clonk had another item which i had not selected. When I threw away the pouch of black powder the Jar of Winds appeared at the same slot. Probably, this has nothing to do with you either.

After some tests I came up with an idea of highlighting (in some way) the circle over which the cursor is currently placed (so player belives that it CAN be selected)
Reply
Parent - - By MimmoO Date 2010-03-22 20:00
1.) i know, not my fault
2.) you somehow misunderstood it. the menu opens with the first click, click number two, three and four select one item each.
3.) see 2.)
4.) yes its the quantity, but flints are not stackable, so...
5.) sometimes you misclick because of 1.)
Parent - - By AlteredARMOR [ua] Date 2010-03-22 20:06
After your explanation only 2) is still left
- Player starts with "blank" screen - no menu or clonk is visible yet
- Then I make a click (the cursor, for instance is placed in the middle above the flag)
- After this click the menu opens and the circle with bow appears just at the place where cursor is, so it is "automatically" placed in the first inventory slot right away
- I agree if I make the click when my cursor is somewhere far away from the places where items appear - everything is fine
Reply
Parent - By MimmoO Date 2010-03-22 20:37
okay, i just tested it, and all i have to say is: newtons fault! he implemented menucontrol and must have changed something in the testing scenario.
Parent - By Clonk-Karl [de] Date 2010-03-23 08:36

> 1.) i know, not my fault


Please just file a fucking bug (including steps how to reproduce) and assign it to me.
Reply
Parent - - By PeterW [de] Date 2010-03-24 14:01
Just wondering: Is this meant to replace all menus? If yes - this won't work for our "multiple menus open at once" approach. We'd have to rethink that. If no - do we really want to have multiple menu designs in the game? We should better settle on one way of doing things...
Parent - By Ringwaul [ca] Date 2010-03-24 16:16
Well, we probably shouldn't remove the menu grid functionality if we don't have to. I think the ring menu could just be a different menu option which could be defined in the 'style' parameter of CreateMenu(). Though then, the ring menu's code would probably need to be integrated with the grid menu script.
Reply
Parent - - By Newton [de] Date 2010-03-29 13:19
How to calculate the (maximum) size for each item with a given ringmenu-circle radius.
Parent - By MimmoO Date 2010-03-29 14:14
i already have a way to calculate that. i calculate the circumference of the circle (200*pi) and then check how but one icon can be so that i dont get over that value.
Up Topic Development / Scenario & Object Development / Ringmenu and how it works

Powered by mwForum 2.29.7 © 1999-2015 Markus Wichitill