Explorar el Código

allow null as itemType attribut for block Types without corresponding items

Kolja Strohm hace 4 días
padre
commit
22a41a4299

+ 0 - 106
ConfigEditor/main.cpp

@@ -1,106 +0,0 @@
-#include <Datei.h>
-#include <DateiSystem.h>
-#include <Fenster.h>
-#include <GraphicsApi.h>
-#include <JsonEditor.h>
-#include <Logging.h>
-#include <main.h>
-#include <MausEreignis.h>
-#include <RenderThread.h>
-#include <Schrift.h>
-#include <TastaturEreignis.h>
-#include <UIInitialization.h>
-#include <XML.h>
-
-using namespace Framework;
-
-int KSGStart Framework::Start(Startparam p)
-{
-    Logging::LoggingChannel* logger
-        = new Logging::OutputDebugStringLoggingChannel();
-    logger->setFormat(Logging::LoggingFormatBuilder()
-                          .datetime("h:i:s")
-                          .level(false)
-                          .text(": ")
-                          .build());
-    Logging::zLoggingHandler()->addChannel(logger);
-
-    WFenster fenster;
-    WNDCLASS wc = Framework::F_Normal(p.hinst);
-    wc.lpszClassName = "Config Editor";
-    fenster.erstellen(WS_OVERLAPPEDWINDOW, wc);
-    fenster.setBounds(Punkt(100, 100), Punkt(1100, 1100));
-
-    fenster.setAnzeigeModus(SW_SHOWNORMAL);
-    fenster.setVSchließAktion([&fenster](void* p, void* f) {
-        StopNachrichtenSchleife(fenster.getFensterHandle());
-    });
-    fenster.setMausAktion(_ret1ME);
-    fenster.setTastaturAktion(_ret1TE);
-    Bildschirm3D screen(
-        dynamic_cast<WFenster*>(fenster.getThis()), new DirectX11());
-    screen.setHandleUserInputsOnTick(1);
-    fenster.setBildschirm(dynamic_cast<Bildschirm*>(screen.getThis()));
-    screen.setFillFarbe(0);
-    screen.setTestRend(1);
-
-    LTDSDatei dat;
-    dat.setPfad(new Text("data/schriften/ksgs.ltds"));
-    dat.leseDaten();
-    Schrift* schrift = dat.ladeSchrift();
-
-    JSON::JsonEditor* editor
-        = new JSON::JsonEditor(Framework::defaultUI(schrift, &screen));
-    editor->setPosition(0, 0);
-    editor->setSize(1080, 1050);
-    editor->setStyle(ZeichnungHintergrund::Style::Hintergrund
-                     | ZeichnungHintergrund::Style::Sichtbar
-                     | ZeichnungHintergrund::Style::Erlaubt);
-    editor->setHintergrundFarbe(0xFF000000);
-    editor->setFont(dynamic_cast<Schrift*>(schrift->getThis()));
-    editor->setMausEreignis(_ret1ME);
-    editor->setTastaturEreignis(_ret1TE);
-
-    Datei v("../Windows Version/data/syntax/class DimensionGenerator.xml");
-    v.open(Datei::Style::lesen);
-    int size = (int)v.getSize();
-    char* buffer = new char[size + 1];
-    v.lese(buffer, size);
-    buffer[size] = 0;
-    v.close();
-    XML::Element* xml = new XML::Element(buffer);
-    delete[] buffer;
-    JSON::Validator::JSONValidator* validator
-        = JSON::Validator::JSONValidator::buildForArray()
-              ->addAcceptedTypeInArray(
-                  new Framework::JSON::Validator::JSONValidator(xml))
-              ->finishArray();
-    editor->setValidator(validator);
-
-    Datei d("../Windows Version/data/generator/overworld.json");
-    // Datei d("C:/Users/kolja/Downloads/train_0/train_0.iml");
-    //  Datei d("C:/Users/kolja/Downloads/train_0/neu 36.txt");
-    d.open(Datei::Style::lesen);
-    size = (int)d.getSize();
-    buffer = new char[size + 1];
-    d.lese(buffer, size);
-    buffer[size] = 0;
-    d.close();
-
-    editor->setContent(buffer);
-    // editor->setContent("{\"price_usd\": \"üöä\",\"test\":{},\"\":[]}");
-    delete[] buffer;
-    screen.addMember(editor);
-
-    RenderTh rTh;
-    rTh.setMaxFps(60);
-    rTh.setQuiet(1);
-    rTh.setBildschirm(dynamic_cast<Bildschirm*>(screen.getThis()));
-
-    rTh.beginn();
-    StartNachrichtenSchleife();
-    rTh.beenden();
-    schrift->release();
-
-    return 0;
-}

