示例#1
0
        /// <summary>
        /// When cards are added or removed from the folder set a flag
        /// </summary>
        private static void CardEvent(CardEventType eventType)
        {
            //Needs to be locked since dumping a bunch of cards in the folder will trigger this event a whole bunch of times that all run at once
            rwlock.EnterWriteLock();

            try
            {
                EventType = eventType;

                //Start a timer which will be reset every time a card is added/removed for when the user dumps in a whole bunch at once
                //Once the timer elapses, a flag will be set to do the refresh, which will then happen on the next Update.
                if (CardTimer == null)
                {
                    //First file, start timer
                    CardTimer          = new Timer(1000);
                    CardTimer.Elapsed += (o, ee) => DoRefresh = true;
                    CardTimer.Start();
                }
                else
                {
                    //Subsequent file, reset timer
                    CardTimer.Stop();
                    CardTimer.Start();
                }
            }
            catch (Exception ex)
            {
                Logger.Log(LogLevel.Error, ex);
                CardTimer?.Dispose();
            }

            rwlock.ExitWriteLock();
        }
示例#2
0
 private void NotifyCardEvent(CardEventType type)
 {
     if (OnCardEvent != null)
     {
         OnCardEvent(type, _card);
     }
 }
        /// <summary>
        /// When cards are added or removed from the folder set a flag
        /// </summary>
        private static void CardEvent(string filePath, CardEventType eventType)
        {
            if (filePath.Contains("_autosave"))
            {
                return;
            }

            //Needs to be locked since dumping a bunch of cards in the folder will trigger this event a whole bunch of times that all run at once
            rwlock.EnterWriteLock();

            try
            {
                EventType = eventType;

                //Start a timer which will be reset every time a card is added/removed for when the user dumps in a whole bunch at once
                //Once the timer elapses, a flag will be set to do the refresh, which will then happen on the next Update.

                //If the time is already running, dispose of it so it can be restarted
                if (CardTimer != null)
                {
                    CardTimer.Dispose();
                }

                CardTimer          = new Timer(1000);
                CardTimer.Elapsed += (o, ee) => DoRefresh = true;
                CardTimer.Start();
            }
            catch (Exception ex)
            {
                Logger.Log(LogLevel.Error, ex);
                CardTimer?.Dispose();
            }

            rwlock.ExitWriteLock();
        }
示例#4
0
 /// <summary>
 /// On a game update run the actual refresh. It must be run from an update or it causes all sorts of errors.
 /// </summary>
 private void Update()
 {
     if (EventFromCharaMaker && DoRefresh)
     {
         //If we saved or deleted a card from the chara maker itself there's no need to refresh, the game will handle that.
         CardTimer.Dispose();
         EventFromCharaMaker = false;
         DoRefresh           = false;
     }
     else if (DoRefresh)
     {
         RefreshList();
         CardTimer.Dispose();
         DoRefresh = false;
     }
     if (Input.GetKeyDown(KeyCode.F5) && MakerAPI.InsideAndLoaded)
     {
         EventType = CardEventType.CharaMakerCharacter;
         RefreshList();
     }
 }
示例#5
0
 public CardEvent(CardEventType eventType) : base(eventType.ToString())
 {
 }