Explorar o código

implement server resource loading

Kolja Strohm hai 1 mes
pai
achega
6ec17e3915

+ 764 - 1
FactoryCraft/FactoryClient.cpp

@@ -1,13 +1,609 @@
 #include "FactoryClient.h"
 
 #include <Bild.h>
+#include <Datei.h>
+#include <DateiSystem.h>
+#include <M3Datei.h>
 #include <Textur.h>
 
 #include "Globals.h"
+#include "Load.h"
 
 using namespace Network;
 using namespace Framework;
 
+void createDefaultCube(Bildschirm* zScreen)
+{
+    Model3DData* data = zScreen->zGraphicsApi()->createModel("cube");
+    data->setAmbientFactor(0.f);
+    data->setDiffusFactor(1.f);
+    data->setSpecularFactor(0.f);
+    float size = 1;
+    float left, right, top, bottom;
+    // Calculate the screen coordinates of the left side of the bitmap.
+    right = (float)((-size / 2.0));
+    // Calculate the screen coordinates of the right side of the bitmap.
+    left = right + (float)size;
+    // Calculate the screen coordinates of the top of the bitmap.
+    top = (float)(size / 2.0);
+    // Calculate the screen coordinates of the bottom of the bitmap.
+    bottom = top - (float)size;
+    float front = -size / 2;
+    float back = front + size;
+
+    Vertex3D* vertecies = new Vertex3D[24];
+    for (int i = 0; i < 24; i++)
+        vertecies[i].knochenId = 0;
+    // front side
+    vertecies[0].pos = Vec3<float>(left, front, top);
+    vertecies[0].tPos = Vec2<float>(0.f, 0.f);
+    vertecies[1].pos = Vec3<float>(right, front, top);
+    vertecies[1].tPos = Vec2<float>(1.f, 0.f);
+    vertecies[2].pos = Vec3<float>(left, front, bottom);
+    vertecies[2].tPos = Vec2<float>(0.f, 1.f);
+    vertecies[3].pos = Vec3<float>(right, front, bottom);
+    vertecies[3].tPos = Vec2<float>(1.f, 1.f);
+    // back side
+    vertecies[4].pos = Vec3<float>(right, back, top);
+    vertecies[4].tPos = Vec2<float>(0.0f, 0.0f);
+    vertecies[5].pos = Vec3<float>(left, back, top);
+    vertecies[5].tPos = Vec2<float>(1.0f, 0.0f);
+    vertecies[6].pos = Vec3<float>(right, back, bottom);
+    vertecies[6].tPos = Vec2<float>(0.0f, 1.0f);
+    vertecies[7].pos = Vec3<float>(left, back, bottom);
+    vertecies[7].tPos = Vec2<float>(1.0f, 1.0f);
+    // left side
+    vertecies[8].pos = Vec3<float>(left, back, top);
+    vertecies[8].tPos = Vec2<float>(0.f, 0.f);
+    vertecies[9].pos = Vec3<float>(left, front, top);
+    vertecies[9].tPos = Vec2<float>(1.f, 0.f);
+    vertecies[10].pos = Vec3<float>(left, back, bottom);
+    vertecies[10].tPos = Vec2<float>(0.f, 1.f);
+    vertecies[11].pos = Vec3<float>(left, front, bottom);
+    vertecies[11].tPos = Vec2<float>(1.f, 1.f);
+    // right side
+    vertecies[12].pos = Vec3<float>(right, front, top);
+    vertecies[12].tPos = Vec2<float>(0.0f, 0.0f);
+    vertecies[13].pos = Vec3<float>(right, back, top);
+    vertecies[13].tPos = Vec2<float>(1.0f, 0.0f);
+    vertecies[14].pos = Vec3<float>(right, front, bottom);
+    vertecies[14].tPos = Vec2<float>(0.0f, 1.0f);
+    vertecies[15].pos = Vec3<float>(right, back, bottom);
+    vertecies[15].tPos = Vec2<float>(1.0f, 1.0f);
+    // top side
+    vertecies[16].pos = Vec3<float>(left, back, top);
+    vertecies[16].tPos = Vec2<float>(0.f, 0.f);
+    vertecies[17].pos = Vec3<float>(right, back, top);
+    vertecies[17].tPos = Vec2<float>(1.f, 0.f);
+    vertecies[18].pos = Vec3<float>(left, front, top);
+    vertecies[18].tPos = Vec2<float>(0.f, 1.f);
+    vertecies[19].pos = Vec3<float>(right, front, top);
+    vertecies[19].tPos = Vec2<float>(1.f, 1.f);
+    // botom side
+    vertecies[20].pos = Vec3<float>(left, front, bottom);
+    vertecies[20].tPos = Vec2<float>(0.0f, 0.0f);
+    vertecies[21].pos = Vec3<float>(right, front, bottom);
+    vertecies[21].tPos = Vec2<float>(1.0f, 0.0f);
+    vertecies[22].pos = Vec3<float>(left, back, bottom);
+    vertecies[22].tPos = Vec2<float>(0.0f, 1.0f);
+    vertecies[23].pos = Vec3<float>(right, back, bottom);
+    vertecies[23].tPos = Vec2<float>(1.0f, 1.0f);
+
+    data->setVertecies(vertecies, 24);
+    // the order of the polygons has to be NORTH (front), EAST (left), SOUTH
+    // (back), WEST (right), TOP, BOTTOM according to the Area definition
+    // front side
+    Polygon3D* p
+        = new Polygon3D(); // looking from (0,0,0) to (1,0,0) to see this side
+    p->indexAnz = 6;
+    p->indexList = new int[p->indexAnz];
+    p->indexList[0] = 0;
+    p->indexList[1] = 1;
+    p->indexList[2] = 2;
+    p->indexList[3] = 1;
+    p->indexList[4] = 3;
+    p->indexList[5] = 2;
+    data->addPolygon(p);
+    // left side
+    p = new Polygon3D(); // looking from (0,0,0) to (0,1,0) to see this side
+    p->indexAnz = 6;
+    p->indexList = new int[p->indexAnz];
+    p->indexList[0] = 0 + 8;
+    p->indexList[1] = 1 + 8;
+    p->indexList[2] = 2 + 8;
+    p->indexList[3] = 1 + 8;
+    p->indexList[4] = 3 + 8;
+    p->indexList[5] = 2 + 8;
+    data->addPolygon(p);
+    // back side
+    p = new Polygon3D(); // looking from (0,0,0) to (-1,0,0) to see this side
+    p->indexAnz = 6;
+    p->indexList = new int[p->indexAnz];
+    p->indexList[0] = 0 + 4;
+    p->indexList[1] = 1 + 4;
+    p->indexList[2] = 2 + 4;
+    p->indexList[3] = 1 + 4;
+    p->indexList[4] = 3 + 4;
+    p->indexList[5] = 2 + 4;
+    data->addPolygon(p);
+    // right side
+    p = new Polygon3D(); // looking from (0,0,0) to (0,-1,0) to see this side
+    p->indexAnz = 6;
+    p->indexList = new int[p->indexAnz];
+    p->indexList[0] = 0 + 12;
+    p->indexList[1] = 1 + 12;
+    p->indexList[2] = 2 + 12;
+    p->indexList[3] = 1 + 12;
+    p->indexList[4] = 3 + 12;
+    p->indexList[5] = 2 + 12;
+    data->addPolygon(p);
+    // top side
+    p = new Polygon3D(); // looking from (0,0,0) to (0,0,-1) to see this side
+    p->indexAnz = 6;
+    p->indexList = new int[p->indexAnz];
+    p->indexList[0] = 0 + 16;
+    p->indexList[1] = 1 + 16;
+    p->indexList[2] = 2 + 16;
+    p->indexList[3] = 1 + 16;
+    p->indexList[4] = 3 + 16;
+    p->indexList[5] = 2 + 16;
+    data->addPolygon(p);
+    // botom side
+    p = new Polygon3D(); // looking from (0,0,0) to (0,0,1) to see this side
+    p->indexAnz = 6;
+    p->indexList = new int[p->indexAnz];
+    p->indexList[0] = 0 + 20;
+    p->indexList[1] = 1 + 20;
+    p->indexList[2] = 2 + 20;
+    p->indexList[3] = 1 + 20;
+    p->indexList[4] = 3 + 20;
+    p->indexList[5] = 2 + 20;
+    data->addPolygon(p);
+    data->calculateNormals();
+    data->release();
+}
+
+void createPlayer(Bildschirm* zScreen)
+{
+    Framework::Model3DData* data
+        = window->zBildschirm()->zGraphicsApi()->createModel("player");
+    data->setAmbientFactor(0.8f);
+    data->setDiffusFactor(0.1f);
+    data->setSpecularFactor(0.1f);
+    float size = 0.8f;
+    float left, right, top, bottom;
+    // Calculate the screen coordinates of the left side of the bitmap.
+    left = (float)((size / 2.0) * -1);
+    // Calculate the screen coordinates of the right side of the bitmap.
+    right = left + (float)size;
+    // Calculate the screen coordinates of the top of the bitmap.
+    top = (float)(size / 2.0);
+    // Calculate the screen coordinates of the bottom of the bitmap.
+    bottom = top - (float)size;
+    float front = -1.5f / 2;
+    float back = front + 1.5f;
+
+    Vertex3D* vertecies = new Vertex3D[24];
+    for (int i = 0; i < 24; i++)
+        vertecies[i].knochenId = 0;
+    vertecies[0].pos = Vec3<float>(left, top, front);
+    vertecies[0].tPos = Vec2<float>(0.f, 0.f);
+    vertecies[1].pos = Vec3<float>(right, top, front);
+    vertecies[1].tPos = Vec2<float>(1.f, 0.f);
+    vertecies[2].pos = Vec3<float>(left, bottom, front);
+    vertecies[2].tPos = Vec2<float>(0.f, 1.f);
+    vertecies[3].pos = Vec3<float>(right, bottom, front);
+    vertecies[3].tPos = Vec2<float>(1.f, 1.f);
+    vertecies[4].pos = Vec3<float>(left, top, back);
+    vertecies[4].tPos = Vec2<float>(0.0f, 0.0f);
+    vertecies[5].pos = Vec3<float>(right, top, back);
+    vertecies[5].tPos = Vec2<float>(1.0f, 0.0f);
+    vertecies[6].pos = Vec3<float>(left, bottom, back);
+    vertecies[6].tPos = Vec2<float>(0.0f, 1.0f);
+    vertecies[7].pos = Vec3<float>(right, bottom, back);
+    vertecies[7].tPos = Vec2<float>(1.0f, 1.0f);
+
+    vertecies[8].pos = Vec3<float>(left, top, front);
+    vertecies[8].tPos = Vec2<float>(1.f, 0.f);
+    vertecies[9].pos = Vec3<float>(right, top, front);
+    vertecies[9].tPos = Vec2<float>(0.f, 0.f);
+    vertecies[10].pos = Vec3<float>(left, bottom, front);
+    vertecies[10].tPos = Vec2<float>(1.f, 1.f);
+    vertecies[11].pos = Vec3<float>(right, bottom, front);
+    vertecies[11].tPos = Vec2<float>(0.f, 1.f);
+    vertecies[12].pos = Vec3<float>(left, top, back);
+    vertecies[12].tPos = Vec2<float>(0.0f, 0.0f);
+    vertecies[13].pos = Vec3<float>(right, top, back);
+    vertecies[13].tPos = Vec2<float>(1.0f, 0.0f);
+    vertecies[14].pos = Vec3<float>(left, bottom, back);
+    vertecies[14].tPos = Vec2<float>(0.0f, 1.0f);
+    vertecies[15].pos = Vec3<float>(right, bottom, back);
+    vertecies[15].tPos = Vec2<float>(1.0f, 1.0f);
+
+    vertecies[16].pos = Vec3<float>(left, top, front);
+    vertecies[16].tPos = Vec2<float>(0.f, 1.f);
+    vertecies[17].pos = Vec3<float>(right, top, front);
+    vertecies[17].tPos = Vec2<float>(1.f, 1.f);
+    vertecies[18].pos = Vec3<float>(left, bottom, front);
+    vertecies[18].tPos = Vec2<float>(0.f, 0.f);
+    vertecies[19].pos = Vec3<float>(right, bottom, front);
+    vertecies[19].tPos = Vec2<float>(1.f, 0.f);
+    vertecies[20].pos = Vec3<float>(left, top, back);
+    vertecies[20].tPos = Vec2<float>(0.0f, 0.0f);
+    vertecies[21].pos = Vec3<float>(right, top, back);
+    vertecies[21].tPos = Vec2<float>(1.0f, 0.0f);
+    vertecies[22].pos = Vec3<float>(left, bottom, back);
+    vertecies[22].tPos = Vec2<float>(0.0f, 1.0f);
+    vertecies[23].pos = Vec3<float>(right, bottom, back);
+    vertecies[23].tPos = Vec2<float>(1.0f, 1.0f);
+
+    data->setVertecies(vertecies, 24);
+    // the order of the polygons has to be NORTH, EAST, SOUTH, WEST, TOP, BOTTOM
+    // according to the Area definition down side
+    Polygon3D* p = new Polygon3D();
+    p->indexAnz = 6;
+    p->indexList = new int[p->indexAnz];
+    p->indexList[0] = 6 + 16;
+    p->indexList[1] = 2 + 16;
+    p->indexList[2] = 3 + 16;
+    p->indexList[3] = 6 + 16;
+    p->indexList[4] = 3 + 16;
+    p->indexList[5] = 7 + 16;
+    data->addPolygon(p);
+    // right side
+    p = new Polygon3D();
+    p->indexAnz = 6;
+    p->indexList = new int[p->indexAnz];
+    p->indexList[0] = 1 + 8;
+    p->indexList[1] = 7 + 8;
+    p->indexList[2] = 3 + 8;
+    p->indexList[3] = 1 + 8;
+    p->indexList[4] = 5 + 8;
+    p->indexList[5] = 7 + 8;
+    data->addPolygon(p);
+    // top side
+    p = new Polygon3D();
+    p->indexAnz = 6;
+    p->indexList = new int[p->indexAnz];
+    p->indexList[0] = 4 + 16;
+    p->indexList[1] = 1 + 16;
+    p->indexList[2] = 0 + 16;
+    p->indexList[3] = 4 + 16;
+    p->indexList[4] = 5 + 16;
+    p->indexList[5] = 1 + 16;
+    data->addPolygon(p);
+    // left side
+    p = new Polygon3D();
+    p->indexAnz = 6;
+    p->indexList = new int[p->indexAnz];
+    p->indexList[0] = 0 + 8;
+    p->indexList[1] = 2 + 8;
+    p->indexList[2] = 6 + 8;
+    p->indexList[3] = 0 + 8;
+    p->indexList[4] = 6 + 8;
+    p->indexList[5] = 4 + 8;
+    data->addPolygon(p);
+    // back side
+    p = new Polygon3D();
+    p->indexAnz = 6;
+    p->indexList = new int[p->indexAnz];
+    p->indexList[0] = 4;
+    p->indexList[1] = 6;
+    p->indexList[2] = 7;
+    p->indexList[3] = 4;
+    p->indexList[4] = 7;
+    p->indexList[5] = 5;
+    data->addPolygon(p);
+    // front side
+    p = new Polygon3D();
+    p->indexAnz = 6;
+    p->indexList = new int[p->indexAnz];
+    p->indexList[0] = 0;
+    p->indexList[1] = 3;
+    p->indexList[2] = 2;
+    p->indexList[3] = 0;
+    p->indexList[4] = 1;
+    p->indexList[5] = 3;
+    data->addPolygon(p);
+    data->calculateNormals();
+    data->release();
+}
+
+void createGrass(Bildschirm* zScreen)
+{
+    Model3DData* data = zScreen->zGraphicsApi()->createModel("grass");
+    data->setAmbientFactor(0.f);
+    data->setDiffusFactor(1.f);
+    data->setSpecularFactor(0.f);
+
+    float size = 1;
+    float left, right, top, bottom;
+    // Calculate the screen coordinates of the left side of the bitmap.
+    right = (float)((-size / 2.0));
+    // Calculate the screen coordinates of the right side of the bitmap.
+    left = right + (float)size;
+    // Calculate the screen coordinates of the top of the bitmap.
+    top = (float)(size / 2.0);
+    // Calculate the screen coordinates of the bottom of the bitmap.
+    bottom = top - (float)size;
+    float front = -size / 2;
+    float back = front + size;
+
+    Vertex3D* vertecies = new Vertex3D[32];
+    for (int i = 0; i < 32; i++)
+        vertecies[i].knochenId = 0;
+
+    // first y plane
+    vertecies[0].pos = Vec3<float>(left, front + 0.2f, top);
+    vertecies[0].tPos = Vec2<float>(0.01f, 0.01f);
+    vertecies[1].pos = Vec3<float>(right, front + 0.2f, top);
+    vertecies[1].tPos = Vec2<float>(0.99f, 0.01f);
+    vertecies[2].pos = Vec3<float>(left, front + 0.2f, bottom);
+    vertecies[2].tPos = Vec2<float>(0.01f, 0.99f);
+    vertecies[3].pos = Vec3<float>(right, front + 0.2f, bottom);
+    vertecies[3].tPos = Vec2<float>(0.99f, 0.99f);
+    // second y plane
+    vertecies[4].pos = Vec3<float>(left, front + 0.4f, top);
+    vertecies[4].tPos = Vec2<float>(0.01f, 0.01f);
+    vertecies[5].pos = Vec3<float>(right, front + 0.4f, top);
+    vertecies[5].tPos = Vec2<float>(0.99f, 0.01f);
+    vertecies[6].pos = Vec3<float>(left, front + 0.4f, bottom);
+    vertecies[6].tPos = Vec2<float>(0.01f, 0.99f);
+    vertecies[7].pos = Vec3<float>(right, front + 0.4f, bottom);
+    vertecies[7].tPos = Vec2<float>(0.99f, 0.99f);
+    // third y plane
+    vertecies[8].pos = Vec3<float>(left, front + 0.6f, top);
+    vertecies[8].tPos = Vec2<float>(0.01f, 0.01f);
+    vertecies[9].pos = Vec3<float>(right, front + 0.6f, top);
+    vertecies[9].tPos = Vec2<float>(0.99f, 0.01f);
+    vertecies[10].pos = Vec3<float>(left, front + 0.6f, bottom);
+    vertecies[10].tPos = Vec2<float>(0.01f, 0.99f);
+    vertecies[11].pos = Vec3<float>(right, front + 0.6f, bottom);
+    vertecies[11].tPos = Vec2<float>(0.99f, 0.99f);
+    // forth y plane
+    vertecies[12].pos = Vec3<float>(left, front + 0.8f, top);
+    vertecies[12].tPos = Vec2<float>(0.01f, 0.01f);
+    vertecies[13].pos = Vec3<float>(right, front + 0.8f, top);
+    vertecies[13].tPos = Vec2<float>(0.99f, 0.01f);
+    vertecies[14].pos = Vec3<float>(left, front + 0.8f, bottom);
+    vertecies[14].tPos = Vec2<float>(0.01f, 0.99f);
+    vertecies[15].pos = Vec3<float>(right, front + 0.8f, bottom);
+    vertecies[15].tPos = Vec2<float>(0.99f, 0.99f);
+    // first x plane
+    vertecies[16].pos = Vec3<float>(right + 0.2f, front, top);
+    vertecies[16].tPos = Vec2<float>(0.01f, 0.01f);
+    vertecies[17].pos = Vec3<float>(right + 0.2f, back, top);
+    vertecies[17].tPos = Vec2<float>(0.99f, 0.01f);
+    vertecies[18].pos = Vec3<float>(right + 0.2f, front, bottom);
+    vertecies[18].tPos = Vec2<float>(0.01f, 0.99f);
+    vertecies[19].pos = Vec3<float>(right + 0.2f, back, bottom);
+    vertecies[19].tPos = Vec2<float>(0.99f, 0.99f);
+    // second x plane
+    vertecies[20].pos = Vec3<float>(right + 0.4f, front, top);
+    vertecies[20].tPos = Vec2<float>(0.01f, 0.01f);
+    vertecies[21].pos = Vec3<float>(right + 0.4f, back, top);
+    vertecies[21].tPos = Vec2<float>(0.99f, 0.01f);
+    vertecies[22].pos = Vec3<float>(right + 0.4f, front, bottom);
+    vertecies[22].tPos = Vec2<float>(0.01f, 0.99f);
+    vertecies[23].pos = Vec3<float>(right + 0.4f, back, bottom);
+    vertecies[23].tPos = Vec2<float>(0.99f, 0.99f);
+    // third x plane
+    vertecies[24].pos = Vec3<float>(right + 0.6f, front, top);
+    vertecies[24].tPos = Vec2<float>(0.01f, 0.01f);
+    vertecies[25].pos = Vec3<float>(right + 0.6f, back, top);
+    vertecies[25].tPos = Vec2<float>(0.99f, 0.01f);
+    vertecies[26].pos = Vec3<float>(right + 0.6f, front, bottom);
+    vertecies[26].tPos = Vec2<float>(0.01f, 0.99f);
+    vertecies[27].pos = Vec3<float>(right + 0.6f, back, bottom);
+    vertecies[27].tPos = Vec2<float>(0.99f, 0.99f);
+    // forth x plane
+    vertecies[28].pos = Vec3<float>(right + 0.8f, front, top);
+    vertecies[28].tPos = Vec2<float>(0.01f, 0.01f);
+    vertecies[29].pos = Vec3<float>(right + 0.8f, back, top);
+    vertecies[29].tPos = Vec2<float>(0.99f, 0.01f);
+    vertecies[30].pos = Vec3<float>(right + 0.8f, front, bottom);
+    vertecies[30].tPos = Vec2<float>(0.01f, 0.99f);
+    vertecies[31].pos = Vec3<float>(right + 0.8f, back, bottom);
+    vertecies[31].tPos = Vec2<float>(0.99f, 0.99f);
+    for (int i = 0; i < 16; i++)
+    {
+        vertecies[i].normal = Vec3<float>(0, 1, 0);
+    }
+    for (int i = 16; i < 32; i++)
+    {
+        vertecies[i].normal = Vec3<float>(1, 0, 0);
+    }
+
+    data->setVertecies(vertecies, 32);
+
+    Polygon3D* p = new Polygon3D();
+    p->indexAnz = 6 * 8;
+    p->indexList = new int[p->indexAnz];
+    for (int i = 0; i < 8; i++)
+    {
+        p->indexList[i * 6 + 0] = 0 + i * 4;
+        p->indexList[i * 6 + 1] = 1 + i * 4;
+        p->indexList[i * 6 + 2] = 2 + i * 4;
+        p->indexList[i * 6 + 3] = 1 + i * 4;
+        p->indexList[i * 6 + 4] = 3 + i * 4;
+        p->indexList[i * 6 + 5] = 2 + i * 4;
+    }
+    data->addPolygon(p);
+
+    // data->calculateNormals();
+    data->release();
+}
+
+void createFluidCube(Bildschirm* zScreen)
+{
+    Model3DData* data = zScreen->zGraphicsApi()->createModel("fluid");
+    data->setAmbientFactor(0.f);
+    data->setDiffusFactor(1.f);
+    data->setSpecularFactor(0.f);
+    float size = 1;
+    float left, right, top, bottom;
+    // Calculate the screen coordinates of the left side of the bitmap.
+    right = (float)((-size / 2.0));
+    // Calculate the screen coordinates of the right side of the bitmap.
+    left = right + (float)size;
+    // Calculate the screen coordinates of the top of the bitmap.
+    top = (float)(size / 2.0);
+    // Calculate the screen coordinates of the bottom of the bitmap.
+    bottom = top - (float)size;
+    float front = -size / 2;
+    float back = front + size;
+
+    Vertex3D* vertecies = new Vertex3D[24];
+    for (int i = 0; i < 24; i++)
+        vertecies[i].knochenId = 0;
+    // front side
+    vertecies[0].pos = Vec3<float>(left, front, top);
+    vertecies[0].tPos = Vec2<float>(0.f, 0.f);
+    vertecies[1].pos = Vec3<float>(right, front, top);
+    vertecies[1].tPos = Vec2<float>(1.f, 0.f);
+    vertecies[2].pos = Vec3<float>(left, front, bottom);
+    vertecies[2].tPos = Vec2<float>(0.f, 1.f);
+    vertecies[3].pos = Vec3<float>(right, front, bottom);
+    vertecies[3].tPos = Vec2<float>(1.f, 1.f);
+    // back side
+    vertecies[4].pos = Vec3<float>(right, back, top);
+    vertecies[4].tPos = Vec2<float>(0.0f, 0.0f);
+    vertecies[5].pos = Vec3<float>(left, back, top);
+    vertecies[5].tPos = Vec2<float>(1.0f, 0.0f);
+    vertecies[6].pos = Vec3<float>(right, back, bottom);
+    vertecies[6].tPos = Vec2<float>(0.0f, 1.0f);
+    vertecies[7].pos = Vec3<float>(left, back, bottom);
+    vertecies[7].tPos = Vec2<float>(1.0f, 1.0f);
+    // left side
+    vertecies[8].pos = Vec3<float>(left, back, top);
+    vertecies[8].tPos = Vec2<float>(0.f, 0.f);
+    vertecies[9].pos = Vec3<float>(left, front, top);
+    vertecies[9].tPos = Vec2<float>(1.f, 0.f);
+    vertecies[10].pos = Vec3<float>(left, back, bottom);
+    vertecies[10].tPos = Vec2<float>(0.f, 1.f);
+    vertecies[11].pos = Vec3<float>(left, front, bottom);
+    vertecies[11].tPos = Vec2<float>(1.f, 1.f);
+    // right side
+    vertecies[12].pos = Vec3<float>(right, front, top);
+    vertecies[12].tPos = Vec2<float>(0.0f, 0.0f);
+    vertecies[13].pos = Vec3<float>(right, back, top);
+    vertecies[13].tPos = Vec2<float>(1.0f, 0.0f);
+    vertecies[14].pos = Vec3<float>(right, front, bottom);
+    vertecies[14].tPos = Vec2<float>(0.0f, 1.0f);
+    vertecies[15].pos = Vec3<float>(right, back, bottom);
+    vertecies[15].tPos = Vec2<float>(1.0f, 1.0f);
+    // top side
+    vertecies[16].pos = Vec3<float>(left, back, top);
+    vertecies[16].tPos = Vec2<float>(0.f, 0.f);
+    vertecies[17].pos = Vec3<float>(right, back, top);
+    vertecies[17].tPos = Vec2<float>(1.f, 0.f);
+    vertecies[18].pos = Vec3<float>(left, front, top);
+    vertecies[18].tPos = Vec2<float>(0.f, 1.f);
+    vertecies[19].pos = Vec3<float>(right, front, top);
+    vertecies[19].tPos = Vec2<float>(1.f, 1.f);
+    // botom side
+    vertecies[20].pos = Vec3<float>(left, front, bottom);
+    vertecies[20].tPos = Vec2<float>(0.0f, 0.0f);
+    vertecies[21].pos = Vec3<float>(right, front, bottom);
+    vertecies[21].tPos = Vec2<float>(1.0f, 0.0f);
+    vertecies[22].pos = Vec3<float>(left, back, bottom);
+    vertecies[22].tPos = Vec2<float>(0.0f, 1.0f);
+    vertecies[23].pos = Vec3<float>(right, back, bottom);
+    vertecies[23].tPos = Vec2<float>(1.0f, 1.0f);
+
+    data->setVertecies(vertecies, 24);
+    // the order of the polygons has to be NORTH (front), EAST (left), SOUTH
+    // (back), WEST (right), TOP, BOTTOM according to the Area definition front
+    // side
+    Polygon3D* p
+        = new Polygon3D(); // looking from (0,0,0) to (1,0,0) to see this side
+    p->indexAnz = 6;
+    p->indexList = new int[p->indexAnz];
+    p->indexList[0] = 0;
+    p->indexList[1] = 1;
+    p->indexList[2] = 2;
+    p->indexList[3] = 1;
+    p->indexList[4] = 3;
+    p->indexList[5] = 2;
+    data->addPolygon(p);
+    // left side
+    p = new Polygon3D(); // looking from (0,0,0) to (0,1,0) to see this side
+    p->indexAnz = 6;
+    p->indexList = new int[p->indexAnz];
+    p->indexList[0] = 0 + 8;
+    p->indexList[1] = 1 + 8;
+    p->indexList[2] = 2 + 8;
+    p->indexList[3] = 1 + 8;
+    p->indexList[4] = 3 + 8;
+    p->indexList[5] = 2 + 8;
+    data->addPolygon(p);
+    // back side
+    p = new Polygon3D(); // looking from (0,0,0) to (-1,0,0) to see this side
+    p->indexAnz = 6;
+    p->indexList = new int[p->indexAnz];
+    p->indexList[0] = 0 + 4;
+    p->indexList[1] = 1 + 4;
+    p->indexList[2] = 2 + 4;
+    p->indexList[3] = 1 + 4;
+    p->indexList[4] = 3 + 4;
+    p->indexList[5] = 2 + 4;
+    data->addPolygon(p);
+    // right side
+    p = new Polygon3D(); // looking from (0,0,0) to (0,-1,0) to see this side
+    p->indexAnz = 6;
+    p->indexList = new int[p->indexAnz];
+    p->indexList[0] = 0 + 12;
+    p->indexList[1] = 1 + 12;
+    p->indexList[2] = 2 + 12;
+    p->indexList[3] = 1 + 12;
+    p->indexList[4] = 3 + 12;
+    p->indexList[5] = 2 + 12;
+    data->addPolygon(p);
+    // top side
+    p = new Polygon3D(); // looking from (0,0,0) to (0,0,-1) to see this side
+    p->indexAnz = 6;
+    p->indexList = new int[p->indexAnz];
+    p->indexList[0] = 0 + 16;
+    p->indexList[1] = 1 + 16;
+    p->indexList[2] = 2 + 16;
+    p->indexList[3] = 1 + 16;
+    p->indexList[4] = 3 + 16;
+    p->indexList[5] = 2 + 16;
+    data->addPolygon(p);
+    // botom side
+    p = new Polygon3D(); // looking from (0,0,0) to (0,0,1) to see this side
+    p->indexAnz = 6;
+    p->indexList = new int[p->indexAnz];
+    p->indexList[0] = 0 + 20;
+    p->indexList[1] = 1 + 20;
+    p->indexList[2] = 2 + 20;
+    p->indexList[3] = 1 + 20;
+    p->indexList[4] = 3 + 20;
+    p->indexList[5] = 2 + 20;
+    data->addPolygon(p);
+
+    data->calculateNormals();
+    data->release();
+}
+
+void createModels(Bildschirm* zScreen)
+{
+    createDefaultCube(zScreen);
+    createPlayer(zScreen);
+    createGrass(zScreen);
+    createFluidCube(zScreen);
+}
+
+struct FileInfo
+{
+    Text path;
+    __int64 size;
+    int year;
+    int month;
+    int day;
+    int seconds;
+};
+
 FactoryClient::FactoryClient()
 {
     client = 0;
@@ -26,6 +622,168 @@ FactoryClient::~FactoryClient()
 
 void FactoryClient::loadServerInfo()
 {
+    LoadMenu* loadMenu = (LoadMenu*)(Menu*)menuRegister->get("load");
+    Text resourcePath = "data/resources/";
+    resourcePath.append() << client->getServerIp() << "/"
+                          << client->getServerPort() << "/";
+    Text tmp = resourcePath + "metainfo.dat";
+    Datei metaInfo(tmp);
+    Trie<FileInfo*> metaInfos;
+    Array<FileInfo*> metaInfoList;
+    Array<FileInfo*> downloadOrder;
+    if (metaInfo.existiert())
+    {
+        loadMenu->beginNextStage(
+            "reading resource metadata", (int)metaInfo.getSize());
+        metaInfo.open(Datei::Style::lesen);
+        while (!metaInfo.istEnde())
+        {
+            short len = 0;
+            metaInfo.lese((char*)&len, 2);
+            char* path = new char[len + 1];
+            metaInfo.lese(path, len);
+            path[len] = 0;
+            FileInfo* fi = new FileInfo();
+            fi->path = Text(path);
+            fi->size = 0;
+            metaInfo.lese((char*)&fi->year, 4);
+            metaInfo.lese((char*)&fi->month, 4);
+            metaInfo.lese((char*)&fi->day, 4);
+            metaInfo.lese((char*)&fi->seconds, 4);
+            metaInfos.set(path, len, fi);
+            delete[] path;
+            metaInfoList.add(fi);
+            loadMenu->stageProgress(18 + len);
+        }
+        metaInfo.close();
+    }
+    short len = 0;
+    foreground->getNachricht((char*)&len, 2);
+    while (len)
+    {
+        char* path = new char[len + 1];
+        foreground->getNachricht(path, len);
+        path[len] = 0;
+        FileInfo* fi = metaInfos.get(path, len);
+        int year;
+        int month;
+        int day;
+        int seconds;
+        foreground->getNachricht((char*)&year, 4);
+        foreground->getNachricht((char*)&month, 4);
+        foreground->getNachricht((char*)&day, 4);
+        foreground->getNachricht((char*)&seconds, 4);
+        if (!fi || fi->year != year || fi->month != month || fi->day != day
+            || fi->seconds != seconds)
+        {
+            if (!fi)
+            {
+                fi = new FileInfo();
+                fi->path = Text(path);
+                metaInfos.set(path, len, fi);
+                metaInfoList.add(fi);
+            }
+            fi->year = year;
+            fi->month = month;
+            fi->day = day;
+            fi->seconds = seconds;
+            foreground->sende("\1", 1);
+            foreground->getNachricht((char*)&fi->size, 8);
+            downloadOrder.add(fi);
+        }
+        else
+        {
+            foreground->sende("\0", 1);
+        }
+        delete[] path;
+        foreground->getNachricht((char*)&len, 2);
+    }
+    loadMenu->allProgress(1);
+    char* buffer = new char[4096];
+    loadMenu->beginNextStage(
+        "download updated resouces", downloadOrder.getEintragAnzahl());
+    for (FileInfo* info : downloadOrder)
+    {
+        loadMenu->beginNextStep(info->path, (int)info->size);
+        tmp = resourcePath + info->path;
+        Datei file(tmp);
+        if (!file.existiert())
+        {
+            file.erstellen();
+        }
+        file.open(Datei::Style::schreiben);
+        __int64 remaining = info->size;
+        while (remaining > 0)
+        {
+            int toRead = remaining > 4096 ? 4096 : (int)remaining;
+            foreground->getNachricht(buffer, toRead);
+            file.schreibe(buffer, toRead);
+            remaining -= toRead;
+            loadMenu->stepProgress(toRead);
+        }
+        file.close();
+        loadMenu->stageProgress(1);
+    }
+    delete[] buffer;
+    loadMenu->allProgress(1);
+    loadMenu->beginNextStage(
+        "writing resource metadata", metaInfoList.getEintragAnzahl());
+    if (!metaInfo.existiert())
+    {
+        metaInfo.erstellen();
+    }
+    metaInfo.open(Datei::Style::schreiben);
+    for (FileInfo* info : metaInfoList)
+    {
+        short len = (short)info->path.getLength();
+        metaInfo.schreibe((char*)&len, 2);
+        metaInfo.schreibe(info->path.getText(), len);
+        metaInfo.schreibe((char*)&info->year, 4);
+        metaInfo.schreibe((char*)&info->month, 4);
+        metaInfo.schreibe((char*)&info->day, 4);
+        metaInfo.schreibe((char*)&info->seconds, 4);
+        loadMenu->stageProgress(1);
+    }
+    metaInfo.close();
+    loadMenu->allProgress(1);
+    loadMenu->beginNextStage(
+        "loading resources", metaInfoList.getEintragAnzahl());
+    for (FileInfo* info : metaInfoList)
+    {
+        if (info->path.endsWith(".ltdb"))
+        {
+            LTDBDatei dat;
+            dat.setDatei(new Text(resourcePath + info->path));
+            dat.leseDaten(0);
+            loadMenu->beginNextStep(info->path, dat.getBildAnzahl());
+            for (Text* name : *dat.zBildListe())
+            {
+                Bild* b = dat.laden(0, new Text(*name));
+                uiFactory.initParam.bildschirm->zGraphicsApi()
+                    ->createOrGetTextur(info->path + "/" + *name, b)
+                    ->release();
+                loadMenu->stepProgress(1);
+            }
+        }
+        else if (info->path.endsWith(".m3"))
+        {
+            M3Datei dat(resourcePath + info->path);
+            dat.leseDaten();
+            loadMenu->beginNextStep(info->path, dat.getModelAnzahl());
+            for (int i = 0; i < dat.getModelAnzahl(); i++)
+            {
+                Model3DData* d = dat.ladeModel(dat.zModelName(i)->getText(),
+                    uiFactory.initParam.bildschirm->zGraphicsApi(),
+                    info->path + "/" + *dat.zModelName(i));
+                d->release();
+                loadMenu->stepProgress(1);
+            }
+        }
+        loadMenu->stageProgress(1);
+    }
+    loadMenu->allProgress(1);
+    createModels(uiFactory.initParam.bildschirm);
+    loadMenu->allProgress(1);
     std::cout << "downloading server type information\n";
     // receive type information
     for (int i = 0; i < blockTypeCount; i++)
@@ -61,6 +819,7 @@ void FactoryClient::loadServerInfo()
             fluid,
             maxFlowDistance);
     }
