Example #1
0
    private void PopulateNoiseLegend(OverlayInfo info)
    {
        if (info.infoUnits != null && info.infoUnits.Count > 0)
        {
            PopulateOverlayInfoUnits(info, false);
        }
        string[] names  = Enum.GetNames(typeof(AudioEventManager.NoiseEffect));
        Array    values = Enum.GetValues(typeof(AudioEventManager.NoiseEffect));

        Color[] dbColours = SimDebugView.dbColours;
        for (int i = 0; i < names.Length; i++)
        {
            GameObject freeUnitObject = GetFreeUnitObject();
            Image      component      = freeUnitObject.transform.Find("Icon").GetComponent <Image>();
            component.gameObject.SetActive(true);
            component.sprite  = Assets.instance.LegendColourBox;
            component.color   = ((i != 0) ? Color.Lerp(dbColours[i * 2], dbColours[Mathf.Min(dbColours.Length - 1, i * 2 + 1)], 0.5f) : new Color(1f, 1f, 1f, 0.7f));
            component.enabled = true;
            component.type    = Image.Type.Simple;
            string  str  = names[i].ToUpper();
            int     num  = (int)values.GetValue(i);
            int     num2 = (int)values.GetValue(i);
            LocText componentInChildren = freeUnitObject.GetComponentInChildren <LocText>();
            componentInChildren.text    = Strings.Get("STRINGS.UI.OVERLAYS.NOISE_POLLUTION.NAMES." + str) + " " + string.Format(UI.OVERLAYS.NOISE_POLLUTION.RANGE, num);
            componentInChildren.color   = Color.white;
            componentInChildren.enabled = true;
            ToolTip component2 = freeUnitObject.GetComponent <ToolTip>();
            component2.enabled = true;
            component2.toolTip = string.Format(Strings.Get("STRINGS.UI.OVERLAYS.NOISE_POLLUTION.TOOLTIPS." + str), num, num2);
            freeUnitObject.SetActive(true);
            freeUnitObject.transform.SetParent(activeUnitsParent.transform);
        }
    }
        public void WriteFrame(BinaryWriter writer, OverlayInfo info)
        {
            switch (Version)
            {
            case 3:
                writer.Write(info.FrameNumber + 1);
                writer.Write(info.Diff);
                writer.Write((short)info.X);
                writer.Write((short)info.Y);
                writer.Write((short)info.Width);
                writer.Write((short)info.Height);
                writer.Write((short)info.CropLeft);
                writer.Write((short)info.CropTop);
                writer.Write((short)info.CropRight);
                writer.Write((short)info.CropBottom);
                writer.Write((short)info.Angle);
                writer.Write((short)info.BaseWidth);
                writer.Write((short)info.BaseHeight);
                writer.Write((short)info.SourceWidth);
                writer.Write((short)info.SourceHeight);
                break;

            default:
                throw new InvalidOperationException();
            }
        }
Example #3
0
        public FrameContext(OverlayContext ctx, OverlayInfo info)
        {
            this.ctx    = ctx;
            Info        = info;
            Source      = ctx.Source;
            Overlay     = ctx.Overlay;
            SourceSize  = ctx.SourceInfo.Size;
            OverlaySize = ctx.OverlayInfo.Size;
            Info        = Info.Resize(SourceSize, OverlaySize);
            if (ctx.Render.Mode == FramingMode.Fit && SourceSize != ctx.TargetInfo.Size)
            {
                Info   = Info.Resize(ctx.TargetInfo.Size, OverlaySize);
                Source = Source.Invoke(SourceSize.GetArea() < ctx.TargetInfo.Size.GetArea() ? ctx.Render.Upsize : ctx.Render.Downsize,
                                       ctx.TargetInfo.Width, ctx.TargetInfo.Height);
                SourceSize = ctx.TargetInfo.Size;
            }
            if (ctx.Render.Mode == FramingMode.Fit)
            {
                Info = Info.Shrink(SourceSize, OverlaySize);
            }
            var resizeFunc = Info.Width > OverlaySize.Width ? ctx.Render.Upsize : ctx.Render.Downsize;
            var crop       = Info.GetCrop();

            Overlay     = ctx.Render.ResizeRotate(Overlay, resizeFunc, null, Info.Width, Info.Height, 0, crop, Info.Warp);
            OverlayMask = ctx.Render.ResizeRotate(ctx.OverlayMask, "BicubicResize", null, Info.Width, Info.Height, 0, crop, Info.Warp);
            InitColorAdjust();
        }
