Register for your free account! | Forgot your password?

Go Back   elitepvpers > MMORPGs > Flyff > Flyff Private Server
You last visited: Today at 00:36

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



System announcement garbled code

Discussion on System announcement garbled code within the Flyff Private Server forum part of the Flyff category.

Reply
 
Old   #1
 
elite*gold: 0
Join Date: Jan 2020
Posts: 78
Received Thanks: 0
System announcement garbled code

Other areas are displaying normally - only one system announcement has garbled text. But English letters and numbers display system announcements normally






Code:
#ifdef __CLIENT
#include "PlayerData.h"
#include "resdata.h"
#include "DPClient.h"
extern CDPClient g_DPlay;
#endif

namespace AnnounceRenderer {

#ifdef __CLIENT
    void CAnnounceRenderer::AddTopAnnounce(const std::string strAnnounce, const std::uint32_t nPlayerIndex) {
        AnnounceData data;

        auto pOldFont = g_Neuz.m_2DRender.GetFont();
        g_Neuz.m_2DRender.SetFont(CWndBase::m_Theme.m_pFontText);

        CEditString str;
        str.SetParsingString(strAnnounce.c_str());

        auto nRightPosition = g_Neuz.m_2DRender.m_clipRect.Width();

        std::string character;

        std::uint16_t index = 0;
        for (auto const& it : strAnnounce) {
            textData chardata;
            chardata.m_char = it;


            CEditString strEdit;
            strEdit.SetParsingString(character.c_str());

            chardata.m_nPositionX = nRightPosition + g_Neuz.m_2DRender.m_pFont->GetTextExtent_EditString(strEdit).cx;
            data.m_strAnnounce.push_back(chardata);
            character.push_back(it);
            index++;

        }

        g_Neuz.m_2DRender.SetFont(pOldFont);

        data.m_nPlayerCasterIndex = nPlayerIndex;
        m_vTopAnnounces.push_back(data);
    }
    
    void CAnnounceRenderer::AddCenterAnnounce(const std::string strAnnounce, const std::uint32_t nPlayerIndex) {
        AnnounceData data;

        auto pOldFont = g_Neuz.m_2DRender.GetFont();
        g_Neuz.m_2DRender.SetFont(CWndBase::m_Theme.m_pFontText);


        CEditString str;
        str.SetParsingString(strAnnounce.c_str());

        const std::uint16_t nRectWidth = 450;
        int pointX = (g_Neuz.m_2DRender.m_clipRect.Width() / 2) - (nRectWidth / 2);
        //int pointX = (g_Neuz.m_2DRender.m_clipRect.Width() / 2) - (g_Neuz.m_2DRender.m_pFont->GetTextExtent_EditString(str).cx / 2);

        auto nRightPosition = pointX + nRectWidth;

        std::string character;

        std::uint16_t index = 0;
        for (auto const& it : strAnnounce) {
            textData chardata;
            chardata.m_char = it;


            CEditString strEdit;
            strEdit.SetParsingString(character.c_str());

            chardata.m_nPositionX = nRightPosition + g_Neuz.m_2DRender.m_pFont->GetTextExtent_EditString(strEdit).cx;
            data.m_strAnnounce.push_back(chardata);
            character.push_back(it);
            index++;

        }

        g_Neuz.m_2DRender.SetFont(pOldFont);

        data.m_nPlayerCasterIndex = nPlayerIndex;
        m_vCenteredAnnounces.push_back(data);
    }

    bool CAnnounceRenderer::OnRightClickUp(UINT nFlags, CPoint point)
    {

        if (g_pPlayer == nullptr) return false;

        if (m_vTopAnnounces.empty()) return false;

        auto itAnnounce = m_vTopAnnounces.begin();


        if (itAnnounce->m_strAnnounce.empty()) return false;

        auto nLeftPoint = itAnnounce->m_strAnnounce.front().m_nPositionX;
        auto nRightPoint = itAnnounce->m_strAnnounce.back().m_nPositionX;

        CRect rect = CRect(nLeftPoint, 5, nRightPoint, 25);

        if (rect.PtInRect(point))
        {
            if (itAnnounce->m_nPlayerCasterIndex == 0) return false;
            if (itAnnounce->m_nPlayerCasterIndex == g_pPlayer->m_idPlayer)
            {
                g_WndMng.PutString("You cannot send messages to your own character !", nullptr, 0xFFFF0000);
                return false;
            }


            CWndMessage* pWndMessage = g_WndMng.OpenMessage(CPlayerDataCenter::GetInstance()->GetPlayerString(itAnnounce->m_nPlayerCasterIndex));
            return true;
        }


        return false;
    }

