Exemplo n.º 1
0
        public string GenerateRaidF(ClientSession player)
        {
            string result = $"raidf ";

            result += Leader == player ? "0 " : "2 ";
            result += $"{RaidDesign} ";
            result  = Characters.Aggregate(result, (current, session) => current + $"{session.Character.CharacterId} ");
            return(result.Remove(result.Length - 1));
        }
Exemplo n.º 2
0
        public string GenerateRaid(ClientSession player)
        {
            if (player == null)
            {
                return("");
            }
            string result = $"raid ";

            result += Leader == player ? "0" : "2";
            result  = Characters.Aggregate(result, (current, session) => current + $" {session.Character.CharacterId}");
            return(result.Remove(result.Length - 1));
        }
Exemplo n.º 3
0
        public string GenerateRdlst()
        {
            string result = $"rdlst {LevelMinimum} {LevelMaximum} 0 ";

            result = Characters.Aggregate(result,
                                          (current, session) =>
                                          current +
                                          $"{session.Character.Level}." +
                                          $"{(session.Character.UseSp || session.Character.IsVehicled ? session.Character.Morph : -1)}." +
                                          $"{(short)session.Character.Class}.0.{session.Character.Name}.{(short)session.Character.Gender}." +
                                          $"{session.Character.CharacterId}.{session.Character.HeroLevel} ");
            return(result);
        }
Exemplo n.º 4
0
        public FontDescriptor(OutputConfiguration config, char[] characters, Font font)
        {
            Font         = font;
            OutConfig    = config;
            CodePageInfo = new CodePageInfo(config.CodePage);

            //
            // init char infos
            //
            Characters = characters.Select(c => new CharacterDescriptor(this, c)).ToArray();

            //
            // Find the widest bitmap size we are going to draw
            //
            Size largestBitmap = Characters.Aggregate(new Size(),
                                                      (size, chi) =>
            {
                return(new Size(
                           chi.SizeCharacter.Width > size.Width ? chi.SizeCharacter.Width : size.Width,
                           chi.SizeCharacter.Height > size.Height ? chi.SizeCharacter.Height : size.Height));
            });

            //
            // create bitmaps per characater
            //
            Characters.ToList().ForEach(c => c.GenerateOriginal(largestBitmap));

            //
            // iterate through all bitmaps and find the tightest common border. only perform
            // this if the configuration specifies
            //

            // this will contain the values of the tightest border around the characters
            Border tightestCommonBorder = Border.Empty;

            // only perform if padding type specifies
            if (OutConfig.paddingRemovalHorizontal == OutputConfiguration.PaddingRemoval.Fixed ||
                OutConfig.paddingRemovalVertical == OutputConfiguration.PaddingRemoval.Fixed ||
                OutConfig.paddingRemovalHorizontal == OutputConfiguration.PaddingRemoval.Clipped ||
                OutConfig.paddingRemovalVertical == OutputConfiguration.PaddingRemoval.Clipped)
            {
                // find the common tightest border
                tightestCommonBorder = Characters.ToList().
                                       Select <CharacterDescriptor, Border>(c => c.OriginalBorder)
                                       .Aggregate <Border, Border>(Border.Empty,
                                                                   (p1, p2) =>
                                                                   new Border(
                                                                       p1.Left <p2.Left?p1.Left : p2.Left,
                                                                                p1.Top <p2.Top?p1.Top : p2.Top,
                                                                                        p1.Right> p2.Right?p1.Right : p2.Right,
                                                                                p1.Bottom> p2.Bottom ? p1.Bottom : p2.Bottom)
                                                                   );
            }
            //
            // iterate thruogh all bitmaps and generate the bitmap we will convert to string
            // this means performing all manipulation (pad remove, flip)
            //

            // iterate over characters
            Characters.ToList().ForEach(c =>
            {
                // check if bitmap exists
                if (c.GenerateManipulatetBitmap(tightestCommonBorder))
                {
                    // create the page array for the character
                    c.GeneratePageArray();
                }
            });

            // populate font info
            populateFontInfoFromCharacters();

            GenerateStringsFromFontInfo();
        }
