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); }
static void OpenPromptWindow(txt_joystick_input_t *joystick_input) { txt_window_t *window; SDL_Joystick *joystick; // Silently update when the shift button is held down. joystick_input->check_conflicts = !TXT_GetModifierState(TXT_MOD_SHIFT); if (SDL_Init(SDL_INIT_JOYSTICK) < 0) { return; } // Check the current joystick is valid joystick = SDL_JoystickOpen(joystick_index); if (joystick == NULL) { OpenErrorWindow(); return; } // Open the prompt window window = TXT_MessageBox(NULL, "Press the new button on the controller..."); TXT_SDL_SetEventCallback(EventCallback, joystick_input); TXT_SignalConnect(window, "closed", PromptWindowClosed, joystick); joystick_input->prompt_window = window; SDL_JoystickEventState(SDL_ENABLE); }
static void OpenMusicPackDir(TXT_UNCAST_ARG(widget), TXT_UNCAST_ARG(unused)) { if (!OpenFolder(music_pack_path)) { TXT_MessageBox("Error", "Failed to open music pack directory."); } }
void TXT_ConfigureJoystickAxis(txt_joystick_axis_t *joystick_axis, int using_button, txt_joystick_axis_callback_t callback) { // Open the joystick first. if (SDL_Init(SDL_INIT_JOYSTICK) < 0) { return; } joystick_axis->joystick = SDL_JoystickOpen(joystick_index); if (joystick_axis->joystick == NULL) { TXT_MessageBox(NULL, "Please configure a controller first!"); return; } SDL_JoystickEventState(SDL_ENABLE); // Build the prompt window. joystick_axis->config_window = TXT_NewWindow("Gamepad/Joystick calibration"); TXT_AddWidgets(joystick_axis->config_window, TXT_NewStrut(0, 1), joystick_axis->config_label = TXT_NewLabel(""), TXT_NewStrut(0, 1), NULL); TXT_SetWindowAction(joystick_axis->config_window, TXT_HORIZ_LEFT, NULL); TXT_SetWindowAction(joystick_axis->config_window, TXT_HORIZ_CENTER, TXT_NewWindowAbortAction(joystick_axis->config_window)); TXT_SetWindowAction(joystick_axis->config_window, TXT_HORIZ_RIGHT, NULL); TXT_SetWidgetAlign(joystick_axis->config_window, TXT_HORIZ_CENTER); if (using_button >= 0) { joystick_axis->config_stage = CONFIG_STAGE1; joystick_axis->config_button = using_button; IdentifyBadAxes(joystick_axis); } else { joystick_axis->config_stage = CONFIG_CENTER; } SetCalibrationLabel(joystick_axis); // Close the joystick and shut down joystick subsystem when the window // is closed. TXT_SignalConnect(joystick_axis->config_window, "closed", CalibrateWindowClosed, joystick_axis); TXT_SDL_SetEventCallback(EventCallback, joystick_axis); // When successfully calibrated, invoke this callback: joystick_axis->callback = callback; }
static void NoJoystick(void) { TXT_MessageBox(NULL, "No joysticks or gamepads could be found.\n\n" "Try configuring your controller from within\n" "your OS first. Maybe you need to install\n" "some drivers or otherwise configure it."); joystick_index = -1; SetJoystickButtonLabel(); }
static void OpenPromptWindow(txt_mouse_input_t *mouse_input) { txt_window_t *window; // Silently update when the shift key is held down. mouse_input->check_conflicts = !TXT_GetModifierState(TXT_MOD_SHIFT); window = TXT_MessageBox(NULL, "Press the new mouse button..."); TXT_SetMouseListener(window, MousePressCallback, mouse_input); }
static int MainMenuKeyPress(txt_window_t *window, int key, void *user_data) { if (key == cheat_sequence[cheat_sequence_index]) { ++cheat_sequence_index; if (cheat_sequence[cheat_sequence_index] == 0) { SensibleDefaults(); cheat_sequence_index = 0; window = TXT_MessageBox(NULL, " \x01 "); return 1; } } else { cheat_sequence_index = 0; } return 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); }
static void DoJoinGame(void *unused1, void *unused2) { execute_context_t *exec; if (connect_address == NULL || strlen(connect_address) <= 0) { TXT_MessageBox(NULL, "Please enter a server address\n" "to connect to."); return; } exec = NewExecuteContext(); AddCmdLineParameter(exec, "-connect %s", connect_address); if (gamemission == hexen) { AddCmdLineParameter(exec, "-class %i", character_class); } // Extra parameters come first, so that they can be used to override // the other parameters. AddExtraParameters(exec); AddIWADParameter(exec); AddWADs(exec); TXT_Shutdown(); M_SaveDefaults(); PassThroughArguments(exec); ExecuteDoom(exec); exit(0); }
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); }
static void OpenErrorWindow(void) { TXT_MessageBox(NULL, "Please configure a controller first!"); }
static void OpenErrorWindow(void) { TXT_MessageBox(NULL, "Please configure a joystick first!"); }