static void roms_done( HWND hwndDlg, LONG lParam ) { size_t i; int error; TCHAR **setting; const TCHAR *string; size_t string_len; struct callback_info *info = ( struct callback_info * ) lParam; for( i = 0; i < info->n; i++ ) { setting = settings_get_rom_setting( &settings_current, info->start + i ); string_len = SendMessage( rom[i], WM_GETTEXTLENGTH, 0, 0 ); string = malloc( sizeof( TCHAR ) * ( string_len + 1 ) ); SendMessage( rom[i], WM_GETTEXT, string_len + 1, ( LPARAM ) string ); error = settings_set_string( setting, string ); if( error ) return; /* FIXME: do I need to free string? free( string ); */ } }
static int machine_select_machine( fuse_machine_info *machine ) { int width, height, i; int capabilities; machine_current = machine; settings_set_string( &settings_current.start_machine, machine->id ); tstates = 0; /* Reset the event stack */ event_reset(); if( event_add( 0, timer_event ) ) return 1; if( event_add( machine->timings.tstates_per_frame, spectrum_frame_event ) ) return 1; sound_end(); if( uidisplay_end() ) return 1; capabilities = libspectrum_machine_capabilities( machine->machine ); /* Set screen sizes here */ if( capabilities & LIBSPECTRUM_MACHINE_CAPABILITY_TIMEX_VIDEO ) { width = DISPLAY_SCREEN_WIDTH; height = 2*DISPLAY_SCREEN_HEIGHT; } else { width = DISPLAY_ASPECT_WIDTH; height = DISPLAY_SCREEN_HEIGHT; } if( uidisplay_init( width, height ) ) return 1; sound_init( settings_current.sound_device ); /* Mark RAM as not-present/read-only. The machine's reset function will * mark available pages as present/writeable. */ for( i = 0; i < 2 * SPECTRUM_RAM_PAGES; i++ ) memory_map_ram[i].writable = 0; /* Do a hard reset */ if( machine_reset( 1 ) ) return 1; /* And the dock menu item */ if( capabilities & LIBSPECTRUM_MACHINE_CAPABILITY_TIMEX_DOCK ) { ui_menu_activate( UI_MENU_ITEM_MEDIA_CARTRIDGE_DOCK_EJECT, 0 ); } /* Reset any dialogue boxes etc. which contain machine-dependent state */ ui_widgets_reset(); return 0; }
static int machine_select_machine( fuse_machine_info *machine ) { int width, height; int capabilities; machine_current = machine; settings_set_string( &settings_current.start_machine, machine->id ); tstates = 0; /* Reset the event stack */ event_reset(); event_add( 0, timer_event ); event_add( machine->timings.tstates_per_frame, spectrum_frame_event ); sound_end(); if( uidisplay_end() ) return 1; capabilities = libspectrum_machine_capabilities( machine->machine ); /* Set screen sizes here */ if( capabilities & LIBSPECTRUM_MACHINE_CAPABILITY_TIMEX_VIDEO ) { width = DISPLAY_SCREEN_WIDTH; height = 2*DISPLAY_SCREEN_HEIGHT; } else { width = DISPLAY_ASPECT_WIDTH; height = DISPLAY_SCREEN_HEIGHT; } if( uidisplay_init( width, height ) ) return 1; sound_init( settings_current.sound_device ); /* Do a hard reset */ if( machine_reset( 1 ) ) return 1; /* And the dock menu item */ if( capabilities & LIBSPECTRUM_MACHINE_CAPABILITY_TIMEX_DOCK ) { ui_menu_activate( UI_MENU_ITEM_MEDIA_CARTRIDGE_DOCK_EJECT, 0 ); } /* Reset any dialogue boxes etc. which contain machine-dependent state */ ui_widgets_reset(); return 0; }
int dck_insert( const char *filename ) { if ( !( libspectrum_machine_capabilities( machine_current->machine ) & LIBSPECTRUM_MACHINE_CAPABILITY_TIMEX_DOCK ) ) { ui_error( UI_ERROR_ERROR, "This machine does not support the dock" ); return 1; } settings_set_string( &settings_current.dck_file, filename ); machine_reset( 0 ); return 0; }
void widget_roms_keyhandler( input_key key ) { switch( key ) { #if 0 case INPUT_KEY_Resize: /* Fake keypress used on window resize */ widget_roms_draw( NULL ); break; #endif case INPUT_KEY_Escape: widget_end_widget( WIDGET_FINISHED_CANCEL ); return; case INPUT_KEY_Return: case INPUT_KEY_KP_Enter: widget_end_all( WIDGET_FINISHED_OK ); return; default: /* Keep gcc happy */ break; } if( key >= INPUT_KEY_a && key <= INPUT_KEY_z && key - INPUT_KEY_a < (ptrdiff_t)rom_count ) { char **setting; char buf[32]; widget_filesel_data data; key -= INPUT_KEY_a; snprintf( buf, sizeof( buf ), "%s - ROM %d", info->title, key ); data.exit_all_widgets = 0; data.title = buf; widget_do_fileselector( &data ); if( !widget_filesel_name ) return; setting = settings_get_rom_setting( widget_settings, key + first_rom, is_peripheral ); settings_set_string( setting, widget_filesel_name ); print_rom( key ); } }
int ide_insert( const char *filename, libspectrum_ide_channel *chn, libspectrum_ide_unit unit, int (*commit_fn)( libspectrum_ide_unit unit ), char **setting, ui_menu_item item ) { int error; /* Remove any currently inserted disk; abort if we want to keep the current disk */ if( *setting ) if( ide_eject( chn, unit, commit_fn, setting, item ) ) return 0; settings_set_string( setting, filename ); error = libspectrum_ide_insert( chn, unit, filename ); if( error ) return error; error = ui_menu_activate( item, 1 ); if( error ) return error; return 0; }
void state_changed() { hotkey_t hk; REFRESH_KEY_SETTING(trigger); settings_set(TRIGGER_KEY, &hk); REFRESH_KEY_SETTING(english); settings_set(ENG_KEY, &hk); varchar colorstr; REFRESH_COLOR_SETTING(background_color_btn); settings_set(PREEDIT_COLOR, colorstr); REFRESH_COLOR_SETTING(font_color_btn); settings_set(PREEDIT_FONT_COLOR, colorstr); /* font and size information */ settings_set(PREEDIT_FONT, (void*) gtk_font_button_get_font_name(font_btn)); /* font color information */ settings_set_double(PREEDIT_OPACITY, gtk_adjustment_get_value(opacity_value)); settings_set_int(CANDIDATES_SIZE, gtk_adjustment_get_value(ncandidates)); /* page up and down trigger */ settings_set_int(PAGE_MINUS_PLUS, gtk_toggle_button_get_active(minus_plus_check)); settings_set_int(PAGE_COMMA_PERIOD, gtk_toggle_button_get_active(comma_period_check)); settings_set_int(PAGE_PAREN, gtk_toggle_button_get_active(paren_check)); /* fuzzy segmentation */ settings_set_int(FUZZY_SEGMENTATION, gtk_toggle_button_get_active(fuzzy_seg_check)); settings_set_int(FUZZY_INNER_SEGMENTATION, gtk_toggle_button_get_active(fuzzy_inner_seg_check)); /* cancel on backspace */ settings_set_int(CANCEL_ON_BACKSPACE, gtk_toggle_button_get_active(cancel_on_backspace_check)); /* smart punctuation */ settings_set_int(SMART_PUNCT, gtk_toggle_button_get_active(smart_punct_check)); settings_set_int(SHUANGPIN, gtk_toggle_button_get_active(shuangpin_check)); int sche_idx = gtk_combo_box_get_active(shuangpin_combo); if (sche_idx < UI_SHUANGPIN_SCHEMES_NUM) settings_set_string(SHUANGPIN_SCHEME, ui_shuangpin_schemes[sche_idx]); /* skins */ settings_set_string(SKIN_NAME, gtk_combo_box_get_active_text(skin_combo)); /* whether hide icbar */ settings_set_int(HIDE_ICBAR, gtk_toggle_button_get_active(hide_icbar_check)); /* init status */ settings_set_int(INIT_PUNC_TYPE, gtk_toggle_button_get_active(punc_english_radio)); settings_set_int(INIT_WIDTH, gtk_toggle_button_get_active(half_width_radio)); settings_set_int(INIT_LANGUAGE, gtk_toggle_button_get_active(lang_english_radio)); settings_save(); send_reload(); }