Пример #1
0
        public DoomApplication(CommandLineArgs args)
        {
            config = new Config(ConfigUtilities.GetConfigPath());

            try
            {
                config.video_screenwidth  = Math.Clamp(config.video_screenwidth, 320, 3200);
                config.video_screenheight = Math.Clamp(config.video_screenheight, 200, 2000);
                var videoMode = new VideoMode((uint)config.video_screenwidth, (uint)config.video_screenheight);
                var style     = Styles.Close | Styles.Titlebar;
                if (config.video_fullscreen)
                {
                    style = Styles.Fullscreen;
                }
                window = new RenderWindow(videoMode, ApplicationInfo.Title, style);
                window.Clear(new Color(64, 64, 64));
                window.Display();

                if (args.deh.Present)
                {
                    DeHackEd.ReadFiles(args.deh.Value);
                }

                resource = new CommonResource(GetWadPaths(args), !args.nodeh.Present);

                renderer = new SfmlRenderer(config, window, resource);

                if (!args.nosound.Present && !args.nosfx.Present)
                {
                    sound = new SfmlSound(config, resource.Wad);
                }

                if (!args.nosound.Present && !args.nomusic.Present)
                {
                    music = ConfigUtilities.GetSfmlMusicInstance(config, resource.Wad);
                }

                userInput = new SfmlUserInput(config, window, !args.nomouse.Present);

                events = new List <DoomEvent>();

                options             = new GameOptions();
                options.GameVersion = resource.Wad.GameVersion;
                options.GameMode    = resource.Wad.GameMode;
                options.MissionPack = resource.Wad.MissionPack;
                options.Renderer    = renderer;
                options.Sound       = sound;
                options.Music       = music;
                options.UserInput   = userInput;

                menu = new DoomMenu(this);

                opening = new OpeningSequence(resource, options);

                cmds = new TicCmd[Player.MaxPlayerCount];
                for (var i = 0; i < Player.MaxPlayerCount; i++)
                {
                    cmds[i] = new TicCmd();
                }
                game = new DoomGame(resource, options);

                wipe   = new WipeEffect(renderer.WipeBandCount, renderer.WipeHeight);
                wiping = false;

                currentState = ApplicationState.None;
                nextState    = ApplicationState.Opening;
                needWipe     = false;

                sendPause = false;

                quit        = false;
                quitMessage = null;

                CheckGameArgs(args);

                window.Closed      += (sender, e) => window.Close();
                window.KeyPressed  += KeyPressed;
                window.KeyReleased += KeyReleased;

                if (!args.timedemo.Present)
                {
                    window.SetFramerateLimit(35);
                }

                mouseGrabbed = false;
            }
            catch (Exception e)
            {
                Dispose();
                ExceptionDispatchInfo.Throw(e);
            }
        }
