示例#1
0
        protected void gvResult_DeleteCommand(object source, DataGridCommandEventArgs e)
        {
            OwnerCollection dt = ((OwnerCollection)this.gvResult.DataSource);

            PubEntAdmin.BLL.Owner l_owner = dt[e.Item.DataSetIndex];
            int    Ownerid  = l_owner.OwnerID;
            string Fname    = l_owner.FirstName;
            string Lname    = l_owner.LastName;
            string Minitial = l_owner.MiddleInitial;

            string Activestatus = ((Button)e.Item.Cells[7].Controls[7]).Text;

            if (Activestatus == "Inactive")
            {
                Boolean ownerExist = LU_DAL.OwnerExist(Ownerid);

                if (ownerExist == false)
                {
                    LU_DAL.DeleteOwnerLU(Ownerid);
                    this.BindData();
                }
                else if (ownerExist == true)
                {
                    string confirm = "Unable to Inactivate, value associated with Publication.";
                    ((Label)e.Item.Cells[8].Controls[1]).Text = confirm;
                }
            }
            if (Activestatus == "Active")
            {
                LU_DAL.UpdateOwnerLU(Ownerid, Fname, Lname, Minitial);
                this.BindData();
            }
        }
        internal void AssignInitialValueAsync(List <BarcodeModel> _alerts)
        {
            try
            {
                ConstantManager.VerifiedBarcodes = _alerts;

                LoadOwnderAsync();
                LoadAssetSizeAsync();
                LoadAssetTypeAsync();
                var RealmDb = Realm.GetInstance(RealmDbManager.GetRealmDbConfig());

                foreach (var item in _alerts)
                {
                    AssetTypeModel selectedType  = null;
                    AssetSizeModel selectedSize  = null;
                    OwnerModel     selectedOwner = OwnerCollection.Where(x => x.FullName == item?.Kegs?.Partners?.FirstOrDefault()?.FullName).FirstOrDefault();

                    if (selectedOwner != null)
                    {
                        RealmDb.Write(() =>
                        {
                            selectedOwner.HasInitial = true;
                        });
                    }
                    if (item.Tags.Count > 2)
                    {
                        selectedType = TypeCollection.Where(x => x.AssetType == item.Tags?[2]?.Value).FirstOrDefault();

                        RealmDb.Write(() =>
                        {
                            selectedType.HasInitial = true;
                        });
                    }
                    if (item.Tags.Count > 3)
                    {
                        selectedSize = SizeCollection.Where(x => x.AssetSize == item.Tags?[3]?.Value).FirstOrDefault();
                        RealmDb.Write(() =>
                        {
                            selectedSize.HasInitial = true;
                        });
                    }

                    MaintenaceCollection.Add(
                        new MoveMaintenanceAlertModel
                    {
                        UOwnerCollection = OwnerCollection.ToList(),
                        USizeCollection  = SizeCollection.ToList(),
                        UTypeCollection  = TypeCollection.ToList(),
                        BarcodeId        = item.Barcode,
                        SelectedUOwner   = selectedOwner ?? selectedOwner,
                        SelectedUSize    = selectedSize ?? selectedSize,
                        SelectedUType    = selectedType ?? selectedType
                    });
                }
            }
            catch (Exception ex)
            {
                Crashes.TrackError(ex);
            }
        }
示例#3
0
        public OwnerCollection GetEnrolledOwnerCollection(int ownerId)
        {
            OwnerCollection ownerCollection = this.ownerResolver.GetOwnerCollection(ownerId);

            Trace.WriteLine("Owner Id: " + ownerId);
            Trace.WriteLine("Policy number: " + ownerCollection.OwnerInformation.PolicyNumber);
            return(ownerCollection);
        }
