void OnConvertImage()
    {
        ShotDeviceInfo infoMain = GetMainDevice(deviceInfoNow);

        if (infoMain == null)
        {
            return;
        }
        Debug.Log("OnConvertImage name =" + infoMain.name);
        string filepath_src = GetSaveScreenShotFilePath(infoMain, false);

        //jpg
        {
            string    filepath_dst = GetSaveScreenShotFilePath(deviceInfoNow, false);
            Texture2D texSrc       = LoadTexture.LoadFromFile(filepath_src);
            Texture2D texDst       = TextureUtil.ConvertSize(texSrc, deviceInfoNow.width, deviceInfoNow.height);
            TextureUtil.SaveTextureToFile(texDst, filepath_dst);
        }

        //png
        {
            string    filepath_dst = GetSaveScreenShotFilePath(deviceInfoNow, true);
            Texture2D texSrc       = LoadTexture.LoadFromFile(filepath_src);
            Texture2D texDst       = TextureUtil.ConvertSize(texSrc, deviceInfoNow.width, deviceInfoNow.height);
            TextureUtil.SaveTextureToFile(texDst, filepath_dst);
        }
    }
    string GetSaveScreenShotFilePath(ShotDeviceInfo info)
    {
        string filedir  = GetSaveDir(info);
        string filepath = filedir + "/" + (indexScreenShot + 1) + ".jpg";

        return(filepath);
    }
    void GotoDevice(int index)
    {
        int idx = index;

        if (idx < 0)
        {
            //切换到第一个
            idx = 0;
        }
        deviceInfoNow = listDevice[idx];
        UpdateTotal();
        screenShotConfig.deviceInfo = deviceInfoNow;

        Language.main.SetLanguage(deviceInfoNow.lan);
        // if (isMain)
        {
            SetScreen(deviceInfoNow.width, deviceInfoNow.height);
        }
        //更新
        if (Application.isEditor)
        {
            GotoScrenShot(indexScreenShot);
        }
        else
        {
            if ((deviceInfoNow.width == Screen.width) && (deviceInfoNow.height == Screen.height))
            {
                //分辨率没有变化
                GotoScrenShot(indexScreenShot);
            }
        }
    }
Esempio n. 4
0
    public ShotItemInfo GetPage(ShotDeviceInfo dev, int idx)
    {
        ShotItemInfo     info       = new ShotItemInfo();
        UIViewController controller = null;

        info.isRealGameUI = true;
        if (dev.name == ScreenDeviceInfo.DEVICE_NAME_ICON)
        {
            controller = IconViewController.main;
            IconViewController.main.deviceInfo = dev;
        }
        else if (dev.name == ScreenDeviceInfo.DEVICE_NAME_AD)
        {
            controller = AdHomeViewController.main;
        }
        else if ((dev.name == ScreenDeviceInfo.DEVICE_NAME_COPY_RIGHT_HUAWEI) || (dev.name == ScreenDeviceInfo.DEVICE_NAME_COPY_RIGHT_HD_HUAWEI))
        {
            controller = CopyRightViewController.main;
            CopyRightViewController.main.deviceInfo = dev;
        }
        else
        {
            switch (idx)
            {
            case 0:
                LevelManager.main.gameLevel = 0;
                controller = GameViewController.main;
                break;

            case 1:
                controller = PlaceViewController.main;
                break;

            case 2:
                // LevelManager.main.gameLevel = 2;
                controller = LearnViewController.main;
                break;

            case 3:
                controller = GuankaViewController.main;
                break;

            case 4:
                controller = HomeViewController.main;
                break;

            default:
                controller = HomeViewController.main;
                break;
            }
        }
        info.controller = controller;

        return(info);
    }
    void OnDevicePre(bool isMain)
    {
        // indexDevice--;
        // if (indexDevice < 0)
        // {
        //     indexDevice = listDevice.Count - 1;
        // }

        bool is_find      = false;
        int  first_device = 0;
        int  index        = 0;

        for (int i = listDevice.Count - 1; i >= 0; i--)
        {
            ShotDeviceInfo info      = listDevice[i];
            bool           is_filter = isMain ? info.isMain : (!info.isMain);
            if (is_filter)
            {
                if (info.index < indexDevice)
                {
                    indexDevice = info.index;
                    is_find     = true;
                    break;
                }
                if (index == 0)
                {
                    first_device = info.index;
                }
                index++;
            }
        }
        if (!is_find)
        {
            //切换到最后一个
            indexDevice = first_device;
        }

        deviceInfoNow = listDevice[indexDevice];

        UpdateTotal();
        screenShotConfig.deviceInfo = deviceInfoNow;

        Language.main.SetLanguage(deviceInfoNow.lan);
        if (isMain)
        {
            SetScreen(deviceInfoNow.width, deviceInfoNow.height);
        }
        UpdateTitle();

        //更新
        if (Application.isEditor)
        {
            GotoScrenShot(indexScreenShot);
        }
    }
