//`mwjjs
//
// Created by t_fire on 2022/4/30.
//

#include "CFTTXmlReaderNode.h"
#include "CAdElImage.h"
#include "XMATH.h"

CAdElImage::CAdElImage(CAdAttribute<TPointF,TAdPointInterpolator> *i0,
           CAdAttribute<TPointF,TAdPointInterpolator> *i1,
           CAdAttribute<uint,TAdColourInterpolator>*i2,
           CAdAttribute<float,TAdFloatInterpolator>*i3,
           char const*i4,bool i5)
    {
    }

    void CAdElImage::Render(float, float) //写出来是为了实例化//`m
    {

    }
    void CAdElImage::Clone(void)//写出来是为了实例化
    {

    }

//001937FC
CAdElement* GetImageElement(CFTTXmlReaderNode nd0)
{
    CAdAttribute<float,TAdFloatInterpolator> *R0_9, *R5_5;
    CAdAttribute<TPointF,TAdPointInterpolator> *R0_50, *R0_20, *R9_2, *R1_5, *R2_5;
    CAdAttribute<uint,TAdColourInterpolator> *R0_21, *R10_1, *R3_5;
    eAlignmentX *R1_2;
    eAlignmentY *R2_2;
    CFTTXmlReaderNode var_28,var_24,var_20,
        R0_0,R0_3,R0_4,R0_5,R0_6,R0_11,R0_12,R0_13,R0_14,R0_15,*R0_2,*R0_32;
    eScaleX var_1C;
    eScaleY var_18;
    ePosTypeX  var_14;
    ePosTypeY var_10;
    CFTTXmlReaderNode var_0C;
    char  *R0_1, *R1_0, *R7_2, *R11_30, *R0_34, *R1_30;
    int R0_40,R0_25,R6_5;
    CAdElement * R0_16;

    var_28 = nd0;

    R0_0 = nd0;
    R0_1 = XMLGetString(R0_0, "File", NULL, NULL);

    R1_0 = R0_1;
    R0_40 = strcmp("ads_as.png", R1_0);


    R0_2 = &var_28;

    R0_3 = R0_2->GetFirstChild("Position");//call
    R0_50 = GetPointAttribute(R0_3);

    R0_4 = R0_2->GetFirstChild("Size");
    R0_20 = GetPointAttribute(R0_4);

    R9_2 = R0_20;

    R0_5 = R0_2->GetFirstChild("Colour");
    R0_21 = GetColourAttribute(R0_5);
    R10_1 = R0_21;

    R0_6 = R0_2->GetFirstChild("Rotation");
    var_24 = R0_6;

    R7_2 = "ads_gp.png";

    //0019385E
    if( R0_40 != 0 )
    {
        //00193868
        R7_2 = R0_1;
        //00193868
    }

    //0019386E
    if( (&var_24)->IsValid() == 0 )
    {
        //00193882
        CAdAttribute<float,TAdFloatInterpolator> * R0_9 = new CAdAttribute<float,TAdFloatInterpolator>(0,0);
        R5_5 = R0_9;
        //00193896
    }else
    {
        //00193870
        R0_11 = (&var_28)->GetFirstChild("Rotation");
        CAdAttribute<float,TAdFloatInterpolator> * R0_23 = GetFloatAttribute(R0_11);
        R5_5 = R0_23;
        //00193880
    }

    R0_12 = var_28;
    R11_30 = NULL;
    R0_25 = GetFlag(R0_12, "Remote", 0);

    R0_13 = var_28;
    R1_2 =  (eAlignmentX*)(&var_24);
    R2_2 = (eAlignmentY*)&var_20;
    GetAlignment(R0_13, *R1_2, *R2_2);

    R0_14 = var_28;
    GetScale(R0_14, var_1C, var_18);//`m

    R0_15 = var_28;
    GetPosType(R0_15, var_14, var_10);

    R1_5 = R0_50;
    R2_5 = R9_2;
    R3_5 = R10_1;
    R6_5  = R0_25;
    R0_16 = new CAdElImage(R1_5, R2_5, R3_5,R5_5, R7_2, R6_5);


    R0_16->eAlignmentX_14 = *(eAlignmentX*)&var_24;
    R0_16->eAlignmentY_18 = *(eAlignmentY*)&var_20;
    R0_16->eScaleX_1C = var_1C;
    R0_16->eScaleY_20 = var_18;

    R0_16->ePosTypeX_24 = var_14;
    R0_16->ePosTypeY_28 = var_10;

    var_0C = (&var_28)->GetFirstChild("Name");

    R0_32 = &var_0C;
    //0019390E
    if( !R0_32->IsValid() )
    {

    }else
    {
        //00193910
        R0_34 = (&var_28)->GetText("Name");
        R11_30 = R0_34;
        //0019391A
    }

    R1_30 = R11_30;
    R0_16->SetName(R1_30);
    
    return R0_16;
}