Example #4
0
    static SkillInfo()
    {
        foreach (var row in sheet)
        {
            if (row.id == -1)
            {
                continue;
            }

            if (row.charClass != null)
            {
                row._iconSpritesheetFilename = @"data\global\ui\spells\" + row.charClass.Substring(0, 2) + "Skillicon";
            }
            else
            {
                row._iconSpritesheetFilename = @"data\global\ui\spells\Skillicon";
            }
            row.castOverlay  = OverlayInfo.Find(row.castOverlayId);
            row.startSound   = SoundInfo.Find(row._stsound);
            row._description = SkillDescription.Find(row.skillDescId);
            if (row._description != null)
            {
                row.name             = Translation.Find(row._description.strName);
                row.shortDescription = Translation.Find(row._description.strShort);
                row.longDescription  = Translation.Find(row._description.strLong);
                row.shortName        = Translation.Find(row._description.strAlt);
            }
            else
            {
                row.name = row.skill;
            }
            if (row._range == "none")
            {
                row.range = Range.NoRestrictions;
            }
            else if (row._range == "h2h")
            {
                row.range = Range.Melee;
            }
            else if (row._range == "rng")
            {
                row.range = Range.Ranged;
            }
            else if (row._range == "both")
            {
                row.range = Range.Both;
            }
            else
            {
                throw new System.Exception("Unknown skill range " + row._range);
            }
            map.Add(row.skill, row);
            idMap.Add(row.id, row);
        }

        Attack = Find("Attack");
    }
Example #5
0
    static SkillInfo()
    {
        int    charOffset = 0;
        string charClass  = null;

        foreach (var row in sheet)
        {
            if (row.id == -1)
            {
                continue;
            }

            if (charClass != row.charClass)
            {
                charClass  = row.charClass;
                charOffset = row.id;
            }

            row.name = Translation.Find("skillname" + row.id);
            if (row.charClass != null)
            {
                row.iconSpritesheetFilename = @"data\global\ui\spells\" + row.charClass.Substring(0, 2) + "Skillicon";
            }
            else
            {
                row.iconSpritesheetFilename = @"data\global\ui\spells\Skillicon";
            }
            row.iconIndex   = row.id - charOffset;
            row.castOverlay = OverlayInfo.Find(row.castOverlayId);
            row.startSound  = SoundInfo.Find(row._stsound);
            if (row._range == "none")
            {
                row.range = Range.NoRestrictions;
            }
            else if (row._range == "h2h")
            {
                row.range = Range.Melee;
            }
            else if (row._range == "rng")
            {
                row.range = Range.Ranged;
            }
            else if (row._range == "both")
            {
                row.range = Range.Both;
            }
            else
            {
                throw new System.Exception("Unknown skill range " + row._range);
            }
            map.Add(row.skill, row);
            idMap.Add(row.id, row);
        }

        Attack = Find("Attack");
    }
Example #6
0
 public void SetLegend(OverlayModes.Mode mode, bool refreshing = false)
 {
     if (currentMode == null || !(currentMode.ViewMode() == mode.ViewMode()) || refreshing)
     {
         ClearLegend();
         OverlayInfo legend = overlayInfoList.Find((OverlayInfo ol) => ol.mode == mode.ViewMode());
         currentMode = mode;
         SetLegend(legend);
     }
 }
Example #7
0
        public static Overlay Create(GameObject gameObject, string overlayId, bool loop, float speed = 1.0f)
        {
            var overlayInfo = OverlayInfo.Find(overlayId);

            if (overlayInfo == null)
            {
                Debug.LogWarning("overlay not found: " + overlayId);
                return(null);
            }

            return(Create(gameObject, overlayInfo, loop, speed));
        }
Example #8
0
    public static Overlay Create(GameObject gameObject, string overlayId)
    {
        var overlayInfo = OverlayInfo.Find(overlayId);

        if (overlayInfo == null)
        {
            Debug.LogWarning("overlay not found: " + overlayId);
            return(null);
        }

        return(Create(gameObject, overlayInfo));
    }