Пример #2
0
        public DoomMenu(DoomApplication app)
        {
            this.app = app;
            options  = app.Options;

            thisIsShareware = new PressAnyKey(
                this,
                DoomInfo.Strings.SWSTRING,
                null);

            saveFailed = new PressAnyKey(
                this,
                DoomInfo.Strings.SAVEDEAD,
                null);

            nightmareConfirm = new YesNoConfirm(
                this,
                DoomInfo.Strings.NIGHTMARE,
                () => app.NewGame(GameSkill.Nightmare, selectedEpisode, 1));

            endGameConfirm = new YesNoConfirm(
                this,
                DoomInfo.Strings.ENDGAME,
                () => app.EndGame());

            quitConfirm = new QuitConfirm(
                this,
                app);

            skillMenu = new SelectableMenu(
                this,
                "NEW GAME", 110, 56,
                "SKILL", 38, 30,
                2,
                true,
                new SimpleMenuItem(
                    "SKILL", 16, 58, 48, 63,
                    () => app.NewGame(GameSkill.Baby, selectedEpisode, 1),
                    null),

                new SimpleMenuItem(
                    "ROUGH", 16, 74, 48, 79,
                    () => app.NewGame(GameSkill.Easy, selectedEpisode, 1),
                    null),

                new SimpleMenuItem(
                    "HURT", 16, 90, 48, 95,
                    () => app.NewGame(GameSkill.Medium, selectedEpisode, 1),
                    null),

                new SimpleMenuItem(
                    "ULTRA", 16, 106, 48, 111,
                    () => app.NewGame(GameSkill.Hard, selectedEpisode, 1),
                    null),

                new SimpleMenuItem(
                    "NMARE", 16, 122, 48, 127,
                    null,
                    nightmareConfirm));

            if (app.Options.GameMode == GameMode.Retail)
            {
                episodeMenu = new SelectableMenu(
                    this,
                    "EPISODES", 54, 38,
                    0,
                    true,

                    new SimpleMenuItem(
                        "EPI1", 16, 58, 48, 63,
                        () => selectedEpisode = 1,
                        skillMenu),

                    new SimpleMenuItem(
                        "EPI2", 16, 74, 48, 79,
                        () => selectedEpisode = 2,
                        skillMenu),

                    new SimpleMenuItem(
                        "EPI3", 16, 90, 48, 95,
                        () => selectedEpisode = 3,
                        skillMenu),

                    new SimpleMenuItem(
                        "EPI4", 16, 106, 48, 111,
                        () => selectedEpisode = 4,
                        skillMenu));
            }
            else
            {
                if (app.Options.GameMode == GameMode.Shareware)
                {
                    episodeMenu = new SelectableMenu(
                        this,
                        "EPISOD", 54, 38,
                        0,
                        true,

                        new SimpleMenuItem(
                            "EPI1", 16, 58, 48, 63,
                            () => selectedEpisode = 1,
                            skillMenu),

                        new SimpleMenuItem(
                            "EPI2", 16, 74, 48, 79,
                            null,
                            thisIsShareware),

                        new SimpleMenuItem(
                            "EPI3", 16, 90, 48, 95,
                            null,
                            thisIsShareware));
                }
                else
                {
                    episodeMenu = new SelectableMenu(
                        this,
                        "EPISODES", 54, 38,
                        0,
                        true,

                        new SimpleMenuItem(
                            "EPI1", 16, 58, 48, 63,
                            () => selectedEpisode = 1,
                            skillMenu),
                        new SimpleMenuItem(
                            "EPI2", 16, 74, 48, 79,
                            () => selectedEpisode = 2,
                            skillMenu),
                        new SimpleMenuItem(
                            "EPI3", 16, 90, 48, 95,
                            () => selectedEpisode = 3,
                            skillMenu));
                }
            }

            var sound = options.Sound;
            var music = options.Music;

            volume = new SelectableMenu(
                this,
                "SVOL", 60, 38,
                0,
                true,

                new SliderMenuItem(
                    "SFXVOL", 48, 59, 80, 64,
                    sound.MaxVolume + 1,
                    () => sound.Volume,
                    vol => sound.Volume = vol),

                new SliderMenuItem("MUSVOL", 48, 91, 80, 96,
                                   music.MaxVolume + 1,
                                   () => music.Volume,
                                   vol => music.Volume = vol));

            var renderer  = options.Renderer;
            var userInput = options.UserInput;

            optionMenu = new SelectableMenu(
                this,
                "OPTTTL", 108, 15,
                0,
                true,

                new SimpleMenuItem(
                    "ENDGAM", 28, 32, 60, 37,
                    null,
                    endGameConfirm,
                    () => app.State == ApplicationState.Game),

                new ToggleMenuItem(
                    "MESSG", 28, 48, 60, 53, "M_MSGON", "M_MSGOFF", 180,
                    () => renderer.DisplayMessage ? 0 : 1,
                    value => renderer.DisplayMessage = value == 0),

                new SliderMenuItem(
                    "SCRNSZ", 28, 80 - 16, 60, 85 - 16,
                    renderer.MaxWindowSize + 1,
                    () => renderer.WindowSize,
                    size => renderer.WindowSize = size),

                new SliderMenuItem(
                    "MSENS", 28, 112 - 16, 60, 117 - 16,
                    userInput.MaxMouseSensitivity + 1,
                    () => userInput.MouseSensitivity,
                    ms => userInput.MouseSensitivity = ms),

                new SimpleMenuItem(
                    "SVOL", 28, 144 - 16, 60, 149 - 16,
                    null,
                    volume));

            load = new LoadMenu(
                this,
                "LOADG", 72, 28,
                0,
                new TextBoxMenuItem(48, 49, 72, 61),
                new TextBoxMenuItem(48, 65, 72, 77),
                new TextBoxMenuItem(48, 81, 72, 93),
                new TextBoxMenuItem(48, 97, 72, 109),
                new TextBoxMenuItem(48, 113, 72, 125),
                new TextBoxMenuItem(48, 129, 72, 141));

            save = new SaveMenu(
                this,
                "SAVEG", 72, 28,
                0,
                new TextBoxMenuItem(48, 49, 72, 61),
                new TextBoxMenuItem(48, 65, 72, 77),
                new TextBoxMenuItem(48, 81, 72, 93),
                new TextBoxMenuItem(48, 97, 72, 109),
                new TextBoxMenuItem(48, 113, 72, 125),
                new TextBoxMenuItem(48, 129, 72, 141));

            help = new HelpScreen(this);

            if (app.Options.GameMode == GameMode.Commercial)
            {
                main = new SelectableMenu(
                    this,
                    "M_HTIC", 80, 0,
                    0,
                    false,
                    new SimpleMenuItem("NEW GAME", 65, 67, 120, 80, null, skillMenu),
                    new SimpleMenuItem("OPTIONS", 65, 83, 97, 88, null, optionMenu),
                    new SimpleMenuItem("LOAD GAME", 65, 99, 97, 104, null, load),
                    new SimpleMenuItem("SAVE GAME", 65, 115, 97, 120, null, save,
                                       () => !(app.State == ApplicationState.Game &&
                                               app.Game.State != GameState.Level)),
                    new SimpleMenuItem("QUIT GAME", 65, 131, 97, 136, null, quitConfirm));
            }
            else
            {
                main = new SelectableMenu(
                    this,
                    "M_HTIC", 80, 0,
                    0,
                    false,
                    new SimpleMenuItem("NEW GAME", 70, 60, 100, 70, null, episodeMenu),
                    new SimpleMenuItem("OPTIONS", 70, 80, 100, 90, null, optionMenu),
                    new SimpleMenuItem("LOAD GAME", 70, 100, 100, 110, null, load),
                    new SimpleMenuItem("SAVE GAME", 70, 120, 100, 130, null, save,
                                       () => !(app.State == ApplicationState.Game &&
                                               app.Game.State != GameState.Level)),
                    new SimpleMenuItem("INFO", 70, 140, 100, 150, null, help),
                    new SimpleMenuItem("QUIT GAME", 70, 160, 100, 170, null, quitConfirm));
            }

            current = main;
            active  = false;

            tics = 0;

            selectedEpisode = 1;

            saveSlots = new SaveSlots();
        }
