Beispiel #1
0
        private void SetTexture()
        {
            //
            //  load the text for the selected Bubble type
            //
            _bThoughtLoaded = _IsThought.Value;

            lock (oBackground)
            {
                if (_IsThought.Value)
                {
                    sbBackground = new StardewBitmap(Path.Combine(ModPath, "think_bubble.png"));
                }
                else
                {
                    sbBackground = new StardewBitmap(Path.Combine(ModPath, "talk_bubble.png"));
                }

                sbBackground.ResizeImage(300, 200);
                if (Game1.IsMultiplayer)
                {
                    //
                    //  store image data to send to other players
                    //
                    _BubbleImageData = sbBackground.TextureNetArray();
                }
            }
        }
Beispiel #2
0
        public override void draw(SpriteBatch b)
        {
            try
            {
                Vector2 origin     = new Vector2(8f, 8f);
                Vector2 bgPosition = new Vector2(Position.X - 100, Position.Y - 265);
                Vector2 txtPosition;
                if (sbBackground == null || _bThoughtLoaded != _IsThought.Value)
                {
#if LOG_DEBUG
                    monitor.Log($"Loading BG. Data length: {_BubbleImageData.Count}", LogLevel.Info);
#endif
                    try
                    {
                        _BubbleImageData.Tick();
                        sbBackground    = new StardewBitmap(_BubbleImageData);
                        _bThoughtLoaded = _IsThought.Value;
                    }
                    catch (Exception ex)
                    {
                        //
                        //  if custom image fails, fallback to standard
                        //
#if LOG_DEBUG
                        monitor.Log($"Error loading BG: {ex}", LogLevel.Error);
#endif
                        SetTexture();
                    }
                }
                if (_IsThought.Value)
                {
                    txtPosition = new Vector2(Position.X - 80, Position.Y - 230);
                }
                else
                {
                    txtPosition = new Vector2(Position.X - 100, Position.Y - 265);
                }

                // float num = 1;
                float num2 = Math.Max(0f, (float)((bgPosition.Y + 1) - 24) / 10000f) + (float)bgPosition.X * 1E-05f;

                b.Draw(sbBackground.Texture(), Game1.GlobalToLocal(Game1.viewport, bgPosition), new Rectangle(0, 0, sbBackground.Width, sbBackground.Height), Color.White, 0f, origin, 1f, SpriteEffects.None, 0.99999f);

                if (lTextLines == null)
                {
#if LOG_DEBUG
                    monitor.Log($"_BubbleText: '{_BubbleText.Value}'", LogLevel.Info);
#endif
                    FormatText();
                }
                foreach (string line in lTextLines)
                {
                    Utility.drawTextWithShadow(b, line, Game1.smallFont, Game1.GlobalToLocal(Game1.viewport, txtPosition), Color.Black, 1f, 1f, -1, -1, 0.0f, 3);
                    txtPosition = new Vector2(txtPosition.X, txtPosition.Y + 25);
                }
            }
            catch { }
        }
Beispiel #3
0
 public BubbleGuyManager(string sSavePath, string sSpriteDir, IModHelper helper, IMonitor monitor, bool bIsMaster)
 {
     IsMaster         = bIsMaster;
     oHelper          = helper;
     oMonitor         = monitor;
     Recorder         = new BubbleRecorder(sSavePath);
     sSpirteDirectory = sSpriteDir;
     if (((Game1.IsMultiplayer && Game1.IsMasterGame) || (!Game1.IsMultiplayer)) && bIsMaster)
     {
         //
         //  the master game will handle the cleanups
         //
         helper.Events.GameLoop.SaveLoaded          += GameLoop_SaveLoaded;
         helper.Events.GameLoop.Saving              += GameLoop_Saving;
         helper.Events.Multiplayer.PeerDisconnected += Multiplayer_PeerDisconnected;
         monitor.Log("Bubble guy master game hooks added.", LogLevel.Info);
     }
     if (bIsMaster)
     {
         helper.Events.Player.Warped += Player_Warped;
     }
     //
     //  load default or custom bubble backgrounds
     //
     if (File.Exists(Path.Combine(sSpirteDirectory, "custom_think_bubble.png")))
     {
         monitor.Log("Using custom Think bubble", LogLevel.Info);
         sbThinkBubble = new StardewBitmap(Path.Combine(sSpirteDirectory, "custom_think_bubble.png"));
     }
     else
     {
         sbThinkBubble = new StardewBitmap(Path.Combine(sSpirteDirectory, "think_bubble.png"));
     }
     if (File.Exists(Path.Combine(sSpirteDirectory, "custom_talk_bubble.png")))
     {
         monitor.Log("Using custom Talk bubble", LogLevel.Info);
         try
         {
             sbTalkBubble = new StardewBitmap(Path.Combine(sSpirteDirectory, "custom_talk_bubble.png"));
         }
         catch (Exception ex)
         {
             monitor.Log("Failed to load custom talk bubble, using default.  See logs for details", LogLevel.Info);
             monitor.Log($"Custome talk bubble error: {ex}", LogLevel.Debug);
             sbTalkBubble = new StardewBitmap(Path.Combine(sSpirteDirectory, "talk_bubble.png"));
         }
     }
     else
     {
         sbTalkBubble = new StardewBitmap(Path.Combine(sSpirteDirectory, "talk_bubble.png"));
     }
     txTalkBubble  = sbTalkBubble.Texture();
     txThinkBubble = sbThinkBubble.Texture();
 }
