| 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"cxx . . $ `<file>/src/files.h`/ |
| 23 | #include "dfont.h"cxx . . $ `<file>/src/dfont.h`/ |
| 24 | #include "message.h"cxx . . $ `<file>/src/message.h`/ |
| 25 | |
| 26 | //using namespace std; |
| 27 | |
| 28 | msgcxx . . $ msg#::msgcxx . . $ msg#msg(49f6e7a06ebc5aa8).(){ |
| 29 | //clear out garbage from buffer. |
| 30 | for (int x = 0; x < 20; x++){ |
| 31 | buffercxx . . $ msg#buffer.[x][0]= '\0'; |
| 32 | } |
| 33 | |
| 34 | } |
| 35 | |
| 36 | msgcxx . . $ msg#::~cxx . . $ msg#`~msg`(ced63f7c635d850d).msgcxx . . $ msg#(){ |
| 37 | //Our default Destructor... |
| 38 | } |
| 39 | void msgcxx . . $ msg#::InitGraphicscxx . . $ msg#InitGraphics(49f6e7a06ebc5aa8).(){ |
| 40 | |
| 41 | screencxx . . $ msg#screen. = SDL_GetVideoSurface(); |
| 42 | SDL_Surface *temp = SDL_CreateRGBSurface(SDL_SWSURFACEcxx . . $ `<external>/3508485105195885937/SDL_video.h:229:9`!, 800, 72, 16, |
| 43 | screencxx . . $ msg#screen.->format->Rmask, |
| 44 | screencxx . . $ msg#screen.->format->Gmask, |
| 45 | screencxx . . $ msg#screen.->format->Bmask, |
| 46 | screencxx . . $ msg#screen.->format->Amask); |
| 47 | messagewindowcxx . . $ msg#messagewindow.=SDL_DisplayFormat(temp); |
| 48 | SDL_FreeSurface(temp); |
| 49 | textcolorcxx . . $ msg#textcolor. = SDL_MapRGB(screencxx . . $ msg#screen.->format, 192, 255, 6); |
| 50 | blackcxx . . $ msg#black. = SDL_MapRGB(screencxx . . $ msg#screen.->format, 0, 0, 0); |
| 51 | whitecxx . . $ msg#white. = SDL_MapRGB(screencxx . . $ msg#screen.->format, 255, 255, 255); |
| 52 | redcxx . . $ msg#red. = SDL_MapRGB(screencxx . . $ msg#screen.->format, 255, 99, 20); |
| 53 | greencxx . . $ msg#green. = SDL_MapRGB(screencxx . . $ msg#screen.->format, 0, 255, 0); |
| 54 | yellowcxx . . $ msg#yellow. = SDL_MapRGB(screencxx . . $ msg#screen.->format, 216, 255, 0); |
| 55 | |
| 56 | } |
| 57 | |
| 58 | void msgcxx . . $ msg#::post_messagecxx . . $ msg#post_message(fda57c8427c60377).(char *temp_string){ |
| 59 | for (int x = 1; x < 20; x++){ |
| 60 | // buffer[x-1]=buffer[x]; |
| 61 | strcpy(buffercxx . . $ msg#buffer.[x-1], buffercxx . . $ msg#buffer.[x]); |
| 62 | } |
| 63 | strcpy(buffercxx . . $ msg#buffer.[19], temp_string); |
| 64 | //display_message(); |
| 65 | } |
| 66 | void msgcxx . . $ msg#::display_messagecxx . . $ msg#display_message(49f6e7a06ebc5aa8).(){ |
| 67 | char filename1[] = "images/font.png"; |
| 68 | char filename2[] = "data/font.dat"; |
| 69 | static DFontcxx . . $ DFont# fontcxx . . $ DFont#DFont(d0489a02ea06dfc6).(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(messagewindowcxx . . $ msg#messagewindow., &rectangle, blackcxx . . $ msg#black.); |
| 79 | |
| 80 | //print bottom 4 lines of buffer[] |
| 81 | for (int x = 16; x < 20; x++){ |
| 82 | font.PutStringcxx . . $ DFont#PutString(dae77c54ebf0dad5).(messagewindowcxx . . $ msg#messagewindow., 5,(15*(x-15))-6, buffercxx . . $ msg#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_BlitSurfacecxx . . $ `<external>/3508485105195885937/SDL_video.h:262:9`!(messagewindowcxx . . $ msg#messagewindow., &source_rectangle, screencxx . . $ msg#screen., &destination_rectangle); |
| 96 | SDL_UpdateRects(screencxx . . $ msg#screen., 1, &destination_rectangle); |
| 97 | } |