Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 3305 in orxonox.OLD for orxonox/branches/updater/src


Ignore:
Timestamp:
Dec 29, 2004, 12:05:29 AM (20 years ago)
Author:
bensch
Message:

orxonox/branches/updater: Now in non-gtk-mode, the Gui will ask questions for what Option to change… it is kind of sexy, but you can not change the Option yet. but this will follow.
I am now going into holydays till 1.1.2005: I hope you all have a good 'rutsch' into the new year.
cheers bensch

PS: I do not believe that anyone reads this, but anyways it was fun writing it :)

Location:
orxonox/branches/updater/src/gui
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • orxonox/branches/updater/src/gui/orxonox_gui.cc

    r3303 r3305  
    5858OrxonoxGui::OrxonoxGui (int argc, char *argv[])
    5959{
    60 #ifdef HAVE_GTK2
    61   initGTK(argc, argv);
    62 #endif /* HAVE_GTK2 */
     60  initGUI(argc, argv);
    6361
    6462  orxonoxGUI = new Window( "Grafical OrxOnoX loader, "PACKAGE_VERSION);
     
    121119    OrxonoxGuiExec::startOrxonox(NULL, exec);
    122120  else
     121    {
    123122#ifdef HAVE_GTK2
    124     {
    125       mainloopGTK();
     123      mainloopGUI();
     124#else /* HAVE_GTK2 */
     125      char boolAns = 'y';
     126      char ans[10];
     127      while(true)
     128        {
     129          PRINT(0)(" Listing all the Orxonox Options: \n");
     130          PRINT(0)("  #############################\n");
     131          Window::mainWindow->walkThrough(Widget::listOptionsAndGroups, 1);
     132         
     133          PRINT(0)("\nDo you want change any of the above values now? [Yn] ");
     134          cin >>boolAns ;
     135          if (boolAns =='n' || boolAns=='N')
     136            break;
     137
     138          PRINT(0)("\n Listing all groups\n");
     139          PRINT(0)("  #################\n");
     140          int groupCount = 0;
     141          Window::mainWindow->walkThrough(Widget::listGroups, &groupCount, 1);
     142         
     143          PRINT(0)("\nIn which Group? [1-%d] ", groupCount);
     144          Packer* group;
     145          while(true)
     146            {
     147              cin >> ans;
     148              int ansIp = atoi(ans);
     149              if (ansIp <= groupCount)
     150                {
     151                  group = static_cast<Packer*>(Window::mainWindow->findGroupByNumber(&ansIp, 1));
     152                break;
     153                }
     154              else
     155                PRINT(0)("\nChoose a smaler Number please: [1-%d] ", groupCount);
     156            }
     157          PRINT(0)("\n\nGroup: [%s]\n\n", group->groupName);
     158          int optionCount = 0;
     159          group->walkThrough(Widget::listOptions, &optionCount, 0);
     160          PRINT(0)("\nWhich Option? [1-%d] ", optionCount);
     161          Option* option;
     162          while(true)
     163            {
     164              cin >> ans;
     165              int ansIp = atoi(ans);
     166              if (ansIp <= groupCount)
     167                {
     168                  option = static_cast<Option*>(group->findOptionByNumber(&ansIp, 0));
     169                break;
     170                }
     171              else
     172                PRINT(0)("\nChoose a smaler Number please: [1-%d] ", optionCount);
     173            }
     174          PRINT(0)("\n\n:: %s ::\n", option->title);
     175
     176          // here follows the rest.... this will be nasty.
     177          //! \todo move this into the gui-gtk-file
     178          //! \todo finish it.
     179        }
    126180    }
    127 #else /* HAVE_GTK2 */
    128   {
    129     PRINT(0)(" Listing all the Orxonox Options: \n");
    130     PRINT(0)("  #############################\n");
    131     orxonoxGUI->walkThrough(orxonoxGUI->listOptions, 0);
    132    
    133     PRINT(0)("\nDo you want me to save the the above values now? [Yn] ");
    134     char c = getchar();
    135     if ((c == 'y' || c == 'Y' || c== 10) && exec->shouldsave())
    136       exec->writeToFile (Window::mainWindow);
    137     OrxonoxGuiExec::startOrxonox(NULL, exec);
    138   }
    139181
    140182#endif /* HAVE_GTK2 */
  • orxonox/branches/updater/src/gui/orxonox_gui_gtk.cc

    r3304 r3305  
    3737extern OrxonoxGuiFlags* flags;
    3838
    39 #ifdef HAVE_GTK2
    4039/**
    4140   \brief Initializes the Guis GTK-stuff.
     
    4342   \param argv The Argument strings.
    4443*/
    45 bool initGTK(int argc, char *argv[])
    46 {
     44bool initGUI(int argc, char *argv[])
     45{
     46#ifdef HAVE_GTK2
    4747#ifdef HAVE_GTHREAD
    4848  PRINTF(3)("Initializing the ThreadSystem of the GUI\n");
     
    5252  gtk_init (&argc, &argv);
    5353  gtk_rc_parse( "rc" );
    54 }
     54#endif /* HAVE_GTK2 */
     55}
     56
    5557
    5658/**
    5759   \brief enters the GTK-main-loop
    5860*/
    59 bool mainloopGTK(void)
    60 {
     61bool mainloopGUI(void)
     62{
     63#ifdef HAVE_GTK2
    6164  gdk_threads_enter();
    6265  gtk_main();
    6366  gdk_threads_leave();
    6467  delete Window::mainWindow;
    65 }
    66 #endif /* HAVE_GTK2 */
     68#endif /* HAVE_GTK2 */
     69}
    6770
    6871
     
    154157Widget* Widget::findWidgetByName(char* name, unsigned int depth)
    155158{
    156   Widget* tmp = NULL;
    157159
    158160  if (this->title && !strcmp(this->title, name))
     
    160162
    161163  if (this->isOption < 0 && static_cast<Packer*>(this)->down)
    162     tmp = static_cast<Packer*>(this)->down->findWidgetByName(name, depth+1);
    163   if (tmp)
    164     return tmp;
    165 
     164    {
     165      Widget* tmp = static_cast<Packer*>(this)->down->findWidgetByName(name, depth+1);
     166      if (tmp)
     167        return tmp;
     168    }
    166169 
    167170  if (depth>0 && this->next)
     
    206209
    207210/**
    208     \brief This is for listing the option of "widget"
     211    \brief This is for listing the options of "widget"
    209212    \param widget specifies the widget that should be listed
    210213*/
    211 void Widget::listOptions (Widget* widget)
     214void Widget::listOptionsAndGroups (Widget* widget)
    212215{
    213216  if (widget->isOption < 0 && static_cast<Packer*>(widget)->groupName)
     
    219222}
    220223
     224/**
     225    \brief This is for listing the options of "widget"
     226    \param widget specifies the widget that should be listed
     227*/
     228void Widget::listOptions (Widget* widget)
     229{
     230  if (widget->isOption >= 1 && widget->isOption <= 3)
     231    cout << "  " << static_cast<Option*>(widget)->title <<" is : " << static_cast<Option*>(widget)->value <<endl;
     232  else if (widget->isOption == 5)
     233    cout << "  " << static_cast<Option*>(widget)->title <<" is : " << static_cast<OptionLabel*>(widget)->cValue <<endl;
     234}
     235
     236/**
     237    \brief This is for listing the options of "widget"
     238    \param widget specifies the widget that should be listed
     239    \param data A Counter, that always knows how many Options have been found yet.
     240*/
     241void Widget::listOptions (Widget* widget, void* data)
     242{
     243 
     244  if (widget->isOption >= 1 && widget->isOption <= 3)
     245    {
     246      int* count = (int*)data;
     247      *count = *count +1;
     248      cout << *count << ": " << static_cast<Option*>(widget)->title <<" is : " << static_cast<Option*>(widget)->value <<endl;
     249    }
     250  else if (widget->isOption == 5)
     251    {
     252      int* count = (int*)data;
     253      *count = *count +1;
     254      cout << *count << ": " << static_cast<Option*>(widget)->title <<" is : " << static_cast<OptionLabel*>(widget)->cValue <<endl;
     255    }
     256}
     257
     258/**
     259    \brief Finds an Option by a given number (the n'th option found away from this Widget)
     260    \param number The Count of options to wait (by reference)
     261    \param depth The depth of the sarch. if 0 it will not search next pointer
     262   
     263    \todo should return Option* would be much sexier.
     264*/
     265Widget* Widget::findOptionByNumber(int* number, unsigned int depth)
     266{
     267  if (isOption > 0)
     268    {
     269      --*number;
     270      if (*number <= 0)
     271        {
     272          return this;
     273        }
     274    }
     275  if (this->isOption < 0 && static_cast<Packer*>(this)->down)
     276    {
     277      Widget* tmp = static_cast<Packer*>(this)->down->findOptionByNumber(number, depth+1);
     278      if (tmp)
     279        return tmp;
     280    }
     281  if (depth>0 && this->next)
     282    return this->next->findOptionByNumber(number, depth);
     283
     284  return NULL;
     285}
     286
     287/**
     288    \brief This is for listing the groups of "widget"
     289    \param widget specifies the widget that should be listed
     290*/
     291void Widget::listGroups(Widget* widget)
     292{
     293  if(widget->isOption < 0 && static_cast<Packer*>(widget)->groupName)
     294    cout << "[" << static_cast<Packer*>(widget)->groupName << "]\n";
     295}
     296
     297/**
     298    \brief This is for listing the Groups of "widget". It also displays the n'th number found.
     299    \param widget specifies the widget that should be listed
     300    \param data the Counter, that will show the number (this function will raise it by one if a Group is fount.
     301*/
     302void Widget::listGroups(Widget* widget, void* data)
     303{
     304  if(widget->isOption < 0 && static_cast<Packer*>(widget)->groupName)
     305    {
     306      int* count = (int*)data;
     307      *count = *count +1;
     308      cout << *count <<": [" << static_cast<Packer*>(widget)->groupName << "]\n";
     309    }
     310}
     311
     312/**
     313    \brief Finds a Group by a given number (the n'th Group found away from this Widget)
     314    \param number The Count of options to wait (by reference)
     315    \param depth The depth of the sarch. if 0 it will not search next pointer
     316*/
     317Widget* Widget::findGroupByNumber(int* number, unsigned int depth)
     318{
     319  if (isOption < 0 && static_cast<Packer*>(this)->groupName)
     320    {
     321      --*number;
     322      if (*number <= 0)
     323        {
     324          return this;
     325        }
     326    }
     327  if (this->isOption < 0 && static_cast<Packer*>(this)->down)
     328    {
     329      Widget* tmp = static_cast<Packer*>(this)->down->findGroupByNumber(number, depth+1);
     330      if (tmp)
     331        return tmp;
     332    }
     333  if (depth>0 && this->next)
     334    return this->next->findGroupByNumber(number, depth);
     335
     336  return NULL;
     337}
     338 
    221339/**
    222340    \brief This is for setting the option of "widget"
  • orxonox/branches/updater/src/gui/orxonox_gui_gtk.h

    r3304 r3305  
    3333#endif /* HAVE_GTK2 */
    3434
    35 #ifdef HAVE_GTK2
    36 bool initGTK(int argc, char* argv[]);
    37 bool mainloopGTK(void);
    38 #endif /* HAVE_GTK2 */
     35bool initGUI(int argc, char* argv[]);
     36bool mainloopGUI(void);
    3937
    4038//! This is the topmost object that can be displayed all others are derived from it.
     
    5654  void walkThrough (void (*function)(Widget*), unsigned int depth);
    5755  void walkThrough (void (*function)(Widget*, void*), void* data, unsigned int depth);
     56  static void listOptionsAndGroups(Widget* widget);
    5857  static void listOptions(Widget* widget);
     58  static void listOptions(Widget* widget, void* data);
     59  Widget* findOptionByNumber(int* number, unsigned int depth);
     60  static void listGroups(Widget* widget);
     61  static void listGroups(Widget* widget, void* data);
     62  Widget* findGroupByNumber(int* number, unsigned int depth);
    5963  static void setOptions(Widget* widget);
    6064  static void flagCheck(Widget* widget, void* flagName);
Note: See TracChangeset for help on using the changeset viewer.