Пример #1
0
LRESULT CALLBACK NesProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
	LPNMHDR nmhdr;
	static char tmpstr[1024];

	switch(message) {
		case WM_INITDIALOG:
			CheckDlgButton(hDlg,IDC_PAUSEAFTERLOADCHECK,config_get_bool("nes.pause_on_load") ? BST_CHECKED : BST_UNCHECKED);
			CheckDlgButton(hDlg,IDC_LOGUNHANDLEDIOCHECK,config_get_bool("nes.log_unhandled_io") ? BST_CHECKED : BST_UNCHECKED);
			CheckDlgButton(hDlg,IDC_FDSHLECHECK,config_get_bool("nes.fds.hle") ? BST_CHECKED : BST_UNCHECKED);
			SetDlgItemText(hDlg,IDC_FDSBIOSEDIT,config_get_string("nes.fds.bios"));
			CheckDlgButton(hDlg,IDC_GENIECHECK,config_get_bool("nes.gamegenie.enabled") ? BST_CHECKED : BST_UNCHECKED);
			SetDlgItemText(hDlg,IDC_GENIEBIOSEDIT,config_get_string("nes.gamegenie.bios"));
			return(TRUE);

		case WM_NOTIFY:
			nmhdr = (LPNMHDR)lParam;
			switch(nmhdr->code) {
				case PSN_APPLY:
					config_set_bool("nes.pause_on_load",IsDlgButtonChecked(hDlg,IDC_PAUSEAFTERLOADCHECK) ? 1 : 0);
					config_set_bool("nes.log_unhandled_io",IsDlgButtonChecked(hDlg,IDC_LOGUNHANDLEDIOCHECK) ? 1 : 0);
					config_set_bool("nes.fds.hle",IsDlgButtonChecked(hDlg,IDC_FDSHLECHECK) ? 1 : 0);
					GetDlgItemText_SetConfig(hDlg,IDC_FDSBIOSEDIT,"nes.fds.bios");
					config_set_bool("nes.gamegenie.enabled",IsDlgButtonChecked(hDlg,IDC_GENIECHECK) ? 1 : 0);
					GetDlgItemText_SetConfig(hDlg,IDC_GENIEBIOSEDIT,"nes.gamegenie.bios");
					return(TRUE);
			}
			break;
	}
	return(FALSE);
}
Пример #2
0
void config_parse_commandline( const char* const* cmdline, unsigned int num )
{
	//TODO: Implement, format --section:key=value
	unsigned int arg;
	for( arg = 0; arg < num; ++arg )
	{
		if( string_match_pattern( cmdline[arg], "--*:*=*" ) )
		{
			unsigned int first_sep = string_find( cmdline[arg], ':', 0 );
			unsigned int second_sep = string_find( cmdline[arg], '=', 0 );
			if( ( first_sep != STRING_NPOS ) && ( second_sep != STRING_NPOS ) && ( first_sep < second_sep ) )
			{
				unsigned int section_length = first_sep - 2;
				unsigned int end_pos = first_sep + 1;
				unsigned int key_length = second_sep - end_pos;

				const char* section_str = cmdline[arg] + 2;
				const char* key_str = pointer_offset_const( cmdline[arg], end_pos );
				
				hash_t section = hash( section_str, section_length );
				hash_t key = hash( key_str, key_length );
				
				char* value = string_substr( cmdline[arg], second_sep + 1, STRING_NPOS );
				char* set_value = value;
				
				unsigned int value_length = string_length( value );
				
				if( !value_length )
					config_set_string( section, key, "" );
				else if( string_equal( value, "false" ) )
					config_set_bool( section, key, false );
				else if( string_equal( value, "true" ) )
					config_set_bool( section, key, true );
				else if( ( string_find( value, '.', 0 ) != STRING_NPOS ) && ( string_find_first_not_of( value, "0123456789.", 0 ) == STRING_NPOS ) && ( string_find( value, '.', string_find( value, '.', 0 ) + 1 ) == STRING_NPOS ) ) //Exactly one "."
					config_set_real( section, key, string_to_real( value ) );
				else if( string_find_first_not_of( value, "0123456789", 0 ) == STRING_NPOS )
					config_set_int( section, key, string_to_int64( value ) );
				else
				{
					if( ( value_length > 1 ) && ( value[0] == '"' ) && ( value[ value_length - 1 ] == '"' ) )
					{
						value[ value_length - 1 ] = 0;
						set_value = value + 1;
						config_set_string( section, key, set_value );
					}
					else
					{
						config_set_string( section, key, value );
					}
				}

				log_infof( HASH_CONFIG, "Config value from command line: %.*s:%.*s = %s", section_length, section_str, key_length, key_str, set_value );
				
				string_deallocate( value );
			}	
		}
	}
}
Пример #3
0
static void shader_write_fbo(config_file_t *conf, const struct gfx_fbo_scale *fbo, unsigned i)
{
   char key[64];
   print_buf(key, "float_framebuffer%u", i);
   config_set_bool(conf, key, fbo->fp_fbo);
   print_buf(key, "srgb_framebuffer%u", i);
   config_set_bool(conf, key, fbo->srgb_fbo);

   if (!fbo->valid)
      return;

   shader_write_scale_dim(conf, "x", fbo->type_x, fbo->scale_x, fbo->abs_x, i);
   shader_write_scale_dim(conf, "y", fbo->type_y, fbo->scale_y, fbo->abs_y, i);
}
Пример #4
0
int test_pos_ngrams()
{
    int i, err = 0;
    fvec_t *f;

    /* Test for positional n-grams */
    test_t t[] = {
        {"b b b b b", 3, 0, 1},
        {"b b b b b", 3, 1, 3},
        {"b b b b b", 2, 0, 1},
        {"b b b b b", 2, 1, 4},
        {NULL, 0, 0, 0}
    };

    test_printf("Testing positional n-grams");

    /* Hack to set delimiters */
    config_set_string(&cfg, "features.granularity", "tokens");
    config_set_string(&cfg, "features.token_delim", " ");
    fvec_delim_set(" ");

    for (i = 0; t[i].str; i++) {

        config_set_int(&cfg, "features.ngram_len", t[i].nlen);
        config_set_bool(&cfg, "features.ngram_pos", t[i].flag);
        config_set_int(&cfg, "features.pos_shift", 0);

        /* Extract features */
        f = fvec_extract(t[i].str, strlen(t[i].str));

        /* Check for correct number of dimensions */
        if (f->len != t[i].len) {
            test_error("(%d) len %d != %d", i, f->len, t[i].len);
            err++;
        }

        fvec_destroy(f);
    }

    config_set_bool(&cfg, "features.ngram_pos", 0);

    test_return(err, i);
    return err;
}
Пример #5
0
/**
 * cheat_manager_save:
 * @path                      : Path to cheats file (relative path).
 *
 * Saves cheats to file on disk.
 *
 * Returns: true (1) if successful, otherwise false (0).
 **/
