diff --git a/CCallback.cpp b/CCallback.cpp index 578cc939c..69687c0e6 100644 --- a/CCallback.cpp +++ b/CCallback.cpp @@ -399,6 +399,7 @@ void CScriptCallback::changePrimSkill(int ID, int which, int val) else if (which==4) { hero->exp+=val; + std::cout << "Bohater o ID " << ID <<" (" <heroh->heroes[ID]->name <<") dostaje "<ID = heroID; player = cb->getHeroOwner(heroID); cb->showSelDialog(player,CGI->objh->advobtxt[146],&tempStore,this); break; @@ -545,10 +546,16 @@ void CPickable::chosen(int which) case SComponent::resource: cb->giveResource(player,tempStore[which]->subtype,tempStore[which]->val); break; + case SComponent::experience: + cb->changePrimSkill(tempStore[which]->ID,4,tempStore[which]->val); + break; default: throw new std::exception("Unhandled choice"); } + for (int i=0;iremoveObjToBlit(this); - //delete this; LOCPLINT->adventureInt->show(); + delete this; } CInfoWindow::~CInfoWindow() { @@ -208,14 +208,17 @@ CSimpleWindow::~CSimpleWindow() } } -void CSelWindow::selectionChange(SComponent * to) +void CSelWindow::selectionChange(CSelectableComponent * to) { blitAt(to->getImg(),to->pos.x-pos.x,to->pos.y-pos.y,bitmap); for (int i=0;iselected) + continue; + else + to->select(true); } CSelectableComponent * pom = dynamic_cast(components[i]); if (!pom) @@ -231,8 +234,24 @@ void CSelWindow::okClicked(tribool down) } void CSelWindow::close() { + int ret = -1; + for (int i=0;i(components[i])->selected) + { + ret = i; + } + components[i]->deactivate(); + } + components.clear(); + okb.deactivate(); + SDL_FreeSurface(bitmap); + bitmap = NULL; + LOCPLINT->removeObjToBlit(this); + LOCPLINT->adventureInt->show(); + LOCPLINT->cb->selectionMade(ret,ID); + delete this; //call owner with selection result - CInfoWindow::close(); } template CSCButton::CSCButton(CDefHandler * img, CIntObject * obj, void(T::*poin)(tribool), T* Delg) { @@ -258,10 +277,10 @@ template void CSCButton::clickLeft (tribool down) { state=0; } + pressedL=state; show(); if (delg) (delg->*func)(down); - pressedL=state; } template void CSCButton::activate() { @@ -1487,7 +1506,8 @@ void CPlayerInterface::showSelDialog(std::string text, std::vectorcomponents[i]->pos.x += temp->pos.x; temp->components[i]->pos.y += temp->pos.y; } - + temp->ID = askID; + components[0]->clickLeft(true); } void CPlayerInterface::showComp(SComponent comp) diff --git a/CPlayerInterface.h b/CPlayerInterface.h index afdd94d33..bf1c6c8d5 100644 --- a/CPlayerInterface.h +++ b/CPlayerInterface.h @@ -120,7 +120,7 @@ public: }; class CInfoWindow : public CSimpleWindow //text + comp. + ok button -{ +{ //okno usuwa swoje komponenty w chwili zamkniecia public: CSCButton okb; std::vector components; @@ -130,9 +130,9 @@ public: virtual ~CInfoWindow(); }; class CSelWindow : public CInfoWindow //component selection window -{ +{ //uwaga - to okno nie usuwa swoich komponentow przy usuwaniu, moga sie one jeszcze przydac skryptowi - tak wiec skrypt korzystajacyz tego okna musi je usunac public: - void selectionChange(SComponent * to); + void selectionChange(CSelectableComponent * to); void okClicked(tribool down); void close(); CSelWindow(){};