[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 | \param widget The Widget from which the data will be parsed |
---|
| 31 | */ |
---|
[2018] | 32 | OrxonoxGuiFlags::OrxonoxGuiFlags (Widget* widget) |
---|
| 33 | { |
---|
[3299] | 34 | this->flagsFrame = new Frame ("Orxonox-Startup-Flags:"); |
---|
| 35 | this->flagsBox = new Box ('v'); |
---|
[2018] | 36 | |
---|
[3299] | 37 | this->flagsLabel = new Label (); |
---|
| 38 | this->flagsLabel->setSize (260,60); |
---|
| 39 | this->flagsBox->fill (flagsLabel); |
---|
| 40 | this->shortFlags = new CheckButton ("shortFlags"); |
---|
| 41 | this->flagsBox->fill (shortFlags); |
---|
[2018] | 42 | |
---|
[3299] | 43 | this->flagsFrame->fill (flagsBox); |
---|
[2018] | 44 | } |
---|
| 45 | |
---|
[2588] | 46 | /** |
---|
| 47 | \brief Function to return the Frame that holds the Flagtext. |
---|
| 48 | \returns Frame that holds the Flagtext. |
---|
| 49 | */ |
---|
[2595] | 50 | Widget* OrxonoxGuiFlags::getWidget () |
---|
[2018] | 51 | { |
---|
[3299] | 52 | return this->flagsFrame; |
---|
[2018] | 53 | } |
---|
| 54 | |
---|
[2588] | 55 | /** |
---|
| 56 | \brief Sets the Flags from widget downwards. |
---|
| 57 | \param widget the Widget from which on to scan for deeper Options and their settings. |
---|
| 58 | */ |
---|
[2018] | 59 | void OrxonoxGuiFlags::setTextFromFlags (Widget* widget) |
---|
| 60 | { |
---|
[3299] | 61 | FlagInfo flagInfo; |
---|
| 62 | flagInfo.shortFlags = this->shortFlags; |
---|
| 63 | flagInfo.flagsLabel = this->flagsLabel; |
---|
| 64 | |
---|
| 65 | this->flagsLabel->ereaseText(); |
---|
| 66 | this->flagsLabel->appendText("orxonox"); |
---|
| 67 | widget->walkThrough(OrxonoxGuiFlags::flagsText, &flagInfo, 0); |
---|
| 68 | // flagsLabel->setTitle(flagText); |
---|
[2018] | 69 | } |
---|
| 70 | |
---|
[2588] | 71 | /** |
---|
| 72 | \brief this actually sets the flagtext, and appends it to flagText |
---|
| 73 | \param widget like OrxonoxGuiFlags::setTextFromFlags(widget) |
---|
[3300] | 74 | \param flagInfo Information aboout the Flag that should be updated. |
---|
[2588] | 75 | */ |
---|
[3299] | 76 | void OrxonoxGuiFlags::flagsText(Widget* widget, void* flagInfo) |
---|
[2018] | 77 | { |
---|
[3299] | 78 | FlagInfo* info = (FlagInfo*)flagInfo; |
---|
[3147] | 79 | if (widget->isOption >= 1) |
---|
[3299] | 80 | if (static_cast<Option*>(widget)->value != static_cast<Option*>(widget)->defaultValue ) |
---|
[2018] | 81 | { |
---|
[3299] | 82 | if (info->shortFlags->isActive() && static_cast<Option*>(widget)->flagNameShort) |
---|
[2018] | 83 | { |
---|
[3299] | 84 | info->flagsLabel->appendText(" -"); |
---|
| 85 | info->flagsLabel->appendText(static_cast<Option*>(widget)->flagNameShort); |
---|
[2018] | 86 | } |
---|
[3299] | 87 | else if (!info->shortFlags->isActive() && static_cast<Option*>(widget)->flagName) |
---|
[2018] | 88 | { |
---|
[3299] | 89 | info->flagsLabel->appendText(" --"); |
---|
| 90 | info->flagsLabel->appendText(static_cast<Option*>(widget)->flagName); |
---|
[2018] | 91 | } |
---|
[3299] | 92 | |
---|
[3147] | 93 | if (static_cast<Option*>(widget)->isOption == 2) |
---|
[2018] | 94 | { |
---|
[3299] | 95 | info->flagsLabel->appendText("="); |
---|
| 96 | info->flagsLabel->appendInt(static_cast<Option*>(widget)->value); |
---|
[2018] | 97 | } |
---|
| 98 | } |
---|
| 99 | } |
---|