示例#1
0
AngelUIHandle UserInterface::ShowChoiceBox(const String& choiceLabel, const StringList& labels, void (*callback)(int), const String& font, Vec2i padding, bool modal)
{
	Gwen::Controls::WindowControl* box = new Gwen::Controls::WindowControl(AngelCanvas);

	box->SetTitle(choiceLabel);

	Gwen::TextObject fontTextObject = Gwen::Utility::StringToUnicode(font);

	Vec2i maxSize;
	std::vector<Gwen::Controls::Button*> buttons;

	for	(unsigned int i=0; i < labels.size(); i++)
	{
		Gwen::Controls::Button* button = new Gwen::Controls::Button(box);
		buttons.push_back(button);
		if (font != "")
		{
			button->SetFont(fontTextObject, 20, false);
		}
		button->SetText(labels[i]);
		button->SetPadding(Gwen::Padding(padding.X, padding.Y, padding.X, padding.Y));
		button->SizeToContents();
		Gwen::Point size = button->GetSize();
		if (maxSize.X < size.x)
		{
			maxSize.X = size.x;
		}
		if (maxSize.Y < size.y)
		{
			maxSize.Y = size.y;
		}
		
		button->onPress.Add(&handler, &EventHandler::OnPress);
	}

	for (unsigned int i=0; i < buttons.size(); i++)
	{
		buttons[i]->SetPos(maxSize.X / 2 - (buttons[i]->GetSize().x / 2), i * (maxSize.Y + padding.Y));
	}

	box->SetSize(maxSize.X + (padding.X * 2), buttons.size() * (maxSize.Y + padding.Y) + (padding.Y * 3));
	box->SetPos((AngelCanvas->GetSize().x / 2) - (box->GetSize().x / 2), (AngelCanvas->GetSize().y / 2) - (box->GetSize().y / 2));

	if (modal)
	{
		box->MakeModal();
	}
	box->SetDeleteOnClose(true);
	box->SetClosable(false);

	handler.AddChoiceCallback(box, callback);

	_elements.insert(box);

	return box;
}
示例#2
0
		InspectorGenerator(Gwen::Controls::Canvas* gui_canvas)
		{
			window = new Gwen::Controls::WindowControl(gui_canvas);

			window->SetTitle(L"Properties");
			window->SetSize(200, 200);
			window->SetPos(0, 0);
			window->SetDeleteOnClose(true);

			entitySelector = new Gwen::Controls::ComboBox(window);
			//entitySelector->onSelection.Add(this, &InspectorGenerator::EntitySelector_OnSelection);
			/*
			auto element = doc->CreateElement("entity_selector"); FSN_ASSERT(element);
			if (entity_selector = dynamic_cast<EntitySelector*>(element))
			{
				auto body = doc->GetFirstChild()->GetElementById("content");
				Rocket::Core::Factory::InstanceElementText(body, "Go To:");
				body->AppendChild(entity_selector.get());
			}
			else
			{
				FSN_EXCEPT(Exception, "Failed to create entity_selector element.");
			}
			element->RemoveReference();

			element = Rocket::Core::Factory::InstanceElement(doc, "inspector_entity", "inspector", Rocket::Core::XMLAttributes()); FSN_ASSERT(element);
			if (entity_inspector = dynamic_cast<Inspectors::ElementEntityInspector*>(element))
			{
				entity_inspector->SetClass("entity", true);
				Inspectors::ElementGroup::AddSubsection(body, "Entity", entity_inspector.get());
			}
			element->RemoveReference();

			element = Rocket::Core::Factory::InstanceElement(doc, "inspector_group", "inspector_group", Rocket::Core::XMLAttributes()); FSN_ASSERT(element);
			if (inspector_group = dynamic_cast<Inspectors::ElementGroup*>(element))
			{
				body->AppendChild(inspector_group.get());
			}
			else
			{
				FSN_EXCEPT(Exception, "Failed to create inspector_group element.");
			}
			element->RemoveReference();
			*/
		}
示例#3
0
		void Generate()
		{
			// Generate title
			{
				std::string title;
				if (entities.size() > 1)
				{
					title = boost::lexical_cast<std::string>(entities.size()) + " entities";
				}
				else if (!entities.empty())
				{
					auto front = entities.front();
					if (front->GetName().empty())
						title = "Unnamed";
					else
						title = front->GetName();
					if (front->IsPseudoEntity())
						title += " Pseudo-Entity";
					else
						title += " - ID: " + boost::lexical_cast<std::string>(front->GetID());

					entity_inspector->SetEntity(front);
				}
				if (!title.empty())
					window->SetTitle(Gwen::Utility::Format(L"Properties: %s", title));
			}

			inspector_group->AddFooter();

			inspector_group->DoneAddingEntities();

			// Set entities
			for (auto entity : entities)
			{
				entitySelector->AddItem(Gwen::Utility::StringToUnicode(entity->GetName()));
			}
		}