From e8056d0d80cf8659c3b3448ffa00ee0944d972bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20W=2E=20Urba=C5=84czyk?= Date: Tue, 15 Apr 2008 17:12:21 +0000 Subject: [PATCH] * improved slider * fixed leaving battles --- AdventureMapButton.h | 7 +++++++ CPlayerInterface.cpp | 35 ++++++++++++++++++++++++++++++----- 2 files changed, 37 insertions(+), 5 deletions(-) diff --git a/AdventureMapButton.h b/AdventureMapButton.h index 20b5a6fd4..7d0404eb6 100644 --- a/AdventureMapButton.h +++ b/AdventureMapButton.h @@ -476,7 +476,14 @@ template void CSlider::clickLeft (tribool down) { if(down) + { + float pw = LOCPLINT->current->motion.x-pos.x-16; + float rw = pw / ((float)(pos.w-32)); + if (rw>1) rw=1; + if (rw<0) rw=0; + moveTo(rw*amount); return; + } if(moving) { MotionInterested::deactivate(); diff --git a/CPlayerInterface.cpp b/CPlayerInterface.cpp index 11118bb96..f7addb2db 100644 --- a/CPlayerInterface.cpp +++ b/CPlayerInterface.cpp @@ -1989,8 +1989,10 @@ BattleAction CPlayerInterface::activeStack(int stackID) //called when it's turn void CPlayerInterface::battleEnd(CCreatureSet * army1, CCreatureSet * army2, CArmedInstance *hero1, CArmedInstance *hero2, std::vector capturedArtifacts, int expForWinner, bool winner) { dynamic_cast(curint)->deactivate(); + LOCPLINT->objsToBlit.erase(std::find(LOCPLINT->objsToBlit.begin(),LOCPLINT->objsToBlit.end(),dynamic_cast(curint))); delete dynamic_cast(curint); - curint = NULL; + curint = adventureInt; + adventureInt->activate(); } void CPlayerInterface::battleStackMoved(int ID, int dest, bool startMoving, bool endMoving) @@ -2387,10 +2389,30 @@ void CRecrutationWindow::sliderMoved(int to) } void CRecrutationWindow::clickLeft(tribool down) { + int curx = 192 + 51 - (102*creatures.size()/2) - (18*(creatures.size()-1)/2); + for(int i=0;icurrent->motion.x,LOCPLINT->current->motion.y)) + { + which = i; + curx = 192 + 51 - (102*creatures.size()/2) - (18*(creatures.size()-1)/2); + for(int j=0;jobjsToBlit.push_back(this); + ClickableL::activate(); buy->activate(); max->activate(); cancel->activate(); @@ -2399,6 +2421,7 @@ void CRecrutationWindow::activate() void CRecrutationWindow::deactivate() { LOCPLINT->objsToBlit.erase(std::find(LOCPLINT->objsToBlit.begin(),LOCPLINT->objsToBlit.end(),this)); + ClickableL::deactivate(); buy->deactivate(); max->deactivate(); cancel->deactivate(); @@ -2417,7 +2440,7 @@ void CRecrutationWindow::show(SDL_Surface * to) printAtMiddle(pom,pos.x+205,pos.y+252,GEOR13,zwykly,ekran); itoa(slider->value,pom,10); //recruit printAtMiddle(pom,pos.x+279,pos.y+252,GEOR13,zwykly,ekran); - + printAtMiddle(CGI->generaltexth->allTexts[16] + " " + CGI->creh->creatures[creatures[which].ID].namePl,pos.x+243,pos.y+32,GEOR16,tytulowy,ekran); //eg "Recruit Dragon flies" int curx = pos.x+115-creatures[which].res.size()*16; for(int i=0;i > &Creatures, IRecruit *irec) //creatures - pairs :rec(irec) { + which = 0; creatures.resize(Creatures.size()); for(int i=0;i > &Creatur pos.h = bitmap->h; slider = new CSlider(pos.x+176,pos.y+279,135,this,&CRecrutationWindow::sliderMoved,1,creatures[0].amount,0,true); std::string pom; - printAtMiddle(CGI->generaltexth->allTexts[16] + " " + CGI->creh->creatures[creatures[0].ID].namePl,243,32,GEOR16,tytulowy,bitmap); //eg "Recruit Dragon flies" printAtMiddle(CGI->generaltexth->allTexts[346],113,231,GEOR13,zwykly,bitmap); //cost per troop t printAtMiddle(CGI->generaltexth->allTexts[465],205,231,GEOR13,zwykly,bitmap); //available t printAtMiddle(CGI->generaltexth->allTexts[16],279,231,GEOR13,zwykly,bitmap); //recruit t @@ -2484,7 +2507,10 @@ CRecrutationWindow::CRecrutationWindow(std::vector > &Creatur creatures[i].pos.y = 65; creatures[i].pos.w = 100; creatures[i].pos.h = 130; - drawBorder(bitmap,curx,64,102,132,int3(255,0,0)); + if(which==i) + drawBorder(bitmap,curx,64,102,132,int3(255,0,0)); + else + drawBorder(bitmap,curx,64,102,132,int3(239,215,123)); curx += 120; } @@ -2492,7 +2518,6 @@ CRecrutationWindow::CRecrutationWindow(std::vector > &Creatur buy = new AdventureMapButton("","",&CRecrutationWindow::Buy,pos.x+212,pos.y+313,"IBY6432.DEF",this); cancel = new AdventureMapButton("","",&CRecrutationWindow::Cancel,pos.x+290,pos.y+313,"ICN6432.DEF",this); LOCPLINT->curint->deactivate(); - which = 0; //AdventureMapButton( std::string Name, std::string HelpBox, void(T::*Function)(), //int x, int y, std::string defName, T* Owner, bool activ=false, std::vector * add = NULL, bool playerColoredButton = true );//c-tor }//(int x, int y, int totalw, T*Owner,void(T::*Moved)(int to), int Capacity, int Amount, int Value, bool Horizontal)