Skip to content

Commit

Permalink
More work on Model Viewer
Browse files Browse the repository at this point in the history
- Doubleclick in lookup tool views model
- Show lookup tool opening model viewer
- Show display ID on creature lookup
- Random tips added
- try-catch to prevent failed lookups on notification rows
  • Loading branch information
NotCoffee418 committed May 16, 2016
1 parent a002e7a commit 38bd47c
Show file tree
Hide file tree
Showing 8 changed files with 79 additions and 17 deletions.
2 changes: 1 addition & 1 deletion TrinityCreator/Database/SqlQuery.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ internal static DataTable FindQuestByName(string partialName)
internal static DataTable FindCreatureByName(string partialName)
{
return ExecuteQuery(
"SELECT entry, name FROM creature_template WHERE name LIKE '%" + CleanText(partialName, false) + "%' ORDER BY entry DESC LIMIT 200;");
"SELECT entry, modelid1, name FROM creature_template WHERE name LIKE '%" + CleanText(partialName, false) + "%' ORDER BY entry DESC LIMIT 200;");
}

internal static DataTable FindGoByName(string partialName)
Expand Down
2 changes: 1 addition & 1 deletion TrinityCreator/LookupTool.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
<Button Name="searchBtn" Content="Search" DockPanel.Dock="Right" Click="searchBtn_Click" IsDefault="True" Width="75"/>
<TextBox Name="searchTxt" />
</DockPanel>
<DataGrid Name="dataGrid" IsReadOnly="True" />
<DataGrid Name="dataGrid" IsReadOnly="True" MouseDoubleClick="dataGrid_MouseDoubleClick"/>
</StackPanel>
</ScrollViewer>
</UserControl>
26 changes: 26 additions & 0 deletions TrinityCreator/LookupTool.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -262,5 +262,31 @@ private void targetSelectCb_SelectionChanged(object sender, SelectionChangedEven
if ((int)SelectedTarget != targetSelectCb.SelectedIndex)
SelectedTarget = (Target)targetSelectCb.SelectedIndex;
}

/// <summary>
/// Use model viewer when possible
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void dataGrid_MouseDoubleClick(object sender, MouseButtonEventArgs e)
{
try
{
DataRowView drv = (DataRowView)dataGrid.SelectedItem;
if (SelectedTarget == Target.Item) // by displayid
{
int id = Convert.ToInt32((uint)drv.Row[1]);
App.ModelViewer.LoadModel(id, "Item", "Display ID");
App._MainWindow.ShowModelViewer();
}
else if (SelectedTarget == Target.Creature) // By entry id
{
int id = Convert.ToInt32((uint)drv.Row[0]);
App.ModelViewer.LoadModel(id, "Creature", "Entry ID");
App._MainWindow.ShowModelViewer();
}
}
catch { /* Happens when clicking notification row, do nothing */ }
}
}
}
4 changes: 2 additions & 2 deletions TrinityCreator/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@
<TabItem Header="Creature (UNFINISHED)"/>
<TabItem Header="Loot (UNFINISHED)" />
<TabItem Header="Vendor (UNFINISHED)" />
<TabItem Header="ModelViewer">
<Frame Name="ModelViewerTab" />
<TabItem Header="Model Viewer" Name="ModelViewerTab" Selector.Selected="modelViewerTab_Selected">
<Frame Name="ModelViewerTabFrame" />
</TabItem>
<TabItem Header="More coming soon!">
<DockPanel>
Expand Down
12 changes: 11 additions & 1 deletion TrinityCreator/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public MainWindow()
// Load usable creators
ItemTab.Content = new ItemPage();
QuestTab.Content = new QuestPage();
ModelViewerTab.Content = new ModelViewerPage();
ModelViewerTabFrame.Content = new ModelViewerPage();


// view unfinished when set & on debug
Expand All @@ -72,6 +72,11 @@ public void ShowLookupTool()
LookupToolExpander.IsExpanded = true;
}

public void ShowModelViewer()
{
ModelViewerTab.IsSelected = true;
}

private void configureMysql_Click(object sender, RoutedEventArgs e)
{
new DbConfigWindow().Show();
Expand Down Expand Up @@ -165,5 +170,10 @@ private void ChangeRandomTip(object sender, ElapsedEventArgs e)
}
} while (oldText == newText);
}

