SettingsMenuScene::SettingsMenuScene(Display::Display &display,
	GameDirector &director) :
	SUPER(display, director, _("Settings"), "Settings")
{
	using Alignment = Display::UiViewModel::Alignment;

	SupportCancelAction(_("Back"));

	auto root = GetContentRoot();

	menuGrid = root->NewChild<Display::FlexGrid>(display);
	menuGrid->SetPos(640, 140);
	menuGrid->SetAlignment(Alignment::N);

	menuGrid->GetColumnDefault(0).SetFill(true);

	size_t row = 0;
	menuGrid->At(row++, 0).NewChild<MenuItemButton<AudioSettingsScene>>(
		display, director, GetTitle(), _("Profile"), false);
	menuGrid->At(row++, 0).NewChild<MenuItemButton<AudioSettingsScene>>(
		display, director, GetTitle(), _("Audio"));
	menuGrid->At(row++, 0).NewChild<MenuItemButton<VideoSettingsScene>>(
		display, director, GetTitle(), _("Video"));
	menuGrid->At(row++, 0).NewChild<MenuItemButton<AudioSettingsScene>>(
		display, director, GetTitle(), _("Network"), false);
	menuGrid->At(row++, 0).NewChild<MenuItemButton<AudioSettingsScene>>(
		display, director, GetTitle(), _("Advanced"), false);

	menuGrid->RequestFocus();
}
Exemple #2
0
TBSelectDropdown::TBSelectDropdown()
    : m_value(-1)
{
    SetSource(&m_default_source);
    SetSkinBg(TBIDC("TBSelectDropdown"), WIDGET_INVOKE_INFO_NO_CALLBACKS);
    m_arrow.SetSkinBg(TBIDC("TBSelectDropdown.arrow"), WIDGET_INVOKE_INFO_NO_CALLBACKS);
    GetContentRoot()->AddChild(&m_arrow);
}
Exemple #3
0
AdvancedItemWidget::AdvancedItemWidget(AdvancedItem *item, AdvancedItemSource *source,
										TBSelectItemViewer *source_viewer, int index)
	: m_source(source)
	, m_source_viewer(source_viewer)
	, m_index(index)
{
	SetSkinBg(TBIDC("TBSelectItem"));
	SetLayoutDistribution(LAYOUT_DISTRIBUTION_GRAVITY);
	SetLayoutDistributionPosition(LAYOUT_DISTRIBUTION_POSITION_LEFT_TOP);
	SetPaintOverflowFadeout(false);

	g_widgets_reader->LoadFile(GetContentRoot(), "Demo/demo01/ui_resources/test_list_item.tb.txt");
	TBCheckBox *checkbox = GetWidgetByIDAndType<TBCheckBox>(TBIDC("check"));
	TBTextField *name = GetWidgetByIDAndType<TBTextField>(TBIDC("name"));
	TBTextField *info = GetWidgetByIDAndType<TBTextField>(TBIDC("info"));
	checkbox->SetValue(item->GetChecked() ? true : false);
	name->SetText(item->str);
	info->SetText(item->GetMale() ? "Male" : "Female");
}
MenubarItemWidget::MenubarItemWidget(MenubarItem *item, MenubarItemSource *source,
                                     TBSelectItemViewer *source_viewer, int index)
    : m_source(source)
    , m_source_viewer(source_viewer)
    , m_index(index)
{
    SetSkinBg(TBIDC("TBSelectItem"));
    SetLayoutDistribution(LAYOUT_DISTRIBUTION_GRAVITY);
    SetLayoutDistributionPosition(LAYOUT_DISTRIBUTION_POSITION_LEFT_TOP);
    SetPaintOverflowFadeout(false);

    TBWidget* root = GetContentRoot();

    TBFontDescription fd;
    fd.SetID(TBIDC("Vera"));
    fd.SetSize(12);

    TBTextField* text = new TBTextField();
    text->SetIgnoreInput(true);
    text->SetText(item->str);
    text->SetFontDescription(fd);
    root->AddChild(text);

    if (item->shortcut_.Length())
    {
        TBWidget* spacer = new TBWidget();
        spacer->SetIgnoreInput(true);
        spacer->SetGravity(WIDGET_GRAVITY_LEFT_RIGHT);
        root->AddChild(spacer);

        TBTextField* shortcut = new TBTextField();
        shortcut->SetIgnoreInput(true);
        shortcut->SetText(item->shortcut_.CString());
        shortcut->SetFontDescription(fd);
        shortcut->SetGravity(WIDGET_GRAVITY_RIGHT);
        root->AddChild(shortcut);
    }

}
SettingsMenuScene::SettingsMenuScene(Display::Display &display,
	GameDirector &director) :
	SUPER(display, director, _("Settings"), "Settings")
{
	using Alignment = Display::UiViewModel::Alignment;

	SupportCancelAction(_("Back"));

	auto root = GetContentRoot();

	menuGrid = root->NewChild<Display::FlexGrid>(display);
	menuGrid->SetPos(640, 140);
	menuGrid->SetAlignment(Alignment::N);

	menuGrid->GetColumnDefault(0).SetFill(true);

	// If there's no active player piloting the UI, then only enable
	// settings which are global to everybody.
	bool hasProfile = false;
	if (auto pilot = director.ShareUiPilot()) {
		hasProfile = !!pilot->ShareProfile();
	}

	size_t row = 0;
	menuGrid->At(row++, 0).NewChild<MenuItemButton<ProfileEditScene>>(
		*this, _("Profile"), hasProfile);
	menuGrid->At(row++, 0).NewChild<MenuItemButton<LocaleSettingsScene>>(
		*this, _("Language and Units"));
	menuGrid->At(row++, 0).NewChild<MenuItemButton<AudioSettingsScene>>(
		*this, _("Audio"));
	menuGrid->At(row++, 0).NewChild<MenuItemButton<VideoSettingsScene>>(
		*this, _("Video"));
	menuGrid->At(row++, 0).NewChild<MenuItemButton<AudioSettingsScene>>(
		*this, _("Network"), false);
	menuGrid->At(row++, 0).NewChild<MenuItemButton<AudioSettingsScene>>(
		*this, _("Advanced"), false);

	menuGrid->RequestFocus();
}
bool TBMessageWindow::Show(const char *title, const char *message, TBMessageWindowSettings *settings)
{
	TBWidget *target = m_target.Get();
	if (!target)
		return false;

	TBMessageWindowSettings default_settings;
	if (!settings)
		settings = &default_settings;

	TBWidget *root = target->GetParentRoot();

	const char *source =	"TBLayout: axis: y, distribution: available\n"
							"	TBLayout: distribution: available, size: available\n"
							"		TBSkinImage: id: 2\n"
							"		TBEditField: multiline: 1, readonly: 1, id: 1\n"
							"	TBLayout: distribution-position: right bottom, id: 3\n";
	if (!g_widgets_reader->LoadData(GetContentRoot(), source))
		return false;

	SetText(title);

	GetWidgetByIDAndType<TBSkinImage>(2)->SetSkinBg(settings->icon_skin);

	TBEditField *editfield = GetWidgetByIDAndType<TBEditField>(1);
	editfield->SetStyling(settings->styling);
	editfield->SetText(message);
	editfield->SetSkinBg("");

	// Create buttons
	if (settings->msg == TB_MSG_OK)
	{
		AddButton("TBMessageWindow.ok", true);
	}
	else if (settings->msg == TB_MSG_OK_CANCEL)
	{
		AddButton("TBMessageWindow.ok", true);
		AddButton("TBMessageWindow.cancel", false);
	}
	else if (settings->msg == TB_MSG_YES_NO)
	{
		AddButton("TBMessageWindow.yes", true);
		AddButton("TBMessageWindow.no", false);
	}

	// Size to fit content. This will use the default size of the textfield.
	ResizeToFitContent();
	TBRect rect = GetRect();

	// Get how much we overflow the textfield has given the current width, and grow our height to show all we can.
	// FIX: It would be better to use adapt-to-content on the editfield to achieve the most optimal size.
	// At least when we do full blown multi pass size checking.
	rect.h += editfield->GetStyleEdit()->GetOverflowY();

	// Create background dimmer
	if (settings->dimmer)
	{
		if (TBDimmer *dimmer = new TBDimmer)
		{
			root->AddChild(dimmer);
			m_dimmer.Set(dimmer);
		}
	}

	// Center and size to the new height
	TBRect bounds(0, 0, root->GetRect().w, root->GetRect().h);
	SetRect(rect.CenterIn(bounds).MoveIn(bounds).Clip(bounds));
	root->AddChild(this);
	return true;
}
Exemple #7
0
TBSelectDropdown::~TBSelectDropdown()
{
    GetContentRoot()->RemoveChild(&m_arrow);
    SetSource(nullptr);
    CloseWindow();
}
ListViewItemWidget::ListViewItemWidget(ListViewItem *item, ListViewItemSource *source,
                                       TBSelectItemViewer *sourceviewer, int index)
    : source_(source)
    , sourceviewer_(sourceviewer)
    , index_(index)
    , item_(item)
    , expandBox_(0)
    , textField_(0)
    , icon_(0)
{
    SetLayoutDistribution(LAYOUT_DISTRIBUTION_GRAVITY);
    SetLayoutDistributionPosition(LAYOUT_DISTRIBUTION_POSITION_LEFT_TOP);
    SetPaintOverflowFadeout(false);

    item_->widget_ = this;

    for (int i = 0; i < item->depth_; i++)
    {
        LayoutParams lp;
        lp.SetWidth(6);
        lp.SetHeight(4);
        TBWidget* spacer = new TBWidget();
        spacer->SetLayoutParams(lp);
        GetContentRoot()->AddChild(spacer);
    }

    if (item_->children_.Size())
    {
        expandBox_ = new TBCheckBox();
        expandBox_->SetSkinBg(TBIDC("TBCheckBox.uilistview"));
        expandBox_->SetValue(item_->GetExpanded());
        expandBox_->SetID(item->id);
        GetContentRoot()->AddChild(expandBox_);
    }
    else
    {
        LayoutParams lp;
        lp.SetWidth(12);
        lp.SetHeight(4);
        TBWidget* spacer = new TBWidget();
        spacer->SetLayoutParams(lp);
        GetContentRoot()->AddChild(spacer);
    }

    if (item->icon_.Length())
    {
        icon_ = new TBSkinImage(TBIDC(item->icon_.CString()));
        icon_->SetIgnoreInput(true);
        GetContentRoot()->AddChild(icon_);
    }

    TBFontDescription fd;
    fd.SetID(TBIDC("Vera"));
    fd.SetSize(11);

    TBTextField* tfield = textField_ = new TBTextField();
    tfield->SetIgnoreInput(true);

    tfield->SetSkinBg(item->textSkin_.Length() ? TBIDC(item->textSkin_.CString()) : TBIDC("Folder"));
    tfield->SetText(item->str);
    tfield->SetFontDescription(fd);

    SetSkinBg(TBIDC("TBSelectItem"));
    GetContentRoot()->AddChild(tfield);

    SetID(item->id);
}