Crossfire Server, Branch 1.12  R12190
CREAnimationPanel.cpp
Go to the documentation of this file.
00001 #include <Qt>
00002 
00003 extern "C" {
00004 #include "global.h"
00005 #include "artifact.h"
00006 #include "object.h"
00007 #include "face.h"
00008 }
00009 
00010 #include "CREAnimationPanel.h"
00011 #include "CREAnimationControl.h"
00012 #include "CREUtils.h"
00013 
00014 CREAnimationPanel::CREAnimationPanel()
00015 {
00016     myAnimation = 0;
00017 
00018     QGridLayout* layout = new QGridLayout(this);
00019 
00020     myUsing = new QTreeWidget(this);
00021     myUsing->setColumnCount(1);
00022     myUsing->setHeaderLabel(tr("Used by"));
00023     myUsing->setIconSize(QSize(32, 32));
00024     layout->addWidget(myUsing, 1, 1);
00025 
00026     myDisplay = new CREAnimationControl(this);
00027     layout->addWidget(myDisplay, 2, 1);
00028 }
00029 
00030 void CREAnimationPanel::setAnimation(const Animations* animation)
00031 {
00032     Q_ASSERT(animation);
00033     myAnimation = animation;
00034 
00035     myUsing->clear();
00036 
00037     myDisplay->setAnimation(myAnimation);
00038 
00039     QTreeWidgetItem* root = NULL;
00040 
00041     const archt* arch;
00042 
00043     for (arch = first_archetype; arch; arch = (arch->more ? arch->more : arch->next))
00044     {
00045         if (arch->clone.animation_id == myAnimation->num)
00046         {
00047             if (root == NULL)
00048             {
00049                 root = CREUtils::archetypeNode(NULL);
00050                 myUsing->addTopLevelItem(root);
00051                 root->setExpanded(true);
00052             }
00053             CREUtils::archetypeNode(arch, root);
00054         }
00055     }
00056 
00057     root = NULL;
00058 
00059     artifactlist* list;
00060     artifact* art;
00061 
00062     for (list = first_artifactlist; list; list = list->next)
00063     {
00064         for (art = list->items; art; art = art->next)
00065         {
00066             if (art->item->animation_id == myAnimation->num)
00067             {
00068                 if (root == NULL)
00069                 {
00070                     root = CREUtils::artifactNode(NULL);
00071                     myUsing->addTopLevelItem(root);
00072                     root->setExpanded(true);
00073                 }
00074                 CREUtils::artifactNode(art, root);
00075             }
00076         }
00077     }
00078 }