void RoomList::set_room_data(const std::set <NetClient::RoomData>& rd) { this->clear(); button_rooms.clear(); last_button_is_create = false; // Make one button for each room for (Network::RoomCIt itr = rd.begin(); itr != rd.end(); ++itr) { // don't display the lobby as a room to switch into if (itr->number == 0) continue; if (((int) buttons.size() + 1) * button_yl > get_yl()) break; button_rooms.push_back(itr->number); buttons.push_back( TextButton(0, buttons.size() * button_yl, get_xl(), button_yl)); std::ostringstream str; str << Language::win_lobby_room_number << (int) itr->number << ", " << (int) itr->members << " " << (itr->members == 1 ? Language::win_lobby_room_player : Language::win_lobby_room_players); buttons.back().set_text(str.str()); buttons.back().set_undraw_color(color[COL_API_M]); } // Room creation button if (((int) buttons.size() + 1) * button_yl <= (int) get_yl()) { button_rooms.push_back(0); buttons.push_back( TextButton(0, buttons.size() * button_yl, get_xl(), button_yl)); buttons.back().set_text(Language::win_lobby_room_create); buttons.back().set_undraw_color(color[COL_API_M]); last_button_is_create = true; } for (std::vector <TextButton> ::iterator itr = buttons.begin(); itr != buttons.end(); ++itr) add_child(*itr); set_draw_required(); }
void NPCQuestWindow(NPC *npc, int id) { int c; int i; int y; HUDInfo *self; self = Pushwindow(); if(self == NULL) { fprintf(stdout,"Big problem here, can't make NPC Dialog window.\n"); return; } self->state = id; self->stealinput = 1; c = GetQuestCount(npc); self->windowupdate = UpdateNPCQuestWindow; self->windowdraw = DrawNPCQuestWindow; self->box.w = Camera.w * 0.4; self->box.h = (c * FontSize[F_Small]) + (BUTTON_H*2) + 10; self->box.x = Camera.w/2 - self->box.w/2; self->box.y = Camera.h * 0.2; PicButton(self,0,SDLK_RETURN,"Done",self->box.x + self->box.w/2 - (BUTTON_W/2),self->box.y + self->box.h - BUTTON_H - 4,BUTTON_W,BUTTON_H); self->ib = (void *)npc; for(i = 0, y = 0; i < c; i++) { /*this will need to be corrected for items that are conditional*/ if(CheckOfferCond(&npc->quests[i])) { TextButton(self,i + 1,SDLK_1 + i,npc->quests[i].name,self->box.x + self->box.w/2 - (BUTTON_W/2),self->box.y + BUTTON_H + ((FontSize[F_Small] + 1)*i),BUTTON_W,FontSize[F_Small]); y++; } } }
void NPCTalkWindow(NPC *npc) { int c; int i; HUDInfo *self; self = Pushwindow(); if(self == NULL) { fprintf(stdout,"Big problem here, can't make NPC Dialog window.\n"); return; } c = GetDialogCount(npc); self->stealinput = 1; self->windowupdate = UpdateNPCTalkWindow; self->windowdraw = DrawNPCTalkWindow; self->box.w = Camera.w * 0.4; self->box.h = (c * FontSize[F_Small]) + (BUTTON_H*2.5) + 10; self->box.x = Camera.w/2 - self->box.w/2; self->box.y = Camera.h * 0.2; PicButton(self,0,SDLK_RETURN,"Done",self->box.x + self->box.w/2 - (BUTTON_W/2),self->box.y + self->box.h - BUTTON_H - 4,BUTTON_W,BUTTON_H); self->ib = (void *)npc; for(i = 0; i < c; i++) { /*this will need to be corrected for items that are conditional*/ if(IsConditionMet(npc->dialog[i].dialogcond)) { TextButton(self,i + 1,SDLK_1 + i,npc->dialog[i].topic,self->box.x + self->box.w/2 - (BUTTON_W/2),self->box.y + BUTTON_H + ((FontSize[F_Small] + 1)*i),BUTTON_W,FontSize[F_Small]); } } }
void NPCShopWindow(NPC *npc) { P_Skill *skill; Item *item; int c; int i; int d; int fail = 0; char text[80]; HUDInfo *self; self = Pushwindow(); if(self == NULL) { fprintf(stdout,"Big problem here, can't make NPC Dialog window.\n"); return; } self->stealinput = 1; c = GetShopCount(npc); self->windowupdate = UpdateNPCShopWindow; self->windowdraw = DrawNPCShopWindow; self->box.w = Camera.w * 0.4; self->box.h = (c * FontSize[F_Small]) + (BUTTON_H*2) + 10; self->box.x = Camera.w/2 - self->box.w/2; self->box.y = Camera.h * 0.2; PicButton(self,0,SDLK_RETURN,"Done",self->box.x + self->box.w/2 - (BUTTON_W/2),self->box.y + self->box.h - BUTTON_H - 4,BUTTON_W,BUTTON_H); self->ib = (void *)npc; for(i = 0; i < c; i++) { /*this will need to be corrected for items that are conditional*/ for(d = 0;d < 4;d++) { if(!IsConditionMet(npc->shop[i].condition[d]))fail = 1; } if(!fail) { if(strcmp(npc->shop[i].type,"item")==0) { item = GetItemByName(npc->shop[i].name); if(item == NULL)continue; sprintf(text,"%s - %iG",npc->shop[i].name,(int)(item->cost * npc->shop[i].markup)); } else if(strcmp(npc->shop[i].type,"spell")==0) { skill = GetSpellByName(npc->shop[i].name); if(skill == NULL)continue; sprintf(text,"(Spell) %s - %iG",npc->shop[i].name,(int)(skill->price * npc->shop[i].markup)); } else if(strcmp(npc->shop[i].type,"skill")==0) { skill = GetSkillByName(npc->shop[i].name); if(skill == NULL)continue; sprintf(text,"(Skill) %s - %iG",npc->shop[i].name,(int)(skill->price * npc->shop[i].markup)); } else if(strcmp(npc->shop[i].type,"service")==0) { sprintf(text,"%s",npc->shop[i].name); } TextButton(self,i + 1,SDLK_1 + i,text,self->box.x + self->box.w/2 - (BUTTON_W/2),self->box.y + BUTTON_H + ((FontSize[F_Small] + 1)*i),BUTTON_W,FontSize[F_Small] + 1); } } }