Example #9
0
    private void PopulateGeneratedLegend(OverlayInfo info, bool isRefresh = false)
    {
        if (isRefresh)
        {
            RemoveActiveObjects();
        }
        if (info.infoUnits != null && info.infoUnits.Count > 0)
        {
            PopulateOverlayInfoUnits(info, isRefresh);
        }
        List <LegendEntry> customLegendData = currentMode.GetCustomLegendData();

        if (customLegendData != null)
        {
            activeUnitsParent.SetActive(true);
            foreach (LegendEntry item in customLegendData)
            {
                GameObject freeUnitObject = GetFreeUnitObject();
                Image      component      = freeUnitObject.transform.Find("Icon").GetComponent <Image>();
                component.gameObject.SetActive(true);
                component.sprite  = Assets.instance.LegendColourBox;
                component.color   = item.colour;
                component.enabled = true;
                component.type    = Image.Type.Simple;
                LocText componentInChildren = freeUnitObject.GetComponentInChildren <LocText>();
                componentInChildren.text    = item.name;
                componentInChildren.color   = Color.white;
                componentInChildren.enabled = true;
                ToolTip component2 = freeUnitObject.GetComponent <ToolTip>();
                component2.enabled = true;
                component2.toolTip = item.desc;
                freeUnitObject.SetActive(true);
                freeUnitObject.transform.SetParent(activeUnitsParent.transform);
            }
        }
        else
        {
            activeUnitsParent.SetActive(false);
        }
        if (!isRefresh && currentMode.legendFilters != null)
        {
            GameObject gameObject = Util.KInstantiateUI(toolParameterMenuPrefab, diagramsParent, false);
            activeDiagrams.Add(gameObject);
            diagramsParent.SetActive(true);
            filterMenu = gameObject.GetComponent <ToolParameterMenu>();
            filterMenu.PopulateMenu(currentMode.legendFilters);
            filterMenu.onParametersChanged += OnFiltersChanged;
            OnFiltersChanged();
        }
    }
Example #10
0
    public static Overlay Create(GameObject gameObject, OverlayInfo overlayInfo)
    {
        // todo overlay objects recycler
        var overlayObject = new GameObject(overlayInfo.id + " (overlay)");

        overlayObject.transform.SetParent(gameObject.transform, false);
        overlayObject.transform.localPosition = new Vector3(0, 0, -0.5f);
        var spritesheet = Spritesheet.Load(overlayInfo.spritesheetFilename);
        var overlay     = overlayObject.AddComponent <Overlay>();

        overlay.animator           = overlayObject.AddComponent <SpriteAnimator>();
        overlay.animator.loop      = false;
        overlay.animator.sprites   = spritesheet.GetSprites(0);
        overlay.animator.fps       = overlayInfo.fps * 1.5f; // todo connect to spell cast rate
        overlay.animator.OnFinish += overlay.OnAnimationFinish;
        overlay.renderer           = overlayObject.GetComponent <SpriteRenderer>();
        overlay.renderer.material  = Materials.softAdditive;
        return(overlay);
    }
Example #11
0
        public void TestNearlyEquals()
        {
            var info1 = new OverlayInfo
            {
                Width  = 1920,
                Height = 1080,
                X      = 0,
                Y      = 0
            };
            var info2 = new OverlayInfo
            {
                Width  = 1920,
                Height = 1080,
                X      = 2,
                Y      = 2
            };

            Assert.True(info1.NearlyEquals(info2, new Size(1920, 1080), 0.01));
        }
Example #12
0
        public void TestShrink()
        {
            var info = new OverlayInfo
            {
                Width  = 1940,
                Height = 808,
                X      = -15
            };
            var shrinked = info.Shrink(new Size(1920, 1080), new Size(1280, 534));
            var target   = new OverlayInfo
            {
                Width     = 1920,
                Height    = 808,
                CropLeft  = 98969,
                CropRight = 32990
            };

            Assert.AreEqual(target, shrinked);
        }
