gServerMenuItem Class Reference

Inheritance diagram for gServerMenuItem:

Inheritance graph
[legend]
Collaboration diagram for gServerMenuItem:

Collaboration graph
[legend]

List of all members.

Public Member Functions

void AddFavorite ()
void SetServer (nServerInfo *s)
gServerInfoGetServer ()
virtual void Render (REAL x, REAL y, REAL alpha=1, bool selected=0)
virtual void RenderBackground ()
virtual void Enter ()
virtual bool Event (SDL_Event &event)
 gServerMenuItem (gServerMenu *men)
virtual ~gServerMenuItem ()

Protected Attributes

gServerInfoserver
double lastPing_
 the time of the last manual ping
bool favorite_
 flag indicating whether this is a favorite


Detailed Description

Definition at line 141 of file gServerBrowser.cpp.


Constructor & Destructor Documentation

gServerMenuItem::gServerMenuItem ( gServerMenu men  ) 

Definition at line 834 of file gServerBrowser.cpp.

00835         :gBrowserMenuItem(men, sg_HelpText), server(NULL), lastPing_(-100), favorite_(false)
00836 {}

gServerMenuItem::~gServerMenuItem (  )  [virtual]

Definition at line 838 of file gServerBrowser.cpp.

References uMenu::AddItem(), uMenu::Item(), uMenuItem::menu, NULL, uMenu::NumItems(), uMenu::RemoveItem(), and SetServer().

00839 {
00840     SetServer(NULL);
00841 
00842     // make sure the last entry in the array (the first menuitem)
00843     // stays the same
00844     uMenuItem* last = menu->Item(menu->NumItems()-1);
00845     menu->RemoveItem(last);
00846     menu->RemoveItem(this);
00847     menu->AddItem(last);
00848 }

Here is the call graph for this function:


Member Function Documentation

void gServerMenuItem::AddFavorite (  ) 

void gServerMenuItem::SetServer ( nServerInfo s  ) 

Definition at line 806 of file gServerBrowser.cpp.

References favorite_, gServerFavorites::IsFavorite(), gServerInfo::menuItem, NULL, server, and SetServer().

Referenced by gServerMenu::gServerMenu(), SetServer(), gServerMenu::Update(), and ~gServerMenuItem().

00807 {
00808     if (s == server)
00809         return;
00810 
00811     if (server)
00812         server->menuItem = NULL;
00813 
00814     server = dynamic_cast<gServerInfo*>(s);
00815 
00816     if (server)
00817     {
00818         if (server->menuItem)
00819             server->menuItem->SetServer(NULL);
00820 
00821         server->menuItem = this;
00822     }
00823 
00824     favorite_ = gServerFavorites::IsFavorite( server );
00825 }

Here is the call graph for this function:

Here is the caller graph for this function:

gServerInfo * gServerMenuItem::GetServer (  ) 

Definition at line 827 of file gServerBrowser.cpp.

References server.

Referenced by gServerMenu::Update().

00828 {
00829     return server;
00830 }

Here is the caller graph for this function:

void gServerMenuItem::Render ( REAL  x,
REAL  y,
REAL  alpha = 1,
bool  selected = 0 
) [virtual]

Reimplemented from uMenuItem.

Definition at line 547 of file gServerBrowser.cpp.

References nServerInfo::Compat_Downgrade, nServerInfo::Compat_Ok, nServerInfo::Compat_Upgrade, nServerInfo::Compatibility(), displace, favorite_, nServerInfoBase::GetName(), nServerInfo::MaxUsers(), uMenuItem::menu, nServerInfo::Ping(), nServerInfo::Polling(), nServerInfo::Reachable(), gServerMenu::Render(), nServerInfo::Score(), score, server, uMenuItem::SetColor(), sg_filterServernameColorStrings, shrink, and nServerInfo::Users().

