Debian Codegraph @

src/message.cpp

raw symbols SCIP
1 /***************************************************************************
2 msg.cpp - description
3 -------------------
4 begin : Monday Jan 13 2003
5 copyright : (C) 2003 by Michael Bridak
6 email : [email protected]
7 $Id: message.cpp,v 1.7 2003/09/21 21:52:40 mbridak Exp $
8 ***************************************************************************/
9
10 /***************************************************************************
11 * *
12 * This program is free software; you can redistribute it and/or modify *
13 * it under the terms of the GNU General Public License as published by *
14 * the Free Software Foundation; either version 2 of the License. *
15 * . *
16 * *
17 ***************************************************************************/
18
19 #include <string>
20 #include "SDL/SDL.h"
21 #include "SDL/SDL_image.h"
22 #include "files.h"
23 #include "dfont.h"
24 #include "message.h"
25
26 //using namespace std;
27
28 msg::msg(){
29 //clear out garbage from buffer.
30 for (int x = 0; x < 20; x++){
31 buffer[x][0]= '\0';
32 }
33
34 }
35
36 msg::~msg(){
37 //Our default Destructor...
38 }
39 void msg::InitGraphics(){
40
41 screen = SDL_GetVideoSurface();
42 SDL_Surface *temp = SDL_CreateRGBSurface(SDL_SWSURFACE, 800, 72, 16,
43 screen->format->Rmask,
44 screen->format->Gmask,
45 screen->format->Bmask,
46 screen->format->Amask);
47 messagewindow=SDL_DisplayFormat(temp);
48 SDL_FreeSurface(temp);
49 textcolor = SDL_MapRGB(screen->format, 192, 255, 6);
50 black = SDL_MapRGB(screen->format, 0, 0, 0);
51 white = SDL_MapRGB(screen->format, 255, 255, 255);
52 red = SDL_MapRGB(screen->format, 255, 99, 20);
53 green = SDL_MapRGB(screen->format, 0, 255, 0);
54 yellow = SDL_MapRGB(screen->format, 216, 255, 0);
55
56 }
57
58 void msg::post_message(char *temp_string){
59 for (int x = 1; x < 20; x++){
60 // buffer[x-1]=buffer[x];
61 strcpy(buffer[x-1], buffer[x]);
62 }
63 strcpy(buffer[19], temp_string);
64 //display_message();
65 }
66 void msg::display_message(){
67 char filename1[] = "images/font.png";
68 char filename2[] = "data/font.dat";
69 static DFont font(filename1, filename2);
70 //Clearout window contents
71 SDL_Rect rectangle;
72 SDL_Rect destination_rectangle;
73 SDL_Rect source_rectangle;
74 rectangle.x=0;
75 rectangle.y=0;
76 rectangle.h=72;
77 rectangle.w=800;
78 SDL_FillRect(messagewindow, &rectangle, black);
79
80 //print bottom 4 lines of buffer[]
81 for (int x = 16; x < 20; x++){
82 font.PutString(messagewindow, 5,(15*(x-15))-6, buffer[x]);
83 }
84
85 //paste surface into screen
86 source_rectangle.x = 0;
87 source_rectangle.y = 0;
88 source_rectangle.h = 72;
89 source_rectangle.w = 800;
90
91 destination_rectangle.x = 175;
92 destination_rectangle.y = 15;
93 destination_rectangle.h = 72;
94 destination_rectangle.w = 800;
95 SDL_BlitSurface(messagewindow, &source_rectangle, screen, &destination_rectangle);
96 SDL_UpdateRects(screen, 1, &destination_rectangle);
97 }