//! \brief Recreates player mesh from scratch static void applyTweak(EquipmentSlot equip, TweakType tw, const std::string & selection) { if(!ValidIONum(player.equiped[equip])) { return; } Entity * io = entities.player(); arx_assert(entities[player.equiped[equip]]->tweakerinfo != NULL); const IO_TWEAKER_INFO & tweak = *entities[player.equiped[equip]]->tweakerinfo; if(!tweak.filename.empty()) { res::path mesh = "graph/obj3d/interactive/npc/human_base/tweaks" / tweak.filename; EERIE_MESH_TWEAK_Do(io, tw, mesh); } if(tweak.skintochange.empty() || tweak.skinchangeto.empty()) { return; } res::path file = "graph/obj3d/textures" / tweak.skinchangeto; TextureContainer * temp = TextureContainer::Load(file, TextureContainer::Level); long mapidx = ObjectAddMap(io->obj, temp); long sel = -1; for(size_t i = 0; i < io->obj->selections.size(); i++) { if(io->obj->selections[i].name == selection) { sel = i; break; } } if(sel == -1) { return; } long textochange = -1; for(size_t i = 0; i < io->obj->texturecontainer.size(); i++) { if(tweak.skintochange == io->obj->texturecontainer[i]->m_texName.filename()) { textochange = i; } } if(textochange == -1) { return; } for(size_t i = 0; i < io->obj->facelist.size(); i++) { EERIE_FACE & face = io->obj->facelist[i]; if(IsInSelection(io->obj, face.vid[0], sel) != -1 && IsInSelection(io->obj, face.vid[1], sel) != -1 && IsInSelection(io->obj, face.vid[2], sel) != -1) { if(face.texid == textochange) { face.texid = (short)mapidx; } } } }
static bool ARX_NPC_ApplyCuts(Entity * io) { if(!io || !(io->ioflags & IO_NPC)) return false; if(io->_npcdata->cuts == 0) return false; // No cuts ReComputeCutFlags(io); long goretex = -1; for(size_t i = 0; i < io->obj->texturecontainer.size(); i++) { if (io->obj->texturecontainer[i] && (boost::contains(io->obj->texturecontainer[i]->m_texName.string(), "gore"))) { goretex = i; break; } } bool hid = false; for(size_t nn = 0; nn < io->obj->facelist.size(); nn++) { io->obj->facelist[nn].facetype &= ~POLY_HIDE; } for(long jj = 0; jj < 6; jj++) { DismembermentFlag flg = DismembermentFlag(1 << jj); ObjSelection numsel = GetCutSelection(io, flg); if((io->_npcdata->cuts & flg) && numsel != ObjSelection()) { for(size_t ll = 0; ll < io->obj->facelist.size(); ll++) { EERIE_FACE & face = io->obj->facelist[ll]; if( IsInSelection(io->obj, face.vid[0], numsel) || IsInSelection(io->obj, face.vid[1], numsel) || IsInSelection(io->obj, face.vid[2], numsel) ) { if(!(face.facetype & POLY_HIDE)) { if(face.texid != goretex) hid = true; } face.facetype |= POLY_HIDE; } } io->_npcdata->cut = 1; } } return hid; }
void CListView::OnCellLeftClick(wxGridEvent& ev) { // This forces the cell to go into edit mode directly m_waitForSlowClick = TRUE; SetGridCursor(ev.GetRow(), ev.GetCol()); // Store the click co-ordinates in the editor if possible // if an editor has created a ClientData area, we presume it's // a wxPoint and we store the click co-ordinates wxGridCellEditor* pEditor = GetCellEditor(ev.GetRow(), ev.GetCol()); wxPoint* pClickPoint = (wxPoint*)pEditor->GetClientData(); if (pClickPoint) { *pClickPoint = ClientToScreen(ev.GetPosition()); #ifndef __WINDOWS__ EnableCellEditControl(true); #endif } // hack to prevent selection from being lost when click combobox if (ev.GetCol() == 0 && IsInSelection(ev.GetRow(), ev.GetCol())) { m_selTemp = m_selection; m_selection = NULL; } pEditor->DecRef(); ev.Skip(); }
const std::string wex::grid::get_selected_cells_value() const { // This does not work, only filled in for singly selected cells. // wxGridCellCoordsArray cells = GetSelectedCells(); wxString text; for (int i = 0; i < GetNumberRows(); i++) { bool value_added = false; for (int j = 0; j < GetNumberCols(); j++) { if (IsInSelection(i, j)) { if (value_added) { text << "\t"; } text << GetCellValue(i, j); value_added = true; } } if (value_added) { text << "\n"; } } return text; }
void wxPropertyList::OnCellPopup( wxGridEvent& event ) { wxPoint pt; int row = event.GetRow(); //pt = ::wxGetMousePosition(); //ScreenToClient(pt); //row = YToRow(pt.y); if(row != wxNOT_FOUND) { wxPropertyItem *pItem = GetPropertyItemFromRow(row); if(pItem) { // select the row first if already in selection, don't // this will clear the previous selection if(!IsInSelection(row, 0)) SelectRow(row); // show popup menu wxMenu *menu = AppResources::CreatePopupMenu(); // enable when it is browsable, and selected one only wxMenuItem *item = menu->FindItem(ID_CACHE_BROWSE); if(item) item->Enable(IsSelectedItemBrowsable()); PopupMenu(menu); delete menu; } } }
bool wxPropertyList::IsSelectedItemBrowsable(int row) { // when there is only one selection, and our current item // is browsable, make sure it can be selected. wxPropertyItem *pItem = 0; size_t count = 0; for(size_t i = 0; i < (size_t)GetNumberRows() && (count < 2); i++) { if(IsInSelection(i, 0)) { if(!pItem) pItem = GetPropertyItemFromRow(i); count ++; } } // if we found nothing, take row (because the event EVT_GRID_CELL_SELECTED // deselects the cells first before selecting the new one again if(row != -1 && !pItem) { pItem = GetPropertyItemFromRow(row); count ++; // needed because of next loop } // only one item allowed to select if(pItem && count == 1) { if(pItem) return pItem->IsDirPath() || pItem->IsFilePath(); } return false; }
/////////////////////////// // Gets first selected row int BaseGrid::GetFirstSelRow() { int nrows = GetRows(); for (int i=0;i<nrows;i++) { if (IsInSelection(i,0)) { return i; } } return -1; }
static float GetSphereRadiusForGroup(EERIE_3DOBJ * obj, const Vec3f & center, const Vec3f & dirvect, long group, float maxi) { float curradius = 0.f; float maxf = 0.f; float div = 0.f; long sel = -1; for(size_t i = 0; i < obj->selections.size(); i++) { // TODO iterator if(obj->selections[i].name == "mou") { sel = i; break; } } for(size_t i = 0; i < obj->grouplist[group].indexes.size(); i++) { if(!IsExclusiveGroupMember(obj, obj->grouplist[group].indexes[i], group)) continue; if(sel > -1 && IsInSelection(obj, obj->grouplist[group].indexes[i], sel) >= 0) continue; Vec3f target = obj->vertexlist[obj->grouplist[group].indexes[i]].v; float distance = fdist(center, target); if(distance < 2.f) continue; if(distance < maxf) continue; Vec3f targvect = (target - center) * 1.f / distance; float val = glm::dot(dirvect, targvect); if(glm::abs(val) < 1.2f) { if(distance > maxi) distance = maxi; curradius += distance; div += 1.f; maxf = std::max(maxf, distance); } } if(div > 0.f) { curradius /= div; } return curradius; }
void wxGridSelection::SelectCell( int row, int col, const wxKeyboardState& kbd, bool sendEvent ) { if ( IsInSelection ( row, col ) ) return; wxGridCellCoords selectedTopLeft, selectedBottomRight; if ( m_selectionMode == wxGrid::wxGridSelectRows ) { m_rowSelection.Add( row ); selectedTopLeft = wxGridCellCoords( row, 0 ); selectedBottomRight = wxGridCellCoords( row, m_grid->GetNumberCols() - 1 ); } else if ( m_selectionMode == wxGrid::wxGridSelectColumns ) { m_colSelection.Add( col ); selectedTopLeft = wxGridCellCoords( 0, col ); selectedBottomRight = wxGridCellCoords( m_grid->GetNumberRows() - 1, col ); } else { m_cellSelection.Add( wxGridCellCoords( row, col ) ); selectedTopLeft = wxGridCellCoords( row, col ); selectedBottomRight = wxGridCellCoords( row, col ); } // Update View: if ( !m_grid->GetBatchCount() ) { wxRect r = m_grid->BlockToDeviceRect( selectedTopLeft, selectedBottomRight ); ((wxWindow *)m_grid->m_gridWin)->Refresh( false, &r ); } // Send event if (sendEvent) { wxGridRangeSelectEvent gridEvt( m_grid->GetId(), wxEVT_GRID_RANGE_SELECT, m_grid, selectedTopLeft, selectedBottomRight, true, kbd); m_grid->GetEventHandler()->ProcessEvent( gridEvt ); } }
void wex::grid::empty_selection() { wxBusyCursor wait; for (int i = 0; i < GetNumberRows(); i++) { for (int j = 0; j < GetNumberCols(); j++) { if (IsInSelection(i, j) && !IsReadOnly(i, j)) { set_grid_cell_value(wxGridCellCoords(i, j), std::string()); } } } }
void wxPropertyList::BrowseSelectedItem() { HideControls(); for(size_t i = 0; i < (size_t)GetNumberRows(); i++) { if(IsInSelection(i, 0)) { // browse for file or directory wxPropertyItem *pItem = GetPropertyItemFromRow(i); if(pItem) { wxString title; wxString str = pItem->GetPropName() + _("-NOTFOUND"); if(pItem->GetCurValue().IsSameAs(str, true)) str.Empty(); else str = pItem->GetCurValue(); // browse the directory path if(pItem->IsDirPath()) { title = _("Select path for ") + pItem->GetPropName(); str = ::wxDirSelector(title, str, 0, wxDefaultPosition, this); } else if(pItem->IsFilePath()) { title = _("Select file for ") + pItem->GetPropName(); str = ::wxFileSelector(title, str, _(""), _(""), _(MC_DEFAULT_WILDCARD), wxFILE_MUST_EXIST, this); } else str.Empty(); if(!str.IsEmpty()) { pItem->SetCurValue(str.c_str()); UpdatePropertyItem(pItem, i); } } // only allow one item to browse break; } } }
void wxPropertyList::OnIgnoreCache( wxCommandEvent& event ) { HideControls(); // ignore all selected items for(size_t i = 0; i < (size_t)GetNumberRows(); i++) { if(IsInSelection(i, 0)) { wxPropertyItem *pItem = GetPropertyItemFromRow(i); if(pItem) { pItem->SetCurValue("IGNORE"); UpdatePropertyItem(pItem, i); } } } }
void wxGridSelection::SelectCell( int row, int col, bool ControlDown, bool ShiftDown, bool AltDown, bool MetaDown, bool sendEvent ) { if ( m_selectionMode == wxGrid::wxGridSelectRows ) { SelectBlock(row, 0, row, m_grid->GetNumberCols() - 1, ControlDown, ShiftDown, AltDown, MetaDown, sendEvent); return; } else if ( m_selectionMode == wxGrid::wxGridSelectColumns ) { SelectBlock(0, col, m_grid->GetNumberRows() - 1, col, ControlDown, ShiftDown, AltDown, MetaDown, sendEvent); return; } else if ( IsInSelection ( row, col ) ) return; m_cellSelection.Add( wxGridCellCoords( row, col ) ); // Update View: if ( !m_grid->GetBatchCount() ) { wxRect r = m_grid->BlockToDeviceRect( wxGridCellCoords( row, col ), wxGridCellCoords( row, col ) ); ((wxWindow *)m_grid->m_gridWin)->Refresh( false, &r ); } // Send event if (sendEvent) { wxGridRangeSelectEvent gridEvt( m_grid->GetId(), wxEVT_GRID_RANGE_SELECT, m_grid, wxGridCellCoords( row, col ), wxGridCellCoords( row, col ), true, ControlDown, ShiftDown, AltDown, MetaDown); m_grid->GetEventHandler()->ProcessEvent(gridEvt); } }
void wxPropertyList::OnDeleteCache( wxCommandEvent& event ) { HideControls(); // convert selections to prop items wxArrayPtrVoid items; for(size_t i = 0; i < (size_t)GetNumberRows(); i++) { // if selected, query for removal if(IsInSelection(i, 0)) { wxPropertyItem *pItem = GetPropertyItemFromRow(i); if(pItem) items.Add((void *)pItem); } } // now delete all prop items in cells for(size_t i = 0; i < items.Count(); i++) RemoveProperty((wxPropertyItem *)items[i]); }
void wxStfGrid::Copy(wxCommandEvent& WXUNUSED(event)) { if (!IsSelection()) { wxGetApp().ErrorMsg( wxT("Select cells first") ); return; } // Write some text to the clipboard // These data objects are held by the clipboard, // so do not delete them in the app. selection.Clear(); bool newline=true; for (int nRow=0;nRow<GetNumberRows();++nRow) { /* bool selected=false;*/ newline=true; for (int nCol=0;nCol<GetNumberCols();++nCol) { if (IsInSelection(nRow,nCol)) { // Add a line break if this is not the first line: if (newline && selection != wxT("") ) { selection << wxT("\n"); } if (!newline) { selection << wxT("\t"); } newline=false; try { selection << GetCellValue(nRow,nCol); /* selected=true;*/ } catch (const std::out_of_range& e) { throw e; } } } } if (wxTheClipboard->Open()) { wxTheClipboard->SetData( new wxTextDataObject(selection) ); wxTheClipboard->Close(); } }
bool wex::grid::is_allowed_drop_selection( const wxGridCellCoords& drop_coords, const std::string& data) { tokenizer tkz(data, "\n"); int start_at_row = drop_coords.GetRow(); while (tkz.has_more_tokens()) { const auto line(tkz.get_next_token()); tokenizer tkz(line, "\t"); int next_col = drop_coords.GetCol(); while (tkz.has_more_tokens() && next_col < GetNumberCols()) { tkz.get_next_token(); // skip the value // If readonly, or this cell is part of the current selection, or outside grid // do not allow. Otherwise when dropping and clearing old selection afterwards, // we also cleared the new cells. // If moving is really supported by wxGrid, this might be changed. if (IsReadOnly(start_at_row, next_col) || IsInSelection(start_at_row, next_col) || start_at_row > GetNumberRows() || next_col > GetNumberCols()) { return false; } next_col++; } start_at_row++; } return true; }
//************************************************************************************* // Creates Clothes Data Structure for an object. //************************************************************************************* void EERIEOBJECT_AddClothesData(EERIE_3DOBJ * obj) { long sel = -1; long selmounocol = -1; for(size_t i = 0; i < obj->selections.size(); i++) { // TODO iterator if(obj->selections[i].name == "mou") { sel = i; break; } } for(size_t i = 0; i < obj->selections.size(); i++) { // TODO iterator if(obj->selections[i].name == "mounocol") { selmounocol = i; break; } } if(sel == -1) return; if(obj->selections[sel].selected.size() > 0) { obj->cdata = new CLOTHES_DATA(); obj->cdata->nb_cvert = (short)obj->selections[sel].selected.size(); obj->cdata->cvert = new CLOTHESVERTEX[obj->cdata->nb_cvert]; memset(obj->cdata->cvert, 0, sizeof(CLOTHESVERTEX)*obj->cdata->nb_cvert); obj->cdata->backup = new CLOTHESVERTEX[obj->cdata->nb_cvert]; memset(obj->cdata->backup, 0, sizeof(CLOTHESVERTEX)*obj->cdata->nb_cvert); } // There is a Mollesse (TM) (C) Selection if(obj->selections[sel].selected.size() > 0) { for(int i = 0; i < obj->cdata->nb_cvert; i++) { obj->cdata->cvert[i].idx = (short)obj->selections[sel].selected[i]; obj->cdata->cvert[i].pos = obj->vertexlist[obj->cdata->cvert[i].idx].v; obj->cdata->cvert[i].t_pos = obj->vertexlist[obj->cdata->cvert[i].idx].v; obj->cdata->cvert[i].mass = 0.5f; if(selmounocol != -1 && IsInSelection(obj, obj->selections[sel].selected[i], selmounocol) >= 0) { obj->cdata->cvert[i].flags = CLOTHES_FLAG_NORMAL | CLOTHES_FLAG_NOCOL; } else { obj->cdata->cvert[i].flags = CLOTHES_FLAG_NORMAL; } obj->cdata->cvert[i].coll = -1; } for(int i = 0; i < obj->cdata->nb_cvert; i++) { for(long j = 0; j < obj->ndata[obj->cdata->cvert[i].idx].nb_Nvertex; j++) { short vert = obj->ndata[obj->cdata->cvert[i].idx].Nvertex[j]; if(IsInSelection(obj, vert, sel) >= 0) { AddSpring(obj, (short)i, (short)GetIDXVert(obj, vert), 11.f, 0.3f, 0); } else { obj->cdata->cvert[i].flags |= CLOTHES_FLAG_FIX; obj->cdata->cvert[i].coll = -2; obj->cdata->cvert[i].mass = 0.f; } } } // Adds more springs (shear) for(int i = 0; i < obj->cdata->nb_cvert; i++) { for(long j = 0; j < obj->ndata[obj->cdata->cvert[i].idx].nb_Nvertex; j++) { short vert = obj->ndata[obj->cdata->cvert[i].idx].Nvertex[j]; if(vert == obj->cdata->cvert[i].idx) continue; // Cannot add a spring between 1 node :p if(IsInSelection(obj, vert, sel) >= 0) { float distance = glm::distance2(obj->vertexlist[obj->cdata->cvert[i].idx].v, obj->vertexlist[vert].v) * square(1.2f); // We springed it in the previous part of code for(long k = 0; k < obj->ndata[vert].nb_Nvertex; k++) { short ver = obj->ndata[vert].Nvertex[k]; if(IsInSelection(obj, ver, sel) >= 0) { // This time we have one ! if(ver == obj->cdata->cvert[i].idx) continue; float distance2 = glm::distance2(obj->vertexlist[obj->cdata->cvert[i].idx].v, obj->vertexlist[ver].v); if(distance2 < distance) { AddSpring(obj, (short)i, (short)GetIDXVert(obj, ver), 4.2f, 0.7f, 1); } } } } } } // Adds more springs (bend) for(int i = 0; i < obj->cdata->nb_cvert; i++) { for(long j = 0; j < obj->ndata[obj->cdata->cvert[i].idx].nb_Nvertex; j++) { short vert = obj->ndata[obj->cdata->cvert[i].idx].Nvertex[j]; if(vert == obj->cdata->cvert[i].idx) continue; // Cannot add a spring between 1 node :p if(IsInSelection(obj, vert, sel) >= 0) { // We springed it in the previous part of code for(long k = 0; k < obj->ndata[vert].nb_Nvertex; k++) { short ver = obj->ndata[vert].Nvertex[k]; if(IsInSelection(obj, ver, sel) >= 0) { // This time we have one ! float distance = glm::distance2(obj->vertexlist[obj->cdata->cvert[i].idx].v, obj->vertexlist[ver].v) * square(1.2f); for(long k2 = 0; k2 < obj->ndata[ver].nb_Nvertex; k2++) { short ve = obj->ndata[ver].Nvertex[k]; if(ve == vert) continue; if(IsInSelection(obj, ve, sel) >= 0) { // This time we have one ! if(obj->cdata->cvert[(short)GetIDXVert(obj, ve)].flags & CLOTHES_FLAG_FIX) continue; float distance2 = glm::distance2(obj->vertexlist[obj->cdata->cvert[i].idx].v, obj->vertexlist[ve].v); if(distance2 > distance && distance2 < distance * square(2.f)) { AddSpring(obj, (short)i, (short)GetIDXVert(obj, ve), 2.2f, 0.9f, 2); } } } } } } } } } }
// TODO copy-paste halo static void AddAnimatedObjectHalo(HaloInfo & haloInfo, const unsigned short * paf, float invisibility, EERIE_3DOBJ * eobj, Entity * io, TexturedVertex * tvList) { IO_HALO * curhalo = NULL; for(size_t h = 0; h < haloInfo.size; h++) { const HaloRenderInfo & entry = haloInfo.entries[h]; if(entry.selection == ObjSelection() || IsInSelection(eobj, paf[0], entry.selection)) { curhalo = entry.halo; break; } } if(!curhalo) return; float tot = 0; float _ffr[3]; ColorRGBA colors[3]; for(size_t o = 0; o < 3; o++) { float tttz = glm::abs(eobj->vertexlist3[paf[o]].norm.z) * ( 1.0f / 2 ); float power = 255.f - (float)(255.f * tttz); power *= (1.f - invisibility); power = glm::clamp(power, 0.f, 255.f); tot += power; _ffr[o] = power; u8 lfr = curhalo->color.r * power; u8 lfg = curhalo->color.g * power; u8 lfb = curhalo->color.b * power; colors[o] = Color(lfr, lfg, lfb, 255).toRGBA(); } if(tot > 260) { long first; long second; long third; if(_ffr[0] >= _ffr[1] && _ffr[1] >= _ffr[2]) { first = 0; second = 1; third = 2; } else if(_ffr[0] >= _ffr[2] && _ffr[2] >= _ffr[1]) { first = 0; second = 2; third = 1; } else if(_ffr[1] >= _ffr[0] && _ffr[0] >= _ffr[2]) { first = 1; second = 0; third = 2; } else if(_ffr[1] >= _ffr[2] && _ffr[2] >= _ffr[0]) { first = 1; second = 2; third = 0; } else if(_ffr[2] >= _ffr[0] && _ffr[0] >= _ffr[1]) { first = 2; second = 0; third = 1; } else { first = 2; second = 1; third = 0; } if(_ffr[first] > 150.f && _ffr[second] > 110.f) { TexturedVertex vert[4]; vert[0] = tvList[first]; vert[1] = tvList[first]; vert[2] = tvList[second]; vert[3] = tvList[second]; vert[0].color = colors[first]; vert[1].color = colors[first]; vert[2].color = colors[second]; vert[3].color = colors[second]; float siz = haloInfo.ddist * (curhalo->radius * (std::sin(arxtime.get_frame_time() * .01f) * .1f + 1.f)) * .6f; if(io == entities.player() && haloInfo.ddist > 0.8f && !EXTERNALVIEW) siz *= 1.5f; Vec3f vect1; vect1.x = tvList[first].p.x - tvList[third].p.x; vect1.y = tvList[first].p.y - tvList[third].p.y; float len1 = 2.f / ffsqrt(vect1.x * vect1.x + vect1.y * vect1.y); if(vect1.x < 0.f) len1 *= 1.2f; vect1.x *= len1; vect1.y *= len1; Vec3f vect2; vect2.x = tvList[second].p.x - tvList[third].p.x; vect2.y = tvList[second].p.y - tvList[third].p.y; float len2 = 1.f / ffsqrt(vect2.x * vect2.x + vect2.y * vect2.y); if(vect2.x < 0.f) len2 *= 1.2f; vect2.x *= len2; vect2.y *= len2; vert[1].p.x += (vect1.x + Random::getf(0.1f, 0.2f)) * siz; vert[1].p.y += (vect1.y + Random::getf(0.1f, 0.2f)) * siz; vert[1].color = Color(0, 0, 0, 255).toRGBA(); float valll; valll = 0.005f + (glm::abs(tvList[first].p.z) - glm::abs(tvList[third].p.z)) + (glm::abs(tvList[second].p.z) - glm::abs(tvList[third].p.z)); valll = 0.0001f + valll * ( 1.0f / 10 ); if(valll < 0.f) valll = 0.f; vert[1].p.z += valll; vert[2].p.z += valll; vert[0].p.z += 0.0001f; vert[3].p.z += 0.0001f;//*( 1.0f / 2 ); vert[1].rhw *= .98f; vert[2].rhw *= .98f; vert[0].rhw *= .98f; vert[3].rhw *= .98f; vert[2].p.x += (vect2.x + Random::getf(0.1f, 0.2f)) * siz; vert[2].p.y += (vect2.y + Random::getf(0.1f, 0.2f)) * siz; vert[1].p.z = (vert[1].p.z + haloInfo.MAX_ZEDE) * ( 1.0f / 2 ); vert[2].p.z = (vert[2].p.z + haloInfo.MAX_ZEDE) * ( 1.0f / 2 ); if(curhalo->flags & HALO_NEGATIVE) vert[2].color = Color(0, 0, 0, 0).toRGBA(); else vert[2].color = Color(0, 0, 0, 255).toRGBA(); Halo_AddVertices(vert); } } }
int TE_DisplayTextEdition(TextEdition *te) { int l, c, state, i=0, upY = -1, downY = -1; char buf[2] = ""; SDL_Rect pos, rect = te->pos; SDL_Surface *surf; CharInfo *ci, *fci, *lci; rect.x = 0; rect.y = 0; rect.w -= VSBWidth(*te); rect.h -= HSBHeight(*te); for (l=0 ; IsLineOK(*te,l) ; l++) { fci = NULL; lci = NULL; for (c=0 ; IsCharOK(te->tab[l][c].c) ; c++) { ci = &(te->tab[l][c]); buf[0] = ci->c == '\n' ? ' ' : ci->c; pos.x = ci->x + te->offsetX; pos.y = ci->y + te->offsetY; pos.w = WidthChar(*te,buf[0]); pos.h = HeigthChar(*te,buf[0]); state = te->focus && IsInSelection(i,te->selection) && !HasJustDisplayStyle(te->style); if (IsRectInRect(pos, rect)) { if (i == te->prevCursorPos || i == te->cursorPos || state != ci->prevState || pos.x != ci->prevX || pos.y != ci->prevY || buf[0] != ci->prevC) { surf = TE_RenderText(buf, *te, state); if (te->blitStyle != TE_BLITSTYLE_SHADED) SDL_BlitSurface(te->tmpSurfSave, &pos, te->tmpSurf, &pos); SDL_BlitSurface(surf, NULL, te->tmpSurf, &pos); SDL_FreeSurface(surf); } lci = ci; if (!fci) fci = ci; } ci->prevState = state; ci->prevX = pos.x; ci->prevY = pos.y; ci->prevC = buf[0]; i++; } if (!lci) lci = &(te->tab[l][c]); else { downY = pos.y; if (upY < 0) upY = pos.y; } pos.x = lci->x + te->offsetX + WidthChar(*te,lci->c); pos.y = lci->y + te->offsetY; pos.h = te->hSpace; if ((pos.w = te->pos.w - pos.x)>0) SDL_BlitSurface(te->tmpSurfSave, &pos, te->tmpSurf, &pos); if (fci) { pos.x = 0; pos.y = fci->y + te->offsetY; pos.h = te->hSpace; if ((pos.w = fci->x + te->offsetX)>0) SDL_BlitSurface(te->tmpSurfSave, &pos, te->tmpSurf, &pos); } for (; te->tab[l][c].c ; c++) te->tab[l][c].prevC = INVALID_CHAR; } pos.y = downY + te->hSpace; pos.x = 0; pos.w = te->pos.w; if ((pos.h = te->pos.h - pos.y)>0) SDL_BlitSurface(te->tmpSurfSave, &pos, te->tmpSurf, &pos); pos.y = 0; pos.x = 0; pos.w = te->pos.w; if ((pos.h = upY)>0) SDL_BlitSurface(te->tmpSurfSave, &pos, te->tmpSurf, &pos); for (; l<te->numLines ; l++) { for (c=0 ; te->tab[l][c].c ; c++) te->tab[l][c].prevC = INVALID_CHAR; } if (!HasJustDisplayStyle(te->style)) DisplayCursor(*te); te->prevCursorPos = te->cursorPos; DisplayScrollBars(te); SDL_BlitSurface(te->tmpSurf, NULL, te->blitSurf, &(te->pos)); return 1; }
wex::grid::grid(const window_data& data) : wxGrid( data.parent(), data.id(), data.pos(), data.size(), data.style(), data.name()) { SetDropTarget(new text_droptarget(this)); m_use_drag_and_drop = true; Bind(wxEVT_MENU, [=](wxCommandEvent& event) { empty_selection();}, wxID_DELETE); Bind(wxEVT_MENU, [=](wxCommandEvent& event) { SelectAll();}, wxID_SELECTALL); Bind(wxEVT_MENU, [=](wxCommandEvent& event) { ClearSelection();}, ID_EDIT_SELECT_NONE); Bind(wxEVT_MENU, [=](wxCommandEvent& event) { copy_selected_cells_to_clipboard();}, wxID_COPY); Bind(wxEVT_MENU, [=](wxCommandEvent& event) { copy_selected_cells_to_clipboard(); empty_selection();}, wxID_CUT); Bind(wxEVT_MENU, [=](wxCommandEvent& event) { paste_cells_from_clipboard();}, wxID_PASTE); Bind(wxEVT_FIND, [=](wxFindDialogEvent& event) { find_next( find_replace_data::get()->get_find_string(), find_replace_data::get()->search_down());}); Bind(wxEVT_FIND_NEXT, [=](wxFindDialogEvent& event) { find_next( find_replace_data::get()->get_find_string(), find_replace_data::get()->search_down());}); Bind(wxEVT_GRID_CELL_LEFT_CLICK, [=](wxGridEvent& event) { // Removed extra check for !IsEditable(), // drag/drop is different from editing, so allow that. if (!IsSelection()) { event.Skip(); return; } if (m_use_drag_and_drop) { // This is because drag/drop is not really supported by the wxGrid. // Even the wxEVT_GRID_CELL_BEGIN_DRAG does not seem to come in. // Therefore, we are really dragging if you click again in // your selection and move mouse and drop elsewhere. // So, if not clicked in the selection, do nothing, this was no drag. if (!IsInSelection(event.GetRow(), event.GetCol())) { event.Skip(); return; } // Is it allowed to drag current selection?? if (!is_allowed_drag_selection()) { event.Skip(); return; } // Start drag operation. wxTextDataObject textData(get_selected_cells_value()); wxDropSource source(textData, this); wxDragResult result = source.DoDragDrop(wxDrag_DefaultMove); if (result != wxDragError && result != wxDragNone && result != wxDragCancel) { // The old contents is not deleted, as should be by moving. // To fix this, do not call Skip so selection remains active, // and call empty_selection. // event.Skip(); empty_selection(); ClearSelection(); } else { // Do not call Skip so selection remains active. // event.Skip(); } } else { event.Skip(); } }); Bind(wxEVT_GRID_CELL_RIGHT_CLICK, [=](wxGridEvent& event) { int style = (IsEditable() ? wex::menu::DEFAULT: wex::menu::IS_READ_ONLY); if (IsSelection()) style |= wex::menu::IS_SELECTED; wex::menu menu(style); build_popup_menu(menu); PopupMenu(&menu); }); Bind(wxEVT_GRID_SELECT_CELL, [=](wxGridEvent& event) { frame::statustext( std::to_string(1 + event.GetCol()) + "," + std::to_string(1 + event.GetRow()), "PaneInfo"); event.Skip();}); Bind(wxEVT_GRID_RANGE_SELECT, [=](wxGridRangeSelectEvent& event) { event.Skip(); frame::statustext(std::to_string(GetSelectedCells().GetCount()), "PaneInfo"); }); Bind(wxEVT_SET_FOCUS, [=](wxFocusEvent& event) { wex::frame* frame = dynamic_cast<wex::frame*>(wxTheApp->GetTopWindow()); if (frame != nullptr) { frame->set_find_focus(this); } event.Skip();}); }
void ARX_NPC_TryToCutSomething(Entity * target, const Vec3f * pos) { //return; if(!target || !(target->ioflags & IO_NPC)) return; if(target->gameFlags & GFLAG_NOGORE) return; float mindistSqr = std::numeric_limits<float>::max(); ObjSelection numsel = ObjSelection(); long goretex = -1; for(size_t i = 0; i < target->obj->texturecontainer.size(); i++) { if(target->obj->texturecontainer[i] && boost::contains(target->obj->texturecontainer[i]->m_texName.string(), "gore") ) { goretex = i; break; } } for(size_t i = 0; i < target->obj->selections.size(); i++) { ObjSelection sel = ObjSelection(i); if(target->obj->selections[i].selected.size() > 0 && boost::contains(target->obj->selections[i].name, "cut_") ) { DismembermentFlag fll = GetCutFlag(target->obj->selections[i].name); if(IsAlreadyCut(target, fll)) continue; long out = 0; for(size_t ll = 0; ll < target->obj->facelist.size(); ll++) { EERIE_FACE & face = target->obj->facelist[ll]; if(face.texid != goretex) { if( IsInSelection(target->obj, face.vid[0], sel) || IsInSelection(target->obj, face.vid[1], sel) || IsInSelection(target->obj, face.vid[2], sel) ) { if(face.facetype & POLY_HIDE) { out++; } } } } if(out < 3) { float dist = glm::distance2(*pos, target->obj->vertexlist3[target->obj->selections[i].selected[0]].v); if(dist < mindistSqr) { mindistSqr = dist; numsel = sel; } } } } if(numsel == ObjSelection()) return; // Nothing to cut... bool hid = false; if(mindistSqr < square(60)) { // can only cut a close part... DismembermentFlag fl = GetCutFlag( target->obj->selections[numsel.handleData()].name ); if(fl && !(target->_npcdata->cuts & fl)) { target->_npcdata->cuts |= fl; hid = ARX_NPC_ApplyCuts(target); } } if(hid) { ARX_SOUND_PlayCinematic("flesh_critical", false); // TODO why play cinmeatic sound? ARX_NPC_SpawnMember(target, numsel); } }
static EERIE_3DOBJ * CreateIntermediaryMesh(const EERIE_3DOBJ * obj1, const EERIE_3DOBJ * obj2, long tw) { ObjSelection tw1 = ObjSelection(); ObjSelection tw2 = ObjSelection(); ObjSelection iw1 = ObjSelection(); ObjSelection jw1 = ObjSelection(); ObjSelection sel_head1 = ObjSelection(); ObjSelection sel_head2 = ObjSelection(); ObjSelection sel_torso1 = ObjSelection(); ObjSelection sel_torso2 = ObjSelection(); ObjSelection sel_legs1 = ObjSelection(); ObjSelection sel_legs2 = ObjSelection(); // First we retreive selection groups indexes for(size_t i = 0; i < obj1->selections.size(); i++) { // TODO iterator ObjSelection sel = ObjSelection(i); if(obj1->selections[i].name == "head") { sel_head1 = sel; } else if(obj1->selections[i].name == "chest") { sel_torso1 = sel; } else if(obj1->selections[i].name == "leggings") { sel_legs1 = sel; } } for(size_t i = 0; i < obj2->selections.size(); i++) { // TODO iterator ObjSelection sel = ObjSelection(i); if(obj2->selections[i].name == "head") { sel_head2 = sel; } else if(obj2->selections[i].name == "chest") { sel_torso2 = sel; } else if(obj2->selections[i].name == "leggings") { sel_legs2 = sel; } } if(sel_head1 == ObjSelection()) return NULL; if(sel_head2 == ObjSelection()) return NULL; if(sel_torso1 == ObjSelection()) return NULL; if(sel_torso2 == ObjSelection()) return NULL; if(sel_legs1 == ObjSelection()) return NULL; if(sel_legs2 == ObjSelection()) return NULL; if(tw == TWEAK_HEAD) { tw1 = sel_head1; tw2 = sel_head2; iw1 = sel_torso1; jw1 = sel_legs1; } if(tw == TWEAK_TORSO) { tw1 = sel_torso1; tw2 = sel_torso2; iw1 = sel_head1; jw1 = sel_legs1; } if(tw == TWEAK_LEGS) { tw1 = sel_legs1; tw2 = sel_legs2; iw1 = sel_torso1; jw1 = sel_head1; } if(tw1 == ObjSelection() || tw2 == ObjSelection()) return NULL; // Now Retreives Tweak Action Points { ActionPoint idx_head1 = GetActionPoint(obj1, "head2chest"); if(idx_head1 == ActionPoint()) return NULL; ActionPoint idx_head2 = GetActionPoint(obj2, "head2chest"); if(idx_head2 == ActionPoint()) return NULL; ActionPoint idx_torso1 = GetActionPoint(obj1, "chest2leggings"); if(idx_torso1 == ActionPoint()) return NULL; ActionPoint idx_torso2 = GetActionPoint(obj2, "chest2leggings"); if(idx_torso2 == ActionPoint()) return NULL; } // copy vertices std::vector<EERIE_VERTEX> obj1vertexlist2 = obj1->vertexlist; std::vector<EERIE_VERTEX> obj2vertexlist2 = obj2->vertexlist; // Work will contain the Tweaked object EERIE_3DOBJ * work = new EERIE_3DOBJ; work->pos = obj1->pos; work->angle = obj1->angle; // We reset all data to create a fresh object work->cub = obj1->cub; work->quat = obj1->quat; // Linked objects are linked to this object. if(obj1->linked.size() > obj2->linked.size()) { work->linked = obj1->linked; } else { work->linked = obj2->linked; } // Is the origin of object in obj1 or obj2 ? Retreives it for work object if(IsInSelection(obj1, obj1->origin, tw1)) { work->point0 = obj2->point0; work->origin = ObjectAddVertex(work, &obj2vertexlist2[obj2->origin]); } else { work->point0 = obj1->point0; work->origin = ObjectAddVertex(work, &obj1vertexlist2[obj1->origin]); } // Recreate Action Points included in work object.for Obj1 for(size_t i = 0; i < obj1->actionlist.size(); i++) { const EERIE_ACTIONLIST & action = obj1->actionlist[i]; if( IsInSelection(obj1, action.idx.handleData(), iw1) || IsInSelection(obj1, action.idx.handleData(), jw1) || action.name == "head2chest" || action.name == "chest2leggings" ) { ObjectAddAction(work, action.name, action.act, action.sfx, &obj1vertexlist2[action.idx.handleData()]); } } // Do the same for Obj2 for(size_t i = 0; i < obj2->actionlist.size(); i++) { const EERIE_ACTIONLIST & action = obj2->actionlist[i]; if( IsInSelection(obj2, action.idx.handleData(), tw2) || action.name == "head2chest" || action.name == "chest2leggings" ) { ObjectAddAction(work, action.name, action.act, action.sfx, &obj2vertexlist2[action.idx.handleData()]); } } // Recreate Vertex using Obj1 Vertexes for(size_t i = 0; i < obj1->vertexlist.size(); i++) { if(IsInSelection(obj1, i, iw1) || IsInSelection(obj1, i, jw1)) { ObjectAddVertex(work, &obj1vertexlist2[i]); } } // The same for Obj2 for(size_t i = 0; i < obj2->vertexlist.size(); i++) { if(IsInSelection(obj2, i, tw2)) { ObjectAddVertex(work, &obj2vertexlist2[i]); } } // Look in Faces for forgotten Vertexes... AND // Re-Create TextureContainers Infos // We look for texturecontainers included in the future tweaked object TextureContainer * tc = NULL; for(size_t i = 0; i < obj1->facelist.size(); i++) { const EERIE_FACE & face = obj1->facelist[i]; if( (IsInSelection(obj1, face.vid[0], iw1) || IsInSelection(obj1, face.vid[0], jw1)) && (IsInSelection(obj1, face.vid[1], iw1) || IsInSelection(obj1, face.vid[1], jw1)) && (IsInSelection(obj1, face.vid[2], iw1) || IsInSelection(obj1, face.vid[2], jw1)) ) { if(face.texid != -1) { if(tc != obj1->texturecontainer[face.texid]) { tc = obj1->texturecontainer[face.texid]; ObjectAddMap(work, tc); } } ObjectAddFace(work, &face, obj1); } } for(size_t i = 0; i < obj2->facelist.size(); i++) { const EERIE_FACE & face = obj2->facelist[i]; if( IsInSelection(obj2, face.vid[0], tw2) || IsInSelection(obj2, face.vid[1], tw2) || IsInSelection(obj2, face.vid[2], tw2) ) { if(face.texid != -1) { if(tc != obj2->texturecontainer[face.texid]) { tc = obj2->texturecontainer[face.texid]; ObjectAddMap(work, tc); } } ObjectAddFace(work, &face, obj2); } } // Recreate Groups work->grouplist.resize(std::max(obj1->grouplist.size(), obj2->grouplist.size())); for(size_t k = 0; k < obj1->grouplist.size(); k++) { const VertexGroup & grp = obj1->grouplist[k]; work->grouplist[k].name = grp.name; long v = GetEquivalentVertex(work, &obj1vertexlist2[grp.origin]); if(v >= 0) { work->grouplist[k].siz = grp.siz; if(IsInSelection(obj1, grp.origin, iw1) || IsInSelection(obj1, grp.origin, jw1)) work->grouplist[k].origin = v; } } for(size_t k = 0; k < obj2->grouplist.size(); k++) { if(k >= obj1->grouplist.size()) { work->grouplist[k].name = obj2->grouplist[k].name; } long v = GetEquivalentVertex(work, &obj2vertexlist2[obj2->grouplist[k].origin]); if(v >= 0) { work->grouplist[k].siz = obj2->grouplist[k].siz; if(IsInSelection(obj2, obj2->grouplist[k].origin, tw2)) work->grouplist[k].origin = v; } } // Recreate Selection Groups (only the 3 selections needed to reiterate MeshTweaking !) work->selections.resize(3); work->selections[0].name = "head"; work->selections[1].name = "chest"; work->selections[2].name = "leggings"; // Re-Creating sel_head if(tw == TWEAK_HEAD) { const EERIE_SELECTIONS & sel = obj2->selections[sel_head2.handleData()]; for(size_t l = 0; l < sel.selected.size(); l++) { EERIE_VERTEX temp; temp.v = obj2vertexlist2[sel.selected[l]].v; long t = GetEquivalentVertex(work, &temp); if(t != -1) { ObjectAddSelection(work, 0, t); } } } else { const EERIE_SELECTIONS & sel = obj1->selections[sel_head1.handleData()]; for(size_t l = 0; l < sel.selected.size(); l++) { EERIE_VERTEX temp; temp.v = obj1vertexlist2[sel.selected[l]].v; long t = GetEquivalentVertex(work, &temp); if(t != -1) { ObjectAddSelection(work, 0, t); } } } // Re-Create sel_torso if(tw == TWEAK_TORSO) { const EERIE_SELECTIONS & sel = obj2->selections[sel_torso2.handleData()]; for(size_t l = 0; l < sel.selected.size(); l++) { EERIE_VERTEX temp; temp.v = obj2vertexlist2[sel.selected[l]].v; long t = GetEquivalentVertex(work, &temp); if(t != -1) { ObjectAddSelection(work, 1, t); } } } else { const EERIE_SELECTIONS & sel = obj1->selections[sel_torso1.handleData()]; for(size_t l = 0; l < sel.selected.size(); l++) { EERIE_VERTEX temp; temp.v = obj1vertexlist2[sel.selected[l]].v; long t = GetEquivalentVertex(work, &temp); if(t != -1) { ObjectAddSelection(work, 1, t); } } } // Re-Create sel_legs if(tw == TWEAK_LEGS) { const EERIE_SELECTIONS & sel = obj2->selections[sel_legs2.handleData()]; for(size_t l = 0; l < sel.selected.size(); l++) { EERIE_VERTEX temp; temp.v = obj2vertexlist2[sel.selected[l]].v; long t = GetEquivalentVertex(work, &temp); if(t != -1) { ObjectAddSelection(work, 2, t); } } } else { const EERIE_SELECTIONS & sel = obj1->selections[sel_legs1.handleData()]; for(size_t l = 0; l < sel.selected.size(); l++) { EERIE_VERTEX temp; temp.v = obj1vertexlist2[sel.selected[l]].v; long t = GetEquivalentVertex(work, &temp); if(t != -1) { ObjectAddSelection(work, 2, t); } } } //Now recreates other selections... for(size_t i = 0; i < obj1->selections.size(); i++) { if(EERIE_OBJECT_GetSelection(work, obj1->selections[i].name) == ObjSelection()) { size_t num = work->selections.size(); work->selections.resize(num + 1); work->selections[num].name = obj1->selections[i].name; for(size_t l = 0; l < obj1->selections[i].selected.size(); l++) { EERIE_VERTEX temp; temp.v = obj1vertexlist2[obj1->selections[i].selected[l]].v; long t = GetEquivalentVertex(work, &temp); if (t != -1) { ObjectAddSelection(work, num, t); } } ObjSelection ii = EERIE_OBJECT_GetSelection(obj2, obj1->selections[i].name); if(ii != ObjSelection()) { const EERIE_SELECTIONS & sel = obj2->selections[ii.handleData()]; for(size_t l = 0; l < sel.selected.size(); l++) { EERIE_VERTEX temp; temp.v = obj2vertexlist2[sel.selected[l]].v; long t = GetEquivalentVertex(work, &temp); if(t != -1) { ObjectAddSelection(work, num, t); } } } } } for(size_t i = 0; i < obj2->selections.size(); i++) { if(EERIE_OBJECT_GetSelection(work, obj2->selections[i].name) == ObjSelection()) { size_t num = work->selections.size(); work->selections.resize(num + 1); work->selections[num].name = obj2->selections[i].name; for(size_t l = 0; l < obj2->selections[i].selected.size(); l++) { EERIE_VERTEX temp; temp.v = obj2vertexlist2[obj2->selections[i].selected[l]].v; long t = GetEquivalentVertex(work, &temp); if(t != -1) { ObjectAddSelection(work, num, t); } } } } // Recreate Animation-groups vertex for(size_t i = 0; i < obj1->grouplist.size(); i++) { for(size_t j = 0; j < obj1->grouplist[i].indexes.size(); j++) { AddVertexToGroup(work, i, &obj1vertexlist2[obj1->grouplist[i].indexes[j]]); } } for(size_t i = 0; i < obj2->grouplist.size(); i++) { for(size_t j = 0; j < obj2->grouplist[i].indexes.size(); j++) { AddVertexToGroup(work, i, &obj2vertexlist2[obj2->grouplist[i].indexes[j]]); } } work->vertexWorldPositions.resize(work->vertexlist.size()); work->vertexClipPositions.resize(work->vertexlist.size()); work->vertexColors.resize(work->vertexlist.size()); return work; }
void wxGridSelection::ToggleCellSelection(int row, int col, const wxKeyboardState& kbd) { // if the cell is not selected, select it if ( !IsInSelection ( row, col ) ) { SelectCell(row, col, kbd); return; } // otherwise deselect it. This can be simple or more or // less difficult, depending on how the cell is selected. size_t count, n; // The simplest case: The cell is contained in m_cellSelection // Then it can't be contained in rows/cols/block (since those // would remove the cell from m_cellSelection on creation), so // we just have to remove it from m_cellSelection. if ( m_selectionMode == wxGrid::wxGridSelectCells ) { count = m_cellSelection.GetCount(); for ( n = 0; n < count; n++ ) { const wxGridCellCoords& sel = m_cellSelection[n]; if ( row == sel.GetRow() && col == sel.GetCol() ) { wxGridCellCoords coords = m_cellSelection[n]; m_cellSelection.RemoveAt(n); if ( !m_grid->GetBatchCount() ) { wxRect r = m_grid->BlockToDeviceRect( coords, coords ); ((wxWindow *)m_grid->m_gridWin)->Refresh( false, &r ); } // Send event wxGridRangeSelectEvent gridEvt( m_grid->GetId(), wxEVT_GRID_RANGE_SELECT, m_grid, wxGridCellCoords( row, col ), wxGridCellCoords( row, col ), false, kbd ); m_grid->GetEventHandler()->ProcessEvent( gridEvt ); return; } } } // The most difficult case: The cell is member of one or even several // blocks. Split each such block in up to 4 new parts, that don't // contain the cell to be selected, like this: // |---------------------------| // | | // | part 1 | // | | // |---------------------------| // | part 3 |x| part 4 | // |---------------------------| // | | // | part 2 | // | | // |---------------------------| // (The x marks the newly deselected cell). // Note: in row selection mode, we only need part1 and part2; // in column selection mode, we only need part 3 and part4, // which are expanded to whole columns automatically! count = m_blockSelectionTopLeft.GetCount(); for ( n = 0; n < count; n++ ) { wxGridCellCoords& coords1 = m_blockSelectionTopLeft[n]; wxGridCellCoords& coords2 = m_blockSelectionBottomRight[n]; int topRow = coords1.GetRow(); int leftCol = coords1.GetCol(); int bottomRow = coords2.GetRow(); int rightCol = coords2.GetCol(); if ( BlockContainsCell( topRow, leftCol, bottomRow, rightCol, row, col ) ) { // remove the block m_blockSelectionTopLeft.RemoveAt(n); m_blockSelectionBottomRight.RemoveAt(n); n--; count--; // add up to 4 smaller blocks and set update region if ( m_selectionMode != wxGrid::wxGridSelectColumns ) { if ( topRow < row ) SelectBlockNoEvent(topRow, leftCol, row - 1, rightCol); if ( bottomRow > row ) SelectBlockNoEvent(row + 1, leftCol, bottomRow, rightCol); } if ( m_selectionMode != wxGrid::wxGridSelectRows ) { if ( leftCol < col ) SelectBlockNoEvent(row, leftCol, row, col - 1); if ( rightCol > col ) SelectBlockNoEvent(row, col + 1, row, rightCol); } } } bool rowSelectionWasChanged = false; // remove a cell from a row, adding up to two new blocks if ( m_selectionMode != wxGrid::wxGridSelectColumns ) { count = m_rowSelection.GetCount(); for ( n = 0; n < count; n++ ) { if ( m_rowSelection[n] == row ) { m_rowSelection.RemoveAt(n); n--; count--; rowSelectionWasChanged = true; if (m_selectionMode == wxGrid::wxGridSelectCells) { if ( col > 0 ) SelectBlockNoEvent(row, 0, row, col - 1); if ( col < m_grid->GetNumberCols() - 1 ) SelectBlockNoEvent( row, col + 1, row, m_grid->GetNumberCols() - 1); } } } } bool colSelectionWasChanged = false; // remove a cell from a column, adding up to two new blocks if ( m_selectionMode != wxGrid::wxGridSelectRows ) { count = m_colSelection.GetCount(); for ( n = 0; n < count; n++ ) { if ( m_colSelection[n] == col ) { m_colSelection.RemoveAt(n); n--; count--; colSelectionWasChanged = true; if (m_selectionMode == wxGrid::wxGridSelectCells) { if ( row > 0 ) SelectBlockNoEvent(0, col, row - 1, col); if ( row < m_grid->GetNumberRows() - 1 ) SelectBlockNoEvent(row + 1, col, m_grid->GetNumberRows() - 1, col); } } } } // Refresh the screen and send the event; according to m_selectionMode, // we need to either update only the cell, or the whole row/column. wxRect r; if ( m_selectionMode == wxGrid::wxGridSelectCells ) { if ( !m_grid->GetBatchCount() ) { r = m_grid->BlockToDeviceRect( wxGridCellCoords( row, col ), wxGridCellCoords( row, col ) ); ((wxWindow *)m_grid->m_gridWin)->Refresh( false, &r ); } wxGridRangeSelectEvent gridEvt( m_grid->GetId(), wxEVT_GRID_RANGE_SELECT, m_grid, wxGridCellCoords( row, col ), wxGridCellCoords( row, col ), false, kbd ); m_grid->GetEventHandler()->ProcessEvent( gridEvt ); } else // rows/columns selection mode { if ( m_selectionMode != wxGrid::wxGridSelectColumns && rowSelectionWasChanged ) { int numCols = m_grid->GetNumberCols(); for ( int colFrom = 0, colTo = 0; colTo <= numCols; ++colTo ) { if ( m_colSelection.Index(colTo) >= 0 || colTo == numCols ) { if ( colFrom < colTo ) { if ( !m_grid->GetBatchCount() ) { r = m_grid->BlockToDeviceRect( wxGridCellCoords( row, colFrom ), wxGridCellCoords( row, colTo-1 ) ); ((wxWindow *)m_grid->m_gridWin)->Refresh( false, &r ); } wxGridRangeSelectEvent gridEvt( m_grid->GetId(), wxEVT_GRID_RANGE_SELECT, m_grid, wxGridCellCoords( row, colFrom ), wxGridCellCoords( row, colTo - 1 ), false, kbd ); m_grid->GetEventHandler()->ProcessEvent( gridEvt ); } colFrom = colTo + 1; } } } if ( m_selectionMode != wxGrid::wxGridSelectRows && colSelectionWasChanged ) { int numRows = m_grid->GetNumberRows(); for ( int rowFrom = 0, rowTo = 0; rowTo <= numRows; ++rowTo ) { if ( m_rowSelection.Index(rowTo) >= 0 || rowTo == numRows ) { if (rowFrom < rowTo) { if ( !m_grid->GetBatchCount() ) { r = m_grid->BlockToDeviceRect( wxGridCellCoords( rowFrom, col ), wxGridCellCoords( rowTo - 1, col ) ); ((wxWindow *)m_grid->m_gridWin)->Refresh( false, &r ); } wxGridRangeSelectEvent gridEvt( m_grid->GetId(), wxEVT_GRID_RANGE_SELECT, m_grid, wxGridCellCoords( rowFrom, col ), wxGridCellCoords( rowTo - 1, col ), false, kbd ); m_grid->GetEventHandler()->ProcessEvent( gridEvt ); } rowFrom = rowTo + 1; } } } } }
////////////// // Draw image void BaseGrid::DrawImage(wxDC &dc) { dc.BeginDrawing(); // Get size and pos int w = 0; int h = 0; GetClientSize(&w,&h); // Set font dc.SetFont(font); // Clear background dc.SetBackground(wxBrush(Options.AsColour(_T("Grid Background")))); dc.Clear(); // Draw labels dc.SetPen(*wxTRANSPARENT_PEN); dc.SetBrush(wxBrush(Options.AsColour(_T("Grid left column")))); dc.DrawRectangle(0,lineHeight,colWidth[0],h-lineHeight); // Visible lines int drawPerScreen = h/lineHeight + 1; int nDraw = MID(0,drawPerScreen,GetRows()-yPos); int maxH = (nDraw+1) * lineHeight; // Row colors std::vector<wxBrush> rowColors; std::vector<wxColor> foreColors; rowColors.push_back(wxBrush(Options.AsColour(_T("Grid Background")))); // 0 = Standard foreColors.push_back(Options.AsColour(_T("Grid standard foreground"))); rowColors.push_back(wxBrush(Options.AsColour(_T("Grid Header")))); // 1 = Header foreColors.push_back(Options.AsColour(_T("Grid standard foreground"))); rowColors.push_back(wxBrush(Options.AsColour(_T("Grid selection background")))); // 2 = Selected foreColors.push_back(Options.AsColour(_T("Grid selection foreground"))); rowColors.push_back(wxBrush(Options.AsColour(_T("Grid comment background")))); // 3 = Commented foreColors.push_back(Options.AsColour(_T("Grid selection foreground"))); rowColors.push_back(wxBrush(Options.AsColour(_T("Grid inframe background")))); // 4 = Video Highlighted foreColors.push_back(Options.AsColour(_T("Grid selection foreground"))); rowColors.push_back(wxBrush(Options.AsColour(_T("Grid selected comment background")))); // 5 = Commented & selected foreColors.push_back(Options.AsColour(_T("Grid selection foreground"))); // First grid row bool drawGrid = true; if (drawGrid) { dc.SetPen(wxPen(Options.AsColour(_T("Grid lines")))); dc.DrawLine(0,0,w,0); dc.SetPen(*wxTRANSPARENT_PEN); } // Draw rows int dx = 0; int dy = 0; int curColor = 0; AssDialogue *curDiag; for (int i=0;i<nDraw+1;i++) { // Prepare int curRow = i+yPos-1; curDiag = GetDialogue(curRow); dx = 0; dy = i*lineHeight; // Check for collisions bool collides = false; if (curDiag) { AssDialogue *sel = GetDialogue(editBox->linen); if (sel && sel != curDiag) { if (curDiag->CollidesWith(sel)) collides = true; } } // Text array wxArrayString strings; // Header if (i == 0) { strings.Add(_("#")); strings.Add(_("L")); strings.Add(_("Start")); strings.Add(_("End")); strings.Add(_("Style")); strings.Add(_("Actor")); strings.Add(_("Effect")); strings.Add(_("Left")); strings.Add(_("Right")); strings.Add(_("Vert")); strings.Add(_("Text")); curColor = 1; } // Lines else if (curDiag) { // Set fields strings.Add(wxString::Format(_T("%i"),curRow+1)); strings.Add(wxString::Format(_T("%i"),curDiag->Layer)); if (byFrame) { strings.Add(wxString::Format(_T("%i"),VFR_Output.GetFrameAtTime(curDiag->Start.GetMS(),true))); strings.Add(wxString::Format(_T("%i"),VFR_Output.GetFrameAtTime(curDiag->End.GetMS(),true))); } else { strings.Add(curDiag->Start.GetASSFormated()); strings.Add(curDiag->End.GetASSFormated()); } strings.Add(curDiag->Style); strings.Add(curDiag->Actor); strings.Add(curDiag->Effect); strings.Add(curDiag->GetMarginString(1)); strings.Add(curDiag->GetMarginString(2)); strings.Add(curDiag->GetMarginString(3)); // Set text int mode = Options.AsInt(_T("Grid Hide Overrides")); wxString value = _T(""); // Hidden overrides if (mode == 1 || mode == 2) { wxString replaceWith = Options.AsText(_T("Grid hide overrides char")); curDiag->ParseASSTags(); size_t n = curDiag->Blocks.size(); for (size_t i=0;i<n;i++) { AssDialogueBlock *block = curDiag->Blocks.at(i); AssDialogueBlockPlain *plain = AssDialogueBlock::GetAsPlain(block); if (plain) { value += plain->GetText(); } else { if (mode == 1) { value += replaceWith; } } } curDiag->ClearBlocks(); } // Show overrides else value = curDiag->Text; // Cap length and set text if (value.Length() > 512) value = value.Left(512) + _T("..."); strings.Add(value); // Set color curColor = 0; bool inSel = IsInSelection(curRow,0); if (inSel && curDiag->Comment) curColor = 5; else if (inSel) curColor = 2; else if (curDiag->Comment) curColor = 3; else if (Options.AsBool(_T("Highlight subs in frame")) && IsDisplayed(curDiag)) curColor = 4; } else { for (int j=0;j<11;j++) strings.Add(_T("?")); } // Draw row background color if (curColor) { dc.SetBrush(rowColors[curColor]); dc.DrawRectangle((curColor == 1) ? 0 : colWidth[0],i*lineHeight+1,w,lineHeight); } // Set text color if (collides) dc.SetTextForeground(Options.AsColour(_T("Grid collision foreground"))); else { dc.SetTextForeground(foreColors[curColor]); } // Draw text wxRect cur; bool isCenter; for (int j=0;j<11;j++) { // Is center? isCenter = !(j == 4 || j == 5 || j == 6 || j == 10); // Calculate clipping cur = wxRect(dx+4,dy,colWidth[j]-6,lineHeight); // Set clipping dc.DestroyClippingRegion(); dc.SetClippingRegion(cur); // Draw dc.DrawLabel(strings[j],cur,isCenter ? wxALIGN_CENTER : (wxALIGN_CENTER_VERTICAL | wxALIGN_LEFT)); dx += colWidth[j]; } //if (collides) dc.SetPen(wxPen(wxColour(255,0,0))); // Draw grid dc.DestroyClippingRegion(); if (drawGrid) { dc.SetPen(wxPen(Options.AsColour(_T("Grid lines")))); dc.DrawLine(0,dy+lineHeight,w,dy+lineHeight); dc.SetPen(*wxTRANSPARENT_PEN); } } // Draw grid columns dx = 0; if (drawGrid) { dc.SetPen(wxPen(Options.AsColour(_T("Grid lines")))); for (int i=0;i<10;i++) { dx += colWidth[i]; dc.DrawLine(dx,0,dx,maxH); } dc.DrawLine(0,0,0,maxH); dc.DrawLine(w-1,0,w-1,h); } // Draw currently active line border dc.SetPen(wxPen(Options.AsColour(_T("Grid Active border")))); dc.SetBrush(*wxTRANSPARENT_BRUSH); dy = (editBox->linen+1-yPos) * lineHeight; dc.DrawRectangle(0,dy,w,lineHeight+1); // Done dc.EndDrawing(); }
//************************************************************************************* //************************************************************************************* EERIE_3DOBJ * CreateIntermediaryMesh(EERIE_3DOBJ * obj1, EERIE_3DOBJ * obj2, long tw) { long i; long tw1 = -1; long tw2 = -1; long iw1 = -1; long iw2 = -1; long jw1 = -1; long jw2 = -1; long sel_head1 = -1; long sel_head2 = -1; long sel_torso1 = -1; long sel_torso2 = -1; long sel_legs1 = -1; long sel_legs2 = -1; // First we retreive selection groups indexes for (i = 0; i < obj1->nbselections; i++) { if (!strcasecmp(obj1->selections[i].name, "head")) sel_head1 = i; else if (!strcasecmp(obj1->selections[i].name, "chest")) sel_torso1 = i; else if (!strcasecmp(obj1->selections[i].name, "leggings")) sel_legs1 = i; } for (i = 0; i < obj2->nbselections; i++) { if (!strcasecmp(obj2->selections[i].name, "head")) sel_head2 = i; else if (!strcasecmp(obj2->selections[i].name, "chest")) sel_torso2 = i; else if (!strcasecmp(obj2->selections[i].name, "leggings")) sel_legs2 = i; } if (sel_head1 == -1) return NULL; if (sel_head2 == -1) return NULL; if (sel_torso1 == -1) return NULL; if (sel_torso2 == -1) return NULL; if (sel_legs1 == -1) return NULL; if (sel_legs2 == -1) return NULL; if (tw == TWEAK_HEAD) { tw1 = sel_head1; tw2 = sel_head2; iw1 = sel_torso1; iw2 = sel_torso2; jw1 = sel_legs1; jw2 = sel_legs2; } if (tw == TWEAK_TORSO) { tw1 = sel_torso1; tw2 = sel_torso2; iw1 = sel_head1; iw2 = sel_head2; jw1 = sel_legs1; jw2 = sel_legs2; } if (tw == TWEAK_LEGS) { tw1 = sel_legs1; tw2 = sel_legs2; iw1 = sel_torso1; iw2 = sel_torso2; jw1 = sel_head1; jw2 = sel_head2; } if ((tw1 == -1) || (tw2 == -1)) return NULL; // Now Retreives Tweak Action Points { long idx_head1, idx_head2; long idx_torso1, idx_torso2; long idx_legs1, idx_legs2; idx_head1 = GetActionPoint(obj1, "head2chest"); if (idx_head1 < 0) return NULL; idx_head2 = GetActionPoint(obj2, "head2chest"); if (idx_head2 < 0) return NULL; idx_torso1 = GetActionPoint(obj1, "chest2leggings"); if (idx_torso1 < 0) return NULL; idx_torso2 = GetActionPoint(obj2, "chest2leggings"); if (idx_torso2 < 0) return NULL; idx_legs1 = obj1->origin; idx_legs2 = obj2->origin; } // copy vertexes EERIE_VERTEX * obj1vertexlist2 = NULL; EERIE_VERTEX * obj2vertexlist2 = NULL; obj1vertexlist2 = (EERIE_VERTEX *)malloc(sizeof(EERIE_VERTEX) * obj1->nbvertex); obj2vertexlist2 = (EERIE_VERTEX *)malloc(sizeof(EERIE_VERTEX) * obj2->nbvertex); memcpy(obj1vertexlist2, obj1->vertexlist, sizeof(EERIE_VERTEX)*obj1->nbvertex); memcpy(obj2vertexlist2, obj2->vertexlist, sizeof(EERIE_VERTEX)*obj2->nbvertex); // Work will contain the Tweaked object EERIE_3DOBJ * work = NULL; work = (EERIE_3DOBJ *)malloc(sizeof(EERIE_3DOBJ)); memset(work, 0, sizeof(EERIE_3DOBJ)); memcpy(&work->pos, &obj1->pos, sizeof(EERIE_3D)); memcpy(&work->angle, &obj1->angle, sizeof(EERIE_3D)); // ident will be the same as original object obj1 work->ident = obj1->ident; // We reset all data to create a fresh object memcpy(&work->cub, &obj1->cub, sizeof(CUB3D)); memcpy(&work->quat, &obj1->quat, sizeof(EERIE_QUAT)); // Linked objects are linked to this object. if (obj1->nblinked > obj2->nblinked) { work->linked = (EERIE_LINKED *)malloc(obj1->nblinked * sizeof(EERIE_LINKED)); memcpy(work->linked, obj1->linked, obj1->nblinked * sizeof(EERIE_LINKED)); work->nblinked = obj1->nblinked; } else if (obj2->nblinked > 0) { work->linked = (EERIE_LINKED *)malloc(obj2->nblinked * sizeof(EERIE_LINKED)); memcpy(work->linked, obj2->linked, obj2->nblinked * sizeof(EERIE_LINKED)); work->nblinked = obj2->nblinked; } else { work->linked = NULL; work->nblinked = 0; } // Is the origin of object in obj1 or obj2 ? Retreives it for work object if (IsInSelection(obj1, obj1->origin, tw1) != -1) { work->point0.x = obj2->point0.x; work->point0.y = obj2->point0.y; work->point0.z = obj2->point0.z; work->origin = ObjectAddVertex(work, &obj2vertexlist2[obj2->origin]); } else { work->point0.x = obj1->point0.x; work->point0.y = obj1->point0.y; work->point0.z = obj1->point0.z; work->origin = ObjectAddVertex(work, &obj1vertexlist2[obj1->origin]); } // Recreate Action Points included in work object.for Obj1 for (i = 0; i < obj1->nbaction; i++) { if ((IsInSelection(obj1, obj1->actionlist[i].idx, iw1) != -1) || (IsInSelection(obj1, obj1->actionlist[i].idx, jw1) != -1) || (!strcasecmp(obj1->actionlist[i].name, "head2chest")) || (!strcasecmp(obj1->actionlist[i].name, "chest2leggings")) ) { ObjectAddAction(work, obj1->actionlist[i].name, obj1->actionlist[i].act, obj1->actionlist[i].sfx, &obj1vertexlist2[obj1->actionlist[i].idx]); } } // Do the same for Obj2 for (i = 0; i < obj2->nbaction; i++) { if ((IsInSelection(obj2, obj2->actionlist[i].idx, tw2) != -1) || (!strcasecmp(obj1->actionlist[i].name, "head2chest")) || (!strcasecmp(obj1->actionlist[i].name, "chest2leggings")) ) { ObjectAddAction(work, obj2->actionlist[i].name, obj2->actionlist[i].act, obj2->actionlist[i].sfx, &obj2vertexlist2[obj2->actionlist[i].idx]); } } // Recreate Vertex using Obj1 Vertexes for (i = 0; i < obj1->nbvertex; i++) { if ((IsInSelection(obj1, i, iw1) != -1) || (IsInSelection(obj1, i, jw1) != -1)) { ObjectAddVertex(work, &obj1vertexlist2[i]); } } // The same for Obj2 for (i = 0; i < obj2->nbvertex; i++) { if (IsInSelection(obj2, i, tw2) != -1) { ObjectAddVertex(work, &obj2vertexlist2[i]); } } // Look in Faces for forgotten Vertexes... AND // Re-Create TextureContainers Infos // We look for texturecontainers included in the future tweaked object TextureContainer * tc = NULL; for (i = 0; i < obj1->nbfaces; i++) { if (((IsInSelection(obj1, obj1->facelist[i].vid[0], iw1) != -1) || (IsInSelection(obj1, obj1->facelist[i].vid[0], jw1) != -1)) && ((IsInSelection(obj1, obj1->facelist[i].vid[1], iw1) != -1) || (IsInSelection(obj1, obj1->facelist[i].vid[1], jw1) != -1)) && ((IsInSelection(obj1, obj1->facelist[i].vid[2], iw1) != -1) || (IsInSelection(obj1, obj1->facelist[i].vid[2], jw1) != -1)) ) { if (obj1->facelist[i].texid != -1) if (tc != obj1->texturecontainer[obj1->facelist[i].texid]) { tc = obj1->texturecontainer[obj1->facelist[i].texid]; ObjectAddMap(work, tc); } ObjectAddFace(work, &obj1->facelist[i], obj1); } } for (i = 0; i < obj2->nbfaces; i++) { if ((IsInSelection(obj2, obj2->facelist[i].vid[0], tw2) != -1) || (IsInSelection(obj2, obj2->facelist[i].vid[1], tw2) != -1) || (IsInSelection(obj2, obj2->facelist[i].vid[2], tw2) != -1)) { if (obj2->facelist[i].texid != -1) if (tc != obj2->texturecontainer[obj2->facelist[i].texid]) { tc = obj2->texturecontainer[obj2->facelist[i].texid]; ObjectAddMap(work, tc); } ObjectAddFace(work, &obj2->facelist[i], obj2); } } // Recreate Groups work->nbgroups = max(obj1->nbgroups, obj2->nbgroups); work->grouplist = (EERIE_GROUPLIST *)malloc(sizeof(EERIE_GROUPLIST) * work->nbgroups); memset(work->grouplist, 0, sizeof(EERIE_GROUPLIST)*work->nbgroups); for (long k = 0; k < obj1->nbgroups; k++) { strcpy(work->grouplist[k].name, obj1->grouplist[k].name); long v = GetEquivalentVertex(work, &obj1vertexlist2[obj1->grouplist[k].origin]); if (v >= 0) { work->grouplist[k].siz = obj1->grouplist[k].siz; if ((IsInSelection(obj1, obj1->grouplist[k].origin, iw1) != -1) || (IsInSelection(obj1, obj1->grouplist[k].origin, jw1) != -1)) work->grouplist[k].origin = v; } } for (int k = 0; k < obj2->nbgroups; k++) { if (k >= obj1->nbgroups) { strcpy(work->grouplist[k].name, obj2->grouplist[k].name); } long v = GetEquivalentVertex(work, &obj2vertexlist2[obj2->grouplist[k].origin]); if (v >= 0) { work->grouplist[k].siz = obj2->grouplist[k].siz; if (IsInSelection(obj2, obj2->grouplist[k].origin, tw2) != -1) work->grouplist[k].origin = v; } } // Recreate Selection Groups (only the 3 selections needed to reiterate MeshTweaking !) work->nbselections = 3; work->selections = (EERIE_SELECTIONS *)malloc(sizeof(EERIE_SELECTIONS) * work->nbselections); memset(work->selections, 0, sizeof(EERIE_SELECTIONS)*work->nbselections); strcpy(work->selections[0].name, "head"); strcpy(work->selections[1].name, "chest"); strcpy(work->selections[2].name, "leggings"); // Re-Creating sel_head if (tw == TWEAK_HEAD) { for (long l = 0; l < obj2->selections[sel_head2].nb_selected; l++) { EERIE_VERTEX temp; temp.v.x = obj2vertexlist2[obj2->selections[sel_head2].selected[l]].v.x; temp.v.y = obj2vertexlist2[obj2->selections[sel_head2].selected[l]].v.y; temp.v.z = obj2vertexlist2[obj2->selections[sel_head2].selected[l]].v.z; long t = GetEquivalentVertex(work, &temp); if (t != -1) { ObjectAddSelection(work, 0, t); } } } else for (long l = 0; l < obj1->selections[sel_head1].nb_selected; l++) { EERIE_VERTEX temp; temp.v.x = obj1vertexlist2[obj1->selections[sel_head1].selected[l]].v.x; temp.v.y = obj1vertexlist2[obj1->selections[sel_head1].selected[l]].v.y; temp.v.z = obj1vertexlist2[obj1->selections[sel_head1].selected[l]].v.z; long t = GetEquivalentVertex(work, &temp); if (t != -1) { ObjectAddSelection(work, 0, t); } } // Re-Create sel_torso if (tw == TWEAK_TORSO) { for (long l = 0; l < obj2->selections[sel_torso2].nb_selected; l++) { EERIE_VERTEX temp; temp.v.x = obj2vertexlist2[obj2->selections[sel_torso2].selected[l]].v.x; temp.v.y = obj2vertexlist2[obj2->selections[sel_torso2].selected[l]].v.y; temp.v.z = obj2vertexlist2[obj2->selections[sel_torso2].selected[l]].v.z; long t = GetEquivalentVertex(work, &temp); if (t != -1) { ObjectAddSelection(work, 1, t); } } } else for (long l = 0; l < obj1->selections[sel_torso1].nb_selected; l++) { EERIE_VERTEX temp; temp.v.x = obj1vertexlist2[obj1->selections[sel_torso1].selected[l]].v.x; temp.v.y = obj1vertexlist2[obj1->selections[sel_torso1].selected[l]].v.y; temp.v.z = obj1vertexlist2[obj1->selections[sel_torso1].selected[l]].v.z; long t = GetEquivalentVertex(work, &temp); if (t != -1) { ObjectAddSelection(work, 1, t); } } // Re-Create sel_legs if (tw == TWEAK_LEGS) { for (long l = 0; l < obj2->selections[sel_legs2].nb_selected; l++) { EERIE_VERTEX temp; temp.v.x = obj2vertexlist2[obj2->selections[sel_legs2].selected[l]].v.x; temp.v.y = obj2vertexlist2[obj2->selections[sel_legs2].selected[l]].v.y; temp.v.z = obj2vertexlist2[obj2->selections[sel_legs2].selected[l]].v.z; long t = GetEquivalentVertex(work, &temp); if (t != -1) { ObjectAddSelection(work, 2, t); } } } else for (long l = 0; l < obj1->selections[sel_legs1].nb_selected; l++) { EERIE_VERTEX temp; temp.v.x = obj1vertexlist2[obj1->selections[sel_legs1].selected[l]].v.x; temp.v.y = obj1vertexlist2[obj1->selections[sel_legs1].selected[l]].v.y; temp.v.z = obj1vertexlist2[obj1->selections[sel_legs1].selected[l]].v.z; long t = GetEquivalentVertex(work, &temp); if (t != -1) { ObjectAddSelection(work, 2, t); } } //Now recreates other selections... for (i = 0; i < obj1->nbselections; i++) { if (EERIE_OBJECT_GetSelection(work, obj1->selections[i].name) == -1) { long num = work->nbselections; work->nbselections++; work->selections = (EERIE_SELECTIONS *)realloc(work->selections, sizeof(EERIE_SELECTIONS) * work->nbselections); memset(&work->selections[num], 0, sizeof(EERIE_SELECTIONS)); strcpy(work->selections[num].name, obj1->selections[i].name); for (long l = 0; l < obj1->selections[i].nb_selected; l++) { EERIE_VERTEX temp; temp.v.x = obj1vertexlist2[obj1->selections[i].selected[l]].v.x; temp.v.y = obj1vertexlist2[obj1->selections[i].selected[l]].v.y; temp.v.z = obj1vertexlist2[obj1->selections[i].selected[l]].v.z; long t = GetEquivalentVertex(work, &temp); if (t != -1) { ObjectAddSelection(work, num, t); } } long ii = EERIE_OBJECT_GetSelection(obj2, obj1->selections[i].name); if (ii != -1) for (long l = 0; l < obj2->selections[ii].nb_selected; l++) { EERIE_VERTEX temp; temp.v.x = obj2vertexlist2[obj2->selections[ii].selected[l]].v.x; temp.v.y = obj2vertexlist2[obj2->selections[ii].selected[l]].v.y; temp.v.z = obj2vertexlist2[obj2->selections[ii].selected[l]].v.z; long t = GetEquivalentVertex(work, &temp); if (t != -1) { ObjectAddSelection(work, num, t); } } } } for (i = 0; i < obj2->nbselections; i++) { if (EERIE_OBJECT_GetSelection(work, obj2->selections[i].name) == -1) { long num = work->nbselections; work->nbselections++; work->selections = (EERIE_SELECTIONS *)realloc(work->selections, sizeof(EERIE_SELECTIONS) * work->nbselections); memset(&work->selections[num], 0, sizeof(EERIE_SELECTIONS)); strcpy(work->selections[num].name, obj2->selections[i].name); for (long l = 0; l < obj2->selections[i].nb_selected; l++) { EERIE_VERTEX temp; temp.v.x = obj2vertexlist2[obj2->selections[i].selected[l]].v.x; temp.v.y = obj2vertexlist2[obj2->selections[i].selected[l]].v.y; temp.v.z = obj2vertexlist2[obj2->selections[i].selected[l]].v.z; long t = GetEquivalentVertex(work, &temp); if (t != -1) { ObjectAddSelection(work, num, t); } } } } // Recreate Animation-groups vertex for (i = 0; i < obj1->nbgroups; i++) { for (long j = 0; j < obj1->grouplist[i].nb_index; j++) { AddVertexToGroup(work, i, &obj1vertexlist2[obj1->grouplist[i].indexes[j]]); } } for (i = 0; i < obj2->nbgroups; i++) { for (long j = 0; j < obj2->grouplist[i].nb_index; j++) { AddVertexToGroup(work, i, &obj2vertexlist2[obj2->grouplist[i].indexes[j]]); } } // Look for Vertices Without Group... for (i = 0; i < work->nbmaps; i++) { work->texturecontainer[i]->Restore(GDevice); } if (work->nbvertex) { work->vertexlist3 = (EERIE_VERTEX *)malloc(sizeof(EERIE_VERTEX) * work->nbvertex); memcpy(work->vertexlist3, work->vertexlist, sizeof(EERIE_VERTEX)*work->nbvertex); } if (obj1vertexlist2) free(obj1vertexlist2); if (obj2vertexlist2) free(obj2vertexlist2); return work; }
//////////////// // Mouse events void BaseGrid::OnMouseEvent(wxMouseEvent &event) { // Window size int w,h; GetClientSize(&w,&h); // Modifiers bool shift = event.m_shiftDown; bool alt = event.m_altDown; bool ctrl = event.m_controlDown; // Row that mouse is over bool click = event.ButtonDown(wxMOUSE_BTN_LEFT); bool dclick = event.LeftDClick(); int row = event.GetY()/lineHeight + yPos - 1; if (holding && !click) { row = MID(0,row,GetRows()-1); } bool validRow = row >= 0 && row < GetRows(); if (!validRow) row = -1; // Get focus if (event.ButtonDown()) { if (Options.AsBool(_T("Grid Allow Focus"))) { SetFocus(); } } // Click type if (click && !holding && validRow) { holding = true; CaptureMouse(); } if (!event.ButtonIsDown(wxMOUSE_BTN_LEFT) && holding) { holding = false; ReleaseMouse(); } // Scroll to keep visible if (holding) { // Find direction int minVis = yPos+1; int maxVis = yPos+h/lineHeight-3; int delta = 0; if (row < minVis) delta = -1; if (row > maxVis) delta = +1; // Scroll ScrollTo(yPos+delta*3); } // Click if ((click || holding || dclick) && validRow) { // Disable extending extendRow = -1; // Toggle selected if (click && ctrl && !shift && !alt) { SelectRow(row,true,!IsInSelection(row,0)); parentFrame->UpdateToolbar(); return; } // Normal click if ((click || dclick) && !shift && !ctrl && !alt) { if (editBox->linen != row) editBox->SetToLine(row); if (dclick) video->JumpToFrame(VFR_Output.GetFrameAtTime(GetDialogue(row)->Start.GetMS(),true)); SelectRow(row,false); parentFrame->UpdateToolbar(); lastRow = row; return; } // Keep selection if (click && !shift && !ctrl && alt) { editBox->SetToLine(row); return; } // Block select if ((click && shift && !ctrl && !alt) || (holding && !ctrl && !alt && !shift)) { if (lastRow != -1) { // Set boundaries int i1 = row; int i2 = lastRow; if (i1 > i2) { int aux = i1; i1 = i2; i2 = aux; } // Toggle each bool notFirst = false; for (int i=i1;i<=i2;i++) { SelectRow(i,notFirst,true); notFirst = true; } parentFrame->UpdateToolbar(); } return; } return; } // Popup if (event.ButtonDown(wxMOUSE_BTN_RIGHT)) { OnPopupMenu(); } // Mouse wheel if (event.GetWheelRotation() != 0) { int step = 3 * event.GetWheelRotation() / event.GetWheelDelta(); ScrollTo(yPos - step); return; } event.Skip(); }