mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-24 22:14:36 +02:00
* VCAI: can't request actions from action handling thread
* Save game screen and returning to main menu will work if game was started with --start option * GUI controls can selectively capture keyboard events. CTextInput won't capture Enter. Fixes #654.
This commit is contained in:
parent
76eb0ed429
commit
6db3c5bc7e
@ -788,7 +788,9 @@ void VCAI::showGarrisonDialog(const CArmedInstance *up, const CGHeroInstance *do
|
|||||||
NET_EVENT_HANDLER;
|
NET_EVENT_HANDLER;
|
||||||
LOG_ENTRY;
|
LOG_ENTRY;
|
||||||
status.addQuery();
|
status.addQuery();
|
||||||
pickBestCreatures (down, up);
|
|
||||||
|
//you can't request action from action-response thread
|
||||||
|
//pickBestCreatures (down, up);
|
||||||
onEnd();
|
onEnd();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -716,6 +716,7 @@ static void listenForEvents()
|
|||||||
const_cast<CGameInfo*>(CGI)->dobjinfo = new CDefObjInfoHandler;
|
const_cast<CGameInfo*>(CGI)->dobjinfo = new CDefObjInfoHandler;
|
||||||
const_cast<CGameInfo*>(CGI)->dobjinfo->load();
|
const_cast<CGameInfo*>(CGI)->dobjinfo->load();
|
||||||
|
|
||||||
|
CGPreGame::createIfNotPresent();
|
||||||
GH.curInt = CGP;
|
GH.curInt = CGP;
|
||||||
GH.defActionsDef = 63;
|
GH.defActionsDef = 63;
|
||||||
break;
|
break;
|
||||||
|
@ -401,10 +401,12 @@ CGPreGame::CGPreGame():
|
|||||||
GH.defActionsDef = 63;
|
GH.defActionsDef = 63;
|
||||||
CGP = this;
|
CGP = this;
|
||||||
menu = new CMenuScreen((*pregameConfig)["window"]);
|
menu = new CMenuScreen((*pregameConfig)["window"]);
|
||||||
|
loadGraphics();
|
||||||
}
|
}
|
||||||
|
|
||||||
CGPreGame::~CGPreGame()
|
CGPreGame::~CGPreGame()
|
||||||
{
|
{
|
||||||
|
disposeGraphics();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CGPreGame::openSel(CMenuScreen::EState screenType, CMenuScreen::EMultiMode multi /*= CMenuScreen::SINGLE_PLAYER*/)
|
void CGPreGame::openSel(CMenuScreen::EState screenType, CMenuScreen::EMultiMode multi /*= CMenuScreen::SINGLE_PLAYER*/)
|
||||||
@ -475,10 +477,17 @@ void CGPreGame::openCampaignScreen(std::string name)
|
|||||||
tlog1<<"Unknown campaign set: "<<name<<"\n";
|
tlog1<<"Unknown campaign set: "<<name<<"\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CGPreGame::createIfNotPresent()
|
||||||
|
{
|
||||||
|
if(!CGP)
|
||||||
|
CGP = new CGPreGame();
|
||||||
|
}
|
||||||
|
|
||||||
CSelectionScreen::CSelectionScreen(CMenuScreen::EState Type, CMenuScreen::EMultiMode MultiPlayer /*= CMenuScreen::SINGLE_PLAYER*/, const std::map<ui32, std::string> *Names /*= NULL*/)
|
CSelectionScreen::CSelectionScreen(CMenuScreen::EState Type, CMenuScreen::EMultiMode MultiPlayer /*= CMenuScreen::SINGLE_PLAYER*/, const std::map<ui32, std::string> *Names /*= NULL*/)
|
||||||
: ISelectionScreenInfo(Names), serverHandlingThread(NULL), mx(new boost::recursive_mutex),
|
: ISelectionScreenInfo(Names), serverHandlingThread(NULL), mx(new boost::recursive_mutex),
|
||||||
serv(NULL), ongoingClosing(false), myNameID(255)
|
serv(NULL), ongoingClosing(false), myNameID(255)
|
||||||
{
|
{
|
||||||
|
CGPreGame::createIfNotPresent(); //we depend on its graphics
|
||||||
screenType = Type;
|
screenType = Type;
|
||||||
multiPlayer = MultiPlayer;
|
multiPlayer = MultiPlayer;
|
||||||
|
|
||||||
@ -514,7 +523,6 @@ CSelectionScreen::CSelectionScreen(CMenuScreen::EState Type, CMenuScreen::EMulti
|
|||||||
bg = new CPicture(BitmapHandler::loadBitmap(rand()%2 ? "ZPIC1000.bmp" : "ZPIC1001.bmp"), -3, -6, true);
|
bg = new CPicture(BitmapHandler::loadBitmap(rand()%2 ? "ZPIC1000.bmp" : "ZPIC1001.bmp"), -3, -6, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
CGP->loadGraphics();
|
|
||||||
sInfo.difficulty = 1;
|
sInfo.difficulty = 1;
|
||||||
current = NULL;
|
current = NULL;
|
||||||
|
|
||||||
|
@ -501,6 +501,8 @@ public:
|
|||||||
void disposeGraphics();
|
void disposeGraphics();
|
||||||
|
|
||||||
void openCampaignScreen(std::string name);
|
void openCampaignScreen(std::string name);
|
||||||
|
|
||||||
|
static void createIfNotPresent();
|
||||||
};
|
};
|
||||||
|
|
||||||
extern ISelectionScreenInfo *SEL;
|
extern ISelectionScreenInfo *SEL;
|
||||||
|
@ -168,7 +168,7 @@ void CGuiHandler::handleEvent(SDL_Event *sEvent)
|
|||||||
bool keysCaptured = false;
|
bool keysCaptured = false;
|
||||||
for(std::list<CIntObject*>::iterator i=keyinterested.begin(); i != keyinterested.end() && current; i++)
|
for(std::list<CIntObject*>::iterator i=keyinterested.begin(); i != keyinterested.end() && current; i++)
|
||||||
{
|
{
|
||||||
if((*i)->captureAllKeys)
|
if((*i)->captureThisEvent(key))
|
||||||
{
|
{
|
||||||
keysCaptured = true;
|
keysCaptured = true;
|
||||||
break;
|
break;
|
||||||
@ -177,7 +177,7 @@ void CGuiHandler::handleEvent(SDL_Event *sEvent)
|
|||||||
|
|
||||||
std::list<CIntObject*> miCopy = keyinterested;
|
std::list<CIntObject*> miCopy = keyinterested;
|
||||||
for(std::list<CIntObject*>::iterator i=miCopy.begin(); i != miCopy.end() && current; i++)
|
for(std::list<CIntObject*>::iterator i=miCopy.begin(); i != miCopy.end() && current; i++)
|
||||||
if(vstd::contains(keyinterested,*i) && (!keysCaptured || (*i)->captureAllKeys))
|
if(vstd::contains(keyinterested,*i) && (!keysCaptured || (*i)->captureThisEvent(key)))
|
||||||
(**i).keyPressed(key);
|
(**i).keyPressed(key);
|
||||||
}
|
}
|
||||||
else if(sEvent->type==SDL_MOUSEMOTION)
|
else if(sEvent->type==SDL_MOUSEMOTION)
|
||||||
|
@ -442,6 +442,11 @@ const Rect & CIntObject::center(const Point &p, bool propagate /*= true*/)
|
|||||||
return pos;
|
return pos;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool CIntObject::captureThisEvent(const SDL_KeyboardEvent & key)
|
||||||
|
{
|
||||||
|
return captureAllKeys;
|
||||||
|
}
|
||||||
|
|
||||||
void CKeyShortcut::keyPressed(const SDL_KeyboardEvent & key)
|
void CKeyShortcut::keyPressed(const SDL_KeyboardEvent & key)
|
||||||
{
|
{
|
||||||
if(vstd::contains(assignedKeys,key.keysym.sym))
|
if(vstd::contains(assignedKeys,key.keysym.sym))
|
||||||
|
@ -104,6 +104,7 @@ public:
|
|||||||
void activateKeys();
|
void activateKeys();
|
||||||
void deactivateKeys();
|
void deactivateKeys();
|
||||||
virtual void keyPressed(const SDL_KeyboardEvent & key);
|
virtual void keyPressed(const SDL_KeyboardEvent & key);
|
||||||
|
virtual bool captureThisEvent(const SDL_KeyboardEvent & key); //allows refining captureAllKeys against specific events (eg. don't capture ENTER)
|
||||||
|
|
||||||
//mouse movement handling
|
//mouse movement handling
|
||||||
bool strongInterest; //if true - report all mouse movements, if not - only when hovered
|
bool strongInterest; //if true - report all mouse movements, if not - only when hovered
|
||||||
|
@ -1470,6 +1470,14 @@ CTextInput::~CTextInput()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool CTextInput::captureThisEvent(const SDL_KeyboardEvent & key)
|
||||||
|
{
|
||||||
|
if(key.keysym.sym == SDLK_RETURN || key.keysym.sym == SDLK_KP_ENTER)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
CFocusable::CFocusable()
|
CFocusable::CFocusable()
|
||||||
{
|
{
|
||||||
focusables.push_back(this);
|
focusables.push_back(this);
|
||||||
|
@ -405,9 +405,11 @@ public:
|
|||||||
CTextInput(const Rect &Pos, const Point &bgOffset, const std::string &bgName, const CFunctionList<void(const std::string &)> &CB);
|
CTextInput(const Rect &Pos, const Point &bgOffset, const std::string &bgName, const CFunctionList<void(const std::string &)> &CB);
|
||||||
CTextInput(const Rect &Pos, SDL_Surface *srf = NULL);
|
CTextInput(const Rect &Pos, SDL_Surface *srf = NULL);
|
||||||
~CTextInput();
|
~CTextInput();
|
||||||
void showAll(SDL_Surface * to);
|
|
||||||
void clickLeft(tribool down, bool previousState);
|
void showAll(SDL_Surface * to) OVERRIDE;
|
||||||
void keyPressed(const SDL_KeyboardEvent & key);
|
void clickLeft(tribool down, bool previousState) OVERRIDE;
|
||||||
|
void keyPressed(const SDL_KeyboardEvent & key) OVERRIDE;
|
||||||
|
bool captureThisEvent(const SDL_KeyboardEvent & key) OVERRIDE;
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Listbox UI Element
|
/// Listbox UI Element
|
||||||
|
Loading…
Reference in New Issue
Block a user