Skip to content

Commit

Permalink
Another Set of Daily Updates.
Browse files Browse the repository at this point in the history
  • Loading branch information
CarJem committed Sep 13, 2020
1 parent e49f78b commit 91e6c9f
Show file tree
Hide file tree
Showing 6 changed files with 137 additions and 24 deletions.
3 changes: 1 addition & 2 deletions ManiacED-Core/Controls/Graphics/DevicePanel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,7 @@ public void Init(IDrawArea parent)
_device.SetSamplerState(0, SamplerState.MagFilter, TextureFilter.None);
_device.SetSamplerState(0, SamplerState.MipFilter, TextureFilter.None);
_device.SetRenderState(RenderState.CullMode, false);
//_device.SetRenderState(RenderState.ZWriteEnable, false);
//_device.SetRenderState(RenderState.ZEnable, false);
_device.SetRenderState(RenderState.ZEnable, ZBufferType.DontUseZBuffer);

if (OnCreateDevice != null)
{
Expand Down
16 changes: 13 additions & 3 deletions ManiacEditor/Controls/Editor/EditorSharpPanel.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,19 @@
<RowDefinition></RowDefinition>
<RowDefinition Height="17"></RowDefinition>
</Grid.RowDefinitions>
<ScrollBar x:Name="vScrollBar1" Width="15" ScrollViewer.IsDeferredScrollingEnabled="True" Orientation="Vertical" Margin="0,0,0,0" Grid.Row="0" Grid.Column="1"></ScrollBar>
<ScrollBar x:Name="hScrollBar1" Height="15" ScrollViewer.IsDeferredScrollingEnabled="True" Orientation="Horizontal" Margin="0,0,0,0" Grid.Row="1" Grid.Column="0"></ScrollBar>
<Grid Background="{DynamicResource ScrollBarBackground}" Grid.Column="1" Grid.Row="1"></Grid>
<ScrollBar x:Name="vScrollBar1" Width="15" ScrollViewer.IsDeferredScrollingEnabled="True" Orientation="Vertical" Margin="0,0,0,0" Grid.Row="0" Grid.Column="1">
<ScrollBar.CommandBindings>
<CommandBinding Command="{x:Static ScrollBar.LineDownCommand}" Executed="ScrollBarButtonsLeftOverEvent" CanExecute="CanExecuteCommand_Scrollbars" />
<CommandBinding Command="{x:Static ScrollBar.LineUpCommand}" Executed="ScrollBarButtonsLeftOverEvent" CanExecute="CanExecuteCommand_Scrollbars" />
</ScrollBar.CommandBindings>
</ScrollBar>
<ScrollBar x:Name="hScrollBar1" Height="15" ScrollViewer.IsDeferredScrollingEnabled="True" Orientation="Horizontal" Margin="0,0,0,0" Grid.Row="1" Grid.Column="0">
<ScrollBar.CommandBindings>
<CommandBinding Command="{x:Static ScrollBar.LineLeftCommand}" Executed="ScrollBarButtonsLeftOverEvent" CanExecute="CanExecuteCommand_Scrollbars" />
<CommandBinding Command="{x:Static ScrollBar.LineRightCommand}" Executed="ScrollBarButtonsLeftOverEvent" CanExecute="CanExecuteCommand_Scrollbars" />
</ScrollBar.CommandBindings>
</ScrollBar>
<Grid Background="{DynamicResource ScrollBarBackground}" Grid.Column="1" Grid.Row="1"></Grid>
<WindowsFormsHost x:Name="Host" Background="Transparent" DpiChanged="Host_DpiChanged" SizeChanged="SharpPanel_SizeChanged" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" Grid.Column="0" Grid.Row="0"></WindowsFormsHost>
</Grid>
<Grid.ContextMenu>
Expand Down
97 changes: 78 additions & 19 deletions ManiacEditor/Controls/Editor/EditorSharpPanel.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ public partial class SharpPanel : UserControl, IDrawArea
private ManiacEditor.Controls.Editor.MainEditor Instance;
public ManiacEditor.DevicePanel GraphicPanel;
private System.Windows.Forms.Panel HostPanel;
private bool HasTrackEventsInit = false;

#region DPI Definitions
public double DPIScale { get; set; }
Expand Down Expand Up @@ -98,21 +99,7 @@ private void SetupScrollBarEvents()
hScrollBar1.ValueChanged += this.HScrollBar1_ValueChanged;
hScrollBar1.MouseEnter += this.HScrollBar1_Entered;
}
public void SetupScrollBars(bool refreshing = false)
{
if ((hScrollBar1 != null || vScrollBar1 != null) && refreshing)
{
vScrollBar1.Scroll -= this.VScrollBar1_Scroll;
vScrollBar1.ValueChanged -= this.VScrollBar1_ValueChanged;
vScrollBar1.MouseEnter -= this.VScrollBar1_Entered;
hScrollBar1.Scroll -= this.HScrollBar1_Scroll;
hScrollBar1.ValueChanged -= this.HScrollBar1_ValueChanged;
hScrollBar1.MouseEnter -= this.HScrollBar1_Entered;
}
hScrollBar1 = new System.Windows.Controls.Primitives.ScrollBar();
vScrollBar1 = new System.Windows.Controls.Primitives.ScrollBar();
if (refreshing) SetupScrollBarEvents();
}

