Lower texture size (in a configurable way) in template tool

This commit is contained in:
Rampastring 2020-09-12 02:39:11 +03:00
parent e6575eee3a
commit b1c2627a2f
5 changed files with 51 additions and 4 deletions

View File

@ -29,6 +29,12 @@
<setting name="GameDirectoryPath" serializeAs="String">
<value />
</setting>
<setting name="MaxMapTileTextureSize" serializeAs="String">
<value>0</value>
</setting>
<setting name="TemplateToolTextureSizeMultiplier" serializeAs="String">
<value>0.5</value>
</setting>
</MobiusEditor.Properties.Settings>
</userSettings>
<runtime>

View File

@ -26,7 +26,7 @@
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>TRACE;DEBUG;STEAMWORKS_WIN;STEAMWORKS_X64;DEVELOPER</DefineConstants>
<DefineConstants>TRACE;DEBUG;STEAMWORKS_WIN;STEAMWORKS_X64</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<LangVersion>7.3</LangVersion>
@ -37,7 +37,7 @@
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE;STEAMWORKS_WIN;STEAMWORKS_X64;DEVELOPER</DefineConstants>
<DefineConstants>TRACE;STEAMWORKS_WIN;STEAMWORKS_X64</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<LangVersion>7.3</LangVersion>

View File

@ -67,5 +67,29 @@ namespace MobiusEditor.Properties {
this["GameDirectoryPath"] = value;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("0")]
public int MaxMapTileTextureSize {
get {
return ((int)(this["MaxMapTileTextureSize"]));
}
set {
this["MaxMapTileTextureSize"] = value;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("0.5")]
public double TemplateToolTextureSizeMultiplier {
get {
return ((double)(this["TemplateToolTextureSizeMultiplier"]));
}
set {
this["TemplateToolTextureSizeMultiplier"] = value;
}
}
}
}

View File

@ -14,5 +14,11 @@
<Setting Name="GameDirectoryPath" Type="System.String" Scope="User">
<Value Profile="(Default)" />
</Setting>
<Setting Name="MaxMapTileTextureSize" Type="System.Int32" Scope="User">
<Value Profile="(Default)">0</Value>
</Setting>
<Setting Name="TemplateToolTextureSizeMultiplier" Type="System.Double" Scope="User">
<Value Profile="(Default)">0.5</Value>
</Setting>
</Settings>
</SettingsFile>

View File

@ -30,6 +30,9 @@ namespace MobiusEditor.Tools
{
public class TemplateTool : ViewTool
{
private const int DesignResWidth = 3840;
private const int DesignTextureWidth = 256;
private static readonly Regex CategoryRegex = new Regex(@"^([a-z]*)", RegexOptions.Compiled);
private readonly ListView templateTypeListView;
@ -153,8 +156,16 @@ namespace MobiusEditor.Tools
.GroupBy(t => templateCategory(t)).OrderBy(g => g.Key);
var templateTypeImages = templateTypes.SelectMany(g => g).Select(t => t.Thumbnail);
var maxWidth = templateTypeImages.Max(t => t.Width);
var maxHeight = templateTypeImages.Max(t => t.Height);
Screen screen = Screen.FromHandle(mapPanel.Handle) ?? Screen.PrimaryScreen;
int maxSize = Properties.Settings.Default.MaxMapTileTextureSize;
if (maxSize == 0)
{
double ratio = DesignResWidth / (double)screen.Bounds.Width;
maxSize = (int)((DesignTextureWidth / ratio) * Properties.Settings.Default.TemplateToolTextureSizeMultiplier);
}
var maxWidth = Math.Min(templateTypeImages.Max(t => t.Width), maxSize);
var maxHeight = Math.Min(templateTypeImages.Max(t => t.Height), maxSize);
var imageList = new ImageList();
imageList.Images.AddRange(templateTypeImages.ToArray());