Esempio n. 1
0
	void ShowAll() {
		DeleteAllChildren();
		PackEnd(new Gui::Label(m_title));
		m_tentry = new Gui::TextEntry();
		PackEnd(m_tentry);

		std::list<std::string> files;
		GetDirectoryContents(GetFullSavefileDirPath().c_str(), files);

		Gui::HBox *hbox = new Gui::HBox();
		PackEnd(hbox);

		Gui::HBox *buttonBox = new Gui::HBox();
		buttonBox->SetSpacing(5.0f);
		Gui::Button *b = new Gui::LabelButton(new Gui::Label(m_type == SAVE ? Lang::SAVE : Lang::LOAD));
		b->onClick.connect(sigc::mem_fun(this, &FileDialog::OnClickAction));
		buttonBox->PackEnd(b);
		b = new Gui::LabelButton(new Gui::Label(Lang::CANCEL));
		b->onClick.connect(sigc::mem_fun(this, &FileDialog::OnClickCancel));
		buttonBox->PackEnd(b);
		PackEnd(buttonBox);


		Gui::VScrollBar *scroll = new Gui::VScrollBar();
		Gui::VScrollPortal *portal = new Gui::VScrollPortal(390);
		portal->SetTransparency(false);
		scroll->SetAdjustment(&portal->vscrollAdjust);
		hbox->PackEnd(portal);
		hbox->PackEnd(scroll);

		Gui::Box *vbox = new Gui::VBox();
		for (std::list<std::string>::iterator i = files.begin(); i!=files.end(); ++i) {
			b = new SimpleLabelButton(new Gui::Label(*i));
			b->onClick.connect(sigc::bind(sigc::mem_fun(this, &FileDialog::OnClickFile), *i));
			vbox->PackEnd(b);
		}
		portal->Add(vbox);
		
		Gui::VBox::ShowAll();
	}