Beispiel #4
0
        public BubbleGuy(bool bIsThought, string sText, Texture2D background) : this()
        {
            SDV_Logger.DumpObject("background", background);
            //ModPath.Set(sModDir);
            _IsThought.Value = bIsThought;
            _IsThought.MarkDirty();
            _PlayerId.Value = Game1.player.UniqueMultiplayerID;
            _PlayerId.MarkDirty();
            sbBackground = new StardewBitmap(background);
            sbBackground.ResizeImage(300, 200);
            sbBackground.FillArray(ref _BubbleImageData);
#if LOG_DEBUG
            monitor.Log($"_BubbleImageData length: {_BubbleImageData.Count}", LogLevel.Info);
#endif
            _BubbleImageData.MarkDirty();
            Text            = sText;
            _bThoughtLoaded = _IsThought.Value;
        }
Beispiel #5
0
        private void SetTexture()
        {
            _bThoughtLoaded = _IsThought.Value;

            lock (oBackground)
            {
                if (_IsThought.Value)
                {
                    sbBackground = new StardewBitmap(Path.Combine(ModPath, "think_bubble.png"));
                }
                else
                {
                    sbBackground = new StardewBitmap(Path.Combine(ModPath, "talk_bubble.png"));
                }
                sbBackground.ResizeImage(300, 200);
                _BubbleImageData = sbBackground.TextureNetArray();

                //sbBackground.Save("bubbleguy.png");
            }
        }
Beispiel #6
0
        public override void draw(SpriteBatch b)
        {
            try
            {
                Vector2 origin     = new Vector2(8f, 8f);
                Vector2 bgPosition = new Vector2(Position.X - 100, Position.Y - 265);
                Vector2 txtPosition;
                if (sbBackground == null || _bThoughtLoaded != _IsThought.Value)
                {
                    //
                    //  this should only occur when the bubble is
                    //  instantiated on a remote client.
                    //  use remote image data synched via netfields
                    //
#if StardewWeb
                    SMAPI.ModDetails.Monitor.Log("Loading BG", LogLevel.Info);
#endif
                    try
                    {
                        //
                        //  use custom hack to move background images
                        //  between players
                        //
                        sbBackground    = new StardewBitmap(_BubbleImageData);
                        _bThoughtLoaded = _IsThought.Value;
                    }
                    catch
                    {
                        //
                        //  if custom image fails, fallback to standard
                        //
                        SetTexture();
                    }
                }
                if (_IsThought.Value)
                {
                    txtPosition = new Vector2(Position.X - 80, Position.Y - 230);
                }
                else
                {
                    txtPosition = new Vector2(Position.X - 100, Position.Y - 265);
                }

                float num2 = Math.Max(0f, (float)((bgPosition.Y + 1) - 24) / 10000f) + (float)bgPosition.X * 1E-05f;

                b.Draw(sbBackground.Texture(), Game1.GlobalToLocal(Game1.viewport, bgPosition), new Rectangle(0, 0, sbBackground.Width, sbBackground.Height), Color.White, 0f, origin, 1f, SpriteEffects.None, 0.99999f);

                if (lTextLines == null)
                {
                    //
                    //  this is a remote client, get text
                    //  manually setup text
                    //
#if StardewWeb
                    SMAPI.ModDetails.Monitor.Log($"_BubbleText: '{_BubbleText.Value}'", LogLevel.Info);
#endif
                    FormatText();
                }
                foreach (string line in lTextLines)
                {
                    Utility.drawTextWithShadow(b, line, Game1.smallFont, Game1.GlobalToLocal(Game1.viewport, txtPosition), Color.Black, 1f, 1f, -1, -1, 0.0f, 3);
                    txtPosition = new Vector2(txtPosition.X, txtPosition.Y + 25);
                }
            }
            catch { }
        }
Beispiel #7
0
 public void SetTalkBubble(Texture2D talkbubble)
 {
     sbTalkBubble = new StardewBitmap(talkbubble);
 }
Beispiel #8
0
 public void SetThinkBubble(Texture2D thinkbubble)
 {
     sbThinkBubble = new StardewBitmap(thinkbubble);
 }