Merge pull request #131 from mrpimpunicorn/resolution-options
Added support for changing preferred resolution in options
This commit is contained in:
commit
f5f0958bf1
BIN
TrueCraft.Client/Content/default-pack.png
Normal file
BIN
TrueCraft.Client/Content/default-pack.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.7 KiB |
1
TrueCraft.Client/Content/default-pack.txt
Normal file
1
TrueCraft.Client/Content/default-pack.txt
Normal file
@ -0,0 +1 @@
|
|||||||
|
No description available.
|
@ -38,7 +38,7 @@ namespace TrueCraft.Client.Rendering
|
|||||||
lock (_syncLock)
|
lock (_syncLock)
|
||||||
{
|
{
|
||||||
_vertices = new VertexBuffer(_graphicsDevice, VertexPositionNormalTexture.VertexDeclaration,
|
_vertices = new VertexBuffer(_graphicsDevice, VertexPositionNormalTexture.VertexDeclaration,
|
||||||
value.Length, BufferUsage.WriteOnly);
|
(value.Length + 1), BufferUsage.WriteOnly);
|
||||||
_vertices.SetData(value);
|
_vertices.SetData(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -119,7 +119,7 @@ namespace TrueCraft.Client.Rendering
|
|||||||
_indices[index].Dispose();
|
_indices[index].Dispose();
|
||||||
|
|
||||||
_indices[index] = new IndexBuffer(_graphicsDevice, typeof(int),
|
_indices[index] = new IndexBuffer(_graphicsDevice, typeof(int),
|
||||||
indices.Length, BufferUsage.WriteOnly);
|
(indices.Length + 1), BufferUsage.WriteOnly);
|
||||||
_indices[index].SetData(indices);
|
_indices[index].SetData(indices);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -162,6 +162,12 @@
|
|||||||
<ItemGroup />
|
<ItemGroup />
|
||||||
<ItemGroup />
|
<ItemGroup />
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<Content Include="Content\default-pack.png">
|
||||||
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
|
</Content>
|
||||||
|
<Content Include="Content\default-pack.txt">
|
||||||
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
|
</Content>
|
||||||
<Content Include="Content\items.png">
|
<Content Include="Content\items.png">
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
</Content>
|
</Content>
|
||||||
|
@ -51,9 +51,9 @@ namespace TrueCraft.Client
|
|||||||
Window.Title = "TrueCraft";
|
Window.Title = "TrueCraft";
|
||||||
Content.RootDirectory = "Content";
|
Content.RootDirectory = "Content";
|
||||||
Graphics = new GraphicsDeviceManager(this);
|
Graphics = new GraphicsDeviceManager(this);
|
||||||
Graphics.IsFullScreen = false;
|
Graphics.IsFullScreen = UserSettings.Local.IsFullscreen;
|
||||||
Graphics.PreferredBackBufferWidth = 1280;
|
Graphics.PreferredBackBufferWidth = UserSettings.Local.WindowResolution.Width;
|
||||||
Graphics.PreferredBackBufferHeight = 720;
|
Graphics.PreferredBackBufferHeight = UserSettings.Local.WindowResolution.Height;
|
||||||
Client = client;
|
Client = client;
|
||||||
EndPoint = endPoint;
|
EndPoint = endPoint;
|
||||||
NextPhysicsUpdate = DateTime.MinValue;
|
NextPhysicsUpdate = DateTime.MinValue;
|
||||||
|
@ -32,7 +32,7 @@ namespace TrueCraft.Core
|
|||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
return System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile),
|
return Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile),
|
||||||
".truecraft/texturepacks/");
|
".truecraft/texturepacks/");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -23,6 +23,8 @@ namespace TrueCraft.Core
|
|||||||
public string LastIP { get; set; }
|
public string LastIP { get; set; }
|
||||||
public string SelectedTexturePack { get; set; }
|
public string SelectedTexturePack { get; set; }
|
||||||
public FavoriteServer[] FavoriteServers { get; set; }
|
public FavoriteServer[] FavoriteServers { get; set; }
|
||||||
|
public bool IsFullscreen { get; set; }
|
||||||
|
public WindowResolution WindowResolution { get; set; }
|
||||||
|
|
||||||
public UserSettings()
|
public UserSettings()
|
||||||
{
|
{
|
||||||
@ -32,6 +34,12 @@ namespace TrueCraft.Core
|
|||||||
LastIP = "";
|
LastIP = "";
|
||||||
SelectedTexturePack = TexturePack.Default.Name;
|
SelectedTexturePack = TexturePack.Default.Name;
|
||||||
FavoriteServers = new FavoriteServer[0];
|
FavoriteServers = new FavoriteServer[0];
|
||||||
|
IsFullscreen = false;
|
||||||
|
WindowResolution = new WindowResolution()
|
||||||
|
{
|
||||||
|
Width = 1280,
|
||||||
|
Height = 720
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Load()
|
public void Load()
|
||||||
@ -52,4 +60,40 @@ namespace TrueCraft.Core
|
|||||||
public string Name { get; set; }
|
public string Name { get; set; }
|
||||||
public string Address { 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
@ -13,6 +13,9 @@ namespace TrueCraft.Launcher.Views
|
|||||||
public LauncherWindow Window { get; set; }
|
public LauncherWindow Window { get; set; }
|
||||||
|
|
||||||
public Label OptionLabel { 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 Label TexturePackLabel { get; set; }
|
||||||
public DataField<Image> TexturePackImageField { get; set; }
|
public DataField<Image> TexturePackImageField { get; set; }
|
||||||
public DataField<string> TexturePackTextField { get; set; }
|
public DataField<string> TexturePackTextField { get; set; }
|
||||||
@ -37,6 +40,36 @@ namespace TrueCraft.Launcher.Views
|
|||||||
Font = Font.WithSize(16),
|
Font = Font.WithSize(16),
|
||||||
TextAlignment = Alignment.Center
|
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...");
|
TexturePackLabel = new Label("Select a texture pack...");
|
||||||
TexturePackImageField = new DataField<Image>();
|
TexturePackImageField = new DataField<Image>();
|
||||||
TexturePackTextField = new DataField<string>();
|
TexturePackTextField = new DataField<string>();
|
||||||
@ -54,6 +87,19 @@ namespace TrueCraft.Launcher.Views
|
|||||||
TexturePackListView.Columns.Add("Image", TexturePackImageField);
|
TexturePackListView.Columns.Add("Image", TexturePackImageField);
|
||||||
TexturePackListView.Columns.Add("Text", TexturePackTextField);
|
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) =>
|
TexturePackListView.SelectionChanged += (sender, e) =>
|
||||||
{
|
{
|
||||||
var texturePack = _texturePacks[TexturePackListView.SelectedRow];
|
var texturePack = _texturePacks[TexturePackListView.SelectedRow];
|
||||||
@ -79,6 +125,9 @@ namespace TrueCraft.Launcher.Views
|
|||||||
LoadTexturePacks();
|
LoadTexturePacks();
|
||||||
|
|
||||||
this.PackStart(OptionLabel);
|
this.PackStart(OptionLabel);
|
||||||
|
this.PackStart(ResolutionLabel);
|
||||||
|
this.PackStart(ResolutionComboBox);
|
||||||
|
this.PackStart(FullscreenCheckBox);
|
||||||
this.PackStart(TexturePackLabel);
|
this.PackStart(TexturePackLabel);
|
||||||
this.PackStart(TexturePackListView);
|
this.PackStart(TexturePackListView);
|
||||||
this.PackStart(OpenFolderButton);
|
this.PackStart(OpenFolderButton);
|
||||||
|
Reference in New Issue
Block a user