|
@@ -31,6 +31,7 @@
|
|
|
#include "../widgets/TextControls.h"
|
|
#include "../widgets/TextControls.h"
|
|
|
#include "../widgets/Buttons.h"
|
|
#include "../widgets/Buttons.h"
|
|
|
#include "../windows/SettingsMainContainer.h"
|
|
#include "../windows/SettingsMainContainer.h"
|
|
|
|
|
+#include "../CMT.h"
|
|
|
|
|
|
|
|
#include "../../CCallback.h"
|
|
#include "../../CCallback.h"
|
|
|
#include "../../lib/CConfigHandler.h"
|
|
#include "../../lib/CConfigHandler.h"
|
|
@@ -43,9 +44,6 @@
|
|
|
#include "../../lib/UnlockGuard.h"
|
|
#include "../../lib/UnlockGuard.h"
|
|
|
#include "../../lib/TerrainHandler.h"
|
|
#include "../../lib/TerrainHandler.h"
|
|
|
|
|
|
|
|
-#include <SDL_surface.h>
|
|
|
|
|
-#include <SDL_events.h>
|
|
|
|
|
-
|
|
|
|
|
#define ADVOPT (conf.go()->ac)
|
|
#define ADVOPT (conf.go()->ac)
|
|
|
|
|
|
|
|
std::shared_ptr<CAdvMapInt> adventureInt;
|
|
std::shared_ptr<CAdvMapInt> adventureInt;
|
|
@@ -91,8 +89,8 @@ CAdvMapInt::CAdvMapInt():
|
|
|
swipeTargetPosition(int3(-1, -1, -1))
|
|
swipeTargetPosition(int3(-1, -1, -1))
|
|
|
{
|
|
{
|
|
|
pos.x = pos.y = 0;
|
|
pos.x = pos.y = 0;
|
|
|
- pos.w = screen->w;
|
|
|
|
|
- pos.h = screen->h;
|
|
|
|
|
|
|
+ pos.w = GH.screenDimensions().x;
|
|
|
|
|
+ pos.h = GH.screenDimensions().y;
|
|
|
strongInterest = true; // handle all mouse move events to prevent dead mouse move space in fullscreen mode
|
|
strongInterest = true; // handle all mouse move events to prevent dead mouse move space in fullscreen mode
|
|
|
townList.onSelect = std::bind(&CAdvMapInt::selectionChanged,this);
|
|
townList.onSelect = std::bind(&CAdvMapInt::selectionChanged,this);
|
|
|
bg = IImage::createFromFile(ADVOPT.mainGraphic);
|
|
bg = IImage::createFromFile(ADVOPT.mainGraphic);
|
|
@@ -138,7 +136,7 @@ CAdvMapInt::CAdvMapInt():
|
|
|
nextHero = makeButton(301, std::bind(&CAdvMapInt::fnextHero,this), ADVOPT.nextHero, SDLK_h);
|
|
nextHero = makeButton(301, std::bind(&CAdvMapInt::fnextHero,this), ADVOPT.nextHero, SDLK_h);
|
|
|
endTurn = makeButton(302, std::bind(&CAdvMapInt::fendTurn,this), ADVOPT.endTurn, SDLK_e);
|
|
endTurn = makeButton(302, std::bind(&CAdvMapInt::fendTurn,this), ADVOPT.endTurn, SDLK_e);
|
|
|
|
|
|
|
|
- int panelSpaceBottom = screen->h - resdatabar.pos.h - 4;
|
|
|
|
|
|
|
+ int panelSpaceBottom = GH.screenDimensions().y - resdatabar.pos.h - 4;
|
|
|
|
|
|
|
|
panelMain = std::make_shared<CAdvMapPanel>(nullptr, Point(0, 0));
|
|
panelMain = std::make_shared<CAdvMapPanel>(nullptr, Point(0, 0));
|
|
|
// TODO correct drawing position
|
|
// TODO correct drawing position
|
|
@@ -159,7 +157,7 @@ CAdvMapInt::CAdvMapInt():
|
|
|
// TODO move configs to resolutions.json, similarly to previous buttons
|
|
// TODO move configs to resolutions.json, similarly to previous buttons
|
|
|
config::ButtonInfo worldViewBackConfig = config::ButtonInfo();
|
|
config::ButtonInfo worldViewBackConfig = config::ButtonInfo();
|
|
|
worldViewBackConfig.defName = "IOK6432.DEF";
|
|
worldViewBackConfig.defName = "IOK6432.DEF";
|
|
|
- worldViewBackConfig.x = screen->w - 73;
|
|
|
|
|
|
|
+ worldViewBackConfig.x = GH.screenDimensions().x - 73;
|
|
|
worldViewBackConfig.y = 343 + 195;
|
|
worldViewBackConfig.y = 343 + 195;
|
|
|
worldViewBackConfig.playerColoured = false;
|
|
worldViewBackConfig.playerColoured = false;
|
|
|
panelWorldView->addChildToPanel(
|
|
panelWorldView->addChildToPanel(
|
|
@@ -167,7 +165,7 @@ CAdvMapInt::CAdvMapInt():
|
|
|
|
|
|
|
|
config::ButtonInfo worldViewPuzzleConfig = config::ButtonInfo();
|
|
config::ButtonInfo worldViewPuzzleConfig = config::ButtonInfo();
|
|
|
worldViewPuzzleConfig.defName = "VWPUZ.DEF";
|
|
worldViewPuzzleConfig.defName = "VWPUZ.DEF";
|
|
|
- worldViewPuzzleConfig.x = screen->w - 188;
|
|
|
|
|
|
|
+ worldViewPuzzleConfig.x = GH.screenDimensions().x - 188;
|
|
|
worldViewPuzzleConfig.y = 343 + 195;
|
|
worldViewPuzzleConfig.y = 343 + 195;
|
|
|
worldViewPuzzleConfig.playerColoured = false;
|
|
worldViewPuzzleConfig.playerColoured = false;
|
|
|
panelWorldView->addChildToPanel( // no help text for this one
|
|
panelWorldView->addChildToPanel( // no help text for this one
|
|
@@ -176,7 +174,7 @@ CAdvMapInt::CAdvMapInt():
|
|
|
|
|
|
|
|
config::ButtonInfo worldViewScale1xConfig = config::ButtonInfo();
|
|
config::ButtonInfo worldViewScale1xConfig = config::ButtonInfo();
|
|
|
worldViewScale1xConfig.defName = "VWMAG1.DEF";
|
|
worldViewScale1xConfig.defName = "VWMAG1.DEF";
|
|
|
- worldViewScale1xConfig.x = screen->w - 191;
|
|
|
|
|
|
|
+ worldViewScale1xConfig.x = GH.screenDimensions().x - 191;
|
|
|
worldViewScale1xConfig.y = 23 + 195;
|
|
worldViewScale1xConfig.y = 23 + 195;
|
|
|
worldViewScale1xConfig.playerColoured = false;
|
|
worldViewScale1xConfig.playerColoured = false;
|
|
|
panelWorldView->addChildToPanel( // help text is wrong for this button
|
|
panelWorldView->addChildToPanel( // help text is wrong for this button
|
|
@@ -184,7 +182,7 @@ CAdvMapInt::CAdvMapInt():
|
|
|
|
|
|
|
|
config::ButtonInfo worldViewScale2xConfig = config::ButtonInfo();
|
|
config::ButtonInfo worldViewScale2xConfig = config::ButtonInfo();
|
|
|
worldViewScale2xConfig.defName = "VWMAG2.DEF";
|
|
worldViewScale2xConfig.defName = "VWMAG2.DEF";
|
|
|
- worldViewScale2xConfig.x = screen->w - 191 + 63;
|
|
|
|
|
|
|
+ worldViewScale2xConfig.x = GH.screenDimensions().x- 191 + 63;
|
|
|
worldViewScale2xConfig.y = 23 + 195;
|
|
worldViewScale2xConfig.y = 23 + 195;
|
|
|
worldViewScale2xConfig.playerColoured = false;
|
|
worldViewScale2xConfig.playerColoured = false;
|
|
|
panelWorldView->addChildToPanel( // help text is wrong for this button
|
|
panelWorldView->addChildToPanel( // help text is wrong for this button
|
|
@@ -192,7 +190,7 @@ CAdvMapInt::CAdvMapInt():
|
|
|
|
|
|
|
|
config::ButtonInfo worldViewScale4xConfig = config::ButtonInfo();
|
|
config::ButtonInfo worldViewScale4xConfig = config::ButtonInfo();
|
|
|
worldViewScale4xConfig.defName = "VWMAG4.DEF";
|
|
worldViewScale4xConfig.defName = "VWMAG4.DEF";
|
|
|
- worldViewScale4xConfig.x = screen->w - 191 + 126;
|
|
|
|
|
|
|
+ worldViewScale4xConfig.x = GH.screenDimensions().x- 191 + 126;
|
|
|
worldViewScale4xConfig.y = 23 + 195;
|
|
worldViewScale4xConfig.y = 23 + 195;
|
|
|
worldViewScale4xConfig.playerColoured = false;
|
|
worldViewScale4xConfig.playerColoured = false;
|
|
|
panelWorldView->addChildToPanel( // help text is wrong for this button
|
|
panelWorldView->addChildToPanel( // help text is wrong for this button
|
|
@@ -201,7 +199,7 @@ CAdvMapInt::CAdvMapInt():
|
|
|
config::ButtonInfo worldViewUndergroundConfig = config::ButtonInfo();
|
|
config::ButtonInfo worldViewUndergroundConfig = config::ButtonInfo();
|
|
|
worldViewUndergroundConfig.defName = "IAM010.DEF";
|
|
worldViewUndergroundConfig.defName = "IAM010.DEF";
|
|
|
worldViewUndergroundConfig.additionalDefs.push_back("IAM003.DEF");
|
|
worldViewUndergroundConfig.additionalDefs.push_back("IAM003.DEF");
|
|
|
- worldViewUndergroundConfig.x = screen->w - 115;
|
|
|
|
|
|
|
+ worldViewUndergroundConfig.x = GH.screenDimensions().x - 115;
|
|
|
worldViewUndergroundConfig.y = 343 + 195;
|
|
worldViewUndergroundConfig.y = 343 + 195;
|
|
|
worldViewUndergroundConfig.playerColoured = true;
|
|
worldViewUndergroundConfig.playerColoured = true;
|
|
|
worldViewUnderground = makeButton(294, std::bind(&CAdvMapInt::fswitchLevel,this), worldViewUndergroundConfig, SDLK_u);
|
|
worldViewUnderground = makeButton(294, std::bind(&CAdvMapInt::fswitchLevel,this), worldViewUndergroundConfig, SDLK_u);
|
|
@@ -617,7 +615,7 @@ void CAdvMapInt::handleMapScrollingUpdate()
|
|
|
int scrollSpeed = static_cast<int>(settings["adventure"]["scrollSpeed"].Float());
|
|
int scrollSpeed = static_cast<int>(settings["adventure"]["scrollSpeed"].Float());
|
|
|
//if advmap needs updating AND (no dialog is shown OR ctrl is pressed)
|
|
//if advmap needs updating AND (no dialog is shown OR ctrl is pressed)
|
|
|
if((animValHitCount % (4 / scrollSpeed)) == 0
|
|
if((animValHitCount % (4 / scrollSpeed)) == 0
|
|
|
- && ((GH.topInt().get() == this) || CSDL_Ext::isCtrlKeyDown()))
|
|
|
|
|
|
|
+ && GH.isKeyboardCtrlDown())
|
|
|
{
|
|
{
|
|
|
if((scrollingDir & LEFT) && (position.x > -CGI->mh->frameW))
|
|
if((scrollingDir & LEFT) && (position.x > -CGI->mh->frameW))
|
|
|
position.x--;
|
|
position.x--;
|
|
@@ -713,21 +711,46 @@ void CAdvMapInt::centerOn(const CGObjectInstance * obj, bool fade)
|
|
|
centerOn(obj->getSightCenter(), fade);
|
|
centerOn(obj->getSightCenter(), fade);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-void CAdvMapInt::keyPressed(const SDL_KeyboardEvent & key)
|
|
|
|
|
|
|
+void CAdvMapInt::keyReleased(const SDL_Keycode &key)
|
|
|
{
|
|
{
|
|
|
|
|
+ if (mode == EAdvMapMode::WORLD_VIEW)
|
|
|
|
|
+ return;
|
|
|
|
|
|
|
|
|
|
+ switch (key)
|
|
|
|
|
+ {
|
|
|
|
|
+ case SDLK_s:
|
|
|
|
|
+ if(isActive())
|
|
|
|
|
+ GH.pushIntT<CSavingScreen>();
|
|
|
|
|
+ return;
|
|
|
|
|
+ default:
|
|
|
|
|
+ {
|
|
|
|
|
+ auto direction = keyToMoveDirection(key);
|
|
|
|
|
+
|
|
|
|
|
+ if (!direction)
|
|
|
|
|
+ return;
|
|
|
|
|
+
|
|
|
|
|
+ ui8 Dir = (direction->x<0 ? LEFT : 0) |
|
|
|
|
|
+ (direction->x>0 ? RIGHT : 0) |
|
|
|
|
|
+ (direction->y<0 ? UP : 0) |
|
|
|
|
|
+ (direction->y>0 ? DOWN : 0) ;
|
|
|
|
|
+
|
|
|
|
|
+ scrollingDir &= ~Dir;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+void CAdvMapInt::keyPressed(const SDL_Keycode & key)
|
|
|
|
|
+{
|
|
|
if (mode == EAdvMapMode::WORLD_VIEW)
|
|
if (mode == EAdvMapMode::WORLD_VIEW)
|
|
|
return;
|
|
return;
|
|
|
|
|
|
|
|
- ui8 Dir = 0;
|
|
|
|
|
- SDL_Keycode k = key.keysym.sym;
|
|
|
|
|
const CGHeroInstance *h = curHero(); //selected hero
|
|
const CGHeroInstance *h = curHero(); //selected hero
|
|
|
const CGTownInstance *t = curTown(); //selected town
|
|
const CGTownInstance *t = curTown(); //selected town
|
|
|
|
|
|
|
|
- switch(k)
|
|
|
|
|
|
|
+ switch(key)
|
|
|
{
|
|
{
|
|
|
case SDLK_g:
|
|
case SDLK_g:
|
|
|
- if(key.state != SDL_PRESSED || GH.topInt()->type & BLOCK_ADV_HOTKEYS)
|
|
|
|
|
|
|
+ if(GH.topInt()->type & BLOCK_ADV_HOTKEYS)
|
|
|
return;
|
|
return;
|
|
|
|
|
|
|
|
{
|
|
{
|
|
@@ -751,13 +774,9 @@ void CAdvMapInt::keyPressed(const SDL_KeyboardEvent & key)
|
|
|
if(isActive())
|
|
if(isActive())
|
|
|
LOCPLINT->proposeLoadingGame();
|
|
LOCPLINT->proposeLoadingGame();
|
|
|
return;
|
|
return;
|
|
|
- case SDLK_s:
|
|
|
|
|
- if(isActive() && key.type == SDL_KEYUP)
|
|
|
|
|
- GH.pushIntT<CSavingScreen>();
|
|
|
|
|
- return;
|
|
|
|
|
case SDLK_d:
|
|
case SDLK_d:
|
|
|
{
|
|
{
|
|
|
- if(h && isActive() && LOCPLINT->makingTurn && key.state == SDL_PRESSED)
|
|
|
|
|
|
|
+ if(h && isActive() && LOCPLINT->makingTurn)
|
|
|
LOCPLINT->tryDiggging(h);
|
|
LOCPLINT->tryDiggging(h);
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
@@ -770,17 +789,17 @@ void CAdvMapInt::keyPressed(const SDL_KeyboardEvent & key)
|
|
|
LOCPLINT->viewWorldMap();
|
|
LOCPLINT->viewWorldMap();
|
|
|
return;
|
|
return;
|
|
|
case SDLK_r:
|
|
case SDLK_r:
|
|
|
- if(isActive() && LOCPLINT->ctrlPressed())
|
|
|
|
|
|
|
+ if(isActive() && GH.isKeyboardCtrlDown())
|
|
|
{
|
|
{
|
|
|
LOCPLINT->showYesNoDialog(CGI->generaltexth->translate("vcmi.adventureMap.confirmRestartGame"),
|
|
LOCPLINT->showYesNoDialog(CGI->generaltexth->translate("vcmi.adventureMap.confirmRestartGame"),
|
|
|
- [](){ LOCPLINT->sendCustomEvent(EUserEvent::RESTART_GAME); }, nullptr);
|
|
|
|
|
|
|
+ [](){ GH.pushUserEvent(EUserEvent::RESTART_GAME); }, nullptr);
|
|
|
}
|
|
}
|
|
|
return;
|
|
return;
|
|
|
case SDLK_SPACE: //space - try to revisit current object with selected hero
|
|
case SDLK_SPACE: //space - try to revisit current object with selected hero
|
|
|
{
|
|
{
|
|
|
if(!isActive())
|
|
if(!isActive())
|
|
|
return;
|
|
return;
|
|
|
- if(h && key.state == SDL_PRESSED)
|
|
|
|
|
|
|
+ if(h)
|
|
|
{
|
|
{
|
|
|
auto unlockPim = vstd::makeUnlockGuard(*CPlayerInterface::pim);
|
|
auto unlockPim = vstd::makeUnlockGuard(*CPlayerInterface::pim);
|
|
|
//TODO!!!!!!! possible freeze, when GS mutex is locked and network thread can't apply package
|
|
//TODO!!!!!!! possible freeze, when GS mutex is locked and network thread can't apply package
|
|
@@ -793,7 +812,7 @@ void CAdvMapInt::keyPressed(const SDL_KeyboardEvent & key)
|
|
|
return;
|
|
return;
|
|
|
case SDLK_RETURN:
|
|
case SDLK_RETURN:
|
|
|
{
|
|
{
|
|
|
- if(!isActive() || !selection || key.state != SDL_PRESSED)
|
|
|
|
|
|
|
+ if(!isActive() || !selection)
|
|
|
return;
|
|
return;
|
|
|
if(h)
|
|
if(h)
|
|
|
LOCPLINT->openHeroWindow(h);
|
|
LOCPLINT->openHeroWindow(h);
|
|
@@ -803,7 +822,7 @@ void CAdvMapInt::keyPressed(const SDL_KeyboardEvent & key)
|
|
|
}
|
|
}
|
|
|
case SDLK_ESCAPE:
|
|
case SDLK_ESCAPE:
|
|
|
{
|
|
{
|
|
|
- if(isActive() || GH.topInt().get() != this || !spellBeingCasted || key.state != SDL_PRESSED)
|
|
|
|
|
|
|
+ if(isActive() || GH.topInt().get() != this || !spellBeingCasted)
|
|
|
return;
|
|
return;
|
|
|
|
|
|
|
|
leaveCastingMode();
|
|
leaveCastingMode();
|
|
@@ -812,10 +831,10 @@ void CAdvMapInt::keyPressed(const SDL_KeyboardEvent & key)
|
|
|
case SDLK_t:
|
|
case SDLK_t:
|
|
|
{
|
|
{
|
|
|
//act on key down if marketplace windows is not already opened
|
|
//act on key down if marketplace windows is not already opened
|
|
|
- if(key.state != SDL_PRESSED || GH.topInt()->type & BLOCK_ADV_HOTKEYS)
|
|
|
|
|
|
|
+ if(GH.topInt()->type & BLOCK_ADV_HOTKEYS)
|
|
|
return;
|
|
return;
|
|
|
|
|
|
|
|
- if(LOCPLINT->ctrlPressed()) //CTRL + T => open marketplace
|
|
|
|
|
|
|
+ if(GH.isKeyboardCtrlDown()) //CTRL + T => open marketplace
|
|
|
{
|
|
{
|
|
|
//check if we have any marketplace
|
|
//check if we have any marketplace
|
|
|
const CGTownInstance *townWithMarket = nullptr;
|
|
const CGTownInstance *townWithMarket = nullptr;
|
|
@@ -841,37 +860,29 @@ void CAdvMapInt::keyPressed(const SDL_KeyboardEvent & key)
|
|
|
}
|
|
}
|
|
|
default:
|
|
default:
|
|
|
{
|
|
{
|
|
|
- static const int3 directions[] = { int3(-1, +1, 0), int3(0, +1, 0), int3(+1, +1, 0),
|
|
|
|
|
- int3(-1, 0, 0), int3(0, 0, 0), int3(+1, 0, 0),
|
|
|
|
|
- int3(-1, -1, 0), int3(0, -1, 0), int3(+1, -1, 0) };
|
|
|
|
|
|
|
+ auto direction = keyToMoveDirection(key);
|
|
|
|
|
|
|
|
- //numpad arrow
|
|
|
|
|
- if(CGuiHandler::isArrowKey(k))
|
|
|
|
|
- k = CGuiHandler::arrowToNum(k);
|
|
|
|
|
|
|
+ if (!direction)
|
|
|
|
|
+ return;
|
|
|
|
|
|
|
|
- k -= SDLK_KP_1;
|
|
|
|
|
|
|
+ ui8 Dir = (direction->x<0 ? LEFT : 0) |
|
|
|
|
|
+ (direction->x>0 ? RIGHT : 0) |
|
|
|
|
|
+ (direction->y<0 ? UP : 0) |
|
|
|
|
|
+ (direction->y>0 ? DOWN : 0) ;
|
|
|
|
|
|
|
|
- if(k < 0 || k > 8)
|
|
|
|
|
- return;
|
|
|
|
|
|
|
+ scrollingDir |= Dir;
|
|
|
|
|
|
|
|
- if (!CGI->mh->canStartHeroMovement())
|
|
|
|
|
|
|
+ //ctrl makes arrow move screen, not hero
|
|
|
|
|
+ if(GH.isKeyboardCtrlDown())
|
|
|
return;
|
|
return;
|
|
|
|
|
|
|
|
- int3 dir = directions[k];
|
|
|
|
|
-
|
|
|
|
|
- if(!isActive() || LOCPLINT->ctrlPressed())//ctrl makes arrow move screen, not hero
|
|
|
|
|
- {
|
|
|
|
|
- Dir = (dir.x<0 ? LEFT : 0) |
|
|
|
|
|
- (dir.x>0 ? RIGHT : 0) |
|
|
|
|
|
- (dir.y<0 ? UP : 0) |
|
|
|
|
|
- (dir.y>0 ? DOWN : 0) ;
|
|
|
|
|
- break;
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ if(!h || !isActive())
|
|
|
|
|
+ return;
|
|
|
|
|
|
|
|
- if(!h || key.state != SDL_PRESSED)
|
|
|
|
|
- break;
|
|
|
|
|
|
|
+ if (!CGI->mh->canStartHeroMovement())
|
|
|
|
|
+ return;
|
|
|
|
|
|
|
|
- if(k == 4)
|
|
|
|
|
|
|
+ if(*direction == Point(0,0))
|
|
|
{
|
|
{
|
|
|
centerOn(h);
|
|
centerOn(h);
|
|
|
return;
|
|
return;
|
|
@@ -879,7 +890,7 @@ void CAdvMapInt::keyPressed(const SDL_KeyboardEvent & key)
|
|
|
|
|
|
|
|
CGPath &path = LOCPLINT->paths[h];
|
|
CGPath &path = LOCPLINT->paths[h];
|
|
|
terrain.currentPath = &path;
|
|
terrain.currentPath = &path;
|
|
|
- int3 dst = h->visitablePos() + dir;
|
|
|
|
|
|
|
+ int3 dst = h->visitablePos() + int3(direction->x, direction->y, 0);
|
|
|
if(dst != verifyPos(dst) || !LOCPLINT->cb->getPathsInfo(h)->getPath(path, dst))
|
|
if(dst != verifyPos(dst) || !LOCPLINT->cb->getPathsInfo(h)->getPath(path, dst))
|
|
|
{
|
|
{
|
|
|
terrain.currentPath = nullptr;
|
|
terrain.currentPath = nullptr;
|
|
@@ -895,13 +906,29 @@ void CAdvMapInt::keyPressed(const SDL_KeyboardEvent & key)
|
|
|
|
|
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
- if(Dir && key.state == SDL_PRESSED //arrow is pressed
|
|
|
|
|
- && LOCPLINT->ctrlPressed()
|
|
|
|
|
- )
|
|
|
|
|
- scrollingDir |= Dir;
|
|
|
|
|
- else
|
|
|
|
|
- scrollingDir &= ~Dir;
|
|
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+boost::optional<Point> CAdvMapInt::keyToMoveDirection(const SDL_Keycode & key)
|
|
|
|
|
+{
|
|
|
|
|
+ switch (key) {
|
|
|
|
|
+ case SDLK_DOWN: return Point( 0, +1);
|
|
|
|
|
+ case SDLK_LEFT: return Point(-1, 0);
|
|
|
|
|
+ case SDLK_RIGHT: return Point(+1, 0);
|
|
|
|
|
+ case SDLK_UP: return Point( 0, -1);
|
|
|
|
|
+
|
|
|
|
|
+ case SDLK_KP_1: return Point(-1, +1);
|
|
|
|
|
+ case SDLK_KP_2: return Point( 0, +1);
|
|
|
|
|
+ case SDLK_KP_3: return Point(+1, +1);
|
|
|
|
|
+ case SDLK_KP_4: return Point(-1, 0);
|
|
|
|
|
+ case SDLK_KP_5: return Point( 0, 0);
|
|
|
|
|
+ case SDLK_KP_6: return Point(+1, 0);
|
|
|
|
|
+ case SDLK_KP_7: return Point(-1, -1);
|
|
|
|
|
+ case SDLK_KP_8: return Point( 0, -1);
|
|
|
|
|
+ case SDLK_KP_9: return Point(+1, -1);
|
|
|
|
|
+ }
|
|
|
|
|
+ return boost::none;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
void CAdvMapInt::handleRightClick(std::string text, tribool down)
|
|
void CAdvMapInt::handleRightClick(std::string text, tribool down)
|
|
|
{
|
|
{
|
|
|
if(down)
|
|
if(down)
|
|
@@ -972,7 +999,7 @@ void CAdvMapInt::select(const CArmedInstance *sel, bool centerView)
|
|
|
heroList.redraw();
|
|
heroList.redraw();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-void CAdvMapInt::mouseMoved( const SDL_MouseMotionEvent & sEvent )
|
|
|
|
|
|
|
+void CAdvMapInt::mouseMoved( const Point & cursorPosition )
|
|
|
{
|
|
{
|
|
|
#if defined(VCMI_ANDROID) || defined(VCMI_IOS)
|
|
#if defined(VCMI_ANDROID) || defined(VCMI_IOS)
|
|
|
if(swipeEnabled)
|
|
if(swipeEnabled)
|
|
@@ -981,9 +1008,9 @@ void CAdvMapInt::mouseMoved( const SDL_MouseMotionEvent & sEvent )
|
|
|
// adventure map scrolling with mouse
|
|
// adventure map scrolling with mouse
|
|
|
// currently disabled in world view mode (as it is in OH3), but should work correctly if mode check is removed
|
|
// currently disabled in world view mode (as it is in OH3), but should work correctly if mode check is removed
|
|
|
// don't scroll if there is no window in focus - these events don't seem to correspond to the actual mouse movement
|
|
// don't scroll if there is no window in focus - these events don't seem to correspond to the actual mouse movement
|
|
|
- if(!CSDL_Ext::isCtrlKeyDown() && isActive() && sEvent.windowID != 0 && mode == EAdvMapMode::NORMAL)
|
|
|
|
|
|
|
+ if(!GH.isKeyboardCtrlDown() && isActive() && mode == EAdvMapMode::NORMAL)
|
|
|
{
|
|
{
|
|
|
- if(sEvent.x<15)
|
|
|
|
|
|
|
+ if(cursorPosition.x<15)
|
|
|
{
|
|
{
|
|
|
scrollingDir |= LEFT;
|
|
scrollingDir |= LEFT;
|
|
|
}
|
|
}
|
|
@@ -991,7 +1018,7 @@ void CAdvMapInt::mouseMoved( const SDL_MouseMotionEvent & sEvent )
|
|
|
{
|
|
{
|
|
|
scrollingDir &= ~LEFT;
|
|
scrollingDir &= ~LEFT;
|
|
|
}
|
|
}
|
|
|
- if(sEvent.x>screen->w-15)
|
|
|
|
|
|
|
+ if(cursorPosition.x > GH.screenDimensions().x - 15)
|
|
|
{
|
|
{
|
|
|
scrollingDir |= RIGHT;
|
|
scrollingDir |= RIGHT;
|
|
|
}
|
|
}
|
|
@@ -999,7 +1026,7 @@ void CAdvMapInt::mouseMoved( const SDL_MouseMotionEvent & sEvent )
|
|
|
{
|
|
{
|
|
|
scrollingDir &= ~RIGHT;
|
|
scrollingDir &= ~RIGHT;
|
|
|
}
|
|
}
|
|
|
- if(sEvent.y<15)
|
|
|
|
|
|
|
+ if(cursorPosition.y<15)
|
|
|
{
|
|
{
|
|
|
scrollingDir |= UP;
|
|
scrollingDir |= UP;
|
|
|
}
|
|
}
|
|
@@ -1007,7 +1034,7 @@ void CAdvMapInt::mouseMoved( const SDL_MouseMotionEvent & sEvent )
|
|
|
{
|
|
{
|
|
|
scrollingDir &= ~UP;
|
|
scrollingDir &= ~UP;
|
|
|
}
|
|
}
|
|
|
- if(sEvent.y>screen->h-15)
|
|
|
|
|
|
|
+ if(cursorPosition.y > GH.screenDimensions().y - 15)
|
|
|
{
|
|
{
|
|
|
scrollingDir |= DOWN;
|
|
scrollingDir |= DOWN;
|
|
|
}
|
|
}
|
|
@@ -1246,7 +1273,7 @@ void CAdvMapInt::tileHovered(const int3 &mapPos)
|
|
|
const CGPathNode * pathNode = LOCPLINT->cb->getPathsInfo(hero)->getPathInfo(mapPos);
|
|
const CGPathNode * pathNode = LOCPLINT->cb->getPathsInfo(hero)->getPathInfo(mapPos);
|
|
|
assert(pathNode);
|
|
assert(pathNode);
|
|
|
|
|
|
|
|
- if(LOCPLINT->altPressed() && pathNode->reachable()) //overwrite status bar text with movement info
|
|
|
|
|
|
|
+ if(GH.isKeyboardAltDown() && pathNode->reachable()) //overwrite status bar text with movement info
|
|
|
{
|
|
{
|
|
|
ShowMoveDetailsInStatusbar(*hero, *pathNode);
|
|
ShowMoveDetailsInStatusbar(*hero, *pathNode);
|
|
|
}
|
|
}
|