void sdlwindow_modify_effect(running_machine *machine, sdl_window_info *window, int dir) { if (video_config.mode == VIDEO_MODE_SOFT) { sdlwindow_modify_yuv(machine, window, dir); return; } else if (USE_OPENGL) { int new_prescale_effect = window->prescale_effect; const char *effect_names[] = { "none", "scale2x" }; if (dir > 0 && window->prescale_effect < 1) new_prescale_effect = window->prescale_effect + 1; if (dir < 0 && window->prescale_effect > 0) new_prescale_effect = window->prescale_effect - 1; if (new_prescale_effect != window->prescale_effect) { worker_param wp; clear_worker_param(&wp); wp.window = window; execute_async_wait(destroy_all_textures_wt, &wp); window->prescale_effect = new_prescale_effect; ui_popup_time(1, "Effect: %s", effect_names[window->prescale_effect]); } } }
void sdlwindow_modify_prescale(running_machine &machine, sdl_window_info *window, int dir) { worker_param wp; int new_prescale = window->prescale; clear_worker_param(&wp); wp.window = window; wp.m_machine = &machine; if (dir > 0 && window->prescale < 3) new_prescale = window->prescale + 1; if (dir < 0 && window->prescale > 1) new_prescale = window->prescale - 1; if (new_prescale != window->prescale) { if (window->fullscreen && video_config.switchres) { execute_async_wait(&sdlwindow_video_window_destroy_wt, &wp); window->prescale = new_prescale; execute_async_wait(&complete_create_wt, &wp); } else { execute_async_wait(destroy_all_textures_wt, &wp); window->prescale = new_prescale; } ui_popup_time(1, "Prescale %d", window->prescale); } }
static void sdlwindow_modify_yuv(running_machine *machine, sdl_window_info *window, int dir) { int new_scale_mode = window->scale_mode; worker_param wp; const char *stemp; if (dir > 0) new_scale_mode = window->scale_mode + 1; if (dir < 0) new_scale_mode = window->scale_mode - 1; stemp = drawsdl_scale_mode_str(new_scale_mode); if (stemp==NULL) return; clear_worker_param(&wp); wp.window = window; wp.machine = machine; sdlwindow_sync(); execute_async_wait(&sdlwindow_video_window_destroy_wt, &wp); window->scale_mode = new_scale_mode; ui_popup_time(1, "Scale mode %s", stemp); mame_printf_verbose("Scale mode %s\n", stemp); sdlwindow_sync(); execute_async_wait(&complete_create_wt, &wp); sdlwindow_sync(); }
void CLIB_DECL popmessage(const char *format, ...) { // if the format is NULL, it is a signal to clear the popmessage if (format == NULL) ui_popup_time(0, " "); // otherwise, generate the buffer and call the UI to display the message else { astring temp; va_list arg; // dump to the buffer va_start(arg, format); temp.vprintf(format, arg); va_end(arg); // pop it in the UI ui_popup_time(temp.len() / 40 + 2, "%s", temp.cstr()); } }
void sdlwindow_toggle_draw(running_machine *machine, sdl_window_info *window) { #if USE_OPENGL //FIXME: Not yet working in 1.3 #if (!SDL_VERSION_ATLEAST(1,3,0)) worker_param wp; // If we are not fullscreen (windowed) remember our windowed size if (!window->fullscreen) { window->windowed_width = window->width; window->windowed_height = window->height; } clear_worker_param(&wp); wp.window = window; wp.machine = machine; execute_async_wait(&sdlwindow_video_window_destroy_wt, &wp); window->scale_mode = VIDEO_SCALE_MODE_NONE; if (video_config.mode == VIDEO_MODE_OPENGL) { video_config.mode = VIDEO_MODE_SOFT; drawsdl_init(&draw); ui_popup_time(1, "Using software rendering"); } else { video_config.mode = VIDEO_MODE_OPENGL; drawogl_init(&draw); ui_popup_time(1, "Using OpenGL rendering"); } execute_async_wait(&complete_create_wt, &wp); #endif #endif }
static void check_osd_inputs(running_machine &machine) { sdl_window_info *window = sdlinput_get_focus_window(machine); // check for toggling fullscreen mode if (ui_input_pressed(machine, IPT_OSD_1)) sdlwindow_toggle_full_screen(machine, window); if (ui_input_pressed(machine, IPT_OSD_2)) { //FIXME: on a per window basis video_config.fullstretch = !video_config.fullstretch; ui_popup_time(1, "Uneven stretch %s", video_config.fullstretch? "enabled":"disabled"); } if (ui_input_pressed(machine, IPT_OSD_4)) { //FIXME: on a per window basis video_config.keepaspect = !video_config.keepaspect; ui_popup_time(1, "Keepaspect %s", video_config.keepaspect? "enabled":"disabled"); } if (USE_OPENGL || SDLMAME_SDL2) { //FIXME: on a per window basis if (ui_input_pressed(machine, IPT_OSD_5)) { video_config.filter = !video_config.filter; ui_popup_time(1, "Filter %s", video_config.filter? "enabled":"disabled"); } } if (ui_input_pressed(machine, IPT_OSD_6)) sdlwindow_modify_prescale(machine, window, -1); if (ui_input_pressed(machine, IPT_OSD_7)) sdlwindow_modify_prescale(machine, window, 1); }
void device_image_interface::message(const char *format, ...) { va_list args; char buffer[256]; /* format the message */ va_start(args, format); vsnprintf(buffer, ARRAY_LENGTH(buffer), format, args); va_end(args); /* display the popup for a standard amount of time */ ui_popup_time(5, "%s: %s", basename(), buffer); }
void nvram_load(running_machine &machine) { int overrideNVram = 0; if(netCommon) { if(nvram_size(machine)>=32*1024*1024) { overrideNVram=1; ui_popup_time(3, "The NVRAM for this game is too big, not loading NVRAM."); } } if (machine.config().m_nvram_handler != NULL) { astring filename; emu_file file(machine.options().nvram_directory(), OPEN_FLAG_READ); if (!overrideNVram && file.open(nvram_filename(filename, machine.root_device()), ".nv") == FILERR_NONE) { (*machine.config().m_nvram_handler)(machine, &file, FALSE); file.close(); } else { (*machine.config().m_nvram_handler)(machine, NULL, FALSE); } } nvram_interface_iterator iter(machine.root_device()); for (device_nvram_interface *nvram = iter.first(); nvram != NULL; nvram = iter.next()) { astring filename; emu_file file(machine.options().nvram_directory(), OPEN_FLAG_READ); if (file.open(nvram_filename(filename, nvram->device())) == FILERR_NONE) { astring filename; emu_file file(machine.options().nvram_directory(), OPEN_FLAG_READ); if (!overrideNVram && file.open(nvram_filename(filename, nvram->device())) == FILERR_NONE) { nvram->nvram_load(file); file.close(); } else { nvram->nvram_reset(); } } else nvram->nvram_reset(); } }
void ui_menu_control_device_image::test_create(bool &can_create, bool &need_confirm) { astring path; osd_directory_entry *entry; osd_dir_entry_type file_type; /* assemble the full path */ zippath_combine(path, current_directory, current_file); /* does a file or a directory exist at the path */ entry = osd_stat(path); file_type = (entry != NULL) ? entry->type : ENTTYPE_NONE; switch(file_type) { case ENTTYPE_NONE: /* no file/dir here - always create */ can_create = true; need_confirm = false; break; case ENTTYPE_FILE: /* a file exists here - ask for permission from the user */ can_create = true; need_confirm = true; break; case ENTTYPE_DIR: /* a directory exists here - we can't save over it */ ui_popup_time(5, "Cannot save over directory"); can_create = false; need_confirm = false; break; default: fatalerror("Unexpected"); can_create = false; need_confirm = false; break; } }
void ui_menu_file_create::handle() { /* process the menu */ const ui_menu_event *event = process(0); /* process the event */ if (event != NULL) { /* handle selections */ switch(event->iptkey) { case IPT_UI_SELECT: if ((event->itemref == ITEMREF_CREATE) || (event->itemref == ITEMREF_NEW_IMAGE_NAME)) { astring tmp_file(filename_buffer); if (tmp_file.find(".") != -1 && tmp_file.find(".") < tmp_file.len() - 1) { current_file.cpy(filename_buffer); ui_menu::stack_pop(machine()); } else ui_popup_time(1, "Please enter a file extension too"); } break; case IPT_SPECIAL: if (get_selection() == ITEMREF_NEW_IMAGE_NAME) { input_character( filename_buffer, ARRAY_LENGTH(filename_buffer), event->unichar, is_valid_filename_char); reset(UI_MENU_RESET_REMEMBER_POSITION); } break; } } }
void nvram_save(running_machine &machine) { static bool first=true; if(netCommon) { if(nvram_size(machine)>=32*1024*1024) { if(first) { ui_popup_time(3, "The NVRAM for this game is too big, not saving NVRAM."); first = false; } return; } } if (machine.config().m_nvram_handler != NULL) { astring filename; emu_file file(machine.options().nvram_directory(), OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS); if (file.open(nvram_filename(filename, machine.root_device()), ".nv") == FILERR_NONE) { (*machine.config().m_nvram_handler)(machine, &file, TRUE); file.close(); } } nvram_interface_iterator iter(machine.root_device()); for (device_nvram_interface *nvram = iter.first(); nvram != NULL; nvram = iter.next()) { astring filename; emu_file file(machine.options().nvram_directory(), OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS); if (file.open(nvram_filename(filename, nvram->device())) == FILERR_NONE) { nvram->nvram_save(file); file.close(); } } }
void ui_menu_file_selector::handle() { file_error err; const file_selector_entry *entry; const file_selector_entry *selected_entry = NULL; int bestmatch = 0; /* process the menu */ const ui_menu_event *event = process(0); if (event != NULL && event->itemref != NULL) { /* handle selections */ if (event->iptkey == IPT_UI_SELECT) { entry = (const file_selector_entry *) event->itemref; switch(entry->type) { case SELECTOR_ENTRY_TYPE_EMPTY: /* empty slot - unload */ *result = R_EMPTY; ui_menu::stack_pop(machine()); break; case SELECTOR_ENTRY_TYPE_CREATE: /* create */ *result = R_CREATE; ui_menu::stack_pop(machine()); break; case SELECTOR_ENTRY_TYPE_SOFTWARE_LIST: *result = R_SOFTLIST; ui_menu::stack_pop(machine()); break; case SELECTOR_ENTRY_TYPE_DRIVE: case SELECTOR_ENTRY_TYPE_DIRECTORY: /* drive/directory - first check the path */ err = zippath_opendir(entry->fullpath, NULL); if (err != FILERR_NONE) { /* this path is problematic; present the user with an error and bail */ ui_popup_time(1, "Error accessing %s", entry->fullpath); break; } current_directory.cpy(entry->fullpath); reset((ui_menu_reset_options)0); break; case SELECTOR_ENTRY_TYPE_FILE: /* file */ current_file.cpy(entry->fullpath); *result = R_FILE; ui_menu::stack_pop(machine()); break; } // reset the char buffer when pressing IPT_UI_SELECT if (filename_buffer[0] != '\0') memset(filename_buffer, '\0', ARRAY_LENGTH(filename_buffer)); } else if (event->iptkey == IPT_SPECIAL) { int buflen = strlen(filename_buffer); bool update_selected = FALSE; /* if it's a backspace and we can handle it, do so */ if ((event->unichar == 8 || event->unichar == 0x7f) && buflen > 0) { *(char *)utf8_previous_char(&filename_buffer[buflen]) = 0; update_selected = TRUE; if (ARRAY_LENGTH(filename_buffer) > 0) ui_popup_time(ERROR_MESSAGE_TIME, "%s", filename_buffer); } /* if it's any other key and we're not maxed out, update */ else if (event->unichar >= ' ' && event->unichar < 0x7f) { buflen += utf8_from_uchar(&filename_buffer[buflen], ARRAY_LENGTH(filename_buffer) - buflen, event->unichar); filename_buffer[buflen] = 0; update_selected = TRUE; if (ARRAY_LENGTH(filename_buffer) > 0) ui_popup_time(ERROR_MESSAGE_TIME, "%s", filename_buffer); } if (update_selected) { const file_selector_entry *cur_selected = (const file_selector_entry *)get_selection(); // check for entries which matches our filename_buffer: // from current entry to the end for (entry = cur_selected; entry != NULL; entry = entry->next) { if (entry->basename != NULL && filename_buffer != NULL) { int match = 0; for (int i = 0; i < ARRAY_LENGTH(filename_buffer); i++) { if (mame_strnicmp(entry->basename, filename_buffer, i) == 0) match = i; } if (match > bestmatch) { bestmatch = match; selected_entry = entry; } } } // and from the first entry to current one for (entry = entrylist; entry != cur_selected; entry = entry->next) { if (entry->basename != NULL && filename_buffer != NULL) { int match = 0; for (int i = 0; i < ARRAY_LENGTH(filename_buffer); i++) { if (mame_strnicmp(entry->basename, filename_buffer, i) == 0) match = i; } if (match > bestmatch) { bestmatch = match; selected_entry = entry; } } } if (selected_entry != NULL && selected_entry != cur_selected) set_selection((void *) selected_entry); } } else if (event->iptkey == IPT_UI_CANCEL) { // reset the char buffer also in this case if (filename_buffer[0] != '\0') memset(filename_buffer, '\0', ARRAY_LENGTH(filename_buffer)); } } }