117 lines
4.1 KiB
C++
117 lines
4.1 KiB
C++
#include "libs.h"
|
|
#include "l3d.h"
|
|
#include "ship_cpanel.h"
|
|
#include "space_station_view.h"
|
|
#include "player.h"
|
|
#include "info_view.h"
|
|
|
|
ShipCpanel::ShipCpanel(void) : Gui::Fixed(0, 0, 640, 64) {
|
|
//SetBgColor(1, 0, 0);
|
|
SetTransparency(true);
|
|
|
|
Gui::Image* img = new Gui::Image("icons/cpanel.png");
|
|
Add(img, 0, 0);
|
|
|
|
Gui::RadioGroup* g = new Gui::RadioGroup();
|
|
Gui::ImageRadioButton* b = new Gui::ImageRadioButton(g, "icons/timeaccel0.png",
|
|
"icons/timeaccel0_on.png");
|
|
b->onSelect.connect(sigc::bind(sigc::mem_fun(this, &ShipCpanel::OnClickTimeaccel), 0.0));
|
|
b->SetShortcut(SDLK_ESCAPE, KMOD_LSHIFT);
|
|
Add(b, 0, 26);
|
|
|
|
b = new Gui::ImageRadioButton(g, "icons/timeaccel1.png", "icons/timeaccel1_on.png");
|
|
b->onSelect.connect(sigc::bind(sigc::mem_fun(this, &ShipCpanel::OnClickTimeaccel), 1.0));
|
|
b->SetShortcut(SDLK_F1, KMOD_LSHIFT);
|
|
b->SetSelected(true);
|
|
Add(b, 22, 26);
|
|
|
|
b = new Gui::ImageRadioButton(g, "icons/timeaccel2.png", "icons/timeaccel2_on.png");
|
|
b->onSelect.connect(sigc::bind(sigc::mem_fun(this, &ShipCpanel::OnClickTimeaccel), 10.0));
|
|
b->SetShortcut(SDLK_F2, KMOD_LSHIFT);
|
|
Add(b, 44, 26);
|
|
|
|
b = new Gui::ImageRadioButton(g, "icons/timeaccel3.png", "icons/timeaccel3_on.png");
|
|
b->onSelect.connect(sigc::bind(sigc::mem_fun(this, &ShipCpanel::OnClickTimeaccel), 100.0));
|
|
b->SetShortcut(SDLK_F3, KMOD_LSHIFT);
|
|
Add(b, 66, 26);
|
|
|
|
b = new Gui::ImageRadioButton(g, "icons/timeaccel4.png", "icons/timeaccel4_on.png");
|
|
b->onSelect.connect(sigc::bind(sigc::mem_fun(this, &ShipCpanel::OnClickTimeaccel), 1000.0));
|
|
b->SetShortcut(SDLK_F4, KMOD_LSHIFT);
|
|
Add(b, 88, 26);
|
|
|
|
g = new Gui::RadioGroup();
|
|
Gui::MultiStateImageButton* cam_button = new Gui::MultiStateImageButton();
|
|
g->Add(cam_button);
|
|
cam_button->SetSelected(true);
|
|
cam_button->AddState(L3D::CAM_FRONT, "icons/cam_front.png");
|
|
cam_button->AddState(L3D::CAM_REAR, "icons/cam_rear.png");
|
|
cam_button->AddState(L3D::CAM_EXTERNAL, "icons/cam_external.png");
|
|
cam_button->SetShortcut(SDLK_F1, KMOD_NONE);
|
|
cam_button->onClick.connect(sigc::mem_fun(this, &ShipCpanel::OnChangeCamView));
|
|
Add(cam_button, 2, 2);
|
|
|
|
Gui::MultiStateImageButton* map_button = new Gui::MultiStateImageButton();
|
|
g->Add(map_button);
|
|
map_button->SetSelected(false);
|
|
map_button->SetShortcut(SDLK_F2, KMOD_NONE);
|
|
map_button->AddState(L3D::MAP_SECTOR, "icons/cpan_f2_map.png");
|
|
map_button->AddState(L3D::MAP_SYSTEM, "icons/cpan_f2_normal.png");
|
|
map_button->onClick.connect(sigc::mem_fun(this, &ShipCpanel::OnChangeMapView));
|
|
Add(map_button, 34, 2);
|
|
|
|
Gui::MultiStateImageButton* info_button = new Gui::MultiStateImageButton();
|
|
g->Add(info_button);
|
|
info_button->SetSelected(false);
|
|
info_button->SetShortcut(SDLK_F3, KMOD_NONE);
|
|
info_button->AddState(0, "icons/cpan_f3_shipinfo.png");
|
|
info_button->onClick.connect(sigc::mem_fun(this, &ShipCpanel::OnChangeInfoView));
|
|
Add(info_button, 66, 2);
|
|
|
|
Gui::ImageButton* comms_button = new Gui::ImageButton("icons/comms_f4.png");
|
|
//g->Add(comms_button);
|
|
comms_button->SetShortcut(SDLK_F4, KMOD_NONE);
|
|
comms_button->onClick.connect(sigc::mem_fun(this, &ShipCpanel::OnClickComms));
|
|
Add(comms_button, 98, 2);
|
|
|
|
m_clock = new Gui::Label("");
|
|
m_clock->SetColor(1, 0.7, 0);
|
|
Add(m_clock, 2, 48);
|
|
}
|
|
|
|
void ShipCpanel::Draw(void) {
|
|
std::string time = date_format(L3D::GetGameTime());
|
|
m_clock->SetText(time);
|
|
|
|
Gui::Fixed::Draw();
|
|
Remove(m_scannerWidget);
|
|
}
|
|
|
|
void ShipCpanel::SetScannerWidget(Widget* w) {
|
|
m_scannerWidget = w;
|
|
Add(w, 150, 64);
|
|
w->Show();
|
|
}
|
|
|
|
void ShipCpanel::OnChangeCamView(Gui::MultiStateImageButton* b) {
|
|
L3D::SetCamType((enum L3D::CamType)b->GetState());
|
|
}
|
|
|
|
void ShipCpanel::OnChangeInfoView(Gui::MultiStateImageButton* b) {
|
|
L3D::infoView->UpdateInfo();
|
|
L3D::SetView(L3D::infoView);
|
|
}
|
|
|
|
void ShipCpanel::OnChangeMapView(Gui::MultiStateImageButton* b) {
|
|
L3D::SetMapView((enum L3D::MapView)b->GetState());
|
|
}
|
|
|
|
void ShipCpanel::OnClickTimeaccel(Gui::ISelectable* i, double step) {
|
|
L3D::SetTimeAccel(step);
|
|
}
|
|
|
|
void ShipCpanel::OnClickComms(void) {
|
|
if(L3D::player->GetDockedWith()) L3D::SetView(L3D::spaceStationView);
|
|
}
|
|
|