Skip to content

Commit

Permalink
Added grid presets
Browse files Browse the repository at this point in the history
  • Loading branch information
jkulawik committed Sep 28, 2020
1 parent 7a9be80 commit b50c06d
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 17 deletions.
64 changes: 52 additions & 12 deletions HPL2/tools/editors/common/EditorWindowLowerToolbar.cpp
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
/*
* Copyright © 2009-2020 Frictional Games
* Copyright © 2011-2020 Frictional Games
*
* This file is part of Amnesia: The Dark Descent.
* This file is part of Amnesia: A Machine For Pigs.
*
* Amnesia: The Dark Descent is free software: you can redistribute it and/or modify
* Amnesia: A Machine For Pigs is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* Amnesia: The Dark Descent is distributed in the hope that it will be useful,
* Amnesia: A Machine For Pigs is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Amnesia: The Dark Descent. If not, see <https://www.gnu.org/licenses/>.
* along with Amnesia: A Machine For Pigs. If not, see <https://www.gnu.org/licenses/>.
*/

#include "EditorWindowLowerToolbar.h"
Expand Down Expand Up @@ -63,8 +63,6 @@ iEditorWindowLowerToolbar::iEditorWindowLowerToolbar(iEditorBase* apEditor) : iE
mbClipPlaneAdded = false;
mbClipPlaneRemoved = false;
mbClipPlaneVecUpdated = false;

//mpShortcutToggleSnap = NULL;
}

//---------------------------------------------------------------
Expand Down Expand Up @@ -99,9 +97,10 @@ void iEditorWindowLowerToolbar::OnInitLayout()
iWidget* iEditorWindowLowerToolbar::AddGridControls()
{
// Grid Controls group
mpGridControlsGroup = mpSet->CreateWidgetGroup(0,cVector2f(200,43),_W("Grid Controls"), mpBGFrame);
mpGridControlsGroup = mpSet->CreateWidgetGroup(0,cVector2f(280,43),_W("Grid Controls"), mpBGFrame);
mpGridControlsGroup->SetDefaultFontSize(iEditorInput::GetFontSize());


// Buttons

// Plane switch
Expand All @@ -110,6 +109,7 @@ iWidget* iEditorWindowLowerToolbar::AddGridControls()
mpBPlaneSwitch->SetToolTip(_W("Cycle through grid planes"));
mpBPlaneSwitch->SetToolTipEnabled(true);


////////////////////
// Snap controls
// Active
Expand All @@ -121,15 +121,36 @@ iWidget* iEditorWindowLowerToolbar::AddGridControls()
mpBSnap->SetToolTip(_W("Toggle grid snapping"));
mpBSnap->SetToolTipEnabled(true);

mpSet->AddGlobalShortcut(0, eKey_C, mpBSnap, eGuiMessage_ButtonPressed);

/*mpShortcutToggleSnap = mpBSnap->AddShortcut(eKeyModifier_None, eKey_C);
mpShortcutToggleSnap->SetEnabled(true);*/
//mpSet->AddGlobalShortcut(0, eKey_C, mpBSnap, eGuiMessage_ButtonPressed);

// Height and sep.
mpInpPlaneHeight = CreateInputNumber(cVector3f(65,5,0.1f), _W("Height"), "", mpGridControlsGroup, 50, 0.25f);
mpInpSnapSep = CreateInputNumber(cVector3f(120,5,0.1f), _W("Snap sep."), "", mpGridControlsGroup, 50, 0.25f);


mpGridPresetLabel = mpSet->CreateWidgetLabel(cVector3f(179, 4, 0.1f), cVector2f(32, 20), _W("Grid presets"), mpGridControlsGroup);

mpSnapPreset5 = mpSet->CreateWidgetButton(cVector3f(175, 18, 0.1f), cVector2f(32, 20), _W("0.05"), mpGridControlsGroup);
mpSnapPreset5->AddCallback(eGuiMessage_ButtonPressed, this, kGuiCallback(InputCallback));
mpSnapPreset5->SetToolTip(_W("Set grid snapping to 5 cm"));
mpSnapPreset5->SetToolTipEnabled(true);

mpSnapPreset25 = mpSet->CreateWidgetButton(cVector3f(210, 18, 0.1f), cVector2f(32, 20), _W("0.25"), mpGridControlsGroup);
mpSnapPreset25->AddCallback(eGuiMessage_ButtonPressed, this, kGuiCallback(InputCallback));
mpSnapPreset25->SetToolTip(_W("Set grid snapping to 25 cm"));
mpSnapPreset25->SetToolTipEnabled(true);

//name mpSnapPreset1 comes from when it was a 0.01 preset, didn't bother changing it
mpSnapPreset1 = mpSet->CreateWidgetButton(cVector3f(245, 18, 0.1f), cVector2f(32, 20), _W("0.5"), mpGridControlsGroup);
mpSnapPreset1->AddCallback(eGuiMessage_ButtonPressed, this, kGuiCallback(InputCallback));
mpSnapPreset1->SetToolTip(_W("Set grid snapping to 1 cm"));
mpSnapPreset1->SetToolTipEnabled(true);

/*
cWidgetButton* mpSnapPreset1;
cWidgetButton* mpSnapPreset5;
cWidgetButton* mpSnapPreset25;
*/
return mpGridControlsGroup;
}

