Enable Background Video in FW

Results 1 to 1 of 1
  1. #1
    Valued Member Mistigri is offline
    MemberRank
    Oct 2020 Join Date
    Forsaken WorldLocation
    120Posts

    Enable Background Video in FW

    We assume that custom code will be in bold and colored Blue.
    ---FW1 versions:


    We will be modifying SMElement/SMElementClient/EC_LoginUIMan.cpp
    In this function below:
    Code:
    bool CECLoginUIMan::Init(A3DEngine *pA3DEngine, A3DDevice *pA3DDevice, const char *pszFilename, int nDefaultWidth, int nDefaultHeight)
    Some blocks of code will need to be uncommented:
    Code:
         EC_RELEASE_DELETE(m_pBackGroundVideo);
         m_pBackGroundVideo = new AMVideoClip; 
         if(_InitBackGroundVideo())
         {
             m_pBackGroundVideo->Start(true);
             const EC_SYSTEM_SETTING& ss = g_pGame->GetConfigs()->GetSystemSettings();
             int nVolume = ss.bEnableMusic ? ss.nMusicVol : 0;
             a_Clamp(nVolume, 0, 100);
             m_pBackGroundVideo->SetVolume(DWORD(nVolume));
         }
    That's how you enable background video in FW1 versions such as Dysil or Bloodharvest!


    ---FW2 versions:
    Here is a provided Sample with AwakeningClientSource as a basis:
    https://drive.google.com/file/d/11qu...4SIiSvg33/view



    1)We will be modifying SMElement/SMElementClient/EC_Resource.h
    Code:
    enum
    {
        RES_ICON_UNKNOWN = 0,
        RES_ICON_PROF_WARRIOR,        //战士
        RES_ICON_PROF_GUARD,        //巨灵
        RES_ICON_PROF_THIEF,        //刺客
        RES_ICON_PROF_GUNMAN,        //火枪手        
        RES_ICON_PROF_ENCHANTER,    //法师
        RES_ICON_PROF_PRIEST,        //牧师
        RES_ICON_PROF_BLOOD,        //血魔    
        RES_ICON_PROF_POET,            //吟游诗人
        RES_ICON_PROF_BLOODRAIDER,    //血袭者
        RES_ICON_PROF_WIZARD,        //断罪者
        RES_ICON_GT_ONLINE,            //GT在线图标
        RES_ICON_GT_DOWNLINE,        //GT不在线图标
        RES_ICON_CROSS_SERVER_ONLINE,        //跨服在线标志
        RES_ICON_CROSS_FRIEND_ONLINE,        //跨服好友在线标志
        RES_ICON_CROSS_FRIEND_OFFLINE,        //跨服好友不在线标志
        NUM_RES_ICON_NUM,
    };
    
    //    Movie resources
    enum
    {
        NUM_RES_VIDEO = 1,
    };

    Code:
    const char* res_ProIcon(int n);
    const char* res_VideoFile(int n);


    2)We will be modifying SMElement/SMElementClient/EC_Resource.cpp
    Code:
    static const AString l_aProIcon[NUM_RES_ICON_NUM] =
    {
        "未知.tga",
        "战士.tga",
        "守护者.tga",
        "刺客.tga",
        "火枪手.tga",
        "法师.tga",
        "牧师.tga",
        "血魔.tga",
        "吟游诗人.tga",
        "血袭者.tga",
        "断罪者.tga",
        "gtonline.tga",
        "gtdownline.tga",
        "跨服在线.tga",
        "跨服好友_on.tga",
        "跨服好友_off.tga",
    };
    
    //    Video files
    static const AString l_aVideoFiles[NUM_RES_VIDEO] =
    {
        "Maps\\login\\video1.mpx",
    };
    

    Code:
    const char* res_ProIcon(int n)
    {
        ASSERT(n >= RES_ICON_UNKNOWN && n < NUM_RES_ICON_NUM);
        return l_aProIcon[n];
    }
    
    const char* res_VideoFile(int n)
    {
        ASSERT(n >=0 && n < NUM_RES_VIDEO);
        return l_aVideoFiles[n];
    }


    3)We will be modifying SMElement/SMElementClient/EC_LoginUIMan.h
    Code:
    protected:
        virtual PAUIDIALOG CreateDlgInstance(const AString strTemplName);
        bool OnCommand_Login(const char* szCommand, AUIDialog* pDlg);
        bool RefreshPlayerList();
        void InitDialogs();
        void _OnConfirm();
        bool _InitBackGroundVideo();        // Background video
    protected://    Attributes
        int m_nCreatePhase;
        int m_nCurProfession;
        int m_nCurGender;
        int m_nCurRace;
        A2DSprite*    m_pLoginBack;
        A2DSprite*    m_pCreateBack;
        AMVideoClip* m_pBackGroundVideo;        // Background video


    4)We will be modifying SMElement/SMElementClient/EC_LoginUIMan.cpp
    Code:
    CECLoginUIMan::CECLoginUIMan()
    {
        m_pLoginBack        = NULL;
        m_pCreateBack        = NULL;
    //    m_pLogo                = NULL;
        m_pBackGroundVideo    = NULL;//Background video
        m_nCurProfession = PROF_WARRIOR;
        m_nCurGender = DEFAULT_GENDER;
        m_nCurRace = RACE_HUMAN;
        memset(m_aModel, 0, sizeof(m_aModel));
    
        m_bDragRole = false;
        m_iState        =    STATE_LOGIN;
    }
    We must modify blocks of code within following function:
    bool CECLoginUIMan::Init(A3DEngine *pA3DEngine, A3DDevice *pA3DDevice, const char *pszFilename, int nDefaultWidth, int nDefaultHeight)

    Code:
        const char* login_video_file_name = "RoleSettings\\video1";
        if (!g_FileExist(login_video_file_name))
        {
            InitBackgroundVideo("Maps\\login\\video1.wmv");
            FILE* fp = fopen(login_video_file_name, "wb");
            if (fp)
            { 
                fclose(fp); 
                fp = NULL;
            }
        }
        
        //Background video    initialization
         EC_RELEASE_DELETE(m_pBackGroundVideo);
         m_pBackGroundVideo = new AMVideoClip; 
         if(_InitBackGroundVideo())
         {
             m_pBackGroundVideo->Start(true);
             const EC_SYSTEM_SETTING& ss = g_pGame->GetConfigs()->GetSystemSettings();
             int nVolume = ss.bEnableMusic ? ss.nMusicVol : 0;
             a_Clamp(nVolume, 0, 100);
             m_pBackGroundVideo->SetVolume(DWORD(nVolume));
         }
        //Background video    initialization
        AfxGetGFXExMan()->SetPriority(5);

    Code:
    bool CECLoginUIMan::_InitBackGroundVideo()
    {
        if(!m_pBackGroundVideo)
        {
            return false;
        }
        int nPlayIndex = rand() % NUM_RES_VIDEO;
        bool bResult = m_pBackGroundVideo->InitSafe(g_pGame->GetA3DDevice(), g_pGame->GetA3DDevice()->GetA3DEngine()->GetAMVideoEngine(), res_VideoFile(nPlayIndex));
        if(!bResult)
        {
            a_LogOutput(1, "Failed to initialize video %s.", res_VideoFile(nPlayIndex));
            EC_RELEASE_DELETE(m_pBackGroundVideo);
        }
        return m_pBackGroundVideo ? true : false;
    }
    
    bool CECLoginUIMan::Release(void)
    {
        g_pGame->GetConfigs()->SaveSystemSettings();
    
        EC_RELEASE_DELETE(m_pLoginBack);
        EC_RELEASE_DELETE(m_pCreateBack);
        for (int iRace = 1; iRace < RACE_LAST; ++iRace)
        {
            for (int iGender = 0; iGender < NUM_GENDER; ++iGender)
            {
                EC_RELEASE_DELETE(m_aModel[iRace][iGender]);
            }
        }
    
        return AUISkinManager::Release();
    }

    Code:
    bool CECLoginUIMan::Render(void)
    {
        if (RenderBackgroundVideo())
        {
            return true;
        }
        
        // Video rendering
        if (m_pBackGroundVideo && m_iState<STATE_SELECT_CHAR )
        {
            g_pGame->GetA3DDevice()->Clear(D3DCLEAR_TARGET|D3DCLEAR_ZBUFFER, 0x00000000, 1.0f, 0);
            
            if (m_pBackGroundVideo->GetVideoWidth() &&
                m_pBackGroundVideo->GetVideoHeight())
            {
                m_pBackGroundVideo->SetVidPos(A3DPOINT2(0,0));
                m_pBackGroundVideo->SetAutoScaleFlags(AMVID_FIT_X | AMVID_FIT_Y);
            }
            m_pBackGroundVideo->DrawToBack();
        }
        // Video rendering
    Please feel free to correct me if you notice a mistake!
    I'm grateful for the people who have supported me in my FW work and Special Thanks to my friends.




Advertisement