Skip to content

Commit

Permalink
Merge pull request #74 from lastbattle/staging
Browse files Browse the repository at this point in the history
Staging
  • Loading branch information
LastBattle authored Sep 30, 2020
2 parents 4a4d666 + db8c660 commit e6fc682
Show file tree
Hide file tree
Showing 18 changed files with 209 additions and 58 deletions.
2 changes: 2 additions & 0 deletions HaCreator/GUI/HaEditor.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,9 @@ private void HaEditor2_Loaded(object sender, RoutedEventArgs e)
commonPanel.Initialize(hcsm);

if (!hcsm.backupMan.AttemptRestore())
{
hcsm.LoadMap(new Load(multiBoard, tabControl1, hcsm.MakeRightClickHandler()));
}
}

/// <summary>
Expand Down
109 changes: 84 additions & 25 deletions HaCreator/MapEditor/Input/InputHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public InputHandler(MultiBoard parentBoard)
parentBoard.LeftMouseUp += new MultiBoard.LeftMouseUpDelegate(parentBoard_LeftMouseUp);
parentBoard.RightMouseClick += new MultiBoard.RightMouseClickDelegate(parentBoard_RightMouseClick);
parentBoard.MouseDoubleClick += new MultiBoard.MouseDoubleClickDelegate(parentBoard_MouseDoubleClick);
parentBoard.ShortcutKeyPressed += new MultiBoard.ShortcutKeyPressedDelegate(parentBoard_ShortcutKeyPressed);
parentBoard.ShortcutKeyPressed += new MultiBoard.ShortcutKeyPressedDelegate(ParentBoard_ShortcutKeyPressed);
parentBoard.MouseMoved += new MultiBoard.MouseMovedDelegate(parentBoard_MouseMoved);
}

Expand Down Expand Up @@ -176,7 +176,15 @@ private UndoRedoAction CreateItemUndoMoveAction(BoardItem item, XNA.Point posCha
return UndoRedoManager.ItemMoved(item, new XNA.Point(item.X + posChange.X, item.Y + posChange.Y), new XNA.Point(item.X, item.Y));
}

