From dc46ad57dd0baafda719511f15c1d0fecaf74ff3 Mon Sep 17 00:00:00 2001 From: David Rose Date: Mon, 25 Oct 2004 21:06:39 +0000 Subject: [PATCH] more config tweaks --- direct/src/dcparser/dcFile.cxx | 3 +-- panda/src/express/config_express.N | 1 + panda/src/express/config_express.h | 1 + panda/src/pstatclient/pStatProperties.cxx | 12 +++++----- panda/src/putil/config_util.cxx | 29 ++++++++++++++++------- panda/src/putil/config_util.h | 15 +++++++----- pandatool/src/eggbase/somethingToEgg.cxx | 2 +- 7 files changed, 39 insertions(+), 24 deletions(-) diff --git a/direct/src/dcparser/dcFile.cxx b/direct/src/dcparser/dcFile.cxx index 0e38019c98..5d4bb0c5bf 100644 --- a/direct/src/dcparser/dcFile.cxx +++ b/direct/src/dcparser/dcFile.cxx @@ -91,8 +91,7 @@ clear() { //////////////////////////////////////////////////////////////////// bool DCFile:: read_all() { - ConfigVariableList dc_files("dc-file", 0, - "The list of dc files to load."); + ConfigVariableList dc_files("dc-file", "The list of dc files to load."); if (dc_files.size() == 0) { cerr << "No files specified via dc-file Config.prc variable!\n"; diff --git a/panda/src/express/config_express.N b/panda/src/express/config_express.N index 4fd7911a86..f9e1ac0f85 100644 --- a/panda/src/express/config_express.N +++ b/panda/src/express/config_express.N @@ -18,6 +18,7 @@ forcetype ConfigVariableDouble forcetype ConfigVariableInt forcetype ConfigVariableList forcetype ConfigVariableManager +forcetype ConfigVariableSearchPath forcetype ConfigVariableString forcetype istream diff --git a/panda/src/express/config_express.h b/panda/src/express/config_express.h index fee25d0de6..7292c151d7 100644 --- a/panda/src/express/config_express.h +++ b/panda/src/express/config_express.h @@ -37,6 +37,7 @@ #include "configVariableInt.h" #include "configVariableList.h" #include "configVariableManager.h" +#include "configVariableSearchPath.h" #include "configVariableString.h" ConfigureDecl(config_express, EXPCL_PANDAEXPRESS, EXPTP_PANDAEXPRESS); diff --git a/panda/src/pstatclient/pStatProperties.cxx b/panda/src/pstatclient/pStatProperties.cxx index f1447fcc8d..6af4c8b92a 100644 --- a/panda/src/pstatclient/pStatProperties.cxx +++ b/panda/src/pstatclient/pStatProperties.cxx @@ -273,17 +273,17 @@ initialize_collector_def(PStatClient *client, PStatCollectorDef *def) { } ConfigVariableBool pstats_active - ("pstats-active-" + config_name, true, ConfigVariable::F_dynamic); + ("pstats-active-" + config_name, true, "", ConfigVariable::F_dynamic); ConfigVariableInt pstats_sort - ("pstats-sort-" + config_name, def->_sort, ConfigVariable::F_dynamic); + ("pstats-sort-" + config_name, def->_sort, "", ConfigVariable::F_dynamic); ConfigVariableDouble pstats_scale - ("pstats-scale-" + config_name, def->_suggested_scale, ConfigVariable::F_dynamic); + ("pstats-scale-" + config_name, def->_suggested_scale, "", ConfigVariable::F_dynamic); ConfigVariableString pstats_units - ("pstats-units-" + config_name, def->_level_units, ConfigVariable::F_dynamic); + ("pstats-units-" + config_name, def->_level_units, "", ConfigVariable::F_dynamic); ConfigVariableDouble pstats_factor - ("pstats-factor-" + config_name, 1.0, ConfigVariable::F_dynamic); + ("pstats-factor-" + config_name, 1.0, "", ConfigVariable::F_dynamic); ConfigVariableDouble pstats_color - ("pstats-color-" + config_name, 0.0, ConfigVariable::F_dynamic); + ("pstats-color-" + config_name, 0.0, "", ConfigVariable::F_dynamic); if (pstats_active.has_value()) { def->_is_active = pstats_active; diff --git a/panda/src/putil/config_util.cxx b/panda/src/putil/config_util.cxx index d608979e81..811bfef4dd 100644 --- a/panda/src/putil/config_util.cxx +++ b/panda/src/putil/config_util.cxx @@ -40,6 +40,17 @@ ConfigureDef(config_util); NotifyCategoryDef(util, ""); NotifyCategoryDef(bam, util_cat); +#ifndef CPPPARSER +ConfigVariableSearchPath model_path +("model-path", "The default directories to search for all models and general files loaded into Panda."); + +ConfigVariableSearchPath texture_path +("texture-path", "A special directory path to search for textures only. Textures are also searched for along the model-path, so the use of texture-path is only useful if you have special directories that only contain textures."); + +ConfigVariableSearchPath sound_path +("sound-path", "The directories to search for loaded sound and music files."); +#endif // CPPPARSER + ConfigureFn(config_util) { BamReaderParam::init_type(); Configurable::init_type(); @@ -71,20 +82,20 @@ ConfigureFn(config_util) { // //const bool track_memory_usage = config_util.GetBool("track-memory-usage", false); -DSearchPath & +// There is no longer any need for C++ code to call these functions to +// access the various path variables; instead, new C++ code should +// just access the path variables directly. +ConfigVariableSearchPath & get_model_path() { - static DSearchPath *model_path = NULL; - return get_config_path("model-path", model_path); + return model_path; } -DSearchPath & +ConfigVariableSearchPath & get_texture_path() { - static DSearchPath *texture_path = NULL; - return get_config_path("texture-path", texture_path); + return texture_path; } -DSearchPath & +ConfigVariableSearchPath & get_sound_path() { - static DSearchPath *sound_path = NULL; - return get_config_path("sound-path", sound_path); + return sound_path; } diff --git a/panda/src/putil/config_util.h b/panda/src/putil/config_util.h index 420e60076c..2a50f182eb 100644 --- a/panda/src/putil/config_util.h +++ b/panda/src/putil/config_util.h @@ -21,6 +21,7 @@ #include "pandabase.h" #include "notifyCategoryProxy.h" +#include "configVariableSearchPath.h" #include "dconfig.h" class DSearchPath; @@ -36,14 +37,16 @@ NotifyCategoryDecl(bam, EXPCL_PANDA, EXPTP_PANDA); //extern EXPCL_PANDA const bool track_memory_usage; -// These are functions instead of constant variables because they are -// computed based on the concatenation of all appearances of the -// corresponding variable in the config files. +extern EXPCL_PANDA ConfigVariableSearchPath model_path; +extern EXPCL_PANDA ConfigVariableSearchPath texture_path; +extern EXPCL_PANDA ConfigVariableSearchPath sound_path; +// The above variables are also shadowed by these functions, so that +// they can easily be accessed in the interpreter (e.g. Python). BEGIN_PUBLISH -EXPCL_PANDA DSearchPath &get_model_path(); -EXPCL_PANDA DSearchPath &get_texture_path(); -EXPCL_PANDA DSearchPath &get_sound_path(); +EXPCL_PANDA ConfigVariableSearchPath &get_model_path(); +EXPCL_PANDA ConfigVariableSearchPath &get_texture_path(); +EXPCL_PANDA ConfigVariableSearchPath &get_sound_path(); END_PUBLISH #endif /* __CONFIG_UTIL_H__ */ diff --git a/pandatool/src/eggbase/somethingToEgg.cxx b/pandatool/src/eggbase/somethingToEgg.cxx index 88ef984426..41be3cccef 100644 --- a/pandatool/src/eggbase/somethingToEgg.cxx +++ b/pandatool/src/eggbase/somethingToEgg.cxx @@ -289,7 +289,7 @@ handle_args(Args &args) { bool SomethingToEgg:: post_command_line() { // Prepend the source filename to the model path. - DSearchPath &model_path = get_model_path(); + ConfigVariableSearchPath &model_path = get_model_path(); Filename directory = _input_filename.get_dirname(); if (directory.empty()) { directory = ".";