Exemple #1
0
        public mpd_base_entity get_base_entity_by_name(string _name)
        {
            entity_data ent = m_data_mngr.get_entity_by_name(_name);

            if (ent != null)
            {
                return(fill_mpd_base_entity(ent));
            }

            return(null);
        }
Exemple #2
0
        public entity_instance(string _prop, int _x, int _y, entity_data _base)
        {
            properties = _prop;

            x = _x;
            y = _y;

            base_entity = _base;

            m_uid = ++__instances_cnt;
        }
        public entity_data get_entity_by_name(string _name)
        {
            entity_data ent = null;

            foreach (var key in entities_data.Keys)
            {
                (entities_data[key] as List <entity_data>).ForEach(delegate(entity_data _ent) { if (_ent.name == _name)
                                                                                                {
                                                                                                    ent = _ent; return;
                                                                                                }
                                                                   });
            }

            return(ent);
        }
Exemple #4
0
        private mpd_base_entity fill_mpd_base_entity(entity_data _ent)
        {
            mpd_base_entity base_ent = new mpd_base_entity();

            base_ent.uid             = _ent.uid;
            base_ent.width           = _ent.width;
            base_ent.height          = _ent.height;
            base_ent.pivot_x         = _ent.pivot_x;
            base_ent.pivot_y         = _ent.pivot_y;
            base_ent.name            = _ent.name;
            base_ent.properties      = _ent.properties;
            base_ent.inst_properties = _ent.inst_properties;

            return(base_ent);
        }
Exemple #5
0
        public void load(BinaryReader _br,
                         byte _ver,
                         Func <string, entity_data> _get_ent,
                         data_sets_manager.EScreenDataType _scr_type)
        {
            string base_ent_name;

            base_ent_name = _br.ReadString();
            base_entity   = _get_ent(base_ent_name);

            if (base_entity == null)
            {
                throw new Exception("Can't find base entity: " + base_ent_name + "\n\nEntity instance loading error!");
            }

            properties = _br.ReadString();
            x          = _br.ReadInt32();
            y          = _br.ReadInt32();
            m_uid      = _br.ReadInt32();
            target_uid = _br.ReadInt32();

            {
                int       CHRs_in_tile = (_scr_type == data_sets_manager.EScreenDataType.sdt_Tiles4x4) ? 32:16;
                Rectangle prj_scr_rect = project_data_converter_provider.get_converter().get_prj_scr_rect();

                y += prj_scr_rect.Y * CHRs_in_tile;
                x += prj_scr_rect.X * CHRs_in_tile;

                y = y < 0 ? 0:y;
                y = (y >= platform_data.get_screen_height_pixels()) ? (platform_data.get_screen_height_pixels() - 1):y;

                x = x < 0 ? 0:x;
                x = (x >= platform_data.get_screen_width_pixels()) ? (platform_data.get_screen_width_pixels() - 1):x;
            }

            // extra data ( reserved for future purposes )
            int extra_data_size = _br.ReadInt32();
        }
Exemple #6
0
 public void reset()
 {
     properties  = null;
     base_entity = null;
 }
        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);
        }