Esempio n. 1
0
static void OpenPromptWindow(txt_key_input_t *key_input)
{
    txt_window_t *window;
    txt_label_t *label;

    // Silently update when the shift button is held down.

    key_input->check_conflicts = !TXT_GetModifierState(TXT_MOD_SHIFT);

    window = TXT_NewWindow(NULL);
    TXT_SetWindowAction(window, TXT_HORIZ_LEFT, NULL);
    TXT_SetWindowAction(window, TXT_HORIZ_CENTER, 
                        TXT_NewWindowAbortAction(window));
    TXT_SetWindowAction(window, TXT_HORIZ_RIGHT, NULL);
    
    label = TXT_NewLabel("Press the new key...");

    TXT_AddWidget(window, label);
    TXT_SetWidgetAlign(label, TXT_HORIZ_CENTER);

    TXT_SetKeyListener(window, KeyPressCallback, key_input);

    // Disable key mappings while we prompt for the key press

    TXT_EnableKeyMapping(0);

    // Grab input while reading the key.  On Windows Mobile
    // handheld devices, the hardware keypresses are only
    // detected when input is grabbed.

    SDL_WM_GrabInput(SDL_GRAB_ON);
    TXT_SignalConnect(window, "closed", ReleaseGrab, NULL);
}
Esempio n. 2
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);
}
Esempio n. 3
0
void MainMenu(void)
{
    txt_window_t *window;
    txt_window_action_t *quit_action;
    txt_window_action_t *warp_action;

    window = TXT_NewWindow("Main Menu");

    TXT_SetWindowHelpURL(window, WINDOW_HELP_URL);

    TXT_AddWidgets(window,
          TXT_NewButton2("Configure Display",
                         (TxtWidgetSignalFunc) ConfigDisplay, NULL),
          TXT_NewButton2("Configure Sound",
                         (TxtWidgetSignalFunc) ConfigSound, NULL),
          TXT_NewButton2("Configure Keyboard",
                         (TxtWidgetSignalFunc) ConfigKeyboard, NULL),
          TXT_NewButton2("Configure Mouse",
                         (TxtWidgetSignalFunc) ConfigMouse, NULL),
          TXT_NewButton2("Configure Gamepad/Joystick",
                         (TxtWidgetSignalFunc) ConfigJoystick, NULL),
          NULL);

    // The compatibility window is only appropriate for Doom/Strife.

    if (gamemission == doom || gamemission == strife)
    {
        txt_button_t *button;

        button = TXT_NewButton2("Compatibility", 
                                (TxtWidgetSignalFunc) CompatibilitySettings,
                                NULL);

        TXT_AddWidget(window, button);
    }

    TXT_AddWidgets(window,
          GetLaunchButton(),
          TXT_NewStrut(0, 1),
          TXT_NewButton2("Start a Network Game", 
                         (TxtWidgetSignalFunc) StartMultiGame, NULL),
          TXT_NewButton2("Join a Network Game", 
                         (TxtWidgetSignalFunc) JoinMultiGame, NULL),
          TXT_NewButton2("Multiplayer Configuration", 
                         (TxtWidgetSignalFunc) MultiplayerConfig, NULL),
          NULL);

    quit_action = TXT_NewWindowAction(KEY_ESCAPE, "Quit");
    warp_action = TXT_NewWindowAction(KEY_F2, "Warp");
    TXT_SignalConnect(quit_action, "pressed", QuitConfirm, NULL);
    TXT_SignalConnect(warp_action, "pressed",
                      (TxtWidgetSignalFunc) WarpMenu, NULL);
    TXT_SetWindowAction(window, TXT_HORIZ_LEFT, quit_action);
    TXT_SetWindowAction(window, TXT_HORIZ_CENTER, warp_action);

    TXT_SetKeyListener(window, MainMenuKeyPress, NULL);
}
Esempio n. 4
0
static void OpenPromptWindow(txt_key_input_t *key_input)
{
    txt_window_t *window;

    // Silently update when the shift button is held down.

    key_input->check_conflicts = !TXT_GetModifierState(TXT_MOD_SHIFT);

    window = TXT_MessageBox(NULL, "Press the new key...");

    TXT_SetKeyListener(window, KeyPressCallback, key_input);

    // Disable key mappings while we prompt for the key press

    TXT_EnableKeyMapping(0);

    // Grab input while reading the key.  On Windows Mobile
    // handheld devices, the hardware keypresses are only
    // detected when input is grabbed.

    SDL_WM_GrabInput(SDL_GRAB_ON);
    TXT_SignalConnect(window, "closed", ReleaseGrab, NULL);
}