Fix pastes not being centred on the cursor
This commit hopefully concludes hammering at old pasting code.
This commit is contained in:
parent
6fb893a8de
commit
eea0c54a36
@ -214,9 +214,7 @@ GameView::GameView():
|
|||||||
selectPoint1(0, 0),
|
selectPoint1(0, 0),
|
||||||
selectPoint2(0, 0),
|
selectPoint2(0, 0),
|
||||||
currentMouse(0, 0),
|
currentMouse(0, 0),
|
||||||
mousePosition(0, 0),
|
mousePosition(0, 0)
|
||||||
placeSaveThumb(nullptr),
|
|
||||||
placeSaveOffset(0, 0)
|
|
||||||
{
|
{
|
||||||
|
|
||||||
int currentX = 1;
|
int currentX = 1;
|
||||||
@ -1181,7 +1179,16 @@ void GameView::OnMouseDown(int x, int y, unsigned button)
|
|||||||
|
|
||||||
Vec2<int> GameView::PlaceSavePos() const
|
Vec2<int> GameView::PlaceSavePos() const
|
||||||
{
|
{
|
||||||
return c->NormaliseBlockCoord(selectPoint2 + placeSaveOffset * CELL + Vec2(1, 1) * CELL / 2);
|
auto [ trQuoX, trRemX ] = floorDiv(placeSaveTranslate.X, CELL);
|
||||||
|
auto [ trQuoY, trRemY ] = floorDiv(placeSaveTranslate.Y, CELL);
|
||||||
|
auto usefulSize = placeSaveThumb->Size();
|
||||||
|
if (trRemX) usefulSize.X -= CELL;
|
||||||
|
if (trRemY) usefulSize.Y -= CELL;
|
||||||
|
auto cursorCell = (usefulSize - Vec2{ CELL, CELL }) / 2 - Vec2{ trQuoX, trQuoY } * CELL; // stamp coordinates
|
||||||
|
auto unaligned = selectPoint2 - cursorCell;
|
||||||
|
auto quoX = floorDiv(unaligned.X, CELL).first;
|
||||||
|
auto quoY = floorDiv(unaligned.Y, CELL).first;
|
||||||
|
return { quoX, quoY };
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameView::OnMouseUp(int x, int y, unsigned button)
|
void GameView::OnMouseUp(int x, int y, unsigned button)
|
||||||
@ -1204,7 +1211,7 @@ void GameView::OnMouseUp(int x, int y, unsigned button)
|
|||||||
{
|
{
|
||||||
if (placeSaveThumb && y <= WINDOWH-BARSIZE)
|
if (placeSaveThumb && y <= WINDOWH-BARSIZE)
|
||||||
{
|
{
|
||||||
c->PlaceSave(PlaceSavePos() / CELL);
|
c->PlaceSave(PlaceSavePos());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -1942,13 +1949,6 @@ void GameView::NotifyTransformedPlaceSaveChanged(GameModel *sender)
|
|||||||
if (sender->GetTransformedPlaceSave())
|
if (sender->GetTransformedPlaceSave())
|
||||||
{
|
{
|
||||||
placeSaveThumb = SaveRenderer::Ref().Render(sender->GetTransformedPlaceSave(), true, true, sender->GetRenderer());
|
placeSaveThumb = SaveRenderer::Ref().Render(sender->GetTransformedPlaceSave(), true, true, sender->GetRenderer());
|
||||||
auto [ quoX, remX ] = floorDiv(placeSaveTranslate.X, CELL);
|
|
||||||
auto [ quoY, remY ] = floorDiv(placeSaveTranslate.Y, CELL);
|
|
||||||
placeSaveOffset = Vec2{ quoX, quoY };
|
|
||||||
auto usefulSize = placeSaveThumb->Size() / CELL;
|
|
||||||
if (remX) usefulSize.X -= 1;
|
|
||||||
if (remY) usefulSize.Y -= 1;
|
|
||||||
placeSaveOffset -= usefulSize / 2;
|
|
||||||
selectMode = PlaceSave;
|
selectMode = PlaceSave;
|
||||||
selectPoint2 = mousePosition;
|
selectPoint2 = mousePosition;
|
||||||
}
|
}
|
||||||
@ -2164,7 +2164,7 @@ void GameView::OnDraw()
|
|||||||
{
|
{
|
||||||
if(placeSaveThumb && selectPoint2.X!=-1)
|
if(placeSaveThumb && selectPoint2.X!=-1)
|
||||||
{
|
{
|
||||||
auto rect = RectSized(PlaceSavePos(), placeSaveThumb->Size());
|
auto rect = RectSized(PlaceSavePos() * CELL, placeSaveThumb->Size());
|
||||||
ren->BlendImage(placeSaveThumb->Data(), 0x80, rect);
|
ren->BlendImage(placeSaveThumb->Data(), 0x80, rect);
|
||||||
ren->XorDottedRect(rect);
|
ren->XorDottedRect(rect);
|
||||||
}
|
}
|
||||||
|
@ -118,7 +118,6 @@ private:
|
|||||||
ui::Point mousePosition;
|
ui::Point mousePosition;
|
||||||
|
|
||||||
std::unique_ptr<VideoBuffer> placeSaveThumb;
|
std::unique_ptr<VideoBuffer> placeSaveThumb;
|
||||||
ui::Point placeSaveOffset;
|
|
||||||
Mat2<int> placeSaveTransform = Mat2<int>::Identity;
|
Mat2<int> placeSaveTransform = Mat2<int>::Identity;
|
||||||
Vec2<int> placeSaveTranslate = Vec2<int>::Zero;
|
Vec2<int> placeSaveTranslate = Vec2<int>::Zero;
|
||||||
void TranslateSave(Vec2<int> addToTranslate);
|
void TranslateSave(Vec2<int> addToTranslate);
|
||||||
@ -163,8 +162,6 @@ public:
|
|||||||
bool AltBehaviour(){ return altBehaviour; }
|
bool AltBehaviour(){ return altBehaviour; }
|
||||||
SelectMode GetSelectMode() { return selectMode; }
|
SelectMode GetSelectMode() { return selectMode; }
|
||||||
void BeginStampSelection();
|
void BeginStampSelection();
|
||||||
ui::Point GetPlaceSaveOffset() { return placeSaveOffset; }
|
|
||||||
void SetPlaceSaveOffset(ui::Point offset) { placeSaveOffset = offset; }
|
|
||||||
ByteString TakeScreenshot(int captureUI, int fileType);
|
ByteString TakeScreenshot(int captureUI, int fileType);
|
||||||
int Record(bool record);
|
int Record(bool record);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user