void show_tx_dialog(pdf_widget *widget) { ui_input_init(&tx_input, pdf_field_value(ctx, widget->obj)); ui.focus = &tx_input; ui.dialog = tx_dialog; tx_widget = widget; }
void ui_init_save_file(const char *path, int (*filter)(const char *fn)) { char dir[PATH_MAX], *p; fc.filter = filter; fz_strlcpy(dir, path, sizeof dir); for (p=dir; *p; ++p) if (*p == '\\') *p = '/'; fz_cleanname(dir); p = strrchr(dir, '/'); if (p) { *p = 0; load_dir(dir); ui_input_init(&fc.input_file, p+1); } else { load_dir("."); ui_input_init(&fc.input_file, dir); } }
static void cert_file_dialog(void) { if (ui_open_file(cert_filename)) { if (cert_filename[0] != 0) { ui_input_init(&cert_password, ""); ui.focus = &cert_password; ui.dialog = cert_password_dialog; } else ui.dialog = NULL; } }
static void load_dir(const char *path) { WIN32_FIND_DATA ffd; HANDLE dir; wchar_t wpath[PATH_MAX]; char buf[PATH_MAX]; int i; realpath(path, fc.curdir); if (!fz_is_directory(ctx, path)) return; ui_input_init(&fc.input_dir, fc.curdir); fc.selected = -1; fc.count = 0; MultiByteToWideChar(CP_UTF8, 0, path, -1, wpath, PATH_MAX); for (i=0; wpath[i]; ++i) if (wpath[i] == '/') wpath[i] = '\\'; StringCchCat(wpath, PATH_MAX, TEXT("/*")); dir = FindFirstFileW(wpath, &ffd); if (dir) { do { WideCharToMultiByte(CP_UTF8, 0, ffd.cFileName, -1, buf, PATH_MAX, NULL, NULL); if (ffd.dwFileAttributes & FILE_ATTRIBUTE_HIDDEN) continue; fc.files[fc.count].is_dir = ffd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY; if (fc.files[fc.count].is_dir || !fc.filter || fc.filter(buf)) { fz_strlcpy(fc.files[fc.count].name, buf, FILENAME_MAX); ++fc.count; } } while (FindNextFile(dir, &ffd)); FindClose(dir); } qsort(fc.files, fc.count, sizeof fc.files[0], cmp_entry); }
static void load_dir(const char *path) { char buf[PATH_MAX]; DIR *dir; struct dirent *dp; realpath(path, fc.curdir); if (!fz_is_directory(ctx, fc.curdir)) return; ui_input_init(&fc.input_dir, fc.curdir); fc.selected = -1; fc.count = 0; dir = opendir(fc.curdir); if (!dir) { fc.files[fc.count].is_dir = 1; fz_strlcpy(fc.files[fc.count].name, "..", FILENAME_MAX); ++fc.count; } else { while ((dp = readdir(dir)) && fc.count < nelem(fc.files)) { /* skip hidden files */ if (dp->d_name[0] == '.' && strcmp(dp->d_name, ".") && strcmp(dp->d_name, "..")) continue; fz_snprintf(buf, sizeof buf, "%s/%s", fc.curdir, dp->d_name); fc.files[fc.count].is_dir = fz_is_directory(ctx, buf); if (fc.files[fc.count].is_dir || !fc.filter || fc.filter(buf)) { fz_strlcpy(fc.files[fc.count].name, dp->d_name, FILENAME_MAX); ++fc.count; } } closedir(dir); } qsort(fc.files, fc.count, sizeof fc.files[0], cmp_entry); }
static void bump_file_version(int dir) { char buf[PATH_MAX], *p, *n; char base[PATH_MAX], out[PATH_MAX]; int x; fz_strlcpy(buf, fc.input_file.text, sizeof buf); p = strrchr(buf, '.'); if (p) { n = p; while (n > buf && n[-1] >= '0' && n[-1] <= '9') --n; if (n != p) x = atoi(n) + dir; else x = dir; memcpy(base, buf, n-buf); base[n-buf] = 0; fz_snprintf(out, sizeof out, "%s%d%s", base, x, p); ui_input_init(&fc.input_file, out); } }
void running_machine::start() { // initialize basic can't-fail systems here config_init(*this); m_input = auto_alloc(*this, input_manager(*this)); output_init(*this); palette_init(*this); m_render = auto_alloc(*this, render_manager(*this)); generic_machine_init(*this); generic_sound_init(*this); // allocate a soft_reset timer m_soft_reset_timer = m_scheduler.timer_alloc(timer_expired_delegate(FUNC(running_machine::soft_reset), this)); // init the osd layer m_osd.init(*this); // create the video manager m_video = auto_alloc(*this, video_manager(*this)); ui_init(*this); // initialize the base time (needed for doing record/playback) ::time(&m_base_time); // initialize the input system and input ports for the game // this must be done before memory_init in order to allow specifying // callbacks based on input port tags time_t newbase = input_port_init(*this); if (newbase != 0) m_base_time = newbase; // intialize UI input ui_input_init(*this); // initialize the streams engine before the sound devices start m_sound = auto_alloc(*this, sound_manager(*this)); // first load ROMs, then populate memory, and finally initialize CPUs // these operations must proceed in this order rom_init(*this); memory_init(*this); watchdog_init(*this); // must happen after memory_init because this relies on generic.spriteram generic_video_init(*this); // allocate the gfx elements prior to device initialization gfx_init(*this); // initialize natural keyboard support inputx_init(*this); // initialize image devices image_init(*this); tilemap_init(*this); crosshair_init(*this); // initialize the debugger if ((debug_flags & DEBUG_FLAG_ENABLED) != 0) debugger_init(*this); // call the game driver's init function // this is where decryption is done and memory maps are altered // so this location in the init order is important ui_set_startup_text(*this, "Initializing...", true); // start up the devices const_cast<device_list &>(devicelist()).start_all(); // if we're coming in with a savegame request, process it now const char *savegame = options().state(); if (savegame[0] != 0) schedule_load(savegame); // if we're in autosave mode, schedule a load else if (options().autosave() && (m_system.flags & GAME_SUPPORTS_SAVE) != 0) schedule_load("auto"); // set up the cheat engine m_cheat = auto_alloc(*this, cheat_manager(*this)); // disallow save state registrations starting here m_save.allow_registration(false); }
void running_machine::start() { /* initialize basic can't-fail systems here */ fileio_init(this); config_init(this); input_init(this); output_init(this); state_init(this); state_save_allow_registration(this, true); palette_init(this); render_init(this); ui_init(this); generic_machine_init(this); generic_video_init(this); generic_sound_init(this); /* initialize the timers and allocate a soft_reset timer this must be done before cpu_init so that CPU's can allocate timers */ timer_init(this); m_soft_reset_timer = timer_alloc(this, static_soft_reset, NULL); /* init the osd layer */ osd_init(this); /* initialize the base time (needed for doing record/playback) */ time(&m_base_time); /* initialize the input system and input ports for the game this must be done before memory_init in order to allow specifying callbacks based on input port tags */ time_t newbase = input_port_init(this, m_game.ipt); if (newbase != 0) m_base_time = newbase; /* intialize UI input */ ui_input_init(this); /* initialize the streams engine before the sound devices start */ streams_init(this); /* first load ROMs, then populate memory, and finally initialize CPUs these operations must proceed in this order */ rom_init(this); memory_init(this); watchdog_init(this); /* allocate the gfx elements prior to device initialization */ gfx_init(this); /* initialize natural keyboard support */ inputx_init(this); /* initialize image devices */ image_init(this); /* start up the devices */ m_devicelist.start_all(); /* call the game driver's init function this is where decryption is done and memory maps are altered so this location in the init order is important */ ui_set_startup_text(this, "Initializing...", true); if (m_game.driver_init != NULL) (*m_game.driver_init)(this); /* finish image devices init process */ image_postdevice_init(this); /* start the video and audio hardware */ video_init(this); tilemap_init(this); crosshair_init(this); sound_init(this); /* initialize the debugger */ if ((debug_flags & DEBUG_FLAG_ENABLED) != 0) debugger_init(this); /* call the driver's _START callbacks */ if (m_config.m_machine_start != NULL) (*m_config.m_machine_start)(this); if (m_config.m_sound_start != NULL) (*m_config.m_sound_start)(this); if (m_config.m_video_start != NULL) (*m_config.m_video_start)(this); /* set up the cheat engine */ cheat_init(this); /* set up the hiscore engine */ hiscore_init(this); /* disallow save state registrations starting here */ state_save_allow_registration(this, false); }
void running_machine::start() { // initialize basic can't-fail systems here fileio_init(this); config_init(this); input_init(this); output_init(this); state_init(this); state_save_allow_registration(this, true); palette_init(this); render_init(this); ui_init(this); generic_machine_init(this); generic_video_init(this); generic_sound_init(this); // initialize the timers and allocate a soft_reset timer // this must be done before cpu_init so that CPU's can allocate timers timer_init(this); m_soft_reset_timer = timer_alloc(this, static_soft_reset, NULL); // init the osd layer osd_init(this); // initialize the base time (needed for doing record/playback) time(&m_base_time); // initialize the input system and input ports for the game // this must be done before memory_init in order to allow specifying // callbacks based on input port tags time_t newbase = input_port_init(this, m_game.ipt); if (newbase != 0) m_base_time = newbase; // intialize UI input ui_input_init(this); // initialize the streams engine before the sound devices start streams_init(this); // first load ROMs, then populate memory, and finally initialize CPUs // these operations must proceed in this order rom_init(this); memory_init(this); watchdog_init(this); // allocate the gfx elements prior to device initialization gfx_init(this); // initialize natural keyboard support inputx_init(this); // initialize image devices image_init(this); // start up the devices m_devicelist.start_all(); // call the game driver's init function // this is where decryption is done and memory maps are altered // so this location in the init order is important ui_set_startup_text(this, "Initializing...", true); if (m_game.driver_init != NULL) (*m_game.driver_init)(this); // finish image devices init process image_postdevice_init(this); // start the video and audio hardware video_init(this); tilemap_init(this); crosshair_init(this); sound_init(this); // initialize the debugger if ((debug_flags & DEBUG_FLAG_ENABLED) != 0) debugger_init(this); // call the driver's _START callbacks if (m_config.m_machine_start != NULL) (*m_config.m_machine_start)(this); if (m_config.m_sound_start != NULL) (*m_config.m_sound_start)(this); if (m_config.m_video_start != NULL) (*m_config.m_video_start)(this); // if we're coming in with a savegame request, process it now const char *savegame = options_get_string(&m_options, OPTION_STATE); if (savegame[0] != 0) schedule_load(savegame); // if we're in autosave mode, schedule a load else if (options_get_bool(&m_options, OPTION_AUTOSAVE) && (m_game.flags & GAME_SUPPORTS_SAVE) != 0) schedule_load("auto"); // set up the cheat engine if (options_get_bool(&m_options, OPTION_CHEAT)) cheat_init(this); // disallow save state registrations starting here state_save_allow_registration(this, false); }
void running_machine::start() { // initialize basic can't-fail systems here config_init(*this); m_input = auto_alloc(*this, input_manager(*this)); output_init(*this); palette_init(*this); m_render = auto_alloc(*this, render_manager(*this)); generic_machine_init(*this); // allocate a soft_reset timer m_soft_reset_timer = m_scheduler.timer_alloc(timer_expired_delegate(FUNC(running_machine::soft_reset), this)); // init the osd layer m_osd.init(*this); // create the video manager m_video = auto_alloc(*this, video_manager(*this)); ui_init(*this); // initialize the base time (needed for doing record/playback) ::time(&m_base_time); // initialize the input system and input ports for the game // this must be done before memory_init in order to allow specifying // callbacks based on input port tags time_t newbase = m_ioport.initialize(); if (newbase != 0) m_base_time = newbase; // intialize UI input ui_input_init(*this); // initialize the streams engine before the sound devices start m_sound = auto_alloc(*this, sound_manager(*this)); // first load ROMs, then populate memory, and finally initialize CPUs // these operations must proceed in this order rom_init(*this); m_memory.initialize(); // initialize the watchdog m_watchdog_timer = m_scheduler.timer_alloc(timer_expired_delegate(FUNC(running_machine::watchdog_fired), this)); if (config().m_watchdog_vblank_count != 0 && primary_screen != NULL) primary_screen->register_vblank_callback(vblank_state_delegate(FUNC(running_machine::watchdog_vblank), this)); save().save_item(NAME(m_watchdog_enabled)); save().save_item(NAME(m_watchdog_counter)); // allocate the gfx elements prior to device initialization gfx_init(*this); // initialize image devices image_init(*this); m_tilemap = auto_alloc(*this, tilemap_manager(*this)); crosshair_init(*this); network_init(*this); // initialize the debugger if ((debug_flags & DEBUG_FLAG_ENABLED) != 0) debugger_init(*this); // call the game driver's init function // this is where decryption is done and memory maps are altered // so this location in the init order is important ui_set_startup_text(*this, "Initializing...", true); // register callbacks for the devices, then start them add_notifier(MACHINE_NOTIFY_RESET, machine_notify_delegate(FUNC(running_machine::reset_all_devices), this)); add_notifier(MACHINE_NOTIFY_EXIT, machine_notify_delegate(FUNC(running_machine::stop_all_devices), this)); save().register_presave(save_prepost_delegate(FUNC(running_machine::presave_all_devices), this)); start_all_devices(); save().register_postload(save_prepost_delegate(FUNC(running_machine::postload_all_devices), this)); // if we're coming in with a savegame request, process it now const char *savegame = options().state(); if (savegame[0] != 0) schedule_load(savegame); // if we're in autosave mode, schedule a load else if (options().autosave() && (m_system.flags & GAME_SUPPORTS_SAVE) != 0) schedule_load("auto"); // set up the cheat engine m_cheat = auto_alloc(*this, cheat_manager(*this)); // allocate autoboot timer m_autoboot_timer = scheduler().timer_alloc(timer_expired_delegate(FUNC(running_machine::autoboot_callback), this)); // initialize lua m_lua_engine.initialize(); // disallow save state registrations starting here m_save.allow_registration(false); }
int ui_save_file(char filename[PATH_MAX], void (*extra_panel)(void)) { int i, rv = 0; ui_panel_begin(0, 0, 4, 4, 1); { ui_layout(L, Y, NW, 0, 0); ui_panel_begin(150, 0, 0, 0, 0); { ui_layout(T, X, NW, 2, 2); list_drives(); if (extra_panel) { ui_spacer(); extra_panel(); } ui_layout(B, X, NW, 2, 2); if (ui_button("Cancel") || (!ui.focus && ui.key == KEY_ESCAPE)) { filename[0] = 0; rv = 1; } } ui_panel_end(); ui_layout(T, X, NW, 2, 2); if (ui_input(&fc.input_dir, 0, 1) == UI_INPUT_ACCEPT) load_dir(fc.input_dir.text); ui_layout(T, X, NW, 2, 2); ui_panel_begin(0, ui.gridsize, 0, 0, 0); { ui_layout(R, NONE, CENTER, 0, 0); if (ui_button("Save")) { fz_snprintf(filename, PATH_MAX, "%s/%s", fc.curdir, fc.input_file.text); rv = 1; } ui_spacer(); if (ui_button("\xe2\x9e\x95")) /* U+2795 HEAVY PLUS */ bump_file_version(1); if (ui_button("\xe2\x9e\x96")) /* U+2796 HEAVY MINUS */ bump_file_version(-1); ui_spacer(); ui_layout(ALL, X, CENTER, 0, 0); ui_input(&fc.input_file, 0, 1); } ui_panel_end(); ui_layout(ALL, BOTH, NW, 2, 2); ui_list_begin(&fc.list_dir, fc.count, 0, 0); for (i = 0; i < fc.count; ++i) { const char *name = fc.files[i].name; char buf[PATH_MAX]; if (fc.files[i].is_dir) fz_snprintf(buf, sizeof buf, "\xf0\x9f\x93\x81 %s", name); else fz_snprintf(buf, sizeof buf, "\xf0\x9f\x93\x84 %s", name); if (ui_list_item(&fc.list_dir, &fc.files[i], buf, i==fc.selected)) { fc.selected = i; if (fc.files[i].is_dir) { fz_snprintf(buf, sizeof buf, "%s/%s", fc.curdir, name); load_dir(buf); ui.active = NULL; } else { ui_input_init(&fc.input_file, name); } } } ui_list_end(&fc.list_dir); } ui_panel_end(); return rv; }