From ff117775641cf4dbd24f71d8b3ca9ad9215eba2e Mon Sep 17 00:00:00 2001 From: Allanis Date: Sat, 20 Jan 2018 17:06:09 +0000 Subject: [PATCH] [Change] Some shortcut key changes. [Add] Launching after landing. --- icons/blastoff.png | Bin 0 -> 336 bytes icons/hyperspace_f8.png | Bin 371 -> 361 bytes icons/labels_off.png | Bin 689 -> 687 bytes icons/labels_on.png | Bin 250 -> 243 bytes icons/sectorview_f6_systeminfo.png | Bin 490 -> 491 bytes icons/wheels_down.png | Bin 460 -> 466 bytes icons/wheels_up.png | Bin 454 -> 464 bytes icons/zoom_in_f7.png | Bin 426 -> 438 bytes icons/zoom_out_f8.png | Bin 419 -> 410 bytes src/player.cpp | 128 ++++++++++++++--------------- src/sector_view.cpp | 6 +- src/ship.cpp | 59 +++++++++---- src/ship.h | 6 +- src/system_view.cpp | 4 +- src/world_view.cpp | 27 +++++- src/world_view.h | 3 + 16 files changed, 145 insertions(+), 88 deletions(-) create mode 100644 icons/blastoff.png diff --git a/icons/blastoff.png b/icons/blastoff.png new file mode 100644 index 0000000000000000000000000000000000000000..398cb3ea997b0a3c16c1b4b685a8a75cd314fe8c GIT binary patch literal 336 zcmeAS@N?(olHy`uVBq!ia0vp^azHG`!2~2D75(ej@)Wnk16ovB4 zk_-iRPv3y>Mm}+%qP?Cjjv*GOlXEh&5*P3$BrT9!u<)YJ5$(O#5A=q{tbC|F)9ta5 zU?gMM<(VH|D`x1)y`HIIBGUg-XGzukGa^o%J7*j`>$Gs^j!Ep_M4CcNzaH=8;o({P z=jW3p**4#lbvDenQKdBhS0vm1m!_qrPo&=Z&F+cIH55GbnJkMh d#&|6`%vc!XsB5@=D_s4yX; z9EhvTbzC?L3}Gs*MQm6BzW#ojqSw!={sTNHrQ#CRSePdFk+9SOc%X!%^wc%Oq&-&v z9-5ooXvAW?Y95h>=rrx~Hu3|o>e@J+COPPw{=$$E`eBHBg|g*RpqzQ8`6P7Ic1Ucs z5lUz}!#B8*7bu~38=D_2$&Fs z1926v+h$43`-FIVVn^{#5IbsP*v_Lp<4^anU-*rzO_veX|EL+ zXR4FkXv8ACsxCDRk!d>SedGYJYG|BH6CZRtN8$RSR{ssI3RkzJ2?_%lng? zo4hg);sf+_{hx{HJ0IV7K0YcJs+0f{(lzA(0RA%3Ewr3f5dZ)H07*qoM6N<$f@*Fj AnE(I) diff --git a/icons/labels_on.png b/icons/labels_on.png index e3ce68707a9e3424940c8d23d93145fcb2e1b280..461ed66d25f159171a82aa92edd7096fefa1dc6e 100644 GIT binary patch delta 56 zcmeyx_?dBnABQA2tB8xjiuV)4G#C>m)`uvxr$t;gJRQLCLgX5Q#RS<8hWkIQU;qM7 LS3j3^P6kHnG#Jw-)`zHPN?hyNvLaO>Z+Y^xg8H?*P{~`S1~}1cz1AJJix-Vv2-+Pq3`@iY8KL&+P8nN0&O zo=+gQ_yi*U3Tt`zl5bwF%X*>4IlFgw3QX19aPL4K_JYDL;Jtl_1)^bLzA_NORWcUl zYU@y+O2)SkkUWFD@8 zVE^cste0qs>AKd^>oYLj-VxpUS^Y0AdR&Ehql&(x(mFr{lg+1Is3`Fb1DSb$lK5pr h_J3I+ODHE^*I$4OZ}t8IzrFwf002ovPDHLkV1k_8xyS$j delta 386 zcmV-|0e$}K1L^~iO$i1E3l9f1ho5$lRw#d0NklF>!q3&%)#L)FqaGCy#sMP@JqXZ`}!Un2nGiF3!@;oOwK@$ zw+{6oO@{Z?*0n! z_m6(bdWBY)u4^s4JOT6VonYELYyQPUPpU9)RMCG_SO-YJWb>()DoT9AKvFED)v`j| g|FT13S*Mu#6B_++3Oe-M@c;k-07*qoM6N<$f?M{ng#Z8m diff --git a/icons/wheels_down.png b/icons/wheels_down.png index 0ca99613b5a0aa8c536848187547e15a9eaff819..e5f0716c529144549cbc178f2a1516bb43ea3cfd 100644 GIT binary patch delta 362 zcmV-w0hRvD1JVPKO$i7Y3kM2}8TSs6Rw#czNkl8fQf`dfJ*n=+m z4epjphYqEq-=?Et}Cr5ZpaqZmsS+4c+9{rZb@XxWj*I z7?*KX#PwNnINw91KQeIkhZ{3m(U@N&+L+d7f8QMF^2oLI@(}d9HZ; zoA+oNef&Mj!S~nud2>>=(Uj7nC=gariX)-%)o!YjIh*HWy z&~XRVH)x^{KL51(Qgzw1V2dM!E3yvq*~I|(5b~Bbr2bRTS}-qXfd{2+lr$}AMoSPaVIC) zBygSOUQT>HugB5Z{+#X4y-(UT>Z4O@^znYy5Zk&tiEGqnb}j$}o21SKt#)wj+{u4B zq|5E6hugorm6gv4^I&Q zY_n~i=W!g*Z|DD8>)w&!oC_%kA^J!N5mIo@E&i5fYNb?FRg_YFq?96}QfeSq|3{nj z>F1<3pC2#n%ZpMo#*W7$BI@9X=r~jkV{9N-uXvLV7hzEph=_>##`C;z5l)agT15bG zct4b72>`zDFYlK6a(JzEcEdPCt7y1oKj>puz1A*VZT$fY09+?~m0 zy@9`Zg7L)r!|FV`-0O0$ov(~*)z8k_pm#U3j@Z|ONnEQw^K$_pS#M6cq}L9CpF4k9 zhYYzxz42Sx&vn73Dy5vz=>|1l z(4~)`M{{_4ee4HEE!8-V2_cB6wbn{nBO)Orj^hamk}lG^t`QLtO(YD%bdgR#XV)13 w99|Ah(*QseMa!$D3679KlQ2$_?lo zFTjjFjR(k3Fgbt?y)#_EvEv5RUc%an)*`wD7Gwc=L$TSGqy(U<0iY;ZzA*T#UwfF-$<+6Z#ovFT z{De#?J$KEi?CY3%;hDPD`KoG!L32rXw~yA#&K+kNBhn^;Y?1ZOWEm-?UemFG7qtvs z&rU64!+0nD+RpOnG8E!JWi%x;E@M@z;ii{gBrC)>}@c$_h|u^l$E4WWIt z%Fpxx&QzG07*qoM6N<$f`j9e4FCWD diff --git a/icons/zoom_out_f8.png b/icons/zoom_out_f8.png index d341ccea891507ed4dd86f7ae40c910f3016ea81..84faaf067a4c06f9c4b83c62350194ef53a3fde6 100644 GIT binary patch delta 306 zcmV-20nPrS1DXSnO$i7Y3kfe-o({*6Rw#c5NklwPGQC^*~ zJwU~qFG3s3b;eeOuB_*lr{jTK09sgYtM#p906GBxP0Qs+N$>xzP^+tKj(m2!NHtnGy`WA1L5ml3}k$kYuc;Gcm6w zzdtSaJDkSv1)(%{V$ys@)_H2us1qP>5C^JJFRr8OJ++?bd+?>uRY(bn@X2RjQR3=r z1dPdK33o08cj$sv6Q^l;fdg!$QPLjbC1>LUb|5Z*KkRCV;c6eC`Tzg`07*qoM6N<$ Ef)aO%=>Px# delta 315 zcmV-B0mS~A1ET|wO$i1E6B|1wbH;3uRw#cENklST5IhhK%cKn(xQkc- zDLqXFcu}AqAPs#a7KqZZ0h^>wMVrFl7-O)3aH9Cf_UnE3=YUJbF$i%O4lEt1s7h&1 zq5R3SrH$n(rB&%t*HdKTcOdHkEv>e3eJKb)+W|n`u>6v^k3VOq)zzh6CCh&6hOK|A z^1ps3D*`pwI$v#vBz81q?D3XSkW*EC!)h4;P%)e-Ku|ij3$|hg$ zmizr(#`g)nGPd1l_>8VIVV6-hDsK>ax=|;0Vd@=RkNiEv(&#EpV&uycH7z|lJU`d) zcqT_Os+Ym3;S^Fvo$E+fT%v9`-!LcRpjoc#hBHA 10) { - dBodySetAngularVel(m_body, 0, 0, 0); - } + if(L3D::KeyState(SDLK_SPACE) || (L3D::MouseButtonState(1) && L3D::MouseButtonState(1) && L3D::MouseButtonState(3))) SetGunState(0,1); + else SetGunState(0,0); - if(GetNavTarget() && L3D::KeyState(SDLK_END)) { - /* Temp test: Kill ("end") the target. */ - Space::KillBody(GetNavTarget()); + /* No torques at huge time accels -- ODE doesn't like it. */ + if(time_accel <= 10) { + if(L3D::GetCamType() != L3D::CAM_EXTERNAL) { + if(L3D::KeyState(SDLK_LEFT)) angThrust.y += 1; + if(L3D::KeyState(SDLK_RIGHT)) angThrust.y += -1; + if(L3D::KeyState(SDLK_UP)) angThrust.x += -1; + if(L3D::KeyState(SDLK_DOWN)) angThrust.x += 1; + } + /* Rotation damping. */ + vector3d damping = CalcRotDamping(); + + angThrust.x -= damping.x; + angThrust.y -= damping.y; + angThrust.z -= damping.z; + + /* + * Dividing by time step so controls don't go insane when + * used at 10x accel. + */ + angThrust *= 1.0f/ta2; + SetAngThrusterState(0, angThrust.x); + SetAngThrusterState(1, angThrust.y); + SetAngThrusterState(2, angThrust.z); + } + if(time_accel > 10) { + dBodySetAngularVel(m_body, 0, 0, 0); + } } } diff --git a/src/sector_view.cpp b/src/sector_view.cpp index f438f4b..79dd62f 100644 --- a/src/sector_view.cpp +++ b/src/sector_view.cpp @@ -19,15 +19,15 @@ SectorView::SectorView(void) : GenericSystemView() { Gui::ImageButton* ib = new Gui::ImageButton("icons/sectorview_f6_systeminfo.png"); ib->onClick.connect(sigc::mem_fun(this, &SectorView::OnClickSystemInfo)); - ib->SetShortcut(SDLK_F6, KMOD_NONE); + ib->SetShortcut(SDLK_F5, KMOD_NONE); m_rightButtonBar->Add(ib, 2, 2); m_zoomInButton = new Gui::ImageButton("icons/zoom_in_f7.png"); - m_zoomInButton->SetShortcut(SDLK_F7, KMOD_NONE); + m_zoomInButton->SetShortcut(SDLK_F6, KMOD_NONE); m_rightButtonBar->Add(m_zoomInButton, 34, 2); m_zoomOutButton = new Gui::ImageButton("icons/zoom_out_f8.png"); - m_zoomOutButton->SetShortcut(SDLK_F8, KMOD_NONE); + m_zoomOutButton->SetShortcut(SDLK_F7, KMOD_NONE); m_rightButtonBar->Add(m_zoomOutButton, 66, 2); m_gluDiskDlist = glGenLists(1); diff --git a/src/ship.cpp b/src/ship.cpp index 11dc6a4..a3932c2 100644 --- a/src/ship.cpp +++ b/src/ship.cpp @@ -23,16 +23,17 @@ static ObjParams params = { }; Ship::Ship(ShipType::Type shipType) : DynamicBody() { - m_isLanded = false; - m_testLanded = false; - m_wheelTransition = 0; - m_wheelState = 0; - m_dockedWith = 0; - dockingTimer = 0; - m_navTarget = 0; - m_combatTarget = 0; - m_shipType = shipType; - m_angThrusters[0] = m_angThrusters[1] = m_angThrusters[2] = 0; + m_flightState = FLYING; + m_testLanded = false; + m_launchLockTimeout = 0; + m_wheelTransition = 0; + m_wheelState = 0; + m_dockedWith = 0; + dockingTimer = 0; + m_navTarget = 0; + m_combatTarget = 0; + m_shipType = shipType; + m_angThrusters[0] = m_angThrusters[1] = m_angThrusters[2] = 0; m_laserCollisionObj.owner = this; m_equipment = EquipSet(shipType); for(int i = 0; i < ShipType::GUNMOUNT_MAX; i++) { @@ -56,7 +57,8 @@ void Ship::UpdateMass(void) { bool Ship::OnCollision(Body* b, Uint32 flags) { if(b->GetType() == Object::PLANET) { - if(m_isLanded) return false; + /* Geoms still enabled when landed. */ + if(m_flightState != FLYING) return false; else m_testLanded = true; } return true; @@ -82,7 +84,9 @@ void Ship::ClearThrusterState(void) { SetAngThrusterState(1, 0.0f); SetAngThrusterState(2, 0.0f); - for(int i = 0; i < ShipType::THRUSTER_MAX; i++) m_thrusters[i] = 0; + if(m_launchLockTimeout == 0) { + for(int i = 0; i < ShipType::THRUSTER_MAX; i++) m_thrusters[i] = 0; + } } /* Hyperspace range is: @@ -107,13 +111,34 @@ void Ship::CalcStats(shipstats_t* stats) { stats->hyperspace_range = 200 * hyperclass * hyperclass / stats->total_mass; } +void Ship::Blastoff(void) { + if(m_flightState != LANDED) return; + + ClearThrusterState(); + m_flightState = FLYING; + m_testLanded = false; + m_dockedWith = 0; + m_launchLockTimeout = 1.0; /* One second of applying thrusters. */ + + Enable(); + const double planetRadius = GetFrame()->m_astroBody->GetRadius(); + vector3d up = vector3d::Normalize(GetPosition()); + dBodySetLinearVel(m_body, 0, 0, 0); + dBodySetAngularVel(m_body, 0, 0, 0); + dBodySetForce(m_body, 0, 0, 0); + dBodySetTorque(m_body, 0, 0, 0); + SetPosition(up*planetRadius+10.0*up); + SetThrusterState(ShipType::THRUSTER_TOP, 1.0f); +} + void Ship::TestLanded(void) { + if(m_launchLockTimeout != 0) return; if(GetFrame()->m_astroBody) { const dReal* vel = dBodyGetLinearVel(m_body); double speed = vector3d(vel[0], vel[1], vel[2]).Length(); const double planetRadius = GetFrame()->m_astroBody->GetRadius(); - if(speed < 15) { + if(speed < 20) { printf("Landed!\n"); /* Orient the damn thing right! */ @@ -138,7 +163,7 @@ void Ship::TestLanded(void) { */ dBodyDisable(m_body); ClearThrusterState(); - m_isLanded = true; + m_flightState = LANDED; m_testLanded = false; } } @@ -148,6 +173,10 @@ void Ship::TimeStepUpdate(const float timeStep) { dockingTimer = (dockingTimer-timeStep > 0 ? dockingTimer-timeStep : 0); /* ODE tri mesh likes to know our old position. */ TriMeshUpdateLastPos(); + + m_launchLockTimeout -= timeStep; + if(m_launchLockTimeout < 0) m_launchLockTimeout = 0; + const ShipType& stype = GetShipType(); for(int i = 0; i < ShipType::THRUSTER_MAX; i++) { float force = timeStep * stype.linThrust[i] * m_thrusters[i]; @@ -302,7 +331,7 @@ static void render_coll_mesh(const CollMesh* m) { } void Ship::Render(const Frame* camFrame) { - if((!dBodyIsEnabled(m_body)) && !m_isLanded) return; + if((!dBodyIsEnabled(m_body)) && !m_flightState) return; const ShipType& stype = GetShipType(); params.angthrust[0] = m_angThrusters[0]; params.angthrust[1] = m_angThrusters[1]; diff --git a/src/ship.h b/src/ship.h index ea32331..bc22bf1 100644 --- a/src/ship.h +++ b/src/ship.h @@ -34,11 +34,14 @@ public: void UpdateMass(void); vector3d CalcRotDamping(); void SetWheelState(bool down); + void Blastoff(void); float GetDockingTimer(void) { return dockingTimer; } void SetDockingTimer(float t) { dockingTimer = t; } virtual void TimeStepUpdate(const float timeStep); virtual void NotifyDeath(const Body* const dyingBody); virtual bool OnCollision(Body* b, Uint32 flags); + enum FlightState { FLYING, LANDED }; + FlightState GetFlightState(void) { return m_flightState; } class LaserObj : public Object { public: @@ -51,14 +54,15 @@ protected: void RenderLaserfire(void); SpaceStation* m_dockedWith; - bool m_isLanded; enum ShipType::Type m_shipType; Uint32 m_gunState[ShipType::GUNMOUNT_MAX]; private: bool IsFiringLasers(void); void TestLanded(void); + FlightState m_flightState; bool m_testLanded; + float m_launchLockTimeout; float m_wheelState; float m_wheelTransition; diff --git a/src/system_view.cpp b/src/system_view.cpp index 04e3787..91893fe 100644 --- a/src/system_view.cpp +++ b/src/system_view.cpp @@ -12,11 +12,11 @@ SystemView::SystemView(void): View() { Add(m_timePoint, 24, 5); m_zoomInButton = new Gui::ImageButton("icons/zoom_in_f7.png"); - m_zoomInButton->SetShortcut(SDLK_F7, KMOD_NONE); + m_zoomInButton->SetShortcut(SDLK_F6, KMOD_NONE); m_rightButtonBar->Add(m_zoomInButton, 34, 2); m_zoomOutButton = new Gui::ImageButton("icons/zoom_out_f8.png"); - m_zoomOutButton->SetShortcut(SDLK_F8, KMOD_NONE); + m_zoomOutButton->SetShortcut(SDLK_F7, KMOD_NONE); m_rightButtonBar->Add(m_zoomOutButton, 66, 2); Gui::ImageButton* b = new Gui::ImageButton("icons/sysview_accel_r3.png", diff --git a/src/world_view.cpp b/src/world_view.cpp index 805ea0f..1620508 100644 --- a/src/world_view.cpp +++ b/src/world_view.cpp @@ -22,24 +22,33 @@ WorldView::WorldView(void): View() { Add(commsOptions, 10, 20); Gui::MultiStateImageButton* wheels_button = new Gui::MultiStateImageButton(); - wheels_button->SetShortcut(SDLK_F7, KMOD_NONE); + wheels_button->SetShortcut(SDLK_F6, 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); Gui::MultiStateImageButton* labels_button = new Gui::MultiStateImageButton(); - labels_button->SetShortcut(SDLK_9, KMOD_NONE); + labels_button->SetShortcut(SDLK_8, KMOD_NONE); labels_button->AddState(1, "icons/labels_on.png"); labels_button->AddState(0, "icons/labels_off.png"); labels_button->onClick.connect(sigc::mem_fun(this, &WorldView::OnChangeLabelsState)); m_rightButtonBar->Add(labels_button, 98, 2); m_hyperspaceButton = new Gui::ImageButton("icons/hyperspace_f8.png"); - m_hyperspaceButton->SetShortcut(SDLK_F8, KMOD_NONE); + m_hyperspaceButton->SetShortcut(SDLK_F7, KMOD_NONE); m_hyperspaceButton->onClick.connect(sigc::mem_fun(this, &WorldView::OnClickHyperspace)); m_rightButtonBar->Add(m_hyperspaceButton, 66, 2); + launchButton = new Gui::ImageButton("icons/blastoff.png"); + launchButton->SetShortcut(SDLK_F5, KMOD_NONE); + launchButton->onClick.connect(sigc::mem_fun(this, &WorldView::OnClickBlastoff)); + m_rightButtonBar->Add(launchButton, 2, 2); + + flightStatus = new Gui::Label(""); + flightStatus->SetColor(1, .7, 0); + m_rightRegion2->Add(flightStatus, 10, 3); + m_bgstarsDlist = glGenLists(1); glNewList(m_bgstarsDlist, GL_COMPILE); @@ -70,6 +79,10 @@ void WorldView::OnChangeLabelsState(Gui::MultiStateImageButton* b) { labelsOn = b->GetState(); } +void WorldView::OnClickBlastoff(void) { + L3D::player->Blastoff(); +} + void WorldView::OnClickHyperspace(void) { StarSystem* s = L3D::GetSelectedSystem(); if(s /* && isn's current system. */) { @@ -163,6 +176,14 @@ void WorldView::Update(void) { } else { //commsOptions->HideAll(); } + + if(L3D::player->GetFlightState() == Ship::LANDED) { + flightStatus->SetText("Landed"); + launchButton->Show(); + } else { + flightStatus->SetText("Manual Controls"); + launchButton->Hide(); + } } Gui::Button* WorldView::AddCommsOption(std::string msg, int ypos) { diff --git a/src/world_view.h b/src/world_view.h index 01c967a..ed71573 100644 --- a/src/world_view.h +++ b/src/world_view.h @@ -16,6 +16,7 @@ public: private: Gui::Button* AddCommsOption(const std::string msg, int ypos); void OnClickHyperspace(void); + void OnClickBlastoff(void); void OnChangeWheelsState(Gui::MultiStateImageButton* b); void OnChangeLabelsState(Gui::MultiStateImageButton* b); virtual bool OnMouseDown(Gui::MouseButtonEvent* e); @@ -23,6 +24,8 @@ private: Gui::ImageButton* m_hyperspaceButton; GLuint m_bgstarsDlist; Gui::Fixed* commsOptions; + Gui::Label* flightStatus; + Gui::ImageButton* launchButton; bool labelsOn; };