Пример #3
0
        public Finale(GameOptions options)
        {
            this.options = options;

            string c1Text;
            string c2Text;
            string c3Text;
            string c4Text;
            string c5Text;
            string c6Text;

            switch (options.MissionPack)
            {
            case MissionPack.Plutonia:
                c1Text = DoomInfo.Strings.P1TEXT;
                c2Text = DoomInfo.Strings.P2TEXT;
                c3Text = DoomInfo.Strings.P3TEXT;
                c4Text = DoomInfo.Strings.P4TEXT;
                c5Text = DoomInfo.Strings.P5TEXT;
                c6Text = DoomInfo.Strings.P6TEXT;
                break;

            case MissionPack.Tnt:
                c1Text = DoomInfo.Strings.T1TEXT;
                c2Text = DoomInfo.Strings.T2TEXT;
                c3Text = DoomInfo.Strings.T3TEXT;
                c4Text = DoomInfo.Strings.T4TEXT;
                c5Text = DoomInfo.Strings.T5TEXT;
                c6Text = DoomInfo.Strings.T6TEXT;
                break;

            default:
                c1Text = DoomInfo.Strings.C1TEXT;
                c2Text = DoomInfo.Strings.C2TEXT;
                c3Text = DoomInfo.Strings.C3TEXT;
                c4Text = DoomInfo.Strings.C4TEXT;
                c5Text = DoomInfo.Strings.C5TEXT;
                c6Text = DoomInfo.Strings.C6TEXT;
                break;
            }

            switch (options.GameMode)
            {
            case GameMode.Shareware:
            case GameMode.Registered:
            case GameMode.Retail:
                options.Music.StartMusic(Bgm.VICTOR, true);
                switch (options.Episode)
                {
                case 1:
                    flat = "FLOOR4_8";
                    text = DoomInfo.Strings.E1TEXT;
                    break;

                case 2:
                    flat = "SFLR6_1";
                    text = DoomInfo.Strings.E2TEXT;
                    break;

                case 3:
                    flat = "MFLR8_4";
                    text = DoomInfo.Strings.E3TEXT;
                    break;

                case 4:
                    flat = "MFLR8_3";
                    text = DoomInfo.Strings.E4TEXT;
                    break;

                default:
                    break;
                }
                break;

            case GameMode.Commercial:
                options.Music.StartMusic(Bgm.READ_M, true);
                switch (options.Map)
                {
                case 6:
                    flat = "SLIME16";
                    text = c1Text;
                    break;

                case 11:
                    flat = "RROCK14";
                    text = c2Text;
                    break;

                case 20:
                    flat = "RROCK07";
                    text = c3Text;
                    break;

                case 30:
                    flat = "RROCK17";
                    text = c4Text;
                    break;

                case 15:
                    flat = "RROCK13";
                    text = c5Text;
                    break;

                case 31:
                    flat = "RROCK19";
                    text = c6Text;
                    break;

                default:
                    break;
                }
                break;

            default:
                options.Music.StartMusic(Bgm.READ_M, true);
                flat = "F_SKY1";
                text = DoomInfo.Strings.C1TEXT;
                break;
            }

            stage = 0;
            count = 0;

            scrolled    = 0;
            showTheEnd  = false;
            theEndIndex = 0;
        }