bool cheat_manager_save(const char *path)
{
    bool ret;
    unsigned i;
    config_file_t *conf               = NULL;
    char buf[PATH_MAX_LENGTH]         = {0};
    char cheats_file[PATH_MAX_LENGTH] = {0};
    settings_t              *settings = config_get_ptr();
    cheat_manager_t *handle = cheat_manager_state;

    fill_pathname_join(buf, settings->path.cheat_database,
                       path, sizeof(buf));

    fill_pathname_noext(cheats_file, buf, ".cht", sizeof(cheats_file));

    conf = config_file_new(cheats_file);

    if (!conf)
        conf = config_file_new(NULL);

    if (!conf)
        return false;

    if (!handle)
    {
        config_file_free(conf);
        return false;
    }

    config_set_int(conf, "cheats", handle->size);

    for (i = 0; i < handle->size; i++)
    {
        char key[64]         = {0};
        char desc_key[256]   = {0};
        char code_key[256]   = {0};
        char enable_key[256] = {0};

        snprintf(key,        sizeof(key),        "cheat%u",        i);
        snprintf(desc_key,   sizeof(desc_key),   "cheat%u_desc",   i);
        snprintf(code_key,   sizeof(code_key),   "cheat%u_code",   i);
        snprintf(enable_key, sizeof(enable_key), "cheat%u_enable", i);

        if (handle->cheats[i].desc)
            config_set_string(conf, desc_key,   handle->cheats[i].desc);
        else
            config_set_string(conf, desc_key,   handle->cheats[i].code);
        config_set_string(conf,    code_key,   handle->cheats[i].code);
        config_set_bool(conf,      enable_key, handle->cheats[i].state);
    }

    ret = config_file_write(conf, cheats_file);
    config_file_free(conf);

    return ret;
}
Пример #6
0
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//controltype_button_message
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
int controltype_button_message(control *c, int tokencount, char *tokens[])
{
	//Get the details
	controltype_button_details *details = (controltype_button_details *) c->controldetails;

	//If it's set control property
	if (tokencount == 6 && !stricmp(tokens[2], szBActionSetControlProperty))
	{
		//Only pressed, only for two state buttons
		if (details->is_twostate && !stricmp(tokens[4], "Pressed") && config_set_bool(tokens[5], &details->is_on))
		{
			style_draw_invalidate(c);
			return 0;
		}
		else if (!strcmp(tokens[4],"VAlign"))
		{
			int i;
			if (-1 != (i = get_string_index(tokens[5], button_valigns)))
			{
				details->valign = i;
				controltype_button_updatesettings(details);
				style_draw_invalidate(c);
				return 0;
			}
		}
		else if (!strcmp(tokens[4],"HAlign"))
		{
			int i;
			if (-1 != (i = get_string_index(tokens[5], button_haligns)))
			{
				details->halign = i;
				controltype_button_updatesettings(details);
				style_draw_invalidate(c);
				return 0;
			}
		}

		//Must be an error
		return 1;
	}

	//Must be an agent message?
	if (details->is_twostate)
		return agent_controlmessage(c, tokencount, tokens, CONTROLTYPE_TWOSTATEBUTTON_AGENTCOUNT, details->agents, controltype_switchbutton_agentnames, controltype_switchbutton_agenttypes);
	else
		return agent_controlmessage(c, tokencount, tokens, CONTROLTYPE_BUTTON_AGENTCOUNT, details->agents, controltype_button_agentnames, controltype_button_agenttypes);
}
Пример #7
0
//PSN_KILLACTIVE validated the changes
LRESULT CALLBACK GeneralProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
	char tmpstr[1024];
	LPNMHDR nmhdr;
	DWORD mask;

	switch(message) {
		case WM_INITDIALOG:
			CheckDlgButton(hDlg,IDC_NESCHECK,checkassociation(".nes") ? BST_UNCHECKED : BST_CHECKED);
			CheckDlgButton(hDlg,IDC_UNFCHECK,checkassociation(".unf") ? BST_UNCHECKED : BST_CHECKED);
			CheckDlgButton(hDlg,IDC_FDSCHECK,checkassociation(".fds") ? BST_UNCHECKED : BST_CHECKED);
			CheckDlgButton(hDlg,IDC_NSFCHECK,checkassociation(".nsf") ? BST_UNCHECKED : BST_CHECKED);
			CheckDlgButton(hDlg,IDC_CARTDBENABLECHECK,config_get_bool("cartdb.enabled") ? BST_CHECKED : BST_UNCHECKED);
			SetDlgItemText(hDlg,IDC_CARTDBEDIT,config_get_string("cartdb.filename"));
			return TRUE;

		case WM_COMMAND:
			switch(LOWORD(wParam)) {
				case IDC_CARTDBEDITBUTTON:
					GetWindowText(GetDlgItem(hDlg,IDC_CARTDBEDIT),tmpstr,1024);
					DialogBoxParam(hInst,(LPCTSTR)IDD_CARTDBFILES,hDlg,(DLGPROC)CartDBFilesDlg,(LPARAM)(char*)tmpstr);
					SetWindowText(GetDlgItem(hDlg,IDC_CARTDBEDIT),tmpstr);
					return(TRUE);
			}
			break;

		case WM_NOTIFY:
			nmhdr = (LPNMHDR)lParam;
			switch(nmhdr->code) {
				case PSN_APPLY:
					mask =  IsDlgButtonChecked(hDlg,IDC_NESCHECK) ? 1  : 0;
					mask |= IsDlgButtonChecked(hDlg,IDC_UNFCHECK) ? 2  : 0;
					mask |= IsDlgButtonChecked(hDlg,IDC_UNFCHECK) ? 4  : 0;
					mask |= IsDlgButtonChecked(hDlg,IDC_FDSCHECK) ? 8  : 0;
					mask |= IsDlgButtonChecked(hDlg,IDC_NSFCHECK) ? 16 : 0;
					modifyassociations(mask);
					config_set_bool("cartdb.enabled",IsDlgButtonChecked(hDlg,IDC_CARTDBENABLECHECK) ? 1 : 0);
					GetDlgItemText_SetConfig(hDlg,IDC_CARTDBEDIT,"cartdb.filename");
					return(TRUE);
			}
			break;
	}
	return(FALSE);
}
Пример #8
0
Файл: xqf-ui.c Проект: IR4T4/xqf
static void source_ctree_enable_master_group (GtkWidget *ctree, struct master *m, int expand) {
	GtkCTreeNode *node;
	GtkCTreeNode *sibling = NULL;
	char cfgkey[128];
	GSList *list;
	int expanded;

	if (!m->isgroup)
		return;

	node = gtk_ctree_find_by_row_data (GTK_CTREE (ctree), NULL, m);

	if (node != NULL) {
		if (expand)
			gtk_ctree_expand (GTK_CTREE (ctree), node);
		return;
	}

	g_snprintf (cfgkey, 128, "/" CONFIG_FILE "/Source Tree/%s node collapsed=false", m->name);

	if (expand)
		config_set_bool (cfgkey, expanded = TRUE);
	else
		expanded = TRUE - config_get_bool (cfgkey);

	/* Find the place to insert new master group */

	list = g_slist_nth (master_groups, m->type);
	if (list)
		list = list->next;

	while (!sibling && list) {
		sibling = gtk_ctree_find_by_row_data (GTK_CTREE (ctree), NULL, (struct master *) list->data);
		list = list->next;
	}

	node = gtk_ctree_insert_node (GTK_CTREE (ctree), NULL, sibling, NULL, 4, NULL, NULL, NULL, NULL, FALSE, expanded);
	gtk_ctree_node_set_row_data (GTK_CTREE (ctree), node, m);
	source_ctree_show_node_status (ctree, m);
}
Пример #9
0
Файл: xqf-ui.c Проект: IR4T4/xqf
void ui_done (void) {
	GtkCTreeNode *node;
	char cfgkey[128];
	int expanded;
	GSList *list;
	struct master *m;

	save_cwidget_geometry (GTK_WIDGET (server_clist), &server_clist_def);
	save_cwidget_geometry (GTK_WIDGET (player_clist), &player_clist_def);
	save_cwidget_geometry (GTK_WIDGET (srvinf_ctree), &srvinf_clist_def);

	config_push_prefix ("/" CONFIG_FILE "/Main Window Geometry/");

	config_set_int ("height", main_window->allocation.height);
	config_set_int ("width", main_window->allocation.width);
	config_set_int ("pane1", GTK_PANED (pane1_widget)->child1->allocation.width);
	config_set_int ("pane2", GTK_PANED (pane2_widget)->child1->allocation.height);
	config_set_int ("pane3", GTK_PANED (pane3_widget)->child1->allocation.width);

	config_pop_prefix ();

	config_clean_section ("/" CONFIG_FILE "/Source Tree");

	for (list = master_groups; list; list = list->next) {
		m = (struct master *) list->data;
		if (m->isgroup) {
			node = gtk_ctree_find_by_row_data (GTK_CTREE (source_ctree), NULL, m);
			if (node) {
				gtk_ctree_get_node_info (GTK_CTREE (source_ctree), node,
						NULL, NULL, NULL, NULL, NULL, NULL, NULL, &expanded);
				if (!expanded) {
					g_snprintf (cfgkey, 128, "/" CONFIG_FILE "/Source Tree/%s node collapsed=false", m->name);
					config_set_bool (cfgkey, TRUE - expanded);
				}
			}
		}
	}
}
Пример #10
0
void save_script_prefs() {
	GList* s;
	char path[PATH_MAX];

	for (s = scripts; s; s = g_list_next(s)) {
		Script* script;
		GSList* optlist;

		script = g_datalist_get_data(&scriptdata, s->data);

		if (!script) {
			xqf_error("no data for script %s", s->data);
			continue;
		}

		snprintf(path, sizeof(path), "/" CONFIG_FILE "/scripts/%s", (char*)s->data);
		config_push_prefix(path);

		for (optlist = script->options; optlist; optlist = g_slist_next(optlist)) {
			ScriptOption* opt = optlist->data;
			const char* val = NULL;
			int enable = 0;

			switch(opt->type) {
				case SCRIPT_OPTION_TYPE_STRING:
				case SCRIPT_OPTION_TYPE_INT:
				case SCRIPT_OPTION_TYPE_LIST:
					val = gtk_entry_get_text(GTK_ENTRY(opt->widget));

					if (!strlen(val)) {
						val = NULL;
					}

					if ((!val && opt->defval) || (val && !opt->defval) || (val && opt->defval && strcmp(opt->defval, val))) {
						g_free(opt->defval);
						debug(4, "set %s/%s=%s (before: %s)", s->data, opt->section, val, opt->defval);
						if (opt->type == SCRIPT_OPTION_TYPE_INT) {
							int tmp = val?atoi(val):0;
							config_set_int(opt->section, tmp);
							opt->defval = g_strdup_printf("%d", tmp);
						}
						else {
							config_set_string(opt->section, val?val:"");
							opt->defval = val?strdup(val):NULL;
						}
					}
					break;
				case SCRIPT_OPTION_TYPE_BOOL:
					enable = GTK_TOGGLE_BUTTON(opt->widget)->active;
					if (enable != opt->enable) {
						config_set_bool(opt->section, enable);
						debug(4, "set %s/%s=%d", s->data, opt->section, enable);
						opt->enable = enable;
					}
					break;
				case SCRIPT_OPTION_TYPE_INVALID:
					break;
			}
		}

		config_pop_prefix();
	}
}
Пример #11
0
/** 
 * video_shader_write_conf_cgp:
 * @conf              : Preset file to read from.
 * @shader            : Shader passes handle.
 *
 * Saves preset and all associated state (passes,
 * textures, imports, etc) to disk. 
 **/