Exemplo n.º 5
0
        // generate the strings
        private void GenerateStringsFromFontInfo()
        {
            StringBuilder sourceText = new StringBuilder();
            StringBuilder headerText = new StringBuilder();

            if (OutConfig.addCommentVariableName)
            {
                // add source file header
                sourceText.AppendFormat("{0}" + OutConfig.nl + "{1} Font data for {2}" + OutConfig.nl + "{3}" + OutConfig.nl + OutConfig.nl,
                                        OutConfig.CommentStart,
                                        OutConfig.CommentBlockMiddle,
                                        getFontName(Font, false),
                                        OutConfig.CommentBlockEnd);

                // add source header
                sourceText.AppendFormat("{0}Character bitmaps for {1} {2}" + OutConfig.nl,
                                        OutConfig.CommentStart,
                                        getFontName(Font, false),
                                        OutConfig.CommentEnd);

                // add header file header
                headerText.AppendFormat("{0}Font data for {1} {2}" + OutConfig.nl,
                                        OutConfig.CommentStart,
                                        getFontName(Font, false),
                                        OutConfig.CommentEnd);
            }

            // get bitmap name
            string charBitmapVarName = String.Format(OutConfig.varNfBitmaps, getFontName(Font, true)) + "[]";

            // source var
            sourceText.AppendFormat("{0} = " + OutConfig.nl + "{{" + OutConfig.nl, charBitmapVarName);

            Characters.ToList().ForEach(chi => chi.GenerateCharacterDataDescriptorAndVisulazer());
            Characters.Aggregate(sourceText, (sb, chi) =>
            {
                // skip empty bitmaps
                if (chi.BitmapToGenerate == null)
                {
                    return(sb);
                }

                // now add letter array
                sourceText.Append(chi.Descriptor);
                // space out
                if (OutConfig.addCommentCharDescriptor && chi.Character != chi.ParentFontInfo.LastChar)
                {
                    // space between chars
                    sb.Append(OutConfig.nl);
                }

                return(sb);
            });

            // space out
            sourceText.Append("};" + OutConfig.nl + OutConfig.nl);

            //
            // Charater descriptor
            //
            // whether or not block lookup was generated
            bool blockLookupGenerated = false;

            // check if required by configuration
            if (OutConfig.generateLookupArray)
            {
                // generate the lookup array
                blockLookupGenerated = generateStringsFromCharacterDescriptorBlockList(sourceText, headerText);
            }
            //
            // Font descriptor
            //

            // according to config
            if (OutConfig.addCommentVariableName)
            {
                // result string
                sourceText.AppendFormat("{0}Font information for {1} {2}" + OutConfig.nl,
                                        OutConfig.CommentStart,
                                        getFontName(Font, false),
                                        OutConfig.CommentEnd);
            }

            // character name
            string fontInfoVarName = String.Format(OutConfig.varNfFontInfo, getFontName(Font, true));

            // add character array for header
            headerText.AppendFormat("extern {0};" + OutConfig.nl, fontInfoVarName);

            // the font character height
            string fontCharHeightString = "";

            // get character height sstring - displayed according to output configuration
            if (OutConfig.descFontHeight != OutputConfiguration.DescriptorFormat.DontDisplay)
            {
                // convert the value
                fontCharHeightString = String.Format("\t{0}, {1} Character height{2}" + OutConfig.nl,
                                                     MyExtensions.ConvertValueByDescriptorFormat(OutConfig.descFontHeight, FixedAbsolutCharHeight),
                                                     OutConfig.CommentStart,
                                                     OutConfig.CommentEnd);
            }

            string fontCodePage = "";

            if (OutConfig.addCodePage)
            {
                fontCodePage = string.Format("\t{0}, {1} CodePage {3}{2}" + OutConfig.nl,
                                             OutConfig.CodePage,
                                             OutConfig.CommentStart,
                                             OutConfig.CommentEnd,
                                             CodePageInfo.GetCodepageName(OutConfig.CodePage));
            }

            string spaceCharacterPixelWidthString = "";

            // get space char width, if it is up to driver to generate
            if (!OutConfig.generateSpaceCharacterBitmap)
            {
                // convert the value
                spaceCharacterPixelWidthString = String.Format("\t{0}, {1} Width, in pixels, of space character{2}" + OutConfig.nl,
                                                               OutConfig.spaceGenerationPixels,
                                                               OutConfig.CommentStart,
                                                               OutConfig.CommentEnd);
            }

            // font info
            sourceText.AppendFormat("{2} =" + OutConfig.nl + "{{" + OutConfig.nl +
                                    "{3}" +
                                    "\t{4}, {0} First character '{9}'{1}" + OutConfig.nl +
                                    "\t{5}, {0} Last character '{10}'{1}" + OutConfig.nl +
                                    "{6}" +
                                    "{7}" +
                                    "\t{8}, {0} Character bitmap array{1}" + OutConfig.nl +
                                    "{11}" +
                                    "}};" + OutConfig.nl,
                                    OutConfig.CommentStart,
                                    OutConfig.CommentEnd,
                                    fontInfoVarName,
                                    fontCharHeightString,
                                    getCharacterDisplayString(CodePageInfo, FirstChar),
                                    getCharacterDisplayString(CodePageInfo, LastChar),
                                    spaceCharacterPixelWidthString,
                                    getFontInfoDescriptorsString(blockLookupGenerated, OutConfig, Font),
                                    MyExtensions.GetVariableNameFromExpression(String.Format(OutConfig.varNfBitmaps, getFontName(Font, true))),
                                    FirstChar,
                                    LastChar,
                                    fontCodePage);

            // add the appropriate entity to the header
            if (blockLookupGenerated)
            {
                // add block lookup to header
                headerText.AppendFormat("extern const FONT_CHAR_INFO_LOOKUP {0}[];" + OutConfig.nl, getCharacterDescriptorArrayLookupDisplayString(Font));
            }
            else
            {
                // add block lookup to header
                headerText.AppendFormat("extern {0}[];" + OutConfig.nl, String.Format(OutConfig.varNfCharInfo, getFontName(Font, true)));
            }

            TextSource = sourceText.ToString();
            TextHeader = headerText.ToString();
        }