00548 {
00549 #ifndef DEDICATED
00550     // REAL time=tSysTimeFloat()*10;
00551 
00552     SetColor( selected, alpha );
00553 
00554     gServerMenu *serverMenu = static_cast<gServerMenu*>(menu);
00555 
00556     if (server)
00557     {
00558         tColoredString name;
00559         tString score;
00560         tString users;
00561         tString ping;
00562 
00563         int p = static_cast<int>(server->Ping()*1000);
00564         if (p < 0)
00565             p = 0;
00566         if (p > 10000)
00567             p = 10000;
00568 
00569         int s = static_cast<int>(server->Score());
00570         if (server->Score() > 10000)
00571             s = 10000;
00572         if (server->Score() < -10000)
00573             s = -10000;
00574 
00575         if (server->Polling())
00576         {
00577             score << tOutput("$network_master_polling");
00578         }
00579         else if (!server->Reachable())
00580         {
00581             score << tOutput("$network_master_unreachable");
00582         }
00583         else if ( nServerInfo::Compat_Ok != server->Compatibility() )
00584         {
00585             switch( server->Compatibility() )
00586             {
00587             case nServerInfo::Compat_Upgrade:
00588                 score << tOutput( "$network_master_upgrage" );
00589                 break;
00590             case nServerInfo::Compat_Downgrade:
00591                 score << tOutput( "$network_master_downgrage" );
00592                 break;
00593             default:
00594                 score << tOutput( "$network_master_incompatible" );
00595                 break;
00596             }
00597         }
00598         else if ( server->Users() >= server->MaxUsers() )
00599         {
00600             score << tOutput( "$network_master_full" );
00601             score << " (" << server->Users() << "/" << server->MaxUsers() << ")";
00602         }
00603         else
00604         {
00605             if ( favorite_ )
00606             {
00607                 score << "B ";
00608             }
00609 
00610             score << s;
00611             users << server->Users() << "/" << server->MaxUsers();
00612             ping  << p;
00613         }
00614 
00615         if ( sg_filterServernameColorStrings )
00616             name << tColoredString::RemoveColors( server->GetName() );
00617         else
00618         {
00619             name << server->GetName();
00620         }
00621 
00622         serverMenu->Render(y*shrink + displace,
00623                            name,
00624                            score, users, ping);
00625     }
00626     else
00627     {
00628         tOutput o("$network_master_noserver");
00629         tString s;
00630         s << o;
00631         serverMenu->Render(y*shrink + displace,
00632                            s,
00633                            tString(""), tString(""), tString(""));
00634 
00635     }
00636 #endif
00637 }

Here is the call graph for this function:

void gServerMenuItem::RenderBackground (  )  [virtual]

Reimplemented from gBrowserMenuItem.

Definition at line 640 of file gServerBrowser.cpp.

References tColoredString::ColorString(), rTextField::EnableLineWrap(), tString::Len(), nServerInfo::Options(), players, nServerInfo::Release(), gBrowserMenuItem::RenderBackground(), server, rTextField::SetDefaultColor(), sr_fontServerDetails, text_height, nServerInfo::Url(), and nServerInfo::UserNamesOneLine().

00641 {
00642 #ifndef DEDICATED
00643     gBrowserMenuItem::RenderBackground();
00644 
00645     if ( server )
00646     {
00647         rTextField::SetDefaultColor( tColor(1,1,1) );
00648 
00649         rTextField players( -.9, -.3, text_height, sr_fontServerDetails );
00650         players.EnableLineWrap();
00651         players << tOutput( "$network_master_players" );
00652         if ( server->UserNamesOneLine().Len() > 2 )
00653             players << server->UserNamesOneLine();
00654         else
00655             players << tOutput( "$network_master_players_empty" );
00656         players << "\n" << tColoredString::ColorString(1,1,1);
00657         tColoredString uri;
00658         uri << server->Url() << tColoredString::ColorString(1,1,1);
00659         players << tOutput( "$network_master_serverinfo", server->Release(), uri, server->Options() );
00660     }
00661 #endif
00662 }

