Skip to content

Commit

Permalink
Beta V1.2.1
Browse files Browse the repository at this point in the history
  • Loading branch information
WallcroftUK committed May 21, 2023
1 parent de42d97 commit f91ea21
Show file tree
Hide file tree
Showing 15 changed files with 836 additions and 213 deletions.
61 changes: 43 additions & 18 deletions LuaToolGUI/AddMonstersWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,21 @@
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Add Monsters to Map" Height="350" Width="525">
<Grid>

<Window.Resources>
<Style TargetType="Button">
<Setter Property="Background" Value="#0078D7" />
<Setter Property="Foreground" Value="White" />
<Setter Property="Padding" Value="10" />
<Setter Property="Margin" Value="5" />
<Setter Property="FontSize" Value="16" />
<Setter Property="MinWidth" Value="100" />
<Setter Property="Height" Value="30" />
<Setter Property="HorizontalAlignment" Value="Left" />
</Style>
</Window.Resources>

<Grid Margin="10" Background="#F1F1F1">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
Expand All @@ -11,26 +25,37 @@
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<TextBlock Grid.Row="0" Grid.Column="0" Margin="5" Text="Map:" VerticalAlignment="Center" />
<ComboBox Grid.Row="0" Grid.Column="1" Margin="5" x:Name="mapComboBox" />
<TextBlock Grid.Row="1" Grid.Column="0" Margin="5" Text="Monster Vnum:" VerticalAlignment="Center" />
<TextBox Grid.Row="1" Grid.Column="1" Margin="5" x:Name="mobVnumTextBox" />
<TextBlock Grid.Row="2" Grid.Column="0" Margin="5" Text="Position X:" VerticalAlignment="Center" />
<TextBox Grid.Row="2" Grid.Column="1" Margin="5" x:Name="positionXTextBox" />
<TextBlock Grid.Row="3" Grid.Column="0" Margin="5" Text="Position Y:" VerticalAlignment="Center" />
<TextBox Grid.Row="3" Grid.Column="1" Margin="5" x:Name="positionYTextBox" />
<TextBlock Grid.Row="4" Grid.Column="0" Margin="5" Text="Facing:" VerticalAlignment="Center" />
<TextBox Grid.Row="4" Grid.Column="1" Margin="5" x:Name="facingTextBox" />
<TextBlock Grid.Row="5" Grid.Column="0" Margin="5" Text="Level:" VerticalAlignment="Center" />
<TextBox Grid.Row="5" Grid.Column="1" Margin="5" x:Name="mobLevelTextBox" />
<Button Grid.Row="6" Margin="343,0,10,0" Content="Add" Click="AddMonsterButton_Click" Grid.Column="1" Height="20" VerticalAlignment="Center" />
<Button Grid.Row="6" Grid.Column="0" Margin="5" Content="Close" Click="CloseButton_Click" />
<Button Grid.Row="6" Grid.Column="1" Margin="140,5,213,5" Content="Save/Close" Click="SaveCloseButton_Click" />
<TextBox x:Name="scriptTextBox" TextWrapping="Wrap" AcceptsReturn="True" VerticalScrollBarVisibility="Auto" Grid.ColumnSpan="2" Margin="5,39,5,-122" Grid.Row="6" />
<TextBlock Grid.Row="0" Grid.Column="0" Margin="0" Text="Map:" VerticalAlignment="Center" />
<ComboBox Grid.Row="0" Grid.Column="1" x:Name="mapComboBox" />
<TextBlock Grid.Row="1" Grid.Column="0" Margin="0" Text="Monster Vnum:" VerticalAlignment="Center" />
<TextBox Grid.Row="1" Grid.Column="1" x:Name="mobVnumTextBox" />
<TextBlock Grid.Row="2" Grid.Column="0" Margin="0" Text="Position X:" VerticalAlignment="Center" />
<TextBox Grid.Row="2" Grid.Column="1" x:Name="positionXTextBox" />
<TextBlock Grid.Row="3" Grid.Column="0" Margin="0" Text="Position Y:" VerticalAlignment="Center" />
<TextBox Grid.Row="3" Grid.Column="1" x:Name="positionYTextBox" />
<TextBlock Grid.Row="4" Grid.Column="0" Margin="0" Text="Facing:" VerticalAlignment="Center" />
<TextBox Grid.Row="4" Grid.Column="1" x:Name="facingTextBox" />
<TextBlock Grid.Row="5" Grid.Column="0" Margin="0" Text="Level:" VerticalAlignment="Center" />
<TextBox Grid.Row="5" Grid.Column="1" x:Name="mobLevelTextBox" />
<TextBlock Grid.Row="7" Grid.Column="0" Margin="0,2,424,0" Text="Kill Count:" VerticalAlignment="Top" Grid.ColumnSpan="2" />
<TextBox Grid.Row="6" x:Name="killCountTextBox" Height="20" Text="only if killcount is selected" VerticalAlignment="Top" Margin="0,20,0,0" Grid.Column="1" Grid.RowSpan="2" />
<TextBlock Grid.Row="6" Grid.Column="0" Margin="0" Text="Special Type:" VerticalAlignment="Center" />
<ComboBox Grid.Row="6" Grid.Column="1" x:Name="specialTypeComboBox">
<ComboBoxItem Content="None" />
<ComboBoxItem Content="Target" />
<ComboBoxItem Content="KillCount" />
</ComboBox>
<StackPanel Grid.Row="7" Orientation="Horizontal" HorizontalAlignment="Right" Grid.Column="1" Height="90" VerticalAlignment="Bottom" Margin="0,0,88,-12">
<Button Content="Add" Click="AddMonsterButton_Click" Height="43" Width="88" />
<Button Content="Close" Click="CloseButton_Click" Height="43" />
<Button Content="Save/Close" Click="SaveCloseButton_Click" Margin="10,0,0,0" Height="43" />
</StackPanel>
<TextBox x:Name="scriptTextBox" TextWrapping="Wrap" AcceptsReturn="True" VerticalScrollBarVisibility="Auto" Grid.ColumnSpan="2" Grid.Row="7" Height="74" VerticalAlignment="Bottom" Margin="-1,0,0,59" />
</Grid>
</Window>
</Window>
18 changes: 17 additions & 1 deletion LuaToolGUI/AddMonstersWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
/// </summary>
using System.Collections.ObjectModel;
using System.Windows;
using System.Windows.Controls;

