Andrew Midson:
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.
This commit is contained in:
parent
394fe84351
commit
964349e401
5 changed files with 26 additions and 7 deletions
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -135,7 +135,15 @@ copy_from_pui (puObject * object, SGPropertyNode * node)
|
|||
node->setFloatValue(object->getFloatValue());
|
||||
break;
|
||||
default:
|
||||
// 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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue