Jump to content

Understanding MCM


sen4mi

Recommended Posts

Posted

MCM lets the FNV mod designer separate in-character interaction (playing the game) from out-of-character interaction (configuring the mod). In other words, it gets out of the way when you are playing, and yet is still available when you want to change the story you are playing in. But this assumes that the mod author has exposed the options you would like to change to the MCM interface.

 

Here, I am not going to attempt to talk about how to choose the right things to configure - I believe that that issue is best addressed by the author, and the author's fans. But I have noticed a number of people expressing confusion about how to write code for MCM. So, hopefully, we can deal with some of those issues in this thread.

 

I am making my initial post here be a mix of skimming over important topics and emphasizing some very basic issues, because I do not know what knowledge arbitrary interested modders will need.  Also, this post will resemble a table of contents.

 

First, Fallout New Vegas (and a number of related Bethesda games) does not support "string" or "list of characters" variables. So this makes challenging writing UI code that let's the programmer specify strings. MCM avoids this problem using nvse functions which manipulate xml files that describe ui elements.  These functions are GetUIFloat, SetUIFloat, SetUIString, and SetUIStringEx, and are described on page 1 of the MCM Guide that you can download with the mod.

 

Second, FNV works by rendering a sequence of screen images.  If you are getting 30 fps, that means it renders 30 images in a second. MCM images are implemented using quest scripts which run in MenuMode 1013. This means that when MCM is active and your MCM script is selected, there will be times when your script is run as a part of rendering the screen. When this happens, your script updates the xml structure which represents MCM's screen image and then the game takes that information and displays it to the user. Later screens reuse this information.

 

On page 3 of the MCM Guide, you are presented with an example of how you might write a quest script, to drive MCM.  Some of that script is concerned with making sure your script runs for the right frames (which means when the user has selected your config menu and the game needs to update the screen data). But the middle of that script is the part that you need to understand and extend, to make the options you want display on the screen.

 

In some ways, this script is patterened after an "event driven ui" model, but everything needed for "painting the screen" needs to be dealt with in one pass, so we do not get independent events. Instead, the underlying MCM system will turn on flags indicated what is needed and you, the coder, must deal with whatever it has asked for (or, if you do not, nothing happens). You must also turn off each of these flags to let MCM know that you have completed this step.

 

Here are the steps (psuedo-events) handled in that MCM example script, along with a short description of each:

 

; 1 - RESET

 

RESET is, in essence, the "paint" event. Here, you declare what options and content you are putting on the screen. This will run every time the screen needs to be updated.  Note that when you do something that changes what's on screen you will be turning on the reset flag so that the next frame will get the updated content.

 

; 2 - DEFAULT

 

This informs your script that the user has asked for ui elements to be set to their default value.

 

; 3 - NEW VALUE

 

This informs your script that the user has updated a ui element with some new value.

 

; 4 - SHOW LIST

 

The user has selected a ui element that's a list, here you provide the details of how that looks when it's expanded. (option type 1)

 

; 5 - SHOW SCALE 

 

The user wants to interact with a ui element that allows a choice of a range of values.  (option type 2, or 2.5 or 8 or 9)

 

; 6 - DEFAULT SCALE

 

The user has asked a scale ui element to return to its default value

 

; 7 - MOUSE OVER

 

The user is hovering over something (or not) so you need to figure out which thing and do whatever it is you do for mouseover effects

 

To get a general idea of what things you can control for each entry, page 5 of the guide lists "properties" of ui elements (and page 8 has some extra properties).

 

The kinds of ui elements are detailed on pages 6 and 7 of the guide.

 

You can also create and use sub-menus. These are handled in your RESET logic, and are described on page 21 and 22 of the guide.

 

Page 24 explains how to use quest stages to serve the role of "subroutines". This becomes important when your UI script gets large. You do not need to care about this issue until you get a MAX_SCRIPT_SIZE Exceeded error.

 

Hopefully this information will help you understand how to use the MCM Guide which will help you implement MCM support for your mod (if you feel that that is important). If you notice something about the guide which seems confusing and work out the answer (or need help with the answer), please feel free to post about that in this thread.  ;)

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...