Example #1
0
 public UIPaused(ICore core, UIType menuType, int width, int height, UIFlags flags, bool transparent)
     : base(core, menuType, width, height, flags, transparent)
 {
     View.AddCallback("MainMenuClick");
     View.AddCallback("RestartClick");
     View.AddCallback("ResumeClick");
 }
Example #2
0
        public UIView(ICore core, UIType menuType, int width, int height, UIFlags flags, bool transparent)
            : base(core)
        {
            webCore            = core.GetService <IUIManagerService>().GetWebCore();
            this.menuType      = menuType;
            this.width         = width;
            this.height        = height;
            this.flags         = flags;
            this.isTransparent = transparent;
            isLoading          = false;
            pageLoaded         = false;
            webTextureID       = TextureFactory.CreateTexture(width, height, isTransparent);
            hudPosX            = 0;
            hudPosY            = 0;
            hud      = new TVScreen2DImmediate();
            Keyboard = core.GetService <IKeyboardService>();
            Mouse    = core.GetService <IMouseService>();
            JoyStick = core.GetService <IJoyStickService>();
            Gamepad  = core.GetService <IGamepadsService>();

            CanculateHudPosition(flags);

            View = webCore.CreateWebView(width, height, isTransparent, true);
            View.OnFinishLoading += OnFinishLoading;
            View.OnCallback      += OnCallback;
            View.Focus();

            buttonClickSound = Core.GetService <ISoundManagerService>().Load2DSound(Path.Combine(Application.StartupPath, @"Data\Sounds\menu\button_click.mp3"));
            buttonFocusSound = Core.GetService <ISoundManagerService>().Load2DSound(Path.Combine(Application.StartupPath, @"Data\Sounds\menu\button_focus.mp3"));
            Core.GetService <ISoundManagerService>().SetVolume(buttonClickSound, 0.5f);
            Core.GetService <ISoundManagerService>().SetVolume(buttonFocusSound, 0.5f);
        }
Example #3
0
        public UIView(ICore core, UIType menuType, int width, int height, UIFlags flags, bool transparent)
            : base(core)
        {
            webCore = core.GetService<IUIManagerService>().GetWebCore();
            this.menuType = menuType;
            this.width = width;
            this.height = height;
            this.flags = flags;
            this.isTransparent = transparent;
            isLoading = false;
            pageLoaded = false;
            webTextureID = TextureFactory.CreateTexture(width, height, isTransparent);
            hudPosX = 0;
            hudPosY = 0;
            hud = new TVScreen2DImmediate();
            Keyboard = core.GetService<IKeyboardService>();
            Mouse = core.GetService<IMouseService>();
            JoyStick = core.GetService<IJoyStickService>();
            Gamepad = core.GetService<IGamepadsService>();

            CanculateHudPosition(flags);

            View = webCore.CreateWebView(width, height, isTransparent, true);
            View.OnFinishLoading += OnFinishLoading;
            View.OnCallback += OnCallback;
            View.Focus();

            buttonClickSound = Core.GetService<ISoundManagerService>().Load2DSound(Path.Combine(Application.StartupPath, @"Data\Sounds\menu\button_click.mp3"));
            buttonFocusSound = Core.GetService<ISoundManagerService>().Load2DSound(Path.Combine(Application.StartupPath, @"Data\Sounds\menu\button_focus.mp3"));
            Core.GetService<ISoundManagerService>().SetVolume(buttonClickSound, 0.5f);
            Core.GetService<ISoundManagerService>().SetVolume(buttonFocusSound, 0.5f);
        }
Example #4
0
        public UIInGame(ICore core, UIType menuType, int width, int height, UIFlags flags, bool transparent)
            : base(core, menuType, width, height, flags, transparent)
        {
            var service = Core.GetService <IScriptManagerService>();

            service.SetGlobal("UIInGame", this);
            service.RegisterCustomFunctions(this);
        }
Example #5
0
 public UIMain(ICore core, UIType menuType, int width, int height, UIFlags flags, bool transparent)
     : base(core, menuType, width, height, flags, transparent)
 {
     this.core = core;
     View.AddCallback("PlayClick");
     View.AddCallback("StatisticsClick");
     View.AddCallback("OptionsClick");
     View.AddCallback("CreditsClick");
     View.AddCallback("QuitClick");
 }
