mirror of
https://github.com/vcmi/vcmi.git
synced 2025-02-03 13:01:33 +02:00
Declare ownership of CCursorHandler::dndObject
# Conflicts: # AI/FuzzyLite # client/gui/CGuiHandler.cpp
This commit is contained in:
parent
a8d25ea7b2
commit
9423555015
@ -27,7 +27,7 @@ void CCursorHandler::initCursor()
|
||||
|
||||
help = CSDL_Ext::newSurface(40,40);
|
||||
//No blending. Ensure, that we are copying pixels during "screen restore draw"
|
||||
SDL_SetSurfaceBlendMode(help,SDL_BLENDMODE_NONE);
|
||||
SDL_SetSurfaceBlendMode(help,SDL_BLENDMODE_NONE);
|
||||
SDL_ShowCursor(SDL_DISABLE);
|
||||
|
||||
changeGraphic(ECursor::ADVENTURE, 0);
|
||||
@ -55,12 +55,9 @@ void CCursorHandler::changeGraphic(ECursor::ECursorTypes type, int index)
|
||||
}
|
||||
}
|
||||
|
||||
void CCursorHandler::dragAndDropCursor(CAnimImage * object)
|
||||
void CCursorHandler::dragAndDropCursor(std::unique_ptr<CAnimImage> object)
|
||||
{
|
||||
if (dndObject)
|
||||
delete dndObject;
|
||||
|
||||
dndObject = object;
|
||||
dndObject = std::move(object);
|
||||
}
|
||||
|
||||
void CCursorHandler::cursorMove(const int & x, const int & y)
|
||||
@ -233,12 +230,10 @@ void CCursorHandler::render()
|
||||
drawRestored();
|
||||
}
|
||||
|
||||
|
||||
CCursorHandler::~CCursorHandler()
|
||||
{
|
||||
if(help)
|
||||
SDL_FreeSurface(help);
|
||||
|
||||
delete currentCursor;
|
||||
delete dndObject;
|
||||
}
|
||||
|
@ -17,18 +17,19 @@ namespace ECursor
|
||||
enum ECursorTypes { ADVENTURE, COMBAT, DEFAULT, SPELLBOOK };
|
||||
|
||||
enum EBattleCursors { COMBAT_BLOCKED, COMBAT_MOVE, COMBAT_FLY, COMBAT_SHOOT,
|
||||
COMBAT_HERO, COMBAT_QUERY, COMBAT_POINTER,
|
||||
COMBAT_HERO, COMBAT_QUERY, COMBAT_POINTER,
|
||||
//various attack frames
|
||||
COMBAT_SHOOT_PENALTY = 15, COMBAT_SHOOT_CATAPULT, COMBAT_HEAL,
|
||||
COMBAT_SACRIFICE, COMBAT_TELEPORT};
|
||||
}
|
||||
|
||||
/// handles mouse cursor
|
||||
class CCursorHandler
|
||||
class CCursorHandler
|
||||
{
|
||||
SDL_Surface * help;
|
||||
CAnimImage * currentCursor;
|
||||
CAnimImage * dndObject; //if set, overrides currentCursor
|
||||
|
||||
std::unique_ptr<CAnimImage> dndObject; //if set, overrides currentCursor
|
||||
bool showing;
|
||||
|
||||
/// Draw cursor preserving original image below cursor
|
||||
@ -37,7 +38,7 @@ class CCursorHandler
|
||||
void drawRestored();
|
||||
/// Simple draw cursor
|
||||
void draw(SDL_Surface *to);
|
||||
|
||||
|
||||
public:
|
||||
/// position of cursor
|
||||
int xpos, ypos;
|
||||
@ -58,8 +59,8 @@ public:
|
||||
* @param image Image to replace cursor with or nullptr to use the normal
|
||||
* cursor. CursorHandler takes ownership of object
|
||||
*/
|
||||
void dragAndDropCursor (CAnimImage * image);
|
||||
|
||||
void dragAndDropCursor (std::unique_ptr<CAnimImage> image);
|
||||
|
||||
void render();
|
||||
|
||||
void shiftPos( int &x, int &y );
|
||||
|
@ -459,8 +459,7 @@ void CGuiHandler::renderFrame()
|
||||
// draw the mouse cursor and update the screen
|
||||
CCS->curh->render();
|
||||
|
||||
if(0 != SDL_RenderCopy(mainRenderer, screenTexture, nullptr, nullptr))
|
||||
logGlobal->error("%s SDL_RenderCopy %s", __FUNCTION__, SDL_GetError());
|
||||
SDL_RenderCopy(mainRenderer, screenTexture, nullptr, nullptr);
|
||||
|
||||
SDL_RenderPresent(mainRenderer);
|
||||
}
|
||||
|
@ -290,7 +290,7 @@ void CHeroArtPlace::select ()
|
||||
}
|
||||
}
|
||||
|
||||
CCS->curh->dragAndDropCursor(new CAnimImage("artifact", ourArt->artType->iconIndex));
|
||||
CCS->curh->dragAndDropCursor(make_unique<CAnimImage>("artifact", ourArt->artType->iconIndex));
|
||||
ourOwner->commonInfo->src.setTo(this, false);
|
||||
ourOwner->markPossibleSlots(ourArt);
|
||||
|
||||
@ -766,7 +766,7 @@ void CArtifactsOfHero::artifactMoved(const ArtifactLocation &src, const Artifact
|
||||
commonInfo->src.art = dst.getArt();
|
||||
commonInfo->src.slotID = dst.slot;
|
||||
assert(commonInfo->src.AOH);
|
||||
CCS->curh->dragAndDropCursor(new CAnimImage("artifact", dst.getArt()->artType->iconIndex));
|
||||
CCS->curh->dragAndDropCursor(make_unique<CAnimImage>("artifact", dst.getArt()->artType->iconIndex));
|
||||
markPossibleSlots(dst.getArt());
|
||||
}
|
||||
}
|
||||
|
@ -187,7 +187,7 @@ void CTradeWindow::CTradeableItem::clickLeft(tribool down, bool previousState)
|
||||
aw->arts->markPossibleSlots(art);
|
||||
|
||||
//aw->arts->commonInfo->dst.AOH = aw->arts;
|
||||
CCS->curh->dragAndDropCursor(new CAnimImage("artifact", art->artType->iconIndex));
|
||||
CCS->curh->dragAndDropCursor(make_unique<CAnimImage>("artifact", art->artType->iconIndex));
|
||||
|
||||
aw->arts->artifactsOnAltar.erase(art);
|
||||
setID(-1);
|
||||
|
Loading…
x
Reference in New Issue
Block a user