Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update warning screen natives #1041

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 0 additions & 14 deletions HUD/GetWarningMessageTitleHash.md

This file was deleted.

17 changes: 17 additions & 0 deletions HUD/GetWarningScreenMessageTitleHash.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
ns: HUD
aliases: ["0x81DF9ABA6C83DFF9", "_GET_WARNING_MESSAGE_TITLE_HASH"]
---
## GET_WARNING_SCREEN_MESSAGE_HASH

```c
// 0x81DF9ABA6C83DFF9
Hash GET_WARNING_SCREEN_MESSAGE_HASH();
```

```
NativeDB Introduced: v1290
```

## Return value
Returns the warning message title text label hash (or `0` if warning message isn't active).
16 changes: 0 additions & 16 deletions HUD/IsWarningMessageActive_2.md

This file was deleted.

13 changes: 13 additions & 0 deletions HUD/IsWarningMessageReadyForControl.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
ns: HUD
aliases: ["0xAF42195A42C63BBA", "_IS_WARNING_MESSAGE_ACTIVE_2"]
---
## IS_WARNING_MESSAGE_READY_FOR_CONTROL

```c
// 0xAF42195A42C63BBA
BOOL IS_WARNING_MESSAGE_READY_FOR_CONTROL();
```

## Return value
Returns if the warning message UI is loaded and ready for control.
159 changes: 71 additions & 88 deletions HUD/SetWarningMessage.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,87 +5,66 @@ ns: HUD

```c
// 0x7B1776B3B53F8D74 0xBE699BDE
void SET_WARNING_MESSAGE(char* entryLine1, int instructionalKey, char* entryLine2, BOOL p3, int p4, cs_type(AnyPtr) char* background, cs_type(AnyPtr) char* p6, BOOL showBg, int errorCode);
void SET_WARNING_MESSAGE(char* line1TextLabel, int buttonsBitField, char* line2TextLabel, BOOL addNumber, int numberToAdd, cs_type(AnyPtr) char* substring1TextLabel, cs_type(AnyPtr) char* substring2TextLabel, BOOL showBg, int errorCode);
```

**instructionalKey enum list**:
Displays a warning screen for one frame.

```
enum INSTRUCTIONAL_BUTTON_TYPES
{
NONE = 0,
SELECT = 1,
OK = 2,
YES = 4,
BACK = 8,
BACK_SELECT = 9,
BACK_OK = 10,
BACK_YES = 12,
CANCEL = 16,
CANCEL_SELECT = 17,
CANCEL_OK = 18,
CANCEL_YES = 20,
NO = 32,
NO_SELECT = 33,
NO_OK = 34,
YES_NO = 36,
RETRY = 64,
RETRY_SELECT = 65,
RETRY_OK = 66,
RETRY_YES = 68,
RETRY_BACK = 72,
RETRY_BACK_SELECT = 73,
RETRY_BACK_OK = 74,
RETRY_BACK_YES = 76,
RETRY_CANCEL = 80,
RETRY_CANCEL_SELECT = 81,
RETRY_CANCEL_OK = 82,
RETRY_CANCEL_YES = 84,
SKIP = 256,
SKIP_SELECT = 257,
SKIP_OK = 258,
SKIP_YES = 260,
SKIP_BACK = 264,
SKIP_BACK_SELECT = 265,
SKIP_BACK_OK = 266,
SKIP_BACK_YES = 268,
SKIP_CANCEL = 272,
SKIP_CANCEL_SELECT = 273,
SKIP_CANCEL_OK = 274,
SKIP_CANCEL_YES = 276,
CONTINUE = 16384,
BACK_CONTINUE = 16392,
CANCEL_CONTINUE = 16400,
LOADING_SPINNER = 134217728,
SELECT_LOADING_SPINNER = 134217729,
OK_LOADING_SPINNER = 134217730,
YES_LOADING_SPINNER = 134217732,
BACK_LOADING_SPINNER = 134217736,
BACK_SELECT_LOADING_SPINNER = 134217737,
BACK_OK_LOADING_SPINNER = 134217738,
BACK_YES_LOADING_SPINNER = 134217740,
CANCEL_LOADING_SPINNER = 134217744,
CANCEL_SELECT_LOADING_SPINNER = 134217745,
CANCEL_OK_LOADING_SPINNER = 134217746,
CANCEL_YES_LOADING_SPINNER = 134217748
}
```
Available buttons for `buttonsBitField` (Can be combined with the `|` operator, for example: `(1 << 1 | 1 << 6 | 1 << 13...)`):
See the [`Controls Game Reference`](https://docs.fivem.net/docs/game-references/controls/) for information about Button Inputs.

Note: this list is definitely NOT complete, but these are the ones I've been able to find before giving up because it's such a boring thing to look for 'good' combinations.

**Result of the example code:**
[https://i.imgur.com/imwoimm.png](https://i.imgur.com/imwoimm.png)
| Button Index | Button Text | Button Input | Notes |
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use an enum over a table.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bump on this

| :---------------: | :---------: | :----------: |:---------------------------:|
| 1 << 0 | Select | INPUT_FRONTEND_ACCEPT | None |
| 1 << 1 | OK | INPUT_FRONTEND_ACCEPT | None |
| 1 << 2 | Yes | INPUT_FRONTEND_ACCEPT | None |
| 1 << 3 | Back | INPUT_FRONTEND_CANCEL | None |
| 1 << 4 | Cancel | INPUT_FRONTEND_CANCEL | None |
| 1 << 5 | No | INPUT_FRONTEND_CANCEL | None |
| 1 << 6 | Retry | INPUT_FRONTEND_X | None |
| 1 << 7 | Restart | INPUT_FRONTEND_X | None |
| 1 << 8 | Skip | INPUT_FRONTEND_X | None |
| 1 << 9 | Quit | INPUT_FRONTEND_CANCEL | None |
| 1 << 10 | Adjust | INPUTGROUP_FRONTEND_DPAD_LR | Adjust with left/right keyboard arrow icons |
| 1 << 11 | Ignore | INPUT_FRONTEND_X | None |
| 1 << 12 | Share | INPUT_FRONTEND_X | None |
| 1 << 13 | Log In | INPUT_FRONTEND_X | None |
| 1 << 14 | Continue | INPUT_FRONTEND_ACCEPT | None |
| 1 << 15 | Adjust | None | Adjust with left/right arrow icons |
| 1 << 16 | Scroll | None | Sets scroll button with up and down arrow icons |
| 1 << 17 | Overwrite | INPUT_FRONTEND_ACCEPT | None |
| 1 << 18 | Rockstar Games Sign Up | INPUT_FRONTEND_ACCEPT | None |
| 1 << 19 | Confirm | INPUT_FRONTEND_ACCEPT | None |
| 1 << 20 | Queue | INPUT_FRONTEND_ACCEPT | None |
| 1 << 21 | Retry | INPUT_FRONTEND_ACCEPT | None |
| 1 << 22 | Back | INPUT_FRONTEND_CANCEL | Same as button index #3 but plays select sound instead of cancel. |
| 1 << 23 | Rockstar Games | INPUT_FRONTEND_ACCEPT | This button\'s text label is `IB_UPDATE_SOCIAL_CLUB`, so it's used for updating the game. |
| 1 << 24 | Spectate | INPUT_FRONTEND_X | None |
| 1 << 25 | OK | INPUT_FRONTEND_CANCEL | OK with CANCEL instead of ACCEPT. |
| 1 << 26 | Cancel Transfer | INPUT_FRONTEND_CANCEL | |
| 1 << 27 | Nothing | None | Sets the loading spinner icon. |
| 1 << 28 | No - Return to Grand Theft Auto V | INPUT_FRONTEND_CANCEL | None |
| 1 << 29 | Cancel | INPUT_FRONTEND_CANCEL | Same as #4 |
| 1 << 30 | None | None | Reserved for NO SOUND. |
| 1 << 31 | Exit | INPUT_FRONTEND_CANCEL | None |
| 1 << 32 | No | INPUT_FRONTEND_X | None |
| 1 << 33 | Host | INPUT_FRONTEND_CANCEL | None |
| 1 << 34 | Search For Job | INPUT_FRONTEND_ACCEPT | None |
| 1 << 35 | Nothing | INPUT_FRONTEND_ACCEPT | None |
| 1 << 36 | Freemode | INPUT_FRONTEND_ACCEPT | None |
| 1 << 37 | Submit | INPUT_FRONTEND_ACCEPT | None |
| 1 << 38 | View Player Profile | INPUT_FRONTEND_ACCEPT | None |


## Parameters
* **entryLine1**: The text label to display as the first line of the warning message.
* **instructionalKey**: This is an enum, check the description for a list.
* **entryLine2**: The text label to display as the second line of the warning message.
* **p3**: Purpose unknown.
* **p4**: Purpose unknown.
* **background**: Set to anything other than 0 or false (even any string) and it will draw a background. Setting it to 0 or false will draw no background.
* **p6**: Purpose unknown.
* **showBg**: Purpose unknown.
* **line1TextLabel**: The text label to display as the first line of the warning message.
* **buttonsBitField**: This is a bit field of WarningScreen (in frontend.xml) buttons. Eg: (1 << 13 | 1 << 28) would set "Sign In" and "No - Return To Grand Theft Auto V" buttons.
* **line2TextLabel**: The text label to display as the second line of the warning message.
* **addNumber**: If a number should be inserted into the text (Similar to how [`ADD_TEXT_COMPONENT_INTEGER`](#_0x03B504CF259931BC) works.
* **numberToAdd**: Adds this number to `~1~` in the text label.
* **substring1TextLabel**: Adds first text label to `~a~` in the text. "" is the default.
* **substring2TextLabel**: Adds second text label to `~a~` in the text. "" is the default.
* **showBg**: If the warning screen should have a black background.
* **errorCode**: When not 0, adds a field displaying the value as 'error code' to the warning message.


Expand Down Expand Up @@ -113,20 +92,24 @@ CreateThread(function()
while true do
Wait(0)
-- Display the warning message every tick.
SetWarningMessage("warning_message_first_line", 82, "warning_message_second_line", 0, -1, true, 0, 0, 0)

-- Check for key presses or instructional button clicks.
-- Input group of 2 is required for this to work while the warning is being displayed.

if (IsControlJustReleased(2, 201) or IsControlJustReleased(2, 217)) then -- any select/confirm key was pressed.
TriggerEvent("optionSelected", "select")
break
elseif (IsControlJustReleased(2, 203)) then -- spacebar/x on controller (alt option) was pressed.
TriggerEvent("optionSelected", "alt")
break
elseif (IsControlJustReleased(2, 202)) then -- any of the cancel/back buttons was pressed
TriggerEvent("optionSelected", "cancel")
break
local ButtonsToSet = (1 << 1 | 1 << 4 | 1 << 6) -- This equals to 82: 1 << 1 sets "OK", 1 << 4 sets "Cancel" and 1 << 6 sets "Retry".
SetWarningMessage("warning_message_first_line", ButtonsToSet, "warning_message_second_line", false, -1, "", "", true, 0)

-- Make sure that the UI is loaded and ready for control.
if IsWarningMessageReadyForControl() then
-- Check for key presses or instructional button clicks.
-- Input group of 2 (Which is frontend control group) is required for this to work while the warning is being displayed.

if (IsControlJustReleased(2, 201) or IsControlJustReleased(2, 217)) then -- any select/confirm key was pressed.
TriggerEvent("optionSelected", "select")
break
elseif (IsControlJustReleased(2, 203)) then -- spacebar/x on controller (alt option) was pressed.
TriggerEvent("optionSelected", "alt")
break
elseif (IsControlJustReleased(2, 202)) then -- any of the cancel/back buttons was pressed
TriggerEvent("optionSelected", "cancel")
break
end
end
end
end)
Expand Down
85 changes: 0 additions & 85 deletions HUD/SetWarningMessageWithAlert.md

This file was deleted.

31 changes: 12 additions & 19 deletions HUD/SetWarningMessageWithHeader.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,30 +6,23 @@ aliases: ["_SET_WARNING_MESSAGE_2"]

```c
// 0xDC38CC1E35B6A5D7 0x2DB9EAB5
void SET_WARNING_MESSAGE_WITH_HEADER(char* titleMsg, char* entryLine1, int flags, char* promptMsg, BOOL p4, Any p5, BOOL background, Any* p7, BOOL showBg);
void SET_WARNING_MESSAGE_WITH_HEADER(char* headerTextLabel, char* line1TextLabel, int buttonsBitField, char* line2TextLabel, BOOL addNumber, int numberToAdd, cs_type(BOOL) char* substring1TextLabel, cs_type(AnyPtr) char* substring2TextLabel, BOOL showBg);
```

```
You can only use text entries. No custom text.
C# Example :
Function.Call(Hash._SET_WARNING_MESSAGE_2, "HUD_QUIT", "HUD_CGIGNORE", 2, "HUD_CGINVITE", 0, -1, 0, 0, 1);
you can recreate this easily with scaleforms
---------------
Fixed native name, from before nativedb restoration.
```
Shows the warning screen for one frame with an option to change the header.

```
NativeDB Added Parameter 10: Any p9
NativeDB Added Parameter 10: int errorCode
```

## Parameters
* **titleMsg**:
* **entryLine1**:
* **flags**:
* **promptMsg**:
* **p4**:
* **p5**:
* **background**:
* **p7**:
* **showBg**:
* **headerTextLabel**: Text label to set on the header.
* **line1TextLabel**: Text label to set on the first line on the body.
* **buttonsBitField**: Buttons bit field. See [`SET_WARNING_MESSAGE`](#_0x7B1776B3B53F8D74) for an example.
* **line2TextLabel**: Text label to set on the second line on the body.
* **addNumber**: If a number needs to be inserted to `~1~` in the text label.
* **numberToAdd**: What number should be inserted to `~1~`.
* **substring1TextLabel**: First text label (or "") to insert into `~1~` of the body.
* **substring2TextLabel**: Second text label (or "") to insert into `~1~` of the body.
* **showBg**: If the message needs to have a black background.

Loading
Loading