Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 4083 in orxonox.OLD


Ignore:
Timestamp:
May 6, 2005, 2:53:28 PM (19 years ago)
Author:
bensch
Message:

orxonox/trunk/gui: now one can only select the data-repos

Location:
orxonox/trunk/src/lib/gui/gui
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • orxonox/trunk/src/lib/gui/gui/gui_gtk.cc

    r4081 r4083  
    17481748  this->changeOption = NULL;
    17491749  this->openUpButton = NULL;
     1750  this->okObject = NULL;
     1751  this->okFunc = NULL;
    17501752
    17511753#ifdef HAVE_GTK2
    17521754  this->widget = gtk_file_selection_new(fileDialogName);
     1755
     1756  gtk_file_selection_set_select_multiple(GTK_FILE_SELECTION (this->widget), FALSE);
     1757
    17531758  g_signal_connect(GTK_FILE_SELECTION (this->widget)->cancel_button,
    17541759                     "button_release_event",
     
    17811786}
    17821787
     1788void FileDialog::setOKFunc(void* okObject, bool(*function)(const char* , void*))
     1789{
     1790  this->okObject = okObject;
     1791  this->okFunc = function;
     1792}
     1793
     1794
    17831795void FileDialog::setOpenUpButton(Button* openUpButton)
    17841796{
     
    18031815}
    18041816
     1817/**
     1818   \brief disables the File Operator Buttons
     1819*/
     1820void FileDialog::disableFileOpts(void)
     1821{
     1822#ifdef HAVE_GTK2
     1823  gtk_file_selection_hide_fileop_buttons(GTK_FILE_SELECTION(this->widget));
     1824#endif /* HAVE_GTK2 */
     1825}
     1826
     1827/**
     1828   \brief The ok-button has been pressed
     1829*/
    18051830void FileDialog::okEvent(void)
    18061831{
    1807   if (this->changeOption)
    1808 #ifdef HAVE_GTK2
    1809     changeOption->setValue(gtk_file_selection_get_filename(GTK_FILE_SELECTION(this->widget)));
    1810 #endif /* HAVE_GTK2 */
    1811   this->close();
    1812 }
    1813 
     1832  if (this->okFunc)
     1833    {
     1834#ifdef HAVE_GTK2
     1835      if(this->okFunc((const char*)gtk_file_selection_get_filename(GTK_FILE_SELECTION(this->widget)), this->okObject))
     1836         this->close();
     1837#endif /* HAVE_GTK2 */
     1838    }
     1839  else if (this->changeOption)
     1840    {
     1841#ifdef HAVE_GTK2
     1842      changeOption->setValue(gtk_file_selection_get_filename(GTK_FILE_SELECTION(this->widget)));
     1843#endif /* HAVE_GTK2 */
     1844      this->close();
     1845    }
     1846  else
     1847    this->close();
     1848}
     1849
     1850/**
     1851   \biref opens up the FileDialog-Window
     1852*/
    18141853void FileDialog::open(void)
    18151854{
     
    18211860}
    18221861
     1862/**
     1863   \closes the FileDialog-Window
     1864*/
    18231865void FileDialog::close(void)
    18241866{
  • orxonox/trunk/src/lib/gui/gui/gui_gtk.h

    r4071 r4083  
    428428  Button* openUpButton;
    429429  bool isOpen;
     430  bool (*okFunc)(const char* , void*);
     431  void* okObject;
     432
    430433 public:
    431434  FileDialog(const char* fileDialogName);
     
    433436
    434437  void setChangeOption(OptionLabel* changeOption);
     438  void setOKFunc(void* okObject, bool(*function)(const char* , void*));
    435439  void setOpenUpButton(Button* openUpButton);
    436440  void setDefaultFileName(const char* defaultFileName);
    437441  void setMask(const char* mask);
     442  void disableFileOpts(void);
    438443
    439444  void okEvent();
  • orxonox/trunk/src/lib/gui/gui/gui_keys.cc

    r4056 r4083  
    6969   this->pKeysBox = new Box('v');
    7070   this->pKeysBox->setGroupName(player);
    71     this->pKeysBox->fill(addKey(UP, "up"));
    72     this->pKeysBox->fill(addKey(DOWN, "down"));
    73     this->pKeysBox->fill(addKey(LEFT, "left"));
    74     this->pKeysBox->fill(addKey(RIGHT, "right"));
    75     this->pKeysBox->fill(addKey(SHOOT, "shoot"));
     71    this->pKeysBox->fill(addKey(UP, "UP"));
     72    this->pKeysBox->fill(addKey(DOWN, "DOWN"));
     73    this->pKeysBox->fill(addKey(LEFT, "LEFT"));
     74    this->pKeysBox->fill(addKey(RIGHT, "RIGHT"));
     75    this->pKeysBox->fill(addKey(SHOOT, "FIRE"));
    7676    delete windowName;
    7777    closeButton = new Button("close");
  • orxonox/trunk/src/lib/gui/gui/gui_update.cc

    r4068 r4083  
    4040  Button* dataDirButton;       //!< A Button for the selection of the DataRepos
    4141  OptionLabel* dataDirLabel;   //!< A Label fot the selection of the DataRepos
     42 
    4243
    4344  this->tmpDir = NULL;
     
    5152  this->updateFrame->setGroupName("update");
    5253  this->updateBox = new Box('v');
     54
     55  dataDirButton = new Button("Data Directory");
     56  dataDirLabel = new OptionLabel("DataDir", "unknown");
     57  dataDirLabel->saveability();
     58  dataDirDialog = new FileDialog("data-Repos-location");
     59  dataDirDialog->setDefaultFileName("data");
     60  dataDirDialog->setMask(DATA_IDENTIFIER);
     61  this->checkDataDir("../data/" DATA_IDENTIFIER, dataDirLabel);
     62  dataDirDialog->disableFileOpts();
     63  dataDirDialog->setOpenUpButton(dataDirButton);
     64  //dataDirDialog->setChangeOption(dataDirLabel);
     65  dataDirDialog->setOKFunc(dataDirLabel, GuiUpdate::checkDataDir);
     66  updateBox->fill(dataDirButton);
     67  updateBox->fill(dataDirLabel);
     68
    5369#ifdef HAVE_CURL
    5470
     
    6076
    6177 
    62   dataDirButton = new Button("browse");
    63   dataDirLabel = new OptionLabel("DataDir", "test");
    64   dataDirLabel->saveability();
    65   dataDirDialog = new FileDialog("data-Repos-location");
    66   dataDirDialog->setDefaultFileName("../data");
    67   dataDirDialog->setOpenUpButton(dataDirButton);
    68   dataDirDialog->setChangeOption(dataDirLabel);
    69   updateBox->fill(dataDirLabel);
    70   updateBox->fill(dataDirButton);
    7178
    7279
     
    7885
    7986#else /* HAVE_CURL */
    80   Label* noCurlLabel = new Label("since you do not have cURL,\nthis option is not availible");
     87  Label* noCurlLabel = new Label("since you do not have cURL-support,\nupdate options are not availible");
    8188  this->updateBox->fill(noCurlLabel); 
    8289#endif /* HAVE_CURL */
     
    94101
    95102}
     103
     104/**
     105   \brief checks if the Folder containing selected File is data.oxd, and if so sets it.
     106   \param
     107*/
     108bool GuiUpdate::checkDataDir(const char* fileName, void* object)
     109{
     110  if (!strcmp(fileName+(strlen(fileName)-strlen(DATA_IDENTIFIER)), DATA_IDENTIFIER))
     111    {
     112      char* tmpName = new char[strlen(fileName)-strlen(DATA_IDENTIFIER)+1];
     113      strncpy(tmpName, fileName, strlen(fileName)-strlen(DATA_IDENTIFIER));
     114      tmpName[strlen(fileName)-strlen(DATA_IDENTIFIER)] = '\0';
     115      static_cast<OptionLabel*>(object)->setValue(tmpName);
     116      delete tmpName;
     117      return true;
     118    }
     119  else
     120    return false;
     121}
     122
    96123
    97124/**
  • orxonox/trunk/src/lib/gui/gui/gui_update.h

    r4061 r4083  
    1010#include "gui_element.h"
    1111#include "gui_gtk.h"
     12
     13
     14#define DATA_IDENTIFIER "data.oxd"
    1215
    1316#include <stdio.h>
     
    5962  static gint updateSourceFunc(GtkWidget* w, GdkEventKey* event, void* info);
    6063#endif /* HAVE_GTK2 */
     64
     65  static bool checkDataDir(const char* fileName, void* object);
    6166
    6267#ifdef HAVE_CURL
Note: See TracChangeset for help on using the changeset viewer.