Esempio n. 6
0
    public void CreateDevice(string name, int w, int h, bool isBoth, bool isMain)
    {
        if (name == DEVICE_NAME_ICON)
        {
            {
                //icon
                ShotDeviceInfo info = CreateDeviceItem(name, w, h, SystemLanguage.Chinese, isMain, false);
            }

            {
                //iconhd
                ShotDeviceInfo info = CreateDeviceItem(name, w, h, SystemLanguage.Chinese, isMain, true);
            }
            return;
        }


        if (name == DEVICE_NAME_COPY_RIGHT_HUAWEI)
        {
            //copyright
            ShotDeviceInfo info   = CreateDeviceItem(name, w, h, SystemLanguage.Chinese, isMain, false);
            ShotDeviceInfo infohd = CreateDeviceItem(name, w, h, SystemLanguage.Chinese, isMain, true);
            return;
        }

        if (name == DEVICE_NAME_COPY_RIGHT_HD_HUAWEI)
        {
            //copyright hd
            //ShotDeviceInfo infohd = CreateDeviceItem(name, w, h, SystemLanguage.Chinese, isMain, true);
            return;
        }

        if (isBoth)
        {
            foreach (SystemLanguage lan in listLanguage)
            {
                //竖屏
                ShotDeviceInfo info = CreateDeviceItem(name, Mathf.Min(w, h), Mathf.Max(w, h), lan, isMain, false);
            }

            foreach (SystemLanguage lan in listLanguage)
            {
                //横屏
                ShotDeviceInfo info = CreateDeviceItem(name, Mathf.Max(w, h), Mathf.Min(w, h), lan, isMain, false);
            }
        }
        else
        {
            foreach (SystemLanguage lan in listLanguage)
            {
                ShotDeviceInfo info = CreateDeviceItem(name, w, h, lan, isMain, false);
            }
        }
    }
