16
16
using System . Windows . Threading ;
17
17
using System . Xml ;
18
18
using System . Windows . Shapes ;
19
+ using System . Windows . Data ;
19
20
20
21
namespace TalkerMakerDeluxe
21
22
{
@@ -161,7 +162,7 @@ void PrepareProject()
161
162
theDatabase . Version = "1.0.0" ;
162
163
theDatabase . Actors . Add ( new Actor ( ) { ID = 0 , name = "Player" , isPlayer = true } ) ;
163
164
theDatabase . Conversations . Add ( new Conversation ( ) { ID = 0 , title = "New Conversation" , description = "A new conversation" , actorID = 0 , conversantID = 0 , actor = theDatabase . Actors [ 0 ] , conversant = theDatabase . Actors [ 0 ] } ) ;
164
- theDatabase . Conversations [ 0 ] . DialogEntries . Add ( new DialogueEntry ( ) { ID = 0 , IsRoot = true , title = "START" , actorID = 0 , actor = theDatabase . Actors [ 0 ] , conversantID = 0 , conversant = theDatabase . Actors [ 0 ] , NodeColor = "Normal" } ) ;
165
+ theDatabase . Conversations [ 0 ] . DialogEntries . Add ( new DialogueEntry ( ) { ID = 0 , IsRoot = true , title = "START" , actorID = 0 , actor = theDatabase . Actors [ 0 ] , conversantID = 0 , conversant = theDatabase . Actors [ 0 ] , NodeColor = "Normal" , fields = new List < DialogueEntry . Field > ( ) } ) ;
165
166
theDatabase . Items . Add ( new Item ( ) { ID = 0 , name = "New Item" } ) ;
166
167
theDatabase . Variables . Add ( new UserVariable ( ) { ID = 0 , name = "New Variable" , type = "Boolean" , initialValue = "false" } ) ;
167
168
theDatabase . Locations . Add ( new Location ( ) { ID = 0 , name = "New Location" } ) ;
@@ -171,6 +172,7 @@ void PrepareProject()
171
172
conditionsStack . DataContext = null ;
172
173
gridScript . DataContext = null ;
173
174
175
+
174
176
lstConversations . SelectionChanged -= lstConversations_SelectionChanged ;
175
177
176
178
lstCharacters . SelectedItem = null ;
@@ -217,7 +219,10 @@ void PrepareProject()
217
219
lstConversations . SelectionChanged += lstConversations_SelectionChanged ;
218
220
lstConversations . SelectedIndex = 0 ;
219
221
//LoadConversation(0);
220
- Console . WriteLine ( "Finish making new project" ) ;
222
+
223
+ SelectNode ( "_node_0" ) ;
224
+
225
+ Console . WriteLine ( "Finished making new project" ) ;
221
226
}
222
227
223
228
void PrepareProject ( string project )
@@ -275,6 +280,8 @@ void PrepareProject(string project)
275
280
lstConversations . Items . Refresh ( ) ;
276
281
lstConversations . SelectionChanged += lstConversations_SelectionChanged ;
277
282
lstConversations . SelectedIndex = 0 ;
283
+
284
+ SelectNode ( "_node_0" ) ;
278
285
}
279
286
280
287
private void DoAutoSave ( object sender , EventArgs e )
@@ -358,11 +365,21 @@ public void AddNode(string parentNode, DialogueEntry entryToAdd = null)
358
365
newDialogueEntry . conversant = theDatabase . Actors . FirstOrDefault ( x => x . ID == theDatabase . Conversations [ loadedConversation ] . conversantID ) ;
359
366
newDialogueEntry . menuText = "" ;
360
367
newDialogueEntry . dialogueText = "" ;
368
+ newDialogueEntry . fields = new List < DialogueEntry . Field > ( ) ;
361
369
}
362
370
else
363
371
{
364
372
newDialogueEntry = new DialogueEntry ( entryToAdd ) ;
365
373
newDialogueEntry . ID = theDatabase . Conversations [ loadedConversation ] . DialogEntries . OrderByDescending ( p => p . ID ) . First ( ) . ID + 1 ;
374
+ newDialogueEntry . fields = new List < DialogueEntry . Field > ( ) ;
375
+ }
376
+
377
+ foreach ( DialogueEntry . Field field in theDatabase . Conversations [ loadedConversation ] . DialogEntries . Find ( x => x . ID == 0 ) . fields )
378
+ {
379
+ if ( ! selectedEntry . fields . Exists ( y => y . name == field . name ) )
380
+ {
381
+ selectedEntry . fields . Add ( new DialogueEntry . Field ( ) { name = field . name , type = field . type , value = field . value } ) ;
382
+ }
366
383
}
367
384
368
385
//Add to conversation
@@ -538,6 +555,7 @@ public void SelectNode(string newNode)
538
555
nodeTree = tcMain . FindName ( newNode . Remove ( 0 , 1 ) ) as TreeNode ;
539
556
node = nodeTree . Content as NodeControl ;
540
557
currentNode = newNode ;
558
+
541
559
542
560
if ( newNode == "_node_0" )
543
561
{
@@ -551,10 +569,38 @@ public void SelectNode(string newNode)
551
569
editScript . IsEnabled = false ;
552
570
conditionsStack . DataContext = null ;
553
571
gridScript . DataContext = null ;
572
+
573
+ selectedEntry = theDatabase . Conversations [ loadedConversation ] . DialogEntries [ 0 ] ;
574
+ if ( selectedEntry . fields == null )
575
+ {
576
+ selectedEntry . fields = new List < DialogueEntry . Field > ( ) ;
577
+ }
578
+ //dgDefaultFields.DataContext = selectedEntry;
579
+ //dgDefaultFields.ItemsSource = selectedEntry.fields;
580
+ //dgDefaultFields.Items.Refresh();
554
581
}
555
582
else
556
583
{
557
- selectedEntry = theDatabase . Conversations [ loadedConversation ] . DialogEntries . FirstOrDefault ( x => x . ID == node . dialogueEntryID ) ;
584
+ selectedEntry = null ;
585
+ selectedEntry = theDatabase . Conversations [ loadedConversation ] . DialogEntries . Find ( x => x . ID == node . dialogueEntryID ) ;
586
+
587
+ if ( selectedEntry . fields == null )
588
+ {
589
+ selectedEntry . fields = new List < DialogueEntry . Field > ( ) ;
590
+ }
591
+
592
+ foreach ( DialogueEntry . Field field in theDatabase . Conversations [ loadedConversation ] . DialogEntries . Find ( x => x . ID == 0 ) . fields )
593
+ {
594
+ if ( ! selectedEntry . fields . Exists ( y => y . name == field . name ) )
595
+ {
596
+ selectedEntry . fields . Add ( new DialogueEntry . Field ( ) { name = field . name , type = field . type , value = field . value } ) ;
597
+ }
598
+ }
599
+
600
+ //dgFields.DataContext = selectedEntry;
601
+ //dgFields.ItemsSource = selectedEntry.fields;
602
+ //dgFields.Items.Refresh();
603
+
558
604
node . DataContext = selectedEntry ;
559
605
Console . WriteLine ( "UserScript: " + selectedEntry . UserScript + " | UserScript.Length: " + selectedEntry . UserScript . Length + " | IsNullOrEmpty: " + string . IsNullOrEmpty ( selectedEntry . UserScript ) + " | IsNullOrWhiteSpace: " + string . IsNullOrWhiteSpace ( selectedEntry . UserScript ) ) ;
560
606
gridDialogueEntry . DataContext = selectedEntry ;
@@ -566,6 +612,17 @@ public void SelectNode(string newNode)
566
612
editConditions . IsEnabled = true ;
567
613
editScript . IsEnabled = true ;
568
614
}
615
+
616
+ if ( selectedEntry != null )
617
+ {
618
+ Console . WriteLine ( $ "Changing Items | Selected ID: { selectedEntry . ID } ") ;
619
+ dgDefaultFields . DataContext = selectedEntry ;
620
+ dgDefaultFields . ItemsSource = selectedEntry . fields ;
621
+ dgDefaultFields . Items . Refresh ( ) ;
622
+ dgFields . DataContext = selectedEntry ;
623
+ dgFields . ItemsSource = selectedEntry . fields ;
624
+ dgFields . Items . Refresh ( ) ;
625
+ }
569
626
}
570
627
571
628
private void DrawConversationTree ( DialogHolder dh )
@@ -681,6 +738,8 @@ private void LoadConversation(int convotoload)
681
738
//recOverview.GetBindingExpression(VisualBrush.VisualProperty).UpdateTarget();
682
739
DrawExtraConnections ( ) ;
683
740
handledNodes . Clear ( ) ;
741
+
742
+ SelectNode ( "_node_0" ) ;
684
743
}
685
744
686
745
private void Delete_Node ( TreeNode mainNode )
@@ -1279,7 +1338,8 @@ private void btnAddConversation_Click(object sender, RoutedEventArgs e)
1279
1338
actorID = 0 ,
1280
1339
actor = theDatabase . Actors [ 0 ] ,
1281
1340
conversantID = 0 ,
1282
- conversant = theDatabase . Actors [ 0 ]
1341
+ conversant = theDatabase . Actors [ 0 ] ,
1342
+ fields = new List < DialogueEntry . Field > ( )
1283
1343
} ;
1284
1344
1285
1345
newConvo . DialogEntries . Add ( convoStart ) ;
@@ -1804,6 +1864,47 @@ private void ScaleTransform_Changed(object sender, EventArgs e)
1804
1864
DrawExtraConnections ( ) ;
1805
1865
}
1806
1866
}
1867
+
1868
+ private void btnAddField_Click ( object sender , RoutedEventArgs e )
1869
+ {
1870
+ if ( selectedEntry != null )
1871
+ {
1872
+ if ( selectedEntry . fields == null )
1873
+ {
1874
+ selectedEntry . fields = new List < DialogueEntry . Field > ( ) ;
1875
+ }
1876
+ selectedEntry . fields . Add ( new DialogueEntry . Field ( ) ) ;
1877
+ dgFields . DataContext = selectedEntry ;
1878
+ dgFields . ItemsSource = selectedEntry . fields ;
1879
+ dgFields . Items . Refresh ( ) ;
1880
+ }
1881
+ }
1882
+
1883
+ private void btnFieldDelete_Click ( object sender , RoutedEventArgs e )
1884
+ {
1885
+ //Console.WriteLine($"Removing Field at Index: {dgFields.SelectedIndex} | {selectedEntry.fields?.Count}");
1886
+ if ( selectedEntry != null && selectedEntry . fields ? . Count > dgFields . SelectedIndex )
1887
+ {
1888
+ selectedEntry . fields . RemoveAt ( dgFields . SelectedIndex ) ;
1889
+ dgFields . DataContext = selectedEntry ;
1890
+ dgFields . ItemsSource = selectedEntry . fields ;
1891
+ dgFields . Items . Refresh ( ) ;
1892
+ }
1893
+ }
1894
+
1895
+ private void btnAddDefaultField_Click ( object sender , RoutedEventArgs e )
1896
+ {
1897
+ if ( selectedEntry . ID == 0 )
1898
+ {
1899
+ Console . Write ( "We're good" ) ;
1900
+ }
1901
+ }
1902
+
1903
+ private void btnDefaultFieldDelete_Click ( object sender , RoutedEventArgs e )
1904
+ {
1905
+
1906
+ }
1907
+
1807
1908
}
1808
1909
1809
1910
public static class SelectOnInternalClick
0 commit comments