Example #6
0
        public UILevelFinished(ICore core, UIType menuType, int width, int height, UIFlags flags, bool transparent)
            : base(core, menuType, width, height, flags, transparent)
        {
            View.AddCallback("MainMenuClick");
            View.AddCallback("NextLevelClick");

            string scenesListFile = Path.Combine(Application.StartupPath, Helpers.GameSettings.ScenesListFile);

            // Collect available scenes.
            GetAvailableScenes(scenesListFile);
        }
Example #7
0
        public UISelectLevel(ICore core, UIType menuType, int width, int height, UIFlags flags, bool transparent)
            : base(core, menuType, width, height, flags, transparent)
        {
            View.AddCallback("MainMenuClick");
            View.AddCallback("PlayClick");
            string scenesListFile = Path.Combine(Application.StartupPath, Helpers.GameSettings.ScenesListFile);

            View.SetProperty("scenesFile", new JSValue(scenesListFile));

            // Collect available scenes.
            GetAvailableScenes(scenesListFile);
        }
Example #8
0
        public UIOptions(ICore core, UIType menuType, int width, int height, UIFlags flags, bool transparent)
            : base(core, menuType, width, height, flags, transparent)
        {
            videoModes = Helpers.GetAvailableVideoModes();

            View.AddCallback("MainMenuClick");
            View.AddCallback("ApplyClick");
            View.AddCallback("MusicVolumeChanged");
            View.AddCallback("FxVolumeChanged");
            View.SetProperty("antialiasing", new JSValue(Helpers.GameSettings.Antialiasing));
            View.SetProperty("musicVolume", new JSValue(Helpers.GameSettings.MusicVolume));
            View.SetProperty("fxVolume", new JSValue(Helpers.GameSettings.FXVolume));
        }