示例#4
0
        protected void gvResult_UpdateCommand(object source, DataGridCommandEventArgs e)
        {
            OwnerCollection dt = ((OwnerCollection)this.gvResult.DataSource);

            PubEntAdmin.BLL.Owner l_owner = dt[e.Item.DataSetIndex];
            int OwnerID = l_owner.OwnerID;

            string lname    = ((TextBox)e.Item.Cells[1].Controls[1]).Text.Trim();
            string fname    = ((TextBox)e.Item.Cells[2].Controls[1]).Text.Trim();
            string minitial = ((TextBox)e.Item.Cells[3].Controls[1]).Text;


            bool valid    = false;
            bool validlen = false;

            if (lname.Length != 0)
            {
                valid    = PubEntAdminManager.OtherVal(lname);
                validlen = PubEntAdminManager.LenVal(lname, 20);
            }


            if (fname.Length != 0)
            {
                valid    = PubEntAdminManager.OtherVal(fname);
                validlen = PubEntAdminManager.LenVal(fname, 20);
            }

            if (minitial.Length != 0)
            {
                valid    = PubEntAdminManager.OtherVal(minitial);
                validlen = PubEntAdminManager.LenVal(minitial, 1);
                minitial = minitial.Trim();
            }

            if ((valid == false) && (validlen == true))
            {
                OwnerCollection coll = LU_DAL.GetOwnerByFullname(fname, lname, minitial);
                if (coll.Count > 0)
                {
                    string confirm = "The Owner already existed.";
                    ((Label)e.Item.Cells[8].Controls[1]).Text = confirm;
                }
                else
                {
                    LU_DAL.UpdateOwnerLU(OwnerID, fname, lname, minitial);
                    this.gvResult.EditItemIndex = -1;
                    //this.BindDataAferUpdate();
                    this.BindData();
                }
            }
            else
            {
                Response.Redirect("InvalidInput.aspx");
            }
        }
 private void LoadOwnderAsync()
 {
     try
     {
         var RealmDb = Realm.GetInstance(RealmDbManager.GetRealmDbConfig());
         OwnerCollection = RealmDb.All <OwnerModel>().ToList();
         SelectedOwner   = OwnerCollection.OrderBy(x => x.FullName).FirstOrDefault();
     }
     catch (Exception ex)
     {
         Crashes.TrackError(ex);
     }
 }
示例#6
0
 /// <summary>
 /// Initializes a new instance of the CalendarModel class.
 /// </summary>
 public CalendarModel()
 {
     _Appointments = new AppointmentCollection(this);
     _Owners = new OwnerCollection(this);
     _WorkDays = new WorkDayCollection(this);
     _CalendarWorkDays = new CalendarWorkDayCollection(this);
     // Initialize default work-days
     _WorkDays.Add(new WorkDay(DayOfWeek.Monday));
     _WorkDays.Add(new WorkDay(DayOfWeek.Tuesday));
     _WorkDays.Add(new WorkDay(DayOfWeek.Wednesday));
     _WorkDays.Add(new WorkDay(DayOfWeek.Thursday));
     _WorkDays.Add(new WorkDay(DayOfWeek.Friday));
 }
        public InvoicePreviewCriteria BuildInvoicePreviewCriteriaFromInvoice(OwnerCollection ownerCollection, InvoiceWithItems invoice, string IsoAlpha3Code)
        {
            InvoicePreviewCriteria ret = new InvoicePreviewCriteria();

            ret.PostalCode = ownerCollection.AddressInformation.Zipcode;
            ret.IsoAlpha2SateOrProvinceCode = "Minnesota"; // ownerCollection.AddressInformation.StateId.ToString();
            ret.IsoAlpha3CountryCode        = IsoAlpha3Code;
            InvoicePreviewItemCriteria item = new InvoicePreviewItemCriteria();

            item.Amount         = invoice.Amount;
            item.DiscountAmount = 0;
            item.ProductId      = "2c91a0f8557bc1f401557f2ceb5e1d31";    // "Pet Insurance";
            ret.Items.Add(item);
            return(ret);
        }