namespace LuaToolGUI
{
Expand Down Expand Up @@ -30,7 +31,22 @@ private void AddMonsterButton_Click(object sender, RoutedEventArgs e)
int facing = int.Parse(facingTextBox.Text);
int level = int.Parse(mobLevelTextBox.Text);

string newMonster = "Monster.CreateWithVnum(" + monsterName + ").At(" + x + ", " + y + ").Facing(" + facing + ").WithCustomLevel(" + level + "),";
string specialType = ((ComboBoxItem)specialTypeComboBox.SelectedItem).Content.ToString();
string newMonster;

if (specialType == "Target")
{
newMonster = "Monster.CreateWithVnum(" + monsterName + ").At(" + x + ", " + y + ").Facing(" + facing + ").AsTarget(),";
}
else if (specialType == "KillCount")
{
int killCount = int.Parse(killCountTextBox.Text);
newMonster = "Monster.CreateWithVnum(" + monsterName + ").At(" + x + ", " + y + ").Facing(" + facing + ").SpawnAfterMobsKilled(" + killCount + "),";
}
else
{
newMonster = "Monster.CreateWithVnum(" + monsterName + ").At(" + x + ", " + y + ").Facing(" + facing + ").WithCustomLevel(" + level + "),";
}

// Check if the map already has monsters in the script
int mapIndex = scriptTextBox.Text.IndexOf(mapName);
Expand Down
44 changes: 44 additions & 0 deletions LuaToolGUI/EventWindow.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<Window x:Class="LuaToolGUI.EventWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Event Window" Height="400" Width="600">
<Grid Margin="20" Background="#F1F1F1">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>

<Label Content="Event Name:" Grid.Row="0" FontSize="16" />
<ComboBox x:Name="EventNameComboBox" Grid.Row="0" Margin="0,5"
SelectionChanged="EventNameComboBox_SelectionChanged"
FontSize="14" />

<StackPanel Grid.Row="1" Margin="0,10" Visibility="{Binding ElementName=EventNameComboBox,
Path=SelectedItem.Tag,
Converter={x:Null}}">
<Label Content="Map Name:" FontSize="16" />
<ComboBox x:Name="MapNameComboBox" Height="31" VerticalAlignment="Top"
FontSize="14" />
</StackPanel>

<StackPanel Grid.Row="2" Margin="0,10" Visibility="{Binding ElementName=EventNameComboBox,
Path=SelectedItem.Tag,
Converter={x:Null}}">
<Label Content="Portal Name:" FontSize="16" />
<ComboBox x:Name="PortalNameComboBox" Height="31" VerticalAlignment="Top"
FontSize="14" />
</StackPanel>

