Zumbs' Blog

The truth may be out there, but lies are inside your head

FOMM and FOMODs for Dummies 6: Working with Forms II

Posted by Zumbs on November 12, 2009

FOMM and FOMODs for Dummies

  1. Installing Mods
  2. Making FOMODS
  3. Basic FOMOD Scripting I
  4. Basic FOMOD Scripting II
  5. Working with Forms I
  6. Working with Forms II
  7. Load Order Magicks

The previous tutorial showed how to setup a form, apply a background image and add install and cancel buttons. This tutorial will show how to add and use checkboxes and radiobuttons to allow the user to customize the installation form. When you start making your own, I highly recommend that you take the time to draw a sketch of the form you wish to make before you start. The tutorial will end with an example, using the skills learned in this tutorial.

Adding a title

A title will tell the user which mod is being installed. A classic position of a title is in the upper center. Text can be added to the installation form by using a label, declared by

public static Label TitleLabel;

and constructed by

TitleLabel = new Label();
TitleLabel.Text = "My mod name";
TitleLabel.ForeColor = Color.Snow;
TitleLabel.BackColor = Color.Transparent;
TitleLabel.Location = new Point(45, 30);
TitleLabel.TextAlign = ContentAlignment.MiddleCenter;
TitleLabel.AutoSize = true;

It can be placed on the background picture by


You can also set the font of the label, but you have to be careful, as the user may not have all fonts installed. You may want to edit the background picture instead of using a label.

Adding a Checkbox

Checkboxes are used to allow the user to choose one or more of a number of options. This can be used to install an optional addon, such as DLC compatiblity. To make a checkbox it must be declared:

public static CheckBox InstallCustomAddonCheckBox;

and is initialized by:

InstallCustomAddonCheckBox = new CheckBox();
InstallCustomAddonCheckBox.Checked = true;
InstallCustomAddonCheckBox.Location = new Point(5, 102);
InstallCustomAddonCheckBox.Size = new Size(20, 20);

The checkbox starts as being checked. You may want to edit the placement, when you use it. Note, however, that it does not come with an explanatory text. To help the user discover what the checkbox does, you can add a label next to the checkbox. A label is declared by

public static Label InstallCustomAddonLabel;

and initialized for

InstallCustomAddonLabel = new Label();
InstallCustomAddonLabel.Text = "Install custom addon";
InstallCustomAddonLabel.Location = new Point(27, 105);
InstallCustomAddonLabel.AutoSize = true;

Note how the label is placed 22 px to the right and 3 px below the checkbox.

Depending on your background picture, the text may be difficult to read. This can be fixed by placing the options menu on a panel with a custom background color. A panel can be declared by:

public static Panel OptionsPanel;

and initialized and customized by:

OptionsPanel = new Panel();
OptionsPanel.Location = new Point(266, 110);
OptionsPanel.Size = new Size(210, 160);
OptionsPanel.BackColor = Color.WhiteSmoke;
OptionsPanel.BorderStyle = BorderStyle.FixedSingle;

The options panel can be placed on the background picture by:


The checkbox and label can be placed on the panel by


After the user presses “Install”, you want to check the state of the checkbox – checked or not checked. This can be done by

if (InstallCustomAddonCheckBox.Checked)
    // handle custom option

Adding a Radiobutton

Radiobuttons are used to allow the user to choose exactly one from a number of options. An example could be which body replacer the user has installed. A radio button can be declared by

public static RadioButton DisableMinigamesRadioButton;

and initialized by

DisableMinigamesRadioButton = new RadioButton();
DisableMinigamesRadioButton.Checked = true;
DisableMinigamesRadioButton.Location = new Point(5, 33);
DisableMinigamesRadioButton.Size = new Size(20, 20);

The radiobutton comes without text, so you have to add a label, like shown above. Please note that only one of the radio buttons should be initialized to being checked. The radio button can be applied to the options panel by


Note, however, that all radio buttons in one panel will be viewed as a group (e.g. be mutually exclusive). To use multiple sets of radio buttons (e.g. choose both male and female body versions), you must place the radio buttons on separate panels. To check which option were chosen, you can use

if (Option1RadioButton.Checked)
    // handle option 1
else if (Option2RadioButton.Checked)
    // handle option 2

Other controls

Aside from buttons, radiobuttons and checkboxes, there are a number of other useful controls. ComboBoxes can be used to present the user with a drop-down, where a the user can make a choice. When selecting an option, you can code something to happen, such as showing a picture (take a look at Breezes male body mod for a code example). Check google for form tutorials and have a look at all the crazy options, if you like 🙂


This example uses two checkboxes and one radiobutton set with three radiobuttons. The mod contains the following files


Only one of the three meshes can be installed (mutually exclusive), but all three esps can be installed. The total form script is presented below, or can be saved from this odt file (wordpress does not allow one to upload .cs or .txt files).

using System;
using System.Drawing;
using System.IO;
using System.Windows.Forms;
using fomm.Scripting;

