예제 #1
0
파일: control.c 프로젝트: dacap/tetrisqueen
/* guarda la información del control de un jugador */
void save_player_control(PLAYER *player, char *section)
{
  set_config_int(section, "left",      player->control.left);
  set_config_int(section, "right",     player->control.right);
  set_config_int(section, "down",      player->control.down);
  set_config_int(section, "rot_left",  player->control.rot_left);
  set_config_int(section, "rot_right", player->control.rot_right);
}
예제 #2
0
파일: gui.cpp 프로젝트: net4nt/aseprite
static void save_gui_config()
{
  she::Display* display = manager->getDisplay();
  if (display) {
    set_config_bool("GfxMode", "Maximized", display->isMaximized());
    set_config_int("GfxMode", "Width", display->originalWidth());
    set_config_int("GfxMode", "Height", display->originalHeight());
  }
}
예제 #3
0
static void save_gui_config()
{
  she::Display* display = Manager::getDefault()->getDisplay();
  if (display) {
    set_config_bool("GfxMode", "Maximized", display->isMaximized());
    set_config_int("GfxMode", "Width", display->originalWidth());
    set_config_int("GfxMode", "Height", display->originalHeight());
  }
  set_config_int("GfxMode", "ScreenScale", screen_scaling);
}
예제 #4
0
void CfgSave()
{
	set_config_int("gfxmode", "fullscreen", cfgFull);
	set_config_int("gfxmode", "zoomin", cfgZoom);

	set_config_int("gfxmode", "width", std::atoi(cfgW));
	set_config_int("gfxmode", "height", std::atoi(cfgH));

	SaveControls();
}
예제 #5
0
int main()
{
  std::srand(std::time(NULL));

  allegro_init();
  install_timer();
  install_keyboard();
//   install_mouse();
  install_joystick(JOY_TYPE_AUTODETECT);

  override_config_file(redir("defnot.ini").c_str());

  gfx_widescreen = get_config_int("Game", "Widescreen", gfx_widescreen);
  gfx_fullscreen = get_config_int("Game", "Fullscreen", gfx_fullscreen);

  if (!setup_gfx() != 0) {
    allegro_message("Unable to setup the graphics mode\n");
    return 1;
  }

//   if (gfx_capabilities & GFX_HW_CURSOR) {
//     enable_hardware_cursor();
//     select_mouse_cursor(MOUSE_CURSOR_ARROW);
//     show_mouse(screen);
//   }

  if (!load_media()) {
    allegro_message("Unable to load data files to play the game\n");
    return 1;
  }

  // install the timer to control the game speed
  LOCK_VARIABLE(beats);
  LOCK_FUNCTION(timer_control);

  beats = 0;
  install_int_ex(timer_control, BPS_TO_TIMER(BPS));

  // insert the callback routine for the close-button
  LOCK_VARIABLE(continuing);
  LOCK_FUNCTION(close_button);

  set_close_button_callback(close_button);

  // play the game
  game_loop();

  set_config_int("Game", "Widescreen", gfx_widescreen);
  set_config_int("Game", "Fullscreen", gfx_fullscreen);

  remove_int(timer_control);
  allegro_exit();
  return 0;
}
예제 #6
0
void save_program_options()
{
   set_config_int("general", "system_of_measurements", system_of_measurements);
   if (display_mode & WINDOWED_MODE_SET)
      set_config_int("general", "display_mode", WINDOWED_MODE);
   else
      set_config_int("general", "display_mode", FULL_SCREEN_MODE);
   set_config_int("comm", "baud_rate", comport.baud_rate);
   set_config_int("comm", "comport_number", comport.number);
   flush_config_file();
}
예제 #7
0
//---------------------------------------------------------------------
void deinicia_allegro() {
	clear_keybuf();
	//salvando o arquivo de configuracao
	set_config_int("Inicializacao", "volume", volume);
	set_config_int("Inicializacao", "vsync", vSync);
	//fechando o allegro
    if (get_update_method())
    {
        shutdown_screen_updating();
    }
	allegro_exit();
	exit(0);
	/* adicione outras deiniciacoes aqui */
}
예제 #8
0
bool node_write_devclass(meshlink_handle_t *mesh, node_t *n) {

	if(n->devclass < 0 || n->devclass > _DEV_CLASS_MAX)
		return false;

	bool result = false;

	splay_tree_t *config_tree;
	init_configuration(&config_tree);

	// ignore read errors; in case the file does not exist we will create it
	read_host_config(mesh, config_tree, n->name);

	config_t* cnf = lookup_config(config_tree, "DeviceClass");

	if(!cnf)
	{
		cnf = new_config();
		cnf->variable = xstrdup("DeviceClass");
		config_add(config_tree, cnf);
	}

	set_config_int(cnf, n->devclass);

	if(!write_host_config(mesh, config_tree, n->name))
		goto fail;

	result = true;

fail:
	exit_configuration(&config_tree);
	return result;
}
예제 #9
0
파일: config.c 프로젝트: cdrr/MAME_hack
static int get_int (char *section, char *option, char *shortcut, int def)
{
	int res,i;

	res = def;

	if (!ignorecfg)
	{
		/* if the option does not exist, create it */
		if (get_config_int (section, option, -777) == -777)
			set_config_int (section, option, def);

		/* look into mame.cfg, [section] */
		res = get_config_int (section, option, def);

		/* look into mame.cfg, [gamename] */
		res = get_config_int ((char *)drivers[game]->name, option, res);
	}

	/* get it from the commandline */
	for (i = 1; i < mame_argc; i++)
	{
		if (mame_argv[i][0] != '-')
			continue;
		if ((stricmp(&mame_argv[i][1], option) == 0) ||
			(shortcut && (stricmp(&mame_argv[i][1], shortcut ) == 0)))
		{
			i++;
			if (i < mame_argc) res = atoi (mame_argv[i]);
		}
	}
	return res;
}
예제 #10
0
/* handle the save command */
int saver()
{
   char buf[FILENAME_LENGTH];

   strcpy(buf, config_file);

   if (file_select_ex("Save Keyboard Config", buf, "CFG", sizeof(buf), 0, 0)) {
      if ((stricmp(config_file, buf) != 0) && (exists(buf))) {
	 if (alert("Overwrite existing file?", NULL, NULL, "Yes", "Cancel", 'y', 27) != 1)
	    return D_REDRAW;
      }

      strlwr(buf);
      strcpy(config_file, buf);

      push_config_state();
      set_config_file(buf);

      set_config_string(NULL, "keyboard_name", keyboard_name);

      set_config_int("key_escape", "accent1", _key_accent1);
      set_config_int("key_escape", "accent2", _key_accent2);
      set_config_int("key_escape", "accent3", _key_accent3);
      set_config_int("key_escape", "accent4", _key_accent4);
      set_config_int("key_escape", "accent1_flag", _key_accent1_flag);
      set_config_int("key_escape", "accent2_flag", _key_accent2_flag);
      set_config_int("key_escape", "accent3_flag", _key_accent3_flag);
      set_config_int("key_escape", "accent4_flag", _key_accent4_flag);

      save_table(_key_ascii_table,               orig_key_ascii_table,               "key_ascii");
      save_table(_key_capslock_table,            orig_key_capslock_table,            "key_capslock");
      save_table(_key_shift_table,               orig_key_shift_table,               "key_shift");
      save_table(_key_control_table,             orig_key_control_table,             "key_control");

      if (split_altgr) {
         save_table(_key_altgr_lower_table,      orig_key_altgr_lower_table,         "key_altgr_lower");
         save_table(_key_altgr_upper_table,      orig_key_altgr_upper_table,         "key_altgr_upper");
      }
      else {
         save_table(_key_altgr_lower_table,      orig_key_altgr_lower_table,         "key_altgr");
      }

      save_table(_key_accent1_lower_table,       orig_key_accent1_lower_table,       "key_accent1_lower");
      save_table(_key_accent1_upper_table,       orig_key_accent1_upper_table,       "key_accent1_upper");
      save_table(_key_accent2_lower_table,       orig_key_accent2_lower_table,       "key_accent2_lower");
      save_table(_key_accent2_upper_table,       orig_key_accent2_upper_table,       "key_accent2_upper");
      save_table(_key_accent3_lower_table,       orig_key_accent3_lower_table,       "key_accent3_lower");
      save_table(_key_accent3_upper_table,       orig_key_accent3_upper_table,       "key_accent3_upper");
      save_table(_key_accent4_lower_table,       orig_key_accent4_lower_table,       "key_accent4_lower");
      save_table(_key_accent4_upper_table,       orig_key_accent4_upper_table,       "key_accent4_upper");

      pop_config_state();
   }

   return D_REDRAW;
}
예제 #11
0
Configuration::~Configuration() {
	// Save game information
	set_config_file("lander.ini");

	// todo: get the window's coordinates
	set_config_int("window","posx",-1);
	set_config_int("window","posy",-1);
	set_config_int("window","fullscreen",fullscreen);

	set_config_int("audio","sfx",sfx);
	set_config_int("audio","music",music);
	flush_config_file();
	
	Logfile::log("Window and Audio config settings saved.\n");
	
	Logfile::log("-Configuration at 0x%x\n", this);
}
void SetEffectsVolume(int volume)
{
    int i;
    for(i=0; i<voice_len_sfx; i++)
    {
        voice_set_volume(VoicesSfx[i], Effect_volume);
    }
    set_config_int("sound","Effect_volume",Effect_volume);
    flush_config_file();
}
void SetMusicVolume(int volume)
{
    int i;
    for(i=0; i<voice_len_music; i++)
    {
        voice_set_volume(VoicesMusic[i], Music_volume);
    }
    set_config_int("sound","Music_volume",Music_volume);
    flush_config_file();
}
예제 #14
0
void eof_controller_save_config(EOF_CONTROLLER * cp, char * name)
{
	int i;
	char string[256] = {0};

	eof_log("eof_controller_save_config() entered", 1);

	if(!cp || !name)
	{
		return;
	}
	for(i = 0; i < EOF_CONTROLLER_MAX_BUTTONS; i++)
	{
		(void) snprintf(string, sizeof(string) - 1, "button_%d_type", i);
		set_config_int(name, string, cp->button[i].type);
		switch(cp->button[i].type)
		{
			case EOF_CONTROLLER_BUTTON_TYPE_KEY:
			{
				(void) snprintf(string, sizeof(string) - 1, "button_%d_key", i);
				set_config_int(name, string, cp->button[i].key);
				break;
			}
			case EOF_CONTROLLER_BUTTON_TYPE_JOYBUTTON:
			{
				(void) snprintf(string, sizeof(string) - 1, "button_%d_controller", i);
				set_config_int(name, string, cp->button[i].joy);
				(void) snprintf(string, sizeof(string) - 1, "button_%d_key", i);
				set_config_int(name, string, cp->button[i].key);
				break;
			}
			case EOF_CONTROLLER_BUTTON_TYPE_JOYAXIS:
			{
				(void) snprintf(string, sizeof(string) - 1, "button_%d_controller", i);
				set_config_int(name, string, cp->button[i].joy);
				(void) snprintf(string, sizeof(string) - 1, "button_%d_axis", i);
				set_config_int(name, string, cp->button[i].index);
				(void) snprintf(string, sizeof(string) - 1, "button_%d_direction", i);
				set_config_int(name, string, cp->button[i].d);
				(void) snprintf(string, sizeof(string) - 1, "button_%d_key", i);
				set_config_int(name, string, cp->button[i].key);
				break;
			}
		}
	}
	set_config_int(name, "delay", cp->delay);
}
int change_resolution(int fullscreen, int ResIndex)
{
    int screen_mode;
    if(!IsInstalled)
    {
        return install(fullscreen,800,480,32); //Security mesure
    }

    KillTextures();
    allegro_gl_set(AGL_COLOR_DEPTH, Resolutions->mode[ResIndex].bpp);
    if(fullscreen)
        screen_mode=GFX_OPENGL_FULLSCREEN;
    else
        screen_mode=GFX_OPENGL_WINDOWED;

    if (set_gfx_mode(screen_mode, Resolutions->mode[ResIndex].width,Resolutions->mode[ResIndex].height, 0, 0))
    {
        set_gfx_mode(GFX_TEXT, 0, 0, 0, 0);
        allegro_message("Unable to set graphic mode\n%s\n", allegro_error);
        return 1;
    }

    SetOpenGL2D();
    RefreshGLTextures();
    AspectRatio=(float)SCREEN_W/(float)SCREEN_H;
    Fullscreen=fullscreen;
    Width=Resolutions->mode[ResIndex].width;
    Height=Resolutions->mode[ResIndex].height;
    depth=Resolutions->mode[ResIndex].bpp;
    ResolutionIndex=ResIndex;
    set_config_file("Resources/Setting.cfg");
    set_config_int("graphics","Fullscreen",Fullscreen);
    set_config_int("graphics","Width",Width);
    set_config_int("graphics","Height",Height);
    set_config_int("graphics","depth",depth);
    set_config_int("graphics","ResolutionIndex",ResIndex);
    flush_config_file();
    LoadSavegame();
    return 0;
}
예제 #16
0
파일: config.c 프로젝트: neiderm/turaco
void Save_INI(void)
{
    // save out all internal bits to be stored
    //set_config_int("System", "Maped_Stretch", display_stretch);
    if (font == &my_new_font)
	set_config_int("System", "Font", 1);
    else
	set_config_int("System", "Font", 0);


    set_config_int("System", "H_Res", gfx_hres);
    set_config_int("System", "V_Res", gfx_vres);

    set_config_on_off("System", "Driver_Subdirs", drv_subdirs);
    
    set_config_on_off("System", "Troll_Magic", troll_magic);

    //set_config_string("User", "Default_Driver", InitGameName);

    // write out the path for the ROMs
    set_config_string("System", "ROMPath", ROMPath);
}
예제 #17
0
/* writes a specific keymapping table to the config file */
void save_table(unsigned short *table, unsigned short *origtable, char *section)
{
   char name[80];
   int i;

   for (i=0; i<KEY_MAX; i++) {
      sprintf(name, "key%d", i);
      if (table[i] != origtable[i])
	 set_config_int(section, name, table[i]);
      else
	 set_config_string(section, name, NULL);
   }
}
예제 #18
0
void save_spacesprite(SpaceSprite *ss, const char *spritename, const char *destination, const char *extension)
{
	STACKTRACE;
	int i;
	char buf[512];

	if (!ss)
		return;

	if (ss->frames()) {
		for (i = 0; i < ss->frames(); i += 1) {
			if (strchr(extension, '.')) {
				sprintf(buf, "tmp/%s%03d%s", spritename, i, extension);
			} else {
				sprintf(buf, "tmp/%s%03d.bmp", spritename, i);
			}

			save_bitmap(buf, ss->get_bitmap(i), NULL);
		}

	}

	sprintf(buf, "tmp/%s.ini", spritename);
	tw_set_config_file(buf);
	set_config_string("Main", "Type", "SpaceSprite");
	set_config_int("SpaceSprite", "Number", (int)ss->frames());
	set_config_int("SpaceSprite", "Width", (int)ss->width());
	set_config_int("SpaceSprite", "Height", (int)ss->height());
	set_config_string("SpaceSprite", "SubType", "Normal");
	set_config_string("SpaceSprite", "Extension", extension);
	chdir("tmp");
	sprintf(buf, "dat ../ships/%s.dat -k -a *", destination);
	//	system(buf);
	sprintf(buf, "move * ..\\ships\\%s", destination);
	system(buf);
	chdir("..");
	return;
}
예제 #19
0
파일: config.c 프로젝트: neiderm/turaco
void Init_INI(void)
{
    unsigned long cver, iniver;

    // initialize the system - create the ini file if necessary
    if (!exists(CONFIG_FILE))
    {
	set_config_file(CONFIG_FILE);
	set_config_int("System", "Version_Major", NEWINI_MAJOR);
	set_config_int("System", "Version_Minor", NEWINI_MINOR);
	set_config_string("System", "Info", CONFIG_INFO);
	set_config_string("System", "Author", CONFIG_AUTHOR);
	set_config_string("System", "ROMPath", DEFAULT_PATH);
	Save_INI();
    } else {
	set_config_file(CONFIG_FILE);
	Load_INI();
    }

    ini_version_major = get_config_int("System", 
				    "Version_Major", ini_version_major);
    ini_version_minor = get_config_int("System", 
				    "Version_Minor", ini_version_minor);

    cver = ((NEWINI_MAJOR)<<16) + NEWINI_MINOR;
    iniver = ((ini_version_major)<<16) + ini_version_minor;

    if (cver < iniver)
    {
	printf("ERROR: The \"%s\" file is newer than TURACO.\n"
	     "       There might be problems when running TURACO!\n"
	     "       Winging it!   Press any key to continue...\n",
	     CONFIG_FILE);
	(void)getch();
    }
}
예제 #20
0
/* handle the save command */
static void save_key_map(void)
{
   int i;
   char *section, *option_format, option[80], tmp1[80], tmp2[80];

   set_config_file("xkeymap.cfg");
   section = uconvert_ascii("xkeymap", tmp1);
   option_format = uconvert_ascii("keycode%d", tmp2);

   for (i = 0; i < 256; i++) {
      if (keycode_to_scancode[i] > 0) {
	 uszprintf(option, sizeof(option), option_format, i);
	 set_config_int(section, option, keycode_to_scancode[i]);
      }
   }
}
예제 #21
0
KeyHandler::~KeyHandler()
{
	// Save key configuration
	set_config_file("lander.ini");
	set_config_int("keys","left",kLeft);
	set_config_int("keys","right",kRight);
	set_config_int("keys","max",kMax);
	set_config_int("keys","med",kMed); 
	set_config_int("keys","min",kMin);
	set_config_int("keys","all",kAll);

	flush_config_file();
	Logfile::log("-KeyHandler at 0x%x\n", this);
}
예제 #22
0
파일: menu.c 프로젝트: evktalo/butterfly
void define_keys(void)
{

 key_box("PRESS KEY FOR UP", CKEY_UP);
 key_box("PRESS KEY FOR LEFT", CKEY_LEFT);
 key_box("PRESS KEY FOR RIGHT", CKEY_RIGHT);
 key_box("PRESS KEY FOR DOWN", CKEY_DOWN);
 key_box("PRESS KEY FOR FIRE 1", CKEY_FIRE1);
 key_box("PRESS KEY FOR FIRE 2", CKEY_FIRE2);
 key_box("PRESS KEY FOR FIRE 3", CKEY_FIRE3);
 key_box("PRESS KEY FOR SLOW", CKEY_SLOW);

 set_config_int("Misc", "key_up", player.key [CKEY_UP]);
 set_config_int("Misc", "key_left", player.key [CKEY_LEFT]);
 set_config_int("Misc", "key_right", player.key [CKEY_RIGHT]);
 set_config_int("Misc", "key_down", player.key [CKEY_DOWN]);
 set_config_int("Misc", "key_fire1", player.key [CKEY_FIRE1]);
 set_config_int("Misc", "key_fire2", player.key [CKEY_FIRE2]);
 set_config_int("Misc", "key_fire3", player.key [CKEY_FIRE3]);
 set_config_int("Misc", "key_slow", player.key [CKEY_SLOW]);

}
예제 #23
0
void ReplaceColorCommand::onExecute(Context* context)
{
  Site site = context->activeSite();

  ReplaceColorFilterWrapper filter(site.layer());
  filter.setFrom(get_config_color(ConfigSection, "Color1", ColorBar::instance()->getFgColor()));
  filter.setTo(get_config_color(ConfigSection, "Color2", ColorBar::instance()->getBgColor()));
  filter.setTolerance(get_config_int(ConfigSection, "Tolerance", 0));

  FilterManagerImpl filterMgr(context, &filter);
  filterMgr.setTarget(TARGET_RED_CHANNEL |
                      TARGET_GREEN_CHANNEL |
                      TARGET_BLUE_CHANNEL |
                      TARGET_GRAY_CHANNEL |
                      TARGET_ALPHA_CHANNEL);

  ReplaceColorWindow window(filter, filterMgr);
  if (window.doModal()) {
    set_config_color(ConfigSection, "From", filter.getFrom());
    set_config_color(ConfigSection, "To", filter.getTo());
    set_config_int(ConfigSection, "Tolerance", filter.getTolerance());
  }
}
예제 #24
0
static int allegro_startup(unsigned int freq)
{
    log_debug("Starting up Allegro sound...  ");

    remove_sound();

    set_config_int("sound", "sb_freq", (int) freq);

    detect_digi_driver(DIGI_AUTODETECT);
    reserve_voices(1, 0);

    if (install_sound(DIGI_AUTODETECT, MIDI_NONE, NULL) != 0) {
        log_debug("Failed: %s\n", allegro_error);
        return -1;
    }

    /* This is not a good idea, as the user might want to specify this from the
       setup program.  */
    /* set_volume(255, 0); */

    log_debug("OK: %s, %s\n", digi_driver->name, digi_driver->desc);
    return 0;
}
예제 #25
0
파일: optmenu.cpp 프로젝트: wziard/miner
void options_menu()
{

   show_mouse(screen);
   DIALOG options_dialog[] =
   {
   /* (dialog proc)     (x)   (y)   (w)   (h)   (fg)  (bg)  (key) (flags)  (d1)  (d2)  (dp) */
      {d_bitmap_proc,     0,   0,SCREEN_W,SCREEN_H,0,255,     0,     0,      0,    0, title_back},
      {d_gamespeed_proc, 20,  10,    0,    0,    0,   0,      0,D_SELECTED,  0,    0, const_cast<char *>("gamespeed")},
      {d_slider_proc,   300,  20,   30,  440,    0, 255,      0,     0,    255,    get_config_int("MINER","BPS", 32) - 32, NULL,  (void *)speedslider_callback},
      {d_mapsize_proc,   20,  60,    0,    0,    0,   0,      0,     0,      0,    0, const_cast<char *>("mapsize")},
      {d_slider_proc,   300,  20,   30,  440,    0, 255,      0,D_HIDDEN,   80,    get_config_int("MINER","MAP_SIZE",20) - 20, NULL,  (void *)mapsizeslider_callback},
      {d_sound_proc,     20, 110,    0,    0,    0,   0,      0,     0,      0,    0, const_cast<char *>("sound")},
      {d_slider_proc,   300,  40,   30,  300,    0, 255,      0,D_HIDDEN,    6,  (int)log2(get_config_int("MINER","NR_OF_VOICES",0) + 1), NULL, (void *)soundslider_callback},
      {d_text_proc,     300,  10,  200,   30,    0, 255,      0,D_HIDDEN,    0,    0, const_cast<char *>("Nr of simultaneous sounds")},
      {d_number_proc,   330,  20,    0,    0,    0,   0,      0,     0,      3,   get_config_int("MINER","BPS", 32), NULL},
      {d_number_proc,   330,  20,    0,    0,    0,   0,      0,D_HIDDEN,    3,   get_config_int("MINER","MAP_SIZE",20) , NULL},
      {d_number_proc,   330,  40,    0,    0,    0,   0,      0,D_HIDDEN,    2,   get_config_int("MINER","NR_OF_VOICES",1), NULL},
      {d_back_proc,      20, 160,    0,    0,    0,   0,      0,     0,      0,    0, const_cast<char *>("exit menu")},
      {NULL,              0,   0,    0,    0,    0,   0,      0,     0,      0,    0,    0, NULL}
   };


   the_options_dialog = options_dialog; // ugly, but I found it easier to initialise the dialog
   // within the function, where all BITMAPS's are loaded etc.
   PALETTE options_palette;

   for (int i=0;i < 256;i++)
   {
      options_palette[i].r = game_palette[i].g;
      options_palette[i].g = game_palette[i].b;
      options_palette[i].b = game_palette[i].r;
   }
   set_dialog_color(options_dialog, bestfit_color(options_palette,0,0,0), bestfit_color(options_palette,63,63,63));


   DIALOG_PLAYER *p = init_dialog(options_dialog, 1);
   
   broadcast_dialog_message(MSG_DRAW, 0);
//   update_dialog(p);
   if (fade_speed)
   {
      fade_from(desktop_palette,options_palette,fade_speed);
   }
   else
   {
      set_palette(options_palette);
   }


   while(update_dialog(p));

   shutdown_dialog(p);

   set_config_int("MINER","BPS", options_dialog[SPEED_SLIDER].d2 + 32);
   set_config_int("MINER","MAP_SIZE", options_dialog[MAPSIZE_SLIDER].d2 + 20);
   set_config_int("MINER","NR_OF_VOICES", (1<<options_dialog[SOUND_SLIDER].d2));
   show_mouse(NULL);

   reinit();
   
   return;
}
예제 #26
0
/** \ingroup settings
 *  Saves the current settings (as specified by allegro_gl_set()) to
 *  the current config file, in the section [OpenGL].
 *
 *  \sa allegro_gl_load_settings()
 */