    void CAnnounceRenderer::ProcessAnnounce(std::vector<AnnounceData>& vAnnounce) {
        if (vAnnounce.empty()) return;


        __time64_t         tTimeLeft;
        __time64_t         tCurrentTick = GetTickCount();
        auto itAnnounce = vAnnounce.begin();

        if (itAnnounce->m_tDelay == 0) return;

        tTimeLeft = itAnnounce->m_tDelay - tCurrentTick;

        if (tTimeLeft < 1000)
        {
            itAnnounce->m_nAlpha -= ((DOUBLE)tTimeLeft * 0.001);
        }
        else if (REMOVE_DELAY - tTimeLeft <= 500)
        {
            itAnnounce->m_nAlpha -= ((DOUBLE)tTimeLeft * 0.002);
        }

        if (itAnnounce->m_nAlpha <= 0)
            vAnnounce.erase(itAnnounce);
    }


    BOOL CAnnounceRenderer::Process()
    {
        ProcessAnnounce(m_vCenteredAnnounces);
        ProcessAnnounce(m_vTopAnnounces);
        return true;
    }

    void CAnnounceRenderer::RenderRectangles(C2DRender* p2DRender, const CRect &drawRect, const std::uint32_t  nAlpha, const std::uint32_t  nOffset)
    {
        /** Left of Rect **/
        p2DRender->RenderFillRect(CRect(drawRect.left - nOffset, drawRect.top, drawRect.left, drawRect.bottom), D3DCOLOR_ARGB(0, 0, 0, 0), D3DCOLOR_ARGB(nAlpha, 0, 0, 0), D3DCOLOR_ARGB(0, 0, 0, 0), D3DCOLOR_ARGB(nAlpha, 0, 0, 0));
        /** Center of Rect **/
        p2DRender->RenderFillRect(CRect(drawRect.left, drawRect.top, drawRect.right, drawRect.bottom), D3DCOLOR_ARGB(nAlpha, 0, 0, 0), D3DCOLOR_ARGB(nAlpha, 0, 0, 0), D3DCOLOR_ARGB(nAlpha, 0, 0, 0), D3DCOLOR_ARGB(nAlpha, 0, 0, 0));
        /** Right of rect **/
        p2DRender->RenderFillRect(CRect(drawRect.right, drawRect.top, drawRect.right + nOffset, drawRect.bottom), D3DCOLOR_ARGB(nAlpha, 0, 0, 0), D3DCOLOR_ARGB(0, 0, 0, 0), D3DCOLOR_ARGB(nAlpha, 0, 0, 0), D3DCOLOR_ARGB(0, 0, 0, 0));

        p2DRender->RenderFillRect(CRect(drawRect.left - nOffset, drawRect.top - 2, drawRect.left, drawRect.top), D3DCOLOR_ARGB(0, 246, 207, 77), D3DCOLOR_ARGB(nAlpha, 246, 207, 77), D3DCOLOR_ARGB(0, 246, 207, 77), D3DCOLOR_ARGB(nAlpha, 246, 207, 77));
        p2DRender->RenderFillRect(CRect(drawRect.left, drawRect.top - 2, drawRect.right, drawRect.top), D3DCOLOR_ARGB(nAlpha, 246, 207, 77), D3DCOLOR_ARGB(nAlpha, 246, 207, 77), D3DCOLOR_ARGB(nAlpha, 246, 207, 77), D3DCOLOR_ARGB(nAlpha, 246, 207, 77));
        p2DRender->RenderFillRect(CRect(drawRect.right, drawRect.top - 2, drawRect.right + nOffset, drawRect.top), D3DCOLOR_ARGB(nAlpha, 246, 207, 77), D3DCOLOR_ARGB(0, 246, 207, 77), D3DCOLOR_ARGB(nAlpha, 246, 207, 77), D3DCOLOR_ARGB(0, 246, 207, 77));

        p2DRender->RenderFillRect(CRect(drawRect.left - nOffset, drawRect.bottom, drawRect.left, drawRect.bottom + 2), D3DCOLOR_ARGB(0, 246, 207, 77), D3DCOLOR_ARGB(nAlpha, 246, 207, 77), D3DCOLOR_ARGB(0, 246, 207, 77), D3DCOLOR_ARGB(nAlpha, 246, 207, 77));
        p2DRender->RenderFillRect(CRect(drawRect.left, drawRect.bottom, drawRect.right, drawRect.bottom + 2), D3DCOLOR_ARGB(nAlpha, 246, 207, 77), D3DCOLOR_ARGB(nAlpha, 246, 207, 77), D3DCOLOR_ARGB(nAlpha, 246, 207, 77), D3DCOLOR_ARGB(nAlpha, 246, 207, 77));
        p2DRender->RenderFillRect(CRect(drawRect.right, drawRect.bottom, drawRect.right + nOffset, drawRect.bottom + 2), D3DCOLOR_ARGB(nAlpha, 246, 207, 77), D3DCOLOR_ARGB(0, 246, 207, 77), D3DCOLOR_ARGB(nAlpha, 246, 207, 77), D3DCOLOR_ARGB(0, 246, 207, 77));
    }

