Exemplo n.º 1
0
void GameLoaderSaver::DialogMainLoop()
{
	Gui::Fixed *background = new Gui::Fixed(float(Gui::Screen::GetWidth()), float(Gui::Screen::GetHeight()));
	background->SetTransparency(false);
	background->SetBgColor(0,0,0,1.0);

	Gui::Fixed *outer = new Gui::Fixed(410, 410);
	outer->SetTransparency(false);
	background->Add(outer, 195, 45);

	Gui::Fixed *inner = new Gui::Fixed(400, 400);
	outer->Add(inner, 5, 5);

	FileSelectorWidget *fileSelector = new FileSelectorWidget(m_type, m_title);
	inner->Add(fileSelector, 0, 0);

	fileSelector->onClickAction.connect(sigc::mem_fun(this, &GameLoaderSaver::OnClickLoad));
	fileSelector->onClickCancel.connect(sigc::mem_fun(this, &GameLoaderSaver::OnClickBack));

	Gui::Screen::AddBaseWidget(background, 0, 0);
	background->ShowAll();

	m_done = false;
	while (!m_done)
		Gui::MainLoopIteration();

	Gui::Screen::RemoveBaseWidget(background);
	delete background;
}
Exemplo n.º 2
0
	LoadDialogView() {
		SetTransparency(false);
		SetBgColor(0,0,0,1.0);

		Gui::Fixed *f2 = new Gui::Fixed(410, 410);
		f2->SetTransparency(false);
		Add(f2, 195, 45);
		Gui::Fixed *f = new Gui::Fixed(400, 400);
		f2->Add(f, 5, 5);
		m_fileDialog = new FileDialog(FileDialog::LOAD, Lang::SELECT_FILENAME_TO_LOAD);
		f->Add(m_fileDialog, 0, 0);

		m_fileDialog->onClickCancel.connect(sigc::mem_fun(this, &LoadDialogView::OnClickBack));
		m_fileDialog->onClickAction.connect(sigc::mem_fun(this, &LoadDialogView::OnClickLoad));
	}
Exemplo n.º 3
0
void Screen::ShowBadError(const char *msg)
{
    // to make things simple for ourselves, we want to hide all the existing widgets
    // however, if we do it through baseContainer->HideChildren() then we lose track of
    // which widgets should be shown again when the red-screen is cleared.
    // So to avoid this problem we don't hide anything, we just temporarily swap to
    // a different base container which is just used for this red-screen

    Gui::Fixed *oldBaseContainer = Screen::baseContainer;
    Screen::baseContainer = new Gui::Fixed();
    Screen::baseContainer->SetSize(float(Screen::width), float(Screen::height));
    Screen::baseContainer->Show();

    Gui::Fixed *f = new Gui::Fixed(6*GetWidth()/8.0f, 6*GetHeight()/8.0f);
    Gui::Screen::AddBaseWidget(f, GetWidth()/8, GetHeight()/8);
    f->SetTransparency(false);
    f->SetBgColor(0.4f,0,0,1.0f);
    f->Add(new Gui::Label(msg, TextLayout::ColourMarkupNone), 10, 10);

    Gui::Button *okButton = new Gui::LabelButton(new Gui::Label("Ok"));
    okButton->SetShortcut(SDLK_RETURN, KMOD_NONE);
    f->Add(okButton, 10.0f, 6*GetHeight()/8.0f - 32);
    f->ShowAll();
    f->Show();

    do {
        Gui::MainLoopIteration();
        SDL_Delay(10);
    } while (!okButton->IsPressed());

    delete f; // Gui::Fixed does a horrible thing and calls Gui::Screen::RemoveBaseWidget(this) in its destructor
    delete Screen::baseContainer;
    Screen::baseContainer = oldBaseContainer;
}
Exemplo n.º 4
0
void Screen::ShowBadError(const char *msg)
{
	fprintf(stderr, "%s", msg);
	baseContainer->HideChildren();
	
	Gui::Fixed *f = new Gui::Fixed(6*GetWidth()/8, 6*GetHeight()/8);
	Gui::Screen::AddBaseWidget(f, GetWidth()/8, GetHeight()/8);
	f->SetTransparency(false);
	f->SetBgColor(0.4,0,0,1.0);
	f->Add(new Gui::Label(msg), 10, 10);

	Gui::Button *okButton = new Gui::LabelButton(new Gui::Label("Ok"));
	okButton->SetShortcut(SDLK_RETURN, KMOD_NONE);
	f->Add(okButton, 10, 6*GetHeight()/8 - 32);
	f->ShowAll();
	f->Show();

	do {
		Gui::MainLoopIteration();
		SDL_Delay(10);
	} while (!okButton->IsPressed());

	Gui::Screen::RemoveBaseWidget(f);
	delete f;
	baseContainer->ShowAll();
}
Exemplo n.º 5
0
void Viewer::PickModel()
{
	Gui::Fixed *f = new Gui::Fixed();
	f->SetSizeRequest(Gui::Screen::GetWidth()*0.5f, Gui::Screen::GetHeight()*0.5);
	Gui::Screen::AddBaseWidget(f, Gui::Screen::GetWidth()*0.25f, Gui::Screen::GetHeight()*0.25f);

	f->Add(new Gui::Label("Enter the name of the model you want to view:"), 0, 0);

	Gui::Label *errormsg = new Gui::Label("");
	f->Add(errormsg, 0, 64);

	Gui::TextEntry *entry = new Gui::TextEntry();
	entry->onKeyPress.connect(sigc::bind(sigc::mem_fun(this, &Viewer::TryModel), entry, errormsg));
	entry->Show();
	f->Add(entry, 0, 32);

	m_model = 0;

	while (!m_model) {
		this->Hide();
		f->ShowAll();
		PollEvents();
		Render::PrepareFrame();
		glClearColor(0,0,0,0);
		glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
		Render::PostProcess();
		Gui::Draw();
		glError();
		Render::SwapBuffers();
	}
	Gui::Screen::RemoveBaseWidget(f);
	delete f;
	this->Show();
}
Exemplo n.º 6
0
void StationShipMarketForm::UpdateShipList()
{
	m_shiplistBox->DeleteAllChildren();

	float line_height = Gui::Screen::GetFontHeight();

	std::vector<ShipFlavour> &ships = m_station->GetShipsOnSale();

	int num = 0;
	for (std::vector<ShipFlavour>::iterator i = ships.begin(); i!=ships.end(); ++i) {
		Gui::Fixed *f = new Gui::Fixed(450, line_height*1.5f);

		Gui::Label *l = new Gui::Label(ShipType::types[(*i).type].name);
		f->Add(l,0,0);
		f->Add(new Gui::Label(format_money((*i).price)), 200, 0);
		f->Add(new Gui::Label(format_money((*i).price - Pi::player->GetFlavour()->price) ), 275, 0);
		f->Add(new Gui::Label(stringf(Lang::NUMBER_TONNES, formatarg("mass", ShipType::types[(*i).type].capacity))), 370, 0);
		
		Gui::SolidButton *sb = new Gui::SolidButton();
		sb->onClick.connect(sigc::bind(sigc::mem_fun(this, &StationShipMarketForm::ViewShip), num));
		f->Add(sb, 430, 0);

		m_shiplistBox->PackEnd(f);

		num++;
	}
}
Exemplo n.º 7
0
StationShipMarketForm::StationShipMarketForm(FormController *controller) : FaceForm(controller)
{
	m_station = Pi::player->GetDockedWith();

	SetTitle(stringf(Lang::SOMEWHERE_SHIP_MARKET, formatarg("station", m_station->GetLabel())));

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

	float line_height = Gui::Screen::GetFontHeight();

	m_shiplistBox = new Gui::VBox();
	m_shiplistBox->SetSpacing(line_height*0.5f);
	UpdateShipList();
	m_shiplistBox->ShowAll();

	portal->Add(m_shiplistBox);
	portal->ShowAll();

	Gui::VBox *outerbox = new Gui::VBox();
	outerbox->SetSpacing(line_height);

	Gui::Fixed *heading = new Gui::Fixed(470, Gui::Screen::GetFontHeight());
	const float *col = Gui::Theme::Colors::tableHeading;
	heading->Add((new Gui::Label(Lang::SHIP))->Color(col), 0, 0);
	heading->Add((new Gui::Label(Lang::PRICE))->Color(col), 200, 0);
	heading->Add((new Gui::Label(Lang::PART_EX))->Color(col), 275, 0);
	heading->Add((new Gui::Label(Lang::CAPACITY))->Color(col), 370, 0);
	heading->Add((new Gui::Label(Lang::VIEW))->Color(col), 430, 0);
	outerbox->PackEnd(heading);

	Gui::HBox *body = new Gui::HBox();
	body->PackEnd(portal);
	body->PackEnd(scroll);
	outerbox->PackEnd(body);

	Add(outerbox, 0, 0);
	ShowAll();

	m_onShipsForSaleChangedConnection = m_station->onShipsForSaleChanged.connect(sigc::mem_fun(this, &StationShipMarketForm::OnShipsForSaleChanged));
}
Exemplo n.º 8
0
	Viewer(): Gui::Fixed(float(g_width), float(g_height)) {
		m_model = 0;
		m_cmesh = 0;
		m_geom = 0;
		m_space = new CollisionSpace();
		m_showBoundingRadius = false;
		Gui::Screen::AddBaseWidget(this, 0, 0);
		SetTransparency(true);

		m_trisReadout = new Gui::Label("");
		Add(m_trisReadout, 500, 0);
		{
			Gui::Button *b = new Gui::SolidButton();
			b->SetShortcut(SDLK_c, KMOD_NONE);
			b->onClick.connect(sigc::mem_fun(*this, &Viewer::OnClickChangeView));
			Add(b, 10, 10);
			Add(new Gui::Label("[c] Change view (normal, collision mesh"), 30, 10);
		} 
		{
			Gui::Button *b = new Gui::SolidButton();
			b->SetShortcut(SDLK_r, KMOD_NONE);
			b->onClick.connect(sigc::mem_fun(*this, &Viewer::OnResetAdjustments));
			Add(b, 10, 30);
			Add(new Gui::Label("[r] Reset thruster and anim sliders"), 30, 30);
		} 
		{
			Gui::Button *b = new Gui::SolidButton();
			b->SetShortcut(SDLK_m, KMOD_NONE);
			b->onClick.connect(sigc::mem_fun(*this, &Viewer::OnClickRebuildCollMesh));
			Add(b, 10, 50);
			Add(new Gui::Label("[m] Rebuild collision mesh"), 30, 50);
		} 
		{
			Gui::Button *b = new Gui::SolidButton();
			b->SetShortcut(SDLK_p, KMOD_NONE);
			b->onClick.connect(sigc::mem_fun(*this, &Viewer::OnClickToggleBenchmark));
			Add(b, 10, 70);
			Add(new Gui::Label("[p] Toggle performance test (renders models 1000 times per frame)"), 30, 70);
		}
		{
			Gui::Button *b = new Gui::SolidButton();
			b->SetShortcut(SDLK_b, KMOD_LSHIFT);
			b->onClick.connect(sigc::mem_fun(*this, &Viewer::OnToggleBoundingRadius));
			Add(b, 10, 90);
			Add(new Gui::Label("[shift-b] Visualize bounding radius"), 30, 90);
		}
#if 0
		{
			Gui::Button *b = new Gui::SolidButton();
			b->SetShortcut(SDLK_g, KMOD_NONE);
			b->onClick.connect(sigc::mem_fun(*this, &Viewer::OnToggleGearState));
			Add(b, 10, 30);
			Add(new Gui::Label("[g] Toggle gear state"), 30, 30);
		}
#endif /* 0 */	
		{
			Add(new Gui::Label("Linear thrust"), 0, Gui::Screen::GetHeight()-140.0f);
			for (int i=0; i<3; i++) {
				m_linthrust[i] = new Gui::Adjustment();
				m_linthrust[i]->SetValue(0.5);
				Gui::VScrollBar *v = new Gui::VScrollBar();
				v->SetAdjustment(m_linthrust[i]);
				Add(v, float(i*25), Gui::Screen::GetHeight()-120.0f);
			}
			
			Add(new Gui::Label("Angular thrust"), 100, Gui::Screen::GetHeight()-140.0f);
			for (int i=0; i<3; i++) {
				m_angthrust[i] = new Gui::Adjustment();
				m_angthrust[i]->SetValue(0.5);
				Gui::VScrollBar *v = new Gui::VScrollBar();
				v->SetAdjustment(m_angthrust[i]);
				Add(v, float(100 + i*25), Gui::Screen::GetHeight()-120.0f);
			}
			
			Add(new Gui::Label("Animations (0 gear, 1-4 are time - ignore them comrade)"),
					200, Gui::Screen::GetHeight()-140.0f);
			for (int i=0; i<LMR_ARG_MAX; i++) {
				Gui::Fixed *box = new Gui::Fixed(32.0f, 120.0f);
				Add(box, float(200 + i*25), Gui::Screen::GetHeight()-120.0f);

				m_anim[i] = new Gui::Adjustment();
				m_anim[i]->SetValue(0);
				Gui::VScrollBar *v = new Gui::VScrollBar();
				v->SetAdjustment(m_anim[i]);
				box->Add(v, 0, 42.0f);
				char buf[32];
				snprintf(buf, sizeof(buf), "%d", i);
				box->Add(new Gui::Label(buf), 0, 0);

				m_animEntry[i] = new Gui::TextEntry();
				box->Add(m_animEntry[i], 0, 16.0f);
				m_anim[i]->onValueChanged.connect(sigc::bind(sigc::mem_fun(this, &Viewer::OnAnimChange), m_anim[i], m_animEntry[i]));
				OnAnimChange(m_anim[i], m_animEntry[i]);
			}
		}

		ShowAll();
		Show();
	}
