Wall brush, fixes #63
This commit is contained in:
parent
cd051924d9
commit
3499cb3035
@ -276,6 +276,7 @@ void GameController::DrawRect(int toolSelection, ui::Point point1, ui::Point poi
|
|||||||
{
|
{
|
||||||
Simulation * sim = gameModel->GetSimulation();
|
Simulation * sim = gameModel->GetSimulation();
|
||||||
Tool * activeTool = gameModel->GetActiveTool(toolSelection);
|
Tool * activeTool = gameModel->GetActiveTool(toolSelection);
|
||||||
|
gameModel->SetLastTool(activeTool);
|
||||||
Brush * cBrush = gameModel->GetBrush();
|
Brush * cBrush = gameModel->GetBrush();
|
||||||
if(!activeTool || !cBrush)
|
if(!activeTool || !cBrush)
|
||||||
return;
|
return;
|
||||||
@ -287,6 +288,7 @@ void GameController::DrawLine(int toolSelection, ui::Point point1, ui::Point poi
|
|||||||
{
|
{
|
||||||
Simulation * sim = gameModel->GetSimulation();
|
Simulation * sim = gameModel->GetSimulation();
|
||||||
Tool * activeTool = gameModel->GetActiveTool(toolSelection);
|
Tool * activeTool = gameModel->GetActiveTool(toolSelection);
|
||||||
|
gameModel->SetLastTool(activeTool);
|
||||||
Brush * cBrush = gameModel->GetBrush();
|
Brush * cBrush = gameModel->GetBrush();
|
||||||
if(!activeTool || !cBrush)
|
if(!activeTool || !cBrush)
|
||||||
return;
|
return;
|
||||||
@ -298,6 +300,7 @@ void GameController::DrawFill(int toolSelection, ui::Point point)
|
|||||||
{
|
{
|
||||||
Simulation * sim = gameModel->GetSimulation();
|
Simulation * sim = gameModel->GetSimulation();
|
||||||
Tool * activeTool = gameModel->GetActiveTool(toolSelection);
|
Tool * activeTool = gameModel->GetActiveTool(toolSelection);
|
||||||
|
gameModel->SetLastTool(activeTool);
|
||||||
Brush * cBrush = gameModel->GetBrush();
|
Brush * cBrush = gameModel->GetBrush();
|
||||||
if(!activeTool || !cBrush)
|
if(!activeTool || !cBrush)
|
||||||
return;
|
return;
|
||||||
@ -309,6 +312,7 @@ void GameController::DrawPoints(int toolSelection, queue<ui::Point*> & pointQueu
|
|||||||
{
|
{
|
||||||
Simulation * sim = gameModel->GetSimulation();
|
Simulation * sim = gameModel->GetSimulation();
|
||||||
Tool * activeTool = gameModel->GetActiveTool(toolSelection);
|
Tool * activeTool = gameModel->GetActiveTool(toolSelection);
|
||||||
|
gameModel->SetLastTool(activeTool);
|
||||||
Brush * cBrush = gameModel->GetBrush();
|
Brush * cBrush = gameModel->GetBrush();
|
||||||
if(!activeTool || !cBrush)
|
if(!activeTool || !cBrush)
|
||||||
{
|
{
|
||||||
@ -701,6 +705,7 @@ void GameController::SetActiveTool(int toolSelection, Tool * tool)
|
|||||||
{
|
{
|
||||||
gameModel->SetActiveTool(toolSelection, tool);
|
gameModel->SetActiveTool(toolSelection, tool);
|
||||||
gameModel->GetRenderer()->gravityZonesEnabled = false;
|
gameModel->GetRenderer()->gravityZonesEnabled = false;
|
||||||
|
gameModel->SetLastTool(tool);
|
||||||
for(int i = 0; i < 3; i++)
|
for(int i = 0; i < 3; i++)
|
||||||
{
|
{
|
||||||
if(gameModel->GetActiveTool(i) == gameModel->GetMenuList().at(SC_WALL)->GetToolList().at(WL_GRAV))
|
if(gameModel->GetActiveTool(i) == gameModel->GetMenuList().at(SC_WALL)->GetToolList().at(WL_GRAV))
|
||||||
|
@ -239,6 +239,7 @@ void GameModel::BuildMenus()
|
|||||||
activeTools[0] = menuList[SC_POWDERS]->GetToolList()[0];
|
activeTools[0] = menuList[SC_POWDERS]->GetToolList()[0];
|
||||||
activeTools[1] = menuList[SC_SPECIAL]->GetToolList()[0];
|
activeTools[1] = menuList[SC_SPECIAL]->GetToolList()[0];
|
||||||
activeTools[2] = NULL;
|
activeTools[2] = NULL;
|
||||||
|
lastTool = activeTools[0];
|
||||||
|
|
||||||
//Set default menu
|
//Set default menu
|
||||||
activeMenu = menuList[SC_POWDERS];
|
activeMenu = menuList[SC_POWDERS];
|
||||||
@ -247,6 +248,7 @@ void GameModel::BuildMenus()
|
|||||||
notifyMenuListChanged();
|
notifyMenuListChanged();
|
||||||
notifyToolListChanged();
|
notifyToolListChanged();
|
||||||
notifyActiveToolsChanged();
|
notifyActiveToolsChanged();
|
||||||
|
notifyLastToolChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameModel::SetVote(int direction)
|
void GameModel::SetVote(int direction)
|
||||||
@ -293,6 +295,7 @@ void GameModel::AddObserver(GameView * observer){
|
|||||||
observer->NotifyColourSelectorVisibilityChanged(this);
|
observer->NotifyColourSelectorVisibilityChanged(this);
|
||||||
observer->NotifyColourSelectorColourChanged(this);
|
observer->NotifyColourSelectorColourChanged(this);
|
||||||
observer->NotifyQuickOptionsChanged(this);
|
observer->NotifyQuickOptionsChanged(this);
|
||||||
|
observer->NotifyLastToolChanged(this);
|
||||||
UpdateQuickOptions();
|
UpdateQuickOptions();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -429,6 +432,20 @@ User GameModel::GetUser()
|
|||||||
return currentUser;
|
return currentUser;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Tool * GameModel::GetLastTool()
|
||||||
|
{
|
||||||
|
return lastTool;
|
||||||
|
}
|
||||||
|
|
||||||
|
void GameModel::SetLastTool(Tool * newTool)
|
||||||
|
{
|
||||||
|
if(lastTool != newTool)
|
||||||
|
{
|
||||||
|
lastTool = newTool;
|
||||||
|
notifyLastToolChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void GameModel::SetZoomEnabled(bool enabled)
|
void GameModel::SetZoomEnabled(bool enabled)
|
||||||
{
|
{
|
||||||
ren->zoomEnabled = enabled;
|
ren->zoomEnabled = enabled;
|
||||||
@ -823,3 +840,11 @@ void GameModel::notifyQuickOptionsChanged()
|
|||||||
observers[i]->NotifyQuickOptionsChanged(this);
|
observers[i]->NotifyQuickOptionsChanged(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GameModel::notifyLastToolChanged()
|
||||||
|
{
|
||||||
|
for(int i = 0; i < observers.size(); i++)
|
||||||
|
{
|
||||||
|
observers[i]->NotifyLastToolChanged(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -51,6 +51,7 @@ private:
|
|||||||
SaveInfo * currentSave;
|
SaveInfo * currentSave;
|
||||||
Simulation * sim;
|
Simulation * sim;
|
||||||
Renderer * ren;
|
Renderer * ren;
|
||||||
|
Tool * lastTool;
|
||||||
Tool * activeTools[3];
|
Tool * activeTools[3];
|
||||||
User currentUser;
|
User currentUser;
|
||||||
bool colourSelector;
|
bool colourSelector;
|
||||||
@ -80,6 +81,7 @@ private:
|
|||||||
void notifyInfoTipChanged();
|
void notifyInfoTipChanged();
|
||||||
void notifyToolTipChanged();
|
void notifyToolTipChanged();
|
||||||
void notifyQuickOptionsChanged();
|
void notifyQuickOptionsChanged();
|
||||||
|
void notifyLastToolChanged();
|
||||||
public:
|
public:
|
||||||
GameModel();
|
GameModel();
|
||||||
~GameModel();
|
~GameModel();
|
||||||
@ -103,6 +105,9 @@ public:
|
|||||||
void SetToolStrength(float value);
|
void SetToolStrength(float value);
|
||||||
float GetToolStrength();
|
float GetToolStrength();
|
||||||
|
|
||||||
|
Tool * GetLastTool();
|
||||||
|
void SetLastTool(Tool * newTool);
|
||||||
|
|
||||||
void SetVote(int direction);
|
void SetVote(int direction);
|
||||||
SaveInfo * GetSave();
|
SaveInfo * GetSave();
|
||||||
Brush * GetBrush();
|
Brush * GetBrush();
|
||||||
|
@ -174,7 +174,8 @@ GameView::GameView():
|
|||||||
showHud(true),
|
showHud(true),
|
||||||
showDebug(false),
|
showDebug(false),
|
||||||
introText(2048),
|
introText(2048),
|
||||||
introTextMessage(introTextData)
|
introTextMessage(introTextData),
|
||||||
|
wallBrush(false)
|
||||||
{
|
{
|
||||||
|
|
||||||
int currentX = 1;
|
int currentX = 1;
|
||||||
@ -642,6 +643,18 @@ void GameView::NotifyActiveToolsChanged(GameModel * sender)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GameView::NotifyLastToolChanged(GameModel * sender)
|
||||||
|
{
|
||||||
|
if(sender->GetLastTool()->GetResolution() == CELL)
|
||||||
|
{
|
||||||
|
wallBrush = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
wallBrush = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void GameView::NotifyToolListChanged(GameModel * sender)
|
void GameView::NotifyToolListChanged(GameModel * sender)
|
||||||
{
|
{
|
||||||
//int currentY = YRES+MENUSIZE-36;
|
//int currentY = YRES+MENUSIZE-36;
|
||||||
@ -1637,22 +1650,29 @@ void GameView::OnDraw()
|
|||||||
if(selectMode == SelectNone && activeBrush && currentMouse.X > 0 && currentMouse.X < XRES && currentMouse.Y > 0 && currentMouse.Y < YRES)
|
if(selectMode == SelectNone && activeBrush && currentMouse.X > 0 && currentMouse.X < XRES && currentMouse.Y > 0 && currentMouse.Y < YRES)
|
||||||
{
|
{
|
||||||
ui::Point finalCurrentMouse = c->PointTranslate(currentMouse);
|
ui::Point finalCurrentMouse = c->PointTranslate(currentMouse);
|
||||||
|
ui::Point initialDrawPoint = drawPoint1;
|
||||||
|
|
||||||
|
if(wallBrush)
|
||||||
|
{
|
||||||
|
finalCurrentMouse = c->NormaliseBlockCoord(finalCurrentMouse);
|
||||||
|
initialDrawPoint = c->NormaliseBlockCoord(initialDrawPoint);
|
||||||
|
}
|
||||||
|
|
||||||
if(drawMode==DrawRect && isMouseDown)
|
if(drawMode==DrawRect && isMouseDown)
|
||||||
{
|
{
|
||||||
if(drawSnap)
|
if(drawSnap)
|
||||||
{
|
{
|
||||||
finalCurrentMouse = rectSnapCoords(c->PointTranslate(drawPoint1), finalCurrentMouse);
|
finalCurrentMouse = rectSnapCoords(c->PointTranslate(initialDrawPoint), finalCurrentMouse);
|
||||||
}
|
}
|
||||||
activeBrush->RenderRect(ren, c->PointTranslate(drawPoint1), finalCurrentMouse);
|
activeBrush->RenderRect(ren, c->PointTranslate(initialDrawPoint), finalCurrentMouse);
|
||||||
}
|
}
|
||||||
else if(drawMode==DrawLine && isMouseDown)
|
else if(drawMode==DrawLine && isMouseDown)
|
||||||
{
|
{
|
||||||
if(drawSnap)
|
if(drawSnap)
|
||||||
{
|
{
|
||||||
finalCurrentMouse = lineSnapCoords(c->PointTranslate(drawPoint1), finalCurrentMouse);
|
finalCurrentMouse = lineSnapCoords(c->PointTranslate(initialDrawPoint), finalCurrentMouse);
|
||||||
}
|
}
|
||||||
activeBrush->RenderLine(ren, c->PointTranslate(drawPoint1), finalCurrentMouse);
|
activeBrush->RenderLine(ren, c->PointTranslate(initialDrawPoint), finalCurrentMouse);
|
||||||
}
|
}
|
||||||
else if(drawMode==DrawFill)
|
else if(drawMode==DrawFill)
|
||||||
{
|
{
|
||||||
@ -1660,7 +1680,19 @@ void GameView::OnDraw()
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
activeBrush->RenderPoint(ren, finalCurrentMouse);
|
if(wallBrush)
|
||||||
|
{
|
||||||
|
ui::Point finalBrushRadius = c->NormaliseBlockCoord(activeBrush->GetRadius());
|
||||||
|
ren->xor_line(finalCurrentMouse.X-finalBrushRadius.X, finalCurrentMouse.Y-finalBrushRadius.Y, finalCurrentMouse.X+finalBrushRadius.X+CELL-1, finalCurrentMouse.Y-finalBrushRadius.Y);
|
||||||
|
ren->xor_line(finalCurrentMouse.X-finalBrushRadius.X, finalCurrentMouse.Y+finalBrushRadius.Y+CELL-1, finalCurrentMouse.X+finalBrushRadius.X+CELL-1, finalCurrentMouse.Y+finalBrushRadius.Y+CELL-1);
|
||||||
|
|
||||||
|
ren->xor_line(finalCurrentMouse.X-finalBrushRadius.X, finalCurrentMouse.Y-finalBrushRadius.Y+1, finalCurrentMouse.X-finalBrushRadius.X, finalCurrentMouse.Y+finalBrushRadius.Y+CELL-2);
|
||||||
|
ren->xor_line(finalCurrentMouse.X+finalBrushRadius.X+CELL-1, finalCurrentMouse.Y-finalBrushRadius.Y+1, finalCurrentMouse.X+finalBrushRadius.X+CELL-1, finalCurrentMouse.Y+finalBrushRadius.Y+CELL-2);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
activeBrush->RenderPoint(ren, finalCurrentMouse);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ren->RenderEnd();
|
ren->RenderEnd();
|
||||||
|
@ -43,6 +43,7 @@ private:
|
|||||||
bool altBehaviour;
|
bool altBehaviour;
|
||||||
bool showHud;
|
bool showHud;
|
||||||
bool showDebug;
|
bool showDebug;
|
||||||
|
bool wallBrush;
|
||||||
int introText;
|
int introText;
|
||||||
std::string introTextMessage;
|
std::string introTextMessage;
|
||||||
int toolIndex;
|
int toolIndex;
|
||||||
@ -144,6 +145,7 @@ public:
|
|||||||
void NotifyToolTipChanged(GameModel * sender);
|
void NotifyToolTipChanged(GameModel * sender);
|
||||||
void NotifyInfoTipChanged(GameModel * sender);
|
void NotifyInfoTipChanged(GameModel * sender);
|
||||||
void NotifyQuickOptionsChanged(GameModel * sender);
|
void NotifyQuickOptionsChanged(GameModel * sender);
|
||||||
|
void NotifyLastToolChanged(GameModel * sender);
|
||||||
|
|
||||||
void ExitPrompt();
|
void ExitPrompt();
|
||||||
|
|
||||||
|
@ -20,7 +20,8 @@ Tool::Tool(int id, string name, string description, int r, int g, int b, VideoBu
|
|||||||
colGreen(g),
|
colGreen(g),
|
||||||
colBlue(b),
|
colBlue(b),
|
||||||
textureGen(textureGen),
|
textureGen(textureGen),
|
||||||
strength(1.0f)
|
strength(1.0f),
|
||||||
|
resolution(1)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
VideoBuffer * Tool::GetTexture(int width, int height)
|
VideoBuffer * Tool::GetTexture(int width, int height)
|
||||||
@ -72,6 +73,7 @@ void ElementTool::DrawFill(Simulation * sim, Brush * brush, ui::Point position)
|
|||||||
WallTool::WallTool(int id, string name, string description, int r, int g, int b, VideoBuffer * (*textureGen)(int, int, int)):
|
WallTool::WallTool(int id, string name, string description, int r, int g, int b, VideoBuffer * (*textureGen)(int, int, int)):
|
||||||
Tool(id, name, description, r, g, b, textureGen)
|
Tool(id, name, description, r, g, b, textureGen)
|
||||||
{
|
{
|
||||||
|
resolution = CELL;
|
||||||
}
|
}
|
||||||
WallTool::~WallTool() {}
|
WallTool::~WallTool() {}
|
||||||
void WallTool::Draw(Simulation * sim, Brush * brush, ui::Point position){
|
void WallTool::Draw(Simulation * sim, Brush * brush, ui::Point position){
|
||||||
|
@ -26,10 +26,12 @@ protected:
|
|||||||
string toolName;
|
string toolName;
|
||||||
string toolDescription;
|
string toolDescription;
|
||||||
float strength;
|
float strength;
|
||||||
|
int resolution;
|
||||||
public:
|
public:
|
||||||
Tool(int id, string name, string description, int r, int g, int b, VideoBuffer * (*textureGen)(int, int, int) = NULL);
|
Tool(int id, string name, string description, int r, int g, int b, VideoBuffer * (*textureGen)(int, int, int) = NULL);
|
||||||
string GetName();
|
string GetName();
|
||||||
string GetDescription();
|
string GetDescription();
|
||||||
|
int GetResolution() { return resolution; }
|
||||||
void SetStrength(float value) { strength = value; }
|
void SetStrength(float value) { strength = value; }
|
||||||
float GetStrength() { return strength; }
|
float GetStrength() { return strength; }
|
||||||
VideoBuffer * GetTexture(int width, int height);
|
VideoBuffer * GetTexture(int width, int height);
|
||||||
|
@ -1250,11 +1250,11 @@ int Simulation::CreateWalls(int x, int y, int rx, int ry, int c, int flags, Brus
|
|||||||
rx = rx/CELL;
|
rx = rx/CELL;
|
||||||
x = x/CELL;
|
x = x/CELL;
|
||||||
y = y/CELL;
|
y = y/CELL;
|
||||||
x -= rx/2;
|
x -= rx;///2;
|
||||||
y -= ry/2;
|
y -= ry;///2;
|
||||||
for (ox=x; ox<=x+rx; ox++)
|
for (ox=x; ox<=x+rx+rx; ox++)
|
||||||
{
|
{
|
||||||
for (oy=y; oy<=y+rx; oy++)
|
for (oy=y; oy<=y+ry+ry; oy++)
|
||||||
{
|
{
|
||||||
if (ox>=0&&ox<XRES/CELL&&oy>=0&&oy<YRES/CELL)
|
if (ox>=0&&ox<XRES/CELL&&oy>=0&&oy<YRES/CELL)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user