LemonUI/NativeUI Upgrade

From Lemon
Jump to navigation Jump to search

Upgrading from NativeUI to LemonUI is pretty straight forward. Most of the classes present on NativeUI are implemented on LemonUI with slight variations.

If a feature that you use in NativeUI is missing on LemonUI, open a GitHub Issue on the repository to take a look and see if is viable.

Equivalent Classes

You can click the LemonUI Classes to see extended information and comparisons.

NativeUI Classes LemonUI Class Additional Info
NativeUI.MenuPool LemonUI.ObjectPool Object Pools support any class that implements LemonUI.IProcessable.
NativeUI.TimerBarPool LemonUI.TimerBarCollection N/A
NativeUI.UIMenu LemonUI.Menus.NativeMenu N/A
NativeUI.InstructionalButton LemonUI.Scaleform.InstructionalButton You can use LemonUI.Scaleform.InstructionalButtons to draw the buttons.
NativeUI.BigMessageHandler LemonUI.Scaleform.BigMessage LemonUI.Scaleform.BigMessage needs to be created with specific parameters for the message that you want to use.
NativeUI.Elements.NativeElement LemonUI.Elements.BaseElement BaseElement is an abstract class, unlike NativeElement.
NativeUI.Elements.NativeRectangle LemonUI.Elements.ScaledRectangle N/A
NativeUI.Elements.NativeSprite LemonUI.Elements.ScaledTexture N/A
NativeUI.Elements.NativeText LemonUI.Elements.ScaledText N/A
NativeUI.Elements.TextAlignment LemonUI.Alignment Only in SHVDN2. Use CitizenFX.Core.UI.Alignment on FiveM and GTA.UI.Alignment on SHVDN3.
NativeUI.IListItem LemonUI.Items.ISlidableItem Completely different interface fields, but provides the same features overall.
NativeUI.UIMenuItem
NativeUI.UIMenuColoredItem
LemonUI.Items.NativeItem Color changes from UIMenuColoredItem are not implemented.
NativeUI.UIMenuCheckboxItem LemonUI.Items.NativeCheckboxItem N/A
NativeUI.UIMenuListItem
NativeUI.UIMenuDynamicListItem
LemonUI.Items.NativeListItem You need to specify the type of object that the item will store (NativeListItem<T>). The name is fetched from the T.ToString() function.
NativeUI.UIMenuSliderItem LemonUI.Items.NativeSliderItem N/A
System.ComponentModel.CancelEventHandler LemonUI.CancelEventHandler Only in FiveM. System.ComponentModel.CancelEventHandler is not implemented, see https://forum.cfx.re/t/1415267/2 for more information.
System.ComponentModel.CancelEventArgs LemonUI.CancelEventArgs Only in FiveM. System.ComponentModel.CancelEventArgs is not implemented, see https://forum.cfx.re/t/1415267/2 for more information.

Object Pools

All of the NativeUI Pools have been replaced by LemonUI.ObjectPool. They behave almost the same and support any item that implements LemonUI.IProcessable.

The only difference is that you don't have the menu related options on the Pool, those are:

MenuPool Field/Property/Function LemonUI Replacement
MouseEdgeEnabled NativeMenu.RotateCamera
ControlDisablingEnabled None
ResetCursorOnOpen NativeMenu.ResetCursorWhenOpened
FormatDescriptions None (Descriptions are formatted automatically)
AUDIO_LIBRARY See the other AUDIO_* Properties below
AUDIO_UPDOWN NativeMenu.SoundUpDown
AUDIO_SELECT NativeMenu.SoundActivated
AUDIO_BACK NativeMenu.SoundClose
AUDIO_ERROR NativeMenu.SoundDisabled
WidthOffset NativeMenu.Offset.Width
CounterPretext None
DisableInstructionalButtons NativeMenu.InstructionalButtons.Enabled = false
BannerInheritance None
OffsetInheritance None
AddSubMenu(UIMenu, string)
AddSubMenu(UIMenu, string, Point)
AddSubMenu(UIMenu, string, string)
AddSubMenu(UIMenu, string, string, Point)
NativeMenu.AddSubMenu(NativeMenu)
RefreshIndex() None (Index Refreshing is done automatically)
ToList() None
ProcessControl()
ProcessKey(Keys)
ProcessMouse(Keys)
None (Control Processing is done on the IProcessable.Process() implementation of each item)
Draw() None (Drawing is done on the IProcessable.Process() implementation of each item)
IsAnyMenuOpen() ObjectPool.AreAnyVisible
ProcessMenus() NativeMenu.Process()
CloseAllMenus() ObjectPool.HideAll()
SetBannerType(NativeSprite)
SetBannerType(IRectangle)
SetBannerType(string)
NativeMenu.Banner
SetKey(MenuControls, Control)
SetKey(MenuControls, Control, int)
SetKey(MenuControls, Keys)
None
ResetKey(MenuControls) None

