[Change] Changed GUI coords to be sensible top-left (0,0).

[Change] Some GUI cleanup.
This commit is contained in:
Rtch90 2018-04-16 22:47:37 +01:00
parent 95d1a02d62
commit 7f4b6b9390
19 changed files with 136 additions and 105 deletions

View File

@ -7,23 +7,23 @@ GenericSystemView::GenericSystemView(void) : View() {
px = py = pidx = 0xdeadbeef; px = py = pidx = 0xdeadbeef;
m_scannerLayout = new Gui::Fixed(360, 60); m_scannerLayout = new Gui::Fixed(360, 60);
m_scannerLayout->SetTransparency(true); m_scannerLayout->SetTransparency(true);
Gui::Screen::AddBaseWidget(m_scannerLayout, 140, 2); Gui::Screen::AddBaseWidget(m_scannerLayout, 140, Gui::Screen::GetHeight()-62);
m_systemName = new Gui::Label(""); m_systemName = new Gui::Label("");
m_systemName->SetColor(1, 1, 0); m_systemName->SetColor(1, 1, 0);
m_scannerLayout->Add(m_systemName, 40, 44); m_scannerLayout->Add(m_systemName, 40, 4);
m_distance = new Gui::Label(""); m_distance = new Gui::Label("");
m_distance->SetColor(1, 0, 0); m_distance->SetColor(1, 0, 0);
m_scannerLayout->Add(m_distance, 150, 44); m_scannerLayout->Add(m_distance, 150, 4);
m_starType = new Gui::Label(""); m_starType = new Gui::Label("");
m_starType->SetColor(1, 0, 1); m_starType->SetColor(1, 0, 1);
m_scannerLayout->Add(m_starType, 22, 26); m_scannerLayout->Add(m_starType, 22, 20);
m_shortDesc = new Gui::Label(""); m_shortDesc = new Gui::Label("");
m_shortDesc->SetColor(1, 0, 1); m_shortDesc->SetColor(1, 0, 1);
m_scannerLayout->Add(m_shortDesc, 5, 8); m_scannerLayout->Add(m_shortDesc, 5, 38);
} }
void GenericSystemView::Draw3D(void) { void GenericSystemView::Draw3D(void) {

View File

@ -64,22 +64,22 @@ void TransparentButton::GetSizeRequested(float size[2]) {
void SolidButton::Draw(void) { void SolidButton::Draw(void) {
glBegin(GL_QUADS); glBegin(GL_QUADS);
glColor3f(.6, .6, .6); glColor3f(.6, .6, .6);
glVertex2f(0, 0);
glVertex2f(15, 0);
glVertex2f(15, 15);
glVertex2f(0, 15); glVertex2f(0, 15);
glVertex2f(15, 15);
glVertex2f(15, 0);
glVertex2f(0, 0);
glColor3fv(Color::bgShadow); glColor3fv(Color::bgShadow);
glVertex2f(2, 0); glVertex2f(2, 15);
glVertex2f(15, 0); glVertex2f(15, 15);
glVertex2f(15, 13); glVertex2f(15, 2);
glVertex2f(2, 13); glVertex2f(2, 2);
glColor3fv(Color::bg); glColor3fv(Color::bg);
glVertex2f(2, 2);
glVertex2f(13, 2);
glVertex2f(13, 13);
glVertex2f(2, 13); glVertex2f(2, 13);
glVertex2f(13, 13);
glVertex2f(13, 2);
glVertex2f(2, 2);
glEnd(); glEnd();
} }

View File

@ -23,9 +23,9 @@ void Fixed::Draw(void) {
if(!m_transparent) { if(!m_transparent) {
glBegin(GL_QUADS); glBegin(GL_QUADS);
glColor3f(m_bgcol[0], m_bgcol[1], m_bgcol[2]); glColor3f(m_bgcol[0], m_bgcol[1], m_bgcol[2]);
glVertex2f(m_w, 0);
glVertex2f(m_w, m_h);
glVertex2f(0, m_h); glVertex2f(0, m_h);
glVertex2f(m_w, m_h);
glVertex2f(m_w, 0);
glVertex2f(0, 0); glVertex2f(0, 0);
glEnd(); glEnd();
} }

View File

@ -86,13 +86,13 @@ void Image::Draw(void) {
float w = m_imgw * m_invtexw; float w = m_imgw * m_invtexw;
float h = m_imgh * m_invtexh; float h = m_imgh * m_invtexh;
glTexCoord2f(0, h); glTexCoord2f(0, h);
glVertex2f(0, 0);
glTexCoord2f(w, h);
glVertex2f(allocSize[0],0);
glTexCoord2f(w, 0);
glVertex2f(allocSize[0], allocSize[1]);
glTexCoord2f(0, 0);
glVertex2f(0, allocSize[1]); glVertex2f(0, allocSize[1]);
glTexCoord2f(w, h);
glVertex2f(allocSize[0], allocSize[1]);
glTexCoord2f(w, 0);
glVertex2f(allocSize[0], 0);
glTexCoord2f(0, 0);
glVertex2f(0, 0);
glEnd(); glEnd();
glDisable(GL_TEXTURE_2D); glDisable(GL_TEXTURE_2D);
glDisable(GL_BLEND); glDisable(GL_BLEND);

View File

@ -38,7 +38,7 @@ GLint Screen::Project(GLdouble objX, GLdouble objY, GLdouble objZ, const GLdoubl
GLint o = gluProject(objX, objY, objZ, model, proj, view, winX, winY, winZ); GLint o = gluProject(objX, objY, objZ, model, proj, view, winX, winY, winZ);
*winX = (*winX) * width * invRealWidth; *winX = (*winX) * width * invRealWidth;
*winY = (*winY) * height * invRealHeight; *winY = GetHeight()- (*winY) * height * invRealHeight;
return o; return o;
} }
@ -48,7 +48,7 @@ void Screen::EnterOrtho(void) {
glMatrixMode(GL_PROJECTION); glMatrixMode(GL_PROJECTION);
glPushMatrix(); glPushMatrix();
glLoadIdentity(); glLoadIdentity();
glOrtho(0, width, 0, height, -1, 1); glOrtho(0, width, height,0, -1, 1);
glMatrixMode(GL_MODELVIEW); glMatrixMode(GL_MODELVIEW);
glPushMatrix(); glPushMatrix();
glLoadIdentity(); glLoadIdentity();
@ -81,7 +81,7 @@ void Screen::RemoveBaseWidget(Widget* w) {
} }
void Screen::SDLEventCoordToScreenCoord(int sdlev_x, int sdlev_y, float* x, float* y) { void Screen::SDLEventCoordToScreenCoord(int sdlev_x, int sdlev_y, float* x, float* y) {
*y = height-(sdlev_y*height*invRealHeight); *y = sdlev_y*height*invRealHeight;
*x = sdlev_x*width*invRealWidth; *x = sdlev_x*width*invRealWidth;
} }
@ -126,6 +126,10 @@ void Screen::OnKeyDown(const SDL_keysym* sym) {
} }
} }
float Screen::GetFontHeight(void) {
return font->GetHeight()*Screen::font_ysize;
}
void Screen::MeasureString(const std::string& s, float& w, float& h) { void Screen::MeasureString(const std::string& s, float& w, float& h) {
font->MeasureString(s.c_str(), w, h); font->MeasureString(s.c_str(), w, h);
w *= Screen::font_xsize; w *= Screen::font_xsize;
@ -134,15 +138,25 @@ void Screen::MeasureString(const std::string& s, float& w, float& h) {
void Screen::RenderString(const std::string& s) { void Screen::RenderString(const std::string& s) {
glPushMatrix(); glPushMatrix();
glScalef(Screen::font_xsize, Screen::font_ysize, 1); {
glTranslatef(0, Screen::font_ysize*Screen::font->GetHeight(),0);
glScalef(Screen::font_xsize, -Screen::font_ysize,1);
glDisable(GL_CULL_FACE);
}
font->RenderString(s.c_str()); font->RenderString(s.c_str());
glEnable(GL_CULL_FACE);
glPopMatrix(); glPopMatrix();
} }
void Screen::RenderMarkup(const std::string& s) { void Screen::RenderMarkup(const std::string& s) {
glPushMatrix(); glPushMatrix();
glScalef(Screen::font_xsize, Screen::font_ysize, 1); {
glTranslatef(0, Screen::font_ysize*Screen::font->GetHeight(), 0);
glScalef(Screen::font_xsize, -Screen::font_ysize, 1);
glDisable(GL_CULL_FACE);
}
font->RenderMarkup(s.c_str()); font->RenderMarkup(s.c_str());
glEnable(GL_CULL_FACE);
glPopMatrix(); glPopMatrix();
} }
@ -157,12 +171,14 @@ bool Screen::CanPutLabel(float x, float y) {
void Screen::RenderLabel(const std::string& s, float x, float y) { void Screen::RenderLabel(const std::string& s, float x, float y) {
if(CanPutLabel(x, y)) { if(CanPutLabel(x, y)) {
labelPositions.push_back(LabelPos(x, y)); labelPositions.push_back(LabelPos(x, y));
glDisable(GL_CULL_FACE);
glPushMatrix(); glPushMatrix();
glTranslatef(x, y, 0); glTranslatef(x, y, 0);
glScalef(Screen::font_xsize, Screen::font_ysize, 1); glScalef(Screen::font_xsize, -Screen::font_ysize, 1);
glTranslatef(0.5*font->GetWidth(), -0.4*font->GetHeight(), 0); glTranslatef(0.5*font->GetWidth(), -0.4*font->GetHeight(), 0);
font->RenderString(s.c_str()); font->RenderString(s.c_str());
glPopMatrix(); glPopMatrix();
glEnable(GL_CULL_FACE);
} }
} }
@ -173,12 +189,14 @@ void Screen::PutClickableLabel(const std::string& s, float x, float y,
LabelPos p = LabelPos(x, y); LabelPos p = LabelPos(x, y);
p.onClick.connect(slot); p.onClick.connect(slot);
labelPositions.push_back(p); labelPositions.push_back(p);
glDisable(GL_CULL_FACE);
glPushMatrix(); glPushMatrix();
glTranslatef(x, y, 0); glTranslatef(x, y, 0);
glScalef(Screen::font_xsize, Screen::font_ysize, 1); glScalef(Screen::font_xsize, -Screen::font_ysize, 1);
glTranslatef(0.5*font->GetWidth(), -0.4*font->GetHeight(), 0); glTranslatef(0.5*font->GetWidth(), -0.4*font->GetHeight(), 0);
font->RenderString(s.c_str()); font->RenderString(s.c_str());
glPopMatrix(); glPopMatrix();
glEnable(GL_CULL_FACE);
} }
} }

View File

@ -24,6 +24,7 @@ namespace Gui {
static void LeaveOrtho(void); static void LeaveOrtho(void);
static int GetWidth(void) { return width; } static int GetWidth(void) { return width; }
static int GetHeight(void) { return height; } static int GetHeight(void) { return height; }
static float GetFontHeight(void);
/* gluProject but fixes UI/screen size mismatch. */ /* gluProject but fixes UI/screen size mismatch. */
static GLint Project(GLdouble objX, GLdouble objY, GLdouble objZ, const GLdouble* model, static GLint Project(GLdouble objX, GLdouble objY, GLdouble objZ, const GLdouble* model,
const GLdouble* proj, const GLint* view, GLdouble* winX, const GLdouble* proj, const GLint* view, GLdouble* winX,

View File

@ -40,43 +40,43 @@ void ToggleButton::GetSizeRequested(float size[2]) {
void ToggleButton::Draw(void) { void ToggleButton::Draw(void) {
if(m_pressed) { if(m_pressed) {
glBegin(GL_QUADS); glBegin(GL_QUADS);
glColor3fv(Color::bgShadow);
glVertex2f(0, 0);
glVertex2f(15, 0);
glVertex2f(15, 15);
glVertex2f(0, 15);
glColor3f(.6, .6, .6); glColor3f(.6, .6, .6);
glVertex2f(2, 0); glVertex2f(0, 15);
glVertex2f(15, 15);
glVertex2f(15, 0); glVertex2f(15, 0);
glVertex2f(15, 13); glVertex2f(0, 0);
glVertex2f(2, 13);
glColor3fv(Color::bgShadow);
glVertex2f(0, 13);
glVertex2f(13, 13);
glVertex2f(13, 0);
glVertex2f(0, 0);
glColor3fv(Color::bg); glColor3fv(Color::bg);
glVertex2f(2, 2);
glVertex2f(13, 2);
glVertex2f(13, 13);
glVertex2f(2, 13); glVertex2f(2, 13);
glVertex2f(13, 13);
glVertex2f(13, 2);
glVertex2f(2, 2);
glEnd(); glEnd();
} else { } else {
glBegin(GL_QUADS); glBegin(GL_QUADS);
glColor3f(.6, .6, .6); glColor3f(.6, .6, .6);
glVertex2f(0, 0);
glVertex2f(15, 0);
glVertex2f(15, 15);
glVertex2f(0, 15); glVertex2f(0, 15);
glVertex2f(15, 15);
glVertex2f(15, 0);
glVertex2f(0, 0);
glColor3fv(Color::bgShadow); glColor3fv(Color::bgShadow);
glVertex2f(2, 0); glVertex2f(2, 15);
glVertex2f(15, 0); glVertex2f(15, 15);
glVertex2f(15, 13); glVertex2f(15, 2);
glVertex2f(2, 13); glVertex2f(2, 2);
glColor3fv(Color::bg); glColor3fv(Color::bg);
glVertex2f(2, 2);
glVertex2f(13, 2);
glVertex2f(13, 13);
glVertex2f(2, 13); glVertex2f(2, 13);
glVertex2f(13, 13);
glVertex2f(13, 2);
glVertex2f(2, 2);
glEnd(); glEnd();
} }
} }

View File

@ -41,10 +41,10 @@ void ToolTip::Draw(void) {
GetSize(size); GetSize(size);
glColor4f(.2, .2, .6, alpha); glColor4f(.2, .2, .6, alpha);
glBegin(GL_QUADS); glBegin(GL_QUADS);
glVertex2f(size[0], 0);
glVertex2f(size[0], size[1]);
glVertex2f(0, size[1]);
glVertex2f(0, 0); glVertex2f(0, 0);
glVertex2f(0, size[1]);
glVertex2f(size[0], size[1]);
glVertex2f(size[0], 0);
glEnd(); glEnd();
glColor4f(.0, .0, .8, alpha); glColor4f(.0, .0, .8, alpha);
glBegin(GL_LINE_LOOP); glBegin(GL_LINE_LOOP);

View File

@ -11,6 +11,30 @@ Widget::Widget(void) {
m_tooltipTimerSignal.connect(sigc::mem_fun(this, &Widget::OnToolTip)); m_tooltipTimerSignal.connect(sigc::mem_fun(this, &Widget::OnToolTip));
} }
void Widget::SetClipping(float width, float height) {
const GLdouble eqn1[4] = { 1, 0, 0, 0 };
const GLdouble eqn2[4] = { 0, 1, 0, 0 };
const GLdouble eqn3[4] = { -1, 0, 0, 0 };
const GLdouble eqn4[4] = { 0, -1, 0, 0 };
glClipPlane(GL_CLIP_PLANE0, eqn1);
glClipPlane(GL_CLIP_PLANE1, eqn2);
glPushMatrix();
glTranslatef(width, height, 0);
glClipPlane(GL_CLIP_PLANE2, eqn3);
glClipPlane(GL_CLIP_PLANE3, eqn4);
glPopMatrix();
glEnable(GL_CLIP_PLANE0);
glEnable(GL_CLIP_PLANE1);
glEnable(GL_CLIP_PLANE2);
glEnable(GL_CLIP_PLANE3);
}
void Widget::EndClipping(void) {
glDisable(GL_CLIP_PLANE0);
glDisable(GL_CLIP_PLANE1);
glDisable(GL_CLIP_PLANE3);
}
void Widget::SetShortcut(SDLKey key, SDLMod mod) { void Widget::SetShortcut(SDLKey key, SDLMod mod) {
m_shortcut.sym = key; m_shortcut.sym = key;
m_shortcut.mod = mod; m_shortcut.mod = mod;

View File

@ -16,6 +16,8 @@ namespace Gui {
void GetSize(float size[2]) { size[0] = m_size.w; size[1] = m_size.h; } void GetSize(float size[2]) { size[0] = m_size.w; size[1] = m_size.h; }
void SetSize(float w, float h) { m_size.w = w; m_size.h = h; }; void SetSize(float w, float h) { m_size.w = w; m_size.h = h; };
void SetShortcut(SDLKey key, SDLMod mod); void SetShortcut(SDLKey key, SDLMod mod);
void SetClipping(float width, float height);
void EndClipping(void);
virtual void Show(void) { m_visible = true; } virtual void Show(void) { m_visible = true; }
virtual void Hide(void); virtual void Hide(void);
bool IsVisible(void) { return m_visible; } bool IsVisible(void) { return m_visible; }

View File

@ -7,11 +7,8 @@
InfoView::InfoView(void) : View() { InfoView::InfoView(void) : View() {
SetTransparency(true); SetTransparency(true);
float size[2];
GetSize(size);
info1 = new Gui::Label("Some star stuff."); info1 = new Gui::Label("Some star stuff.");
Add(info1, 40, size[1]-40); Add(info1, 40, 40);
} }
void InfoView::UpdateInfo(void) { void InfoView::UpdateInfo(void) {

View File

@ -362,14 +362,14 @@ void L3D::Start(void) {
opts[1] = new Gui::ToggleButton(); opts[1]->SetShortcut(SDLK_2, KMOD_NONE); opts[1] = new Gui::ToggleButton(); opts[1]->SetShortcut(SDLK_2, KMOD_NONE);
opts[2] = new Gui::ToggleButton(); opts[2]->SetShortcut(SDLK_3, KMOD_NONE); opts[2] = new Gui::ToggleButton(); opts[2]->SetShortcut(SDLK_3, KMOD_NONE);
opts[3] = new Gui::ToggleButton(); opts[3]->SetShortcut(SDLK_4, KMOD_NONE); opts[3] = new Gui::ToggleButton(); opts[3]->SetShortcut(SDLK_4, KMOD_NONE);
splash->Add(opts[0], w, h+64); splash->Add(opts[0], w, h-64);
splash->Add(new Gui::Label("New game starting on Earth"), w+32, h+64); splash->Add(new Gui::Label("New game starting on Earth"), w+32, h-64);
splash->Add(opts[1], w, h+32); splash->Add(opts[1], w, h-32);
splash->Add(new Gui::Label("New game starting on debug point"), w+32, h+32); splash->Add(new Gui::Label("New game starting on debug point"), w+32, h-32);
splash->Add(opts[2], w, h); splash->Add(opts[2], w, h);
splash->Add(new Gui::Label("Load quicksave"), w+32, h); splash->Add(new Gui::Label("Load quicksave"), w+32, h);
splash->Add(opts[3], w, h-32); splash->Add(opts[3], w, h+32);
splash->Add(new Gui::Label("Quit"), w+32, h-32); splash->Add(new Gui::Label("Quit"), w+32, h+32);
splash->ShowAll(); splash->ShowAll();

View File

@ -286,8 +286,6 @@ void Player::DrawHUD(const Frame* cam_frame) {
if(L3D::showDebugInfo) { if(L3D::showDebugInfo) {
char buf[1024]; char buf[1024];
glPushMatrix();
glTranslatef(0, 440, 0);
vector3d pos = GetPosition(); vector3d pos = GetPosition();
vector3d abs_pos = GetPositionRelTo(Space::GetRootFrame()); vector3d abs_pos = GetPositionRelTo(Space::GetRootFrame());
const char* rel_to = (GetFrame() ? GetFrame()->GetLabel() : "System"); const char* rel_to = (GetFrame() ? GetFrame()->GetLabel() : "System");
@ -298,7 +296,6 @@ void Player::DrawHUD(const Frame* cam_frame) {
abs_pos.x, abs_pos.y, abs_pos.z, abs_pos.Length()/AU, abs_pos.x, abs_pos.y, abs_pos.z, abs_pos.Length()/AU,
rel_to, pos.Length()/1000); rel_to, pos.Length()/1000);
Gui::Screen::RenderString(buf); Gui::Screen::RenderString(buf);
glPopMatrix();
} }
{ {
@ -310,7 +307,7 @@ void Player::DrawHUD(const Frame* cam_frame) {
snprintf(buf, sizeof(buf), "Velocity: %.0f m/s", _vel); snprintf(buf, sizeof(buf), "Velocity: %.0f m/s", _vel);
} }
glPushMatrix(); glPushMatrix();
glTranslatef(2, 66, 0); glTranslatef(2, Gui::Screen::GetHeight()-Gui::Screen::GetFontHeight()-66, 0);
Gui::Screen::RenderString(buf); Gui::Screen::RenderString(buf);
glPopMatrix(); glPopMatrix();
} }
@ -323,7 +320,7 @@ void Player::DrawHUD(const Frame* cam_frame) {
snprintf(buf, sizeof(buf), "Set speed %.0f m/s", m_setSpeed); snprintf(buf, sizeof(buf), "Set speed %.0f m/s", m_setSpeed);
} }
glPushMatrix(); glPushMatrix();
glTranslatef(200, 66, 0); glTranslatef(200, Gui::Screen::GetHeight()-Gui::Screen::GetFontHeight()-66, 0);
Gui::Screen::RenderString(buf); Gui::Screen::RenderString(buf);
glPopMatrix(); glPopMatrix();
} }
@ -336,7 +333,7 @@ void Player::DrawHUD(const Frame* cam_frame) {
char buf[128]; char buf[128];
snprintf(buf, sizeof(buf), "Altitude: %.0f m", altitude); snprintf(buf, sizeof(buf), "Altitude: %.0f m", altitude);
glPushMatrix(); glPushMatrix();
glTranslatef(400, 6, 0); glTranslatef(400, Gui::Screen::GetHeight()-Gui::Screen::GetFontHeight()-66, 0);
Gui::Screen::RenderString(buf); Gui::Screen::RenderString(buf);
glPopMatrix(); glPopMatrix();
} }

View File

@ -16,7 +16,7 @@ SectorView::SectorView(void) : GenericSystemView() {
m_zoom = 1; m_zoom = 1;
m_infoLabel = new Gui::Label(""); m_infoLabel = new Gui::Label("");
Add(m_infoLabel, 2, 2); Add(m_infoLabel, 2, Gui::Screen::GetHeight()-Gui::Screen::GetFontHeight()-66);
Gui::ImageButton* ib = new Gui::ImageButton("icons/sectorview_f6_systeminfo.png"); Gui::ImageButton* ib = new Gui::ImageButton("icons/sectorview_f6_systeminfo.png");
ib->onClick.connect(sigc::mem_fun(this, &SectorView::OnClickSystemInfo)); ib->onClick.connect(sigc::mem_fun(this, &SectorView::OnClickSystemInfo));

View File

@ -6,8 +6,8 @@
#include "info_view.h" #include "info_view.h"
#include "world_view.h" #include "world_view.h"
ShipCpanel::ShipCpanel(void) : Gui::Fixed(640, 64) { ShipCpanel::ShipCpanel(void) : Gui::Fixed(Gui::Screen::GetWidth(), 64) {
Gui::Screen::AddBaseWidget(this, 0, 0); Gui::Screen::AddBaseWidget(this, 0, Gui::Screen::GetHeight()-64);
SetTransparency(true); SetTransparency(true);
Gui::Image* img = new Gui::Image("icons/cpanel.png"); Gui::Image* img = new Gui::Image("icons/cpanel.png");
@ -18,33 +18,33 @@ ShipCpanel::ShipCpanel(void) : Gui::Fixed(640, 64) {
"icons/timeaccel0_on.png"); "icons/timeaccel0_on.png");
b->onSelect.connect(sigc::bind(sigc::mem_fun(this, &ShipCpanel::OnClickTimeaccel), 0.0)); b->onSelect.connect(sigc::bind(sigc::mem_fun(this, &ShipCpanel::OnClickTimeaccel), 0.0));
b->SetShortcut(SDLK_ESCAPE, KMOD_LSHIFT); b->SetShortcut(SDLK_ESCAPE, KMOD_LSHIFT);
Add(b, 0, 26); Add(b, 0, 20);
b = new Gui::ImageRadioButton(g, "icons/timeaccel1.png", "icons/timeaccel1_on.png"); 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->onSelect.connect(sigc::bind(sigc::mem_fun(this, &ShipCpanel::OnClickTimeaccel), 1.0));
b->SetShortcut(SDLK_F1, KMOD_LSHIFT); b->SetShortcut(SDLK_F1, KMOD_LSHIFT);
b->SetSelected(true); b->SetSelected(true);
Add(b, 22, 26); Add(b, 22, 20);
b = new Gui::ImageRadioButton(g, "icons/timeaccel2.png", "icons/timeaccel2_on.png"); 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->onSelect.connect(sigc::bind(sigc::mem_fun(this, &ShipCpanel::OnClickTimeaccel), 10.0));
b->SetShortcut(SDLK_F2, KMOD_LSHIFT); b->SetShortcut(SDLK_F2, KMOD_LSHIFT);
Add(b, 44, 26); Add(b, 44, 20);
b = new Gui::ImageRadioButton(g, "icons/timeaccel3.png", "icons/timeaccel3_on.png"); 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->onSelect.connect(sigc::bind(sigc::mem_fun(this, &ShipCpanel::OnClickTimeaccel), 100.0));
b->SetShortcut(SDLK_F3, KMOD_LSHIFT); b->SetShortcut(SDLK_F3, KMOD_LSHIFT);
Add(b, 66, 26); Add(b, 66, 20);
b = new Gui::ImageRadioButton(g, "icons/timeaccel4.png", "icons/timeaccel4_on.png"); 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->onSelect.connect(sigc::bind(sigc::mem_fun(this, &ShipCpanel::OnClickTimeaccel), 1000.0));
b->SetShortcut(SDLK_F4, KMOD_LSHIFT); b->SetShortcut(SDLK_F4, KMOD_LSHIFT);
Add(b, 88, 26); Add(b, 88, 20);
b = new Gui::ImageRadioButton(g, "icons/timeaccel5.png", "icons/timeaccel5_on.png"); b = new Gui::ImageRadioButton(g, "icons/timeaccel5.png", "icons/timeaccel5_on.png");
b->onSelect.connect(sigc::bind(sigc::mem_fun(this, &ShipCpanel::OnClickTimeaccel), 10000.0)); b->onSelect.connect(sigc::bind(sigc::mem_fun(this, &ShipCpanel::OnClickTimeaccel), 10000.0));
b->SetShortcut(SDLK_F5, KMOD_LSHIFT); b->SetShortcut(SDLK_F5, KMOD_LSHIFT);
Add(b, 110, 26); Add(b, 110, 20);
g = new Gui::RadioGroup(); g = new Gui::RadioGroup();
Gui::MultiStateImageButton* cam_button = new Gui::MultiStateImageButton(); Gui::MultiStateImageButton* cam_button = new Gui::MultiStateImageButton();
@ -55,7 +55,7 @@ ShipCpanel::ShipCpanel(void) : Gui::Fixed(640, 64) {
cam_button->AddState(WorldView::CAM_EXTERNAL, "icons/cam_external.png", "External view"); cam_button->AddState(WorldView::CAM_EXTERNAL, "icons/cam_external.png", "External view");
cam_button->SetShortcut(SDLK_F1, KMOD_NONE); cam_button->SetShortcut(SDLK_F1, KMOD_NONE);
cam_button->onClick.connect(sigc::mem_fun(this, &ShipCpanel::OnChangeCamView)); cam_button->onClick.connect(sigc::mem_fun(this, &ShipCpanel::OnChangeCamView));
Add(cam_button, 2, 2); Add(cam_button, 2, 40);
Gui::MultiStateImageButton* map_button = new Gui::MultiStateImageButton(); Gui::MultiStateImageButton* map_button = new Gui::MultiStateImageButton();
g->Add(map_button); g->Add(map_button);
@ -64,7 +64,7 @@ ShipCpanel::ShipCpanel(void) : Gui::Fixed(640, 64) {
map_button->AddState(L3D::MAP_SECTOR, "icons/cpan_f2_map.png", "Galaxy sector map"); map_button->AddState(L3D::MAP_SECTOR, "icons/cpan_f2_map.png", "Galaxy sector map");
map_button->AddState(L3D::MAP_SYSTEM, "icons/cpan_f2_normal.png", "Star system view"); map_button->AddState(L3D::MAP_SYSTEM, "icons/cpan_f2_normal.png", "Star system view");
map_button->onClick.connect(sigc::mem_fun(this, &ShipCpanel::OnChangeMapView)); map_button->onClick.connect(sigc::mem_fun(this, &ShipCpanel::OnChangeMapView));
Add(map_button, 34, 2); Add(map_button, 34, 40);
Gui::MultiStateImageButton* info_button = new Gui::MultiStateImageButton(); Gui::MultiStateImageButton* info_button = new Gui::MultiStateImageButton();
g->Add(info_button); g->Add(info_button);
@ -72,7 +72,7 @@ ShipCpanel::ShipCpanel(void) : Gui::Fixed(640, 64) {
info_button->SetShortcut(SDLK_F3, KMOD_NONE); info_button->SetShortcut(SDLK_F3, KMOD_NONE);
info_button->AddState(0, "icons/cpan_f3_shipinfo.png", "Ship information."); info_button->AddState(0, "icons/cpan_f3_shipinfo.png", "Ship information.");
info_button->onClick.connect(sigc::mem_fun(this, &ShipCpanel::OnChangeInfoView)); info_button->onClick.connect(sigc::mem_fun(this, &ShipCpanel::OnChangeInfoView));
Add(info_button, 66, 2); Add(info_button, 66, 40);
Gui::MultiStateImageButton* comms_button = new Gui::MultiStateImageButton(); Gui::MultiStateImageButton* comms_button = new Gui::MultiStateImageButton();
g->Add(comms_button); g->Add(comms_button);
@ -80,11 +80,11 @@ ShipCpanel::ShipCpanel(void) : Gui::Fixed(640, 64) {
comms_button->SetShortcut(SDLK_F4, KMOD_NONE); comms_button->SetShortcut(SDLK_F4, KMOD_NONE);
comms_button->AddState(0, "icons/comms_f4.png", "Comms."); comms_button->AddState(0, "icons/comms_f4.png", "Comms.");
comms_button->onClick.connect(sigc::mem_fun(this, &ShipCpanel::OnClickComms)); comms_button->onClick.connect(sigc::mem_fun(this, &ShipCpanel::OnClickComms));
Add(comms_button, 98, 2); Add(comms_button, 98, 40);
m_clock = new Gui::Label(""); m_clock = new Gui::Label("");
m_clock->SetColor(1, 0.7, 0); m_clock->SetColor(1, 0.7, 0);
Add(m_clock, 2, 48); Add(m_clock, 2, 3);
tempMsg = new Gui::Label(""); tempMsg = new Gui::Label("");
Add(tempMsg, 170, 44); Add(tempMsg, 170, 44);

View File

@ -41,21 +41,19 @@ StationFrontView::StationFrontView(SpaceStationView* parent): StationSubView(par
"can offer you this promotional message from one of the station's sponsors:\n\n" "can offer you this promotional message from one of the station's sponsors:\n\n"
" ADOPT A CAT: THEY CHEW IMPORTANT CABLES!"); " ADOPT A CAT: THEY CHEW IMPORTANT CABLES!");
float size[2]; Add(l, 40, 100);
GetSize(size);
Add(l, 40, size[1]-100);
Gui::SolidButton* b = new Gui::SolidButton(); Gui::SolidButton* b = new Gui::SolidButton();
b->onClick.connect(sigc::mem_fun(this, &StationFrontView::OnClickRequestLaunch)); b->onClick.connect(sigc::mem_fun(this, &StationFrontView::OnClickRequestLaunch));
Add(b, 40, size[1]-300); Add(b, 40, 300);
l = new Gui::Label("Request Launch"); l = new Gui::Label("Request Launch");
Add(l, 65, size[1]-300); Add(l, 65, 300);
b = new Gui::SolidButton(); b = new Gui::SolidButton();
b->onClick.connect(sigc::mem_fun(this, &StationFrontView::OnClickGotoShipYard)); b->onClick.connect(sigc::mem_fun(this, &StationFrontView::OnClickGotoShipYard));
Add(b, 40, size[1]-360); Add(b, 40, 360);
l = new Gui::Label("Shipyard"); l = new Gui::Label("Shipyard");
Add(l, 65, size[1]-360); Add(l, 65, 360);
} }
/**********************************************************/ /**********************************************************/

View File

@ -76,12 +76,11 @@ void SystemInfoView::PutBodies(StarSystem::SBody* body, int dir, float pos[2],
if(body->type != StarSystem::TYPE_GRAVPOINT) { if(body->type != StarSystem::TYPE_GRAVPOINT) {
Gui::ImageButton* ib = new Gui::ImageButton(body->GetIcon()); Gui::ImageButton* ib = new Gui::ImageButton(body->GetIcon());
ib->GetSize(size); ib->GetSize(size);
size[1] = -size[1];
if(prevSize == -1) prevSize = size[!dir]; if(prevSize == -1) prevSize = size[!dir];
ib->onClick.connect(sigc::bind(sigc::mem_fun(this, &SystemInfoView::OnBodySelected), body)); ib->onClick.connect(sigc::bind(sigc::mem_fun(this, &SystemInfoView::OnBodySelected), body));
myPos[0] += (dir ? prevSize*0.5 - size[0]*0.5 : 0); myPos[0] += (dir ? prevSize*0.5 - size[0]*0.5 : 0);
myPos[1] += (!dir ? prevSize*0.5 - size[1]*0.5 : 0); myPos[1] += (!dir ? prevSize*0.5 - size[1]*0.5 : 0);
Add(ib, myPos[0], myPos[1]+size[1]); Add(ib, myPos[0], myPos[1]);
majorBodies++; majorBodies++;
pos[dir] += size[dir]; pos[dir] += size[dir];
dir = !dir; dir = !dir;
@ -100,21 +99,16 @@ void SystemInfoView::PutBodies(StarSystem::SBody* body, int dir, float pos[2],
void SystemInfoView::SystemChanged(StarSystem* s) { void SystemInfoView::SystemChanged(StarSystem* s) {
DeleteAllChildren(); DeleteAllChildren();
float csize[2];
int majorBodies = 0; int majorBodies = 0;
GetSize(csize);
float pos[2];
pos[0] = 0;
pos[1] = csize[1];
float pos[2] = { 0, 0 };
PutBodies(s->rootBody, 1, pos, majorBodies, -1); PutBodies(s->rootBody, 1, pos, majorBodies, -1);
char buf[512]; char buf[512];
snprintf(buf, sizeof(buf), "Stable system with %d major bodies", majorBodies); snprintf(buf, sizeof(buf), "Stable system with %d major bodies", majorBodies);
m_infoText = new Gui::Label(buf); m_infoText = new Gui::Label(buf);
m_infoText->SetColor(1, 1, 0); m_infoText->SetColor(1, 1, 0);
Add(m_infoText, 50, 200); Add(m_infoText, 50, 400);
ShowAll(); ShowAll();
} }

View File

@ -9,7 +9,7 @@ SystemView::SystemView(void): View() {
m_timePoint = new Gui::Label(""); m_timePoint = new Gui::Label("");
m_timePoint->SetColor(.7, .7, .7); m_timePoint->SetColor(.7, .7, .7);
Add(m_timePoint, 24, 5); Add(m_timePoint, 2, Gui::Screen::GetHeight()-Gui::Screen::GetFontHeight()-66);;
m_zoomInButton = new Gui::ImageButton("icons/zoom_in_f7.png"); m_zoomInButton = new Gui::ImageButton("icons/zoom_in_f7.png");
m_zoomInButton->SetShortcut(SDLK_F6, KMOD_NONE); m_zoomInButton->SetShortcut(SDLK_F6, KMOD_NONE);

View File

@ -12,15 +12,15 @@
class View : public Gui::Fixed { class View : public Gui::Fixed {
public: public:
View(void) : Gui::Fixed(Gui::Screen::GetWidth(), Gui::Screen::GetHeight()-64) { View(void) : Gui::Fixed(Gui::Screen::GetWidth(), Gui::Screen::GetHeight()-64) {
Gui::Screen::AddBaseWidget(this, 0, 64); Gui::Screen::AddBaseWidget(this, 0, 0);
m_rightButtonBar = new Gui::Fixed(128, 26); m_rightButtonBar = new Gui::Fixed(128, 26);
m_rightButtonBar->SetBgColor(.65, .65, .65); m_rightButtonBar->SetBgColor(.65, .65, .65);
Gui::Screen::AddBaseWidget(m_rightButtonBar, Gui::Screen::GetWidth()-128, 0); Gui::Screen::AddBaseWidget(m_rightButtonBar, Gui::Screen::GetWidth()-128, Gui::Screen::GetHeight()-26);
m_rightRegion2 = new Gui::Fixed(122, 17); m_rightRegion2 = new Gui::Fixed(122, 17);
m_rightRegion2->SetTransparency(true); m_rightRegion2->SetTransparency(true);
Gui::Screen::AddBaseWidget(m_rightRegion2, Gui::Screen::GetWidth()-123, 26); Gui::Screen::AddBaseWidget(m_rightRegion2, Gui::Screen::GetWidth()-123, Gui::Screen::GetHeight()-44);
} }
virtual ~View(void) { delete m_rightButtonBar; delete m_rightRegion2; } virtual ~View(void) { delete m_rightButtonBar; delete m_rightRegion2; }
virtual void ShowAll(void) { virtual void ShowAll(void) {