本文整理汇总了C++中CUIntArray::Add方法的典型用法代码示例。如果您正苦于以下问题:C++ CUIntArray::Add方法的具体用法?C++ CUIntArray::Add怎么用?C++ CUIntArray::Add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CUIntArray
的用法示例。
在下文中一共展示了CUIntArray::Add方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SetAverageItem
BOOL CSListView::SetAverageItem( CGridCtrl &grid, CStockContainer & container, BOOL bRedraw )
{
if( grid.GetColumnCount() <= 0 )
return FALSE;
container.Lock();
// Get LPARAM
CUIntArray anParams;
anParams.SetSize( 0, grid.GetColumnCount() );
for( int nCol=0; nCol < grid.GetColumnCount(); nCol ++ )
{
LPARAM lParam = grid.GetItemData( 0, nCol );
anParams.Add( lParam );
}
// Set Average
CStockInfo & infoAve = container.GetAverage( );
CStockInfo & infoWAve = container.GetWeightAverage( );
int iRowAve=0, iRowWAve=0;
if( grid.GetRowCount() >= 3
&& grid.GetItemData(grid.GetRowCount()-2,0) == (LPARAM)ID_STOCKCNTN_AVERAGE
&& grid.GetItemData(grid.GetRowCount()-1,0) == (LPARAM)ID_STOCKCNTN_WEIGHTAVERAGE )
{
// get item id
iRowAve = grid.GetRowCount()-2;
iRowWAve = grid.GetRowCount()-1;
}
else
{
// Insert item
iRowAve = grid.InsertRow( infoAve.GetStockName() );
grid.SetItemData( iRowAve, 0, (LPARAM)ID_STOCKCNTN_AVERAGE );
iRowWAve = grid.InsertRow( infoWAve.GetStockName() );
grid.SetItemData( iRowWAve, 0, (LPARAM)ID_STOCKCNTN_WEIGHTAVERAGE );
}
// Set Average
for( nCol=0; nCol<anParams.GetSize(); nCol++ )
{
grid.SetItemText( iRowAve, nCol, AfxGetVariantDispString(anParams[nCol], infoAve, NULL) );
grid.SetItemBkColour( iRowAve, nCol, AfxGetProfile().GetColor(CColorClass::clrSListBK) );
grid.SetItemFgColour( iRowAve, nCol, AfxGetVariantColor( anParams[nCol], infoAve ) );
}
// Set Weight Average
for( nCol=0; nCol<anParams.GetSize(); nCol++ )
{
grid.SetItemText( iRowWAve, nCol, AfxGetVariantDispString(anParams[nCol], infoWAve, NULL) );
grid.SetItemBkColour( iRowWAve, nCol, AfxGetProfile().GetColor(CColorClass::clrSListBK) );
grid.SetItemFgColour( iRowWAve, nCol, AfxGetVariantColor( anParams[nCol], infoWAve ) );
}
// Set Param which is
// SLH_MARKETVALUE, SLH_MARKETVALUEA, SLH_MARKETVALUEB and etc, and more than SLH_USERDEFINE_BEGIN
for( nCol=0; nCol < anParams.GetSize(); nCol ++ )
{
UINT lParam = anParams[nCol];
if( SLH_DIFF == lParam || SLH_DIFFPERCENT == lParam || SLH_SCOPE == lParam
|| SLH_DIFFPERCENT_MIN5 == lParam || SLH_PE == lParam
|| SLH_PMAININCOME == lParam || SLH_RATIO_PCASH == lParam
|| SLH_RATIO_CURRENCY == lParam || SLH_RATIO_CHANGEHAND == lParam
|| SLH_RATIO_VOLUME == lParam || SLH_RS == lParam
|| SLH_MARKETVALUE == lParam || SLH_MARKETVALUEA == lParam
|| SLH_MARKETVALUEB == lParam || lParam >= SLH_USERDEFINE_BEGIN )
{
double dc = 0., average = 0.;
double wsum = 0.0001, waverage = 0., w = 0.;
for( int iRow=1; iRow<grid.GetRowCount(); iRow++ )
{
if( iRow == iRowAve || iRow == iRowWAve )
continue;
int id = grid.GetItemData(iRow,0);
if( id < 0 || id > container.GetSize() )
continue;
CStockInfo & info = container.ElementAt(id);
w = info.m_fShare_count_total;
double dValue = 0.;
if( !AfxGetVariantValue( lParam, info, &dValue, &container ) )
continue;
average = (average * dc + dValue)/(dc+1);
waverage = (waverage * wsum + dValue * w)/(wsum+w);
dc += 1;
wsum += w;
}
CString strText;
if( SLH_MARKETVALUE == lParam || SLH_MARKETVALUEA == lParam || SLH_MARKETVALUEB == lParam )
{
strText.Format( "%u", (DWORD)average );
grid.SetItemText( iRowAve, nCol, strText );
grid.SetItemText( iRowWAve, nCol, "-" );
}
else
{
//.........这里部分代码省略.........
示例2: OnRclickList
void CPlayerSubresyncBar::OnRclickList(NMHDR* pNMHDR, LRESULT* pResult)
{
LPNMLISTVIEW lpnmlv = (LPNMLISTVIEW)pNMHDR;
if (lpnmlv->iItem >= 0 && lpnmlv->iSubItem >= 0) {
enum {
TOGSEP = 1,
DUPITEM, DELITEM,
RESETS, SETOS, SETCS, RESETE, SETOE, SETCE,
STYLEFIRST, STYLELAST = STYLEFIRST + 1000, STYLEEDIT,
UNICODEYES, UNICODENO,
LAYERDEC, LAYERINC,
ACTORFIRST, ACTORLAST = ACTORFIRST + 1000,
EFFECTFIRST, EFFECTLAST = EFFECTFIRST + 1000
};
CStringArray styles;
CStringArray actors;
CStringArray effects;
CMenu m;
m.CreatePopupMenu();
if (m_mode == VOBSUB || m_mode == TEXTSUB) {
m.AppendMenu(MF_STRING | MF_ENABLED, TOGSEP, ResStr(IDS_SUBRESYNC_SEPARATOR));
m.AppendMenu(MF_SEPARATOR);
if (m_mode == TEXTSUB) {
m.AppendMenu(MF_STRING | MF_ENABLED, DUPITEM, ResStr(IDS_SUBRESYNC_DUPLICATE));
}
m.AppendMenu(MF_STRING | MF_ENABLED, DELITEM, ResStr(IDS_SUBRESYNC_DELETE));
}
switch (lpnmlv->iSubItem) {
case COL_START:
if (m_mode == VOBSUB || m_mode == TEXTSUB) {
m.AppendMenu(MF_SEPARATOR);
m.AppendMenu(MF_STRING | MF_ENABLED, RESETS, ResStr(IDS_SUBRESYNC_RESET) + _T("\tF1"));
m.AppendMenu(MF_STRING | MF_ENABLED, SETOS, ResStr(IDS_SUBRESYNC_ORIGINAL) + _T("\tF3"));
m.AppendMenu(MF_STRING | MF_ENABLED, SETCS, ResStr(IDS_SUBRESYNC_CURRENT) + _T("\tF5"));
}
break;
case COL_END:
if (m_mode == TEXTSUB) {
m.AppendMenu(MF_SEPARATOR);
m.AppendMenu(MF_STRING | MF_ENABLED, RESETE, ResStr(IDS_SUBRESYNC_RESET) + _T("\tF2"));
m.AppendMenu(MF_STRING | MF_ENABLED, SETOE, ResStr(IDS_SUBRESYNC_ORIGINAL) + _T("\tF4"));
m.AppendMenu(MF_STRING | MF_ENABLED, SETCE, ResStr(IDS_SUBRESYNC_CURRENT) + _T("\tF6"));
}
break;
case COL_STYLE:
if (m_mode == TEXTSUB) {
m.AppendMenu(MF_SEPARATOR);
int id = STYLEFIRST;
POSITION pos = m_sts.m_styles.GetStartPosition();
while (pos && id <= STYLELAST) {
CString key;
STSStyle* val;
m_sts.m_styles.GetNextAssoc(pos, key, val);
styles.Add(key);
m.AppendMenu(MF_STRING | MF_ENABLED, id++, key);
}
if (id > STYLEFIRST && m_list.GetSelectedCount() == 1) {
m.AppendMenu(MF_SEPARATOR);
m.AppendMenu(MF_STRING | MF_ENABLED, STYLEEDIT, ResStr(IDS_SUBRESYNC_EDIT));
}
}
break;
case COL_UNICODE:
if (m_mode == TEXTSUB) {
m.AppendMenu(MF_SEPARATOR);
m.AppendMenu(MF_STRING | MF_ENABLED, UNICODEYES, m_strYesMenu);
m.AppendMenu(MF_STRING | MF_ENABLED, UNICODENO, m_strNoMenu);
}
break;
case COL_LAYER:
if (m_mode == TEXTSUB) {
m.AppendMenu(MF_SEPARATOR);
m.AppendMenu(MF_STRING | MF_ENABLED, LAYERDEC, ResStr(IDS_SUBRESYNC_DECREASE));
m.AppendMenu(MF_STRING | MF_ENABLED, LAYERINC, ResStr(IDS_SUBRESYNC_INCREASE));
}
break;
case COL_ACTOR:
if (m_mode == TEXTSUB) {
CMapStringToPtr actormap;
for (size_t i = 0, j = m_sts.GetCount(); i < j; i++) {
actormap[m_sts[i].actor] = nullptr;
}
actormap.RemoveKey(_T(""));
if (!actormap.IsEmpty()) {
m.AppendMenu(MF_SEPARATOR);
int id = ACTORFIRST;
POSITION pos = actormap.GetStartPosition();
//.........这里部分代码省略.........
示例3: ExportList
void CSListView::ExportList( CListExportDlg * pDlg )
{
ASSERT( pDlg );
if( NULL == pDlg )
return;
int nColumnCount = m_Grid.GetColumnCount();
ASSERT( nColumnCount > 0 );
if( nColumnCount <= 0 )
return;
CStockContainer & container = AfxGetSListStockContainer();
// Get Current StockList Time
DWORD dwDate;
CSPTime sptime;
CSPTime time;
if( container.GetCurrentType( NULL, NULL, &dwDate )
&& (-1 != dwDate || container.GetLatestTechDate(&dwDate))
&& sptime.FromStockTimeDay( dwDate ) )
time = CSPTime( sptime.GetTime() );
// Set Column
CStringArray astrColumn;
CUIntArray anWidth;
CUIntArray anParams;
for(int nCol = 0; nCol < nColumnCount; nCol ++ )
{
astrColumn.Add( m_Grid.GetItemText(0,nCol) );
anWidth.Add( m_Grid.GetColumnWidth(nCol) );
anParams.Add( m_Grid.GetItemData(0,nCol) );
}
if( ! pDlg->ExportBegin( astrColumn, anWidth, TRUE )
|| ! pDlg->ExportOpenTable( time, TRUE ) )
return;
container.Lock();
// set Item
int nCount = 0, nTotalCount = 0;
if( pDlg->m_bItemAll )
{
nTotalCount = m_Grid.GetRowCount()-1;
pDlg->SetProgressRange( 0, nTotalCount );
for( int nRow=1; nRow<m_Grid.GetRowCount(); nRow++ )
{
CStringArray astrItemText;
astrItemText.SetSize( 0, nColumnCount+1 );
LPARAM id = m_Grid.GetItemData(nRow,0);
CStockInfo & info = container.GetStockInfoByID(id);
for(nCol=0; nCol<anParams.GetSize(); nCol++ )
{
astrItemText.Add( m_Grid.GetItemText( nRow, nCol ) );
}
pDlg->ExportAddItem( astrItemText );
nCount ++;
pDlg->SetProgress( nCount );
}
}
else if( pDlg->m_bItemSelected )
{
nTotalCount = m_Grid.GetSelectedCount();
pDlg->SetProgressRange( 0, nTotalCount );
for( int nRow=1; nRow<m_Grid.GetRowCount(); nRow++ )
{
BOOL bSelected = FALSE;
for( nCol=0; nCol<m_Grid.GetColumnCount(); nCol ++ )
bSelected |= ( m_Grid.GetItemState(nRow,nCol) & GVIS_SELECTED );
if( !bSelected )
continue;
CStringArray astrItemText;
astrItemText.SetSize( 0, nColumnCount+1 );
LPARAM id = m_Grid.GetItemData(nRow,0);
CStockInfo & info = container.GetStockInfoByID(id);
for(nCol=0; nCol<anParams.GetSize(); nCol++ )
{
astrItemText.Add( m_Grid.GetItemText( nRow, nCol ) );
}
pDlg->ExportAddItem( astrItemText );
nCount ++;
pDlg->SetProgress( nCount );
}
}
else if( pDlg->m_bItemDefine )
{
nTotalCount = min(m_Grid.GetRowCount()-1,pDlg->m_nItemEnd) - max(1,pDlg->m_nItemBegin) + 1;
pDlg->SetProgressRange( 0, nTotalCount );
for( int nRow=max(1,pDlg->m_nItemBegin); nRow<=min(m_Grid.GetRowCount()-1,pDlg->m_nItemEnd); nRow++ )
{
CStringArray astrItemText;
astrItemText.SetSize( 0, nColumnCount+1 );
LPARAM id = m_Grid.GetItemData(nRow,0);
CStockInfo & info = container.GetStockInfoByID(id);
for(nCol=0; nCol<anParams.GetSize(); nCol++ )
{
astrItemText.Add( m_Grid.GetItemText( nRow, nCol ) );
}
//.........这里部分代码省略.........
示例4: LoadToolbox
// 加载Toolbox配置文件
BOOL CVciOwm::LoadToolbox(LPCTSTR lpszToolboxFile)
{
if(GetFileAttributes(lpszToolboxFile) == 0xFFFFFFFF)
{
return FALSE;
}
CXmlParser parser;
if(parser.Open(lpszToolboxFile))
{
DEBUG_OUTF(LOG_LEVEL_ERROR, "Load toolbox file %s fail!", lpszToolboxFile);
return FALSE;
}
CString strImagePath = theApp.GetModulePath();
BOOL bRet = TRUE;
DOMNode* pNode = parser.GetRootNode();
// 加载图片资源
DOMNode* pImageNode = parser.GetChildNode(pNode, "image");
while (pImageNode != NULL)
{
CString strIconFile = strImagePath + "\\" + parser.GetNodeAttribute(pImageNode, "file");
int nImageId = atoi(parser.GetNodeAttribute(pImageNode, "id"));
// 加载单个图片
if(!theApp.SetToolboxIcon(strIconFile, nImageId))
{
bRet = FALSE;
}
pImageNode = parser.GetNextNode(pImageNode, "image");
}
DOMNode* pImageListNode = parser.GetChildNode(pNode, "imagelist");
while (pImageListNode != NULL)
{
CString strBmpFile = strImagePath + "\\" + parser.GetNodeAttribute(pImageListNode, "file");
CString strIDs = parser.GetNodeText(pImageListNode);
CUIntArray auID;
int nPos = strIDs.Find(",");
while(nPos != -1)
{
auID.Add(atoi(strIDs.Left(nPos)));
strIDs.Delete(0, nPos+1);
nPos = strIDs.Find(",");
}
auID.Add(atoi(strIDs));
// 加载图片列表
if(!theApp.SetToolboxIcons(strBmpFile, &auID))
{
bRet = FALSE;
}
pImageListNode = parser.GetNextNode(pImageListNode, "imagelist");
}
// 加载控件组和控件
DOMNode* pGroupNode = parser.GetChildNode(pNode, "group");
while (pGroupNode != NULL)
{
CString strGroupName = parser.GetNodeAttribute(pGroupNode, "name");
int nGroupId = atoi(parser.GetNodeAttribute(pGroupNode, "id"));
BOOL bExpand = (parser.GetNodeAttribute(pGroupNode, "expand") == "true");
CXTPTaskPanelGroup* pFolderClass = theApp.CreateToolboxGroup(nGroupId, strGroupName);
// 加载控件
DOMNode* pItemNode = parser.GetChildNode(pGroupNode, "control");
while (pItemNode != NULL)
{
CString strControlName = parser.GetNodeAttribute(pItemNode, "name");
int nControlImageId = atoi(parser.GetNodeAttribute(pItemNode, "image-id"));
CXTPTaskPanelGroupItem* pItem = pFolderClass->AddLinkItem(nControlImageId, nControlImageId);
pItem->SetCaption(theApp.StripMnemonics(strControlName));
pItemNode = parser.GetNextNode(pItemNode, "control");
}
pFolderClass->SetExpanded(bExpand);
pGroupNode = parser.GetNextNode(pGroupNode, "group");
}
parser.Close();
return TRUE;
}
示例5: SelectBlock
void CXTPReportSelectedRows::SelectBlock(int nBlockBegin, int nEnd, BOOL bControlKey)
{
CXTPReportRows* pRows;
switch(m_nRowType)
{
case xtpRowTypeHeader : pRows = m_pControl->GetHeaderRows(); break;
case xtpRowTypeFooter : pRows = m_pControl->GetFooterRows(); break;
default : pRows = m_pControl->GetRows(); break;
}
int nRowsCount(0);
if (pRows)
nRowsCount = pRows->GetCount();
BOOL bGo = (nBlockBegin >= 0 && nBlockBegin < nRowsCount && nEnd < nRowsCount);
if (!bGo)
{
Clear(GetNotifyOnSelectedRowsClear());
return;
}
if (bControlKey == FALSE)
{
nBlockBegin = m_nRowBlockBegin != -1 ? m_nRowBlockBegin : nBlockBegin;
int nBegin = nBlockBegin;
if (nBegin == -1 || nEnd == -1)
return;
if (nBegin > nEnd)
{
nBegin = nEnd;
nEnd = nBlockBegin;
}
if (m_arrSelectedBlocks.GetSize() == 1 && m_arrSelectedBlocks[0].nIndexBegin == nBegin &&
m_arrSelectedBlocks[0].nIndexEnd == nEnd + 1)
{
return;
}
XTPReportRowType nRowType = m_nRowType;
Clear(GetNotifyOnSelectedRowsClear());
m_nRowType = nRowType;
if (m_nRowBlockBegin == -1) m_nRowBlockBegin = nBlockBegin;
BOOL bSkipGroupFocus = m_pControl->IsSkipGroupsFocusEnabled();
BOOL bHasGroups = m_pControl->GetColumns()->GetGroupsOrder()->GetCount() != 0;
if (!bHasGroups || !bSkipGroupFocus)
{
_InsertBlock(0, nBegin, nEnd + 1);
}
else
{
for (int i = nBegin; i <= nEnd; i++)
{
CXTPReportRow* pRow = pRows->GetAt(i);
if (!pRow)
continue;
if (!bSkipGroupFocus || !pRow->IsGroupRow() || !pRow->IsExpanded() || (i == nBegin) || (i == nEnd))
{
Add(pRow);
}
}
}
// notify owner the selection state has changed.
_NotifyStateChanged(nBegin, nEnd);
}
else
{
int kSB = (int) m_arrSelectedBlocks.GetSize();
if (kSB > 0)
{
int iMin = m_arrSelectedBlocks[0].nIndexBegin;
int iMax = m_arrSelectedBlocks[kSB - 1].nIndexEnd;
if (nEnd >= iMin && nEnd < iMax)
{
return;
}
}
BOOL bSkipGroupFocus = FALSE;//m_pControl->IsSkipGroupsFocusEnabled();
BOOL bHasGroups = m_pControl->GetColumns()->GetGroupsOrder()->GetCount() != 0;
BOOL bWasShiftKey = m_pControl->m_bWasShiftKey;
if (m_nRowBlockBegin != -1)
nBlockBegin = m_nRowBlockBegin;
int nBegin(nBlockBegin), iB, iE;
if (nBegin == -1 || nEnd == -1)
{
return;
}
BOOL bSwap = SwapIfNeed(nBegin, nEnd);
int nArSz = (int) m_arrSelectedBlocks.GetSize();
CUIntArray ar;
if (nArSz > 0)
{
//.........这里部分代码省略.........
示例6: toolThreadProc
//.........这里部分代码省略.........
}
if (!drank && (self->hp < self->maxHp && self->hp < hpBelow && config->drinkHp))
{
drank |= tryDrinking(CTibiaItem::getValueForConst("fluid"), 11, config->drinkHp, config->useHotkey, hpBelow, -1);
if (drank)
RandomVariableHp(config->hpBelow, MAKE, config, self);
}
if (!drank && (self->hp < self->maxHp && self->hp < customItem1Below && config->customItem1Use))
{
drank |= tryDrinking(config->customItem1Item, 0, config->customItem1Use, config->useHotkey, customItem1Below, -1);
if (drank)
RandomVariableHp(config->customItem1Below, MAKE, config, self);
}
if (!drank && (self->mana < self->maxMana && self->mana < manaBelowG && config->drinkManaG) && self->lvl >= 80)
{
drank |= tryDrinking(CTibiaItem::getValueForConst("fluidManaG"), 0, config->drinkManaG, config->useHotkey, -1, manaBelowG);
if (drank)
RandomVariableMana(config->manaBelowG, MAKE, config, self);
}
if (!drank && (self->mana < self->maxMana && self->mana < manaBelowS && config->drinkManaS) && self->lvl >= 50)
{
drank |= tryDrinking(CTibiaItem::getValueForConst("fluidManaS"), 0, config->drinkManaS, config->useHotkey, -1, manaBelowS);
if (drank)
RandomVariableMana(config->manaBelowS, MAKE, config, self);
}
if (!drank && (self->mana < self->maxMana && self->mana < manaBelowN && config->drinkManaN))
{
drank |= tryDrinking(CTibiaItem::getValueForConst("fluidMana"), 0, config->drinkManaN, config->useHotkey, -1, manaBelowN);
if (drank)
RandomVariableMana(config->manaBelowN, MAKE, config, self);
}
if (!drank && (self->mana < self->maxMana && self->mana < manaBelow && config->drinkMana))
{
drank |= tryDrinking(CTibiaItem::getValueForConst("fluid"), 10, config->drinkMana, config->useHotkey, -1, manaBelow);
if (drank)
RandomVariableMana(config->manaBelow, MAKE, config, self);
}
if (!drank && (self->mana < self->maxMana && self->mana < customItem2Below && config->customItem2Use))
{
drank |= tryDrinking(config->customItem2Item, 0, config->customItem2Use, config->useHotkey, -1, customItem2Below);
if (drank)
RandomVariableMana(config->customItem2Below, MAKE, config, self);
}
if (drank)
{
int stopSleepTime = reader.getCurrentTm() + CModuleUtil::randomFormula(config->sleep, 200, config->sleep);
while (reader.getCurrentTm() < stopSleepTime)
{
Sleep(50);
}
}
if (config->dropEmpty)
{
CUIntArray itemArray;
itemArray.Add(CTibiaItem::getValueForConst("fluid"));
itemArray.Add(CTibiaItem::getValueForConst("fluidEmpty"));
itemArray.Add(CTibiaItem::getValueForConst("fluidEmptyS"));
itemArray.Add(CTibiaItem::getValueForConst("fluidEmptyG"));
int contNr;
int openContNr = 0;
int openContMax = reader.readOpenContainerCount();
for (contNr = 0; contNr < reader.m_memMaxContainers && openContNr < openContMax; contNr++)
{
CTibiaContainer *cont = reader.readContainer(contNr);
if (cont->flagOnOff)
{
openContNr++;
CTibiaItem *item = CModuleUtil::lookupItem(contNr, &itemArray);
if (item->objectId)
{
CPackSender::moveObjectFromContainerToFloor(item->objectId, 0x40 + contNr, item->pos, self->x, self->y, self->z, item->quantity ? item->quantity : 1);
Sleep(CModuleUtil::randomFormula(config->sleep, 200, 0));
delete item;
delete cont;
break;
}
delete item;
}
delete cont;
}
}
delete self;
}
setMana.clear();
setHp.clear();
toolThreadShouldStop = 0;
drinkFails = 0;
return 0;
}
示例7: tryDrinking
int tryDrinking(int itemId, int itemType, int drink, int hotkey, int hpBelow, int manaBelow)
{
CMemReader& reader = CMemReader::getMemReader();
int contNr;
CUIntArray itemArray;
int drank = 0;
itemArray.Add(itemId);
CTibiaCharacter *self = reader.readSelfCharacter();
if (hotkey)
{
CPackSender::useItemOnCreature(itemId, self->tibiaId);
if (CModuleUtil::waitForHpManaIncrease(self->hp, self->mana))//most likely using item succeeded
{
drank = 1;
drinkFails = 0;
}
else
{
drinkFails += 1;
drinkFails = (drinkFails > MAX_DRINK_FAILS) ? 1 : drinkFails;
}
}
else
{
int openContNr = 0;
int openContMax = reader.readOpenContainerCount();
for (contNr = 0; contNr < reader.m_memMaxContainers && openContNr < openContMax; contNr++)
{
CTibiaContainer *cont = reader.readContainer(contNr);
if (cont->flagOnOff)
{
openContNr++;
CTibiaItem *item;
if (itemType)
item = CModuleUtil::lookupItem(contNr, &itemArray, itemType);
else
item = CModuleUtil::lookupItem(contNr, &itemArray);
if (item->objectId)
{
if ((self->hp < hpBelow || hpBelow == -1) && (self->mana < manaBelow || manaBelow == -1) && drink)
{
CPackSender::useItemFromContainerOnCreature(itemId, 0x40 + contNr, item->pos, self->tibiaId);
drank = 1;
drinkFails = 0;
}
delete item;
break;
}
delete item;
}
delete cont;
}
}
delete self;
return drank;
}
示例8: EnumerateSerialPorts
void EnumerateSerialPorts(CUIntArray& ports)
{
//Make sure we clear out any elements which may already be in the array
ports.RemoveAll();
//Determine what OS we are running on
OSVERSIONINFO osvi;
osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
BOOL bGetVer = GetVersionEx(&osvi);
//On NT use the QueryDosDevice API
if (bGetVer && (osvi.dwPlatformId == VER_PLATFORM_WIN32_NT))
{
//Use QueryDosDevice to look for all devices of the form COMx. This is a better
//solution as it means that no ports have to be opened at all.
TCHAR szDevices[65535];
DWORD dwChars = QueryDosDevice(NULL, szDevices, 65535);
if (dwChars)
{
int i=0;
for (;;)
{
//Get the current device name
TCHAR* pszCurrentDevice = &szDevices[i];
//If it looks like "COMX" then
//add it to the array which will be returned
int nLen = _tcslen(pszCurrentDevice);
if (nLen > 3 && _tcsnicmp(pszCurrentDevice, _T("COM"), 3) == 0)
{
//Work out the port number
int nPort = _ttoi(&pszCurrentDevice[3]);
ports.Add(nPort);
}
// Go to next NULL character
while(szDevices[i] != _T('\0'))
i++;
// Bump pointer to the next string
i++;
// The list is double-NULL terminated, so if the character is
// now NULL, we're at the end
if (szDevices[i] == _T('\0'))
break;
}
}
else
TRACE(_T("Failed in call to QueryDosDevice, GetLastError:%d\n"), GetLastError());
}
else
{
//On 95/98 open up each port to determine their existence
//Up to 255 COM ports are supported so we iterate through all of them seeing
//if we can open them or if we fail to open them, get an access denied or general error error.
//Both of these cases indicate that there is a COM port at that number.
for (UINT i=1; i<256; i++)
{
//Form the Raw device name
CString sPort;
sPort.Format(_T("\\\\.\\COM%d"), i);
//Try to open the port
BOOL bSuccess = FALSE;
HANDLE hPort = ::CreateFile(sPort, GENERIC_READ | GENERIC_WRITE, 0, 0, OPEN_EXISTING, 0, 0);
if (hPort == INVALID_HANDLE_VALUE)
{
DWORD dwError = GetLastError();
//Check to see if the error was because some other app had the port open or a general failure
if (dwError == ERROR_ACCESS_DENIED || dwError == ERROR_GEN_FAILURE)
bSuccess = TRUE;
}
else
{
//The port was opened successfully
bSuccess = TRUE;
//Don't forget to close the port, since we are going to do nothing with it anyway
CloseHandle(hPort);
}
//Add the port number to the array which will be returned
if (bSuccess)
ports.Add(i);
}
}
}
示例9: OnUpdate
void CSListView::OnUpdate(CView* pSender, LPARAM lHint, CObject* pHint)
{
// TODO: Add your specialized code here and/or call the base class
if( UPDATE_HINT_SLISTVIEW != lHint )
return;
if( IsWindowVisible() )
SetFocus( );
int nColumnCount = m_Grid.GetColumnCount();
if( nColumnCount <= 0 )
return;
if( GetParentFrame()->GetSafeHwnd() != AfxGetMainFrame()->GetActiveFrame()->GetSafeHwnd() )
{
m_bShouldUpdate = TRUE;
return;
}
m_bShouldUpdate = FALSE;
CStockContainer & container = AfxGetSListStockContainer();
container.Lock();
m_Grid.DeleteNonFixedRows();
// Progress
CMainFrame * pMainFrame = AfxGetMainFrame();
if( pMainFrame )
{
pMainFrame->ShowProgressBar( );
pMainFrame->SetProgress( 0 );
pMainFrame->SetMessageText( IDS_MAINFRAME_WAITING );
}
CUIntArray anParams;
anParams.SetSize( 0, nColumnCount );
for( int nCol=0; nCol < nColumnCount; nCol ++ )
{
LPARAM lParam = m_Grid.GetItemData( 0, nCol );
anParams.Add( lParam );
}
CRect rectClient;
GetClientRect( &rectClient );
int nPageCount = 1 + rectClient.Height() / abs(m_Grid.GetFixedRowHeight()) + 1;
for( int i=0; i<container.GetSize(); i++ )
{
CStockInfo & info = container.GetStockInfoByID(i);
int nRow = m_Grid.InsertRow( info.GetStockName() );
m_Grid.SetItemData( nRow, 0, i );
for( int nCol=0; nCol<anParams.GetSize(); nCol++ )
{
m_Grid.SetItemFormat( nRow, nCol, DT_CENTER|DT_VCENTER|DT_SINGLELINE );
m_Grid.SetItemText( nRow, nCol, AfxGetVariantDispString( anParams[nCol], info, &container ) );
m_Grid.SetItemBkColour( nRow, nCol, AfxGetProfile().GetColor(CColorClass::clrSListBK) );
m_Grid.SetItemFgColour( nRow, nCol, AfxGetVariantColor( anParams[nCol], info ) );
if( anParams[nCol] == SLH_DATE )
m_Grid.SetColumnWidth( nCol, 80 );
if( anParams[nCol] == SLH_CODE )
m_Grid.SetColumnWidth( nCol, 60 );
}
if( i == nPageCount+5 )
{
m_Grid.Invalidate( );
MSG msg;
while (::PeekMessage(&msg, NULL, NULL, NULL, PM_NOREMOVE) )
AfxGetApp()->PumpMessage();
}
if( pMainFrame )
pMainFrame->SetProgress( 100*i/container.GetSize() );
}
// Set Average and Weight Average
// SetAverageItem( m_Grid, container, FALSE );
// Sort If Needed
if( -1 != m_nColSort )
{
LPARAM lParam = m_Grid.GetItemData( 0, m_nColSort );
if( lParam >= 0 )
{
CStockContainer::m_pSortContainer = &container;
container.m_nSortVariantID = lParam;
container.m_bSortAscend = m_bSortAscend;
m_Grid.SortItems( ItemCompareFunc, 0, TRUE );
}
}
if( pMainFrame )
{
pMainFrame->SetProgress( 100 );
pMainFrame->HideProgressBar( );
pMainFrame->SetMessageText( IDS_MAINFRAME_FINISHED );
pMainFrame->SetMessageText( IDS_HELPTIP_SLIST );
}
if( m_bFirstUpdate )
m_Grid.AutoSizeColumns( );
//.........这里部分代码省略.........
示例10: toolThreadProc
DWORD WINAPI toolThreadProc(LPVOID lpParam)
{
CConfigData *config = (CConfigData *)lpParam;
CMemReader& reader = CMemReader::getMemReader();
CUIntArray acceptedItems;
int uhFallbackNeeded = 0;
int grpUhFallbackNeeded = 0;
int i;
while (!toolThreadShouldStop)
{
Sleep(200);
if (!reader.isLoggedIn())
continue; // do not proceed if not connected
CTibiaCharacter *self = reader.readSelfCharacter();
if (self->hp <= config->m_uhBorderline || config->m_hotkeySelf)
{
int uhContainer;
acceptedItems.RemoveAll();
if (!uhFallbackNeeded)
{
switch (config->m_runetype)
{
case 0:
acceptedItems.Add(CTibiaItem::getValueForConst("runeUH"));
break;
case 1:
acceptedItems.Add(CTibiaItem::getValueForConst("runeIH"));
break;
}
}
else
{
acceptedItems.Add(CTibiaItem::getValueForConst("runeUH"));
acceptedItems.Add(CTibiaItem::getValueForConst("runeIH"));
uhFallbackNeeded = 0;
}
CTibiaItem *uhItem = new CTibiaItem();
uhContainer = -1;
int contNr;
int openContNr = 0;
int openContMax = reader.readOpenContainerCount();
for (contNr = 0; contNr < reader.m_memMaxContainers && !uhItem->objectId && openContNr < openContMax; contNr++)
{
CTibiaContainer *cont = reader.readContainer(contNr);
if (cont->flagOnOff)
{
openContNr++;
delete uhItem;
uhItem = CModuleUtil::lookupItem(contNr, &acceptedItems);
uhContainer = contNr;
};
delete cont;
}
if (uhItem->objectId)
{
CVariableStore::setVariable("UH_needed", "true");
if (self->hp <= config->m_uhBorderline)
{
CPackSender::useWithObjectFromContainerOnFloor(
uhItem->objectId, 0x40 + uhContainer, uhItem->pos, 0x63,
self->x, self->y, self->z);
Sleep(config->m_sleepAfter);
}
if (config->m_hotkeySelf)
{
CPackSender::useWithObjectFromContainerOnFloor(
uhItem->objectId, 0x40 + uhContainer, uhItem->pos, 0x63,
self->x, self->y, self->z, 105);
}
}
else
{
if (config->m_fallback)
uhFallbackNeeded = 1;
}
delete uhItem;
}
else
{
CVariableStore::setVariable("UH_needed", "false");
}
// grp heal
int crNr;
for (crNr = 0; crNr < reader.m_memMaxCreatures; crNr++)
//.........这里部分代码省略.........