Here is the call graph for this function:

void gServerMenuItem::Enter (  )  [virtual]

Reimplemented from uMenuItem.

Definition at line 791 of file gServerBrowser.cpp.

References ConnectToServer(), uMenu::Exit(), nServerInfo::GetFromLANContinuouslyStop(), uMenuItem::menu, and server.

00792 {
00793     nServerInfo::GetFromLANContinuouslyStop();
00794 
00795     menu->Exit();
00796 
00797     //  gLogo::SetBig(false);
00798     //  gLogo::SetSpinning(true);
00799     // gLogo::SetDisplayed(false);
00800 
00801     if (server)
00802         ConnectToServer(server);
00803 }

Here is the call graph for this function:

bool gServerMenuItem::Event ( SDL_Event &  event  )  [virtual]

Reimplemented from gBrowserMenuItem.

Definition at line 702 of file gServerBrowser.cpp.

References gServerFavorites::AddFavorite(), nServerInfo::CalcScore(), nServerInfo::ClearInfoFlags(), continuePoll, gBrowserMenuItem::Event(), favorite_, nServerInfo::GetScoreBias(), lastPing_, uMenuItem::menu, nServerInfo::QUERY_ALL, nServerInfo::QueryServer(), server, nServerInfo::SetQueryType(), nServerInfo::SetScoreBias(), and tSysTimeFloat().

00703 {
00704 #ifndef DEDICATED
00705     switch (event.type)
00706     {
00707     case SDL_KEYDOWN:
00708         switch (event.key.keysym.sym)
00709         {
00710         case SDLK_p:
00711             continuePoll = true;
00712             if ( server && tSysTimeFloat() - lastPing_ > .5f )
00713             {
00714                 lastPing_ = tSysTimeFloat();
00715 
00716                 server->SetQueryType( nServerInfo::QUERY_ALL );
00717                 server->QueryServer();
00718                 server->ClearInfoFlags();
00719             }
00720             return true;
00721             break;
00722         default:
00723             break;
00724         }
00725         switch (event.key.keysym.unicode)
00726         {
00727         case '+':
00728             if ( server )
00729             {
00730                 server->SetScoreBias( server->GetScoreBias() + 10 );
00731                 server->CalcScore();
00732             }
00733             (static_cast<gServerMenu*>(menu))->Update();
00734 
00735             return true;
00736             break;
00737         case '-':
00738             if ( server )
00739             {
00740                 server->SetScoreBias( server->GetScoreBias() - 10 );
00741                 server->CalcScore();
00742             }
00743             (static_cast<gServerMenu*>(menu))->Update();
00744 
00745             return true;
00746             break;
00747         case 'b':
00748             if ( server && !favorite_ )
00749             {
00750                 favorite_ = gServerFavorites::AddFavorite( server );
00751             }
00752             return true;
00753             break;
00754         default:
00755             break;
00756         }
00757     }
00758 #endif
00759 
00760     return gBrowserMenuItem::Event( event );
00761 }

Here is the call graph for this function:


Member Data Documentation

gServerInfo* gServerMenuItem::server [protected]

Definition at line 144 of file gServerBrowser.cpp.

Referenced by Enter(), Event(), GetServer(), Render(), RenderBackground(), and SetServer().

double gServerMenuItem::lastPing_ [protected]

the time of the last manual ping

Definition at line 145 of file gServerBrowser.cpp.

Referenced by Event().

bool gServerMenuItem::favorite_ [protected]

flag indicating whether this is a favorite

Definition at line 146 of file gServerBrowser.cpp.

Referenced by Event(), Render(), and SetServer().


The documentation for this class was generated from the following file:
Generated on Sat Mar 15 23:45:31 2008 for Armagetron Advanced by  doxygen 1.5.4