+    loadMenu->allProgress(1);
     foregroundReader->lese((char*)&itemTypeCount, 4);
     itemTypes = new ItemType*[itemTypeCount];
     for (int i = 0; i < itemTypeCount; i++)
@@ -82,6 +841,7 @@ void FactoryClient::loadServerInfo()
         delete[] name;
         delete[] tooltipUIML;
     }
+    loadMenu->allProgress(1);
     foregroundReader->lese((char*)&entityTypeCount, 4);
     entityTypes = new EntityType*[entityTypeCount];
     for (int i = 0; i < entityTypeCount; i++)
@@ -90,7 +850,8 @@ void FactoryClient::loadServerInfo()
         foregroundReader->lese((char*)&id, 4);
         entityTypes[i] = new EntityType(id, ModelInfo(foregroundReader));
     }
-    // pre rendering item models
+    loadMenu->allProgress(1);
+    loadMenu->beginNextStage("rendering item icons", itemTypeCount);
     Kam3D* kam = new Kam3D();
     Welt3D* w = new Welt3D();
     w->addDiffuseLight(DiffuseLight{
@@ -139,9 +900,11 @@ void FactoryClient::loadServerInfo()
         t->release();
         window->zBildschirm()->unlock();
         w->removeZeichnung(mdl);
+        loadMenu->stageProgress(1);
     }
     b->release();
     kam->release();
+    loadMenu->allProgress(1);
 }
 
 bool FactoryClient::connect(Text ip, unsigned short sslPort)

