last commit was buggy, this tiny rewrite should be perfect
This commit is contained in:
parent
a81a41b67f
commit
dab25160cc
@ -190,7 +190,6 @@ GameView::GameView():
|
|||||||
activeBrush(NULL),
|
activeBrush(NULL),
|
||||||
saveSimulationButtonEnabled(false),
|
saveSimulationButtonEnabled(false),
|
||||||
drawMode(DrawPoints),
|
drawMode(DrawPoints),
|
||||||
drawModeReset(false),
|
|
||||||
drawPoint1(0, 0),
|
drawPoint1(0, 0),
|
||||||
drawPoint2(0, 0),
|
drawPoint2(0, 0),
|
||||||
selectMode(SelectNone),
|
selectMode(SelectNone),
|
||||||
@ -1081,6 +1080,7 @@ void GameView::OnMouseMove(int x, int y, int dx, int dy)
|
|||||||
else if (drawMode == DrawPoints || drawMode == DrawFill)
|
else if (drawMode == DrawPoints || drawMode == DrawFill)
|
||||||
{
|
{
|
||||||
isMouseDown = false;
|
isMouseDown = false;
|
||||||
|
drawMode = DrawPoints;
|
||||||
c->MouseUp(x, y, 0, 2);
|
c->MouseUp(x, y, 0, 2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1220,11 +1220,10 @@ void GameView::OnMouseUp(int x, int y, unsigned button)
|
|||||||
// plop tool stuff (like STKM)
|
// plop tool stuff (like STKM)
|
||||||
c->ToolClick(toolIndex, finalDrawPoint2);
|
c->ToolClick(toolIndex, finalDrawPoint2);
|
||||||
}
|
}
|
||||||
if (drawModeReset)
|
|
||||||
{
|
// update the drawing mode for the next line
|
||||||
drawModeReset = false;
|
// since ctrl/shift state may have changed since we started drawing
|
||||||
drawMode = DrawPoints;
|
UpdateDrawMode();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1353,47 +1352,14 @@ void GameView::OnKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool
|
|||||||
{
|
{
|
||||||
case KEY_LALT:
|
case KEY_LALT:
|
||||||
case KEY_RALT:
|
case KEY_RALT:
|
||||||
drawSnap = true;
|
|
||||||
enableAltBehaviour();
|
enableAltBehaviour();
|
||||||
break;
|
break;
|
||||||
case KEY_LCTRL:
|
case KEY_LCTRL:
|
||||||
case KEY_RCTRL:
|
case KEY_RCTRL:
|
||||||
if (!isMouseDown)
|
|
||||||
{
|
|
||||||
if (drawModeReset)
|
|
||||||
drawModeReset = false;
|
|
||||||
else
|
|
||||||
drawPoint1 = currentMouse;
|
|
||||||
if (shift)
|
|
||||||
{
|
|
||||||
if (!toolBrush)
|
|
||||||
drawMode = DrawFill;
|
|
||||||
else
|
|
||||||
drawMode = DrawPoints;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
drawMode = DrawRect;
|
|
||||||
}
|
|
||||||
enableCtrlBehaviour();
|
enableCtrlBehaviour();
|
||||||
break;
|
break;
|
||||||
case KEY_LSHIFT:
|
case KEY_LSHIFT:
|
||||||
case KEY_RSHIFT:
|
case KEY_RSHIFT:
|
||||||
if (!isMouseDown)
|
|
||||||
{
|
|
||||||
if (drawModeReset)
|
|
||||||
drawModeReset = false;
|
|
||||||
else
|
|
||||||
drawPoint1 = currentMouse;
|
|
||||||
if (ctrl)
|
|
||||||
{
|
|
||||||
if (!toolBrush)
|
|
||||||
drawMode = DrawFill;
|
|
||||||
else
|
|
||||||
drawMode = DrawPoints;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
drawMode = DrawLine;
|
|
||||||
}
|
|
||||||
enableShiftBehaviour();
|
enableShiftBehaviour();
|
||||||
break;
|
break;
|
||||||
case ' ': //Space
|
case ' ': //Space
|
||||||
@ -1595,15 +1561,10 @@ void GameView::OnKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool
|
|||||||
|
|
||||||
void GameView::OnKeyRelease(int key, Uint16 character, bool shift, bool ctrl, bool alt)
|
void GameView::OnKeyRelease(int key, Uint16 character, bool shift, bool ctrl, bool alt)
|
||||||
{
|
{
|
||||||
if (!isMouseDown)
|
|
||||||
drawMode = DrawPoints;
|
|
||||||
else if (drawMode == DrawPoints)
|
|
||||||
drawModeReset = true;
|
|
||||||
switch(key)
|
switch(key)
|
||||||
{
|
{
|
||||||
case KEY_LALT:
|
case KEY_LALT:
|
||||||
case KEY_RALT:
|
case KEY_RALT:
|
||||||
drawSnap = false;
|
|
||||||
disableAltBehaviour();
|
disableAltBehaviour();
|
||||||
break;
|
break;
|
||||||
case KEY_LCTRL:
|
case KEY_LCTRL:
|
||||||
@ -1927,7 +1888,9 @@ void GameView::enableShiftBehaviour()
|
|||||||
if(!shiftBehaviour)
|
if(!shiftBehaviour)
|
||||||
{
|
{
|
||||||
shiftBehaviour = true;
|
shiftBehaviour = true;
|
||||||
if(isMouseDown || (toolBrush && drawMode == DrawPoints))
|
if (!isMouseDown)
|
||||||
|
UpdateDrawMode();
|
||||||
|
if (isMouseDown || (toolBrush && drawMode == DrawPoints))
|
||||||
c->SetToolStrength(10.0f);
|
c->SetToolStrength(10.0f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1937,7 +1900,9 @@ void GameView::disableShiftBehaviour()
|
|||||||
if(shiftBehaviour)
|
if(shiftBehaviour)
|
||||||
{
|
{
|
||||||
shiftBehaviour = false;
|
shiftBehaviour = false;
|
||||||
if(!ctrlBehaviour)
|
if (!isMouseDown)
|
||||||
|
UpdateDrawMode();
|
||||||
|
if (!ctrlBehaviour)
|
||||||
c->SetToolStrength(1.0f);
|
c->SetToolStrength(1.0f);
|
||||||
else
|
else
|
||||||
c->SetToolStrength(.1f);
|
c->SetToolStrength(.1f);
|
||||||
@ -1949,41 +1914,36 @@ void GameView::enableAltBehaviour()
|
|||||||
if(!altBehaviour)
|
if(!altBehaviour)
|
||||||
{
|
{
|
||||||
altBehaviour = true;
|
altBehaviour = true;
|
||||||
|
drawSnap = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameView::disableAltBehaviour()
|
void GameView::disableAltBehaviour()
|
||||||
{
|
{
|
||||||
if(altBehaviour)
|
if (altBehaviour)
|
||||||
{
|
{
|
||||||
altBehaviour = false;
|
altBehaviour = false;
|
||||||
|
drawSnap = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameView::enableCtrlBehaviour() {
|
void GameView::enableCtrlBehaviour()
|
||||||
// "Usual" Ctrl-holding behavior uses highlights
|
|
||||||
enableCtrlBehaviour(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
void GameView::enableCtrlBehaviour(bool isHighlighted)
|
|
||||||
{
|
{
|
||||||
if(!ctrlBehaviour)
|
if(!ctrlBehaviour)
|
||||||
{
|
{
|
||||||
ctrlBehaviour = true;
|
ctrlBehaviour = true;
|
||||||
|
if (!isMouseDown)
|
||||||
|
UpdateDrawMode();
|
||||||
|
|
||||||
//Show HDD save & load buttons
|
//Show HDD save & load buttons
|
||||||
if (isHighlighted) {
|
saveSimulationButton->Appearance.BackgroundInactive = saveSimulationButton->Appearance.BackgroundHover = ui::Colour(255, 255, 255);
|
||||||
saveSimulationButton->Appearance.BackgroundInactive = saveSimulationButton->Appearance.BackgroundHover = ui::Colour(255, 255, 255);
|
saveSimulationButton->Appearance.TextInactive = saveSimulationButton->Appearance.TextHover = ui::Colour(0, 0, 0);
|
||||||
saveSimulationButton->Appearance.TextInactive = saveSimulationButton->Appearance.TextHover = ui::Colour(0, 0, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
saveSimulationButton->Enabled = true;
|
saveSimulationButton->Enabled = true;
|
||||||
SetSaveButtonTooltips();
|
SetSaveButtonTooltips();
|
||||||
|
|
||||||
if (isHighlighted) {
|
searchButton->Appearance.BackgroundInactive = searchButton->Appearance.BackgroundHover = ui::Colour(255, 255, 255);
|
||||||
searchButton->Appearance.BackgroundInactive = searchButton->Appearance.BackgroundHover = ui::Colour(255, 255, 255);
|
searchButton->Appearance.TextInactive = searchButton->Appearance.TextHover = ui::Colour(0, 0, 0);
|
||||||
searchButton->Appearance.TextInactive = searchButton->Appearance.TextHover = ui::Colour(0, 0, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
searchButton->SetToolTip("Open a simulation from your hard drive.");
|
searchButton->SetToolTip("Open a simulation from your hard drive.");
|
||||||
if (currentSaveType == 2)
|
if (currentSaveType == 2)
|
||||||
@ -2003,6 +1963,8 @@ void GameView::disableCtrlBehaviour()
|
|||||||
if(ctrlBehaviour)
|
if(ctrlBehaviour)
|
||||||
{
|
{
|
||||||
ctrlBehaviour = false;
|
ctrlBehaviour = false;
|
||||||
|
if (!isMouseDown)
|
||||||
|
UpdateDrawMode();
|
||||||
|
|
||||||
//Hide HDD save & load buttons
|
//Hide HDD save & load buttons
|
||||||
saveSimulationButton->Appearance.BackgroundInactive = ui::Colour(0, 0, 0);
|
saveSimulationButton->Appearance.BackgroundInactive = ui::Colour(0, 0, 0);
|
||||||
@ -2023,6 +1985,23 @@ void GameView::disableCtrlBehaviour()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GameView::UpdateDrawMode()
|
||||||
|
{
|
||||||
|
if (ctrlBehaviour && shiftBehaviour)
|
||||||
|
{
|
||||||
|
if (toolBrush)
|
||||||
|
drawMode = DrawPoints;
|
||||||
|
else
|
||||||
|
drawMode = DrawFill;
|
||||||
|
}
|
||||||
|
else if (ctrlBehaviour)
|
||||||
|
drawMode = DrawRect;
|
||||||
|
else if (shiftBehaviour)
|
||||||
|
drawMode = DrawLine;
|
||||||
|
else
|
||||||
|
drawMode = DrawPoints;
|
||||||
|
}
|
||||||
|
|
||||||
void GameView::SetSaveButtonTooltips()
|
void GameView::SetSaveButtonTooltips()
|
||||||
{
|
{
|
||||||
if (!Client::Ref().GetAuthUser().ID)
|
if (!Client::Ref().GetAuthUser().ID)
|
||||||
|
@ -97,7 +97,6 @@ private:
|
|||||||
vector<ToolButton*> colourPresets;
|
vector<ToolButton*> colourPresets;
|
||||||
|
|
||||||
DrawMode drawMode;
|
DrawMode drawMode;
|
||||||
bool drawModeReset;
|
|
||||||
ui::Point drawPoint1;
|
ui::Point drawPoint1;
|
||||||
ui::Point drawPoint2;
|
ui::Point drawPoint2;
|
||||||
|
|
||||||
@ -123,10 +122,10 @@ private:
|
|||||||
void enableShiftBehaviour();
|
void enableShiftBehaviour();
|
||||||
void disableShiftBehaviour();
|
void disableShiftBehaviour();
|
||||||
void enableCtrlBehaviour();
|
void enableCtrlBehaviour();
|
||||||
void enableCtrlBehaviour(bool isHighlighted);
|
|
||||||
void disableCtrlBehaviour();
|
void disableCtrlBehaviour();
|
||||||
void enableAltBehaviour();
|
void enableAltBehaviour();
|
||||||
void disableAltBehaviour();
|
void disableAltBehaviour();
|
||||||
|
void UpdateDrawMode();
|
||||||
public:
|
public:
|
||||||
GameView();
|
GameView();
|
||||||
virtual ~GameView();
|
virtual ~GameView();
|
||||||
|
Reference in New Issue
Block a user