Ejemplo n.º 1
0
	virtual void UpdateInfo() {
		const float YSEP = Gui::Screen::GetFontHeight() * 1.5f;
		DeleteAllChildren();
		Add(new Gui::Label(Lang::CARGO_INVENTORY), 40, 40);
		Add(new Gui::Label(Lang::JETTISON), 40, 40+YSEP*2);
		float ypos = 40 + 3*YSEP;
		for (int i=1; i<Equip::TYPE_MAX; i++) {
			if (Equip::types[i].slot != Equip::SLOT_CARGO) continue;
			const int gotNum = Pi::player->m_equipment.Count(Equip::SLOT_CARGO, static_cast<Equip::Type>(i));
			if (!gotNum) continue;
			Gui::Button *b = new Gui::SolidButton();
			b->onClick.connect(sigc::bind(sigc::mem_fun(this, &CargoPage::JettisonCargo), static_cast<Equip::Type>(i)));
			Add(b, 40, ypos);
			Add(new Gui::Label(Equip::types[i].name), 70, ypos);
			char buf[128];
			snprintf(buf, sizeof(buf), "%dt", gotNum*Equip::types[i].mass);
			Add(new Gui::Label(buf), 300, ypos);
			ypos += YSEP;
		}

		if (Pi::player->m_equipment.Count(Equip::SLOT_CARGO, Equip::WATER) > 0) {
			Gui::HBox *box = new Gui::HBox();
			box->SetSpacing(5.0f);
			Gui::Button *b = new Gui::SolidButton();
			b->onClick.connect(sigc::mem_fun(this, &CargoPage::Refuel));
			box->PackEnd(b);
			box->PackEnd(new Gui::Label(Lang::REFUEL));
			Add(box, 300, 40);
			box->ShowAll();
		}

		ShowChildren();
	}
Ejemplo n.º 2
0
	virtual void UpdateInfo() {
		const float YSEP = Gui::Screen::GetFontHeight() * 1.5f;
		DeleteAllChildren();

		Gui::Label *l = new Gui::Label(Lang::MISSIONS);
		Add(l, 20, 20);

		l = new Gui::Label(Lang::TYPE);
		Add(l, 20, 20+YSEP*2);
		
		l = new Gui::Label(Lang::CLIENT);
		Add(l, 100, 20+YSEP*2);
		
		l = new Gui::Label(Lang::LOCATION);
		Add(l, 260, 20+YSEP*2);
		
		l = new Gui::Label(Lang::DUE);
		Add(l, 420, 20+YSEP*2);
		
		l = new Gui::Label(Lang::REWARD);
		Add(l, 580, 20+YSEP*2);

		l = new Gui::Label(Lang::STATUS);
		Add(l, 680, 20+YSEP*2);

		ShowChildren();

		Gui::VScrollBar *scroll = new Gui::VScrollBar();
		Gui::VScrollPortal *portal = new Gui::VScrollPortal(760);
		scroll->SetAdjustment(&portal->vscrollAdjust);

		const std::list<const Mission*> &missions = Pi::player->missions.GetAll();
		Gui::Fixed *innerbox = new Gui::Fixed(760, missions.size());

		float ypos = 0;
		for (std::list<const Mission*>::const_iterator i = missions.begin(); i != missions.end(); ++i) {
			SystemPath path = (*i)->location;
			RefCountedPtr<StarSystem> s = StarSystem::GetCached(path);

			l = new Gui::Label((*i)->type);
			innerbox->Add(l, 0, ypos);
			
			l = new Gui::Label((*i)->client);
			innerbox->Add(l, 80, ypos);
			
			if (!path.IsBodyPath())
				l = new Gui::Label(stringf("%0 [%1{d},%2{d},%3{d}]", s->GetName().c_str(), path.sectorX, path.sectorY, path.sectorZ));
			else
				l = new Gui::Label(stringf("%0\n%1 [%2{d},%3{d},%4{d}]", s->GetBodyByPath(&path)->name.c_str(), s->GetName().c_str(), path.sectorX, path.sectorY, path.sectorZ));
			innerbox->Add(l, 240, ypos);
			
			l = new Gui::Label(format_date((*i)->due));
			innerbox->Add(l, 400, ypos);

			l = new Gui::Label(format_money((*i)->reward));
			innerbox->Add(l, 560, ypos);

			switch ((*i)->status) {
                case Mission::FAILED: l = new Gui::Label(std::string("#f00")+std::string(Lang::FAILED)); break;
                case Mission::COMPLETED: l = new Gui::Label(std::string("#ff0")+std::string(Lang::COMPLETED)); break;
				default:
                case Mission::ACTIVE: l = new Gui::Label(std::string("#0f0")+std::string(Lang::ACTIVE)); break;
			}
			innerbox->Add(l, 660, ypos);

			ypos += YSEP*3;
		}
		portal->Add(innerbox);

		Gui::HBox *body = new Gui::HBox();
		body->PackEnd(portal);
		body->PackEnd(scroll);
		body->ShowAll();
		Add(body, 20, 20+YSEP*3);
	}