From e16b978fca78b240f4c418a582cc4bc252f106a9 Mon Sep 17 00:00:00 2001 From: Webster Sheets Date: Sun, 22 Nov 2020 19:15:30 -0500 Subject: [PATCH] Use PiGuiView instead of UIView --- src/SectorView.cpp | 9 ++------- src/SectorView.h | 7 +++---- src/SystemView.cpp | 6 +----- src/SystemView.h | 6 +++--- src/pigui/PiGuiView.h | 7 +++---- 5 files changed, 12 insertions(+), 23 deletions(-) diff --git a/src/SectorView.cpp b/src/SectorView.cpp index 3fe9f2271..2a2bfb1aa 100644 --- a/src/SectorView.cpp +++ b/src/SectorView.cpp @@ -95,7 +95,7 @@ void SectorView::InputBinding::RegisterBindings() } SectorView::SectorView(Game *game) : - UIView(), + PiGuiView("sector-view"), InputBindings(Pi::input), m_galaxy(game->GetGalaxy()) { @@ -128,7 +128,7 @@ SectorView::SectorView(Game *game) : } SectorView::SectorView(const Json &jsonObj, Game *game) : - UIView(), + PiGuiView("sector-view"), InputBindings(Pi::input), m_galaxy(game->GetGalaxy()) { @@ -383,8 +383,6 @@ void SectorView::Draw3D() m_disk->SetColor(Color(0, 0, 204)); m_disk->Draw(m_renderer); m_renderer->ResetDepthRange(); - - UIView::Draw3D(); } void SectorView::SetHyperspaceTarget(const SystemPath &path) @@ -1095,7 +1093,6 @@ void SectorView::OnSwitchTo() { m_renderer->SetViewport({ 0, 0, Graphics::GetScreenWidth(), Graphics::GetScreenHeight() }); Pi::input->AddInputFrame(&InputBindings); - UIView::OnSwitchTo(); Update(); } @@ -1241,8 +1238,6 @@ void SectorView::Update() m_fresnelMat->diffuse = Color::WHITE; m_jumpSphere.reset(new Graphics::Drawables::Sphere3D(m_renderer, m_fresnelMat, m_jumpSphereState, 4, 1.0f)); } - - UIView::Update(); } void SectorView::ShowAll() diff --git a/src/SectorView.h b/src/SectorView.h index d56d67847..5cc85866b 100644 --- a/src/SectorView.h +++ b/src/SectorView.h @@ -4,14 +4,13 @@ #ifndef _SECTORVIEW_H #define _SECTORVIEW_H -#include "Input.h" -#include "UIView.h" +#include "DeleteEmitter.h" #include "Input.h" #include "galaxy/Sector.h" #include "galaxy/SystemPath.h" #include "graphics/Drawables.h" #include "gui/Gui.h" -#include "DeleteEmitter.h" +#include "pigui/PiGuiView.h" #include #include #include @@ -23,7 +22,7 @@ namespace Graphics { class RenderState; } -class SectorView : public UIView, public DeleteEmitter { +class SectorView : public PiGuiView, public DeleteEmitter { public: SectorView(Game *game); SectorView(const Json &jsonObj, Game *game); diff --git a/src/SystemView.cpp b/src/SystemView.cpp index bb3fc1f7d..61dcbfa52 100644 --- a/src/SystemView.cpp +++ b/src/SystemView.cpp @@ -234,7 +234,7 @@ void SystemView::InputBindings::RegisterBindings() } SystemView::SystemView(Game *game) : - UIView(), + PiGuiView("system-view"), m_input(Pi::input), m_game(game), m_showL4L5(LAG_OFF), @@ -589,8 +589,6 @@ void SystemView::Draw3D() if (m_gridDrawing != GridDrawing::OFF) { DrawGrid(); } - - UIView::Draw3D(); } void SystemView::Update() @@ -633,8 +631,6 @@ void SystemView::Update() m_rot_x_to += m_input.mapViewPitch->GetValue() * ft * 60; m_rot_x_to = Clamp(m_rot_x_to, -80.0f, 80.0f); - - UIView::Update(); } void SystemView::MouseWheel(bool up) diff --git a/src/SystemView.h b/src/SystemView.h index 50918c158..bd14f256d 100644 --- a/src/SystemView.h +++ b/src/SystemView.h @@ -8,7 +8,7 @@ #include "DeleteEmitter.h" #include "Frame.h" #include "Input.h" -#include "UIView.h" +#include "pigui/PiGuiView.h" #include "graphics/Drawables.h" #include "matrix4x4.h" #include "vector3.h" @@ -112,13 +112,13 @@ struct Projectable Projectable() : type(NONE) {} }; -class SystemView : public UIView, public DeleteEmitter { +class SystemView : public PiGuiView, public DeleteEmitter { public: SystemView(Game *game); virtual ~SystemView(); virtual void Update(); virtual void Draw3D(); - virtual void OnSwitchTo() { Update(); Draw3D(); } + // virtual void OnSwitchTo() { Update(); Draw3D(); } Projectable* GetSelectedObject(); void SetSelectedObject(Projectable::types type, Projectable::bases base, SystemBody *sb); diff --git a/src/pigui/PiGuiView.h b/src/pigui/PiGuiView.h index 422c49ffb..98748a716 100644 --- a/src/pigui/PiGuiView.h +++ b/src/pigui/PiGuiView.h @@ -4,11 +4,10 @@ #pragma once #include "../View.h" -#include "PiGui.h" -// replacement for UIView. Currently a shim, this class should be able to -// dispatch to lua-registered handler functions and call them during the Draw3D -// method. +// Replacement for UIView. This class dispatches to lua-registered pigui draw +// functions when DrawPiGui() is called. +// TODO: support rendering to a debug window during the Update() and Draw3D() methods. class PiGuiView : public View { public: PiGuiView(std::string name) :