[Freeciv-Dev] Re: client string options: choosing from a list (PR#1856)
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
On Mon, Jul 29, 2002 at 07:27:30PM -0700, jdorje@xxxxxxxxxxxxxxxxxxxxx wrote:
> The next step in allowing easier selection of tilesets from within the
> client is to provide the user with a list of tilesets to choose from.
>
> This patch does that, and more. It provides a list of choices for some
> of the string options; the user selects from these choices in a
> drop-down list. Only xaw has been implemented so far.
>
> Specifically, a new field is added to the client option list - this
> field contains a function that can be called to get a list of string
> options for the list (or NULL). Functions are provided to assemble
> lists of valid tilesets, soundsets, and sound plugins. For tilesets and
> soundsets, the function calls another (shared) function to search the
> data directories (with scandir; is this safe?) to assemble the list.
> For sound plugins the list is assembled easily using preprocessor macros.
>
> Changes that may affect other code include:
>
> - datafilename() has been changed so that it calls a separate function
> to get the list of data directories.
>
> - The name of the soundset only should now be specified, without the
> trailing ".spec". This matches what is done for tilesets.
>
> Changes to the interface include:
>
> - A new function, datafilelist, in shared.[ch] returns a list of files
> matching a given suffix.
>
> - New functions get_tileset_list, get_soundset_list, and
> get_soundplugin_list have been introduced. The names of these are
> consistent with each other rather than with the local code (I'm not sure
> what is best).
>
> If anyone can provide changes for the other GUI's to support the
> listings, that would be great.
A good patch.
> +/**********************************************************************
> + Returns a static, NULL-terminated list of all sound plugins
> + available on the system.
> +***********************************************************************/
> +char **get_soundplugin_list(void)
> +{
> + static char* plugin_list[] =
> + {"none",
> +#ifdef ESD
> + "esd",
> +#endif
> +#ifdef SDL
> + "sdl",
> +#endif
> +#ifdef WINMM
> + "winmm",
> +#endif
> +#ifdef AMIGA
> + "amiga",
> +#endif
> + NULL};
> +
> + return plugin_list;
> +}
This can be done without the #ifdefs. See audio_get_all_plugin_names.
> +static char *soundspec_fullname(const char *soundset_name)
> +{
> + char *soundset_default = "stdsounds"; /* Do not i18n! */
> + char *fname, *dname;
> + fname = fc_malloc(strlen(soundset_name) + 16);
The 16 seems arbitrary.
> + sprintf(fname, "%s.spec", soundset_name);
> +
> + dname = datafilename(fname);
> + if (dname
> + || strcmp(soundset_name, soundset_default) == 0) {
> + free(fname);
> + return NULL;
> + }
> +
> + return soundspec_fullname(soundset_default);
> +}
> +char **get_soundplugin_list(void);
> +char **get_soundset_list(void);
Add const.
> + /* A function to return a static NULL-terminated list of possible
> + string values, or NULL for none. */
> + char **(*p_string_vals)(void);
More const ;)
> + if (!tileset_list) {
> + /* Note: this means you must restart the client after installing a new
> + tileset. */
We can currently live with this.
> + A function passed to scandir() to check for file names matching a given
I'm not so sure if scandir is available everywhere. Maybe needs a
configure check. According to my manpage it isn't in POSIX.
Raimar
--
email: rf13@xxxxxxxxxxxxxxxxx
"That's fundamental game play! My main enemy is *ALWAYS* fighting
a 4-front war. I make sure of it!"
-- Tony Stuckey, freeciv-dev
|
|