    void CAnnounceRenderer::RenderTopAnnounces(C2DRender* p2DRender) {
        CPoint point = CPoint(50, 5);

        if (m_vTopAnnounces.empty()) return;
        auto itAnnounce = m_vTopAnnounces.begin();

        RenderRectangles(p2DRender, CRect(point.x, point.y - 5, g_Neuz.m_2DRender.m_clipRect.Width() - 50, point.y + 20), itAnnounce->m_nAlpha, 50);

        for (auto itLetter = itAnnounce->m_strAnnounce.begin(); itLetter != itAnnounce->m_strAnnounce.end();)
        {
            if (itLetter->m_nPositionX <= g_Neuz.m_2DRender.m_clipRect.Width())
            {
                std::string strLetter;
                strLetter.push_back(itLetter->m_char);
                CEditString string;
                string.SetParsingString(strLetter.c_str(), D3DCOLOR_ARGB(255, 254, 254, 254));
                p2DRender->TextOut_EditString(itLetter->m_nPositionX, point.y, string);
            }

            itLetter->m_nPositionX -= 2; // 2 before

            if (itLetter->m_nPositionX <= 0)
            {
                itLetter->m_nPositionX += g_Neuz.m_2DRender.m_clipRect.Width();

                itLetter->m_nRoundsCount++;

                if (itLetter->m_nRoundsCount >= MAX_ROUNDS_TOP)
                    itLetter = itAnnounce->m_strAnnounce.erase(itLetter);
                else
                    ++itLetter;
            }
            else
                ++itLetter;
        }

        if (itAnnounce->m_strAnnounce.empty()) {
            if (itAnnounce->m_tDelay == 0) {
                if (std::distance(itAnnounce, m_vTopAnnounces.end()) == 1)
                    itAnnounce->m_tDelay = GetTickCount() + REMOVE_DELAY;
                else
                    m_vTopAnnounces.erase(itAnnounce);
            }
        }
    }

