Example #1
0
/*----------------------------------------------------------------------------------------------
	Initialize with the time zone information. This can be called multiple times, although
	it's not protected for multi-threaded access.
	REVIEW ShonK: Should we protect this with a critical section?
----------------------------------------------------------------------------------------------*/
void TimeMapper::Init(void)
{
	TIME_ZONE_INFORMATION tzi;
	GetTimeZoneInformation(&tzi);

	ClearItems(m_rgyminMin, kytLim);
	ClearItems(m_rgyminLim, kytLim);
	m_dminTz1 = m_dminTz2 = -(tzi.Bias + tzi.StandardBias);

	// Note: Win98 gives bogus information for tzi.DaylightBias when there is no daylight
	// savings time. In this case, tzi.StandardDate.wMonth is 0.
	if (!tzi.StandardDate.wMonth || tzi.StandardBias == tzi.DaylightBias)
		return;

	if (tzi.StandardDate.wYear || tzi.DaylightDate.wYear)
	{
		// REVIEW ShonK: Can this ever happen? MSDN seems to indicate it can, but I don't
		// understand what the info means.
		Assert(!"Don't know how to handle this DST conversion.");
		return;
	}

	if (tzi.StandardDate.wMonth == tzi.DaylightDate.wMonth)
	{
		Assert(!"Bad months in the time zone info.");
		return;
	}

	int dminT = -(tzi.Bias + tzi.DaylightBias);
	if (tzi.StandardDate.wMonth > tzi.DaylightDate.wMonth)
	{
		// Jan 1 is STD time.
		if (!CalcTransitions(tzi.Bias, tzi.StandardDate, g_rgyday[0], m_rgyminLim) ||
			!CalcTransitions(tzi.Bias, tzi.StandardDate, g_rgyday[1],
				m_rgyminLim + kytSundayLeap) ||
			!CalcTransitions(tzi.Bias, tzi.DaylightDate, g_rgyday[0], m_rgyminMin) ||
			!CalcTransitions(tzi.Bias, tzi.DaylightDate, g_rgyday[1],
				m_rgyminMin + kytSundayLeap))
		{
			Assert(!"Calculating transitions failed.");
			return;
		}
		m_dminTz2 = dminT;
	}
	else
	{
		// Jan 1 is DST.
		if (!CalcTransitions(tzi.Bias, tzi.StandardDate, g_rgyday[0], m_rgyminMin) ||
			!CalcTransitions(tzi.Bias, tzi.StandardDate, g_rgyday[1],
				m_rgyminMin + kytSundayLeap) ||
			!CalcTransitions(tzi.Bias, tzi.DaylightDate, g_rgyday[0], m_rgyminLim) ||
			!CalcTransitions(tzi.Bias, tzi.DaylightDate, g_rgyday[1],
				m_rgyminLim + kytSundayLeap))
		{
			Assert(!"Calculating transitions failed.");
			return;
		}
		m_dminTz1 = dminT;
	}
}
  double CalculateSequence(const std::vector<ExpressionItem*> i_items,
                           size_t i_startLoc,
                           size_t i_endLoc)
  {
    std::vector<ExpressionItem*> currentPriorityResult = CopyItems(i_items,
                                                                   i_startLoc,
                                                                   i_endLoc);
    for (int priority = 0;
         priority < OperatorPrioritiesCount;
         ++priority)
    {
      std::vector<ExpressionItem*> newResult = CalculateSequenceForPriority(currentPriorityResult,
                                                                            static_cast<OperatorPriority>(priority));
      ClearItems(currentPriorityResult);
      currentPriorityResult = newResult;
    }

    assert(currentPriorityResult.size() == 1);
    assert(currentPriorityResult[0]->Type() == ExpressionItemTypeOperand);

    Operand* operand = dynamic_cast<Operand*>(currentPriorityResult[0]);
    double result = operand->GetValue();
    ClearItems(currentPriorityResult);

    return result;
  }
  size_t ParseExpression(const std::string& i_string,
                         std::vector<ExpressionItem*>& o_items,
                         size_t& o_maxNestingLevel)
  {
    if (i_string.size() == 0)
    {
      return 0;
    }

    size_t currentLoc = 0;
    size_t nestingLevel = 0;
    size_t maxNestingLevel = 0;
    while (currentLoc < i_string.size())
    {
      switch (i_string[currentLoc])
      {
      case '(':
        nestingLevel++;
        maxNestingLevel = (nestingLevel > maxNestingLevel) ? nestingLevel : maxNestingLevel;
        currentLoc++;
        break;
      case ')':
        nestingLevel--;
        currentLoc++;
        break;
      default:
      {
        size_t parsedSize = 0;
        ExpressionItem* item = ExpressionItem::ParseString(i_string,
                                                           currentLoc,
                                                           nestingLevel,
                                                           parsedSize);
        if (item == NULL)
        {
          ClearItems(o_items);
          return currentLoc;
        }
        currentLoc += parsedSize;
        o_items.push_back(item);
      }
      }
    }

    if (nestingLevel != 0)
    {
      ClearItems(o_items);
      return currentLoc;
    }

    o_maxNestingLevel = maxNestingLevel;

    return kDefaultErrorPos;
  }
Example #4
0
void PauseMenu::DoResume()
{
	if (black)
		black->AddTween(Ptr<FadeOut>::New(FADE_TIME, Tweener::EASE_OUT).Get());

	black = nullptr;

	title->AddTween(Ptr<MoveTo>::New(Vector3f(-140, 440, 5), FADE_TIME, Tweener::EASE_OUT).Get());
	title->AddTween(Ptr<FadeOut>::New(FADE_TIME, Tweener::EASE_OUT).Get());

	title = nullptr;

	for (int i = 0; i < GetItemCount(); i++)
	{
		auto menuItem = GetMenuItem(i);

		menuItem->AddTween(Ptr<MoveTo>::New(Vector3f(-140, 440, 5), FADE_TIME, Tweener::EASE_OUT).Get());
		menuItem->AddTween(Ptr<FadeOut>::New(FADE_TIME, Tweener::EASE_OUT).Get());
	}

	ClearItems();

	((GameScene*)Game::GetInstance()->GetScene().Get())->GetSTGLayer()->Resume();
	((GameScene*)Game::GetInstance()->GetScene().Get())->GetSTGParticleLayer()->Resume();

	EventSystem::GetInstance()->UnRegisterKeyDownListener(this);
}
void EstrangedMenuScrollerLoadGame::AddSavedGames()
{
	ClearItems();

	const char *SAVE_PATH = "./SAVE/";
	FileFindHandle_t fh;
	char path[256];
	Q_snprintf(path, sizeof(path), "%s*.sav", SAVE_PATH);

	char const *fn = g_pFullFileSystem->FindFirstEx(path, "MOD", &fh);
	if (!fn) return;

	char save_name[64];
	do
	{
		Q_StripExtension(fn, save_name, sizeof(save_name));

		AddItem(new vgui::Button(NULL, "", save_name, this, save_name));

		fn = g_pFullFileSystem->FindNext(fh);
	}
	while(fn);

	g_pFullFileSystem->FindClose(fh);
}
Example #6
0
BookmarkManager::~BookmarkManager()
{
  for_each(m_userMarkLayers.begin(), m_userMarkLayers.end(), DeleteFunctor());
  m_userMarkLayers.clear();

  ClearItems();
}
Example #7
0
void C4Menu::Clear()
{
	Close(false);
	Symbol.Clear();
	ClearItems();
	ClearFrameDeco();
	fActive = false;
}
Example #8
0
void CFileItemList::Clear()
{
  CSingleLock lock(m_lock);

  ClearItems();


  m_replaceListing = false;
  m_content.clear();
}
Example #9
0
void BookmarkManager::LoadBookmarks()
{
  ClearItems();

  string const dir = GetPlatform().SettingsDir();

  Platform::FilesList files;
  Platform::GetFilesByExt(dir, BOOKMARKS_FILE_EXTENSION, files);
  for (size_t i = 0; i < files.size(); ++i)
    LoadBookmark(dir + files[i]);

  LoadState();
}
Example #10
0
void PauseMenu::Clear()
{
	title->MarkDestroy();
	black->MarkDestroy();
	for (int i = 0; i < GetItemCount(); i++)
	{
		auto menuItem = GetMenuItem(i);
		menuItem->MarkDestroy();
	}
	ClearItems();
	title = nullptr;
	black = nullptr;
	EventSystem::GetInstance()->UnRegisterKeyDownListener(this);
}
Example #11
0
	void CVLDatabase::Clear()
	{
		ClearItems();
		if (opened)
		{
			try
			{
				CloseRecordset();
				connection->Execute(Format(TEXT("DELETE FROM %s"), (LPCTSTR)recordsetName.c_str()).c_str(),
					NULL, adCmdText | adExecuteNoRecords);
				OpenRecordset();
			}
			catch(_com_error &e)
			{
				ComErrorToException(e, string("Can not clear database"));
			}
		}
	}
