Resize brush X and Y axis seperately using Shift and Control, Addresses issue #27
This commit is contained in:
parent
f9eeebb910
commit
fc93b71485
@ -32,7 +32,7 @@ protected:
|
|||||||
{
|
{
|
||||||
for(int y = 0; y < size.Y; y++)
|
for(int y = 0; y < size.Y; y++)
|
||||||
{
|
{
|
||||||
if(bitmap[y*size.X+x] && (!y || !x || y == size.X-1 || x == size.Y-1 || !bitmap[y*size.X+(x+1)] || !bitmap[y*size.X+(x-1)] || !bitmap[(y-1)*size.X+x] || !bitmap[(y+1)*size.X+x]))
|
if(bitmap[y*size.X+x] && (!y || !x || x == size.X-1 || y == size.Y-1 || !bitmap[y*size.X+(x+1)] || !bitmap[y*size.X+(x-1)] || !bitmap[(y-1)*size.X+x] || !bitmap[(y+1)*size.X+x]))
|
||||||
outline[y*size.X+x] = 255;
|
outline[y*size.X+x] = 255;
|
||||||
else
|
else
|
||||||
outline[y*size.X+x] = 0;
|
outline[y*size.X+x] = 0;
|
||||||
|
@ -185,9 +185,13 @@ void GameController::PlaceSave(ui::Point position)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameController::AdjustBrushSize(int direction, bool logarithmic)
|
void GameController::AdjustBrushSize(int direction, bool logarithmic, bool xAxis, bool yAxis)
|
||||||
{
|
{
|
||||||
|
if(xAxis && yAxis)
|
||||||
|
return;
|
||||||
|
|
||||||
ui::Point newSize(0, 0);
|
ui::Point newSize(0, 0);
|
||||||
|
ui::Point oldSize = gameModel->GetBrush()->GetRadius();
|
||||||
if(logarithmic)
|
if(logarithmic)
|
||||||
newSize = gameModel->GetBrush()->GetRadius() + ui::Point(direction * ((gameModel->GetBrush()->GetRadius().X/10)>0?gameModel->GetBrush()->GetRadius().X/10:1), direction * ((gameModel->GetBrush()->GetRadius().Y/10)>0?gameModel->GetBrush()->GetRadius().Y/10:1));
|
newSize = gameModel->GetBrush()->GetRadius() + ui::Point(direction * ((gameModel->GetBrush()->GetRadius().X/10)>0?gameModel->GetBrush()->GetRadius().X/10:1), direction * ((gameModel->GetBrush()->GetRadius().Y/10)>0?gameModel->GetBrush()->GetRadius().Y/10:1));
|
||||||
else
|
else
|
||||||
@ -196,7 +200,14 @@ void GameController::AdjustBrushSize(int direction, bool logarithmic)
|
|||||||
newSize.X = 0;
|
newSize.X = 0;
|
||||||
if(newSize.Y<0)
|
if(newSize.Y<0)
|
||||||
newSize.Y = 0;
|
newSize.Y = 0;
|
||||||
|
|
||||||
|
if(xAxis)
|
||||||
|
gameModel->GetBrush()->SetRadius(ui::Point(newSize.X, oldSize.Y));
|
||||||
|
else if(yAxis)
|
||||||
|
gameModel->GetBrush()->SetRadius(ui::Point(oldSize.X, newSize.Y));
|
||||||
|
else
|
||||||
gameModel->GetBrush()->SetRadius(newSize);
|
gameModel->GetBrush()->SetRadius(newSize);
|
||||||
|
|
||||||
BrushChanged(gameModel->GetBrushID(), gameModel->GetBrush()->GetRadius().X, gameModel->GetBrush()->GetRadius().Y);
|
BrushChanged(gameModel->GetBrushID(), gameModel->GetBrush()->GetRadius().X, gameModel->GetBrush()->GetRadius().Y);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -68,7 +68,7 @@ public:
|
|||||||
void LoadRenderPreset(RenderPreset preset);
|
void LoadRenderPreset(RenderPreset preset);
|
||||||
void SetZoomEnabled(bool zoomEnable);
|
void SetZoomEnabled(bool zoomEnable);
|
||||||
void SetZoomPosition(ui::Point position);
|
void SetZoomPosition(ui::Point position);
|
||||||
void AdjustBrushSize(int direction, bool logarithmic = false);
|
void AdjustBrushSize(int direction, bool logarithmic = false, bool xAxis = false, bool yAxis = false);
|
||||||
void AdjustZoomSize(int direction, bool logarithmic = false);
|
void AdjustZoomSize(int direction, bool logarithmic = false);
|
||||||
void ToolClick(int toolSelection, ui::Point point);
|
void ToolClick(int toolSelection, ui::Point point);
|
||||||
void DrawPoints(int toolSelection, queue<ui::Point*> & pointQueue);
|
void DrawPoints(int toolSelection, queue<ui::Point*> & pointQueue);
|
||||||
|
@ -38,7 +38,8 @@ GameView::GameView():
|
|||||||
infoTip(""),
|
infoTip(""),
|
||||||
infoTipPresence(0),
|
infoTipPresence(0),
|
||||||
toolTipPosition(-1, -1),
|
toolTipPosition(-1, -1),
|
||||||
alternativeSaveSource(false)
|
shiftBehaviour(false),
|
||||||
|
ctrlBehaviour(false)
|
||||||
{
|
{
|
||||||
|
|
||||||
int currentX = 1;
|
int currentX = 1;
|
||||||
@ -50,7 +51,7 @@ GameView::GameView():
|
|||||||
SearchAction(GameView * _v) { v = _v; }
|
SearchAction(GameView * _v) { v = _v; }
|
||||||
void ActionCallback(ui::Button * sender)
|
void ActionCallback(ui::Button * sender)
|
||||||
{
|
{
|
||||||
if(v->GetAlternativeSourceEnabled())
|
if(v->CtrlBehaviour())
|
||||||
v->c->OpenLocalBrowse();
|
v->c->OpenLocalBrowse();
|
||||||
else
|
else
|
||||||
v->c->OpenSearch();
|
v->c->OpenSearch();
|
||||||
@ -93,7 +94,7 @@ GameView::GameView():
|
|||||||
SaveSimulationAction(GameView * _v) { v = _v; }
|
SaveSimulationAction(GameView * _v) { v = _v; }
|
||||||
void ActionCallback(ui::Button * sender)
|
void ActionCallback(ui::Button * sender)
|
||||||
{
|
{
|
||||||
if(v->GetAlternativeSourceEnabled())
|
if(v->CtrlBehaviour())
|
||||||
v->c->OpenLocalSaveWindow();
|
v->c->OpenLocalSaveWindow();
|
||||||
else
|
else
|
||||||
v->c->OpenSaveWindow();
|
v->c->OpenSaveWindow();
|
||||||
@ -792,7 +793,7 @@ void GameView::OnMouseWheel(int x, int y, int d)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
c->AdjustBrushSize(d);
|
c->AdjustBrushSize(d, false, shiftBehaviour, ctrlBehaviour);
|
||||||
if(isMouseDown)
|
if(isMouseDown)
|
||||||
{
|
{
|
||||||
pointQueue.push(new ui::Point(x, y));
|
pointQueue.push(new ui::Point(x, y));
|
||||||
@ -854,7 +855,7 @@ void GameView::OnKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool
|
|||||||
drawMode = DrawFill;
|
drawMode = DrawFill;
|
||||||
else
|
else
|
||||||
drawMode = DrawRect;
|
drawMode = DrawRect;
|
||||||
enableHDDSave();
|
enableCtrlBehaviour();
|
||||||
break;
|
break;
|
||||||
case KEY_SHIFT:
|
case KEY_SHIFT:
|
||||||
if(drawModeReset)
|
if(drawModeReset)
|
||||||
@ -865,6 +866,7 @@ void GameView::OnKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool
|
|||||||
drawMode = DrawFill;
|
drawMode = DrawFill;
|
||||||
else
|
else
|
||||||
drawMode = DrawLine;
|
drawMode = DrawLine;
|
||||||
|
enableShiftBehaviour();
|
||||||
break;
|
break;
|
||||||
case ' ': //Space
|
case ' ': //Space
|
||||||
c->SetPaused();
|
c->SetPaused();
|
||||||
@ -920,10 +922,10 @@ void GameView::OnKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool
|
|||||||
c->OpenStamps();
|
c->OpenStamps();
|
||||||
break;
|
break;
|
||||||
case ']':
|
case ']':
|
||||||
c->AdjustBrushSize(1, true);
|
c->AdjustBrushSize(1, true, shiftBehaviour, ctrlBehaviour);
|
||||||
break;
|
break;
|
||||||
case '[':
|
case '[':
|
||||||
c->AdjustBrushSize(-1, true);
|
c->AdjustBrushSize(-1, true, shiftBehaviour, ctrlBehaviour);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -949,7 +951,10 @@ void GameView::OnKeyRelease(int key, Uint16 character, bool shift, bool ctrl, bo
|
|||||||
drawSnap = false;
|
drawSnap = false;
|
||||||
break;
|
break;
|
||||||
case KEY_CTRL:
|
case KEY_CTRL:
|
||||||
disableHDDSave();
|
disableCtrlBehaviour();
|
||||||
|
break;
|
||||||
|
case KEY_SHIFT:
|
||||||
|
disableShiftBehaviour();
|
||||||
break;
|
break;
|
||||||
case 'z':
|
case 'z':
|
||||||
if(!zoomCursorFixed)
|
if(!zoomCursorFixed)
|
||||||
@ -1163,12 +1168,29 @@ void GameView::changeColour()
|
|||||||
c->SetColour(ui::Colour(colourRSlider->GetValue(), colourGSlider->GetValue(), colourBSlider->GetValue(), colourASlider->GetValue()));
|
c->SetColour(ui::Colour(colourRSlider->GetValue(), colourGSlider->GetValue(), colourBSlider->GetValue(), colourASlider->GetValue()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameView::enableHDDSave()
|
void GameView::enableShiftBehaviour()
|
||||||
{
|
{
|
||||||
if(!alternativeSaveSource)
|
if(!shiftBehaviour)
|
||||||
{
|
{
|
||||||
alternativeSaveSource = true;
|
shiftBehaviour = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void GameView::disableShiftBehaviour()
|
||||||
|
{
|
||||||
|
if(shiftBehaviour)
|
||||||
|
{
|
||||||
|
shiftBehaviour = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void GameView::enableCtrlBehaviour()
|
||||||
|
{
|
||||||
|
if(!ctrlBehaviour)
|
||||||
|
{
|
||||||
|
ctrlBehaviour = true;
|
||||||
|
|
||||||
|
//Show HDD save & load buttons
|
||||||
saveSimulationButton->Appearance.BackgroundInactive = ui::Colour(255, 255, 255);
|
saveSimulationButton->Appearance.BackgroundInactive = ui::Colour(255, 255, 255);
|
||||||
saveSimulationButton->Appearance.TextInactive = ui::Colour(0, 0, 0);
|
saveSimulationButton->Appearance.TextInactive = ui::Colour(0, 0, 0);
|
||||||
searchButton->Appearance.BackgroundInactive = ui::Colour(255, 255, 255);
|
searchButton->Appearance.BackgroundInactive = ui::Colour(255, 255, 255);
|
||||||
@ -1176,12 +1198,13 @@ void GameView::enableHDDSave()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameView::disableHDDSave()
|
void GameView::disableCtrlBehaviour()
|
||||||
{
|
{
|
||||||
if(alternativeSaveSource)
|
if(ctrlBehaviour)
|
||||||
{
|
{
|
||||||
alternativeSaveSource = false;
|
ctrlBehaviour = false;
|
||||||
|
|
||||||
|
//Hide HDD save & load buttons
|
||||||
saveSimulationButton->Appearance.BackgroundInactive = ui::Colour(0, 0, 0);
|
saveSimulationButton->Appearance.BackgroundInactive = ui::Colour(0, 0, 0);
|
||||||
saveSimulationButton->Appearance.TextInactive = ui::Colour(255, 255, 255);
|
saveSimulationButton->Appearance.TextInactive = ui::Colour(255, 255, 255);
|
||||||
searchButton->Appearance.BackgroundInactive = ui::Colour(0, 0, 0);
|
searchButton->Appearance.BackgroundInactive = ui::Colour(0, 0, 0);
|
||||||
|
@ -37,7 +37,8 @@ private:
|
|||||||
bool zoomEnabled;
|
bool zoomEnabled;
|
||||||
bool zoomCursorFixed;
|
bool zoomCursorFixed;
|
||||||
bool drawSnap;
|
bool drawSnap;
|
||||||
bool alternativeSaveSource;
|
bool shiftBehaviour;
|
||||||
|
bool ctrlBehaviour;
|
||||||
int toolIndex;
|
int toolIndex;
|
||||||
|
|
||||||
int infoTipPresence;
|
int infoTipPresence;
|
||||||
@ -96,15 +97,18 @@ private:
|
|||||||
virtual ui::Point lineSnapCoords(ui::Point point1, ui::Point point2);
|
virtual ui::Point lineSnapCoords(ui::Point point1, ui::Point point2);
|
||||||
virtual ui::Point rectSnapCoords(ui::Point point1, ui::Point point2);
|
virtual ui::Point rectSnapCoords(ui::Point point1, ui::Point point2);
|
||||||
|
|
||||||
void enableHDDSave();
|
void enableShiftBehaviour();
|
||||||
void disableHDDSave();
|
void disableShiftBehaviour();
|
||||||
|
void enableCtrlBehaviour();
|
||||||
|
void disableCtrlBehaviour();
|
||||||
public:
|
public:
|
||||||
GameView();
|
GameView();
|
||||||
|
|
||||||
//Breaks MVC, but any other way is going to be more of a mess.
|
//Breaks MVC, but any other way is going to be more of a mess.
|
||||||
ui::Point GetMousePosition();
|
ui::Point GetMousePosition();
|
||||||
void SetSample(SimulationSample sample);
|
void SetSample(SimulationSample sample);
|
||||||
bool GetAlternativeSourceEnabled(){ return alternativeSaveSource; }
|
bool CtrlBehaviour(){ return ctrlBehaviour; }
|
||||||
|
bool ShiftBehaviour(){ return shiftBehaviour; }
|
||||||
|
|
||||||
void AttachController(GameController * _c){ c = _c; }
|
void AttachController(GameController * _c){ c = _c; }
|
||||||
void NotifyRendererChanged(GameModel * sender);
|
void NotifyRendererChanged(GameModel * sender);
|
||||||
|
Loading…
Reference in New Issue
Block a user