rConsole Class Reference

#include <rConsole.h>

Inheritance diagram for rConsole:

Inheritance graph
[legend]
Collaboration diagram for rConsole:

Collaboration graph
[legend]

List of all members.

Public Member Functions

 rConsole ()
int Height ()
REAL Timeout ()
void SetHeight (int h, bool stop_scroll=true)
void SetTimeout (REAL to)
void Render ()
virtual tConsoleDoPrint (const tString &s)
void Scroll (int dir)
virtual void DoCenterDisplay (const tString &s, REAL timeout=2, REAL r=1, REAL g=1, REAL b=1)
virtual tString ColorString (REAL r, REAL g, REAL b) const

Public Attributes

bool fullscreen
bool autoDisplayAtSwap
bool autoDisplayAtNewline

Private Member Functions

void DisplayAtNewline ()

Static Private Member Functions

static int MaxHeight ()

Private Attributes

tArray< tStringlines
int currentTop
int currentIn
double lastTimeout
double lastCustomTimeout
int height
REAL timeout


Detailed Description

Definition at line 40 of file rConsole.h.


Constructor & Destructor Documentation

rConsole::rConsole (  ) 

Definition at line 36 of file rConsole.cpp.

References tConsole::RegisterBetterConsole().

00037         :currentTop(0),currentIn(0),
00038         lastCustomTimeout(-20),height(8),timeout(2),
00039         fullscreen(0),autoDisplayAtSwap(1),
00040 autoDisplayAtNewline(0){
00041     RegisterBetterConsole(this);
00042 }

Here is the call graph for this function:


Member Function Documentation

int rConsole::MaxHeight (  )  [static, private]

Definition at line 50 of file rConsole.cpp.

References rCHEIGHT_CON, sr_maxRows, and x.

Referenced by Height(), and Render().

00050                        {
00051     int x=int(1.7/rCHEIGHT_CON)-1;;
00052     if (x>sr_maxRows)
00053         return sr_maxRows;
00054     else
00055         return x;
00056 }

Here is the caller graph for this function:

void rConsole::DisplayAtNewline (  )  [private]

Definition at line 156 of file rConsoleCout.cpp.

Referenced by DoCenterDisplay(), and DoPrint().

00156                                {
00157 }

Here is the caller graph for this function:

int rConsole::Height ( void   ) 

Definition at line 58 of file rConsole.cpp.

References fullscreen, height, MaxHeight(), rSmallConsoleCallback::SmallColsole(), and sr_rows.

Referenced by DoPrint(), and Render().

00058                     {
00059     if (fullscreen)
00060         return MaxHeight();
00061     else if (rSmallConsoleCallback::SmallColsole())
00062         return sr_rows;
00063     else
00064         return height > sr_rows ? height : sr_rows;
00065 
00066 }

Here is the call graph for this function:

Here is the caller graph for this function:

REAL rConsole::Timeout (  ) 

Definition at line 67 of file rConsole.cpp.

References fullscreen, and timeout.

00067                       {
00068     if (fullscreen)
00069         return(100000000.0);
00070     else
00071         return timeout;
00072 }

void rConsole::SetHeight ( int  h,
bool  stop_scroll = true 
)

Definition at line 75 of file rConsole.cpp.

References height, lastCustomTimeout, and tSysTimeFloat().

Referenced by do_chat(), do_con(), and MainMenu().

00075                                               {
00076     height=h;
00077     if (stop_scroll)
00078         lastCustomTimeout=tSysTimeFloat()-30;
00079 }

Here is the call graph for this function:

Here is the caller graph for this function:

void rConsole::SetTimeout ( REAL  to  ) 

Definition at line 81 of file rConsole.cpp.

References timeout.

00081 {timeout=to;}

void rConsole::Render (  ) 

Definition at line 76 of file rConsoleGraph.cpp.

References rDisplayList::Call(), center_b, center_fadetime, center_g, center_r, rDisplayList::Clear(), tColoredString::ColorString(), tString::Count(), currentIn, currentTop, DisplayText(), rTextField::EnableLineWrap(), rForceTextCallback::ForceText(), H, Height(), height, lastCustomTimeout, lastTimeout, rTextField::Lines(), lines, tColoredString::LongestLine(), MaxHeight(), rCHEIGHT_CON, rCWIDTH_CON, REAL, rTextField::ResetColor(), rTextField::SetDefaultColor(), rTextField::SetIndent(), rTextField::SetWidth(), rSmallConsoleCallback::SmallColsole(), sr_fontCenterMessage, sr_fontConsole, sr_glOut, sr_ResetRenderState(), sr_screen, sr_screenHeight, sr_screenWidth, sr_textOut, Time, timeout, tSysTimeFloat(), and width.

Referenced by sr_ConsolePerFrame().

00076                      {
00077     if (!sr_glOut)
00078         return;
00079 
00080     sr_ResetRenderState(true);
00081 
00082     REAL W=sr_screenWidth;
00083     REAL H=sr_screenHeight;
00084 
00085     // previous logic
00086     //REAL MW=400;
00087     //REAL MH=(MW*3)/4;
00088     //if(W>MW)
00089     //    W=MW;
00090     //if(H>MH)
00091     //    H=MH;
00092     // rCWIDTH_CON=10/W;
00093     // rCHEIGHT_CON=18/H;
00094 
00095     // the text field has an openGL coordinate with of 1.9; cram the specified number
00096     // of columns in it
00097     rCWIDTH_CON=1.9/sr_columns;
00098 
00099     // get corresponding character height
00100     rCHEIGHT_CON=rCWIDTH_CON*W*9/(5*H);
00101 
00102     if (sr_screen){
00103         Time=tSysTimeFloat();
00104 
00105         if (Time-center_fadetime<2){
00106             REAL alpha=center_fadetime-Time+1;
00107             if (alpha>1) alpha=1;
00108             if (alpha<0) alpha=0;
00109             rTextField::SetDefaultColor( tColor(center_r,center_g,center_b,alpha) );
00110 
00111             REAL width=rCWIDTH_CON*4;
00112             REAL height=rCHEIGHT_CON*4;
00113             REAL len=sr_centerString.LongestLine();
00114             REAL lines=(REAL)(sr_centerString.Count('\n')+1);
00115 
00116             REAL space = 1.6;
00117             REAL needed = width * len;
00118             if (needed > space) {
00119                 width *= space/needed;
00120                 height *= space/needed;
00121             }
00122             space = 0.9 + centerMessageY;
00123             needed = height*lines;
00124             if (needed > space) {
00125                 width *= space/needed;
00126                 height *= space/needed;
00127             }
00128 
00129             DisplayText(0,centerMessageY,height,sr_centerString,sr_fontCenterMessage);
00130             //std::cerr << "DisplayText(0," << centerMessageY << "," << (rCWIDTH_CON*4*fak) << "," << (rCHEIGHT_CON*4*fak) << "," <<sr_centerString << ");\n";
00131         }
00132 
00133         if (sr_textOut || rForceTextCallback::ForceText()){
00134             if (lastCustomTimeout<Time-5 &&
00135                     lastTimeout+timeout<Time && currentTop<currentIn){
00136                 currentTop++;
00137                 lastTimeout=Time;
00138             }
00139 
00140             static int lastTop = currentTop;
00141             static int lastIn  = currentIn;
00142             if ( lastTop != currentTop || lastIn != currentIn )
00143             {
00144                 lastTop = currentTop;
00145                 lastIn  = currentIn;
00146                 sr_consoleDisplayList.Clear();
00147             }
00148 
00149             rTextField::SetDefaultColor( tColor(1,1,1) );
00150 
00151             if ( sr_consoleDisplayList.Call() )
00152             {
00153                 return;
00154             }
00155             rDisplayListFiller filler( sr_consoleDisplayList );
00156 
00157             rTextField out(-.95f,.99f,rCHEIGHT_CON, sr_fontConsole);//,&rFont::s_defaultFontSmall);
00158             out.SetWidth(1.9f);
00159             out.EnableLineWrap();
00160             out.SetIndent(sr_indent);
00161 
00162             int i;
00163             for (i=currentTop;i<=currentIn && i<=currentTop+MaxHeight();i++)
00164                 if (lines[i].Len()>1){
00165                     rTextField::SetDefaultColor( tColor(1,1,1) );
00166                     out << lines[i];
00167                     out.ResetColor();
00168                 }
00169             if (i<currentIn){
00170                 // rTextField::SetDefaultColor( tColor(1,.8,.5) );
00171                 out << tColoredString::ColorString( 1,.8,.5) << "       v   v   v   v   v   v   v   v   v\n";
00172             }
00173 
00174 
00175             int over=out.Lines()-Height();
00176             if (over>0 && (rSmallConsoleCallback::SmallColsole() || lastCustomTimeout<tSysTimeFloat()-15)){
00177                 lastTimeout=Time;
00178                 currentTop+=(over+1)/2;
00179             }
00180         }
00181 
00182         rTextField::SetDefaultColor( tColor(1,1,1) );
00183     }
00184 }

Here is the call graph for this function:

Here is the caller graph for this function:

tConsole & rConsole::DoPrint ( const tString s  )  [virtual]

Reimplemented from tConsole.

Definition at line 97 of file rConsole.cpp.

References autoDisplayAtNewline, BACKEXTRA, c, currentIn, currentTop, DisplayAtNewline(), rForceTextCallback::ForceText(), Height(), lastCustomTimeout, lastTimeout, GrowingArrayBase::Len(), lines, MAXBACK, rNoAutoDisplayAtNewlineCallback::NoAutoDisplayAtNewline(), rSmallConsoleCallback::SmallColsole(), sr_screen, sr_textOut, and tSysTimeFloat().

00097                                             {
00098     bool print_to_stdout=false;
00099 #ifdef DEBUG
00100     print_to_stdout=true;
00101 #endif
00102     bool swap = false;
00103 
00104     if (!sr_screen)
00105         print_to_stdout=true;
00106     if (print_to_stdout)
00107     {
00108         std::cout << tColoredString::RemoveColors(s);
00109         std::cout.flush();
00110     }
00111 
00112     if (sr_screen){
00113         const char *c=s;
00114         while (*c!=0){
00115             lines[currentIn] << *c;
00116             if (*c=='\n'){
00117                 if (currentIn<=currentTop+1)
00118                     lastTimeout=tSysTimeFloat()+4;
00119                 currentIn++;
00120                 if (autoDisplayAtNewline && !rNoAutoDisplayAtNewlineCallback::NoAutoDisplayAtNewline() && (sr_textOut ||
00121                         rForceTextCallback::ForceText()))
00122                     swap = true;
00123 
00124                 if (currentIn >= MAXBACK+BACKEXTRA){
00125                     for(int i=0;i<MAXBACK;i++)
00126                         lines[i]=lines[i+BACKEXTRA];
00127 
00128                     for(int j=lines.Len()-1;j>=MAXBACK;j--)
00129                         lines[j].Clear();
00130 
00131                     currentIn-=BACKEXTRA;
00132                     currentTop-=BACKEXTRA;
00133                     if (currentTop<0)
00134                         currentTop=0;
00135                 }
00136             }
00137             c++;
00138         }
00139 
00140         if (rSmallConsoleCallback::SmallColsole() || lastCustomTimeout<tSysTimeFloat()-15)
00141             while ((currentIn-currentTop) > Height())
00142                 currentTop++;
00143     }
00144 
00145     if (swap)
00146         DisplayAtNewline();
00147 
00148     return *this;
00149 }

Here is the call graph for this function:

void rConsole::Scroll ( int  dir  ) 

Definition at line 151 of file rConsole.cpp.

References rCenterDisplayCallback::CenterDisplay(), currentIn, currentTop, lastCustomTimeout, and tSysTimeFloat().

Referenced by messdown_func(), and messup_func().

00151                             {
00152     rCenterDisplayCallback::CenterDisplay();
00153 
00154     currentTop+=dir*10;
00155     lastCustomTimeout=tSysTimeFloat();
00156     if (currentTop<0)
00157         currentTop=0;
00158 
00159     if (currentTop>currentIn-10)
00160         lastCustomTimeout=tSysTimeFloat()-10;
00161 
00162     if (currentTop>currentIn){
00163         currentTop=currentIn;
00164         lastCustomTimeout=tSysTimeFloat()-20;
00165     }
00166 }

Here is the call graph for this function:

Here is the caller graph for this function:

void rConsole::DoCenterDisplay ( const tString s,
REAL  timeout = 2,
REAL  r = 1,
REAL  g = 1,
REAL  b = 1 
) [virtual]

Reimplemented from tConsole.

Definition at line 49 of file rConsoleCout.cpp.

References DisplayAtNewline().

00049                                                                                 {
00050     std::cout << tColoredString::RemoveColors(s) << '\n';
00051     DisplayAtNewline();
00052 }

Here is the call graph for this function:

tString rConsole::ColorString ( REAL  r,
REAL  g,
REAL  b 
) const [virtual]

Reimplemented from tConsole.

Definition at line 168 of file rConsole.cpp.

References tColoredString::ColorString().

00168                                                          {
00169     tColoredString ret;
00170     ret << tColoredString::ColorString(r,g,b);
00171     return ret;
00172 }

Here is the call graph for this function:


Member Data Documentation

tArray<tString> rConsole::lines [private]

Definition at line 41 of file rConsole.h.

Referenced by DoPrint(), and Render().

int rConsole::currentTop [private]

Definition at line 43 of file rConsole.h.

Referenced by DoPrint(), Render(), and Scroll().

int rConsole::currentIn [private]

Definition at line 44 of file rConsole.h.

Referenced by DoPrint(), Render(), Scroll(), and sr_Read_stdin().

double rConsole::lastTimeout [private]

Definition at line 46 of file rConsole.h.

Referenced by DoPrint(), and Render().

double rConsole::lastCustomTimeout [private]

Definition at line 47 of file rConsole.h.

Referenced by DoPrint(), Render(), Scroll(), and SetHeight().

int rConsole::height [private]

Definition at line 50 of file rConsole.h.

Referenced by Height(), Render(), and SetHeight().

REAL rConsole::timeout [private]

Definition at line 51 of file rConsole.h.

Referenced by Render(), SetTimeout(), and Timeout().

bool rConsole::fullscreen

Definition at line 57 of file rConsole.h.

Referenced by gServerBrowser::BrowseLAN(), gServerBrowser::BrowseSpecialMaster(), ConnectToServerCore(), exit_game_objects(), Height(), ret_to_MainMenu(), gGame::StateUpdate(), and Timeout().

bool rConsole::autoDisplayAtSwap

Definition at line 60 of file rConsole.h.

Referenced by main(), and sr_ConsolePerFrame().

bool rConsole::autoDisplayAtNewline

Definition at line 61 of file rConsole.h.

Referenced by gServerBrowser::BrowseLAN(), gServerBrowser::BrowseSpecialMaster(), ConnectToServerCore(), DoPrint(), ret_to_MainMenu(), and gGame::StateUpdate().


The documentation for this class was generated from the following files:
Generated on Sat Mar 15 23:52:20 2008 for Armagetron Advanced by  doxygen 1.5.4