Example #1
0
        private unsafe void DrawPersonalPage(uint *bmpAddress, int bmpWidth, int bmpHeight)
        {
            const float winX         = 0.08f;
            const float winY         = 0.15f;
            const float winW         = 0.75f - winX;
            const float winH         = 0.93f - winY;
            const float leftColX     = winX + 0.03f;
            const float textStartY   = winY + 0.05f;
            const float textSpacingY = 0.1f;

            RenderUtils.FillRoundedRectangle(bmpAddress, bmpWidth, bmpHeight, winX, winY, winX + winW, winY + winH, 15, RenderUtils.Color(145, 225, 225, 255));

            Font leftColFont = Font.Default;

            uint[] leftColColors   = Font.DefaultBlack_I;
            uint[] highlightColors = Font.DefaultRed_I;

            void Place(int i, int xOff, string leftColStr, uint[] colors)
            {
                float y = textStartY + (i * textSpacingY);

                leftColFont.DrawString(bmpAddress, bmpWidth, bmpHeight, (int)(bmpWidth * leftColX) + xOff, (int)(bmpHeight * y), leftColStr, colors);
            }

            PBENature  nature;
            DateTime   met;
            MapSection loc;
            byte       metLvl;
            uint       pid;
            IVs        ivs;

            if (_pPkmn is not null)
            {
                nature = _pPkmn.Nature;
                met    = _pPkmn.MetDate;
                loc    = _pPkmn.MetLocation;
                metLvl = _pPkmn.MetLevel;
                pid    = _pPkmn.PID;
                ivs    = _pPkmn.IndividualValues;
            }
            else if (_pcPkmn is not null)
            {
                nature = _pcPkmn.Nature;
                met    = _pcPkmn.MetDate;
                loc    = _pcPkmn.MetLocation;
                metLvl = _pcPkmn.MetLevel;
                pid    = _pcPkmn.PID;
                ivs    = _pcPkmn.IndividualValues;
            }
            else
            {
                PartyPokemon pPkmn = _bPkmn.PartyPkmn;
                nature = pPkmn.Nature;
                met    = pPkmn.MetDate;
                loc    = pPkmn.MetLocation;
                metLvl = pPkmn.MetLevel;
                pid    = pPkmn.PID;
                ivs    = pPkmn.IndividualValues;
            }

            string    characteristic = Characteristic.GetCharacteristic(pid, ivs) + '.';
            PBEFlavor?flavor         = PBEDataUtils.GetLikedFlavor(nature);

            // Nature
            string str = PBELocalizedString.GetNatureName(nature).English + ' ';

            Place(0, 0, str, highlightColors);
            leftColFont.MeasureString(str, out int strW, out _);
            str = "nature.";
            Place(0, strW, str, leftColColors);
            // Met date
            str = met.ToString("MMMM dd, yyyy");
            Place(1, 0, str, leftColColors);
            // Met location
            str = loc.ToString();
            Place(2, 0, str, highlightColors);
            // Met level
            str = string.Format("Met at Level {0}.", metLvl);
            Place(3, 0, str, leftColColors);
            // Characteristic
            str = characteristic;
            Place(5, 0, str, leftColColors);
            // Flavor
            if (flavor.HasValue)
            {
                str = "Likes ";
                Place(6, 0, str, leftColColors);
                leftColFont.MeasureString(str, out strW, out _);
                str = flavor.Value.ToString() + ' ';
                Place(6, strW, str, highlightColors);
                leftColFont.MeasureString(str, out int strW2, out _);
                str = "food.";
                Place(6, strW + strW2, str, leftColColors);
            }
            else
            {
                str = "Likes all food.";
                Place(6, 0, str, leftColColors);
            }
        }