    void CAnnounceRenderer::RenderCenterAnnounces(C2DRender* p2DRender) {
        auto offSetY = (184 * p2DRender->m_clipRect.Height() / 768) - 120;
        if (m_vCenteredAnnounces.empty()) return;

        auto itAnnounce = m_vCenteredAnnounces.begin();

        std::string strFull;

        for (auto const [character, position, count] : itAnnounce->m_strAnnounce) {
            strFull.push_back(character);
        }

        CEditString str;
        str.SetParsingString(strFull.c_str());

        const std::uint16_t nRectWidth = 450;

        CPoint point = CPoint((p2DRender->m_clipRect.Width() / 2) - (nRectWidth / 2), offSetY);

        RenderRectangles(p2DRender, CRect(point.x, point.y - 5, point.x + nRectWidth, point.y + 20), itAnnounce->m_nAlpha, 50);

        for (auto itLetter = itAnnounce->m_strAnnounce.begin(); itLetter != itAnnounce->m_strAnnounce.end();)
        {
            if (itLetter->m_nPositionX <= point.x + nRectWidth && itLetter->m_nPositionX >= point.x)
            {
                std::string strLetter;
                strLetter.push_back(itLetter->m_char);
                CEditString string;
                string.SetParsingString(strLetter.c_str(), D3DCOLOR_ARGB(255, 254, 254, 254));
                p2DRender->TextOut_EditString(itLetter->m_nPositionX, point.y, string);
            }

            itLetter->m_nPositionX -= 2; // 2 before

            if (std::distance(itLetter, itAnnounce->m_strAnnounce.end()) == 1 && itLetter->m_nPositionX <= point.x)
            {
                itAnnounce->m_strAnnounce.clear();
                break;
            }
            else
                ++itLetter;
        }

        if (itAnnounce->m_strAnnounce.empty()) {
            if (itAnnounce->m_tDelay == 0) {
            if( std::distance(itAnnounce, m_vCenteredAnnounces.end()) == 1)
                itAnnounce->m_tDelay = GetTickCount() + REMOVE_DELAY;
            else
                m_vCenteredAnnounces.erase(itAnnounce);
            }
        }
    }

    void CAnnounceRenderer::RenderAnnounces(C2DRender* p2DRender) {
        auto pOldFont = p2DRender->GetFont();
        p2DRender->SetFont(CWndBase::m_Theme.m_pFontText);
        RenderCenterAnnounces(p2DRender);
        RenderTopAnnounces(p2DRender);
    
        p2DRender->SetFont(pOldFont);
    }


    /********************/

    void CWndAnnouncement::SetUsedItem(const std::uint32_t nItemId) {
        m_nItemId = nItemId;
    }

    BOOL CWndAnnouncement::OnChildNotify(UINT message, UINT nID, LRESULT* pLResult)
    {
        switch (nID)
        {
        case WIDC_BUTTON:   
            std::string str = m_pWndEdit->GetString();

            if (str.length() < MAX_ANNOUNCE_SIZE)
            {
                g_DPlay.SendAnnouncement(str, m_nItemId);
                Destroy();
            }
            else
            {
                CString strError;
                strError.Format("Your announcement should not exceed %d name !", MAX_ANNOUNCE_SIZE);
                g_WndMng.OpenMessageBox(strError);
            }
            break;
            break;
        }

        return CWndNeuz::OnChildNotify(message, nID, pLResult);
    }

    void CWndAnnouncement::OnInitialUpdate()
    {
        CWndNeuz::OnInitialUpdate();

        m_pWndEdit = (CWndEdit*)GetDlgItem(WIDC_EDIT);

        MoveParentCenter();
    }
    BOOL CWndAnnouncement::Initialize(CWndBase* pWndParent, DWORD dwWndId)
    {
        return CWndNeuz::InitDialog(g_Neuz.GetSafeHwnd(), APP_ANNOUNCE, 0, CPoint(0, 0), pWndParent);
    }
#endif
}

#ifdef __CLIENT
AnnounceRenderer::CAnnounceRenderer g_AnnounceRenderer = AnnounceRenderer::CAnnounceRenderer();
#endif
siono01 is offline  
Old 03/07/2025, 14:16   #2



 
Flogolo's Avatar
 
elite*gold: 0
Join Date: Nov 2011
Posts: 4,885
Received Thanks: 799
Quote:
Originally Posted by siono01 View Post
Other areas are displaying normally - only one system announcement has garbled text. But English letters and numbers display system announcements normally






Code:
#ifdef __CLIENT
#include "PlayerData.h"
#include "resdata.h"
#include "DPClient.h"
extern CDPClient g_DPlay;
#endif