+ 3 - 6
FactoryCraft/Globals.cpp

@@ -26,19 +26,16 @@ void initVariables()
 
 void initMenus()
 {
-    LoadMenu *load = new LoadMenu(uiFactory.initParam.bildschirm);
-    menuRegister->put("load",
-        RCPointer<Menu>::of(load));
     menuRegister->put("serverSelection",
         RCPointer<Menu>::of(
             new ServerSelectionMenu(uiFactory.initParam.bildschirm)));
     menuRegister->put("addServer",
         RCPointer<Menu>::of(new AddServerMenu(uiFactory.initParam.bildschirm)));
+    menuRegister->put("load",
+        RCPointer<Menu>::of(new LoadMenu(uiFactory.initParam.bildschirm)));
     menuRegister->put(
         "game", RCPointer<Menu>::of(new Game(uiFactory.initParam.bildschirm)));
-
-    menuRegister->get("load")->show();
-    load->load();
+    menuRegister->get("serverSelection")->show();
 }
 
 void releaseVariables()

+ 71 - 662
FactoryCraft/Load.cpp

@@ -9,694 +9,103 @@
 #include <Text.h>
 #include <Textur.h>
 
+#include "FactoryClient.h"
 #include "Globals.h"
 #include "Initialisierung.h"
 #include "ServerSelection.h"
 
