]> git.mxchange.org Git - flightgear.git/commitdiff
Andrew Midson:
authorehofman <ehofman>
Mon, 31 Jan 2005 10:36:59 +0000 (10:36 +0000)
committerehofman <ehofman>
Mon, 31 Jan 2005 10:36:59 +0000 (10:36 +0000)
I have made the
'Select Airport from List' option in FlightGear work
(I think) properly. I have some concerns about the
solution, which could be broken by changes to plib (if
they re-use the value I have assigned to
PUCLASS_LIST), but for the moment it seems to work OK.

Erik Hofman:
A request has been sent to John Fay to include the puList
code in the puAux subdirectory of plib so expect some
changes for future version of FlightGear.

src/GUI/AirportList.cxx
src/GUI/AirportList.hxx
src/GUI/dialog.cxx
src/GUI/puList.cxx
src/GUI/puList.hxx

index 6ded7f88b2c9bb7c5b9524f4f7a28fe50a718b41..88d77494d6bb655a84833b31a2aca4cf45bf21ff 100644 (file)
@@ -41,9 +41,9 @@ AirportList::~AirportList ()
 }
 
 char *
-AirportList::getStringValue ()
+AirportList::getListStringValue ()
 {
-    return (char *)_airports->getAirport(getIntegerValue())->_id.c_str();
+    return (char *)_airports->getAirport(getListIntegerValue())->_id.c_str();
 }
 
 // end of AirportList.cxx
index 97a1c734631a32fa88e15d8496e9e763c2df6efe..2f3ad87ca89681c8e9b1f3b17a9846f01e003564 100644 (file)
@@ -15,7 +15,7 @@ class AirportList : public puList
     virtual ~AirportList ();
 
     // FIXME: add other string value functions
-    virtual char * getStringValue ();
+    virtual char * getListStringValue ();
 
  private:
     FGAirportList * _airports;
index 52f2fef76b0c43a9e1f17f6558a5e6aaca443bc1..00fc3de8bec6ef80aa0136276c01c2677d1fcbc3 100644 (file)
@@ -135,7 +135,15 @@ copy_from_pui (puObject * object, SGPropertyNode * node)
         node->setFloatValue(object->getFloatValue());
         break;
     default:
-        node->setStringValue(object->getStringValue());
+        // Special case to handle lists, as getStringValue cannot be overridden
+        if(object->getType() & PUCLASS_LIST)
+        {
+            node->setStringValue(((puList *) object)->getListStringValue());
+        }
+        else
+        {
+            node->setStringValue(object->getStringValue());
+        }
         break;
     }
 }
@@ -398,7 +406,7 @@ FGDialog::makeObject (SGPropertyNode * props, int parentWidth, int parentHeight)
              puTextBox->enableInput();
        }
        setupObject(puTextBox,props);
-       return puTextBox; 
+       return puTextBox;
     } else if (type == "select") {
         vector<SGPropertyNode_ptr> value_nodes;
         SGPropertyNode * selection_node =
index 17f654bfcfbb046cd13d09ce0da6703fa17fe05e..5902a68ca1fafead66bdba89d5f7578dbb8de54a 100644 (file)
@@ -53,12 +53,14 @@ handle_arrow (puObject * arrow)
 puList::puList (int x, int y, int w, int h)
     : puGroup(x, y)
 {
+    type |= PUCLASS_LIST;
     init(w, h);
 }
 
 puList::puList (int x, int y, int w, int h, char ** contents)
     : puGroup(x, y)
 {
+    type |= PUCLASS_LIST;
     init(w, h);
     newList(contents);
 }
@@ -75,11 +77,17 @@ puList::newList (char ** contents)
 }
 
 char *
-puList::getStringValue ()
+puList::getListStringValue ()
 {
     return _contents[_list_box->getIntegerValue()];
 }
 
+int
+puList::getListIntegerValue()
+{
+  return _list_box->getIntegerValue();
+}
+
 void
 puList::init (int w, int h)
 {
index 563763a0b0eaf0fc79a6f0a238e4071dd875da36..b33e45f62033213bc03f52360f96dd559ce1e097 100644 (file)
@@ -9,6 +9,8 @@
 
 #include <plib/pu.h>
 
+# define PUCLASS_LIST   0x80000000  // Hopefully this value will never be used by plib
+# define PUCLASS_LIST   0x80000000  // Hopefully this value will never be used by plib
 
 /**
  * A scrolling list for PUI.
@@ -24,7 +26,8 @@ class puList : public puGroup
 
     virtual void newList (char ** contents);
     // TODO: other string value funcs
-    virtual char * getStringValue ();
+    virtual char * getListStringValue ();
+    virtual int getListIntegerValue();
 
  protected:
     virtual void init (int w, int h);