Exemplo n.º 1
0
    /// <summary>
    /// called on save prompt (yes, no)
    /// </summary>
    public void InputChoice(int Id)
    {
        // yes, save
        if (Id == 0)
        {
            string savePointNameId = game.GetSavePointData().nameId;
            // check to see if editting or new entry
            Script_Entry existingEntry = entryManager.GetExistingEntry(savePointNameId);
            if (existingEntry != null)
            {
                entryInput.InitializeState(existingEntry.text);
            }
            else
            {
                entryInput.InitializeState(string.Empty);
            }

            StartEntryMode();
            dm.HideDialogue();
        }
        // no, don't save
        else
        {
            dm.NextDialogueNode(1);
        }
        EndSavePrompt();
    }
 void IncreaseScrollContainerHeightByEntryHeight(Script_Entry e)
 {
     scrollContainer.sizeDelta = new Vector2(
         scrollContainer.sizeDelta.x,
         scrollContainer.sizeDelta.y
         + e.GetComponent <RectTransform>().rect.height
         + scrollContainer.GetComponent <VerticalLayoutGroup>().spacing
         );
 }
    /// <summary>
    ///
    /// Add additional height for scrollContainer with each overflowing entry
    /// this will allow the scrollbar to calculate it
    /// </summary>
    void HandleContainerSizing(Script_Entry e)
    {
        if (game.entries.Length == overflowEntriesCount)
        {
            scrollContainer.sizeDelta = new Vector2(scrollContainer.sizeDelta.x, overflowStartingHeight);
        }
        else if (game.entries.Length > overflowEntriesCount)
        {
            IncreaseScrollContainerHeightByEntryHeight(e);
        }
        else
        {
            InitializeState();
        }

        scrollbar.value = 1f;
    }
    public void SaveEntries(Model_SaveData data)
    {
        Model_Entry[] entriesData = new Model_Entry[game.entries.Length];

        // get entries from game, create a model for each
        for (var i = 0; i < entriesData.Length; i++)
        {
            Script_Entry e = game.entries[i];
            entriesData[i] = new Model_Entry(
                e.nameId,
                e.text,
                e.headline,
                e.timestamp.ToBinary()
                );
        }

        data.entriesData = entriesData;
    }
    public Model_SavedGameTitleData Create()
    {
        string run       = game.Run.dayName;
        float  clockTime = Script_ClockManager.Control.ClockTime;

        string name = Script_Names.Player;

        Script_Entry lastEntry = game.entryManager.GetLastEntry();
        string       headline  = lastEntry ? lastEntry.headline : string.Empty;

        long  date     = lastEntry ? lastEntry.timestamp.ToBinary() : DateTime.Now.ToBinary();
        float playTime = game.totalPlayTime;

        return(new Model_SavedGameTitleData(
                   run,
                   clockTime,
                   name,
                   headline,
                   date,
                   playTime
                   ));
    }
    public void AddEntry(
        string nameId,
        string text,
        DateTime timestamp,
        string headline
        )
    {
        Script_Entry existingEntry = GetExistingEntry(nameId);

        if (existingEntry != null)
        {
            EditEntry(existingEntry, text, timestamp);
            return;
        }

        // instantiate Entry
        Script_Entry e = Instantiate(entryPrefab, Vector3.zero, Quaternion.identity);

        e.transform.SetParent(entriesParent, false);

        int Id = game.entries.Length;

        print($"adding headline: {headline}; my Id: {Id}");
        e.Setup(Id, nameId, text, timestamp, headline);
        e.GetComponent <Script_EntryOnSelect>().Setup(entriesViewController);

        // update game refs to entries
        Script_Entry[] newEntries = new Script_Entry[game.entries.Length + 1];
        newEntries = Script_Utils.CopyArrayElements(game.entries, newEntries);
        newEntries[newEntries.Length - 1] = e;
        game.UpdateEntries(newEntries);

        // set explicit navigation and container sizing
        LinkNavigationWithPrevious(Id, entriesParent);
        HandleContainerSizing(e);

        // update EntriesCanvasState if was empty canvas before
        entriesViewController.UpdateCanvasState();
    }
 public void EditEntry(Script_Entry e, string newText, DateTime newTimestamp)
 {
     e.Edit(newText, newTimestamp);
 }