-void createDefaultCube(Bildschirm* zScreen)
+LoadMenu::LoadMenu(Bildschirm* zScreen)
+    : Menu(zScreen)
 {
-    Model3DData* data = zScreen->zGraphicsApi()->createModel("cube");
-    data->setAmbientFactor(0.f);
-    data->setDiffusFactor(1.f);
-    data->setSpecularFactor(0.f);
-    float size = 1;
-    float left, right, top, bottom;
-    // Calculate the screen coordinates of the left side of the bitmap.
-    right = (float)((-size / 2.0));
-    // Calculate the screen coordinates of the right side of the bitmap.
-    left = right + (float)size;
-    // Calculate the screen coordinates of the top of the bitmap.
-    top = (float)(size / 2.0);
-    // Calculate the screen coordinates of the bottom of the bitmap.
-    bottom = top - (float)size;
-    float front = -size / 2;
-    float back = front + size;
-
-    Vertex3D* vertecies = new Vertex3D[24];
-    for (int i = 0; i < 24; i++)
-        vertecies[i].knochenId = 0;
-    // front side
-    vertecies[0].pos = Vec3<float>(left, front, top);
-    vertecies[0].tPos = Vec2<float>(0.f, 0.f);
-    vertecies[1].pos = Vec3<float>(right, front, top);
-    vertecies[1].tPos = Vec2<float>(1.f, 0.f);
-    vertecies[2].pos = Vec3<float>(left, front, bottom);
-    vertecies[2].tPos = Vec2<float>(0.f, 1.f);
-    vertecies[3].pos = Vec3<float>(right, front, bottom);
-    vertecies[3].tPos = Vec2<float>(1.f, 1.f);
-    // back side
-    vertecies[4].pos = Vec3<float>(right, back, top);
-    vertecies[4].tPos = Vec2<float>(0.0f, 0.0f);
-    vertecies[5].pos = Vec3<float>(left, back, top);
-    vertecies[5].tPos = Vec2<float>(1.0f, 0.0f);
-    vertecies[6].pos = Vec3<float>(right, back, bottom);
-    vertecies[6].tPos = Vec2<float>(0.0f, 1.0f);
-    vertecies[7].pos = Vec3<float>(left, back, bottom);
-    vertecies[7].tPos = Vec2<float>(1.0f, 1.0f);
-    // left side
-    vertecies[8].pos = Vec3<float>(left, back, top);
-    vertecies[8].tPos = Vec2<float>(0.f, 0.f);
-    vertecies[9].pos = Vec3<float>(left, front, top);
-    vertecies[9].tPos = Vec2<float>(1.f, 0.f);
-    vertecies[10].pos = Vec3<float>(left, back, bottom);
-    vertecies[10].tPos = Vec2<float>(0.f, 1.f);
-    vertecies[11].pos = Vec3<float>(left, front, bottom);
-    vertecies[11].tPos = Vec2<float>(1.f, 1.f);
-    // right side
-    vertecies[12].pos = Vec3<float>(right, front, top);
-    vertecies[12].tPos = Vec2<float>(0.0f, 0.0f);
-    vertecies[13].pos = Vec3<float>(right, back, top);
-    vertecies[13].tPos = Vec2<float>(1.0f, 0.0f);
-    vertecies[14].pos = Vec3<float>(right, front, bottom);
-    vertecies[14].tPos = Vec2<float>(0.0f, 1.0f);
-    vertecies[15].pos = Vec3<float>(right, back, bottom);
-    vertecies[15].tPos = Vec2<float>(1.0f, 1.0f);
-    // top side
-    vertecies[16].pos = Vec3<float>(left, back, top);
-    vertecies[16].tPos = Vec2<float>(0.f, 0.f);
-    vertecies[17].pos = Vec3<float>(right, back, top);
-    vertecies[17].tPos = Vec2<float>(1.f, 0.f);
-    vertecies[18].pos = Vec3<float>(left, front, top);
-    vertecies[18].tPos = Vec2<float>(0.f, 1.f);
-    vertecies[19].pos = Vec3<float>(right, front, top);
-    vertecies[19].tPos = Vec2<float>(1.f, 1.f);
-    // botom side
-    vertecies[20].pos = Vec3<float>(left, front, bottom);
-    vertecies[20].tPos = Vec2<float>(0.0f, 0.0f);
-    vertecies[21].pos = Vec3<float>(right, front, bottom);
-    vertecies[21].tPos = Vec2<float>(1.0f, 0.0f);
-    vertecies[22].pos = Vec3<float>(left, back, bottom);
-    vertecies[22].tPos = Vec2<float>(0.0f, 1.0f);
-    vertecies[23].pos = Vec3<float>(right, back, bottom);
-    vertecies[23].tPos = Vec2<float>(1.0f, 1.0f);
-
-    data->setVertecies(vertecies, 24);
-    // the order of the polygons has to be NORTH (front), EAST (left), SOUTH
-    // (back), WEST (right), TOP, BOTTOM according to the Area definition
-    // front side
-    Polygon3D* p
-        = new Polygon3D(); // looking from (0,0,0) to (1,0,0) to see this side
-    p->indexAnz = 6;
-    p->indexList = new int[p->indexAnz];
-    p->indexList[0] = 0;
-    p->indexList[1] = 1;
-    p->indexList[2] = 2;
-    p->indexList[3] = 1;
-    p->indexList[4] = 3;
-    p->indexList[5] = 2;
-    data->addPolygon(p);
-    // left side
-    p = new Polygon3D(); // looking from (0,0,0) to (0,1,0) to see this side
-    p->indexAnz = 6;
-    p->indexList = new int[p->indexAnz];
-    p->indexList[0] = 0 + 8;
-    p->indexList[1] = 1 + 8;
-    p->indexList[2] = 2 + 8;
-    p->indexList[3] = 1 + 8;
-    p->indexList[4] = 3 + 8;
-    p->indexList[5] = 2 + 8;
-    data->addPolygon(p);
-    // back side
-    p = new Polygon3D(); // looking from (0,0,0) to (-1,0,0) to see this side
-    p->indexAnz = 6;
-    p->indexList = new int[p->indexAnz];
-    p->indexList[0] = 0 + 4;
-    p->indexList[1] = 1 + 4;
-    p->indexList[2] = 2 + 4;
-    p->indexList[3] = 1 + 4;
-    p->indexList[4] = 3 + 4;
-    p->indexList[5] = 2 + 4;
-    data->addPolygon(p);
-    // right side
-    p = new Polygon3D(); // looking from (0,0,0) to (0,-1,0) to see this side
-    p->indexAnz = 6;
-    p->indexList = new int[p->indexAnz];
-    p->indexList[0] = 0 + 12;
-    p->indexList[1] = 1 + 12;
-    p->indexList[2] = 2 + 12;
-    p->indexList[3] = 1 + 12;
-    p->indexList[4] = 3 + 12;
-    p->indexList[5] = 2 + 12;
-    data->addPolygon(p);
-    // top side
-    p = new Polygon3D(); // looking from (0,0,0) to (0,0,-1) to see this side
-    p->indexAnz = 6;
-    p->indexList = new int[p->indexAnz];
-    p->indexList[0] = 0 + 16;
-    p->indexList[1] = 1 + 16;
-    p->indexList[2] = 2 + 16;
-    p->indexList[3] = 1 + 16;
-    p->indexList[4] = 3 + 16;
-    p->indexList[5] = 2 + 16;
-    data->addPolygon(p);
-    // botom side
-    p = new Polygon3D(); // looking from (0,0,0) to (0,0,1) to see this side
-    p->indexAnz = 6;
-    p->indexList = new int[p->indexAnz];
-    p->indexList[0] = 0 + 20;
-    p->indexList[1] = 1 + 20;
-    p->indexList[2] = 2 + 20;
-    p->indexList[3] = 1 + 20;
-    p->indexList[4] = 3 + 20;
-    p->indexList[5] = 2 + 20;
-    data->addPolygon(p);
-    data->calculateNormals();
-    data->release();
+    Punkt center = zScreen->getBackBufferSize() / 2;
+    all = initFBalken(
+        center.x - 100, center.y - 65, 200, 30, FBalken::Style::normal);
+    stageTitle = initTextFeld(center.x - 100,
+        center.y - 30,
+        zScreen->getBackBufferSize().x - center.x + 100,
+        15,
+        TextFeld::Style::Text,
+        "");
+    stage = initFBalken(
+        center.x - 100, center.y - 15, 200, 30, FBalken::Style::normal);
+    stage->removeStyle(FBalken::Style::Sichtbar);
+    stepTitle = initTextFeld(center.x - 100,
+        center.y + 20,
+        zScreen->getBackBufferSize().x - center.x + 100,
+        15,
+        TextFeld::Style::Text,
+        "");
+    step = initFBalken(
+        center.x - 100, center.y + 35, 200, 30, FBalken::Style::normal);
+    step->removeStyle(FBalken::Style::Sichtbar);
+    elements.add(step);
+    elements.add(stepTitle);
+    elements.add(stage);
+    elements.add(stageTitle);
+    elements.add(all);
 }
 
