From 50726de10284f27a5e84d30c49a89f0314017efd Mon Sep 17 00:00:00 2001
From: Allanis <allanis.saracraft.studios@gmail.com>
Date: Sun, 24 Dec 2017 18:45:22 +0000
Subject: [PATCH] [Add] Add toggle labels button.

---
 icons/labels_off.png | Bin 0 -> 689 bytes
 icons/labels_on.png  | Bin 0 -> 250 bytes
 src/player.cpp       |   2 +-
 src/world_view.cpp   |  12 ++++++++++++
 src/world_view.h     |   3 +++
 5 files changed, 16 insertions(+), 1 deletion(-)
 create mode 100644 icons/labels_off.png
 create mode 100644 icons/labels_on.png

diff --git a/icons/labels_off.png b/icons/labels_off.png
new file mode 100644
index 0000000000000000000000000000000000000000..d0303b9248082d14c2983cc01e92e9fbad6d8ea6
GIT binary patch
literal 689
zcmV;i0#5yjP)<h;3K|Lk000e1NJLTq0015U000&U0ssI2SOL4300001b5ch_0Itp)
z=>Px#32;bRa{vGf6951U69E94oEQKA00(qQO+^RT2n`f31`zWx3IG5A8FWQhbVF}#
zZDnqB07G(RVRU6=Aa`kWXdp*PO;A^X4i^9b0v<_3K~y-)V{B<^VW16QVxSoqH5v`D
zAaiP%YZw?9TK?jUSdshpH4p3)xqttLqtkUqClZWiU|=x4&tSWEF4Nz?4-Ji8sHy+p
z<%LTro<6O&Z41-izYGiv8vFN=W^~Kn7LB|6MDFinU|<k>^oYaQSiGl)+rfc>f#Lnk
znJ;#1`~UYZM5SnbeRXX$rg5#!tvFr%MnUn7qN32FM@)bJ{y2N~u7}4JH;>OEBBpCr
zas2+xz`*cXRP>s&%QI$H1|(Ck0!FM^M)CA%on1Rve*R=&VEE6(^q-ND>F?iv%*>Ar
zjjlU7A%_wPVGRNIO-(<Gi0JOzF7WIb<G+853=9km4DaOR&inb3nL-#C7?4Bo)7rI9
zBO?C)`2*o9Xlq-gB(X?J;tE`%0tAxIjMuN@`tTlE@Pm}pWp~dvii()(YwBu<%`%z?
z_Cd`3CLs98zz`xR@a&nz@}(m8?~|V!HTUm>>pvS9bT%mXg0KHS78V8u2G$=xZ0FC_
z+`kX2#+IfQcrc(FU7ntr#_&%Arc<=OK7HPt>e}k4O&g@TyIB<!AmSSP_oe;)jWucG
z3~T-uFRT~NXaDw%;s1ZExmk1nKDfo}k@OM{>t9@4@8slua&cXEa>kmKuRA*3aCBl|
zV7Ngjqocc;@!vm=FJIWcefz=7`;(iSyfP2s1N3zLpNZ)^AK!OAJ}MWglmHUaHRS*R
X{xZ=mw47BD00000NkvXXu0mjfs1QEc

literal 0
HcmV?d00001

diff --git a/icons/labels_on.png b/icons/labels_on.png
new file mode 100644
index 0000000000000000000000000000000000000000..e3ce68707a9e3424940c8d23d93145fcb2e1b280
GIT binary patch
literal 250
zcmeAS@N?(olHy`uVBq!ia0vp^azHG`!2~2D7<bPAQjEnx?oJHr&dIz4aySb-B8wRq
zxP?KOkzv*x37{Z*iKnkC`wb3W5k1-F-jmCLLXst}5hc#~xw)x%B@E6*sfi`2DGKG8
zB^e6tp1uL$jeO!jMd_X{jv*GOlXEh&5*P3$BrTAXFqN8r(e#Wd5IG;Xs&it_wEY^K
z8+UD+74kT0cJxN+UiZ5lo{BFRow9yB;xrM<YR&hJJv)K-^|WPT6@gYFhop>;WJ+A?
o*|H*4A#Zu|w1r+8mu=QC&YdTFyI^xfJ<v)9Pgg&ebxsLQ0KS<}+yDRo

literal 0
HcmV?d00001

diff --git a/src/player.cpp b/src/player.cpp
index e222bd5..db28bf6 100644
--- a/src/player.cpp
+++ b/src/player.cpp
@@ -177,7 +177,7 @@ void Player::DrawHUD(const Frame* cam_frame) {
   Gui::Screen::EnterOrtho();
   glColor3f(.7, .7, .7);
 
-  {
+  if(L3D::world_view->GetShowLabels()) {
     for(std::list<Body*>::iterator i = Space::bodies.begin(); i != Space::bodies.end(); ++i) {
       if((L3D::GetCamType() != L3D::CAM_EXTERNAL) && (*i == this)) continue;
       Body* b = *i;
diff --git a/src/world_view.cpp b/src/world_view.cpp
index 209aa8d..d261847 100644
--- a/src/world_view.cpp
+++ b/src/world_view.cpp
@@ -15,6 +15,7 @@ WorldView::WorldView(void): View() {
   float size[2];
   GetSize(size);
 
+  labelsOn = true;
   SetTransparency(true);
 
   commsOptions = new Fixed(size[0], size[1]/2);
@@ -28,6 +29,13 @@ WorldView::WorldView(void): View() {
   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->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->onClick.connect(sigc::mem_fun(this, &WorldView::OnClickHyperspace));
@@ -59,6 +67,10 @@ void WorldView::OnChangeWheelsState(Gui::MultiStateImageButton* b) {
   L3D::player->SetWheelState(b->GetState());
 }
 
+void WorldView::OnChangeLabelsState(Gui::MultiStateImageButton* b) {
+  labelsOn = 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 31552e0..5e3531e 100644
--- a/src/world_view.h
+++ b/src/world_view.h
@@ -13,14 +13,17 @@ public:
   matrix4x4d viewingRotation;
   static const float PICK_OBJECT_RECT_SIZE;
   void UpdateCommsOptions(void);
+  bool GetShowLabels(void) { return labelsOn; }
 private:
   Gui::Button* AddCommsOption(const std::string msg, int ypos);
   void OnClickHyperspace(void);
   void OnChangeWheelsState(Gui::MultiStateImageButton* b);
+  void OnChangeLabelsState(Gui::MultiStateImageButton* b);
   virtual bool OnMouseDown(Gui::MouseButtonEvent* e);
   Body* PickBody(const float screenX, const float screenY) const;
   Gui::ImageButton* m_hyperspaceButton;
   GLuint m_bgstarsDlist;
   Gui::Fixed* commsOptions;
+  bool labelsOn;
 };