/* wb_cb : WAD browser callback. This function is called whenever a user presses an entry in the browser. */ void wb_cb(FL_OBJECT *a, long l) { int line; Int4 index; int RetVal; const char *ch; line = fl_get_browser(a); /* get line number in browser */ if ( line == 1 ) /* first line is the legend */ return; index = LinearMap[line]; /* check appropriate choice-box to see if we should handle this ourself, or spawn an external program */ switch ( pEntryTag[index] ) { case TAG_SFX : ch = fl_get_choice_text( snd_cho ); break; case TAG_FLAT : case TAG_FULL : case TAG_IMG : ch = fl_get_choice_text( img_cho ); break; case TAG_HIRES: ch = fl_get_choice_text( img_cho ); if ( !strcmp( ch, INTERNALLY_STR ) ) Message("Entry type %s cannot be handled internally, " "spawning external... \n", TagString(pEntryTag[index]) ); /* fallthrough */ case TAG_MUS : ch = EXTERNALLY_STR; break; default : ch = NULL; break; } if ( !strcmp( ch, EXTERNALLY_STR ) ) { /* handle externally, but we must determine if we have an external program */ switch (pEntryTag[index]) { case TAG_MUS : RetVal = (Ext_MUS_Player[0] != '\0') ? 0 : 1; break; case TAG_SFX : RetVal = (Ext_WAV_Player[0] != '\0') ? 0 : 1; break; case TAG_FLAT : case TAG_FULL : case TAG_IMG : case TAG_HIRES: RetVal = (Ext_PCX_Viewer[0] != '\0') ? 0 : 1; break; default : RetVal = 1; break; } if (RetVal) { Message("No external program defined for type %s\n", TagString(pEntryTag[index]) ); return; } SpawnExternal( index ); } else /* handle internally */ HandleInternal( index ); /* Dump (flush) all X-events before we return, so e.g. if a user keeps the "down"-key pressed, the effect will be as expected. */ XSync( fl_get_display(), True ); }
void select_single(FL_OBJECT *ob, long data) { const char *str; str = fl_get_choice_text (ob); if (strcmp (str, "dual") == 0) { single = 0; } if (strcmp (str, "single") == 0) { single = 1; } if (strcmp (str, "interferometer") == 0) { single = 2; } if (strcmp (str, "split") == 0) { single = 3; } if (strcmp (str, "uhd") == 0) { single = 4; } }
void NeoWindow::HandleOptionsObject( FL_OBJECT *obj ) { // Handle command from form on options dialog FD_options *box = options_box; if ( obj == box->ok ) { fl_hide_form( box->options ); fl_free_form( box->options ); Refresh( true ); options_box = NULL; } else if ( obj == box->initial_pop ) neo->initial_creatures = fl_get_slider_value( obj ); else if ( obj == box->initial_plant ) neo->num_initial_food_locs = fl_get_slider_value( obj ); else if ( obj == box->initial_flesh ) neo->num_initial_meat_locs = fl_get_slider_value( obj ); else if ( obj == box->give_head_start ) neo->bGiveHeadStart = fl_get_button( obj ); else if ( obj == box->allow_sex ) neo->bAllowSexual = fl_get_button( obj ); else if ( obj == box->allow_asex ) neo->bAllowAsexual = fl_get_button( obj ); else if ( obj == box->terrain_size ) neo->terrain_size = atoi( fl_get_choice_text( obj ) ); else if ( obj == box->scale ) neo->scale = fl_get_slider_value( obj ); else if ( obj == box->prob_crossover ) neo->prob_crossover = fl_get_slider_value( obj ); else if ( obj == box->prob_mutation ) neo->prob_mutation = fl_get_slider_value( obj ); else if ( obj == box->max_pop ) neo->maximum_creatures = fl_get_slider_value( obj ); else if ( obj == box->min_pop ) neo->nMinimumPopulation = fl_get_slider_value( obj ); else if ( obj == box->age_factor ) neo->age_factor = fl_get_slider_value( obj ); else if ( obj == box->carcass_decay_rate ) neo->nCarcassDecayRate = fl_get_slider_value( obj ); else if ( obj == box->waste_decay_rate ) neo->nWasteDecayRate = fl_get_slider_value( obj ); else if ( obj == box->poison_decay_rate ) neo->nPoisonDecayRate = fl_get_slider_value( obj ); else if ( obj == box->give_head_start ) neo->bGiveHeadStart = fl_get_button( obj ); else if ( obj == box->allow_sex ) neo->bAllowSexual = fl_get_button( obj ); else if ( obj == box->allow_asex ) neo->bAllowAsexual = fl_get_button( obj ); else if ( obj == box->maintain_min_pop ) neo->bKeepMinimumPopulation = fl_get_button( obj ); else if ( obj == box->use_survivor ) neo->bUseSurvivorForMinimum = fl_get_button( obj ); else if ( obj == box->save_sim ) if ( fl_get_button( obj ) ) neo->saveEveryNsteps = fl_get_slider_value( box->save_every ); else neo->saveEveryNsteps = -1; else if ( obj == box->file_name ) strcpy( neo->fileName, fl_get_input( obj ) ); }
/*** callbacks and freeobj handles for form receiver_start ***/ void select_bandwidth(FL_OBJECT *ob, long data) { const char *str; double fbw; str = fl_get_choice_text (ob); fbw = atof (str); bandwidth = (int)fbw; }
void set_dec_mode (FL_OBJECT *ob, long data) { strcpy (dec_mode, fl_get_choice_text (ob)); if (strcmp (dec_mode, "external") == 0) { sprintf (dec_mode, "external %s", (char *)fl_show_fselector ("Select DEC Control File",".", "*.*","dec_control_file")); } }
/* Callback for the sound-choice. Only used to hide/show the "reverse" button, and only if we have sound */ void snd_cho_cb(FL_OBJECT *a, long l) { #ifdef AUDIO_DEVICE const char *ch; ch = fl_get_choice_text( a ); if ( !strcmp(ch, EXTERNALLY_STR ) ) fl_hide_object( rev_but ); else fl_show_object( rev_but ); #endif }
void select_psr_srate (FL_OBJECT *ob, long data) { char *str; char numbuf[128], *np, *p; str = (char *)fl_get_choice_text (ob); p = str; np = numbuf; while (isdigit(*p)) { *np = *p; np++; *np = '\0'; p++; } psr_srate = atoi(numbuf) * 1000; }
void set_side_choice (FL_OBJECT *ob, long data) { const char *str; if ((str = fl_get_choice_text (ob)) != NULL) { if (strcmp (str, "A") == 0) { strcpy (side, "A:0"); } else if (strcmp (str, "B") == 0) { strcpy (side, "B:0"); } } else { strcpy (side, "A:0"); } }
/* callback for palette-change choice */ void pal_ch_cb(FL_OBJECT *a, long l) { const char *ch; char **current_xpm; ch = fl_get_choice_text( a ); /* copy the RGB selected by the user to the "current" RGB. */ if( !strcmp(ch,PAL_DOOM) ) CopyRGB( DAC_Reg, doom_rgb); else if( !strcmp(ch,PAL_HERETIC) ) CopyRGB( DAC_Reg, heretic_rgb); else if( !strcmp(ch,PAL_E_HERETIC) ) CopyRGB( DAC_Reg, E_HERETIC_rgb); else if( !strcmp(ch,PAL_HEXEN) ) CopyRGB( DAC_Reg, hexen_rgb); else if( !strcmp(ch,PAL_STRIFE) ) CopyRGB( DAC_Reg, strife_rgb); else if( !strcmp(ch, PAL_USER) && USER_rgb ) CopyRGB( DAC_Reg, USER_rgb); else /* this should not happen */ Abort("unknown palette type!\n"); CreateXpmPalette( DAC_Reg, keep_transparent_color ); /* redraw current image */ if ( ( current_xpm = CreateXpmImage( 0, 0, 0, 1, NULL)) ) { fl_free_pixmap_pixmap( img_pxm ); fl_set_pixmap_data( img_pxm, current_xpm ); } }
void adjust_brightness (FL_OBJECT *ob, long data) { const char *str; str = fl_get_choice_text (ob); if (strcmp (str, "100") == 0) { waterfall_brightness = 1.0; } if (strcmp (str, "75") == 0) { waterfall_brightness = 0.75; } if (strcmp (str, "66") == 0) { waterfall_brightness = 0.66; } if (strcmp (str, "50") == 0) { waterfall_brightness = 0.50; } update_wfall_colormap (); }
/* export_cb : Export Callback Export to file the entry highlighted in the browser. */ void export_cb(FL_OBJECT *a, long l) { Int4 index; int RetVal; unsigned char *pImgBuf; short Width; short Height; const char *format; RetVal = fl_get_browser(wad_brow); if ( RetVal == 1 ) /* first line is the legend */ return; index = LinearMap[RetVal]; switch (pEntryTag[index]) { case TAG_MUS : GenFileName(pDirEnt[index].name, ".mus", TmpNameStr); RetVal = Gen_MUS_File(WADfp, pDirEnt[index], TmpNameStr); break; case TAG_SFX : GenFileName(pDirEnt[index].name, ".wav", TmpNameStr); RetVal = Gen_WAV_File(WADfp, pDirEnt[index], TmpNameStr); break; case TAG_FLAT : case TAG_FULL : case TAG_IMG : pImgBuf = ParseImgBlock(pDirEnt[index], pEntryTag[index], &Width, &Height, NULL, NULL, WADfp); if (pImgBuf == NULL) { RetVal = 4; break; } format = fl_get_choice_text( exp_img_fmt_cho ); if ( !strcmp(format, PCX_STR ) ) { /* pcx */ GenFileName(pDirEnt[index].name, ".pcx", TmpNameStr); RetVal = PCX_WriteImage(pDirEnt[index], WADfp, Width, Height, pImgBuf, 1, TmpNameStr); } else { /* xpm */ char **xpm; GenFileName(pDirEnt[index].name, ".xpm", TmpNameStr); /* don't just redraw, we don't know what's in the xpm: */ xpm = CreateXpmImage( pImgBuf, Width, Height, 0, NULL ); if ( xpm && CreateXpmFile( xpm, TmpNameStr ) ) RetVal = 0; else RetVal = 666; /* why not? */ } break; case TAG_HIRES: GenFileName(pDirEnt[index].name, ".pcx", TmpNameStr); RetVal = PCX_WriteImage(pDirEnt[index], WADfp, 640, 480, pBitMap, 4, TmpNameStr); break; default: RetVal = 1; break; } if (RetVal != 0) { Beep(); Message("error generating external file \"%s\" (%d)\n", TmpNameStr, RetVal); } else Message("External file \"%s\" created OK\n", TmpNameStr); }