Пример #4
0
        public DoomApplication(CommandLineArgs args, String[] configLines, HttpClient http, Stream wadStream,
                               IJSRuntime jsRuntime, IJSInProcessRuntime jSInProcessRuntime, WebAssemblyJSRuntime webAssemblyJSRuntime,
                               string wadUrl)
        {
            Http                 = http;
            WadStream            = wadStream;
            JsRuntime            = jsRuntime;
            JSInProcessRuntime   = jSInProcessRuntime;
            WebAssemblyJSRuntime = webAssemblyJSRuntime;
            configLines          = new string[] {
                "video_screenwidth=320",
                "video_screenHeight=200",
            };
            config = new Config(configLines);

            try
            {
                config.video_screenwidth  = Math.Clamp(config.video_screenwidth, 320, 3200);
                config.video_screenheight = Math.Clamp(config.video_screenheight, 200, 2000);
                var videoMode = VideoMode.CanvasMode;
                var style     = Styles.Close | Styles.Titlebar;
                if (config.video_fullscreen)
                {
                    style = Styles.Fullscreen;
                }
                window = new RenderWindow(videoMode, ApplicationInfo.Title, style);
                window.Clear(new Color(64, 64, 64));
                window.Display();

                if (args.deh.Present)
                {
                    DeHackEd.ReadFiles(args.deh.Value);
                }

                // resource = new CommonResource(GetWadPaths(args));
                resource = new CommonResource(new string[] { wadUrl });

                renderer = new SfmlRenderer(config, window, resource);

                if (!args.nosound.Present && !args.nosfx.Present)
                {
                    sound = new SfmlSound(config, resource.Wad);
                }

                if (!args.nosound.Present && !args.nomusic.Present)
                {
                    music = ConfigUtilities.GetSfmlMusicInstance(config, resource.Wad);
                }

                userInput = new SfmlUserInput(config, window, !args.nomouse.Present);



                options             = new GameOptions();
                options.GameVersion = resource.Wad.GameVersion;
                options.GameMode    = resource.Wad.GameMode;
                options.MissionPack = resource.Wad.MissionPack;
                options.Renderer    = renderer;
                options.Sound       = sound;
                options.Music       = music;
                options.UserInput   = userInput;

                menu = new DoomMenu(this);

                opening = new OpeningSequence(resource, options);

                cmds = new TicCmd[Player.MaxPlayerCount];
                for (var i = 0; i < Player.MaxPlayerCount; i++)
                {
                    cmds[i] = new TicCmd();
                }
                game = new DoomGame(resource, options);

                wipe   = new WipeEffect(renderer.WipeBandCount, renderer.WipeHeight);
                wiping = false;

                currentState = ApplicationState.None;
                nextState    = ApplicationState.Opening;
                needWipe     = false;

                sendPause = false;

                quit        = false;
                quitMessage = null;

                CheckGameArgs(args);
            }
            catch (Exception e)
            {
                Dispose();
                ExceptionDispatchInfo.Throw(e);
            }
        }
