[Partial Fix] Mostly fixed system info view to show triple and quadruple
systems.
This commit is contained in:
parent
dc836e99b1
commit
97dbcae545
@ -37,9 +37,20 @@ void GenericSystemView::Draw3D(void) {
|
||||
char buf[256];
|
||||
snprintf(buf, sizeof(buf), "Dist. %.2f light years.", dist);
|
||||
|
||||
std::string desc;
|
||||
if(s->GetNumStars() == 4) {
|
||||
desc= "Quadruple system. ";
|
||||
} else if(s->GetNumStars() == 3) {
|
||||
desc = "Triple system. ";
|
||||
} else if(s->GetNumStars() == 2) {
|
||||
desc = "Binary system. ";
|
||||
} else {
|
||||
desc = s->rootBody->GetAstroDescription();
|
||||
}
|
||||
|
||||
m_systemName->SetText(s->rootBody->name);
|
||||
m_distance->SetText(buf);
|
||||
m_starType->SetText(s->rootBody->GetAstroDescription());
|
||||
m_starType->SetText(desc);
|
||||
m_shortDesc->SetText("Short description of system");
|
||||
|
||||
onSelectedSystemChanged.emit(s);
|
||||
|
@ -460,6 +460,7 @@ StarSystem::StarSystem(int sector_x, int sector_y, int system_idx) {
|
||||
primary->name = s.m_systems[system_idx].name;
|
||||
MakeStarOfType(primary, type, rand);
|
||||
rootBody = primary;
|
||||
m_numStars = 1;
|
||||
} else {
|
||||
SBody* centGrav = new SBody;
|
||||
centGrav->type = TYPE_GRAVPOINT;
|
||||
@ -486,6 +487,7 @@ StarSystem::StarSystem(int sector_x, int sector_y, int system_idx) {
|
||||
centGrav->mass = star[0]->mass + star[1]->mass;
|
||||
centGrav->children.push_back(star[0]);
|
||||
centGrav->children.push_back(star[1]);
|
||||
m_numStars = 2;
|
||||
|
||||
if((star[0]->orbMax < fixed(100, 1)) &&
|
||||
(!rand.Int32(3))) {
|
||||
@ -497,6 +499,7 @@ StarSystem::StarSystem(int sector_x, int sector_y, int system_idx) {
|
||||
star[2]->orbMax = 0;
|
||||
MakeRandomStarLighterThan(star[2], star[0]->mass, rand);
|
||||
centGrav2 = star[2];
|
||||
m_numStars = 3;
|
||||
} else {
|
||||
centGrav2 = new SBody;
|
||||
centGrav2->type = TYPE_GRAVPOINT;
|
||||
@ -518,6 +521,7 @@ StarSystem::StarSystem(int sector_x, int sector_y, int system_idx) {
|
||||
centGrav2->mass = star[2]->mass + star[3]->mass;
|
||||
centGrav2->children.push_back(star[2]);
|
||||
centGrav2->children.push_back(star[3]);
|
||||
m_numStars = 4;
|
||||
}
|
||||
SBody* superCentGrav = new SBody;
|
||||
superCentGrav->type = TYPE_GRAVPOINT;
|
||||
|
@ -26,6 +26,8 @@ public:
|
||||
*sec_x = m_secx; *sec_y = m_secy, *sys_idx = m_sysIdx;
|
||||
}
|
||||
|
||||
int GetNumStars(void) const { return m_numStars; }
|
||||
|
||||
static float starColors[][3];
|
||||
|
||||
struct Orbit {
|
||||
@ -133,6 +135,7 @@ private:
|
||||
void GenerateFromCustom(const CustomSBody*);
|
||||
|
||||
int m_secx, m_secy, m_sysIdx;
|
||||
int m_numStars;
|
||||
|
||||
MTRand rand;
|
||||
};
|
||||
|
@ -55,69 +55,43 @@ void SystemInfoView::OnBodySelected(StarSystem::SBody* b) {
|
||||
m_infoText->SetText(desc);
|
||||
}
|
||||
|
||||
void SystemInfoView::PutBodies(StarSystem::SBody* body, int dir, float pos[2], int& majorBodies) {
|
||||
float size[2];
|
||||
float myPos[2];
|
||||
myPos[0] = pos[0];
|
||||
myPos[1] = pos[1];
|
||||
if(body->type != StarSystem::TYPE_GRAVPOINT) {
|
||||
Gui::ImageButton* ib = new Gui::ImageButton(body->GetIcon());
|
||||
ib->GetSize(size);
|
||||
size[1] = -size[1];
|
||||
pos[dir] += size[dir];
|
||||
myPos[dir] += size[dir];
|
||||
ib->onClick.connect(sigc::bind(sigc::mem_fun(this, &SystemInfoView::OnBodySelected), body));
|
||||
Add(ib, pos[0], pos[1]+0.5*size[1]);
|
||||
majorBodies++;
|
||||
dir = !dir;
|
||||
myPos[dir] += 0.5*size[dir];
|
||||
} else {
|
||||
pos[!dir] += 320;
|
||||
}
|
||||
|
||||
for(std::vector<StarSystem::SBody*>::iterator i = body->children.begin();
|
||||
i != body->children.end(); ++i) {
|
||||
PutBodies(*i, dir, myPos, majorBodies);
|
||||
}
|
||||
}
|
||||
|
||||
void SystemInfoView::SystemChanged(StarSystem* s) {
|
||||
DeleteAllChildren();
|
||||
float csize[2];
|
||||
int majorBodies = 0;
|
||||
GetSize(csize);
|
||||
|
||||
float xpos = 0;
|
||||
float size[2];
|
||||
float ycent;
|
||||
std::vector<StarSystem::SBody*>::iterator i = s->rootBody->children.begin();
|
||||
float pos[2];
|
||||
pos[0] = 50;
|
||||
pos[1] = csize[1]+40;
|
||||
|
||||
if(s->rootBody->type == StarSystem::TYPE_GRAVPOINT) {
|
||||
/* Binary system. */
|
||||
Gui::ImageButton* ib = new Gui::ImageButton((*i)->GetIcon());
|
||||
ib->GetSize(size);
|
||||
ib->onClick.connect(sigc::bind(sigc::mem_fun(this, &SystemInfoView::OnBodySelected), *i));
|
||||
Add(ib, 0, csize[1] - size[1]);
|
||||
float yoffset = size[1];
|
||||
float xoffset = size[0];
|
||||
++i; majorBodies++;
|
||||
|
||||
ib = new Gui::ImageButton((*i)->GetIcon());
|
||||
ib->GetSize(size);
|
||||
ib->onClick.connect(sigc::bind(sigc::mem_fun(this, &SystemInfoView::OnBodySelected), *i));
|
||||
Add(ib, 0, csize[1] - size[1] - yoffset);
|
||||
++i; majorBodies++;
|
||||
|
||||
xpos += xoffset;
|
||||
ycent = csize[1] - yoffset*0.5;
|
||||
} else {
|
||||
Gui::ImageButton* ib = new Gui::ImageButton(s->rootBody->GetIcon());
|
||||
ib->GetSize(size);
|
||||
ib->onClick.connect(sigc::bind(sigc::mem_fun(this, &SystemInfoView::OnBodySelected), s->rootBody));
|
||||
Add(ib, 0, csize[1] - size[1]);
|
||||
xpos += size[0];
|
||||
ycent = csize[1] - size[1]*0.5;
|
||||
majorBodies++;
|
||||
}
|
||||
|
||||
for(; i != s->rootBody->children.end(); ++i) {
|
||||
if((*i)->type == StarSystem::TYPE_GRAVPOINT) {
|
||||
|
||||
} else {
|
||||
Gui::ImageButton* ib = new Gui::ImageButton((*i)->GetIcon());
|
||||
ib->GetSize(size);
|
||||
ib->onClick.connect(sigc::bind(sigc::mem_fun(this, &SystemInfoView::OnBodySelected), *i));
|
||||
Add(ib, xpos, ycent - 0.5*size[1]);
|
||||
majorBodies++;
|
||||
}
|
||||
|
||||
float moon_ypos = ycent - size[1] - 5;
|
||||
if((*i)->children.size())
|
||||
for(std::vector<StarSystem::SBody*>::iterator moon = (*i)->children.begin();
|
||||
moon != (*i)->children.end(); ++moon) {
|
||||
float msize[2];
|
||||
Gui::ImageButton* ib = new Gui::ImageButton((*moon)->GetIcon());
|
||||
ib->GetSize(msize);
|
||||
ib->onClick.connect(sigc::bind(sigc::mem_fun(this, &SystemInfoView::OnBodySelected), *moon));
|
||||
Add(ib, xpos + 0.5*size[0] - 0.5*msize[0], moon_ypos);
|
||||
moon_ypos -= msize[1];
|
||||
}
|
||||
xpos += size[0];
|
||||
}
|
||||
PutBodies(s->rootBody, 1, pos, majorBodies);
|
||||
|
||||
char buf[512];
|
||||
snprintf(buf, sizeof(buf), "Stable system with %d major bodies", majorBodies);
|
||||
|
@ -13,6 +13,7 @@ public:
|
||||
private:
|
||||
void SystemChanged(StarSystem* s);
|
||||
void OnBodySelected(StarSystem::SBody* b);
|
||||
void PutBodies(StarSystem::SBody* body, int dir, float pos[2], int& majorBodies);
|
||||
StarSystem::SBody* m_bodySelected;
|
||||
Gui::Label* m_infoText;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user