namespace AnnounceRenderer {

#ifdef __CLIENT
    void CAnnounceRenderer::AddTopAnnounce(const std::string strAnnounce, const std::uint32_t nPlayerIndex) {
        AnnounceData data;

        auto pOldFont = g_Neuz.m_2DRender.GetFont();
        g_Neuz.m_2DRender.SetFont(CWndBase::m_Theme.m_pFontText);

        CEditString str;
        str.SetParsingString(strAnnounce.c_str());

        auto nRightPosition = g_Neuz.m_2DRender.m_clipRect.Width();

        std::string character;

        std::uint16_t index = 0;
        for (auto const& it : strAnnounce) {
            textData chardata;
            chardata.m_char = it;


            CEditString strEdit;
            strEdit.SetParsingString(character.c_str());

            chardata.m_nPositionX = nRightPosition + g_Neuz.m_2DRender.m_pFont->GetTextExtent_EditString(strEdit).cx;
            data.m_strAnnounce.push_back(chardata);
            character.push_back(it);
            index++;

        }

        g_Neuz.m_2DRender.SetFont(pOldFont);

        data.m_nPlayerCasterIndex = nPlayerIndex;
        m_vTopAnnounces.push_back(data);
    }
    
    void CAnnounceRenderer::AddCenterAnnounce(const std::string strAnnounce, const std::uint32_t nPlayerIndex) {
        AnnounceData data;

        auto pOldFont = g_Neuz.m_2DRender.GetFont();
        g_Neuz.m_2DRender.SetFont(CWndBase::m_Theme.m_pFontText);


        CEditString str;
        str.SetParsingString(strAnnounce.c_str());

        const std::uint16_t nRectWidth = 450;
        int pointX = (g_Neuz.m_2DRender.m_clipRect.Width() / 2) - (nRectWidth / 2);
        //int pointX = (g_Neuz.m_2DRender.m_clipRect.Width() / 2) - (g_Neuz.m_2DRender.m_pFont->GetTextExtent_EditString(str).cx / 2);

        auto nRightPosition = pointX + nRectWidth;

        std::string character;

        std::uint16_t index = 0;
        for (auto const& it : strAnnounce) {
            textData chardata;
            chardata.m_char = it;


            CEditString strEdit;
            strEdit.SetParsingString(character.c_str());

            chardata.m_nPositionX = nRightPosition + g_Neuz.m_2DRender.m_pFont->GetTextExtent_EditString(strEdit).cx;
            data.m_strAnnounce.push_back(chardata);
            character.push_back(it);
            index++;

        }

        g_Neuz.m_2DRender.SetFont(pOldFont);

        data.m_nPlayerCasterIndex = nPlayerIndex;
        m_vCenteredAnnounces.push_back(data);
    }

    bool CAnnounceRenderer::OnRightClickUp(UINT nFlags, CPoint point)
    {

        if (g_pPlayer == nullptr) return false;

        if (m_vTopAnnounces.empty()) return false;

        auto itAnnounce = m_vTopAnnounces.begin();


        if (itAnnounce->m_strAnnounce.empty()) return false;

        auto nLeftPoint = itAnnounce->m_strAnnounce.front().m_nPositionX;
        auto nRightPoint = itAnnounce->m_strAnnounce.back().m_nPositionX;

        CRect rect = CRect(nLeftPoint, 5, nRightPoint, 25);

        if (rect.PtInRect(point))
        {
            if (itAnnounce->m_nPlayerCasterIndex == 0) return false;
            if (itAnnounce->m_nPlayerCasterIndex == g_pPlayer->m_idPlayer)
            {
                g_WndMng.PutString("You cannot send messages to your own character !", nullptr, 0xFFFF0000);
                return false;
            }


            CWndMessage* pWndMessage = g_WndMng.OpenMessage(CPlayerDataCenter::GetInstance()->GetPlayerString(itAnnounce->m_nPlayerCasterIndex));
            return true;
        }


        return false;
    }

    void CAnnounceRenderer::ProcessAnnounce(std::vector<AnnounceData>& vAnnounce) {
        if (vAnnounce.empty()) return;


        __time64_t         tTimeLeft;
        __time64_t         tCurrentTick = GetTickCount();
        auto itAnnounce = vAnnounce.begin();

        if (itAnnounce->m_tDelay == 0) return;

        tTimeLeft = itAnnounce->m_tDelay - tCurrentTick;

        if (tTimeLeft < 1000)
        {
            itAnnounce->m_nAlpha -= ((DOUBLE)tTimeLeft * 0.001);
        }
        else if (REMOVE_DELAY - tTimeLeft <= 500)
        {
            itAnnounce->m_nAlpha -= ((DOUBLE)tTimeLeft * 0.002);
        }

        if (itAnnounce->m_nAlpha <= 0)
            vAnnounce.erase(itAnnounce);
    }


