private void OnAddInstallation() { try { var folderBrowser = new FolderBrowserDialog { Description = "Please select the DCS folder you wish to add...", RootFolder = Environment.SpecialFolder.MyComputer, ShowNewFolderButton = false }; if (folderBrowser.ShowDialog() == DialogResult.OK) { var selectedFolder = folderBrowser.SelectedPath; var installation = new InstallLocation(selectedFolder); Installations.Add(new InstallLocationModel(installation)); _settingsService.AddInstalls(installation.Directory); } } catch (Exception e) { GeneralExceptionHandler.Instance.OnError(e); } }
/// <summary> /// Gets the folder path for the chosen installlocation /// </summary> /// <param name="location"></param> /// <returns></returns> private string GetInstallFolderPath(InstallLocation location) { Environment.SpecialFolder specialDirectory; var folderName = runningAssembly.AssemblyName.Replace(".exe", ""); switch (location) { case InstallLocation.AppData: specialDirectory = Environment.SpecialFolder.ApplicationData; break; case InstallLocation.Documents: specialDirectory = Environment.SpecialFolder.MyDocuments; break; default: specialDirectory = Environment.SpecialFolder.MyDocuments; break; } string targetFolderPath = Path.Combine(Environment.GetFolderPath(specialDirectory), folderName); try { Directory.CreateDirectory(targetFolderPath); } catch { return(null); } return(targetFolderPath); }
public override void Initialize() { base.Initialize(); InstallLocation install = Install; List <AnimationData> animationData = new List <AnimationData>(); using (FileStream stream = File.Open(install.GetPath("animdata.mul"), FileMode.Open)) using (BinaryReader reader = new BinaryReader(stream)) { int totalBlocks = (int)(reader.BaseStream.Length / 548); for (int i = 0; i < totalBlocks; i++) { int header = reader.ReadInt32(); byte[] frameData = reader.ReadBytes(64); AnimationData animData = new AnimationData { FrameData = new sbyte[64], Unknown = reader.ReadByte(), FrameCount = reader.ReadByte(), FrameInterval = reader.ReadByte(), FrameStart = reader.ReadByte() }; Buffer.BlockCopy(frameData, 0, animData.FrameData, 0, 64); animationData.Add(animData); } } _animationData = animationData.ToArray(); }
private void OnSelectedInstallChanged(InstallLocation install) { Options.Clear(); if (install == null) { return; } Task.Run(() => { try { var categories = SettingsController.GetDcsCategoryOptionForInstall(install, false); var category = categories.FirstOrDefault(c => c.Id == _categoryId); if (category == null) { return; } var models = OptionModelFactory.CreateAll(category.Options); foreach (var model in models) { model.ValueChangeObservable.Subscribe(value => OnValueChanged(model, value)); Options.AddOnScheduler(model); } } catch (Exception e) { GeneralExceptionHandler.Instance.OnError(e); } }); }
public OpenUOSDK(string path = "") { if (_ClientData == null && (path != "" || path != null)) { if (Directory.Exists(path)) { _ClientData = path; } } IoCContainer container = new IoCContainer(); container.RegisterModule <UltimaSDKCoreModule>(); container.RegisterModule <UltimaSDKBitmapModule>(); InstallLocation location = (_ClientData == null ? InstallationLocator.Locate().FirstOrDefault() : (InstallLocation)_ClientData); if (!Directory.Exists(location.ToString())) { Utility.PushColor(ConsoleColor.Red); Console.WriteLine("OpenUO Error: Client files not found."); Utility.PopColor(); } _animationDataFactory = new AnimationDataFactory(location, container); _animationFactory = new AnimationFactory(location, container); _artworkFactory = new ArtworkFactory(location, container); _asciiFontFactory = new ASCIIFontFactory(location, container); _clilocFactory = new ClilocFactory(location, container); _gumpFactory = new GumpFactory(location, container); _skillsFactory = new SkillsFactory(location, container); _soundFactory = new SoundFactory(location, container); _texmapFactory = new TexmapFactory(location, container); _unicodeFontFactory = new UnicodeFontFactory(location, container); }
public Maps(InstallLocation install) { Felucca = new Map(install, 0, 0, 6144, 4096); Trammel = new Map(install, 0, 1, 6144, 4096); Ilshenar = new Map(install, 2, 2, 2304, 1600); Malas = new Map(install, 3, 3, 2560, 2048); Tokuno = new Map(install, 4, 4, 1448, 1448); }
public Map(InstallLocation install, int fileIndex, int mapID, int width, int height) { m_FileIndex = fileIndex; m_MapID = mapID; m_Width = width; m_Height = height; m_Tiles = new TileMatrix(install, m_FileIndex, m_MapID, m_Width, m_Height); }
public override void Initialize() { base.Initialize(); InstallLocation install = Install; _fileIndex = install.CreateFileIndex("texidx.mul", "texmaps.mul"); }
/// <summary> /// Check if the install location is not empty and is not a system directory /// </summary> public bool IsInstallLocationValid() { if (string.IsNullOrEmpty(InstallLocation?.Trim())) { return(false); } return(!UninstallToolsGlobalConfig.GetAllProgramFiles().Any(x => PathTools.PathsEqual(x, InstallLocation))); }
public override void Initialize() { base.Initialize(); InstallLocation install = Install; ReadCategories(install); ReadSkills(install); }
public override void Initialize() { base.Initialize(); InstallLocation install = Install; _fileIndex = install.IsUOPFormat ? install.CreateFileIndex("artLegacyMUL.uop", 0x10000, false, ".tga") : install.CreateFileIndex("artidx.mul", "art.mul"); }
/// <summary> /// Serves as a hash function for a particular type. /// </summary> /// <returns>A hash code for the current <see cref="T:System.Object" />.</returns> public override int GetHashCode() { return(Architecture.GetHashCode() ^ DisplayName?.GetHashCode() ?? 0 ^ InstallLocation?.GetHashCode() ?? 0 ^ PackageName?.GetHashCode() ?? 0 ^ PublisherId?.GetHashCode() ?? 0 ^ ResourceId?.GetHashCode() ?? 0 ^ Version.GetHashCode()); }
public override void Initialize() { base.Initialize(); InstallLocation install = Install; _fileIndex = install.IsUOPFormat ? install.CreateFileIndex("soundLegacyMUL.uop", 0xFFF, false, ".dat") : install.CreateFileIndex("soundidx.mul", "sound..mul"); }
public World(IoCContainer container) { IConfiguration config = container.Resolve <IConfiguration>(); _container = container; _install = config.GetValue <InstallLocation>(ConfigSections.Client, ConfigKeys.InstallLocation); _camera = new Camera2D(); _facets = new List <Facet>(); }
public override void Initialize() { base.Initialize(); InstallLocation install = Install; _fileIndex = install.IsUOPFormat ? install.CreateFileIndex("gumpartLegacyMUL.uop") : install.CreateFileIndex("gumpidx.mul", "gumpart.mul"); }
public override void Initialize() { base.Initialize(); InstallLocation install = Install; _fonts = new ASCIIFont[10]; using (BinaryReader reader = new BinaryReader(File.Open(install.GetPath("fonts.mul"), FileMode.Open))) { for (int i = 0; i < 10; ++i) { reader.ReadByte(); //header var chars = new ASCIIChar[224]; int fontHeight = 0; for (int k = 0; k < 224; ++k) { byte width = reader.ReadByte(); byte height = reader.ReadByte(); reader.ReadByte(); // delimeter? if (width > 0 && height > 0) { if (height > fontHeight && k < 96) { fontHeight = height; } var pixels = new ushort[width * height]; for (int y = 0; y < height; ++y) { for (int x = 0; x < width; ++x) { pixels[y * width + x] = (ushort)(reader.ReadByte() | (reader.ReadByte() << 8)); } } chars[k] = new ASCIIChar { Pixels = pixels, Width = width, Height = height }; } } _fonts[i] = new ASCIIFont(fontHeight, chars); } } }
public MainWindow() { InitializeComponent(); Container = new IoCContainer(); InstallLocation = InstallationLocator.Locate().First(); SDK = new TilesCategorySDKModule(InstallLocation); Container.RegisterModule <UltimaSDKCoreModule>(); Container.RegisterModule <OpenUO.Ultima.PresentationFramework.UltimaSDKImageSourceModule>(); FactoryArt = new ArtworkFactory(InstallLocation, Container); FactoryTex = new TexmapFactory(InstallLocation, Container); DataContext = SDK; }
private void ReadSkills(InstallLocation install) { FileIndexBase fileIndex = install.CreateFileIndex("skills.idx", "skills.mul"); _skills = new Skill[fileIndex.Length]; for (int i = 0; i < _skills.Length; i++) { Skill skill = ReadSkill(fileIndex, i); _skills[i] = skill; } }
private void ReadCategories(InstallLocation install) { List <SkillCategory> categories = new List <SkillCategory>(); string grpPath = install.GetPath("skillgrp.mul"); if (grpPath == null) { _categories = categories.ToArray(); return; } using (FileStream stream = new FileStream(grpPath, FileMode.Open, FileAccess.Read, FileShare.Read)) { BinaryReader bin = new BinaryReader(stream); int categoryCount = bin.ReadInt32(); categories.Add(new SkillCategory(new SkillCategoryData(-17, 0, "Misc."))); for (int i = 1; i < categoryCount; i++) { BinaryReader nameReader = new BinaryReader(stream); StringBuilder nameBuilder = new StringBuilder(); byte[] nameBuffer = bin.ReadBytes(17); for (int j = 0; j < 17; j++) { char ch = (char)nameBuffer[j]; if (char.IsLetterOrDigit(ch) || char.IsWhiteSpace(ch) || char.IsPunctuation(ch)) { nameBuilder.Append(ch); } } string name = nameBuilder.ToString(); long fileIndex = stream.Position - name.Length; categories.Add(new SkillCategory(new SkillCategoryData(fileIndex, i, name))); } _categoryLookup = new int[(stream.Length - stream.Position) / 4]; for (int i = 0; i < _categoryLookup.Length; i++) { _categoryLookup[i] = bin.ReadInt32(); } } _categories = categories.ToArray(); }
private void findDirectoryButton_Click(object sender, EventArgs e) { using (FolderBrowserDialog dialog = new FolderBrowserDialog()) { dialog.Description = "Select your Ultima Online directory"; if (dialog.ShowDialog() == DialogResult.OK) { InstallLocation install = new InstallLocation(dialog.SelectedPath); installsComboBox.SelectedItem = new ComboBoxItem <InstallLocation>(string.Format("{0} - {1}", install.Version, install.Directory), install); } } }
public static void Init() { Container = new IoCContainer(); if (InstallLocation == null) { InstallLocation = InstallationLocator.Locate().FirstOrDefault(); } if (InstallLocation != null) { SdkTiles = new TilesCategorySDKModule(InstallLocation); SdkTiles.Populate(); } if (!innerInit) { InnerInit(); } }
public override void Initialize() { base.Initialize(); InstallLocation install = Install; _fileIndices = new[] { install.CreateFileIndex("anim.idx", "anim.mul"), install.CreateFileIndex("anim2.idx", "anim2.mul"), install.CreateFileIndex("anim3.idx", "anim3.mul"), install.CreateFileIndex("anim4.idx", "anim4.mul"), install.CreateFileIndex("anim5.idx", "anim5.mul") }; _bodyTable = new BodyTable(install.GetPath("body.def")); _bodyConverter = new BodyConverter(install.GetPath("bodyconv.def")); _hues = new Hues(install); }
private void buttonLoadFolder_Click(object sender, RoutedEventArgs e) { if (!string.IsNullOrEmpty(textBoxFolder.Text)) { try { InstallLocation = new InstallLocation(textBoxFolder.Text); SDK = new TilesCategorySDKModule(InstallLocation); Container = new IoCContainer(); Container.RegisterModule <UltimaSDKCoreModule>(); Container.RegisterModule <OpenUO.Ultima.PresentationFramework.UltimaSDKImageSourceModule>(); FactoryArt = new ArtworkFactory(InstallLocation, Container); FactoryTex = new TexmapFactory(InstallLocation, Container); } catch (Exception) { } } }
public void AddInstalls(params string[] directories) { foreach (var dir in directories) { if (_installationCache.All(i => i.Directory != dir)) { var install = new InstallLocation(dir); _installationCache.Add(install); if (SelectedInstall == null) { SelectedInstall = install; } } } SetValue(SettingsCategories.Installations, SettingsKeys.Installs, _installationCache.Select(i => i.Directory).ToArray()); }
public override void Start() { base.Start(); var dataDirectory = Settings.UltimaOnline.DataDirectory; if (string.IsNullOrEmpty(dataDirectory) || !Directory.Exists(dataDirectory)) { using (var form = new SelectInstallForm("CoreAdapterTests")) { if (form.ShowDialog() == DialogResult.Cancel) { //TODO: End game } var version = form.SelectedInstall.Version; Settings.UltimaOnline.DataDirectory = dataDirectory = form.SelectedInstall.Directory; Settings.UltimaOnline.ClientVersion = version.ToString(); } } var install = new InstallLocation(dataDirectory); _spriteBatch = new SpriteBatch(GraphicsDevice) { VirtualResolution = new Vector3(_virtualResolution, 1) }; _artworkFactory = new ArtworkFactory(install, _container); _texmapFactory = new TexmapFactory(install, _container); _animationFactory = new AnimationFactory(install, _container); _gumpFactory = new GumpFactory(install, _container); _asciiFontFactory = new ASCIIFontFactory(install, _container); _unicodeFontFactory = new UnicodeFontFactory(install, _container); // register the renderer in the pipeline var scene = SceneSystem.SceneInstance.Scene; var compositor = ((SceneGraphicsCompositorLayers)scene.Settings.GraphicsCompositor); compositor.Master.Renderers.Add(new ClearRenderFrameRenderer()); compositor.Master.Renderers.Add(new SceneDelegateRenderer(RenderQuad)); }
public TilesCategorySDKModule(InstallLocation install) { Install = install; Factories = new List <Factory>(); Supp = new SuppInfo(install); Supp.Populate(); Walls = new Walls(install); Misc = new Misc(install); Roofs = new Roofs(install); Floors = new Floors(install); Factories.Add(Walls); Factories.Add(Misc); Factories.Add(Roofs); Factories.Add(Floors); Categories = new List <IList <TileCategory> >(); TileData = new TileData(install); CheckFromTxt = true; TmpStyleList = new List <TileStyle>(); TmpTileList = new List <Tile>(); }
public AutoexecLuaContext(InstallLocation install) { _autoexecPath = install.AutoexecCfg; DoString("options = options or {}"); DoString($"{OptionCategory.Graphics} = {OptionCategory.Graphics} or {{}}"); DoString($"{OptionCategory.Camera} = {OptionCategory.Camera} or {{}}"); DoString($"{OptionCategory.CameraMirrors} = {OptionCategory.CameraMirrors} or {{}}"); DoString($"{OptionCategory.Terrain} = {OptionCategory.Terrain} or {{}}"); DoString($"{OptionCategory.TerrainMirror} = {OptionCategory.TerrainMirror} or {{}}"); DoString($"{OptionCategory.TerrainReflection} = {OptionCategory.TerrainReflection} or {{}}"); DoString($"{OptionCategory.Sound} = {OptionCategory.Sound} or {{}}"); foreach (var range in CameraRangeSettings.All) { DoString($"{OptionCategory.Camera}.{range} = {OptionCategory.Camera}.{range} or {{}}"); DoString($"{OptionCategory.CameraMirrors}.{range} = {OptionCategory.CameraMirrors}.{range} or {{}}"); } Reload(); }
public DcsOptionsCategory[] GetDcsCategoryOptionForInstall(InstallLocation install, bool isVr) { var categories = _profileSettingsService.GetDcsOptions(); using (var context = new OptionLuaContext(install)) { foreach (var category in categories) { foreach (var option in category.Options) { if (!_profileSettingsService.TryGetValue <object>(ProfileSettingsCategories.GameOptions, option.Id, out var value)) { value = context.GetValue(category.Id, option.Id); } if (value != null) { var valueStr = value.ToString(); var valueType = option.Value.GetType(); var converter = TypeDescriptor.GetConverter(valueType); try { option.Value = converter.ConvertFromString(valueStr); } catch (Exception e) { Tracer.Error(e, $"An error occured while trying to convert the value {valueStr} to type {valueType} for option id {option.Id}."); } } else { Tracer.Warn($"Unable to find option value for {category.DisplayName} {option.Id}. Using default value {option.Value}"); } } } } return(categories); }
private void OnConfigRestoreDefaultsInvoked(object sender, System.EventArgs e) { IConfiguration config = Container.Resolve <IConfiguration>(); config.SetValue(ConfigSections.Client, ConfigKeys.GameWidth, 1024); config.SetValue(ConfigSections.Client, ConfigKeys.GameHeight, 768); #if DEBUG config.SetValue(ConfigSections.Diagnostics, ConfigKeys.ShowConsole, true); #else config.SetValue(ConfigSections.Diagnostics, ConfigKeys.ShowConsole, false); #endif config.SetValue(ConfigSections.Diagnostics, ConfigKeys.ConsoleTraceListener, false); config.SetValue(ConfigSections.Diagnostics, ConfigKeys.FileTraceListener, true); InstallLocation install = InstallationLocator.Locate().FirstOrDefault(); if (install != null) { config.SetValue(ConfigSections.Client, ConfigKeys.InstallLocation, install); } }
public void CleanupShaders(InstallLocation install) { var path = Path.Combine(install.SavedGamesPath, "fxo"); if (Directory.Exists(path)) { Directory.Delete(path, true); } path = Path.Combine(install.SavedGamesPath, "metashaders"); if (Directory.Exists(path)) { Directory.Delete(path, true); } path = Path.Combine(install.SavedGamesPath, "metashaders2"); if (Directory.Exists(path)) { Directory.Delete(path, true); } }