Skip to content

Commit

Permalink
Added console command to enable menu, config entries to disable drone…
Browse files Browse the repository at this point in the history
… and chase camera globally, aligned menu to the right
  • Loading branch information
Shrimpey committed Sep 11, 2019
1 parent 4c2b515 commit fcde6ae
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 10 deletions.
7 changes: 2 additions & 5 deletions EnhancedCamera/EnhancedCamera.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,9 @@
<Reference Include="CitizenFX.Core.Client">
<HintPath>F:\Fivem\FiveM.app\citizen\clr2\lib\mono\4.5\CitizenFX.Core.Client.dll</HintPath>
</Reference>
<Reference Include="MenuAPI">
<HintPath>..\dependencies\client\MenuAPI.dll</HintPath>
</Reference>
<Reference Include="NativeUI.net, Version=1.7.0.0, Culture=neutral, processorArchitecture=MSIL">
<Reference Include="MenuAPI, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\..\FiveM\ServerData\resources\PlaygroundScripts\NativeUI.net.dll</HintPath>
<HintPath>..\dependencies\client\MenuAPI.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json">
<HintPath>..\..\..\vStancer+sl_sh\fivem-vstancer\VStancer.Client\Newtonsoft.Json.dll</HintPath>
Expand Down
46 changes: 42 additions & 4 deletions EnhancedCamera/MainMenu.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ public class MainMenu : BaseScript {
private static MenuCheckboxItem chaseCam;
private static MenuCheckboxItem droneCam;
private static Control MenuToggleControl;
private static bool chaseCameraConfigEnabled;
private static bool droneCameraConfigEnabled;

// Public variables
public static CustomCam CustomCamMenu { get; private set; }
Expand All @@ -39,6 +41,20 @@ public MainMenu() {
SetConfigParameters();
// Setup main menu and submenus
CreateSubmenus();
// Register console command
RegisterCommand("enhancedCam", new Action<int>((source) => {
if (MenuController.IsAnyMenuOpen()) {
MenuController.CloseAllMenus();
} else {
MenuController.MainMenu.OpenMenu();
}
}), false);
// Right align menu
try {
MenuController.MenuAlignment = MenuController.MenuAlignmentOption.Right;
}catch(Exception e) {
Debug.WriteLine("[EnhancedCamera] Exception: Cannot align menu to the right.");
}
// Initiate tick
Tick += OnTick;
Tick += GeneralUpdate;
Expand Down Expand Up @@ -91,9 +107,11 @@ private void CreateSubmenus() {
#region adding menu items
// Checkboxes
Menu.AddMenuItem(leadCam);
Menu.AddMenuItem(chaseCam);
Menu.AddMenuItem(droneCam);

if(chaseCameraConfigEnabled)
Menu.AddMenuItem(chaseCam);
if(droneCameraConfigEnabled)
Menu.AddMenuItem(droneCam);

// Custom cam parameters menu
CustomCamMenu = new CustomCam();
Menu customCamMenu = CustomCamMenu.GetMenu();
Expand All @@ -110,7 +128,9 @@ private void CreateSubmenus() {
{
Label = "→→→"
};
AddMenu(Menu, droneCamMenu, buttonDrone);

if (droneCameraConfigEnabled)
AddMenu(Menu, droneCamMenu, buttonDrone);

// Credits
MenuItem credits = new MenuItem("Credits", "~g~Shrimp~s~ - idea and execution\n" +
Expand Down Expand Up @@ -403,13 +423,31 @@ private static Dictionary<string, string> LoadConfig(string filename = "config.i

private static void SetConfigParameters() {
Dictionary<string, string> config = LoadConfig();

// Set menu key
config.TryGetValue("toggleMenu", out string value);
if (int.TryParse(value, out int result)) {
MenuToggleControl = (Control)result;
} else {
MenuToggleControl = (Control)344;
}
MenuController.MenuToggleKey = MenuToggleControl;

// Set chase and drone camera bools
config.TryGetValue("chaseCameraEnabled", out string chaseCamEnabledStr);
if (int.TryParse(chaseCamEnabledStr, out int chaseCamEnabled)) {
chaseCameraConfigEnabled = (chaseCamEnabled==1)?(true):(false);
} else {
chaseCameraConfigEnabled = true;
}

config.TryGetValue("droneCameraEnabled", out string droneCameraEnabledStr);
if (int.TryParse(droneCameraEnabledStr, out int droneCameraEnabled)) {
droneCameraConfigEnabled = (droneCameraEnabled == 1) ? (true) : (false);
} else {
droneCameraConfigEnabled = true;
}

}

public static async Task<string> GetUserInput(string windowTitle, string defaultText, int maxInputLength)
Expand Down
6 changes: 5 additions & 1 deletion EnhancedCamera/dist/config.ini
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
#The Control to toggle the Menu (default is 344=F11) list at https://wiki.fivem.net/wiki/Controls
toggleMenu=344
toggleMenu=344
#Should chase camera be enabled for users to select? (1 - yes, 0 - no)
chaseCameraEnabled=1
#Should drone camera be enabled for users to select? (1 - yes, 0 - no)
droneCameraEnabled=1

0 comments on commit fcde6ae

Please sign in to comment.