Menus

UIMenu Field/Property/Function LemonUI Replacement
AUDIO_LIBRARY See the other AUDIO_* Properties below
AUDIO_UPDOWN NativeMenu.SoundUpDown
AUDIO_LEFTRIGHT NativeMenu.SoundLeftRight
AUDIO_SELECT NativeMenu.SoundActivated
AUDIO_BACK NativeMenu.SoundClose
AUDIO_ERROR NativeMenu.SoundDisable
MenuItems NativeMenu.Items (get only)
MouseEdgeEnabled NativeMenu.RotateCamera
ControlDisablingEnabled None
ResetCursorOnOpen NativeMenu.ResetCursorWhenOpened
FormatDescriptions None (Descriptions are formatted automatically)
MouseControlsEnabled NativeMenu.UseMouse
ScaleWithSafezone NativeMenu.SafeZoneAware
Offset NativeMenu.Offset
BannerSprite
BannerRectangle
BannerTexture
NativeMenu.Banner
OnIndexChange NativeMenu.SelectedIndexChanged
OnListChange NativeListItem<T>.ItemChanged
OnCheckboxChange NativeCheckboxItem.CheckboxChanged
OnItemSelect NativeItem.Selected
OnSliderChange NativeSliderItem.ValueChanged
OnMenuOpen NativeMenu.Shown
OnMenuClose NativeMenu.Closing (before)
NativeMenu.Closed (after)
OnMenuChange None
SetMenuWidthOffset(int) NativeMenu.Width
DisableInstructionalButtons(bool) NativeMenu.InstructionalButtons.Visible
SetBannerType(ISprite)
SetBannerType(Sprite)
SetBannerType(IRectangle)
SetBannerType(string)
NativeMenu.Banner
AddItem(UIMenuItem) NativeMenu.Add(NativeItem)
RemoveItemAt(int) NativeMenu.Remove(NativeMenu.Items[NativeMenu.Index])
RefreshIndex() None (Index Refreshing is done automatically)
Clear() NativeMenu.Clear()
Remove(Func<UIMenuItem, bool>) NativeMenu.Remove(Func<NativeItem, bool>)
DrawCalculations() None
GoUpOverflow()
GoUp()
NativeMenu.Previous()
GoDownOverflow()
GoDown()
NativeMenu.Next()
GoLeft() ISlidableItem.GoLeft()
GoRight() ISlidableItem.GoRight()
SelectItem() None
GoBack() NativeMenu.Back()
BindMenuToItem(UIMenu, UIMenuItem) NativeMenu.AddSubMenu(NativeMenu) (returns NativeItem with the menu info)
ReleaseMenuFromItem(UIMenuItem) None
SetKey(MenuControls, Keys)
SetKey(MenuControls, Control)
SetKey(MenuControls, Control, int)
None
ResetKey(MenuControls) None
HasControlJustBeenPressed(MenuControls, Keys) None
HasControlJustBeenReleaseed(MenuControls, Keys) None
IsControlBeingPressed(MenuControls, Keys) None
AddInstructionalButton(InstructionalButton) NativeMenu.Buttons.Add(InstructionalButton)
RemoveInstructionalButton(InstructionalButton) NativeMenu.Buttons.Remove(InstructionalButton)
Draw() NativeMenu.Process()
ProcessMouse() None (Done in NativeMenu.Process())
ProcessControl(Keys) None
ProcessKey(Keys) None
UpdateScaleform() NativeMenu.Buttons.Refresh()
Visible NativeMenu.Visible
CurrentSelection NativeMenu.SelectedIndex
IsUsingController Game.CurrentInputMode == InputMode.GamePad on FiveM and SHVDN2, Game.LastInputMethod == GamePad on SHVDN3
Size NativeMenu.Items.Count
Title Text
Subtitle None (NativeMenu.Subtitle can be used to get the string but not the NativeText object)
CounterPretext None
ParentMenu NativeMenu.Parent
ParentItem None
Children None
WidthOffset NativeMenu.Offset.Width

Items

Normal Items

