Added Game Mode in the World Editor

This commit is contained in:
parax0
2015-11-26 02:05:26 -07:00
parent 2e5678e863
commit 7a69346ff3
17 changed files with 123 additions and 17 deletions

View File

@@ -15,6 +15,7 @@ CBasicViewport::CBasicViewport(QWidget *pParent) :
setMouseTracking(true);
mCamera.SetAspectRatio((float) width() / height());
mViewInfo.pCamera = &mCamera;
mViewInfo.GameMode = false;
}
CBasicViewport::~CBasicViewport()
@@ -56,7 +57,8 @@ void CBasicViewport::paintGL()
Paint();
// Finally, draw XYZ axes in the corner
DrawAxes();
if (!mViewInfo.GameMode)
DrawAxes();
}
void CBasicViewport::resizeGL(int w, int h)
@@ -163,6 +165,11 @@ void CBasicViewport::contextMenuEvent(QContextMenuEvent *pEvent)
ContextMenu(pEvent);
}
void CBasicViewport::SetGameMode(bool Enabled)
{
mViewInfo.GameMode = Enabled;
}
void CBasicViewport::SetCursorState(const QCursor &Cursor)
{
mCursorState = Cursor;

View File

@@ -52,6 +52,7 @@ public:
void focusOutEvent(QFocusEvent *pEvent);
void contextMenuEvent(QContextMenuEvent *pEvent);
void SetGameMode(bool Enabled);
void SetCursorState(const QCursor& Cursor);
void SetCursorVisible(bool visible);
bool IsCursorVisible();

View File

@@ -132,15 +132,21 @@ void CSceneViewport::keyReleaseEvent(QKeyEvent* pEvent)
// ************ PROTECTED SLOTS ************
void CSceneViewport::CheckUserInput()
{
if (!underMouse() || IsMouseInputActive())
bool MouseActive = (underMouse() && !IsMouseInputActive());
if (!MouseActive || mViewInfo.GameMode)
{
ResetHover();
mGizmoHovering = false;
return;
if (!MouseActive)
return;
}
CRay ray = CastRay();
CheckGizmoInput(ray);
if (!mViewInfo.GameMode)
CheckGizmoInput(ray);
if (!mpEditor->Gizmo()->IsTransforming())
SceneRayCast(ray);
@@ -152,7 +158,7 @@ void CSceneViewport::Paint()
mpRenderer->BeginFrame();
if (mDrawSky)
if (mDrawSky || mViewInfo.GameMode)
{
CModel *pSky = mpScene->GetActiveSkybox();
if (pSky) mpRenderer->RenderSky(pSky, mViewInfo);
@@ -163,7 +169,7 @@ void CSceneViewport::Paint()
mpRenderer->RenderBuckets(mViewInfo);
mpRenderer->RenderBloom();
if (mpEditor->IsGizmoVisible())
if (mpEditor->IsGizmoVisible() && !mViewInfo.GameMode)
{
CGizmo *pGizmo = mpEditor->Gizmo();
mCamera.LoadMatrices();

View File

@@ -467,3 +467,8 @@ void CWorldEditor::on_ActionDrawObjectCollision_triggered()
{
ui->MainViewport->Renderer()->ToggleObjectCollision(ui->ActionDrawObjectCollision->isChecked());
}
void CWorldEditor::on_ActionGameMode_triggered()
{
ui->MainViewport->SetGameMode(ui->ActionGameMode->isChecked());
}

View File

@@ -76,6 +76,7 @@ private slots:
void on_ActionIncrementGizmo_triggered();
void on_ActionDecrementGizmo_triggered();
void on_ActionDrawObjectCollision_triggered();
void on_ActionGameMode_triggered();
};
#endif // CWORLDEDITOR_H

View File

@@ -267,6 +267,8 @@
<addaction name="ActionFakeBloom"/>
<addaction name="ActionBloom"/>
</widget>
<addaction name="ActionGameMode"/>
<addaction name="separator"/>
<addaction name="ActionDrawWorld"/>
<addaction name="ActionDrawObjects"/>
<addaction name="ActionDrawCollision"/>
@@ -715,6 +717,17 @@
<string>4</string>
</property>
</action>
<action name="ActionGameMode">
<property name="checkable">
<bool>true</bool>
</property>
<property name="text">
<string>Game Mode</string>
</property>
<property name="shortcut">
<string>G</string>
</property>
</action>
</widget>
<customwidgets>
<customwidget>