~akirad/cinecutie/trunk

« back to all changes in this revision

Viewing changes to cinecutie/autoconf.C

  • Committer: Paolo Rampino
  • Date: 2010-02-17 19:46:21 UTC
  • Revision ID: git-v1:c39ff77ffa6ae08441c12e7d7f54e3897ddde7f1
Initial Merge

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
 
 
2
/*
 
3
 * CINELERRA
 
4
 * Copyright (C) 2008 Adam Williams <broadcast at earthling dot net>
 
5
 * 
 
6
 * This program is free software; you can redistribute it and/or modify
 
7
 * it under the terms of the GNU General Public License as published by
 
8
 * the Free Software Foundation; either version 2 of the License, or
 
9
 * (at your option) any later version.
 
10
 * 
 
11
 * This program is distributed in the hope that it will be useful,
 
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
14
 * GNU General Public License for more details.
 
15
 * 
 
16
 * You should have received a copy of the GNU General Public License
 
17
 * along with this program; if not, write to the Free Software
 
18
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
19
 * 
 
20
 */
 
21
 
 
22
#include "autoconf.h"
 
23
#include "bchash.h"
 
24
#include "filexml.h"
 
25
 
 
26
 
 
27
static char *xml_titles[] = 
 
28
{
 
29
        "SHOW_MUTE",
 
30
        "SHOW_CAMERA_X",
 
31
        "SHOW_CAMERA_Y",
 
32
        "SHOW_CAMERA_Z",
 
33
        "SHOW_PROJECTOR_X",
 
34
        "SHOW_PROJECTOR_Y",
 
35
        "SHOW_PROJECTOR_Z",
 
36
        "SHOW_FADE",
 
37
        "SHOW_PAN",
 
38
        "SHOW_MODE",
 
39
        "SHOW_MASK",
 
40
        "SHOW_NUDGE"
 
41
};
 
42
 
 
43
static int auto_defaults[] = 
 
44
{
 
45
        0,
 
46
        0,
 
47
        0,
 
48
        0,
 
49
        0,
 
50
        0,
 
51
        0,
 
52
        1,
 
53
        0,
 
54
        0
 
55
};
 
56
 
 
57
int AutoConf::load_defaults(BC_Hash* defaults)
 
58
{
 
59
        for(int i = 0; i < AUTOMATION_TOTAL; i++)
 
60
        {
 
61
                autos[i] = defaults->get(xml_titles[i], auto_defaults[i]);
 
62
        }
 
63
        transitions = defaults->get("SHOW_TRANSITIONS", 1);
 
64
        plugins = defaults->get("SHOW_PLUGINS", 1);
 
65
        return 0;
 
66
}
 
67
 
 
68
void AutoConf::load_xml(FileXML *file)
 
69
{
 
70
        for(int i = 0; i < AUTOMATION_TOTAL; i++)
 
71
        {
 
72
                autos[i] = file->tag.get_property(xml_titles[i], auto_defaults[i]);
 
73
        }
 
74
        transitions = file->tag.get_property("SHOW_TRANSITIONS", 1);
 
75
        plugins = file->tag.get_property("SHOW_PLUGINS", 1);
 
76
}
 
77
 
 
78
int AutoConf::save_defaults(BC_Hash* defaults)
 
79
{
 
80
        for(int i = 0; i < AUTOMATION_TOTAL; i++)
 
81
        {
 
82
                defaults->update(xml_titles[i], autos[i]);
 
83
        }
 
84
        defaults->update("SHOW_TRANSITIONS", transitions);
 
85
        defaults->update("SHOW_PLUGINS", plugins);
 
86
        return 0;
 
87
}
 
88
 
 
89
void AutoConf::save_xml(FileXML *file)
 
90
{
 
91
        for(int i = 0; i < AUTOMATION_TOTAL; i++)
 
92
        {
 
93
                file->tag.set_property(xml_titles[i], autos[i]);
 
94
        }
 
95
        file->tag.set_property("SHOW_TRANSITIONS", transitions);
 
96
        file->tag.set_property("SHOW_PLUGINS", plugins);
 
97
}
 
98
 
 
99
int AutoConf::set_all(int value)
 
100
{
 
101
        for(int i = 0; i < AUTOMATION_TOTAL; i++)
 
102
        {
 
103
                autos[i] = value;
 
104
        }
 
105
        transitions = value;
 
106
        plugins = value;
 
107
        return 0;
 
108
}
 
109
 
 
110
AutoConf& AutoConf::operator=(AutoConf &that)
 
111
{
 
112
        copy_from(&that);
 
113
        return *this;
 
114
}
 
115
 
 
116
void AutoConf::copy_from(AutoConf *src)
 
117
{
 
118
        for(int i = 0; i < AUTOMATION_TOTAL; i++)
 
119
        {
 
120
                autos[i] = src->autos[i];
 
121
        }
 
122
        transitions = src->transitions;
 
123
        plugins = src->plugins;
 
124
}
 
125
 
 
126