Panda3D
|
00001 // Filename: loaderOptions.cxx 00002 // Created by: drose (05Oct05) 00003 // 00004 //////////////////////////////////////////////////////////////////// 00005 // 00006 // PANDA 3D SOFTWARE 00007 // Copyright (c) Carnegie Mellon University. All rights reserved. 00008 // 00009 // All use of this software is subject to the terms of the revised BSD 00010 // license. You should have received a copy of this license along 00011 // with this source code in a file named "LICENSE." 00012 // 00013 //////////////////////////////////////////////////////////////////// 00014 00015 #include "loaderOptions.h" 00016 #include "config_util.h" 00017 #include "indent.h" 00018 00019 //////////////////////////////////////////////////////////////////// 00020 // Function: LoaderOptions::Constructor 00021 // Access: Published 00022 // Description: 00023 //////////////////////////////////////////////////////////////////// 00024 LoaderOptions:: 00025 LoaderOptions(int flags) : 00026 _flags(flags), _texture_flags(0) 00027 { 00028 // Shadowing the variables in config_util for static init ordering 00029 // issues. 00030 static ConfigVariableBool *preload_textures; 00031 static ConfigVariableBool *preload_simple_textures; 00032 if (preload_textures == NULL) { 00033 preload_textures = new ConfigVariableBool("preload-textures", true); 00034 } 00035 if (preload_simple_textures == NULL) { 00036 preload_simple_textures = new ConfigVariableBool("preload-simple-textures", false); 00037 } 00038 00039 if (*preload_textures) { 00040 _texture_flags |= TF_preload; 00041 } 00042 if (*preload_simple_textures) { 00043 _texture_flags |= TF_preload_simple; 00044 } 00045 } 00046 00047 //////////////////////////////////////////////////////////////////// 00048 // Function: LoaderOptions::output 00049 // Access: Published 00050 // Description: 00051 //////////////////////////////////////////////////////////////////// 00052 void LoaderOptions:: 00053 output(ostream &out) const { 00054 out << "LoaderOptions("; 00055 00056 string sep = ""; 00057 write_flag(out, sep, "LF_search", LF_search); 00058 write_flag(out, sep, "LF_report_errors", LF_report_errors); 00059 if ((_flags & LF_convert_anim) == LF_convert_anim) { 00060 write_flag(out, sep, "LF_convert_anim", LF_convert_anim); 00061 } else { 00062 write_flag(out, sep, "LF_convert_skeleton", LF_convert_skeleton); 00063 write_flag(out, sep, "LF_convert_channels", LF_convert_channels); 00064 } 00065 if ((_flags & LF_no_cache) == LF_no_cache) { 00066 write_flag(out, sep, "LF_no_cache", LF_no_cache); 00067 } else { 00068 write_flag(out, sep, "LF_no_disk_cache", LF_no_disk_cache); 00069 write_flag(out, sep, "LF_no_ram_cache", LF_no_ram_cache); 00070 } 00071 write_flag(out, sep, "LF_allow_instance", LF_allow_instance); 00072 if (sep.empty()) { 00073 out << "0"; 00074 } 00075 00076 out << ", "; 00077 00078 sep = ""; 00079 write_texture_flag(out, sep, "TF_preload", TF_preload); 00080 write_texture_flag(out, sep, "TF_preload_simple", TF_preload_simple); 00081 write_texture_flag(out, sep, "TF_allow_1d", TF_allow_1d); 00082 write_texture_flag(out, sep, "TF_generate_mipmaps", TF_generate_mipmaps); 00083 if (sep.empty()) { 00084 out << "0"; 00085 } 00086 00087 out << ")"; 00088 } 00089 00090 //////////////////////////////////////////////////////////////////// 00091 // Function: LoaderOptions::write_flag 00092 // Access: Private 00093 // Description: Used to implement output(). 00094 //////////////////////////////////////////////////////////////////// 00095 void LoaderOptions:: 00096 write_flag(ostream &out, string &sep, 00097 const string &flag_name, int flag) const { 00098 if ((_flags & flag) == flag) { 00099 out << sep << flag_name; 00100 sep = " | "; 00101 } 00102 } 00103 00104 //////////////////////////////////////////////////////////////////// 00105 // Function: LoaderOptions::write_texture_flag 00106 // Access: Private 00107 // Description: Used to implement output(). 00108 //////////////////////////////////////////////////////////////////// 00109 void LoaderOptions:: 00110 write_texture_flag(ostream &out, string &sep, 00111 const string &flag_name, int flag) const { 00112 if ((_texture_flags & flag) == flag) { 00113 out << sep << flag_name; 00114 sep = " | "; 00115 } 00116 }