示例#8
0
        private AnimDrawable LoadUpgrade(StructureObject structObj, int upgradeSlot, DrawProperties inheritProps)
        {
            string upgradeName = "";

            if (upgradeSlot == 0)
            {
                upgradeName = structObj.Upgrade1;
            }
            else if (upgradeSlot == 1)
            {
                upgradeName = structObj.Upgrade2;
            }
            else if (upgradeSlot == 2)
            {
                upgradeName = structObj.Upgrade3;
            }

            IniFile.IniSection upgradeRules = OwnerCollection.Rules.GetOrCreateSection(upgradeName);
            if (upgradeRules != null && upgradeRules.HasKey("Image"))
            {
                upgradeName = upgradeRules.ReadString("Image");
            }
            IniFile.IniSection upgradeArt = OwnerCollection.Art.GetOrCreateSection(upgradeName);
            if (upgradeArt != null && upgradeArt.HasKey("Image"))
            {
                upgradeName = upgradeArt.ReadString("Image");
            }

            IniFile.IniSection upgRules = OwnerCollection.Rules.GetOrCreateSection(upgradeName);
            IniFile.IniSection upgArt   = OwnerCollection.Art.GetOrCreateSection(upgradeName);
            AnimDrawable       upgrade  = new AnimDrawable(_config, _vfs, upgRules, upgArt);

            upgrade.OwnerCollection = OwnerCollection;
            upgrade.Props           = inheritProps;
            upgrade.LoadFromRules();
            upgrade.NewTheater     = this.NewTheater;
            upgrade.IsBuildingPart = true;
            string shpfilename = NewTheater ? OwnerCollection.ApplyNewTheaterIfNeeded(upgradeName, upgradeName + ".shp") : upgradeName + ".shp";

            upgrade.Shp = _vfs.Open <ShpFile>(shpfilename);
            Point powerupOffset = new Point(_powerupSlots[upgradeSlot].X, _powerupSlots[upgradeSlot].Y);

            upgrade.Props.Offset.Offset(powerupOffset);
            return(upgrade);
        }
示例#9
0
        public string GetFilename()
        {
            string fn = Image;

            if (TheaterExtension)
            {
                fn += ModConfig.ActiveTheater.Extension;
            }
            else
            {
                fn += ".shp";
            }
            if (NewTheater)
            {
                fn = OwnerCollection.ApplyNewTheaterIfNeeded(Art.Name, fn);
            }
            return(fn);
        }
示例#10
0
        private void OrderAsInList(IEnumerable <Guid> componentGuids)
        {
            Dictionary <Guid, TComponentType> map = new Dictionary <Guid, TComponentType>();

            foreach (Guid componentGuid in componentGuids)
            {
                TComponentType a = Project.TranslateComponent <TComponentType>(componentGuid);
                OwnerCollection.RemoveAsGuidSilent(a);
                map[componentGuid] = a;
            }
            foreach (Guid attributeGuid in componentGuids)
            {
                OwnerCollection.AddAsGuidSilent(map[attributeGuid]);
            }
            NotifyCollectionChangedEventArgs e = new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset);

            OwnerCollection.InvokeCollectionChanged(e);
        }
示例#11
0
        //protected ITestDataManager TestDataManager
        //{
        //    get
        //    {
        //        return testDataManager;
        //    }
        //}

        public void InitTestClass()
        {
            try
            {
                ServiceFactory.InitializeServiceFactory(new ContainerConfiguration(ApplicationProfileType.TestFramework));
                testDataManager = IocContainer.Resolve <ITestDataManager>();

                serializer = ServiceFactory.Instance.Create <IJsonSerialization>();

                qaLibRestClient         = new QALibRestClient();
                ownerCollection         = new OwnerCollection();
                accountExpected         = new Account();
                accountExpected.AutoPay = true;

                random = new Random();
            }
            catch (Exception ex)
            {
                BillingTestCommon.log.Fatal(ex);
            }
            Assert.IsNotNull(testDataManager);
        }
