mirror of
https://github.com/The-Powder-Toy/The-Powder-Toy.git
synced 2025-08-29 10:49:53 +02:00
signs can be moved onto the zoom window, fixes #89
This commit is contained in:
@@ -379,17 +379,7 @@ ui::Point GameController::PointTranslate(ui::Point point)
|
|||||||
if(point.X < 0)
|
if(point.X < 0)
|
||||||
point.X = 0;
|
point.X = 0;
|
||||||
|
|
||||||
bool zoomEnabled = gameModel->GetZoomEnabled();
|
return gameModel->AdjustZoomCoords(point);
|
||||||
if(!zoomEnabled)
|
|
||||||
return point;
|
|
||||||
//If we try to draw inside the zoom window, normalise the coordinates
|
|
||||||
int zoomFactor = gameModel->GetZoomFactor();
|
|
||||||
ui::Point zoomWindowPosition = gameModel->GetZoomWindowPosition();
|
|
||||||
ui::Point zoomWindowSize = ui::Point(gameModel->GetZoomSize()*zoomFactor, gameModel->GetZoomSize()*zoomFactor);
|
|
||||||
|
|
||||||
if(point.X >= zoomWindowPosition.X && point.X >= zoomWindowPosition.Y && point.X <= zoomWindowPosition.X+zoomWindowSize.X && point.Y <= zoomWindowPosition.Y+zoomWindowSize.Y)
|
|
||||||
return ((point-zoomWindowPosition)/gameModel->GetZoomFactor())+gameModel->GetZoomPosition();
|
|
||||||
return point;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ui::Point GameController::NormaliseBlockCoord(ui::Point point)
|
ui::Point GameController::NormaliseBlockCoord(ui::Point point)
|
||||||
|
@@ -326,7 +326,7 @@ void GameModel::BuildMenus()
|
|||||||
//Add special sign and prop tools
|
//Add special sign and prop tools
|
||||||
menuList[SC_TOOL]->AddTool(new WindTool(0, "WIND", "Creates air movement.", 64, 64, 64, "DEFAULT_UI_WIND"));
|
menuList[SC_TOOL]->AddTool(new WindTool(0, "WIND", "Creates air movement.", 64, 64, 64, "DEFAULT_UI_WIND"));
|
||||||
menuList[SC_TOOL]->AddTool(new PropertyTool());
|
menuList[SC_TOOL]->AddTool(new PropertyTool());
|
||||||
menuList[SC_TOOL]->AddTool(new SignTool());
|
menuList[SC_TOOL]->AddTool(new SignTool(this));
|
||||||
menuList[SC_TOOL]->AddTool(new SampleTool(this));
|
menuList[SC_TOOL]->AddTool(new SampleTool(this));
|
||||||
|
|
||||||
//Add decoration tools to menu
|
//Add decoration tools to menu
|
||||||
@@ -694,6 +694,20 @@ ui::Point GameModel::GetZoomPosition()
|
|||||||
return ren->zoomScopePosition;
|
return ren->zoomScopePosition;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ui::Point GameModel::AdjustZoomCoords(ui::Point position)
|
||||||
|
{
|
||||||
|
if (!GetZoomEnabled())
|
||||||
|
return position;
|
||||||
|
|
||||||
|
int zoomFactor = GetZoomFactor();
|
||||||
|
ui::Point zoomWindowPosition = GetZoomWindowPosition();
|
||||||
|
ui::Point zoomWindowSize = ui::Point(GetZoomSize()*zoomFactor, GetZoomSize()*zoomFactor);
|
||||||
|
|
||||||
|
if (position.X >= zoomWindowPosition.X && position.X >= zoomWindowPosition.Y && position.X <= zoomWindowPosition.X+zoomWindowSize.X && position.Y <= zoomWindowPosition.Y+zoomWindowSize.Y)
|
||||||
|
return ((position-zoomWindowPosition)/GetZoomFactor())+GetZoomPosition();
|
||||||
|
return position;
|
||||||
|
}
|
||||||
|
|
||||||
void GameModel::SetZoomWindowPosition(ui::Point position)
|
void GameModel::SetZoomWindowPosition(ui::Point position)
|
||||||
{
|
{
|
||||||
ren->zoomWindowPosition = position;
|
ren->zoomWindowPosition = position;
|
||||||
|
@@ -182,6 +182,7 @@ public:
|
|||||||
int GetZoomFactor();
|
int GetZoomFactor();
|
||||||
void SetZoomPosition(ui::Point position);
|
void SetZoomPosition(ui::Point position);
|
||||||
ui::Point GetZoomPosition();
|
ui::Point GetZoomPosition();
|
||||||
|
ui::Point AdjustZoomCoords(ui::Point position);
|
||||||
void SetZoomWindowPosition(ui::Point position);
|
void SetZoomWindowPosition(ui::Point position);
|
||||||
ui::Point GetZoomWindowPosition();
|
ui::Point GetZoomWindowPosition();
|
||||||
void SetStamp(GameSave * newStamp);
|
void SetStamp(GameSave * newStamp);
|
||||||
|
@@ -7,6 +7,7 @@
|
|||||||
#include "gui/interface/Label.h"
|
#include "gui/interface/Label.h"
|
||||||
#include "gui/interface/Textbox.h"
|
#include "gui/interface/Textbox.h"
|
||||||
#include "gui/interface/DropDown.h"
|
#include "gui/interface/DropDown.h"
|
||||||
|
#include "gui/game/GameModel.h"
|
||||||
|
|
||||||
class SignWindow: public ui::Window
|
class SignWindow: public ui::Window
|
||||||
{
|
{
|
||||||
@@ -222,12 +223,13 @@ void SignWindow::DoMouseMove(int x, int y, int dx, int dy) {
|
|||||||
ui::Window::DoMouseMove(x, y, dx, dy);
|
ui::Window::DoMouseMove(x, y, dx, dy);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if(x < XRES && y < YRES)
|
ui::Point pos = tool->gameModel->AdjustZoomCoords(ui::Point(x, y));
|
||||||
|
if(pos.X < XRES && pos.Y < YRES)
|
||||||
{
|
{
|
||||||
movingSign->x = x;
|
movingSign->x = pos.X;
|
||||||
movingSign->y = y;
|
movingSign->y = pos.Y;
|
||||||
signPosition.X = x;
|
signPosition.X = pos.X;
|
||||||
signPosition.Y = y;
|
signPosition.Y = pos.Y;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -42,11 +42,15 @@ public:
|
|||||||
int colRed, colBlue, colGreen;
|
int colRed, colBlue, colGreen;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class GameModel;
|
||||||
|
|
||||||
class SignTool: public Tool
|
class SignTool: public Tool
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
SignTool():
|
GameModel * gameModel;
|
||||||
Tool(0, "SIGN", "Sign. Displays text. Click on a sign to edit it or anywhere else to place a new one.", 0, 0, 0, "DEFAULT_UI_SIGN", SignTool::GetIcon)
|
SignTool(GameModel *model):
|
||||||
|
Tool(0, "SIGN", "Sign. Displays text. Click on a sign to edit it or anywhere else to place a new one.", 0, 0, 0, "DEFAULT_UI_SIGN", SignTool::GetIcon),
|
||||||
|
gameModel(model)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
static VideoBuffer * GetIcon(int toolID, int width, int height);
|
static VideoBuffer * GetIcon(int toolID, int width, int height);
|
||||||
@@ -58,8 +62,6 @@ public:
|
|||||||
virtual void DrawFill(Simulation * sim, Brush * brush, ui::Point position) { }
|
virtual void DrawFill(Simulation * sim, Brush * brush, ui::Point position) { }
|
||||||
};
|
};
|
||||||
|
|
||||||
class GameModel;
|
|
||||||
|
|
||||||
class SampleTool: public Tool
|
class SampleTool: public Tool
|
||||||
{
|
{
|
||||||
GameModel * gameModel;
|
GameModel * gameModel;
|
||||||
|
Reference in New Issue
Block a user