Example #13
0
        public FrameParams CalcFrame(OverlayInfo info)
        {
            var frame   = new FrameParams();
            var srcSize = SourceInfo.Size;

            frame.MergedWidth  = srcSize.Width + Math.Max(-info.X, 0) + Math.Max(info.Width + info.X - srcSize.Width, 0);
            frame.MergedHeight = srcSize.Height + Math.Max(-info.Y, 0) + Math.Max(info.Height + info.Y - srcSize.Height, 0);
            frame.MergedAr     = frame.MergedWidth / (double)frame.MergedHeight;
            frame.OutAr        = TargetInfo.Width / (double)TargetInfo.Height;
            var wider = frame.MergedAr > frame.OutAr;

            if (Mode == FramingMode.FitBorders)
            {
                wider = !wider;
            }
            frame.FinalWidth  = wider ? TargetInfo.Width : (int)Math.Round(TargetInfo.Width * (frame.MergedAr / frame.OutAr));
            frame.FinalHeight = wider ? (int)Math.Round(TargetInfo.Height * (frame.OutAr / frame.MergedAr)) : TargetInfo.Height;
            frame.FinalX      = wider ? 0 : (TargetInfo.Width - frame.FinalWidth) / 2;
            frame.FinalY      = wider ? (TargetInfo.Height - frame.FinalHeight) / 2 : 0;
            return(frame);
        }
Example #14
0
    static MissileInfo()
    {
        foreach (var row in sheet)
        {
            if (row.id == -1)
            {
                continue;
            }

            row.spritesheetFilename = @"data\global\missiles\" + row.celFile;
            row.material            = row.trans == 0 ? Materials.normal : Materials.softAdditive;
            row.lifeTime            = row.range / 25.0f;
            row.explosionMissile    = Find(row.explosionMissileId);
            row.fps         = row.animSpeed * 1.5f;
            row.travelSound = SoundInfo.Find(row.travelSoundId);
            row.hitSound    = SoundInfo.Find(row.hitSoundId);
            row.progSound   = SoundInfo.Find(row.progSoundId);
            row.progOverlay = OverlayInfo.Find(row.progOverlayId);
            map.Add(row.missile, row);
            idMap.Add(row.id, row);
        }
    }
Example #15
0
        public static void LoadAll()
        {
            var sw = System.Diagnostics.Stopwatch.StartNew();

            Translation.Load();
            SoundInfo.Load();
            SoundEnvironment.Load();
            ObjectInfo.Load();
            BodyLoc.Load();
            ExpTable.Load();
            LevelType.Load();
            LevelWarpInfo.Load();
            LevelPreset.Load();
            LevelMazeInfo.Load();
            LevelInfo.Load();
            OverlayInfo.Load();
            MissileInfo.Load();
            ItemStat.Load();
            ItemRatio.Load();
            ItemType.Load();
            ItemPropertyInfo.Load();
            ItemSet.Load();
            UniqueItem.Load();
            SetItem.Load();
            TreasureClass.Load();
            MagicAffix.Load();
            CharStatsInfo.Load();
            MonLvl.Load();
            MonPreset.Load();
            MonSound.Load();
            MonStatsExtended.Load();
            MonStat.Load();
            SuperUnique.Load();
            SkillDescription.Load();
            SkillInfo.Load();
            SpawnPreset.Load();
            StateInfo.Load();
            Debug.Log("All txt files loaded in " + sw.ElapsedMilliseconds + " ms");
        }
Example #16
0
    static SkillInfo()
    {
        foreach (var row in sheet)
        {
            if (row.id == -1)
            {
                continue;
            }

            row.name        = Translation.Find("skillname" + row.id);
            row.castOverlay = OverlayInfo.Find(row.castOverlayId);
            row.startSound  = SoundInfo.Find(row._stsound);
            if (row._range == "none")
            {
                row.range = Range.NoRestrictions;
            }
            else if (row._range == "h2h")
            {
                row.range = Range.Melee;
            }
            else if (row._range == "rng")
            {
                row.range = Range.Ranged;
            }
            else if (row._range == "both")
            {
                row.range = Range.Both;
            }
            else
            {
                throw new System.Exception("Unknown skill range " + row._range);
            }
            map.Add(row.skill, row);
            idMap.Add(row.id, row);
        }

        Attack = Find("Attack");
    }