Example #9
0
        private void CanculateHudPosition(UIFlags flags)
        {
            switch (flags)
            {
            case UIFlags.TopCenter:
                hudPosX = (screenWidth - width) / 2;
                hudPosY = 0;
                break;

            case UIFlags.LeftCenter:
                hudPosX = 0;
                hudPosY = (screenHeight - height) / 2;
                break;

            case UIFlags.RightCenter:
                hudPosX = screenWidth - width;
                hudPosY = (screenHeight - height) / 2;
                break;

            case UIFlags.BottomCenter:
                hudPosX = (screenWidth - width) / 2;
                hudPosY = screenHeight - height;
                break;

            case UIFlags.Center:
                hudPosX = (screenWidth - width) / 2;
                hudPosY = (screenHeight - height) / 2;
                break;

            case UIFlags.BottomRight:
                hudPosX = screenWidth - width;
                hudPosY = screenHeight - height;
                break;

            case UIFlags.BottomLeft:
                hudPosX = 0;
                hudPosY = screenHeight - height;
                break;

            default:
                hudPosX = 0;
                hudPosY = 0;
                break;
            }
        }
        public Highlight(BinaryReader br)
        {
            var filename = br.GetFilename();

            uint magic = br.ReadUInt24();

            Debug.Assert(magic == MAGIC_CONSTANT);

            byte formatVersion = br.ReadByte();

            Debug.Assert(formatVersion == 3 || formatVersion == 4);

            this.checksum = new Checksum(br);

            int dataLength = br.ReadInt32();

            Debug.Assert(br.BaseStream.Position + dataLength == br.BaseStream.Length);

            if (Checksum.CanCompute)
            {
                long   pos           = br.BaseStream.Position;
                byte[] checksumInput = br.ReadBytes(dataLength);
                br.BaseStream.Position = pos;
                Checksum computedChecksum = Checksum.Compute(checksumInput);
                Debug.Assert(this.checksum == computedChecksum);
            }

            using (DebugBlockLength dbl = new DebugBlockLength(dataLength, br))
            {
                uint unknown1 = br.ReadUInt32();                    // 0?
                Debug.Assert(unknown1 == 0);

                uint unknown2 = br.ReadUInt32();                    // 0?
                Debug.Assert(unknown2 == 0);

                uint unknown3 = br.ReadUInt32();                    // 0?
                Debug.Assert(unknown3 == 0);

                uint unknown4 = br.ReadUInt32();                    // 0?
                Debug.Assert(unknown4 == 0);

                uint unknown5 = br.ReadUInt32();                    // 0?
                Debug.Assert(unknown5 == 0);

                uint unknown6 = br.ReadUInt32();                    // 0?
                Debug.Assert(unknown6 == 0);

                uint unknown7 = br.ReadUInt32();                    // 0?
                Debug.Assert(unknown7 == 0);

                uint unknown8 = br.ReadUInt32();                    // 0?
                Debug.Assert(unknown8 == 0);

                this.majorVersion = new MajorVersion(br);
                Debug.Assert(this.majorVersion.IsKnownByTool(), $"Unknown major version {majorVersion}");

                this.buildNumber = new BuildNumber(br);
                Debug.Assert(buildNumber.IsKnownByTool(), $"Unknown build number {buildNumber}");

                this.playerId = br.ReadUInt32();                    // player id of the logged in user

                uint unknown12 = br.ReadUInt32();                   // 0?
                Debug.Assert(unknown12 == 0);

                this.uiFlags = (UIFlags)br.ReadUInt32();
                Debug.Assert(((uint)uiFlags & 0xFFFFFFF0u) == 0);                                                 // assume only the bottom four bits will be set...
                Debug.Assert(uiFlags.HasFlag(UIFlags.ManualHighlight) != uiFlags.HasFlag(UIFlags.Top5Highlight)); // exactly one of these will be set

                this.map = br.ReadMap64();

                this.gameMode = br.ReadGameMode64();

                if (formatVersion >= 4)
                {
                    this.v4_unknown1 = br.ReadUInt32();
                    Debug.Assert(this.v4_unknown1 == 0);

                    this.v4_unknown2 = br.ReadUInt32();
                    Debug.Assert(this.v4_unknown2 == 0);
                }

                // 2 entries will be a POTG, 1 entry will be either a highlight or a POTG against bots, I think...
                int numHighlightInfos = br.ReadInt32();
                Debug.Assert(numHighlightInfos == 1 || numHighlightInfos == 2);

                this.highlightInfos = new HighlightInfo[numHighlightInfos];
                for (int i = 0; i < numHighlightInfos; ++i)
                {
                    highlightInfos[i] = new HighlightInfo(br, this.majorVersion);
                }
                Debug.Assert(br.GetFilename().StartsWith(highlightInfos[0].uuid.ToString()));

                int numHeroes = br.ReadInt32();

                this.heroesWithUnlockables = new HeroWithUnlockables[numHeroes];
                for (int i = 0; i < numHeroes; ++i)
                {
                    heroesWithUnlockables[i] = new HeroWithUnlockables(br, majorVersion);
                }

                // I have absolutely no idea what this section is for but it seems to be entirely predictable *shrug*
                {
                    this.unknown60 = br.ReadUInt32();
                    Debug.Assert(unknown60 == 0);

                    this.unknown61 = br.ReadUInt32();
                    Debug.Assert(unknown61 == 0);

                    byte unknown62 = br.ReadByte();

                    /*Debug.Assert(
                     *      unknown62 == 0x00 ||
                     *      unknown62 == 0x01 ||
                     *      unknown62 == 0x07 ||
                     *      unknown62 == 0x0a ||
                     *      unknown62 == 0x11 ||
                     *      unknown62 == 0x1c ||
                     *      unknown62 == 0x27 ||
                     *      unknown62 == 0x2a ||
                     *      unknown62 == 0x36 ||
                     *      unknown62 == 0x4e ||
                     *      unknown62 == 0x61 ||
                     *      unknown62 == 0x80 ||
                     *      unknown62 == 0xc1 ||
                     *      unknown62 == 0xc7 ||
                     *      unknown62 == 0xf7 ||
                     *      unknown62 == 0xff);*/

                    int fillerCount = (unknown62 & 1);
                    this.fillerStructs = new FillerStruct[fillerCount];
                    for (int i = 0; i < fillerCount; ++i)
                    {
                        this.fillerStructs[i] = new FillerStruct(br);
                    }
                }

                int replayDataLength = br.ReadInt32();
                Debug.Assert(br.BaseStream.Position + replayDataLength == br.BaseStream.Length);

                replayBlock = new Replay(br, this.majorVersion);
            }

            Debug.Assert(
                replayBlock.buildNumber == this.buildNumber ||
                (this.buildNumber == 38044 && replayBlock.buildNumber == 38024) ||
                (this.buildNumber == 38459 && replayBlock.buildNumber == 38510) ||
                (this.buildNumber == 38459 && replayBlock.buildNumber == 38679) ||
                (this.buildNumber == 38765 && replayBlock.buildNumber == 38679) ||
                (this.buildNumber == 38459 && replayBlock.buildNumber == 38765) ||
                (this.buildNumber == 39023 && replayBlock.buildNumber == 38882) ||
                (this.buildNumber == 39023 && replayBlock.buildNumber == 39221) ||
                (this.buildNumber == 39358 && replayBlock.buildNumber == 39221) ||
                (this.buildNumber == 39484 && replayBlock.buildNumber == 39425) ||
                (this.buildNumber == 39484 && replayBlock.buildNumber == 39572) ||
                (this.buildNumber == 39484 && replayBlock.buildNumber == 39775) ||
                (this.buildNumber == 39935 && replayBlock.buildNumber == 39823) ||
                (this.buildNumber == 40048 && replayBlock.buildNumber == 39974) ||
                (this.buildNumber == 40133 && replayBlock.buildNumber == 39974) ||
                (this.buildNumber == 40990 && replayBlock.buildNumber == 40763) ||
                (this.buildNumber == 41714 && replayBlock.buildNumber == 41350) ||
                (this.buildNumber == 41713 && replayBlock.buildNumber == 41835) ||
                (this.buildNumber == 42665 && replayBlock.buildNumber == 42563) ||
                (this.buildNumber == 45752 && replayBlock.buildNumber == 45876) ||
                (this.buildNumber == 51948 && replayBlock.buildNumber == 51830)
                // I've no idea what's up with all these weird permutations...
                );
            Debug.Assert(replayBlock.map == this.map);
            Debug.Assert(replayBlock.gameMode == this.gameMode);
            if (replayBlock.highlightInfo != null)
            {
                //Debug.Assert(replayBlock.highlightInfo == highlightInfos[0]);
                Debug.Assert(HighlightInfo.EqualWithTypeMasking(replayBlock.highlightInfo, highlightInfos[0]));
            }

            if (this.highlightInfos[0].typeFlags.HasFlag(HighlightInfo.HighlightTypeFlag.Manual))
            {
                Debug.Assert(this.highlightInfos[0].unknown4 == 0);
            }
            else
            {
                Debug.Assert(this.highlightInfos[0].unknown4 != 0);
                if (this.highlightInfos.Length > 1)
                {
                    Debug.Assert(this.highlightInfos[0].unknown4 >= this.highlightInfos[1].unknown4);
                }
            }
            Debug.Assert(this.highlightInfos[0].unknown5 > this.replayBlock.paramsBlock.startMs / 1000.0f);
            Debug.Assert(this.highlightInfos[0].unknown5 < this.replayBlock.paramsBlock.endMs / 1000.0f);

            if (!this.highlightInfos[0].typeFlags.HasFlag(HighlightInfo.HighlightTypeFlag.POTG))
            {
                if (uiFlags.HasFlag(UIFlags.ManualHighlight))
                {
                    Debug.Assert(this.highlightInfos[0].typeFlags.HasFlag(HighlightInfo.HighlightTypeFlag.Manual));
                }
                else
                {
                    Debug.Assert(
                        this.highlightInfos[0].typeFlags.HasFlag(HighlightInfo.HighlightTypeFlag.Top5) ||
                        this.highlightInfos[0].typeFlags.HasFlag(HighlightInfo.HighlightTypeFlag.Unknown_10)
                        );
                }
            }


            if (this.highlightInfos[0].typeFlags.HasFlag(HighlightInfo.HighlightTypeFlag.Manual))
            {
                Debug.Assert(this.highlightInfos[0].category == HighlightCategory.None);
            }
            else
            {
                Debug.Assert(
                    this.highlightInfos[0].category == HighlightCategory.HighScore ||
                    this.highlightInfos[0].category == HighlightCategory.Lifesaver ||
                    this.highlightInfos[0].category == HighlightCategory.Sharpshooter ||
                    this.highlightInfos[0].category == HighlightCategory.Shutdown
                    );
            }
        }