void video_shader_write_conf_cgp(config_file_t *conf,
      struct video_shader *shader)
{
   unsigned i;

   config_set_int(conf, "shaders", shader->passes);
   if (shader->feedback_pass >= 0)
      config_set_int(conf, "feedback_pass", shader->feedback_pass);

   for (i = 0; i < shader->passes; i++)
   {
      char key[64] = {0};
      const struct video_shader_pass *pass = &shader->pass[i];

      snprintf(key, sizeof(key), "shader%u", i);
      config_set_string(conf, key, pass->source.path);

      if (pass->filter != RARCH_FILTER_UNSPEC)
      {
         snprintf(key, sizeof(key), "filter_linear%u", i);
         config_set_bool(conf, key, pass->filter == RARCH_FILTER_LINEAR);
      }

      snprintf(key, sizeof(key), "wrap_mode%u", i);
      config_set_string(conf, key, wrap_mode_to_str(pass->wrap));

      if (pass->frame_count_mod)
      {
         snprintf(key, sizeof(key), "frame_count_mod%u", i);
         config_set_int(conf, key, pass->frame_count_mod);
      }

      snprintf(key, sizeof(key), "mipmap_input%u", i);
      config_set_bool(conf, key, pass->mipmap);

      snprintf(key, sizeof(key), "alias%u", i);
      config_set_string(conf, key, pass->alias);

      shader_write_fbo(conf, &pass->fbo, i);
   }

   if (shader->num_parameters)
   {
      char parameters[4096] = {0};

      strlcpy(parameters, shader->parameters[0].id, sizeof(parameters));

      for (i = 1; i < shader->num_parameters; i++)
      {
         /* O(n^2), but number of parameters is very limited. */
         strlcat(parameters, ";", sizeof(parameters));
         strlcat(parameters, shader->parameters[i].id, sizeof(parameters));
      }

      config_set_string(conf, "parameters", parameters);
      
      for (i = 0; i < shader->num_parameters; i++)
         config_set_float(conf, shader->parameters[i].id,
               shader->parameters[i].current);
   }

   if (shader->luts)
   {
      char textures[4096] = {0};

      strlcpy(textures, shader->lut[0].id, sizeof(textures));
      for (i = 1; i < shader->luts; i++)
      {
         /* O(n^2), but number of textures is very limited. */
         strlcat(textures, ";", sizeof(textures));
         strlcat(textures, shader->lut[i].id, sizeof(textures));
      }

      config_set_string(conf, "textures", textures);

      for (i = 0; i < shader->luts; i++)
      {
         char key[64] = {0};

         config_set_string(conf, shader->lut[i].id, shader->lut[i].path);

         if (shader->lut[i].filter != RARCH_FILTER_UNSPEC)
         {
            snprintf(key, sizeof(key), "%s_linear", shader->lut[i].id);
            config_set_bool(conf, key, 
                  shader->lut[i].filter == RARCH_FILTER_LINEAR);
         }

         snprintf(key, sizeof(key), "%s_wrap_mode", shader->lut[i].id);
         config_set_string(conf, key, wrap_mode_to_str(shader->lut[i].wrap));

         snprintf(key, sizeof(key), "%s_mipmap", shader->lut[i].id);
         config_set_bool(conf, key, shader->lut[i].mipmap);
      }
   }

   if (*shader->script_path)
      config_set_string(conf, "import_script", shader->script_path);
   if (*shader->script_class)
      config_set_string(conf, "import_script_class", shader->script_class);

