int CGridManager::GetHighestindex(vector<float3> MapPositions) { if(MapPositions.empty()){ return -1; }else{ set<int> indexes; for(vector<float3>::iterator i = MapPositions.begin(); i != MapPositions.end(); ++i){ // float3 j = *i; int Index = GetIndex(MaptoGrid(j)); if(ValidIndex(Index)){ indexes.insert(Index); } } { boost::mutex::scoped_lock lock(cellmutex); if(sortedcells.empty()==false){ for(set<boost::shared_ptr<CGridCell>,cmpCell>::iterator i = sortedcells.begin(); i != sortedcells.end(); ++i){ boost::shared_ptr<CGridCell> p = *i; if(indexes.find(p->GetIndex())!= indexes.end()){ return p->GetIndex(); } } } } } return -1; }
//------------------------------------------------------------------------------ void CFont::SetFontColor(int r, int g, int b, unsigned int FontIndex) { if( !ValidIndex(FontIndex) ) return; Fonts.at(FontIndex).Color.r = r; Fonts.at(FontIndex).Color.g = g; Fonts.at(FontIndex).Color.b = b; }
//============================================================================== void CFont::Write(SDL_Surface* Surf_Display, const char* Text, unsigned int x, unsigned int y, unsigned int FontIndex) const { if( Text == NULL || !ValidIndex(FontIndex) ) return; SDL_Surface* Surf_Text = TTF_RenderText_Blended(Fonts.at(FontIndex).Font, Text, Fonts.at(FontIndex).Color); CSurface::OnDraw(Surf_Display, Surf_Text, x, y); SDL_FreeSurface(Surf_Text); }
float SAnimSegmentsPanel::GetSegmentLength(int32 AnimSegmentIndex) const { if (ValidIndex(AnimSegmentIndex)) { return AnimTrack->AnimSegments[AnimSegmentIndex].GetLength(); } return 0.f; }
float SAnimSegmentsPanel::GetSegmentStartPos(int32 AnimSegmentIndex) const { if (ValidIndex(AnimSegmentIndex)) { return AnimTrack->AnimSegments[AnimSegmentIndex].StartPos; } return 0.f; }
void CGridManager::SetValuebyGrid(float3 Gridpos, float Value) { if(ValidGridPos(Gridpos)){ int Index = this->GetIndex(Gridpos); if(ValidIndex(Index)){ SetValuebyIndex(Index, Value); } } }
void CConfiguration::RemoveVariable(const int Index) { if (ValidIndex(Index)) { CVariable *variable = m_Variables[Index]; m_Variables.erase(m_Variables.begin()+Index); delete variable; } }
void TodoList::mouseMoveEvent(QMouseEvent *event){ int x = event->globalPos().x() - this->pos().x(); int y = event->globalPos().y() - this->pos().y(); moveY = oldMoveY + y - pressY; selectIndex = (y - moveY - 95) / 80; if(ValidIndex()){ MoveIndex(selectIndex,oldMoveX + x - pressX); } }
void CGridManager::ApplyModifierAtIndex(int Index, float Modifier){ if(ValidIndex(Index)){ if(CellExists(Index)){ boost::mutex::scoped_lock lock(cellmutex); boost::shared_ptr<CGridCell> p =GetCell(Index); p->ApplyModifier(Modifier); } } }
void CGridManager::AddValueatMapPos(float3 MapPos, float Value){ if(ValidMapPos(MapPos)){ float CurrentValue = GetValuebyMap(MapPos); CurrentValue += Value; int Index = MaptoIndex(MapPos); if(ValidIndex(Index)){ SetValuebyIndex(Index,CurrentValue); } } }
ThingyRef& CThingyList::FetchThingyRefAt(ArrayIndexT inAtIndex) const { ThingyRef* resultP = NULL; if (!ValidIndex(inAtIndex)) { DEBUG_OUT("Throwing: ThingyList index out of range: "<<inAtIndex, DEBUG_ERROR | DEBUG_CONTAINMENT ); Throw_(invalidIndexErr); } else { resultP = (ThingyRef*) GetItemPtr(inAtIndex); } return *resultP; }
// 리스트삽입 inline TYPE& Insert(int index, TYPE* newData = (TYPE*) AutoCreate) { CalcIndex(index); if(Size <= index) ValidIndex(index); else { ValidIndex(Size); BxCore::Util::MemCpy(&Unit[index + 1], &Unit[index], sizeof(TYPE*) * (Size - index)); } Unit[index] = (newData)? newData : new TYPE; if(!newData && IsTypePointer<TYPE>()) BxCore::Util::MemSet(Unit[index], 0, sizeof(TYPE)); if(Size < index + 1) Size = index + 1; else ++Size; ++Count; BytesUpdated = false; return *Unit[index]; }
FString SAnimSegmentsPanel::GetAnimSegmentName(int32 AnimSegmentIndex) const { if (ValidIndex(AnimSegmentIndex)) { UAnimSequenceBase* AnimReference = AnimTrack->AnimSegments[AnimSegmentIndex].AnimReference; if(AnimReference) { return AnimReference->GetName(); } } return FString(); }
void SAnimSegmentsPanel::RemoveAnimSegment(int32 AnimSegmentIndex) { if(ValidIndex(AnimSegmentIndex)) { const FScopedTransaction Transaction( LOCTEXT("AnimSegmentseEditor", "Remove Segment") ); OnPreAnimUpdateDelegate.Execute(); AnimTrack->AnimSegments.RemoveAt(AnimSegmentIndex); OnPostAnimUpdateDelegate.Execute(); } }
void DArray<T>::EmptyAndDelete() { for (int i = 0; i < m_arraySize; ++i) { if (ValidIndex(i)) { delete array[i]; } } Empty(); }
int CGridManager::GetIndex(float3 Gridpos) { if(ValidGridPos(Gridpos)){ int GridIndex = ((int)Gridpos.z*GetGridWidth()) + (int)Gridpos.x ; if(!ValidIndex(GridIndex)){ return -1; }else { return GridIndex; } }else{ return -1; } }
FString SAnimSegmentsPanel::GetAnimSegmentDetailedInfo(int32 AnimSegmentIndex) const { if (ValidIndex(AnimSegmentIndex)) { FAnimSegment& AnimSegment = AnimTrack->AnimSegments[AnimSegmentIndex]; UAnimSequenceBase * Anim = AnimSegment.AnimReference; if ( Anim != NULL ) { return FString::Printf(TEXT("%s %.2f"), *Anim->GetName(), AnimSegment.GetLength() ); } } return FString(); }
void CConfiguration::SetCharVariable(const CString& Name, const char Value) { int index = VarIndex(Name); if (ValidIndex(index)) { CVariable *variable = m_Variables[index]; variable->SetChar(Value); } else { InsertCharVariable(Name,Value); } }
// 데이터할당 inline TYPE& operator[](int index) { CalcIndex(index); ValidIndex(index); if(!Unit[index]) { Unit[index] = new TYPE; if(IsTypePointer<TYPE>()) BxCore::Util::MemSet(Unit[index], 0, sizeof(TYPE)); if(Size < index + 1) Size = index + 1; ++Count; BytesUpdated = false; } return *Unit[index]; }
void SAnimSegmentsPanel::SetSegmentStartPos(float NewStartPos, int32 AnimSegmentIndex) { if (ValidIndex(AnimSegmentIndex)) { if(!bDragging) { const FScopedTransaction Transaction( LOCTEXT("AnimSegmentPanel_SetSegmentStart", "Edit Segment Start Time") ); OnPreAnimUpdateDelegate.Execute(); bDragging = true; } AnimTrack->AnimSegments[AnimSegmentIndex].StartPos = NewStartPos; AnimTrack->CollapseAnimSegments(); } }
float3 CGridManager::IndextoGrid(int Index) { if(ValidIndex(Index)){ int x = 0; int z=0; x = Index%GetGridWidth(); if(Index-x>0){ z = (Index-x)/GetGridWidth(); }else{ z=0; } return float3(float(x),0,float(z)); }else{ return UpVector; } }
AGalacticThingy* CThingyList::FetchThingyAt(ArrayIndexT inAtIndex) const { if (!ValidIndex(inAtIndex)) { DEBUG_OUT("WARNING: ThingyList index out of range: "<<inAtIndex, DEBUG_IMPORTANT | DEBUG_CONTAINMENT ); return NULL; } ThingyRef* aRefP = (ThingyRef*) GetItemPtr(inAtIndex); AGalacticThingy* aThingy = aRefP->GetThingy(); aThingy = ValidateThingy(aThingy); #ifdef DEBUG if (aThingy == NULL) { DEBUG_OUT("ThingyList has invalid reference at index "<<inAtIndex << " to id "<<aRefP->GetThingyID()<<"; Not Removed", DEBUG_ERROR | DEBUG_CONTAINMENT ); } #endif return aThingy; }
void TodoList::mouseReleaseEvent(QMouseEvent *event){ int x = event->globalPos().x() - this->pos().x(); int y = event->globalPos().y() - this->pos().y(); moveY = oldMoveY + y - pressY; selectIndex = (y - moveY - 95) / 80; if(ValidIndex()){ MoveIndex(selectIndex,oldMoveX + x - pressX); } moveAniSource = moveY; moveAniFrame = 0; mousePre = false; moveAniTarget = (moveY/ 80 + ((moveY%80)/80.0 >= 0.5)) * 80;//找到最接近80的倍数的值 if (moveY > 0)moveAniTarget = 0; //lastDateY = (-80 * indexSize) + 0; if (moveY < lastDateY)moveAniTarget = lastDateY; if (deleteIndex != -1 && deleteIndex < indexSize){ //deleteIndex 为选中项目id,要和事件id区分! int id = indexID[deleteIndex]; //对应时间的paid int validID = -1; int count = 0; if (id == -1){ //批量删除todolist for (int i = deleteIndex + 1; i < indexSize && indexID[i] != -1; i++){ if (validID == -1)validID = indexID[i]; count++; } } else{ //删除单个Todo count = 1; validID = id; } indexSize -= count; for (int i = deleteIndex; i < indexSize; i++){ indexID[i] = indexID[i + count]; indexPosX[i] = indexPosX[i + count]; } pa.RemoveTodo(validID, count, viewDate.year, viewDate.month); deleteIndex = -1; } }
void CConfiguration::SetFlagVariable(const CString& Name, const bool Value) { int index = VarIndex(Name); if (ValidIndex(index)) { if (!Value) { RemoveVariable(index); } } else { if (Value) { InsertFlagVariable(Name,true); } } }
//------------------------------------------------------------------------------ void CFont::GetTextSize(const char *text, int *w, int *h, unsigned int FontIndex) { if( !ValidIndex(FontIndex) ) return; TTF_SizeText(Fonts.at(FontIndex).Font, text, w, h); }
//------------------------------------------------------------------------------ void CFont::SetFontOutline(int outline, unsigned int FontIndex) { if( outline < 0 || !ValidIndex(FontIndex) ) return; TTF_SetFontOutline(Fonts.at(FontIndex).Font, outline); }
//------------------------------------------------------------------------------ void CFont::SetFontStyle(int style, unsigned int FontIndex) { if( style < 0 || !ValidIndex(FontIndex) ) return; TTF_SetFontStyle(Fonts.at(FontIndex).Font, style); }
OvershootData& Data(MotiveIndex index) { assert(ValidIndex(index)); return data_[index]; }
void TodoList::mousePressEvent(QMouseEvent *event){ int x = event->globalPos().x() - this->pos().x(); int y = event->globalPos().y() - this->pos().y(); pressX = x; pressY = y; oldMoveY = moveY; mousePre = true; if(y < 76 && (x >= 68 && x <= 105)){ viewDate.ToLastMonth(); ChangeState(WINSTATE::LIST); } if(y < 76 && (x >= 318 && x <= 355)){ viewDate.ToNextMonth(); ChangeState(WINSTATE::LIST); } //qDebug("%d %d",x,y); if(y < 76 && (x >= 255 && x <= 320)){ viewState = VIEWSTATE((int(viewState) + 1)%3); ChangeState(WINSTATE::LIST); } mouseList[mouseCount ++] = event->button()==Qt::LeftButton; mouseTime = 20; //以下把y转为绘制画面的相对坐标 //相对选择项目的坐标 int sy = y - moveY; selectIndex = (sy - 95) / 80; if(ValidIndex()) oldMoveX = indexPosX[selectIndex]; if(ValidIndex() && indexID[selectIndex] != -1){ int id = indexID[selectIndex]; int viewYear = viewDate.year; int viewMonth = viewDate.month; TodoItem &item = pa.GetItem(id,viewYear,viewMonth); int offset = selectIndex * 80; if(85 <= x && x <= 120 && 110 + offset <= sy && sy <= 140 + offset){ pa.MarkAsDone(id,viewYear,viewMonth,!item.HaveDone()); } if(mouseCount >= 2 && mouseList[0] && mouseList[1]){ //跳转到添加新Todo界面 ui->nameBox->setText(QString::fromStdString(item.GetName())); switch (item.GetLevel()) { case 0: ui->radioButton_4->setChecked(true);break; case 1: ui->radioButton_2->setChecked(true);break; case 2: ui->radioButton_3->setChecked(true);break; case 3: ui->radioButton_1->setChecked(true);break; } ui->horizontalSlider->setValue(item.GetWarnTime()/5); SetWarnText(ui->horizontalSlider->value()); Date date = item.GetTime(); QDate qdate(date.year,date.month,date.day); QTime qtime(date.hour,date.minute); ui->dateTimeEdit->setDateTime(QDateTime(qdate,qtime)); ui->placeBox->setText(QString::fromStdString(item.GetPlace())); ui->labelBox->setText(QString::fromStdString(item.GetLabel())); ui->contentBox->setText(QString::fromStdString(item.GetContent())); ui->comboBox->setCurrentIndex(item.GetKind()); selectID = id; ChangeState(WINSTATE::DETAIL); mouseCount = 0; } if(mouseCount >= 2 && !mouseList[0] && !mouseList[1]){ pa.RemoveTodo(id,viewYear,viewMonth); mouseCount = 0; } } }
SplineData& Data(MotiveIndex index) { assert(ValidIndex(index)); return data_[index]; }