class Script : BaseScript
    public static bool install;
    public static Form InstallForm;
    public static PictureBox BackgroundPicture;
    public static Panel InstallPanel;
    public static Button InstallButton;
    public static Button CancelInstallButton;
    public static Panel OptionsPanel;
    public static CheckBox InstallFOOK2CompatibilityCheckBox;
    public static Label InstallFOOK2CompatibilityAddonLabel;
    public static CheckBox InstallDLCCompatibilityCheckBox;
    public static Label InstallDLCCompatibilityAddonLabel;
    public static RadioButton MeshDefaultRadioButton;
    public static Label MeshDefaultLabel;
    public static RadioButton Mesh1RadioButton;
    public static Label Mesh1Label;
    public static RadioButton Mesh2RadioButton;
    public static Label Mesh2Label;
    public static Image GetImageFromFomod(string filename)
        byte[] data = GetFileFromFomod(filename);
        MemoryStream s = new MemoryStream(data);
        Image img = Image.FromStream(s);
        return img;
    public static void CreateInstallForm()
        InstallForm = CreateCustomForm();

        // customize install form
        InstallForm.FormBorderStyle = FormBorderStyle.Fixed3D;
        InstallForm.StartPosition = FormStartPosition.CenterScreen;
        InstallForm.Size = new Size(500, 600);
        // place background picture box
        BackgroundPicture = new PictureBox();
        BackgroundPicture.Location = new Point(0, 0);
        BackgroundPicture.Size = new Size(500, 600);
        // load picture file from .fomod and stream into picture box
        BackgroundPicture.Image = GetImageFromFomod("fomod/screenshot.png");
        // add BackgroundPicture to list of controls
        // install button
        InstallButton = new Button();
        InstallButton.Text = "Install";
        InstallButton.BackColor = Color.Silver;
        InstallButton.Location = new Point(5, 540);
        InstallButton.Size = new Size(100, 23);
        // cancel button
        CancelInstallButton = new Button();
        CancelInstallButton.Text = "Cancel";
        CancelInstallButton.BackColor = Color.Silver;
        CancelInstallButton.Location = new Point(105, 540);
        CancelInstallButton.Size = new Size(100, 23);
        // options panel
        OptionsPanel = new Panel();
        OptionsPanel.Location = new Point(100, 300);
        OptionsPanel.Size = new Size(210, 250);
        OptionsPanel.BackColor = Color.WhiteSmoke;
        OptionsPanel.BorderStyle = BorderStyle.FixedSingle;
        // FOOK2 compatibility patch
        InstallFOOK2CompatibilityCheckBox = new CheckBox();
        InstallFOOK2CompatibilityCheckBox.Checked = true;
        InstallFOOK2CompatibilityCheckBox.Location = new Point(5, 5);
        InstallFOOK2CompatibilityCheckBox.Size = new Size(20, 20);
        InstallFOOK2CompatibilityAddonLabel = new Label();
        InstallFOOK2CompatibilityAddonLabel.Text = "Install FOOK2 Compatibility patch";
        InstallFOOK2CompatibilityAddonLabel.Location = new Point(27, 8);
        InstallFOOK2CompatibilityAddonLabel.AutoSize = true;
        // dlc compatibility patch
        InstallDLCCompatibilityCheckBox = new CheckBox();
        InstallDLCCompatibilityCheckBox.Checked = true;
        InstallDLCCompatibilityCheckBox.Location = new Point(5, 38);
        InstallDLCCompatibilityCheckBox.Size = new Size(20, 20);
        InstallDLCCompatibilityAddonLabel = new Label();
        InstallDLCCompatibilityAddonLabel.Text = "Install DLC Compatibility patch";
        InstallDLCCompatibilityAddonLabel.Location = new Point(27, 41);
        InstallDLCCompatibilityAddonLabel.AutoSize = true;
        // radiobutton menu
        MeshDefaultRadioButton = new RadioButton();
        MeshDefaultRadioButton.Checked = true;
        MeshDefaultRadioButton.Location = new Point(5, 71);
        MeshDefaultRadioButton.Size = new Size(20, 20);
        MeshDefaultLabel = new Label();
        MeshDefaultLabel.Text = "Vanilla mesh";
        MeshDefaultLabel.Location = new Point(27, 74);
        MeshDefaultLabel.AutoSize = true;
        Mesh1RadioButton = new RadioButton();
        Mesh1RadioButton.Checked = false;
        Mesh1RadioButton.Location = new Point(5, 104);
        Mesh1RadioButton.Size = new Size(20, 20);
        Mesh1Label = new Label();
        Mesh1Label.Text = "Breeze mesh";
        Mesh1Label.Location = new Point(27, 107);
        Mesh1Label.AutoSize = true;
        Mesh2RadioButton = new RadioButton();
        Mesh2RadioButton.Checked = false;
        Mesh2RadioButton.Location = new Point(5, 137);
        Mesh2RadioButton.Size = new Size(20, 20);
        Mesh2Label = new Label();
        Mesh2Label.Text = "Robert mesh";
        Mesh2Label.Location = new Point(27, 140);
        Mesh2Label.AutoSize = true;

        // build form
    public static void AttachHandlers()
        //Attach a handler that will fire when the appropriate button is clicked 
        InstallButton.Click += delegate(object sender, EventArgs args)
            install = true;
        CancelInstallButton.Click += delegate(object sender, EventArgs args)
            install = false;
    public static void PerformCustomInstall()
        else if(Mesh1RadioButton.Checked)
            CopyDataFile("meshes/mesh1.nif", "meshes/mesh.nif");
        else if(Mesh2RadioButton.Checked)
            CopyDataFile("meshes/mesh2.nif", "meshes/mesh.nif");
        SetPluginActivation("mod-base.esp", true);
            SetPluginActivation("mod-FOOK2-compatibility-patch.esp", true);
            SetPluginActivation("mod-the-pitt-compatibility.esp", true);
    public static bool OnActivate()
        return install;

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: