Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members | Related Pages

Ui.cpp

Go to the documentation of this file.
00001 /*
00002  * Ui.cpp
00003  *
00004  * Part of Fly! Legacy project
00005  *
00006  * Copyright 2003 Chris Wallace
00007  *
00008  * Fly! Legacy is free software; you can redistribute it and/or modify
00009  *   it under the terms of the GNU General Public License as published by
00010  *   the Free Software Foundation; either version 2 of the License, or
00011  *   (at your option) any later version.
00012  *
00013  * Fly! Legacy is distributed in the hope that it will be useful,
00014  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
00015  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016  *   GNU General Public License for more details.
00017  *
00018  * You should have received a copy of the GNU General Public License
00019  *   along with Fly! Legacy; if not, write to the Free Software
00020  *    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00021  *
00022  *
00023  * This module implements general purpose UI routines for initialization, translation
00024  *   etc.
00025  */
00026 
00027 #include "../Include/Ui.h"
00028 #include "../Include/Globals.h"
00029 
00030 
00031 //
00032 // puText widgets for display of real-time debugging information
00033 //
00034 puText*   puDebug1;
00035 puText*   puDebug2;
00036 puText*   puDebug3;
00037 char    msgDebug1[256];
00038 char    msgDebug2[256];
00039 char    msgDebug3[256];
00040 
00041 
00042 void init_ui (void)
00043 {
00045   char *mark1 = new char[32];
00046   strcpy (mark1, "puInit Start");
00047   puInit ();
00048   char *mark2 = new char[32];
00049   strcpy (mark2, "puInit End");
00050 
00051   // Initialize debug messages
00052   strcpy (msgDebug1, "");
00053   strcpy (msgDebug2, "");
00054   strcpy (msgDebug3, "");
00055 
00056   puDebug1 = new puText (50, 500);
00057   puDebug2 = new puText (50, 480);
00058   puDebug3 = new puText (50, 460);
00059   
00060   puDebug1->setColor (PUCOL_LABEL, 0.5, 0.5, 0.5);
00061   puDebug2->setColor (PUCOL_LABEL, 0.5, 0.5, 0.5);
00062   puDebug3->setColor (PUCOL_LABEL, 0.5, 0.5, 0.5);
00063 
00064   puDebug1->setLabel (msgDebug1);
00065   puDebug2->setLabel (msgDebug2);
00066   puDebug3->setLabel (msgDebug3);
00067 
00068   // Create application menu
00069   init_menu ();
00070 }
00071 
00072 void cleanup_ui (void)
00073 {
00074   delete puDebug1;
00075   delete puDebug2;
00076   delete puDebug3;
00077 
00078   cleanup_menu ();
00079 }
00080 
00081 void DebugMessage1 (const char* fmt, ...)
00082 {
00083   va_list argp;
00084   va_start(argp, fmt);
00085   vsprintf(msgDebug1, fmt, argp);
00086   va_end(argp);
00087 
00088   puDebug1->setLabel (msgDebug1);
00089 }
00090 
00091 void DebugMessage2 (const char* fmt, ...)
00092 {
00093   va_list argp;
00094   va_start(argp, fmt);
00095   vsprintf(msgDebug2, fmt, argp);
00096   va_end(argp);
00097 
00098   puDebug2->setLabel (msgDebug2);
00099 }
00100 
00101 void DebugMessage3 (const char* fmt, ...)
00102 {
00103   va_list argp;
00104   va_start(argp, fmt);
00105   vsprintf(msgDebug3, fmt, argp);
00106   va_end(argp);
00107 
00108   puDebug3->setLabel (msgDebug3);
00109 }
00110 
00111 
00112 
00113 //
00114 // This function is called as part of every screen refresh.  It is responsible for
00115 //   redrawing all of the UI components as overlays on the simulation display.
00116 //
00117 void DrawUi (float dT)
00118 {
00119   // Redraw PUI widgets
00120   puDisplay ();
00121 }
SourceForge.net Logo Documentation generated by doxygen