Beispiel #1
0
static void OpenSelectorWindow(txt_dropdown_list_t *list)
{
    txt_window_t *window;
    int i;

    // Open a simple window with no title bar or action buttons.

    window = TXT_NewWindow(NULL);

    TXT_SetWindowAction(window, TXT_HORIZ_LEFT, NULL);
    TXT_SetWindowAction(window, TXT_HORIZ_CENTER, NULL);
    TXT_SetWindowAction(window, TXT_HORIZ_RIGHT, NULL);

    // Position the window so that the currently selected item appears
    // over the top of the list widget.

    TXT_SetWindowPosition(window, TXT_HORIZ_LEFT, TXT_VERT_TOP,
                          list->widget.x - 2, SelectorWindowY(list));

    // Add a button to the window for each option in the list.

    for (i=0; i<list->num_values; ++i)
    {
        txt_button_t *button;
        callback_data_t *data;

        button = TXT_NewButton(list->values[i]);

        TXT_AddWidget(window, button);

        // Callback struct

        data = malloc(sizeof(callback_data_t));
        data->list = list;
        data->window = window;
        data->item = i;
        
        // When the button is pressed, invoke the button press callback
       
        TXT_SignalConnect(button, "pressed", ItemSelected, data);
        
        // When the window is closed, free back the callback struct

        TXT_SignalConnect(window, "closed", FreeCallbackData, data);

        // Is this the currently-selected value?  If so, select the button
        // in the window as the default.
        
        if (i == *list->variable)
        {
            TXT_SelectWidget(window, button);
        }
    }

    // Catch presses of escape in this window and close it.

    TXT_SetKeyListener(window, SelectorWindowListener, NULL);
}
Beispiel #2
0
void Window2(void)
{
    txt_window_t *window;
    txt_table_t *table;
    txt_table_t *unselectable_table;
    txt_scrollpane_t *scrollpane;

    window = TXT_NewWindow("Another test");
    TXT_SetWindowPosition(window, 
                          TXT_HORIZ_RIGHT, 
                          TXT_VERT_TOP, 
                          TXT_SCREEN_W - 1, 1);

    TXT_AddWidgets(window,
                   TXT_NewScrollPane(40, 1,
                        TXT_NewLabel("* Unselectable scroll pane *")),
                   unselectable_table = TXT_NewTable(1),
                   NULL);

    TXT_AddWidget(unselectable_table, TXT_NewLabel("* Unselectable table *"));

    TXT_AddWidget(window, TXT_NewSeparator("Input boxes"));
    table = TXT_NewTable(2);
    TXT_AddWidget(window, table);
    TXT_AddWidget(table, TXT_NewLabel("String: "));
    TXT_AddWidget(table, TXT_NewInputBox(&textbox_value, 20));
    TXT_AddWidget(table, TXT_NewLabel("Int: "));
    TXT_AddWidget(table, TXT_NewIntInputBox(&numbox_value, 10));
    TXT_AddWidget(table, TXT_NewLabel("Spin control:"));
    TXT_AddWidget(table, TXT_NewSpinControl(&numbox_value, 0, 15));

    TXT_AddWidget(window, TXT_NewSeparator("Scroll pane test"));
    scrollpane = TXT_NewScrollPane(40, 5, TXT_NewLabel(
        "This is a scrollable pane. The contents\n"
        "of this box are larger than the box\n"
        "itself, but it can be scrolled around\n"
        "to explore the full contents.\n"
        "\n"
        "Scrollable panes can be scrolled both\n"
        "vertically and horizontally. They\n"
        "can contain any widget. The scroll bars\n"
        "appear automatically as needed.\n"
        "\n"
        "This is a very long line of text that forces a horizontal scrollbar"
    ));
    TXT_AddWidget(window, scrollpane);
}
Beispiel #3
0
static void BuildMasterStatusWindow(void)
{
    txt_window_t *master_window;

    master_window = TXT_NewWindow(NULL);
    master_msg_label = TXT_NewLabel("");
    TXT_AddWidget(master_window, master_msg_label);

    // This window is here purely for information, so it should be
    // in the background.

    TXT_LowerWindow(master_window);
    TXT_SetWindowPosition(master_window, TXT_HORIZ_CENTER, TXT_VERT_CENTER,
                                         TXT_SCREEN_W / 2, TXT_SCREEN_H - 4);
    TXT_SetWindowAction(master_window, TXT_HORIZ_LEFT, NULL);
    TXT_SetWindowAction(master_window, TXT_HORIZ_CENTER, NULL);
    TXT_SetWindowAction(master_window, TXT_HORIZ_RIGHT, NULL);
}
Beispiel #4
0
static void OpenWaitDialog(void)
{
    txt_window_action_t *cancel;

    TXT_SetDesktopTitle(PACKAGE_STRING);

    window = TXT_NewWindow("Waiting for game start...");

    TXT_AddWidget(window, TXT_NewLabel("\nPlease wait...\n\n"));

    cancel = TXT_NewWindowAction(KEY_ESCAPE, "Cancel");
    TXT_SignalConnect(cancel, "pressed", EscapePressed, NULL);

    TXT_SetWindowAction(window, TXT_HORIZ_LEFT, cancel);
    TXT_SetWindowPosition(window, TXT_HORIZ_CENTER, TXT_VERT_BOTTOM,
                                  TXT_SCREEN_W / 2, TXT_SCREEN_H - 9);

    old_max_players = 0;
}
void ConfigDisplay(TXT_UNCAST_ARG(widget), void *user_data)
{
    txt_window_t *window;
    txt_table_t *sizes_table;
    txt_window_action_t *advanced_button;

    // Open the window
    window = TXT_NewWindow("Display Configuration");
    TXT_SetWindowHelpURL(window, WINDOW_HELP_URL);

    // Build window:
    TXT_AddWidgets(window,
        TXT_NewCheckBox("Full screen", &fullscreen),
        TXT_NewConditional(&fullscreen, 0,
            sizes_table = TXT_NewTable(3)),
        NULL);

    TXT_SetColumnWidths(window, 42);

    // The window is set at a fixed vertical position.  This keeps
    // the top of the window stationary when switching between
    // fullscreen and windowed mode (which causes the window's
    // height to change).
    TXT_SetWindowPosition(window, TXT_HORIZ_CENTER, TXT_VERT_TOP,
                                  TXT_SCREEN_W / 2, 6);

    GenerateSizesTable(NULL, sizes_table);

    // Button to open "advanced" window.
    // Need to pass a pointer to the window sizes table, as some of the options
    // in there trigger a rebuild of it.
    advanced_button = TXT_NewWindowAction('a', "Advanced");
    TXT_SetWindowAction(window, TXT_HORIZ_CENTER, advanced_button);
    TXT_SignalConnect(advanced_button, "pressed",
                      AdvancedDisplayConfig, sizes_table);
}
Beispiel #6
0
void ConfigDisplay(void)
{
    txt_window_t *window;
    txt_table_t *modes_table;
    txt_separator_t *modes_separator;
    txt_table_t *bpp_table;
    txt_window_action_t *advanced_button;
    txt_checkbox_t *fs_checkbox;
    int i;
    int num_columns;
    int num_rows;
    int window_y;

    // What color depths are supported?  Generate supported_bpps array
    // and set selected_bpp to match the current value of screen_bpp.

    IdentifyPixelDepths();
    SetSelectedBPP();

    // First time in? Initialise selected_screen_{width,height}

    if (selected_screen_width == 0)
    {
        selected_screen_width = screen_width;
        selected_screen_height = screen_height;
    }

    // Open the window

    window = TXT_NewWindow("Display Configuration");

    // Some machines can have lots of video modes.  This tries to
    // keep a limit of six lines by increasing the number of
    // columns.  In extreme cases, the window is moved up slightly.

    BuildFullscreenModesList();

    if (num_screen_modes_fullscreen <= 24)
    {
        num_columns = 3;
    }
    else if (num_screen_modes_fullscreen <= 40)
    {
        num_columns = 4;
    }
    else
    {
        num_columns = 5;
    }

    modes_table = TXT_NewTable(num_columns);

    // Build window:

    TXT_AddWidget(window, 
                  fs_checkbox = TXT_NewCheckBox("Full screen", &fullscreen));

    if (num_supported_bpps > 1)
    {
        TXT_AddWidgets(window,
                       TXT_NewSeparator("Color depth"),
                       bpp_table = TXT_NewTable(4),
                       NULL);

        for (i = 0; i < num_supported_bpps; ++i)
        {
            txt_radiobutton_t *button;

            button = TXT_NewRadioButton(supported_bpps[i],
                                        &selected_bpp, i);

            TXT_AddWidget(bpp_table, button);
            TXT_SignalConnect(button, "selected", UpdateBPP, modes_table);
        }
    }

    TXT_AddWidgets(window,
                   modes_separator = TXT_NewSeparator(""),
                   modes_table,
                   NULL);

    TXT_SignalConnect(fs_checkbox, "changed",
                      GenerateModesTable, modes_table);
    TXT_SignalConnect(fs_checkbox, "changed",
                      UpdateModeSeparator, modes_separator);

    // How many rows high will the configuration window be?
    // Need to take into account number of fullscreen modes, and also
    // number of supported pixel depths.
    // The windowed modes list is four rows, so take the maximum of
    // windowed and fullscreen.

    num_rows = (num_screen_modes_fullscreen + num_columns - 1) / num_columns;

    if (num_rows < 4)
    {
        num_rows = 4;
    }

    if (num_supported_bpps > 1)
    {
        num_rows += 2;
    }

    if (num_rows < 14)
    {
        window_y = 8 - ((num_rows + 1) / 2);
    }
    else
    {
        window_y = 1;
    }

    // The window is set at a fixed vertical position.  This keeps
    // the top of the window stationary when switching between
    // fullscreen and windowed mode (which causes the window's
    // height to change).

    TXT_SetWindowPosition(window, TXT_HORIZ_CENTER, TXT_VERT_TOP, 
                                  TXT_SCREEN_W / 2, window_y);

    GenerateModesTable(NULL, modes_table);
    UpdateModeSeparator(NULL, modes_separator);

    // Button to open "advanced" window.
    // Need to pass a pointer to the modes table, as some of the options
    // in there trigger a rebuild of it.

    advanced_button = TXT_NewWindowAction('a', "Advanced");
    TXT_SetWindowAction(window, TXT_HORIZ_CENTER, advanced_button);
    TXT_SignalConnect(advanced_button, "pressed",
                      AdvancedDisplayConfig, modes_table);
}
Beispiel #7
0
void ConfigSound(TXT_UNCAST_ARG(widget), void *user_data)
{
    txt_window_t *window;
    txt_window_action_t *music_action;

    // Build the window

    window = TXT_NewWindow("Sound configuration");
    TXT_SetWindowHelpURL(window, WINDOW_HELP_URL);

    TXT_SetColumnWidths(window, 40);
    TXT_SetWindowPosition(window, TXT_HORIZ_CENTER, TXT_VERT_TOP,
                                  TXT_SCREEN_W / 2, 3);

    music_action = TXT_NewWindowAction('m', "Music Packs");
    TXT_SetWindowAction(window, TXT_HORIZ_CENTER, music_action);
    TXT_SignalConnect(music_action, "pressed", OpenMusicPackDir, NULL);

    TXT_AddWidgets(window,
        TXT_NewSeparator("Sound effects"),
        TXT_NewRadioButton("Disabled", &snd_sfxdevice, SNDDEVICE_NONE),
        TXT_If(gamemission == doom,
            TXT_NewRadioButton("PC speaker effects", &snd_sfxdevice,
                               SNDDEVICE_PCSPEAKER)),
        TXT_NewRadioButton("Digital sound effects",
                           &snd_sfxdevice,
                           SNDDEVICE_SB),
        TXT_If(gamemission == doom || gamemission == heretic
            || gamemission == hexen,
            TXT_NewConditional(&snd_sfxdevice, SNDDEVICE_SB,
                TXT_NewHorizBox(
                    TXT_NewStrut(4, 0),
                    TXT_NewCheckBox("Pitch-shifted sounds", &snd_pitchshift),
                    NULL))),
        TXT_If(gamemission == strife,
            TXT_NewConditional(&snd_sfxdevice, SNDDEVICE_SB,
                TXT_NewHorizBox(
                    TXT_NewStrut(4, 0),
                    TXT_NewCheckBox("Show text with voices", &show_talk),
                    NULL))),

        TXT_NewSeparator("Music"),
        TXT_NewRadioButton("Disabled", &snd_musicdevice, SNDDEVICE_NONE),

        TXT_NewRadioButton("OPL (Adlib/Soundblaster)", &snd_musicdevice,
                           SNDDEVICE_SB),
        TXT_NewConditional(&snd_musicdevice, SNDDEVICE_SB,
            TXT_NewHorizBox(
                TXT_NewStrut(4, 0),
                TXT_NewLabel("Chip type: "),
                OPLTypeSelector(),
                NULL)),

        TXT_NewRadioButton("GUS (emulated)", &snd_musicdevice, SNDDEVICE_GUS),
        TXT_NewConditional(&snd_musicdevice, SNDDEVICE_GUS,
            TXT_MakeTable(2,
                TXT_NewStrut(4, 0),
                TXT_NewLabel("Path to patch files: "),
                TXT_NewStrut(4, 0),
                TXT_NewFileSelector(&gus_patch_path, 34,
                                    "Select directory containing GUS patches",
                                    TXT_DIRECTORY),
                NULL)),

        TXT_NewRadioButton("Native MIDI", &snd_musicdevice, SNDDEVICE_GENMIDI),
        TXT_NewConditional(&snd_musicdevice, SNDDEVICE_GENMIDI,
            TXT_MakeTable(2,
                TXT_NewStrut(4, 0),
                TXT_NewLabel("Timidity configuration file: "),
                TXT_NewStrut(4, 0),
                TXT_NewFileSelector(&timidity_cfg_path, 34,
                                    "Select Timidity config file",
                                    cfg_extension),
                NULL)),
        NULL);
}
Beispiel #8
0
void ConfigSound(void)
{
    txt_window_t *window;
    txt_table_t *extra_table;
    txt_dropdown_list_t *sfx_mode_control;
    txt_dropdown_list_t *music_mode_control;
    int num_sfx_modes, num_music_modes;

    // Work out what sfx mode we are currently using:

    if (snd_sfxdevice == SNDDEVICE_PCSPEAKER)
    {
        snd_sfxmode = SFXMODE_PCSPEAKER;
    }
    else if (snd_sfxdevice >= SNDDEVICE_SB)
    {
        snd_sfxmode = SFXMODE_DIGITAL;
    }
    else
    {
        snd_sfxmode = SFXMODE_DISABLED;
    }

    // Is music enabled?

    switch (snd_musicdevice)
    {
        case SNDDEVICE_GENMIDI:
            snd_musicmode = MUSICMODE_NATIVE;
            break;
        case SNDDEVICE_CD:
            snd_musicmode = MUSICMODE_CD;
            break;
        case SNDDEVICE_SB:
        case SNDDEVICE_ADLIB:
        case SNDDEVICE_AWE32:
            snd_musicmode = MUSICMODE_OPL;
            break;
        case SNDDEVICE_GUS:
            snd_musicmode = MUSICMODE_GUS;
            break;
        default:
            snd_musicmode = MUSICMODE_DISABLED;
            break;
    }

    // Doom has PC speaker sound effects, but others do not:

    if (gamemission == doom)
    {
        num_sfx_modes = NUM_SFXMODES;
    }
    else
    {
        num_sfx_modes = NUM_SFXMODES - 1;
    }

    // Hexen has CD audio; others do not.

    if (gamemission == hexen)
    {
        num_music_modes = NUM_MUSICMODES;
    }
    else
    {
        num_music_modes = NUM_MUSICMODES - 1;
    }

    // Build the window

    window = TXT_NewWindow("Sound configuration");
    TXT_SetWindowHelpURL(window, WINDOW_HELP_URL);
    TXT_SetTableColumns(window, 2);
    TXT_SetColumnWidths(window, 19, 15);

    TXT_SetWindowPosition(window, TXT_HORIZ_CENTER, TXT_VERT_TOP,
                                  TXT_SCREEN_W / 2, 5);

    TXT_AddWidgets(window,
                   TXT_NewSeparator("Sound effects"),
                   TXT_NewLabel("Sound effects"),
                   sfx_mode_control = TXT_NewDropdownList(&snd_sfxmode,
                                                          sfxmode_strings,
                                                          num_sfx_modes),
                   TXT_NewLabel("Sound channels"),
                   TXT_NewSpinControl(&numChannels, 1, 8),
                   TXT_NewLabel("SFX volume"),
                   TXT_NewSpinControl(&sfxVolume, 0, 15),
                   NULL);

    // Only show for games that implemented pitch shifting:
    if (gamemission == doom || gamemission == heretic || gamemission == hexen)
    {
        TXT_AddWidgets(window,
                       TXT_NewCheckBox("Pitch-shifted sounds",
                                       &snd_pitchshift),
                       TXT_TABLE_OVERFLOW_RIGHT,
                       NULL);
    }

    if (gamemission == strife)
    {
        TXT_AddWidgets(window,
                       TXT_NewLabel("Voice volume"),
                       TXT_NewSpinControl(&voiceVolume, 0, 15),
                       TXT_NewCheckBox("Show text with voices", &show_talk),
                       TXT_TABLE_OVERFLOW_RIGHT,
                       NULL);
    }

    TXT_AddWidgets(window,
                   TXT_NewSeparator("Music"),
                   TXT_NewLabel("Music"),
                   music_mode_control = TXT_NewDropdownList(&snd_musicmode,
                                                            musicmode_strings,
                                                            num_music_modes),
                   TXT_NewLabel("Music volume"),
                   TXT_NewSpinControl(&musicVolume, 0, 15),
                   extra_table = TXT_NewTable(2),
                   TXT_TABLE_OVERFLOW_RIGHT,
                   NULL);

    TXT_SetColumnWidths(extra_table, 19, 15);

    TXT_SignalConnect(sfx_mode_control, "changed", UpdateSndDevices, NULL);
    TXT_SignalConnect(music_mode_control, "changed", UpdateSndDevices, NULL);

    // Update extra_table when the music mode is changed, and build it now.
    TXT_SignalConnect(music_mode_control, "changed",
                      UpdateExtraTable, extra_table);
    UpdateExtraTable(music_mode_control, extra_table);
}