示例#12
0
        protected void gvResult_ItemDataBound(object sender, DataGridItemEventArgs e)
        {
            OwnerCollection dt = ((OwnerCollection)this.gvResult.DataSource);

            if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
            {
                PubEntAdmin.BLL.Owner l_owner = dt[e.Item.DataSetIndex];

                //delete btn col
                Button l_able = e.Item.Cells[7].FindControl("lnkbtnDel") as Button;

                if (l_owner.Checked)
                {
                    ((Label)e.Item.Cells[5].Controls[1]).Text = "Active";
                    l_able.Text = "Inactivate";
                    Panel l_pnl = e.Item.Cells[7].FindControl("pnlConfirmDel") as Panel;
                    ((Label)l_pnl.Controls[1]).Text = "Are you sure you want to inactivate this Lookup Value [" + Server.HtmlEncode(l_owner.LastName + ',' + l_owner.FirstName) + "]?";
                }
                else
                {
                    ((Label)e.Item.Cells[5].Controls[1]).Text = "Inactive";
                    l_able.Text = "Activate";
                    Panel l_pnl = e.Item.Cells[7].FindControl("pnlConfirmDel") as Panel;
                    ((Label)l_pnl.Controls[1]).Text = "Are you sure you want to activate this Lookup Value [" + Server.HtmlEncode(l_owner.LastName + ',' + l_owner.FirstName) + "]?";

                    ((Button)e.Item.Cells[6].Controls[0]).Enabled = false;
                }
            }
            else if (e.Item.ItemType == ListItemType.EditItem)
            {
                PubEntAdmin.BLL.Owner l_owner = dt[e.Item.ItemIndex];
                String status = "";
                if (l_owner.Checked == true)
                {
                    status = "Active";
                }
                else
                {
                    status = "Inactive";
                }
                ((Label)e.Item.Cells[5].Controls[1]).Text = status;

                if (e.Item.Cells[6].Controls[2] is Button)
                {
                    Button l_btnCancel = ((Button)e.Item.Cells[6].Controls[2]);
                    l_btnCancel.ID = "gvResult_Cancel";

                    Panel l_panel = new Panel();
                    l_panel.ID       = "l_panel";
                    l_panel.CssClass = "modalPopup";
                    l_panel.Style.Add("display", "none");
                    l_panel.Width = Unit.Pixel(233);

                    Label l_label = new Label();
                    l_label.Text = "Are you sure you want to continue?";

                    HtmlGenericControl l_div    = new HtmlGenericControl();
                    Button             l_ok     = new Button();
                    Button             l_cancel = new Button();
                    l_ok.ID       = "l_ok";
                    l_ok.Text     = "OK";
                    l_cancel.ID   = "l_cancel";
                    l_cancel.Text = "Cancel";
                    l_div.Controls.Add(l_ok);
                    l_div.Controls.Add(new LiteralControl("&nbsp;"));
                    l_div.Controls.Add(l_cancel);
                    l_div.Attributes.Add("align", "center");

                    l_panel.Controls.Add(l_label);
                    l_panel.Controls.Add(new LiteralControl("<br>"));
                    l_panel.Controls.Add(new LiteralControl("<br>"));
                    l_panel.Controls.Add(l_div);

                    ModalPopupExtender l_mpe = new ModalPopupExtender();
                    l_mpe.ID = "l_mpe";
                    l_mpe.TargetControlID    = l_btnCancel.ID;
                    l_mpe.PopupControlID     = l_panel.ID;
                    l_mpe.BackgroundCssClass = "modalBackground";
                    l_mpe.DropShadow         = true;
                    l_mpe.OkControlID        = l_ok.ID;
                    l_mpe.CancelControlID    = l_cancel.ID;


                    ConfirmButtonExtender l_cbe = new ConfirmButtonExtender();
                    l_cbe.TargetControlID     = l_btnCancel.ID;
                    l_cbe.ConfirmText         = "";
                    l_cbe.DisplayModalPopupID = l_mpe.ID;

                    e.Item.Cells[6].Controls.Add(l_panel);
                    e.Item.Cells[6].Controls.Add(l_mpe);
                    e.Item.Cells[6].Controls.Add(l_cbe);
                }

                //delete btn col
                Button l_able = e.Item.Cells[7].FindControl("lnkbtnDel") as Button;

                if (l_owner.Checked)
                {
                    ((Label)e.Item.Cells[5].Controls[1]).Text = "Active";
                    l_able.Text = "Inactivate";
                    Panel l_pnl = e.Item.Cells[6].FindControl("pnlConfirmDel") as Panel;
                    ((Label)l_pnl.Controls[1]).Text = "Are you sure you want to inactivate this Lookup Value [" + Server.HtmlEncode(l_owner.LastName + ',' + l_owner.FirstName) + "]?";
                }
                else
                {
                    ((Label)e.Item.Cells[5].Controls[1]).Text = "Inactive";
                    l_able.Text = "Activate";
                    Panel l_pnl = e.Item.Cells[7].FindControl("pnlConfirmDel") as Panel;
                    ((Label)l_pnl.Controls[1]).Text = "Are you sure you want to activate this Lookup Value [" + Server.HtmlEncode(l_owner.LastName + ',' + l_owner.FirstName) + "]?";
                }
            }
        }