Esempio n. 2
0
void FileSelectorWidget::ShowAll()
{
	DeleteAllChildren();
	PackEnd(new Gui::Label(m_title));
	m_tentry = new Gui::TextEntry();
	PackEnd(m_tentry);

	Gui::HBox *hbox = new Gui::HBox();
	PackEnd(hbox);

	Gui::HBox *buttonBox = new Gui::HBox();
	buttonBox->SetSpacing(5.0f);
	Gui::Button *b = new Gui::LabelButton(new Gui::Label(m_type == SAVE ? Lang::SAVE : Lang::LOAD));
	b->onClick.connect(sigc::mem_fun(this, &FileSelectorWidget::OnClickAction));
	buttonBox->PackEnd(b);
	b = new Gui::LabelButton(new Gui::Label(Lang::CANCEL));
	b->onClick.connect(sigc::mem_fun(this, &FileSelectorWidget::OnClickCancel));
	buttonBox->PackEnd(b);
	PackEnd(buttonBox);

	Gui::VScrollBar *scroll = new Gui::VScrollBar();
	Gui::VScrollPortal *portal = new Gui::VScrollPortal(390);
	portal->SetTransparency(false);
	scroll->SetAdjustment(&portal->vscrollAdjust);
	hbox->PackEnd(portal);
	hbox->PackEnd(scroll);

	Gui::Box *vbox = new Gui::VBox();
	for (FileSystem::FileEnumerator files(FileSystem::rawFileSystem, Pi::GetSaveDir()); !files.Finished(); files.Next())
	{
		std::string name = files.Current().GetName();
		b = new SimpleLabelButton(new Gui::Label(name));
		b->onClick.connect(sigc::bind(sigc::mem_fun(this, &FileSelectorWidget::OnClickFile), name));
		vbox->PackEnd(b);
	}
	portal->Add(vbox);

	Gui::VBox::ShowAll();
}
Esempio n. 3
0
void LuaConsole::AddOutput(const std::string &line) {
    Gui::Label *label = 0;
    if (int(m_outputLines.size()) > m_nextOutputLine) {
        label = m_outputLines[m_nextOutputLine];
        Remove(label);
    } else {
        Gui::Screen::PushFont("ConsoleFont");
        label = new Gui::Label("", Gui::TextLayout::ColourMarkupNone);
        Gui::Screen::PopFont();
        m_outputLines.push_back(label);
    }
    m_nextOutputLine = (m_nextOutputLine + 1) % m_maxOutputLines;

    label->SetText(line);
    float size[2];
    label->GetSizeRequested(size);
    label->SetSize(float(Gui::Screen::GetWidth()), size[1]);
    label->Show();

    Remove(m_entryField);
    PackEnd(label);
    PackEnd(m_entryField);
}
Esempio n. 4
0
LuaConsole::LuaConsole(int displayedOutputLines):
    m_maxOutputLines(displayedOutputLines) {

    m_historyPosition = -1;

    SetTransparency(false);
    SetBgColor(0.6f, 0.1f, 0.0f, 0.6f);

    Gui::Screen::PushFont("ConsoleFont");
    m_entryField = new Gui::TextEntry();
    Gui::Screen::PopFont();
    m_entryField->SetNewlineMode(Gui::TextEntry::AcceptCtrlNewline);
    m_outputLines.reserve(displayedOutputLines);
    m_nextOutputLine = 0;

    // XXX HACK: bypassing TextEntry::Show, because it grabs focus
    m_entryField->Gui::Widget::Show();
    m_entryField->onFilterKeys.connect(sigc::mem_fun(this, &LuaConsole::OnFilterKeys));
    m_entryField->onKeyPress.connect(sigc::mem_fun(this, &LuaConsole::OnKeyPressed));

    PackEnd(m_entryField);
}
Esempio n. 5
0
LuaConsole::LuaConsole(int displayedOutputLines):
	m_maxOutputLines(displayedOutputLines),
	m_precompletionStatement(),
	m_completionList() {

	m_historyPosition = -1;

	SetTransparency(false);
	SetBgColor(0.6f, 0.1f, 0.0f, 0.6f);

	Gui::Screen::PushFont("ConsoleFont");
	m_entryField = new Gui::TextEntry();
	Gui::Screen::PopFont();
	m_entryField->SetNewlineMode(Gui::TextEntry::AcceptCtrlNewline);
	m_outputLines.reserve(displayedOutputLines);
	m_nextOutputLine = 0;

	// XXX HACK: bypassing TextEntry::Show, because it grabs focus
	m_entryField->Gui::Widget::Show();
	m_entryField->onFilterKeys.connect(sigc::mem_fun(this, &LuaConsole::OnFilterKeys));
	m_entryField->onKeyPress.connect(sigc::mem_fun(this, &LuaConsole::OnKeyPressed));

	PackEnd(m_entryField);

	// prepare the global table
	lua_State *l = Lua::manager->GetLuaState();

	LUA_DEBUG_START(l);

	lua_newtable(l);
	lua_newtable(l);
	lua_pushliteral(l, "__index");
	lua_getglobal(l, "_G");
	lua_rawset(l, -3);
	lua_setmetatable(l, -2);
	lua_setfield(l, LUA_REGISTRYINDEX, "ConsoleGlobal");

	LUA_DEBUG_END(l, 0);
}
Esempio n. 6
0
Box *Box::PackEnd(const WidgetSet &set)
{
	for (size_t i = 0; i < set.numWidgets; ++i)
		PackEnd(set.widgets[i]);
	return this;
}
Esempio n. 7
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();
}
Esempio n. 8
0
Box *Box::PackEnd(const WidgetSet &set, Uint32 flags)
{
	for (int i = 0; i < set.numWidgets; ++i)
		PackEnd(set.widgets[i], flags);
	return this;
}
Esempio n. 9
0
void Box::Pack( const Widget::Ptr& widget, bool expand, bool fill ) {
    PackEnd( widget, expand, fill );
}