Esempio n. 7
0
    public void InitDevice()
    {
        listLanguage = new List <SystemLanguage>();
        listLanguage.Add(SystemLanguage.Chinese);
        listLanguage.Add(SystemLanguage.English);

        listDevice = new List <ShotDeviceInfo>();


        // {

        // //ipadpro
        CreateDevice(DEVICE_NAME_IPADPRO, SCREEN_WIDTH_IPADPRO, SCREEN_HEIGHT_IPADPRO, true
                     , true);

        //iphone_6_5
        CreateDevice(DEVICE_NAME_IPHONE_6_5, SCREEN_WIDTH_IPHONE_6_5, SCREEN_HEIGHT_IPHONE_6_5, true, true);


        //iphone
        CreateDevice(DEVICE_NAME_IPHONE, SCREEN_WIDTH_IPHONE, SCREEN_HEIGHT_IPHONE, true, true);


        //  ipad
        CreateDevice(DEVICE_NAME_IPAD, SCREEN_WIDTH_IPAD, SCREEN_HEIGHT_IPAD, true, false);

        //  1080p
        CreateDevice(DEVICE_NAME_1080P, SCREEN_WIDTH_1080P, SCREEN_HEIGHT_1080P, true, false);
        //  480p
        CreateDevice(DEVICE_NAME_480P, SCREEN_WIDTH_480P, SCREEN_HEIGHT_480P, true, true);


        //   weibo
        CreateDevice(DEVICE_NAME_WEIBO, SCREEN_WIDTH_WEIBO, SCREEN_HEIGHT_WEIBO, false, true);

        //   copy right huawei
        CreateDevice(DEVICE_NAME_COPY_RIGHT_HUAWEI, SCREEN_WIDTH_COPY_RIGHT_HUAWEI, SCREEN_HEIGHT_COPY_RIGHT_HUAWEI, false, true);

        // }

        {
            // //ICON
            CreateDevice(DEVICE_NAME_ICON, SCREEN_WIDTH_ICON, SCREEN_HEIGHT_ICON, false, true);
            //adhome
            CreateDevice(DEVICE_NAME_AD, 1024, 500, false, true);

            CreateDevice(DEVICE_NAME_AD, 1080, 480, false, true);
        }


        deviceInfoNow = listDevice[0];
    }
    void OnDeviceNext(bool isMain, out bool isfind)
    {
        // indexDevice++;
        // if (indexDevice >= listDevice.Count)
        // {
        //     indexDevice = 0;
        // }
        bool is_find      = false;
        int  first_device = 0;
        int  index        = 0;

        foreach (ShotDeviceInfo info in listDevice)
        {
            bool is_filter = isMain ? info.isMain : (!info.isMain);
            if (is_filter)
            {
                if (info.index > indexDevice)
                {
                    indexDevice = info.index;
                    is_find     = true;
                    break;
                }
                if (index == 0)
                {
                    first_device = info.index;
                }
                index++;
            }
        }
        if (!is_find)
        {
            //切换到第一个
            indexDevice = first_device;
        }
        isfind        = is_find;
        deviceInfoNow = listDevice[indexDevice];
        UpdateTotal();
        screenShotConfig.deviceInfo = deviceInfoNow;

        Language.main.SetLanguage(deviceInfoNow.lan);
        if (isMain)
        {
            SetScreen(deviceInfoNow.width, deviceInfoNow.height);
        }
        //更新
        if (Application.isEditor)
        {
            GotoScrenShot(indexScreenShot);
        }
    }
    public void OnClickBtnCopyRight()
    {
        indexScreenShot = 0;
        indexDevice     = 0;
        listDevice.Clear();
        {           //   copy right huawei
            ScreenDeviceInfo.main.CreateDevice(ScreenDeviceInfo.DEVICE_NAME_COPY_RIGHT_HUAWEI, ScreenDeviceInfo.SCREEN_WIDTH_COPY_RIGHT_HUAWEI, ScreenDeviceInfo.SCREEN_HEIGHT_COPY_RIGHT_HUAWEI, false, true);
            //CreateDevice(ScreenDeviceInfo.DEVICE_NAME_COPY_RIGHT_HD_HUAWEI, SCREEN_WIDTH_COPY_RIGHT_HUAWEI, SCREEN_HEIGHT_COPY_RIGHT_HUAWEI, false, true);
        }
        deviceInfoNow = listDevice[0];

        SetScreen(deviceInfoNow.width, deviceInfoNow.height);
        Invoke("OnClickSaveAuto", 2f);
    }
