00001 #include "autoconf.h"
00002 #include "defaults.h"
00003 #include "filexml.h"
00004
00005
00006 static char *xml_titles[] =
00007 {
00008 "SHOW_MUTE",
00009 "SHOW_CAMERA_X",
00010 "SHOW_CAMERA_Y",
00011 "SHOW_CAMERA_Z",
00012 "SHOW_PROJECTOR_X",
00013 "SHOW_PROJECTOR_Y",
00014 "SHOW_PROJECTOR_Z",
00015 "SHOW_FADE",
00016 "SHOW_PAN",
00017 "SHOW_MODE",
00018 "SHOW_MASK",
00019 "SHOW_NUDGE"
00020 };
00021
00022 static int auto_defaults[] =
00023 {
00024 0,
00025 1,
00026 1,
00027 0,
00028 0,
00029 0,
00030 1,
00031 1,
00032 0,
00033 0
00034 };
00035
00036 int AutoConf::load_defaults(Defaults* defaults)
00037 {
00038 for(int i = 0; i < AUTOMATION_TOTAL; i++)
00039 {
00040 autos[i] = defaults->get(xml_titles[i], auto_defaults[i]);
00041 }
00042 transitions = defaults->get("SHOW_TRANSITIONS", 1);
00043 plugins = defaults->get("SHOW_PLUGINS", 1);
00044 return 0;
00045 }
00046
00047 void AutoConf::load_xml(FileXML *file)
00048 {
00049 for(int i = 0; i < AUTOMATION_TOTAL; i++)
00050 {
00051 autos[i] = file->tag.get_property(xml_titles[i], auto_defaults[i]);
00052 }
00053 transitions = file->tag.get_property("SHOW_TRANSITIONS", 1);
00054 plugins = file->tag.get_property("SHOW_PLUGINS", 1);
00055 }
00056
00057 int AutoConf::save_defaults(Defaults* defaults)
00058 {
00059 for(int i = 0; i < AUTOMATION_TOTAL; i++)
00060 {
00061 defaults->update(xml_titles[i], autos[i]);
00062 }
00063 defaults->update("SHOW_TRANSITIONS", transitions);
00064 defaults->update("SHOW_PLUGINS", plugins);
00065 return 0;
00066 }
00067
00068 void AutoConf::save_xml(FileXML *file)
00069 {
00070 for(int i = 0; i < AUTOMATION_TOTAL; i++)
00071 {
00072 file->tag.set_property(xml_titles[i], autos[i]);
00073 }
00074 file->tag.set_property("SHOW_TRANSITIONS", transitions);
00075 file->tag.set_property("SHOW_PLUGINS", plugins);
00076 }
00077
00078 int AutoConf::set_all(int value)
00079 {
00080 for(int i = 0; i < AUTOMATION_TOTAL; i++)
00081 {
00082 autos[i] = 1;
00083 }
00084 transitions = 1;
00085 plugins = 1;
00086 return 0;
00087 }
00088
00089 AutoConf& AutoConf::operator=(AutoConf &that)
00090 {
00091 copy_from(&that);
00092 return *this;
00093 }
00094
00095 void AutoConf::copy_from(AutoConf *src)
00096 {
00097 for(int i = 0; i < AUTOMATION_TOTAL; i++)
00098 {
00099 autos[i] = src->autos[i];
00100 }
00101 transitions = src->transitions;
00102 plugins = src->plugins;
00103 }
00104
00105