private void parentBoard_ShortcutKeyPressed(Board selectedBoard, bool ctrl, bool shift, bool alt, Keys key)
/// <summary>
/// Keyboard navigation on the MultiBoard
/// </summary>
/// <param name="selectedBoard"></param>
/// <param name="ctrl"></param>
/// <param name="shift"></param>
/// <param name="alt"></param>
/// <param name="key"></param>
private void ParentBoard_ShortcutKeyPressed(Board selectedBoard, bool ctrl, bool shift, bool alt, Keys key)
{
lock (parentBoard)
{
Expand All @@ -187,40 +195,91 @@ private void parentBoard_ShortcutKeyPressed(Board selectedBoard, bool ctrl, bool
if (key == Keys.ControlKey || key == Keys.ShiftKey || key == Keys.Menu /*ALT key*/)
return;
bool clearRedo = true;

const int navigationSHVScrollSpeed = 16;

switch (key)
{
case Keys.Left:
foreach (BoardItem item in selectedBoard.SelectedItems)
if (!item.BoundToSelectedItem(selectedBoard))
{
if (selectedBoard.SelectedItems.Count > 0)
{
foreach (BoardItem item in selectedBoard.SelectedItems)
if (!item.BoundToSelectedItem(selectedBoard))
{
item.X--;
actions.Add(CreateItemUndoMoveAction(item, new XNA.Point(1, 0)));
}
}
else // if no item is being selected, shift the view instead
{
item.X--;
actions.Add(CreateItemUndoMoveAction(item, new XNA.Point(1, 0)));
selectedBoard.ParentControl.AddHScrollbarValue(-navigationSHVScrollSpeed);
}
break;
break;
}
case Keys.Right:
foreach (BoardItem item in selectedBoard.SelectedItems)
if (!item.BoundToSelectedItem(selectedBoard))
{
if (selectedBoard.SelectedItems.Count > 0)
{
foreach (BoardItem item in selectedBoard.SelectedItems)
if (!item.BoundToSelectedItem(selectedBoard))
{
item.X++;
actions.Add(CreateItemUndoMoveAction(item, new XNA.Point(-1, 0)));
}
}
else // if no item is being selected, shift the view instead
{
item.X++;
actions.Add(CreateItemUndoMoveAction(item, new XNA.Point(-1, 0)));
selectedBoard.ParentControl.AddHScrollbarValue(navigationSHVScrollSpeed);
}
break;
break;
}
case Keys.Up:
foreach (BoardItem item in selectedBoard.SelectedItems)
if (!item.BoundToSelectedItem(selectedBoard))
{
if (selectedBoard.SelectedItems.Count > 0)
{
foreach (BoardItem item in selectedBoard.SelectedItems)
if (!item.BoundToSelectedItem(selectedBoard))
{
item.Y--;
actions.Add(CreateItemUndoMoveAction(item, new XNA.Point(0, 1)));
}
}
else // if no item is being selected, shift the view instead
{
item.Y--;
actions.Add(CreateItemUndoMoveAction(item, new XNA.Point(0, 1)));
selectedBoard.ParentControl.AddVScrollbarValue(-navigationSHVScrollSpeed);
}
break;
break;
}
case Keys.Down:
foreach (BoardItem item in selectedBoard.SelectedItems)
if (!item.BoundToSelectedItem(selectedBoard))
{
if (selectedBoard.SelectedItems.Count > 0)
{
item.Y++;
actions.Add(CreateItemUndoMoveAction(item, new XNA.Point(0, -1)));
foreach (BoardItem item in selectedBoard.SelectedItems)
if (!item.BoundToSelectedItem(selectedBoard))
{
item.Y++;
actions.Add(CreateItemUndoMoveAction(item, new XNA.Point(0, -1)));
}
}
break;
else // if no item is being selected, shift the view instead
{
selectedBoard.ParentControl.AddVScrollbarValue(navigationSHVScrollSpeed);
}
break;
}

case Keys.PageUp:
{
selectedBoard.ParentControl.AddVScrollbarValue(-999);
break;
}
case Keys.PageDown:
{
selectedBoard.ParentControl.AddVScrollbarValue(999);
break;
}

case Keys.Delete:
switch (selectedBoard.Mouse.State)
{
Expand Down Expand Up @@ -274,10 +333,10 @@ private void parentBoard_ShortcutKeyPressed(Board selectedBoard, bool ctrl, bool
{
foreach (BoardItem item in selectedBoard.SelectedItems)
{
if (item is IFlippable)
if (item is IFlippable flippable)
{
((IFlippable)item).Flip = !((IFlippable)item).Flip;
actions.Add(UndoRedoManager.ItemFlipped((IFlippable)item));
flippable.Flip = !flippable.Flip;
actions.Add(UndoRedoManager.ItemFlipped(flippable));
}
}
}
Expand Down
40 changes: 35 additions & 5 deletions HaCreator/MapEditor/MultiBoard.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -656,13 +656,10 @@ private void DxContainer_MouseDoubleClick(object sender, System.Windows.Forms.Mo
private void DxContainer_MouseWheel(object sender, System.Windows.Forms.MouseEventArgs e)
{
int rotationDelta = e.Delta;
//System.Diagnostics.Debug.Write("Rotation: " + rotationDelta);
//System.Diagnostics.Debug.Write("Rotation: " + rotationDelta);

// wheel up = positive, wheel down = negative
hScrollBar.Value += rotationDelta;

// Update display
hScrollBar_Scroll(null, null);
AddHScrollbarValue((int)rotationDelta);
}

/// <summary>
Expand Down Expand Up @@ -913,6 +910,23 @@ private void ResetDevice()
DxDevice.Reset(pParams);
}


/// <summary>
/// Adds the horizontal scroll bar value
/// </summary>
/// <param name="value"></param>
public void AddHScrollbarValue(int value)
{
SetHScrollbarValue((int) (hScrollBar.Value + value));

// Update display
hScrollBar_Scroll(null, null);
}

/// <summary>
/// Sets the horizontal scroll bar value
/// </summary>
/// <param name="value"></param>
public void SetHScrollbarValue(int value)
{
lock (this)
Expand All @@ -921,6 +935,22 @@ public void SetHScrollbarValue(int value)
}
}

/// <summary>
/// Adds the horizontal scroll bar value
/// </summary>
/// <param name="value"></param>
public void AddVScrollbarValue(int value)
{
SetVScrollbarValue((int)(vScrollBar.Value + value));

// Update display
vScrollBar_Scroll(null, null);
}

/// <summary>
/// Sets the vertical scroll bar value
/// </summary>
/// <param name="value"></param>
public void SetVScrollbarValue(int value)
{
lock (this)
Expand Down
16 changes: 15 additions & 1 deletion HaCreator/MapSimulator/MapSimulatorLoader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,21 @@ private static List<IDXObject> LoadFrames(TexturePool texturePool, WzImageProper
}
else
{
WzCanvasProperty frameProp = (WzCanvasProperty)_frameProp;
WzCanvasProperty frameProp;

if (_frameProp is WzUOLProperty) // some could be UOL. Ex: 321100000 Mirror world: [Mirror World] Leafre
{
WzObject linkVal = ((WzUOLProperty)_frameProp).LinkValue;
if (linkVal is WzCanvasProperty linkCanvas)
{
frameProp = linkCanvas;
}
else
continue;
} else
{
frameProp = (WzCanvasProperty)_frameProp;
}

int delay = (int)InfoTool.GetOptionalInt(frameProp["delay"], 100);

Expand Down
16 changes: 12 additions & 4 deletions HaRepacker/GUI/ListEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,20 @@ namespace HaRepacker.GUI
{
public partial class ListEditor : Form
{
WzMapleVersion version;
private readonly WzMapleVersion version;

public ListEditor(string path, WzMapleVersion version)
{
this.version = version;

InitializeComponent();

string text = "";
if (path != null)
{
List<string> listEntries = ListFileParser.ParseListFile(path, version);
foreach (string entry in listEntries) text += entry + "\n";
foreach (string entry in listEntries)
text += entry + "\n";
text = text.Substring(0, text.Length - 1);
}
textBox.Text = text.Replace("\n", "\r\n");
Expand All @@ -42,8 +45,13 @@ private void ListEditor_FormClosing(object sender, FormClosingEventArgs e)

private void btnSave_Click(object sender, EventArgs e)
{
SaveFileDialog dialog = new SaveFileDialog() { Title = "Select where to save the file", Filter = "List WZ File (*.wz)|*.wz" };
if (dialog.ShowDialog() != DialogResult.OK) return;
SaveFileDialog dialog = new SaveFileDialog()
{
Title = "Select where to save the file", Filter = "List WZ File (*.wz)|*.wz"
};
if (dialog.ShowDialog() != DialogResult.OK)
return;

List<string> listEntries = textBox.Text.Replace("\r\n", "\n").Split("\n".ToCharArray()).ToList<string>();
ListFileParser.SaveToDisk(dialog.FileName, version, listEntries);
}
Expand Down
24 changes: 22 additions & 2 deletions HaRepacker/GUI/Panels/MainPanel.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -124,11 +124,22 @@
</Setter.Value>
</Setter>
</Style>
<Storyboard x:Key="Storyboard_TreeviewItemSelectedAnimation">
<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleX)" Storyboard.TargetName="button_MoreOption">
<EasingDoubleKeyFrame KeyTime="0:0:0.2" Value="1.5"/>
<EasingDoubleKeyFrame KeyTime="0:0:0.4" Value="1"/>
</DoubleAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleY)" Storyboard.TargetName="button_MoreOption">
<EasingDoubleKeyFrame KeyTime="0:0:0.2" Value="1.5"/>
<EasingDoubleKeyFrame KeyTime="0:0:0.4" Value="1"/>
</DoubleAnimationUsingKeyFrames>
</Storyboard>
</UserControl.Resources>
<UserControl.Triggers>
<EventTrigger RoutedEvent="FrameworkElement.Loaded">
<BeginStoryboard Storyboard="{StaticResource Storyboard_Find_FadeIn}"/>
<BeginStoryboard Storyboard="{StaticResource Storyboard_Find_FadeOut}"/>
<BeginStoryboard Storyboard="{StaticResource Storyboard_TreeviewItemSelectedAnimation}"/>
</EventTrigger>
</UserControl.Triggers>

Expand Down Expand Up @@ -310,7 +321,7 @@
HorizontalAlignment="Stretch" VerticalAlignment="Stretch"
ResizeBehavior="PreviousAndNext" />


<Grid x:Name="grid" Grid.Column="2" Background="#FFF1F1F1">
<Grid.RowDefinitions>
<RowDefinition Height="40"/>
Expand Down Expand Up @@ -350,7 +361,16 @@
<Button x:Name="button_MoreOption" Content="..." Width="40" Height="50" FontSize="40" Style="{DynamicResource ButtonStyle_MoreOption}"
VerticalAlignment="Top" HorizontalAlignment="Right" Margin="10,10,20,10"
Grid.Row="0" Grid.RowSpan="2"
Click="button_MoreOption_Click">
Visibility="Collapsed"
Click="button_MoreOption_Click" RenderTransformOrigin="0.5,0.5">
<Button.RenderTransform>
<TransformGroup>
<ScaleTransform/>
<SkewTransform/>
<RotateTransform/>
<TranslateTransform/>
</TransformGroup>
</Button.RenderTransform>
<Button.ContextMenu>
<ContextMenu Name="cm" StaysOpen="true">
<MenuItem Header="Animate (F5)" x:Name="menuItem_Animate" Click="menuItem_Animate_Click"/>
Expand Down
15 changes: 15 additions & 0 deletions HaRepacker/GUI/Panels/MainPanel.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1172,12 +1172,16 @@ private void ShowObjectValue(WzObject obj)
bool bIsWzFloatProperty = obj is WzFloatProperty;
bool bIsWzShortProperty = obj is WzShortProperty;

bool bAnimateMoreButton = false; // The button to animate when there is more option under button_MoreOption

// Set layout visibility
if (obj is WzFile || obj is WzDirectory || obj is WzImage || obj is WzNullProperty || obj is WzSubProperty || obj is WzConvexProperty)
{
}
else if (obj is WzCanvasProperty)
{
bAnimateMoreButton = true; // flag

menuItem_changeImage.Visibility = Visibility.Visible;
menuItem_saveImage.Visibility = Visibility.Visible;

Expand All @@ -1196,6 +1200,8 @@ private void ShowObjectValue(WzObject obj)
}
else if (obj is WzUOLProperty)
{
bAnimateMoreButton = true; // flag

// Image
WzObject linkValue = ((WzUOLProperty)obj).LinkValue;
if (linkValue is WzCanvasProperty)
Expand Down Expand Up @@ -1223,6 +1229,8 @@ private void ShowObjectValue(WzObject obj)
}
else if (bIsWzSoundProperty)
{
bAnimateMoreButton = true; // flag

mp3Player.Visibility = Visibility.Visible;
mp3Player.SoundProperty = (WzBinaryProperty)obj;

Expand Down Expand Up @@ -1334,6 +1342,13 @@ private void ShowObjectValue(WzObject obj)
else
{
}

button_MoreOption.Visibility = bAnimateMoreButton ? Visibility.Visible : Visibility.Collapsed;
if (bAnimateMoreButton)
{
System.Windows.Media.Animation.Storyboard storyboard_moreAnimation = (System.Windows.Media.Animation.Storyboard)(this.FindResource("Storyboard_TreeviewItemSelectedAnimation"));
storyboard_moreAnimation.Begin();
}
}

/// <summary>
Expand Down
5 changes: 4 additions & 1 deletion HaSharedLirary/Render/BaseDXDrawableItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,11 @@ public virtual void Draw(SpriteBatch sprite, SkeletonMeshRenderer skeletonMeshRe
drawFrame.DrawObject(sprite, skeletonMeshRenderer, gameTime,
shiftCenteredX - _Position.X, shiftCenteredY - _Position.Y,
flip);

this._LastFrameDrawn = drawFrame; // set the last frame drawn
}
this._LastFrameDrawn = drawFrame; // set the last frame drawn
else
this._LastFrameDrawn = null;
}

/// <summary>
Expand Down
Loading

0 comments on commit e6fc682

Please sign in to comment.