#include "CGFXSpec.h"
#include "CFTTDevice.h"
#include "AndroidApp.h"
#include "CFTTAndroidDevice.h"
#include "CXmlUtil.h"
#include "CFTTGraphicsDevice.h"
#include "STORY.h"
#include "CFE.h"

char CGFXSpec::s_cDeviceReport[0x1000];
//-------------------------------------------------------------------------------------------------
const char *list_ResLimit_323204[4] = {
    "ResLimit_Phone",    //手机
    "ResLimit_Phablet",  //平板手机
    "ResLimit_Tablet",   //平板电脑
    "ResLimit_Screen"    //
};
//-------------------------------------------------------------------------------------------------
GFXSPEC_Specification GFXSPEC_tSpecification_AndroidLow{
    0x1e,               //field_0
    1.399999976158142,  //fLODMultGame_4
    1.200000047683716,  //fLODMultNIS_8
    0.75,               //fRTTScaleFactorX_C
    0.75,               //fRTTScaleFactorY_10
    256,                //iAtlasWidth_14
    256,                //iAtlasHeight_18
    2,                  //iKitTexFormat_1C
    512,                //iKitDims_20
    false,              //bSoftShadows_24
    true,               //bEnvObjectShadows_25
    false,              //bGameplayStadium_26
    true,               //bCrowdAnimated_27
    false,              //bDropTexMips_28
    false,              //field_29 unuse
    false,              //field_2A unuse
    false,              //field_2B unuse
    0,                  //eEnableDOF_2C
    false,              //bEnableDepthFog_30
    false,              //bEnableReflection_31
    false,              //bEnableGodRays_32
    false,              //bHighQualityNet_33
    0u,
    0u,
    1u,
    0u,
    nullptr,                 //pVHSShader_38
    false,                   //bHighQualityGroundShadows_3C
    false,                   //b3DGrass_3D
    false,                   //bFloatEnvMap_3E
    false,                   //bDynNormMap_3F
    0,                       //eAntiAliasing_40
    0,                       //ePlayerLightingQuality_44
    EPitchShader_Quality_0,  //eHighQualityGrass_48
    0,                       //eCrowdQuality_4C
    -1,                      //iMinMaxResolution_50
    false,                   //bForce16Bit_54
};
//-------------------------------------------------------------------------------------------------
GFXSPEC_Specification GFXSPEC_tSpecification_AndroidMed{
    0x1e,               //field_0
    1.200000047683716,  //fLODMultGame_4
    1.100000023841858,  //fLODMultNIS_8
    0.75,               //fRTTScaleFactorX_C
    0.75,               //fRTTScaleFactorY_10
    256,                //iAtlasWidth_14
    256,                //iAtlasHeight_18
    3,                  //iKitTexFormat_1C
    256,                //iKitDims_20
    false,              //bSoftShadows_24
    true,               //bEnvObjectShadows_25
    true,               //bGameplayStadium_26
    true,               //bCrowdAnimated_27
    false,              //bDropTexMips_28
    false,              //field_29 unuse
    false,              //field_2A unuse
    false,              //field_2B unuse
    1,                  //eEnableDOF_2C
    true,               //bEnableDepthFog_30
    true,               //bEnableReflection_31
    true,               //bEnableGodRays_32
    true,               //bHighQualityNet_33
    1u,
    1u,
    3u,
    0u,
    "2d_vhsbasic",           //pVHSShader_38
    false,                   //bHighQualityGroundShadows_3C
    false,                   //b3DGrass_3D
    false,                   //bFloatEnvMap_3E
    false,                   //bDynNormMap_3F
    0,                       //eAntiAliasing_40
    1,                       //ePlayerLightingQuality_44
    EPitchShader_Quality_1,  //eHighQualityGrass_48
    0,                       //eCrowdQuality_4C
    -1,                      //iMinMaxResolution_50
    false,                   //bForce16Bit_54
};
//-------------------------------------------------------------------------------------------------
GFXSPEC_Specification GFXSPEC_tSpecification_AndroidHigh{
    0x3c,   //field_0
    0.875,  //fLODMultGame_4
    0.75,   //fLODMultNIS_8
    1.0,    //fRTTScaleFactorX_C
    1.0,    //fRTTScaleFactorY_10
    256,    //iAtlasWidth_14
    256,    //iAtlasHeight_18
    3,      //iKitTexFormat_1C
    512,    //iKitDims_20
    true,   //bSoftShadows_24
    true,   //bEnvObjectShadows_25
    true,   //bGameplayStadium_26
    true,   //bCrowdAnimated_27
    false,  //bDropTexMips_28
    false,  //field_29 unuse
    false,  //field_2A unuse
    false,  //field_2B unuse
    2,      //eEnableDOF_2C
    true,   //bEnableDepthFog_30
    true,   //bEnableReflection_31
    true,   //bEnableGodRays_32
    true,   //bHighQualityNet_33
    1u,
    1u,
    4u,
    0u,
    "2d_vhsfancy",           //pVHSShader_38
    true,                    //bHighQualityGroundShadows_3C
    true,                    //b3DGrass_3D
    true,                    //bFloatEnvMap_3E
    true,                    //bDynNormMap_3F
    0,                       //eAntiAliasing_40
    1,                       //ePlayerLightingQuality_44
    EPitchShader_Quality_2,  //eHighQualityGrass_48
    2,                       //eCrowdQuality_4C
    -1,                      //iMinMaxResolution_50
    false,                   //bForce16Bit_54
};
//-------------------------------------------------------------------------------------------------
GFXSPEC_Specification GFXSPEC_tSpecification_AndroidHighest{
    0x3c,   //field_0
    0.75,   //fLODMultGame_4
    0.5,    //fLODMultNIS_8
    1.0,    //fRTTScaleFactorX_C
    1.0,    //fRTTScaleFactorY_10
    256,    //iAtlasWidth_14
    256,    //iAtlasHeight_18
    3,      //iKitTexFormat_1C
    512,    //iKitDims_20
    true,   //bSoftShadows_24
    true,   //bEnvObjectShadows_25
    true,   //bGameplayStadium_26
    true,   //bCrowdAnimated_27
    false,  //bDropTexMips_28
    false,  //field_29 unuse
    false,  //field_2A unuse
    false,  //field_2B unuse
    3,      //eEnableDOF_2C
    true,   //bEnableDepthFog_30
    true,   //bEnableReflection_31
    true,   //bEnableGodRays_32
    true,   //bHighQualityNet_33
    1u,
    1u,
    4u,
    0u,
    "2d_vhsfancy",           //pVHSShader_38
    true,                    //bHighQualityGroundShadows_3C
    true,                    //b3DGrass_3D
    true,                    //bFloatEnvMap_3E
    true,                    //bDynNormMap_3F
    3,                       //eAntiAliasing_40
    2,                       //ePlayerLightingQuality_44
    EPitchShader_Quality_3,  //eHighQualityGrass_48
    3,                       //eCrowdQuality_4C
    -1,                      //iMinMaxResolution_50
    false,                   //bForce16Bit_54
};
//-------------------------------------------------------------------------------------------------