Exemplo n.º 9
0
Arquivo: Pi.cpp Projeto: Snaar/pioneer
void Pi::Start()
{
	WorldView *view = new WorldView();
	
	Gui::Fixed *splash = new Gui::Fixed(Gui::Screen::GetWidth(), Gui::Screen::GetHeight());
	Gui::Screen::AddBaseWidget(splash, 0, 0);
	splash->SetTransparency(true);

	const float w = Gui::Screen::GetWidth() / 2;
	const float h = Gui::Screen::GetHeight() / 2;
	const int OPTS = 5;
	Gui::ToggleButton *opts[OPTS];
	opts[0] = new Gui::ToggleButton(); opts[0]->SetShortcut(SDLK_1, 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[3] = new Gui::ToggleButton(); opts[3]->SetShortcut(SDLK_4, KMOD_NONE);
	opts[4] = new Gui::ToggleButton(); opts[4]->SetShortcut(SDLK_5, KMOD_NONE);
	splash->Add(opts[0], w, 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(new Gui::Label("New game starting on Epsilon Eridani"), w+32, h-32);
	splash->Add(opts[2], w, h);
	splash->Add(new Gui::Label("New game starting on debug point"), w+32, h);
	splash->Add(opts[3], w, h+32);
	splash->Add(new Gui::Label("Load a saved game"), w+32, h+32);
	splash->Add(opts[4], w, h+64);
	splash->Add(new Gui::Label("Quit"), w+32, h+64);

	splash->ShowAll();

	int choice = 0;
	Uint32 last_time = SDL_GetTicks();
	float _time = 0;
	do {
		Pi::HandleEvents();

		Render::PrepareFrame();
		glMatrixMode(GL_PROJECTION);
		glLoadIdentity();
		float fracH = 1.0 / Pi::GetScrAspect();
		glFrustum(-1, 1, -fracH, fracH, 1.0f, 10000.0f);
		glMatrixMode(GL_MODELVIEW);
		glLoadIdentity();
		glClearColor(0,0,0,0);
		glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
		SDL_ShowCursor(1);
		SDL_WM_GrabInput(SDL_GRAB_OFF);

		draw_intro(view, _time);
		Render::PostProcess();
		Gui::Draw();
		Render::SwapBuffers();
		
		Pi::frameTime = 0.001*(SDL_GetTicks() - last_time);
		_time += Pi::frameTime;
		last_time = SDL_GetTicks();

		// poll ui instead of using callbacks :-J
		for (int i=0; i<OPTS; i++) if (opts[i]->GetPressed()) choice = i+1;
	} while (!choice);
	splash->HideAll();
	
	Gui::Screen::RemoveBaseWidget(splash);
	delete splash;
	delete view;
	
	InitGame();


	if (choice == 1) {
		/* Earth start point */
		SBodyPath path(0,0,0);
		Space::DoHyperspaceTo(&path);
		//Frame *pframe = *(++(++(Space::rootFrame->m_children.begin())));
		//player->SetFrame(pframe);
		// XXX there isn't a sensible way to find stations for a planet.
		SpaceStation *station = 0;
		for (Space::bodiesIter_t i = Space::bodies.begin(); i!=Space::bodies.end(); i++) {
			if ((*i)->IsType(Object::SPACESTATION)) { station = (SpaceStation*)*i; break; }
		}
		assert(station);
		player->SetPosition(vector3d(0,0,0));
		player->SetFrame(station->GetFrame());
		player->SetDockedWith(station, 0);
		MainLoop();
	} else if (choice == 2) {
		/* Epsilon Eridani start point */
		SBodyPath path(1,0,2);
		Space::DoHyperspaceTo(&path);
		// XXX there isn't a sensible way to find stations for a planet.
		SpaceStation *station = 0;
		for (Space::bodiesIter_t i = Space::bodies.begin(); i!=Space::bodies.end(); i++) {
			if ((*i)->IsType(Object::SPACESTATION)) {
				station = (SpaceStation*)*i;
				if (!station->IsGroundStation()) break;
			}
		}
		assert(station);
		player->SetPosition(vector3d(0,0,0));
		player->SetFrame(station->GetFrame());
		player->SetDockedWith(station, 0);
		MainLoop();
	} else if (choice == 3) {
		/* debug start point */
		SBodyPath path(1,0,2);
		path.sbodyId = 6;
		Space::DoHyperspaceTo(&path);
		player->SetPosition(vector3d(2*EARTH_RADIUS,0,0));
		player->SetVelocity(vector3d(0,0,0));
		player->m_equipment.Add(Equip::HYPERCLOUD_ANALYZER);

		Ship *enemy = new Ship(ShipType::EAGLE_LRF);
		enemy->SetFrame(player->GetFrame());
		enemy->SetPosition(player->GetPosition()+vector3d(0,0,-9000.0));
		enemy->SetVelocity(vector3d(0,0,0));
		enemy->m_equipment.Add(Equip::PULSECANNON_1MW);
		enemy->AIKill(player);
		Space::AddBody(enemy);

		player->SetCombatTarget(enemy);


		const ShipType *shipdef;
		double mass, acc1, acc2, acc3;
		printf("Player ship mass = %.0fkg, Enemy ship mass = %.0fkg\n",
			player->GetMass(), enemy->GetMass());

		shipdef = &player->GetShipType();
		mass = player->GetMass();
		acc1 = shipdef->linThrust[ShipType::THRUSTER_FORWARD] / (9.81*mass);
		acc2 = shipdef->linThrust[ShipType::THRUSTER_REVERSE] / (9.81*mass);
		acc3 = shipdef->linThrust[ShipType::THRUSTER_UP] / (9.81*mass);
		printf("Player ship thrust = %.1fg, %.1fg, %.1fg\n", acc1, acc2, acc3);

		shipdef = &enemy->GetShipType();
		mass = enemy->GetMass();
		acc1 = shipdef->linThrust[ShipType::THRUSTER_FORWARD] / (9.81*mass);
		acc2 = shipdef->linThrust[ShipType::THRUSTER_REVERSE] / (9.81*mass);
		acc3 = shipdef->linThrust[ShipType::THRUSTER_UP] / (9.81*mass);
		printf("Enemy ship thrust = %.1fg, %.1fg, %.1fg\n", acc1, acc2, acc3);


	/*	Frame *stationFrame = new Frame(pframe, "Station frame...");
		stationFrame->SetRadius(5000);
		stationFrame->m_sbody = 0;
		stationFrame->SetPosition(vector3d(0,0,zpos));
		stationFrame->SetAngVelocity(vector3d(0,0,0.5));

		for (int i=0; i<4; i++) {
			Ship *body = new Ship(ShipType::LADYBIRD);
			char buf[64];
			snprintf(buf,sizeof(buf),"X%c-0%02d", 'A'+i, i);
			body->SetLabel(buf);
			body->SetFrame(stationFrame);
			body->SetPosition(vector3d(200*(i+1), 0, 2000));
			Space::AddBody(body);
		}
			
		SpaceStation *station = new SpaceStation(SpaceStation::JJHOOP);
		station->SetLabel("Poemi-chan's Folly");
		station->SetFrame(stationFrame);
		station->SetPosition(vector3d(0,0,0));
		Space::AddBody(station);

		SpaceStation *station2 = new SpaceStation(SpaceStation::GROUND_FLAVOURED);
		station2->SetLabel("Conor's End");
		station2->SetFrame(*pframe->m_children.begin()); // rotating frame of planet
		station2->OrientOnSurface(EARTH_RADIUS, M_PI/4, M_PI/4);
		Space::AddBody(station2);
	*/
	//	player->SetDockedWith(station2, 0);

		MainLoop();
	} else if (choice == 4) {
		if (Pi::player) {
			Pi::player->MarkDead();
			Space::bodies.remove(Pi::player);
			delete Pi::player;
			Pi::player = 0;
		}
		Pi::gameMenuView->OpenLoadDialog();
		do {
			Gui::MainLoopIteration();
		} while (Pi::currentView != Pi::worldView);
		
		if (Pi::isGameStarted) MainLoop();
	} else {
		Pi::Quit();
	}
	UninitGame();
}
Exemplo n.º 10
0
void SystemInfoView::OnBodyViewed(SystemBody *b)
{
	std::string desc, data;

	m_infoBox->DeleteAllChildren();

	Gui::Fixed *outer = new Gui::Fixed(600, 200);
	m_infoBox->PackStart(outer);
	Gui::VBox *col1 = new Gui::VBox();
	Gui::VBox *col2 = new Gui::VBox();
	outer->Add(col1, 0, 0);
	outer->Add(col2, 300, 0);

#define _add_label_and_value(label, value) { \
	Gui::Label *l = (new Gui::Label(label))->Color(255,255,0); \
	col1->PackEnd(l); \
	l = (new Gui::Label(value))->Color(255,255,0); \
	col2->PackEnd(l); \
}

	bool multiple = (b->GetSuperType() == SystemBody::SUPERTYPE_STAR &&
					 b->GetParent() && b->GetParent()->GetType() == SystemBody::TYPE_GRAVPOINT && b->GetParent()->GetParent());
	{
		Gui::Label *l = new Gui::Label(b->GetName() + ": " + b->GetAstroDescription() +
			(multiple ? (std::string(" (")+b->GetParent()->GetName() + ")") : ""));
		l->Color(255,255,0);
		m_infoBox->PackStart(l);
	}

	_add_label_and_value(Lang::MASS, stringf(Lang::N_WHATEVER_MASSES, formatarg("mass", b->GetMassAsFixed().ToDouble()),
		formatarg("units", std::string(b->GetSuperType() == SystemBody::SUPERTYPE_STAR ? Lang::SOLAR : Lang::EARTH))));

	_add_label_and_value(Lang::RADIUS, stringf(Lang::N_WHATEVER_RADII, formatarg("radius", b->GetRadiusAsFixed().ToDouble()),
		formatarg("units", std::string(b->GetSuperType() == SystemBody::SUPERTYPE_STAR ? Lang::SOLAR : Lang::EARTH)),
		formatarg("radkm", b->GetRadius() / 1000.0)));

	if (b->GetSuperType() == SystemBody::SUPERTYPE_STAR) {
		_add_label_and_value(Lang::EQUATORIAL_RADIUS_TO_POLAR_RADIUS_RATIO, stringf("%0{f.3}", b->GetAspectRatio()));
	}

	if (b->GetType() != SystemBody::TYPE_STARPORT_ORBITAL) {
		_add_label_and_value(Lang::SURFACE_TEMPERATURE, stringf(Lang::N_CELSIUS, formatarg("temperature", b->GetAverageTemp()-273)));
		_add_label_and_value(Lang::SURFACE_GRAVITY, stringf("%0{f.3} m/s^2", b->CalcSurfaceGravity()));
	}

	if (b->GetParent()) {
		float days = float(b->GetOrbit().Period()) / float(60*60*24);
		if (days > 1000) {
			data = stringf(Lang::N_YEARS, formatarg("years", days/365));
		} else {
			data = stringf(Lang::N_DAYS, formatarg("days", b->GetOrbit().Period() / (60*60*24)));
		}
		if (multiple) {
			float pdays = float(b->GetParent()->GetOrbit().Period()) /float(60*60*24);
			data += " (" + (pdays > 1000 ? stringf(Lang::N_YEARS, formatarg("years", pdays/365))
										 : stringf(Lang::N_DAYS, formatarg("days", b->GetParent()->GetOrbit().Period() / (60*60*24)))) + ")";
		}
		_add_label_and_value(Lang::ORBITAL_PERIOD, data);
		_add_label_and_value(Lang::PERIAPSIS_DISTANCE, format_distance(b->GetOrbMin()*AU, 3) +
			(multiple ? (std::string(" (") + format_distance(b->GetParent()->GetOrbMin()*AU, 3)+ ")") : ""));
		_add_label_and_value(Lang::APOAPSIS_DISTANCE, format_distance(b->GetOrbMax()*AU, 3) +
			(multiple ? (std::string(" (") + format_distance(b->GetParent()->GetOrbMax()*AU, 3)+ ")") : ""));
		_add_label_and_value(Lang::ECCENTRICITY, stringf("%0{f.2}", b->GetOrbit().GetEccentricity()) +
			(multiple ? (std::string(" (") + stringf("%0{f.2}", b->GetParent()->GetOrbit().GetEccentricity()) + ")") : ""));
		if (b->GetType() != SystemBody::TYPE_STARPORT_ORBITAL) {
			_add_label_and_value(Lang::AXIAL_TILT, stringf(Lang::N_DEGREES, formatarg("angle", b->GetAxialTilt() * (180.0/M_PI))));
			if (b->IsRotating()) {
				_add_label_and_value(
					std::string(Lang::DAY_LENGTH)+std::string(Lang::ROTATIONAL_PERIOD),
					stringf(Lang::N_EARTH_DAYS, formatarg("days", b->GetRotationPeriodInDays())));
			}
		}
		int numSurfaceStarports = 0;
		std::string nameList;
		for (const SystemBody* kid : b->GetChildren()) {
			if (kid->GetType() == SystemBody::TYPE_STARPORT_SURFACE) {
				nameList += (numSurfaceStarports ? ", " : "") + kid->GetName();
				numSurfaceStarports++;
			}
		}
		if (numSurfaceStarports) {
			_add_label_and_value(Lang::STARPORTS, nameList);
		}
	}

	m_infoBox->ShowAll();
	m_infoBox->ResizeRequest();
}
Exemplo n.º 11
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, YSEP*3 * missions.size());

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

			l = new Gui::Label((*i)->type);
			innerbox->Add(l, 0, ypos);
			
			l = new Gui::Label((*i)->client);
			innerbox->Add(l, 80, ypos);
			
			l = new Gui::Label(stringf("%0,\n%1 [%2{d},%3{d},%4{d}]", sbody->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;
		}
		Add(portal, 20, 20 + YSEP*3);
		Add(scroll, 780, 20 + YSEP*3);
		scroll->ShowAll();
		portal->Add(innerbox);
		portal->ShowAll();
	}
