-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
de42d97
commit f91ea21
Showing
15 changed files
with
836 additions
and
213 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.