Example #12
0
///<summary>D'tor</summary>
CFeedStore::~CFeedStore()
{
	//-- If the Delete() method was called, delete the feedStoreDir now
	if (DeleteOnDelete)
	{
		//-- Delete all items
		ClearItems();
		
		//-- Now remove the feed store dir itself
		FeedStoreDir.cdUp();
		FeedStoreDir.rmdir(StoreUID);
	}
	
	//-- Locked makes sure that only after successfully calling init or copying the instance an Unlock call is happening
	if (Locked)
		CLock::Unlock("StoreLock", StoreUID);
		
	if (FeedStoreDirI)
		delete FeedStoreDirI;
}
Example #13
0
	void CVLDatabase::Close()
	{
		ClearItems();
		try
		{
			CloseRecordset();
			recordset = NULL;
			if (connected)
			{
				connection->Close();
				connected = false;
			}
			connection = NULL;
		}
		catch (_com_error &e)
		{
			ComErrorToException(e, string("Can not close database"));
		}
		provider = "";
		dataSource = "";
	}
Example #14
0
	static bool FParseSilTime(const XChar * prgch, int cch, XChar chDateSep, XChar chSep,
		XChar chTimeSep, const XChar ** ppchLim, bool fUtc, SilTime * pstim)
{
	// REVIEW SteveMc: Should we do range checking and report errors?
	AssertArray(prgch, cch);
	AssertPtrN(ppchLim);
	AssertPtr(pstim);

	SilTimeInfo sti;
	ClearItems(&sti, 1);

	const XChar * pch = prgch;
	const XChar * pchLim = prgch + cch;

	// Get the year.
	if (pch < pchLim && *pch == '-')
		pch++;
	while (pch < pchLim && '0' <= *pch && *pch <= '9')
		sti.year = sti.year * 10 + (*pch++ - '0');
	if (cch > 0 && *prgch == chDateSep)
		sti.year = -sti.year;

	if (pch < pchLim && *pch == chDateSep)
	{
		pch++;
		while (pch < pchLim && '0' <= *pch && *pch <= '9')
			sti.ymon = sti.ymon * 10 + (*pch++ - '0');
		if (pch < pchLim && *pch == chDateSep)
		{
			pch++;
			while (pch < pchLim && '0' <= *pch && *pch <= '9')
				sti.mday = sti.mday * 10 + (*pch++ - '0');
		}
	}

	if (pch < pchLim && *pch == chSep)
	{
		pch++;
		while (pch < pchLim && '0' <= *pch && *pch <= '9')
			sti.hour = sti.hour * 10 + (*pch++ - '0');
		if (pch < pchLim && *pch == chTimeSep)
		{
			pch++;
			while (pch < pchLim && '0' <= *pch && *pch <= '9')
				sti.min = sti.min * 10 + (*pch++ - '0');
			if (pch < pchLim && *pch == chTimeSep)
			{
				pch++;
				while (pch < pchLim && '0' <= *pch && *pch <= '9')
					sti.sec = sti.sec * 10 + (*pch++ - '0');
				if (pch < pchLim && *pch == '.')
				{
					pch++;
					if ('0' <= *pch && *pch <= '9')
					{
						sti.msec += (*pch++ - '0') * 100;
						if ('0' <= *pch && *pch <= '9')
						{
							sti.msec += (*pch++ - '0') * 10;
							if ('0' <= *pch && *pch <= '9')
								sti.msec += (*pch++ - '0');
						}
					}
				}
			}
		}
	}

	if (ppchLim)
		*ppchLim = pch;

	pstim->SetTimeInfo(sti, true);
	return true;
}
Example #15
0
bool C4ObjectMenu::DoRefillInternal(bool &rfRefilled)
{
	// Variables
	C4FacetSurface fctSymbol;
	C4Object *pObj;
	char szCaption[256+1],szCommand[256+1],szCommand2[256+1];
	int32_t iCount;
	C4Def *pDef;
	C4IDList ListItems;
	C4Object *pTarget;
	C4Facet fctTarget;

	// Refill
	switch (Identification)
	{
		// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
	case C4MN_Activate:
		// Clear items
		ClearItems();
		// Refill target
		if (!(pTarget=RefillObject)) return false;
		{
			// Add target contents items
			C4ObjectListIterator iter(pTarget->Contents);
			while ((pObj = iter.GetNext(&iCount)))
			{
				pDef = pObj->Def;
				if (pDef->NoGet) continue;
				// Prefer fully constructed objects
				if (~pObj->OCF & OCF_FullCon)
				{
					// easy way: only if first concat check matches
					// this doesn't catch all possibilities, but that will rarely matter
					C4Object *pObj2=pTarget->Contents.Find(pDef, ANY_OWNER, OCF_FullCon);
					if (pObj2) if (pObj2->CanConcatPictureWith(pObj)) pObj = pObj2;
				}
				// Caption
				sprintf(szCaption,LoadResStr("IDS_MENU_ACTIVATE"),(const char *) pObj->GetName());
				// Picture
				fctSymbol.Set(fctSymbol.Surface, 0,0,C4SymbolSize,C4SymbolSize);
				pObj->Picture2Facet(fctSymbol);
				// Commands
				sprintf(szCommand,"SetCommand(\"Activate\",Object(%d))&&ExecuteCommand()",pObj->Number);
				sprintf(szCommand2,"SetCommand(\"Activate\",nil,%d,0,Object(%d),%s)&&ExecuteCommand()",pTarget->Contents.ObjectCount(pDef->id),pTarget->Number,pDef->id.ToString());
				// Add menu item
				Add(szCaption,fctSymbol,szCommand,iCount,pObj,"",pDef->id,szCommand2,true,pObj->GetValue(pTarget, NO_OWNER));
				// facet taken over (arrg!)
				fctSymbol.Default();
			}
		}
		break;
		// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
	case C4MN_Get:
	case C4MN_Contents:
		// Clear items
		ClearItems();
		// Refill target
		if (!(pTarget = RefillObject)) return false;
		{
			// Add target contents items
			C4ObjectListIterator iter(pTarget->Contents);
			while ((pObj = iter.GetNext(&iCount)))
			{
				pDef = pObj->Def;
				if (pDef->NoGet) continue;
				// Prefer fully constructed objects
				if (~pObj->OCF & OCF_FullCon)
				{
					// easy way: only if first concat check matches
					// this doesn't catch all possibilities, but that will rarely matter
					C4Object *pObj2 = pTarget->Contents.Find(pDef, ANY_OWNER, OCF_FullCon);
					if (pObj2) if (pObj2->CanConcatPictureWith(pObj)) pObj = pObj2;
				}
				// Determine whether to get or activate
				bool fGet = true;
				if (!(pObj->OCF & OCF_Carryable)) fGet = false; // not a carryable item
				if (Identification == C4MN_Contents)
				{
					if (Object && !!Object->Call(PSF_RejectCollection, &C4AulParSet(pObj->Def, pObj))) fGet = false; // collection rejected
				}
				if (!(pTarget->OCF & OCF_Entrance)) fGet = true; // target object has no entrance: cannot activate - force get
				// Caption
				sprintf(szCaption, LoadResStr(fGet ? "IDS_MENU_GET" : "IDS_MENU_ACTIVATE"), (const char *)pObj->GetName());
				// Picture
				fctSymbol.Set(fctSymbol.Surface, 0, 0, C4SymbolSize, C4SymbolSize);
				pObj->Picture2Facet(fctSymbol);
				// Primary command: get/activate single object
				sprintf(szCommand, "SetCommand(\"%s\", Object(%d)) && ExecuteCommand()", fGet ? "Get" : "Activate", pObj->Number);
				// Secondary command: get/activate all objects of the chosen type
				szCommand2[0] = 0; int32_t iAllCount;
				if ((iAllCount = pTarget->Contents.ObjectCount(pDef->id)) > 1)
					sprintf(szCommand2, "SetCommand(\"%s\", nil, %d,0, Object(%d), %s) && ExecuteCommand()", fGet ? "Get" : "Activate", iAllCount, pTarget->Number, pDef->id.ToString());
				// Add menu item (with object)
				Add(szCaption, fctSymbol, szCommand, iCount, pObj, "", pDef->id, szCommand2);
				fctSymbol.Default();
			}
		}
		break;
		// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
	default:
		// Not an internal menu
		return true;
		// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
	}

	// Successfull internal refill
	rfRefilled = true;
	return true;
}
Example #16
0
ItemManager::~ItemManager(void)
{
  ClearItems();
  ClearItemTypes();
}
Example #17
0
void GameDisplayDlg::GenShowItems()
{
	ClearItems();

	if(m_stShowItem.type == 0)
	{
		return;
	}
	//	Reset the original item attribute
	ItemAttrib stOriItem;
	ZeroMemory(&stOriItem, sizeof(ItemAttrib));
	if(IsEquipItem(&m_stShowItem))
	{
		stOriItem.id = m_stShowItem.id;
		//if(GameInfoManager::GetInstance()->GetItemAttrib(m_pItemAttrib->id, &m_oriItem))
		{
			//	Calculate the addition of the equipment
#define GET_ITEM_ADDITION(ATTRIB)	stOriItem.ATTRIB = m_stShowItem.ATTRIB - stOriItem.ATTRIB;
			GET_ITEM_ADDITION(maxAC);
			GET_ITEM_ADDITION(maxMAC);
			GET_ITEM_ADDITION(maxDC);
			GET_ITEM_ADDITION(maxMC);
			GET_ITEM_ADDITION(maxSC);
			GET_ITEM_ADDITION(lucky);
			GET_ITEM_ADDITION(atkSpeed);
			GET_ITEM_ADDITION(moveSpeed);
			GET_ITEM_ADDITION(accuracy);
			GET_ITEM_ADDITION(hide);
		}
		//else
		{
			//ZeroMemory(&m_oriItem, sizeof(ItemAttrib));
		}
	}

	//	start
	//int nRectHeight = 0;
	int nMaxWidth = 0;
	int nCurWidth = 0;

#define TEST_MAXWIDTH(width)				{if(width > nMaxWidth){nMaxWidth = width;}};
#define TEST_TEXTWIDTH(text, fsize)			{int nTextLength = GetTextWidth(text, fsize);TEST_MAXWIDTH(nTextLength);}

	int nDrawRectX = s_nLeftBoundary;
	int nDrawRectY = s_nTopBoundary;

	int nCurX = nDrawRectX;
	int nCurY = nDrawRectY;

	char szText[MAX_PATH];
	//	first, quality
	int nQualityIndex = m_stShowItem.level;
	if(nQualityIndex < 0 ||
		nQualityIndex >= sizeof(s_pszItemLevel) / sizeof(s_pszItemLevel[0]))
	{
		nQualityIndex = 0;
	}

	//	name
	TEST_TEXTWIDTH(m_stShowItem.name, 14);
	DisplayItem* pNameItem = AddStringItem(m_stShowItem.name, nCurX, nCurY, ARGB_YELLOW, AfxGetFont14());
	//nRectHeight += s_nTitleHeight;

	//	item icon
	nCurX = nDrawRectX;
	nCurY = nDrawRectY;
	nCurY += s_nTitleHeight;
	//nRectHeight += s_nItemIconHeight;

	int nIntroLine = 0;
	//	type
	sprintf(szText, "类型:%s", "书籍");
	nCurWidth = s_nItemIconWidth + s_nItemIntroGapX + GetTextWidth(szText, 12);
	TEST_MAXWIDTH(nCurWidth);
	nCurX = nDrawRectX;
	nCurY = nDrawRectY;
	nCurX += s_nItemIconWidth + s_nItemIntroGapX;
	nCurY += s_nTitleHeight + 5 + nIntroLine * s_nEachLineHeight;
	AddStringItem(szText, nCurX, nCurY);
	++nIntroLine;

	//	weight
	sprintf(szText, "重量:%d", m_stShowItem.weight);
	nCurWidth = s_nItemIconWidth + s_nItemIntroGapX + GetTextWidth(szText, 12);
	TEST_MAXWIDTH(nCurWidth);
	nCurX = nDrawRectX;
	nCurY = nDrawRectY;
	nCurX += s_nItemIconWidth + s_nItemIntroGapX;
	nCurY += s_nTitleHeight + 5 + nIntroLine * s_nEachLineHeight;
	AddStringItem(szText, nCurX, nCurY);
	++nIntroLine;

	//	bind or not
	sprintf(szText, "%s", TEST_FLAG_BOOL(m_stShowItem.atkPois, 0x1) ? "[已绑定]" : "[未绑定]");
	nCurWidth = s_nItemIconWidth + s_nItemIntroGapX + GetTextWidth(szText, 12);
	TEST_MAXWIDTH(nCurWidth);
	nCurX = nDrawRectX;
	nCurY = nDrawRectY;
	nCurX += s_nItemIconWidth + s_nItemIntroGapX;
	nCurY += s_nTitleHeight + 5 + nIntroLine * s_nEachLineHeight;
	AddStringItem(szText, nCurX, nCurY);
	++nIntroLine;

	//	details
	int nDetailLine = 0;
	int nDetailDrawX = s_nLeftBoundary;
	int nDetailDrawY = s_nTopBoundary + s_nTitleHeight + s_nItemIconHeight + s_nItemIntroGapX;

	if(IsEquipItem(&m_stShowItem))
	{
		//	*equipment*
		//	equipment information
		nCurX = nDetailDrawX;
		nCurY = nDetailDrawY + nDetailLine * s_nEachLineHeight;
		nCurWidth = 5 * 12;
		TEST_MAXWIDTH(nCurWidth);
		AddStringItem("[装备信息]", nCurX, nCurY);
		++nDetailLine;

		//	dura
		nCurX = nDetailDrawX;
		nCurY = nDetailDrawY + nDetailLine * s_nEachLineHeight;
		int nDura = HIWORD(m_stShowItem.maxHP) / 1000;
		int nDuraMax = LOWORD(m_stShowItem.maxHP) / 1000;
		sprintf(szText, "持久:%d/%d", nDura, nDuraMax);
		nCurWidth = GetTextWidth(szText, 12);
		TEST_MAXWIDTH(nCurWidth);
		AddStringItem(szText, nCurX, nCurY);
		++nDetailLine;

		//	quality
		nCurX = nDrawRectX;
		nCurY = nDetailDrawY + nDetailLine * s_nEachLineHeight;
		sprintf(szText, "品质:%s", s_pszItemLevel[nQualityIndex]);
		nCurWidth = GetTextWidth(szText, 12);
		TEST_MAXWIDTH(nCurWidth);
		AddStringItem(szText, nCurX, nCurY);
		++nDetailLine;

		//	level
		int nLevel = 0;
		nCurX = nDrawRectX;
		nCurY = nDetailDrawY + nDetailLine * s_nEachLineHeight;
		sprintf(szText, "级别:%d", nLevel);
		nCurWidth = GetTextWidth(szText, 12);
		TEST_MAXWIDTH(nCurWidth);
		AddStringItem(szText, nCurX, nCurY);
		++nDetailLine;

		//	a blank line
		++nDetailLine;

		//	equipment base attribute
		nCurX = nDetailDrawX;
		nCurY = nDetailDrawY + nDetailLine * s_nEachLineHeight;
		nCurWidth = 5 * 12;
		TEST_MAXWIDTH(nCurWidth);
		AddStringItem("[基础属性]", nCurX, nCurY);
		++nDetailLine;

		//	AC
		if(m_stShowItem.AC != 0 ||
			m_stShowItem.maxAC != 0)
		{
			if(m_stShowItem.type != /*ITEM_WEAPON*/111 &&
				m_stShowItem.type != /*ITEM_NECKLACE*/111)
			{
				nCurX = nDetailDrawX;
				nCurY = nDetailDrawY;
				nCurY += s_nEachLineHeight * nDetailLine;
				if(stOriItem.maxAC != 0)
				{
					sprintf(szText, "防御:%d-%d(+%d)",
						m_stShowItem.AC, m_stShowItem.maxAC, stOriItem.maxAC);
					nCurWidth = GetTextWidth(szText, 12);
					TEST_MAXWIDTH(nCurWidth);
					AddStringItem(szText, nCurX, nCurY, ARGB_GREEN);
				}
				else
				{
					sprintf(szText, "防御:%d-%d",
						m_stShowItem.AC, m_stShowItem.maxAC);
					nCurWidth = GetTextWidth(szText, 12);
					TEST_MAXWIDTH(nCurWidth);
					AddStringItem(szText, nCurX, nCurY);
				}

				++nDetailLine;
			}
		}

		//	MAC
		if(m_stShowItem.MAC != 0 ||
			m_stShowItem.maxMAC != 0)
		{
			if(m_stShowItem.type != /*ITEM_WEAPON*/111 &&
				m_stShowItem.type != /*ITEM_NECKLACE*/111)
			{
				nCurX = nDetailDrawX;
				nCurY = nDetailDrawY;
				nCurY += s_nEachLineHeight * nDetailLine;
				if(stOriItem.maxAC != 0)
				{
					sprintf(szText, "魔御:%d-%d(+%d)",
						m_stShowItem.MAC, m_stShowItem.maxMAC, stOriItem.maxMAC);
					nCurWidth = GetTextWidth(szText, 12);
					TEST_MAXWIDTH(nCurWidth);
					AddStringItem(szText, nCurX, nCurY, ARGB_GREEN);
				}
				else
				{
					sprintf(szText, "魔御:%d-%d",
						m_stShowItem.MAC, m_stShowItem.maxMAC);
					nCurWidth = GetTextWidth(szText, 12);
					TEST_MAXWIDTH(nCurWidth);
					AddStringItem(szText, nCurX, nCurY);
				}

				++nDetailLine;
			}
		}

		//	DC
		if(m_stShowItem.DC != 0 ||
			m_stShowItem.maxDC != 0)
		{
			nCurX = nDetailDrawX;
			nCurY = nDetailDrawY;
			nCurY += s_nEachLineHeight * nDetailLine;
			if(stOriItem.maxDC != 0)
			{
				sprintf(szText, "攻击:%d-%d(+%d)",
					m_stShowItem.DC, m_stShowItem.maxDC, stOriItem.maxDC);
				nCurWidth = GetTextWidth(szText, 12);
				TEST_MAXWIDTH(nCurWidth);
				AddStringItem(szText, nCurX, nCurY, ARGB_GREEN);
			}
			else
			{
				sprintf(szText, "攻击:%d-%d",
					m_stShowItem.DC, m_stShowItem.maxDC);
				nCurWidth = GetTextWidth(szText, 12);
				TEST_MAXWIDTH(nCurWidth);
				AddStringItem(szText, nCurX, nCurY);
			}

			++nDetailLine;
		}

		//	MC
		if(m_stShowItem.MC != 0 ||
			m_stShowItem.maxMC != 0)
		{
			nCurX = nDetailDrawX;
			nCurY = nDetailDrawY;
			nCurY += s_nEachLineHeight * nDetailLine;
			if(stOriItem.maxMC != 0)
			{
				sprintf(szText, "魔法:%d-%d(+%d)",
					m_stShowItem.MC, m_stShowItem.maxMC, stOriItem.maxMC);
				nCurWidth = GetTextWidth(szText, 12);
				TEST_MAXWIDTH(nCurWidth);
				AddStringItem(szText, nCurX, nCurY, ARGB_GREEN);
			}
			else
			{
				sprintf(szText, "魔法:%d-%d",
					m_stShowItem.MC, m_stShowItem.maxMC);
				nCurWidth = GetTextWidth(szText, 12);
				TEST_MAXWIDTH(nCurWidth);
				AddStringItem(szText, nCurX, nCurY);
			}

			++nDetailLine;
		}

		//	SC
		if(m_stShowItem.SC != 0 ||
			m_stShowItem.maxSC != 0)
		{
			nCurX = nDetailDrawX;
			nCurY = nDetailDrawY;
			nCurY += s_nEachLineHeight * nDetailLine;
			if(stOriItem.maxSC != 0)
			{
				sprintf(szText, "道术:%d-%d(+%d)",
					m_stShowItem.SC, m_stShowItem.maxSC, stOriItem.maxSC);
				nCurWidth = GetTextWidth(szText, 12);
				TEST_MAXWIDTH(nCurWidth);
				AddStringItem(szText, nCurX, nCurY, ARGB_GREEN);
			}
			else
			{
				sprintf(szText, "道术:%d-%d",
					m_stShowItem.SC, m_stShowItem.maxSC);
				nCurWidth = GetTextWidth(szText, 12);
				TEST_MAXWIDTH(nCurWidth);
				AddStringItem(szText, nCurX, nCurY);
			}

			++nDetailLine;
		}

		//	Lucky
		if(m_stShowItem.lucky != 0)
		{
			if(m_stShowItem.type == /*ITEM_WEAPON*/111 ||
				m_stShowItem.type == /*ITEM_NECKLACE*/111)
			{
				nCurX = nDetailDrawX;
				nCurY = nDetailDrawY;
				nCurY += s_nEachLineHeight * nDetailLine;
				AfxGetPrinter()->SetColor(ARGB_WHITE);
				if(stOriItem.lucky != 0)
				{
					sprintf(szText, "幸运:+%d(+%d)",
						m_stShowItem.lucky, stOriItem.lucky);
					nCurWidth = GetTextWidth(szText, 12);
					TEST_MAXWIDTH(nCurWidth);
					AddStringItem(szText, nCurX, nCurY, ARGB_GREEN);
				}
				else
				{
					sprintf(szText, "幸运:+%d",
						m_stShowItem.lucky);
					nCurWidth = GetTextWidth(szText, 12);
					TEST_MAXWIDTH(nCurWidth);
					AddStringItem(szText, nCurX, nCurY);
				}

				++nDetailLine;
			}
		}

		//	AtkSpeed
		if(m_stShowItem.atkSpeed != 0)
		{
			if(m_stShowItem.type == /*ITEM_RING*/111 ||
				m_stShowItem.type == /*ITEM_NECKLACE*/111)
			{
				nCurX = nDetailDrawX;
				nCurY = nDetailDrawY;
				nCurY += s_nEachLineHeight * nDetailLine;
				AfxGetPrinter()->SetColor(ARGB_WHITE);
				if(stOriItem.atkSpeed != 0)
				{
					sprintf(szText, "攻击速度:+%d(+%d)",
						m_stShowItem.atkSpeed, stOriItem.atkSpeed);
					nCurWidth = GetTextWidth(szText, 12);
					TEST_MAXWIDTH(nCurWidth);
					AddStringItem(szText, nCurX, nCurY, ARGB_GREEN);
				}
				else
				{
					sprintf(szText, "攻击速度:+%d",
						m_stShowItem.atkSpeed);
					nCurWidth = GetTextWidth(szText, 12);
					TEST_MAXWIDTH(nCurWidth);
					AddStringItem(szText, nCurX, nCurY);
				}

				++nDetailLine;
			}
		}

		//	MoveSpeed
		if(m_stShowItem.moveSpeed != 0)
		{
			//if(m_pItemAttrib->type == ITEM_RING ||
			//m_pItemAttrib->type == ITEM_NECKLACE)
			{
				nCurX = nDetailDrawX;
				nCurY = nDetailDrawY;
				nCurY += s_nEachLineHeight * nDetailLine;
				AfxGetPrinter()->SetColor(ARGB_WHITE);
				if(stOriItem.moveSpeed != 0)
				{
					sprintf(szText, "移动速度:+%d(+%d)",
						m_stShowItem.moveSpeed, stOriItem.moveSpeed);
					nCurWidth = GetTextWidth(szText, 12);
					TEST_MAXWIDTH(nCurWidth);
					AddStringItem(szText, nCurX, nCurY, ARGB_GREEN);
				}
				else
				{
					sprintf(szText, "移动速度:+%d",
						m_stShowItem.moveSpeed);
					nCurWidth = GetTextWidth(szText, 12);
					TEST_MAXWIDTH(nCurWidth);
					AddStringItem(szText, nCurX, nCurY);
				}

				++nDetailLine;
			}
		}

		//	Accuracy
		if(m_stShowItem.accuracy != 0)
		{
			if(m_stShowItem.type == /*ITEM_BRACELAT*/111 ||
				m_stShowItem.type == /*ITEM_NECKLACE*/111 ||
				m_stShowItem.type == /*ITEM_WEAPON*/111)
			{
				nCurX = nDetailDrawX;
				nCurY = nDetailDrawY;
				nCurY += s_nEachLineHeight * nDetailLine;
				AfxGetPrinter()->SetColor(ARGB_WHITE);
				if(stOriItem.accuracy != 0)
				{
					sprintf(szText, "准确:+%d(+%d)",
						m_stShowItem.accuracy, stOriItem.accuracy);
					nCurWidth = GetTextWidth(szText, 12);
					TEST_MAXWIDTH(nCurWidth);
					AddStringItem(szText, nCurX, nCurY, ARGB_GREEN);
				}
				else
				{
					sprintf(szText, "准确:+%d",
						m_stShowItem.accuracy);
					nCurWidth = GetTextWidth(szText, 12);
					TEST_MAXWIDTH(nCurWidth);
					AddStringItem(szText, nCurX, nCurY);
				}

				++nDetailLine;
			}
		}

		//	Hide
		if(m_stShowItem.hide != 0)
		{
			if(m_stShowItem.type == /*ITEM_BRACELAT*/111 ||
				m_stShowItem.type == /*ITEM_NECKLACE*/111)
			{
				nCurX = nDetailDrawX;
				nCurY = nDetailDrawY;
				nCurY += s_nEachLineHeight * nDetailLine;
				AfxGetPrinter()->SetColor(ARGB_WHITE);
				if(stOriItem.hide != 0)
				{
					sprintf(szText, "躲避:+%d(+%d)",
						m_stShowItem.hide, stOriItem.hide);
					nCurWidth = GetTextWidth(szText, 12);
					TEST_MAXWIDTH(nCurWidth);
					AddStringItem(szText, nCurX, nCurY, ARGB_GREEN);
				}
				else
				{
					sprintf(szText, "躲避:+%d",
						m_stShowItem.hide);
					nCurWidth = GetTextWidth(szText, 12);
					TEST_MAXWIDTH(nCurWidth);
					AddStringItem(szText, nCurX, nCurY);
				}

				++nDetailLine;
			}
		}
	}
	else if(m_stShowItem.type == /*ITEM_COST*/1)
	{
		//	[物品信息]
		{
			nCurX = nDetailDrawX;
			nCurY = nDetailDrawY;
			nCurY += s_nEachLineHeight * nDetailLine;
			sprintf(szText, "[物品信息]");
			nCurWidth = 12 * 5;
			TEST_MAXWIDTH(nCurWidth);
			AddStringItem(szText, nCurX, nCurY);
			++nDetailLine;
		}
		//	Count
		{
			nCurX = nDetailDrawX;
			nCurY = nDetailDrawY;
			nCurY += s_nEachLineHeight * nDetailLine;
			sprintf(szText, "数量:%d",
				m_stShowItem.atkSpeed);
			nCurWidth = GetTextWidth(szText, 12);
			TEST_MAXWIDTH(nCurWidth);
			AddStringItem(szText, nCurX, nCurY);
			++nDetailLine;
		}

		//	Drug
		if(m_stShowItem.curse == 0)
		{
			//	HP
			if(m_stShowItem.HP != 0)
			{
				nCurX = nDetailDrawX;
				nCurY = nDetailDrawY;
				nCurY += s_nEachLineHeight * nDetailLine;
				if(m_stShowItem.lucky == 0)
				{
					sprintf(szText, "缓慢补充HP:%d",
						m_stShowItem.HP);
					nCurWidth = GetTextWidth(szText, 12);
					TEST_MAXWIDTH(nCurWidth);
					AddStringItem(szText, nCurX, nCurY);
				}
				else if(m_stShowItem.lucky == 1)
				{
					sprintf(szText, "急速补充HP:%d",
						m_stShowItem.HP);
					nCurWidth = GetTextWidth(szText, 12);
					TEST_MAXWIDTH(nCurWidth);
					AddStringItem(szText, nCurX, nCurY);
				}
				++nDetailLine;
			}
			//	MP
			if(m_stShowItem.MP != 0)
			{
				nCurX = nDetailDrawX;
				nCurY = nDetailDrawY;
				nCurY += s_nEachLineHeight * nDetailLine;
				if(m_stShowItem.lucky == 0)
				{
					sprintf(szText, "缓慢补充MP:%d",
						m_stShowItem.MP);
					nCurWidth = GetTextWidth(szText, 12);
					TEST_MAXWIDTH(nCurWidth);
					AddStringItem(szText, nCurX, nCurY);
				}
				else if(m_stShowItem.lucky == 1)
				{
					sprintf(szText, "急速补充MP:%d",
						m_stShowItem.MP);
					nCurWidth = GetTextWidth(szText, 12);
					TEST_MAXWIDTH(nCurWidth);
					AddStringItem(szText, nCurX, nCurY);
				}
				++nDetailLine;
			}
			//	Cooldown time
			if(m_stShowItem.hide != 0)
			{
				nCurX = nDetailDrawX;
				nCurY = nDetailDrawY;
				nCurY += s_nEachLineHeight * nDetailLine;
				sprintf(szText, "冷却时间:%d秒",
					m_stShowItem.hide);
				nCurWidth = GetTextWidth(szText, 12);
				TEST_MAXWIDTH(nCurWidth);
				AddStringItem(szText, nCurX, nCurY);
				++nDetailLine;
			}
		}
	}
	else if(m_stShowItem.type == /*ITEM_BOOK*/2)
	{
		//	[秘籍信息]
		nCurX = nDetailDrawX;
		nCurY = nDetailDrawY;
		nCurY += s_nEachLineHeight * nDetailLine;
		nCurWidth = 12 * 5;
		TEST_MAXWIDTH(nCurWidth);
		AddStringItem("[秘籍信息]", nCurX, nCurY);
		++nDetailLine;

		//	Job
		nCurX = nDetailDrawX;
		nCurY = nDetailDrawY;
		nCurY += s_nEachLineHeight * nDetailLine;
		AfxGetPrinter()->SetColor(ARGB_WHITE);
		if(m_stShowItem.lucky == 1)
		{
			nCurWidth = 12 * 4;
			TEST_MAXWIDTH(nCurWidth);
			AddStringItem("战士秘籍", nCurX, nCurY);
		}
		else if(m_stShowItem.lucky == 2)
		{
			nCurWidth = 12 * 4;
			TEST_MAXWIDTH(nCurWidth);
			AddStringItem("法师秘籍", nCurX, nCurY);
		}
		else if(m_stShowItem.lucky == 3)
		{
			nCurWidth = 12 * 4;
			TEST_MAXWIDTH(nCurWidth);
			AddStringItem("道士秘籍", nCurX, nCurY);
		}
		else
		{
			nCurWidth = 12 * 4;
			TEST_MAXWIDTH(nCurWidth);
			AddStringItem("无需求", nCurX, nCurY);
		}

		++nDetailLine;
	}

	//	suit attribute
	/*if(IsEquipItem(&m_stShowItem) &&
		m_stShowItem.atkPalsy != 0)
	{
		SuitExtraAttrib* pExtraAttribList = GetGlobalSuitExtraAttrib(m_stShowItem.atkPalsy);

		if(pExtraAttribList)
		{
			//	a line blank
			++nDetailLine;

			//	Suit name
			const ItemAttrib* pPlayerItem = NULL;
			bool bActived[PLAYER_ITEM_TOTAL];
			ZeroMemory(bActived, sizeof(bActived));
			int nActiveItemSum = 0;
			int nActiveItemAll = 0;

			for(int i = 0; i < PLAYER_ITEM_TOTAL; ++i)
			{
				if(pExtraAttribList->nSuitEquipID[i] != 0)
				{
					++nActiveItemAll;
				}
			}

			for(int i = PLAYER_ITEM_WEAPON; i < PLAYER_ITEM_TOTAL; ++i)
			{
				if(-1 == m_nOwner)
				{
					pPlayerItem = GamePlayer::GetInstance()->GetPlayerItem((PLAYER_ITEM_TYPE)i);
				}
				else
				{
					pPlayerItem = m_stItems[i];
				}

				if(pPlayerItem->atkPalsy == pExtraAttribList->nSuitID)
				{
					//	检测是否存在过
					for(int j = 0; j < 10; ++j)
					{
						if(pPlayerItem->id == pExtraAttribList->nSuitEquipID[j] &&
							!bActived[j] &&
							pExtraAttribList->nSuitEquipID[j] != 0)
						{
							bActived[j] = true;
							++nActiveItemSum;
							break;
						}
					}
				}
			}

			nCurX = nDetailDrawX;
			nCurY = nDetailDrawY;
			nCurY += s_nEachLineHeight * nDetailLine;
			sprintf(szText, "[%s](%d/%d)",
				pExtraAttribList->szSuitChName,
				nActiveItemSum,
				nActiveItemAll);
			nCurWidth = GetTextWidth(szText, 12);
			TEST_MAXWIDTH(nCurWidth);
			AddStringItem(szText, nCurX, nCurY, ARGB_GREEN);
			++nDetailLine;
			
			//	suit item name
			for(int i = 0; i < PLAYER_ITEM_TOTAL; ++i)
			{
				if(pExtraAttribList->nSuitEquipID[i] != 0)
				{
					ItemAttrib item;
					ZeroMemory(&item, sizeof(ItemAttrib));

					if(GameInfoManager::GetInstance()->GetItemAttrib(pExtraAttribList->nSuitEquipID[i], &item))
					{
						nCurX = nDetailDrawX;
						nCurY = nDetailDrawY;
						nCurY += s_nEachLineHeight * nDetailLine;
						nCurWidth = GetTextWidth(item.name, 12);
						TEST_MAXWIDTH(nCurWidth);
						if(bActived[i])
						{
							AddStringItem(item.name, nCurX, nCurY, COLOR_SUITNAMEITEM_ACTIVE);
						}
						else
						{
							AddStringItem(item.name, nCurX, nCurY, COLOR_SUITNAMEITEM_UNACTIVE);
						}
						
						++nDetailLine;
					}
				}
			}

			//	a line blank
			++nDetailLine;

			//	suit effect describe
			nCurX = nDetailDrawX;
			nCurY = nDetailDrawY;
			nCurY += s_nEachLineHeight * nDetailLine;
			AfxGetPrinter()->SetColor(ARGB_GREEN);
			if(pExtraAttribList->nSuitShowType == 1)
			{
				AddStringItem("[特殊效果]", nCurX, nCurY, ARGB_GREEN);
			}
			else
			{
				AddStringItem("[套装效果]", nCurX, nCurY, ARGB_GREEN);
			}
			++nDetailLine;

			//	suit effect
			int nActiveMax = 0;
			int nActiveAttribSum = 0;

			for(int i = 0; i < MAX_EXTRAATTIRB; ++i)
			{
				if(nActiveItemSum >= pExtraAttribList->nActiveSum[i] &&
					pExtraAttribList->nActiveSum[i] > nActiveMax)
				{
					nActiveMax = pExtraAttribList->nActiveSum[i];
					nActiveAttribSum = pExtraAttribList->nActiveAttribSum[i];
				}
			}

			ItemExtraAttribItem extraAttrib;

			for(int i = 0; i < PLAYER_ITEM_TOTAL; ++i)
			{
				if(pExtraAttribList->stExtraAttrib[i].nAttribID == 0)
				{
					break;
				}

				DWORD dwItemColor = COLOR_EXTRAATTRIB_UNACTIVE;
				if(nActiveAttribSum > i)
				{
					dwItemColor = COLOR_EXTRAATRRIB_ACTIVE;
				}

				extraItem = pExtraAttribList->stExtraAttrib[i];
				if(extraItem.nAttribID == EAID_AC ||
					extraItem.nAttribID == EAID_MAC ||
					extraItem.nAttribID == EAID_DC ||
					extraItem.nAttribID == EAID_MC ||
					extraItem.nAttribID == EAID_SC)
				{
					sprintf(szText, "%s%d-%d",
						g_szExtraAttribDescriptor[extraItem.nAttribID], HIWORD(extraItem.nAttribValue), LOWORD(extraItem.nAttribValue));
				}
				else
				{
					sprintf(szText, "%s+%d",
						g_szExtraAttribDescriptor[extraItem.nAttribID], extraItem.nAttribValue);
				}

				nCurX = nDetailDrawX;
				nCurY = nDetailDrawY;
				nCurY += s_nEachLineHeight * nDetailLine;

				AfxGetPrinter()->PrintWithoutStroke(nCurX, nCurY, szText, dwItemColor);
				++nDetailLine;
			}
		}
	}*/

	//	addition information
	if(TEST_FLAG_BOOL(m_stShowItem.EXPR, /*EXPR_MASK_NOSAVE*/1) ||
		TEST_FLAG_BOOL(m_stShowItem.EXPR, /*EXPR_MASK_NOSELL*/2))
	{
		//	A line blank
		++nDetailLine;

		//	No save
		if(TEST_FLAG_BOOL(m_stShowItem.EXPR, /*EXPR_MASK_NOSAVE*/1))
		{
			nCurX = nDetailDrawX;
			nCurY = nDetailDrawY;
			nCurY += s_nEachLineHeight * nDetailLine;
			nCurWidth = 12 * 6;
			TEST_MAXWIDTH(nCurWidth);
			AddStringItem("(无法保存)", nCurX, nCurY, ARGB_RED);
			++nDetailLine;
		}
		if(TEST_FLAG_BOOL(m_stShowItem.EXPR, /*EXPR_MASK_NOSELL*/2))
		{
			nCurX = nDetailDrawX;
			nCurY = nDetailDrawY;
			nCurY += s_nEachLineHeight * nDetailLine;
			nCurWidth = 12 * 6;
			TEST_MAXWIDTH(nCurWidth);
			AddStringItem("(无法出售)", nCurX, nCurY, ARGB_RED);
			++nDetailLine;
		}
	}

	//	end, add border width
	m_rcClient.left = m_rcClient.top = 0;
	m_rcClient.right = nMaxWidth + 2 * s_nLeftBoundary;
	m_rcClient.bottom = s_nTitleHeight + s_nItemIconHeight + s_nItemIntroGapX + s_nEachLineHeight * nDetailLine + 2 * s_nTopBoundary;

	//	adjust name rect
	if(pNameItem)
	{
		int nNameCenterX = GetTextWidth(pNameItem->xText.c_str(), 14);
		nNameCenterX = (m_rcClient.right - m_rcClient.left - nNameCenterX) / 2;
		pNameItem->nPosX = nNameCenterX;
	}
}
Example #18
0
		void GuiResourceFolder::LoadResourceFolderFromXml(DelayLoadingList& delayLoadings, const WString& containingFolder, Ptr<parsing::xml::XmlElement> folderXml, collections::List<WString>& errors)
		{
			ClearItems();
			ClearFolders();
			FOREACH(Ptr<XmlElement>, element, XmlGetElements(folderXml))
			{
				WString name;
				if(Ptr<XmlAttribute> nameAtt=XmlGetAttribute(element, L"name"))
				{
					name=nameAtt->value.value;
				}
				if(element->name.value==L"Folder")
				{
					if (name == L"")
					{
						errors.Add(L"A resource folder should have a name.");
						errors.Add(
							L"Format: RESOURCE, Row: " + itow(element->codeRange.start.row + 1) +
							L", Column: " + itow(element->codeRange.start.column + 1) +
							L", Message: A resource folder should have a name.");
					}
					else
					{
						Ptr<GuiResourceFolder> folder=new GuiResourceFolder;
						if(AddFolder(name, folder))
						{
							WString newContainingFolder=containingFolder;
							Ptr<XmlElement> newFolderXml=element;
							if(Ptr<XmlAttribute> contentAtt=XmlGetAttribute(element, L"content"))
							{
								if(contentAtt->value.value==L"Link")
								{
									folder->SetFileContentPath(XmlGetValue(element));
									WString filePath = containingFolder + folder->GetFileContentPath();
									WString text;
									if(LoadTextFile(filePath, text))
									{
										if(auto parser=GetParserManager()->GetParser<XmlDocument>(L"XML"))
										{
											if(auto xml=parser->TypedParse(text, errors))
											{
												newContainingFolder=GetFolderPath(filePath);
												newFolderXml=xml->rootElement;
											}
										}
									}
									else
									{
										errors.Add(L"Failed to load file \"" + filePath + L"\".");
									}
								}
							}
							folder->LoadResourceFolderFromXml(delayLoadings, newContainingFolder, newFolderXml, errors);
						}
						else
						{
							errors.Add(L"Duplicated resource folder name \"" + name + L"\".");
						}
					}
				}
				else if(element->name.value.Length() <= 3 || element->name.value.Sub(0, 4) != L"ref.")
				{
					WString relativeFilePath;
					WString filePath;
					if(Ptr<XmlAttribute> contentAtt=XmlGetAttribute(element, L"content"))
					{
						if(contentAtt->value.value==L"File")
						{
							relativeFilePath = XmlGetValue(element);
							filePath = containingFolder + relativeFilePath;
							if(name==L"")
							{
								name=GetFileName(filePath);
							}
						}
					}

					Ptr<GuiResourceItem> item = new GuiResourceItem;
					if(AddItem(name, item))
					{
						WString type = element->name.value;
						IGuiResourceTypeResolver* typeResolver = GetResourceResolverManager()->GetTypeResolver(type);
						IGuiResourceTypeResolver* preloadResolver = typeResolver;

						if(typeResolver)
						{
							if (!typeResolver->DirectLoadXml())
							{
								WString preloadType = typeResolver->IndirectLoad()->GetPreloadType();
								if (preloadType != L"")
								{
									preloadResolver = GetResourceResolverManager()->GetTypeResolver(preloadType);
									if (!preloadResolver)
									{
										errors.Add(L"Unknown resource resolver \"" + preloadType + L"\" of resource type \"" + type + L"\".");
									}
								}
							}
						}
						else
						{
							errors.Add(L"Unknown resource type \"" + type + L"\".");
						}

						if(typeResolver && preloadResolver)
						{
							if (auto directLoad = preloadResolver->DirectLoadXml())
							{
								Ptr<DescriptableObject> resource;
								WString itemType = preloadResolver->GetType();
								if (filePath == L"")
								{
									resource = directLoad->ResolveResource(element, errors);
								}
								else
								{
									item->SetFileContentPath(relativeFilePath);
									resource = directLoad->ResolveResource(filePath, errors);
								}

								if (typeResolver != preloadResolver)
								{
									if (auto indirectLoad = typeResolver->IndirectLoad())
									{
										if(indirectLoad->IsDelayLoad())
										{
											DelayLoading delayLoading;
											delayLoading.type = type;
											delayLoading.workingDirectory = containingFolder;
											delayLoading.preloadResource = item;
											delayLoadings.Add(delayLoading);
										}
										else if(resource)
										{
											resource = indirectLoad->ResolveResource(resource, 0, errors);
											itemType = typeResolver->GetType();
										}
									}
									else
									{
										resource = 0;
										errors.Add(L"Resource type \"" + typeResolver->GetType() + L"\" is not a indirect load resource type.");
									}
								}
								item->SetContent(itemType, resource);
							}
							else
							{
								errors.Add(L"Resource type \"" + preloadResolver->GetType() + L"\" is not a direct load resource type.");
							}
						}

						if(!item->GetContent())
						{
							RemoveItem(name);
						}
					}
					else
					{
						errors.Add(L"Duplicated resource item name \"" + name + L"\".");
					}
				}
			}
Example #19
0
CLineGraph::~CLineGraph()
{
	ClearItems();
}
TextOsd::~TextOsd()
{
  ClearItems();
}
Example #21
0
DEFINE_THIS_FILE
//:End Ignore

//:>********************************************************************************************
//:>	AfWnd methods.
//:>********************************************************************************************

/*----------------------------------------------------------------------------------------------
	Register this window class.  This is a static method.

	@param pszName The window class name.
	@param grfwcs Window class style flags (CS_HREDRAW, CS_NOCLOSE, ...)
	@param ridCrs Resource ID for the window class cursor, or 0.
	@param ridMenu Resource ID for the window class menu, or 0.
	@param clrBack Background color for the window class.
	@param ridIcon Resource ID for the window class icon, or 0.
	@param ridIconSmall Resource ID for the window class small icon, or 0.
----------------------------------------------------------------------------------------------*/
void AfWnd::RegisterClass(Pcsz pszName, int grfwcs, int ridCrs, int ridMenu, int clrBack,
	int ridIcon, int ridIconSmall)
{
	AssertPsz(pszName);
	Assert(!(ridCrs & 0xFFFF0000));
	Assert(!(ridMenu & 0xFFFF0000));
	Assert(clrBack == -1 || !(clrBack & 0xFFFF0000));
	Assert(!(ridIcon & 0xFFFF0000));
	Assert(!(ridIconSmall & 0xFFFF0000));

	WNDCLASSEX wcx;
	HINSTANCE hinst = ModuleEntry::GetModuleHandle();

	ClearItems(&wcx, 1);
	wcx.cbSize = isizeof(wcx);
	wcx.style = grfwcs;
	wcx.lpfnWndProc = &AfWnd::WndProc;
	wcx.cbClsExtra = 0;

	// REVIEW ShonK: For dialogs this needs to be DLGWINDOWEXTRA. Will we ever register
	// dialog classes? Probably not.
	wcx.cbWndExtra = 0;

	wcx.hInstance = hinst;

	// REVIEW ShonK: Determine whether to pass NULL or hinst in LoadIcon calls.
	wcx.hIcon = ridIcon ? ::LoadIcon(hinst, MAKEINTRESOURCE(ridIcon)) : NULL;
	wcx.hCursor = ridCrs ? ::LoadCursor(NULL, MAKEINTRESOURCE(ridCrs)) : NULL;
	// REVIEW ShonK: Do we not want to disallow a brush to be passed in clrBack?
	// hbrBackground in WNDCLASSEX allows a brush if it is not one a fixed number of
	// system colors. For context help we want COLOR_INFOBK which is not listed as
	// one of the valid colors. However, this along with the assert above, fails if
	// we try to pass a brush with COLOR_INFOBK, although this should be acceptable to
	// WNDCLASSEX. It ends up that we can pass COLOR_INFOBK to this method directly, and
	// it works OK. Will any color work using this approach, or should we allow a brush
	// to be consistent with WNDCLASSEX?
	// wcx.hbrBackground = (uint)clrBack < (uint)30 ? (HBRUSH)(clrBack + 1) : (HBRUSH)clrBack;
	wcx.hbrBackground = clrBack >= 0 ? (HBRUSH)(clrBack + 1) : NULL;
	wcx.lpszMenuName = MAKEINTRESOURCE(ridMenu);
	wcx.lpszClassName = pszName;
	wcx.hIconSm = ridIconSmall ? ::LoadIcon(hinst, MAKEINTRESOURCE(ridIconSmall)) : NULL;

	if (!::RegisterClassEx(&wcx))
	{
		// we try to avoid this, but it can happen with opening/closing multiple projects and
		// multiple dialogs.
		DWORD dw = ::GetLastError();
		if (dw == ERROR_CLASS_ALREADY_EXISTS)
			return;
		AssertMsg(false, "Registering window class failed.");
		ThrowHr(WarnHr(E_UNEXPECTED));
	}
}
Example #22
0
bool C4MainMenu::DoRefillInternal(bool &rfRefilled)
{
	// Variables
	C4FacetSurface fctSymbol;
	C4Player *pPlayer;
	C4IDList ListItems;
	C4Facet fctTarget;
	bool fWasEmpty = !GetItemCount();

	// Refill
	switch (Identification)
	{
		// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
	case C4MN_Hostility:
	{
		// Clear items
		ClearItems();
		// Refill player
		if (!(pPlayer = ::Players.Get(Player))) return false;
		// Refill items
		C4Player *pPlr; int32_t iIndex;
		for (iIndex=0; (pPlr = ::Players.GetByIndex(iIndex)); iIndex++)
			// Ignore player self and invisible
			if (pPlr != pPlayer) if (!pPlr->IsInvisible())
				{
					// Symbol
					fctSymbol.Create(C4SymbolSize,C4SymbolSize);
					pPlayer->DrawHostility(fctSymbol,iIndex);
					// Message
					StdStrBuf sMsg;
					bool isFriendly = pPlayer->Hostility.find(pPlr) == pPlayer->Hostility.end();
					if (isFriendly)
						sMsg.Format(LoadResStr("IDS_MENU_ATTACK"),pPlr->GetName());
					else
						sMsg.Format(LoadResStr("IDS_MENU_NOATTACK"),pPlr->GetName());
					// Command
					char szCommand[1000];
					sprintf(szCommand,"SetHostility:%i",pPlr->Number);
					// Info caption
					char szInfoCaption[C4MaxTitle+1],szFriendly[50],szNot[30]="";
					SCopy(LoadResStr(isFriendly ? "IDS_MENU_ATTACKHOSTILE" : "IDS_MENU_ATTACKFRIENDLY"),szFriendly);
					if (!isFriendly) SCopy(LoadResStr("IDS_MENU_ATTACKNOT"),szNot);
					sprintf(szInfoCaption,LoadResStr("IDS_MENU_ATTACKINFO"),pPlr->GetName(),szFriendly,szNot);
					if (iIndex==pPlayer->Number) SCopy(LoadResStr("IDS_MENU_ATTACKSELF"),szInfoCaption);
					// Add item
					Add(sMsg.getData(),fctSymbol,szCommand,C4MN_Item_NoCount,NULL,szInfoCaption);
					fctSymbol.Default();
				}
		break;
	}
	// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
	case C4MN_TeamSelection:
	case C4MN_TeamSwitch:
	{
		// Clear items
		ClearItems();
		// add all teams as menu items
		// 2do: Icon
		C4Team *pTeam; int32_t i=0; bool fAddNewTeam=Game.Teams.IsAutoGenerateTeams();
		for (;;)
		{
			pTeam = Game.Teams.GetTeamByIndex(i);
			if (pTeam)
			{
				// next regular team
				++i;
				// do not add a new team if an empty team exists
				if (!pTeam->GetPlayerCount()) fAddNewTeam = false;
			}
			else if (fAddNewTeam)
			{
				// join new team
				fAddNewTeam = false;
			}
			else
			{
				// all teams done
				break;
			}
			// create team symbol: Icon spec if specified; otherwise flag for empty and crew for nonempty team
			fctSymbol.Create(C4SymbolSize,C4SymbolSize);
			const char *szIconSpec = pTeam ? pTeam->GetIconSpec() : NULL;
			bool fHasIcon = false;
			if (szIconSpec && *szIconSpec)
			{
				fHasIcon = Game.DrawTextSpecImage(fctSymbol, szIconSpec, NULL, pTeam->GetColor());
			}
			if (!fHasIcon)
			{
				if (pTeam && pTeam->GetPlayerCount())
					::GraphicsResource.fctCrewClr.DrawClr(fctSymbol, true, pTeam->GetColor());
				else
					C4GUI::Icon::GetIconFacet(C4GUI::Ico_Team).Draw(fctSymbol, true);
			}
			StdStrBuf sTeamName;
			if (pTeam)
			{
				sTeamName.Take(pTeam->GetNameWithParticipants());
			}
			else
				sTeamName.Ref(LoadResStr("IDS_PRC_NEWTEAM"));
			const char *szOperation = (Identification == C4MN_TeamSwitch) ? "TeamSwitch" : "TeamSel";
			Add(sTeamName.getData(), fctSymbol,FormatString("%s:%d", szOperation, pTeam ? pTeam->GetID() : TEAMID_New).getData(),
			    C4MN_Item_NoCount,NULL,FormatString(LoadResStr("IDS_MSG_JOINTEAM"), sTeamName.getData()).getData(), C4ID(pTeam ? pTeam->GetID() : 0));
			fctSymbol.Default();
		}
		break;
	}
	// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
	case C4MN_Observer: // observer menu
	{
		// Clear items
		ClearItems();
		// Check validity
		C4Viewport *pVP = ::Viewports.GetViewport(NO_OWNER);
		if (!pVP) return false;
		int32_t iInitialSelection = 0;
		// Add free view
		AddRefSym(LoadResStr("IDS_MSG_FREEVIEW"), C4GUI::Icon::GetIconFacet(C4GUI::Ico_Star), "Observe:Free", C4MN_Item_NoCount, NULL, LoadResStr("IDS_MSG_FREELYSCROLLAROUNDTHEMAP"));
		// Add players
		C4Player *pPlr; int32_t iIndex;
		for (iIndex=0; (pPlr = ::Players.GetByIndex(iIndex)); iIndex++)
		{
			// Ignore invisible
			if (!pPlr->IsInvisible())
			{
				// Symbol
				fctSymbol.Create(C4SymbolSize,C4SymbolSize);
				::GraphicsResource.fctPlayerClr.DrawClr(fctSymbol, true, pPlr->ColorDw);
				// Message
				StdStrBuf sMsg;
				DWORD dwClr = pPlr->ColorDw;
				sMsg.Format("<c %x>%s</c>", (unsigned int)C4GUI::MakeColorReadableOnBlack(dwClr), pPlr->GetName());
				// Command
				StdStrBuf sCommand;
				sCommand.Format("Observe:%d", (int)pPlr->Number);
				// Info caption
				StdStrBuf sInfo;
				sInfo.Format(LoadResStr("IDS_TEXT_FOLLOWVIEWOFPLAYER"), pPlr->GetName());
				// Add item
				Add(sMsg.getData(),fctSymbol,sCommand.getData(),C4MN_Item_NoCount,NULL,sInfo.getData());
				fctSymbol.Default();
				// check if this is the currently selected player
				if (pVP->GetPlayer() == pPlr->Number) iInitialSelection = GetItemCount()-1;
			}
			// Initial selection on followed player
			if (fWasEmpty) SetSelection(iInitialSelection, false, true);
		}
	}
	break;
	// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
	default:
		// No internal refill needed
		return true;
		// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
	}

	// Successfull internal refill
	rfRefilled = true;
	return true;
}
Example #23
0
void InventoryTab::SetItems(INF_CRE_ITEM *pItems)
{
    QImage   hBitmap;
    QString  strName;
    QString  strQty;
    QString  strNotFound;
    char     szResName[9];
    CResInfo *pResInfo;
    int i;

    // clear out our view and copy in the new items
    ClearItems();
    memcpy(&m_infItems[0], pItems, sizeof(INF_CRE_ITEM)*INF_NUM_ITEMSLOTS);

    // fill the view
    ui->tableInventory->setRowCount(INF_NUM_ITEMSLOTS-1);
    for(i=0; i<INF_NUM_ITEMSLOTS-1; i++)
    {
        ui->tableInventory->setItem(i, 1, new QTableWidgetItem(QString(_itemPos[i].pszPos)));

        if (m_infItems[i].chResName[0])
        {
            pResInfo = EEKeeper::GetItem(m_infItems[i].chResName, &m_infItm[i]);
            if (!pResInfo)
            {
                if (!strNotFound.isEmpty())
                    strNotFound += ",";
                memcpy(szResName, m_infItems[i].chResName, 8);
                szResName[8] = '\x0';
                strNotFound += szResName;
                continue;
            }

            if (EEKeeper::GetItemBitmap(pResInfo, m_infItm[i], 0, qRgba(0, 0, 0, 0), hBitmap))
            {
                QIcon icon(QPixmap::fromImage(hBitmap));
                ui->tableInventory->setItem(i, 0, new QTableWidgetItem(icon, ""));
            }

            if (!_infTlk.GetString(m_infItm[i].dwIdentifiedItemName, strName))
                _infTlk.GetString(m_infItm[i].dwGenericItemName, strName);

            strQty = QString("%1/%2/%3")
                    .arg(m_infItems[i].wQuantity1)
                    .arg(m_infItems[i].wQuantity2)
                    .arg(m_infItems[i].wQuantity3);

            ui->tableInventory->setItem(i, 2, new QTableWidgetItem(strQty));
            ui->tableInventory->setItem(i, 3, new QTableWidgetItem(strName));

            memcpy(szResName, m_infItems[i].chResName, 8);
            szResName[8] = '\x0';
            ui->tableInventory->setItem(i, 4, new QTableWidgetItem(QString(szResName)));
        }
    }

    // update our buttons
    //UpdateButtonStates();

    if (!strNotFound.isEmpty())
    {
        QString message = tr("Some items assigned to this character were not found in the "
                             "database. If you save this character, those items will not be saved.\n\n"
                             "Cannot find: ") + strNotFound;

        QMessageBox::warning(
                    this,
                    tr("Unknown items"),
                    message
                    );
    }
}