    BOOL CAnnounceRenderer::Process()
    {
        ProcessAnnounce(m_vCenteredAnnounces);
        ProcessAnnounce(m_vTopAnnounces);
        return true;
    }

    void CAnnounceRenderer::RenderRectangles(C2DRender* p2DRender, const CRect &drawRect, const std::uint32_t  nAlpha, const std::uint32_t  nOffset)
    {
        /** Left of Rect **/
        p2DRender->RenderFillRect(CRect(drawRect.left - nOffset, drawRect.top, drawRect.left, drawRect.bottom), D3DCOLOR_ARGB(0, 0, 0, 0), D3DCOLOR_ARGB(nAlpha, 0, 0, 0), D3DCOLOR_ARGB(0, 0, 0, 0), D3DCOLOR_ARGB(nAlpha, 0, 0, 0));
        /** Center of Rect **/
        p2DRender->RenderFillRect(CRect(drawRect.left, drawRect.top, drawRect.right, drawRect.bottom), D3DCOLOR_ARGB(nAlpha, 0, 0, 0), D3DCOLOR_ARGB(nAlpha, 0, 0, 0), D3DCOLOR_ARGB(nAlpha, 0, 0, 0), D3DCOLOR_ARGB(nAlpha, 0, 0, 0));
        /** Right of rect **/
        p2DRender->RenderFillRect(CRect(drawRect.right, drawRect.top, drawRect.right + nOffset, drawRect.bottom), D3DCOLOR_ARGB(nAlpha, 0, 0, 0), D3DCOLOR_ARGB(0, 0, 0, 0), D3DCOLOR_ARGB(nAlpha, 0, 0, 0), D3DCOLOR_ARGB(0, 0, 0, 0));

        p2DRender->RenderFillRect(CRect(drawRect.left - nOffset, drawRect.top - 2, drawRect.left, drawRect.top), D3DCOLOR_ARGB(0, 246, 207, 77), D3DCOLOR_ARGB(nAlpha, 246, 207, 77), D3DCOLOR_ARGB(0, 246, 207, 77), D3DCOLOR_ARGB(nAlpha, 246, 207, 77));
        p2DRender->RenderFillRect(CRect(drawRect.left, drawRect.top - 2, drawRect.right, drawRect.top), D3DCOLOR_ARGB(nAlpha, 246, 207, 77), D3DCOLOR_ARGB(nAlpha, 246, 207, 77), D3DCOLOR_ARGB(nAlpha, 246, 207, 77), D3DCOLOR_ARGB(nAlpha, 246, 207, 77));
        p2DRender->RenderFillRect(CRect(drawRect.right, drawRect.top - 2, drawRect.right + nOffset, drawRect.top), D3DCOLOR_ARGB(nAlpha, 246, 207, 77), D3DCOLOR_ARGB(0, 246, 207, 77), D3DCOLOR_ARGB(nAlpha, 246, 207, 77), D3DCOLOR_ARGB(0, 246, 207, 77));

        p2DRender->RenderFillRect(CRect(drawRect.left - nOffset, drawRect.bottom, drawRect.left, drawRect.bottom + 2), D3DCOLOR_ARGB(0, 246, 207, 77), D3DCOLOR_ARGB(nAlpha, 246, 207, 77), D3DCOLOR_ARGB(0, 246, 207, 77), D3DCOLOR_ARGB(nAlpha, 246, 207, 77));
        p2DRender->RenderFillRect(CRect(drawRect.left, drawRect.bottom, drawRect.right, drawRect.bottom + 2), D3DCOLOR_ARGB(nAlpha, 246, 207, 77), D3DCOLOR_ARGB(nAlpha, 246, 207, 77), D3DCOLOR_ARGB(nAlpha, 246, 207, 77), D3DCOLOR_ARGB(nAlpha, 246, 207, 77));
        p2DRender->RenderFillRect(CRect(drawRect.right, drawRect.bottom, drawRect.right + nOffset, drawRect.bottom + 2), D3DCOLOR_ARGB(nAlpha, 246, 207, 77), D3DCOLOR_ARGB(0, 246, 207, 77), D3DCOLOR_ARGB(nAlpha, 246, 207, 77), D3DCOLOR_ARGB(0, 246, 207, 77));
    }