UIMenuItem Field/Property/Function LemonUI Replacement
Activated NativeItem.Activated
Selected NativeMenu.SelectedItem == NativeItem
Hovered None
Description NativeItem.Description
Enabled NativeItem.Enabled
Position(int) None
Draw() NativeItem.Draw()
Offset NativeMenu.Offset
Text NativeItem.Title
SetLeftBadge(BadgeStyle) NativeItem.LeftBadge
SetRightBadge(BadgeStyle) NativeItem.RightBadge
SetRightLabel(string) NativeItem.AltTitle
RightLabel NativeItem.AltTitle
LeftBadge NativeItem.LeftBadge
RightBadge NativeItem.RightBadge
Parent None

Checkbox Items

UIMenuCheckboxItem Field/Property/Function LemonUI Replacement
CheckboxEvent NativeCheckboxItem.CheckboxChanged
Checked NativeCheckboxItem.Checked
Position(int) None
Draw() NativeCheckboxItem.Draw()
CheckboxEventTrigger() None
SetRightBadge(BadgeStyle) NativeCheckboxItem.RightBadge
SetRightLabel(string) NativeCheckboxItem.AltTitle

List Items

The main difference between UIMenuListItem and NativeListItem is that you need to specify the type of objects stored in the list, for example:

NativeListItem<string> strings = new NativeListItem<string>("List of Strings"));
NativeListItem<int> ints = new NativeListItem<int>("List of Ints"));
UIMenuListItem Field/Property/Function LemonUI Replacement
OnListChanged NativeListItem.ItemChanged
Index NativeListItem.SelectedIndex
Items NativeListItem.Items
Position(int) None
ItemToIndex(object) NativeListItem.Items.IndexOf(T)
IndexToItem(int) NativeListItem.Items[int]
Draw() NativeListItem.Draw()
SetRightBadge(BadgeStyle) NativeListItem.RightBadge
SetRightLabel(string) NativeListItem.AltText
CurrentItem() NativeListItem.SelectedItem

Slider Items

UIMenuSliderItem Field/Property/Function LemonUI Replacement
OnSliderChanged NativeSliderItem.ValueChanged
Maximum NativeSliderItem.Maximum
Value NativeSliderItem.Value
Multiplier NativeSliderItem.Multiplier
Position(int) None
Draw() NativeSliderItem.Draw()

Timer Bars

Timer Bars are the little bars with gradients shown at specific times in the game.

Timer Bar Collection

TimerBarPool Field/Property/Function LemonUI Replacement
Add(TimerBarBase) TimerBarCollection.Add(TimerBar)
Draw() TimerBarCollection.Process()
Remove(TimerBarBase) TimerBarCollection.Remove(TimerBar)
ToList() TimerBarCollection.TimerBars

Base Timer Bar and Text Timer Bar

Both are replaced by LemonUI's TimerBar class.

BaseTimerBar Field/Property/Function LemonUI Replacement
Draw(int) TimerBar.Draw()
Label TimerBar.Title
TextTimerBar Field/Property/Function LemonUI Replacement
Text TimerBar.Info

Timer Bars with Progress

BarTimerBar Field/Property/Function LemonUI Replacement
Percentage TimerBarProgress.Percentage
BackgroundColor TimerBarProgress.BackgroundColor
ForegroundColor TimerBarProgress.ForegroundColor

Big Message Scaleform

Remember to store the BigMessage class if you plan to use it later.

BigMessageHandler Field/Property/Function LemonUI Replacement
Load() None (creating the class will automatically load the Scaleform)
Dispose() BigMessage.Dispose()
ShowMissionPassedMessage(string, int) new BigMessage("TITLE", "SUBTITLE", MessageType.MissionPassedOldGen)
ShowColoredShard(string, string, HudColor, HudColor, int) new BigMessage("TITLE", "SUBTITLE", 0, 1)
(Zero is the first color, One is the second color)
ShowOldMessage(string, int) new BigMessage("TITLE", "SUBTITLE", MessageType.MissionPassedOldGen)
ShowSimpleShard(string, string, int) new BigMessage("TITLE", "SUBTITLE", MessageType.RankUp)
ShowRankupMessage(string, string, int, int) new BigMessage("TITLE", "SUBTITLE", "LEVEL", MessageType.CopsAndCrooks)
(The level doesn't need to be an int)
ShowWeaponPurchasedMessage(string, string, WeaponHash, int) new BigMessage("TITLE", "SUBTITLE", WeaponHash.Unarmed)
(WeaponHash.Unarmed is an example, you can use anything from the enum as far as I know)
ShowMpMessageLarge(string, int) new BigMessage("TITLE", MessageType.CenteredLarge)
ShowCustomShard(string, params object[]) None