Example #11
0
 public UIInGame(ICore core, UIType menuType, int width, int height, UIFlags flags, bool transparent)
     : base(core, menuType, width, height, flags, transparent)
 {
     var service = Core.GetService<IScriptManagerService>();
     service.SetGlobal("UIInGame", this);
     service.RegisterCustomFunctions(this);
 }
Example #12
0
 private void CanculateHudPosition(UIFlags flags)
 {
     switch (flags)
     {
         case UIFlags.TopCenter:
             hudPosX = (screenWidth - width) / 2;
             hudPosY = 0;
             break;
         case UIFlags.LeftCenter:
             hudPosX = 0;
             hudPosY = (screenHeight - height) / 2;
             break;
         case UIFlags.RightCenter:
             hudPosX = screenWidth - width;
             hudPosY = (screenHeight - height) / 2;
             break;
         case UIFlags.BottomCenter:
             hudPosX = (screenWidth - width) / 2;
             hudPosY = screenHeight - height;
             break;
         case UIFlags.Center:
             hudPosX = (screenWidth - width) / 2;
             hudPosY = (screenHeight - height) / 2;
             break;
         case UIFlags.BottomRight:
             hudPosX = screenWidth - width;
             hudPosY = screenHeight - height;
             break;
         case UIFlags.BottomLeft:
             hudPosX = 0;
             hudPosY = screenHeight - height;
             break;
         default:
             hudPosX = 0;
             hudPosY = 0;
             break;
     }
 }
