@@ -13,6 +13,8 @@ public class MessagesEditor {
1313 private static string [ ] characterList = new string [ 0 ] ;
1414 private static string [ ] contextList = new string [ 0 ] ;
1515 private static string [ ] itemList = new string [ 0 ] ;
16+ private static string [ ] customFlagsList = new string [ 0 ] ;
17+ private static string [ ] booleanArray = new string [ ] { "True" , "False" } ;
1618 public static GUIStyle messagesWindowHeaderStyle = new GUIStyle ( DGUI . windowStyle ) ;
1719 public static GUIStyle messagesWindowMainStyle = new GUIStyle ( DGUI . windowStyle ) ;
1820 public static GUIStyle messagesWindowSidebarStyle = new GUIStyle ( DGUI . windowStyle ) ;
@@ -140,8 +142,7 @@ public static void Main() {
140142 break ;
141143 }
142144 }
143-
144- #region MESSAGE CARD
145+
145146 Rect boxRect = EditorGUILayout . BeginVertical ( DGUI . boxStyle ) ;
146147
147148 var color = currentMessage . color ;
@@ -209,6 +210,17 @@ public static void Main() {
209210 }
210211 text += condition . DisplayHasItem ( itemName ) ;
211212 break ;
213+ case Condition . Type . CustomFlagEqualTo :
214+ text += condition . DisplayCustomFlagEqualTo ( ) ;
215+ break ;
216+ case Condition . Type . ItemWasDiscarded :
217+ var itemNameDiscarded = "" ;
218+ if ( Item . Find ( diplomataEditor . inventory . items , condition . itemId ) != null ) {
219+ itemName = DictHandler . ContainsKey ( Item . Find ( diplomataEditor . inventory . items , condition . itemId ) . name ,
220+ diplomataEditor . preferences . currentLanguage ) . value ;
221+ }
222+ text += condition . DisplayItemWasDiscarded ( itemNameDiscarded ) ;
223+ break ;
212224 }
213225
214226 if ( k < currentMessage . conditions . Length - 1 ) {
@@ -308,6 +320,9 @@ public static void Main() {
308320 }
309321 text += effect . DisplayDiscardItem ( discardItemName ) ;
310322 break ;
323+ case Effect . Type . SetCustomFlag :
324+ text += effect . DisplayCustomFlagEqualTo ( ) ;
325+ break ;
311326 }
312327
313328 if ( k < currentMessage . effects . Length - 1 ) {
@@ -344,19 +359,13 @@ public static void Main() {
344359 DGUI . labelStyle . alignment = TextAnchor . UpperLeft ;
345360 }
346361
347- /*if (GUI.GetNameOfFocusedControl() == "title" + currentMessage.id ||
348- GUI.GetNameOfFocusedControl() == "content" + currentMessage.id) {
349- SetMessage(currentMessage);
350- }*/
351-
352362 if ( GUI . Button ( boxRect , "" , buttonStyle ) ) {
353363 SetMessage ( currentMessage ) ;
354364 EditorGUI . FocusTextInControl ( "" ) ;
355365 }
356366
357367 EditorGUILayout . EndVertical ( ) ;
358368 EditorGUILayout . Separator ( ) ;
359- #endregion
360369 }
361370
362371 if ( GUILayout . Button ( "Add Message" , GUILayout . Height ( DGUI . BUTTON_HEIGHT ) ) ) {
@@ -577,14 +586,20 @@ public static void Sidebar() {
577586 case AnimatorControllerParameterType . Bool :
578587 string selected = animatorAttribute . setBool . ToString ( ) ;
579588
580- selected = DGUI . Popup ( "Set boolean to " , selected , new string [ ] { "True" , "False" } ) ;
589+ EditorGUI . BeginChangeCheck ( ) ;
581590
582- if ( selected == "True" ) {
583- animatorAttribute . setBool = true ;
584- }
591+ selected = DGUI . Popup ( "Set boolean to " , selected , booleanArray ) ;
592+
593+ if ( EditorGUI . EndChangeCheck ( ) ) {
594+
595+ if ( selected == "True" ) {
596+ animatorAttribute . setBool = true ;
597+ }
598+
599+ else {
600+ animatorAttribute . setBool = false ;
601+ }
585602
586- else {
587- animatorAttribute . setBool = false ;
588603 }
589604
590605 break ;
@@ -850,6 +865,59 @@ public static void Sidebar() {
850865
851866 GUILayout . EndHorizontal ( ) ;
852867 break ;
868+
869+ case Condition . Type . ItemWasDiscarded :
870+ GUILayout . BeginHorizontal ( ) ;
871+ UpdateItemList ( ) ;
872+
873+ var discardedItemName = "" ;
874+
875+ if ( itemList . Length > 0 ) {
876+ itemName = DictHandler . ContainsKey ( Item . Find ( diplomataEditor . inventory . items , condition . itemId ) . name , diplomataEditor . preferences . currentLanguage ) . value ;
877+ }
878+
879+ EditorGUI . BeginChangeCheck ( ) ;
880+
881+ discardedItemName = DGUI . Popup ( "Item was discarded " , discardedItemName , itemList ) ;
882+
883+ if ( EditorGUI . EndChangeCheck ( ) ) {
884+ foreach ( Item item in diplomataEditor . inventory . items ) {
885+
886+ if ( DictHandler . ContainsKey ( item . name , diplomataEditor . preferences . currentLanguage ) . value == discardedItemName ) {
887+ condition . itemId = item . id ;
888+ break ;
889+ }
890+
891+ }
892+ }
893+
894+ GUILayout . EndHorizontal ( ) ;
895+ break ;
896+
897+ case Condition . Type . CustomFlagEqualTo :
898+ UpdateCustomFlagsList ( ) ;
899+
900+ condition . customFlag . name = DGUI . Popup ( "Flag: " , condition . customFlag . name , customFlagsList ) ;
901+
902+ string selected = condition . customFlag . value . ToString ( ) ;
903+
904+ EditorGUI . BeginChangeCheck ( ) ;
905+
906+ selected = DGUI . Popup ( "is " , selected , booleanArray ) ;
907+
908+ if ( EditorGUI . EndChangeCheck ( ) ) {
909+
910+ if ( selected == "True" ) {
911+ condition . customFlag . value = true ;
912+ }
913+
914+ else {
915+ condition . customFlag . value = false ;
916+ }
917+
918+ }
919+
920+ break ;
853921 }
854922
855923 if ( GUILayout . Button ( "Delete Condition" , GUILayout . Height ( DGUI . BUTTON_HEIGHT_SMALL ) ) ) {
@@ -975,14 +1043,20 @@ public static void Sidebar() {
9751043 case AnimatorControllerParameterType . Bool :
9761044 string selected = effect . animatorAttributeSetter . setBool . ToString ( ) ;
9771045
978- selected = DGUI . Popup ( "Set boolean to " , selected , new string [ ] { "True" , "False" } ) ;
1046+ EditorGUI . BeginChangeCheck ( ) ;
9791047
980- if ( selected == "True" ) {
981- effect . animatorAttributeSetter . setBool = true ;
982- }
1048+ selected = DGUI . Popup ( "Set boolean to " , selected , booleanArray ) ;
1049+
1050+ if ( EditorGUI . EndChangeCheck ( ) ) {
1051+
1052+ if ( selected == "True" ) {
1053+ effect . animatorAttributeSetter . setBool = true ;
1054+ }
1055+
1056+ else {
1057+ effect . animatorAttributeSetter . setBool = false ;
1058+ }
9831059
984- else {
985- effect . animatorAttributeSetter . setBool = false ;
9861060 }
9871061
9881062 break ;
@@ -1061,6 +1135,31 @@ public static void Sidebar() {
10611135
10621136 GUILayout . EndHorizontal ( ) ;
10631137 break ;
1138+
1139+ case Effect . Type . SetCustomFlag :
1140+ UpdateCustomFlagsList ( ) ;
1141+
1142+ effect . customFlag . name = DGUI . Popup ( "Flag: " , effect . customFlag . name , customFlagsList ) ;
1143+
1144+ string effectSelected = effect . customFlag . value . ToString ( ) ;
1145+
1146+ EditorGUI . BeginChangeCheck ( ) ;
1147+
1148+ effectSelected = DGUI . Popup ( " set to " , effectSelected , booleanArray ) ;
1149+
1150+ if ( EditorGUI . EndChangeCheck ( ) ) {
1151+
1152+ if ( effectSelected == "True" ) {
1153+ effect . customFlag . value = true ;
1154+ }
1155+
1156+ else {
1157+ effect . customFlag . value = false ;
1158+ }
1159+
1160+ }
1161+
1162+ break ;
10641163 }
10651164
10661165 if ( GUILayout . Button ( "Delete Effect" , GUILayout . Height ( DGUI . BUTTON_HEIGHT_SMALL ) ) ) {
@@ -1155,6 +1254,14 @@ public static void UpdateContextList() {
11551254 }
11561255 }
11571256
1257+ public static void UpdateCustomFlagsList ( ) {
1258+ customFlagsList = new string [ 0 ] ;
1259+
1260+ foreach ( Flag flag in CharacterMessagesManager . diplomataEditor . customFlags . flags ) {
1261+ customFlagsList = ArrayHandler . Add ( customFlagsList , flag . name ) ;
1262+ }
1263+ }
1264+
11581265 }
11591266
11601267}
0 commit comments