    void CAnnounceRenderer::RenderTopAnnounces(C2DRender* p2DRender) {
        CPoint point = CPoint(50, 5);

        if (m_vTopAnnounces.empty()) return;
        auto itAnnounce = m_vTopAnnounces.begin();

        RenderRectangles(p2DRender, CRect(point.x, point.y - 5, g_Neuz.m_2DRender.m_clipRect.Width() - 50, point.y + 20), itAnnounce->m_nAlpha, 50);

        for (auto itLetter = itAnnounce->m_strAnnounce.begin(); itLetter != itAnnounce->m_strAnnounce.end();)
        {
            if (itLetter->m_nPositionX <= g_Neuz.m_2DRender.m_clipRect.Width())
            {
                std::string strLetter;
                strLetter.push_back(itLetter->m_char);
                CEditString string;
                string.SetParsingString(strLetter.c_str(), D3DCOLOR_ARGB(255, 254, 254, 254));
                p2DRender->TextOut_EditString(itLetter->m_nPositionX, point.y, string);
            }

            itLetter->m_nPositionX -= 2; // 2 before

            if (itLetter->m_nPositionX <= 0)
            {
                itLetter->m_nPositionX += g_Neuz.m_2DRender.m_clipRect.Width();

                itLetter->m_nRoundsCount++;

                if (itLetter->m_nRoundsCount >= MAX_ROUNDS_TOP)
                    itLetter = itAnnounce->m_strAnnounce.erase(itLetter);
                else
                    ++itLetter;
            }
            else
                ++itLetter;
        }

        if (itAnnounce->m_strAnnounce.empty()) {
            if (itAnnounce->m_tDelay == 0) {
                if (std::distance(itAnnounce, m_vTopAnnounces.end()) == 1)
                    itAnnounce->m_tDelay = GetTickCount() + REMOVE_DELAY;
                else
                    m_vTopAnnounces.erase(itAnnounce);
            }
        }
    }

    void CAnnounceRenderer::RenderCenterAnnounces(C2DRender* p2DRender) {
        auto offSetY = (184 * p2DRender->m_clipRect.Height() / 768) - 120;
        if (m_vCenteredAnnounces.empty()) return;

        auto itAnnounce = m_vCenteredAnnounces.begin();

        std::string strFull;

        for (auto const [character, position, count] : itAnnounce->m_strAnnounce) {
            strFull.push_back(character);
        }

        CEditString str;
        str.SetParsingString(strFull.c_str());

        const std::uint16_t nRectWidth = 450;

        CPoint point = CPoint((p2DRender->m_clipRect.Width() / 2) - (nRectWidth / 2), offSetY);

        RenderRectangles(p2DRender, CRect(point.x, point.y - 5, point.x + nRectWidth, point.y + 20), itAnnounce->m_nAlpha, 50);

        for (auto itLetter = itAnnounce->m_strAnnounce.begin(); itLetter != itAnnounce->m_strAnnounce.end();)
        {
            if (itLetter->m_nPositionX <= point.x + nRectWidth && itLetter->m_nPositionX >= point.x)
            {
                std::string strLetter;
                strLetter.push_back(itLetter->m_char);
                CEditString string;
                string.SetParsingString(strLetter.c_str(), D3DCOLOR_ARGB(255, 254, 254, 254));
                p2DRender->TextOut_EditString(itLetter->m_nPositionX, point.y, string);
            }

            itLetter->m_nPositionX -= 2; // 2 before

            if (std::distance(itLetter, itAnnounce->m_strAnnounce.end()) == 1 && itLetter->m_nPositionX <= point.x)
            {
                itAnnounce->m_strAnnounce.clear();
                break;
            }
            else
                ++itLetter;
        }

        if (itAnnounce->m_strAnnounce.empty()) {
            if (itAnnounce->m_tDelay == 0) {
            if( std::distance(itAnnounce, m_vCenteredAnnounces.end()) == 1)
                itAnnounce->m_tDelay = GetTickCount() + REMOVE_DELAY;
            else
                m_vCenteredAnnounces.erase(itAnnounce);
            }
        }
    }