Пример #5
0
        public World(CommonResource resorces, GameOptions options, DoomGame game)
        {
            this.options = options;
            this.game    = game;

            if (game != null)
            {
                random = game.Random;
            }
            else
            {
                random = new DoomRandom();
            }

            map = new Map(resorces, this);

            thinkers         = new Thinkers(this);
            specials         = new Specials(this);
            thingAllocation  = new ThingAllocation(this);
            thingMovement    = new ThingMovement(this);
            thingInteraction = new ThingInteraction(this);
            mapCollision     = new MapCollision(this);
            mapInteraction   = new MapInteraction(this);
            pathTraversal    = new PathTraversal(this);
            hitscan          = new Hitscan(this);
            visibilityCheck  = new VisibilityCheck(this);
            sectorAction     = new SectorAction(this);
            playerBehavior   = new PlayerBehavior(this);
            itemPickup       = new ItemPickup(this);
            weaponBehavior   = new WeaponBehavior(this);
            monsterBehavior  = new MonsterBehavior(this);
            lightingChange   = new LightingChange(this);
            statusBar        = new StatusBar(this);
            autoMap          = new AutoMap(this);
            cheat            = new Cheat(this);

            options.IntermissionInfo.TotalFrags = 0;
            options.IntermissionInfo.ParTime    = 180;

            for (var i = 0; i < Player.MaxPlayerCount; i++)
            {
                options.Players[i].KillCount   = 0;
                options.Players[i].SecretCount = 0;
                options.Players[i].ItemCount   = 0;
            }

            // Initial height of view will be set by player think.
            options.Players[options.ConsolePlayer].ViewZ = Fixed.Epsilon;

            totalKills   = 0;
            totalItems   = 0;
            totalSecrets = 0;

            LoadThings();

            // If deathmatch, randomly spawn the active players.
            if (options.Deathmatch != 0)
            {
                for (var i = 0; i < Player.MaxPlayerCount; i++)
                {
                    if (options.Players[i].InGame)
                    {
                        options.Players[i].Mobj = null;
                        thingAllocation.DeathMatchSpawnPlayer(i);
                    }
                }
            }

            specials.SpawnSpecials();

            levelTime    = 0;
            doneFirstTic = false;
            secretExit   = false;
            completed    = false;

            validCount = 0;

            displayPlayer = options.ConsolePlayer;

            dummy = new Mobj(this);

            options.Music.StartMusic(Map.GetMapBgm(options), true);
        }
