Files
neoLegacy/Minecraft.Client/Common/UI/SuperflatData.cpp
T
Tranqlmao 9abd52985e TU53 + Bug Fixes (Many)
Patch Notes:
Blocks
+ Colored shulker boxes
+ Concrete powder
+ Concrete
+ Glazed terracotta
Items
+ Shulker shell
+ Iron nugget
UI Changes
+ Added Custom Controls to Keyboard & Mouse, as well as Controller
+ Added Custom SuperFlat
+ Added Edit Server Menu
+ Added Firework Crafting
Feature Changes
+ Host Options
+ Added Pick Block
+ Added off-hand slot for maps and arrows.
Bug Fixes & changes
+ TU47: Banner hitbox wrong (and inventory model fixed)
+ TU47/48: Ice not melting properly
+ TU48: Dead bushes not dropping sticks
+ TU48: Guardians and polar bears not dropping cooked fish when on fire
+ TU48: Bonus chest missing saplings and seeds
+ TU48: Frosted ice obtainable
+ TU48: Hoppers not collecting items
+ TU48: Wither skeletons spawning in 2-high gaps
+ TU48: End crystals exploding with “TNT Explodes” off
+ TU48: Tamed ocelots staying hostile
+ TU48: Signs not placing on tall grass
+ TU51: Skeleton hitbox wrong
+ TU53: Fall damage in shallow water
+ TU53: Squids not spawning in man-made pools
+ Elytra has been improved to be more accurate to the source material
+ Removed Spectral Arrow from crafting
+ Fixed several broken item descriptions
+ You can no longer cook Pufferfish or Clownfish
+ Fixed scaling issue with paperdoll and chat
+ Iron and gold armor can now be smelted into nuggets.
+ More items can now be used as fuel in a furnace.
+ Using a firework rocket while gliding with elytra will now give the player a boost.
+ Changed the color of dyes, wool, carpets, and banners.
+ Reordered all colored blocks and items in the Creative inventory. Banners now have the same order of colors as all other colored blocks and items.
+ Fishing rods can now hook on entities without causing knockback or pseudo-damage.
+ Fixed banner crafting
+ Fixed Map colors for certain blocks
+ Fixed Path block height
+ Fixed String block issues
+ Fixed Item frame culling.
+ Fixed Tutorial world NBT/Block State issues
+ Fixed World Slider
+ Fixed Enderman AI
+ Fixed Player animation bug
+ HUD Flash text changes
+ Generation accuracy changes
+ Many other small accuracy changes and fixes
2026-11-24 13:44:06 -05:00

569 lines
19 KiB
C++

