4 #include "process_chat.h"
9 void drawComment(SDL_Surface* surf,CHAT_SLOT* slot,int now_vpos);
14 int chat_process(COMMDATA* data,SDL_Surface* surf,const int now_vpos){
15 CHAT* chat = &data->chat;
16 CHAT_SLOT* slot = &data->slot;
17 FILE* log = data->common->log;
19 CHAT_SLOT_ITEM* slot_item;
21 resetChatSlotIterator(slot);
22 while((slot_item = getChatSlotErased(slot,now_vpos)) != NULL){
23 chat_item = slot_item->chat_item;
24 fprintf(log,"[process-chat/process]<vpos:%6d>com%4d<color:%2d loc:%2d size:%2d %6d-%6d(%6d)> erased. \n",now_vpos,chat_item->no,chat_item->color,chat_item->location,chat_item->size,chat_item->vstart,chat_item->vend,chat_item->vpos);
26 deleteChatSlot(slot,slot_item);
29 resetChatIterator(chat);
30 while((chat_item = getChatShowed(chat,now_vpos)) != NULL){
31 fprintf(log,"[process-chat/process]<vpos:%6d>com%4d<color:%2d loc:%2d size:%2d %6d-%6d(%6d)> added. \n",now_vpos,chat_item->no,chat_item->color,chat_item->location,chat_item->size,chat_item->vstart,chat_item->vend,chat_item->vpos);
33 addChatSlot(data,slot,chat_item,surf->w,surf->h);
35 drawComment(surf,slot,now_vpos);
43 void drawComment(SDL_Surface* surf,CHAT_SLOT* slot,int now_vpos){
46 int max_item = slot->max_item;
48 for(i=0;i<max_item;i++){
49 item = &slot->item[i];
51 rect.x = getX(now_vpos,item,surf->w);
53 SDL_BlitSurface(item->surf,NULL,surf,&rect);
61 int getX(int now_vpos,const CHAT_SLOT_ITEM* item,int video_width){
62 int text_width = item->surf->w;
63 int width = video_width;
64 if(item->chat_item->location != CMD_LOC_DEF){
65 return (width - text_width) >>1;
67 int tmp = now_vpos - item->chat_item->vpos + TEXT_AHEAD_SEC;
68 return width - ((tmp * (width + text_width)) / TEXT_SHOW_SEC);