    void CAnnounceRenderer::RenderAnnounces(C2DRender* p2DRender) {
        auto pOldFont = p2DRender->GetFont();
        p2DRender->SetFont(CWndBase::m_Theme.m_pFontText);
        RenderCenterAnnounces(p2DRender);
        RenderTopAnnounces(p2DRender);
    
        p2DRender->SetFont(pOldFont);
    }


    /********************/

    void CWndAnnouncement::SetUsedItem(const std::uint32_t nItemId) {
        m_nItemId = nItemId;
    }

    BOOL CWndAnnouncement::OnChildNotify(UINT message, UINT nID, LRESULT* pLResult)
    {
        switch (nID)
        {
        case WIDC_BUTTON:   
            std::string str = m_pWndEdit->GetString();

            if (str.length() < MAX_ANNOUNCE_SIZE)
            {
                g_DPlay.SendAnnouncement(str, m_nItemId);
                Destroy();
            }
            else
            {
                CString strError;
                strError.Format("Your announcement should not exceed %d name !", MAX_ANNOUNCE_SIZE);
                g_WndMng.OpenMessageBox(strError);
            }
            break;
            break;
        }

        return CWndNeuz::OnChildNotify(message, nID, pLResult);
    }

    void CWndAnnouncement::OnInitialUpdate()
    {
        CWndNeuz::OnInitialUpdate();

        m_pWndEdit = (CWndEdit*)GetDlgItem(WIDC_EDIT);

        MoveParentCenter();
    }
    BOOL CWndAnnouncement::Initialize(CWndBase* pWndParent, DWORD dwWndId)
    {
        return CWndNeuz::InitDialog(g_Neuz.GetSafeHwnd(), APP_ANNOUNCE, 0, CPoint(0, 0), pWndParent);
    }
#endif
}

#ifdef __CLIENT
AnnounceRenderer::CAnnounceRenderer g_AnnounceRenderer = AnnounceRenderer::CAnnounceRenderer();
#endif
is this a question? if yes it does not belong here.

Questions have to be placed here:
Flogolo is offline  
Old 03/14/2025, 09:21   #3
♥ Yuuki Asuna ♥



 
DarkOPM's Avatar
 
elite*gold: 45
The Black Market: 140/0/0
Join Date: Jun 2005
Posts: 54,877
Received Thanks: 8,573
Arrow Flyff PServer Guides & Releases -> Flyff Private Ser…

#moved
DarkOPM is offline  
Thanks
1 User
Reply


Similar Threads Similar Threads
Class Reborn Cap 110 - Dg 11- Pvp System- Uniques System -Job System- Coin System
04/09/2018 - SRO PServer Advertising - 17 Replies
http://i.epvpimg.com/HXIucab.jpg http://i.epvpimg.com/Ht37fab.png https://www.youtube.com/watch?v=1vJSSpEqTZw http://i.epvpimg.com/Ht37fab.png Site ClassReborn Online
Class Reborn Cap 110 - Dg 11- Pvp System- Uniques System -Job System- Coin System
02/18/2018 - SRO PServer Advertising - 2 Replies
http://i.epvpimg.com/HXIucab.jpg http://i.epvpimg.com/Ht37fab.png Site Download
role name established garbled solve?
09/22/2016 - Nostale - 3 Replies
role name established garbled solve?
Torchlight II Release Announcement .. Announcement!!!
08/25/2012 - User Submitted News - 3 Replies
Ja, ihr habt richtig gehört. Jetzt ist es Wirklich fest Angekündigt!!! Torchlight II wird kommen! Der langersehnte Diablo 3 Konkurrent hebt sich hervor.



All times are GMT +1. The time now is 00:37.


Powered by vBulletin®
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2025 elitepvpers All Rights Reserved.