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 | |
---|
26 | #include "orxonox_gui_flags.h" |
---|
27 | #include <iostream.h> |
---|
28 | |
---|
29 | /** |
---|
30 | \brief Creates the Flags-Frame |
---|
31 | \param widget The Widget from which the data will be parsed |
---|
32 | */ |
---|
33 | OrxonoxGuiFlags::OrxonoxGuiFlags (Widget* widget) |
---|
34 | { |
---|
35 | flagText = (char*) malloc (1024); |
---|
36 | |
---|
37 | flagsFrame = new Frame ("Orxonox-Startup-Flags:"); |
---|
38 | flagsBox = new Box ('v'); |
---|
39 | |
---|
40 | flagsLabel = new Label (); |
---|
41 | flagsBox->fill (flagsLabel); |
---|
42 | shortFlags = new CheckButton ("shortFlags"); |
---|
43 | flagsBox->fill (shortFlags); |
---|
44 | |
---|
45 | flagsFrame->fill (flagsBox); |
---|
46 | } |
---|
47 | |
---|
48 | /** |
---|
49 | \brief Function to return the Frame that holds the Flagtext. |
---|
50 | \returns Frame that holds the Flagtext. |
---|
51 | */ |
---|
52 | Widget* OrxonoxGuiFlags::getWidget () |
---|
53 | { |
---|
54 | return flagsFrame; |
---|
55 | } |
---|
56 | |
---|
57 | /** |
---|
58 | \brief Sets the Flags from widget downwards. |
---|
59 | \param widget the Widget from which on to scan for deeper Options and their settings. |
---|
60 | */ |
---|
61 | void OrxonoxGuiFlags::setTextFromFlags (Widget* widget) |
---|
62 | { |
---|
63 | sprintf (flagText, ""); |
---|
64 | strcat (flagText, "orxonox"); |
---|
65 | FlagsText (widget); |
---|
66 | flagsLabel->setText (flagText); |
---|
67 | } |
---|
68 | |
---|
69 | /** |
---|
70 | \brief this actually sets the flagtext, and appends it to flagText |
---|
71 | \param widget like OrxonoxGuiFlags::setTextFromFlags(widget) |
---|
72 | */ |
---|
73 | void OrxonoxGuiFlags::FlagsText(Widget* widget) |
---|
74 | { |
---|
75 | if (widget->is_option >= 1) |
---|
76 | if (static_cast<Option*>(widget)->value != static_cast<Option*>(widget)->default_value && (strcmp (static_cast<Option*>(widget)->flag_name, "") || strcmp (static_cast<Option*>(widget)->flag_name_short, ""))) |
---|
77 | { |
---|
78 | if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(shortFlags->widget))) |
---|
79 | { |
---|
80 | strcat (flagText, " -"); |
---|
81 | strcat (flagText, static_cast<Option*>(widget)->flag_name_short); |
---|
82 | } |
---|
83 | else |
---|
84 | { |
---|
85 | strcat (flagText, " --"); |
---|
86 | strcat (flagText, static_cast<Option*>(widget)->flag_name); |
---|
87 | } |
---|
88 | if (static_cast<Option*>(widget)->is_option == 2) |
---|
89 | { |
---|
90 | sprintf (flagText, "%s=%i", flagText, static_cast<Option*>(widget)->value); |
---|
91 | } |
---|
92 | } |
---|
93 | switch (widget->is_option) |
---|
94 | { |
---|
95 | case -1: |
---|
96 | FlagsText (static_cast<Container*>(widget)->down); |
---|
97 | break; |
---|
98 | case -2: |
---|
99 | FlagsText (static_cast<Box*>(widget)->down); |
---|
100 | break; |
---|
101 | } |
---|
102 | |
---|
103 | if (widget->next != NULL) |
---|
104 | FlagsText (widget->next); |
---|
105 | } |
---|