-void createPlayer(Bildschirm* zScreen)
+void LoadMenu::stepProgress(int stepSize)
 {
-    Framework::Model3DData* data
-        = window->zBildschirm()->zGraphicsApi()->createModel("player");
-    data->setAmbientFactor(0.8f);
-    data->setDiffusFactor(0.1f);
-    data->setSpecularFactor(0.1f);
-    float size = 0.8f;
-    float left, right, top, bottom;
-    // Calculate the screen coordinates of the left side of the bitmap.
-    left = (float)((size / 2.0) * -1);
-    // Calculate the screen coordinates of the right side of the bitmap.
-    right = left + (float)size;
-    // Calculate the screen coordinates of the top of the bitmap.
-    top = (float)(size / 2.0);
-    // Calculate the screen coordinates of the bottom of the bitmap.
-    bottom = top - (float)size;
-    float front = -1.5f / 2;
-    float back = front + 1.5f;
-
-    Vertex3D* vertecies = new Vertex3D[24];
-    for (int i = 0; i < 24; i++)
-        vertecies[i].knochenId = 0;
-    vertecies[0].pos = Vec3<float>(left, top, front);
-    vertecies[0].tPos = Vec2<float>(0.f, 0.f);
-    vertecies[1].pos = Vec3<float>(right, top, front);
-    vertecies[1].tPos = Vec2<float>(1.f, 0.f);
-    vertecies[2].pos = Vec3<float>(left, bottom, front);
-    vertecies[2].tPos = Vec2<float>(0.f, 1.f);
-    vertecies[3].pos = Vec3<float>(right, bottom, front);
-    vertecies[3].tPos = Vec2<float>(1.f, 1.f);
-    vertecies[4].pos = Vec3<float>(left, top, back);
-    vertecies[4].tPos = Vec2<float>(0.0f, 0.0f);
-    vertecies[5].pos = Vec3<float>(right, top, back);
-    vertecies[5].tPos = Vec2<float>(1.0f, 0.0f);
-    vertecies[6].pos = Vec3<float>(left, bottom, back);
-    vertecies[6].tPos = Vec2<float>(0.0f, 1.0f);
-    vertecies[7].pos = Vec3<float>(right, bottom, back);
-    vertecies[7].tPos = Vec2<float>(1.0f, 1.0f);
-
-    vertecies[8].pos = Vec3<float>(left, top, front);
-    vertecies[8].tPos = Vec2<float>(1.f, 0.f);
-    vertecies[9].pos = Vec3<float>(right, top, front);
-    vertecies[9].tPos = Vec2<float>(0.f, 0.f);
-    vertecies[10].pos = Vec3<float>(left, bottom, front);
-    vertecies[10].tPos = Vec2<float>(1.f, 1.f);
-    vertecies[11].pos = Vec3<float>(right, bottom, front);
-    vertecies[11].tPos = Vec2<float>(0.f, 1.f);
-    vertecies[12].pos = Vec3<float>(left, top, back);
-    vertecies[12].tPos = Vec2<float>(0.0f, 0.0f);
-    vertecies[13].pos = Vec3<float>(right, top, back);
-    vertecies[13].tPos = Vec2<float>(1.0f, 0.0f);
-    vertecies[14].pos = Vec3<float>(left, bottom, back);
-    vertecies[14].tPos = Vec2<float>(0.0f, 1.0f);
-    vertecies[15].pos = Vec3<float>(right, bottom, back);
-    vertecies[15].tPos = Vec2<float>(1.0f, 1.0f);
-
-    vertecies[16].pos = Vec3<float>(left, top, front);
-    vertecies[16].tPos = Vec2<float>(0.f, 1.f);
-    vertecies[17].pos = Vec3<float>(right, top, front);
-    vertecies[17].tPos = Vec2<float>(1.f, 1.f);
-    vertecies[18].pos = Vec3<float>(left, bottom, front);
-    vertecies[18].tPos = Vec2<float>(0.f, 0.f);
-    vertecies[19].pos = Vec3<float>(right, bottom, front);
-    vertecies[19].tPos = Vec2<float>(1.f, 0.f);
-    vertecies[20].pos = Vec3<float>(left, top, back);
-    vertecies[20].tPos = Vec2<float>(0.0f, 0.0f);
-    vertecies[21].pos = Vec3<float>(right, top, back);
-    vertecies[21].tPos = Vec2<float>(1.0f, 0.0f);
-    vertecies[22].pos = Vec3<float>(left, bottom, back);
-    vertecies[22].tPos = Vec2<float>(0.0f, 1.0f);
-    vertecies[23].pos = Vec3<float>(right, bottom, back);
-    vertecies[23].tPos = Vec2<float>(1.0f, 1.0f);
-
-    data->setVertecies(vertecies, 24);
-    // the order of the polygons has to be NORTH, EAST, SOUTH, WEST, TOP, BOTTOM
-    // according to the Area definition down side
-    Polygon3D* p = new Polygon3D();
-    p->indexAnz = 6;
-    p->indexList = new int[p->indexAnz];
-    p->indexList[0] = 6 + 16;
-    p->indexList[1] = 2 + 16;
-    p->indexList[2] = 3 + 16;
-    p->indexList[3] = 6 + 16;
-    p->indexList[4] = 3 + 16;
-    p->indexList[5] = 7 + 16;
-    data->addPolygon(p);
-    // right side
-    p = new Polygon3D();
-    p->indexAnz = 6;
-    p->indexList = new int[p->indexAnz];
-    p->indexList[0] = 1 + 8;
-    p->indexList[1] = 7 + 8;
-    p->indexList[2] = 3 + 8;
-    p->indexList[3] = 1 + 8;
-    p->indexList[4] = 5 + 8;
-    p->indexList[5] = 7 + 8;
-    data->addPolygon(p);
-    // top side
-    p = new Polygon3D();
-    p->indexAnz = 6;
-    p->indexList = new int[p->indexAnz];
-    p->indexList[0] = 4 + 16;
-    p->indexList[1] = 1 + 16;
-    p->indexList[2] = 0 + 16;
-    p->indexList[3] = 4 + 16;
-    p->indexList[4] = 5 + 16;
-    p->indexList[5] = 1 + 16;
-    data->addPolygon(p);
-    // left side
-    p = new Polygon3D();
-    p->indexAnz = 6;
-    p->indexList = new int[p->indexAnz];
-    p->indexList[0] = 0 + 8;
-    p->indexList[1] = 2 + 8;
-    p->indexList[2] = 6 + 8;
-    p->indexList[3] = 0 + 8;
-    p->indexList[4] = 6 + 8;
-    p->indexList[5] = 4 + 8;
-    data->addPolygon(p);
-    // back side
-    p = new Polygon3D();
-    p->indexAnz = 6;
-    p->indexList = new int[p->indexAnz];
-    p->indexList[0] = 4;
-    p->indexList[1] = 6;
-    p->indexList[2] = 7;
-    p->indexList[3] = 4;
-    p->indexList[4] = 7;
-    p->indexList[5] = 5;
-    data->addPolygon(p);
-    // front side
-    p = new Polygon3D();
-    p->indexAnz = 6;
-    p->indexList = new int[p->indexAnz];
-    p->indexList[0] = 0;
-    p->indexList[1] = 3;
-    p->indexList[2] = 2;
-    p->indexList[3] = 0;
-    p->indexList[4] = 1;
-    p->indexList[5] = 3;
-    data->addPolygon(p);
-    data->calculateNormals();
-    data->release();
+    step->aktionPlus(stepSize);
 }
 
