mirror of
https://github.com/AxioDL/PrimeWorldEditor.git
synced 2025-12-11 14:41:57 +00:00
Added Game Mode in the World Editor
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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());
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user