Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 3161 in orxonox.OLD


Ignore:
Timestamp:
Dec 13, 2004, 2:10:38 AM (19 years ago)
Author:
bensch
Message:

orxonox/trunk/gui: OptionLabel now has a member cValue for saving its state beside its name

Location:
orxonox/trunk/gui
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • orxonox/trunk/gui/orxonox_gui.cc

    r3152 r3161  
    2626   curl interface to Download cool stuff
    2727
    28    make Windows grab Focus if it is open and release it when closed (only child-windows)
    2928   chain all the windows when starting the GUI (DANGER: performance!!)
    3029
    31    widgets save themselve
     30   widgets save themselves
    3231   good way to step through all the Widgets
    3332   ... many more ...
     33   label -> protected : getlabel function
     34
    3435*/
    3536
  • orxonox/trunk/gui/orxonox_gui_exec.cc

    r3147 r3161  
    128128                              && (static_cast<Option*>(widget)->saveable) )
    129129                             || (widget->isOption<0
    130                                  && strcmp (static_cast<Packer*>(widget)->getGroupName(), ""))))
     130                                 && static_cast<Packer*>(widget)->getGroupName())))
    131131    {
    132132      fprintf (CONFIG_FILE, "  ", depth);
     
    137137  if (widget->isOption <0)
    138138    {
    139       if (strcmp (static_cast<Packer*>(widget)->getGroupName(), ""))
     139      if (static_cast<Packer*>(widget)->getGroupName())
    140140        {
    141141          fprintf (CONFIG_FILE, "[%s]\n", static_cast<Packer*>(widget)->getGroupName());
     
    155155        char Buffer[256];
    156156        char* space2under;
    157         sprintf (Buffer, "%s", static_cast<Option*>(widget)->label);
     157        strcpy (Buffer, static_cast<Option*>(widget)->label);
    158158        if (strchr (Buffer, '_'))
    159159          cout << "Warning Optionname" << Buffer << " is not Valid for Saving, because it includes an underscore" << endl;
    160160        while (space2under = strchr(Buffer, ' '))
    161161          {
    162             sprintf (space2under, "_%s", space2under+1);
     162            space2under[0] = '_';
    163163          }
    164         fprintf (CONFIG_FILE, "%s = %i\n", Buffer, static_cast<Option*>(widget)->value);
     164        if (widget->isOption <=3)
     165          fprintf (CONFIG_FILE, "%s = %d\n", Buffer, static_cast<Option*>(widget)->value);
     166        else if (widget->isOption == 5)
     167          fprintf (CONFIG_FILE, "%s = %s\n", Buffer, static_cast<OptionLabel*>(widget)->cValue);
    165168      }
    166169
     
    184187      while (fscanf (CONFIG_FILE, "%s", Buffer) != EOF)
    185188        {
     189          // group-search //
    186190          if (!strncmp (Buffer, "[", 1))
    187191            {
     
    192196                }
    193197            }
     198          // option-setting //
    194199          if (!strcmp (Buffer, "="))
    195200            {
     
    248253  if (widget->isOption < 0)
    249254    {
    250       if (!strcmp(groupName, static_cast<Packer*>(widget)->getGroupName()))
     255      if (static_cast<Packer*>(widget)->getGroupName() && !strcmp(groupName, static_cast<Packer*>(widget)->getGroupName()))
    251256        {
    252257          return widget;
  • orxonox/trunk/gui/orxonox_gui_gtk.cc

    r3160 r3161  
    188188{
    189189  down = NULL;
    190   this->setGroupName ("");
     190  groupName = NULL;
    191191
    192192
     
    201201void Packer::setGroupName (char* name)
    202202{
    203   groupName = name;
     203  if (groupName)
     204    delete groupName;
     205  groupName = new char [strlen(name)+1];
     206  strcpy(groupName, name);
    204207}
    205208
     
    398401{
    399402  if (exec->shouldsave())
    400     exec->writeToFile (orxonoxGUI);
     403    exec->writeToFile (Window::mainWindow);
    401404
    402405  gtk_main_quit();
     
    902905}
    903906
    904 OptionLabel::OptionLabel(char* text)
     907OptionLabel::OptionLabel(char* label, char* value)
    905908{
    906909  init();
    907   setTitle(text);
     910  setTitle(label);
     911  setValue(value);
    908912}
    909913
    910914void OptionLabel::init(void)
    911915{
    912   isOption = 4;
    913 
    914916  static_cast<Option*>(this)->init();
     917  isOption = 5;
     918  cValue = NULL;
    915919
    916920  widget = gtk_label_new ("");
    917921}
     922void OptionLabel::setValue(char* newValue)
     923{
     924  if (cValue)
     925    delete cValue;
     926  cValue = new char [strlen(newValue)+1];
     927  strcpy(cValue, newValue);
     928  gtk_label_set_text (GTK_LABEL (widget), cValue);
     929}
    918930
    919931void OptionLabel::setTitle(char* title)
    920932{
     933  if (label)
     934    delete label;
     935  label = new char [strlen(title)+1];
     936  strcpy(label, title);
    921937  gtk_label_set_text (GTK_LABEL (widget), title);
    922938}
  • orxonox/trunk/gui/orxonox_gui_gtk.h

    r3158 r3161  
    3232  GtkWidget* widget; //!< widget is the gtk_widget that the specific Object Contains.
    3333  void init(void);
    34   int isOption; //!< with this Paramenter one can set the option-type: -2:Container, -1: Box, 0: not an Option, 1: Bool-option, 2: int-option, 3:float option, 4:char option, 5: char* option
     34  int isOption; //!< with this Paramenter one can set the option-type: -2:Container, -1: Box, 0: not an Option, 1: Bool-option, 2: int-option, 3: float option, 4:char option, 5: char* option
    3535  /**
    3636     \briefdefines isOption states
     
    262262{
    263263 public:
    264   OptionLabel(char* text);
    265   void init(void);
    266 
     264  OptionLabel(char* label, char* value);
     265  void init(void);
     266 
     267  char* cValue;
     268 
     269  void setValue(char* newValue);
    267270  void setTitle(char* title);
    268271  void redraw();
  • orxonox/trunk/gui/orxonox_gui_keys.cc

    r3158 r3161  
    6161  pKeyFrame = new Frame ("keys");
    6262   pKeysBox = new Box('v');
     63   pKeysBox->setGroupName ("player1");
    6364    pKeysBox->fill(addKey(UP, "up"));
    6465    pKeysBox->fill(addKey(DOWN, "down"));
     
    7374    pKeyFrame->fill(pKeysBox);
    7475   pKeyWindow->fill(pKeyFrame);
    75    //  Window::addWindow(pKeyWindow);
     76   Window::addWindow(pKeyWindow);
    7677   pKeyWindow->connectSignal("destroy", pKeyWindow, Window::windowClose);
    7778   pKeyWindow->connectSignal("delete_event", pKeyWindow, Window::windowClose);
     
    9495  inputKey[key]->pKeyBox = new Box();
    9596  inputKey[key]->pKeyButton = new Button(name);
    96   inputKey[key]->pKeyOLabel = new OptionLabel (name);
     97  inputKey[key]->pKeyOLabel = new OptionLabel (name, name);
    9798  inputKey[key]->pKeyOLabel->saveable = true;
    9899 
     
    256257    }
    257258
    258   inputkey->pKeyOLabel->setTitle (title);
     259  inputkey->pKeyOLabel->setValue (title);
    259260  inputButton->disconnectSignal(keySignal);
    260261  inputWindow->close();
Note: See TracChangeset for help on using the changeset viewer.