GFXSPEC_Specification *list_Specification_323214[]{
    &GFXSPEC_tSpecification_AndroidLow,
    &GFXSPEC_tSpecification_AndroidLow,
    &GFXSPEC_tSpecification_AndroidMed,
    &GFXSPEC_tSpecification_AndroidHigh,
    &GFXSPEC_tSpecification_AndroidHighest,
};
//-------------------------------------------------------------------------------------------------
GFXSPEC_Specification *GFXSPEC_pSpecification;
char CGFXSpec::s_cDeviceAnalyticsString[512];
//-------------------------------------------------------------------------------------------------
//0018F3F0
extern "C" {
bool sub_18F3F0(CFTTXmlReaderNode *pXmlNode0, const char *pName, int *pOut) {
  return true;
}
}
//-------------------------------------------------------------------------------------------------
//0018E728 经过单元测试，功能正常
void CGFXSpec::Initialise() {
  // 只保留android相关的代码，ios的忽略
  //SYS_GetHardwareType();

  //locret_18E80A return
  LOGI("CGFXSpec::Initialise End");
}
//-------------------------------------------------------------------------------------------------
//0018E878 经过单元测试，功能正常
void CGFXSpec::Platform_InspectDevice() {
  LOGI("CGFXSpec::Platform_InspectDevice: Entry");

  //loc_18EE76
  LOGI("CGFXSpec::Platform_InspectDevice");
}
//-------------------------------------------------------------------------------------------------
//0018EEF4 //^_- 经过单元测试，功能正常
void CGFXSpec::UpdateGraphicsFromConfig(CFTTXmlReaderNode *pXmlNode) {
  LOGI("CGFXSpec::UpdateGraphicsFromConfig entry");
}
//-------------------------------------------------------------------------------------------------
//0018F41C //^_^
void CGFXSpec::ApplyResolutionClamp(CFTTXmlReaderNode *pXmlNode) {
  //locret_18F4C6
}
//-------------------------------------------------------------------------------------------------