| 2656 | } |
| 2657 | |
| 2658 | int FindPilot() { |
| 2659 | |
| 2660 | int exit_menu = 0; |
| 2661 | const char *p; |
| 2662 | char message[MAX_CHAT_SEND_LEN]; |
| 2663 | char pilot_name[MAX_CHAT_SEND_LEN]; |
| 2664 | static char fmt_msg[MAX_CHAT_SEND_LEN * 2]; |
| 2665 | void *title_text = DLLCreateNewUITextItem(TXT_PXO_FINDPILOT, UICOL_WINDOW_TITLE); |
| 2666 | |
| 2667 | void *cancel_on_text = DLLCreateNewUITextItem(TXT_PXO_CANCEL, UICOL_HOTSPOT_HI); |
| 2668 | void *cancel_off_text = DLLCreateNewUITextItem(TXT_PXO_CANCEL, UICOL_HOTSPOT_LO); |
| 2669 | void *search_on_text = DLLCreateNewUITextItem(TXT_PXO_SEARCH, UICOL_HOTSPOT_HI); |
| 2670 | void *search_off_text = DLLCreateNewUITextItem(TXT_PXO_SEARCH, UICOL_HOTSPOT_LO); |
| 2671 | |
| 2672 | void *pilot_text = DLLCreateNewUITextItem(TXT_PXO_PILOTNAME, UICOL_TEXT_NORMAL); |
| 2673 | |
| 2674 | void *main_wnd = DLLNewUIGameWindowCreate(0, 0, 256, 256, UIF_PROCESS_ALL | UIF_CENTER | NUWF_TITLEMED); |
| 2675 | |
| 2676 | void *title_t = DLLTextCreate(main_wnd, title_text, 0, 7, UIF_CENTER); |
| 2677 | void *pilot_t = DLLTextCreate(main_wnd, pilot_text, 50, 95, UIF_CENTER); |
| 2678 | void *pilot_edit = DLLEditCreate(main_wnd, 3, 50, 115, 130, 15, UIF_CENTER); |
| 2679 | |
| 2680 | // DLLNewUIWindowSetFocusOnEditGadget(pilot_edit,main_wnd); |
| 2681 | // HotSpotCreate(int item,int parentitem, int id, int key, int txtitemoff, int txtitemon, int x, int y, int w, int h, |
| 2682 | // int flags,int winnum) |
| 2683 | void *cancel_hs = |
| 2684 | DLLHotSpotCreate(main_wnd, UID_CANCEL, KEY_ESC, cancel_on_text, cancel_off_text, 130, 256 - 80, 60, 20, 0); |
| 2685 | void *search_hs = |
| 2686 | DLLHotSpotCreate(main_wnd, UID_OK, KEY_ENTER, search_on_text, search_off_text, 60, 256 - 80, 60, 20, 0); |
| 2687 | DLLNewUIGameWindowOpen(main_wnd); |
| 2688 | while (!exit_menu) { |
| 2689 | int res; |
| 2690 | |
| 2691 | res = DLLDoUI(); |
| 2692 | |
| 2693 | // handle all UI results. |
| 2694 | |
| 2695 | switch (res) { |
| 2696 | case 3: |
| 2697 | case UID_OK: { |
| 2698 | DLLEditGetText(pilot_edit, pilot_name, MAX_CHAT_SEND_LEN); |
| 2699 | DLLCreateSplashScreen(TXT_PXO_SEARCHINGPILOT, 1); |
| 2700 | p = GetChannelByUser(pilot_name); |
| 2701 | while (p == nullptr) { |
| 2702 | int sres = DLLPollUI(); |
| 2703 | // Detect if cancel is hit |
| 2704 | if (sres == 99) { |
| 2705 | p = nullptr; |
| 2706 | // Cancel the lookup |
| 2707 | GetChannelByUser((char *)-1); |
| 2708 | break; |
| 2709 | } |
| 2710 | DLLDescentDefer(); |
| 2711 | p = GetChatText(); |
| 2712 | if (p && pconsole) { |
| 2713 | DLLUIConsoleGadgetputs(pconsole, p); |
| 2714 | DLLUIConsoleGadgetputs(pconsole, "\x0a\x0d"); |
| 2715 | } |
no test coverage detected