Skip to content

Commit

Permalink
Add render scale to the MediaHelper plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
philipbutkiewicz committed Mar 28, 2024
1 parent bd4b5db commit d9948ca
Show file tree
Hide file tree
Showing 4 changed files with 104 additions and 9 deletions.
16 changes: 16 additions & 0 deletions MediaHelper.plugin/PreviewBrowserForm.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 29 additions & 0 deletions MediaHelper.plugin/PreviewBrowserForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ private void LoadCurrentFile()

comboBoxFrameskip_SelectedIndexChanged(this, EventArgs.Empty);
comboBoxSpeed_SelectedIndexChanged(this, EventArgs.Empty);
comboBoxRenderScale_SelectedIndexChanged(this, EventArgs.Empty);


previewRenderer.LoadProject(project);
Expand Down Expand Up @@ -300,6 +301,7 @@ private void PreviewBrowserForm_Load(object sender, EventArgs e)
{
comboBoxSpeed.SelectedIndex = 2;
comboBoxFrameskip.SelectedIndex = 0;
comboBoxRenderScale.SelectedIndex = 2;

if (LoadFromList)
{
Expand Down Expand Up @@ -493,6 +495,33 @@ private void comboBoxSpeed_SelectedIndexChanged(object sender, EventArgs e)

}

/// <summary>
/// Updates the preview renderer render scale on combo box value change.
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void comboBoxRenderScale_SelectedIndexChanged(object sender, EventArgs e)
{
if (previewRenderer != null)
{
switch (comboBoxRenderScale.SelectedIndex)
{
case 0:
previewRenderer.RenderScale = 1f;
break;
case 1:
previewRenderer.RenderScale = 1.25f;
break;
case 2:
previewRenderer.RenderScale = 1.5f;
break;
case 3:
previewRenderer.RenderScale = 2f;
break;
}
}
}

/// <summary>
/// Goes to the previous index on button click.
/// </summary>
Expand Down
50 changes: 43 additions & 7 deletions MediaHelper.plugin/PreviewBrowserForm.resx
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@
<value>208, 8</value>
</data>
<data name="labelFile.Size" type="System.Drawing.Size, System.Drawing">
<value>437, 25</value>
<value>384, 25</value>
</data>
<assembly alias="mscorlib" name="mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="labelFile.TabIndex" type="System.Int32, mscorlib">
Expand All @@ -147,6 +147,42 @@
<data name="&gt;&gt;labelFile.ZOrder" xml:space="preserve">
<value>0</value>
</data>
<data name="comboBoxRenderScale.Dock" type="System.Windows.Forms.DockStyle, System.Windows.Forms">
<value>Right</value>
</data>
<data name="comboBoxRenderScale.Items" xml:space="preserve">
<value>1x</value>
</data>
<data name="comboBoxRenderScale.Items1" xml:space="preserve">
<value>1.25x</value>
</data>
<data name="comboBoxRenderScale.Items2" xml:space="preserve">
<value>1.5x</value>
</data>
<data name="comboBoxRenderScale.Items3" xml:space="preserve">
<value>2x</value>
</data>
<data name="comboBoxRenderScale.Location" type="System.Drawing.Point, System.Drawing">
<value>592, 8</value>
</data>
<data name="comboBoxRenderScale.Size" type="System.Drawing.Size, System.Drawing">
<value>53, 21</value>
</data>
<data name="comboBoxRenderScale.TabIndex" type="System.Int32, mscorlib">
<value>8</value>
</data>
<data name="&gt;&gt;comboBoxRenderScale.Name" xml:space="preserve">
<value>comboBoxRenderScale</value>
</data>
<data name="&gt;&gt;comboBoxRenderScale.Type" xml:space="preserve">
<value>System.Windows.Forms.ComboBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;comboBoxRenderScale.Parent" xml:space="preserve">
<value>panel1</value>
</data>
<data name="&gt;&gt;comboBoxRenderScale.ZOrder" xml:space="preserve">
<value>1</value>
</data>
<data name="buttonSave.Dock" type="System.Windows.Forms.DockStyle, System.Windows.Forms">
<value>Left</value>
</data>
Expand All @@ -172,7 +208,7 @@
<value>panel1</value>
</data>
<data name="&gt;&gt;buttonSave.ZOrder" xml:space="preserve">
<value>1</value>
<value>2</value>
</data>
<data name="comboBoxFrameskip.Dock" type="System.Windows.Forms.DockStyle, System.Windows.Forms">
<value>Right</value>
Expand Down Expand Up @@ -211,7 +247,7 @@
<value>panel1</value>
</data>
<data name="&gt;&gt;comboBoxFrameskip.ZOrder" xml:space="preserve">
<value>2</value>
<value>3</value>
</data>
<data name="comboBoxSpeed.Dock" type="System.Windows.Forms.DockStyle, System.Windows.Forms">
<value>Right</value>
Expand Down Expand Up @@ -247,7 +283,7 @@
<value>panel1</value>
</data>
<data name="&gt;&gt;comboBoxSpeed.ZOrder" xml:space="preserve">
<value>3</value>
<value>4</value>
</data>
<data name="buttonNext.Dock" type="System.Windows.Forms.DockStyle, System.Windows.Forms">
<value>Left</value>
Expand All @@ -271,7 +307,7 @@
<value>panel1</value>
</data>
<data name="&gt;&gt;buttonNext.ZOrder" xml:space="preserve">
<value>4</value>
<value>5</value>
</data>
<data name="buttonDelete.Dock" type="System.Windows.Forms.DockStyle, System.Windows.Forms">
<value>Left</value>
Expand Down Expand Up @@ -304,7 +340,7 @@
<value>panel1</value>
</data>
<data name="&gt;&gt;buttonDelete.ZOrder" xml:space="preserve">
<value>5</value>
<value>6</value>
</data>
<data name="buttonPrev.Dock" type="System.Windows.Forms.DockStyle, System.Windows.Forms">
<value>Left</value>
Expand All @@ -328,7 +364,7 @@
<value>panel1</value>
</data>
<data name="&gt;&gt;buttonPrev.ZOrder" xml:space="preserve">
<value>6</value>
<value>7</value>
</data>
<data name="panel1.Dock" type="System.Windows.Forms.DockStyle, System.Windows.Forms">
<value>Bottom</value>
Expand Down
18 changes: 16 additions & 2 deletions MediaHelper.plugin/PreviewRenderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,15 @@ public int FrameSkip
set { frameSkip = value; }
}

