complete interface docs

This commit is contained in:
Luke committed 2022-09-17 12:24:48 +02:00
1 parent d44c42104e
commit c7a4aca477
4 files changed
+440 -130

No files matched your search

+117 -31
View File
@@ -5,35 +5,49 @@ title: Notifications
import Tabs from '@theme/Tabs'; import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem'; import TabItem from '@theme/TabItem';
### lib.notify ## lib.notify
Custom notifications with a lot of styling options. Custom notifications with a lot of styling options.
<Tabs>
<TabItem value='Lua'>
```lua ```lua
-- id: string (optional) lib.notify(data)
-- title: string (if description then optional) ```
-- description: string (if title then optional) </TabItem>
-- duration: number (optional) <TabItem value='JS/TS'>
-- position: 'top' | 'top-right' | 'top-left' | 'bottom' | 'bottom-right' | 'bottom-left' (optional)
-- type: 'inform' | 'error' | 'success' ```ts
-- style: table (optional) import lib from '@overextended/ox_lib/client'
-- icon: string (optional)
-- iconColor: string (optional)
lib.notify(data) lib.notify(data)
``` ```
`id` - When set the current notification will be unique and only shown once on screen </TabItem>
`title` - Must provide if there is no description </Tabs>
`description` - Must provide if there is no title
`position` - Default: `'top-right'`
`type` - Default: `'inform'`
`style` - React CSS styling, works the same as in [TextUI](textui.md)
`icon` - Font Awesome 6 icon, works the same as in [TextUI](textui.md)
`iconColor` - Set a different color for the provided icon
* id?: `string`
* When set the current notification will be unique and only shown once on screen when spammed.
* title?: `string`
* Must provide if there is no description
* description?: `string`
* Must provide if there is no title
* duration?: `number`
* position?: `'top'` or `'top-right'` or `'top-left'` or `'bottom'` or `'bottom-right'` or `'bottom-left'`
* Default: `'top-right'`
* type: `'inform'` or `'error'` or `'success'`
* Default: `'inform'`
* style?: `table` (`object`)
* React CSS styling format
* icon?: `string`
* Font Awesome 6 icon name
* iconColor: `string`
### Usage Example
### Standard
**Example:**
<Tabs> <Tabs>
<TabItem value='standard' label="Standard"> <TabItem value='Lua'>
```lua ```lua
lib.notify({ lib.notify({
@@ -42,9 +56,27 @@ lib.notify({
type = 'success' type = 'success'
}) })
``` ```
![notification](https://i.imgur.com/cRxJICO.png)
</TabItem> </TabItem>
<TabItem value='custom' label="Custom"> <TabItem value='JS/TS'>
```ts
import lib from '@overextended/ox_lib/client'
lib.notify({
title: 'Notification title',
description: 'Notification description',
type: 'success'
})
```
</TabItem>
</Tabs>
![notification](https://i.imgur.com/cRxJICO.png)
### Custom
<Tabs>
<TabItem value='Lua'>
```lua ```lua
lib.notify({ lib.notify({
@@ -60,25 +92,64 @@ lib.notify({
iconColor = '#C53030' iconColor = '#C53030'
}) })
``` ```
![custom_notification](https://i.imgur.com/0EK5APp.png) </TabItem>
<TabItem value='JS/TS'>
```ts
import lib from '@overextended/ox_lib/client'
lib.notify({
id: 'some_identifier',
title: 'Notification title',
description: 'Notification description',
position: 'top',
style: {
backgroundColor: '#141517',
color: '#909296'
},
icon: 'ban',
iconColor: '#C53030'
})
```
</TabItem> </TabItem>
</Tabs> </Tabs>
### lib.defaultNotify
![custom_notification](https://i.imgur.com/0EK5APp.png)
## lib.defaultNotify
Default notifications provided by Chakra UI. Default notifications provided by Chakra UI.
<Tabs>
<TabItem value='Lua'>
```lua ```lua
-- title: string (if description then optional) lib.defaultNotify(data)
-- description: string (if title then optional) ```
-- duration: number (optional) </TabItem>
-- position: ToastPositionWithLogical (optional) <TabItem value='JS/TS'>
-- status: "info" | "warning" | "success" | "error" (optional)
-- id: number (optional) ```ts
import lib from '@overextended/ox_lib/client'
lib.defaultNotify(data) lib.defaultNotify(data)
``` ```
</TabItem>
</Tabs>
**Example:** * id?: `number`
* Same as id in `lib.notify`
* title?: `string`
* description?: `string`
* duration?: `number`
* position?: `'top'` or `'top-right'` or `'top-left'` or `'bottom'` or `'bottom-right'` or `'bottom-left'`
* status?: `'info'` or `'warning'` or `'success'` or `'error'`
### Usage Example
<Tabs>
<TabItem value='Lua'>
```lua ```lua
lib.defaultNotify({ lib.defaultNotify({
@@ -87,4 +158,19 @@ lib.defaultNotify({
status = 'success' status = 'success'
}) })
``` ```
</TabItem>
<TabItem value='JS/TS'>
```ts
import lib from '@overextended/ox_lib/client'
lib.defaultNotify({
title: 'Notification title',
description: 'Notification description',
status: 'success'
})
```
</TabItem>
</Tabs>
![default_notification](https://i.imgur.com/EIibuY9.png) ![default_notification](https://i.imgur.com/EIibuY9.png)
+227 -81
View File
@@ -2,54 +2,81 @@
title: Progress title: Progress
--- ---
### lib.progressBar import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';
## lib.progressBar
Displays a running progress bar. Displays a running progress bar.
```lua <Tabs>
-- duration: number <TabItem value='Lua'>
-- label: string
-- useWhileDead: boolean (optional)
-- allowRagdoll: boolean (optional)
-- allowCuffed: boolean (optional)
-- allowFalling: boolean (optional)
-- canCancel: boolean (optional)
-- anim: table (optional)
-- dict: string (optional - either scenario or dict)
-- clip: string
-- flag: number (optional - default is 49)
-- blendIn: float (optional - default is 3.0)
-- blendOut: float (optional - default is 1.0)
-- duration: number (optional - default is -1)
-- playbackRate: number (optional - default is 0)
-- lockX: boolean (optional)
-- lockY: boolean (optional)
-- lockZ: boolean (optional)
-- scenario: string (optional - either scenario or dict) ```lua
-- playEnter: boolean (optional - default is true) lib.progressBar(data)
-- prop: table (optional) ```
-- model: hash </TabItem>
-- bone: number (optional - default is 60309) <TabItem value='JS/TS'>
-- pos: table
-- x: number ```ts
-- y: number import lib from '@overextended/ox_lib/client'
-- z: number
-- rot: table
-- x: number
-- y: number
-- z: number
-- disable: table (optional)
-- move: boolean (optional)
-- car: boolean (optional)
-- combat: boolean (optional)
-- mouse: boolean (optional)
lib.progressBar(data) lib.progressBar(data)
``` ```
If you want to define multiple props, you can pass them </TabItem>
as individual tables in the `prop` table. </Tabs>
* duration: `number`
* label: `string`
* useWhileDead?: `boolean`
* allowRagdoll?: `boolean`
* allowCuffed?: `boolean`
* allowFalling?: `boolean`
* canCancel?: `boolean`
* anim?: `table` (`object`)
* dict?: `string`
* Must specify either scenario or dict
* clip: `string`
* flag?: `number`
* Default: `49`
* blendIn?: `float`
* Default: `3.0`
* blendOut?: `float`
* Default: `1.0`
* duration?: `number`
Default: `-1`
* playbackRate?: `number`
Default: `0`
* lockX?: `boolean`
* lockY?: `boolean`
* lockZ?: `boolean`
* scenario?: `string`
* Must specify either scenario or dict
* playEnter?: `boolean`
* Default: `true`
* prop?: `table` (`object` or `array`)
* [ If you want to define multiple props, you can pass them as individual tables (array of objects) ]
* model: `hash`
* bone?: `number`
* Default: `60309`
* pos: `table`
* x: `number`
* y: `number`
* z: `number`
* rot: `table` (`object`)
* x: `number`
* y: `number`
* z: `number`
* disable?: `table` (`object`)
* move?: `boolean`
* car?: `boolean`
* combat?: `boolean`
* mouse?: `boolean`
### Usage Example
<Tabs>
<TabItem value='Lua'>
**Example:**
```lua ```lua
if lib.progressBar({ if lib.progressBar({
duration = 2000, duration = 2000,
@@ -70,54 +97,114 @@ if lib.progressBar({
}, },
}) then print('Do stuff when complete') else print('Do stuff when cancelled') end }) then print('Do stuff when complete') else print('Do stuff when cancelled') end
``` ```
</TabItem>
<TabItem value='JS/TS'>
:::caution
This function is **asynchronous** requiring you to do a `.then` callback on the promise or make your function `async`.
:::
```ts
import lib from '@overextended/ox_lib/client'
if (await lib.progressBar({
duration: 2000,
label: 'Drinking water',
useWhileDead: false,
canCancel: true,
disable: {
car: true,
},
anim: {
dict: 'mp_player_intdrink',
clip: 'loop_bottle'
},
prop: {
model: `prop_ld_flow_bottle`,
pos: vec3(0.03, 0.03, 0.02),
rot: vec3(0.0, 0.0, -1.5)
},
})) print('Do stuff when complete') else print('Do stuff when cancelled')
```
</TabItem>
</Tabs>
![progress_bar](https://i.imgur.com/7pAwktr.png) ![progress_bar](https://i.imgur.com/7pAwktr.png)
### lib.progressCircle ## lib.progressCircle
Similar to `lib.progressBar` except it displays a circle and has no label and Similar to `lib.progressBar` except it displays a circle and you can define a position.
you can define a position.
<Tabs>
<TabItem value='Lua'>
```lua ```lua
-- duration: number lib.progressCircle(data)
-- label: string (optional) ```
-- position: "middle" or "bottom" (optional - default is "middle") </TabItem>
-- useWhileDead: boolean (optional) <TabItem value='JS/TS'>
-- canCancel: boolean (optional)
-- anim: table (optional)
-- dict: string (optional - either scenario or dict)
-- clip: string
-- flag: number (optional - default is 49)
-- blendIn: float (optional - default is 3.0)
-- blendOut: float (optional - default is 1.0)
-- duration: number (optional - default is -1)
-- playbackRate: number (optional - default is 0)
-- lockX: boolean (optional)
-- lockY: boolean (optional)
-- lockZ: boolean (optional)
-- scenario: string (optional - either scenario or dict) ```ts
-- playEnter: boolean (optional - default is true) import lib from '@overextended/ox_lib/client'
-- prop: table (optional)
-- model: hash
-- bone: number (optional - default is 60309)
-- pos: table
-- x: number
-- y: number
-- z: number
-- rot: table
-- x: number
-- y: number
-- z: number
-- disable: table (optional)
-- move: boolean (optional)
-- car: boolean (optional)
-- combat: boolean (optional)
-- mouse: boolean (optional)
lib.progressCircle(data) lib.progressCircle(data)
``` ```
</TabItem>
</Tabs>
* duration: `number`
* label?: `string`
* position?: `'middle'` or `'bottom'`
* Default: `'middle'`
* useWhileDead?: `boolean`
* allowRagdoll?: `boolean`
* allowCuffed?: `boolean`
* allowFalling?: `boolean`
* canCancel?: `boolean`
* anim?: `table` (`object`)
* dict?: `string`
* Must specify either scenario or dict
* clip: `string`
* flag?: `number`
* Default: `49`
* blendIn?: `float`
* Default: `3.0`
* blendOut?: `float`
* Default: `1.0`
* duration?: `number`
Default: `-1`
* playbackRate?: `number`
Default: `0`
* lockX?: `boolean`
* lockY?: `boolean`
* lockZ?: `boolean`
* scenario?: `string`
* Must specify either scenario or dict
* playEnter?: `boolean`
* Default: `true`
* prop?: `table` (`object` or `array`)
* [ If you want to define multiple props, you can pass them as individual tables (array of objects) ]
* model: `hash`
* bone?: `number`
* Default: `60309`
* pos: `table`
* x: `number`
* y: `number`
* z: `number`
* rot: `table` (`object`)
* x: `number`
* y: `number`
* z: `number`
* disable?: `table` (`object`)
* move?: `boolean`
* car?: `boolean`
* combat?: `boolean`
* mouse?: `boolean`
### Usage Example
<Tabs>
<TabItem value='Lua'>
**Example:**
```lua ```lua
if lib.progressCircle({ if lib.progressCircle({
duration = 2000, duration = 2000,
@@ -138,20 +225,79 @@ if lib.progressCircle({
}, },
}) then print('Do stuff when complete') else print('Do stuff when cancelled') end }) then print('Do stuff when complete') else print('Do stuff when cancelled') end
``` ```
</TabItem>
<TabItem value='JS/TS'>
:::caution
This function is **asynchronous** requiring you to do a `.then` callback on the promise or make your function `async`.
:::
```ts
import lib from '@overextended/ox_lib/client'
if (await lib.progressCircle({
duration: 2000,
position: 'bottom',
useWhileDead: false,
canCancel: true,
disable: {
car: true,
},
anim: {
dict: 'mp_player_intdrink',
clip: 'loop_bottle'
},
prop: {
model: `prop_ld_flow_bottle`,
pos: vec3(0.03, 0.03, 0.02),
rot: vec3(0.0, 0.0, -1.5)
},
})) print('Do stuff when complete') else print('Do stuff when cancelled')
```
</TabItem>
</Tabs>
![progress_circle](https://i.imgur.com/nETRm5f.png) ![progress_circle](https://i.imgur.com/nETRm5f.png)
### lib.progressActive ## lib.progressActive
Returns true if a progress bar is currently active. Returns true if a progress bar is currently active.
<Tabs>
<TabItem value='Lua'>
```lua ```lua
lib.progressActive() lib.progressActive()
``` ```
</TabItem>
<TabItem value='JS/TS'>
### lib.cancelProgress ```ts
import lib from '@overextended/ox_lib/client'
lib.progressActive()
```
</TabItem>
</Tabs>
## lib.cancelProgress
If there is a progress bar active and the If there is a progress bar active and the
progress bar can be cancelled then it cancels it. progress bar can be cancelled then it cancels it.
<Tabs>
<TabItem value='Lua'>
```lua ```lua
lib.cancelProgress() lib.cancelProgress()
``` ```
</TabItem>
<TabItem value='JS/TS'>
```ts
import lib from '@overextended/ox_lib/client'
lib.cancelProgress()
```
</TabItem>
</Tabs>
+73 -18
View File
@@ -5,32 +5,63 @@ title: TextUI
import Tabs from '@theme/Tabs'; import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem'; import TabItem from '@theme/TabItem';
### lib.showTextUI ## lib.showTextUI
Show the TextUI window. Show the TextUI window.
**DO NOT** run this every tick, it's intented to be used as a toggle. **DO NOT** run this every tick, it's intented to be used as a toggle.
<Tabs>
<TabItem value='Lua'>
```lua ```lua
-- text: string
-- options: table (optional)
-- position: "right-center" or "left-center" or "top-center" (default - "right-center")
-- icon: string or table
-- iconColor: string
-- style: React.CSSProperties
lib.showTextUI(text, options) lib.showTextUI(text, options)
``` ```
</TabItem>
<TabItem value='JS/TS'>
```ts
import lib from '@overextended/ox_lib/client'
lib.showTextUI(text, options)
```
</TabItem>
</Tabs>
* text: `string`
* options?: `table`
* position?: `'right-center'` or `'left-center'` or `'top-center'`
* Default: `'right-center'`
* icon?: `string` or `table` (`array`)
* iconColor?: `string`
* style?: React.CSSProperties
### Usage Example
### Basic
**Example:**
<Tabs> <Tabs>
<TabItem label="Basic" value="basic"> <TabItem value='Lua'>
```lua ```lua
lib.showTextUI('[E] - Fuel vehicle') lib.showTextUI('[E] - Fuel vehicle')
``` ```
</TabItem>
<TabItem value='JS/TS'>
```ts
import lib from '@overextended/ox_lib/client'
lib.showTextUI('[E] - Fuel vehicle')
```
</TabItem>
</Tabs>
![](https://i.imgur.com/3ptQyAq.png) ![](https://i.imgur.com/3ptQyAq.png)
</TabItem>
<TabItem label="Custom style" value="custom"> ### Custom styling
<Tabs>
<TabItem value='Lua'>
```lua ```lua
lib.showTextUI('[E] - Pick apple', { lib.showTextUI('[E] - Pick apple', {
@@ -43,22 +74,46 @@ lib.showTextUI('[E] - Pick apple', {
} }
}) })
``` ```
</TabItem>
<TabItem value='JS/TS'>
![](https://i.imgur.com/gNDwPBN.png) ```ts
import lib from '@overextended/ox_lib/client'
lib.showTextUI('[E] - Pick apple', {
position: "top-center",
icon: 'hand',
style: {
borderRadius: 0,
backgroundColor: '#48BB78',
color: 'white'
}
})
```
</TabItem> </TabItem>
</Tabs> </Tabs>
The icon library used is Font Awesome 6.0, if for the icon you define only a string ![](https://i.imgur.com/gNDwPBN.png)
the default icon type will be `solid`.
If you want to use a different icon type, i.e
apple as a brand, you need to define icon as a table with the first value being
the icon type as a string, and the second being the icon name.
`icon = {'fab', 'apple'}`
### lib.hideTextUI ### lib.hideTextUI
Hides the currently visible TextUI window Hides the currently visible TextUI window
<Tabs>
<TabItem value='Lua'>
```lua ```lua
lib.hideTextUI() lib.hideTextUI()
``` ```
</TabItem>
<TabItem value='JS/TS'>
```ts
import lib from '@overextended/ox_lib/client'
lib.hideTextUI()
```
</TabItem>
</Tabs>
+23
View File
@@ -65,6 +65,29 @@ That's it!
You can now use the library functions inside of your resource, check the rest of the You can now use the library functions inside of your resource, check the rest of the
documentation to see how to utilise them. documentation to see how to utilise them.
# Using icons for interface functions
The icon library used is Font Awesome 6.0, if for the icon you define only a string
the default icon type will be `solid`.
If you want to use a different icon type, i.e
apple as a brand, you need to define icon as a table (`array`) with the first value being
the icon type (`fas`, `far`, `fab`) as a string, and the second being the icon name.
<Tabs>
<TabItem value='Lua'>
```lua
icon = {'fab', 'apple'}
```
</TabItem>
<TabItem value='JS/TS'>
```ts
icon: ['fab', 'apple']
```
</TabItem>
</Tabs>
# Building the UI # Building the UI
If you wish to edit any of the UI elements you will need to download the *source* code, edit what you need and then If you wish to edit any of the UI elements you will need to download the *source* code, edit what you need and then