bool TfrmMove::canAssign() { if( SampleTree -> Selected == NULL || AvlTree -> Selected == NULL ) { return false; } IPart* leftData = (IPart *)(SampleTree -> Selected -> Data); IPart* rightData = (IPart *)(AvlTree -> Selected -> Data); return leftData != NULL && getImageIndex( leftData ) == Util::UNASSIGNED && rightData != NULL && getImageIndex( rightData ) != Util::ASSIGNED && rightData->getType() > IPart::LayoutType; }
BOOL CSearchDlg::OnInitDialog () { CDialog::OnInitDialog (); mode[0].Attach (GetDlgItem (IDC_PMODE1)->m_hWnd); mode[1].Attach (GetDlgItem (IDC_PMODE2)->m_hWnd); mode[2].Attach (GetDlgItem (IDC_PMODE3)->m_hWnd); mode[3].Attach (GetDlgItem (IDC_PMODE4)->m_hWnd); mode[4].Attach (GetDlgItem (IDC_PMODE5)->m_hWnd); mode[BOX_FILE].Attach (GetDlgItem (IDC_FFUNC)->m_hWnd); mode[BOX_NAME].Attach (GetDlgItem (IDC_NFUNC)->m_hWnd); mode[BOX_MODE].Attach (GetDlgItem (IDC_MFUNC)->m_hWnd); hero[0].Attach (GetDlgItem (IDC_PHERO1)->m_hWnd); hero[1].Attach (GetDlgItem (IDC_PHERO2)->m_hWnd); hero[2].Attach (GetDlgItem (IDC_PHERO3)->m_hWnd); hero[3].Attach (GetDlgItem (IDC_PHERO4)->m_hWnd); hero[4].Attach (GetDlgItem (IDC_PHERO5)->m_hWnd); dfrom.Attach (GetDlgItem (IDC_SAVEDA)->m_hWnd); dto.Attach (GetDlgItem (IDC_SAVEDB)->m_hWnd); lfrom.Attach (GetDlgItem (IDC_LENGTHA)->m_hWnd); lto.Attach (GetDlgItem (IDC_LENGTHB)->m_hWnd); for (int i = 0; i < 8; i++) mode[i].SetCurSel (0); dfrom.SetTime (&CTime (1971, 1, 1, 0, 0, 0)); dto.SetTime (&CTime::GetCurrentTime ()); lfrom.SetTime (&CTime (2000, 1, 1, 0, 0, 0)); lto.SetTime (&CTime (2000, 1, 1, 23, 59, 59)); for (int i = 0; i < 5; i++) { hero[i].SetImageList (getImageList ()); int cur = 0; int cnt = getNumHeroes (); hero[i].InsertItem ("Any hero", getImageIndex ("Unknown")); for (int j = 0; j < getNumTaverns (); j++) { DotaTavern* tavern = getTavern (j); hero[i].InsertItem (tavern->name, getImageIndex (tavern->side == 0 ? "RedBullet" : "GreenBullet"), 0, -1); for (int cur = 0; cur < getNumHeroes (); cur++) { DotaHero* h = getHero (cur); if (h->tavern == j) hero[i].InsertItem (h->name, getImageIndex (h->imgTag), RGB (255, 255, 255), h->point); } } selhero[i] = 0; hero[i].SetCurSel (0); } return TRUE; }
void Toolbar::updateAction( unsigned int& index, ItemPtr item, TBBUTTONINFO& info ) { unsigned int mask = BTNS_SEP | BTNS_CHECK | BTNS_GROUP | BTNS_CHECKGROUP | BTNS_DROPDOWN; if( ( info.fsStyle & mask ) != 0 || // not a push button info.idCommand != item->commandID() ) // not for me { TBBUTTON button; memset( &button, 0, sizeof(button) ); button.iBitmap = getImageIndex( item ); button.idCommand = item->commandID(); button.fsState = TBSTATE_ENABLED; button.fsStyle = BTNS_BUTTON; button.dwData = 0; button.iString = -1; sendMessage( TB_INSERTBUTTON, index, (LPARAM)&button ); } TBBUTTONINFO buttonInfo = { sizeof( buttonInfo ), TBIF_TEXT | TBIF_BYINDEX | TBIF_STATE }; std::string tooltip = item->description(); // auto tooltip if( item->shortcutKey().size() ) { tooltip += " ("; tooltip += item->shortcutKey(); tooltip += ')'; } buttonInfo.pszText = &tooltip[0]; buttonInfo.fsState = item->update() && isEnabled() ? TBSTATE_ENABLED : 0; if ( sendMessage( WM_CGUITOOLBAR_USE_WRAP, 0, 0 ) && ( info.fsState & TBSTATE_WRAP ) ) buttonInfo.fsState |= TBSTATE_WRAP; if( forceChanged_ || info.pszText != tooltip || info.fsState != buttonInfo.fsState ) sendMessage( TB_SETBUTTONINFO, index, (LPARAM)&buttonInfo ); }
void CActionsDlg::setReplay (W3GReplay* replay) { w3g = replay; actions.setReplay (replay); history->setReplay (replay); selPlayer.Reset (); hkeys.DeleteAllItems (); for (int i = 0; i < NUM_ACTIONS; i++) actions.SetItemText (i, 1, ""); if (w3g && w3g->dota.isDota) { selPlayer.EnableWindow (TRUE); if (w3g->dota.numSentinel) selPlayer.InsertItem ("Sentinel", getImageIndex ("RedBullet"), 0); for (int i = 0; i < w3g->dota.numSentinel; i++) { if (w3g->players[w3g->dota.sentinel[i]].hero) selPlayer.InsertItem (wmprintf (L"%s (%s)", w3g->players[w3g->dota.sentinel[i]].uname, makeucd (getHero (w3g->players[w3g->dota.sentinel[i]].hero->id)->name)), getImageIndex (getHero (w3g->players[w3g->dota.sentinel[i]].hero->id)->imgTag), getLightColor (w3g->players[w3g->dota.sentinel[i]].slot.color), w3g->dota.sentinel[i]); else selPlayer.InsertItem (wmprintf (L"%s (No Hero)", w3g->players[w3g->dota.sentinel[i]].uname), getImageIndex ("Empty"), getLightColor (w3g->players[w3g->dota.sentinel[i]].slot.color), w3g->dota.sentinel[i]); } if (w3g->dota.numScourge) selPlayer.InsertItem ("Scourge", getImageIndex ("GreenBullet"), 0); for (int i = 0; i < w3g->dota.numScourge; i++) { if (w3g->players[w3g->dota.scourge[i]].hero) selPlayer.InsertItem (wmprintf (L"%s (%s)", w3g->players[w3g->dota.scourge[i]].uname, makeucd (getHero (w3g->players[w3g->dota.scourge[i]].hero->id)->name)), getImageIndex (getHero (w3g->players[w3g->dota.scourge[i]].hero->id)->imgTag), getLightColor (w3g->players[w3g->dota.scourge[i]].slot.color), w3g->dota.scourge[i]); else selPlayer.InsertItem (wmprintf (L"%s (No Hero)", w3g->players[w3g->dota.scourge[i]].uname), getImageIndex ("Empty"), getLightColor (w3g->players[w3g->dota.scourge[i]].slot.color), w3g->dota.scourge[i]); } selPlayer.SetCurSel (1); OnCbnSelchangeSelplayer (); } else if (w3g) { selPlayer.EnableWindow (TRUE); for (int i = 0; i < w3g->numPlayers; i++) selPlayer.InsertItem (w3g->players[w3g->pindex[i]].uname, getImageIndex (raceImage[w3g->players[w3g->pindex[i]].race]), getLightColor (w3g->players[w3g->pindex[i]].slot.color), w3g->pindex[i]); selPlayer.SetCurSel (0); OnCbnSelchangeSelplayer (); } else selPlayer.EnableWindow (FALSE); }
ImageIndexInfo ResourceImageSet::getIndexInfo(size_t _group, const std::string & _index) { if (_group < mGroups.size()) { GroupImage & group = mGroups[_group]; size_t index_image = getImageIndex(group, _index); if (index_image != ITEM_NONE) { IndexImage & index = group.indexes[index_image]; return ImageIndexInfo(group.texture, group.size, index.rate, index.frames); } } return ImageIndexInfo(mTextureEmpty, mSizeEmpty, 0, mFramesEmpty); }
bool TfrmMove::anyBoxes( IPart * parent, Util::IconType type ) { if( parent -> getType() == IPart::BoxType ) { return getImageIndex( parent ) == type; } const std::vector<IPart*> & list = parent -> getList(); for( std::vector<IPart*>::const_iterator li = list.begin(); li != list.end(); ++ li ) { if( anyBoxes( *li, type ) ) { return true; } } return false; }
ImageIndexInfo ResourceImageSet::getIndexInfo(const std::string& _group, const std::string& _index) { size_t index_group = getGroupIndex(_group); if (index_group != ITEM_NONE) { GroupImage& group = mGroups[index_group]; size_t index_image = getImageIndex(group, _index); if (index_image != ITEM_NONE) { IndexImage& index = group.indexes[index_image]; return ImageIndexInfo(group.texture, group.size, index.rate, index.frames); } } return ImageIndexInfo(Constants::getEmptyString(), Constants::getZeroIntSize(), 0, mFramesEmpty); }
int TfrmMove::getImageIndex( TTreeNode *node ) { if( node == NULL ) { return Util::UNASSIGNED; } IPart* data = (IPart*)(node -> Data); if( data == NULL ) { return Util::UNASSIGNED; } Layout* lay = dynamic_cast<Layout*>( data ); if( lay != NULL && lay->availability() == IPart::UNAVAILABLE ) { return Util::OFF_LINE; } int image = getImageIndex( data ); if( image == Util::ASSIGNED ) { return image; } float fill = -1; AvlRack * ar = dynamic_cast< AvlRack *>( data ); if( ar ) { fill = ar -> getFillFactor(); } else { AvlSection * as = dynamic_cast< AvlSection *>( data ); if( as ) { fill = as -> getFillFactor(); } else { AvlTank * at = dynamic_cast< AvlTank *>( data ); if( at ) { fill = at -> getFillFactor(); } } } if( fill < 0 ) { return image; } else if( fill < 0.01 ) { return Util::NO_CHILDREN; } else if( fill > 0.98 ) { return Util::ALL_FILLED; } else { return Util::PART_FILLED; } }
void CPlayerStatsDlg::refill () { games.DeleteAllItems (); for (int i = 0; i < items.getSize (); i++) items[i].curpos = sortUp ? -i : i; qsort (items.ptr (), items.getSize (), sizeof (StatsItem), itemCompare); for (int i = 0; i < items.getSize (); i++) { StatsItem* item = &items[i]; DotaHero* hero = getHeroByPoint (item->hero); int pos = games.InsertItem (games.GetItemCount (), hero ? hero->name : "No hero", getImageIndex (hero ? hero->imgTag : "Empty")); games.SetItemData (pos, i); if (item->kills >= 0 && item->deaths >= 0) games.SetItemText (pos, COL_KD, mprintf ("%d-%d", item->kills, item->deaths)); if (item->creeps >= 0 && item->denies >= 0) games.SetItemText (pos, COL_CS, mprintf ("%d/%d", item->creeps, item->denies)); games.SetItemText (pos, COL_GOLD, mprintf ("%d", item->gold)); games.SetItemText (pos, COL_AGOLD, mprintf ("%d", item->agold)); if (item->lvl > 0) games.SetItemText (pos, COL_LVL, mprintf ("%d", item->lvl)); if (item->alvl > 0) games.SetItemText (pos, COL_ALVL, mprintf ("%d", item->alvl)); if (item->score[0] > 0 || item->score[1] > 0) games.SetItemText (pos, COL_SCORE, mprintf ("%d/%d", item->score[0], item->score[1])); if (item->left >= item->time) games.SetItemText (pos, COL_LEFT, "End"); else games.SetItemText (pos, COL_LEFT, format_time (item->left, TIME_HOURS | TIME_SECONDS)); games.SetItemText (pos, COL_LENGTH, format_time (item->time, TIME_HOURS | TIME_SECONDS)); games.SetItemText (pos, COL_APM, mprintf ("%d", item->apm)); LVSetItemText (games, pos, COL_NAME, item->name); games.SetItemText (pos, COL_DATE, CTime (item->date).Format ("%d/%m/%Y %H:%M")); games.SetItemText (pos, COL_LANE, laneTypes[item->lane]); games.SetItemText (pos, COL_RESULT, resTypes[item->res]); } for (int i = 0; i < NUM_COLS; i++) games.SetColumnWidth (i, LVSCW_AUTOSIZE_USEHEADER); }
int TfrmMove::getImageIndex( IPart *data ) { if( data->getType() == IPart::SitesType ) { return Util::SITE_LIST; } else if( data->getType() == IPart::SiteType ) { return Util::SITE; } Box * b = dynamic_cast<Box*>( data ); if( b ) { if( b->isLHSDone() || b->isRHSDone() ) { return Util::AVAILABLE; } if( b->isLHSAssigned() || b->isRHSAssigned() ) { return Util::ASSIGNED; /* int jobID = createNewJob ? 0 : job.getID(); return b->getRetrievalCID() == jobID ? Util::ASSIGNED : Util::OFF_LINE; */ } } int children = data->getChildCount(); if( children == 0 ) { return Util::NO_CHILDREN; } else if( children < 0 ) { return Util::UNASSIGNED; } int min = Util::AVAILABLE; for( IPart * li : data->getList() ) { int it = getImageIndex( li ); if( it < min ) { min = it; } } return min; }
void Toolbar::updateToggle( unsigned int& index, ItemPtr item, TBBUTTONINFO& info ) { if( ( info.fsStyle & BTNS_CHECK ) == 0 || // not a toggle button info.idCommand != item->commandID() ) // not for me { TBBUTTON button; memset( &button, 0, sizeof(button) ); button.iBitmap = getImageIndex( item ); button.idCommand = item->commandID(); button.fsState = TBSTATE_ENABLED; button.fsStyle = BTNS_CHECK; button.dwData = (DWORD)item.getObject(); button.iString = -1; sendMessage( TB_INSERTBUTTON, index, (LPARAM)&button ); } TBBUTTONINFO buttonInfo = { sizeof( buttonInfo ), TBIF_TEXT | TBIF_BYINDEX | TBIF_STATE }; std::string tooltip = item->description(); // auto tooltip if( item->shortcutKey().size() ) { tooltip += " ("; tooltip += item->shortcutKey(); tooltip += ')'; } buttonInfo.pszText = &tooltip[0]; LPARAM enabled = item->update() && isEnabled() ? TBSTATE_ENABLED : 0; LPARAM checked = ( *item )[ 0 ]->update() ? 0 : TBSTATE_CHECKED; if( !enabled ) checked = 0; buttonInfo.fsState = (BYTE)( enabled | checked ); if ( sendMessage( WM_CGUITOOLBAR_USE_WRAP, 0, 0 ) && ( info.fsState & TBSTATE_WRAP ) ) buttonInfo.fsState |= TBSTATE_WRAP; if( forceChanged_ || info.pszText != tooltip || info.fsState != buttonInfo.fsState ) sendMessage( TB_SETBUTTONINFO, index, (LPARAM)&buttonInfo ); }
void CDraftDlg::setReplay (W3GReplay* tw3g) { w3g = tw3g; draftPool.DeleteAllItems (); draftBans.DeleteAllItems (); draftPicks.DeleteAllItems (); draftPool.EnableWindow (FALSE); draftBans.EnableWindow (FALSE); draftPicks.EnableWindow (FALSE); if (w3g && w3g->dota.isDota) { DraftData* draft = &(w3g->game.draft); if (draft->numPool) { draftPool.EnableWindow (TRUE); for (int i = 0; i < draft->numPool; i++) { DotaHero* hero = getHero (draft->pool[i]); int pos = draftPool.InsertItem (i, hero->abbr, getImageIndex (hero->imgTag)); draftPool.SetItemData (pos, (DWORD_PTR) (i & 1 ? 0xFFEEEE : 0xFFFFFF)); } } if (draft->numPicks[0] || draft->numPicks[1] || draft->numBans[0] || draft->numBans[1]) { int seCapt = w3g->getCaptain (1); int scCapt = w3g->getCaptain (2); wchar_t fmt[512]; if (seCapt >= 0) { swprintf (fmt, sizeof fmt, L"Sentinel captain: %s", w3g->players[seCapt].uname); SetDlgItemTextW (m_hWnd, IDC_SENTINEL_TIP, fmt); GetDlgItem (IDC_SENTINEL_TIP)->ShowWindow (SW_SHOW); } else GetDlgItem (IDC_SENTINEL_TIP)->ShowWindow (SW_HIDE); if (scCapt >= 0) { swprintf (fmt, sizeof fmt, L"Scourge captain: %s", w3g->players[scCapt].uname); SetDlgItemTextW (m_hWnd, IDC_SCOURGE_TIP, fmt); GetDlgItem (IDC_SCOURGE_TIP)->ShowWindow (SW_SHOW); } else GetDlgItem (IDC_SCOURGE_TIP)->ShowWindow (SW_HIDE); } DWORD colors[2] = {getLightColor (0), getLightColor (6)}; if (draft->numBans[0] || draft->numBans[1]) { draftBans.EnableWindow (TRUE); int cur = draft->firstPick - 1; int ptr[2] = {0, 0}; while (ptr[0] < draft->numBans[0] || ptr[1] < draft->numBans[1]) { if (ptr[cur] < draft->numBans[cur]) { DotaHero* hero = getHero (draft->bans[cur][ptr[cur]++]); int pos = draftBans.InsertItem (draftBans.GetItemCount (), hero->abbr, getImageIndex (hero->imgTag)); draftBans.SetItemData (pos, colors[cur]); } cur = 1 - cur; } } if (draft->numPicks[0] || draft->numPicks[1]) { draftPicks.EnableWindow (TRUE); int cur = draft->firstPick - 1; int mod = 1; int ptr[2] = {0, 0}; while (ptr[0] < draft->numPicks[0] || ptr[1] < draft->numPicks[1]) { if (ptr[cur] < draft->numPicks[cur]) { DotaHero* hero = getHero (draft->picks[cur][ptr[cur]++]); int pos = draftPicks.InsertItem (draftPicks.GetItemCount (), hero->abbr, getImageIndex (hero->imgTag)); draftPicks.SetItemData (pos, colors[cur]); } mod++; if (mod >= 2) { cur = 1 - cur; mod = 0; } } } } }
void __fastcall TfrmMove::treeGetSelectedIndex(TObject *Sender, TTreeNode *Node) { Node -> SelectedIndex = getImageIndex( Node ); }
void Toolbar::updateChoice( unsigned int& index, ItemPtr item, TBBUTTONINFO& info ) { unsigned int i = 0; while( index < (unsigned int)sendMessage( TB_BUTTONCOUNT, 0, 0 ) && i < item->num() ) { static const unsigned int MAX_MENU_TEXT = 1024; char txtBuf[ MAX_MENU_TEXT + 1 ]; TBBUTTONINFO info = { sizeof( info ), TBIF_BYINDEX | TBIF_COMMAND | TBIF_IMAGE | TBIF_LPARAM | TBIF_SIZE | TBIF_STATE | TBIF_STYLE | TBIF_TEXT }; info.pszText = txtBuf; info.cchText = MAX_MENU_TEXT; sendMessage( TB_GETBUTTONINFO, index, (LPARAM)&info ); ItemPtr subItem = (*item)[ i ]; if( ( info.fsStyle & BTNS_CHECK ) == 0 || // not a toggle button info.idCommand != subItem->commandID() ) // not for me { TBBUTTON button; memset( &button, 0, sizeof(button) ); button.iBitmap = getImageIndex( subItem ); button.idCommand = subItem->commandID(); button.fsState = TBSTATE_ENABLED; button.fsStyle = BTNS_CHECK; button.dwData = 0; button.iString = -1; sendMessage( TB_INSERTBUTTON, index, (LPARAM)&button ); } TBBUTTONINFO buttonInfo = { sizeof( buttonInfo ), TBIF_TEXT | TBIF_BYINDEX | TBIF_STATE }; std::string tooltip = subItem->description(); // auto tooltip if( subItem->shortcutKey().size() || item->shortcutKey().size() ) { if (subItem->shortcutKey().size() && item->shortcutKey().size()) { tooltip = L ( "GUIMANAGER/GUI_TOOLBAR/TOOLTIP_FORM0", subItem->description(), subItem->shortcutKey(), item->shortcutKey() ); } else if (subItem->shortcutKey().size()) { tooltip = L ( "GUIMANAGER/GUI_TOOLBAR/TOOLTIP_FORM1", subItem->description(), subItem->shortcutKey() ); } else if (item->shortcutKey().size()) { tooltip = L ( "GUIMANAGER/GUI_TOOLBAR/TOOLTIP_FORM2", subItem->description(), item->shortcutKey() ); } } buttonInfo.pszText = &tooltip[0]; LPARAM enabled = item->update() && isEnabled() ? TBSTATE_ENABLED : 0; LPARAM checked = subItem->update() ? TBSTATE_CHECKED : 0; if( !enabled ) checked = 0; buttonInfo.fsState = (BYTE)( enabled | checked ); if ( sendMessage( WM_CGUITOOLBAR_USE_WRAP, 0, 0 ) && ( info.fsState & TBSTATE_WRAP ) ) buttonInfo.fsState |= TBSTATE_WRAP; if( forceChanged_ || info.pszText != tooltip || info.fsState != buttonInfo.fsState ) sendMessage( TB_SETBUTTONINFO, index, (LPARAM)&buttonInfo ); ++i; ++index; } while( i < item->num() ) { ItemPtr subItem = (*item)[ i ]; TBBUTTON button; memset( &button, 0, sizeof(button) ); button.iBitmap = getImageIndex( subItem ); button.idCommand = subItem->commandID(); button.fsState = TBSTATE_ENABLED; button.fsStyle = BTNS_CHECK; button.dwData = 0; button.iString = -1; sendMessage( TB_INSERTBUTTON, index, (LPARAM)&button ); TBBUTTONINFO buttonInfo = { sizeof( buttonInfo ), TBIF_TEXT | TBIF_BYINDEX | TBIF_STATE }; std::string tooltip = subItem->description(); // auto tooltip if( subItem->shortcutKey().size() || item->shortcutKey().size() ) { if (subItem->shortcutKey().size() && item->shortcutKey().size()) { tooltip = L ( "GUIMANAGER/GUI_TOOLBAR/TOOLTIP_FORM0", subItem->description(), subItem->shortcutKey(), item->shortcutKey() ); } else if (subItem->shortcutKey().size()) { tooltip = L ( "GUIMANAGER/GUI_TOOLBAR/TOOLTIP_FORM1", subItem->description(), subItem->shortcutKey() ); } else if (item->shortcutKey().size()) { tooltip = L ( "GUIMANAGER/GUI_TOOLBAR/TOOLTIP_FORM2", subItem->description(), item->shortcutKey() ); } } buttonInfo.pszText = &tooltip[0]; LPARAM enabled = item->update() && isEnabled() ? TBSTATE_ENABLED : 0; LPARAM checked = subItem->update() ? TBSTATE_CHECKED : 0; if( !enabled ) checked = 0; buttonInfo.fsState = (BYTE)( enabled | checked ); if ( sendMessage( WM_CGUITOOLBAR_USE_WRAP, 0, 0 ) && ( info.fsState & TBSTATE_WRAP ) ) buttonInfo.fsState |= TBSTATE_WRAP; if( forceChanged_ || info.pszText != tooltip || info.fsState != buttonInfo.fsState ) sendMessage( TB_SETBUTTONINFO, index, (LPARAM)&buttonInfo ); ++i; ++index; } --index; }