//0019309C
void GetPosType(CFTTXmlReaderNode nd0,ePosTypeX & i1,ePosTypeY &i2)
{

}


//00192F84
void GetScale(CFTTXmlReaderNode nd0,eScaleX &i1,eScaleY &i2)
{
}


//00191F48
bool GetFlag(CFTTXmlReaderNode nd0,char* i2,bool i3)
{
    return 1;
}


//00192A2C
CAdAttribute<float,TAdFloatInterpolator> * GetFloatAttribute(CFTTXmlReaderNode nd0)
{
}


//001924A8
CAdAttribute<uint,TAdColourInterpolator> * GetColourAttribute(CFTTXmlReaderNode nd0)
{
}


//00191FB8
CAdAttribute<TPointF,TAdPointInterpolator> * GetPointAttribute(CFTTXmlReaderNode nd0)
{
}


//00192EBC
void GetAlignment(CFTTXmlReaderNode rn0, eAlignmentX & pui1, eAlignmentY &pui2)
{
    int R7_0,R0_0,R0_6,R6_0;
    eAlignmentX R4_0;
    eAlignmentY R4_1;
    CFTTXmlReaderNode *R0_1, *R0_2, R0_3,R0_4,*R0_5,R0_7,R0_10;
    CFTTXmlReaderNode var_1C,var_08,var_04;
    char *R0_8, *R7_1, *R0_9,*R0_12, *R0_11, *R0_13;

    var_1C = rn0;

    R0_2 =  &var_1C;

    R0_3 = R0_2->GetFirstChild("AlignX");
    var_08 = R0_3;
    R0_1 = &var_08;
    R0_0 = R0_1->IsValid();

    R7_0 = R0_0;

    R0_4 = R0_2->GetFirstChild("AlignY");
    var_04 = R0_4;
    R0_5 = &var_04;
    R0_6 = R0_5->IsValid();

    R6_0 = R0_6;

    //00192EF0
    if( !R7_0 )
    {
        //00192F22
        R4_0 = (eAlignmentX)1;
        //00192F22
    }else
    {
        //00192EF2
        R4_0 = (eAlignmentX)0;
        R0_7 = var_1C;
        R0_8 = XMLGetString(R0_7,"AlignX", NULL, NULL);

        R7_1 = R0_8;

        //00192F08
        if(strcmp(R0_8, "Left"))
        {
            //00192F0E
            R0_9 = R7_1;

            R4_0 = (eAlignmentX)1;
            //00192F1A
            if(!strcmp(R0_9, "Right"))
            {
                //00192F1E
                R4_0 = (eAlignmentX)2;
                //00192F1E
            }
            //00192F20
        }
    }

    pui1 = R4_0;

    //00192F24
    if( R6_0 == 0 )
    {
        //00192F5A
        R4_1 = (eAlignmentY)1;
        //00192F5A
    }else
    {
        //00192F2A
        R0_10 = var_1C;

        R4_1 = (eAlignmentY)0;
        R0_12 = XMLGetString(R0_10,"AlignY", NULL, NULL);

        R0_11 = R0_12;

        //00192F44
        if( !strcmp(R0_11,"Top") )
        {

        }else
        {
            //00192F46
            R0_13 = R0_12;

            R4_1 = (eAlignmentY)1;
            //00192F52
            if( !strcmp(R0_13,"Bottom") )
            {
                //00192F56
                R4_1 = (eAlignmentY)2;
                //00192F56
            }
            //00192F58
        }
    }

    pui2 = (eAlignmentY)R4_1;
}


//0014BA50
float  FEU_UpdateHighlightRect(float *pf0, float f1)
{
    float S0_0,S12_0,S14_0;
    float R0_0,R0_2;

    //0014BA58
    if(f1 != 0.0)
    {
        //0014BA62
        R0_2 = XMATH_InterpolateClampFloat(f1,0.0,1.0,1.0,(float)5.877496977483795e-39);

        S12_0 = R0_2*pf0[2];

        pf0[0] = ((pf0[0]+(pf0[2]*(float)0.5))-(S12_0*(float)0.5));

        S14_0 = R0_2*pf0[3];

        pf0[1] = ((pf0[1]+(pf0[3]*(float)0.5))-(S14_0*(float)0.5));

        pf0[2] = S12_0;

        pf0[3] = S14_0;

        S0_0 = R0_2;
        //0014BAB6
    }else
    {
        //0014BAB8
        S0_0 = 1.0;
        //0014BAB8
    }

    R0_0 = S0_0;

    return R0_0;
}


