feat: allow newlines in template
This commit is contained in:
parent
6a24a29ceb
commit
25d156c20f
|
@ -99,7 +99,7 @@ internal class Command : IDisposable {
|
|||
private FileStream OpenFile(string ext, ScreenshotMetadata meta) {
|
||||
Directory.CreateDirectory(this.Plugin.Config.SaveDirectory);
|
||||
|
||||
var fileName = this.Plugin.Config.SaveFileNameTemplate.Render(meta);
|
||||
var fileName = this.Plugin.Config.SaveFileNameTemplate.Render(meta).ReplaceLineEndings(" ");
|
||||
|
||||
var path = Path.Join(this.Plugin.Config.SaveDirectory, fileName);
|
||||
path += $".{ext}";
|
||||
|
|
|
@ -12,7 +12,15 @@ public class Configuration : IPluginConfiguration {
|
|||
public string SaveDirectory = Path.Join(Environment.GetFolderPath(Environment.SpecialFolder.MyPictures), "Screenie");
|
||||
public Format SaveFormat = Format.Png;
|
||||
public int SaveFormatData = 90;
|
||||
public string SaveFileNameFormat = "{{ captured_at_local | date.to_string '%Y/%m/[%H.%M.%S]' }} {{ active_character.name }} - {{ location }}{{ if area }} ({{ area }}){{ end }}";
|
||||
public string SaveFileNameFormat = """
|
||||
{{ captured_at_local | date.to_string '%Y/%m/[%H.%M.%S]' }}
|
||||
{{ active_character.name }}
|
||||
-
|
||||
{{ location }}
|
||||
{{- if area }}
|
||||
({{ area }})
|
||||
{{- end -}}
|
||||
""";
|
||||
|
||||
private int _templateHashCode;
|
||||
private Template? _template;
|
||||
|
|
|
@ -55,7 +55,7 @@ internal class PluginUi : IDisposable {
|
|||
|
||||
using var end = new OnDispose(ImGui.End);
|
||||
|
||||
ImGui.SetNextWindowSize(new Vector2(350, 500), ImGuiCond.FirstUseEver);
|
||||
ImGui.SetNextWindowSize(new Vector2(420, 500), ImGuiCond.FirstUseEver);
|
||||
if (!ImGui.Begin(Plugin.Name, ref this.Visible)) {
|
||||
return;
|
||||
}
|
||||
|
@ -94,7 +94,7 @@ internal class PluginUi : IDisposable {
|
|||
|
||||
ImGui.TextUnformatted("Filename format");
|
||||
ImGui.SetNextItemWidth(-1);
|
||||
anyChanged |= ImGui.InputText("##filename-format", ref this.Plugin.Config.SaveFileNameFormat, 1024);
|
||||
anyChanged |= ImGui.InputTextMultiline("##filename-format", ref this.Plugin.Config.SaveFileNameFormat, 1024, new Vector2(-1, 150));
|
||||
|
||||
var template = this.Plugin.Config.SaveFileNameTemplate;
|
||||
if (template.HasErrors) {
|
||||
|
@ -106,12 +106,16 @@ internal class PluginUi : IDisposable {
|
|||
}
|
||||
} else {
|
||||
try {
|
||||
ImGui.TextUnformatted(this.Plugin.Config.SaveFileNameTemplate.Render(this.Metadata));
|
||||
ImGui.TextUnformatted(this.Plugin.Config.SaveFileNameTemplate.Render(this.Metadata).ReplaceLineEndings(" "));
|
||||
} catch (Exception ex) {
|
||||
ImGui.TextUnformatted($"Failed to evaluate: {ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
ImGui.ProgressBar(
|
||||
(float) (TimeSpan.FromSeconds(5) - this._metaUpdate.Elapsed).TotalSeconds / 5,
|
||||
new Vector2(-1, 1)
|
||||
);
|
||||
|
||||
if (anyChanged) {
|
||||
this.Plugin.SaveConfig();
|
||||
|
|
Loading…
Reference in New Issue