#include "stdafx.h"
#include "UI.h"
#include "SuperflatData.h"
#include "IUIScene_CreativeMenu.h"
#include "../../../Minecraft.World/net.minecraft.world.item.h"
#include "../../../Minecraft.World/net.minecraft.world.level.tile.h"
#include "../../../Minecraft.World/net.minecraft.world.level.biome.h"
#include <set>
namespace
{
const SuperflatData::Param s_params[] =
{
{ SuperflatData::eParam_Toggle, L"Villages", L"Villages appear in Plains, Savanna, Desert, Taiga and Ice Plains biomes. They are protected by Iron Golems and populated by villagers you can trade with.", L"village", nullptr, 0, 0, 0 },
{ SuperflatData::eParam_SizeSlider, L"Size", L"Changes how large each village grows.", L"village", L"size", 0, 1, 0 },
{ SuperflatData::eParam_DistanceSlider, L"Spacing", L"Changes how far apart villages are placed.", L"village", L"distance", 16, 100, 32 },
{ SuperflatData::eParam_Toggle, L"Caves", L"Winding tunnels carved through the layers of the world.", L"caves", nullptr, 0, 0, 0 },
{ SuperflatData::eParam_Toggle, L"Ravine", L"Deep, narrow canyons cut down through the layers of the world.", L"ravine", nullptr, 0, 0, 0 },
{ SuperflatData::eParam_Toggle, L"Abandoned Mineshafts", L"Old networks of wooden tunnels and rails, often holding chests with loot.", L"mineshaft", nullptr, 0, 0, 0 },
{ SuperflatData::eParam_ChanceSlider, L"Chance", L"Changes how likely a mineshaft is to appear in each area of the world.", L"mineshaft", L"chance", 1, 10, 10 },
{ SuperflatData::eParam_Toggle, L"Strongholds", L"Underground fortresses made of stone brick that hold the portal to The End.", L"stronghold", nullptr, 0, 0, 0 },
{ SuperflatData::eParam_CountSlider, L"Count", L"Changes how many strongholds are placed in the world.", L"stronghold", L"count", 1, 3, 1 },
{ SuperflatData::eParam_DistanceSlider, L"Spacing", L"Changes how far from the centre of the world the strongholds are placed.", L"stronghold", L"distance", 16, 100, 32 },
{ SuperflatData::eParam_Toggle, L"Biome Structures", L"Desert Temples, Jungle Temples, Witch Huts and Igloos, each generated in its own biome.", L"biome_1", nullptr, 0, 0, 0 },
{ SuperflatData::eParam_DistanceSlider, L"Spacing", L"Changes how far apart biome structures are placed.", L"biome_1", L"distance", 16, 100, 32 },
{ SuperflatData::eParam_Toggle, L"Ocean Monuments", L"Huge underwater temples guarded by Guardians. They need an Ocean or Deep Ocean biome and deep water.", L"oceanmonument", nullptr, 0, 0, 0 },
{ SuperflatData::eParam_DistanceSlider, L"Spacing", L"Changes how far apart ocean monuments are placed.", L"oceanmonument", L"spacing", 32, 100, 32 },
{ SuperflatData::eParam_SeparationSlider, L"Separation", L"Changes the minimum gap between ocean monuments, as a share of their spacing.", L"oceanmonument", L"separation", 5, 15, 5 },
{ SuperflatData::eParam_Toggle, L"Dungeons", L"Small rooms of cobblestone with a monster spawner and chests.", L"dungeon", nullptr, 0, 0, 0 },
{ SuperflatData::eParam_Toggle, L"Decorations", L"Trees, flowers, tall grass and other features that suit the chosen biome.", L"decoration", nullptr, 0, 0, 0 },
{ SuperflatData::eParam_Toggle, L"Lakes", L"Small pools of water scattered across the surface.", L"lake", nullptr, 0, 0, 0 },
{ SuperflatData::eParam_Toggle, L"Lava Lakes", L"Small pools of lava scattered across the world.", L"lava_lake", nullptr, 0, 0, 0 },
};
const int s_paramCount = static_cast<int>(sizeof(s_params) / sizeof(s_params[0]));
struct BiomeEntry
{
int id;
const wchar_t *name;
const wchar_t *description;
int iconId;
int iconData;
};
const BiomeEntry s_biomes[] =
{
{ 1, L"Plains", L"Open, grassy land with very few trees. Horses and farm animals roam here and villages can appear.", Tile::grass_Id, 0 },
{ 35, L"Savanna", L"Dry, warm grassland dotted with acacia trees. Villages and horses can be found here.", Tile::sapling_Id, 4 },
{ 37, L"Mesa", L"A dry land of layered, coloured hardened clay and red sand.", Tile::sand_Id, 1 },
{ 2, L"Desert", L"Hot, sandy land covered in cacti and dead bushes. Desert temples and villages can appear here.", Tile::sand_Id, 0 },
{ 4, L"Forest", L"Woodland full of oak and birch trees, with flowers growing on the ground.", Tile::log_Id, 0 },
{ 29, L"Roofed Forest", L"A dense forest of dark oak trees and giant mushrooms that blocks out the sunlight.", Tile::log2_Id, 1 },
{ 21, L"Jungle", L"Thick rainforest full of huge trees, vines and cocoa. Jungle temples and ocelots can be found here.", Tile::cocoa_Id, 0 },
{ 6, L"Swampland", L"Wet, murky land of shallow water, lily pads and vines. Witch huts and slimes can appear here.", Tile::waterlily_Id, 0 },
{ 3, L"Extreme Hills", L"Tall, rocky mountains where emerald ore can be found.", Tile::stone_Id, 0 },
{ 0, L"Ocean", L"Wide stretches of water. Squid swim here.", -1, 0 },
{ 24, L"Deep Ocean", L"Deep stretches of water where Ocean Monuments can appear.", -1, 0 },
{ 12, L"Ice Plains", L"A frozen, snow covered plain where water turns to ice. Igloos and villages can appear here.", Tile::ice_Id, 0 },
{ 30, L"Cold Taiga", L"A snowy forest of spruce trees. Wolves and rabbits live here.", Tile::snow_layer_Id, 0 },
{ 5, L"Taiga", L"A cool forest of spruce trees and ferns. Wolves can be found here.", Tile::leaves_Id, 1 },
{ 32, L"Mega Taiga", L"A forest of giant spruce trees with mossy boulders.", Tile::log2_Id, 0 },
{ 14, L"Mushroom Island", L"A rare island covered in mycelium and giant mushrooms, home to mooshrooms.", Tile::mushroom_red_Id, 0 },
{ 8, L"Nether", L"A fiery dimension of netherrack, lava and dangerous creatures.", Tile::netherrack_Id, 0 },
{ 9, L"The End", L"A dark, empty dimension of end stone floating in the void.", Tile::end_stone_Id, 0 },
};
const int s_biomeCount = static_cast<int>(sizeof(s_biomes) / sizeof(s_biomes[0]));
const wchar_t *s_presetNames[] =
{
L"Classic Flat",
L"Tunnelers' Dream",
L"Water World",
L"Overworld",
L"Snowy Kingdom",
L"Desert",
L"Redstone Ready",
};
const int s_presetCount = static_cast<int>(sizeof(s_presetNames) / sizeof(s_presetNames[0]));
struct BlockEntry
{
int id;
int data;
};
vector<BlockEntry> &Blocks()
{
static vector<BlockEntry> s_blocks;
return s_blocks;
}
void BuildBlocks()
{
vector<BlockEntry> &blocks = Blocks();
if (!blocks.empty())
return;
blocks.push_back({ 0, 0 });
blocks.push_back({ Tile::water_Id, 0 });
blocks.push_back({ Tile::lava_Id, 0 });
std::set<int> seen;
seen.insert(0);
seen.insert(Tile::water_Id << 4);
seen.insert(Tile::lava_Id << 4);
const int groups[] =
{
IUIScene_CreativeMenu::eCreativeInventory_BuildingBlocks,
IUIScene_CreativeMenu::eCreativeInventory_Decoration,
IUIScene_CreativeMenu::eCreativeInventory_Redstone,
};
for (int g = 0; g < static_cast<int>(sizeof(groups) / sizeof(groups[0])); ++g)
{
const vector<shared_ptr<ItemInstance> > &items = IUIScene_CreativeMenu::GetCategoryGroup(groups[g]);
for (auto &item : items)
{
if (item == nullptr)
continue;
int id = item->id;
if (id <= 0 || id >= 256 || Tile::tiles[id] == nullptr || id == Tile::chest_trap_Id)
continue;
int data = item->getAuxValue() & 15;
int key = (id << 4) | data;
if (seen.find(key) != seen.end())
continue;
seen.insert(key);
blocks.push_back({ id, data });
}
}
}
void GetCustomPresetsPath(wchar_t *out, size_t outLen)
{
wchar_t exePath[MAX_PATH] = {};
GetModuleFileNameW(nullptr, exePath, MAX_PATH);
wchar_t *lastSlash = wcsrchr(exePath, L'\\');
if (lastSlash)
*(lastSlash + 1) = L'\0';
_snwprintf_s(out, outLen, _TRUNCATE, L"%lssuperflat_presets.txt", exePath);
}
}
int SuperflatData::GetParamCount()
{
return s_paramCount;
}
const SuperflatData::Param &SuperflatData::GetParam(int index)
{
return s_params[index];
}
int SuperflatData::GetParamParent(int index)
{
for (int i = index; i >= 0; --i)
{
if (s_params[i].kind == eParam_Toggle)
return i;
}
return -1;
}
int SuperflatData::ReadParamValue(FlatGeneratorInfo &info, int index)
{
const Param &param = s_params[index];
if (param.kind == eParam_Toggle)
return info.hasStructure(param.structure) ? 1 : 0;
if (param.kind == eParam_ChanceSlider)
{
wstring raw = info.getOption(param.structure, param.option, L"");
if (raw.empty())
return param.defaultValue;
double chance = _wtof(raw.c_str());
int value = static_cast<int>(chance * 1000.0 + 0.5);
if (value < param.minValue) value = param.minValue;
if (value > param.maxValue) value = param.maxValue;
return value;
}
if (param.kind == eParam_SeparationSlider)
{
int spacing = info.getIntOption(param.structure, L"spacing", 32);
int separation = info.getIntOption(param.structure, param.option, -1);
if (separation < 0 || spacing <= 0)
return param.defaultValue;
int value = separation * 100 / (spacing * 5);
if (value < param.minValue) value = param.minValue;
if (value > param.maxValue) value = param.maxValue;
return value;
}
int value = info.getIntOption(param.structure, param.option, param.defaultValue);
if (value < param.minValue) value = param.minValue;
if (value > param.maxValue) value = param.maxValue;
return value;
}
void SuperflatData::WriteParamValue(FlatGeneratorInfo &info, int index, int value)
{
const Param &param = s_params[index];
if (param.kind == eParam_Toggle)
{
info.setStructure(param.structure, value != 0);
return;
}
if (!info.hasStructure(param.structure))
return;
if (param.kind == eParam_SeparationSlider)
{
int spacing = info.getIntOption(param.structure, L"spacing", 32);
int separation = spacing * value * 5 / 100;
if (separation < 5)
separation = 5;
if (separation > spacing - 1)
separation = spacing - 1;
info.setIntOption(param.structure, param.option, separation);
return;
}
if (param.kind == eParam_ChanceSlider)
{
wchar_t buffer[32];
swprintf(buffer, 32, L"%.3f", value / 1000.0);
info.setOption(param.structure, param.option, buffer);
}
else
{
info.setIntOption(param.structure, param.option, value);
}
}
wstring SuperflatData::GetParamLabel(int index, int value)
{
const Param &param = s_params[index];
wchar_t buffer[128];
switch (param.kind)
{
case eParam_SizeSlider:
swprintf(buffer, 128, L"%ls - %ls", param.name, value == 0 ? L"Small" : L"Large");
break;
case eParam_DistanceSlider:
swprintf(buffer, 128, L"%ls - %dm", param.name, value * 16);
break;
case eParam_ChanceSlider:
swprintf(buffer, 128, L"%ls - %.1f%%", param.name, value / 10.0);
break;
case eParam_CountSlider:
swprintf(buffer, 128, L"%ls - %d", param.name, value);
break;
case eParam_SeparationSlider:
swprintf(buffer, 128, L"%ls - %d%%", param.name, value * 5);
break;
default:
swprintf(buffer, 128, L"%ls", param.name);
break;
}
return buffer;
}
int SuperflatData::GetBiomeCount()
{
return s_biomeCount;
}
int SuperflatData::GetBiomeId(int index)
{
if (index < 0 || index >= s_biomeCount)
return 1;
return s_biomes[index].id;
}
const wchar_t *SuperflatData::GetBiomeName(int index)
{
if (index < 0 || index >= s_biomeCount)
return L"";
return s_biomes[index].name;
}
int SuperflatData::GetBiomeIndex(int biomeId)
{
for (int i = 0; i < s_biomeCount; ++i)
{
if (s_biomes[i].id == biomeId)
return i;
}
return 0;
}
const wchar_t *SuperflatData::GetBiomeDescription(int index)
{
if (index < 0 || index >= s_biomeCount)
return L"";
return s_biomes[index].description;
}
shared_ptr<ItemInstance> SuperflatData::GetBiomeIcon(int index)
{
if (index < 0 || index >= s_biomeCount)
return nullptr;
if (s_biomes[index].iconId < 0)
return std::make_shared<ItemInstance>(Tile::water_Id, 1, 0);
return std::make_shared<ItemInstance>(s_biomes[index].iconId, 1, s_biomes[index].iconData);
}
shared_ptr<ItemInstance> SuperflatData::GetBlockIcon(int id, int data)
{
if (id <= 0)
return nullptr;
if (id == Tile::water_Id || id == Tile::flowing_water_Id)
return std::make_shared<ItemInstance>(Tile::water_Id, 1, 0);
if (id == Tile::lava_Id || id == Tile::flowing_lava_Id)
return std::make_shared<ItemInstance>(Tile::lava_Id, 1, 0);
if (id >= 256 || Tile::tiles[id] == nullptr)
return nullptr;
return std::make_shared<ItemInstance>(id, 1, data);
}
wstring SuperflatData::GetBlockDescription(int id, int data)
{
if (id == 0)
return L"An empty layer that leaves a gap in the world.";
if (id == Tile::water_Id || id == Tile::flowing_water_Id)
return L"A layer of still water.";
if (id == Tile::lava_Id || id == Tile::flowing_lava_Id)
return L"A layer of still lava.";
shared_ptr<ItemInstance> item = GetBlockIcon(id, data);
if (item == nullptr)
return L"";
unsigned int descId = item->getUseDescriptionId();
if (descId == 0)
return L"";
LPCWSTR text = app.GetString(descId);
return text ? app.FormatHTMLString(0, wstring(text)) : wstring(L"");
}
shared_ptr<ItemInstance> SuperflatData::GetPresetIcon(int index)
{
switch (index)
{
case 0: return std::make_shared<ItemInstance>(Tile::grass_Id, 1, 0);
case 1: return std::make_shared<ItemInstance>(Tile::stone_Id, 1, 0);
case 2: return std::make_shared<ItemInstance>(Tile::water_Id, 1, 0);
case 3: return std::make_shared<ItemInstance>(Tile::tallgrass_Id, 1, 1);
case 4: return std::make_shared<ItemInstance>(Tile::snow_layer_Id, 1, 0);
case 5: return std::make_shared<ItemInstance>(Tile::sand_Id, 1, 0);
case 6: return std::make_shared<ItemInstance>(Item::redstone);
}
return nullptr;
}
int SuperflatData::GetPresetCount()
{
return s_presetCount;
}
const wchar_t *SuperflatData::GetPresetName(int index)
{
if (index < 0 || index >= s_presetCount)
return L"";
return s_presetNames[index];
}
FlatGeneratorInfo SuperflatData::MakePreset(int index)
{
FlatGeneratorInfo info;
info.clear();
switch (index)
{
case 0:
info.setBiome(1);
info.setStructure(FlatGeneratorInfo::STRUCTURE_VILLAGE, true);
info.addLayerOnTop(1, Tile::bedrock_Id);
info.addLayerOnTop(2, Tile::dirt_Id);
info.addLayerOnTop(1, Tile::grass_Id);
break;
case 1:
info.setBiome(3);
info.setStructure(FlatGeneratorInfo::STRUCTURE_DUNGEON, true);
info.setStructure(FlatGeneratorInfo::STRUCTURE_BIOME_DECORATION, true);
info.setStructure(FlatGeneratorInfo::STRUCTURE_STRONGHOLD, true);
info.setStructure(FlatGeneratorInfo::STRUCTURE_MINESHAFT, true);
info.addLayerOnTop(1, Tile::bedrock_Id);
info.addLayerOnTop(100, Tile::stone_Id);
info.addLayerOnTop(5, Tile::dirt_Id);
info.addLayerOnTop(1, Tile::grass_Id);
break;
case 2:
info.setBiome(24);
info.addLayerOnTop(1, Tile::bedrock_Id);
info.addLayerOnTop(5, Tile::stone_Id);
info.addLayerOnTop(5, Tile::dirt_Id);
info.addLayerOnTop(5, Tile::sand_Id);
info.addLayerOnTop(90, Tile::water_Id);
break;
case 3:
info.setBiome(1);
info.setStructure(FlatGeneratorInfo::STRUCTURE_VILLAGE, true);
info.setStructure(FlatGeneratorInfo::STRUCTURE_BIOME_DECORATION, true);
info.setStructure(FlatGeneratorInfo::STRUCTURE_STRONGHOLD, true);
info.setStructure(FlatGeneratorInfo::STRUCTURE_MINESHAFT, true);
info.setStructure(FlatGeneratorInfo::STRUCTURE_DUNGEON, true);
info.setStructure(FlatGeneratorInfo::STRUCTURE_LAKE, true);
info.setStructure(FlatGeneratorInfo::STRUCTURE_LAVA_LAKE, true);
info.addLayerOnTop(1, Tile::bedrock_Id);
info.addLayerOnTop(59, Tile::stone_Id);
info.addLayerOnTop(3, Tile::dirt_Id);
info.addLayerOnTop(1, Tile::grass_Id);
break;
case 4:
info.setBiome(12);
info.setStructure(FlatGeneratorInfo::STRUCTURE_VILLAGE, true);
info.setStructure(FlatGeneratorInfo::STRUCTURE_BIOME_SPECIFIC, true);
info.addLayerOnTop(1, Tile::bedrock_Id);
info.addLayerOnTop(59, Tile::stone_Id);
info.addLayerOnTop(3, Tile::dirt_Id);
info.addLayerOnTop(1, Tile::grass_Id);
info.addLayerOnTop(1, Tile::snow_layer_Id);
break;
case 5:
info.setBiome(2);
info.setStructure(FlatGeneratorInfo::STRUCTURE_VILLAGE, true);
info.setStructure(FlatGeneratorInfo::STRUCTURE_BIOME_SPECIFIC, true);
info.setStructure(FlatGeneratorInfo::STRUCTURE_BIOME_DECORATION, true);
info.setStructure(FlatGeneratorInfo::STRUCTURE_STRONGHOLD, true);
info.setStructure(FlatGeneratorInfo::STRUCTURE_MINESHAFT, true);
info.addLayerOnTop(1, Tile::bedrock_Id);
info.addLayerOnTop(3, Tile::stone_Id);
info.addLayerOnTop(52, Tile::sandstone_Id);
info.addLayerOnTop(8, Tile::sand_Id);
break;
case 6:
info.setBiome(2);
info.addLayerOnTop(1, Tile::bedrock_Id);
info.addLayerOnTop(3, Tile::stone_Id);
info.addLayerOnTop(52, Tile::sandstone_Id);
break;
default:
return FlatGeneratorInfo::getDefault();
}
return info;
}
int SuperflatData::GetBlockCount()
{
BuildBlocks();
return static_cast<int>(Blocks().size());
}
int SuperflatData::GetBlockId(int index)
{
BuildBlocks();
return Blocks()[index].id;
}
int SuperflatData::GetBlockData(int index)
{
BuildBlocks();
return Blocks()[index].data;
}
int SuperflatData::FindBlock(int id, int data)
{
BuildBlocks();
vector<BlockEntry> &blocks = Blocks();
for (size_t i = 0; i < blocks.size(); ++i)
{
if (blocks[i].id == id && blocks[i].data == data)
return static_cast<int>(i);
}
for (size_t i = 0; i < blocks.size(); ++i)
{
if (blocks[i].id == id)
return static_cast<int>(i);
}
return -1;
}
wstring SuperflatData::GetBlockName(int id, int data)
{
if (id == 0)
return L"Air";
if (id == Tile::water_Id || id == Tile::flowing_water_Id)
return L"Water";
if (id == Tile::lava_Id || id == Tile::flowing_lava_Id)
return L"Lava";
if (id < 0 || id >= 256 || Tile::tiles[id] == nullptr)
return L"Unknown";
shared_ptr<ItemInstance> item = std::make_shared<ItemInstance>(id, 1, data);
wstring name = item->getHoverName();
if (name.empty())
name = L"Block " + std::to_wstring(id);
return name;
}
wstring SuperflatData::GetLayerLabel(FlatLayerInfo &layer)
{
return std::to_wstring(layer.getHeight()) + L" x " + GetBlockName(layer.getId(), layer.getData());
}
vector<SuperflatData::CustomPreset> &SuperflatData::GetCustomPresets()
{
static vector<CustomPreset> s_presets;
return s_presets;
}
void SuperflatData::LoadCustomPresets()
{
vector<CustomPreset> &presets = GetCustomPresets();
presets.clear();
wchar_t path[MAX_PATH] = {};
GetCustomPresetsPath(path, MAX_PATH);
FILE *f = nullptr;
if (_wfopen_s(&f, path, L"r, ccs=UTF-8") != 0 || !f)
return;
wchar_t line[2048];
while (fgetws(line, 2048, f))
{
size_t len = wcslen(line);
while (len > 0 && (line[len - 1] == L'\n' || line[len - 1] == L'\r'))
line[--len] = L'\0';
wchar_t *tab = wcschr(line, L'\t');
if (!tab)
continue;
*tab = L'\0';
CustomPreset preset;
preset.name = line;
preset.value = tab + 1;
if (!preset.name.empty() && !preset.value.empty())
presets.push_back(preset);
}
fclose(f);
}
void SuperflatData::SaveCustomPresets()
{
wchar_t path[MAX_PATH] = {};
GetCustomPresetsPath(path, MAX_PATH);
FILE *f = nullptr;
if (_wfopen_s(&f, path, L"w, ccs=UTF-8") != 0 || !f)
return;
for (auto &preset : GetCustomPresets())
fwprintf(f, L"%ls\t%ls\n", preset.name.c_str(), preset.value.c_str());
fclose(f);
}
wstring SuperflatData::GetDefaultOptions()
{
return MakePreset(0).toString();
}
wstring SuperflatData::Describe(FlatGeneratorInfo &info)
{
wstring text = L"Biome: ";
text += GetBiomeName(GetBiomeIndex(info.getBiome()));
text += L"\nLayers:";
vector<FlatLayerInfo> &layers = *info.getLayers();
for (int i = static_cast<int>(layers.size()) - 1; i >= 0; --i)
text += L"\n- " + GetLayerLabel(layers[i]);
wstring features;
for (int i = 0; i < s_paramCount; ++i)
{
if (s_params[i].kind == eParam_Toggle && info.hasStructure(s_params[i].structure))
features += wstring(L"\n- ") + s_params[i].name;
}
if (!features.empty())
text += L"\nFeatures:" + features;
return text;
}