void AnimatorBar::AnimationHasChanged() { if(m_pObjType) { OINFO* info = GetOINFO(m_pObjType->DLLIndex); vector<CObj*> objs; CObj* o; POSITION pos = application->layouts.GetHeadPosition(); while(pos) { CLayout* layout = application->layouts.GetNext(pos); POSITION pos2 = layout->objects.GetStartPosition(); for (int i = 0; i < layout->objects.GetCount(); i++) { long ID; layout->objects.GetNextAssoc(pos2, ID, o); if (o->GetGlobalID() == m_pObjType->ObjectIdentifier) objs.push_back(o); } } // Now loop each of the objects and call the end animation function. for(vector<CObj*>::iterator i = objs.begin(); i!= objs.end(); i++) { if(info->ETOnNotify) info->ETOnNotify((*i)->editObject, 2); } if(objs.size() > 0) if(info->ETOnNotify) info->ETOnNotify((*objs.begin())->editObject, 3); } }
void ObjectBarDialog::OnClickObject(NMHDR *pNMHDR, LRESULT *pResult) { POSITION Pos = objects.GetFirstSelectedItemPosition(); int Item = objects.GetNextSelectedItem(Pos); if (!layout) return; if (layout->m_ObjectFrameIsLockedTo != 0) // InputLocked() return; // Select in layout editor, if it's open if (parent.m_tabs.SelectionGet() == 0 && parent.m_tabs.ItemGetCount() == 2) { parent.layout_editor[0][0]->m_sel.RemoveAll(); // This is intentionally here; clear selection if clicked on whitespace if(Item == -1) { parent.layout_editor[0][0]->Invalidate(); g_PropertyBar->Update(parent.layout_editor[0][0], TYPE_LAYOUT, NULL, layout, NULL, application); return; } // Now we have to wangle in the selected object int ObjectIdentifier = objects.GetItemData(Item); if (ObjectIdentifier==-1) return; //folder CObj* pObject = 0; CObjType* pObjectType = 0; POSITION LayerPos = layout->layers.GetHeadPosition(); // So we have to find all the CObj's with this CObjType in the layout, and add them // For each layer while(LayerPos) { CLayer* pLayer = layout->layers.GetNext(LayerPos); // Loop all objects CObjList Objects; pLayer->GetEveryObject(Objects, layout); POSITION ObjectPos = Objects.GetHeadPosition(); for (int i = 0; i < Objects.GetCount(); i++) { CObj* pTestObject; long ID = Objects.GetNext(ObjectPos); layout->objects.Lookup(ID, pTestObject); if (pTestObject->GetGlobalID() != -1) { CObjType* pTestType = pTestObject->GetObjectType(application); if (pTestType->ObjectIdentifier == ObjectIdentifier) { pObjectType = pTestType; pObject = pTestObject; long nKey = pObject->GetInstanceID(); parent.layout_editor[0][0]->m_sel.AddTail(nKey); } } } } g_PropertyBar->Update(parent.layout_editor[0][0], TYPE_OBJECT, &parent.layout_editor[0][0]->m_sel, layout, &layout->objects, application); // Show object properties parent.layout_editor[0][0]->Invalidate(); // While we're here, show animations for object // Future note: .. to be continued if(!pObjectType) return; int iRoot = -1; OINFO* oInfo = GetOINFO(pObjectType->DLLIndex); if (oInfo->ETGetAnimationHandle) { oInfo->ETGetAnimationHandle(pObject->editObject, iRoot); pMainWnd->animator.UpdateAnimations(application, layout, pObjectType, iRoot); } } }
void ObjectBarDialog::Refresh(bool layer_changed) { // check for unnecessary refresh if (layer_changed && !show_only_selected_layer) return; // clear all lists objects.DeleteAllItems(); for (int i = 0; i < large_images.GetImageCount(); i++) large_images.Remove(0); for (int i = 0; i < small_images.GetImageCount(); i++) small_images.Remove(0); if(folderfilter > -1 && folderfilter >= application->object_folders.size()) folderfilter = -1; CObj* pObject; CObjType* pObjectType; CStringArray List; // Object list //object folders if (folderfilter == -1) { HBITMAP large_image = (HBITMAP) LoadImage(GetModuleHandle(0), MAKEINTRESOURCE(20150), IMAGE_BITMAP, 32, 32, LR_LOADTRANSPARENT); HBITMAP small_image = (HBITMAP) LoadImage(GetModuleHandle(0), MAKEINTRESOURCE(20150), IMAGE_BITMAP, 16, 16, LR_LOADTRANSPARENT); int ImageID = ImageList_Add(large_images.m_hImageList, large_image, NULL); ImageList_Add(small_images.m_hImageList, small_image, NULL); DeleteObject(large_image); DeleteObject(small_image); for (int i=0; i<application->object_folders.size(); ++i) { if(application->object_folders[i].name == "Default") continue; int item = objects.InsertItem(objects.GetItemCount(), application->object_folders[i].name, ImageID); objects.SetItemData(item, (DWORD_PTR)(const char*)"-1"); } } // -1 is Default, -2 is disabled else if(folderfilter != -2 && application->object_folders[folderfilter].name != "Default") { HBITMAP large_image = (HBITMAP) LoadImage(GetModuleHandle(0), MAKEINTRESOURCE(20150), IMAGE_BITMAP, 32, 32, LR_LOADTRANSPARENT); HBITMAP small_image = (HBITMAP) LoadImage(GetModuleHandle(0), MAKEINTRESOURCE(20150), IMAGE_BITMAP, 16, 16, LR_LOADTRANSPARENT); int ImageID = ImageList_Add(large_images.m_hImageList, large_image, NULL); ImageList_Add(small_images.m_hImageList, small_image, NULL); DeleteObject(large_image); DeleteObject(small_image); int item = objects.InsertItem(0,"...\\"+application->object_folders[folderfilter].name, ImageID); objects.SetItemData(item, (DWORD_PTR)(const char*)"-1"); } if (layout) { POSITION LayerPos = layout->layers.GetHeadPosition(); // For each layer while(LayerPos) { CLayer* pLayer = layout->layers.GetNext(LayerPos); if (show_only_selected_layer && pLayer != layout->current_layer) continue; if (!show_nonlayout_objects && pLayer->m_layerType == LAYER_NONFRAME) continue; // Loop all objects CObjList Objects; pLayer->GetEveryObject(Objects, layout); POSITION ObjectPos = Objects.GetHeadPosition(); for (int i = 0; i < Objects.GetCount(); i++) { long ID = Objects.GetNext(ObjectPos); layout->objects.Lookup(ID, pObject); if (pObject->GetGlobalID() != -1) { pObjectType = pObject->GetObjectType(application); // Failed/invalid object type, for some reason if(!pObjectType) continue; //folder filtering if(folderfilter ==-1 && pObjectType->GetFolder() != "Default") continue; else if(folderfilter > -1 && pObjectType->GetFolder()!=application->object_folders[folderfilter].name) continue; bool bAdd = true; for (int j = 0; j < List.GetSize(); j++) if (List.GetAt(j) == pObjectType->GetName()) bAdd = false; if (bAdd) { HBITMAP large_image = pObjectType->m_Image.MakeBitmap(); HBITMAP small_image = pObjectType->small_image.MakeBitmap(); int ImageID = ImageList_Add(large_images.m_hImageList, large_image, NULL); ImageList_Add(small_images.m_hImageList, small_image, NULL); DeleteObject(large_image); DeleteObject(small_image); int Item = objects.InsertItem(objects.GetItemCount(), pObjectType->GetName(), ImageID); objects.SetItemData(Item, (LPARAM)((const char*)pObjectType->GetName())); List.Add(pObjectType->GetName()); } } // Iterate each object } // Iterate each layer } } else { POSITION Pos = application->object_types.GetStartPosition(); CObjType* oT; long nKey = 0; while (Pos != NULL) { application->object_types.GetNextAssoc(Pos, nKey, oT); if(oT && !oT->m_bIsGroupType) { int ImageID = ImageList_Add(large_images.m_hImageList, oT->m_Image.MakeBitmap(), NULL); int Item = objects.InsertItem(objects.GetItemCount(), oT->GetName(), ImageID); objects.SetItemData(Item, (DWORD)((LPCSTR)oT->GetName())); List.Add(oT->GetName()); } } } objects.ShowScrollBar(SB_VERT); // Work out if there's a vertical scrollbar. If there is, we'll resize a bit. int iListCount = objects.GetItemCount(); int iListSize = objects.GetCountPerPage(); if(iListCount < iListSize) { // Disable the arrows on the vertical scrollbar objects.EnableScrollBar(SB_VERT, ESB_DISABLE_BOTH); objects.SetScrollRange(SB_VERT, 0, 2); } else { // Enable the vertical scrollbar objects.EnableScrollBar(SB_VERT, ESB_ENABLE_BOTH); } if (sorting == ob_sort_az) objects.SortItems(ObjectCompare, (LPARAM)&objects); if (sorting == ob_sort_za) objects.SortItems(ObjectCompareZA, (LPARAM)&objects); // now replace the ids for (int i = 0; i < objects.GetItemCount(); i++) { if((const char*)objects.GetItemData(i) == "-1") { objects.SetItemData(i, -1); continue; } CObjType* type = GetTypeFromName(application, objects.GetItemText(i, 0)); objects.SetItemData(i, type->ObjectIdentifier); } }
// Initialise the dialog // BOOL CEventWizardDlg::OnInitDialog() { // Startup CDialog::OnInitDialog(); int currentPosition = 1; // Create an m_ObjectImages m_ObjectImages.DeleteImageList(); bool bSmallImages = false; // Check what size images we'll need // 32x32 without families or 16x16 with if (application->families.size() == 0) { m_ObjectImages.Create(32, 32, ILC_COLOR24, 3, 3); m_List.SetImageList(&m_ObjectImages, LVSIL_NORMAL); HBITMAP SystemBitmap = LoadBitmap(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDB_SYSTEM)); ImageList_Add(m_ObjectImages, SystemBitmap, SystemBitmap); DeleteObject(SystemBitmap); } else { // If it's small, also set the view to small images m_List.SetView(LV_VIEW_SMALLICON); m_ObjectImages.Create(16, 16, ILC_COLOR24, 3, 3); m_List.SetImageList(&m_ObjectImages, LVSIL_SMALL); HBITMAP SystemBitmap = LoadBitmap(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDB_SYSTEMC)); ImageList_Add(m_ObjectImages, SystemBitmap, SystemBitmap); DeleteObject(SystemBitmap); bSmallImages = true; } // Prepare to iterate all objects to add icons POSITION pos = objMap->GetStartPosition(); long mapKey; CObjType* ObjectType; // Add '(System)' because system uses it object_folders["(System)"] = 0; // Loop through and add all objects to the otList while (pos != NULL) { objMap->GetNextAssoc(pos, mapKey, ObjectType); if(!ObjectType->m_bIsGroupType) { CObj *o; bool bAdd = false; // If global, its okay to add...if its not global..and we have a layout...we need to check if (ObjectType->m_bGlobal) { bAdd = true; } else if(layout) { POSITION pos = layout->objects.GetStartPosition(); for (int i = 0; i < layout->objects.GetCount(); i++) { long ID; layout->objects.GetNextAssoc(pos, ID, o); if (o->GetGlobalID() == ObjectType->ObjectIdentifier) { bAdd = true; } } } else // we have no layout to this event sheet { bAdd = true; } // Dont add if it doesn't have conditions/actions bool hasAces = false; for (int i = 0; i < ObjectType->GetTableCount(m_aceType); i++) { if (ObjectType->GetACESEntry(m_aceType, i)->aceListName == "") { hasAces = true; break; } if (hasAces) break; } if(!hasAces) bAdd = false; // Okay cool...look like its okay to add...just check if is showabout in the event sheet editor if(bAdd && ObjectType->m_bShowInEventSheetEditor) { // Possibly add a new category if(object_folders.find(ObjectType->GetFolder()) == object_folders.end()) { object_folders[ObjectType->GetFolder()] = object_folders.size(); } m_otList.push_back(ObjectType); } } } // Sort sort(m_otList.begin(), m_otList.end(), ObjTypeSortFunction); // Now loop the otList backwards to display each object icon for(vector<CObjType*>::iterator i = m_otList.begin(); i != m_otList.end(); i++) { HBITMAP Bitmap; if (bSmallImages) Bitmap = (*i)->small_image.MakeBitmap(); else Bitmap = (*i)->m_Image.MakeBitmap(); ImageList_Add(m_ObjectImages, Bitmap, Bitmap); DeleteObject(Bitmap); } pos = objMap->GetStartPosition(); // Family icons list<Family>::iterator f = application->families.begin(); for ( ; f != application->families.end(); f++) { if(f->is_in_use) { HBITMAP Bitmap = f->small_image.MakeBitmap(); ImageList_Add(m_ObjectImages, Bitmap, Bitmap); DeleteObject(Bitmap); } } // Title CString Title; if (m_aceType == CONDITION) Title.Format("Construct : New condition"); else if (m_aceType == ACTION) Title.Format("Construct : New action"); else if (m_aceType == EXPRESSION) Title.Format("Construct : New expression"); SetWindowText(Title); CRect Rect; m_ACEList.GetWindowRect(&Rect); ScreenToClient(&Rect); Rect.top = Rect.bottom - 1; Rect.bottom = Rect.top + 18; m_CategoryTabs.Create(this, Rect, 1001, WS_CHILD | WS_VISIBLE, __ETWS_ORIENT_BOTTOM); m_ACEList.GetWindowRect(&Rect); ScreenToClient(&Rect); Rect.top -= 17; Rect.bottom = Rect.top + 18; m_Tabs.Create(this, Rect, 1002, WS_CHILD | WS_VISIBLE, __ETWS_ORIENT_TOP); GetClientRect(&Rect); Rect.bottom = Rect.top + 22; Rect.right += 48; // Resizing anchors BOOL First = dlgMan.Load(this->m_hWnd, "Software\\Construct\\EventWizardDialogs"); if (!First) { first_run.Attach(this); first_run.SetHighlightOnMouseOver(); first_run.SetResize(); first_run.SetWrapText(); if (m_aceType == ACTION) first_run.SetText("Events are created via this wizard. Choose an object from the list below. A list of actions will then appear, some of which require parameters: for example 'Create object' under System. Once all parameters are filled out, click Finish to insert your action."); if (m_aceType == CONDITION) first_run.SetText("Events are created via this wizard. Choose an object from the list below. A list of conditions will then appear, some of which require parameters: for example 'Compare' under System. Once all parameters are filled out, click Finish to insert your condition."); } dlgAnchor.Init(this->m_hWnd); dlgAnchor.Add(IDC_OBJECTLIST, ANCHOR_TOPLEFT | ANCHOR_BOTTOMRIGHT); dlgAnchor.Add(IDC_ACELIST, ANCHOR_TOPLEFT | ANCHOR_BOTTOMRIGHT); dlgAnchor.Add(IDC_FIND, ANCHOR_TOP | ANCHOR_RIGHT); dlgAnchor.Add(1001, ANCHOR_LEFT | ANCHOR_BOTTOMRIGHT); dlgAnchor.Add(1002, ANCHOR_TOPLEFT | ANCHOR_RIGHT); dlgAnchor.Add(1003, ANCHOR_TOPLEFT | ANCHOR_RIGHT); dlgAnchor.Add(IDC_BACK, ANCHOR_BOTTOM | ANCHOR_RIGHT); dlgAnchor.Add(IDC_CANCEL, ANCHOR_BOTTOM | ANCHOR_LEFT); dlgAnchor.Add(IDC_NEXT, ANCHOR_BOTTOM | ANCHOR_RIGHT); m_Cancel.SetWindowText(CANCEL); // Set ACE margins CRect ListRect; m_ACEList.GetClientRect(&ListRect); ListRect.left += 5; ListRect.top += 5; m_ACEList.SetWorkAreas(1, &ListRect); m_ACEList.SetColumnWidth(0, 200); // Spaces everything out nicely for step 2. int initStep = m_iStep; if (m_InitialStage == 0) { m_iStep = 1; ChangeStep(); } else { // New to 0.96.3 m_pSelectedObject = m_InitialSelect; initStep = 2; } // The below is used so we set the default selected items (eg. if we are editing) if(m_pSelectedObject != -2) { // Have an object already selected for(int i = 0; i < m_List.GetItemCount(); i++) if(m_List.GetItemData(i) == m_pSelectedObject) m_List.SetItemState(i,LVIS_SELECTED, LVIS_SELECTED); } if(m_aceIndex != -1) { PreChangeStep(); m_iStep = 2; int aceIndex = m_aceIndex; ChangeStep(); if(m_childid != 0) { CObjType* pType = application->FindObjTypeFromNumber(m_pSelectedObject); if(pType) { int index = 1; list<CBehavior>::iterator i = pType->behaviors.begin(); list<CBehavior>::iterator end = pType->behaviors.end(); for(; i!= end; i++) { if(i->id == m_childid) { m_Tabs.SelectionSet(index); break; } index ++; } list<CEffect>::iterator e = pType->effects.begin(); for(;e!= pType->effects.end(); e++) { if(e->m_effectID == -m_childid) m_Tabs.SelectionSet(index); index ++; } } ChangeStep(); } m_aceIndex = aceIndex; for(int i = 0; i < m_ACEList.GetItemCount(); i++) { if(m_ACEList.GetItemData(i) == m_aceIndex) m_ACEList.SetItemState(i,LVIS_SELECTED, LVIS_SELECTED); } } if(initStep != m_iStep) { PreChangeStep(); m_iStep = initStep; ChangeStep(); } UpdateButtons(); // Expression dialogs will move slightly to make it clear it's on top of the existing parameters dialog. if (m_aceType == EXPRESSION) { RECT rc; this->GetWindowRect(&rc); rc.left += 50; rc.top += 50; this->SetWindowPos(NULL, rc.left, rc.top, 0, 0, SWP_NOSIZE); } // New drawing code LOGFONT* m_pLF; m_pLF=(LOGFONT*)calloc(1,sizeof(LOGFONT)); strncpy(m_pLF->lfFaceName,"Segoe UI",9); m_pLF->lfHeight=14; m_pLF->lfWeight=600; m_pLF->lfItalic=0; m_pLF->lfUnderline=0; m_FontBold.CreateFontIndirect(m_pLF); m_pLF->lfWeight = 0; m_Font.CreateFontIndirect(m_pLF); m_Find.SetIcon(IDI_SEARCH); return FALSE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE }