mirror of
https://github.com/vcmi/vcmi.git
synced 2025-09-16 09:26:28 +02:00
Finished treasure chests.
This commit is contained in:
@@ -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 <<" (" <<CGI->heroh->heroes[ID]->name <<") dostaje "<<val<<" expa, ale nic z tym nie umiem zrobic :("<<std::endl;
|
||||
//TODO - powiadomic interfejsy, sprawdzic czy nie ma awansu itp
|
||||
}
|
||||
}
|
||||
|
7
CLua.cpp
7
CLua.cpp
@@ -531,6 +531,7 @@ void CPickable::onHeroVisit(CGObjectInstance *os, int heroID)
|
||||
break;
|
||||
}
|
||||
}//random treasure artifact, or (if backapack is full) 1k/0.5k
|
||||
tempStore[1]->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;i<tempStore.size();i++)
|
||||
delete tempStore[i];
|
||||
tempStore.clear();
|
||||
}
|
||||
|
||||
std::string CPickable::hoverText(CGObjectInstance *os)
|
||||
|
@@ -50,8 +50,8 @@ void CInfoWindow::close()
|
||||
SDL_FreeSurface(bitmap);
|
||||
bitmap = NULL;
|
||||
LOCPLINT->removeObjToBlit(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;i<components.size();i++)
|
||||
{
|
||||
if(components[i]==to)
|
||||
{
|
||||
if (to->selected)
|
||||
continue;
|
||||
else
|
||||
to->select(true);
|
||||
}
|
||||
CSelectableComponent * pom = dynamic_cast<CSelectableComponent*>(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.size();i++)
|
||||
{
|
||||
if(dynamic_cast<CSelectableComponent*>(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 <typename T>CSCButton<T>::CSCButton(CDefHandler * img, CIntObject * obj, void(T::*poin)(tribool), T* Delg)
|
||||
{
|
||||
@@ -258,10 +277,10 @@ template <typename T> void CSCButton<T>::clickLeft (tribool down)
|
||||
{
|
||||
state=0;
|
||||
}
|
||||
pressedL=state;
|
||||
show();
|
||||
if (delg)
|
||||
(delg->*func)(down);
|
||||
pressedL=state;
|
||||
}
|
||||
template <typename T> void CSCButton<typename T>::activate()
|
||||
{
|
||||
@@ -1487,7 +1506,8 @@ void CPlayerInterface::showSelDialog(std::string text, std::vector<CSelectableCo
|
||||
temp->components[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)
|
||||
|
@@ -120,7 +120,7 @@ public:
|
||||
};
|
||||
|
||||
class CInfoWindow : public CSimpleWindow //text + comp. + ok button
|
||||
{
|
||||
{ //okno usuwa swoje komponenty w chwili zamkniecia
|
||||
public:
|
||||
CSCButton<CInfoWindow> okb;
|
||||
std::vector<SComponent*> 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(){};
|
||||
|
Reference in New Issue
Block a user