コード例 #1
0
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);
}
コード例 #2
0
ファイル: lightOutput.c プロジェクト: jhiesey/SensorNet
bool sensorReadRPC(unsigned short from, unsigned short inLen, void *inData, unsigned short *outLen, void *outData) {

    if(inLen == 0)
        return false;

    unsigned short index;
    memcpy(&index, inData, 2);
    inLen -= 2;
    inData = (char *) inData + 2;

    switch(ntohs(index)) {
        case 0:
            return getLightColor(from, inLen, inData, outLen, outData);
        default:
            return false;
    }
}
コード例 #3
0
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;
        }
      }
    }
  }
}