Skip to content

Commit

Permalink
collapsing responses
Browse files Browse the repository at this point in the history
  • Loading branch information
iBowie committed Jul 6, 2020
1 parent 56a1bd1 commit 6fedf1f
Show file tree
Hide file tree
Showing 6 changed files with 112 additions and 52 deletions.
1 change: 1 addition & 0 deletions BowieD.Unturned.NPCMaker/BowieD.Unturned.NPCMaker.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,7 @@
<Compile Include="Random.cs" />
<Compile Include="Markup\IMarkup.cs" />
<Compile Include="ScreenHelper.cs" />
<Compile Include="TextUtil.cs" />
<Compile Include="Themes\MetroTheme.cs" />
<Compile Include="Themes\Theme.cs" />
<Compile Include="Themes\ThemeManager.cs" />
Expand Down
117 changes: 69 additions & 48 deletions BowieD.Unturned.NPCMaker/Controls/Dialogue_Response.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,61 +8,82 @@
xmlns:iconPacks="http://metro.mahapps.com/winfx/xaml/iconpacks"
xmlns:xaml="clr-namespace:BowieD.Unturned.NPCMaker.XAML"
mc:Ignorable="d"
Height="242" Width="321.25" MinWidth="301" MinHeight="242">
Height="Auto" Width="Auto">
<Border BorderBrush="{StaticResource AccentColor}" BorderThickness="2" CornerRadius="4" Margin="5">
<Border.RenderTransform>
<TransformGroup>
<TranslateTransform x:Name="animateTransform"/>
</TransformGroup>
</Border.RenderTransform>
<Grid>
<Label HorizontalContentAlignment="Center" Content="{xaml:Localize Key=DIALOGUE_Reply}" Margin="46,10,168.25,0" Height="31" VerticalAlignment="Top"/>
<Button Click="EditConditionsButton_Click" Name="editConditionsButton" Content="{xaml:Localize Key=DIALOGUE_Reply_Conditions}" HorizontalAlignment="Right" Margin="0,10,46.25,0" Height="31" Width="117" VerticalAlignment="Top"/>
<Button Click="EditRewardsButton_Click" Name="editRewardsButton" Content="{xaml:Localize Key=DIALOGUE_Reply_Rewards}" VerticalAlignment="Top" HorizontalAlignment="Right" Margin="0,46,46.25,0" Height="31" Width="117"/>
<Button ToolTip="{xaml:Localize Key=DIALOGUE_Reply_Remove}" Name="deleteButton" Height="31" Width="31" Margin="10,10,0,0" VerticalAlignment="Top" HorizontalAlignment="Left">
<Button.Content>
<iconPacks:PackIconMaterial Kind="Delete" Foreground="{DynamicResource AccentColor}"/>
</Button.Content>
</Button>
<Border Height="32" Margin="113,82,10.25,0" VerticalAlignment="Top">
<TextBlock Text="{xaml:Localize Key=DIALOGUE_Reply_Redirects_Dialogue}" VerticalAlignment="Center" TextWrapping="Wrap" FontSize="11" TextAlignment="Left" Margin="0,4,0,4"/>
</Border>
<Border Height="31" Margin="113,118,10.25,0" VerticalAlignment="Top">
<TextBlock Text="{xaml:Localize Key=DIALOGUE_Reply_Redirects_Vendor}" VerticalAlignment="Center" TextWrapping="Wrap" FontSize="11" TextAlignment="Left" Margin="0,4,0,4"/>
</Border>
<Border Margin="113,154,10.25,0" Height="31" VerticalAlignment="Top">
<TextBlock Text="{xaml:Localize Key=DIALOGUE_Reply_Redirects_Quest}" VerticalAlignment="Center" TextWrapping="Wrap" FontSize="11" TextAlignment="Left" Margin="0,4,0,4"/>
</Border>
<Button Click="DialogueSelect_Click" Width="31" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="77,82,0,0" Height="31">
<Button.Content>
<iconPacks:PackIconMaterial Kind="MessageOutline" Foreground="{DynamicResource AccentColor}"/>
</Button.Content>
</Button>
<Button Click="VendorSelect_Click" Width="31" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="77,118,0,0" Height="31">
<Button.Content>
<iconPacks:PackIconMaterial Kind="CurrencyUsd" Foreground="{DynamicResource AccentColor}"/>
</Button.Content>
</Button>
<Button Click="QuestSelect_Click" Width="31" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="77,154,0,0" Height="31">
<Button.Content>
<iconPacks:PackIconMaterial Kind="Exclamation" Foreground="{DynamicResource AccentColor}"/>
</Button.Content>
</Button>
<TextBox TextChanged="MainText_TextChanged" Name="mainText" Margin="10,46,168.25,0" TextWrapping="NoWrap" Height="31" VerticalAlignment="Top"/>
<mah:NumericUpDown ValueChanged="TxtBoxDialogueID_ValueChanged" ParsingNumberStyle="Integer" HorizontalContentAlignment="Left" HideUpDownButtons="True" Maximum="65535" Minimum="0" NumericInputMode="Decimal" InterceptMouseWheel="False" InterceptArrowKeys="False" Width="50" Margin="10,82,0,0" x:Name="txtBoxDialogueID" HorizontalAlignment="Left" Height="31" VerticalAlignment="Top"/>
<mah:NumericUpDown ValueChanged="TxtBoxVendorID_ValueChanged" ParsingNumberStyle="Integer" HorizontalContentAlignment="Left" HideUpDownButtons="True" Maximum="65535" Minimum="0" NumericInputMode="Decimal" InterceptMouseWheel="False" InterceptArrowKeys="False" Width="50" Height="31" Margin="10,118,0,0" HorizontalAlignment="Left" x:Name="txtBoxVendorID" VerticalAlignment="Top"/>
<mah:NumericUpDown ValueChanged="TxtBoxQuestID_ValueChanged" ParsingNumberStyle="Integer" HorizontalContentAlignment="Left" HideUpDownButtons="True" Maximum="65535" Minimum="0" NumericInputMode="Decimal" InterceptMouseWheel="False" InterceptArrowKeys="False" Width="50" Height="31" Margin="10,154,0,0" x:Name="txtBoxQuestID" VerticalAlignment="Top" HorizontalAlignment="Left"/>
<Button Click="ChangeVisibilityButton_Click" Content="{xaml:Localize Key=DIALOGUE_Reply_Visibility}" Margin="10,190,46.25,0" Height="31" VerticalAlignment="Top"/>
<Button ToolTip="{xaml:Localize Key=DIALOGUE_Reply_Move_Up}" Name="orderButtonUp" HorizontalAlignment="Right" Margin="0,10,10.25,0" VerticalAlignment="Top" Height="31" Width="31">
<Button.Content>
<iconPacks:PackIconMaterial Kind="ArrowUp" Foreground="{DynamicResource AccentColor}"/>
</Button.Content>
</Button>
<Button ToolTip="{xaml:Localize Key=DIALOGUE_Reply_Move_Down}" Name="orderButtonDown" HorizontalAlignment="Right" Margin="0,190,10.25,0" VerticalAlignment="Top" Height="31" Width="31">
<Button.Content>
<iconPacks:PackIconMaterial Kind="ArrowDown" Foreground="{DynamicResource AccentColor}"/>
</Button.Content>
</Button>
<Grid Name="collapsedGrid" Visibility="Collapsed">
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<Label Margin="10" Width="240">
<TextBlock FontStyle="Italic" Name="collapsedText"/>
</Label>
<Button Grid.Column="1" Click="Expand_Button_Click" ToolTip="{xaml:Localize Key=INTERFACE_Control_Expand}" HorizontalAlignment="Right" Margin="10,10,10,10" VerticalAlignment="Top" Height="31" Width="31">
<Button.Content>
<iconPacks:PackIconMaterial Kind="ArrowExpand" Foreground="{DynamicResource AccentColor}"/>
</Button.Content>
</Button>
</Grid>
<Grid Name="expandedGrid" Visibility="Visible">
<Label HorizontalContentAlignment="Center" Content="{xaml:Localize Key=DIALOGUE_Reply}" Margin="46,10,168.25,0" Height="31" VerticalAlignment="Top"/>
<Button Click="EditConditionsButton_Click" Name="editConditionsButton" Content="{xaml:Localize Key=DIALOGUE_Reply_Conditions}" HorizontalAlignment="Right" Margin="0,10,46.25,0" Height="31" Width="117" VerticalAlignment="Top"/>
<Button Click="EditRewardsButton_Click" Name="editRewardsButton" Content="{xaml:Localize Key=DIALOGUE_Reply_Rewards}" VerticalAlignment="Top" HorizontalAlignment="Right" Margin="0,46,46.25,0" Height="31" Width="117"/>
<Button ToolTip="{xaml:Localize Key=DIALOGUE_Reply_Remove}" Name="deleteButton" Height="31" Width="31" Margin="10,10,0,0" VerticalAlignment="Top" HorizontalAlignment="Left">
<Button.Content>
<iconPacks:PackIconMaterial Kind="Delete" Foreground="{DynamicResource AccentColor}"/>
</Button.Content>
</Button>
<Border Height="32" Margin="113,82,10.25,0" VerticalAlignment="Top">
<TextBlock Text="{xaml:Localize Key=DIALOGUE_Reply_Redirects_Dialogue}" VerticalAlignment="Center" TextWrapping="Wrap" FontSize="11" TextAlignment="Left" Margin="0,4,0,4"/>
</Border>
<Border Height="31" Margin="113,118,10.25,0" VerticalAlignment="Top">
<TextBlock Text="{xaml:Localize Key=DIALOGUE_Reply_Redirects_Vendor}" VerticalAlignment="Center" TextWrapping="Wrap" FontSize="11" TextAlignment="Left" Margin="0,4,0,4"/>
</Border>
<Border Margin="113,154,10.25,0" Height="31" VerticalAlignment="Top">
<TextBlock Text="{xaml:Localize Key=DIALOGUE_Reply_Redirects_Quest}" VerticalAlignment="Center" TextWrapping="Wrap" FontSize="11" TextAlignment="Left" Margin="0,4,0,4"/>
</Border>
<Button Click="DialogueSelect_Click" Width="31" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="77,82,0,0" Height="31">
<Button.Content>
<iconPacks:PackIconMaterial Kind="MessageOutline" Foreground="{DynamicResource AccentColor}"/>
</Button.Content>
</Button>
<Button Click="VendorSelect_Click" Width="31" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="77,118,0,0" Height="31">
<Button.Content>
<iconPacks:PackIconMaterial Kind="CurrencyUsd" Foreground="{DynamicResource AccentColor}"/>
</Button.Content>
</Button>
<Button Click="QuestSelect_Click" Width="31" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="77,154,0,0" Height="31">
<Button.Content>
<iconPacks:PackIconMaterial Kind="Exclamation" Foreground="{DynamicResource AccentColor}"/>
</Button.Content>
</Button>
<TextBox TextChanged="MainText_TextChanged" Name="mainText" Margin="10,46,168.25,0" TextWrapping="NoWrap" Height="31" VerticalAlignment="Top"/>
<mah:NumericUpDown ValueChanged="TxtBoxDialogueID_ValueChanged" ParsingNumberStyle="Integer" HorizontalContentAlignment="Left" HideUpDownButtons="True" Maximum="65535" Minimum="0" NumericInputMode="Decimal" InterceptMouseWheel="False" InterceptArrowKeys="False" Width="50" Margin="10,82,0,0" x:Name="txtBoxDialogueID" HorizontalAlignment="Left" Height="31" VerticalAlignment="Top"/>
<mah:NumericUpDown ValueChanged="TxtBoxVendorID_ValueChanged" ParsingNumberStyle="Integer" HorizontalContentAlignment="Left" HideUpDownButtons="True" Maximum="65535" Minimum="0" NumericInputMode="Decimal" InterceptMouseWheel="False" InterceptArrowKeys="False" Width="50" Height="31" Margin="10,118,0,0" HorizontalAlignment="Left" x:Name="txtBoxVendorID" VerticalAlignment="Top"/>
<mah:NumericUpDown ValueChanged="TxtBoxQuestID_ValueChanged" ParsingNumberStyle="Integer" HorizontalContentAlignment="Left" HideUpDownButtons="True" Maximum="65535" Minimum="0" NumericInputMode="Decimal" InterceptMouseWheel="False" InterceptArrowKeys="False" Width="50" Height="31" Margin="10,154,0,0" x:Name="txtBoxQuestID" VerticalAlignment="Top" HorizontalAlignment="Left"/>
<Button Click="ChangeVisibilityButton_Click" Content="{xaml:Localize Key=DIALOGUE_Reply_Visibility}" Margin="10,190,46.25,10" Height="31" VerticalAlignment="Top"/>
<Button ToolTip="{xaml:Localize Key=DIALOGUE_Reply_Move_Up}" Name="orderButtonUp" HorizontalAlignment="Right" Margin="0,10,10.25,10" VerticalAlignment="Top" Height="31" Width="31">
<Button.Content>
<iconPacks:PackIconMaterial Kind="ArrowUp" Foreground="{DynamicResource AccentColor}"/>
</Button.Content>
</Button>
<Button Click="Collapse_Button_Click" ToolTip="{xaml:Localize Key=INTERFACE_Control_Collapse}" HorizontalAlignment="Right" Margin="0,46,10,0" VerticalAlignment="Top" Height="31" Width="31">
<Button.Content>
<iconPacks:PackIconMaterial Kind="ArrowCollapse" Foreground="{DynamicResource AccentColor}"/>
</Button.Content>
</Button>
<Button ToolTip="{xaml:Localize Key=DIALOGUE_Reply_Move_Down}" Name="orderButtonDown" HorizontalAlignment="Right" Margin="0,190,10.25,10" VerticalAlignment="Top" Height="31" Width="31">
<Button.Content>
<iconPacks:PackIconMaterial Kind="ArrowDown" Foreground="{DynamicResource AccentColor}"/>
</Button.Content>
</Button>
</Grid>
</Grid>
</Border>
</UserControl>
24 changes: 24 additions & 0 deletions BowieD.Unturned.NPCMaker/Controls/Dialogue_Response.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,21 @@ public Dialogue_Response(NPC.NPCResponse startResponse = null)
}