   if (shader->variables)
   {
      char variables[4096] = {0};

      strlcpy(variables, shader->variable[0].id, sizeof(variables));

      for (i = 1; i < shader->variables; i++)
      {
         strlcat(variables, ";", sizeof(variables));
         strlcat(variables, shader->variable[i].id, sizeof(variables));
      }

      config_set_string(conf, "imports", variables);

      for (i = 0; i < shader->variables; i++)
         shader_write_variable(conf, &shader->variable[i]);
   }
}
Пример #12
0
void rarch_config_save(const char * conf_name)
{
   if(!path_file_exists(conf_name))
      rarch_config_create_default(conf_name);
   else
   {
      config_file_t * conf = config_file_new(conf_name);

      if(conf == NULL)
         conf = config_file_new(NULL);

      // g_settings
      config_set_string(conf, "libretro_path", g_settings.libretro);
#ifdef HAVE_XML
      config_set_string(conf, "cheat_database_path", g_settings.cheat_database);
#endif
      config_set_bool(conf, "rewind_enable", g_settings.rewind_enable);
      config_set_string(conf, "video_cg_shader", g_settings.video.cg_shader_path);
      config_set_float(conf, "video_aspect_ratio", g_settings.video.aspect_ratio);
#ifdef HAVE_FBO
      config_set_float(conf, "video_fbo_scale_x", g_settings.video.fbo_scale_x);
      config_set_float(conf, "video_fbo_scale_y", g_settings.video.fbo_scale_y);
      config_set_string(conf, "video_second_pass_shader", g_settings.video.second_pass_shader);
      config_set_bool(conf, "video_render_to_texture", g_settings.video.render_to_texture);
      config_set_bool(conf, "video_second_pass_smooth", g_settings.video.second_pass_smooth);
#endif
      config_set_bool(conf, "video_smooth", g_settings.video.smooth);
      config_set_bool(conf, "video_vsync", g_settings.video.vsync);
      config_set_string(conf, "audio_device", g_settings.audio.device);

      for (unsigned i = 0; i < 7; i++)
      {
         char cfg[64];
	 snprintf(cfg, sizeof(cfg), "input_dpad_emulation_p%u", i + 1);
	 config_set_int(conf, cfg, g_settings.input.dpad_emulation[i]);
      }

#ifdef RARCH_CONSOLE
      config_set_bool(conf, "fbo_enabled", g_console.fbo_enabled);
#ifdef __CELLOS_LV2__
      config_set_bool(conf, "custom_bgm_enable", g_console.custom_bgm_enable);
#endif
      config_set_bool(conf, "overscan_enable", g_console.overscan_enable);
      config_set_bool(conf, "screenshots_enable", g_console.screenshots_enable);
#ifdef _XBOX
      config_set_bool(conf, "gamma_correction_enable", g_console.gamma_correction_enable);
      config_set_int(conf, "color_format", g_console.color_format);
#endif
      config_set_bool(conf, "throttle_enable", g_console.throttle_enable);
      config_set_bool(conf, "triple_buffering_enable", g_console.triple_buffering_enable);
      config_set_bool(conf, "info_msg_enable", g_console.info_msg_enable);
      config_set_int(conf, "sound_mode", g_console.sound_mode);
      config_set_int(conf, "aspect_ratio_index", g_console.aspect_ratio_index);
      config_set_int(conf, "current_resolution_id", g_console.current_resolution_id);
      config_set_int(conf, "custom_viewport_width", g_console.viewports.custom_vp.width);
      config_set_int(conf, "custom_viewport_height", g_console.viewports.custom_vp.height);
      config_set_int(conf, "custom_viewport_x", g_console.viewports.custom_vp.x);
      config_set_int(conf, "custom_viewport_y", g_console.viewports.custom_vp.y);
      config_set_int(conf, "screen_orientation", g_console.screen_orientation);
      config_set_string(conf, "default_rom_startup_dir", g_console.default_rom_startup_dir);
      config_set_float(conf, "menu_font_size", g_console.menu_font_size);
      config_set_float(conf, "overscan_amount", g_console.overscan_amount);
#endif

      // g_extern
      config_set_int(conf, "state_slot", g_extern.state_slot);
      config_set_int(conf, "audio_mute", g_extern.audio_data.mute);

      if (!config_file_write(conf, conf_name))
         RARCH_ERR("Failed to write config file to \"%s\". Check permissions.\n", conf_name);

      free(conf);
   }
}
Пример #13
0
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//plugin_message
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
int plugin_message(int tokencount, char *tokens[], bool from_core, module* caller)
{
	char *filename;

	if (tokencount == 3 && !stricmp(tokens[2], szBActionSave))
	{
		config_save(config_path_mainscript);
		return 0;
	}
	else if (!stricmp(tokens[2], szBActionSaveAs))
	{
		if (tokencount == 4)
		{
			config_save(tokens[3]);
		}
		else
		{       
			if ((filename = dialog_file(szFilterScript, "Save Configuration Script", ".rc", config_path_plugin, true)))
			{
				config_save(filename);
			}           
		}       
		return 0;
	}
	else if (tokencount == 3 && !stricmp(tokens[2], szBActionRevert))
	{
		plugin_reconfigure(true);
		return 0;
	}
	else if (!stricmp(tokens[2], szBActionLoad))
	{
		if (tokencount == 4)
		{
			config_load2(tokens[3], caller);
			return 0;
		}
		else if (tokencount == 3)
		{
			if ((filename = dialog_file(szFilterScript, "Load Configuration Script", ".rc", config_path_plugin, false)))
			{
				config_load2(filename, caller);
			}
			return 0;
		}
		else if (tokencount == 6)
		{
			if (0 == stricmp(tokens[4], "from"))
			{
				config_load(tokens[5], caller, tokens[3]);
				return 0;
			} else if (0 == stricmp(tokens[4], "into"))
			{
				config_load(tokens[3], module_get(tokens[5]));
				return 0;
			}
		}
		else if (tokencount == 8 && 0 == stricmp(tokens[4], "from") && 0 == stricmp(tokens[6], "into"))
		{
			config_load(tokens[5], module_get(tokens[7]), tokens[3]);
			return 0;
		}
	}
	else if (!stricmp(tokens[2], szBActionAbout))
	{
		if (tokencount == 3)
		{
			MessageBox(NULL, szPluginAbout, szVersion, MB_OK|MB_SYSTEMMODAL);
			return 0;
		}
		else if (tokencount == 4 && !stricmp(tokens[3], "LastControl"))
		{
			MessageBox(NULL, szPluginAboutLastControl, szAppName, MB_OK|MB_SYSTEMMODAL);
			return 0;
		}
		else if (tokencount == 4 && !stricmp(tokens[3], "QuickHelp"))
		{
			MessageBox(NULL, szPluginAboutQuickRef, szAppName, MB_OK|MB_SYSTEMMODAL);
			return 0;
		}
	}
	else if (!stricmp(tokens[2], szBActionEdit))
	{
		//SendMessage(plugin_hwnd_blackbox, BB_EDITFILE, (WPARAM)-1, (LPARAM) config_path_mainscript);
		//return 0;
		char temp[MAX_PATH]; GetBlackboxEditor(temp);
		BBExecute(NULL, "",temp , config_path_mainscript, NULL, SW_SHOWNORMAL, false);
		return 0;
	}
	else if (tokencount == 5 && !stricmp(tokens[2], szBActionSetPluginProperty))
	{
		for (struct plugin_properties *p = plugin_properties; p->key; p++)
			if (p->data && 0 == stricmp(tokens[3], p->key)) {
				switch (p->type) {
					case M_BOL:
						if (config_set_bool(tokens[4], (bool*)p->data)) break; return 1;
					case M_INT:
						if (config_set_int(tokens[4], (int*)p->data)) break; return 1;
					case M_STR:
						if (config_set_str(tokens[4], (char**)p->data)) break; return 1;
					default: return 1;
				}
				if (p->update) control_invalidate();
				if (from_core) menu_update_global();
				return 0;
			}
	}
	else if (tokencount == 4 && !stricmp(tokens[2], szBActionOnLoad) )
	{
		config_set_str(tokens[3],&(globalmodule.actions[MODULE_ACTION_ONLOAD]));
		return 0;
	}
	else if (tokencount == 4 && !stricmp(tokens[2], szBActionOnUnload) )
	{
		config_set_str(tokens[3],&(globalmodule.actions[MODULE_ACTION_ONUNLOAD]));
		return 0;
	}
	return 1;
}
Пример #14
0
static config_file_t *open_default_config_file(void)
{
   config_file_t *conf = NULL;

#if defined(_WIN32) && !defined(_XBOX)
   char conf_path[PATH_MAX];

   char app_path[PATH_MAX];
   fill_pathname_application_path(app_path, sizeof(app_path));
   fill_pathname_resolve_relative(conf_path, app_path, "retroarch.cfg", sizeof(conf_path));

   conf = config_file_new(conf_path);
   if (!conf)
   {
      const char *appdata = getenv("APPDATA");
      if (appdata)
      {
         fill_pathname_join(conf_path, appdata, "retroarch.cfg", sizeof(conf_path));
         conf = config_file_new(conf_path);
      }
   }

   // Try to create a new config file.
   if (!conf)
   {
      conf = config_file_new(NULL);
      bool saved = false;
      if (conf) // Since this is a clean config file, we can safely use config_save_on_exit.
      {
         fill_pathname_resolve_relative(conf_path, app_path, "retroarch.cfg", sizeof(conf_path));
         config_set_bool(conf, "config_save_on_exit", true);
         saved = config_file_write(conf, conf_path);
      }

      if (saved)
         RARCH_WARN("Created new config file in: \"%s\".\n", conf_path); // WARN here to make sure user has a good chance of seeing it.
      else
      {
         RARCH_ERR("Failed to create new config file in: \"%s\".\n", conf_path);
         config_file_free(conf);
         conf = NULL;
      }
   }

   if (conf)
      strlcpy(g_extern.config_path, conf_path, sizeof(g_extern.config_path));
#elif !defined(__CELLOS_LV2__) && !defined(_XBOX)
   char conf_path[PATH_MAX];
   const char *xdg  = getenv("XDG_CONFIG_HOME");
   const char *home = getenv("HOME");

   // XDG_CONFIG_HOME falls back to $HOME/.config.
   if (xdg)
      fill_pathname_join(conf_path, xdg, "retroarch/retroarch.cfg", sizeof(conf_path));
   else if (home)
      fill_pathname_join(conf_path, home, ".config/retroarch/retroarch.cfg", sizeof(conf_path));

   if (xdg || home)
   {
      RARCH_LOG("Looking for config in: \"%s\".\n", conf_path);
      conf = config_file_new(conf_path);
   }

   // Fallback to $HOME/.retroarch.cfg.
   if (!conf && home)
   {
      fill_pathname_join(conf_path, home, ".retroarch.cfg", sizeof(conf_path));
      RARCH_LOG("Looking for config in: \"%s\".\n", conf_path);
      conf = config_file_new(conf_path);
   }

   // Try to create a new config file.
   if (!conf && (home || xdg))
   {
      // XDG_CONFIG_HOME falls back to $HOME/.config.
      if (xdg)
         fill_pathname_join(conf_path, xdg, "retroarch/retroarch.cfg", sizeof(conf_path));
      else if (home)
         fill_pathname_join(conf_path, home, ".config/retroarch/retroarch.cfg", sizeof(conf_path));

      char basedir[PATH_MAX];
      fill_pathname_basedir(basedir, conf_path, sizeof(basedir));

      if (path_mkdir(basedir))
      {
#ifndef GLOBAL_CONFIG_DIR
#define GLOBAL_CONFIG_DIR "/etc"
#endif
         char skeleton_conf[PATH_MAX];
         fill_pathname_join(skeleton_conf, GLOBAL_CONFIG_DIR, "retroarch.cfg", sizeof(skeleton_conf));
         conf = config_file_new(skeleton_conf);
         if (conf)
            RARCH_WARN("Using skeleton config \"%s\" as base for a new config file.\n", skeleton_conf);
         else
            conf = config_file_new(NULL);

         bool saved = false;
         if (conf)
         {
            config_set_bool(conf, "config_save_on_exit", true); // Since this is a clean config file, we can safely use config_save_on_exit.
            saved = config_file_write(conf, conf_path);
         }

         if (saved)
            RARCH_WARN("Created new config file in: \"%s\".\n", conf_path); // WARN here to make sure user has a good chance of seeing it.
         else
         {
            RARCH_ERR("Failed to create new config file in: \"%s\".\n", conf_path);
            config_file_free(conf);
            conf = NULL;
         }
      }
   }

   if (conf)
      strlcpy(g_extern.config_path, conf_path, sizeof(g_extern.config_path));
#endif
   
   return conf;
}
Пример #15
0
/**
 * video_shader_write_conf_cgp:
 * @conf              : Preset file to read from.
 * @shader            : Shader passes handle.
 *
 * Saves preset and all associated state (passes,
 * textures, imports, etc) to disk.
 **/