示例#13
0
        public override void LoadFromRules()
        {
            base.LoadFromRules();

            IsBuildingPart  = true;
            InvisibleInGame = Rules.ReadBool("InvisibleInGame") || LampNames.Contains(Name.ToUpper());

            string foundation = Art.ReadString("Foundation", "1x1");

            if (!foundation.Equals("custom", StringComparison.InvariantCultureIgnoreCase))
            {
                int fx = foundation[0] - '0';
                int fy = foundation[2] - '0';
                Foundation = new Size(fx, fy);
            }
            else
            {
                int fx = Art.ReadInt("Foundation.X", 1);
                int fy = Art.ReadInt("Foundation.Y", 1);
                Foundation = new Size(fx, fy);
            }
            Props.SortIndex = Art.ReadInt("NormalYSort") - Art.ReadInt("NormalZAdjust");             // "main" building image before anims

            _baseShp = new ShpDrawable(Rules, Art);
            _baseShp.OwnerCollection = OwnerCollection;
            _baseShp.LoadFromArtEssential();
            _baseShp.Props = Props;
            _baseShp.Shp   = VFS.Open <ShpFile>(_baseShp.GetFilename());

            var extraProps = Props.Clone();

            extraProps.SortIndex = 0;
            foreach (string extraImage in AnimImages)
            {
                var extra = LoadExtraImage(extraImage, extraProps);
                if (extra != null && extra.Shp != null)
                {
                    _anims.Add(extra);

                    var extraDmg = LoadExtraImage(extraImage + "Damaged", extra.Props);
                    if (extraDmg != null && extraDmg.Shp != null)
                    {
                        _animsDamaged.Add(extraDmg);
                    }
                    else                     // no damaged anim --> use normal anim also in damaged state
                    {
                        _animsDamaged.Add(extra);
                    }
                }
            }

            // Starkku: New code for adding fire animations to buildings, supports custom-paletted animations.
            if (OwnerCollection.Engine >= EngineType.RedAlert2)
            {
                LoadFireAnimations();
            }

            // Add turrets
            if (Rules.ReadBool("Turret") && Rules.HasKey("TurretAnim"))
            {
                string   turretName = Rules.ReadString("TurretAnim");
                Drawable turret     = Rules.ReadBool("TurretAnimIsVoxel")
                                        ? (Drawable) new VoxelDrawable(VFS.Open <VxlFile>(turretName + ".vxl"), VFS.Open <HvaFile>(turretName + ".hva"))
                                        : new ShpDrawable(VFS.Open <ShpFile>(turretName + ".shp"));
                turret.Props.Offset       = Props.Offset + new Size(Rules.ReadInt("TurretAnimX"), Rules.ReadInt("TurretAnimY"));
                turret.Props.HasShadow    = Rules.ReadBool("UseTurretShadow");
                turret.Props.FrameDecider = FrameDeciders.TurretFrameDecider;
                turret.Props.ZAdjust      = Rules.ReadInt("TurretAnimZAdjust");
                SubDrawables.Add(turret);

                if (turret is VoxelDrawable && turretName.ToUpper().Contains("TUR"))
                {
                    string barrelName = turretName.Replace("TUR", "BARL");
                    if (VFS.Exists(barrelName + ".vxl"))
                    {
                        var barrel = new VoxelDrawable(VFS.Open <VxlFile>(barrelName + ".vxl"), VFS.Open <HvaFile>(barrelName + ".hva"));
                        SubDrawables.Add(barrel);
                        barrel.Props = turret.Props;
                    }
                }
            }

            // Bib
            if (Art.HasKey("BibShape"))
            {
                var bibImg = Art.ReadString("BibShape") + ".shp";
                if (NewTheater)
                {
                    bibImg = OwnerCollection.ApplyNewTheaterIfNeeded(bibImg, bibImg);
                }
                var bibShp = VFS.Open <ShpFile>(bibImg);
                if (bibShp != null)
                {
                    var bib = new ShpDrawable(bibShp);
                    bib.Props = this.Props.Clone();
                    bib.Flat  = true;
                    SubDrawables.Add(bib);
                }
            }

            // Powerup slots, at most 3
            for (int i = 1; i <= 3; i++)
            {
                if (!Art.HasKey(String.Format("PowerUp{0}LocXX", i)))
                {
                    break;
                }
                _powerupSlots.Add(new PowerupSlot {
                    X     = Art.ReadInt(String.Format("PowerUp{0}LocXX", i)),
                    Y     = Art.ReadInt(String.Format("PowerUp{0}LocYY", i)),
                    Z     = Art.ReadInt(String.Format("PowerUp{0}LocZZ", i)),
                    YSort = Art.ReadInt(String.Format("PowerUp{0}LocYSort", i)),
                });
            }
        }
