-#include <SDL/SDL.h>\r
-#include "chat.h"\r
-#include "chat_slot.h"\r
-#include "process_chat.h"\r
-#include "../main.h"\r
-#include "../mydef.h"\r
-\r
-//\82±\82Ì\83\\81[\83X\93à\82Å\82µ\82©\8eg\82í\82È\82¢\83\81\83\\83b\83h\r
-void drawComment(SDL_Surface* surf,CHAT_SLOT* slot,int now_vpos);\r
-\r
-/**\r
- * \83R\83\81\83\93\83g\82ð\95`\89æ\82·\82é\81B\r
- */\r
-int chat_process(COMMDATA* data,SDL_Surface* surf,const int now_vpos){\r
- CHAT* chat = &data->chat;\r
- CHAT_SLOT* slot = &data->slot;\r
- FILE* log = data->common->log;\r
- /*\8c©\82¹\82È\82¢\82à\82Ì\82ð\8dí\8f\9c*/\r
- CHAT_SLOT_ITEM* slot_item;\r
- CHAT_ITEM* chat_item;\r
- resetChatSlotIterator(slot);\r
- while((slot_item = getChatSlotErased(slot,now_vpos)) != NULL){\r
- chat_item = slot_item->chat_item;\r
- 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
- fflush(log);\r
- deleteChatSlot(slot,slot_item);\r
- }\r
- /*\8c©\82¹\82é\82à\82Ì\82ð\83Z\83b\83g*/\r
- resetChatIterator(chat);\r
- while((chat_item = getChatShowed(chat,now_vpos)) != NULL){\r
- 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
- fflush(log);\r
- addChatSlot(data,slot,chat_item,surf->w,surf->h);\r
- }\r
- drawComment(surf,slot,now_vpos);\r
- return TRUE;\r
-}\r
-\r
-/*\r
- * \83\8c\83C\83\84\8f\87\82É\82»\82Á\82Ä\95`\89æ\82·\82é\r
- */\r
-\r
-void drawComment(SDL_Surface* surf,CHAT_SLOT* slot,int now_vpos){\r
- int i;\r
- SDL_Rect rect;\r
- int max_item = slot->max_item;\r
- CHAT_SLOT_ITEM* item;\r
- for(i=0;i<max_item;i++){\r
- item = &slot->item[i];\r
- if(item->used){\r
- rect.x = getX(now_vpos,item,surf->w);\r
- rect.y = item->y;\r
- SDL_BlitSurface(item->surf,NULL,surf,&rect);\r
- }\r
- }\r
-}\r
-\r
-/*\r
- * \88Ê\92u\82ð\8b\81\82ß\82é\r
- */\r
-int getX(int now_vpos,const CHAT_SLOT_ITEM* item,int video_width){\r
- int text_width = item->surf->w;\r
- int width = video_width;\r
- if(item->chat_item->location != CMD_LOC_DEF){\r
- return (width - text_width) >>1;\r
- }else{\r
- int tmp = now_vpos - item->chat_item->vpos + TEXT_AHEAD_SEC;\r
- return width - ((tmp * (width + text_width)) / TEXT_SHOW_SEC);\r
- }\r
- return -1;\r
-}\r
+#include <SDL/SDL.h>
+#include "chat.h"
+#include "chat_slot.h"
+#include "process_chat.h"
+#include "../main.h"
+#include "../mydef.h"
+
+//このソース内でしか使わないメソッド
+void drawComment(SDL_Surface* surf,CHAT_SLOT* slot,int now_vpos);
+
+/**
+ * コメントを描画する。
+ */
+int chat_process(COMMDATA* data,SDL_Surface* surf,const int now_vpos){
+ CHAT* chat = &data->chat;
+ CHAT_SLOT* slot = &data->slot;
+ FILE* log = data->common->log;
+ /*見せないものを削除*/
+ CHAT_SLOT_ITEM* slot_item;
+ CHAT_ITEM* chat_item;
+ resetChatSlotIterator(slot);
+ while((slot_item = getChatSlotErased(slot,now_vpos)) != NULL){
+ chat_item = slot_item->chat_item;
+ 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);
+ fflush(log);
+ deleteChatSlot(slot,slot_item);
+ }
+ /*見せるものをセット*/
+ resetChatIterator(chat);
+ while((chat_item = getChatShowed(chat,now_vpos)) != NULL){
+ 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);
+ fflush(log);
+ addChatSlot(data,slot,chat_item,surf->w,surf->h);
+ }
+ drawComment(surf,slot,now_vpos);
+ return TRUE;
+}
+
+/*
+ * レイヤ順にそって描画する
+ */
+
+void drawComment(SDL_Surface* surf,CHAT_SLOT* slot,int now_vpos){
+ int i;
+ SDL_Rect rect;
+ int max_item = slot->max_item;
+ CHAT_SLOT_ITEM* item;
+ for(i=0;i<max_item;i++){
+ item = &slot->item[i];
+ if(item->used){
+ rect.x = getX(now_vpos,item,surf->w);
+ rect.y = item->y;
+ SDL_BlitSurface(item->surf,NULL,surf,&rect);
+ }
+ }
+}
+
+/*
+ * 位置を求める
+ */
+int getX(int now_vpos,const CHAT_SLOT_ITEM* item,int video_width){
+ int text_width = item->surf->w;
+ int width = video_width;
+ if(item->chat_item->location != CMD_LOC_DEF){
+ return (width - text_width) >>1;
+ }else{
+ int tmp = now_vpos - item->chat_item->vpos + TEXT_AHEAD_SEC;
+ return width - ((tmp * (width + text_width)) / TEXT_SHOW_SEC);
+ }
+ return -1;
+}