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++)
|
||||
{
|
||||
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;
|
||||
else
|
||||
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 oldSize = gameModel->GetBrush()->GetRadius();
|
||||
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));
|
||||
else
|
||||
@ -196,7 +200,14 @@ void GameController::AdjustBrushSize(int direction, bool logarithmic)
|
||||
newSize.X = 0;
|
||||
if(newSize.Y<0)
|
||||
newSize.Y = 0;
|
||||
gameModel->GetBrush()->SetRadius(newSize);
|
||||
|
||||
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);
|
||||
|
||||
BrushChanged(gameModel->GetBrushID(), gameModel->GetBrush()->GetRadius().X, gameModel->GetBrush()->GetRadius().Y);
|
||||
}
|
||||
|
||||
|
@ -68,7 +68,7 @@ public:
|
||||
void LoadRenderPreset(RenderPreset preset);
|
||||
void SetZoomEnabled(bool zoomEnable);
|
||||
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 ToolClick(int toolSelection, ui::Point point);
|
||||
void DrawPoints(int toolSelection, queue<ui::Point*> & pointQueue);
|
||||
|
@ -38,7 +38,8 @@ GameView::GameView():
|
||||
infoTip(""),
|
||||
infoTipPresence(0),
|
||||
toolTipPosition(-1, -1),
|
||||
alternativeSaveSource(false)
|
||||
shiftBehaviour(false),
|
||||
ctrlBehaviour(false)
|
||||
{
|
||||
|
||||
int currentX = 1;
|
||||
@ -50,7 +51,7 @@ GameView::GameView():
|
||||
SearchAction(GameView * _v) { v = _v; }
|
||||
void ActionCallback(ui::Button * sender)
|
||||
{
|
||||
if(v->GetAlternativeSourceEnabled())
|
||||
if(v->CtrlBehaviour())
|
||||
v->c->OpenLocalBrowse();
|
||||
else
|
||||
v->c->OpenSearch();
|
||||
@ -93,7 +94,7 @@ GameView::GameView():
|
||||
SaveSimulationAction(GameView * _v) { v = _v; }
|
||||
void ActionCallback(ui::Button * sender)
|
||||
{
|
||||
if(v->GetAlternativeSourceEnabled())
|
||||
if(v->CtrlBehaviour())
|
||||
v->c->OpenLocalSaveWindow();
|
||||
else
|
||||
v->c->OpenSaveWindow();
|
||||
@ -792,7 +793,7 @@ void GameView::OnMouseWheel(int x, int y, int d)
|
||||
}
|
||||
else
|
||||
{
|
||||
c->AdjustBrushSize(d);
|
||||
c->AdjustBrushSize(d, false, shiftBehaviour, ctrlBehaviour);
|
||||
if(isMouseDown)
|
||||
{
|
||||
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;
|
||||
else
|
||||
drawMode = DrawRect;
|
||||
enableHDDSave();
|
||||
enableCtrlBehaviour();
|
||||
break;
|
||||
case KEY_SHIFT:
|
||||
if(drawModeReset)
|
||||
@ -865,6 +866,7 @@ void GameView::OnKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool
|
||||
drawMode = DrawFill;
|
||||
else
|
||||
drawMode = DrawLine;
|
||||
enableShiftBehaviour();
|
||||
break;
|
||||
case ' ': //Space
|
||||
c->SetPaused();
|
||||
@ -920,10 +922,10 @@ void GameView::OnKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool
|
||||
c->OpenStamps();
|
||||
break;
|
||||
case ']':
|
||||
c->AdjustBrushSize(1, true);
|
||||
c->AdjustBrushSize(1, true, shiftBehaviour, ctrlBehaviour);
|
||||
break;
|
||||
case '[':
|
||||
c->AdjustBrushSize(-1, true);
|
||||
c->AdjustBrushSize(-1, true, shiftBehaviour, ctrlBehaviour);
|
||||
break;
|
||||
}
|
||||
|
||||
@ -949,7 +951,10 @@ void GameView::OnKeyRelease(int key, Uint16 character, bool shift, bool ctrl, bo
|
||||
drawSnap = false;
|
||||
break;
|
||||
case KEY_CTRL:
|
||||
disableHDDSave();
|
||||
disableCtrlBehaviour();
|
||||
break;
|
||||
case KEY_SHIFT:
|
||||
disableShiftBehaviour();
|
||||
break;
|
||||
case 'z':
|
||||
if(!zoomCursorFixed)
|
||||
@ -1163,12 +1168,29 @@ void GameView::changeColour()
|
||||
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.TextInactive = ui::Colour(0, 0, 0);
|
||||
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.TextInactive = ui::Colour(255, 255, 255);
|
||||
searchButton->Appearance.BackgroundInactive = ui::Colour(0, 0, 0);
|
||||
|
@ -37,7 +37,8 @@ private:
|
||||
bool zoomEnabled;
|
||||
bool zoomCursorFixed;
|
||||
bool drawSnap;
|
||||
bool alternativeSaveSource;
|
||||
bool shiftBehaviour;
|
||||
bool ctrlBehaviour;
|
||||
int toolIndex;
|
||||
|
||||
int infoTipPresence;
|
||||
@ -96,15 +97,18 @@ private:
|
||||
virtual ui::Point lineSnapCoords(ui::Point point1, ui::Point point2);
|
||||
virtual ui::Point rectSnapCoords(ui::Point point1, ui::Point point2);
|
||||
|
||||
void enableHDDSave();
|
||||
void disableHDDSave();
|
||||
void enableShiftBehaviour();
|
||||
void disableShiftBehaviour();
|
||||
void enableCtrlBehaviour();
|
||||
void disableCtrlBehaviour();
|
||||
public:
|
||||
GameView();
|
||||
|
||||
//Breaks MVC, but any other way is going to be more of a mess.
|
||||
ui::Point GetMousePosition();
|
||||
void SetSample(SimulationSample sample);
|
||||
bool GetAlternativeSourceEnabled(){ return alternativeSaveSource; }
|
||||
bool CtrlBehaviour(){ return ctrlBehaviour; }
|
||||
bool ShiftBehaviour(){ return shiftBehaviour; }
|
||||
|
||||
void AttachController(GameController * _c){ c = _c; }
|
||||
void NotifyRendererChanged(GameModel * sender);
|
||||
|
Loading…
Reference in New Issue
Block a user