void allegro_gl_save_settings() {

	char *section = "OpenGL";
	int save = allegro_gl_get(AGL_REQUIRE) | allegro_gl_get(AGL_SUGGEST);
	
	if (save & AGL_ALLEGRO_FORMAT)
		set_config_int(section, "allegro_format",
			allegro_gl_get(AGL_ALLEGRO_FORMAT));
	if (save & AGL_RED_DEPTH)
		set_config_int(section, "red_depth",
			allegro_gl_get(AGL_RED_DEPTH));
	if (save & AGL_GREEN_DEPTH)
		set_config_int(section, "green_depth",
			allegro_gl_get(AGL_GREEN_DEPTH));
	if (save & AGL_BLUE_DEPTH)
		set_config_int(section, "blue_depth",
			allegro_gl_get(AGL_BLUE_DEPTH));
	if (save & AGL_ALPHA_DEPTH)
		set_config_int(section, "alpha_depth",
			allegro_gl_get(AGL_ALPHA_DEPTH));
	if (save & AGL_COLOR_DEPTH)
		set_config_int(section, "color_depth",
			allegro_gl_get(AGL_COLOR_DEPTH));
	if (save & AGL_ACC_RED_DEPTH)
		set_config_int(section, "accum_red_depth",
			allegro_gl_get(AGL_ACC_RED_DEPTH));
	if (save & AGL_ACC_GREEN_DEPTH)
		set_config_int(section, "accum_green_depth",
			allegro_gl_get(AGL_ACC_GREEN_DEPTH));
	if (save & AGL_ACC_BLUE_DEPTH)
		set_config_int(section, "accum_blue_depth",
			allegro_gl_get(AGL_ACC_BLUE_DEPTH));
	if (save & AGL_ACC_ALPHA_DEPTH)
		set_config_int(section, "accum_alpha_depth",
			allegro_gl_get(AGL_ACC_ALPHA_DEPTH));
	if (save & AGL_DOUBLEBUFFER)
		set_config_int(section, "double_buffer",
			allegro_gl_get(AGL_DOUBLEBUFFER));
	if (save & AGL_STEREO)
		set_config_int(section, "stereo_display",
			allegro_gl_get(AGL_STEREO));
	if (save & AGL_AUX_BUFFERS)
		set_config_int(section, "aux_buffers",
			allegro_gl_get(AGL_AUX_BUFFERS));
	if (save & AGL_Z_DEPTH)
		set_config_int(section, "z_depth",
			allegro_gl_get(AGL_Z_DEPTH));
	if (save & AGL_STENCIL_DEPTH)
		set_config_int(section, "stencil_depth",
			allegro_gl_get(AGL_STENCIL_DEPTH));
	if (save & AGL_WINDOW_X)
		set_config_int(section, "window_x",
			allegro_gl_get(AGL_WINDOW_X));
	if (save & AGL_WINDOW_Y)
		set_config_int(section, "window_y",
			allegro_gl_get(AGL_WINDOW_Y));
	if (save & AGL_FULLSCREEN)
		set_config_int(section, "fullscreen",
			allegro_gl_get(AGL_FULLSCREEN));
	if (save & AGL_WINDOWED)
		set_config_int(section, "windowed",
			allegro_gl_get(AGL_WINDOWED));
	if (save & AGL_VIDEO_MEMORY_POLICY)
		set_config_int(section, "video_memory_policy",
			allegro_gl_get(AGL_VIDEO_MEMORY_POLICY));
	if (save & AGL_SAMPLE_BUFFERS)
		set_config_int(section, "sample_buffers",
		               allegro_gl_get(AGL_SAMPLE_BUFFERS));
	if (save & AGL_SAMPLES)
		set_config_int(section, "samples",
		               allegro_gl_get(AGL_SAMPLES));
	if (save & AGL_FLOAT_COLOR)
		set_config_int(section, "float_color",
		               allegro_gl_get(AGL_FLOAT_COLOR));
	if (save & AGL_FLOAT_Z)
		set_config_int(section, "float_depth",
		               allegro_gl_get(AGL_FLOAT_Z));

	if (save & AGL_REQUIRE)
		build_settings(allegro_gl_get(AGL_REQUIRE), section, "require");
	if (save & AGL_SUGGEST)
		build_settings(allegro_gl_get(AGL_SUGGEST), section, "suggest");
}
예제 #27
0
파일: menu.c 프로젝트: evktalo/butterfly
void set_options(void)
{

 int i, anykey = 0;

 int option_select = 0;

 while (TRUE)
 {

 rectfill(display, 200, 240, 400, 510, COL_OUTLINE);
 rect(display, 201, 241, 399, 509, COL_COL1);



 textprintf_centre_ex(display, font, 300, 257, -1, -1, "options");

 rectfill(display, 202, 300 + option_select * 20, 398, 318 + option_select * 20, TRANS_GREEN3);
 hline(display, 202, 298 + option_select * 20, 398, TRANS_GREEN2);
 hline(display, 202, 320 + option_select * 20, 398, TRANS_GREEN2);

 textprintf_ex(display, font, 220, 300, -1, -1, "effects volume - %i", options.sfx_volume);
 textprintf_ex(display, font, 220, 320, -1, -1, "music volume - %i", options.ambience_volume);

 if (options.windowed == 0)
  textprintf_ex(display, font, 220, 340, -1, -1, "mode - fullscreen");
   else
    textprintf_ex(display, font, 220, 340, -1, -1, "mode - windowed");

 if (options.run_vsync == 0)
  textprintf_ex(display, font, 220, 360, -1, -1, "vsync - off");
   else
    textprintf_ex(display, font, 220, 360, -1, -1, "vsync - on");

 if (options.joystick)
 {
  textprintf_ex(display, font, 220, 380, -1, -1, "fire 1 - joystick %i", options.joy_button [0] + 1);
  textprintf_ex(display, font, 220, 400, -1, -1, "fire 2 - joystick %i", options.joy_button [1] + 1);
  textprintf_ex(display, font, 220, 420, -1, -1, "fire 3 - joystick %i", options.joy_button [3] + 1);
  textprintf_ex(display, font, 220, 440, -1, -1, "slow move - joystick %i", options.joy_button [2] + 1);

 }
  else
  {
   textprintf_ex(display, font, 220, 400, -1, -1, "no joystick");

  }

  textprintf_ex(display, font, 220, 460, -1, -1, "exit");


 vsync();
 blit(display, screen, 0, 0, 100, 0, 600, 600);

 anykey = 0;


  for (i = KEY_A; i < KEY_CAPSLOCK + 1; i ++)
  {
   if (key [i])
   {
    anykey = 1;
   }
  }

  if (anykey == 0 && (options.joystick == 0 || any_joystick_input() == 0))
   key_wait = 0;



 if (key_wait <= 0)
 {
  if (menu_command(MC_UP))
  {
   option_select --;
   if (option_select < 0)
    option_select = OPT_EXIT;
   if (option_select == OPT_JOYSLOW && options.joystick == 0)
    option_select = OPT_VSYNC;
   key_wait = 7;
  }
  if (menu_command(MC_DOWN))
  {
   option_select ++;
   if (option_select > OPT_EXIT)
    option_select = 0;
   if (option_select == OPT_JOY1 && options.joystick == 0)
    option_select = OPT_EXIT;
   key_wait = 7;
  }

  if (menu_command(MC_LEFT))
  {
   if (option_select == OPT_SFX_VOLUME)
   {
    options.sfx_volume -= 10;
    if (options.sfx_volume < 0)
     options.sfx_volume = 0;
   }
   if (option_select == OPT_MUSIC_VOLUME)
   {
    options.ambience_volume -= 10;
    if (options.ambience_volume < 0)
     options.ambience_volume = 0;
   }

   if (option_select == OPT_JOY1)
   {
    if (options.joy_button [0] == 0)
     options.joy_button [0] = joy[0].num_buttons - 1;
      else
       options.joy_button [0] --;
   }
   if (option_select == OPT_JOY2)
   {
    if (options.joy_button [1] == 0)
     options.joy_button [1] = joy[0].num_buttons - 1;
      else
       options.joy_button [1] --;
   }
   if (option_select == OPT_JOYSLOW)
   {
    if (options.joy_button [2] == 0)
     options.joy_button [2] = joy[0].num_buttons - 1;
      else
       options.joy_button [2] --;
   }
   if (option_select == OPT_JOY3)
   {
    if (options.joy_button [3] == 0)
     options.joy_button [3] = joy[0].num_buttons - 1;
      else
       options.joy_button [3] --;
   }
   key_wait = 7;
  }

  if (menu_command(MC_RIGHT))
  {
   if (option_select == OPT_SFX_VOLUME)
   {
    options.sfx_volume += 10;
    if (options.sfx_volume > 100)
     options.sfx_volume = 100;
   }
   if (option_select == OPT_MUSIC_VOLUME)
   {
    options.ambience_volume += 10;
    if (options.ambience_volume > 100)
     options.ambience_volume = 100;
   }

   if (option_select == OPT_JOY1)
   {
    if (options.joy_button [0] >= joy[0].num_buttons - 1)
     options.joy_button [0] = 0;
      else
       options.joy_button [0] ++;
   }
   if (option_select == OPT_JOY2)
   {
    if (options.joy_button [1] >= joy[0].num_buttons - 1)
     options.joy_button [1] = 0;
      else
       options.joy_button [1] ++;
   }
   if (option_select == OPT_JOY3)
   {
    if (options.joy_button [3] >= joy[0].num_buttons - 1)
     options.joy_button [3] = 0;
      else
       options.joy_button [3] ++;
   }
   if (option_select == OPT_JOYSLOW)
   {
    if (options.joy_button [2] >= joy[0].num_buttons - 1)
     options.joy_button [2] = 0;
      else
       options.joy_button [2] ++;
   }
   key_wait = 7;
  }

  if (key [KEY_ESC])
   break;

  if (menu_command(MC_SELECT))
  {
   if (option_select == OPT_EXIT)
   {
    break;
   }
  }

  if (menu_command(MC_SELECT) || menu_command(MC_LEFT) || menu_command(MC_RIGHT))
  {
   if (option_select == OPT_MODE)
   {
    options.windowed ^= 1;
    key_wait = 7;
   }
   if (option_select == OPT_VSYNC)
   {
    options.run_vsync ^= 1;
    key_wait = 7;
   }
  }


/*   if (menu_select == MENU_KEYS)
   {
    key_wait = 10;
    define_keys();
    key_wait = 10;
   }

   if (menu_select == MENU_OPTIONS)
   {
    key_wait = 10;
    set_options();
    key_wait = 10;
   }*/



 }
//  else
   key_wait --;




    do
    {
        thing ++;
    } while (ticked == 0);
    ticked = 0;

 vsync();
 blit(display, screen, 0, 0, 100, 0, 600, 600);



 };

 set_config_int("Misc", "sfx_volume", options.sfx_volume);
 set_config_int("Misc", "ambience_volume", options.ambience_volume);
 if (options.joystick)
 {
  set_config_int("Misc", "joy_button_1", options.joy_button [0]);
  set_config_int("Misc", "joy_button_2", options.joy_button [1]);
  set_config_int("Misc", "joy_button_slow", options.joy_button [2]);
  set_config_int("Misc", "joy_button_3", options.joy_button [3]);
 }
 set_config_int("Misc", "vsync", options.run_vsync);
 set_config_int("Misc", "Windowed", options.windowed);


}
예제 #28
0
파일: render.cpp 프로젝트: vmrob/aseprite
// static
void RenderEngine::setCheckedBgType(CheckedBgType type)
{
  checked_bg_type = type;
  set_config_int("Options", "CheckedBgType", (int)type);
}
예제 #29
0
/**
 * Shows the "New Sprite" dialog.
 */
