make the new ui available to all in-game views

master
Robert Norris 2013-01-09 17:13:14 +11:00
parent e49eda3d7c
commit e357b24d29
12 changed files with 50 additions and 20 deletions

View File

@ -23,7 +23,7 @@ static const float ZOOM_IN_SPEED = 2;
static const float ZOOM_OUT_SPEED = 1.f/ZOOM_IN_SPEED;
static const float WHEEL_SENSITIVITY = .2f; // Should be a variable in user settings.
GalacticView::GalacticView() :
GalacticView::GalacticView() : UIView(),
m_quad(Graphics::TextureBuilder::UI("galaxy.bmp").CreateTexture(Gui::Screen::GetRenderer()))
{
@ -140,6 +140,8 @@ void GalacticView::Draw3D()
m_labels->Clear();
PutLabels(-vector3d(offset_x, offset_y, 0.0));
UIView::Draw3D();
}
void GalacticView::Update()
@ -158,6 +160,8 @@ void GalacticView::Update()
AnimationCurves::Approach(m_zoom, m_zoomTo, frameTime);
m_scaleReadout->SetText(stringf(Lang::INT_LY, formatarg("scale", int(0.5*Galaxy::GALAXY_RADIUS/m_zoom))));
UIView::Update();
}
void GalacticView::MouseWheel(bool up)

View File

@ -11,8 +11,9 @@
#include <string>
#include "View.h"
#include "graphics/RenderState.h"
#include "UIView.h"
class GalacticView: public View {
class GalacticView: public UIView {
public:
GalacticView();
virtual ~GalacticView();

View File

@ -16,7 +16,7 @@
#if WITH_OBJECTVIEWER
ObjectViewerView::ObjectViewerView(): View()
ObjectViewerView::ObjectViewerView(): UIView()
{
SetTransparency(true);
viewingDist = 1000.0f;
@ -115,11 +115,14 @@ void ObjectViewerView::Draw3D()
body->Render(m_renderer, 0, vector3d(0,0,-viewingDist), m_camRot);
}
UIView::Draw3D();
}
void ObjectViewerView::OnSwitchTo()
{
m_camRot = matrix4x4d::Identity();
UIView::OnSwitchTo();
}
void ObjectViewerView::Update()
@ -154,6 +157,8 @@ void ObjectViewerView::Update()
if (body && body->IsType(Object::TERRAINBODY)) m_vbox->ShowAll();
else m_vbox->HideAll();
UIView::Update();
}
void ObjectViewerView::OnChangeTerrain()

View File

@ -6,13 +6,13 @@
#include "libs.h"
#include "gui/Gui.h"
#include "View.h"
#include "UIView.h"
#if WITH_OBJECTVIEWER
class Body;
class ObjectViewerView: public View {
class ObjectViewerView: public UIView {
public:
ObjectViewerView();
virtual void Update();

View File

@ -43,7 +43,7 @@ enum DetailSelection {
static const float ZOOM_SPEED = 15;
static const float WHEEL_SENSITIVITY = .03f; // Should be a variable in user settings.
SectorView::SectorView()
SectorView::SectorView() : UIView()
{
InitDefaults();
@ -75,7 +75,7 @@ SectorView::SectorView()
InitObject();
}
SectorView::SectorView(Serializer::Reader &rd)
SectorView::SectorView(Serializer::Reader &rd) : UIView()
{
InitDefaults();
@ -482,6 +482,8 @@ void SectorView::Draw3D()
m_renderer->DrawLines(m_secLineVerts->GetNumVerts(), &m_secLineVerts->position[0], &m_secLineVerts->diffuse[0], m_alphaBlendState);
UpdateFactionToggles();
UIView::Draw3D();
}
void SectorView::SetHyperspaceTarget(const SystemPath &path)
@ -1111,6 +1113,8 @@ void SectorView::OnSwitchTo()
m_onKeyPressConnection =
Pi::onKeyPress.connect(sigc::mem_fun(this, &SectorView::OnKeyPressed));
UIView::OnSwitchTo();
Update();
UpdateSystemLabels(m_targetSystemLabels, m_hyperspaceTarget);
@ -1350,6 +1354,8 @@ void SectorView::Update()
m_jumpSphere.reset( new Graphics::Drawables::Sphere3D(fresnelMat, m_jumpSphereState, 3, 1.0f) );
m_jumpDisk.reset( new Graphics::Drawables::Disk(fresnelMat, m_jumpSphereState, 72, 1.0f) );
}
UIView::Update();
}
void SectorView::ShowAll()

View File

@ -6,6 +6,10 @@
#include "libs.h"
#include "gui/Gui.h"
#include "UIView.h"
#include <vector>
#include <set>
#include <string>
#include "View.h"
#include "galaxy/Sector.h"
#include "galaxy/SystemPath.h"
@ -13,7 +17,7 @@
#include "graphics/RenderState.h"
#include <set>
class SectorView: public View {
class SectorView: public UIView {
public:
SectorView();
SectorView(Serializer::Reader &rd);

View File

@ -17,7 +17,7 @@
#include "graphics/Drawables.h"
#include "Factions.h"
SystemInfoView::SystemInfoView()
SystemInfoView::SystemInfoView() : UIView()
{
SetTransparency(true);
m_refresh = false;
@ -425,6 +425,7 @@ void SystemInfoView::Draw3D()
PROFILE_SCOPED()
m_renderer->SetTransform(matrix4x4f::Identity());
m_renderer->ClearScreen();
UIView::Draw3D();
}
void SystemInfoView::Update()
@ -434,6 +435,7 @@ void SystemInfoView::Update()
m_refresh = false;
assert((OnSwitchTo(), !m_refresh));
}
UIView::Update();
}
void SystemInfoView::OnSwitchTo()
@ -445,6 +447,7 @@ void SystemInfoView::OnSwitchTo()
RefCountedPtr<StarSystem> currentSys = Pi::game->GetSpace()->GetStarSystem();
if ((!currentSys || currentSys->GetPath() != m_system->GetPath()) && Pi::sectorView->GetSelected() != m_selectedBodyPath)
m_refresh = true;
UIView::OnSwitchTo();
}
void SystemInfoView::NextPage()

