[Add] Add toggle labels button.

This commit is contained in:
Rtch90 2017-12-24 18:45:22 +00:00
parent 0e59178d77
commit 222751e772
5 changed files with 16 additions and 1 deletions

BIN
icons/labels_off.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 689 B

BIN
icons/labels_on.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 250 B

View File

@ -177,7 +177,7 @@ void Player::DrawHUD(const Frame* cam_frame) {
Gui::Screen::EnterOrtho(); Gui::Screen::EnterOrtho();
glColor3f(.7, .7, .7); glColor3f(.7, .7, .7);
{ if(L3D::world_view->GetShowLabels()) {
for(std::list<Body*>::iterator i = Space::bodies.begin(); i != Space::bodies.end(); ++i) { for(std::list<Body*>::iterator i = Space::bodies.begin(); i != Space::bodies.end(); ++i) {
if((L3D::GetCamType() != L3D::CAM_EXTERNAL) && (*i == this)) continue; if((L3D::GetCamType() != L3D::CAM_EXTERNAL) && (*i == this)) continue;
Body* b = *i; Body* b = *i;

View File

@ -15,6 +15,7 @@ WorldView::WorldView(void): View() {
float size[2]; float size[2];
GetSize(size); GetSize(size);
labelsOn = true;
SetTransparency(true); SetTransparency(true);
commsOptions = new Fixed(size[0], size[1]/2); 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)); wheels_button->onClick.connect(sigc::mem_fun(this, &WorldView::OnChangeWheelsState));
m_rightButtonBar->Add(wheels_button, 34, 2); 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 = new Gui::ImageButton("icons/hyperspace_f8.png");
m_hyperspaceButton->SetShortcut(SDLK_F8, KMOD_NONE); m_hyperspaceButton->SetShortcut(SDLK_F8, KMOD_NONE);
m_hyperspaceButton->onClick.connect(sigc::mem_fun(this, &WorldView::OnClickHyperspace)); 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()); L3D::player->SetWheelState(b->GetState());
} }
void WorldView::OnChangeLabelsState(Gui::MultiStateImageButton* b) {
labelsOn = b->GetState();
}
void WorldView::OnClickHyperspace(void) { void WorldView::OnClickHyperspace(void) {
StarSystem* s = L3D::GetSelectedSystem(); StarSystem* s = L3D::GetSelectedSystem();
if(s /* && isn's current system. */) { if(s /* && isn's current system. */) {

View File

@ -13,14 +13,17 @@ public:
matrix4x4d viewingRotation; matrix4x4d viewingRotation;
static const float PICK_OBJECT_RECT_SIZE; static const float PICK_OBJECT_RECT_SIZE;
void UpdateCommsOptions(void); void UpdateCommsOptions(void);
bool GetShowLabels(void) { return labelsOn; }
private: private:
Gui::Button* AddCommsOption(const std::string msg, int ypos); Gui::Button* AddCommsOption(const std::string msg, int ypos);
void OnClickHyperspace(void); void OnClickHyperspace(void);
void OnChangeWheelsState(Gui::MultiStateImageButton* b); void OnChangeWheelsState(Gui::MultiStateImageButton* b);
void OnChangeLabelsState(Gui::MultiStateImageButton* b);
virtual bool OnMouseDown(Gui::MouseButtonEvent* e); virtual bool OnMouseDown(Gui::MouseButtonEvent* e);
Body* PickBody(const float screenX, const float screenY) const; Body* PickBody(const float screenX, const float screenY) const;
Gui::ImageButton* m_hyperspaceButton; Gui::ImageButton* m_hyperspaceButton;
GLuint m_bgstarsDlist; GLuint m_bgstarsDlist;
Gui::Fixed* commsOptions; Gui::Fixed* commsOptions;
bool labelsOn;
}; };