Incorporated Oliver's initial networking code.
This commit is contained in:
parent
116e3913ae
commit
540849b9c3
7 changed files with 125 additions and 3 deletions
|
@ -49,6 +49,9 @@
|
||||||
release build */
|
release build */
|
||||||
#undef FG_NDEBUG
|
#undef FG_NDEBUG
|
||||||
|
|
||||||
|
/* Define to include Oliver's networking support */
|
||||||
|
#undef FG_NETWORK_OLK
|
||||||
|
|
||||||
/* Define to the type of elements in the array set by `getgroups'.
|
/* Define to the type of elements in the array set by `getgroups'.
|
||||||
Usually this is either `int' or `gid_t'. */
|
Usually this is either `int' or `gid_t'. */
|
||||||
#undef GETGROUPS_T
|
#undef GETGROUPS_T
|
||||||
|
|
|
@ -50,6 +50,7 @@
|
||||||
#include <Math/fg_random.h>
|
#include <Math/fg_random.h>
|
||||||
#include <Math/mat3.h>
|
#include <Math/mat3.h>
|
||||||
#include <Math/polar3d.hxx>
|
#include <Math/polar3d.hxx>
|
||||||
|
#include <Network/network.h>
|
||||||
#include <Scenery/scenery.hxx>
|
#include <Scenery/scenery.hxx>
|
||||||
#include <Time/fg_timer.hxx>
|
#include <Time/fg_timer.hxx>
|
||||||
|
|
||||||
|
@ -1105,6 +1106,12 @@ void fgUpdateHUD( void ) {
|
||||||
char *gmt_str = get_formated_gmt_time();
|
char *gmt_str = get_formated_gmt_time();
|
||||||
HUD_TextList.add( fgText( 40, 10, gmt_str) );
|
HUD_TextList.add( fgText( 40, 10, gmt_str) );
|
||||||
|
|
||||||
|
#ifdef FG_NETWORK_OLK
|
||||||
|
if ( net_hud_display ) {
|
||||||
|
net_hud_update();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
HUD_TextList.draw();
|
HUD_TextList.draw();
|
||||||
|
|
||||||
line_width = (current_options.get_xsize() > 1000) ? 1.0 : 0.5;
|
line_width = (current_options.get_xsize() > 1000) ? 1.0 : 0.5;
|
||||||
|
|
103
src/GUI/gui.cxx
103
src/GUI/gui.cxx
|
@ -58,6 +58,7 @@
|
||||||
#include <Main/fg_init.hxx>
|
#include <Main/fg_init.hxx>
|
||||||
#include <Main/views.hxx>
|
#include <Main/views.hxx>
|
||||||
#include <Misc/fgpath.hxx>
|
#include <Misc/fgpath.hxx>
|
||||||
|
#include <Network/network.h>
|
||||||
#include <Time/fg_time.hxx>
|
#include <Time/fg_time.hxx>
|
||||||
|
|
||||||
#include "gui.h"
|
#include "gui.h"
|
||||||
|
@ -507,6 +508,91 @@ static void NewAirportInit(void)
|
||||||
FG_FINALIZE_PUI_DIALOG( AptDialog );
|
FG_FINALIZE_PUI_DIALOG( AptDialog );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// The beginnings of networking :-)
|
||||||
|
// Needs cleaning up but works
|
||||||
|
// These statics should disapear when this is a class
|
||||||
|
static puDialogBox *NetIdDialog = 0;
|
||||||
|
static puFrame *NetIdDialogFrame = 0;
|
||||||
|
static puText *NetIdDialogMessage = 0;
|
||||||
|
static puInput *NetIdDialogInput = 0;
|
||||||
|
|
||||||
|
static char NewNetId[16];
|
||||||
|
static char NewNetIdLabel[] = "Enter New Callsign";
|
||||||
|
|
||||||
|
static puOneShot *NetIdDialogOkButton = 0;
|
||||||
|
static puOneShot *NetIdDialogCancelButton = 0;
|
||||||
|
|
||||||
|
void NetIdDialog_Cancel(puObject *)
|
||||||
|
{
|
||||||
|
FG_POP_PUI_DIALOG( NetIdDialog );
|
||||||
|
}
|
||||||
|
|
||||||
|
void NetIdDialog_OK (puObject *)
|
||||||
|
{
|
||||||
|
string NetId;
|
||||||
|
|
||||||
|
FGTime *t = FGTime::cur_time_params;
|
||||||
|
int PauseMode = t->getPause();
|
||||||
|
if(!PauseMode)
|
||||||
|
t->togglePauseMode();
|
||||||
|
|
||||||
|
char *s;
|
||||||
|
NetIdDialogInput->getValue(&s);
|
||||||
|
NetId = s;
|
||||||
|
|
||||||
|
NetIdDialog_Cancel( NULL );
|
||||||
|
current_options.set_net_id( NetId.c_str() );
|
||||||
|
net_hud_display = 1;
|
||||||
|
|
||||||
|
if( PauseMode != t->getPause() )
|
||||||
|
t->togglePauseMode();
|
||||||
|
}
|
||||||
|
|
||||||
|
void NewCallSign(puObject *cb)
|
||||||
|
{
|
||||||
|
sprintf( NewNetId, "%s", current_options.get_net_id().c_str() );
|
||||||
|
NetIdDialogInput->setValue( NewNetId );
|
||||||
|
|
||||||
|
FG_PUSH_PUI_DIALOG( NetIdDialog );
|
||||||
|
}
|
||||||
|
|
||||||
|
static void NewNetIdInit(void)
|
||||||
|
{
|
||||||
|
sprintf( NewNetId, "%s", current_options.get_net_id().c_str() );
|
||||||
|
int len = 150 - puGetStringWidth( puGetDefaultLabelFont(),
|
||||||
|
NewNetIdLabel ) / 2;
|
||||||
|
|
||||||
|
NetIdDialog = new puDialogBox (150, 50);
|
||||||
|
{
|
||||||
|
NetIdDialogFrame = new puFrame (0,0,350, 150);
|
||||||
|
NetIdDialogMessage = new puText (len, 110);
|
||||||
|
NetIdDialogMessage -> setLabel (NewNetIdLabel);
|
||||||
|
|
||||||
|
NetIdDialogInput = new puInput (50, 70, 300, 100);
|
||||||
|
NetIdDialogInput -> setValue (NewNetId);
|
||||||
|
NetIdDialogInput -> acceptInput();
|
||||||
|
|
||||||
|
NetIdDialogOkButton = new puOneShot (50, 10, 110, 50);
|
||||||
|
NetIdDialogOkButton -> setLegend (gui_msg_OK);
|
||||||
|
NetIdDialogOkButton -> setCallback (NetIdDialog_OK);
|
||||||
|
NetIdDialogOkButton -> makeReturnDefault(TRUE);
|
||||||
|
|
||||||
|
NetIdDialogCancelButton = new puOneShot (240, 10, 300, 50);
|
||||||
|
NetIdDialogCancelButton -> setLegend (gui_msg_CANCEL);
|
||||||
|
NetIdDialogCancelButton -> setCallback (NetIdDialog_Cancel);
|
||||||
|
|
||||||
|
}
|
||||||
|
FG_FINALIZE_PUI_DIALOG( NetIdDialog );
|
||||||
|
}
|
||||||
|
|
||||||
|
static void net_display_toggle( puObject *cb)
|
||||||
|
{
|
||||||
|
net_hud_display = (net_hud_display) ? 0 : 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*************** End Networking **************/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* -----------------------------------------------------------------------
|
/* -----------------------------------------------------------------------
|
||||||
The menu stuff
|
The menu stuff
|
||||||
|
@ -553,6 +639,17 @@ puCallback optionsSubmenuCb [] = {
|
||||||
notCb, notCb, NULL
|
notCb, notCb, NULL
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#ifdef FG_NETWORK_OLK
|
||||||
|
char *networkSubmenu [] = {
|
||||||
|
"Unregister from FGD ", "Send MSG to All", "Send MSG", "Show Pilots", "Register to FGD",
|
||||||
|
"Scan for Deamons", "Enter Callsign", "Display Netinfos", "Toggle Display", NULL
|
||||||
|
};
|
||||||
|
puCallback networkSubmenuCb [] = {
|
||||||
|
notCb, notCb, notCb, notCb, notCb, notCb, NewCallSign, notCb,
|
||||||
|
net_display_toggle, NULL
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
char *helpSubmenu [] = {
|
char *helpSubmenu [] = {
|
||||||
"About...", "Help", NULL
|
"About...", "Help", NULL
|
||||||
};
|
};
|
||||||
|
@ -626,6 +723,9 @@ void guiInit()
|
||||||
// Set up our Dialog Boxes
|
// Set up our Dialog Boxes
|
||||||
ConfirmExitDialogInit();
|
ConfirmExitDialogInit();
|
||||||
NewAirportInit();
|
NewAirportInit();
|
||||||
|
#ifdef FG_NETWORK_OLK
|
||||||
|
NewNetIdInit();
|
||||||
|
#endif
|
||||||
mkDialogInit();
|
mkDialogInit();
|
||||||
|
|
||||||
// Make the menu bar
|
// Make the menu bar
|
||||||
|
@ -636,6 +736,9 @@ void guiInit()
|
||||||
mainMenuBar -> add_submenu ("Aircraft", aircraftSubmenu, aircraftSubmenuCb);
|
mainMenuBar -> add_submenu ("Aircraft", aircraftSubmenu, aircraftSubmenuCb);
|
||||||
mainMenuBar -> add_submenu ("Environment", environmentSubmenu, environmentSubmenuCb);
|
mainMenuBar -> add_submenu ("Environment", environmentSubmenu, environmentSubmenuCb);
|
||||||
mainMenuBar -> add_submenu ("Options", optionsSubmenu, optionsSubmenuCb);
|
mainMenuBar -> add_submenu ("Options", optionsSubmenu, optionsSubmenuCb);
|
||||||
|
#ifdef FG_NETWORK_OLK
|
||||||
|
mainMenuBar -> add_submenu ("Network", networkSubmenu, networkSubmenuCb);
|
||||||
|
#endif
|
||||||
mainMenuBar -> add_submenu ("Help", helpSubmenu, helpSubmenuCb);
|
mainMenuBar -> add_submenu ("Help", helpSubmenu, helpSubmenuCb);
|
||||||
mainMenuBar-> close ();
|
mainMenuBar-> close ();
|
||||||
// Set up menu bar toggle
|
// Set up menu bar toggle
|
||||||
|
|
|
@ -58,6 +58,7 @@ fgfs_LDADD = \
|
||||||
$(top_builddir)/Simulator/GUI/libGUI.a \
|
$(top_builddir)/Simulator/GUI/libGUI.a \
|
||||||
$(top_builddir)/Simulator/Scenery/libScenery.a \
|
$(top_builddir)/Simulator/Scenery/libScenery.a \
|
||||||
$(top_builddir)/Simulator/Airports/libAirports.a \
|
$(top_builddir)/Simulator/Airports/libAirports.a \
|
||||||
|
$(top_builddir)/Simulator/Network/libNetwork.a \
|
||||||
$(top_builddir)/Simulator/Objects/libObjects.a \
|
$(top_builddir)/Simulator/Objects/libObjects.a \
|
||||||
$(top_builddir)/Simulator/Time/libTime.a \
|
$(top_builddir)/Simulator/Time/libTime.a \
|
||||||
$(top_builddir)/Simulator/Weather/libWeather.a \
|
$(top_builddir)/Simulator/Weather/libWeather.a \
|
||||||
|
|
|
@ -427,7 +427,7 @@ static void fgRenderFrame( void ) {
|
||||||
sgMultMat4( sgVIEW, current_view.sgVIEW, sgTRANS );
|
sgMultMat4( sgVIEW, current_view.sgVIEW, sgTRANS );
|
||||||
ssgSetCamera( sgVIEW );
|
ssgSetCamera( sgVIEW );
|
||||||
// ssgSetCamera( current_view.sgVIEW );
|
// ssgSetCamera( current_view.sgVIEW );
|
||||||
ssgCullAndDraw( scene );
|
// ssgCullAndDraw( scene );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1066,8 +1066,10 @@ int main( int argc, char **argv ) {
|
||||||
// distribution) specifically from the ssg tux example
|
// distribution) specifically from the ssg tux example
|
||||||
//
|
//
|
||||||
|
|
||||||
ssgModelPath( "/stage/pinky01/src/Libs/plib-1.0.12/examples/ssg/tux/data/" );
|
// ssgModelPath( "/stage/pinky01/src/Libs/plib-1.0.12/examples/ssg/tux/data/" );
|
||||||
ssgTexturePath( "/stage/pinky01/src/Libs/plib-1.0.12/examples/ssg/tux/data/" );
|
// ssgTexturePath( "/stage/pinky01/src/Libs/plib-1.0.12/examples/ssg/tux/data/" );
|
||||||
|
ssgModelPath( "/h/curt/src/Libs/plib-1.0.12/examples/ssg/tux/data/" );
|
||||||
|
ssgTexturePath( "/h/curt/src/Libs/plib-1.0.12/examples/ssg/tux/data/" );
|
||||||
|
|
||||||
scene = new ssgRoot;
|
scene = new ssgRoot;
|
||||||
penguin = new ssgTransform;
|
penguin = new ssgTransform;
|
||||||
|
|
|
@ -201,6 +201,7 @@ fgOPTIONS::fgOPTIONS() :
|
||||||
}
|
}
|
||||||
|
|
||||||
airport_id = ""; // default airport id
|
airport_id = ""; // default airport id
|
||||||
|
net_id = "";
|
||||||
|
|
||||||
// initialize port config string list
|
// initialize port config string list
|
||||||
port_options_list.erase ( port_options_list.begin(),
|
port_options_list.erase ( port_options_list.begin(),
|
||||||
|
|
|
@ -151,6 +151,9 @@ private:
|
||||||
|
|
||||||
// Serial port configuration strings
|
// Serial port configuration strings
|
||||||
str_container port_options_list;
|
str_container port_options_list;
|
||||||
|
|
||||||
|
// Network options
|
||||||
|
string net_id;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
@ -210,6 +213,7 @@ public:
|
||||||
inline str_container get_port_options_list() const {
|
inline str_container get_port_options_list() const {
|
||||||
return port_options_list;
|
return port_options_list;
|
||||||
}
|
}
|
||||||
|
inline string get_net_id() const { return net_id; }
|
||||||
|
|
||||||
// Update functions
|
// Update functions
|
||||||
inline void set_airport_id( const string id ) { airport_id = id; }
|
inline void set_airport_id( const string id ) { airport_id = id; }
|
||||||
|
@ -230,6 +234,7 @@ public:
|
||||||
void toggle_panel();
|
void toggle_panel();
|
||||||
inline void set_xsize( int x ) { xsize= x; }
|
inline void set_xsize( int x ) { xsize= x; }
|
||||||
inline void set_ysize( int y ) { xsize= y; }
|
inline void set_ysize( int y ) { xsize= y; }
|
||||||
|
inline void set_net_id( const string id ) { net_id = id; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue