diff --git a/icons/wheels_down.png b/icons/wheels_down.png new file mode 100644 index 0000000..0ca9961 Binary files /dev/null and b/icons/wheels_down.png differ diff --git a/icons/wheels_up.png b/icons/wheels_up.png new file mode 100644 index 0000000..9b2af35 Binary files /dev/null and b/icons/wheels_up.png differ diff --git a/src/ship.cpp b/src/ship.cpp index 6442620..c1ee5a2 100644 --- a/src/ship.cpp +++ b/src/ship.cpp @@ -7,6 +7,8 @@ #include "space.h" Ship::Ship(ShipType::Type shipType) : RigidBody() { + m_wheelTransition = 0; + m_wheelState = 0; m_dockedWith = 0; m_mesh = 0; m_shipType = shipType; @@ -95,6 +97,12 @@ void Ship::AITurn(void) { dGeomSetData(ray, static_cast(&m_laserCollisionObj)); m_tempLaserGeom[i] = ray; } + + if(m_wheelTransition != 0.0f) { + m_wheelState += m_wheelTransition*timeStep*0.001; + m_wheelState = CLAMP(m_wheelState, 0, 1); + if((m_wheelState == 0) || (m_wheelState == 1)) m_wheelTransition = 0; + } } const ShipType& Ship::GetShipType(void) { @@ -124,6 +132,11 @@ void Ship::SetGunState(int idx, int state) { m_gunState[idx] = state; } +void Ship::SetWheelState(bool down) { + if(down) m_wheelTransition = 1; + else m_wheelTransition = -1; +} + /* Assumed to be at model coords. */ void Ship::RenderLaserfire(void) { const ShipType& stype = GetShipType(); @@ -167,6 +180,7 @@ void Ship::Render(const Frame* camFrame) { params.pAnim[ASRC_MINFRAC] = L3D::GetGameTime() / 60; params.pAnim[ASRC_HOURFRAC] = L3D::GetGameTime() / 3600.0f; params.pAnim[ASRC_DAYFRAC] = L3D::GetGameTime() / (24*3600.0f); + params.pAnim[ASRC_GEAR] = m_wheelState; strncpy(params.pText[0], GetLabel().c_str(), sizeof(params.pText)); diff --git a/src/ship.h b/src/ship.h index 43f09ae..a51cc73 100644 --- a/src/ship.h +++ b/src/ship.h @@ -29,6 +29,7 @@ public: const ShipType& GetShipType(void); void CalcStats(shipstats_t* stats); void UpdateMass(void); + void SetWheelState(bool down); class LaserObj : public Object { public: @@ -45,6 +46,9 @@ protected: ObjMesh* m_mesh; Uint32 m_gunState[ShipType::GUNMOUNT_MAX]; private: + float m_wheelState; + float m_wheelTransition; + float m_thrusters[ShipType::THRUSTER_MAX]; float m_angThrusters[3]; dGeomID m_tempLaserGeom[ShipType::GUNMOUNT_MAX]; diff --git a/src/world_view.cpp b/src/world_view.cpp index 549e391..ed176cc 100644 --- a/src/world_view.cpp +++ b/src/world_view.cpp @@ -11,6 +11,13 @@ static const float lightCol[] = { 1, 1, .9, 0 }; WorldView::WorldView(void): View() { SetTransparency(true); + Gui::MultiStateImageButton* wheels_button = new Gui::MultiStateImageButton(); + wheels_button->SetShortcut(SDLK_F7, KMOD_NONE); + wheels_button->AddState(0, "icons/wheels_up.png"); + wheels_button->AddState(1, "icons/wheels_down.png"); + wheels_button->onClick.connect(sigc::mem_fun(this, &WorldView::OnChangeWheelsState)); + m_rightButtonBar->Add(wheels_button, 34, 2); + m_hyperspaceButton = new Gui::ImageButton("icons/hyperspace_f8.png"); m_hyperspaceButton->SetShortcut(SDLK_F8, KMOD_NONE); m_hyperspaceButton->onClick.connect(sigc::mem_fun(this, &WorldView::OnClickHyperspace)); @@ -37,6 +44,10 @@ WorldView::WorldView(void): View() { glEndList(); } +void WorldView::OnChangeWheelsState(Gui::MultiStateImageButton* b) { + L3D::player->SetWheelState(b->GetState()); +} + void WorldView::OnClickHyperspace(void) { StarSystem* s = L3D::GetSelectedSystem(); if(s /* && isn's current system. */) { diff --git a/src/world_view.h b/src/world_view.h index 77d86c8..4fcaeb5 100644 --- a/src/world_view.h +++ b/src/world_view.h @@ -12,6 +12,7 @@ public: private: void OnClickHyperspace(void); + void OnChangeWheelsState(Gui::MultiStateImageButton* b); Gui::ImageButton* m_hyperspaceButton; GLuint m_bgstarsDlist; };