Esempio n. 10
0
    ShotDeviceInfo CreateDeviceItem(string name, int w, int h, SystemLanguage lan, bool isMain, bool isHd)
    {
        ShotDeviceInfo info = new ShotDeviceInfo();

        info.width    = w;
        info.height   = h;
        info.lan      = lan;
        info.name     = name;
        info.isIconHd = isHd;
        info.isMain   = isMain;
        info.index    = listDevice.Count;
        listDevice.Add(info);
        return(info);
    }
 /// <summary>
 /// Awake is called when the script instance is being loaded.
 /// </summary>
 void Awake()
 {
     Debug.Log("UIScreenShotController Awake");
     GameManager.main.isLoadGameScreenShot = true;
     screenShotConfig = new ScreenShotConfig();
     //mainCam = Common.GetMainCamera();
     LevelManager.main.ParsePlaceList();
     LevelManager.main.ParseGuanka();
     listDevice = ScreenDeviceInfo.main.listDevice;
     // InitDevice();
     indexScreenShot = 0;
     indexDevice     = 0;
     deviceInfoNow   = listDevice[indexDevice];
     SetScreen(deviceInfoNow.width, deviceInfoNow.height);
 }
    string GetSaveScreenShotFilePath(ShotDeviceInfo info, bool isPng)
    {
        string filedir = GetSaveDir(info);
        //microsoft 需要png
        string ext      = ".jpg";
        string filepath = filedir + "/" + (indexScreenShot + 1) + ext;

        if (isPng)
        {
            ext      = ".png";
            filepath = filedir + "/png/" + (indexScreenShot + 1) + ext;
            FileUtil.CreateDir(FileUtil.GetFileDir(filepath));
        }

        return(filepath);
    }
    int GetLastDevice(bool isMain)
    {
        int ret = 0;

        for (int i = listDevice.Count - 1; i >= 0; i--)
        {
            ShotDeviceInfo info      = listDevice[i];
            bool           is_filter = isMain ? info.isMain : (!info.isMain);
            if (is_filter)
            {
                ret = info.index;
                break;
            }
        }
        return(ret);
    }
    string GetSaveDir(ShotDeviceInfo info)
    {
        string ret     = "";
        string rootDir = GetRootDirOutPut();

        if (info.width > info.height)
        {
            ret = rootDir + "/screenshot/heng";
        }
        else
        {
            ret = rootDir + "/screenshot/shu";
        }

        string strlan = GetLanguageNameKey();


        if (deviceInfoNow.name == ScreenDeviceInfo.DEVICE_NAME_AD)
        {
            ret  = rootDir + "/" + info.name;
            ret += "/" + strlan;
        }
        else if (deviceInfoNow.name == ScreenDeviceInfo.DEVICE_NAME_ICON)
        {
            ret = GetRootDirIcon() + "/" + info.name;
            if (info.isIconHd)
            {
                ret += "hd";
            }
        }
        else if ((deviceInfoNow.name == ScreenDeviceInfo.DEVICE_NAME_COPY_RIGHT_HUAWEI) || (deviceInfoNow.name == ScreenDeviceInfo.DEVICE_NAME_COPY_RIGHT_HD_HUAWEI))
        {
            ret = rootDir + "/" + info.name;
            if (info.isIconHd)
            {
                ret += "hd";
            }
        }
        else
        {
            ret += "/" + strlan;
            ret += "/" + info.name;
        }
        //创建文件夹
        Directory.CreateDirectory(ret);
        return(ret);
    }
    void InitConvertDevice(out bool isHaveDevice)
    {
        isHaveDevice = false;
        //初始化第一个想要转换的设备
        foreach (ShotDeviceInfo info in listDevice)
        {
            if (!info.isMain)
            {
                indexDevice  = info.index;
                isHaveDevice = true;
                break;
            }
        }

        deviceInfoNow = listDevice[indexDevice];
        Debug.Log("InitConvertDevice:indexDevice=" + indexDevice + "name=" + deviceInfoNow.name);
    }
    public ShotItemInfo GetPage(ShotDeviceInfo dev, int idx)
    {
        ShotItemInfo     info       = new ShotItemInfo();
        UIViewController controller = null;

        info.isRealGameUI = true;
        if (dev.name == UIScreenShotController.DEVICE_NAME_ICON)
        {
            controller = IconViewController.main;
            IconViewController.main.deviceInfo = dev;
        }
        else if (dev.name == UIScreenShotController.DEVICE_NAME_AD)
        {
            controller = AdHomeViewController.main;
        }
        else if (dev.name == UIScreenShotController.DEVICE_NAME_COPY_RIGHT_HUAWEI)
        {
            controller = CopyRightViewController.main;
            CopyRightViewController.main.deviceInfo = dev;
        }
        else
        {
            switch (idx)
            {
            // case 0:
            //     controller = HomeViewController.main;
            //     break;
            // case 1:
            //     controller = GuankaViewController.main;
            //     break;
            // case 2:
            //     controller = GameViewController.main;
            //     break;
            // case 3:
            //   //  controller = HowToPlayViewController.main;
            //     break;
            default:
                controller = CopyRightViewController.main;
                break;
            }
        }
        info.controller = controller;

        return(info);
    }
    //获取长宽比例一致的mian device
    ShotDeviceInfo GetMainDevice(ShotDeviceInfo info)
    {
        ShotDeviceInfo infoRet = null;

        foreach (ShotDeviceInfo infotmp in listDevice)
        {
            if (infotmp.isMain)
            {
                float dif = Mathf.Abs(infotmp.width * 1f / infotmp.height - info.width * 1f / info.height);
                Debug.Log("dif=" + dif + " infotmp:w=" + infotmp.width + " h=" + infotmp.height + " info:w=" + info.width + " h=" + info.height);
                if (dif < 0.1f)
                {
                    infoRet = infotmp;
                    break;
                }
            }
        }
        return(infoRet);
    }
    public void InitDevice()
    {
        indexScreenShot = 0;
        indexDevice     = 0;

        listLanguage = new List <SystemLanguage>();
        listLanguage.Add(SystemLanguage.Chinese);
        listLanguage.Add(SystemLanguage.English);

        listDevice = new List <ShotDeviceInfo>();


        {
            // //ICON
            // CreateDevice(DEVICE_NAME_ICON, SCREEN_WIDTH_ICON, SCREEN_HEIGHT_ICON, false, true);
            // //adhome
            // CreateDevice(DEVICE_NAME_AD, 1024, 500, false, true);
            // CreateDevice(DEVICE_NAME_AD, 1080, 480, false, true);

            // // //ipadpro
            // CreateDevice(DEVICE_NAME_IPADPRO, SCREEN_WIDTH_IPADPRO, SCREEN_HEIGHT_IPADPRO, true, true);
            // //iphone
            // CreateDevice(DEVICE_NAME_IPHONE, SCREEN_WIDTH_IPHONE, SCREEN_HEIGHT_IPHONE, true, true);
            // //ipad
            // CreateDevice(DEVICE_NAME_IPAD, SCREEN_WIDTH_IPAD, SCREEN_HEIGHT_IPAD, true, false);

            // //1080p
            // CreateDevice(DEVICE_NAME_1080P, SCREEN_WIDTH_1080P, SCREEN_HEIGHT_1080P, true, false);

            // //weibo
            // CreateDevice(DEVICE_NAME_WEIBO, SCREEN_WIDTH_WEIBO, SCREEN_HEIGHT_WEIBO, false, true);

            //copy right huawei
            CreateDevice(DEVICE_NAME_COPY_RIGHT_HUAWEI, SCREEN_WIDTH_COPY_RIGHT_HUAWEI, SCREEN_HEIGHT_COPY_RIGHT_HUAWEI, false, true);
        }
        deviceInfoNow = listDevice[0];
    }
    void CreateDevice(string name, int w, int h, bool isBoth, bool isMain)
    {
        if (name == DEVICE_NAME_ICON)
        {
            {
                //icon
                ShotDeviceInfo info = new ShotDeviceInfo();
                info.width    = w;
                info.height   = h;
                info.lan      = SystemLanguage.Chinese;
                info.name     = name;
                info.isIconHd = false;
                info.isMain   = isMain;
                info.index    = listDevice.Count;
                listDevice.Add(info);
            }

            {
                //iconhd
                ShotDeviceInfo info = new ShotDeviceInfo();
                info.width    = w;
                info.height   = h;
                info.lan      = SystemLanguage.Chinese;
                info.name     = name;
                info.isIconHd = true;
                info.isMain   = isMain;
                info.index    = listDevice.Count;
                listDevice.Add(info);
            }
            return;
        }


        if (name == DEVICE_NAME_COPY_RIGHT_HUAWEI)
        {
            {
                //copyright
                ShotDeviceInfo info = new ShotDeviceInfo();
                info.width    = w;
                info.height   = h;
                info.lan      = SystemLanguage.Chinese;
                info.name     = name;
                info.isIconHd = false;
                info.isMain   = isMain;
                info.index    = listDevice.Count;
                listDevice.Add(info);
            }

            {
                //copyright hd
                ShotDeviceInfo info = new ShotDeviceInfo();
                info.width    = w;
                info.height   = h;
                info.lan      = SystemLanguage.Chinese;
                info.name     = name;
                info.isIconHd = true;
                info.isMain   = isMain;
                info.index    = listDevice.Count;
                listDevice.Add(info);
            }
            return;
        }

        if (isBoth)
        {
            foreach (SystemLanguage lan in listLanguage)
            {
                {
                    //竖屏
                    ShotDeviceInfo info = new ShotDeviceInfo();
                    info.width  = Mathf.Min(w, h);
                    info.height = Mathf.Max(w, h);
                    info.lan    = lan;
                    info.name   = name;
                    info.isMain = isMain;
                    info.index  = listDevice.Count;
                    listDevice.Add(info);
                    //Debug.Log("Add Device name=" + name + " lan =" + lan);
                }
            }

            foreach (SystemLanguage lan in listLanguage)
            {
                {
                    //横屏
                    ShotDeviceInfo info = new ShotDeviceInfo();
                    info.width  = Mathf.Max(w, h);
                    info.height = Mathf.Min(w, h);
                    info.lan    = lan;
                    info.name   = name;
                    info.isMain = isMain;
                    info.index  = listDevice.Count;
                    listDevice.Add(info);
                }
            }
        }
        else
        {
            foreach (SystemLanguage lan in listLanguage)
            {
                {
                    ShotDeviceInfo info = new ShotDeviceInfo();
                    info.width  = w;
                    info.height = h;
                    info.lan    = lan;
                    info.name   = name;
                    info.isMain = isMain;
                    info.index  = listDevice.Count;
                    listDevice.Add(info);
                    //Debug.Log("Add Device name=" + name + " lan =" + lan);
                }
            }
        }
    }