View File

@ -6,14 +6,14 @@
#include "libs.h"
#include "gui/Gui.h"
#include "View.h"
#include "UIView.h"
#include <vector>
class StarSystem;
class SystemBody;
namespace Graphics { class Renderer; }
class SystemInfoView: public View {
class SystemInfoView: public UIView {
public:
SystemInfoView();
virtual void Update();

View File

@ -26,7 +26,7 @@ static const float WHEEL_SENSITIVITY = .1f; // Should be a variable in user set
// i don't know how to name it
static const double ROUGH_SIZE_OF_TURD = 10.0;
SystemView::SystemView()
SystemView::SystemView() : UIView()
{
SetTransparency(true);
@ -364,6 +364,8 @@ void SystemView::Draw3D()
PutSelectionBox(navTargetSystemBody, pos, Color::GREEN);
}
}
UIView::Draw3D();
}
void SystemView::Update()
@ -389,6 +391,8 @@ void SystemView::Update()
m_rot_x += motion[1]*20*ft;
m_rot_z += motion[0]*20*ft;
}
UIView::Update();
}
void SystemView::MouseWheel(bool up)

View File

@ -6,21 +6,19 @@
#include "libs.h"
#include "gui/Gui.h"
#include "View.h"
#include "UIView.h"
#include "graphics/Drawables.h"
class StarSystem;
class SystemBody;
class Orbit;
class SystemView: public View {
class SystemView: public UIView {
public:
SystemView();
virtual ~SystemView();
virtual void Update();
virtual void Draw3D();
protected:
virtual void OnSwitchTo() {}
private:
static const double PICK_OBJECT_RECT_SIZE;
void PutOrbit(const Orbit *orb, const vector3d &offset, const Color &color, double planetRadius = 0.0);

View File

@ -40,13 +40,13 @@ static const float WHEEL_SENSITIVITY = .05f; // Should be a variable in user set
static const float HUD_CROSSHAIR_SIZE = 24.0f;
static const Uint8 HUD_ALPHA = 87;
WorldView::WorldView(): View()
WorldView::WorldView(): UIView()
{
m_camType = CAM_INTERNAL;
InitObject();
}
WorldView::WorldView(Serializer::Reader &rd): View()
WorldView::WorldView(Serializer::Reader &rd): UIView()
{
m_camType = CamType(rd.Int32());
InitObject();
@ -424,6 +424,8 @@ void WorldView::Draw3D()
}
m_cameraContext->EndFrame();
UIView::Draw3D();
}
void WorldView::OnToggleLabels()
@ -950,10 +952,13 @@ void WorldView::Update()
Body* const target = PickBody(double(Gui::Screen::GetWidth())/2.0, double(Gui::Screen::GetHeight())/2.0);
SelectBody(target, false);
}
UIView::Update();
}
void WorldView::OnSwitchTo()
{
UIView::OnSwitchTo();
RefreshButtonStateAndVisibility();
}

View File

@ -7,7 +7,7 @@
#include "libs.h"
#include "gui/Gui.h"
#include "gui/GuiWidget.h"
#include "View.h"
#include "UIView.h"
#include "Serializer.h"
#include "SpeedLines.h"
#include "Background.h"
@ -22,7 +22,7 @@ class Ship;
class NavTunnelWidget;
namespace Gui { class TexturedQuad; }
class WorldView: public View {
class WorldView: public UIView {
public:
friend class NavTunnelWidget;
WorldView();