/// <summary>
/// Gets or sets render scale.
/// </summary>
public float RenderScale
{
get { return renderScale; }
set { renderScale = value; }
}

#endregion

#region Events
Expand Down Expand Up @@ -147,6 +156,11 @@ public class RenderTaskEndedEventArgs : EventArgs
/// </summary>
private int frameSkip = 0;

/// <summary>
/// Render scale.
/// </summary>
private float renderScale = 1f;

/// <summary>
/// Preview loading progress.
/// </summary>
Expand Down Expand Up @@ -337,8 +351,8 @@ private void LoadTextures()
GC.Collect();
}

Console.WriteLine($"Window size is {(int)(bitmapWidth * 1.5f)}, {(int)(bitmapHeight * 1.5f)}");
SDL.SDL_SetWindowSize(sdlWindow, (int)(bitmapWidth * 1.5f), (int)(bitmapHeight * 1.5f));
Console.WriteLine($"Window size is {(int)(bitmapWidth * renderScale)}, {(int)(bitmapHeight * renderScale)}");
SDL.SDL_SetWindowSize(sdlWindow, (int)(bitmapWidth * renderScale), (int)(bitmapHeight * renderScale));

finishedLoadingPreviewFrames = true;

Expand Down

0 comments on commit d9948ca

Please sign in to comment.