示例#1
0
        public static string GetVersionString(TRVersion.Game version)
        {
            switch (version)
            {
            case TRVersion.Game.TR1:
                return("Tomb Raider");

            case TRVersion.Game.TR2:
                return("Tomb Raider 2");

            case TRVersion.Game.TR3:
                return("Tomb Raider 3");

            case TRVersion.Game.TR4:
                return("Tomb Raider 4");

            case TRVersion.Game.TRNG:
                return("TRNG");

            case TRVersion.Game.TR5:
                return("Tomb Raider 5");

            case TRVersion.Game.TR5Main:
                return("TR5Main");

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
示例#2
0
        public static int TryToGetStateID(TRVersion.Game version, uint objectId, string stateName)
        {
            Game      game;
            ItemState entry = new ItemState();

            Games.TryGetValue(version.Native(), out game);

            if (game != null)
            {
                entry = game.States.FirstOrDefault(item => item.Item == objectId && item.Name.ToLower().Contains(stateName.ToLower()));
            }

            if (entry.Name == null)
            {
                foreach (var otherGame in Games.Where(g => g.Key != version.Native()))
                {
                    entry = otherGame.Value.States.FirstOrDefault(item => item.Item == objectId && item.Name.ToLower().Contains(stateName.ToLower()));
                    if (entry.Name != null)
                    {
                        break;
                    }
                }
            }

            if (entry.Name == null)
            {
                return(-1);
            }
            else
            {
                return((int)entry.State);
            }
        }
示例#3
0
 public ItemType(WadStaticId staticId, TRVersion.Game gameVersion = TRVersion.Game.TR4)
 {
     IsStatic     = true;
     MoveableId   = new WadMoveableId();
     _gameVersion = gameVersion.Native();
     StaticId     = staticId;
 }
示例#4
0
        private void butCreate_Click(object sender, EventArgs e)
        {
            Version = (TRVersion.Game)comboGameVersion.SelectedItem;

            DialogResult = DialogResult.OK;
            Close();
        }
示例#5
0
 public ItemType(WadMoveableId moveableId, TRVersion.Game gameVersion = TRVersion.Game.TR4)
 {
     IsStatic     = false;
     MoveableId   = moveableId;
     _gameVersion = gameVersion.Native();
     StaticId     = new WadStaticId();
 }
示例#6
0
        public Prj2SoundsConversionDialog(TRVersion.Game version, List <FileFormatConversions.SoundInfoConversionRow> conversionRows)
        {
            _version        = version.Native();
            _conversionRows = conversionRows;

            InitializeComponent();
        }
示例#7
0
        private Project CreateNewProject(string projectName, string projectPath, string enginePath, string scriptPath, string levelsPath)
        {
            TRVersion.Game gameVersion = 0;

            switch (comboBox_EngineType.SelectedIndex)
            {
            case 1:
                gameVersion = TRVersion.Game.TRNG;
                break;

            case 2:
                gameVersion = TRVersion.Game.TRNG;
                break;
            }

            string launchFilePath = Path.Combine(projectPath, "launch.exe");

            return(new Project
            {
                Name = projectName,
                GameVersion = gameVersion,
                DefaultLanguage = GameLanguage.English,
                LaunchFilePath = launchFilePath,
                ProjectPath = projectPath,
                EnginePath = enginePath,
                ScriptPath = scriptPath,
                LevelsPath = levelsPath
            });
        }
示例#8
0
        public static uint?GetItemIndex(TRVersion.Game version, string name, out bool isMoveable)
        {
            Game game;

            if (!Games.TryGetValue(version.Native(), out game))
            {
                isMoveable = false;
                return(null);
            }

            var entry = game.Moveables.FirstOrDefault(item => item.Value.Names.Any(possibleName => possibleName.Equals(name, StringComparison.InvariantCultureIgnoreCase)));

            if (entry.Value.Names != null)
            {
                isMoveable = true;
                return(entry.Key);
            }

            entry = game.Statics.FirstOrDefault(item => item.Value.Names.Any(possibleName => possibleName.Equals(name, StringComparison.InvariantCultureIgnoreCase)));
            if (entry.Value.Names != null)
            {
                isMoveable = false;
                return(entry.Key);
            }

            entry = game.SpriteSequences.FirstOrDefault(item => item.Value.Names.Any(possibleName => possibleName.Equals(name, StringComparison.InvariantCultureIgnoreCase)));
            if (entry.Value.Names != null)
            {
                isMoveable = false;
                return(entry.Key);
            }

            isMoveable = false;
            return(null);
        }
示例#9
0
        private void CompileMainSFX(TRVersion.Game version, bool onlyIndexed)
        {
            LevelSettings settings;
            var           sounds = Sounds.SoundInfos;

            if (sounds.Count == 0)
            {
                popup.ShowError(soundInfoEditor, "No sounds present. Nothing to compile!");
                return;
            }

            settings = new LevelSettings()
            {
                GameVersion = version
            };
            settings.WadSoundPaths.Clear();
            var samplePath = LevelFileDialog.BrowseFolder(this, null, _configuration.SoundTool_LastMainSFXSamplePath,
                                                          "Choose a path where all samples are stored", null);

            if (string.IsNullOrEmpty(samplePath))
            {
                return; // User cancelled path selection
            }
            settings.WadSoundPaths.Add(new WadSoundPath(samplePath));
            _configuration.SoundTool_LastMainSFXSamplePath = samplePath; // Update settings

            var mainSFXPath = LevelFileDialog.BrowseFile(this, null, _configuration.SoundTool_LastMainSFXPath,
                                                         "Choose a path to save MAIN.SFX", _fileFormatSfx, null, true);

            if (string.IsNullOrEmpty(mainSFXPath))
            {
                return; // User cancelled saving
            }
            bool missing;
            var  samples = WadSample.CompileSamples(sounds, settings, onlyIndexed, out missing);

            try
            {
                using (var writer = new BinaryWriterEx(new FileStream(mainSFXPath, FileMode.Create, FileAccess.Write, FileShare.None)))
                {
                    foreach (var sample in samples.Values)
                    {
                        writer.Write(sample.Data, 0, sample.Data.Length);
                    }
                }

                var message = "MAIN.SFX compiled successfully!";
                if (missing)
                {
                    message += "\n" + "Some samples weren't found and won't play in game.";
                }
                popup.ShowInfo(soundInfoEditor, message);
                _configuration.SoundTool_LastMainSFXPath = mainSFXPath;
            }
            catch (Exception ex)
            {
                popup.ShowError(soundInfoEditor, "There was a error writing MAIN.SFX. \nException: " + ex.Message);
            }
        }
示例#10
0
        public static string GetDefaultTemplatesPath(TRVersion.Game gameVersion)
        {
            switch (gameVersion)
            {
            case TRVersion.Game.TRNG: return(Path.Combine(GetProgramDirectory(), "TIDE", "Templates", "TOMB4", "Defaults"));

            case TRVersion.Game.TR5Main: return(Path.Combine(GetProgramDirectory(), "TIDE", "Templates", "TOMB5", "Defaults"));

            default: return(null);
            }
        }
示例#11
0
        public static int TryGetSoundInfoIdByDescription(TRVersion.Game version, string name)
        {
            var sounds = Games[version.Native()].Sounds;

            foreach (var pair in sounds)
            {
                if (pair.Value.Description.Equals(name, StringComparison.InvariantCultureIgnoreCase))
                {
                    return((int)pair.Key);
                }
            }
            return(-1);
        }
示例#12
0
        public static Level CreateSimpleLevel(TRVersion.Game version = TRVersion.Game.TRNG)
        {
            logger.Info("Creating new empty level");

            Level result = new Level();

            result.Settings.GameVersion = version;
            result.Settings.ConvertLevelExtension();

            if (result.Rooms[0] == null)
            {
                result.Rooms[0] = new Room(result, Room.DefaultRoomDimensions, Room.DefaultRoomDimensions, result.Settings.DefaultAmbientLight, "Room 0");
            }
            return(result);
        }
示例#13
0
        public static string GetSpriteSequenceTR5MainSlot(TRVersion.Game version, uint id)
        {
            Game game;

            if (!Games.TryGetValue(version.Native(), out game))
            {
                return("");
            }
            Item entry;

            if (!game.SpriteSequences.TryGetValue(id, out entry))
            {
                return("");
            }
            return(game.SpriteSequences[id].TR5MainSlot);
        }
示例#14
0
        public static string GetSpriteSequenceName(TRVersion.Game version, uint id)
        {
            Game game;

            if (!Games.TryGetValue(version.Native(), out game))
            {
                return("Unknown #" + id);
            }
            Item entry;

            if (!game.SpriteSequences.TryGetValue(id, out entry))
            {
                return("Unknown #" + id);
            }
            return(game.SpriteSequences[id].Names.LastOrDefault());
        }
示例#15
0
        public static string GetOriginalSoundName(TRVersion.Game version, uint id)
        {
            Game game;

            if (!Games.TryGetValue(version.Native(), out game))
            {
                return("UNKNOWN_SOUND_" + id);
            }
            ItemSound entry;

            if (!game.Sounds.TryGetValue(id, out entry))
            {
                return("UNKNOWN_SOUND_" + id);
            }
            return(game.Sounds[id].Name);
        }
示例#16
0
        public static uint GetMoveableSkin(TRVersion.Game version, uint id)
        {
            Game game;

            if (!Games.TryGetValue(version.Native(), out game))
            {
                return(id);
            }
            Item entry;

            if (!game.Moveables.TryGetValue(id, out entry))
            {
                return(id);
            }
            return(game.Moveables[id].SkinId);
        }
示例#17
0
        public static bool IsSoundFixedByDefault(TRVersion.Game version, uint id)
        {
            Game game;

            if (!Games.TryGetValue(version.Native(), out game))
            {
                return(false);
            }
            ItemSound entry;

            if (!game.Sounds.TryGetValue(id, out entry))
            {
                return(false);
            }
            return(game.Sounds[id].FixedByDefault);
        }
示例#18
0
        public static bool IsStaticShatterable(TRVersion.Game version, uint id)
        {
            Game game;

            if (!Games.TryGetValue(version.Native(), out game))
            {
                return(false);
            }
            Item entry;

            if (!game.Statics.TryGetValue(id, out entry))
            {
                return(false);
            }

            return(entry.Shatterable);
        }
示例#19
0
        public static bool IsMoveableAI(TRVersion.Game version, uint id)
        {
            Game game;

            if (!Games.TryGetValue(version.Native(), out game))
            {
                return(false);
            }
            Item entry;

            if (!game.Moveables.TryGetValue(id, out entry))
            {
                return(false);
            }

            return(entry.AIObject);
        }
示例#20
0
        public PopUpSearch(Control callbackControl, TRVersion.Game version = TRVersion.Game.TR4)
        {
            InitializeComponent();

            // Remember colors
            _correctColor = txtSearchString.BackColor;
            _wrongColor   = _correctColor.MixWith(Color.DarkRed, 0.55);

            // Set up parameters
            _currentIndex = -1;
            _searchItems.Clear();
            _callbackControl = callbackControl;
            _version         = version;

            // TODO: Support other control types?
            if (_callbackControl is DarkComboBox)
            {
                var callbackCombo = (DarkComboBox)_callbackControl;
                foreach (var item in callbackCombo.Items)
                {
                    if (item is IWadObject)
                    {
                        _searchItems.Add((item as IWadObject).ToString(_version));
                    }
                    else
                    {
                        _searchItems.Add(item.ToString());
                    }
                }
            }

            // Set pop-up width to parent control width
            Size = new Size(_callbackControl.Size.Width, MinimumSize.Height);

            // Set backcolor
            BackColor = Colors.DarkBackground;

            // Start intro animation
            _animProgress    = 0.0f;
            _animTimer.Tick += UpdateTimer;
            _animTimer.Start();
        }
示例#21
0
        public static WadMoveableId?GetHorizon(TRVersion.Game gameVersion)
        {
            switch (gameVersion)
            {
            case TRVersion.Game.TR2:
                return(new WadMoveableId(254));

            case TRVersion.Game.TR3:
                return(new WadMoveableId(355));

            case TRVersion.Game.TR4:
            case TRVersion.Game.TR5:
            case TRVersion.Game.TRNG:
            case TRVersion.Game.TR5Main:
                return(new WadMoveableId(459));

            default:
                return(null);
            }
        }
示例#22
0
        public static uint GetSubstituteID(TRVersion.Game version, uint id)
        {
            Game game;

            if (!Games.TryGetValue(version.Native(), out game))
            {
                return(id);
            }
            Item entry;

            if (!game.Moveables.TryGetValue(id, out entry))
            {
                return(id);
            }
            if (game.Moveables[id].SubstituteId == -1)
            {
                return(id);
            }
            return((uint)game.Moveables[id].SubstituteId);
        }
示例#23
0
        public static int PredictSoundMapSize(TRVersion.Game version, bool IsNg, int numDemoData)
        {
            switch (version.Native())
            {
            case TRVersion.Game.TR1:
                return(256);

            case TRVersion.Game.TR2:
            case TRVersion.Game.TR3:
                return(370);

            case TRVersion.Game.TR4:
                return(IsNg && numDemoData != 0 ? numDemoData : 370);

            case TRVersion.Game.TR5:
            case TRVersion.Game.TR5Main:
                return(450);

            default:
                throw new ArgumentOutOfRangeException("Unknown game version.");
            }
        }
示例#24
0
        private TRVersion.Game GetGameVersion(string exeFilePath)
        {
            TRVersion.Game gameVersion = 0;

            switch (Path.GetFileName(exeFilePath).ToLower())
            {
            case "tomb4.exe":
                gameVersion = TRVersion.Game.TR4;
                break;

            case "pctomb5.exe":
                gameVersion = TRVersion.Game.TR5Main;
                break;
            }

            if (gameVersion == TRVersion.Game.TR4 && File.Exists(Path.Combine(Path.GetDirectoryName(exeFilePath), "tomb_nextgeneration.dll")))
            {
                gameVersion = TRVersion.Game.TRNG;
            }

            return(gameVersion);
        }
示例#25
0
        public static int GetTR5MainSoundMapStart(TRVersion.Game version)
        {
            switch (version)
            {
            case TRVersion.Game.TR1:
                return(450);

            case TRVersion.Game.TR2:
                return(450 + 256);

            case TRVersion.Game.TR3:
                return(450 + 256 + 370);

            case TRVersion.Game.TR4:
            case TRVersion.Game.TRNG:
                return(450 + 256 + 370 + 370);

            case TRVersion.Game.TR5:
                return(0);

            default:
                return(0);
            }
        }
示例#26
0
        public static string GetAnimationName(TRVersion.Game version, uint objectId, uint animId)
        {
            Game          game;
            ItemAnimation entry = new ItemAnimation();

            Games.TryGetValue(version.Native(), out game);

            if (game != null)
            {
                entry = game.Animations.FirstOrDefault(item => item.Item == objectId && item.Animation == animId);
            }

            if (entry.Name == null)
            {
                var otherGames = Games.Where(g => g.Key != version.Native()).ToList();
                otherGames.Reverse();

                foreach (var otherGame in otherGames)
                {
                    entry = otherGame.Value.Animations.FirstOrDefault(item => item.Item == objectId && item.Animation == animId);
                    if (entry.Name != null)
                    {
                        break;
                    }
                }
            }

            if (entry.Name == null)
            {
                return("Animation " + animId);
            }
            else
            {
                return(entry.Name);
            }
        }
示例#27
0
        public static string GetStateName(TRVersion.Game version, uint objectId, uint stateId)
        {
            Game      game;
            ItemState entry = new ItemState();

            Games.TryGetValue(version.Native(), out game);

            if (game != null)
            {
                entry = game.States.FirstOrDefault(item => item.Item == objectId && item.State == stateId);
            }

            if (entry.Name == null)
            {
                var otherGames = Games.Where(g => g.Key != version.Native()).ToList();
                otherGames.Reverse();

                foreach (var otherGame in otherGames)
                {
                    entry = otherGame.Value.States.FirstOrDefault(item => item.Item == objectId && item.State == stateId);
                    if (entry.Name != null)
                    {
                        break;
                    }
                }
            }

            if (entry.Name == null)
            {
                return("Unknown state " + stateId);
            }
            else
            {
                return(entry.Name);
            }
        }
示例#28
0
 public string ToString(TRVersion.Game gameVersion) => Id.ToString(gameVersion.Native());
示例#29
0
 public string ShortName(TRVersion.Game gameVersion) => TrCatalog.GetStaticName(gameVersion, TypeId);
示例#30
0
 public string ToString(TRVersion.Game gameVersion)
 {
     return("(" + TypeId + ") " + TrCatalog.GetStaticName(gameVersion, TypeId));
 }