OSDN Git Service

index on dev20110528_setting_reduce: 9817594 フィールド名修正
[coroid/inqubus.git] / vhook / chat / process_chat.c
1 #include <SDL/SDL.h>\r
2 #include "chat.h"\r
3 #include "chat_slot.h"\r
4 #include "process_chat.h"\r
5 #include "../main.h"\r
6 #include "../mydef.h"\r
7 \r
8 //\82±\82Ì\83\\81[\83X\93à\82Å\82µ\82©\8eg\82í\82È\82¢\83\81\83\\83b\83h\r
9 void drawComment(SDL_Surface* surf,CHAT_SLOT* slot,int now_vpos);\r
10 \r
11 /**\r
12  * \83R\83\81\83\93\83g\82ð\95`\89æ\82·\82é\81B\r
13  */\r
14 int chat_process(COMMDATA* data,SDL_Surface* surf,const int now_vpos){\r
15         CHAT* chat = &data->chat;\r
16         CHAT_SLOT* slot = &data->slot;\r
17         FILE* log = data->common->log;\r
18         /*\8c©\82¹\82È\82¢\82à\82Ì\82ð\8dí\8f\9c*/\r
19         CHAT_SLOT_ITEM* slot_item;\r
20         CHAT_ITEM* chat_item;\r
21         resetChatSlotIterator(slot);\r
22         while((slot_item = getChatSlotErased(slot,now_vpos)) != NULL){\r
23                 chat_item = slot_item->chat_item;\r
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);\r
25                 fflush(log);\r
26                 deleteChatSlot(slot,slot_item);\r
27         }\r
28         /*\8c©\82¹\82é\82à\82Ì\82ð\83Z\83b\83g*/\r
29         resetChatIterator(chat);\r
30         while((chat_item = getChatShowed(chat,now_vpos)) != NULL){\r
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);\r
32                 fflush(log);\r
33                 addChatSlot(data,slot,chat_item,surf->w,surf->h);\r
34         }\r
35         drawComment(surf,slot,now_vpos);\r
36         return TRUE;\r
37 }\r
38 \r
39 /*\r
40  * \83\8c\83C\83\84\8f\87\82É\82»\82Á\82Ä\95`\89æ\82·\82é\r
41  */\r
42 \r
43 void drawComment(SDL_Surface* surf,CHAT_SLOT* slot,int now_vpos){\r
44         int i;\r
45         SDL_Rect rect;\r
46         int max_item = slot->max_item;\r
47         CHAT_SLOT_ITEM* item;\r
48         for(i=0;i<max_item;i++){\r
49                 item = &slot->item[i];\r
50                 if(item->used){\r
51                         rect.x = getX(now_vpos,item,surf->w);\r
52                         rect.y = item->y;\r
53                         SDL_BlitSurface(item->surf,NULL,surf,&rect);\r
54                 }\r
55         }\r
56 }\r
57 \r
58 /*\r
59  * \88Ê\92u\82ð\8b\81\82ß\82é\r
60  */\r
61 int getX(int now_vpos,const CHAT_SLOT_ITEM* item,int video_width){\r
62         int text_width = item->surf->w;\r
63         int width = video_width;\r
64         if(item->chat_item->location != CMD_LOC_DEF){\r
65                 return (width - text_width) >>1;\r
66         }else{\r
67                 int tmp = now_vpos - item->chat_item->vpos + TEXT_AHEAD_SEC;\r
68                 return width - ((tmp * (width + text_width)) / TEXT_SHOW_SEC);\r
69         }\r
70         return -1;\r
71 }\r