Download

Creating a custom menu

Hello,

I’m trying to create a custom menu for my server. I’ve read through other menus, PlayerController, the HUD file, etc. Quite a few things and I can’t figure out how to display a menu on key press. I can see where pause menu, inventory menu, etc is referenced but I can’t see where it says what key references it. I looked through the option menu as well and couldn’t find anything as far as where the remapping gets sent to.

Also, how does one use Game.ini to adjust mod files? Such as

[ThisMod]
ThatOneSetting = 2.0

Any help is greatly appreciated!

Answer: Create a copy of the PlayerController blueprint, and add it to your GameMode. Open it up and select Graph, then refer to the picture below. The name of the middle box doesn’t matter. I used the R key and the Inventory menu to test this, then I used my MainUI for the one that I want to have edited. In the Viewport, you’ll notice that it says “Target is UserWidget” - this WILL crash your Dev Kit. You need to reparent whatever widget you use TO PRIMALUI!

Here’s how to implement a timer:

Here’s how you can utilize a non-escape key to both open and close the menu:

I will look into the customization via .ini later on.

Well, as you’re wanting it to be on KeyPress, note that this requires your mod to be Dirty, as-in it needs to be loaded first.\

Best bet, is to add a keypress event on a copied PlayerController that will create a widget and add it to the viewport. For the widget itself, make sure it’s reparented to PrimalUI and not UserWidget else it will crash the client as soon as it attempts to create it.

To get variables from the .ini’s: [thread=82834]here[/thread].

-WM

Thank you so much for the response. It really does suck that you have to load the mod first, I hope this is something that can be circumvented in the future.

How can I get this thing to close on key press the 2nd time, or use a timer? I can’t seem to figure out how to close the menu in general. Even with another key.

As long as you don’t disable it, Escape should close it - I could be wrong here and it may be disabled by default(been a while since needing to worry about the basics). Otherwise, on the widget, OnKeyDown > R-Click > Implement Function > (Key Event) Get Key > Equal (Key #) > Branch > True > Remove From Viewport.

Or, Event Construct > Delay (#) > Remove From Viewport.

Or, again, add a button on the widget, then add an OnClicked event that fires Remove From Viewport.

I’d advise against using R being the reload input event. Also, plug a Self reference into Owning Player when creating the widget, it may be in the controller itself, but I can’t say for certain that it defaults to Self. Better to be safe than sorry, and especially with widgets which are extremely unstable.

-WM

Thank you, again! I had my “Context Sensitive” box ticked this entire time, so half of these functions were invisible to me. I forgot about buttons, hahaha. Also, I’m using the R key as a test button because escape doesn’t work in the dev kit, and using F1, F2, is troublesome unless I disable cheatplayer every time.

Also, I’m using the box at the top of the screen that the message of the day appears in, so it defaults to not closing with escape (but “escape closes menu” is toggled in the blueprint).

Woeful, would you happen to know how cheats work? I’m very interested in adding a cheat to adjust my server menus, as opposed to updating the mod and forcing a restart. I’m very curious about how SetMessageOfTheDay works - both reading from GameUserSettings.ini and rewriting the same line.

They’re contained within the CheatManager class(untouchable/unreadable), all they do is fire custom events/functions. You can read from .ini’s, you cannot write to them(unless you’re building a custom GameMode/Rule-Set), you can only write to the two logs.

-WM

Awesome. I have two more questions, and this should cover everything.

  1. What would be the exact process for reading a string from an ini? I’ve tried a few different ways (using GameUserSettings.ini at C:\Program Files\Epic Games\ARKDevKit\Projects\ShooterGame\Saved\Config\Windows), but it always crashes me.

  2. How can I make it so the menu cannot be opened with something else already opened, such as your inventory? I’m currently using the MessageOfTheDay background (at the top of the screen) for these, as I needed a large box. I ghetto rigged it so that you can’t open multiple of my menus, but they do conflict with in-game menus still.

Strings cannot be read from the vanilla .ini’s. This, I expect, is partially due to “security” reasons - the various passwords are stored here. I don’t know about TC/CD’s using the CustomGameMode.

Pretty sure there’s something along the lines of “is viewing inventory” or something. It’ll either be a variable in the controller, ShooterPlayerController or on the pawn. If it’s the pawn just Get Controlled Pawn > Cast Shooter/PrimalCharacter > (variable if it’s there).

-WM