void video_shader_write_conf_cgp(config_file_t *conf,
      struct video_shader *shader)
{
   unsigned i;

   config_set_int(conf, "shaders", shader->passes);
   if (shader->feedback_pass >= 0)
      config_set_int(conf, "feedback_pass", shader->feedback_pass);

   for (i = 0; i < shader->passes; i++)
   {
      char key[64];
      size_t tmp_size = PATH_MAX_LENGTH * sizeof(char);
      char *tmp       = (char*)malloc(PATH_MAX_LENGTH * sizeof(char));
      const struct video_shader_pass *pass = &shader->pass[i];

      key[0] = '\0';

      snprintf(key, sizeof(key), "shader%u", i);
      strlcpy(tmp, pass->source.path, tmp_size);

      if (!path_is_absolute(tmp))
         path_resolve_realpath(tmp, tmp_size);
      config_set_string(conf, key, tmp);

      free(tmp);

      if (pass->filter != RARCH_FILTER_UNSPEC)
      {
         snprintf(key, sizeof(key), "filter_linear%u", i);
         config_set_bool(conf, key, pass->filter == RARCH_FILTER_LINEAR);
      }

      snprintf(key, sizeof(key), "wrap_mode%u", i);
      config_set_string(conf, key, wrap_mode_to_str(pass->wrap));

      if (pass->frame_count_mod)
      {
         snprintf(key, sizeof(key), "frame_count_mod%u", i);
         config_set_int(conf, key, pass->frame_count_mod);
      }

      snprintf(key, sizeof(key), "mipmap_input%u", i);
      config_set_bool(conf, key, pass->mipmap);

      snprintf(key, sizeof(key), "alias%u", i);
      config_set_string(conf, key, pass->alias);

      shader_write_fbo(conf, &pass->fbo, i);
   }