Example #17
0
 private void SetLegend(OverlayInfo overlayInfo)
 {
     if (overlayInfo == null)
     {
         ClearLegend();
     }
     else if (!overlayInfo.isProgrammaticallyPopulated && (overlayInfo.infoUnits == null || overlayInfo.infoUnits.Count == 0))
     {
         ClearLegend();
     }
     else
     {
         Show(true);
         title.text = overlayInfo.name;
         if (overlayInfo.isProgrammaticallyPopulated)
         {
             PopulateGeneratedLegend(overlayInfo, false);
         }
         else
         {
             PopulateOverlayInfoUnits(overlayInfo, false);
         }
     }
 }
Example #18
0
        public static Overlay Create(GameObject gameObject, OverlayInfo overlayInfo, bool loop, float speed = 1.0f)
        {
            // todo overlay objects recycler
            var overlayObject = new GameObject(overlayInfo.id + " (overlay)");

            overlayObject.transform.SetParent(gameObject.transform, false);
            float zOffset = overlayInfo.preDraw ? 0.5f : -0.5f;

            overlayObject.transform.localPosition = new Vector3(0, 0, zOffset);
            var spritesheet = Spritesheet.Load(overlayInfo.spritesheetFilename);
            var overlay     = overlayObject.AddComponent <Overlay>();

            overlay.animator         = overlayObject.AddComponent <SpriteAnimator>();
            overlay.animator.loop    = loop;
            overlay.animator.sprites = spritesheet.GetSprites(0);
            overlay.animator.fps     = overlayInfo.fps * speed * 1.5f; // 1.5 multiplier is set to match original animation speed
            if (!loop)
            {
                overlay.animator.OnFinish += overlay.OnAnimationFinish;
            }
            overlay.renderer          = overlayObject.GetComponent <SpriteRenderer>();
            overlay.renderer.material = Materials.softAdditive;
            return(overlay);
        }
Example #19
0
 public Overlay(OverlayInfo info, byte[] data, int cpu)
 {
     Name = string.Format("ov{0:s}_{1:d}", cpu.ToString(), info.id);
     Data = data;
     Info = info;
 }
Example #20
0
 private void PopulateOverlayInfoUnits(OverlayInfo overlayInfo, bool isRefresh = false)
 {
     if (overlayInfo.infoUnits != null && overlayInfo.infoUnits.Count > 0)
     {
         activeUnitsParent.SetActive(true);
         foreach (OverlayInfoUnit infoUnit in overlayInfo.infoUnits)
         {
             GameObject freeUnitObject = GetFreeUnitObject();
             if ((UnityEngine.Object)infoUnit.icon != (UnityEngine.Object)null)
             {
                 Image component = freeUnitObject.transform.Find("Icon").GetComponent <Image>();
                 component.gameObject.SetActive(true);
                 component.sprite  = infoUnit.icon;
                 component.color   = infoUnit.color;
                 component.enabled = true;
                 component.type    = (infoUnit.sliceIcon ? Image.Type.Sliced : Image.Type.Simple);
             }
             else
             {
                 freeUnitObject.transform.Find("Icon").gameObject.SetActive(false);
             }
             if (!string.IsNullOrEmpty(infoUnit.description))
             {
                 LocText componentInChildren = freeUnitObject.GetComponentInChildren <LocText>();
                 componentInChildren.text    = string.Format(infoUnit.description, infoUnit.formatData);
                 componentInChildren.color   = infoUnit.fontColor;
                 componentInChildren.enabled = true;
             }
             ToolTip component2 = freeUnitObject.GetComponent <ToolTip>();
             if (!string.IsNullOrEmpty(infoUnit.tooltip))
             {
                 component2.toolTip = string.Format(infoUnit.tooltip, infoUnit.tooltipFormatData);
                 component2.enabled = true;
             }
             else
             {
                 component2.enabled = false;
             }
             freeUnitObject.SetActive(true);
             freeUnitObject.transform.SetParent(activeUnitsParent.transform);
         }
     }
     else
     {
         activeUnitsParent.SetActive(false);
     }
     if (!isRefresh)
     {
         if (overlayInfo.diagrams != null && overlayInfo.diagrams.Count > 0)
         {
             diagramsParent.SetActive(true);
             foreach (GameObject diagram in overlayInfo.diagrams)
             {
                 GameObject item = Util.KInstantiateUI(diagram, diagramsParent, false);
                 activeDiagrams.Add(item);
             }
         }
         else
         {
             diagramsParent.SetActive(false);
         }
     }
 }