LemonUIbyLemon / LemonUI

LemonUI for .NET (FiveM, RageMP, RagePluginHook and ScriptHookVDotNet 3)
MIT License
181 stars 41 forks source link

RageMP Fixes #88

Closed MrJohnDev closed 1 year ago

MrJohnDev commented 2 years ago

define fix

Concurrent downgrade

BUG: No showing text

My test Code:

using RAGE;
using RAGE.Ui;
using System.Collections.Generic;
using LemonUI;

namespace ClientSide.UI
{

    class Menu : Events.Script
    {
        ObjectPool pool;
        LemonUI.Menus.NativeItem basicItem;
        LemonUI.Menus.NativeMenu menu;
        LemonUI.Menus.NativeCheckboxItem checkboxItem;
        LemonUI.Menus.NativeListItem ListItems;
        LemonUI.Menus.NativeSliderItem SliderItem;

        public Menu()
        {
            Input.Bind(VirtualKeys.M, true, openMenu); // M
        }

        void openMenu() {

            if (menu == null) {
                Setup();
            }

            if (menu.Visible)
            {
                menu.Visible = false;
                Chat.Show(true);
                Events.Tick -= OnTick;
            }
            else
            {
                menu.Visible = true;
                Chat.Show(false);
                Events.Tick += OnTick;
            }
        }

        void Setup()
        {
            pool = new ObjectPool(); //Object Pool stores all of your UI changes. This line stores your Menu.
            menu = new LemonUI.Menus.NativeMenu("Menu Example", "Choose an Option" /*(<-Subtitle)*/); //With this line of code, LemonUI allows you to create Rockstar-like menus with the NativeMenu class. (Such as Director Mode menu, Interaction Menu, when pressing M)
            pool.Add(menu); //This adds the menu into an Object Pool.

            basicItem = new LemonUI.Menus.NativeItem("Basic Item", "This is the description of a basic Item"); //This is how you create a simple Item to your menu. "Basic Item" will be the title, and the second will be the description.
            menu.Add(basicItem); //This line of code adds the basicItem to your Menu.

            checkboxItem = new LemonUI.Menus.NativeCheckboxItem("CheckBox Test", "This is the description of a checkbox Item"/*, true); It can be set true by default */ ); //This is how you create a simple checkbox Item to your menu. It can be either toggled on or off.
            menu.Add(checkboxItem); //This line of code adds the CheckboxItem to your Menu.

            ListItems = new LemonUI.Menus.NativeListItem<int>("ListItem Test", "This is the description of a list Item", 1, 2, 3, 4, 5); //This is how you create a simple ListItem to your menu. it allows you to scroll between 1 and 5.
            menu.Add(ListItems); //This line of code adds the certain Item to your Menu.

            SliderItem = new LemonUI.Menus.NativeSliderItem("SliderItem Test", "This is the description of a slider Item"); //This is how you crate a simple Slider Item. You can move from Left to Right to change a numeric value. 
            menu.Add(SliderItem); //This line of code adds the SliderItem to your Menu.

        }

        private void OnTick(List<Events.TickNametagData> nametags)
        {
            pool.Process(); //This line of code it makes sure, that is able to detect changes and draw the UI elements.
        }
    }
}
MrJohnDev commented 2 years ago

Also put in RAGE Client

using System;
using System.Collections.Generic;
using System.Text;

namespace LemonUI // Previously System.ComponentModel
{
    /// <summary>
    /// Represents the method that will handle the event raised when canceling an event.
    /// </summary>
    public delegate void CancelEventHandler(object sender, CancelEventArgs e);

    /// <summary>
    /// EventArgs used to describe a cancel event.
    /// </summary>
    public class CancelEventArgs : EventArgs
    {
        /// <summary>
        /// Gets or sets a value indicating whether we should cancel the operation or not
        /// </summary>
        public bool Cancel { get; set; }

        /// <summary>
        /// Default constructor
        /// </summary>
        public CancelEventArgs()
        {
        }

        /// <summary>
        /// Helper constructor
        /// </summary>
        /// <param name="cancel"></param>
        public CancelEventArgs(bool cancel) => Cancel = cancel;
    }
}
justalemon commented 2 years ago

Hey! I don't know if you noticed, but your code doesn't compiles, hence why it hasn't been merged.

TheOfficialDroid commented 2 years ago

@MrJohnDev

using System.Collections.Concurrent; needs moving into SHVDN3/RPH/FiveM as the following is never included

#else

using System.Collections.Concurrent;

#endif
justalemon commented 1 year ago

Closing this stale PR as no merge conflicts have been fixed.