ask player for character's name to replace generic name "player" (or other values; see config.h) after 'nethack -u player' or OPTIONS=name:player */
| 1850 | /* ask player for character's name to replace generic name "player" (or other |
| 1851 | values; see config.h) after 'nethack -u player' or OPTIONS=name:player */ |
| 1852 | void |
| 1853 | X11_askname(void) |
| 1854 | { |
| 1855 | Widget popup, dialog; |
| 1856 | Arg args[1]; |
| 1857 | |
| 1858 | #ifdef SELECTSAVED |
| 1859 | if (iflags.wc2_selectsaved && !iflags.renameinprogress) |
| 1860 | switch (restore_menu(WIN_MAP)) { |
| 1861 | case -1: /* quit */ |
| 1862 | X11_bail("Until next time then..."); |
| 1863 | /*NOTREACHED*/ |
| 1864 | case 0: /* no game chosen; start new game */ |
| 1865 | break; |
| 1866 | case 1: /* save game selected, plname[] has been set */ |
| 1867 | return; |
| 1868 | } |
| 1869 | #else |
| 1870 | nhUse(X11_bail); |
| 1871 | #endif /* SELECTSAVED */ |
| 1872 | |
| 1873 | if (iflags.wc_player_selection == VIA_DIALOG) { |
| 1874 | /* X11_player_selection_dialog() handles name query */ |
| 1875 | plsel_ask_name = TRUE; |
| 1876 | iflags.defer_plname = TRUE; |
| 1877 | return; |
| 1878 | } /* else iflags.wc_player_selection == VIA_PROMPTS */ |
| 1879 | |
| 1880 | XtSetArg(args[0], XtNallowShellResize, True); |
| 1881 | |
| 1882 | popup = XtCreatePopupShell("askname", transientShellWidgetClass, toplevel, |
| 1883 | args, ONE); |
| 1884 | XtOverrideTranslations(popup, |
| 1885 | XtParseTranslationTable("<Message>WM_PROTOCOLS: askname_delete()")); |
| 1886 | |
| 1887 | dialog = CreateDialog(popup, nhStr("dialog"), askname_done, |
| 1888 | (XtCallbackProc) 0); |
| 1889 | |
| 1890 | SetDialogPrompt(dialog, nhStr("What is your name?")); /* set prompt */ |
| 1891 | SetDialogResponse(dialog, svp.plname, PL_NSIZ); /* set default answer */ |
| 1892 | |
| 1893 | XtRealizeWidget(popup); |
| 1894 | positionpopup(popup, TRUE); /* center,bottom */ |
| 1895 | |
| 1896 | nh_XtPopup(popup, (int) XtGrabExclusive, dialog); |
| 1897 | |
| 1898 | /* The callback will enable the event loop exit. */ |
| 1899 | (void) x_event(EXIT_ON_EXIT); |
| 1900 | |
| 1901 | /* tty's character selection uses this; we might someday; |
| 1902 | since we let user pick an arbitrary name now, he/she can |
| 1903 | pick another one during role selection */ |
| 1904 | iflags.renameallowed = TRUE; |
| 1905 | |
| 1906 | XtDestroyWidget(dialog); |
| 1907 | XtDestroyWidget(popup); |
| 1908 | } |
| 1909 |
nothing calls this directly
no test coverage detected