2 #include "chat_slot.h"
\r
3 #include "process_chat.h"
\r
4 #include "../mydef.h"
\r
5 #include "../comment/com_surface.h"
\r
6 #include "../nicodef.h"
\r
12 int initChatSlot(FILE* log,CHAT_SLOT* slot,int max_slot,CHAT* chat){
\r
13 slot->max_item=max_slot;
\r
15 slot->item = malloc(sizeof(CHAT_SLOT_ITEM) * max_slot);
\r
16 if(slot->item == NULL){
\r
17 fputs("failed to malloc for comment slot.\n",log);
\r
21 CHAT_SLOT_ITEM* item;
\r
22 for(i=0;i<max_slot;i++){
\r
23 item = &slot->item[i];
\r
30 void closeChatSlot(CHAT_SLOT* slot){
\r
32 CHAT_SLOT_ITEM* item;
\r
33 for(i=0;i<slot->max_item;i++){
\r
34 item = &slot->item[i];
\r
35 SDL_FreeSurface(item->surf);
\r
37 //
\83A
\83C
\83e
\83\80\82ð
\8fÁ
\8b\8e\81B
\r
41 void deleteChatSlot(CHAT_SLOT* slot,CHAT_SLOT_ITEM* item){
\r
42 item->chat_item=NULL;
\r
43 SDL_FreeSurface(item->surf);
\r
48 void deleteChatSlotFromIndex(CHAT_SLOT* slot,int index){
\r
49 CHAT_SLOT_ITEM* item = &slot->item[index];
\r
50 deleteChatSlot(slot,item);
\r
54 *
\83X
\83\8d\83b
\83g
\82É
\92Ç
\89Á
\82·
\82é
\81B
\r
56 void addChatSlot(DATA* data,CHAT_SLOT* slot,CHAT_ITEM* item,int video_width,int video_height){
\r
57 //
\82à
\82¤
\8c©
\82¹
\82ç
\82ê
\82½
\81B
\r
58 item->showed = TRUE;
\r
59 if(slot->max_item <= 0){
\r
62 SDL_Surface* surf = makeCommentSurface(data,item,video_width,video_height);
\r
63 /*
\8aJ
\82«
\83X
\83\8d\83b
\83g
\83\8b\8c\9f\8dõ*/
\r
66 int slot_max = slot->max_item;
\r
67 for(i=0;i<slot_max;i++){
\r
68 if(!slot->item[i].used){
\r
72 if(cnt < 0 || slot->item[cnt].chat_item->vend > slot->item[i].chat_item->vend){
\r
76 CHAT_SLOT_ITEM* slot_item = &slot->item[cnt];
\r
77 /*
\8bó
\82«
\82ª
\96³
\82¯
\82ê
\82Î
\8b
\90§
\93I
\82É
\8dì
\82é
\81B*/
\r
78 if(slot_item->used){
\r
79 deleteChatSlotFromIndex(slot,cnt);
\r
81 //
\82±
\82Ì
\8e\9e\93_
\82Å
\92Ç
\89Á
\r
82 slot_item->chat_item = item;
\r
83 slot_item->surf = surf;
\r
84 /*
\83\8d\83P
\81[
\83V
\83\87\83\93\82Å
\95ª
\8aò*/
\r
86 if(item->location == CMD_LOC_BOTTOM){
\r
87 y = video_height - surf->h;
\r
94 for(i=0;i<slot_max;i++){
\r
95 CHAT_SLOT_ITEM* other_slot = &slot->item[i];
\r
96 if(!other_slot->used){
\r
99 const CHAT_ITEM* other_item = other_slot->chat_item;
\r
100 int other_y = other_slot->y;
\r
101 /*
\96³
\8e\8b\82·
\82é
\8fð
\8c\8f*/
\r
102 if(other_y + other_slot->surf->h <= y){
\r
105 if(y + surf->h <= other_y){
\r
108 if(other_item->location != item->location){
\r
111 int start = MAX(other_item->vstart,item->vstart);
\r
112 int end = MIN(other_item->vend,item->vend);
\r
113 int obj_x_t1 = getX(start,slot_item,video_width);
\r
114 int obj_x_t2 = getX(end,slot_item,video_width);
\r
115 int o_x_t1 = getX(start,other_slot,video_width);
\r
116 int o_x_t2 = getX(end,other_slot,video_width);
\r
117 //
\93\96\82½
\82è
\94»
\92è
\r
118 if ((obj_x_t1 <= o_x_t1 + other_slot->surf->w && o_x_t1 <= obj_x_t1 + surf->w)
\r
119 || (obj_x_t2 <= o_x_t2 + other_slot->surf->w && o_x_t2 <= obj_x_t2 + surf->w)){
\r
120 if(item->location == CMD_LOC_BOTTOM){
\r
121 y = other_y - surf->h - 1;
\r
123 y = other_y + other_slot->surf->h + 1;
\r
130 /*
\82»
\82à
\82»
\82à
\89æ
\96Ê
\93à
\82É
\96³
\82¯
\82ê
\82Î
\96³
\88Ó
\96¡
\81B*/
\r
131 if(y < 0 || y+surf->h > video_height){//
\94Í
\88Í
\82ð
\92´
\82¦
\82Ä
\82é
\82Ì
\82Å
\81A
\83\89\83\93\83_
\83\80\82É
\94z
\92u
\81B
\r
132 y = ((rnd() & 0xffff) * (video_height - surf->h)) / 0xffff;
\r
135 slot_item->used = TRUE;
\r
139 *
\83C
\83e
\83\8c\81[
\83^
\82ð
\83\8a\83Z
\83b
\83g
\82·
\82é
\81B
\r
141 void resetChatSlotIterator(CHAT_SLOT* slot){
\r
142 slot->iterator_index = 0;
\r
145 *
\83C
\83e
\83\8c\81[
\83^
\82ð
\93¾
\82é
\r
147 CHAT_SLOT_ITEM* getChatSlotErased(CHAT_SLOT* slot,int now_vpos){
\r
148 int *i = &slot->iterator_index;
\r
149 int max_item = slot->max_item;
\r
151 CHAT_SLOT_ITEM* slot_item;
\r
152 for(;*i<max_item;(*i)++){
\r
153 slot_item = &slot->item[*i];
\r
154 if(!slot_item->used){
\r
157 item = slot_item->chat_item;
\r
158 if(item==NULL)continue;
\r
159 if(now_vpos < item->vstart || now_vpos > item->vend){
\r