+ 0 - 18
FactoryCraft.sln

@@ -9,8 +9,6 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Windows Version", "Windows
 EndProject
 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "NoiseTest", "NoiseTest\NoiseTest.vcxproj", "{096A454C-3835-4A4E-89FE-34EDCCD80467}"
 EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ConfigEditor", "ConfigEditor\ConfigEditor.vcxproj", "{1EF64C4F-FDB8-4C8E-9D85-B71937DDCADD}"
-EndProject
 Global
 	GlobalSection(SolutionConfigurationPlatforms) = preSolution
 		Debug|ARM = Debug|ARM
@@ -77,22 +75,6 @@ Global
 		{096A454C-3835-4A4E-89FE-34EDCCD80467}.Release|x64.Build.0 = Release|x64
 		{096A454C-3835-4A4E-89FE-34EDCCD80467}.Release|x86.ActiveCfg = Release|Win32
 		{096A454C-3835-4A4E-89FE-34EDCCD80467}.Release|x86.Build.0 = Release|Win32
-		{1EF64C4F-FDB8-4C8E-9D85-B71937DDCADD}.Debug|ARM.ActiveCfg = Debug|x64
-		{1EF64C4F-FDB8-4C8E-9D85-B71937DDCADD}.Debug|ARM.Build.0 = Debug|x64
-		{1EF64C4F-FDB8-4C8E-9D85-B71937DDCADD}.Debug|ARM64.ActiveCfg = Debug|x64
-		{1EF64C4F-FDB8-4C8E-9D85-B71937DDCADD}.Debug|ARM64.Build.0 = Debug|x64
-		{1EF64C4F-FDB8-4C8E-9D85-B71937DDCADD}.Debug|x64.ActiveCfg = Debug|x64
-		{1EF64C4F-FDB8-4C8E-9D85-B71937DDCADD}.Debug|x64.Build.0 = Debug|x64
-		{1EF64C4F-FDB8-4C8E-9D85-B71937DDCADD}.Debug|x86.ActiveCfg = Debug|Win32
-		{1EF64C4F-FDB8-4C8E-9D85-B71937DDCADD}.Debug|x86.Build.0 = Debug|Win32
-		{1EF64C4F-FDB8-4C8E-9D85-B71937DDCADD}.Release|ARM.ActiveCfg = Release|x64
-		{1EF64C4F-FDB8-4C8E-9D85-B71937DDCADD}.Release|ARM.Build.0 = Release|x64
-		{1EF64C4F-FDB8-4C8E-9D85-B71937DDCADD}.Release|ARM64.ActiveCfg = Release|x64
-		{1EF64C4F-FDB8-4C8E-9D85-B71937DDCADD}.Release|ARM64.Build.0 = Release|x64
-		{1EF64C4F-FDB8-4C8E-9D85-B71937DDCADD}.Release|x64.ActiveCfg = Release|x64
-		{1EF64C4F-FDB8-4C8E-9D85-B71937DDCADD}.Release|x64.Build.0 = Release|x64
-		{1EF64C4F-FDB8-4C8E-9D85-B71937DDCADD}.Release|x86.ActiveCfg = Release|Win32
-		{1EF64C4F-FDB8-4C8E-9D85-B71937DDCADD}.Release|x86.Build.0 = Release|Win32
 	EndGlobalSection
 	GlobalSection(SolutionProperties) = preSolution
 		HideSolutionNode = FALSE

+ 29 - 4
FactoryCraft/BasicBlocks.cpp