void NewFileCommand::onExecute(Context* context)
{
  JWidget width, height, radio1, radio2, radio3, colors, ok, bg_box;
  int imgtype, w, h, bg, ncolors;
  char buf[1024];
  Color bg_table[] = {
    Color::fromMask(),
    Color::fromRgb(0, 0, 0),
    Color::fromRgb(255, 255, 255),
    Color::fromRgb(255, 0, 255),
    app_get_colorbar()->getBgColor()
  };

  // Load the window widget
  FramePtr window(load_widget("new_sprite.xml", "new_sprite"));
  get_widgets(window,
	      "width", &width,
	      "height", &height,
	      "radio1", &radio1,
	      "radio2", &radio2,
	      "radio3", &radio3,
	      "colors", &colors,
	      "ok_button", &ok,
	      "bg_box", &bg_box, NULL);

  // Default values: Indexed, 320x240, Background color
  imgtype = get_config_int("NewSprite", "Type", IMAGE_INDEXED);
  imgtype = MID(IMAGE_RGB, imgtype, IMAGE_INDEXED);
  w = get_config_int("NewSprite", "Width", 320);
  h = get_config_int("NewSprite", "Height", 240);
  bg = get_config_int("NewSprite", "Background", 4); // Default = Background color
  ncolors = get_config_int("NewSprite", "Colors", 256);

  width->setTextf("%d", MAX(1, w));
  height->setTextf("%d", MAX(1, h));
  colors->setTextf("%d", MID(2, ncolors, 256));

  // Select image-type
  switch (imgtype) {
    case IMAGE_RGB:       radio1->setSelected(true); break;
    case IMAGE_GRAYSCALE: radio2->setSelected(true); break;
    case IMAGE_INDEXED:   radio3->setSelected(true); break;
  }

  // Select background color
  jlistbox_select_index(bg_box, bg);

  // Open the window
  window->open_window_fg();

  if (window->get_killer() == ok) {
    bool ok = false;

    // Get the options
    if (radio1->isSelected())      imgtype = IMAGE_RGB;
    else if (radio2->isSelected()) imgtype = IMAGE_GRAYSCALE;
    else if (radio3->isSelected()) imgtype = IMAGE_INDEXED;

    w = width->getTextInt();
    h = height->getTextInt();
    ncolors = colors->getTextInt();
    bg = jlistbox_get_selected_index(bg_box);

    w = MID(1, w, 9999);
    h = MID(1, h, 9999);
    ncolors = MID(2, ncolors, 256);

    // Select the color
    Color color = Color::fromMask();

    if (bg >= 0 && bg <= 4) {
      color = bg_table[bg];
      ok = true;
    }

    if (ok) {
      // Save the configuration
      set_config_int("NewSprite", "Type", imgtype);
      set_config_int("NewSprite", "Width", w);
      set_config_int("NewSprite", "Height", h);
      set_config_int("NewSprite", "Background", bg);

      // Create the new sprite
      ASSERT(imgtype == IMAGE_RGB || imgtype == IMAGE_GRAYSCALE || imgtype == IMAGE_INDEXED);
      ASSERT(w >= 1 && w <= 9999);
      ASSERT(h >= 1 && h <= 9999);

      UniquePtr<Document> document(
	Document::createBasicDocument(imgtype, w, h,
				      (imgtype == IMAGE_INDEXED ? ncolors: 256)));
      Sprite* sprite(document->getSprite());

      get_default_palette()->copyColorsTo(sprite->getCurrentPalette());

      usprintf(buf, "Sprite-%04d", ++_sprite_counter);
      document->setFilename(buf);

      // If the background color isn't transparent, we have to
      // convert the `Layer 1' in a `Background'
      if (color.getType() != Color::MaskType) {
	Sprite* sprite = document->getSprite();

	ASSERT(sprite->getCurrentLayer() && sprite->getCurrentLayer()->is_image());
	
	static_cast<LayerImage*>(sprite->getCurrentLayer())->configureAsBackground();
	image_clear(sprite->getCurrentImage(), color_utils::color_for_image(color, imgtype));
      }
      
      // Show the sprite to the user
      context->addDocument(document);

      // Release the document as it is already owned by the context.
      // And put the document in a reliable editor.
      set_document_in_more_reliable_editor(document.release());
    }
  }
}
예제 #30
0
파일: tree.c 프로젝트: Angeldude/sonic-pi
void test_diff_tree__diff_configs(void)
{
	const char *a_commit = "d70d245e";
	const char *b_commit = "7a9e0b02";

	g_repo = cl_git_sandbox_init("diff");

	cl_assert((a = resolve_commit_oid_to_tree(g_repo, a_commit)) != NULL);
	cl_assert((b = resolve_commit_oid_to_tree(g_repo, b_commit)) != NULL);

	cl_git_pass(git_diff_tree_to_tree(&diff, g_repo, a, b, NULL));

	cl_git_pass(git_diff_foreach(diff, 
		diff_file_cb, diff_binary_cb, diff_hunk_cb, diff_line_cb, &expect));

	cl_assert_equal_i(2, expect.files);
	cl_assert_equal_i(2, expect.file_status[GIT_DELTA_MODIFIED]);
	cl_assert_equal_i(6, expect.hunks);
	cl_assert_equal_i(55, expect.lines);
	cl_assert_equal_i(33, expect.line_ctxt);
	cl_assert_equal_i(7, expect.line_adds);
	cl_assert_equal_i(15, expect.line_dels);

	git_diff_free(diff);
	diff = NULL;

	set_config_int(g_repo, "diff.context", 1);

	memset(&expect, 0, sizeof(expect));

	cl_git_pass(git_diff_tree_to_tree(&diff, g_repo, a, b, NULL));

	cl_git_pass(git_diff_foreach(diff,
		diff_file_cb, diff_binary_cb, diff_hunk_cb, diff_line_cb, &expect));

	cl_assert_equal_i(2, expect.files);
	cl_assert_equal_i(2, expect.file_status[GIT_DELTA_MODIFIED]);
	cl_assert_equal_i(7, expect.hunks);
	cl_assert_equal_i(34, expect.lines);
	cl_assert_equal_i(12, expect.line_ctxt);
	cl_assert_equal_i(7, expect.line_adds);
	cl_assert_equal_i(15, expect.line_dels);

	git_diff_free(diff);
	diff = NULL;

	set_config_int(g_repo, "diff.context", 0);
	set_config_int(g_repo, "diff.noprefix", 1);

	memset(&expect, 0, sizeof(expect));

	cl_git_pass(git_diff_tree_to_tree(&diff, g_repo, a, b, NULL));

	cl_git_pass(git_diff_foreach(diff,
		diff_file_cb, diff_binary_cb, diff_hunk_cb, diff_line_cb, &expect));

	cl_assert_equal_i(2, expect.files);
	cl_assert_equal_i(2, expect.file_status[GIT_DELTA_MODIFIED]);
	cl_assert_equal_i(7, expect.hunks);
	cl_assert_equal_i(22, expect.lines);
	cl_assert_equal_i(0, expect.line_ctxt);
	cl_assert_equal_i(7, expect.line_adds);
	cl_assert_equal_i(15, expect.line_dels);
}