Not logged inOpenClonk Forum
Up Topic General / Help and Questions / Making Menues
- - By Pyrit Date 2015-08-23 14:22
For a scenario I wanted to make a marketplace, where you can buy and sell different things. When I wanted to make a menue for it I realized I have no idea how. I'm on the controls branch. :o

The menu would be split into 2 parts. One for "You" and one for "Market". The "You"-side should have tabs on the left that list all containers near you. You can click on a container tab and it's contents are shown in a list in the "You"-window. When you click on a content, it will wander into the "selling/dump/monetize" tab of the market window. The other tab of the market window shows all items that are available to purchase. The menue keeps track of the values of sold/purchased items and indicates how much money you'll gain or loose by an arrow in the middle. On the bottom is the mandatory description window and a window with accept/exit buttons - preferably with hotkeys. It's basically a Fallout 3 - style trading dialogue... Compare the attachment.

My first question for now would be how to make a menue appear when you press E in front of the building. then I'm not sure how to proceed. :D Maybe splitting the menu into two sides. Then adding lists and tabs. But yeah making it show up in the first place is my problem atm. Yes I have looked for examples and I had a look at the producer library, but I don't understand wich part of the code is responsible for making the menu appear on screen. Is the stuff already documented somewhere? :D
Parent - - By Zapper [de] Date 2015-08-23 16:51
I can write a more in-depth post when I am at home. But I wanted to say that I already have a finished market (including model) lying around somewhere :)

Btw, there is an introduction about the menus in the docs!
Parent - - By Pyrit Date 2015-08-23 19:50
Ah thanks, through google I found it:

The code parts formatting is totally broken for me. How does it look to you?
Parent - By Zapper [de] Date 2015-08-23 22:01
Mh, that's actually deprecated but I still cannot delete wiki pages...

The "real" documentation is now in the actual documentation, which is sadly not built for the Controls branch....
This here is my original documentation file, maybe it helps a bit for now..:
Parent - - By Zapper [de] Date 2015-08-23 16:54
PS: the menu on E is created by the object InteractionMenu in the HUD folder. It's a wrapper around the menu system
Parent - - By Pyrit Date 2015-08-23 20:11
Still can't figure it out. :/
Parent - - By Zapper [de] Date 2015-08-24 22:00 Edited 2015-08-24 22:02
Do you want to use the default interaction menu or do you want to create an own menu?
With the default interaction menu, you can only change one side of the menu - you can currently not display f.e. value on the other side. Btw, you know that you can buy at the flag? The menu is only a little different from yours - just the layout and the missing sell functionality

PS: with the default interaction menu, you can basically add a sub-menu (like the "Inventory" menu or the "Sell" menu at the flag or the "Controls" menu at the pump) and fill that with custom entries - and you can manipulate the description box. But you cannot manipulate the rest of the layout

PPS: You could of course just add a "trade" button to the market (like the pump controls) that opens the trade dialog. Or you could add the buy/sell stuff both on the market's side.
Ooor, you could use the market's inventory as the "sell" part. So when you put stuff into the market, you mark it as "for sell" and when you sell, everything in the market disappears
Parent - - By Marky Date 2016-10-12 20:20 Edited 2016-10-12 20:22
Not really sure if this is the right place, but I'll post here anyway. Hazard has the option to change the firemode of a weapon. I could do this with 3 options:
- open firemode menu on right-clicking the weapon. Downside: You have to click on the new mode, because it does not support keyboard navigation yet.
- same, but with old style menu. Downside: looks not consistent.
- offer interaction with the weapon in the interaction menu (E), as a separate tab. Downside: Is very slow, menu blocks the whole screen. Upside: Best overview. Risk: Needs either a modification of the interaction menu (search for objects that are contained, too.) or must add menu entries to through the clonk (clonk collects info which additional menus to display from its contents - probably better than offering separate tabs).

Can you recommend anything?
Parent - - By Luchs Date 2016-10-12 20:58
Do you actually need a menu for this? What about a dedicated key which switches through weapon modes?
Parent - - By Marky [de] Date 2016-10-12 21:20
If you keep it close to the original from CR the change in weapon mode would empty your weapon and you have to reload first, so switching a few times to the desired mode is probably cumbersome.
The idea is good though: I could show a preview that you have to confirm by pressing the fire button.
Parent - By Clonkonaut [de] Date 2016-10-13 10:31