   if (shader->num_parameters)
   {
      size_t param_size = 4096 * sizeof(char);
      char *parameters  = (char*)malloc(4096 * sizeof(char));

      parameters[0] = '\0';

      strlcpy(parameters, shader->parameters[0].id, param_size);

      for (i = 1; i < shader->num_parameters; i++)
      {
         /* O(n^2), but number of parameters is very limited. */
         strlcat(parameters, ";", param_size);
         strlcat(parameters, shader->parameters[i].id, param_size);
      }

      config_set_string(conf, "parameters", parameters);

      for (i = 0; i < shader->num_parameters; i++)
         config_set_float(conf, shader->parameters[i].id,
               shader->parameters[i].current);
      free(parameters);
   }

   if (shader->luts)
   {
      size_t tex_size = 4096 * sizeof(char);
      char *textures  = (char*)malloc(4096 * sizeof(char));

      textures[0] = '\0';

      strlcpy(textures, shader->lut[0].id, tex_size);
      for (i = 1; i < shader->luts; i++)
      {
         /* O(n^2), but number of textures is very limited. */
         strlcat(textures, ";", tex_size);
         strlcat(textures, shader->lut[i].id, tex_size);
      }

      config_set_string(conf, "textures", textures);

      free(textures);

      for (i = 0; i < shader->luts; i++)
      {
         char key[64];

         key[0] = '\0';

         config_set_string(conf, shader->lut[i].id, shader->lut[i].path);

         if (shader->lut[i].filter != RARCH_FILTER_UNSPEC)
         {
            snprintf(key, sizeof(key), "%s_linear", shader->lut[i].id);
            config_set_bool(conf, key,
                  shader->lut[i].filter == RARCH_FILTER_LINEAR);
         }

         snprintf(key, sizeof(key),
               "%s_wrap_mode", shader->lut[i].id);
         config_set_string(conf, key,
               wrap_mode_to_str(shader->lut[i].wrap));

         snprintf(key, sizeof(key),
               "%s_mipmap", shader->lut[i].id);
         config_set_bool(conf, key,
               shader->lut[i].mipmap);
      }
   }

   if (*shader->script_path)
      config_set_string(conf, "import_script", shader->script_path);
   if (*shader->script_class)
      config_set_string(conf, "import_script_class", shader->script_class);