Expand Down Expand Up @@ -173,13 +194,16 @@ iWidget* iEditorWindowLowerToolbar::AddCameraControls()
{
mpHandleCamera = mpSet->CreateWidgetDummy(0, mpBGFrame);


mpBCameraLockToGrid = mpSet->CreateWidgetButton(0, 19, _W("LT"), mpHandleCamera);

mpBCameraLockToGrid->AddCallback(eGuiMessage_ButtonPressed, this, kGuiCallback(InputCallback));
mpBCameraLockToGrid->SetToggleable(true);
mpBCameraLockToGrid->SetToolTip(_W("Lock camera tracking to grid"));
mpBCameraLockToGrid->SetToolTipEnabled(true);

mpBCameraFocusOnSelection = mpSet->CreateWidgetButton(cVector3f(0,21,0), 19, _W("F"), mpHandleCamera);

mpBCameraFocusOnSelection->AddCallback(eGuiMessage_ButtonPressed, this, kGuiCallback(InputCallback));
mpBCameraFocusOnSelection->SetToolTip(_W("Focus on selection"));
mpBCameraFocusOnSelection->SetToolTipEnabled(true);
Expand All @@ -195,12 +219,14 @@ iWidget* iEditorWindowLowerToolbar::AddClipPlaneControls()
mpGClipPlanes = mpSet->CreateWidgetGroup(0, cVector2f(275,43), _W("Clip planes"), mpBGFrame);
mpGClipPlanes->SetDefaultFontSize(iEditorInput::GetFontSize());


mpInpClipPlanes = CreateInputEnum(cVector3f(5,0,0.1f), _W(""), "", tWStringList(), mpGClipPlanes,50);
mpInpClipPlanes->SetMaxShownItems(3);
mpBAddClipPlane = mpSet->CreateWidgetButton(cVector3f(60, 5, 0.1f), cVector2f(15), _W("+"), mpGClipPlanes);

mpBAddClipPlane->AddCallback(eGuiMessage_ButtonPressed, this, kGuiCallback(InputCallback));
mpBRemClipPlane = mpSet->CreateWidgetButton(cVector3f(60, 21, 0.1f), cVector2f(15), _W("-"), mpGClipPlanes);

mpBRemClipPlane->AddCallback(eGuiMessage_ButtonPressed, this, kGuiCallback(InputCallback));

// Buttons
Expand All @@ -209,6 +235,7 @@ iWidget* iEditorWindowLowerToolbar::AddClipPlaneControls()
mpBClipNormalSwitch->SetToolTip(_W("Cycle through clip plane alignments"));
mpBClipNormalSwitch->SetToolTipEnabled(true);


mpInpClipPlaneHeight = CreateInputNumber(cVector3f(130,5,0.1f), _W("Height"), "", mpGClipPlanes, 50, 0.25f);
mpSet->AddGlobalShortcut(0, eKey_O, mpInpClipPlaneHeight->GetInputWidget(), eGuiMessage_TextBoxValueUp);
mpSet->AddGlobalShortcut(0, eKey_L, mpInpClipPlaneHeight->GetInputWidget(), eGuiMessage_TextBoxValueDown);
Expand All @@ -218,6 +245,7 @@ iWidget* iEditorWindowLowerToolbar::AddClipPlaneControls()
mpBClipPlaneCullSide->SetToolTip(_W("Set culled plane side"));
mpBClipPlaneCullSide->SetToolTipEnabled(true);


mpInpClipPlaneActive = CreateInputBool(cVector3f(215,5,0.1f), _W("Active"), "", mpGClipPlanes);

return mpGClipPlanes;
Expand Down Expand Up @@ -454,6 +482,18 @@ bool iEditorWindowLowerToolbar::InputCallback(iWidget* apWidget, const cGuiMessa
pAction = hplNew(cEditorActionClipPlaneSetCullingOnPositiveSide,(pWorld, lClipPlaneIdx, !pClipPlane->GetCullingOnPositiveSide()));
}
}
else if(apWidget==mpSnapPreset1)
{
mpInpSnapSep->SetValue(0.5f, true, true);
}
else if(apWidget==mpSnapPreset5)
{
mpInpSnapSep->SetValue(0.05f, true, true);
}
else if(apWidget==mpSnapPreset25)
{
mpInpSnapSep->SetValue(0.25f, true, true);
}

mpEditor->AddAction(pAction);

Expand Down
14 changes: 9 additions & 5 deletions HPL2/tools/editors/common/EditorWindowLowerToolbar.h
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
/*
* Copyright © 2009-2020 Frictional Games
* Copyright © 2011-2020 Frictional Games
*
* This file is part of Amnesia: The Dark Descent.
* This file is part of Amnesia: A Machine For Pigs.
*
* Amnesia: The Dark Descent is free software: you can redistribute it and/or modify
* Amnesia: A Machine For Pigs is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* Amnesia: The Dark Descent is distributed in the hope that it will be useful,
* Amnesia: A Machine For Pigs is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Amnesia: The Dark Descent. If not, see <https://www.gnu.org/licenses/>.
* along with Amnesia: A Machine For Pigs. If not, see <https://www.gnu.org/licenses/>.
*/

#ifndef HPLEDITOR_EDITOR_WINDOW_LOWER_TOOLBAR_H
Expand Down Expand Up @@ -68,6 +68,10 @@ class iEditorWindowLowerToolbar : public iEditorWindow
cWidgetButton* mpBSnap;
cEditorInputNumber* mpInpSnapSep;
cEditorInputNumber* mpInpPlaneHeight;
cWidgetLabel* mpGridPresetLabel;
cWidgetButton* mpSnapPreset1;
cWidgetButton* mpSnapPreset5;
cWidgetButton* mpSnapPreset25;

// Viewport controls
cWidgetDummy* mpHandleViewportControls;
Expand Down

0 comments on commit b50c06d

Please sign in to comment.