Exemplo n.º 12
0
void SystemInfoView::OnBodyViewed(SBody *b)
{
	std::string desc, data;

	m_infoBox->DeleteAllChildren();
	
	Gui::Fixed *outer = new Gui::Fixed(600, 200);
	m_infoBox->PackStart(outer);
	Gui::VBox *col1 = new Gui::VBox();
	Gui::VBox *col2 = new Gui::VBox();
	outer->Add(col1, 0, 0);
	outer->Add(col2, 300, 0);

#define _add_label_and_value(label, value) { \
	Gui::Label *l = (new Gui::Label(label))->Color(1.0f,1.0f,0.0f); \
	col1->PackEnd(l); \
	l = (new Gui::Label(value))->Color(1.0f,1.0f,0.0f); \
	col2->PackEnd(l); \
}

	{
		Gui::Label *l = new Gui::Label(b->name + ": " + b->GetAstroDescription());
		l->Color(1,1,0);
		m_infoBox->PackStart(l);
	}

	_add_label_and_value(Lang::MASS, stringf(Lang::N_WHATEVER_MASSES, formatarg("mass", b->mass.ToDouble()), 
		formatarg("units", std::string(b->GetSuperType() == SBody::SUPERTYPE_STAR ? Lang::SOLAR : Lang::EARTH))));

	if (b->type != SBody::TYPE_STARPORT_ORBITAL) {
		_add_label_and_value(Lang::SURFACE_TEMPERATURE, stringf(Lang::N_CELSIUS, formatarg("temperature", b->averageTemp-273)));
		_add_label_and_value(Lang::SURFACE_GRAVITY, stringf("%0{f.3} m/s^2", b->CalcSurfaceGravity()));
	}

	if (b->parent) {
		float days = float(b->orbit.period) / float(60*60*24);
		if (days > 1000) {
			data = stringf(Lang::N_YEARS, formatarg("years", days/365));
		} else {
			data = stringf(Lang::N_DAYS, formatarg("days", b->orbit.period / (60*60*24)));
		}
		_add_label_and_value(Lang::ORBITAL_PERIOD, data);
		_add_label_and_value(Lang::PERIAPSIS_DISTANCE, stringf("%0{f.3} AU", b->orbMin.ToDouble()));
		_add_label_and_value(Lang::APOAPSIS_DISTANCE, stringf("%0{f.3} AU", b->orbMax.ToDouble()));
		_add_label_and_value(Lang::ECCENTRICITY, stringf("%0{f.2}", b->orbit.eccentricity));
		if (b->type != SBody::TYPE_STARPORT_ORBITAL) {
			_add_label_and_value(Lang::AXIAL_TILT, stringf(Lang::N_DEGREES, formatarg("angle", b->axialTilt.ToDouble() * (180.0/M_PI))));
			if (b->rotationPeriod != 0) {
				_add_label_and_value(
					std::string(Lang::DAY_LENGTH)+std::string(Lang::ROTATIONAL_PERIOD),
					stringf(Lang::N_EARTH_DAYS, formatarg("days", b->rotationPeriod.ToDouble())));
			}
		}
		int numSurfaceStarports = 0;
		std::string nameList;
		for (std::vector<SBody*>::iterator i = b->children.begin(); i != b->children.end(); ++i) {
			if ((*i)->type == SBody::TYPE_STARPORT_SURFACE) {
				nameList += (numSurfaceStarports ? ", " : "") + (*i)->name;
				numSurfaceStarports++;
			}
		}
		if (numSurfaceStarports) {
			_add_label_and_value(Lang::STARPORTS, nameList);
		}
	}

	m_infoBox->ShowAll();
	m_infoBox->ResizeRequest();
}
Exemplo n.º 13
0
void SystemInfoView::SystemChanged(const SystemPath &path)
{
	DeleteAllChildren();
	m_tabs = 0;
	m_bodyIcons.clear();

	if (!path.HasValidSystem())
		return;

	m_system = StarSystemCache::GetCached(path);

	m_sbodyInfoTab = new Gui::Fixed(float(Gui::Screen::GetWidth()), float(Gui::Screen::GetHeight()-100));

	if (m_system->GetUnexplored()) {
		Add(m_sbodyInfoTab, 0, 0);

		std::string _info =
			Lang::UNEXPLORED_SYSTEM_STAR_INFO_ONLY;

		Gui::Label *l = (new Gui::Label(_info))->Color(255,255,0);
		m_sbodyInfoTab->Add(l, 35, 300);
		m_selectedBodyPath = SystemPath();

		ShowAll();
		return;
	}

	m_econInfoTab = new Gui::Fixed(float(Gui::Screen::GetWidth()), float(Gui::Screen::GetHeight()-100));
	Gui::Fixed *demographicsTab = new Gui::Fixed();

	m_tabs = new Gui::Tabbed();
	m_tabs->AddPage(new Gui::Label(Lang::PLANETARY_INFO), m_sbodyInfoTab);
	m_tabs->AddPage(new Gui::Label(Lang::ECONOMIC_INFO), m_econInfoTab);
	m_tabs->AddPage(new Gui::Label(Lang::DEMOGRAPHICS), demographicsTab);
	Add(m_tabs, 0, 0);

	m_sbodyInfoTab->onMouseButtonEvent.connect(sigc::mem_fun(this, &SystemInfoView::OnClickBackground));

	int majorBodies, starports, onSurface;
	{
		float pos[2] = { 0, 0 };
		float psize = -1;
		majorBodies = starports = onSurface = 0;
		PutBodies(m_system->GetRootBody().Get(), m_econInfoTab, 1, pos, majorBodies, starports, onSurface, psize);

		majorBodies = starports = onSurface = 0;
		pos[0] = pos[1] = 0;
		psize = -1;
		PutBodies(m_system->GetRootBody().Get(), m_sbodyInfoTab, 1, pos, majorBodies, starports, onSurface, psize);

		majorBodies = starports = onSurface = 0;
		pos[0] = pos[1] = 0;
		psize = -1;
		PutBodies(m_system->GetRootBody().Get(), demographicsTab, 1, pos, majorBodies, starports, onSurface, psize);
	}

	std::string _info = stringf(
		Lang::STABLE_SYSTEM_WITH_N_MAJOR_BODIES_STARPORTS,
		formatarg("bodycount", majorBodies),
		formatarg("body(s)", std::string(majorBodies == 1 ? Lang::BODY : Lang::BODIES)),
		formatarg("portcount", starports),
		formatarg("starport(s)", std::string(starports == 1 ? Lang::STARPORT : Lang::COUNT_STARPORTS)));
	if (starports > 0)
		_info += stringf(Lang::COUNT_ON_SURFACE, formatarg("surfacecount", onSurface));
	_info += ".\n\n";
	_info += m_system->GetLongDescription();

	{
		// astronomical body info tab
		m_infoBox = new Gui::VBox();

		Gui::HBox *scrollBox = new Gui::HBox();
		scrollBox->SetSpacing(5);
		m_sbodyInfoTab->Add(scrollBox, 35, 250);

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

		Gui::Label *l = (new Gui::Label(_info))->Color(255,255,0);
		m_infoBox->PackStart(l);
		portal->Add(m_infoBox);
		scrollBox->PackStart(scroll);
		scrollBox->PackStart(portal);
	}

	{
		// economy tab
		Gui::HBox *scrollBox2 = new Gui::HBox();
		scrollBox2->SetSpacing(5);
		m_econInfoTab->Add(scrollBox2, 35, 300);
		Gui::VScrollBar *scroll2 = new Gui::VScrollBar();
		Gui::VScrollPortal *portal2 = new Gui::VScrollPortal(730);
		scroll2->SetAdjustment(&portal2->vscrollAdjust);
		scrollBox2->PackStart(scroll2);
		scrollBox2->PackStart(portal2);

		m_econInfo = new Gui::Label("");
		m_econInfoTab->Add(m_econInfo, 35, 250);

		Gui::Fixed *f = new Gui::Fixed();
		m_econMajImport = new Gui::Label("");
		m_econMinImport = new Gui::Label("");
		m_econMajExport = new Gui::Label("");
		m_econMinExport = new Gui::Label("");
		m_econIllegal = new Gui::Label("");
		m_econMajImport->Color(255,255,0);
		m_econMinImport->Color(255,255,0);
		m_econMajExport->Color(255,255,0);
		m_econMinExport->Color(255,255,0);
		m_econIllegal->Color(255,255,0);
		f->Add(m_econMajImport, 0, 0);
		f->Add(m_econMinImport, 150, 0);
		f->Add(m_econMajExport, 300, 0);
		f->Add(m_econMinExport, 450, 0);
		f->Add(m_econIllegal, 600, 0);
		portal2->Add(f);

		UpdateEconomyTab();
	}

	{
		Gui::Fixed *col1 = new Gui::Fixed();
		demographicsTab->Add(col1, 200, 300);
		Gui::Fixed *col2 = new Gui::Fixed();
		demographicsTab->Add(col2, 400, 300);

		const float YSEP = Gui::Screen::GetFontHeight() * 1.2f;

		col1->Add((new Gui::Label(Lang::SYSTEM_TYPE))->Color(255,255,0), 0, 0);
		col2->Add(new Gui::Label(m_system->GetShortDescription()), 0, 0);

		col1->Add((new Gui::Label(Lang::GOVERNMENT_TYPE))->Color(255,255,0), 0, 2*YSEP);
		col2->Add(new Gui::Label(m_system->GetSysPolit().GetGovernmentDesc()), 0, 2*YSEP);

		col1->Add((new Gui::Label(Lang::ECONOMY_TYPE))->Color(255,255,0), 0, 3*YSEP);
		col2->Add(new Gui::Label(m_system->GetSysPolit().GetEconomicDesc()), 0, 3*YSEP);

		col1->Add((new Gui::Label(Lang::ALLEGIANCE))->Color(255,255,0), 0, 4*YSEP);
		col2->Add(new Gui::Label(m_system->GetFaction()->name.c_str()), 0, 4*YSEP);
		col1->Add((new Gui::Label(Lang::POPULATION))->Color(255,255,0), 0, 5*YSEP);
		std::string popmsg;
		fixed pop = m_system->GetTotalPop();
		if (pop >= fixed(1,1)) { popmsg = stringf(Lang::OVER_N_BILLION, formatarg("population", pop.ToInt32())); }
		else if (pop >= fixed(1,1000)) { popmsg = stringf(Lang::OVER_N_MILLION, formatarg("population", (pop*1000).ToInt32())); }
		else if (pop != fixed(0)) { popmsg = Lang::A_FEW_THOUSAND; }
		else { popmsg = Lang::NO_REGISTERED_INHABITANTS; }
		col2->Add(new Gui::Label(popmsg), 0, 5*YSEP);

		col1->Add((new Gui::Label(Lang::SECTOR_COORDINATES))->Color(255,255,0), 0, 6*YSEP);
		col2->Add(new Gui::Label(stringf("%0{d}, %1{d}, %2{d}", path.sectorX, path.sectorY, path.sectorZ)), 0, 6*YSEP);

		col1->Add((new Gui::Label(Lang::SYSTEM_NUMBER))->Color(255,255,0), 0, 7*YSEP);
		col2->Add(new Gui::Label(stringf("%0", path.systemIndex)), 0, 7*YSEP);
	}

	UpdateIconSelections();

	ShowAll();
}
Exemplo n.º 14
0
void SystemInfoView::SystemChanged(const SystemPath &path)
{
	DeleteAllChildren();
	m_tabs = 0;
	m_bodyIcons.clear();

	if (!path.HasValidSystem())
		return;

	m_system = StarSystem::cache->GetCached(path);

	m_sbodyInfoTab = new Gui::Fixed(float(Gui::Screen::GetWidth()), float(Gui::Screen::GetHeight()-100));

	if (m_system->GetUnexplored()) {
		Add(m_sbodyInfoTab, 0, 0);

		std::string _info =
			Lang::UNEXPLORED_SYSTEM_STAR_INFO_ONLY;

		Gui::Label *l = (new Gui::Label(_info))->Color(255,255,0);
		m_sbodyInfoTab->Add(l, 35, 300);
		m_selectedBodyPath = SystemPath();

		ShowAll();
		return;
	}

	Gui::Fixed *demographicsTab = new Gui::Fixed();

	m_tabs = new Gui::Tabbed();
	m_tabs->AddPage(new Gui::Label(Lang::PLANETARY_INFO), m_sbodyInfoTab);
	m_tabs->AddPage(new Gui::Label(Lang::DEMOGRAPHICS), demographicsTab);
	Add(m_tabs, 0, 0);

	m_sbodyInfoTab->onMouseButtonEvent.connect(sigc::mem_fun(this, &SystemInfoView::OnClickBackground));

	int majorBodies, starports, onSurface;
	{
		float pos[2] = { 0, 0 };
		float psize = -1;

		majorBodies = starports = onSurface = 0;
		pos[0] = pos[1] = 0;
		psize = -1;
		PutBodies(m_system->GetRootBody().Get(), m_sbodyInfoTab, 1, pos, majorBodies, starports, onSurface, psize);

		majorBodies = starports = onSurface = 0;
		pos[0] = pos[1] = 0;
		psize = -1;
		PutBodies(m_system->GetRootBody().Get(), demographicsTab, 1, pos, majorBodies, starports, onSurface, psize);
	}

	std::string _info = stringf(
		Lang::STABLE_SYSTEM_WITH_N_MAJOR_BODIES_STARPORTS,
		formatarg("bodycount", majorBodies),
		formatarg("body(s)", std::string(majorBodies == 1 ? Lang::BODY : Lang::BODIES)),
		formatarg("portcount", starports),
		formatarg("starport(s)", std::string(starports == 1 ? Lang::STARPORT : Lang::COUNT_STARPORTS)));
	if (starports > 0)
		_info += stringf(Lang::COUNT_ON_SURFACE, formatarg("surfacecount", onSurface));
	_info += ".\n\n";
	_info += m_system->GetLongDescription();

	{
		// astronomical body info tab
		m_infoBox = new Gui::VBox();

		Gui::HBox *scrollBox = new Gui::HBox();
		scrollBox->SetSpacing(5);
		m_sbodyInfoTab->Add(scrollBox, 35, 250);

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

		Gui::Label *l = (new Gui::Label(_info))->Color(255,255,0);
		m_infoBox->PackStart(l);
		portal->Add(m_infoBox);
		scrollBox->PackStart(scroll);
		scrollBox->PackStart(portal);
	}

	{
		Gui::Fixed *col1 = new Gui::Fixed();
		demographicsTab->Add(col1, 200, 300);
		Gui::Fixed *col2 = new Gui::Fixed();
		demographicsTab->Add(col2, 400, 300);

		const float YSEP = Gui::Screen::GetFontHeight() * 1.2f;

		col1->Add((new Gui::Label(Lang::SYSTEM_TYPE))->Color(255,255,0), 0, 0);

		col1->Add((new Gui::Label(Lang::SECTOR_COORDINATES))->Color(255,255,0), 0, 6*YSEP);
		col2->Add(new Gui::Label(stringf("%0{d}, %1{d}, %2{d}", path.sectorX, path.sectorY, path.sectorZ)), 0, 6*YSEP);

		col1->Add((new Gui::Label(Lang::SYSTEM_NUMBER))->Color(255,255,0), 0, 7*YSEP);
		col2->Add(new Gui::Label(stringf("%0", path.systemIndex)), 0, 7*YSEP);
	}

	UpdateIconSelections();

	ShowAll();
}
Exemplo n.º 15
0
GameMenuView::GameMenuView(): View()
{
	Gui::Tabbed *tabs = new Gui::Tabbed();
	Add(tabs, 0, 0);

	Gui::Fixed *mainTab = new Gui::Fixed(800, 600);
	tabs->AddPage(new Gui::Label(Lang::SIGHTS_SOUNDS_SAVES), mainTab);

	mainTab->Add((new Gui::Label(Lang::PIONEER))->Shadow(true), 350, 10);
	SetTransparency(false);
	Gui::Label *l = new Gui::Label(Lang::PIONEER);
	l->Color(1,.7f,0);
	m_rightRegion2->Add(l, 10, 0);

	{
		Gui::Box *hbox = new Gui::HBox();
		hbox->SetSpacing(5.0f);
		mainTab->Add(hbox, 20, 30);

		m_saveButton = new Gui::LabelButton(new Gui::Label(Lang::SAVE_THE_GAME));
		m_saveButton->SetShortcut(SDLK_s, KMOD_NONE);
		m_saveButton->onClick.connect(sigc::mem_fun(this, &GameMenuView::OpenSaveDialog));
		hbox->PackEnd(m_saveButton);
		m_loadButton = new Gui::LabelButton(new Gui::Label(Lang::LOAD_A_GAME));
		m_loadButton->onClick.connect(sigc::mem_fun(this, &GameMenuView::OpenLoadDialog));
		m_loadButton->SetShortcut(SDLK_l, KMOD_NONE);
		hbox->PackEnd(m_loadButton);
		m_exitButton = new Gui::LabelButton(new Gui::Label(Lang::EXIT_THIS_GAME));
		m_exitButton->onClick.connect(sigc::mem_fun(this, &GameMenuView::HideAll));
		m_exitButton->onClick.connect(sigc::ptr_fun(&Pi::EndGame));
		hbox->PackEnd(m_exitButton);

		m_menuButton = new Gui::LabelButton(new Gui::Label(Lang::RETURN_TO_MENU));
		m_menuButton->onClick.connect(sigc::bind(sigc::ptr_fun(&Pi::SetView), static_cast<View*>(0)));
		mainTab->Add(m_menuButton, 20, 30);
	}

	Gui::Box *vbox = new Gui::VBox();
	vbox->SetSizeRequest(300, 440);
	vbox->SetSpacing(5.0);
	mainTab->Add(vbox, 20, 60);

	{
		vbox->PackEnd((new Gui::Label(Lang::WINDOW_OR_FULLSCREEN))->Color(1.0f,1.0f,0.0f));
		m_toggleFullscreen = new Gui::ToggleButton();
		m_toggleFullscreen->onChange.connect(sigc::mem_fun(this, &GameMenuView::OnToggleFullscreen));
		Gui::HBox *hbox = new Gui::HBox();
		hbox->SetSpacing(5.0f);
		hbox->PackEnd(m_toggleFullscreen);
		hbox->PackEnd(new Gui::Label(Lang::FULL_SCREEN));
		vbox->PackEnd(hbox);

		vbox->PackEnd((new Gui::Label(Lang::OTHER_GRAPHICS_SETTINGS))->Color(1.0f,1.0f,0.0f));
		m_toggleShaders = new Gui::ToggleButton();
		m_toggleShaders->onChange.connect(sigc::mem_fun(this, &GameMenuView::OnToggleShaders));
		hbox = new Gui::HBox();
		hbox->SetSpacing(5.0f);
		hbox->PackEnd(m_toggleShaders);
		hbox->PackEnd(new Gui::Label(Lang::USE_SHADERS));
		m_toggleCompressTextures = new Gui::ToggleButton();
		m_toggleCompressTextures->onChange.connect(sigc::mem_fun(this, &GameMenuView::OnToggleCompressTextures));
		hbox->PackEnd(m_toggleCompressTextures);
		hbox->PackEnd(new Gui::Label(Lang::COMPRESS_TEXTURES));
		vbox->PackEnd(hbox);

		vbox->PackEnd((new Gui::Label(Lang::SOUND_SETTINGS))->Color(1.0f,1.0f,0.0f));
		m_masterVolume = new VolumeControl(Lang::VOL_MASTER, Pi::config->Float("MasterVolume"), Pi::config->Int("MasterMuted"));
		vbox->PackEnd(m_masterVolume);
		m_sfxVolume = new VolumeControl(Lang::VOL_EFFECTS, Pi::config->Float("SfxVolume"), Pi::config->Int("SfxMuted"));
		vbox->PackEnd(m_sfxVolume);
		m_musicVolume = new VolumeControl(Lang::VOL_MUSIC, Pi::config->Float("MusicVolume"), Pi::config->Int("MusicMuted"));
		vbox->PackEnd(m_musicVolume);

		m_masterVolume->onChanged.connect(sigc::mem_fun(this, &GameMenuView::OnChangeVolume));
		m_sfxVolume->onChanged.connect(sigc::mem_fun(this, &GameMenuView::OnChangeVolume));
		m_musicVolume->onChanged.connect(sigc::mem_fun(this, &GameMenuView::OnChangeVolume));
	}

	// Video mode selector
	{
		m_videoModes = Graphics::GetAvailableVideoModes();
		vbox->PackEnd((new Gui::Label(Lang::VIDEO_RESOLUTION))->Color(1.0f,1.0f,0.0f));

		m_screenModesGroup = new Gui::RadioGroup();

		// box to put the scroll portal and its scroll bar into
		Gui::HBox *scrollHBox = new Gui::HBox();
		vbox->PackEnd(scrollHBox);

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

		Gui::VBox *vbox2 = new Gui::VBox();
		portal->Add(vbox2);

		for (std::vector<Graphics::VideoMode>::const_iterator it = m_videoModes.begin();
			it != m_videoModes.end(); ++it) {
			Gui::RadioButton *temp = new Gui::RadioButton(m_screenModesGroup);
			temp->onSelect.connect(sigc::bind(sigc::mem_fun(this,
				&GameMenuView::OnChangeVideoResolution), it - m_videoModes.begin()));
			Gui::HBox *hbox = new Gui::HBox();
			hbox->SetSpacing(5.0f);
			hbox->PackEnd(temp);
			hbox->PackEnd(new Gui::Label(stringf(Lang::X_BY_X, formatarg("x", int(it->width)), formatarg("y", int(it->height)))));
			vbox2->PackEnd(hbox);
			//mark the current video mode
			if ((Pi::GetScrWidth() == it->width) && (Pi::GetScrHeight() == it->height)) {
				temp->SetSelected(true);
			}
		}
	}

	//Graphical detail settings
	{
		Gui::HBox *detailBox = new Gui::HBox();
		detailBox->SetSpacing(20.0f);
		mainTab->Add(detailBox, 350, 60);

		vbox = new Gui::VBox();
		vbox->SetSpacing(5.0f);
		detailBox->PackEnd(vbox);

		vbox->PackEnd((new Gui::Label(Lang::CITY_DETAIL_LEVEL))->Color(1.0f,1.0f,0.0f));
		m_cityDetailGroup = new Gui::RadioGroup();

		for (int i=0; i<5; i++) {
			Gui::RadioButton *rb = new Gui::RadioButton(m_cityDetailGroup);
			rb->onSelect.connect(sigc::bind(sigc::mem_fun(this, &GameMenuView::OnChangeCityDetail), i));
			Gui::HBox *hbox = new Gui::HBox();
			hbox->SetSpacing(5.0f);
			hbox->PackEnd(rb);
			hbox->PackEnd(new Gui::Label(planet_detail_desc[i]));
			vbox->PackEnd(hbox);
		}

		vbox = new Gui::VBox();
		vbox->SetSpacing(5.0f);
		detailBox->PackEnd(vbox);

		vbox->PackEnd((new Gui::Label(Lang::PLANET_DETAIL_DISTANCE))->Color(1.0f,1.0f,0.0f));
		m_planetDetailGroup = new Gui::RadioGroup();

		for (int i=0; i<5; i++) {
			Gui::RadioButton *rb = new Gui::RadioButton(m_planetDetailGroup);
			rb->onSelect.connect(sigc::bind(sigc::mem_fun(this, &GameMenuView::OnChangePlanetDetail), i));
			Gui::HBox *hbox = new Gui::HBox();
			hbox->SetSpacing(5.0f);
			hbox->PackEnd(rb);
			hbox->PackEnd(new Gui::Label(planet_detail_desc[i]));
			vbox->PackEnd(hbox);
		}

		vbox = new Gui::VBox();
		vbox->SetSpacing(5.0f);
		detailBox->PackEnd(vbox);

		vbox->PackEnd((new Gui::Label(Lang::PLANET_TEXTURES))->Color(1.0f,1.0f,0.0f));
		m_planetTextureGroup = new Gui::RadioGroup();

		for (int i=0; i<2; i++) {
			Gui::RadioButton *rb = new Gui::RadioButton(m_planetTextureGroup);
			rb->onSelect.connect(sigc::bind(sigc::mem_fun(this, &GameMenuView::OnChangePlanetTextures), i));
			Gui::HBox *hbox = new Gui::HBox();
			hbox->SetSpacing(5.0f);
			hbox->PackEnd(rb);
			hbox->PackEnd(new Gui::Label(planet_textures_desc[i]));
			vbox->PackEnd(hbox);
		}

		vbox = new Gui::VBox();
		vbox->SetSpacing(5.0f);
		detailBox->PackEnd(vbox);

		vbox->PackEnd((new Gui::Label(Lang::FRACTAL_DETAIL))->Color(1.0f,1.0f,0.0f));
		m_planetFractalGroup = new Gui::RadioGroup();

		for (int i=0; i<5; i++) {
			Gui::RadioButton *rb = new Gui::RadioButton(m_planetFractalGroup);
			rb->onSelect.connect(sigc::bind(sigc::mem_fun(this, &GameMenuView::OnChangeFractalMultiple), i));
			Gui::HBox *hbox = new Gui::HBox();
			hbox->SetSpacing(5.0f);
			hbox->PackEnd(rb);
			hbox->PackEnd(new Gui::Label(planet_fractal_desc[i]));
			vbox->PackEnd(hbox);
		}
	}


	// language

	vbox = new Gui::VBox();
	vbox->SetSizeRequest(300, 200);
	mainTab->Add(vbox, 400, 250);

	vbox->PackEnd((new Gui::Label(Lang::LANGUAGE_SELECTION))->Color(1.0f,1.0f,0.0f));

	m_languageGroup = new Gui::RadioGroup();
	const std::vector<std::string> &availableLanguages = Lang::GetAvailableLanguages();

	{
		// box to put the scroll portal and its scroll bar into
		Gui::HBox *scrollHBox = new Gui::HBox();
		vbox->PackEnd(scrollHBox);

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

		Gui::VBox *vbox2 = new Gui::VBox();
		portal->Add(vbox2);

		for (std::vector<std::string>::const_iterator i = availableLanguages.begin(); i != availableLanguages.end(); ++i) {
			Gui::RadioButton *temp = new Gui::RadioButton(m_languageGroup);
			temp->onSelect.connect(sigc::bind(sigc::mem_fun(this, &GameMenuView::OnChangeLanguage), *i));
			Gui::HBox *hbox = new Gui::HBox();
			hbox->SetSpacing(5.0f);
			hbox->PackEnd(temp);
			hbox->PackEnd(new Gui::Label(*i));
			vbox2->PackEnd(hbox);
			if ((*i) == Pi::config->String("Lang"))
				temp->SetSelected(true);
		}
	}


	// key binding tab 1
	{
		Gui::Fixed *keybindingTab = new Gui::Fixed(800, 600);
		tabs->AddPage(new Gui::Label(Lang::CONTROLS), keybindingTab);

		Gui::VBox *box1 = new Gui::VBox();
		box1->SetSpacing(5.0f);
		keybindingTab->Add(box1, 10, 10);

		Gui::VBox *box2 = new Gui::VBox();
		box2->SetSpacing(5.0f);
		keybindingTab->Add(box2, 400, 10);

		Gui::VBox *box = box1;
		KeyGetter *keyg;

		for (int i=0; KeyBindings::bindingProtos[i].label; i++) {
			const char *label = KeyBindings::bindingProtos[i].label;
			const char *function = KeyBindings::bindingProtos[i].function;

			if (function) {
				KeyBindings::KeyBinding kb = KeyBindings::KeyBindingFromString(Pi::config->String(function));
				keyg = new KeyGetter(label, kb);
				keyg->onChange.connect(sigc::bind(sigc::mem_fun(this, &GameMenuView::OnChangeKeyBinding), function));
				box->PackEnd(keyg);
			} else {
				// section
				box->PackEnd((new Gui::Label(label))->Color(1.0f, 1.0f, 0.0f));
			}

			/* 2nd column */
			if (i == 20) {
				box = box2;
			}
		}

		for (int i=0; KeyBindings::axisBindingProtos[i].label; i++) {
			AxisGetter *axisg;
			const char *label = KeyBindings::axisBindingProtos[i].label;
			const char *function = KeyBindings::axisBindingProtos[i].function;

			if (function) {
				KeyBindings::AxisBinding ab = KeyBindings::AxisBindingFromString(Pi::config->String(function).c_str());
				axisg = new AxisGetter(label, ab);
				axisg->onChange.connect(sigc::bind(sigc::mem_fun(this, &GameMenuView::OnChangeAxisBinding), function));
				box->PackEnd(axisg);
			} else {
				// section
				box->PackEnd((new Gui::Label(label))->Color(1.0f, 1.0f, 0.0f));
			}

			/* 2nd column */
			if (i == 20) {
				box = box2;
			}
		}

		m_toggleJoystick = new Gui::ToggleButton();
		m_toggleJoystick->onChange.connect(sigc::mem_fun(this, &GameMenuView::OnToggleJoystick));
		Gui::HBox *hbox = new Gui::HBox();
		hbox->SetSpacing(5.0f);
		hbox->PackEnd(m_toggleJoystick);
		hbox->PackEnd(new Gui::Label(Lang::ENABLE_JOYSTICK));
		box->PackEnd(hbox);

		// Invert Mouse
		m_toggleMouseYInvert = new Gui::ToggleButton();
		m_toggleMouseYInvert->onChange.connect(sigc::mem_fun(this, &GameMenuView::OnToggleMouseYInvert));
		box->PackEnd((new Gui::Label(Lang::MOUSE_INPUT))->Color(1.0f,1.0f,0.0f));

		Gui::HBox *mybox = new Gui::HBox();
		mybox->SetSpacing(5.0f);
		mybox->PackEnd(m_toggleMouseYInvert);
		mybox->PackEnd(new Gui::Label(Lang::INVERT_MOUSE_Y));
		box->PackEnd(mybox);

		// Toggle nav tunnel
		m_toggleNavTunnel = new Gui::ToggleButton();
		m_toggleNavTunnel->onChange.connect(sigc::mem_fun(this, &GameMenuView::OnToggleNavTunnel));
		box->PackEnd((new Gui::Label(Lang::HUD))->Color(1.0f,1.0f,0.0f));

		Gui::HBox *guibox = new Gui::HBox();
		guibox->SetSpacing(5.0f);
		guibox->PackEnd(m_toggleNavTunnel);
		guibox->PackEnd(new Gui::Label(Lang::DISPLAY_NAV_TUNNEL));
		box->PackEnd(guibox);
	}

	// key binding tab 2
	{
		Gui::Fixed *keybindingTab = new Gui::Fixed(800, 600);
		tabs->AddPage(new Gui::Label(Lang::VIEW), keybindingTab);

		Gui::VBox *box1 = new Gui::VBox();
		box1->SetSpacing(5.0f);
		keybindingTab->Add(box1, 10, 10);

		Gui::VBox *box = box1;
		KeyGetter *keyg;

		for (int i=0; KeyBindings::camBindingProtos[i].label; i++) {
			const char *label = KeyBindings::camBindingProtos[i].label;
			const char *function = KeyBindings::camBindingProtos[i].function;

			if (function) {
				KeyBindings::KeyBinding kb = KeyBindings::KeyBindingFromString(Pi::config->String(function));
				keyg = new KeyGetter(label, kb);
				keyg->onChange.connect(sigc::bind(sigc::mem_fun(this, &GameMenuView::OnChangeKeyBinding), function));
				box->PackEnd(keyg);
			} else {
				// section
				box->PackEnd((new Gui::Label(label))->Color(1.0f, 1.0f, 0.0f));
			}
		}
	}
}
Exemplo n.º 16
0
void CommodityTradeWidget::ShowAll()
{
	DeleteAllChildren();
	m_stockLabels.clear();
	m_cargoLabels.clear();

	SetTransparency(true);

	Gui::VScrollBar *scroll = new Gui::VScrollBar();
	Gui::VScrollPortal *portal = new Gui::VScrollPortal(450);
	scroll->SetAdjustment(&portal->vscrollAdjust);
	//int GetStock(Equip::Type t) const { return m_equipmentStock[t]; }

	int NUM_ITEMS = 0;
	const float YSEP = floor(Gui::Screen::GetFontHeight() * 2.5f);
	for (int i=Equip::FIRST_COMMODITY; i<=Equip::LAST_COMMODITY; i++) {
		assert(Equip::types[i].slot == Equip::SLOT_CARGO);

		if (m_seller->DoesSell(Equip::Type(i))) {
				NUM_ITEMS++;
		}
	}
	Gui::Fixed *innerbox = new Gui::Fixed(450, NUM_ITEMS*YSEP);
	innerbox->SetTransparency(true);

	const float iconOffset = 8.0f;
	for (int i=Equip::FIRST_COMMODITY, num=0; i<=Equip::LAST_COMMODITY; i++) {
		assert(Equip::types[i].slot == Equip::SLOT_CARGO);

		if (!m_seller->DoesSell(Equip::Type(i))) continue;
		int stock = m_seller->GetStock(static_cast<Equip::Type>(i));

        std::map<Equip::Type,std::string>::iterator icon_iter = s_iconMap.find(Equip::Type(i));
		if (icon_iter != s_iconMap.end()) {
			Gui::Image *icon = new Gui::Image(("icons/goods/" + (*icon_iter).second + ".png").c_str());
			// this forces the on-screen rendering to fit within (rescale) to these dimensions
			icon->SetRenderDimensions(38.0f, 32.0f);
			innerbox->Add(icon, 0, num*YSEP);
		}

		Gui::Label *l = new Gui::Label(Equip::types[i].name);
		if (Equip::types[i].description)
			l->SetToolTip(Equip::types[i].description);
		innerbox->Add(l,42,num*YSEP+iconOffset);
		Gui::RepeaterButton *b = new Gui::RepeaterButton(RBUTTON_DELAY, RBUTTON_REPEAT);
		sigc::slot<void> func = sigc::bind(sigc::mem_fun(this, &CommodityTradeWidget::OnClickBuy), i);
		b->onClick.connect(sigc::bind(sigc::mem_fun(this, &CommodityTradeWidget::ManageRButton), b, func));
		innerbox->Add(b, 380, num*YSEP+iconOffset);
		b = new Gui::RepeaterButton(RBUTTON_DELAY, RBUTTON_REPEAT);
		func = sigc::bind(sigc::mem_fun(this, &CommodityTradeWidget::OnClickSell), i);
		b->onClick.connect(sigc::bind(sigc::mem_fun(this, &CommodityTradeWidget::ManageRButton), b, func));
		innerbox->Add(b, 415, num*YSEP+iconOffset);
		char buf[128];
		innerbox->Add(new Gui::Label(
					format_money(m_seller->GetPrice(static_cast<Equip::Type>(i)))
					), 200, num*YSEP+iconOffset);

		snprintf(buf, sizeof(buf), "%dt", stock*Equip::types[i].mass);
		Gui::Label *stocklabel = new Gui::Label(buf);
		m_stockLabels[i] = stocklabel;
		innerbox->Add(stocklabel, 275, num*YSEP+iconOffset);

		snprintf(buf, sizeof(buf), "%dt", Pi::player->m_equipment.Count(Equip::SLOT_CARGO, static_cast<Equip::Type>(i))*Equip::types[i].mass);
		Gui::Label *cargolabel = new Gui::Label(buf);
		m_cargoLabels[i] = cargolabel;
		innerbox->Add(cargolabel, 325, num*YSEP+iconOffset);
		num++;
	}
	innerbox->ShowAll();

	portal->Add(innerbox);
	portal->ShowAll();

	Gui::Fixed *heading = new Gui::Fixed(470, Gui::Screen::GetFontHeight());
	const Color &col = Gui::Theme::Colors::tableHeading;
	heading->Add((new Gui::Label(Lang::ITEM))->Color(col), 0, 0);
	heading->Add((new Gui::Label(Lang::PRICE))->Color(col), 200, 0);
	heading->Add((new Gui::Label(Lang::BUY))->Color(col), 380, 0);
	heading->Add((new Gui::Label(Lang::SELL))->Color(col), 415, 0);
	heading->Add((new Gui::Label(Lang::STOCK))->Color(col), 275, 0);
	heading->Add((new Gui::Label(Lang::CARGO))->Color(col), 325, 0);
	PackEnd(heading);

	Gui::HBox *body = new Gui::HBox();
	body->PackEnd(portal);
	body->PackEnd(scroll);
	PackEnd(body);

	SetSpacing(YSEP-Gui::Screen::GetFontHeight());

	Gui::VBox::ShowAll();
}
Exemplo n.º 17
0
GameMenuView::GameMenuView(): View()
{
	m_subview = 0;

	Gui::Tabbed *tabs = new Gui::Tabbed();
	Add(tabs, 0, 0);

	Gui::Fixed *mainTab = new Gui::Fixed(800, 600);
	tabs->AddPage(new Gui::Label(Lang::SIGHTS_SOUNDS_SAVES), mainTab);

	mainTab->Add((new Gui::Label(Lang::PIONEER))->Shadow(true), 350, 10);
	SetTransparency(false);
	Gui::Label *l = new Gui::Label(Lang::PIONEER);
	l->Color(1,.7,0);
	m_rightRegion2->Add(l, 10, 0);
	
	{
		Gui::LabelButton *b;
		Gui::Box *hbox = new Gui::HBox();
		hbox->SetSpacing(5.0f);
		mainTab->Add(hbox, 20, 30);
		b = new Gui::LabelButton(new Gui::Label(Lang::SAVE_THE_GAME));
		b->SetShortcut(SDLK_s, KMOD_NONE);
		b->onClick.connect(sigc::mem_fun(this, &GameMenuView::OpenSaveDialog));
		hbox->PackEnd(b);
		b = new Gui::LabelButton(new Gui::Label(Lang::LOAD_A_GAME));
		b->onClick.connect(sigc::mem_fun(this, &GameMenuView::OpenLoadDialog));
		b->SetShortcut(SDLK_l, KMOD_NONE);
		hbox->PackEnd(b);
		b = new Gui::LabelButton(new Gui::Label(Lang::EXIT_THIS_GAME));
		b->onClick.connect(sigc::mem_fun(this, &GameMenuView::HideAll));
		b->onClick.connect(sigc::ptr_fun(&Pi::EndGame));
		hbox->PackEnd(b);
	}

	Gui::Box *vbox = new Gui::VBox();
	vbox->SetSizeRequest(300, 440);
	vbox->SetSpacing(5.0);
	mainTab->Add(vbox, 20, 60);

	{
		vbox->PackEnd((new Gui::Label(Lang::WINDOW_OR_FULLSCREEN))->Color(1.0f,1.0f,0.0f));
		m_toggleFullscreen = new Gui::ToggleButton();
		m_toggleFullscreen->onChange.connect(sigc::mem_fun(this, &GameMenuView::OnToggleFullscreen));
		Gui::HBox *hbox = new Gui::HBox();
		hbox->SetSpacing(5.0f);
		hbox->PackEnd(m_toggleFullscreen);
		hbox->PackEnd(new Gui::Label(Lang::FULL_SCREEN));
		vbox->PackEnd(hbox);
		
		vbox->PackEnd((new Gui::Label(Lang::OTHER_GRAPHICS_SETTINGS))->Color(1.0f,1.0f,0.0f));
		m_toggleShaders = new Gui::ToggleButton();
		m_toggleShaders->onChange.connect(sigc::mem_fun(this, &GameMenuView::OnToggleShaders));
		hbox = new Gui::HBox();
		hbox->SetSpacing(5.0f);
		hbox->PackEnd(m_toggleShaders);
		hbox->PackEnd(new Gui::Label(Lang::USE_SHADERS));
		vbox->PackEnd(hbox);
		
		m_toggleHDR = new Gui::ToggleButton();
		m_toggleHDR->onChange.connect(sigc::mem_fun(this, &GameMenuView::OnToggleHDR));
		hbox = new Gui::HBox();
		hbox->SetSpacing(5.0f);
		hbox->PackEnd(m_toggleHDR);
		hbox->PackEnd(new Gui::Label(Lang::USE_HDR));
		vbox->PackEnd(hbox);
		if (!Render::IsHDRAvailable()) m_toggleHDR->SetEnabled(false);
		
		vbox->PackEnd((new Gui::Label(Lang::SOUND_SETTINGS))->Color(1.0f,1.0f,0.0f));
		m_masterVolume = new VolumeControl(Lang::VOL_MASTER, Pi::config.Float("MasterVolume"), Pi::config.Int("MasterMuted"));
		vbox->PackEnd(m_masterVolume);
		m_sfxVolume = new VolumeControl(Lang::VOL_EFFECTS, Pi::config.Float("SfxVolume"), Pi::config.Int("SfxMuted"));
		vbox->PackEnd(m_sfxVolume);
		m_musicVolume = new VolumeControl(Lang::VOL_MUSIC, Pi::config.Float("MusicVolume"), Pi::config.Int("MusicMuted"));
		vbox->PackEnd(m_musicVolume);

		m_masterVolume->onChanged.connect(sigc::mem_fun(this, &GameMenuView::OnChangeVolume));
		m_sfxVolume->onChanged.connect(sigc::mem_fun(this, &GameMenuView::OnChangeVolume));
		m_musicVolume->onChanged.connect(sigc::mem_fun(this, &GameMenuView::OnChangeVolume));
	}

	vbox->PackEnd((new Gui::Label(Lang::VIDEO_RESOLUTION))->Color(1.0f,1.0f,0.0f));

	Gui::RadioGroup *g = new Gui::RadioGroup();
	SDL_Rect **modes;
	modes = SDL_ListModes(NULL, SDL_FULLSCREEN|SDL_HWSURFACE);
	if ((modes!=0) && (modes != reinterpret_cast<SDL_Rect**>(-1))) {
		// box to put the scroll portal and its scroll bar into
		Gui::HBox *scrollHBox = new Gui::HBox();
		vbox->PackEnd(scrollHBox);
		
		Gui::VScrollBar *scroll = new Gui::VScrollBar();
		Gui::VScrollPortal *portal = new Gui::VScrollPortal(280);
		scroll->SetAdjustment(&portal->vscrollAdjust);
		scrollHBox->PackEnd(portal);
		scrollHBox->PackEnd(scroll);

		Gui::VBox *vbox2 = new Gui::VBox();
		portal->Add(vbox2);
		
		for (int i=0; modes[i]; ++i) {
			Gui::RadioButton *temp = new Gui::RadioButton(g);
			temp->onSelect.connect(sigc::bind(sigc::mem_fun(this,
					&GameMenuView::OnChangeVideoResolution), i));
			Gui::HBox *hbox = new Gui::HBox();
			hbox->SetSpacing(5.0f);
			hbox->PackEnd(temp);
			hbox->PackEnd(new Gui::Label(stringf(256, Lang::X_BY_X, modes[i]->w, modes[i]->h)));
			vbox2->PackEnd(hbox);
			if ((Pi::GetScrWidth() == modes[i]->w) && (Pi::GetScrHeight() == modes[i]->h)) {
				temp->SetSelected(true);
			}
		}
	}


	Gui::HBox *detailBox = new Gui::HBox();
	detailBox->SetSpacing(60.0f);
	mainTab->Add(detailBox, 400, 60);

	vbox = new Gui::VBox();
	vbox->SetSpacing(5.0f);
	detailBox->PackEnd(vbox);

	vbox->PackEnd((new Gui::Label(Lang::PLANET_DETAIL_LEVEL))->Color(1.0f,1.0f,0.0f));
	m_planetDetailGroup = new Gui::RadioGroup();

	for (int i=0; i<5; i++) {
		Gui::RadioButton *rb = new Gui::RadioButton(m_planetDetailGroup);
		rb->onSelect.connect(sigc::bind(sigc::mem_fun(this, &GameMenuView::OnChangePlanetDetail), i));
		Gui::HBox *hbox = new Gui::HBox();
		hbox->SetSpacing(5.0f);
		hbox->PackEnd(rb);
		hbox->PackEnd(new Gui::Label(planet_detail_desc[i]));
		vbox->PackEnd(hbox);
	}
	
	vbox = new Gui::VBox();
	vbox->SetSpacing(5.0f);
	detailBox->PackEnd(vbox);

	vbox->PackEnd((new Gui::Label(Lang::CITY_DETAIL_LEVEL))->Color(1.0f,1.0f,0.0f));
	m_cityDetailGroup = new Gui::RadioGroup();

	for (int i=0; i<5; i++) {
		Gui::RadioButton *rb = new Gui::RadioButton(m_cityDetailGroup);
		rb->onSelect.connect(sigc::bind(sigc::mem_fun(this, &GameMenuView::OnChangeCityDetail), i));
		Gui::HBox *hbox = new Gui::HBox();
		hbox->SetSpacing(5.0f);
		hbox->PackEnd(rb);
		hbox->PackEnd(new Gui::Label(planet_detail_desc[i]));
		vbox->PackEnd(hbox);
	}


	// language
	
	vbox = new Gui::VBox();
	vbox->SetSizeRequest(300, 200);
	mainTab->Add(vbox, 400, 250);

	vbox->PackEnd((new Gui::Label(Lang::LANGUAGE_SELECTION))->Color(1.0f,1.0f,0.0f));

	g = new Gui::RadioGroup();
	const std::list<std::string> availableLanguages = Lang::GetAvailableLanguages();

	{
		// box to put the scroll portal and its scroll bar into
		Gui::HBox *scrollHBox = new Gui::HBox();
		vbox->PackEnd(scrollHBox);
		
		Gui::VScrollBar *scroll = new Gui::VScrollBar();
		Gui::VScrollPortal *portal = new Gui::VScrollPortal(280);
		scroll->SetAdjustment(&portal->vscrollAdjust);
		scrollHBox->PackEnd(portal);
		scrollHBox->PackEnd(scroll);

		Gui::VBox *vbox2 = new Gui::VBox();
		portal->Add(vbox2);
		
		for (std::list<std::string>::const_iterator i = availableLanguages.begin(); i != availableLanguages.end(); i++) {
			Gui::RadioButton *temp = new Gui::RadioButton(g);
			temp->onSelect.connect(sigc::bind(sigc::mem_fun(this, &GameMenuView::OnChangeLanguage), *i));
			Gui::HBox *hbox = new Gui::HBox();
			hbox->SetSpacing(5.0f);
			hbox->PackEnd(temp);
			hbox->PackEnd(new Gui::Label(*i));
			vbox2->PackEnd(hbox);
			if ((*i) == Pi::config.String("Lang"))
				temp->SetSelected(true);
		}
	}


	// key binding tab
	{
		Gui::Fixed *keybindingTab = new Gui::Fixed(800, 600);
		tabs->AddPage(new Gui::Label(Lang::CONTROLS), keybindingTab);

		Gui::VBox *box1 = new Gui::VBox();
		box1->SetSpacing(5.0f);
		keybindingTab->Add(box1, 10, 10);

		Gui::VBox *box2 = new Gui::VBox();
		box2->SetSpacing(5.0f);
		keybindingTab->Add(box2, 400, 10);

		Gui::VBox *box = box1;
		KeyGetter *keyg;

		for (int i=0; KeyBindings::bindingProtos[i].label; i++) {
			const char *label = KeyBindings::bindingProtos[i].label;
			const char *function = KeyBindings::bindingProtos[i].function;

			if (function) {
				KeyBindings::KeyBinding kb = KeyBindings::KeyBindingFromString(Pi::config.String(function));
				keyg = new KeyGetter(label, kb);
				keyg->onChange.connect(sigc::bind(sigc::mem_fun(this, &GameMenuView::OnChangeKeyBinding), function));
				box->PackEnd(keyg);
			} else {
				// section
				box->PackEnd((new Gui::Label(label))->Color(1.0f, 1.0f, 0.0f));
			}

			/* 2nd column */
			if (i == 20) {
				box = box2;
			}
		}

		for (int i=0; KeyBindings::axisBindingProtos[i].label; i++) {
			AxisGetter *axisg;
			const char *label = KeyBindings::axisBindingProtos[i].label;
			const char *function = KeyBindings::axisBindingProtos[i].function;

			if (function) {
				KeyBindings::AxisBinding ab = KeyBindings::AxisBindingFromString(Pi::config.String(function).c_str());
				axisg = new AxisGetter(label, ab);
				axisg->onChange.connect(sigc::bind(sigc::mem_fun(this, &GameMenuView::OnChangeAxisBinding), function));
				box->PackEnd(axisg);
			} else {
				// section
				box->PackEnd((new Gui::Label(label))->Color(1.0f, 1.0f, 0.0f));
			}

			/* 2nd column */
			if (i == 20) {
				box = box2;
			}
		}

		m_toggleJoystick = new Gui::ToggleButton();
		m_toggleJoystick->onChange.connect(sigc::mem_fun(this, &GameMenuView::OnToggleJoystick));
		Gui::HBox *hbox = new Gui::HBox();
		hbox->SetSpacing(5.0f);
		hbox->PackEnd(m_toggleJoystick);
		hbox->PackEnd(new Gui::Label(Lang::ENABLE_JOYSTICK));
		box->PackEnd(hbox);

		// Invert Mouse
		m_toggleMouseYInvert = new Gui::ToggleButton();
		m_toggleMouseYInvert->onChange.connect(sigc::mem_fun(this, &GameMenuView::OnToggleMouseYInvert));
		box->PackEnd((new Gui::Label(Lang::MOUSE_INPUT))->Color(1.0f,1.0f,0.0f));

		Gui::HBox *mybox = new Gui::HBox();
		mybox->SetSpacing(5.0f);
		mybox->PackEnd(m_toggleMouseYInvert);
		mybox->PackEnd(new Gui::Label(Lang::INVERT_MOUSE_Y));
		box->PackEnd(mybox);
	}
}
Exemplo n.º 18
0
StationShipEquipmentForm::StationShipEquipmentForm(FormController *controller) : FaceForm(controller)
{
    m_station = Pi::player->GetDockedWith();

    SetTitle(stringf(Lang::SOMEWHERE_SHIP_EQUIPMENT, formatarg("station", m_station->GetLabel())));

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

    int NUM_ITEMS = 0;
    const float YSEP = floor(Gui::Screen::GetFontHeight() * 1.5f);
    for (int i=Equip::FIRST_SHIPEQUIP; i<=Equip::LAST_SHIPEQUIP; i++) {
        if (m_station->GetStock(static_cast<Equip::Type>(i)))
            NUM_ITEMS++;
    }

    Gui::VBox *outerbox = new Gui::VBox();

    Gui::Fixed *innerbox = new Gui::Fixed(450, NUM_ITEMS*YSEP);
    innerbox->SetTransparency(true);

    for (int i=Equip::FIRST_SHIPEQUIP, num=0; i<=Equip::LAST_SHIPEQUIP; i++) {
        Equip::Type type = static_cast<Equip::Type>(i);
        int stock = m_station->GetStock(type);
        if (!stock) continue;
        Gui::Label *l = new Gui::Label(Equip::types[i].name);
        if (Equip::types[i].description) {
            l->SetToolTip(Equip::types[i].description);
        }
        innerbox->Add(l,0,num*YSEP);

        innerbox->Add(new Gui::Label(format_money(m_station->GetPrice(type))), 200, num*YSEP);

        innerbox->Add(new Gui::Label(format_money(REMOVAL_VALUE_PERCENT * m_station->GetPrice(type) / 100)),
                      275, num*YSEP);

        innerbox->Add(new Gui::Label(stringf(Lang::NUMBER_TONNES, formatarg("mass", Equip::types[i].mass))), 360, num*YSEP);

        ButtonPair pair;
        pair.type = type;

        pair.add = new Gui::SolidButton();
        pair.add->onClick.connect(sigc::bind(sigc::mem_fun(this, &StationShipEquipmentForm::FitItem), type));
        innerbox->Add(pair.add, 400, num*YSEP);

        pair.remove = new Gui::SolidButton();
        pair.remove->onClick.connect(sigc::bind(sigc::mem_fun(this, &StationShipEquipmentForm::RemoveItem), type));
        innerbox->Add(pair.remove, 420, num*YSEP);

        m_buttons.push_back(pair);

        num++;
    }

    portal->Add(innerbox);

    Gui::Fixed *heading = new Gui::Fixed(470, Gui::Screen::GetFontHeight());
    const float *col = Gui::Theme::Colors::tableHeading;
    heading->Add((new Gui::Label(Lang::ITEM))->Color(col), 0, 0);
    heading->Add((new Gui::Label(Lang::PRICE_TO_FIT))->Color(col), 200, 0);
    heading->Add((new Gui::Label(Lang::PRICE_TO_REMOVE))->Color(col), 275, 0);
    heading->Add((new Gui::Label(Lang::WT))->Color(col), 360, 0);
    heading->Add((new Gui::Label(Lang::FIT))->Color(col), 400, 0);
    heading->Add((new Gui::Label(Lang::REMOVE))->Color(col), 420, 0);
    outerbox->PackEnd(heading);

    Gui::HBox *body = new Gui::HBox();
    body->PackEnd(portal);
    body->PackEnd(scroll);
    outerbox->PackEnd(body);

    outerbox->SetSpacing(YSEP-Gui::Screen::GetFontHeight());
    Add(outerbox, 0, 0);

}