private void SetupOtherEvents()
{
SystemEvents.PowerModeChanged += CheckDeviceState;
Expand Down Expand Up @@ -286,8 +273,8 @@ public void UpdateZoomLevel(int zoom_level, System.Drawing.Point zoom_point)
case 5: Methods.Solution.SolutionState.Main.Zoom = 4; break;
case 4: Methods.Solution.SolutionState.Main.Zoom = 3; break;
case 3: Methods.Solution.SolutionState.Main.Zoom = 2; break;
case 2: Methods.Solution.SolutionState.Main.Zoom = 3 / 2.0; break;
case 1: Methods.Solution.SolutionState.Main.Zoom = 5 / 4.0; break;
case 2: Methods.Solution.SolutionState.Main.Zoom = 1.6; break;
case 1: Methods.Solution.SolutionState.Main.Zoom = 1.24; break;
case 0: Methods.Solution.SolutionState.Main.Zoom = 1; break;
case -1: Methods.Solution.SolutionState.Main.Zoom = 2 / 3.0; break;
case -2: Methods.Solution.SolutionState.Main.Zoom = 1 / 2.0; break;
Expand Down Expand Up @@ -448,6 +435,76 @@ public void UpdateGraphicsPanelControls()
#region ScrollBars

#region ScrollBar Events

bool HasEventX1 = false;
bool HasEventY1 = false;
bool HasEventX2 = false;
bool HasEventY2 = false;

private void CanExecuteCommand_Scrollbars(object sender, CanExecuteRoutedEventArgs e)
{
e.CanExecute = true;
}

private void vScrollBar1_IncreaseRepeatButton_Click(object sender, RoutedEventArgs e)
{
int y = Methods.Solution.SolutionState.Main.ViewPositionY - (int)(16 * GetZoom());
if (vScrollBar1.Minimum <= y)
{
Methods.Solution.SolutionState.Main.SetViewPositionY(y, true);
}
}

private void vScrollBar1_DecreaseRepeatButton_Click(object sender, RoutedEventArgs e)
{
int y = Methods.Solution.SolutionState.Main.ViewPositionY + (int)(16 * GetZoom());
if (vScrollBar1.Maximum >= y)
{
Methods.Solution.SolutionState.Main.SetViewPositionY(y, true);
}
}

private void hScrollBar1_IncreaseRepeatButton_Click(object sender, RoutedEventArgs e)
{
int x = Methods.Solution.SolutionState.Main.ViewPositionX + (int)(16 * GetZoom());
if (hScrollBar1.Maximum >= x)
{
Methods.Solution.SolutionState.Main.SetViewPositionX(x, true);
}
}

private void hScrollBar1_DecreaseRepeatButton_Click(object sender, RoutedEventArgs e)
{
int x = Methods.Solution.SolutionState.Main.ViewPositionX - (int)(16 * GetZoom());
if (hScrollBar1.Minimum <= x)
{
Methods.Solution.SolutionState.Main.SetViewPositionX(x, true);
}
}
private void ScrollBarButtonsLeftOverEvent(object sender, ExecutedRoutedEventArgs e)
{
if (e.OriginalSource.GetType() == typeof(System.Windows.Controls.Primitives.RepeatButton))
{
string name = (e.OriginalSource as RepeatButton).Name;
if (name == "PART_LineDownButton")
{
vScrollBar1_DecreaseRepeatButton_Click(sender, null);
}
else if (name == "PART_LineUpButton")
{
vScrollBar1_IncreaseRepeatButton_Click(sender, null);
}
else if (name == "PART_LineLeftButton")
{
hScrollBar1_DecreaseRepeatButton_Click(sender, null);
}
else if (name == "PART_LineRightButton")
{
hScrollBar1_IncreaseRepeatButton_Click(sender, null);
}

}
}
public void VScrollBar1_Scroll(object sender, System.Windows.Controls.Primitives.ScrollEventArgs e)
{

Expand All @@ -456,12 +513,14 @@ public void HScrollBar1_Scroll(object sender, System.Windows.Controls.Primitives
{

}
public void VScrollBar1_ValueChanged(object sender, RoutedEventArgs e)
public void VScrollBar1_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e)
{

ScrollBar_ValueChanged(sender as System.Windows.Controls.Primitives.ScrollBar);
}
public void HScrollBar1_ValueChanged(object sender, RoutedEventArgs e)
public void HScrollBar1_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e)
{

ScrollBar_ValueChanged(sender as System.Windows.Controls.Primitives.ScrollBar);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using RSDKv5;
using RSDKv5;
using SystemColors = System.Drawing.Color;
using System.Linq;

Expand Down
41 changes: 41 additions & 0 deletions ManiacEditor/Entity Renders/Normal Renders/Bounded/ConveyorBelt.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
using RSDKv5;
using SystemColors = System.Drawing.Color;
using System.Linq;

namespace ManiacEditor.Entity_Renders
{
public class ConveyorBelt : EntityRenderer
{

public override void Draw(Structures.EntityRenderProp Properties)
{
DevicePanel d = Properties.Graphics;
Classes.Scene.EditorEntity e = Properties.EditorObject;
int x = Properties.DrawX;
int y = Properties.DrawY;
int Transparency = Properties.Transparency;

//var Animation = Methods.Drawing.ObjectDrawing.LoadAnimation(Properties.Graphics, "Editor/EditorIcons.bin");
//DrawTexturePivotNormal(d, Animation, 0, 5, x, y, Transparency);

var widthPixels = (int)(e.attributesMap["size"].ValueVector2.X.High);
var heightPixels = (int)(e.attributesMap["size"].ValueVector2.Y.High);
var width = (int)widthPixels / 16;
var height = (int)heightPixels / 16;

DrawBounds(d, x, y, widthPixels, heightPixels, Transparency, SystemColors.White, SystemColors.Transparent);
}

public override bool isObjectOnScreen(DevicePanel d, Classes.Scene.EditorEntity entity, int x, int y, int Transparency)
{
var widthPixels = (int)(entity.attributesMap["size"].ValueVector2.X.High);
var heightPixels = (int)(entity.attributesMap["size"].ValueVector2.Y.High);
return d.IsObjectOnScreen(x - widthPixels / 2, y - heightPixels / 2, widthPixels, heightPixels);
}

public override string GetObjectName()
{
return "ConveyorBelt";
}
}
}
3 changes: 3 additions & 0 deletions ManiacEditor/ManiacEditor.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,9 @@
<Compile Include="Actions\IAction.cs" />
<Compile Include="Entity Renders\Normal Renders\Bosses\ScrewMobile.cs" />
<Compile Include="Entity Renders\Normal Renders\Bosses\ShiverSaw.cs" />
<Compile Include="Entity Renders\Normal Renders\Bounded\ConveyorBelt.cs">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Compile>
<Compile Include="Entity Renders\Normal Renders\Generic\OutroIntroObject.cs" />
<Compile Include="Entity Renders\Normal Renders\Gimmicks\SDashWheel.cs" />
<Compile Include="Entity Renders\Normal Renders\Motion\TeeterTotter.cs" />
Expand Down

0 comments on commit 91e6c9f

Please sign in to comment.