@@ -65,6 +65,10 @@ Block* BasicBlockType::createBlock(
 
 Item* BasicBlockType::createItem() const
 {
+    if (getItemTypeName().istGleich(""))
+    {
+        return 0;
+    }
     return Game::INSTANCE->zItemType(itemTypeId)->createItem();
 }
 
@@ -75,6 +79,10 @@ Framework::Text BasicBlockType::getItemTypeName() const
 
 ItemType* BasicBlockType::createItemType() const
 {
+    if (getItemTypeName().istGleich(""))
+    {
+        return 0;
+    }
     return new BasicBlockItemType(getItemTypeName(),
         new ModelInfo(zModel()->getModelPath(),
             zModel()->getTexturePaths(),
@@ -154,7 +162,15 @@ BasicBlockType* BasicBlockTypeFactory::fromJson(
     Framework::JSON::JSONObject* zJson) const
 {
     BasicBlockType* result = BlockTypeFactoryBase::fromJson(zJson);
-    result->setItemTypeName(zJson->zValue("itemType")->asString()->getString());
+    if (zJson->zValue("itemType")->getType() == Framework::AbstractType::STRING)
+    {
+        result->setItemTypeName(
+            zJson->zValue("itemType")->asString()->getString());
+    }
+    else
+    {
+        result->setItemTypeName("");
+    }
     result->setTransparent(zJson->zValue("transparent")->asBool()->getBool());
     result->setPassable(zJson->zValue("passable")->asBool()->getBool());
     result->setSpeedModifier(
@@ -169,8 +185,15 @@ Framework::JSON::JSONObject* BasicBlockTypeFactory::toJsonObject(
 {
     Framework::JSON::JSONObject* result
         = BlockTypeFactoryBase::toJsonObject(zObject);
-    result->addValue("itemType",
-        new Framework::JSON::JSONString(zObject->getItemTypeName()));
+    if (zObject->getItemTypeName().istGleich(""))
+    {
+        result->addValue("itemType", new Framework::JSON::JSONValue());
+    }
+    else
+    {
+        result->addValue("itemType",
+            new Framework::JSON::JSONString(zObject->getItemTypeName()));
+    }
     result->addValue(
         "transparent", new Framework::JSON::JSONBool(zObject->isTransparent()));
     result->addValue(
@@ -189,7 +212,9 @@ JSONObjectValidationBuilder* BasicBlockTypeFactory::addToValidator(
         builder
             ->withRequiredAttribute("itemType",
                 Game::INSTANCE->zTypeRegistry()->getValidator<Framework::Text>(
-                    ItemTypeNameFactory::TYPE_ID))
+                    ItemTypeNameFactory::TYPE_ID),
+                true,
+                false)
             ->withRequiredBool("transparent")
             ->withDefault(false)
             ->finishBool()

+ 19 - 19
Windows Version/data/blocks/blockTypes.json

@@ -1,22 +1,22 @@
 [
-  {
-    "type": "basicBlock",
-    "name": "Dirt",
-    "itemType": "Dirt",
-    "model": {
-      "modelPath": "cube",
-      "texturePaths": [
-        "blocks.ltdb/dirt.png",
-        "blocks.ltdb/dirt.png",
-        "blocks.ltdb/dirt.png",
-        "blocks.ltdb/dirt.png",
-        "blocks.ltdb/lawn.png",
-        "blocks.ltdb/dirt.png"
-      ]
+    {
+        "type": "basicBlock",
+        "name": "Dirt",
+        "itemType": "Dirt",
+        "model": {
+            "modelPath": "cube",
+            "texturePaths": [
+                "blocks.ltdb/dirt.png",
+                "blocks.ltdb/dirt.png",
+                "blocks.ltdb/dirt.png",
+                "blocks.ltdb/dirt.png",
+                "blocks.ltdb/lawn.png",
+                "blocks.ltdb/dirt.png"
+            ]
+        },
+        "mapColor": "0xFF3C7C29",
+        "groupNames": [ "Shovel" ]
     },
-    "mapColor": "0xFF3C7C29",
-    "groupNames": [ "Shovel" ]
-  },
   {
     "type": "basicBlock",
     "name": "Stone",
@@ -405,7 +405,7 @@
   {
     "type": "grass",
     "name": "Grass",
-    "itemType": "",
+    "itemType": null,
     "model": {
       "modelPath": "grass",
       "texturePaths": [
@@ -506,7 +506,7 @@
   {
     "type": "additionalItemsBlockType",
     "name": "Wheat",
-    "itemType": "Wheat",
+    "itemType": null,
     "model": {
       "modelPath": "grass",
       "texturePaths": [

+ 1 - 1
Windows Version/data/generator/overworld.json

@@ -18,7 +18,7 @@
       ]
     },
     "biomNoise": {
-      "type": "Cellular",
+        "type": "Cellular",
       "seed": {
         "type": "variable",
         "name": "dimensionSeed"

+ 0 - 13
Windows Version/data/items/itemTypes.json

@@ -71,19 +71,6 @@
     "hp": 1,
     "durability": 10
   },
-  {
-    "type": "basic",
-    "name": "Flint",
-    "model": {
-      "modelPath": "items.m3/flint",
-      "texturePaths": [
-        "items.ltdb/flint.png"
-      ]
-    },
-    "itemName": "Flint",
-    "hp": 1,
-    "durability": 10
-  },
   {
     "type": "basic",
     "name": "Broken Shovel",