|
| 1 | +# Menu Core |
| 2 | +<img width="640" height="360" alt="image" src="https://github.com/user-attachments/assets/52320c53-0084-4494-8376-c11ec65e7125" /> |
| 3 | + |
| 4 | + |
| 5 | +A Friday Night Funkin' mod to enable a custom menu at the start of the game. This menu will allow the user to switch between different mods and their own custom menus, to allow for custom mod content to be enabled/disabled, or grouped together. |
| 6 | + |
| 7 | +## Setting up |
| 8 | + |
| 9 | +Download the latest version of MenuCore, [here](https://github.com/Kade-github/Menu-Core/releases/latest). |
| 10 | + |
| 11 | +Then extract the folder into your `mods/` directory. |
| 12 | + |
| 13 | +You are now ready to start using menu core |
| 14 | + |
| 15 | +## Using Menu Core |
| 16 | + |
| 17 | +Inside of your *mod* (not MenuCore), create a new Module: |
| 18 | + |
| 19 | +```haxe |
| 20 | +package kade.hex; |
| 21 | +
|
| 22 | +import kade.hex.states.HexMainMenu; |
| 23 | +
|
| 24 | +import funkin.modding.module.Module; |
| 25 | +import funkin.modding.module.ModuleHandler; |
| 26 | +
|
| 27 | +import flixel.FlxState; |
| 28 | +
|
| 29 | +class HMenuCore extends Module { |
| 30 | + var addedVersion:Bool = false; |
| 31 | +
|
| 32 | + var modName = "VS Hex"; |
| 33 | + var modDescription = "V.S Hex v3"; |
| 34 | + var modAssetKey = "mc_hex"; |
| 35 | +
|
| 36 | + var modState = null; |
| 37 | +
|
| 38 | + public function new() { |
| 39 | + // Priority is set to 3 here. |
| 40 | + super("HMenuCore", 3); |
| 41 | + } |
| 42 | + |
| 43 | + public function addVersion() |
| 44 | + { |
| 45 | + var mcHandle = ModuleHandler.getModule("MC_Data"); |
| 46 | + if (mcHandle == null) { |
| 47 | + trace("MenuCore: MC_Data not found!"); |
| 48 | + return; |
| 49 | + } |
| 50 | +
|
| 51 | + if (mcHandle.versions.indexOf(modName) != -1) { |
| 52 | + // Already added |
| 53 | + return; |
| 54 | + } |
| 55 | +
|
| 56 | + modState = new HexMainMenu(); |
| 57 | + |
| 58 | + mcHandle.addVersion(modName, modAssetKey, modDescription, modState); |
| 59 | + } |
| 60 | +
|
| 61 | + public override function onStateChangeBegin(event:StateChangeScriptEvent):Void { |
| 62 | + super.onStateChangeBegin(event); |
| 63 | +
|
| 64 | + addVersion(); |
| 65 | + } |
| 66 | +
|
| 67 | + public override function onCreate(event):Void { |
| 68 | + super.onCreate(event); |
| 69 | +
|
| 70 | + addVersion(); |
| 71 | + } |
| 72 | +} |
| 73 | +``` |
| 74 | + |
| 75 | +You will create a module like so, name it whatever. Make sure it's `priority` is after **2**! After that, copy the three other non-constructor functions and change the top properties to what you'd like! |
| 76 | + |
| 77 | +```haxe |
| 78 | +var modName = "VS Hex"; |
| 79 | +var modDescription = "V.S Hex v3"; |
| 80 | +var modAssetKey = "mc_hex"; |
| 81 | +``` |
| 82 | + |
| 83 | +Then at the bottom (in the `addVersion` method) you'll see |
| 84 | +```haxe |
| 85 | +modState = new HexMainMenu(); |
| 86 | +``` |
| 87 | + |
| 88 | +This will be what state will be created by MenuCore (and where the user will be sent too). To find out more about how to create states like this, please check out the [Scripted States](../Expert/03.ScriptedStates.md) article. |
| 89 | + |
| 90 | +> Author: [Kade](https://github.com/Kade-github) |
0 commit comments