-void createGrass(Bildschirm* zScreen)
+void LoadMenu::beginNextStep(const char* title, int nextStepSize)
 {
-    Model3DData* data = zScreen->zGraphicsApi()->createModel("grass");
-    data->setAmbientFactor(0.f);
-    data->setDiffusFactor(1.f);
-    data->setSpecularFactor(0.f);
-
-    float size = 1;
-    float left, right, top, bottom;
-    // Calculate the screen coordinates of the left side of the bitmap.
-    right = (float)((-size / 2.0));
-    // Calculate the screen coordinates of the right side of the bitmap.
-    left = right + (float)size;
-    // Calculate the screen coordinates of the top of the bitmap.
-    top = (float)(size / 2.0);
-    // Calculate the screen coordinates of the bottom of the bitmap.
-    bottom = top - (float)size;
-    float front = -size / 2;
-    float back = front + size;
-
-    Vertex3D* vertecies = new Vertex3D[32];
-    for (int i = 0; i < 32; i++)
-        vertecies[i].knochenId = 0;
-
-    // first y plane
-    vertecies[0].pos = Vec3<float>(left, front + 0.2f, top);
-    vertecies[0].tPos = Vec2<float>(0.01f, 0.01f);
-    vertecies[1].pos = Vec3<float>(right, front + 0.2f, top);
-    vertecies[1].tPos = Vec2<float>(0.99f, 0.01f);
-    vertecies[2].pos = Vec3<float>(left, front + 0.2f, bottom);
-    vertecies[2].tPos = Vec2<float>(0.01f, 0.99f);
-    vertecies[3].pos = Vec3<float>(right, front + 0.2f, bottom);
-    vertecies[3].tPos = Vec2<float>(0.99f, 0.99f);
-    // second y plane
-    vertecies[4].pos = Vec3<float>(left, front + 0.4f, top);
-    vertecies[4].tPos = Vec2<float>(0.01f, 0.01f);
-    vertecies[5].pos = Vec3<float>(right, front + 0.4f, top);
-    vertecies[5].tPos = Vec2<float>(0.99f, 0.01f);
-    vertecies[6].pos = Vec3<float>(left, front + 0.4f, bottom);
-    vertecies[6].tPos = Vec2<float>(0.01f, 0.99f);
-    vertecies[7].pos = Vec3<float>(right, front + 0.4f, bottom);
-    vertecies[7].tPos = Vec2<float>(0.99f, 0.99f);
-    // third y plane
-    vertecies[8].pos = Vec3<float>(left, front + 0.6f, top);
-    vertecies[8].tPos = Vec2<float>(0.01f, 0.01f);
-    vertecies[9].pos = Vec3<float>(right, front + 0.6f, top);
-    vertecies[9].tPos = Vec2<float>(0.99f, 0.01f);
-    vertecies[10].pos = Vec3<float>(left, front + 0.6f, bottom);
-    vertecies[10].tPos = Vec2<float>(0.01f, 0.99f);
-    vertecies[11].pos = Vec3<float>(right, front + 0.6f, bottom);
-    vertecies[11].tPos = Vec2<float>(0.99f, 0.99f);
-    // forth y plane
-    vertecies[12].pos = Vec3<float>(left, front + 0.8f, top);
-    vertecies[12].tPos = Vec2<float>(0.01f, 0.01f);
-    vertecies[13].pos = Vec3<float>(right, front + 0.8f, top);
-    vertecies[13].tPos = Vec2<float>(0.99f, 0.01f);
-    vertecies[14].pos = Vec3<float>(left, front + 0.8f, bottom);
-    vertecies[14].tPos = Vec2<float>(0.01f, 0.99f);
-    vertecies[15].pos = Vec3<float>(right, front + 0.8f, bottom);
-    vertecies[15].tPos = Vec2<float>(0.99f, 0.99f);
-    // first x plane
-    vertecies[16].pos = Vec3<float>(right + 0.2f, front, top);
-    vertecies[16].tPos = Vec2<float>(0.01f, 0.01f);
-    vertecies[17].pos = Vec3<float>(right + 0.2f, back, top);
-    vertecies[17].tPos = Vec2<float>(0.99f, 0.01f);
-    vertecies[18].pos = Vec3<float>(right + 0.2f, front, bottom);
-    vertecies[18].tPos = Vec2<float>(0.01f, 0.99f);
-    vertecies[19].pos = Vec3<float>(right + 0.2f, back, bottom);
-    vertecies[19].tPos = Vec2<float>(0.99f, 0.99f);
-    // second x plane
-    vertecies[20].pos = Vec3<float>(right + 0.4f, front, top);
-    vertecies[20].tPos = Vec2<float>(0.01f, 0.01f);
-    vertecies[21].pos = Vec3<float>(right + 0.4f, back, top);
-    vertecies[21].tPos = Vec2<float>(0.99f, 0.01f);
-    vertecies[22].pos = Vec3<float>(right + 0.4f, front, bottom);
-    vertecies[22].tPos = Vec2<float>(0.01f, 0.99f);
-    vertecies[23].pos = Vec3<float>(right + 0.4f, back, bottom);
-    vertecies[23].tPos = Vec2<float>(0.99f, 0.99f);
-    // third x plane
-    vertecies[24].pos = Vec3<float>(right + 0.6f, front, top);
-    vertecies[24].tPos = Vec2<float>(0.01f, 0.01f);
-    vertecies[25].pos = Vec3<float>(right + 0.6f, back, top);
-    vertecies[25].tPos = Vec2<float>(0.99f, 0.01f);
-    vertecies[26].pos = Vec3<float>(right + 0.6f, front, bottom);
-    vertecies[26].tPos = Vec2<float>(0.01f, 0.99f);
-    vertecies[27].pos = Vec3<float>(right + 0.6f, back, bottom);
-    vertecies[27].tPos = Vec2<float>(0.99f, 0.99f);
-    // forth x plane
-    vertecies[28].pos = Vec3<float>(right + 0.8f, front, top);
-    vertecies[28].tPos = Vec2<float>(0.01f, 0.01f);
-    vertecies[29].pos = Vec3<float>(right + 0.8f, back, top);
-    vertecies[29].tPos = Vec2<float>(0.99f, 0.01f);
-    vertecies[30].pos = Vec3<float>(right + 0.8f, front, bottom);
-    vertecies[30].tPos = Vec2<float>(0.01f, 0.99f);
-    vertecies[31].pos = Vec3<float>(right + 0.8f, back, bottom);
-    vertecies[31].tPos = Vec2<float>(0.99f, 0.99f);
-    for (int i = 0; i < 16; i++)
-    {
-        vertecies[i].normal = Vec3<float>(0, 1, 0);
-    }
-    for (int i = 16; i < 32; i++)
-    {
-        vertecies[i].normal = Vec3<float>(1, 0, 0);
-    }
-
-    data->setVertecies(vertecies, 32);
-
-    Polygon3D* p = new Polygon3D();
-    p->indexAnz = 6 * 8;
-    p->indexList = new int[p->indexAnz];
-    for (int i = 0; i < 8; i++)
-    {
-        p->indexList[i * 6 + 0] = 0 + i * 4;
-        p->indexList[i * 6 + 1] = 1 + i * 4;
-        p->indexList[i * 6 + 2] = 2 + i * 4;
-        p->indexList[i * 6 + 3] = 1 + i * 4;
-        p->indexList[i * 6 + 4] = 3 + i * 4;
-        p->indexList[i * 6 + 5] = 2 + i * 4;
-    }
-    data->addPolygon(p);
-
-    //data->calculateNormals();
-    data->release();
+    stepTitle->setText(title);
+    step->setAktionAnzahl(nextStepSize);
+    step->reset();
+    step->addStyle(FBalken::Style::Sichtbar);
 }
 
