diff --git a/TrueCraft.Client/Content/default-pack.png b/TrueCraft.Client/Content/default-pack.png new file mode 100644 index 0000000..cf893db Binary files /dev/null and b/TrueCraft.Client/Content/default-pack.png differ diff --git a/TrueCraft.Client/Content/default-pack.txt b/TrueCraft.Client/Content/default-pack.txt new file mode 100644 index 0000000..b90cfbc --- /dev/null +++ b/TrueCraft.Client/Content/default-pack.txt @@ -0,0 +1 @@ +No description available. \ No newline at end of file diff --git a/TrueCraft.Client/Rendering/Mesh.cs b/TrueCraft.Client/Rendering/Mesh.cs index 91a8109..43d8cd8 100644 --- a/TrueCraft.Client/Rendering/Mesh.cs +++ b/TrueCraft.Client/Rendering/Mesh.cs @@ -38,7 +38,7 @@ namespace TrueCraft.Client.Rendering lock (_syncLock) { _vertices = new VertexBuffer(_graphicsDevice, VertexPositionNormalTexture.VertexDeclaration, - value.Length, BufferUsage.WriteOnly); + (value.Length + 1), BufferUsage.WriteOnly); _vertices.SetData(value); } @@ -119,7 +119,7 @@ namespace TrueCraft.Client.Rendering _indices[index].Dispose(); _indices[index] = new IndexBuffer(_graphicsDevice, typeof(int), - indices.Length, BufferUsage.WriteOnly); + (indices.Length + 1), BufferUsage.WriteOnly); _indices[index].SetData(indices); } } diff --git a/TrueCraft.Client/TrueCraft.Client.csproj b/TrueCraft.Client/TrueCraft.Client.csproj index 63564df..0be89e5 100644 --- a/TrueCraft.Client/TrueCraft.Client.csproj +++ b/TrueCraft.Client/TrueCraft.Client.csproj @@ -162,6 +162,12 @@ + + PreserveNewest + + + PreserveNewest + PreserveNewest diff --git a/TrueCraft.Client/TrueCraftGame.cs b/TrueCraft.Client/TrueCraftGame.cs index c6fd897..b747325 100644 --- a/TrueCraft.Client/TrueCraftGame.cs +++ b/TrueCraft.Client/TrueCraftGame.cs @@ -51,9 +51,9 @@ namespace TrueCraft.Client Window.Title = "TrueCraft"; Content.RootDirectory = "Content"; Graphics = new GraphicsDeviceManager(this); - Graphics.IsFullScreen = false; - Graphics.PreferredBackBufferWidth = 1280; - Graphics.PreferredBackBufferHeight = 720; + Graphics.IsFullScreen = UserSettings.Local.IsFullscreen; + Graphics.PreferredBackBufferWidth = UserSettings.Local.WindowResolution.Width; + Graphics.PreferredBackBufferHeight = UserSettings.Local.WindowResolution.Height; Client = client; EndPoint = endPoint; NextPhysicsUpdate = DateTime.MinValue; diff --git a/TrueCraft.Core/TexturePack.cs b/TrueCraft.Core/TexturePack.cs index d5f4418..e9c735a 100644 --- a/TrueCraft.Core/TexturePack.cs +++ b/TrueCraft.Core/TexturePack.cs @@ -32,7 +32,7 @@ namespace TrueCraft.Core { get { - return System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), + return Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), ".truecraft/texturepacks/"); } } diff --git a/TrueCraft.Core/UserSettings.cs b/TrueCraft.Core/UserSettings.cs index 1d4a012..8ead5d9 100644 --- a/TrueCraft.Core/UserSettings.cs +++ b/TrueCraft.Core/UserSettings.cs @@ -23,6 +23,8 @@ namespace TrueCraft.Core public string LastIP { get; set; } public string SelectedTexturePack { get; set; } public FavoriteServer[] FavoriteServers { get; set; } + public bool IsFullscreen { get; set; } + public WindowResolution WindowResolution { get; set; } public UserSettings() { @@ -32,6 +34,12 @@ namespace TrueCraft.Core LastIP = ""; SelectedTexturePack = TexturePack.Default.Name; FavoriteServers = new FavoriteServer[0]; + IsFullscreen = false; + WindowResolution = new WindowResolution() + { + Width = 1280, + Height = 720 + }; } public void Load() @@ -52,4 +60,40 @@ namespace TrueCraft.Core public string Name { get; set; } public string Address { get; set; } } + + public class WindowResolution + { + public static readonly WindowResolution[] Defaults = + new WindowResolution[] + { + // (from Wikipedia/other) + WindowResolution.FromString("800 x 600"), // SVGA + WindowResolution.FromString("960 x 640"), // DVGA + WindowResolution.FromString("1024 x 600"), // WSVGA + WindowResolution.FromString("1024 x 768"), // XGA + WindowResolution.FromString("1280 x 1024"), // SXGA + WindowResolution.FromString("1600 x 1200"), // UXGA + WindowResolution.FromString("1920 x 1080"), // big + WindowResolution.FromString("1920 x 1200"), // really big + WindowResolution.FromString("4096 x 2160"), // huge + }; + + public static WindowResolution FromString(string str) + { + var tmp = str.Split('x'); + return new WindowResolution() + { + Width = int.Parse(tmp[0].Trim()), + Height = int.Parse(tmp[1].Trim()) + }; + } + + public int Width { get; set; } + public int Height { get; set; } + + public override string ToString() + { + return string.Format("{0} x {1}", Width, Height); + } + } } \ No newline at end of file diff --git a/TrueCraft.Launcher/Views/OptionView.cs b/TrueCraft.Launcher/Views/OptionView.cs index 52d04ba..92d13b0 100644 --- a/TrueCraft.Launcher/Views/OptionView.cs +++ b/TrueCraft.Launcher/Views/OptionView.cs @@ -13,6 +13,9 @@ namespace TrueCraft.Launcher.Views public LauncherWindow Window { get; set; } public Label OptionLabel { get; set; } + public Label ResolutionLabel { get; set; } + public ComboBox ResolutionComboBox { get; set; } + public CheckBox FullscreenCheckBox { get; set; } public Label TexturePackLabel { get; set; } public DataField TexturePackImageField { get; set; } public DataField TexturePackTextField { get; set; } @@ -37,6 +40,36 @@ namespace TrueCraft.Launcher.Views Font = Font.WithSize(16), TextAlignment = Alignment.Center }; + + ResolutionLabel = new Label("Select a resolution..."); + ResolutionComboBox = new ComboBox(); + + int resolutionIndex = -1; + for (int i = 0; i < WindowResolution.Defaults.Length; i++) + { + ResolutionComboBox.Items.Add(WindowResolution.Defaults[i].ToString()); + + if (resolutionIndex == -1) + { + resolutionIndex = + ((WindowResolution.Defaults[i].Width == UserSettings.Local.WindowResolution.Width) && + (WindowResolution.Defaults[i].Height == UserSettings.Local.WindowResolution.Height)) ? i : -1; + } + } + + if (resolutionIndex == -1) + { + ResolutionComboBox.Items.Add(UserSettings.Local.WindowResolution.ToString()); + resolutionIndex = ResolutionComboBox.Items.Count - 1; + } + + ResolutionComboBox.SelectedIndex = resolutionIndex; + FullscreenCheckBox = new CheckBox() + { + Label = "Fullscreen mode", + State = (UserSettings.Local.IsFullscreen) ? CheckBoxState.On : CheckBoxState.Off + }; + TexturePackLabel = new Label("Select a texture pack..."); TexturePackImageField = new DataField(); TexturePackTextField = new DataField(); @@ -54,6 +87,19 @@ namespace TrueCraft.Launcher.Views TexturePackListView.Columns.Add("Image", TexturePackImageField); TexturePackListView.Columns.Add("Text", TexturePackTextField); + ResolutionComboBox.SelectionChanged += (sender, e) => + { + UserSettings.Local.WindowResolution = + WindowResolution.FromString(ResolutionComboBox.SelectedText); + UserSettings.Local.Save(); + }; + + FullscreenCheckBox.Clicked += (sender, e) => + { + UserSettings.Local.IsFullscreen = !UserSettings.Local.IsFullscreen; + UserSettings.Local.Save(); + }; + TexturePackListView.SelectionChanged += (sender, e) => { var texturePack = _texturePacks[TexturePackListView.SelectedRow]; @@ -79,6 +125,9 @@ namespace TrueCraft.Launcher.Views LoadTexturePacks(); this.PackStart(OptionLabel); + this.PackStart(ResolutionLabel); + this.PackStart(ResolutionComboBox); + this.PackStart(FullscreenCheckBox); this.PackStart(TexturePackLabel); this.PackStart(TexturePackListView); this.PackStart(OpenFolderButton);