int CloneMouse(long x, long y, UINT btn) { int nDest = vClone.GetItemFromPos(x,y); if(nDest<0) return FALSE; // vClone.SelectItem(nDest); //if(CTreeViewToKClone(nDest)==-1){ //ファイル名 // for(int i=0; i<vClone.GetItemNum(); i++) // { // if(i==0) continue; // KClone* p = GetKClone(i+1); // if(!p) continue; // // if(last_selection == nDest && vstate != last_state){ // vClone.SetCheck(i+1, vstate); // p->clone_data.visible = !vstate; // } // } //}else { if(CTreeViewToKClone(nDest)<0) return 0; int vstate = vClone.IsChecked(nDest); KClone* p = GetKClone(nDest); if(!p) return FALSE; p->clone_data.visible = !vstate; if(last_selection == nDest && vstate != last_state) vClone.SelectItem(last_selection); //win.CSetWindowText(hMainWnd, "pos : %d , checked : %d last_selection:%d %d %d", CTreeViewToKClone(nDest), vstate, last_selection, last_state, p->clone_data.visible); last_selection = nDest; last_state = vstate; } Render(); return FALSE; }
//指定されたKCloneインデックスに該当する項目を選択状態にする void CloneSelectClone(int clone_index) { int item = KCloneToCTreeView(clone_index); vClone.SelectItem(item); SetFocus(hMainWnd); }
//更新処理 void RefreshCloneTree(KModelEdit* mdl, const char* szModelName, int select) { //static int old_sceneobject = GetSelectedSceneObject(); //int current_sceneobject = GetSelectedSceneObject(); //if(old_sceneobject!=current_sceneobject){ // old_sceneobject = current_sceneobject //}else{ SaveItemState(); //} //以前のデータをクリア ClearCloneTree(vClone.GetTreeWnd()); //ファイル名表示部分 if(szModelName!=NULL) { char* szTitle = (char*)GlobalAlloc(GPTR, sizeof(char) * (lstrlen(szModelName)+1)); lstrcpy(szTitle, szModelName); PathStripPath(szTitle); vClone.AddItem(szTitle, 0); GlobalFree(szTitle); }else vClone.AddItem("(null)", 0); KClone** node_ptr=(KClone**)GlobalAlloc(GPTR,256*sizeof(KClone*)); KClone* kpt=mdl->GetTree(); if(kpt == NULL) return; int* node_id=(int*)GlobalAlloc(GPTR,256*sizeof(int)); int node=0; long child_end=0; node_id[node] = 1; node_ptr[node]=NULL; //NULL->child node++; node_id[node] = vClone.AddItem(kpt->clone_data.clone_name, node_id[node-1]); node_ptr[node] = kpt; while(node!=-1) { if((child_end!=1)&&(kpt->child!=NULL)){ node++; kpt = kpt->child; node_ptr[node]=kpt; child_end=0; //--copy-------------------- node_id[node] = vClone.AddItem(kpt->clone_data.clone_name, node_id[node-1]); //-------------------------- }else if(kpt->sibling!=NULL){ kpt = kpt->sibling; node_ptr[node]=kpt; child_end=0; //--copy-------------------- node_id[node] = vClone.AddItem(kpt->clone_data.clone_name, node_id[node-1]); //-------------------------- }else{ node--; kpt = node_ptr[node]; if(kpt==NULL) kpt = mdl->GetTree()->sibling; if(kpt==NULL) break; child_end=1; } } GlobalFree(node_ptr); GlobalFree(node_id); long scene = GetSelectedScene(); if(scene<0) return; long scene_object = GetSelectedSceneObject(); if(scene_object<0) return; KModelEdit* m = demo.scene[scene].sceneobj[scene_object].model; long allocnum = 0; KClone* kcl = NULL; if(m){ allocnum = m->GetCloneAllocNum(); kcl = m->GetCloneAllocPtr(); } if(kcl==NULL) return; for(int i=0; i<allocnum; i++){ vClone.SetCheck(2+i, !(kcl[i].clone_data.visible)); } //for(int i=0; i<vClone.GetItemNum(); i++) //{ // //if(i==0) continue; // KClone* p = GetKClone(i+1); // if(!p){ // continue; // } // vClone.SetCheck(i+1, !(p->clone_data.visible)); //} // } ApplyItemState(); if(select>=0){ vClone.SelectItem(select+1); } }