Main Page   Class Hierarchy   Compound List   File List   Compound Members   File Members  

playrwin.c

Go to the documentation of this file.
00001 /*************************************************************************
00002 *   FILE: playrwin.c
00003 * AUTHOR: CAL/SRW
00004 * DATE: 30 April 1993/1 May 1993
00005 * PURPOSE:
00006 *   Declares the Player Information window, a component of the UI.
00007 **************************************************************************/
00008 
00009 #include <stdio.h>
00010 #include <string.h>
00011 #include <assert.h>
00012 #include "playrwin.h"
00013 #include "map.h"
00014 
00015 
00016 PlayerWindow::PlayerWindow (void)
00017 {
00018   XDim = PlayerWinXDim;  YDim = PlayerWinYDim;
00019   CliX1 = CliY1 = CliX2 = CliY2 = 0;
00020   TX1 = TY1 = TX2 = TY2 = 0;
00021   BorderColor = RED;
00022   BkColor = LIGHTGRAY;
00023   TitleColor = WHITE;
00024   Title = new char [strlen (PlayerWinTitle)];
00025   assert (Title != 0);
00026   strcpy (Title, PlayerWinTitle);
00027   ClientD = TitleD = NULL;
00028   Drawn = False;
00029   Name = "Welcome to Scotland Yard";
00030   Tokens[Bus] = 0;
00031   Tokens[Taxi] = 0;
00032   Tokens[Subway] = 0;
00033   RoundNum = 0;
00034   Address = 0;
00035 }
00036 
00037 
00038 void PlayerWindow::DrawInfo (void)
00039 {
00040   char AddressBuf[21], buffer[80];
00041   char bus[20], taxi[20], subway[20], round[20];
00042 
00043   ClientD->SetColor (BLACK);
00044   ClientD->SetTextStyle (GOTHIC_FONT, HORIZ_DIR, 1);
00045   ClientD->SetTextJustify (LEFT_TEXT, TOP_TEXT);
00046   ClientD->OutTextXY (5, 5, Name);
00047   ClientD->SetTextStyle (DEFAULT_FONT, HORIZ_DIR, 1);
00048 
00049   if ((strcmp (Name, "Welcome to Scotland Yard")) == 0)
00050     {ClientD->OutTextXY (5, 40, "Written by THE MAD HAMSTERS");}
00051   else
00052   if (Tokens[Bus]!=Invalid) {
00053     sprintf (bus, "Bus %d", Tokens[Bus]);
00054     ClientD->OutTextXY (5, 40, bus);
00055     sprintf (taxi, "Taxi %d", Tokens[Taxi]);
00056     ClientD->OutTextXY (65, 40, taxi);
00057     sprintf (subway, "Subway %d", Tokens[Subway]);
00058     ClientD->OutTextXY (133, 40, subway);
00059     sprintf (round, "Round: %d", RoundNum+1);
00060     ClientD->OutTextXY (133, 5, round);
00061 
00062     if(theMap.get_name(Address)) {
00063       sprintf(buffer, "%-20s", theMap.get_name(Address));
00064       ClientD->OutTextXY (5, 30, buffer);
00065     }
00066   }
00067   else
00068   {
00069     ClientD->OutTextXY (5,40, "says, 'Bloody Wanker'!!");
00070     sprintf (round, "Round: %d", RoundNum+1);
00071     ClientD->OutTextXY (133, 5, round);
00072   }
00073 
00074 }
00075 
00076 
00077 void PlayerWindow::Draw (void)
00078 {
00079   if (!Drawn)
00080   {
00081     assert (Disp != NULL);
00082     Disp->FastDraw ();
00083     PrepScreen ();
00084     DrawBorder ();
00085     if (TitleD)
00086       DrawTitle ();
00087     ClientD->Clear ();
00088     ClientD->Draw ();
00089     DrawInfo ();
00090     Disp->Done ();
00091     Drawn = True;
00092   }
00093 }
00094 
00095 
00096 void PlayerWindow::Update (Player& P, int roundnum)
00097 {
00098   Name = P.GetName ();
00099   Address = P.GetPosition();
00100   Tokens [Taxi] = P.NumTokens (Taxi);
00101   Tokens [Bus] = P.NumTokens (Bus);
00102   Tokens [Subway] = P.NumTokens (Subway);
00103   RoundNum=roundnum;
00104   Clear();
00105   DrawInfo();
00106 }
00107 
00108 

Generated on Sun Jul 6 23:07:16 2003 for Scotland Yard by doxygen1.2.15