Переглянути джерело

add search icon to inventory search filter

Kolja Strohm 9 місяців тому
батько
коміт
1273e568ae

+ 5 - 0
FactoryCraft/Entity.cpp

@@ -86,6 +86,11 @@ bool Entity::tick(double time)
     if (!World::INSTANCE || !World::INSTANCE->zKamera()) return 0;
     if (playerControlled && GetForegroundWindow() == window->getFensterHandle())
     {
+        if (!World::INSTANCE->zChunk(
+                World::INSTANCE->getChunkCenter((int)pos.x, (int)pos.y)))
+        {
+            return 0;
+        }
         Vec3<float> direction = World::INSTANCE->zKamera()->getDirection();
         Vec3<float> lastPos = pos;
         int flags = 0;

+ 38 - 22
FactoryCraft/Game.cpp

@@ -14,6 +14,16 @@ Game::Game(Bildschirm* zScreen)
       recipieVisible(0),
       itemListContainer(0)
 {
+    LTDBDatei dat;
+    dat.setDatei(new Text("data/images/gui_icons.ltdb"));
+    dat.leseDaten(0);
+    Bild* search = dat.laden(0, new Text("search.png"));
+    searchIcon = new BildZ();
+    searchIcon->setBildZ(search);
+    searchIcon->setStyle(
+        BildZ::Style::Sichtbar | BildZ::Style::Alpha | BildZ::Style::Rahmen);
+    searchIcon->setSize(20, 20);
+    searchIcon->setRahmenFarbe(0xFF6d6d6d);
     elements.add(new ScreenCenter());
     inventoryDragController = new DragController<InventoryDragSource, int>();
     logout = initKnopf(10, 10, 200, 20, Knopf::Style::Normal, "Verlassen");
@@ -54,6 +64,8 @@ Game::Game(Bildschirm* zScreen)
         20,
         Framework::TextFeld::Style::TextFeld,
         "");
+    searchIcon->setPosition(
+        filter->getX() + filter->getBreite() - 20, filter->getY());
 
     chat = new Chat();
     elements.add(chat);
@@ -90,7 +102,8 @@ Game::~Game()
 {
     inventoryDragController->release();
     filter->release();
-    if(itemListContainer) itemListContainer->release();
+    searchIcon->release();
+    if (itemListContainer) itemListContainer->release();
 }
 
 void Game::updatePosition(
@@ -204,25 +217,25 @@ void Game::api(char* data)
             delete[] uiml;
         }
     case 3:
-    { // update dialog content
-        short dialogNameLen = *(short*)(data + 1);
-        char* dialogName = new char[dialogNameLen + 1];
-        memcpy(dialogName, data + 3, dialogNameLen);
-        dialogName[dialogNameLen] = 0;
-        for (UIMLDialog* dialog : dialogs)
-        {
-            if (dialog->getName().istGleich(dialogName))
+        { // update dialog content
+            short dialogNameLen = *(short*)(data + 1);
+            char* dialogName = new char[dialogNameLen + 1];
+            memcpy(dialogName, data + 3, dialogNameLen);
+            dialogName[dialogNameLen] = 0;
+            for (UIMLDialog* dialog : dialogs)
             {
-                int uimlLen = *(int*)(data + 3 + dialogNameLen);
-                char* uiml = new char[uimlLen + 1];
-                memcpy(uiml, data + 7 + dialogNameLen, uimlLen);
-                uiml[uimlLen] = 0;
-                dialog->updateUIML(uiml);
-                delete[] uiml;
-				break;
-			}
-		}
-    }
+                if (dialog->getName().istGleich(dialogName))
+                {
+                    int uimlLen = *(int*)(data + 3 + dialogNameLen);
+                    char* uiml = new char[uimlLen + 1];
+                    memcpy(uiml, data + 7 + dialogNameLen, uimlLen);
+                    uiml[uimlLen] = 0;
+                    dialog->updateUIML(uiml);
+                    delete[] uiml;
+                    break;
+                }
+            }
+        }
     }
 }
 
@@ -269,6 +282,8 @@ void Game::updateRecipieVisibility()
             recipieVisible = 1;
             window->zBildschirm()->addMember(
                 dynamic_cast<Zeichnung*>(filter->getThis()));
+            window->zBildschirm()->addMember(
+                dynamic_cast<Zeichnung*>(searchIcon->getThis()));
         }
     }
     else
@@ -277,6 +292,7 @@ void Game::updateRecipieVisibility()
         {
             recipieVisible = 0;
             window->zBildschirm()->removeMember(filter);
+            window->zBildschirm()->removeMember(searchIcon);
             if (itemListContainer)
                 itemListContainer->removeStyle(Fenster::Style::Sichtbar);
         }
@@ -296,8 +312,8 @@ void Game::showItemList()
 
 bool Game::isItemListVisible()
 {
-    return itemListContainer && itemListContainer->hatStyle(
-        Fenster::Style::Sichtbar);
+    return itemListContainer
+        && itemListContainer->hatStyle(Fenster::Style::Sichtbar);
 }
 
 const Text* Game::zFilterText()
@@ -340,7 +356,7 @@ ScreenCenter::ScreenCenter()
     setSize(uiFactory.initParam.bildschirm->getBackBufferSize());
 }
 
-void ScreenCenter::render(Bild& zRObj) 
+void ScreenCenter::render(Bild& zRObj)
 {
     zRObj.drawLinieH(gr.x / 2 - 5, gr.y / 2, 10, 0xFFFFFFFF);
     zRObj.drawLinieV(gr.x / 2, gr.y / 2 - 5, 10, 0xFFFFFFFF);

+ 1 - 0
FactoryCraft/Game.h

@@ -23,6 +23,7 @@ private:
     Framework::UIMLView* targetUIMLView;
     DragController<InventoryDragSource, int>* inventoryDragController;
     Framework::TextFeld* filter;
+    Framework::BildZ* searchIcon;
     ItemListContainer* itemListContainer;
     Framework::Knopf* chatButton;
     MapWindow* mapWindow;

+ 2 - 4
FactoryCraft/ItemBar.cpp

@@ -1,6 +1,7 @@
 #include "ItemBar.h"
 
 #include <Bild.h>
+#include <DateiSystem.h>
 #include <XML.h>
 
 #include "Globals.h"
@@ -183,10 +184,7 @@ void ItemBarView::render(Bild& rObj)
         int index = 0;
         for (SlotInfo info : *slots)
         {
-            info.render(x,
-                y,
-                rObj,
-                index == leftHandPos, 0);
+            info.render(x, y, rObj, index == leftHandPos, 0);
             x += 60;
             if (++rowCount >= rowSize)
             {

+ 5 - 2
FactoryCraft/RecipieIngredient.cpp

@@ -344,8 +344,11 @@ void RecipieIngredient::doMausEreignis(
 {
     if (me.id == ME_RLinks)
     {
-        World::INSTANCE->zClient()->craftingUIMLRequest(
-            itemTypes.get(currentIconIndex));
+        if (itemTypes.getEintragAnzahl() > currentIconIndex)
+        {
+            World::INSTANCE->zClient()->craftingUIMLRequest(
+                itemTypes.get(currentIconIndex));
+        }
     }
     ZeichnungHintergrund::doMausEreignis(me, userRet);
 }