-void createFluidCube(Bildschirm* zScreen)
+void LoadMenu::stageProgress(int stepSize)
 {
-    Model3DData* data = zScreen->zGraphicsApi()->createModel("fluid");
-    data->setAmbientFactor(0.f);
-    data->setDiffusFactor(1.f);
-    data->setSpecularFactor(0.f);
-    float size = 1;
-    float left, right, top, bottom;
-    // Calculate the screen coordinates of the left side of the bitmap.
-    right = (float)((-size / 2.0));
-    // Calculate the screen coordinates of the right side of the bitmap.
-    left = right + (float)size;
-    // Calculate the screen coordinates of the top of the bitmap.
-    top = (float)(size / 2.0);
-    // Calculate the screen coordinates of the bottom of the bitmap.
-    bottom = top - (float)size;
-    float front = -size / 2;
-    float back = front + size;
-
-    Vertex3D* vertecies = new Vertex3D[24];
-    for (int i = 0; i < 24; i++)
-        vertecies[i].knochenId = 0;
-    // front side
-    vertecies[0].pos = Vec3<float>(left, front, top);
-    vertecies[0].tPos = Vec2<float>(0.f, 0.f);
-    vertecies[1].pos = Vec3<float>(right, front, top);
-    vertecies[1].tPos = Vec2<float>(1.f, 0.f);
-    vertecies[2].pos = Vec3<float>(left, front, bottom);
-    vertecies[2].tPos = Vec2<float>(0.f, 1.f);
-    vertecies[3].pos = Vec3<float>(right, front, bottom);
-    vertecies[3].tPos = Vec2<float>(1.f, 1.f);
-    // back side
-    vertecies[4].pos = Vec3<float>(right, back, top);
-    vertecies[4].tPos = Vec2<float>(0.0f, 0.0f);
-    vertecies[5].pos = Vec3<float>(left, back, top);
-    vertecies[5].tPos = Vec2<float>(1.0f, 0.0f);
-    vertecies[6].pos = Vec3<float>(right, back, bottom);
-    vertecies[6].tPos = Vec2<float>(0.0f, 1.0f);
-    vertecies[7].pos = Vec3<float>(left, back, bottom);
-    vertecies[7].tPos = Vec2<float>(1.0f, 1.0f);
-    // left side
-    vertecies[8].pos = Vec3<float>(left, back, top);
-    vertecies[8].tPos = Vec2<float>(0.f, 0.f);
-    vertecies[9].pos = Vec3<float>(left, front, top);
-    vertecies[9].tPos = Vec2<float>(1.f, 0.f);
-    vertecies[10].pos = Vec3<float>(left, back, bottom);
-    vertecies[10].tPos = Vec2<float>(0.f, 1.f);
-    vertecies[11].pos = Vec3<float>(left, front, bottom);
-    vertecies[11].tPos = Vec2<float>(1.f, 1.f);
-    // right side
-    vertecies[12].pos = Vec3<float>(right, front, top);
-    vertecies[12].tPos = Vec2<float>(0.0f, 0.0f);
-    vertecies[13].pos = Vec3<float>(right, back, top);
-    vertecies[13].tPos = Vec2<float>(1.0f, 0.0f);
-    vertecies[14].pos = Vec3<float>(right, front, bottom);
-    vertecies[14].tPos = Vec2<float>(0.0f, 1.0f);
-    vertecies[15].pos = Vec3<float>(right, back, bottom);
-    vertecies[15].tPos = Vec2<float>(1.0f, 1.0f);
-    // top side
-    vertecies[16].pos = Vec3<float>(left, back, top);
-    vertecies[16].tPos = Vec2<float>(0.f, 0.f);
-    vertecies[17].pos = Vec3<float>(right, back, top);
-    vertecies[17].tPos = Vec2<float>(1.f, 0.f);
-    vertecies[18].pos = Vec3<float>(left, front, top);
-    vertecies[18].tPos = Vec2<float>(0.f, 1.f);
-    vertecies[19].pos = Vec3<float>(right, front, top);
-    vertecies[19].tPos = Vec2<float>(1.f, 1.f);
-    // botom side
-    vertecies[20].pos = Vec3<float>(left, front, bottom);
-    vertecies[20].tPos = Vec2<float>(0.0f, 0.0f);
-    vertecies[21].pos = Vec3<float>(right, front, bottom);
-    vertecies[21].tPos = Vec2<float>(1.0f, 0.0f);
-    vertecies[22].pos = Vec3<float>(left, back, bottom);
-    vertecies[22].tPos = Vec2<float>(0.0f, 1.0f);
-    vertecies[23].pos = Vec3<float>(right, back, bottom);
-    vertecies[23].tPos = Vec2<float>(1.0f, 1.0f);
-
-    data->setVertecies(vertecies, 24);
-    // the order of the polygons has to be NORTH (front), EAST (left), SOUTH
-    // (back), WEST (right), TOP, BOTTOM according to the Area definition front
-    // side
-    Polygon3D* p
-        = new Polygon3D(); // looking from (0,0,0) to (1,0,0) to see this side
-    p->indexAnz = 6;
-    p->indexList = new int[p->indexAnz];
-    p->indexList[0] = 0;
-    p->indexList[1] = 1;
-    p->indexList[2] = 2;
-    p->indexList[3] = 1;
-    p->indexList[4] = 3;
-    p->indexList[5] = 2;
-    data->addPolygon(p);
-    // left side
-    p = new Polygon3D(); // looking from (0,0,0) to (0,1,0) to see this side
-    p->indexAnz = 6;
-    p->indexList = new int[p->indexAnz];
-    p->indexList[0] = 0 + 8;
-    p->indexList[1] = 1 + 8;
-    p->indexList[2] = 2 + 8;
-    p->indexList[3] = 1 + 8;
-    p->indexList[4] = 3 + 8;
-    p->indexList[5] = 2 + 8;
-    data->addPolygon(p);
-    // back side
-    p = new Polygon3D(); // looking from (0,0,0) to (-1,0,0) to see this side
-    p->indexAnz = 6;
-    p->indexList = new int[p->indexAnz];
-    p->indexList[0] = 0 + 4;
-    p->indexList[1] = 1 + 4;
-    p->indexList[2] = 2 + 4;
-    p->indexList[3] = 1 + 4;
-    p->indexList[4] = 3 + 4;
-    p->indexList[5] = 2 + 4;
-    data->addPolygon(p);
-    // right side
-    p = new Polygon3D(); // looking from (0,0,0) to (0,-1,0) to see this side
-    p->indexAnz = 6;
-    p->indexList = new int[p->indexAnz];
-    p->indexList[0] = 0 + 12;
-    p->indexList[1] = 1 + 12;
-    p->indexList[2] = 2 + 12;
-    p->indexList[3] = 1 + 12;
-    p->indexList[4] = 3 + 12;
-    p->indexList[5] = 2 + 12;
-    data->addPolygon(p);
-    // top side
-    p = new Polygon3D(); // looking from (0,0,0) to (0,0,-1) to see this side
-    p->indexAnz = 6;
-    p->indexList = new int[p->indexAnz];
-    p->indexList[0] = 0 + 16;
-    p->indexList[1] = 1 + 16;
-    p->indexList[2] = 2 + 16;
-    p->indexList[3] = 1 + 16;
-    p->indexList[4] = 3 + 16;
-    p->indexList[5] = 2 + 16;
-    data->addPolygon(p);
-    // botom side
-    p = new Polygon3D(); // looking from (0,0,0) to (0,0,1) to see this side
-    p->indexAnz = 6;
-    p->indexList = new int[p->indexAnz];
-    p->indexList[0] = 0 + 20;
-    p->indexList[1] = 1 + 20;
-    p->indexList[2] = 2 + 20;
-    p->indexList[3] = 1 + 20;
-    p->indexList[4] = 3 + 20;
-    p->indexList[5] = 2 + 20;
-    data->addPolygon(p);
-
-    data->calculateNormals();
-    data->release();
+    stage->aktionPlus(stepSize);
+    step->removeStyle(FBalken::Style::Sichtbar);
 }
 