Пример #6
0
 public World(CommonResource resorces, GameOptions options) : this(resorces, options, null)
 {
 }
Пример #7
0
        public World(CommonResource resorces, GameOptions options, Player[] players)
        {
            Options = options;
            Players = players;

            map = new Map(resorces, this);

            random = options.Random;

            validCount = 0;

            thinkers = new Thinkers(this);
            specials = new Specials(this);

            thingAllocation  = new ThingAllocation(this);
            thingMovement    = new ThingMovement(this);
            thingInteraction = new ThingInteraction(this);
            mapCollision     = new MapCollision(this);
            mapInteraction   = new MapInteraction(this);
            pathTraversal    = new PathTraversal(this);
            hitscan          = new Hitscan(this);
            visibilityCheck  = new VisibilityCheck(this);
            sectorAction     = new SectorAction(this);
            playerBehavior   = new PlayerBehavior(this);
            itemPickup       = new ItemPickup(this);
            weaponBehavior   = new WeaponBehavior(this);
            monsterBehavior  = new MonsterBehavior(this);
            lightingChange   = new LightingChange(this);
            statusBar        = new StatusBar(this);
            autoMap          = new AutoMap(this);

            totalKills              = 0;
            totalItems              = 0;
            totalSecrets            = 0;
            options.wminfo.maxFrags = 0;
            options.wminfo.ParTime  = 180;
            for (var i = 0; i < Player.MaxPlayerCount; i++)
            {
                players[i].KillCount   = 0;
                players[i].SecretCount = 0;
                players[i].ItemCount   = 0;
            }

            // Initial height of PointOfView
            // will be set by player think.
            players[consoleplayer].ViewZ = new Fixed(1);

            LoadThings();

            // if deathmatch, randomly spawn the active players
            if (options.Deathmatch != 0)
            {
                for (var i = 0; i < Player.MaxPlayerCount; i++)
                {
                    if (players[i].InGame)
                    {
                        players[i].Mobj = null;
                        G_DeathMatchSpawnPlayer(i);
                    }
                }
            }

            SpawnSpecials();
        }
Пример #8
0
        public Doom(CommandLineArgs args, Config config, GameContent content, IVideo video, ISound sound, IMusic music, IUserInput userInput)
        {
            video     = video ?? NullVideo.GetInstance();
            sound     = sound ?? NullSound.GetInstance();
            music     = music ?? NullMusic.GetInstance();
            userInput = userInput ?? NullUserInput.GetInstance();

            this.args      = args;
            this.config    = config;
            this.content   = content;
            this.video     = video;
            this.sound     = sound;
            this.music     = music;
            this.userInput = userInput;

            if (args.deh.Present)
            {
                DeHackEd.ReadFiles(args.deh.Value);
            }

            if (!args.nodeh.Present)
            {
                DeHackEd.ReadDeHackEdLump(content.Wad);
            }

            events = new List <DoomEvent>();

            options             = new GameOptions();
            options.GameVersion = content.Wad.GameVersion;
            options.GameMode    = content.Wad.GameMode;
            options.MissionPack = content.Wad.MissionPack;
            options.Video       = video;
            options.Sound       = sound;
            options.Music       = music;
            options.UserInput   = userInput;

            menu = new DoomMenu(this);

            opening = new OpeningSequence(content, options);

            cmds = new TicCmd[Player.MaxPlayerCount];
            for (var i = 0; i < Player.MaxPlayerCount; i++)
            {
                cmds[i] = new TicCmd();
            }
            game = new DoomGame(content, options);

            wipeEffect = new WipeEffect(video.WipeBandCount, video.WipeHeight);
            wiping     = false;

            currentState = DoomState.None;
            nextState    = DoomState.Opening;
            needWipe     = false;

            sendPause = false;

            quit        = false;
            quitMessage = null;

            mouseGrabbed = false;

            CheckGameArgs();
        }
Пример #9
0
 public World(GameContent resorces, GameOptions options) : this(resorces, options, null)
 {
 }