Example #1
0
void ezQtPropertyContainerWidget::UpdateElements()
{
  ezQtScopedUpdatesDisabled _(this);

  ezUInt32 iElements = GetRequiredElementCount();

  while (m_Elements.GetCount() > iElements)
  {
    RemoveElement(m_Elements.GetCount() - 1);
  }
  while (m_Elements.GetCount() < iElements)
  {
    AddElement(m_Elements.GetCount());
  }

  for (ezUInt32 i = 0; i < iElements; ++i)
  {
    UpdateElement(i);
  }

  // Force re-layout of parent hierarchy to prevent flicker.
  QWidget* pCur = m_pGroup;
  while (pCur != nullptr && qobject_cast<QScrollArea*>(pCur) == nullptr)
  {
    pCur->updateGeometry();
    pCur = pCur->parentWidget();
  }
}
Example #2
0
	void Renderer::UpdateDynamicElements()
	{
		for (UiElement* dynElemPtr : _dynamicElements)
		{
			if (dynElemPtr->RequireUpdate())
			{
				DeleteUiElementResources(dynElemPtr);
				UpdateElement(dynElemPtr);
			}
		}
	}
Example #3
0
/**
 * Update a new story page element.
 * @param tile Tile location if it is a location page element, otherwise unused.
 * @param flags type of operation
 * @param p1 various bitstuffed elements
 * - p1 = (bit  0 -  15) - The page element to update.
 *        (bit  16 -  31) - unused
 * @param p2 Id of referenced object
 * @param text Text content in case it is a text or location page element
 * @return the cost of this operation or an error
 */
CommandCost CmdUpdateStoryPageElement(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
{
	StoryPageElementID page_element_id = (StoryPageElementID)GB(p1, 0, 16);

	if (_current_company != OWNER_DEITY) return CMD_ERROR;
	if (!StoryPageElement::IsValidID(page_element_id)) return CMD_ERROR;

	StoryPageElement *pe = StoryPageElement::Get(page_element_id);
	StoryPageID page_id = pe->page;
	StoryPageElementType type = pe->type;

	if (!VerifyElementContentParameters(page_id, type, tile, p2, text)) return CMD_ERROR;

	if (flags & DC_EXEC) {
		UpdateElement(*pe, tile, p2, text);
		InvalidateWindowClassesData(WC_STORY_BOOK, pe->page);
	}

	return CommandCost();
}
Example #4
0
/**
 * Create a new story page element.
 * @param tile Tile location if it is a location page element, otherwise unused.
 * @param flags type of operation
 * @param p1 various bitstuffed elements
 * - p1 = (bit  0 -  15) - The page which the element belongs to.
 *        (bit  16 -  23) - Page element type
 * @param p2 Id of referenced object
 * @param text Text content in case it is a text or location page element
 * @return the cost of this operation or an error
 */
CommandCost CmdCreateStoryPageElement(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
{
	if (!StoryPageElement::CanAllocateItem()) return CMD_ERROR;

	StoryPageID page_id = (CompanyID)GB(p1, 0, 16);
	StoryPageElementType type = Extract<StoryPageElementType, 16, 8>(p1);

	/* Allow at most 128 elements per page. */
	uint16 element_count = 0;
	StoryPageElement *iter;
	FOR_ALL_STORY_PAGE_ELEMENTS(iter) {
		if (iter->page == page_id) element_count++;
	}
	if (element_count >= 128) return CMD_ERROR;

	if (_current_company != OWNER_DEITY) return CMD_ERROR;
	if (!StoryPage::IsValidID(page_id)) return CMD_ERROR;
	if (!VerifyElementContentParameters(page_id, type, tile, p2, text)) return CMD_ERROR;

	if (flags & DC_EXEC) {
		if (_story_page_element_pool.items == 0) {
			/* Initialize the next sort value variable. */
			_story_page_element_next_sort_value = 0;
		}

		StoryPageElement *pe = new StoryPageElement();
		pe->sort_value = _story_page_element_next_sort_value;
		pe->type = type;
		pe->page = page_id;
		UpdateElement(*pe, tile, p2, text);

		InvalidateWindowClassesData(WC_STORY_BOOK, page_id);

		_new_story_page_element_id = pe->index;
		_story_page_element_next_sort_value++;
	}

	return CommandCost();
}