コード例 #1
0
ファイル: joystick.c プロジェクト: Lord-Ptolemy/strife-ve
static int CalibrationEventCallback(SDL_Event *event, void *user_data)
{
    if (event->type != SDL_JOYBUTTONDOWN)
    {
        return 0;
    }

    // At this point, we have a button press.
    // In the first "center" stage, we're just trying to work out which
    // joystick is being configured and which button the user is pressing.
    joystick_index = event->jbutton.which;
    calibrate_button = event->jbutton.button;

    // If the joystick is a known one, auto-load default
    // config for it. Otherwise, proceed with calibration.
    if (IsKnownJoystick(joystick_index))
    {
        LoadKnownConfiguration();
        usejoystick = 1;
        TXT_CloseWindow(calibration_window);
    }
    else
    {
        TXT_CloseWindow(calibration_window);

        // Calibrate joystick axes: Y axis first, then X axis once
        // completed.
        TXT_ConfigureJoystickAxis(y_axis_widget, calibrate_button,
                                  CalibrateXAxis);
    }

    return 1;
}
コード例 #2
0
ファイル: mode.c プロジェクト: Lord-Ptolemy/strife-ve
static void OpenGameSelectDialog(GameSelectCallback callback)
{
    mission_config_t *mission = NULL;
    txt_window_t *window;
    const iwad_t **iwads;
    int num_games;
    int i;

    window = TXT_NewWindow("Select game");

    TXT_AddWidget(window, TXT_NewLabel("Select a game to configure:\n"));
    num_games = 0;

    // Add a button for each game.

    for (i=0; i<arrlen(mission_configs); ++i)
    {
        // Do we have any IWADs for this game installed?
        // If so, add a button.

        iwads = D_FindAllIWADs(mission_configs[i].mask);

        if (iwads[0] != NULL)
        {
            mission = &mission_configs[i];
            TXT_AddWidget(window, TXT_NewButton2(mission_configs[i].label,
                                                 GameSelected,
                                                 &mission_configs[i]));
            ++num_games;
        }

        free(iwads);
    }

    TXT_AddWidget(window, TXT_NewStrut(0, 1));

    // No IWADs found at all?  Fall back to doom, then.

    if (num_games == 0)
    {
        TXT_CloseWindow(window);
        SetMission(DEFAULT_MISSION);
        callback();
        return;
    }

    // Only one game? Use that game, and don't bother with a dialog.

    if (num_games == 1)
    {
        TXT_CloseWindow(window);
        SetMission(mission);
        callback();
        return;
    }

    game_selected_callback = callback;
}
コード例 #3
0
ファイル: txt_keyinput.c プロジェクト: twipley/chocolate-doom
static int KeyPressCallback(txt_window_t *window, int key, 
                            TXT_UNCAST_ARG(key_input))
{
    TXT_CAST_ARG(txt_key_input_t, key_input);

    if (key != KEY_ESCAPE)
    {
        // Got the key press.  Save to the variable and close the window.

        *key_input->variable = key;

        if (key_input->check_conflicts)
        {
            TXT_EmitSignal(key_input, "set");
        }

        TXT_CloseWindow(window);

        // Re-enable key mappings now that we have the key

        TXT_EnableKeyMapping(1);

        return 1;
    }
    else
    {
        return 0;
    }
}
コード例 #4
0
static void VKBCycleCharsets(TXT_UNCAST_ARG(widget), void *userdata)
{
    TXT_CloseWindow(vkb_window);
    VKBCreateWindow(vkb_inputbox,
              (vkb_charset_index+1) %
              (sizeof(vkb_charset) / sizeof(vkb_charset[0])));
}
コード例 #5
0
static int EventCallback(SDL_Event *event, TXT_UNCAST_ARG(joystick_input))
{
    TXT_CAST_ARG(txt_joystick_input_t, joystick_input);

    // Got the joystick button press?

    if (event->type == SDL_JOYBUTTONDOWN)
    {
        int vbutton, physbutton;

        // Before changing anything, remap button configuration into
        // canonical form, to avoid conflicts.
        CanonicalizeButtons();

        vbutton = VirtualButtonForVariable(joystick_input->variable);
        physbutton = event->jbutton.button;

        if (joystick_input->check_conflicts)
        {
            ClearVariablesUsingButton(physbutton);
        }

        // Set mapping.
        *joystick_input->variable = vbutton;
        joystick_physical_buttons[vbutton] = physbutton;

        TXT_CloseWindow(joystick_input->prompt_window);
        return 1;
    }

    return 0;
}
コード例 #6
0
static void SelectQueryAddress(TXT_UNCAST_ARG(button),
                               TXT_UNCAST_ARG(querydata))
{
    TXT_CAST_ARG(txt_button_t, button);
    TXT_CAST_ARG(net_querydata_t, querydata);
    int i;

    if (querydata->server_state != 0)
    {
        TXT_MessageBox("Cannot connect to server",
                       "Gameplay is already in progress\n"
                       "on this server.");
        return;
    }

    // Set address to connect to:

    free(connect_address);
    connect_address = M_StringDuplicate(button->label);

    // Auto-choose IWAD if there is already a player connected.

    if (querydata->num_players > 0)
    {
        for (i = 0; found_iwads[i] != NULL; ++i)
        {
            if (found_iwads[i]->mode == querydata->gamemode
             && found_iwads[i]->mission == querydata->gamemission)
            {
                found_iwad_selected = i;
                iwadfile = found_iwads[i]->name;
                break;
            }
        }

        if (found_iwads[i] == NULL)
        {
            TXT_MessageBox(NULL,
                           "The game on this server seems to be:\n"
                           "\n"
                           "   %s\n"
                           "\n"
                           "but the IWAD file %s is not found!\n"
                           "Without the required IWAD file, it may not be\n"
                           "possible to join this game.",
                           D_SuggestGameName(querydata->gamemission,
                                             querydata->gamemode),
                           D_SuggestIWADName(querydata->gamemission,
                                             querydata->gamemode));
        }
    }

    // Finished with search.

    TXT_CloseWindow(query_window);
}
コード例 #7
0
ファイル: txt_dropdown.c プロジェクト: AlexMax/d2k
static int SelectorWindowListener(txt_window_t *window, int key, void *user_data)
{
    if (key == KEY_ESCAPE)
    {
        TXT_CloseWindow(window);
        return 1;
    }

    return 0;
}
コード例 #8
0
static void VKBCloseWindow(TXT_UNCAST_ARG(widget), int keep)
{
    if (keep)
    {
        FinishEditing(vkb_inputbox);
    }
    else
    {
        vkb_inputbox->editing = 0;
    }

    TXT_CloseWindow(vkb_window);
}
コード例 #9
0
ファイル: txt_dropdown.c プロジェクト: AlexMax/d2k
static void ItemSelected(TXT_UNCAST_ARG(button), TXT_UNCAST_ARG(callback_data))
{
    TXT_CAST_ARG(callback_data_t, callback_data);

    // Set the variable

    *callback_data->list->variable = callback_data->item;

    TXT_EmitSignal(callback_data->list, "changed");

    // Close the window

    TXT_CloseWindow(callback_data->window);
}
コード例 #10
0
static int EventCallback(SDL_Event *event, TXT_UNCAST_ARG(joystick_input))
{
    TXT_CAST_ARG(txt_joystick_input_t, joystick_input);

    // Got the joystick button press?

    if (event->type == SDL_JOYBUTTONDOWN)
    {
        *joystick_input->variable = event->jbutton.button;
        TXT_EmitSignal(joystick_input, "set");
        TXT_CloseWindow(joystick_input->prompt_window);
        return 1;
    }

    return 0;
}
コード例 #11
0
ファイル: txt_mouseinput.c プロジェクト: MP2E/chocolate-doom
static int MousePressCallback(txt_window_t *window, 
                              int x, int y, int b,
                              TXT_UNCAST_ARG(mouse_input))
{
    TXT_CAST_ARG(txt_mouse_input_t, mouse_input);

    // Got the mouse press.  Save to the variable and close the window.

    *mouse_input->variable = b - TXT_MOUSE_BASE;

    if (mouse_input->check_conflicts)
    {
        TXT_EmitSignal(mouse_input, "set");
    }

    TXT_CloseWindow(window);

    return 1;
}
コード例 #12
0
ファイル: execute.c プロジェクト: Nekrofage/DoomRPi
static void TestCallback(TXT_UNCAST_ARG(widget), TXT_UNCAST_ARG(data))
{
    execute_context_t *exec;
    char *main_cfg;
    char *extra_cfg;
    txt_window_t *testwindow;
    txt_label_t *label;
    
    testwindow = TXT_NewWindow("Starting Doom");

    label = TXT_NewLabel("Starting Doom to test the\n"
                         "settings.  Please wait.");
    TXT_SetWidgetAlign(label, TXT_HORIZ_CENTER);
    TXT_AddWidget(testwindow, label);
    TXT_DrawDesktop();

    // Save temporary configuration files with the current configuration

    main_cfg = TempFile("tmp.cfg");
    extra_cfg = TempFile("extratmp.cfg");

    M_SaveMainDefaults(main_cfg);
    M_SaveExtraDefaults(extra_cfg);

    // Run with the -testcontrols parameter

    exec = NewExecuteContext();
    AddCmdLineParameter(exec, "-testcontrols");
    AddCmdLineParameter(exec, "-config \"%s\"", main_cfg);
    AddCmdLineParameter(exec, "-extraconfig \"%s\"", extra_cfg);
    ExecuteDoom(exec);

    TXT_CloseWindow(testwindow);

    // Delete the temporary config files

    remove(main_cfg);
    remove(extra_cfg);
    free(main_cfg);
    free(extra_cfg);
}
コード例 #13
0
ファイル: execute.c プロジェクト: MP2E/chocolate-doom
static void TestCallback(TXT_UNCAST_ARG(widget), TXT_UNCAST_ARG(data))
{
    execute_context_t *exec;
    char *main_cfg;
    char *extra_cfg;
    txt_window_t *testwindow;

    testwindow = TXT_MessageBox("Starting Doom",
                                "Starting Doom to test the\n"
                                "settings.  Please wait.");
    TXT_DrawDesktop();

    // Save temporary configuration files with the current configuration

    main_cfg = TempFile("tmp.cfg");
    extra_cfg = TempFile("extratmp.cfg");

    M_SaveDefaultsAlternate(main_cfg, extra_cfg);

    // Run with the -testcontrols parameter

    exec = NewExecuteContext();
    AddCmdLineParameter(exec, "-testcontrols");
    AddCmdLineParameter(exec, "-config \"%s\"", main_cfg);
    AddCmdLineParameter(exec, "-extraconfig \"%s\"", extra_cfg);
    ExecuteDoom(exec);

    TXT_CloseWindow(testwindow);

    // Delete the temporary config files

    remove(main_cfg);
    remove(extra_cfg);
    free(main_cfg);
    free(extra_cfg);
}
コード例 #14
0
ファイル: joystick.c プロジェクト: RetroAsh/chocolate-doom
static int CalibrationEventCallback(SDL_Event *event, void *user_data)
{
    boolean advance;

    if (event->type != SDL_JOYBUTTONDOWN)
    {
        return 0;
    }

    // At this point, we have a button press.
    // In the first "center" stage, we're just trying to work out which
    // joystick is being configured and which button the user is pressing.
    if (calibrate_stage == CALIBRATE_CENTER)
    {
        joystick_index = event->jbutton.which;
        calibrate_button = event->jbutton.button;
        IdentifyBadAxes();

        // If the joystick is a known one, auto-load default
        // config for it.
        if (IsKnownJoystick(joystick_index))
        {
            LoadKnownConfiguration();
            usejoystick = 1;
            TXT_CloseWindow(calibration_window);
        }
        else
        {
            // Advance to next stage.
            calibrate_stage = CALIBRATE_LEFT;
            SetCalibrationLabel();
        }

        return 1;
    }

    // In subsequent stages, the user is asked to push in a specific
    // direction and press the button. They must push the same button
    // as they did before; this is necessary to support button axes.
    if (event->jbutton.which == joystick_index
     && event->jbutton.button == calibrate_button)
    {
        switch (calibrate_stage)
        {
            default:
            case CALIBRATE_LEFT:
                advance = CalibrateAxis(&joystick_x_axis, &joystick_x_invert);
                break;

            case CALIBRATE_RIGHT:
                advance = SetButtonAxisPositive(&joystick_x_axis);
                break;

            case CALIBRATE_UP:
                advance = CalibrateAxis(&joystick_y_axis, &joystick_y_invert);
                break;

            case CALIBRATE_DOWN:
                advance = SetButtonAxisPositive(&joystick_y_axis);
                break;
        }

        // Advance to the next calibration stage?

        if (advance)
        {
            calibrate_stage = NextCalibrateStage();
            SetCalibrationLabel();

            // Finished?
            if (calibrate_stage == CALIBRATE_CENTER)
            {
                usejoystick = 1;
                TXT_CloseWindow(calibration_window);
            }

            return 1;
        }
    }

    return 0;
}
コード例 #15
0
static void CloseLevelSelectDialog(TXT_UNCAST_ARG(button), TXT_UNCAST_ARG(window))
{
    TXT_CAST_ARG(txt_window_t, window);

    TXT_CloseWindow(window);            
}
コード例 #16
0
ファイル: txt_joyaxis.c プロジェクト: Azarien/chocolate-doom
static int EventCallback(SDL_Event *event, TXT_UNCAST_ARG(joystick_axis))
{
    TXT_CAST_ARG(txt_joystick_axis_t, joystick_axis);
    boolean advance;

    if (event->type != SDL_JOYBUTTONDOWN)
    {
        return 0;
    }

    // At this point, we have a button press.
    // In the first "center" stage, we're just trying to work out which
    // joystick is being configured and which button the user is pressing.
    if (joystick_axis->config_stage == CONFIG_CENTER)
    {
        joystick_axis->config_button = event->jbutton.button;
        IdentifyBadAxes(joystick_axis);

        // Advance to next stage.
        joystick_axis->config_stage = CONFIG_STAGE1;
        SetCalibrationLabel(joystick_axis);

        return 1;
    }

    // In subsequent stages, the user is asked to push in a specific
    // direction and press the button. They must push the same button
    // as they did before; this is necessary to support button axes.
    if (event->jbutton.which == SDL_JoystickInstanceID(joystick_axis->joystick)
     && event->jbutton.button == joystick_axis->config_button)
    {
        switch (joystick_axis->config_stage)
        {
            default:
            case CONFIG_STAGE1:
                advance = CalibrateAxis(joystick_axis);
                break;

            case CONFIG_STAGE2:
                advance = SetButtonAxisPositive(joystick_axis);
                break;
        }

        // Advance to the next calibration stage?

        if (advance)
        {
            joystick_axis->config_stage = NextCalibrateStage(joystick_axis);
            SetCalibrationLabel(joystick_axis);

            // Finished?
            if (joystick_axis->config_stage == CONFIG_CENTER)
            {
                TXT_CloseWindow(joystick_axis->config_window);

                if (joystick_axis->callback != NULL)
                {
                    joystick_axis->callback();
                }
            }

            return 1;
        }
    }

    return 0;
}
コード例 #17
0
static void WindowCloseCallback(TXT_UNCAST_ARG(widget), TXT_UNCAST_ARG(window))
{
    TXT_CAST_ARG(txt_window_t, window);

    TXT_CloseWindow(window);
}
コード例 #18
0
ファイル: guitest.c プロジェクト: RobbieJVMW/dockerdoom
void CloseWindow(TXT_UNCAST_ARG(button), void *user_data)
{
    TXT_CloseWindow(firstwin);
}
コード例 #19
0
ファイル: guitest.c プロジェクト: RobbieJVMW/dockerdoom
void ClosePwnBox(TXT_UNCAST_ARG(widget), TXT_UNCAST_ARG(window))
{
    TXT_CAST_ARG(txt_window_t, window);

    TXT_CloseWindow(window);
}