Crossfire Server, Branch 1.12
R12190
|
00001 #include <Qt> 00002 00003 extern "C" { 00004 #include "global.h" 00005 #include "face.h" 00006 #include "image.h" 00007 } 00008 00009 #include "CREFacePanel.h" 00010 #include "CREUtils.h" 00011 00013 static const char *const colorname[] = { 00014 "black", /* 0 */ 00015 "white", /* 1 */ 00016 "blue", /* 2 */ 00017 "red", /* 3 */ 00018 "orange", /* 4 */ 00019 "light_blue", /* 5 */ 00020 "dark_orange", /* 6 */ 00021 "green", /* 7 */ 00022 "light_green", /* 8 */ 00023 "grey", /* 9 */ 00024 "brown", /* 10 */ 00025 "yellow", /* 11 */ 00026 "khaki" /* 12 */ 00027 }; 00028 00029 00030 CREFacePanel::CREFacePanel() 00031 { 00032 myFace = 0; 00033 00034 QGridLayout* layout = new QGridLayout(this); 00035 00036 myUsing = new QTreeWidget(this); 00037 myUsing->setColumnCount(1); 00038 myUsing->setHeaderLabel(tr("Used by")); 00039 myUsing->setIconSize(QSize(32, 32)); 00040 layout->addWidget(myUsing, 1, 1, 3, 2); 00041 00042 myColor = new QComboBox(this); 00043 layout->addWidget(myColor, 4, 2); 00044 layout->addWidget(new QLabel("Magicmap color: "), 4, 1); 00045 00046 for(uint color = 0; color < sizeof(colorname) / sizeof(*colorname); color++) 00047 myColor->addItem(colorname[color], color); 00048 00049 myFile = new QLineEdit(this); 00050 myFile->setReadOnly(true); 00051 layout->addWidget(myFile, 5, 2); 00052 layout->addWidget(new QLabel("Original file: "), 5, 1); 00053 00054 mySave = new QPushButton(tr("Save face")); 00055 layout->addWidget(mySave, 6, 1); 00056 00057 connect(mySave, SIGNAL(clicked(bool)), this, SLOT(saveClicked(bool))); 00058 } 00059 00060 void CREFacePanel::setFace(const New_Face* face) 00061 { 00062 Q_ASSERT(face); 00063 myFace = face; 00064 00065 myUsing->clear(); 00066 00067 QTreeWidgetItem* root = NULL; 00068 00069 const archt* arch; 00070 00071 for (arch = first_archetype; arch; arch = arch->more ? arch->more : arch->next) 00072 { 00073 if (arch->clone.face == myFace) 00074 { 00075 if (root == NULL) 00076 { 00077 root = CREUtils::archetypeNode(NULL); 00078 myUsing->addTopLevelItem(root); 00079 root->setExpanded(true); 00080 } 00081 CREUtils::archetypeNode(arch, root); 00082 } 00083 } 00084 00085 root = NULL; 00086 00087 const Animations* anim; 00088 00089 // "bug" animation is zero, don't forget that shift 00090 for (int a = 0; a <= num_animations; a++) 00091 { 00092 anim = &animations[a]; 00093 for (int face = 0; face < anim->num_animations; face++) 00094 { 00095 if (anim->faces[face] == myFace->number) 00096 { 00097 if (root == NULL) 00098 { 00099 root = CREUtils::animationNode(NULL); 00100 myUsing->addTopLevelItem(root); 00101 root->setExpanded(true); 00102 } 00103 CREUtils::animationNode(anim, root); 00104 break; 00105 } 00106 } 00107 } 00108 00109 root = NULL; 00110 00111 const artifactlist* list; 00112 const typedata* data; 00113 const artifact* arti; 00114 00115 for (list = first_artifactlist; list; list = list->next) 00116 { 00117 data = get_typedata(list->type); 00118 00119 // item = new QTreeWidgetItem(root, QStringList(data ? data->name : tr("type %1").arg(type))); 00120 00121 for (arti = list->items; arti; arti = arti->next) 00122 { 00123 if (arti->item->face == myFace) 00124 { 00125 if (!root) 00126 { 00127 root = CREUtils::artifactNode(NULL); 00128 myUsing->addTopLevelItem(root); 00129 root->setExpanded(true); 00130 } 00131 00132 CREUtils::artifactNode(arti, root); 00133 } 00134 } 00135 } 00136 00137 myColor->setCurrentIndex(myFace->magicmap); 00138 } 00139 void CREFacePanel::saveClicked(bool) 00140 { 00141 }