示例#14
0
        public override void Draw(GameObject obj, DrawingSurface ds, bool shadows = true)
        {
            if (InvisibleInGame)
            {
                return;
            }

            var drawList = new List <Drawable>();

            drawList.Add(_baseShp);

            if (obj is StructureObject && (obj as StructureObject).Health < 128)
            {
                drawList.AddRange(_animsDamaged);
                drawList.AddRange(_fires);
            }
            else
            {
                drawList.AddRange(_anims);
            }

            drawList.AddRange(SubDrawables);             // bib

            /* order:
             * ActiveAnims+Flat=yes
             * BibShape
             * ActiveAnims (+ZAdjust=0)
             * Building
             * ActiveAnims+ZAdjust=-32 */
            drawList = drawList.OrderBy(d => d.Flat ? -1 : 1).ThenBy(d => d.Props.SortIndex).ToList();

            foreach (var d in drawList)
            {
                d.Draw(obj, ds, false);
            }
            if (shadows)
            {
                foreach (var d in drawList)
                {
                    d.DrawShadow(obj, ds);
                }
            }

            var strObj = obj as StructureObject;

            if (!strObj.Upgrade1.Equals("None", StringComparison.InvariantCultureIgnoreCase) && _powerupSlots.Count >= 1)
            {
                var powerup = OwnerCollection.GetDrawable(strObj.Upgrade1);
                DrawPowerup(obj, powerup, 0, ds);
            }

            if (!strObj.Upgrade2.Equals("None", StringComparison.InvariantCultureIgnoreCase) && _powerupSlots.Count >= 2)
            {
                var powerup = OwnerCollection.GetDrawable(strObj.Upgrade2);
                DrawPowerup(obj, powerup, 1, ds);
            }

            if (!strObj.Upgrade3.Equals("None", StringComparison.InvariantCultureIgnoreCase) && _powerupSlots.Count >= 3)
            {
                var powerup = OwnerCollection.GetDrawable(strObj.Upgrade3);
                DrawPowerup(obj, powerup, 2, ds);
            }
        }
