public virtual void load_screens(BinaryReader _br,
                                         project_data_desc _prj_data,
                                         data_sets_manager.EScreenDataType _scr_type,
                                         tiles_data _data)
        {
            int prj_scr_tiles_width  = (_prj_data.m_scr_blocks_width == 0xff) ? platform_data.get_screen_tiles_width_by_file_ext_uni(_prj_data.m_file_ext, _scr_type, true):(_scr_type == data_sets_manager.EScreenDataType.sdt_Tiles4x4 ? ((_prj_data.m_scr_blocks_width + 1) >> 1):_prj_data.m_scr_blocks_width);
            int prj_scr_tiles_height = (_prj_data.m_scr_blocks_height == 0xff) ? platform_data.get_screen_tiles_height_by_file_ext_uni(_prj_data.m_file_ext, _scr_type, true):(_scr_type == data_sets_manager.EScreenDataType.sdt_Tiles4x4 ? ((_prj_data.m_scr_blocks_height + 1) >> 1):_prj_data.m_scr_blocks_height);

            load_screens(_br, _prj_data.m_ver, _scr_type, _prj_data.m_scr_align, prj_scr_tiles_width, prj_scr_tiles_height, _data);
        }
        public DialogResult ShowDialog(project_data_desc _prj_data)
        {
            if (_prj_data.m_scr_blocks_width == 0xff && _prj_data.m_scr_blocks_height == 0xff)
            {
                CBoxUseFileScreenResolution.Checked = CBoxUseFileScreenResolution.Enabled = false;
            }
            else
            {
                CBoxUseFileScreenResolution.Enabled = true;
            }
#if !DEF_ZX
            CBoxConvertColors.Enabled = (platform_data.get_platform_type() == platform_data.get_platform_type_by_file_ext(_prj_data.m_file_ext)) ? false:true;
#endif
            return(ShowDialog());
        }
예제 #3
0
        public int load(BinaryReader _br, project_data_desc _prj_data, IProgress <int> _progress, IProgress <string> _status)
        {
            int load_progress = 0;

            byte data_id      = 0;
            int  data_set_pos = 0;

            do
            {
                data_id = _br.ReadByte();

                if (data_id == utils.CONST_IO_DATA_TILES_AND_SCREENS)
                {
                    _status.Report("Tiles && screens");

                    int data_cnt = _br.ReadInt32();

                    for (int i = 0; i < data_cnt; i++)
                    {
                        tiles_data_create();
                        get_tiles_data(tiles_data_pos).load(_br, _prj_data, screen_data_type);

                        _progress.Report(utils.calc_progress_val(ref load_progress, data_cnt, i));
                    }

                    data_set_pos = _br.ReadInt32();
                }
                else
                if (data_id == utils.CONST_IO_DATA_ENTITIES)
                {
                    _status.Report("Entities");

                    List <entity_data> ent_list;

                    entity_data ent;

                    int ents_cnt;
                    int grps_cnt = _br.ReadInt32();

                    string grp_name;

                    entities_data.Clear();

                    for (int grp_n = 0; grp_n < grps_cnt; grp_n++)
                    {
                        grp_name = _br.ReadString();

                        ent_list = new List <entity_data>();
                        entities_data.Add(grp_name, ent_list);

                        ents_cnt = _br.ReadInt32();

                        for (int ent_n = 0; ent_n < ents_cnt; ent_n++)
                        {
                            ent = new entity_data();
                            ent.load(_br, _prj_data.m_ver);

                            ent_list.Add(ent);
                        }
                    }

                    // dispatch_event_set_entities_data(); - moved to the post_load_update()

                    _progress.Report(utils.calc_progress_val_half(ref load_progress));
                }
                else
                if (data_id == utils.CONST_IO_DATA_LAYOUT)
                {
                    _status.Report("Layouts");

                    int layouts_data_cnt = _br.ReadInt32();

                    for (int i = 0; i < layouts_data_cnt; i++)
                    {
                        layout_data_create();
                        get_layout_data(layouts_data_pos).load(_br, _prj_data.m_ver, get_entity_by_name, screen_data_type);
                    }

                    entity_instance.load_instances_counter(_br);

                    _progress.Report(utils.calc_progress_val_half(ref load_progress));
                }
                else
                if (data_id == utils.CONST_IO_DATA_PALETTE)
                {
                    _status.Report("Palette");

                    int i;

                    int   plt_len  = platform_data.get_main_palette_colors_cnt(_prj_data.m_file_ext);
                    int[] plt_main = null;

                    bool ignore_palette = (_prj_data.m_file_ext != platform_data.get_platform_file_ext(platform_data.get_platform_type()));

                    if (ignore_palette)
                    {
                        if (_prj_data.m_convert_colors)
                        {
                            plt_main = platform_data.get_palette_by_file_ext(_prj_data.m_file_ext);

                            if (((_prj_data.m_ver <= 6) && (_prj_data.m_file_ext == platform_data.CONST_NES_FILE_EXT || _prj_data.m_file_ext == platform_data.CONST_SMS_FILE_EXT)) || (_prj_data.m_ver >= 7))
                            {
                                // load main palette from the project file
                                int data_pos = 0;

                                do
                                {
                                    plt_main[data_pos] = _br.ReadByte() << 16 | _br.ReadByte() << 8 | _br.ReadByte();
                                }while(++data_pos != plt_len);
                            }
                        }

                        project_data_converter_provider.get_converter().palettes_processing(_prj_data.m_ver, platform_data.get_platform_type_by_file_ext(_prj_data.m_file_ext), _prj_data.m_convert_colors, this, plt_main);

                        if (_prj_data.m_convert_colors)
                        {
                            for (i = 0; i < utils.CONST_NUM_SMALL_PALETTES; i++)
                            {
                                palette_group.Instance.get_palettes_arr()[i].update();
                            }
                        }
                        else
                        {
                            if (_prj_data.m_file_ext == platform_data.CONST_NES_FILE_EXT || _prj_data.m_file_ext == platform_data.CONST_SMS_FILE_EXT)
                            {
                                // skip palette
                                _br.ReadBytes(plt_len * 3);
                            }
                        }
                    }
                    else
                    {
                        if (((_prj_data.m_ver <= 6) && (_prj_data.m_file_ext == platform_data.CONST_NES_FILE_EXT || _prj_data.m_file_ext == platform_data.CONST_SMS_FILE_EXT)) || (_prj_data.m_ver >= 7))
                        {
                            palette_group.Instance.load_main_palette(_br);
                        }
                    }
#if DEF_FIXED_LEN_PALETTE16_ARR
                    // fill missing palette(s)
                    {
                        tiles_data data;

                        for (int data_n = 0; data_n < tiles_data_cnt; data_n++)
                        {
                            data = get_tiles_data(data_n);

                            for (i = data.palettes_arr.Count; i < platform_data.get_fixed_palette16_cnt(); i++)
                            {
                                data.palettes_arr.Add(new palette16_data());
                            }
                        }
                    }
#endif
                    _progress.Report(utils.calc_progress_val_half(ref load_progress));
                }
                else
                if (data_id == utils.CONST_IO_DATA_TILES_PATTERNS)
                {
                    _status.Report("Tiles Patterns");

                    int data_cnt = _br.ReadInt32();

                    for (int i = 0; i < data_cnt; i++)
                    {
                        m_tiles_data[i].load_tiles_patterns(_br, _prj_data.m_ver);
                    }

                    _progress.Report(utils.calc_progress_val_half(ref load_progress));
                }
            }while(data_id != utils.CONST_IO_DATA_END);

            return(data_set_pos);
        }