예제 #1
0
        private Image RenderTypeZero()
        {
            string topLine = string.Empty, bottomLine = string.Empty;

            ResetParameters();

            for (var i = 0; i <= LineIndex; i++)
            {
                var line = GetParsedCommands(File.MessageList[messageIndex].MessageLines[i]);

                if (line.Contains("$Nu") && hasPerms)
                {
                    line = line.Replace("$Nu", PlayerName);
                }

                line = line.Replace(Environment.NewLine, "\n");

                if (charActive == charA)
                {
                    topLine = line;
                }
                else
                {
                    bottomLine = line;
                }
            }

            //Hard coded dimensions
            var    box       = new Bitmap(400, 240);
            Bitmap topBox    = new Bitmap(1, 1),
                   bottomBox = new Bitmap(1, 1);

            if (topLine != string.Empty && charA != string.Empty)
            {
                topBox = (Bitmap)(TextBoxes[TextboxIndex].Clone());
                using (var g = Graphics.FromImage(topBox))
                {
                    g.DrawImage(AssetGeneration.GetCharacterBuImage(charA, emotionA, colorA, true, PlayerGender),
                                new Point(2, 3));
                    g.DrawImage(
                        AssetGeneration.DrawString(new Bitmap(260, 50), topLine, 0, 22, Color.FromArgb(68, 8, 0)),
                        new Point(76, 0));
                }
            }

            if (bottomLine != string.Empty && charB != string.Empty)
            {
                bottomBox = (Bitmap)TextBoxes[TextboxIndex].Clone();
                using (var g = Graphics.FromImage(bottomBox))
                {
                    g.DrawImage(AssetGeneration.GetCharacterBuImage(charB, emotionB, colorB, true, PlayerGender),
                                new Point(2, 3));
                    g.DrawImage(
                        AssetGeneration.DrawString(new Bitmap(282, 50), bottomLine, 0, 22, Color.FromArgb(68, 8, 0)),
                        new Point(76, 0));
                }
            }

            using (var g = Graphics.FromImage(box))
            {
                if (LineIndex < File.MessageList[messageIndex].MessageLines.Count - 1)
                {
                    using (var g2 = Graphics.FromImage(charActive == charA ? topBox : bottomBox))
                    {
                        g2.DrawImage(Resources.KeyPress, new Point(TextBoxes[TextboxIndex].Width - 30, 32));
                    }
                }

                if (enableBackgrounds)
                {
                    g.DrawImage(BackgroundImage, new Point(0, 0));
                }
                g.DrawImage(topBox, new Point(10, 3));
                g.DrawImage(bottomBox, new Point(10, box.Height - bottomBox.Height + 2));

                if (topLine != string.Empty && charA != string.Empty)
                {
                    var topName    = names.ContainsKey(charA) ? names[charA] : (charA == "username" ? PlayerName : charA);
                    var nameLen    = AssetGeneration.GetLength(topName);
                    var topNameBox =
                        (Bitmap)
                        AssetGeneration.DrawString(Resources.NameBox, topName, Resources.NameBox.Width / 2 - nameLen / 2,
                                                   16, Color.FromArgb(253, 234, 177)); //Center name in NameBox
                    g.DrawImage(topNameBox, new Point(7, topBox.Height - (topNameBox.Height - 20)));
                }

                if (string.IsNullOrEmpty(bottomLine) || string.IsNullOrEmpty(charB))
                {
                    return(box);
                }
                {
                    var bottomName = names.ContainsKey(charB)
                        ? names[charB]
                        : (charB == "username" ? PlayerName : charB);
                    var nameLen       = AssetGeneration.GetLength(bottomName);
                    var bottomNameBox =
                        (Bitmap)
                        AssetGeneration.DrawString(Resources.NameBox, bottomName,
                                                   Resources.NameBox.Width / 2 - nameLen / 2, 16, Color.FromArgb(253, 234, 177));
                    g.DrawImage(bottomNameBox, new Point(7, box.Height - bottomBox.Height - 14));
                }
            }
            return(box);
        }
예제 #2
0
        private Image RenderTypeOne(string line)
        {
            //Probably shouldn't be hard-coded
            var box = new Bitmap(400, 240);
            var tb  = (Bitmap)TextBoxes[TextboxIndex].Clone();

            //Generate text image from string
            if (line.Contains("$Nu") && hasPerms)
            {
                line = line.Replace("$Nu", PlayerName);
            }

            line = line.Replace(Environment.NewLine, "\n");

            //Draw the line's text
            var text = (Bitmap)AssetGeneration.DrawString(new Bitmap(310, 50), line, 0, 22, Color.FromArgb(68, 8, 0));

            using (var g = Graphics.FromImage(tb))
            {
                g.DrawImage(text, new Point(29, 0));
            }

            //Name box
            var name = names.ContainsKey(charActive)
                ? names[charActive]
                : (charActive == "username" ? PlayerName : charActive);
            var nameLength = AssetGeneration.GetLength(name);
            var nb         =
                (Bitmap)
                AssetGeneration.DrawString(Resources.NameBox, name, Resources.NameBox.Width / 2 - nameLength / 2, 16,
                                           Color.FromArgb(253, 234, 177)); //Center name in NameBox

            using (var g = Graphics.FromImage(box))
            {
                if (enableBackgrounds)
                {
                    g.DrawImage(BackgroundImage, new Point(0, 0));
                }

                if (charA != string.Empty)
                {
                    var ca = AssetGeneration.GetCharacterStageImage(charA, emotionA, colorA, true, PlayerGender);
                    g.DrawImage((charActive == charA) ? ca : AssetGeneration.Fade(ca),
                                new Point(-28, box.Height - ca.Height + 14));
                }

                if (charB != string.Empty)
                {
                    var cb = AssetGeneration.GetCharacterStageImage(charB, emotionB, colorB, false, PlayerGender);
                    g.DrawImage((charActive == charB) ? cb : AssetGeneration.Fade(cb),
                                new Point(box.Width - cb.Width + 28, box.Height - cb.Height + 14));
                }

                g.DrawImage(tb, new Point(10, box.Height - tb.Height + 2));

                if (charActive != string.Empty)
                {
                    g.DrawImage(nb,
                                charActive == charB
                            ? new Point(box.Width - nb.Width - 6, box.Height - tb.Height - 14)
                            : new Point(7, box.Height - tb.Height - 14));
                }

                if (LineIndex > File.MessageList[messageIndex].MessageLines.Count - 1)
                {
                    g.DrawImage(Resources.KeyPress, new Point(box.Width - 33, box.Height - tb.Height + 32));
                }
            }

            return(box);
        }