void menu_activate(struct menu *menu) { if (menu->child) return menu_activate(menu->child); if (menu->selector && menu->selector->activate_proc) menu->selector->activate_proc(menu->selector); }
void startup_load() { load_file(); if (in_startup_mode == false) { end_startup(); post_load(); } else { menu_activate(0); draw_startup(0); } }
int main(int argc, char* argv[]) { #if 0 void debug_oldstructs(); debug_oldstructs(); #endif try{ init_boe(argc, argv); if(!get_bool_pref("GameRunBefore")) cChoiceDlog("welcome").show(); else if(get_bool_pref("GiveIntroHint", true)) tip_of_day(); set_pref("GameRunBefore", true); finished_init = true; if(ae_loading) { finish_load_party(); post_load(); } menu_activate(); restore_cursor(); while(!All_Done) Handle_One_Event(); close_program(); return 0; } catch(std::exception& x) { showFatalError(x.what()); throw; } catch(std::string& x) { showFatalError(x); throw; } catch(...) { showFatalError("An unknown error occurred!"); throw; } }
void ui_poll(void) { uint8_t event = get_event(); if (event == EV_NONE) return; switch (event) { case EV_ENCODER_CW: menu_button_forward(); break; case EV_ENCODER_CCW: menu_button_back(); break; case EV_ENCODER_PUSH: menu_activate(); break; case EV_SMAUL_PUSH: menu_button_smaul(); break; case EV_TICK: key_timer(); count_ui_timer(); smaul_pulse_update(); break; case EV_KEY_CHANGE: key_change(); break; } if (event != EV_TICK && event != EV_KEY_CHANGE) { enable_lcd_backlight(); reset_ui_timer(); } ui_repaint(); }
// TODO: Pass the event object around instead of keeping a global one void Mouse_Pressed() { if(had_text_freeze > 0) { had_text_freeze--; return; } if(overall_mode != MODE_STARTUP) { location mousePos(event.mouseButton.x, event.mouseButton.y); volatile bool doneScrolling = false; if(mousePos.in(text_sbar->getBounds())) { mainPtr.setActive(false); boost::thread updater(std::bind(handleUpdateWhileScrolling, std::ref(doneScrolling), REFRESH_TRANS)); text_sbar->handleClick(mousePos); doneScrolling = true; updater.join(); redraw_screen(REFRESH_TRANS); } else if(mousePos.in(item_sbar->getBounds())) { mainPtr.setActive(false); boost::thread updater(std::bind(handleUpdateWhileScrolling, std::ref(doneScrolling), REFRESH_INVEN)); item_sbar->handleClick(mousePos); doneScrolling = true; updater.join(); redraw_screen(REFRESH_INVEN); } else if(overall_mode == MODE_SHOPPING && mousePos.in(shop_sbar->getBounds())) { mainPtr.setActive(false); boost::thread updater(std::bind(handleUpdateWhileScrolling, std::ref(doneScrolling), REFRESH_DLOG)); shop_sbar->handleClick(mousePos); doneScrolling = true; updater.join(); redraw_screen(REFRESH_DLOG); } else All_Done = handle_action(event); } else All_Done = handle_startup_press({event.mouseButton.x, event.mouseButton.y}); menu_activate(); }
void handle_menu_choice(eMenu item_hit) { std::string dialogToShow; sf::Event dummyEvent = {sf::Event::KeyPressed}; short i, choice; switch(item_hit) { case eMenu::NONE: break; case eMenu::FILE_OPEN: do_load(); break; case eMenu::FILE_SAVE: do_save(0); break; case eMenu::FILE_SAVE_AS: do_save(1); break; case eMenu::FILE_NEW: if(overall_mode != MODE_STARTUP) { std::string choice = cChoiceDlog("restart-game",{"okay","cancel"}).show(); if(choice == "cancel") return; for(i = 0; i < 6; i++) univ.party[i].main_status = eMainStatus::ABSENT; party_in_memory = false; reload_startup(); overall_mode = MODE_STARTUP; draw_startup(0); } start_new_game(); draw_startup(0); menu_activate(); break; case eMenu::FILE_ABORT: if(overall_mode != MODE_STARTUP) { std::string choice = cChoiceDlog("abort-game",{"okay","cancel"}).show(); if (choice=="cancel") return; reload_startup(); overall_mode = MODE_STARTUP; } party_in_memory = false; draw_startup(0); menu_activate(); break; case eMenu::PREFS: pick_preferences(); break; case eMenu::QUIT: if(overall_mode == MODE_STARTUP) { if(party_in_memory) { std::string choice = cChoiceDlog("quit-confirm-save", {"save","quit","cancel"}).show(); if(choice == "cancel") break; if(choice == "save") { fs::path file = nav_put_party(); if(!file.empty()) break; save_party(file, univ); } } All_Done = true; break; } if(overall_mode > MODE_TOWN) { std::string choice = cChoiceDlog("quit-confirm-nosave",{"quit","cancel"}).show(); if(choice == "cancel") return; } else { std::string choice = cChoiceDlog("quit-confirm-save",{"quit","save","cancel"}).show(); if(choice == "cancel") break; if(choice == "save") { if(univ.file.empty()) { univ.file = nav_put_party(); if(univ.file.empty()) break; } save_party(univ.file, univ); } } All_Done = true; break; case eMenu::OPTIONS_PC_GRAPHIC: choice = char_select_pc(1,"New graphic for who?"); if(choice < 6) pick_pc_graphic(choice,1,nullptr); draw_terrain(); break; case eMenu::OPTIONS_DELETE_PC: if(!prime_time()) { ASB("Finish what you're doing first."); print_buf(); } else { choice = char_select_pc(1,"Delete who?"); if(choice < 6) { std::string confirm = cChoiceDlog("delete-pc-confirm",{"yes","no"}).show(); if(confirm == "yes") kill_pc(univ.party[choice],eMainStatus::ABSENT); } draw_terrain(); } break; case eMenu::OPTIONS_RENAME_PC: choice = char_select_pc(1,"Rename who?"); if(choice < 6) pick_pc_name(choice,nullptr); put_pc_screen(); put_item_screen(stat_window); break; case eMenu::OPTIONS_NEW_PC: if(!(is_town())) { add_string_to_buf("Add PC: Town mode only."); print_buf(); break; } for(i = 0; i < 6; i++) if(univ.party[i].main_status == eMainStatus::ABSENT) i = 20; if(i == 6) { ASB("Add PC: You already have 6 PCs."); print_buf(); break; } if(univ.town->has_tavern) { give_help(56,0); create_pc(6,nullptr); } else { add_string_to_buf("Add PC: You cannot add new characters in this town. Try in the town you started in.", 2); } print_buf(); put_pc_screen(); put_item_screen(stat_window); break; case eMenu::OPTIONS_JOURNAL: journal(); break; case eMenu::OPTIONS_TALK_NOTES: if(overall_mode == MODE_TALKING) { ASB("Talking notes: Can't read while talking."); print_buf(); return; } talk_notes(); break; case eMenu::OPTIONS_ENCOUNTER_NOTES: adventure_notes(); break; case eMenu::OPTIONS_STATS: if(overall_mode != MODE_STARTUP) print_party_stats(); break; case eMenu::HELP_OUT: dialogToShow = "help-outdoor"; break; case eMenu::HELP_TOWN: dialogToShow = "help-town"; break; case eMenu::HELP_COMBAT: dialogToShow = "help-combat"; break; case eMenu::HELP_BARRIER: dialogToShow = "help-fields"; break; case eMenu::HELP_HINTS: dialogToShow = "help-hints"; break; case eMenu::HELP_SPELLS: dialogToShow = "help-magic"; break; case eMenu::ABOUT: dialogToShow = "about-boe"; break; case eMenu::LIBRARY_MAGE: display_spells(eSkill::MAGE_SPELLS,100,0); break; case eMenu::LIBRARY_PRIEST: display_spells(eSkill::PRIEST_SPELLS,100,0); break; case eMenu::LIBRARY_SKILLS: display_skills(eSkill::INVALID,0); break; case eMenu::LIBRARY_ALCHEMY: // TODO: Create a dedicated dialog for alchemy info display_alchemy(); break; case eMenu::LIBRARY_TIPS: tip_of_day(); break; case eMenu::LIBRARY_INTRO: dialogToShow = "welcome"; break; case eMenu::ACTIONS_ALCHEMY: dummyEvent.key.code = sf::Keyboard::A; dummyEvent.key.shift = true; handle_keystroke(dummyEvent); break; case eMenu::ACTIONS_WAIT: dummyEvent.key.code = sf::Keyboard::W; handle_keystroke(dummyEvent); break; case eMenu::ACTIONS_AUTOMAP: if(!prime_time()) { ASB("Finish what you're doing first."); print_buf(); } else { give_help(62,0); display_map(); } make_cursor_sword(); break; case eMenu::HELP_TOC: if(fs::is_directory(progDir/"doc")) launchURL("file://" + (progDir/"doc/game/Contents.html").string()); else launchURL("https://blades.calref.net/doc/game/Contents.html"); break; case eMenu::ABOUT_MAGE: case eMenu::ABOUT_PRIEST: give_help(209,0); break; case eMenu::ABOUT_MONSTERS: give_help(212,0); break; } if(!dialogToShow.empty()) { cChoiceDlog dlog(dialogToShow); dlog.show(); } }
Boolean handle_menu (short item, HMENU) { short choice,i; POINT x = {1001,0},pass_point; Boolean to_return = false; switch (item) { case 1: // File Menu if (in_startup_mode == true) startup_load(); else do_load(); break; case 2: do_save(0); break; case 3: if (in_startup_mode == true) save_file(1); else do_save(1); break; case 4: if (in_startup_mode == false) { choice = FCD(1091,0); if (choice == 1) return false; for (i = 0; i < 6; i++) adven[i].main_status = MAIN_STATUS_ABSENT; party_in_memory = false; reload_startup(); in_startup_mode = true; draw_startup(0); } start_new_game(); draw_startup(0); break; case 6: pick_preferences(); break; case 7: pick_compatibility(); break; case 8: // Quit if (in_startup_mode == true) { to_return = All_Done = true; break; } if (overall_mode > MODE_TOWN) { choice = FCD(1067,0); if (choice == 1) return All_Done; } else { choice = FCD(1066,0); if (choice == 3) break; if (choice == 1) save_file(0); } to_return = All_Done = true; break; // Options menu case 21: choice = char_select_pc(0,0,"New graphic for who?"); if (choice < 6) pick_pc_graphic(choice,1,0); initiate_redraw(); break; case 22: choice = select_pc(0,0); if (choice < 6) pick_pc_name(choice,0); put_pc_screen(); put_item_screen(stat_window,0); break; case 23: if (!(is_town())) { add_string_to_buf("Add PC: Town mode only."); print_buf(); break; } for (i = 0; i < NUM_OF_PCS; i++) if (adven[i].main_status == MAIN_STATUS_ABSENT) i = 20; if (i == INVALID_PC) { ASB("Add PC: You already have 6 PCs."); print_buf(); } if (c_town.town_num == scenario.which_town_start) { give_help(56,0,0); create_pc(6,0); } else { add_string_to_buf("Add PC: You can only make new"); add_string_to_buf(" characters in the town you "); add_string_to_buf(" started in."); } print_buf(); put_pc_screen(); put_item_screen(stat_window,0); break; case 24: if (prime_time() == false) { ASB("Finish what you're doing first."); print_buf(); } else { choice = char_select_pc(0,0,"Delete who?"); if (choice < 6) { if ((i = FCD(1053,0)) == 2) adven[choice].kill(0); } initiate_redraw(); } break; case 27: if (overall_mode == MODE_TALKING) { ASB("Talking notes: Can't read while talking."); print_buf(); return to_return; } talk_notes(); break; case 28: adventure_notes(); break; case 29: if (in_startup_mode == false) print_party_stats(); break; // Help menu case 41: FCD(1079,0); break; case 42: FCD(1080,0); break; case 43: FCD(1081,0); break; case 44: FCD(1072,0); break; // magic barriers case 46: FCD(1084,0); break; case 47: FCD(1088,0); break; // Library case 61: display_spells(0,100,0); break; case 62: display_spells(1,100,0); break; case 63: display_skills(100,0); break; case 64: display_help(0,0); break; case 65: tip_of_day(); break; case 67: FCD(986,0); break; // Actions case 81: if (overall_mode != MODE_TOWN) { ASB("Alchemy: In town mode only."); print_buf(); break; } pass_point.x = 1000; pass_point.y = 405; to_return = handle_action(pass_point,(WPARAM) 0,(LPARAM)-1); break; case 82: to_return = handle_action(x,(WPARAM) 0,(LPARAM)-1); break; case 84: if (prime_time() == false) { ASB("Finish what you're doing first."); print_buf(); } else { give_help(62,0,0); display_map(); } SetCursor(sword_curs); break; // Mage is 399 case 399: give_help(209,0,0); party.help_received[9] = false; break; // Priest is 499 case 499: give_help(209,0,0); party.help_received[9] = false; break; // Monsters is 599 case 599: give_help(212,0,0); break; case 100: // Index WinHelp(mainPtr,"Blades of Exile.hlp",HELP_CONTENTS,0L); break; case 200: // About FCD(1062,0); break; default: if ((item >= 400) && (item < 500)) { // mage spell if (prime_time() == false) { ASB("Finish what you're doing first."); print_buf(); } else handle_menu_spell(item - 400,0); break; } if ((item >= 500) && (item < 600)) { // priest spell if (prime_time() == false) { ASB("Finish what you're doing first."); print_buf(); } else handle_menu_spell(item - 500,1); break; } if ((item >= 600) && (item < 700)) { // monster spell display_monst(item - 600,(creature_data_type *) NULL,1); break; } break; } if (in_startup_mode == true) menu_activate(0); else menu_activate(1); return to_return; }
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR, int nCmdShow) { MSG msg; WNDCLASS wndclass, wndclass2; RECT windRECT; HINSTANCE boeSoundsDLL; wndclass.style = CS_HREDRAW | CS_VREDRAW | CS_BYTEALIGNWINDOW; wndclass.lpfnWndProc = WndProc; wndclass.cbClsExtra = 0; wndclass.cbWndExtra = 0; wndclass.hInstance = hInstance; wndclass.hIcon = LoadIcon(hInstance,MAKEINTRESOURCE(10)); wndclass.hCursor = NULL; wndclass.hbrBackground = (HBRUSH) GetStockObject(WHITE_BRUSH); wndclass.lpszMenuName = MAKEINTRESOURCE(1); wndclass.lpszClassName = szAppName; RegisterClass(&wndclass); wndclass2.style = CS_HREDRAW | CS_VREDRAW | CS_BYTEALIGNWINDOW; wndclass2.lpfnWndProc = WndProc; wndclass2.cbClsExtra = 0; wndclass2.cbWndExtra = 0; wndclass2.hInstance = hInstance; wndclass2.hIcon = LoadIcon(hInstance,MAKEINTRESOURCE(10)); wndclass2.hCursor = NULL; wndclass2.hbrBackground = (HBRUSH) GetStockObject(WHITE_BRUSH); wndclass2.lpszMenuName = NULL; wndclass2.lpszClassName = szWinName; RegisterClass(&wndclass2); mainPtr = CreateWindow (szAppName, "Classic Blades of Exile", WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN, 0, 0, 588, 478, NULL, NULL, hInstance, NULL); if (!hPrevInstance) { // initialize Get_Path(file_path_name); store_hInstance = hInstance; accel = LoadAccelerators(hInstance, MAKEINTRESOURCE(1)); boeSoundsDLL = LoadLibrary("./boesounds.dll"); if (!boeSoundsDLL) { MessageBox(mainPtr, "BOESOUNDS.DLL not found", "Error", MB_OK | MB_ICONEXCLAMATION); return (-1); } load_sounds(boeSoundsDLL); loadFonts(); loadCursors(); SetCursor(sword_curs); current_cursor = 124; /* cursors loaded */ data_store = new piles_of_stuff_dumping_type; data_store3 = new piles_of_stuff_dumping_type3; data_store4 = new piles_of_stuff_dumping_type4; data_store5 = new piles_of_stuff_dumping_type5; scen_item_list = new scen_item_data_type; srand(GetCurrentTime()); get_reg_data(); if (display_mode != 5) max_window(mainPtr); else { GetWindowRect(GetDesktopWindow(),&windRECT); MoveWindow(mainPtr,(windRECT.right - (588 + 10)) / 2, (windRECT.bottom - (425 + 52)) / 2 , 588 + 10,425 + 52,true); } shop_sbar = CreateWindow("scrollbar",NULL, WS_CHILD | WS_TABSTOP | SBS_VERT, shop_sbar_rect.left,shop_sbar_rect.top,shop_sbar_rect.right,shop_sbar_rect.bottom, mainPtr,(HMENU) 3, store_hInstance,NULL); lpsi.fMask = SIF_RANGE; lpsi.nMax = 16; SetScrollInfo(shop_sbar,SB_CTL,&lpsi,false); // SetScrollRange(shop_sbar,SB_CTL,0,16,false); ShowWindow(mainPtr, nCmdShow); plop_fancy_startup(); init_screen_locs(); FlushEvents(2); SetTimer(mainPtr,1,620,NULL); SetTimer(mainPtr,2,200,NULL); file_initialize(); if (GetDeviceCaps(main_dc,BITSPIXEL) * GetDeviceCaps(main_dc,PLANES) < 8) { MessageBox(mainPtr,"Blades of Exile is designed for 256 colors. The current graphics device is set for less. Exile 3 is playable with less colors, but will look somewhat odd." , "Not 256 colors!",MB_OK | MB_ICONEXCLAMATION); MessageBox(mainPtr,"For tips on how to get 256 colors, hit F1 for help, and then select 'Getting 256 Colors' from the table of contents." , "Not 256 colors!",MB_OK | MB_ICONEXCLAMATION); } menu_activate(0); cursor_stay(); showcursor(true); reset_text_bar(); adjust_window_mode(); cd_init_dialogs(); if (game_run_before == false) { FCD(986,0); WritePrivateProfileString("Blades of Exile", "game_run_before", "1", "./blades.ini"); } else if (give_intro_hint == true) tip_of_day(); } event_handled = false; while(GetMessage(&msg,NULL,0,0)) { if (event_handled == false) { if (!TranslateAccelerator(mainPtr, accel, &msg)) { TranslateMessage(&msg); DispatchMessage(&msg); } } } delete scen_item_list; delete data_store5; delete data_store4; delete data_store3; if(data_store2 != NULL) delete[] data_store2; if(scen_headers != NULL) delete[] scen_headers; delete data_store; lose_graphics(); FreeLibrary((HMODULE) boeSoundsDLL); return msg.wParam; }
int init (int argc, char *argv[]) { char *p; int rc = 0, oldmode, i; url_t u; int x0=-1, y0=-1, r=-1, c=-1; struct hostent *remote; char buffer[MAX_PATH]; if (action == ACTION_TESTONLY) exit (0); if (action == ACTION_BADARGS) { usage (); exit (1); } if (options.keep_winsize) { r = cfg_get_integer (CONFIG_NFTP, fl_opt.platform_nick, "rows"); c = cfg_get_integer (CONFIG_NFTP, fl_opt.platform_nick, "cols"); if (r == 0 && c == 0) r = -1, c = -1; } if (options.keep_winpos) { x0 = cfg_get_integer (CONFIG_NFTP, fl_opt.platform_nick, "x0"); y0 = cfg_get_integer (CONFIG_NFTP, fl_opt.platform_nick, "y0"); if (x0 == 0 || y0 == 0) x0 = -1, y0 = -1; } p = cfg_get_string (CONFIG_NFTP, fl_opt.platform_nick, "font"); if (p[0] == '\0') p = NULL; fly_init (x0, y0, r, c, p); fly_mouse (options.mouse); wintitle = get_window_name (); if (fl_opt.platform == PLATFORM_OS2_VIO) { strcpy (buffer, paths.system_libpath); str_cats (buffer, "nftp.ico"); if (access (buffer, R_OK) == 0) set_icon (buffer); } if (main_menu != NULL) { menu_activate (main_menu); } display.rshift = 0; display.lshift = 0; display.tabsize = 8; display.view[V_LEFT] = -1; display.view[V_RIGHT] = -1; display.cursor = V_LEFT; display.parsed = TRUE; for (i=0; i<MAX_SITE; i++) { site[i].set_up = FALSE; site[i].CC.na = 0; site[i].CC.n = 0; } // ignore "broken PIPE" signals signal (SIGPIPE, SIG_IGN); set_window_name ("NFTP%s(C) Copyright Sergey Ayukov", NFTP_VERSION); lcache.lda = 0; lcache.ld = 0; lcache.L = NULL; local[V_LEFT].dir.name = NULL; local[V_LEFT].dir.files = NULL; local[V_LEFT].dir.nfiles = 0; local[V_LEFT].sortmode = abs (options.default_localsort); if (options.default_localsort >= 0) local[V_LEFT].sortdirection = 1; else local[V_LEFT].sortdirection = -1; l_chdir (V_LEFT, NULL); local[V_RIGHT].dir.name = NULL; local[V_RIGHT].dir.files = NULL; local[V_RIGHT].dir.nfiles = 0; local[V_RIGHT].sortmode = abs (options.default_localsort); if (options.default_localsort >= 0) local[V_RIGHT].sortdirection = 1; else local[V_RIGHT].sortdirection = -1; l_chdir (V_RIGHT, NULL); PutLineIntoResp (RT_COMM, 0, "NFTP Version%s(%s, %s) -- %s", NFTP_VERSION, __DATE__, __TIME__, fl_opt.platform_name); PutLineIntoResp (RT_RESP, 0, "Copyright (C) 1994--2000 Sergey Ayukov <*****@*****.**>"); PutLineIntoResp (RT_RESP, 0, "Portions Copyright (C) Eric Young <*****@*****.**>"); status.usage_interval = 0; if (!fl_opt.has_osmenu) PutLineIntoResp (RT_RESP, 0, MSG(M_RESP_F9_FOR_MENU)); update (1); if (options.firewall_type != 0) { if (options.fire_server[0] == '\0') { fly_ask_ok (ASK_WARN, MSG(M_PROXY_ISNT_SPECIFIED)); options.firewall_type = 0; } else { if (strspn (options.fire_server, " .0123456789") == strlen (options.fire_server)) { firewall.fwip = inet_addr (options.fire_server); } else { PutLineIntoResp (RT_COMM, 0, MSG(M_RESP_LOOKING_UP), options.fire_server); remote = gethostbyname (options.fire_server); if (remote == NULL) { PutLineIntoResp (RT_COMM, 0, MSG(M_RESP_CANNOT_RESOLVE), options.fire_server); options.firewall_type = 0; } else { firewall.fwip = *((unsigned long *)(remote->h_addr)); PutLineIntoResp (RT_COMM,0, MSG(M_RESP_FOUND), remote->h_name); } } } } // read password cache psw_read (); // analyze arguments switch (action) { case ACTION_NONE: if (options.download_path != NULL) { l_chdir (V_RIGHT, options.download_path); } else { p = cfg_get_string (CONFIG_NFTP, "", "local-directory-left"); if (p[0] != '\0') { l_chdir (V_LEFT, p); } p = cfg_get_string (CONFIG_NFTP, "", "local-directory-right"); if (p[0] != '\0') { l_chdir (V_RIGHT, p); } } switch (options.start_prompt) { case 1: return FMSG_BASE_MENU + KEY_GEN_LOGIN; case 2: return FMSG_BASE_MENU + KEY_GEN_BOOKMARKS; case 3: return FMSG_BASE_MENU + KEY_GEN_HISTORY; case 5: return FMSG_BASE_MENU + KEY_MENU; } return 0; case ACTION_DOWNLOAD: case ACTION_UPLOAD: oldmode = status.batch_mode; status.batch_mode = TRUE; if (action == ACTION_DOWNLOAD) rc = do_get (optarg1); if (action == ACTION_UPLOAD) rc = do_put (optarg1); //set_view_mode (VIEW_CONTROL); //update (1); if (rc && !cmdline.batchmode) fly_ask_ok (0, MSG(M_TRANSFER_FAILED), optarg1); if ((disc_after && rc == 0) || cmdline.batchmode) { Logoff (0); terminate (); exit (0); } status.batch_mode = oldmode; return 0; //case ACTION_CMDLIST: // rc = runscript (optarg1); // return 0; case ACTION_NICK_BOOK: case ACTION_NICK_HIST: if (action == ACTION_NICK_BOOK && bookmark_nickname (optarg1, &u) == 0) return 0; if (action == ACTION_NICK_HIST && history_nickname (optarg1, &u) == 0) return 0; rc = Login (-1, &u, V_LEFT); if (rc) return 0; if ((action == ACTION_NICK_BOOK && MAX_SITE > 1 && optarg2 != NULL && bookmark_nickname (optarg2, &u) == 1) || (action == ACTION_NICK_HIST && MAX_SITE > 1 && optarg2 != NULL && history_nickname (optarg2, &u) == 1)) { rc = Login (-1, &u, V_RIGHT); } if (options.login_bell) Bell (3); return 0; case ACTION_OPEN_BOOKMARKS: return FMSG_BASE_MENU + KEY_GEN_BOOKMARKS; case ACTION_OPEN_HISTORY: return FMSG_BASE_MENU + KEY_GEN_HISTORY; case ACTION_LOGIN: // if download_path was specified in nftp.ini, set it now if (options.download_path != NULL) { l_chdir (V_LEFT, options.download_path); l_chdir (V_RIGHT, options.download_path); } dmsg ("optarg1 is [%s]\n", optarg1); parse_url (optarg1, &u); rc = Login (-1, &u, V_LEFT); if (MAX_SITE > 1 && optarg2 != NULL) { parse_url (optarg2, &u); rc = Login (-1, &u, V_RIGHT); } // attempt to download file if chdir failed /*if (site.set_up && strcmp (site.u.pathname, RCURDIR.name) != 0) { rc = do_get (optarg1); } if (rc) return 0; */ if (options.login_bell) Bell (3); return 0; case ACTION_TESTONLY: terminate (); exit (0); } fly_error ("internal error in init()"); return 0; }
void menu_activate_top(struct menu *menu) { if (menu->parent) return menu_activate_top(menu->parent); return menu_activate(menu); }
int init (int argc, char *argv[]) { char *p; int rc = 0, oldmode; url_t u; int x0=-1, y0=-1, r=-1, c=-1; struct hostent *remote; char buffer[MAX_PATH]; if (action == ACTION_TESTONLY) exit (0); if (action == ACTION_BADAGS) { usage (); exit (1); } if (options.keep_winsize) { r = cfg_get_integer (CONFIG_NFTP, fl_opt.platform_nick, "rows"); c = cfg_get_integer (CONFIG_NFTP, fl_opt.platform_nick, "cols"); if (r == 0 && c == 0) r = -1, c = -1; } if (options.keep_winpos) { x0 = cfg_get_integer (CONFIG_NFTP, fl_opt.platform_nick, "x0"); y0 = cfg_get_integer (CONFIG_NFTP, fl_opt.platform_nick, "y0"); if (x0 == 0 || y0 == 0) x0 = -1, y0 = -1; } p = cfg_get_string (CONFIG_NFTP, fl_opt.platform_nick, "font"); if (p[0] == '\0') p = NULL; fly_init (x0, y0, r, c, p); if (options.show_hw_cursor) video_cursor_state (1); fly_mouse (options.mouse); wintitle = get_window_name (); if (fl_opt.platform == PLATFORM_OS2_VIO) { strcpy (buffer, paths.system_libpath); str_cats (buffer, "nftp.ico"); if (access (buffer, R_OK) == 0) set_icon (buffer); } if (main_menu != NULL) { menu_activate (main_menu); adjust_menu_status (); } display.dir_mode = options.defaultdirmode; display.view_mode = VIEW_CONTROL; display.rshift = 0; display.lshift = 0; display.tabsize = 8; if (options.slowlink) set_view_mode (VIEW_REMOTE); else set_view_mode (VIEW_CONTROL); site.maxndir = 1024; site.dir = malloc (sizeof(directory)*site.maxndir); // ignore "broken PIPE" signals signal (SIGPIPE, SIG_IGN); set_window_name ("NFTP%s(C) Copyright Sergey Ayukov", NFTP_VERSION); local.dir.files = NULL; local.sortmode = abs (options.default_localsort); if (options.default_localsort >= 0) local.sortdirection = 1; else local.sortdirection = -1; build_local_filelist (NULL); site.batch_mode = FALSE; site.chunks = NULL; PutLineIntoResp2 ("NFTP Version%s(%s, %s) -- %s", NFTP_VERSION, __DATE__, __TIME__, fl_opt.platform_name); PutLineIntoResp1 ("Copyright (C) 1994-2003 Sergey Ayukov <*****@*****.**>"); PutLineIntoResp1 ("Portions Copyright (C) Eric Young <*****@*****.**>"); //PutLineIntoResp1 ("Portions Copyright (C) Martin Nicolay <*****@*****.**>"); status.usage_interval = 0; if (!fl_opt.has_osmenu) PutLineIntoResp1 (M("Press F9 or Ctrl-F for menu")); update (1); if (options.firewall_type != 0) { if (options.fire_server[0] == '\0') { fly_ask_ok (ASK_WARN, M("Firewall proxy host isn't specified in NFTP.INI")); options.firewall_type = 0; } else { if (strspn (options.fire_server, " .0123456789") == strlen (options.fire_server)) { firewall.fwip = inet_addr (options.fire_server); } else { PutLineIntoResp2 (M("Looking up '%s'"), options.fire_server); remote = gethostbyname (options.fire_server); if (remote == NULL) { PutLineIntoResp2 (M("Cannot find '%s'"), options.fire_server); options.firewall_type = 0; } else { firewall.fwip = *((unsigned long *)(remote->h_addr)); PutLineIntoResp2 (M("Found '%s'"), remote->h_name); } } } } // read password cache psw_read (); // analyze arguments switch (action) { case 0: if (options.download_path != NULL) { set_local_path (options.download_path); } else { p = cfg_get_string (CONFIG_NFTP, "", "local-directory"); if (p[0] != '\0') set_local_path (p); } build_local_filelist (NULL); switch (options.start_prompt) { case 1: return FMSG_BASE_MENU + KEY_GEN_LOGIN; case 2: return FMSG_BASE_MENU + KEY_GEN_BOOKMARKS; case 3: return FMSG_BASE_MENU + KEY_GEN_HISTORY; case 5: return FMSG_BASE_MENU + KEY_MENU; } return 0; case ACTION_DOWNLOAD: case ACTION_UPLOAD: oldmode = site.batch_mode; site.batch_mode = TRUE; if (action == ACTION_DOWNLOAD) rc = do_get (optarg1); if (action == ACTION_UPLOAD) rc = do_put (optarg1); //set_view_mode (VIEW_CONTROL); //update (1); if (rc && !cmdline.batchmode) fly_ask_ok (0, M("Transfer of '%s' has failed"), optarg1); if ((disc_after && rc == 0) || cmdline.batchmode) { Logoff (); terminate (); exit (0); } site.batch_mode = oldmode; return 0; case ACTION_CMDLIST: rc = runscript (optarg1); return 0; case ACTION_NICK_BOOK: case ACTION_NICK_HIST: if (action == ACTION_NICK_BOOK && bookmark_nickname (optarg1, &u) == 0) return 0; if (action == ACTION_NICK_HIST && history_nickname (optarg1, &u) == 0) return 0; rc = Login (&u); if (rc) return 0; if (options.login_bell) Bell (3); return 0; case ACTION_OPEN_BOOKMARKS: return FMSG_BASE_MENU + KEY_GEN_BOOKMARKS; case ACTION_OPEN_HISTORY: return FMSG_BASE_MENU + KEY_GEN_HISTORY; case ACTION_LOGIN: // if download_path was specified in nftp.ini, set it now if (options.download_path != NULL) set_local_path (options.download_path); build_local_filelist (NULL); parse_url (optarg1, &u); rc = Login (&u); // attempt to download file if chdir failed /*if (site.set_up && strcmp (site.u.pathname, RCURDIR.name) != 0) { rc = do_get (optarg1); } if (rc) return 0; */ if (options.login_bell) Bell (3); return 0; case ACTION_TESTONLY: terminate (); exit (0); } fly_error ("internal error in init()"); return 0; }