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.