private void modelViewerTab_Selected(object sender, RoutedEventArgs e)
{
ShowLookupTool();
}
}
}
6 changes: 3 additions & 3 deletions TrinityCreator/ModelViewerPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@
<DockPanel>
<StackPanel Orientation="Horizontal" DockPanel.Dock="Top">

<ComboBox Name="inputIdCb" MinWidth="75" Margin="5" SelectedIndex="0">
<ComboBox Name="inputIdCb" MinWidth="75" Margin="5" SelectedIndex="0" x:FieldModifier="public">
<ComboBoxItem Content="Display ID"/>
<ComboBoxItem Content="Entry ID"/>
</ComboBox>
<TextBox Name="displayIdTxt" MinWidth="75" Margin="0,5,0,5"/>
<ComboBox Name="displayTypeCb" MinWidth="75" Margin="5" SelectedIndex="0">
<TextBox Name="displayIdTxt" MinWidth="75" Margin="0,5,0,5" x:FieldModifier="public"/>
<ComboBox Name="displayTypeCb" MinWidth="75" Margin="5" SelectedIndex="0" x:FieldModifier="public">
<ComboBoxItem Content="Item"/>
<ComboBoxItem Content="Creature"/>
</ComboBox>
Expand Down
42 changes: 33 additions & 9 deletions TrinityCreator/ModelViewerPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,9 @@ private void loadBtn_Click(object sender, RoutedEventArgs e)
LoadModel();
}

public void LoadModel(int displayId = 0, string type = "")
public void LoadModel(int displayId = 0, string type = "", string idType = "")
{
// Sync with UI
if (displayId == 0)
{
try
Expand All @@ -49,27 +50,50 @@ public void LoadModel(int displayId = 0, string type = "")
else displayIdTxt.Text = displayId.ToString();

if (type == "")
type = ((ComboBoxItem)displayTypeCb.SelectedValue).Content.ToString();
else
{
if (displayTypeCb.SelectedIndex == -1)
displayTypeCb.SelectedIndex = 0;
switch (type)
{
case "Item":
displayTypeCb.SelectedIndex = 0;
break;
case "Creature":
displayTypeCb.SelectedIndex = 1;
break;
}
}

type = ((ComboBoxItem)displayTypeCb.SelectedValue).Content.ToString();
if (idType == "")
idType = ((ComboBoxItem)inputIdCb.SelectedValue).Content.ToString();
else
{
switch (idType)
{
case "Display ID":
inputIdCb.SelectedIndex = 0;
break;
case "Entry ID":
inputIdCb.SelectedIndex = 1;
break;
}
}
else displayTypeCb.SelectedValue = type;


// load model
switch (type)
{
case "Item":
if (inputIdCb.SelectedIndex == 1)
if (idType == "Entry ID")
displayId = SqlQuery.GetItemDisplayFromEntry(displayId);
mvBrowser.LoadUrl("http://www.wowhead.com/#modelviewer:4:13;" + displayId);
mvBrowser.LoadUrl("http://www.wowhead.com/#modelviewer:4:13;" + displayId, blankFirst:true);
break;
case "Creature": // input should be entry instead of display
if (Connection.IsConfigured())
{
if (inputIdCb.SelectedIndex == 0)
if (idType == "Display ID")
displayId = SqlQuery.GetCreatureIdFromDisplayId(displayId);
mvBrowser.LoadUrl("http://www.wowhead.com/npc=" + displayId + "/#modelviewer:10+0", true);
mvBrowser.LoadUrl("http://www.wowhead.com/npc=" + displayId + "/#modelviewer:10+0");
}
break;
}
Expand Down
2 changes: 2 additions & 0 deletions TrinityCreator/Resources/RandomTips.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,6 @@ Use the lookup tool on the right to find ID's.
Please report any bugs and suggestions on GitHub.
Configure your database & dbc in settings to use the lookup tool and other features.
You need to restart TrinityCore and sometimes delete your WoW Cache to view your creations.
Doubleclick a row in the Lookup Tool to view it's in-game model if possible.
You can click-drag the border of Lookup Tool to resize it.
---

0 comments on commit 38bd47c

Please sign in to comment.