<Label Content="Map Task Type:" Grid.Row="3" Margin="0,5,0,15" FontSize="16" />
<ComboBox x:Name="MapTaskTypeComboBox" Grid.Row="3" VerticalAlignment="Top"
FontSize="14" Margin="0,36,0,0" Grid.RowSpan="2" />

<Button x:Name="AddEventButton" Content="Add Event" Grid.Row="4" Margin="0,20,0,0"
Click="AddEventButton_Click" HorizontalAlignment="Center"
Width="120" Height="40" FontSize="16" Background="#007ACC" Foreground="White" />
</Grid>
</Window>
120 changes: 120 additions & 0 deletions LuaToolGUI/EventWindow.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;

namespace LuaToolGUI
{
public partial class EventWindow : Window
{
private Dictionary<string, Tuple<string, string>> portalConnections;
private TextBox luaCodeTextBox;
private ObservableCollection<string> mapNames;

public EventWindow(Dictionary<string, Tuple<string, string>> portalConnections, TextBox luaCodeTextBox, ObservableCollection<string> mapNames)
{
InitializeComponent();

this.portalConnections = portalConnections;
this.luaCodeTextBox = luaCodeTextBox;
this.mapNames = mapNames;

// Populate the EventNameComboBox
EventNameComboBox.ItemsSource = Enum.GetValues(typeof(EventName));
MapTaskTypeComboBox.ItemsSource = Enum.GetValues(typeof(MapTasks));
}

private void AddEventButton_Click(object sender, RoutedEventArgs e)
{
StringBuilder luaCode = new StringBuilder();
luaCode.AppendLine("");

// Get the map coordinates and map ID from the input fields
string mapName = MapNameComboBox.SelectedItem?.ToString();
EventName eventName = (EventName)EventNameComboBox.SelectedItem;
MapTasks mapTaskType = (MapTasks)MapTaskTypeComboBox.SelectedItem;

if (string.IsNullOrEmpty(mapName))
{
// Handle error: No map name selected
return;
}

// Append additional Lua code
luaCode.AppendLine($"--- Map {mapName}");

luaCode.AppendLine($"{mapName}.{mapTaskType}({{");

if (eventName == EventName.OpenPortal)
{
// Handle Event.OpenPortal scenario
foreach (var portalConnection in portalConnections)
{
string fromPortal = portalConnection.Key;
luaCode.AppendLine($"Event.OpenPortal({fromPortal})");
}
}
else if (eventName == EventName.TryStartTaskForMap)
{
// Handle Event.TryStartTaskForMap scenario
luaCode.AppendLine($"Event.TryStartTaskForMap({mapName}),");
}
else if (eventName == EventName.DespawnAllMobsInRoom & mapTaskType == MapTasks.OnAllTargetMobsDead)
{
// Handle Event.DespawnAllMobsInRoom scenario
luaCode.AppendLine($"Event.DespawnAllMobsInRoom({mapName}),");
}
else
{
// Handle other event scenarios
luaCode.AppendLine($"Event.{eventName}({mapName}),");
}
luaCode.AppendLine($"}})");

luaCode.AppendLine("---");

// Update the Lua code in the luaCodeTextBox
luaCodeTextBox.Text += luaCode.ToString();

// Close the EventWindow
this.Close();
}

private void EventNameComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
if (EventNameComboBox.SelectedItem == null)
return;

EventName selectedEvent = (EventName)EventNameComboBox.SelectedItem;

if (selectedEvent == EventName.OpenPortal)
{
MapNameComboBox.Visibility = Visibility.Collapsed;
PortalNameComboBox.Visibility = Visibility.Visible;

// Populate the portal names
PortalNameComboBox.ItemsSource = portalConnections.Keys.ToList();
}
else if (selectedEvent == EventName.TryStartTaskForMap)
{
MapNameComboBox.Visibility = Visibility.Visible;
PortalNameComboBox.Visibility = Visibility.Collapsed;

// Populate the map names
MapNameComboBox.ItemsSource = mapNames;
}
else
{
MapNameComboBox.Visibility = Visibility.Visible;
PortalNameComboBox.Visibility = Visibility.Visible;

// Populate both portal names and map names
PortalNameComboBox.ItemsSource = portalConnections.Keys.ToList();
MapNameComboBox.ItemsSource = mapNames;
}
}
}
}
Loading

0 comments on commit f91ea21

Please sign in to comment.