> If you keep it close to the original from CR

I don't think that's a wise idea, overall. We had to make certain concessions to CR's limited capabilities. Or, to be more precise, we didn't even think about alternative ways to do something because it was impossible to do so anyway.
But since OC offers a lot more possibilities, you should consider easier or more convenient control styles.
Parent - By K-Pone Date 2016-10-12 21:07
I would say either as Luchs said you could make a dedicated key for it (like the 'P' Key in the Defense scenarios that open the shop) or simply add buttons for fire mode switching to the interface. I would prefer to combine these.
Parent - - By Zapper [de] Date 2016-10-13 08:19
I would suggest the folllowing:

1. Add all weapons in the inventory into the interaction menu of the Clonk as an entry below the inventory. Add a hint "Use [T] to toggle the mode of the selected weapon" below that. I can make a sketch if you want.
2. Allow the player to use T (or any other key) to toggle the weapon mode. This should probably be without a confirmation. It should also work during reload so that you can just hit the button twice to get to the correct mode.
Parent - By Marky [de] Date 2016-10-13 19:26
That's how I started implementing it, because the equipment/gear stuff will be in this menu, too.
Parent - - By Zapper [de] Date 2015-08-26 09:10
What is your state? If there are things in the libraries that are very hard to understand without proper documentation, I can of course write some. I just don't know where to put it yet...
Parent - - By Pyrit Date 2015-08-26 19:54
I can't figure out how to open a menu of an object if you stand in front of it and hit E.
I have found public func HasInteractionMenu() { return true; } but that's all...
Parent - By vagner [br] Date 2015-08-26 21:50
Maybe you will found what you want in ClonkControl.ocd
Parent - - By Zapper [de] Date 2015-08-26 22:14
With HasInteractionMenu the object should already be shown in the GUI, right? (If it's a structure or vehicle at least).

Then you can use GetInteractionMenus to specify which different sub menus you want to have (f.e. production/selling/bla). See f.e. the pump.

There you can specify a callback that yields the menu items. See for example the flag's GetBuyMenuEntries.

You can either just return definitions ("IDs") there and have a default menu, or return a custom design.

PS: if you want to update all currently opened menus of a specific category for all players (because f.e. the items in the market change), you can use UpdateInteractionMenus.
For example, the flag does UpdateInteractionMenus(this.GetBuyMenuEntries); when someone buys stuff. This updates only the buy menu items.
Parent - By Pyrit Date 2015-08-27 18:31
Aaaaa it didn't work, because it wasn't a C4D_Structure! :D
Thanks now I can start experimenting.
Parent - - By Pyrit Date 2015-08-27 20:59

>Then you can use GetInteractionMenus to specify which different sub menus you want to have

Can I somehow create a clean, empty menu from sketch? I want to have my own menu and fill it with subwindows.
Parent - - By Zapper [de] Date 2015-08-27 21:39
Inside the interaction menu or as a standalone?

As a standalone, you can just use GuiOpen, like the hammer does.
Parent - - By Pyrit Date 2015-08-27 21:48
Okay, so the hammer uses ControlUseStart() to initialize the menu. But what function do I use when it should be opened with pressing E in front of the building? :o
Parent - By Zapper [de] Date 2015-08-28 07:30
It's not really intended that buildings don't want to integrate into the interaction menu.

You could either add a button in the "normal" interaction menu that opens the new menu ("Start Trading!") oooor you could use the default Clonk interaction (like when grabbing a lorry or plucking a mushroom). For that you'd use IsInteractable, GetInteractionMetaInfo and Interact like in the crop library.

And I just noticed I don't like the naming of these functions, meh.
Parent - - By Zapper [de] Date 2015-09-06 20:22
Controls is merged now. So the documentation is now here:
Parent - By Maikel Date 2015-09-06 21:00
This could use a nice picture with an example on the margins and submenus, like you had in the wiki.
- By vagner Date 2015-08-23 16:54
Very nice idea.
Up Topic General / Help and Questions / Making Menues

Powered by mwForum 2.29.7 © 1999-2015 Markus Wichitill