Example #13
0
 public UIStatistics(ICore core, UIType menuType, int width, int height, UIFlags flags, bool transparent)
     : base(core, menuType, width, height, flags, transparent)
 {
     View.AddCallback("MainMenuClick");
 }
Example #14
0
 public UITutorial(ICore core, UIType menuType, int width, int height, UIFlags flags, bool transparent)
     : base(core, menuType, width, height, flags, transparent)
 {
 }
Example #15
0
 public UIMain(ICore core, UIType menuType, int width, int height, UIFlags flags, bool transparent)
     : base(core, menuType, width, height, flags, transparent)
 {
     this.core = core;
     View.AddCallback("PlayClick");
     View.AddCallback("StatisticsClick");
     View.AddCallback("OptionsClick");
     View.AddCallback("CreditsClick");
     View.AddCallback("QuitClick");
 }
Example #16
0
        public UILevelFinished(ICore core, UIType menuType, int width, int height, UIFlags flags, bool transparent)
            : base(core, menuType, width, height, flags, transparent)
        {
            View.AddCallback("MainMenuClick");
            View.AddCallback("NextLevelClick");

            string scenesListFile = Path.Combine(Application.StartupPath, Helpers.GameSettings.ScenesListFile);

            // Collect available scenes.
            GetAvailableScenes(scenesListFile);
        }
Example #17
0
        public UIOptions(ICore core, UIType menuType, int width, int height, UIFlags flags, bool transparent)
            : base(core, menuType, width, height, flags, transparent)
        {
            videoModes = Helpers.GetAvailableVideoModes();

            View.AddCallback("MainMenuClick");
            View.AddCallback("ApplyClick");
            View.AddCallback("MusicVolumeChanged");
            View.AddCallback("FxVolumeChanged");
            View.SetProperty("antialiasing", new JSValue(Helpers.GameSettings.Antialiasing));
            View.SetProperty("musicVolume", new JSValue(Helpers.GameSettings.MusicVolume));
            View.SetProperty("fxVolume", new JSValue(Helpers.GameSettings.FXVolume));
        }
Example #18
0
 public UIPaused(ICore core, UIType menuType, int width, int height, UIFlags flags, bool transparent)
     : base(core, menuType, width, height, flags, transparent)
 {
     View.AddCallback("MainMenuClick");
     View.AddCallback("RestartClick");
     View.AddCallback("ResumeClick");
 }
Example #19
0
        public UISelectLevel(ICore core, UIType menuType, int width, int height, UIFlags flags, bool transparent)
            : base(core, menuType, width, height, flags, transparent)
        {
            View.AddCallback("MainMenuClick");
            View.AddCallback("PlayClick");
            string scenesListFile = Path.Combine(Application.StartupPath, Helpers.GameSettings.ScenesListFile);
            View.SetProperty("scenesFile", new JSValue(scenesListFile));

            // Collect available scenes.
            GetAvailableScenes(scenesListFile);
        }
Example #20
0
 public UIStatistics(ICore core, UIType menuType, int width, int height, UIFlags flags, bool transparent)
     : base(core, menuType, width, height, flags, transparent)
 {
     View.AddCallback("MainMenuClick");
 }
Example #21
0
 public UITutorial(ICore core, UIType menuType, int width, int height, UIFlags flags, bool transparent)
     : base(core, menuType, width, height, flags, transparent)
 {
 }