Message boxes with custom buttons

Discuss modding questions and implementation details.
Post Reply
User avatar
Hazelnut
Posts: 2867
Joined: Sat Aug 26, 2017 2:46 pm
Contact:

Message boxes with custom buttons

Post by Hazelnut »

DFU message boxes can have buttons on for player input, and Daggerfall has 20 standard buttons which DFU replicates. Usually we see yes/no, recall/anchor, and occasionally guilty/not / debate/lie if you've been naughty. The standard set of buttons can be seen in the list in the next post (first 20 of the list) and are not all useful, so mods often want more options. I figured out how to do this a year or so ago in a way that didn't require significant changes to DFU, just a minor tweak, but have held off on publicising since at least one person was working towards more complete and more user friendly support for this. Considering v1.0 of DFU is now approaching (exciting times!) and nothing has materialised after a year, I'm going to write up how mods can add custom buttons to message boxes here. Hopefully people wont be too disappointed with this method.

The basic idea is that the message box buttons in DFU are run off an enum (MessageBoxButtons) and since C# enums are simply integers with named values, new numbers can be used by simply casting to the enum. The button images are called "BUTTONS.RCI_XX-0.png" where XX = the button index, so if a mod provides an image file "BUTTONS.RCI_21-0.png" and then calls the add button method like this:

Code: Select all

protected const DaggerfallMessageBox.MessageBoxButtons weekButton = (DaggerfallMessageBox.MessageBoxButtons)21;
messageBox.AddButton(weekButton);
Using a constant definition is not strictly necessary, but I would recommend it especially if you use the button in more than one place. Obviously the main issue with this is that the button index values will need to be coordinated, but since that issue already exists for other DF resources and we have a topic for this on these forums I am not too concerned. That thread has a new section for button indexes now and I'm sure the DFU mod community can deal with this no problem. (right?)

So what about quest prompts I hear you cry! We're so tired of only being able to give yes/no prompts. That's soon to be taken care of with PR#2122 and a new action for quests called promptmulti. This action allows the quest to pop up a message box with between 2-4 buttons, including custom ones. The syntax looks like this:

Code: Select all

promptmulti 1072 4:noChoice _dirRand_ 24:south _headS_ 25:west _headW_ 28:swest _headSW_
The first number is the message id to put in the message box, then there are between 2 and 4 button specifiers of the format "N:label _task_" where N is the button index, label is a simple string meaningful name for the button, and _task_ is the task to activate if that button is clicked. Note that the label is just for the readability of the quest and does nothing, simply allowing you to label each option so you don't need to keep remembering which button each index number represents. (it's actually optional and you can drop the ":label" parts if you want and it will still work) The buttons are rendered left to right with the first one being the default option if enter is pressed.

From version 1.2, my Roleplay & Realism mod has examples of both 3 and 4 button message boxes with a combination of standard and custom buttons from both code and a quest. It also has 16 generally useful custom button images for indexes 21-36 which can be used by any mods either by making it dependent on R&R since it's pretty commonly used or just copy the image(s) you need into your mod and use the same agreed index if you don't want the dependency.

Direct references to example use & button images:
https://github.com/ajrb/dfunity-mods/bl ... RR.cs#L109
https://github.com/ajrb/dfunity-mods/bl ... 1.txt#L900
https://github.com/ajrb/dfunity-mods/tr ... es/Buttons

I hope that this explanation makes sense and modders can now have more flexibility to create their visions.
See my mod code for examples of how to change various aspects of DFU: https://github.com/ajrb/dfunity-mods

User avatar
Hazelnut
Posts: 2867
Joined: Sat Aug 26, 2017 2:46 pm
Contact:

Re: Message boxes with custom buttons

Post by Hazelnut »

Button indexes:

0 Accept
1 Reject
2 Cancel
3 Yes
4 No
5 OK
6 Male
7 Female
8 Add
9 Delete
10 Edit
11 Counter
12 12 MON
13 36 MON
14 Copy
15 Guilty
16 Not Guilty
17 Debate
18 Lie
19 Anchor
20 Teleport
21 5 Days
22 North
23 East
24 South
25 West
26 N East
27 S East
28 S West
29 N West
30 Attack
31 Flee
32 Persuade
33 Distract
34 Sneak
35 Rest
36 Pack
See my mod code for examples of how to change various aspects of DFU: https://github.com/ajrb/dfunity-mods

User avatar
Hazelnut
Posts: 2867
Joined: Sat Aug 26, 2017 2:46 pm
Contact:

Re: Message boxes with custom buttons

Post by Hazelnut »

This is now available in the latest DFU release 0.11.4 and the 16 extra custom buttons are available in Roleplay & realism v1.2.
See my mod code for examples of how to change various aspects of DFU: https://github.com/ajrb/dfunity-mods

l3lessed
Posts: 1142
Joined: Mon Aug 12, 2019 4:32 pm
Contact:

Re: Message boxes with custom buttons

Post by l3lessed »

This is wonderful addition. Thanks Hazel.
My Daggerfall Mod Github: l3lessed DFU Mod Github

My Beth Mods: l3lessed Nexus Page

Daggerfall Unity mods: Combat Overhaul Mod

Enjoy the free work I'm doing? Consider lending your support.

Post Reply