示例#15
0
        public override void LoadFromRules()
        {
            base.LoadFromRules();

            IsBuildingPart  = true;
            InvisibleInGame = Rules.ReadBool("InvisibleInGame") || LampNames.Contains(Name.ToUpper());
            string foundation = Art.ReadString("Foundation", "1x1");

            if (!foundation.Equals("custom", StringComparison.InvariantCultureIgnoreCase))
            {
                int fx = foundation[0] - '0';
                int fy = foundation[2] - '0';
                Foundation = new Size(fx, fy);
            }
            else
            {
                int fx = Art.ReadInt("Foundation.X", 1);
                int fy = Art.ReadInt("Foundation.Y", 1);
                Foundation = new Size(fx, fy);
            }
            Props.SortIndex       = Art.ReadInt("NormalYSort") - Art.ReadInt("NormalZAdjust");       // "main" building image before anims
            Props.ZShapePointMove = Art.ReadPoint("ZShapePointMove");

            _canBeOccupied         = Rules.ReadBool("CanBeOccupied");
            _techLevel             = Rules.ReadInt("TechLevel");
            _conditionYellowHealth = 128;
            _conditionRedHealth    = 64;
            IniFile.IniSection audioVisual = OwnerCollection.Rules.GetOrCreateSection("AudioVisual");
            if (audioVisual != null)
            {
                if (audioVisual.HasKey("ConditionYellow"))
                {
                    int conditionYellow = audioVisual.ReadPercent("ConditionYellow");
                    _conditionYellowHealth = (int)(256 * (double)conditionYellow / 100);
                }
                if (audioVisual.HasKey("ConditionRed"))
                {
                    int conditionRed = audioVisual.ReadPercent("ConditionRed");
                    _conditionRedHealth = (int)(256 * (double)conditionRed / 100);
                }
            }
            _baseShp = new ShpDrawable(_config, _vfs, Rules, Art);
            _baseShp.OwnerCollection = OwnerCollection;
            _baseShp.LoadFromArtEssential();
            _baseShp.Props = Props;
            _baseShp.Shp   = _vfs.Open <ShpFile>(_baseShp.GetFilename());

            var extraProps = Props.Clone();

            extraProps.SortIndex = 0;
            foreach (string extraImage in AnimImages)
            {
                var extra = LoadExtraImage(extraImage, extraProps);
                if (extra != null && extra.Shp != null)
                {
                    _anims.Add(extra);

                    var extraDmg = LoadExtraImage(extraImage + "Damaged", extra.Props);
                    if (extraDmg != null && extraDmg.Shp != null)
                    {
                        _animsDamaged.Add(extraDmg);
                    }
                    else                     // no damaged anim --> use normal anim also in damaged state
                    {
                        _animsDamaged.Add(extra);
                    }
                }
            }

            // RA2 and later support adding fire animations to buildings, supports custom-paletted animations.
            if (_config.Engine >= EngineType.RedAlert2)
            {
                LoadFireAnimations();
            }

            // Add turrets
            if (Rules.ReadBool("Turret") && Rules.HasKey("TurretAnim"))
            {
                string             turretName = Rules.ReadString("TurretAnim");
                IniFile.IniSection turretArt  = OwnerCollection.Art.GetOrCreateSection(turretName);
                if (turretArt.HasKey("Image"))
                {
                    turretName = turretArt.ReadString("Image");
                }
                // NewTheater/generic image fallback support for turrets.
                string   turretNameShp = NewTheater ? OwnerCollection.ApplyNewTheaterIfNeeded(turretName, turretName + ".shp") : turretName + ".shp";
                Drawable turret        = Rules.ReadBool("TurretAnimIsVoxel")
                                        ? (Drawable) new VoxelDrawable(_config, _vfs.Open <VxlFile>(turretName + ".vxl"), _vfs.Open <HvaFile>(turretName + ".hva"))
                                        : (Drawable) new ShpDrawable(new ShpRenderer(_config, _vfs), _vfs.Open <ShpFile>(turretNameShp));
                turret.Props.Offset       = Props.Offset + new Size(Rules.ReadInt("TurretAnimX"), Rules.ReadInt("TurretAnimY"));
                turret.Props.HasShadow    = Rules.ReadBool("UseTurretShadow");
                turret.Props.FrameDecider = FrameDeciders.TurretFrameDecider;
                turret.Props.ZAdjust      = Rules.ReadInt("TurretAnimZAdjust");
                turret.Props.Cloakable    = Props.Cloakable;
                SubDrawables.Add(turret);

                if (turret is VoxelDrawable && turretName.ToUpper().Contains("TUR"))
                {
                    string barrelName = turretName.Replace("TUR", "BARL");
                    if (_vfs.FileExists(barrelName + ".vxl"))
                    {
                        var barrel = new VoxelDrawable(_config, _vfs.Open <VxlFile>(barrelName + ".vxl"), _vfs.Open <HvaFile>(barrelName + ".hva"));
                        SubDrawables.Add(barrel);
                        barrel.Props = turret.Props;
                    }
                }
            }

            // Bib
            if (Art.HasKey("BibShape"))
            {
                var bibImg = Art.ReadString("BibShape") + ".shp";
                if (NewTheater)
                {
                    bibImg = OwnerCollection.ApplyNewTheaterIfNeeded(bibImg, bibImg);
                }
                var bibShp = _vfs.Open <ShpFile>(bibImg);
                if (bibShp != null)
                {
                    var bib = new ShpDrawable(new ShpRenderer(_config, _vfs), bibShp);
                    bib.Props = this.Props.Clone();
                    bib.Flat  = true;
                    SubDrawables.Add(bib);
                }
            }

            // Powerup slots, at most 3
            for (int i = 1; i <= 3; i++)
            {
                _powerupSlots.Add(new PowerupSlot {
                    X     = Art.ReadInt(String.Format("PowerUp{0}LocXX", i), 0),
                    Y     = Art.ReadInt(String.Format("PowerUp{0}LocYY", i), 0),
                    Z     = Art.ReadInt(String.Format("PowerUp{0}LocZZ", i), 0),
                    YSort = Art.ReadInt(String.Format("PowerUp{0}LocYSort", i), 0),
                });
            }

            if (IsWall && _baseShp.Shp != null)
            {
                _baseShp.Shp.Initialize();
                if (_baseShp.Shp.NumImages >= 32)
                {
                    IsActualWall = true;
                }
            }
        }
示例#16
0
 public void Invalidate()
 {
     IsValid = false;
     ParentRepository.Invalidate();
     OwnerCollection.NotifyValidCountChanged();
 }