[2581] | 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 | 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 Foundation, |
---|
| 18 | Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
---|
| 19 | |
---|
| 20 | |
---|
| 21 | ### File Specific: |
---|
| 22 | main-programmer: Benjamin Grauer |
---|
| 23 | |
---|
| 24 | */ |
---|
| 25 | |
---|
[2018] | 26 | #include "orxonox_gui_flags.h" |
---|
| 27 | |
---|
[2588] | 28 | /** |
---|
| 29 | \brief Creates the Flags-Frame |
---|
| 30 | */ |
---|
[3423] | 31 | OrxonoxGuiFlags::OrxonoxGuiFlags(void) |
---|
[2018] | 32 | { |
---|
[3423] | 33 | this->flagsFrame = new Frame("Orxonox-Startup-Flags:"); |
---|
| 34 | this->flagsBox = new Box('v'); |
---|
[2018] | 35 | |
---|
[3423] | 36 | this->flagsLabel = new Label(); |
---|
| 37 | this->flagsLabel->setSize(260,60); |
---|
| 38 | this->flagsBox->fill(flagsLabel); |
---|
| 39 | this->shortFlags = new CheckButton("shortFlags"); |
---|
| 40 | this->flagsBox->fill(shortFlags); |
---|
[2018] | 41 | |
---|
[3423] | 42 | this->flagsFrame->fill(flagsBox); |
---|
| 43 | } |
---|
[2018] | 44 | |
---|
[3423] | 45 | /** |
---|
| 46 | \brief Destructs the Flags-stuff |
---|
| 47 | */ |
---|
| 48 | OrxonoxGuiFlags::~OrxonoxGuiFlags(void) |
---|
| 49 | { |
---|
| 50 | // nothing to do here |
---|
[2018] | 51 | } |
---|
| 52 | |
---|
[2588] | 53 | /** |
---|
| 54 | \brief Function to return the Frame that holds the Flagtext. |
---|
| 55 | \returns Frame that holds the Flagtext. |
---|
| 56 | */ |
---|
[3423] | 57 | Widget* OrxonoxGuiFlags::getWidget(void) |
---|
[2018] | 58 | { |
---|
[3423] | 59 | return this->flagsFrame; |
---|
[2018] | 60 | } |
---|
| 61 | |
---|
[2588] | 62 | /** |
---|
| 63 | \brief Sets the Flags from widget downwards. |
---|
| 64 | \param widget the Widget from which on to scan for deeper Options and their settings. |
---|
| 65 | */ |
---|
[3423] | 66 | void OrxonoxGuiFlags::setTextFromFlags(Widget* widget) |
---|
[2018] | 67 | { |
---|
[3423] | 68 | FlagInfo flagInfo; |
---|
| 69 | flagInfo.shortFlags = this->shortFlags; |
---|
| 70 | flagInfo.flagsLabel = this->flagsLabel; |
---|
| 71 | |
---|
| 72 | this->flagsLabel->ereaseText(); |
---|
| 73 | this->flagsLabel->appendText("orxonox"); |
---|
| 74 | widget->walkThrough(OrxonoxGuiFlags::flagsText, &flagInfo, 0); |
---|
| 75 | // flagsLabel->setTitle(flagText); |
---|
[2018] | 76 | } |
---|
| 77 | |
---|
[2588] | 78 | /** |
---|
| 79 | \brief this actually sets the flagtext, and appends it to flagText |
---|
| 80 | \param widget like OrxonoxGuiFlags::setTextFromFlags(widget) |
---|
[3423] | 81 | \param flagInfo Information aboout the Flag that should be updated. |
---|
[2588] | 82 | */ |
---|
[3423] | 83 | void OrxonoxGuiFlags::flagsText(Widget* widget, void* flagInfo) |
---|
[2018] | 84 | { |
---|
[3423] | 85 | FlagInfo* info =(FlagInfo*)flagInfo; |
---|
| 86 | if(widget->isOption >= 1) |
---|
| 87 | if (static_cast<Option*>(widget)->value != static_cast<Option*>(widget)->defaultValue ) |
---|
[2018] | 88 | { |
---|
[3423] | 89 | if(info->shortFlags->isActive() && static_cast<Option*>(widget)->flagNameShort) |
---|
[2018] | 90 | { |
---|
[3423] | 91 | info->flagsLabel->appendText(" -"); |
---|
| 92 | info->flagsLabel->appendText(static_cast<Option*>(widget)->flagNameShort); |
---|
[2018] | 93 | } |
---|
[3423] | 94 | else if(!info->shortFlags->isActive() && static_cast<Option*>(widget)->flagName) |
---|
[2018] | 95 | { |
---|
[3423] | 96 | info->flagsLabel->appendText(" --"); |
---|
| 97 | info->flagsLabel->appendText(static_cast<Option*>(widget)->flagName); |
---|
[2018] | 98 | } |
---|
[3423] | 99 | |
---|
| 100 | if(static_cast<Option*>(widget)->isOption == 2) |
---|
[2018] | 101 | { |
---|
[3423] | 102 | info->flagsLabel->appendText("="); |
---|
| 103 | info->flagsLabel->appendInt(static_cast<Option*>(widget)->value); |
---|
[2018] | 104 | } |
---|
| 105 | } |
---|
| 106 | } |
---|