Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Custom World Generation Options For New Worlds. #1935

Merged
merged 7 commits into from
Aug 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions src/TEdit.Terraria/Tile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,22 @@ public object Clone()
return MemberwiseClone();
}

// Added legacy enums back
public enum WallType : int
{
Sky = 0,
StoneWall = 1,
DirtWall = 2
}

public enum TileType : int
{
DirtBlock = 0,
StoneBlock = 1,
GrassBlock = 2,
AshBlock = 57
}

public void Reset()
{
Actuator = false;
Expand Down
142 changes: 123 additions & 19 deletions src/TEdit.Terraria/World.Properties.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,23 +88,23 @@ private void UpdateMaxLayerLevels()
{
if (!SafeGroundLayers)
{
// Defualt: Use unsafe levels.
// Defualt: Use unsafe levels.
MaxCavernLevel = Calc.Clamp(TilesHigh, 0, TilesHigh);
MaxGroundLevel = Calc.Clamp(TilesHigh - 6, 0, TilesHigh);
}
else
{
MaxCavernLevel = Calc.Clamp(TilesHigh - WorldConfiguration.CavernLevelToBottomOfWorld, 6, TilesHigh);
MaxGroundLevel = Calc.Clamp(MaxCavernLevel - 6, 0, TilesHigh);
// Adjust the sliders to reflect new values if over the max.
if (GroundLevel > MaxGroundLevel)
GroundLevel = MaxGroundLevel;
if (RockLevel > MaxCavernLevel)
RockLevel = MaxCavernLevel;
// Adjust the sliders to reflect new values if over the max.
if (GroundLevel > MaxGroundLevel)
GroundLevel = MaxGroundLevel;
if (RockLevel > MaxCavernLevel)
RockLevel = MaxCavernLevel;
}
}
public uint WorldVersion => Version;
public Random Rand;
public int[] TreeBG = new int[3];
Expand All @@ -118,7 +118,7 @@ private void UpdateMaxLayerLevels()
private double _groundLevel;
private double _rockLevel;
private int _shadowOrbCount;
private bool _safeGroundLayers;
private bool _safeGroundLayers;
private int _tilesHigh;
private int _treeX0;
private int _treeX1;
Expand Down Expand Up @@ -288,8 +288,8 @@ public double RockLevel
}
}
}
[Category("Levels")]
[Category("Levels")]
public bool SafeGroundLayers
{
get => _safeGroundLayers;
Expand Down Expand Up @@ -723,19 +723,123 @@ public bool DownedFlyingDutchman

#endregion Invasions

#region Custom World Generation

private double _hillSize;
private bool _generateGrass;
private bool _generateWalls;
private bool _generateCaves;
private ObservableCollection<string> _cavePresets;
private int _cavePresetIndex;
private bool _surfaceCaves;
private double _caveNoise;
private double _caveMultiplier;
private double _caveDensity;
private bool _generateUnderworld;
private bool _generateAsh;
private bool _generateLava;
private double _underworldRoofNoise;
private double _underworldFloorNoise;
private double _underworldLavaNoise;
private bool _generateOres;

public double HillSize
{
get => _hillSize;
set => this.RaiseAndSetIfChanged(ref _hillSize, value);
}
public bool GenerateGrass
{
get => _generateGrass;
set => this.RaiseAndSetIfChanged(ref _generateGrass, value);
}
public bool GenerateWalls
{
get => _generateWalls;
set => this.RaiseAndSetIfChanged(ref _generateWalls, value);
}
public bool GenerateCaves
{
get => _generateCaves;
set => this.RaiseAndSetIfChanged(ref _generateCaves, value);
}
public int CavePresetIndex
{
get => _cavePresetIndex;
set => this.RaiseAndSetIfChanged(ref _cavePresetIndex, value);
}
public ObservableCollection<string> CavePresets
{
get => _cavePresets;
set => this.RaiseAndSetIfChanged(ref _cavePresets, value);
}
public bool SurfaceCaves
{
get => _surfaceCaves;
set => this.RaiseAndSetIfChanged(ref _surfaceCaves, value);
}
public double CaveNoise
{
get => _caveNoise;
set => this.RaiseAndSetIfChanged(ref _caveNoise, value);
}
public double CaveMultiplier
{
get => _caveMultiplier;
set => this.RaiseAndSetIfChanged(ref _caveMultiplier, value);
}
public double CaveDensity
{
get => _caveDensity;
set => this.RaiseAndSetIfChanged(ref _caveDensity, value);
}
public bool GenerateUnderworld
{
get => _generateUnderworld;
set => this.RaiseAndSetIfChanged(ref _generateUnderworld, value);
}
public bool GenerateAsh
{
get => _generateAsh;
set => this.RaiseAndSetIfChanged(ref _generateAsh, value);
}
public bool GenerateLava
{
get => _generateLava;
set => this.RaiseAndSetIfChanged(ref _generateLava, value);
}
public double UnderworldRoofNoise
{
get => _underworldRoofNoise;
set => this.RaiseAndSetIfChanged(ref _underworldRoofNoise, value);
}
public double UnderworldFloorNoise
{
get => _underworldFloorNoise;
set => this.RaiseAndSetIfChanged(ref _underworldFloorNoise, value);
}
public double UnderworldLavaNoise
{
get => _underworldLavaNoise;
set => this.RaiseAndSetIfChanged(ref _underworldLavaNoise, value);
}
public bool GenerateOres
{
get => _generateOres;
set => this.RaiseAndSetIfChanged(ref _generateOres, value);
}
#endregion

[Reactive] public bool PartyManual { get; set; }
[Reactive] public bool PartyGenuine { get; set; }
[Reactive] public int PartyCooldown { get; set; }


public int TileEntitiesNumber => TileEntities.Count;


[Reactive][ReadOnly(true)] public byte[] UnknownData { get; set; }

[Reactive] public Int64 CreationTime { get; set; }


[Reactive] public int IceBackStyle { get; set; }
[Reactive] public int JungleBackStyle { get; set; }
[Reactive] public int HellBackStyle { get; set; }
Expand Down Expand Up @@ -795,17 +899,17 @@ public byte Bg8
[Reactive] public byte BgTree4 { get; set; }
[Reactive] public byte UnderworldBg { get; set; }
[Reactive] public byte MushroomBg { get; set; }
[Reactive] public int TilesWide { get; set; }
[Reactive] public int TilesHighReactive { get; set; }
[Reactive] public int TilesHighReactive { get; set; }
public int TilesHigh
{
get => _tilesHigh;
set
{
// Update the reactive property to ensure UI and other bindings are notified.
TilesHighReactive = value;
// Update the reactive property to ensure UI and other bindings are notified.
TilesHighReactive = value;
_tilesHigh = value;
this.RaiseAndSetIfChanged(ref _tilesHigh, value);
UpdateMaxLayerLevels();
Expand Down
44 changes: 23 additions & 21 deletions src/TEdit/Editor/Plugins/ImageToPixelartEditorView.xaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<Window x:Class="TEdit.Editor.Plugins.ImageToPixelartEditorView"
<Window x:Name="MainWindow"
x:Class="TEdit.Editor.Plugins.ImageToPixelartEditorView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:view="clr-namespace:TEdit.View"
Expand All @@ -11,7 +12,7 @@
Height="764">

<!-- Main Container -->
<Grid Background="{StaticResource ControlBackgroundBrush}">
<Grid x:Name="MainGrid" Background="{StaticResource ControlBackgroundBrush}">
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
Expand All @@ -22,22 +23,22 @@
</Grid.ColumnDefinitions>

<!-- Image and Tiled Background Container -->
<Grid Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="2">
<Grid x:Name="ImageBackgroundGrid" Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="2">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>

<!-- First Tiled Background Image -->
<Border Margin="12,10,6,10" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
<Border x:Name="InputImageBorder" Margin="12,10,6,10" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
<Border.Background>
<ImageBrush x:Name="TiledBackground1" TileMode="Tile" Viewport="0,0,59,59" ViewportUnits="Absolute" ImageSource="/TEdit;component/Images/Pixelart/etp.jpg" />
</Border.Background>
<Image x:Name="BackgroundImage1" RenderOptions.BitmapScalingMode="NearestNeighbor" Stretch="Uniform" Source="/TEdit;component/Images/Pixelart/globeTest.png" AllowDrop="True" Drop="BackgroundImage1_Drop" DragEnter="BackgroundImage1_DragEnter" />
</Border>

<!-- Second Tiled Background Image -->
<Border Margin="6,10,12,10" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Grid.Column="1">
<Border x:Name="OutputImageBorder" Margin="6,10,12,10" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Grid.Column="1">
<Border.Background>
<ImageBrush x:Name="TiledBackground2" TileMode="Tile" Viewport="0,0,59,59" ViewportUnits="Absolute" ImageSource="/TEdit;component/Images/Pixelart/etp.jpg" />
</Border.Background>
Expand All @@ -46,11 +47,11 @@
</Grid>

<!-- Basic Configurations GroupBox -->
<GroupBox Margin="10" HorizontalAlignment="Left" VerticalAlignment="Bottom" BorderBrush="White" Height="156" Grid.Row="1" Grid.Column="0">
<GroupBox x:Name="BasicConfigurationGroupBox" Margin="10" HorizontalAlignment="Left" VerticalAlignment="Bottom" BorderBrush="White" Height="156" Grid.Row="1" Grid.Column="0">
<GroupBox.Header>
<TextBlock Text="Basic Configurations:" Foreground="White"/>
</GroupBox.Header>
<Canvas Height="136" Width="466">
<Canvas x:Name="BasicConfigurationCanvas" Height="136" Width="466">
<!-- Basic Configuration Controls -->
<Label x:Name="Spacing" Height="19" Width="44" FontSize="11" FontFamily="Microsoft Sans Serif" TabIndex="1" HorizontalAlignment="Center" VerticalAlignment="Top" Content="Spacing" Canvas.Top="12" />
<TextBox x:Name="NUDTextBox1" Text="4" TextAlignment="Left" TextChanged="NUDTextBox1_TextChanged" Height="26" Width="143" Canvas.Top="29" HorizontalAlignment="Center" VerticalAlignment="Top" PreviewMouseWheel="NUDTextBox1_PreviewMouseWheel" TabIndex="2"/>
Expand All @@ -74,11 +75,11 @@
</GroupBox>

<!-- Schematic Rotation GroupBox -->
<GroupBox Margin="493,0,0,60" HorizontalAlignment="Left" VerticalAlignment="Bottom" BorderBrush="White" Height="106" Grid.Row="1" Grid.Column="0" >
<GroupBox x:Name="SchematicRotationGroupBox" Margin="493,0,0,60" HorizontalAlignment="Left" VerticalAlignment="Bottom" BorderBrush="White" Height="106" Grid.Row="1" Grid.Column="0" >
<GroupBox.Header>
<TextBlock Text="Schematic Rotation:" Foreground="White"/>
</GroupBox.Header>
<Canvas Height="92" Width="178" >
<Canvas x:Name="SchematicRotationCanvas" Height="92" Width="178" >

<!-- Schematic Rotation Controls -->
<RadioButton x:Name="Rotation0" Height="14" Width="87" HorizontalAlignment="Left" VerticalAlignment="Center" Canvas.Left="1" Canvas.Top="4" Content="No Rotation" IsChecked="False" TabIndex="17" />
Expand All @@ -101,11 +102,11 @@
</GroupBox>

<!-- Color Filter Tools GroupBox -->
<GroupBox Margin="493,0,0,10" HorizontalAlignment="Left" VerticalAlignment="Bottom" BorderBrush="White" Height="50" Grid.Row="1" Grid.Column="0" >
<GroupBox x:Name="ColorFilterToolsGroupBox" Margin="493,0,0,10" HorizontalAlignment="Left" VerticalAlignment="Bottom" BorderBrush="White" Height="50" Grid.Row="1" Grid.Column="0" >
<GroupBox.Header>
<TextBlock Text="Color Filter Tools:" Foreground="White"/>
</GroupBox.Header>
<Canvas Height="25" Width="178" >
<Canvas x:Name="ColorFilterToolsCanvas" Height="25" Width="178" >

<!-- Color Filter Tools Controls -->
<!-- Color Filter Tools Controls -->
Expand All @@ -115,11 +116,11 @@
</GroupBox>

<!-- Grid Options GroupBox -->
<GroupBox Margin="688,0,0,10" HorizontalAlignment="Left" VerticalAlignment="Bottom" BorderBrush="White" Height="156" Grid.Row="1" Grid.Column="0" >
<GroupBox x:Name="GridOptionsGroupBox" Margin="688,0,0,10" HorizontalAlignment="Left" VerticalAlignment="Bottom" BorderBrush="White" Height="156" Grid.Row="1" Grid.Column="0" >
<GroupBox.Header>
<TextBlock Text="Grid Options:" Foreground="White"/>
</GroupBox.Header>
<Canvas Height="128" Width="150" >
<Canvas x:Name="GridOptionsCanvas" Height="128" Width="150" >

<!-- Grid Options Controls -->
<CheckBox x:Name="ShowGrid" Height="14" Width="79" TabIndex="25" HorizontalAlignment="Left" VerticalAlignment="Center" Content="Show Grid" Canvas.Left="-1" ToolTip="Place a grid over the rendered pixel art." />
Expand All @@ -138,11 +139,12 @@
</Canvas>
</GroupBox>

<GroupBox Margin="855,0,0,10" HorizontalAlignment="Left" VerticalAlignment="Bottom" BorderBrush="White" Height="156" Width="127" Grid.Row="1" Grid.Column="0" >
<!-- Scaling Mode GroupBox -->
<GroupBox x:Name="ScalingModeGroupBox" Margin="855,0,0,10" HorizontalAlignment="Left" VerticalAlignment="Bottom" BorderBrush="White" Height="156" Width="127" Grid.Row="1" Grid.Column="0" >
<GroupBox.Header>
<TextBlock Text="Scaling Mode:" Foreground="White"/>
</GroupBox.Header>
<Canvas Height="133" Margin="0,0,-2,0" >
<Canvas x:Name="ScalingModeCanvas" Height="133" Margin="0,0,-2,0" >

<!-- Scaling Mode Controls -->
<RadioButton x:Name="Bilinear" Height="19" Width="64" TabIndex="30" HorizontalAlignment="Left" VerticalAlignment="Top" Canvas.Left="-1" Content="Bilinear" Canvas.Top="0" IsChecked="False" />
Expand All @@ -159,11 +161,11 @@
</GroupBox>

<!-- Color Filter Settings GroupBox -->
<GroupBox Margin="987,0,0,66" HorizontalAlignment="Left" VerticalAlignment="Bottom" Canvas.Left="318" BorderBrush="White" Canvas.Top="-8" Height="100" Width="127" Grid.Row="1" Grid.Column="0">
<GroupBox x:Name="ColorFilterSettingsGroupBox" Margin="987,0,0,66" HorizontalAlignment="Left" VerticalAlignment="Bottom" Canvas.Left="318" BorderBrush="White" Canvas.Top="-8" Height="100" Width="127" Grid.Row="1" Grid.Column="0">
<GroupBox.Header>
<TextBlock Text="Color Filter Settings:" Foreground="White"/>
</GroupBox.Header>
<Canvas Height="74" Margin="0,0,-2,0">
<Canvas x:Name="ColorFilterSettingsCanvas" Height="74" Margin="0,0,-2,0">

<!-- Color Filter Settings Controls -->
<CheckBox x:Name="UseTiles" Height="14" Width="76" TabIndex="39" HorizontalAlignment="Left" VerticalAlignment="Top" IsChecked="False" Content="Use Tiles" Checked="CheckBox_Changed" Unchecked="CheckBox_Changed" />
Expand All @@ -174,11 +176,11 @@
</GroupBox>

<!-- Color Filter Data Controls -->
<GroupBox Margin="987,0,0,10" HorizontalAlignment="Left" VerticalAlignment="Bottom" Canvas.Left="318" BorderBrush="White" Canvas.Top="-8" Height="56" Width="127" Grid.Row="1" Grid.Column="0">
<GroupBox x:Name="ColorFilterDataGroupBox" Margin="987,0,0,10" HorizontalAlignment="Left" VerticalAlignment="Bottom" Canvas.Left="318" BorderBrush="White" Canvas.Top="-8" Height="56" Width="127" Grid.Row="1" Grid.Column="0">
<GroupBox.Header>
<TextBlock Text="Color Filter Data:" Foreground="White"/>
</GroupBox.Header>
<Canvas Height="33" Margin="0,0,-2,0">
<Canvas x:Name="ColorFilterDataCanvas" Height="33" Margin="0,0,-2,0">

<!-- Color Filter Data Controls -->
<Label x:Name="TotalColors" Height="16" Width="79" FontSize="11" FontFamily="Microsoft Sans Serif" TabIndex="43" HorizontalAlignment="Left" VerticalAlignment="Center" Content="Total Colors -----" Canvas.Left="1" Canvas.Top="3" />
Expand All @@ -189,11 +191,11 @@
</GroupBox>

<!-- Pixel Art Statistics GroupBox -->
<GroupBox Margin="1119,0,0,0" HorizontalAlignment="Left" VerticalAlignment="Center" BorderBrush="White" Height="156" Width="327" Grid.Row="1" Grid.Column="0">
<GroupBox x:Name="PixelArtStatisticsGroupBox" Margin="1119,0,0,0" HorizontalAlignment="Left" VerticalAlignment="Center" BorderBrush="White" Height="156" Width="327" Grid.Row="1" Grid.Column="0">
<GroupBox.Header>
<TextBlock Text="Pixel Art Statistics:" Foreground="White"/>
</GroupBox.Header>
<Canvas Height="135" Margin="0,0,3,0">
<Canvas x:Name="PixelArtStatisticsCanvas" Height="135" Margin="0,0,3,0">

<!-- Pixelart Statistics Controls -->
<Label x:Name="TotalHeight" Height="19" Width="79" FontSize="11" FontFamily="Microsoft Sans Serif" TabIndex="47" HorizontalAlignment="Center" VerticalAlignment="Top" Content="Total Height ------" Canvas.Left="6" Canvas.Top="6" />
Expand Down
Loading
Loading