public NPC.NPCResponse Response { get; private set; }

public bool IsCollapsed { get; private set; }

public void Expand()
{
expandedGrid.Visibility = Visibility.Visible;
collapsedGrid.Visibility = Visibility.Collapsed;
}
public void Collapse()
{
expandedGrid.Visibility = Visibility.Collapsed;
collapsedGrid.Visibility = Visibility.Visible;
collapsedText.Text = TextUtil.Shortify(mainText.Text, 24);
}

public void RebuildResponse()
{
Response.mainText = mainText.Text;
Expand Down Expand Up @@ -159,5 +174,14 @@ private void TxtBoxDialogueID_ValueChanged(object sender, RoutedPropertyChangedE
public UIElement UpButton => orderButtonUp;
public UIElement DownButton => orderButtonDown;
public Transform Transform => animateTransform;

private void Collapse_Button_Click(object sender, RoutedEventArgs e)
{
Collapse();
}
private void Expand_Button_Click(object sender, RoutedEventArgs e)
{
Expand();
}
}
}
3 changes: 1 addition & 2 deletions BowieD.Unturned.NPCMaker/NPC/NPCDialogue.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,9 @@ public string UIText
else
{
string t = messages[0].pages[0];
const int tLengthMax = 24;
if (!string.IsNullOrEmpty(t))
{
return $"[{id}] - {(t.Substring(0, t.Length < tLengthMax ? t.Length : tLengthMax))}{(t.Length >= tLengthMax ? "..." : "")}";
return TextUtil.Shortify($"[{id}] - {t}", 24);
}

return $"[{id}]";
Expand Down
4 changes: 2 additions & 2 deletions BowieD.Unturned.NPCMaker/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
[assembly: AssemblyCulture("")]
[assembly: ComVisible(false)]
[assembly: ThemeInfo(ResourceDictionaryLocation.None, ResourceDictionaryLocation.SourceAssembly)]
[assembly: AssemblyVersion("1.12.2.17")]
[assembly: AssemblyFileVersion("1.12.2.17")]
[assembly: AssemblyVersion("1.12.2.18")]
[assembly: AssemblyFileVersion("1.12.2.18")]
[assembly: NeutralResourcesLanguage("en-US")]

15 changes: 15 additions & 0 deletions BowieD.Unturned.NPCMaker/TextUtil.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
namespace BowieD.Unturned.NPCMaker
{
public static class TextUtil
{
public static string Shortify(string original, int maxLength = 40)
{
if (string.IsNullOrEmpty(original))
return original ?? string.Empty;
string shortened = original.Substring(0, original.Length < maxLength ? original.Length : maxLength);
if (original.Length > maxLength)
return shortened + "...";
return shortened;
}
}
}

0 comments on commit 6fedf1f

Please sign in to comment.