From 41a1a7cf1b7db7bff4fa9d04f9fc059a8682d134 Mon Sep 17 00:00:00 2001 From: Luke <39926192+LukeWasTakenn@users.noreply.github.com> Date: Wed, 15 Feb 2023 18:35:29 +0100 Subject: [PATCH] add radial menu typescript examples --- docs/ox_lib/Interface/Client/radial.md | 137 +++++++++++++++++++++++++ 1 file changed, 137 insertions(+) diff --git a/docs/ox_lib/Interface/Client/radial.md b/docs/ox_lib/Interface/Client/radial.md index 19fbe386..b0b68df1 100644 --- a/docs/ox_lib/Interface/Client/radial.md +++ b/docs/ox_lib/Interface/Client/radial.md @@ -2,10 +2,30 @@ title: Radial Menu --- +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; + ### lib.addRadialItem Item or array of items added to the global radial menu. + + + +```lua +lib.addRadialItem(items) +``` + + + +```ts +import lib from '@overextended/ox_lib/client' + +lib.addRadialItem(items) +``` + + + * id: `string` * Id that is used for removing options. * icon: `string` @@ -18,12 +38,46 @@ Item or array of items added to the global radial menu. Id of an item to be removed from the global menu. + + + +```lua +lib.removeRadialItem(item) +``` + + + +```ts +import lib from '@overextended/ox_lib/client' + +lib.removeRadialItem(item) +``` + + + * id: `string` ### lib.registerRadial Registers a radial sub menu with predefined options. + + + +```lua +lib.registerRadial(radial) +``` + + + +```ts +import lib from '@overextended/ox_lib/client' + +lib.registerRadial(radial) +``` + + + * id: `string` * Unique menu id used to open with `menu` prop on an item. * items: `array` @@ -37,6 +91,23 @@ Registers a radial sub menu with predefined options. Hides the radial menu if one is open. + + + +```lua +lib.hideRadial() +``` + + + +```ts +import lib from '@overextended/ox_lib/client' + +lib.hideRadial() +``` + + + ### Usage Example :::tip @@ -48,6 +119,9 @@ as long labels will look out of place and should not be used with the radial men Here's a use case example with some global options and an option utilising the lib's points system. + + + ```lua lib.registerRadial({ id = 'police_menu', @@ -116,5 +190,68 @@ function point:onExit() lib.removeRadialItem('garage_access') end ``` + + + +:::caution + +Points system in the lib isn't available for the npm package. +::: + +```ts +import lib from '@overextended/ox_lib/client' + +lib.registerRadial({ + id: 'police_menu', + items: [ + { + label: 'Handcuff', + icon: 'handcuffs', + onSelect: () => { + console.log('Handcuffs') + } + }, + { + label: 'Frisk', + icon: 'hand' + }, + { + label: 'Fingerprint', + icon: 'fingerprint' + }, + { + label: 'Jail', + icon: 'bus' + }, + { + label: 'Search', + icon: 'magnifying-glass', + onSelect: () => { + console.log('Search') + } + } + ] +}) + +lib.addRadialItem([ + { + id: 'police', + label: 'Police', + icon: 'shield-halved', + menu: 'police_menu' + }, + { + id: 'business_stuff', + label: 'Business', + icon: 'briefcase', + onSelect: () => { + console.log('Business') + } + } +]) +``` + + + ![radial1](https://i.imgur.com/4eYU94s.png) ![radial2](https://i.imgur.com/Czw7mLF.png)