예제 #1
0
 public void UnlockNoteCarnet()
 {
     if (SavedDataServices.DiscoverNote(sommeil.index, noteCarnet.typeNote))
     {
         SavedDataServices.SavePlayer();
     }
 }
예제 #2
0
    public NoteCarnet[] GetUnlockedNotesCarnet()
    {
        var entriesList = new List <NoteCarnet>();

        foreach (var resultat in _resultatEntities)
        {
            if (SavedDataServices.IsNoteDiscovered(resultat.sommeil.index, resultat.noteCarnet.typeNote))
            {
                entriesList.Add(resultat.noteCarnet);
            }
        }

        return(entriesList.ToArray());
    }
    protected void DrawData(DataType dataType, ref bool unfold, Action drawAction)
    {
        var label       = Regex.Replace(dataType.ToString(), "([a-z])([A-Z])", "$1 $2");
        var lblSize     = label.Length;
        var localUnfold = unfold;

        DrawUtility.DrawHorizontal(() =>
        {
            GUILayout.Space(5);
            DrawUtility.DrawVertical(() =>
            {
                GUILayout.Space(5);
                DrawUtility.DrawFoldableBox(label, ref localUnfold,
                                            () =>
                {
                    DrawUtility.DrawHorizontalLine();
                    DrawUtility.DrawHorizontal(() =>
                    {
                        GUILayout.Space(5);
                        DrawUtility.DrawButton(IconName.SAVE, $"Save {label}",
                                               () => DrawUtility.YesNoDialog($"Save {label}", $"Are you sure to overwrite {label}?",
                                                                             () => SavedDataServices.Save(dataType)),
                                               GUILayout.Height(35), GUILayout.Width(35 + (9 + lblSize) * 5));

                        DrawUtility.DrawButton(IconName.REFRESH, $"Reload {label}",
                                               () => SavedDataServices.Load(dataType), GUILayout.Height(35),
                                               GUILayout.Width(35 + (11 + lblSize) * 5));

                        DrawUtility.DrawButton(IconName.TRASH, $"Reset {label}",
                                               () => DrawUtility.YesNoDialog($"Reset {label}", $"Are you sure to reset {label}?",
                                                                             () => SavedDataServices.ResetData(dataType)),
                                               GUILayout.Height(35), GUILayout.Width(35 + (10 + lblSize) * 5));
                    });
                    GUILayout.Space(5);
                    DrawUtility.DrawHorizontalLine();

                    drawAction();

                    GUILayout.Space(5);
                }, Indent.Nothing);
            });
        });
        unfold = localUnfold;
    }
예제 #4
0
 public void Init()
 {
     SavedDataServices.LoadEverything();
     m_scannerManager = InstanceManager.ScannerManager;
 }
예제 #5
0
    private void DrawNotebookEntries(EntitiesManager entitiesManager, ref SavedDataServices.PlayerData playerData)
    {
        if (playerData.notebookEntries == null)
        {
            playerData.notebookEntries = new List <ushort>();
        }

        var data            = playerData;
        var sommeilEntities = entitiesManager.SommeilEntities;

        DrawUtility.DrawListFolder("Notes Carnet", ref m_unfoldNotebookEntries, () =>
        {
            var canAddItem  = false;
            byte sommeilIdx = 0;
            for (; sommeilIdx < sommeilEntities.Length; sommeilIdx++)
            {
                if (data.notebookEntries.GetNotebookEntryIndex(sommeilIdx) != -1 ||
                    entitiesManager.GetNotesCarnetBySommeil(sommeilEntities[sommeilIdx]).Length == 0)
                {
                    continue;
                }
                canAddItem = true;
                break;
            }

            DrawUtility.BeginGUILayoutIndent();
            DrawUtility.DrawVertical(() =>
            {
                for (byte i = 0; i < data.notebookEntries.Count; i++)
                {
                    DrawUtility.DrawHorizontal(() =>
                    {
                        GUILayout.BeginVertical(GUILayout.Height(50));
                        GUILayout.FlexibleSpace();
                        if (DrawRemoveButton())
                        {
                            data.notebookEntries.RemoveAt(i);
                            return;
                        }

                        GUILayout.FlexibleSpace();
                        GUILayout.EndVertical();

                        DrawUtility.DrawVertical(() =>
                        {
                            var(sommeilIndex, typeNote) = SavedDataServices.GetNotebookEntryValues(data.notebookEntries[i]);
                            EditorGUI.indentLevel--;
                            var labelWidth = EditorGUIUtility.labelWidth;
                            var fieldWith  = EditorGUIUtility.fieldWidth;
                            EditorGUIUtility.labelWidth = 100;
                            EditorGUIUtility.fieldWidth = 25;
                            DrawUtility.DrawHorizontal(() =>
                            {
                                DrawUtility.DrawVertical(() =>
                                {
                                    GUI.enabled  = canAddItem;
                                    sommeilIndex = (byte)EditorGUILayout.IntSlider("Index Sommeil", sommeilIndex, 0,
                                                                                   sommeilEntities.Length - 1);
                                    EditorGUILayout.LabelField("Sommeil", sommeilEntities[sommeilIndex].nom, EditorStyles.boldLabel);
                                    GUI.enabled = true;
                                });
                            });

                            var notes       = entitiesManager.GetNotesCarnetBySommeil(sommeilEntities[sommeilIndex]);
                            var noteIndexes = 0;

                            var everything = true;

                            for (byte j = 0; j < notes.Length; j++)
                            {
                                if ((typeNote & (byte)notes[j].typeNote) != 0)
                                {
                                    noteIndexes |= j.ToBitMask();
                                }
                                else
                                {
                                    everything = false;
                                }
                            }

                            if (notes.Length > 0)
                            {
                                var noteNames =
                                    notes.Select(x => $@"{x.objet}            ________            {x.typeNote.PrettyName()}").ToArray();

                                DrawUtility.DrawHorizontal(() =>
                                {
                                    EditorGUIUtility.fieldWidth = fieldWith;
                                    noteIndexes = (byte)EditorGUILayout.MaskField("Notes", everything ? -1 : noteIndexes, noteNames);

                                    typeNote = 0;
                                    for (byte j = 0; j < notes.Length; j++)
                                    {
                                        if ((noteIndexes & j.ToBitMask()) != 0)
                                        {
                                            typeNote |= (byte)notes[j].typeNote;
                                        }
                                    }

                                    GUI.enabled = false;
                                    EditorGUILayout.LabelField("Notebook Entry", data.notebookEntries[i].ToString());
                                    GUI.enabled = true;
                                    EditorGUIUtility.labelWidth = labelWidth;
                                });
                                EditorGUI.indentLevel++;
                            }

                            var entryIndex = data.notebookEntries.GetNotebookEntryIndex(sommeilIndex);

                            if (entryIndex != -1 && entryIndex != i)
                            {
                                sommeilIndex = SavedDataServices.GetSommeilIndex(data.notebookEntries[i]);
                            }

                            data.notebookEntries[i] = SavedDataServices.ToNotebookEntry(sommeilIndex, typeNote);
                        });
                    }, GUI.skin.box);
                }

                GUI.enabled = canAddItem;
                if (DrawAddButton())
                {
                    data.notebookEntries.Add(SavedDataServices.ToNotebookEntry(sommeilIdx, 0));
                }
                GUI.enabled = true;
            });
            DrawUtility.EndGUILayoutIndent();
        });
        playerData = data;
    }
예제 #6
0
 private static void Init()
 {
     SavedDataServices.LoadEverything();
     GetWindow <EditSavedDataEditor>().Show();
 }