-void createModels(Bildschirm* zScreen)
+void LoadMenu::beginNextStage(const char* title, int nextStageSize)
 {
-    createDefaultCube(zScreen);
-    createPlayer(zScreen);
-    createGrass(zScreen);
-    createFluidCube(zScreen);
+    stageTitle->setText(title);
+    stage->setAktionAnzahl(nextStageSize);
+    stage->reset();
+    stage->addStyle(FBalken::Style::Sichtbar);
+    step->removeStyle(FBalken::Style::Sichtbar);
 }
 
-LoadMenu::LoadMenu(Bildschirm* zScreen)
-    : Menu(zScreen)
+void LoadMenu::allProgress(int stepSize)
 {
-    Punkt center = zScreen->getBackBufferSize() / 2;
-    step = initFBalken(
-        center.x - 100, center.y + 25, 200, 30, FBalken::Style::normal);
-    stage = initFBalken(
-        center.x - 100, center.y - 15, 200, 30, FBalken::Style::normal);
-    all = initFBalken(
-        center.x - 100, center.y - 55, 200, 30, FBalken::Style::normal);
-    elements.add(step);
-    elements.add(stage);
-    elements.add(all);
-
+    all->aktionPlus(stepSize);
+    stage->removeStyle(FBalken::Style::Sichtbar);
+    step->removeStyle(FBalken::Style::Sichtbar);
 }
 
-void LoadMenu::load() {
-    new AsynchronCall("Load Menu", [this]() {
-        Sleep(1000);
-        all->setAktionAnzahl(2);
-        all->reset();
-        // loading textures
-        Datei texturF;
-        texturF.setDatei("data/textures");
-        RCArray<Text>* files = texturF.getDateiListe();
-        if (files)
-        {
-            int count = 0;
-            for (Text* fileName : *files)
-            {
-                LTDBDatei dat;
-                dat.setDatei(new Text(Text("data/textures/") + *fileName));
-                dat.leseDaten(0);
-                count += dat.getBildAnzahl();
-            }
-            stage->setAktionAnzahl(count);
-            stage->reset();
-            for (Text* fileName : *files)
-            {
-                LTDBDatei dat;
-                dat.setDatei(new Text(Text("data/textures/") + *fileName));
-                dat.leseDaten(0);
-                for (Text* name : *dat.zBildListe())
-                {
-                    step->reset();
-                    Bild* b = dat.laden(step, new Text(*name));
-                    zScreen->zGraphicsApi()
-                        ->createOrGetTextur(*fileName + "/" + *name, b)
-                        ->release();
-                    stage->aktionPlus();
-                }
-            }
-            files->release();
-        }
-        all->aktionPlus();
-        // loading models
-        stage->setAktionAnzahl(1);
-        Datei modelF;
-        modelF.setDatei("data/models");
-        files = modelF.getDateiListe();
-        if (files)
-        {
-            int count = 0;
-            for (Text* fileName : *files)
-            {
-                M3Datei dat(Text("data/models/") + *fileName);
-                dat.leseDaten();
-                count += dat.getModelAnzahl();
-            }
-            stage->setAktionAnzahl(count + 1);
-            stage->reset();
-            for (Text* fileName : *files)
-            {
-                M3Datei dat(Text("data/models/") + *fileName);
-                dat.leseDaten();
-                for (int i = 0; i < dat.getModelAnzahl(); i++)
-                {
-                    step->reset();
-                    Model3DData* d = dat.ladeModel(dat.zModelName(i)->getText(),
-                        zScreen->zGraphicsApi(),
-                        *fileName + "/" + *dat.zModelName(i));
-                    d->release();
-                    stage->aktionPlus();
-                }
-            }
-            files->release();
-        }
-        createModels(zScreen);
-        stage->aktionPlus();
-        all->aktionPlus();
-        stage->reset();
-        zScreen->lock();
-        hide();
-        menuRegister->get("serverSelection")->show();
-        zScreen->unlock();
-    });
+void LoadMenu::load(FactoryClient* client,
+    Text name,
+    Text secret,
+    unsigned short port,
+    std::function<void(int, Text)> onFinish)
+{
+    all->setAktionAnzahl(9);
+    all->reset();
+    stageTitle->setText("");
+    stepTitle->setText("");
+    step->removeStyle(FBalken::Style::Sichtbar);
+    stage->removeStyle(FBalken::Style::Sichtbar);
+    new AsynchronCall(
+        "Load Menu", [this, client, name, secret, port, onFinish]() {
+            Text tmp = secret;
+            int result = client->join(name, tmp, port);
+            onFinish(result, secret);
+        });
 }
 
 Bild* loadImage(Framework::Text path)
 {
     LTDBDatei file;
-    file.setDatei(path.getTeilText(0, path.positionVon("/", path.anzahlVon("/") - 1)));
+    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));
+    return file.laden(0,
+        path.getTeilText(path.positionVon("/", path.anzahlVon("/") - 1) + 1));
 }

+ 16 - 1
FactoryCraft/Load.h

@@ -1,20 +1,35 @@
 #pragma once
 
 #include <Fortschritt.h>
+#include <TextFeld.h>
 
 #include "Menu.h"
 #undef LoadMenu
 
+class ServerStatus;
+class FactoryClient;
+
 class LoadMenu : public Menu
 {
 private:
     FBalken* step;
+    TextFeld* stepTitle;
     FBalken* stage;
+    TextFeld* stageTitle;
     FBalken* all;
 
 public:
     LoadMenu(Bildschirm* zScreen);
-    void load();
+    void load(FactoryClient* client,
+        Text name,
+        Text secret,
+        unsigned short port,
+        std::function<void(int, Text)> onFinish);
+    void stepProgress(int stepSize);
+    void beginNextStep(const char* title, int nextStepSize);
+    void stageProgress(int stepSize);
+    void beginNextStage(const char* title, int nextStageSize);
+    void allProgress(int stepSize);
 };
 
 Bild* loadImage(Framework::Text path);

+ 48 - 31
FactoryCraft/ServerSelection.cpp

@@ -14,6 +14,7 @@
 #include "FactoryClient.h"
 #include "Globals.h"
 #include "Initialisierung.h"
+#include "Load.h"
 
 using namespace Framework;
 
@@ -60,37 +61,53 @@ ServerStatus::ServerStatus(Framework::Text name,
                     secret = this->secrets->get(playerName);
                 if (statusId == 203) secret = "";
                 bool isNew = secret.getLength() == 0;
-                int stId = client->join(playerName, secret, getPort());
-                lockZeichnung();
-                statusId = stId;
-                if (statusId == 403) status = "The name is already in use";
-                if (statusId == 500) status = "Unknown Server message received";
-                if (statusId == 201) status = "Please try again";
-                unlockZeichnung();
-                if (statusId == 200 || statusId == 201)
-                {
-                    if (statusId == 200)
-                        ((ServerSelectionMenu*)(Menu*)menuRegister->get(
-                             "serverSelection"))
-                            ->hide();
-                    if (isNew)
-                    {
-                        this->secrets->put(playerName, secret);
-                        ((ServerSelectionMenu*)(Menu*)menuRegister->get(
-                             "serverSelection"))
-                            ->saveServers();
-                    }
-                    if (statusId == 200)
-                    {
-                        World::INSTANCE = new World(
-                            dynamic_cast<Bildschirm3D*>(window->zBildschirm()),
-                            client);
-                        ((ServerSelectionMenu*)(Menu*)menuRegister->get("game"))
-                            ->show();
-                    }
-                }
-                else
-                    client->release();
+                menuRegister->get("serverSelection")->hide();
+                menuRegister->get("load")->show();
+                ((LoadMenu*)(Menu*)menuRegister->get("load"))
+                    ->load(client,
+                        playerName,
+                        secret,
+                        getPort(),
+                        [this, isNew, client](int result, Text secret) {
+                            menuRegister->get("load")->hide();
+                            lockZeichnung();
+                            statusId = result;
+                            if (statusId == 403)
+                                status = "The name is already in use";
+                            if (statusId == 500)
+                                status = "Unknown Server message received";
+                            if (statusId == 201) status = "Please try again";
+                            unlockZeichnung();
+                            if (statusId == 200 || statusId == 201)
+                            {
+                                if (isNew)
+                                {
+                                    this->secrets->put(playerName, secret);
+                                    ((ServerSelectionMenu*)(Menu*)menuRegister
+                                            ->get("serverSelection"))
+                                        ->saveServers();
+                                }
+                                if (statusId == 200)
+                                {
+                                    World::INSTANCE
+                                        = new World(dynamic_cast<Bildschirm3D*>(
+                                                        window->zBildschirm()),
+                                            client);
+                                    menuRegister->get("game")->show();
+                                }
+                                else
+                                {
+                                    menuRegister->get("serverSelection")
+                                        ->show();
+                                    client->release();
+                                }
+                            }
+                            else
+                            {
+                                menuRegister->get("serverSelection")->show();
+                                client->release();
+                            }
+                        });
             }
         }
         return 1;