Example #1
0
String D2StatData::process(D2Item* item)
{
  if (item->base->type->isType("jewl") && item->quality == D2Item::qUnique)
    return processRBF(item->stats);
  if (item->base->type->isType("mcha") && item->quality == D2Item::qUnique)
    return processTorch(item->stats);
  if (item->base->type->isType("scha") && item->quality == D2Item::qUnique)
    return processAnni(item->stats);

  Array<D2ItemStat> list = item->stats;

  bool hasDef = false;
  if (item->unique && item->unique->base == item->base && findStat(list, &stats[16]) >= 0)
    hasDef = true;
  if (!item->unique && findStat(list, &stats[16]) >= 0)
    hasDef = true;
  if (item->unique && item->unique->base == item->base && (item->flags & D2Item::fUnidentified))
  {
    if (findStat(item->unique->preset, &stats[16]) >= 0)
      hasDef = true;
    else
    {
      int ppdef = findStat(item->unique->preset, &stats[31]);
      int def = findStat(list, &stats[360]);
      if (ppdef >= 0 && def >= 0)
        list[def].value1 += item->unique->preset[ppdef].value1;
    }
  }
  if (hasDef)
  {
    int def = findStat(list, &stats[360]);
    if (def >= 0) list.remove(def, 1);
  }
  if (item->unique && item->unique->type == 6)
  {
    int sox = findStat(list, &stats[194]);
    if (sox >= 0) list.remove(sox, 1);
  }
  if (item->unique || item->socketItems.length())
  {
    ungroup(list);

    for (int i = 0; i < item->socketItems.length(); i++)
    {
      D2Item* sub = item->socketItems[i];
      if (!sub) continue;
      Array<D2ItemStat> subStats;
      if (sub->base && sub->base->numGemMods == 1)
        subStats = sub->base->gemMods[0];
      else if (sub->base && sub->base->numGemMods == 3)
      {
        if (item->base->type->isType("weap"))
          subStats = sub->base->gemMods[0];
        else if (item->base->type->isType("shld"))
          subStats = sub->base->gemMods[2];
        else if (item->base->type->isType("tors") || item->base->type->isType("helm"))
          subStats = sub->base->gemMods[1];
      }
      else
        subStats = sub->stats;
      ungroup(subStats);
      for (int j = 0; j < subStats.length(); j++)
        subStat(list, subStats[j]);
    }

    if (item->unique)
    {
      for (int i = 0; i < item->unique->preset.length(); i++)
      {
        D2ItemStat stat = item->unique->preset[i];
        int pos = findStat(list, stat.stat, stat.param);
        if (pos >= 0 && list[pos].value1 <= stat.value1 && list[pos].value2 <= stat.value2)
          list.remove(pos, 1);
      }
    }

    group(list);
  }

  list.sort(statCompare);
  String text;
  bool comma = false;
  for (int i = 0; i < list.length(); i++)
  {
    String fmt = format(list[i], true);
    if (fmt.length())
    {
      if (text.length() && s_isalpha(fmt[0]))
        text += ',', comma = true;
      else if (comma)
        text += ',', comma = false;
      if (text.length())
        text += ' ';
      text += fmt;
    }
  }
  return text;
}
Example #2
0
void TraceGroup::on_ungroup()
{
	ungroup();
}
Example #3
0
void UMLEditor::layout(){
  mainPanel = new QWidget;
  mainLayout = new QHBoxLayout;

  btnGroup = new QButtonGroup(this);
  btnGroup->setExclusive(true);

  SelectButton *btn = new SelectButton(canvas);
  ClassBoxButton *btn2 = new ClassBoxButton(canvas);
  btnGroup->addButton(btn);
  btnGroup->addButton(btn2);
  buttons.push_back(new SelectButton(canvas));
  buttons.push_back(new ClassBoxButton(canvas));
  buttons.push_back(new UseCaseButton(canvas));
  buttons.push_back(new AssLineButton(canvas));
  buttons.push_back(new GenLineButton(canvas));
  buttons.push_back(new ComLineButton(canvas));
  buttons[0]->pressed();

  for(std::vector<Button*>::size_type i = 0; i != buttons.size(); i++) {
    btnGroup->addButton(buttons[i]);
  }

  toolPanel = new QWidget;
  toolPanelLayout = new QGridLayout;
  toolPanelLayout->setAlignment(Qt::AlignTop);

  for(std::vector<QToolButton*>::size_type i = 0; i != buttons.size(); i++) {
    toolPanelLayout->addWidget(buttons[i], i, 0, Qt::AlignHCenter);
  }

  toolPanel->setLayout(toolPanelLayout);
  toolPanel->setMinimumWidth(100);

  menubar = new QMenuBar;
  file =  menubar->addMenu(tr("&File"));
  edit =  menubar->addMenu(tr("&Edit"));

  exit = new QAction(tr("Exit"), mainPanel);
  this->connect(exit, SIGNAL(triggered()), this, SLOT(close()));
  group = new QAction(tr("Group"), mainPanel);
  this->connect(group, SIGNAL(triggered()), canvas, SLOT(group()));
  ungroup = new QAction(tr("UnGroup"), mainPanel);
  this->connect(ungroup, SIGNAL(triggered()), canvas, SLOT(ungroup()));
  named = new QAction(tr("Change Object Name"), mainPanel);
  this->connect(named, SIGNAL(triggered()), canvas, SLOT(named()));

  file->addAction(exit);
  edit->addAction(group);
  edit->addAction(ungroup);
  edit->addAction(named);

  canvas->setSceneRect(QRectF(-200,-200,400,400));
  //view->setDragMode(QGraphicsView::RubberBandDrag);
  view->setScene(canvas);
  view->resize(400,400);

  mainLayout->addWidget(toolPanel,0);
  mainLayout->setAlignment(toolPanel,Qt::AlignTop);
  mainLayout->addWidget(view,1);
  mainLayout->setMenuBar(menubar);

  mainPanel->setLayout(mainLayout);
  setCentralWidget(mainPanel);
}