   if (shader->variables)
   {
      size_t var_tmp  = 4096 * sizeof(char);
      char *variables = (char*)malloc(4096 * sizeof(char));

      variables[0] = '\0';

      strlcpy(variables, shader->variable[0].id, var_tmp);

      for (i = 1; i < shader->variables; i++)
      {
         strlcat(variables, ";", var_tmp);
         strlcat(variables, shader->variable[i].id, var_tmp);
      }

      config_set_string(conf, "imports", variables);

      for (i = 0; i < shader->variables; i++)
         shader_write_variable(conf, &shader->variable[i]);
      free(variables);
   }
}
Пример #16
0
int rc_parse (void) {
  char *fn;
  struct keyword *kw;

  fn = file_in_dir (user_rcdir, RC_FILE);
  rc_open (fn);
  g_free (fn);

  if(!rc)
    return -1;

  while ((token = rc_next_token ()) != TOKEN_EOF) {

    switch (token) {

    case TOKEN_KEYWORD:
      for (kw = keywords; kw->name; kw++) {
	if (strcmp (token_str, kw->name) == 0) {

	  switch (kw->required) {
	  case KEYWORD_INT:
	    if (rc_expect_token (TOKEN_INT))
	      config_set_int (kw->config, token_int);
	    break;

	  case KEYWORD_BOOL:
	    if (rc_expect_token (TOKEN_INT))
	      config_set_bool (kw->config, token_int);
	    break;

	  case KEYWORD_STRING:
	    if (rc_expect_token (TOKEN_STRING))
	      config_set_string (kw->config, token_str);
	    break;
	  }

	  break;
	}
      }
      break;

    case TOKEN_EOL:
    case TOKEN_EOF:
      break;

    default:
      syntax_error ();
      rc_skip_to_eol ();
      break;

    } /* switch */
  } /* while */

  rc_close ();

  /* Compatibility with old versions */

  if (!games[Q1_SERVER].dir && games[QW_SERVER].dir) {
    games[Q1_SERVER].dir = g_strdup (games[QW_SERVER].dir);
    config_set_string ("/" CONFIG_FILE "/Game: QS/dir", games[Q1_SERVER].dir);
  }

  if (default_w_switch < 0) default_w_switch = 0;
  if (default_b_switch < 0) default_b_switch = 0;

  return 0;
}
Пример #17
0
void config_parse( stream_t* stream, hash_t filter_section, bool overwrite )
{
	char* buffer;
	hash_t section = 0;
	hash_t key = 0;
	unsigned int line = 0;

#if BUILD_ENABLE_DEBUG_CONFIG
	log_debugf( HASH_CONFIG, "Parsing config stream: %s", stream_path( stream ) );
#endif
	buffer = memory_allocate_zero( 1024ULL, 0, MEMORY_TEMPORARY );
	while( !stream_eos( stream ) )
	{
		++line;
		stream_read_line_buffer( stream, buffer, 1024, '\n' );
		string_strip( buffer, " \t\n\r" );
		if( !string_length( buffer ) || ( buffer[0] == ';' ) || ( buffer[0] == '#' ) )
			continue;
		if( buffer[0] == '[' )
		{
			//Section declaration
			unsigned int endpos = string_rfind( buffer, ']', string_length( buffer ) - 1 );
			if( ( endpos == STRING_NPOS ) || ( endpos < 1 ) )
			{
				log_warnf( HASH_CONFIG, WARNING_BAD_DATA, "Invalid section declaration on line %d in config stream '%s'", line, stream_path( stream ) );
				continue;
			}
			buffer[endpos] = 0;
			section = hash( buffer + 1, endpos - 1 );
#if BUILD_ENABLE_DEBUG_CONFIG
			log_debugf( HASH_CONFIG, "  config: section set to '%s' (0x%llx)", buffer + 1, section );
#endif
		}
		else if( !filter_section || ( filter_section == section ) )
		{
			//name=value declaration
			char* name;
			char* value;
			unsigned int separator = string_find( buffer, '=', 0 );
			if( separator == STRING_NPOS )
			{
				log_warnf( HASH_CONFIG, WARNING_BAD_DATA, "Invalid value declaration on line %d in config stream '%s', missing assignment operator '=': %s", line, stream_path( stream ), buffer );
				continue;
			}
			
			name = string_strip_substr( buffer, " \t", separator );
			value = string_strip( buffer + separator + 1, " \t" );
			if( !string_length( name ) )
			{
				log_warnf( HASH_CONFIG, WARNING_BAD_DATA, "Invalid value declaration on line %d in config stream '%s', empty name string", line, stream_path( stream ) );
				continue;
			}

			key = hash( name, string_length( name ) );

			if( overwrite || !config_key( section, key, false ) )
			{
#if BUILD_ENABLE_DEBUG_CONFIG
				log_debugf( HASH_CONFIG, "  config: %s (0x%llx) = %s", name, key, value );
#endif

				if( !string_length( value ) )
					config_set_string( section, key, "" );
				else if( string_equal( value, "false" ) )
					config_set_bool( section, key, false );
				else if( string_equal( value, "true" ) )
					config_set_bool( section, key, true );
				else if( ( string_find( value, '.', 0 ) != STRING_NPOS ) && ( string_find_first_not_of( value, "0123456789.", 0 ) == STRING_NPOS ) && ( string_find( value, '.', string_find( value, '.', 0 ) + 1 ) == STRING_NPOS ) ) //Exactly one "."
					config_set_real( section, key, string_to_real( value ) );
				else if( string_find_first_not_of( value, "0123456789", 0 ) == STRING_NPOS )
					config_set_int( section, key, string_to_int64( value ) );
				else
					config_set_string( section, key, value );
			}
		}
	}
	memory_deallocate( buffer );
}
Пример #18
0
void rarch_config_save(const char * conf_name)
{
      config_file_t * conf = config_file_new(conf_name);

      if(!conf)
      {
         RARCH_ERR("Failed to write config file to \"%s\". Check permissions.\n", conf_name);
         return;
      }

      // g_settings
      config_set_string(conf, "libretro_path", g_settings.libretro);
#ifdef HAVE_XML
      config_set_string(conf, "cheat_database_path", g_settings.cheat_database);
#endif
      config_set_bool(conf, "rewind_enable", g_settings.rewind_enable);
      config_set_string(conf, "video_cg_shader", g_settings.video.cg_shader_path);
      config_set_float(conf, "video_aspect_ratio", g_settings.video.aspect_ratio);
#ifdef HAVE_FBO
      config_set_float(conf, "video_fbo_scale_x", g_settings.video.fbo.scale_x);
      config_set_float(conf, "video_fbo_scale_y", g_settings.video.fbo.scale_y);
      config_set_string(conf, "video_second_pass_shader", g_settings.video.second_pass_shader);
      config_set_bool(conf, "video_render_to_texture", g_settings.video.render_to_texture);
      config_set_bool(conf, "video_second_pass_smooth", g_settings.video.second_pass_smooth);
      config_set_bool(conf, "fbo_enabled", g_settings.video.fbo.enable);
#endif
      config_set_bool(conf, "video_smooth", g_settings.video.smooth);
      config_set_bool(conf, "video_vsync", g_settings.video.vsync);
      config_set_int(conf, "aspect_ratio_index", g_settings.video.aspect_ratio_idx);
      config_set_int(conf, "color_format", g_settings.video.color_format);
      config_set_string(conf, "audio_device", g_settings.audio.device);
      config_set_bool(conf, "audio_rate_control", g_settings.audio.rate_control);
      config_set_float(conf, "audio_rate_control_delta", g_settings.audio.rate_control_delta);

      for (unsigned i = 0; i < 7; i++)
      {
         char cfg[64];
         snprintf(cfg, sizeof(cfg), "input_dpad_emulation_p%u", i + 1);
         config_set_int(conf, cfg, g_settings.input.dpad_emulation[i]);
         snprintf(cfg, sizeof(cfg), "input_device_p%u", i + 1);
         config_set_int(conf, cfg, g_settings.input.device[i]);
      }

      config_set_bool(conf, "overscan_enable", g_extern.console.screen.state.overscan.enable);
      config_set_bool(conf, "screenshots_enable", g_extern.console.screen.state.screenshots.enable);
      config_set_bool(conf, "gamma_correction", g_extern.console.screen.gamma_correction);
#ifdef _XBOX1
      config_set_int(conf, "flicker_filter", g_extern.console.screen.state.flicker_filter.value);
      config_set_int(conf, "sound_volume_level", g_extern.console.sound.volume_level);
#endif
      config_set_bool(conf, "throttle_enable", g_extern.console.screen.state.throttle.enable);
      config_set_bool(conf, "triple_buffering_enable", g_extern.console.screen.state.triple_buffering.enable);
      config_set_bool(conf, "info_msg_enable", g_extern.console.rmenu.state.msg_info.enable);
      config_set_int(conf, "current_resolution_id", g_extern.console.screen.resolutions.current.id);
      config_set_int(conf, "custom_viewport_width", g_extern.console.screen.viewports.custom_vp.width);
      config_set_int(conf, "custom_viewport_height", g_extern.console.screen.viewports.custom_vp.height);
      config_set_int(conf, "custom_viewport_x", g_extern.console.screen.viewports.custom_vp.x);
      config_set_int(conf, "custom_viewport_y", g_extern.console.screen.viewports.custom_vp.y);
      config_set_string(conf, "default_rom_startup_dir", g_extern.console.main_wrap.paths.default_rom_startup_dir);
      config_set_float(conf, "menu_font_size", g_extern.console.rmenu.font_size);
      config_set_float(conf, "overscan_amount", g_extern.console.screen.overscan_amount);
#ifdef HAVE_ZLIB
      config_set_int(conf, "zip_extract_mode", g_extern.file_state.zip_extract_mode);
#endif

      // g_extern
      config_set_int(conf, "sound_mode", g_extern.console.sound.mode);
      config_set_int(conf, "state_slot", g_extern.state_slot);
      config_set_int(conf, "audio_mute", g_extern.audio_data.mute);
      config_set_bool(conf, "soft_display_filter_enable", g_extern.console.screen.state.soft_filter.enable);
      config_set_int(conf, "screen_orientation", g_extern.console.screen.orientation);
      config_set_bool(conf, "custom_bgm_enable", g_extern.console.sound.custom_bgm.enable);

      if (!config_file_write(conf, conf_name))
         RARCH_ERR("Failed to write config file to \"%s\". Check permissions.\n", conf_name);

      free(conf);
}
Пример #19
0
LRESULT CALLBACK PaletteProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
	LPNMHDR nmhdr;
	static char tmpstr[1024];
	char *ptr;
	int i;
	int reinitvideo = 0;

	switch(message) {
		case WM_INITDIALOG:
			CheckDlgButton(hDlg,IDC_FRAMELIMITCHECK,config_get_bool("video.framelimit") ? BST_CHECKED : BST_UNCHECKED);

			//video filters
			ptr = config_get_string("video.filter");
			for(i=0;filters[i];i++) {
				ComboBox_AddString(GetDlgItem(hDlg,IDC_FILTERCOMBO),filters[i]);
				if(stricmp(filters[i],ptr) == 0)
					ComboBox_SetCurSel(GetDlgItem(hDlg,IDC_FILTERCOMBO),i);
			}

			//scale
			for(i=0;scales[i];i++) {
				ComboBox_AddString(GetDlgItem(hDlg,IDC_SCALECOMBO),scales[i]);
				if((i + 1) == config_get_int("video.scale"))
					ComboBox_SetCurSel(GetDlgItem(hDlg,IDC_SCALECOMBO),i);
			}

			//port1 input devices
			ptr = config_get_string("input.port0");
			for(i=0;inputdevices[i];i++) {
				ComboBox_AddString(GetDlgItem(hDlg,IDC_PORT1COMBO),inputdevices[i]);
				if(stricmp(inputdevices[i],ptr) == 0)
					ComboBox_SetCurSel(GetDlgItem(hDlg,IDC_PORT1COMBO),i);
			}

			//port2 input devices
			ptr = config_get_string("input.port1");
			for(i=0;inputdevices[i];i++) {
				ComboBox_AddString(GetDlgItem(hDlg,IDC_PORT2COMBO),inputdevices[i]);
				if(stricmp(inputdevices[i],ptr) == 0)
					ComboBox_SetCurSel(GetDlgItem(hDlg,IDC_PORT2COMBO),i);
			}

			//expansion port devices
			ptr = config_get_string("input.expansion");
			for(i=0;inputexpansion[i];i++) {
				ComboBox_AddString(GetDlgItem(hDlg,IDC_EXPANSIONCOMBO),inputexpansion[i]);
				if(stricmp(inputexpansion[i],ptr) == 0)
					ComboBox_SetCurSel(GetDlgItem(hDlg,IDC_EXPANSIONCOMBO),i);
			}

			return(TRUE);

		case WM_NOTIFY:
			nmhdr = (LPNMHDR)lParam;
			switch(nmhdr->code) {
				case PSN_APPLY:
					config_set_bool("video.framelimit",IsDlgButtonChecked(hDlg,IDC_FRAMELIMITCHECK) ? 1 : 0);
					ptr = mem_strdup(config_get_string("video.filter"));
					GetDlgItemText_SetConfig(hDlg,IDC_FILTERCOMBO,"video.filter");
					if(stricmp(ptr,config_get_string("video.filter")) != 0) {
						reinitvideo = 1;
					}
					mem_free(ptr);
					i = ComboBox_GetCurSel(GetDlgItem(hDlg,IDC_SCALECOMBO));
					if(i != CB_ERR) {
						if(config_get_int("video.scale") != (i + 1)) {
							config_set_int("video.scale",i + 1);
							reinitvideo = 1;
						}
					}
					if(reinitvideo) {
						video_reinit();
					}
					GetDlgItemText_SetConfig(hDlg,IDC_PORT1COMBO,"input.port0");
					GetDlgItemText_SetConfig(hDlg,IDC_PORT2COMBO,"input.port1");
					nes_set_inputdev(0,get_device_id(config_get_string("input.port0")));
					nes_set_inputdev(1,get_device_id(config_get_string("input.port1")));
					return(TRUE);
			}
			break;
	}
	return(FALSE);
}
Пример #20
0
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//controltype_label_message
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
int controltype_label_message(control *c, int tokencount, char *tokens[])
{
	// token strings

	enum
	{
		T_NONE          = 0,
		T_STYLE         ,
		T_VALIGN        ,
		T_HALIGN        ,
		T_HASTITLE      ,
		T_LOCKPOS       ,

		T_PLUGINLOAD    ,
		T_PLUGINUNLOAD  ,
		T_PLUGINSETPOS  ,
		T_PLUGINSHOW    ,

		T_PLUGINABOUT
	};

	extern char szWPStyle [];

	static struct token_check controltype_label_property_tokens[] =
	{
		{ szWPStyle,            T_STYLE         , 1 },
		{ "VAlign",             T_VALIGN        , 1 },
		{ "HAlign",             T_HALIGN        , 1 },
		{ "HasTitleBar",        T_HASTITLE      , 1 },
		{ "IsLocked",           T_LOCKPOS       , 1 },
		{ NULL }
	};

	static struct token_check controltype_label_plugin_property_tokens[] =
	{
		{ "IsVisible",          T_PLUGINSHOW    , 1 },
		{ "Position",           T_PLUGINSETPOS  , 2 },
		{ NULL }
	};

	static struct token_check controltype_label_plugin_tokens[] =
	{
		{ "Load",               T_PLUGINLOAD    , 1 },
		{ "Unload",             T_PLUGINUNLOAD  , 1 },
		{ "About",              T_PLUGINABOUT   , 0 },
		{ szBActionPluginSetProperty, (UINT_PTR)controltype_label_plugin_property_tokens  , 2 },
		{ NULL }
	};

	static struct token_check controltype_label_message_tokens[] =
	{
		{ szBActionSetControlProperty, (UINT_PTR)controltype_label_property_tokens, 2 },
		{ szBActionPlugin, (UINT_PTR)controltype_label_plugin_tokens, 2 },
		{ NULL }
	};

	// -----------------
	//Get the details
	controltype_label_details *details = (controltype_label_details *) c->controldetails;

	//If set control details
	int i;
	int curtok = 2;
	switch (token_check(controltype_label_message_tokens, &curtok, tokencount, tokens))
	{
		// -----------------
	case T_STYLE:
		if (-1 != (i = get_string_index(tokens[curtok], szStyleNames)))
		{
			c->windowptr->style = i;
			style_draw_invalidate(c);
			return 0;
		}
		break;

		// -----------------
	case T_HALIGN:
		if (-1 != (i = get_string_index(tokens[curtok], label_haligns)))
		{
			details->halign = i;
			controltype_label_updatesettings(details);
			style_draw_invalidate(c);
			return 0;
		}
		break;

		// -----------------
	case T_VALIGN:
		if (-1 != (i = get_string_index(tokens[curtok], label_valigns)))
		{
			details->valign = i;
			controltype_label_updatesettings(details);
			style_draw_invalidate(c);
			return 0;
		}
		break;

		// -----------------
	case T_HASTITLE:
		if (details->is_frame && config_set_bool(tokens[curtok], &details->has_titlebar))
		{
			style_draw_invalidate(c);
			return 0;
		}
		break;

		// -----------------
	case T_LOCKPOS:
		if (details->is_frame && config_set_bool(tokens[curtok], &details->is_locked))
			return 0;
		break;

		// -----------------
	case T_PLUGINLOAD:
		if (details->is_frame)
		{
			char *plugin_name = tokens[curtok];
			if (0 == strcmp(plugin_name, "*browse*"))
			{
				// "open file" dialog
				plugin_name = dialog_file("Plugins\0*.dll\0", "Add Plugin" , NULL, ".dll", false);
				if (NULL == plugin_name)
				{
					//message_override = true;
					return 2;
				}
			}
			ModuleInfo * m = loadPlugin(&details->module_info, c->windowptr->hwnd, plugin_name);
			if (m)
			{
				variables_set(false, "LastPlugin", m->module_name);
				return 0;
			}
		}
		break;

		// -----------------
	case T_PLUGINUNLOAD:
		if (unloadPlugin(&details->module_info, tokens[curtok]))
			return 0;
		break;

		// -----------------
	case T_PLUGINSETPOS:
	{
		int x, y;
		if (config_set_int(tokens[curtok], &x)
				&& config_set_int(tokens[1+curtok], &y)
				&& plugin_setpos(details->plugin_info, tokens[-2+curtok], x, y)
		   )
			return 0;

		return 0; // dont generate an error here...
	}
	break;

	// -----------------
	case T_PLUGINSHOW:
	{
		bool show;
		if (plugin_getset_show_state(details->plugin_info, tokens[-2+curtok],
									 config_set_bool(tokens[curtok], &show) ? show : 2)
		   )
			return 0;

		return 0; // dont generate an error here...
	}
	break;

	// -----------------
	case T_PLUGINABOUT:
	{
		aboutPlugins(details->module_info, c->controlname);
		return 0;
	}
	break;

	// -----------------
	//Must be an agent message
	default:
		return agent_controlmessage(c, tokencount, tokens, CONTROLTYPE_LABEL_AGENT_COUNT, details->agents, controltype_label_agentnames, controltype_label_agenttypes);
	}
	return 1;
}