Browse Source

showInfoDialog should be compatible with interfaces other than advmapint.

Michał W. Urbańczyk 18 years ago
parent
commit
d64dfa0a23
8 changed files with 41 additions and 6 deletions
  1. 10 0
      CAdvmapInterface.cpp
  2. 4 1
      CAdvmapInterface.h
  3. 1 0
      CCastleInterface.cpp
  4. 1 1
      CCastleInterface.h
  5. 19 0
      CHeroWindow.cpp
  6. 2 1
      CHeroWindow.h
  7. 3 3
      CPlayerInterface.cpp
  8. 1 0
      CPlayerInterface.h

+ 10 - 0
CAdvmapInterface.cpp

@@ -1343,8 +1343,18 @@ void CAdvMapInt::fendTurn()
 	LOCPLINT->makingTurn = false;
 }
 
+void CAdvMapInt::activate()
+{
+	//todo - docelowo wartoby rozdzielic czesc odpowiedzialna za wyswietlanie i aktywacje
+	show();
+}
+void CAdvMapInt::deactivate()
+{
+	hide();
+}
 void CAdvMapInt::show()
 {
+	LOCPLINT->curint = this;
 	blitAt(bg,0,0);
 
 	kingOverview.show();

+ 4 - 1
CAdvmapInterface.h

@@ -193,7 +193,7 @@ public:
 	CDefHandler * getAnim(int mode);
 };
 /*****************************/
-class CAdvMapInt //adventure map interface
+class CAdvMapInt : public IActivable //adventure map interface
 {
 public:
 	CAdvMapInt(int Player);
@@ -258,6 +258,9 @@ public:
 	void fnextHero();
 	void fendTurn();
 
+	void activate();
+	void deactivate();
+
 	void show(); //shows and activates adv. map interface
 	void hide(); //deactivates advmap interface
 	void update(); //redraws terrain

+ 1 - 0
CCastleInterface.cpp

@@ -286,6 +286,7 @@ void CCastleInterface::show(SDL_Surface * to)
 }
 void CCastleInterface::activate()
 {
+	LOCPLINT->curint = this;
 	//for(int i=0;i<buildings.size();i++)
 	//	buildings[i]->activate();
 }

+ 1 - 1
CCastleInterface.h

@@ -24,7 +24,7 @@ public:
 	void clickRight (tribool down);
 };
 
-class CCastleInterface : public IShowable
+class CCastleInterface : public IShowable, public IActivable
 {
 public:
 	SDL_Surface * townInt;

+ 19 - 0
CHeroWindow.cpp

@@ -343,6 +343,7 @@ void CHeroWindow::quit()
 
 void CHeroWindow::activate()
 {
+	LOCPLINT->curint = this;
 	quitButton->activate();
 	dismissButton->activate();
 	questlogButton->activate();
@@ -361,6 +362,24 @@ void CHeroWindow::activate()
 	//LOCPLINT->lclickable.push_back(artFeet);
 }
 
+void CHeroWindow::deactivate()
+{
+	quitButton->deactivate();
+	dismissButton->deactivate();
+	questlogButton->deactivate();
+	gar1button->deactivate();
+	gar2button->deactivate();
+	gar3button->deactivate();
+	gar4button->deactivate();
+	leftArtRoll->deactivate();
+	rightArtRoll->deactivate();
+	portraitArea->deactivate();
+	for(int g=0; g<heroList.size(); ++g)
+	{
+		heroList[g]->deactivate();
+	}
+}
+
 void CHeroWindow::dismissCurrent()
 {
 }

+ 2 - 1
CHeroWindow.h

@@ -27,7 +27,7 @@ public:
 	void show(SDL_Surface * to = NULL);
 };
 
-class CHeroWindow: public IShowable, public virtual CIntObject
+class CHeroWindow: public IActivable, public IShowable, public virtual CIntObject
 {
 	SDL_Surface * background, * curBack;
 	const CGHeroInstance * curHero;
@@ -56,6 +56,7 @@ public:
 	~CHeroWindow(); //d-tor
 	void setHero(const CGHeroInstance * hero); //sets main displayed hero
 	void activate(); //activates hero window;
+	void deactivate(); //activates hero window;
 	virtual void show(SDL_Surface * to = NULL); //shows hero window
 	void redrawCurBack(); //redraws curBAck from scratch
 	void quit(); //stops displaying hero window

+ 3 - 3
CPlayerInterface.cpp

@@ -52,7 +52,7 @@ void CInfoWindow::close()
 	SDL_FreeSurface(bitmap);
 	bitmap = NULL;
 	LOCPLINT->removeObjToBlit(this);
-	LOCPLINT->adventureInt->show();
+	LOCPLINT->curint->activate();
 	delete this;
 }
 CInfoWindow::~CInfoWindow()
@@ -250,7 +250,7 @@ void CSelWindow::close()
 	SDL_FreeSurface(bitmap);
 	bitmap = NULL;
 	LOCPLINT->removeObjToBlit(this);
-	LOCPLINT->adventureInt->show();
+	LOCPLINT->curint->activate();
 	LOCPLINT->cb->selectionMade(ret,ID);
 	delete this;
 	//call owner with selection result
@@ -1539,7 +1539,7 @@ void CPlayerInterface::showComp(SComponent comp)
 
 void CPlayerInterface::showInfoDialog(std::string text, std::vector<SComponent*> & components)
 {
-	adventureInt->hide(); //dezaktywacja starego interfejsu
+	curint->deactivate(); //dezaktywacja starego interfejsu
 	CInfoWindow * temp = CMessage::genIWindow(text,LOCPLINT->playerID,32,components);
 	LOCPLINT->objsToBlit.push_back(temp);
 	temp->pos.x=300-(temp->pos.w/2);

+ 1 - 0
CPlayerInterface.h

@@ -184,6 +184,7 @@ class CPlayerInterface : public CGameInterface
 public:
 	bool makingTurn;
 		SDL_Event * current;
+	IActivable *curint;
 	CAdvMapInt * adventureInt;
 	CCastleInterface * castleInt;
 	FPSmanager * mainFPSmng;