| 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 | |
|---|
| 21 | namespace OrxGui |
|---|
| 22 | { |
|---|
| 23 | |
|---|
| 24 | /** |
|---|
| 25 | * standard constructor |
|---|
| 26 | */ |
|---|
| 27 | Saveable::Saveable (const std::string& optionName, SaveableGroup* group) |
|---|
| 28 | : BaseObject(optionName) |
|---|
| 29 | { |
|---|
| 30 | this->bSaveable = false; |
|---|
| 31 | |
|---|
| 32 | this->group = group; |
|---|
| 33 | this->group->addSaveable(this); |
|---|
| 34 | |
|---|
| 35 | } |
|---|
| 36 | |
|---|
| 37 | |
|---|
| 38 | /** |
|---|
| 39 | * standard deconstructor |
|---|
| 40 | */ |
|---|
| 41 | Saveable::~Saveable () |
|---|
| 42 | { |
|---|
| 43 | this->group->removeSaveable(this); |
|---|
| 44 | // delete what has to be deleted here |
|---|
| 45 | } |
|---|
| 46 | |
|---|
| 47 | |
|---|
| 48 | void Saveable::makeSaveable() |
|---|
| 49 | { |
|---|
| 50 | this->bSaveable = true; |
|---|
| 51 | |
|---|
| 52 | } |
|---|
| 53 | |
|---|
| 54 | |
|---|
| 55 | SaveableGroup::SaveableGroup(const std::string& groupName, OrxGui::Gui* gui) |
|---|
| 56 | : BaseObject(groupName) |
|---|
| 57 | { |
|---|
| 58 | assert (gui != NULL); |
|---|
| 59 | this->gui = gui; |
|---|
| 60 | |
|---|
| 61 | this->gui->addSaveableGroup(this); |
|---|
| 62 | //this->mainWidget = NULL; |
|---|
| 63 | } |
|---|
| 64 | |
|---|
| 65 | |
|---|
| 66 | |
|---|
| 67 | SaveableGroup::~SaveableGroup() |
|---|
| 68 | { |
|---|
| 69 | this->gui->removeSaveableGroup(this); |
|---|
| 70 | } |
|---|
| 71 | |
|---|
| 72 | |
|---|
| 73 | /** |
|---|
| 74 | * @brief Adds a Saveable to the List. |
|---|
| 75 | * @param saveable the saveable to add. |
|---|
| 76 | */ |
|---|
| 77 | void SaveableGroup::addSaveable(Saveable* saveable) |
|---|
| 78 | { |
|---|
| 79 | if (std::find(this->saveables.begin(), this->saveables.end(), saveable) == this->saveables.end()) |
|---|
| 80 | this->saveables.push_back(saveable); |
|---|
| 81 | } |
|---|
| 82 | |
|---|
| 83 | /** |
|---|
| 84 | * @brief Removes a Saveable from the List. |
|---|
| 85 | * @param saveable the saveable to remove. |
|---|
| 86 | */ |
|---|
| 87 | void SaveableGroup::removeSaveable(Saveable* saveable) |
|---|
| 88 | { |
|---|
| 89 | std::vector<Saveable*>::iterator delSav = std::find(this->saveables.begin(), this->saveables.end(), saveable); |
|---|
| 90 | if (delSav != this->saveables.end()) |
|---|
| 91 | this->saveables.erase(delSav); |
|---|
| 92 | } |
|---|
| 93 | |
|---|
| 94 | |
|---|
| 95 | /** |
|---|
| 96 | * @brief load the value onto the Group. |
|---|
| 97 | * @param value the Value to load. |
|---|
| 98 | */ |
|---|
| 99 | void SaveableGroup::load(const MultiType& value) |
|---|
| 100 | {} |
|---|
| 101 | |
|---|
| 102 | /** |
|---|
| 103 | * @brief save the value from the Group |
|---|
| 104 | * @returns nothing. |
|---|
| 105 | */ |
|---|
| 106 | const MultiType& SaveableGroup::save() |
|---|
| 107 | {} |
|---|
| 108 | |
|---|
| 109 | |
|---|
| 110 | |
|---|
| 111 | |
|---|
| 112 | } |
|---|