浏览代码

add support for item icons as image paths in uiml

Kolja Strohm 3 天之前
父节点
当前提交
389775b003
共有 4 个文件被更改,包括 34 次插入31 次删除
  1. 0 1
      FactoryCraft/CraftingGrid.cpp
  2. 2 19
      FactoryCraft/ListView.cpp
  3. 26 6
      FactoryCraft/Load.cpp
  4. 6 5
      FactoryCraft/QuestGraph.cpp

+ 0 - 1
FactoryCraft/CraftingGrid.cpp

@@ -26,7 +26,6 @@ Framework::Zeichnung* CraftingGridElement::parseElement(
     Framework::XML::Element& element, Framework::UIMLContainer& generalFactory)
 {
     Text targetValue = element.getAttributeValue("target");
-    Vec3<int> blockPos(0, 0, 0);
     int addressLength = 0;
     int* address = getUIMLTargetAddress(targetValue, addressLength);
     return new CraftingGridView(element.getAttributeValue("id"),

+ 2 - 19
FactoryCraft/ListView.cpp

@@ -37,8 +37,8 @@ bool ListViewElement::updateElement(Framework::XML::Element& element,
     for (int index = 0; index < view->list->getEintragAnzahl(); index++)
     {
         if (!element.selectChildsByName("listItem")
-                 .whereAttributeEquals("id", *view->ids.z(index))
-                 .exists())
+                .whereAttributeEquals("id", *view->ids.z(index))
+                .exists())
         {
             view->list->removeEintrag(index);
             view->ids.remove(index);
@@ -111,23 +111,6 @@ void ListViewElement::layout(Framework::XML::Element& element,
             view->list->setVertikalKlickScroll((int)height);
             view->list->updateVScroll();
         }
-        auto children = element.selectChildsByName("listItem");
-        for (auto item : children)
-        {
-            auto elements
-                = item->selectChildsByName("itemContent").selectChildren();
-            int elementIndex = 0;
-            for (auto element : elements)
-            {
-                generalLayouter.layout(*element,
-                    *generalLayouter.zZeichnungById(
-                        element->getAttributeValue("id")),
-                    view->getBreite() - view->list->getBreite(),
-                    view->getHeight(),
-                    generalLayouter);
-                elementIndex++;
-            }
-        }
     }
 }
 

+ 26 - 6
FactoryCraft/Load.cpp

@@ -102,10 +102,30 @@ void LoadMenu::load(FactoryClient* client,
 
 Bild* loadImage(Framework::Text path)
 {
-    LTDBDatei file;
-    file.setDatei(
-        path.getTeilText(0, path.positionVon("/", path.anzahlVon("/") - 1)));
-    file.leseDaten(0);
-    return file.laden(0,
-        path.getTeilText(path.positionVon("/", path.anzahlVon("/") - 1) + 1));
+    if (path.beginnsWith("itemType:"))
+    {
+        Text* typeIdName = path.getTeilText(9);
+        for (int i = 0; i < itemTypeCount; i++)
+        {
+            if (itemTypes[i]->getName().istGleich(*typeIdName))
+            {
+                Bild* img
+                    = dynamic_cast<Bild*>(itemTypes[i]->zIcon()->getThis());
+                typeIdName->release();
+                return img;
+            }
+        }
+        typeIdName->release();
+        return 0;
+    }
+    else
+    {
+        LTDBDatei file;
+        file.setDatei(path.getTeilText(
+            0, path.positionVon("/", path.anzahlVon("/") - 1)));
+        file.leseDaten(0);
+        return file.laden(0,
+            path.getTeilText(
+                path.positionVon("/", path.anzahlVon("/") - 1) + 1));
+    }
 }

+ 6 - 5
FactoryCraft/QuestGraph.cpp

@@ -1029,9 +1029,9 @@ void QuestGraphItemLayer::resolveHorizontalConflicts(
             for (int i = 1; i <= 10; i++)
             {
                 if (!zNextLayer->isHorizontalLineConflict(outgoingY - i))
-				{
-					offset = -i;
-					break;
+                {
+                    offset = -i;
+                    break;
                 }
                 if (!zNextLayer->isHorizontalLineConflict(outgoingY + i))
                 {
@@ -1233,7 +1233,7 @@ void QuestGraph::fixItemPositions()
         horizontalScrollBar->update(
             layers.getEintragAnzahl() * 150 - 80, getInnenBreite());
     }
-    QuestGraphItemLayer *last = 0;
+    QuestGraphItemLayer* last = 0;
     for (int i = layers.getEintragAnzahl() - 1; i >= 0; i--)
     {
         QuestGraphItemLayer* layer = layers.z(i);
@@ -1243,7 +1243,8 @@ void QuestGraph::fixItemPositions()
     }
 }
 
-void QuestGraph::centerVertically() {
+void QuestGraph::centerVertically()
+{
     int height = 0;
     for (QuestGraphItemLayer* layer : layers)
     {