1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-11-24 08:32:34 +02:00

* improved hotkeys

* updated changelog
* version set to 0.64 (this rev will be released)
This commit is contained in:
Michał W. Urbańczyk 2008-11-01 22:32:56 +00:00
parent 248b5e8677
commit b988d5a51c
8 changed files with 75 additions and 39 deletions

View File

@ -89,18 +89,6 @@ void AdventureMapButton::activate()
Hoverable::activate();
KeyInterested::activate();
}
void AdventureMapButton::keyPressed(const SDL_KeyboardEvent & key)
{
if(key.keysym.sym == ourKey)
{
if(key.state == SDL_PRESSED)
clickLeft(true);
else
clickLeft(false);
}
}
void AdventureMapButton::deactivate()
{
if (!active) return;
@ -119,7 +107,7 @@ void AdventureMapButton::init(const CFunctionList<void()> &Callback, const std::
abs=true;
active=false;
ourObj=NULL;
ourKey = key;
assignedKeys.insert(key);
state=0;
hoverTexts = Name;
helpBox=HelpBox;

View File

@ -3,12 +3,11 @@
#include "client/FunctionList.h"
#include <boost/bind.hpp>
class AdventureMapButton
: public ClickableL, public ClickableR, public Hoverable, public KeyInterested, public CButtonBase
: public ClickableR, public Hoverable, public KeyShortcut, public CButtonBase
{
public:
std::map<int,std::string> hoverTexts; //state -> text for statusbar
std::string helpBox; //for right-click help
int ourKey; //key shortcut
CFunctionList<void()> callback;
bool colorChange, blocked,
actOnDown; //runs when mouse is pressed down over it, not when up
@ -17,7 +16,6 @@ public:
virtual void clickLeft (tribool down);
void hover (bool on);
void block(bool on); //if button is blocked then it'll change it's graphic to inactive (offset==2) and won't react on l-clicks
void keyPressed (const SDL_KeyboardEvent & key);
void activate(); // makes button active
void deactivate(); // makes button inactive (but doesn't delete)

View File

@ -92,6 +92,7 @@ CBattleInterface::CBattleInterface(CCreatureSet * army1, CCreatureSet * army2, C
bSpell = new AdventureMapButton (std::string(), std::string(), boost::bind(&CBattleInterface::bSpellf,this), 645, 561, "icm005.def", SDLK_c);
bWait = new AdventureMapButton (std::string(), std::string(), boost::bind(&CBattleInterface::bWaitf,this), 696, 561, "icm006.def", SDLK_w);
bDefence = new AdventureMapButton (std::string(), std::string(), boost::bind(&CBattleInterface::bDefencef,this), 747, 561, "icm007.def", SDLK_d);
bDefence->assignedKeys.insert(SDLK_SPACE);
bConsoleUp = new AdventureMapButton (std::string(), std::string(), boost::bind(&CBattleInterface::bConsoleUpf,this), 624, 561, "ComSlide.def", SDLK_UP);
bConsoleDown = new AdventureMapButton (std::string(), std::string(), boost::bind(&CBattleInterface::bConsoleDownf,this), 624, 580, "ComSlide.def", SDLK_DOWN);
bConsoleDown->bitmapOffset = 2;

View File

@ -60,6 +60,19 @@ public:
return (*a.first)<(*b.first);
}
} ocmptwo_cgin ;
void KeyShortcut::keyPressed(const SDL_KeyboardEvent & key)
{
if(vstd::contains(assignedKeys,key.keysym.sym))
{
if(key.state == SDL_PRESSED)
clickLeft(true);
else
clickLeft(false);
}
}
void CGarrisonSlot::hover (bool on)
{
Hoverable::hover(on);
@ -497,7 +510,8 @@ CInfoWindow::CInfoWindow(std::string text, int player, int charperline, const st
buttons.push_back(new AdventureMapButton("","",Buttons[i].second,0,0,Buttons[i].first));
if(!Buttons[i].second) //if no function, then by default we'll set it to close
{
buttons[i]->ourKey = SDLK_RETURN;
buttons[i]->assignedKeys.insert(SDLK_RETURN);
buttons[i]->assignedKeys.insert(SDLK_ESCAPE);
buttons[i]->callback += boost::bind(&CInfoWindow::close,this);
}
}
@ -751,11 +765,13 @@ CSelectableComponent::~CSelectableComponent()
}
void CSelectableComponent::activate()
{
KeyInterested::activate();
SComponent::activate();
ClickableL::activate();
}
void CSelectableComponent::deactivate()
{
KeyInterested::deactivate();
SComponent::deactivate();
ClickableL::deactivate();
}
@ -3362,6 +3378,8 @@ CLevelWindow::CLevelWindow(const CGHeroInstance *hero, int pskill, std::vector<u
cb = callback;
for(int i=0;i<skills.size();i++)
comps.push_back(new CSelectableComponent(SComponent::secskill44,skills[i],hero->getSecSkillLevel(skills[i])+1,boost::bind(&CLevelWindow::selectionChanged,this,i)));
comps[0]->assignedKeys.insert(SDLK_1);
comps[1]->assignedKeys.insert(SDLK_2);
bitmap = BitmapHandler::loadBitmap("LVLUPBKG.bmp");
graphics->blueToPlayersAdv(bitmap,hero->tempOwner);
SDL_SetColorKey(bitmap,SDL_SRCCOLORKEY,SDL_MapRGB(bitmap->format,0,255,255));
@ -3370,7 +3388,7 @@ CLevelWindow::CLevelWindow(const CGHeroInstance *hero, int pskill, std::vector<u
pos.w = bitmap->w;
pos.h = bitmap->h;
ok = new AdventureMapButton("","",boost::bind(&CLevelWindow::close,this),pos.x+297,pos.y+413,"IOKAY.DEF",SDLK_RETURN);
ok->block(true);
//draw window
char buf[100], buf2[100];
strcpy(buf2,CGI->generaltexth->allTexts[444].c_str()); //%s has gained a level.
@ -3403,6 +3421,8 @@ CLevelWindow::CLevelWindow(const CGHeroInstance *hero, int pskill, std::vector<u
}
void CLevelWindow::selectionChanged(unsigned to)
{
if(ok->blocked)
ok->block(false);
for(int i=0;i<comps.size();i++)
if(i==to)
comps[i]->select(true);

View File

@ -140,6 +140,17 @@ public:
virtual void activate()=0;
virtual void deactivate()=0;
};
class KeyShortcut : public KeyInterested, public ClickableL
{
public:
std::set<int> assignedKeys;
KeyShortcut(){};
KeyShortcut(int key){assignedKeys.insert(key);};
KeyShortcut(std::set<int> Keys):assignedKeys(Keys){};
virtual void keyPressed(const SDL_KeyboardEvent & key);
};
class MotionInterested: public virtual CIntObject
{
public:
@ -240,7 +251,7 @@ public:
~CCustomImgComponent();
};
class CSelectableComponent : public SComponent, public ClickableL
class CSelectableComponent : public SComponent, public KeyShortcut
{
public:
bool selected;
@ -249,7 +260,6 @@ public:
SDL_Surface * border, *myBitmap;
boost::function<void()> onSelect;
void clickLeft(boost::logic::tribool down);
void init(SDL_Surface * Border);
CSelectableComponent(Etype Type, int Sub, int Val, boost::function<void()> OnSelect = 0, SDL_Surface * Border=NULL);

View File

@ -1,24 +1,15 @@
0.63 -> 0.64 (Nov 01 2008 ?)
* sprites from /Sprites folder are handled correctly now
0.63 -> 0.64 (Nov 01 2008)
GENERAL:
* sprites from /Sprites folder are handled correctly
* several fixes for pathfinder and path arrows
* clicking on a tile in advmap view when a path is shown will not only hide it but also calculate a new one
* water elemental will really be treated as 2 hex creature
* potential infinite loop in reverseCreature removed
* better handling of battle cursor
* better handling disposed/predefined heroes
* fixed blocked shooter behavior
* slowed map scrolling
* blocked scrolling adventure map with mouse when left ctrl is pressed
* blocked map scrolling when dialog window is opened
* it's possible in battles to check remeaining HP of neutral stacks
* heroes regain 1 mana point each turn
* support for mistycisim and intelligence skills
* partial support for Magic Arrow spell
* fixed memory leak
* fixed bug with dying unit
* scholar will be accessible from the top
* partially done tavern and hero recruitment
* minor changes
* hero hiring possible
* added support for a number of hotkeys
* it's not possible anymore to leave hero level-up window without selecting secondary skill
* many minor improvements
* Added some kind of simple chatting functionality through console. Implemented several WoG cheats equivalents:
a) woggaladriel -> vcmiainur
b) wogoliphaunt -> vcminoldor
@ -27,6 +18,31 @@
e) wogisengard -> vcmiformenos
f) wogsaruman -> vcmiistari
g) wogpathofthedead -> vcmiangband
h) woggandalfwhite -> vcmiglorfindel
ADVENTURE INTERFACE:
* clicking on a tile in advmap view when a path is shown will not only hide it but also calculate a new one
* slowed map scrolling
* blocked scrolling adventure map with mouse when left ctrl is pressed
* blocked map scrolling when dialog window is opened
* scholar will be accessible from the top
TOWN INTERFACE:
* partially done tavern window (only hero hiring functionality)
BATTLES:
* water elemental will really be treated as 2 hex creature
* potential infinite loop in reverseCreature removed
* better handling of battle cursor
* fixed blocked shooter behavior
* it's possible in battles to check remeaining HP of neutral stacks
* partial support for Magic Arrow spell
* fixed bug with dying unit
* stack queue hotkey is now 'Q'
* added shots limit
0.62 -> 0.63 (Oct 01 2008)
GENERAL:

View File

@ -18,7 +18,7 @@ typedef boost::int8_t si8; //signed int 8 bits (1 byte)
#define THC
#endif
#define NAME_VER ("VCMI 0.63c")
#define NAME_VER ("VCMI 0.64")
#define CONSOLE_LOGGING_LEVEL 5
#define FILE_LOGGING_LEVEL 6

View File

@ -1097,7 +1097,10 @@ upgend:
if( curStack->position != ba.destinationTile //we wasn't able to reach destination tile
|| BattleInfo::mutualPosition(ba.destinationTile,ba.additionalInfo) < 0 //destination tile is not neighbouring with enemy stack
)
return;
{
sendDataToClients(ui16(3008)); //end movement and attack
break;
}
BattleAttack bat;
prepareAttack(bat,curStack,stackAtEnd);