1 | /* |
---|
2 | orxonox - the future of 3D-vertical-scrollers |
---|
3 | |
---|
4 | Copyright (C) 2004 orx |
---|
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, or (at your option) |
---|
9 | any later version. |
---|
10 | |
---|
11 | ### File Specific: |
---|
12 | main-programmer: Benjamin Grauer |
---|
13 | co-programmer: ... |
---|
14 | */ |
---|
15 | |
---|
16 | //#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_ |
---|
17 | |
---|
18 | #include "gui_saveable.h" |
---|
19 | #include "gui.h" |
---|
20 | #include "preferences.h" |
---|
21 | |
---|
22 | namespace OrxGui |
---|
23 | { |
---|
24 | |
---|
25 | /** |
---|
26 | * standard constructor |
---|
27 | */ |
---|
28 | Saveable::Saveable (const std::string& optionName, SaveableGroup* group) |
---|
29 | : BaseObject(optionName) |
---|
30 | { |
---|
31 | this->bSaveable = false; |
---|
32 | |
---|
33 | assert(group != NULL); |
---|
34 | this->group = group; |
---|
35 | this->group->addSaveable(this); |
---|
36 | |
---|
37 | } |
---|
38 | |
---|
39 | |
---|
40 | /** |
---|
41 | * standard deconstructor |
---|
42 | */ |
---|
43 | Saveable::~Saveable () |
---|
44 | { |
---|
45 | this->group->removeSaveable(this); |
---|
46 | // delete what has to be deleted here |
---|
47 | } |
---|
48 | |
---|
49 | |
---|
50 | void Saveable::makeSaveable() |
---|
51 | { |
---|
52 | this->bSaveable = true; |
---|
53 | |
---|
54 | } |
---|
55 | |
---|
56 | |
---|
57 | void Saveable::load(const MultiType& value) |
---|
58 | { |
---|
59 | Preferences::getInstance()->setMultiType(this->group->getName(), this->getName(), value); |
---|
60 | } |
---|
61 | |
---|
62 | const MultiType& Saveable::save() |
---|
63 | { |
---|
64 | Preferences::getInstance()->getMultiType(this->group->getName(), this->getName(), 0); |
---|
65 | } |
---|
66 | |
---|
67 | |
---|
68 | |
---|
69 | |
---|
70 | SaveableGroup::SaveableGroup(const std::string& groupName, OrxGui::Gui* gui) |
---|
71 | : BaseObject(groupName) |
---|
72 | { |
---|
73 | assert (gui != NULL); |
---|
74 | this->gui = gui; |
---|
75 | |
---|
76 | this->gui->addSaveableGroup(this); |
---|
77 | //this->mainWidget = NULL; |
---|
78 | } |
---|
79 | |
---|
80 | |
---|
81 | |
---|
82 | SaveableGroup::~SaveableGroup() |
---|
83 | { |
---|
84 | this->gui->removeSaveableGroup(this); |
---|
85 | } |
---|
86 | |
---|
87 | |
---|
88 | /** |
---|
89 | * @brief Adds a Saveable to the List. |
---|
90 | * @param saveable the saveable to add. |
---|
91 | */ |
---|
92 | void SaveableGroup::addSaveable(Saveable* saveable) |
---|
93 | { |
---|
94 | if (std::find(this->saveables.begin(), this->saveables.end(), saveable) == this->saveables.end()) |
---|
95 | this->saveables.push_back(saveable); |
---|
96 | } |
---|
97 | |
---|
98 | /** |
---|
99 | * @brief Removes a Saveable from the List. |
---|
100 | * @param saveable the saveable to remove. |
---|
101 | */ |
---|
102 | void SaveableGroup::removeSaveable(Saveable* saveable) |
---|
103 | { |
---|
104 | std::vector<Saveable*>::iterator delSav = std::find(this->saveables.begin(), this->saveables.end(), saveable); |
---|
105 | if (delSav != this->saveables.end()) |
---|
106 | this->saveables.erase(delSav); |
---|
107 | } |
---|
108 | |
---|
109 | |
---|
110 | /** |
---|
111 | * @brief load the value onto the Group. |
---|
112 | * @param value the Value to load. |
---|
113 | */ |
---|
114 | void SaveableGroup::load(const MultiType& value) |
---|
115 | { |
---|
116 | } |
---|
117 | |
---|
118 | /** |
---|
119 | * @brief save the value from the Group |
---|
120 | * @returns nothing. |
---|
121 | */ |
---|
122 | const MultiType& SaveableGroup::save() |
---|
123 | {} |
---|
124 | |
---|
125 | |
---|
126 | |
---|
127 | |
---|
128 | } |
---|