Quellcode durchsuchen

* it's possible to give numbers moved creatures with keyboard in the stack split window
* updated changelog

Michał W. Urbańczyk vor 16 Jahren
Ursprung
Commit
a635ac7143
4 geänderte Dateien mit 94 neuen und 7 gelöschten Zeilen
  1. 50 6
      CPlayerInterface.cpp
  2. 14 1
      CPlayerInterface.h
  3. 8 0
      ChangeLog
  4. 22 0
      global.h

+ 50 - 6
CPlayerInterface.cpp

@@ -3216,10 +3216,12 @@ CRecrutationWindow::~CRecrutationWindow()
 
 CSplitWindow::CSplitWindow(int cid, int max, CGarrisonInt *Owner)
 {
+	which = 1;
 	c=cid;
 	slider = NULL;
 	gar = Owner;
 	bitmap = BitmapHandler::loadBitmap("GPUCRDIV.bmp");
+	graphics->blueToPlayersAdv(bitmap,LOCPLINT->playerID);
 	SDL_SetColorKey(bitmap,SDL_SRCCOLORKEY,SDL_MapRGB(bitmap->format,0,255,255));
 	pos.x = screen->w/2 - bitmap->w/2;
 	pos.y = screen->h/2 - bitmap->h/2;
@@ -3247,6 +3249,7 @@ CSplitWindow::~CSplitWindow()
 }
 void CSplitWindow::activate()
 {
+	ClickableL::activate();
 	LOCPLINT->objsToBlit.push_back(this);
 	KeyInterested::activate();
 	ok->activate();
@@ -3255,6 +3258,7 @@ void CSplitWindow::activate()
 }
 void CSplitWindow::deactivate()
 {
+	ClickableL::deactivate();
 	LOCPLINT->objsToBlit.erase(std::find(LOCPLINT->objsToBlit.begin(),LOCPLINT->objsToBlit.end(),this));
 	KeyInterested::deactivate();
 	ok->deactivate();
@@ -3280,23 +3284,63 @@ void CSplitWindow::sliderMoved(int to)
 }
 void CSplitWindow::show(SDL_Surface * to)
 {
-	char pom[15];
 	blitAt(bitmap,pos.x,pos.y,screen);
 	ok->show();
 	cancel->show();
 	slider->show();
-	SDL_itoa(a1,pom,10);
-	printAtMiddle(pom,pos.x+70,pos.y+237,GEOR16,zwykly,screen);
-	SDL_itoa(a2,pom,10);
-	printAtMiddle(pom,pos.x+233,pos.y+237,GEOR16,zwykly,screen);
+	printAtMiddle(boost::lexical_cast<std::string>(a1) + (!which ? "_" : ""),pos.x+70,pos.y+237,GEOR16,zwykly,screen);
+	printAtMiddle(boost::lexical_cast<std::string>(a2) + (which ? "_" : ""),pos.x+233,pos.y+237,GEOR16,zwykly,screen);
 	anim->blitPic(screen,pos.x+20,pos.y+54,false);
 	anim->blitPic(screen,pos.x+177,pos.y+54,false);
 }
 void CSplitWindow::keyPressed (const SDL_KeyboardEvent & key)
 {
-	//TODO: make manual typing possible
+	if(key.state != SDL_PRESSED)
+		return;
+
+	int &cur = (which ? a2 : a1), 
+		&sec = (which ? a1 : a2), 
+		ncur = cur;
+	if (key.keysym.sym == SDLK_BACKSPACE)
+	{
+		ncur /= 10;
+	}
+	else if(key.keysym.sym == SDLK_TAB)
+	{
+		which = !which;
+	}
+	else
+	{
+		int number = key.keysym.sym - SDLK_0;
+		if (number < 0   ||   number > 9) //not a number presses
+		{
+			return;
+		}
+		ncur = cur*10 + number;
+	}
+	int delta = ncur - cur;
+	if(delta > sec)
+	{
+		cur += sec;
+		sec = 0;
+	}
+	slider->moveTo(which ? ncur : a1+a2-ncur);
+}
+
+void CSplitWindow::clickLeft( boost::logic::tribool down )
+{
+	if(down)
+	{
+		Point click(LOCPLINT->current->motion.x,LOCPLINT->current->motion.y);
+		click -= pos.topLeft();
+		if(Rect(19,216,105,40).isIn(click))
+			which = 0;
+		else if(Rect(175,216,105,40).isIn(click))
+			which = 1;
+	}
 }
 
+
 void CCreInfoWindow::show(SDL_Surface * to)
 {
 	char pom[15];

+ 14 - 1
CPlayerInterface.h

@@ -58,10 +58,22 @@ struct Point
 	{
 		return Point(x+b.x,y+b.y);
 	}
+	Point& operator+=(const Point &b)
+	{
+		x += b.x;
+		y += b.y;
+		return *this;
+	}
 	Point operator-(const Point &b)
 	{
 		return Point(x+b.x,y+b.y);
 	}
+	Point& operator-=(const Point &b)
+	{
+		x -= b.x;
+		y -= b.y;
+		return *this;
+	}
 	bool operator<(const Point &b)
 	{
 		return x < b.x   &&   y < b.y;
@@ -633,7 +645,7 @@ public:
 	~CRecrutationWindow();
 };
 
-class CSplitWindow : public IShowable, public KeyInterested
+class CSplitWindow : public IShowable, public KeyInterested, public ClickableL
 {
 public:
 	CGarrisonInt *gar;
@@ -651,6 +663,7 @@ public:
 	void close();
 	void deactivate();
 	void show(SDL_Surface * to = NULL);
+	void clickLeft(boost::logic::tribool down);
 	void keyPressed (const SDL_KeyboardEvent & key);
 	void sliderMoved(int to);
 };

+ 8 - 0
ChangeLog

@@ -11,8 +11,10 @@ GENERAL:
 * updating blockmap/visitmap of randomized objects 
 * fixed crashes on loading maps with flag all mines/dwelling victory condition
 * further fixes for leveling-up (stability and identical offered skills bug)
+* support for numpad keyboard
 
 ADVENTURE INTERFACE:
+* added "Next hero" button functionality
 * added missing path arrows
 * corrected centering on hero's position 
 * recalculating hero path after reselecting hero
@@ -23,6 +25,8 @@ ADVENTURE INTERFACE:
 
 BATTLES:
 * partial support for battle obstacles
+* only one spell can be casted per turn
+* blocked opening sepllbook if hero doesn't have a one
 * spells not known by hero can't be casted 
 * spell books won't be placed in War Machine slots after battle
 * attack is now possible when hex under cursor is not displayed 
@@ -41,6 +45,8 @@ New spells supported:
  - Misfortune
 
 TOWN INTERFACE:
+* cannot build more than one capitol
+* cannot build shipyard if town is not near water
 * Rampart's Treasury requires Miner's Guild 
 * minor improvements in Recruitment Window
 * fixed crash occuring when clicking on hero portrait in Tavern Window, minor improvements for Tavern Window
@@ -56,6 +62,8 @@ PREGAME:
 * minor fixes
 
 OBJECTS:
+* windmill gives 500 gold only during first week ever (not every month)
+* After the first visit to the Witch Hut, right-click/hover tip mentions the skill available. 
 New objects supported:
  * Prison
  * Magic Well

+ 22 - 0
global.h

@@ -200,6 +200,28 @@ namespace vstd
 }
 using vstd::operator-=;
 
+template <typename t1, typename t2>
+t1 & amax(t1 &a, const t2 &b)
+{
+	if(a >= b)
+		return a;
+	else
+	{
+		a = b;
+		return a;
+	}
+}
+template <typename t1, typename t2>
+t1 & amin(t1 &a, const t2 &b)
+{
+	if(a <= b)
+		return a;
+	else
+	{
+		a = b;
+		return a;
+	}
+}
 #include "CConsoleHandler.h"
 extern DLL_EXPORT std::ostream *logfile;
 extern DLL_EXPORT CConsoleHandler *console;