private void InitDrawableDefaults(Drawable drawable, IniFile.IniSection artSection) { drawable.OwnerCollection = this; _drawables.Add(drawable); _drawablesDict[drawable.Name] = drawable; drawable.Props.PaletteType = Defaults.GetDefaultPalette(Type, Engine); drawable.Props.LightingType = Defaults.GetDefaultLighting(Type); drawable.IsRemapable = Defaults.GetDefaultRemappability(Type, Engine); drawable.Props.FrameDecider = Defaults.GetDefaultFrameDecider(Type); // apply collection-specific offsets switch (Type) { case CollectionType.Building: case CollectionType.Overlay: case CollectionType.Smudge: drawable.Props.Offset.Offset(Drawable.TileWidth / 2, 0); break; case CollectionType.Terrain: case CollectionType.Vehicle: case CollectionType.Infantry: case CollectionType.Aircraft: case CollectionType.Animation: drawable.Props.Offset.Offset(Drawable.TileWidth / 2, Drawable.TileHeight / 2); break; } }
protected Drawable(IniFile.IniSection rules, IniFile.IniSection art) { Rules = rules; Art = art; Name = rules != null ? rules.Name : ""; Foundation = new Size(1, 1); }
void addKey() { try { ExtendedTreeNode selected = (ExtendedTreeNode)iniSectionTreeView.SelectedNode; switch (selected.GetIntegerType()) { case (0): ExtendedTreeNode addKey = new ExtendedTreeNode(String.Format("NewKey{0}", keyNumber), 1); selected.Nodes.Add(addKey); IniFile.IniSection selectedSection = ini.GetSection(selected.Text); selectedSection.AddKey(String.Format("NewKey{0}", keyNumber)); keyNumber++; break; case (1): MessageBox.Show("Please select a section node", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); break; case (2): MessageBox.Show("Please select a section node", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); break; } } catch { MessageBox.Show("Please select a section node!", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
public void SerializeIsoMapPack5(IniFile.IniSection isoMapPack5) { int cells = (Width * 2 - 1) * Height; int lzoPackSize = cells * 11 + 4; // last 4 bytes contains a lzo pack header saying no more data is left var isoMapPack = new byte[lzoPackSize]; var isoMapPack2 = new byte[lzoPackSize]; long di = 0; foreach (var tile in this.isoTiles) { var bs = tile.ToMapPack5Entry().ToArray(); Array.Copy(bs, 0, isoMapPack, di, 11); di += 11; } var compressed = Format5.Encode(isoMapPack, 5); string compressed64 = Convert.ToBase64String(compressed); int i = 1; int idx = 0; isoMapPack5.Clear(); while (idx < compressed64.Length) { int adv = Math.Min(74, compressed64.Length - idx); isoMapPack5.SetValue(i++.ToString(), compressed64.Substring(idx, adv)); idx += adv; } }
private void runGameWithCache(DataGridViewCellEventArgs e) { IniFile.IniSection cs = i.GetSection((string)cache.Rows[e.RowIndex].Cells[0].Value); File.Copy(folder + cs.Name, folder + "..\\PAK\\song.pak.xen", true); File.Copy(folder + cs.GetKey("Audio").Value, folder + "..\\MUSIC\\fastgh3.fsb.xen", true); Process.Start(folder + "..\\..\\game.exe"); }
public override void LoadRules(IniFile.IniSection rules) { base.LoadRules(rules); Normalized = rules.ReadBool("Normalized"); Translucent = rules.ReadBool("Translucent"); IsTiberium = rules.ReadBool("IsTiberium"); IsMeteor = rules.ReadBool("IsMeteor"); Elasticity = rules.ReadFloat("Elasticity", 0.8f); MinAngularVelocity = rules.ReadFloat("MinAngularVelocity"); MaxAngularVelocity = rules.ReadFloat("MaxAngularVelocity", 0.174528f); Duration = rules.ReadInt("Duration", 30); MinZVel = rules.ReadFloat("MinZVel", 3.5f); MaxZVel = rules.ReadFloat("MaxZVel", 5f); MaxXYVel = rules.ReadFloat("MaxXYVel", 15f); Spawns = Get <VoxelAnimation>(rules.ReadString("Spawns")); SpawnCount = rules.ReadInt("SpawnCount"); ShareBodyData = rules.ReadBool("ShareBodyData"); ShareTurretData = rules.ReadBool("ShareTurretData"); ShareBarrelData = rules.ReadBool("ShareBarrelData"); VoxelIndex = rules.ReadInt("VoxelIndex"); StartSound = Get <Sound>(rules.ReadString("StartSound")); StopSound = Get <Sound>(rules.ReadString("StopSound")); BounceAnim = Get <Animation>(rules.ReadString("BounceAnim")); ExpireAnim = Get <Animation>(rules.ReadString("ExpireAnim")); TrailerAnim = Get <Animation>(rules.ReadString("TrailerAnim")); Damage = rules.ReadInt("Damage"); DamageRadius = rules.ReadInt("DamageRadius"); Warhead = Get <WarheadType>(rules.ReadString("Warhead")); AttachedSystem = Get <ParticleSystem>(rules.ReadString("AttachedSystem")); ShareSource = Get <TechnoType>(rules.ReadString("ShareSource")); }
/* Finds out the correct name for an animation palette to use with fire animations. * Reason why this is so complicated is because NPatch & Ares, the YR logic extensions that support custom animation palettes * use different name for the flag declaring the palette. (NPatch uses 'Palette' whilst Ares uses 'CustomPalette' to make it distinct * from the custom object palettes). */ private Palette GetFireAnimPalette(IniFile.IniSection animation) { // Starkku: Altered as a part of a fix for crash that happened if custom palette was declared but file wasn't there. Palette pal = null; if (animation.ReadString("Palette") != "") { pal = OwnerCollection.Palettes.GetCustomPalette(animation.ReadString("Palette")); if (pal == null) { pal = OwnerCollection.Palettes.AnimPalette; } } else if (animation.ReadString("CustomPalette") != "") { pal = OwnerCollection.Palettes.GetCustomPalette(animation.ReadString("CustomPalette")); if (pal == null) { pal = OwnerCollection.Palettes.AnimPalette; } } else if (animation.ReadString("AltPalette") != "") { pal = OwnerCollection.Palettes.UnitPalette; } else { pal = OwnerCollection.Palettes.AnimPalette; } return(pal); }
/* Finds out the correct name for an animation palette to use with fire animations. * Reason why this is so complicated is because with NPatch & Ares, the YR logic extensions that support custom animation palettes * use different name for the flag declaring the palette. (NPatch uses 'Palette' whilst Ares uses 'CustomPalette' to make it distinct * from the custom object palettes). */ private Palette GetFireAnimPalette(IniFile.IniSection animation) { Palette pal = null; if (animation.ReadString("Palette") != "") { pal = OwnerCollection.Palettes.GetCustomPalette(animation.ReadString("Palette")); if (pal == null) { pal = OwnerCollection.Palettes.AnimPalette; } } else if (animation.ReadString("CustomPalette") != "") { pal = OwnerCollection.Palettes.GetCustomPalette(animation.ReadString("CustomPalette")); if (pal == null) { pal = OwnerCollection.Palettes.AnimPalette; } } else if (animation.ReadString("AltPalette") != "") { pal = OwnerCollection.Palettes.UnitPalette; } else { pal = OwnerCollection.Palettes.AnimPalette; } return(pal); }
/// <summary>Loads the houses. </summary> private void LoadHouses() { Logger.Info("Loading houses"); IniFile.IniSection housesSection = _rules.GetOrCreateSection("Houses"); foreach (var v in housesSection.OrderedEntries) { var houseSection = _rules.GetSection(v.Value); if (houseSection == null) { continue; } string color; if (v.Value == "Neutral" || v.Value == "Special") { color = "LightGrey"; // this is hardcoded in the game } else { color = houseSection.ReadString("Color"); } if (!string.IsNullOrEmpty(color) && !string.IsNullOrEmpty(v.Value)) { _countryColors[v.Value] = _namedColors[color]; } } }
public override void LoadRules(IniFile.IniSection rules) { base.LoadRules(rules); WeaponType = rules.ReadEnum <WeaponType>("WeaponType", null); Action = rules.ReadEnum <Action>("Action", Action.MultiMissile); IsPowered = rules.ReadBool("IsPowered", true); DisableableFromShell = rules.ReadBool("DisableableFromShell"); SidebarFlashTabFrames = rules.ReadInt("SidebarFlashTabFrames", -1); AIDefendAgainst = rules.ReadBool("AIDefendAgainst"); PreClick = rules.ReadBool("PreClick"); PostClick = rules.ReadBool("PostClick"); ShowTimer = rules.ReadBool("ShowTimer"); SpecialSound = Get <Sound>(rules.ReadString("SpecialSound")); StartSound = Get <Sound>(rules.ReadString("StartSound")); Range = rules.ReadFloat("Range", 0); LineMultiplier = rules.ReadInt("LineMultiplier", 0); Type = rules.ReadEnum <AbstractType>("Type", null); PreDependent = rules.ReadEnum <WeaponType>("PreDependent", null); AuxBuilding = Get <BuildingType>(rules.ReadString("AuxBuilding")); UseChargeDrain = rules.ReadBool("UseChargeDrain"); ManualControl = rules.ReadBool("ManualControl"); RechargeTime = rules.ReadFloat("RechargeTime", 5.0f); SidebarImage = rules.ReadString("SidebarImage", ""); }
protected Drawable(ModConfig config, VirtualFileSystem vfs, IniFile.IniSection rules, IniFile.IniSection art) { _config = config; _vfs = vfs; Rules = rules; Art = art; Name = rules != null ? rules.Name : ""; }
public SavingManager(IniFile.IniSection incSection) : this(Where.local) //local { if (incSection == null) { return; } section = incSection; }
public SavingManager(string _fileName) //local { isLocal = true; fileName = _fileName; string sectionName = _fileName.Remove(_fileName.LastIndexOf('.')); section = GetSettingsSection(sectionName); }
public static void SetFirstKeyFromSection(IniFile.IniSection section, ref string keyReturn) { foreach (IniFile.IniSection.IniKey key in section.Keys) { keyReturn = key.Name; break; } }
public SavingManager(IniFile.IniSection incSection) //custom { if (incSection == null) { return; } section = incSection; }
private Drawable InitBuildingDrawable(IniFile.IniSection rulesSection, IniFile.IniSection artSection) { var drawable = new BuildingDrawable(rulesSection, artSection); InitDrawableDefaults(drawable, artSection); drawable.LoadFromRules(); return(drawable); }
private void IniLoadPresetList() { //파일이 존재하지 않으면? string strPath = System.IO.Directory.GetCurrentDirectory() + "\\presetlist.ini"; bool bExists = File.Exists(strPath); #if false IniFile ini = new IniFile(); if (bExists) { ini.Load(strPath); //for (int i = 0; i < this.presetList.Count(); i++) int i = 0; while (true) { string sectionName = "PRESET_" + i.ToString(); IniFile.IniSection section = ini.GetSection(sectionName); if (section == null) { break; } int id; int.TryParse(ini.GetKeyValue(sectionName, PresetInfo.STR_ID), out id); string name = ini.GetKeyValue(sectionName, PresetInfo.STR_NAME); int sec; int.TryParse(ini.GetKeyValue(sectionName, PresetInfo.STR_SEC), out sec); float x; float.TryParse(ini.GetKeyValue(sectionName, PresetInfo.STR_X), out x); float y; float.TryParse(ini.GetKeyValue(sectionName, PresetInfo.STR_Y), out y); float zoom; float.TryParse(ini.GetKeyValue(sectionName, PresetInfo.STR_ZOOM), out zoom); string group = ini.GetKeyValue(sectionName, PresetInfo.STR_GROUP); float panabs; float.TryParse(ini.GetKeyValue(sectionName, PresetInfo.STR_PANABS), out panabs); float tiltabs; float.TryParse(ini.GetKeyValue(sectionName, PresetInfo.STR_TILTABS), out tiltabs); float panrel; float.TryParse(ini.GetKeyValue(sectionName, PresetInfo.STR_PANREL), out panrel); float tiltrel; float.TryParse(ini.GetKeyValue(sectionName, PresetInfo.STR_TILTREL), out tiltrel); int tardist; int.TryParse(ini.GetKeyValue(sectionName, PresetInfo.STR_TARDIST), out tardist); string tarlat = ini.GetKeyValue(sectionName, PresetInfo.STR_TARLAT); string tarlong = ini.GetKeyValue(sectionName, PresetInfo.STR_TARLONG); string pathimg1 = ini.GetKeyValue(sectionName, PresetInfo.STR_PATHIMG1); string pathimg2 = ini.GetKeyValue(sectionName, PresetInfo.STR_PATHIMG2); PresetInfo presetInfo = new PresetInfo(id, name, sec, x, y, zoom, group, panabs, tiltabs, panrel, tiltrel, tardist, tarlat, tarlong, pathimg1, pathimg2); presetList.Add(presetInfo); i++; } printList(); } #endif }
public TileDrawable(IniFile.IniSection rules, IniFile.IniSection art, TileCollection.TileSetEntry entry) : base(rules, art) { TsEntry = entry; if (entry != null) { Name = entry.ToString(); } }
public SavingManager(Where type, string incFullPath) //custom { if (type != Where.custom) { throw new ArgumentException("type is not Custom"); } DefaultSettings(); section = new IniFile(incFullPath).AddSection("WBSettings"); }
private Drawable InitAnimDrawable(IniFile.IniSection rules, IniFile.IniSection art) { var anim = new AnimDrawable(rules, art); InitDrawableDefaults(anim, art); anim.LoadFromRules(); anim.Shp = VFS.Open <ShpFile>(anim.Image + ".shp"); return(anim); }
public TileDrawable(ModConfig config, VirtualFileSystem vfs, IniFile.IniSection rules, IniFile.IniSection art, TileCollection.TileSetEntry entry) : base(config, vfs, rules, art) { TsEntry = entry; if (entry != null) { Name = entry.ToString(); } }
protected Drawable(IniFile.IniSection rules, IniFile.IniSection art) { Ready_Start = 0; Ready_Count = 1; Ready_CountNext = 1; Rules = rules; Art = art; Name = rules != null ? rules.Name : ""; Foundation = new Size(1, 1); }
private IniFile.IniSection AddGetSection(IniFile ini, string name) { IniFile.IniSection section = ini.GetSection(name); if (section == null) { section = ini.AddSection(name); //ini.Save(path); } return(section); }
void Initialize(IniFile.IniSection lamp, Lighting scenario) { logger.Trace("Loading LightSource {0} at ({1},{2})", lamp.Name, Tile); // Read and assume default values LightVisibility = lamp.ReadDouble("LightVisibility", 5000.0); LightIntensity = lamp.ReadDouble("LightIntensity", 0.0); LightRedTint = lamp.ReadDouble("LightRedTint", 1.0); LightGreenTint = lamp.ReadDouble("LightGreenTint", 1.0); LightBlueTint = lamp.ReadDouble("LightBlueTint", 1.0); this.scenario = scenario; }
private void cacheDelete1(object sender, EventArgs e) { foreach (DataGridViewRow d in cache.SelectedRows) { IniFile.IniSection s = i.GetSection(d.Cells[0].Value.ToString()); File.Delete(folder + s.Name); File.Delete(folder + s.GetKey("Audio").Value); i.RemoveSection(s.Name); i.Save(folder + ".db.ini"); cache.Rows.Remove(d); } }
public Lighting(IniFile.IniSection iniSection) { Level = iniSection.ReadDouble("Level", 0.032); Ambient = iniSection.ReadDouble("Ambient", 1.0); Red = iniSection.ReadDouble("Red", 1.0); Green = iniSection.ReadDouble("Green", 1.0); Blue = iniSection.ReadDouble("Blue", 1.0); Ground = iniSection.ReadDouble("Ground", 0.0); logger.Trace("Lighting loaded: level: {0}, ambient: {1}, red: {2}, green: {3}, blue: {4}, ground: {5}", Level, Ambient, Red, Green, Blue, Ground); }
void remove() { if (iniSectionTreeView.Nodes.Count > 0) { if (iniSectionTreeView.SelectedNode != null) { DialogResult dr = MessageBox.Show(String.Format("Are you sure you'd like to delete the item '{0}'?", iniSectionTreeView.SelectedNode.Text), "Question", MessageBoxButtons.YesNo, MessageBoxIcon.Question); switch (dr) { case (DialogResult.Yes): ExtendedTreeNode selected = (ExtendedTreeNode)iniSectionTreeView.SelectedNode; switch (selected.GetIntegerType()) { case (0): DialogResult drt = MessageBox.Show("This will delete all keys within this section. This cannot be undone. Proceed?", "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); switch (drt) { case (DialogResult.Yes): IniFile.IniSection section = ini.GetSection(selected.Text); ini.RemoveSection(section); selected.Remove(); changed = true; break; case (DialogResult.No): break; } break; case (1): IniFile.IniSection sectionn = ini.GetSection(selected.Parent.Text); sectionn.RemoveKey(selected.Text); selected.Remove(); changed = true; break; case (2): break; } break; case (DialogResult.No): break; } } } }
public static IniFile.IniSection FindSectionInTreeBySection(string section) { var path = PublicData.FolderConfigPath; while (path.Contains(PublicData.RootPath)) { IniFile.IniSection found = FindSectionInFolderBySection(section, path); if (found != null) { return(found); } path = PublicData.PathDeacreaseByFolder(path); } return(null); }
private AnimDrawable LoadUpgrade(StructureObject structObj, int upgradeSlot, DrawProperties inheritProps) { string upgradeName = ""; if (upgradeSlot == 0) { upgradeName = structObj.Upgrade1; } else if (upgradeSlot == 1) { upgradeName = structObj.Upgrade2; } else if (upgradeSlot == 2) { upgradeName = structObj.Upgrade3; } IniFile.IniSection upgradeRules = OwnerCollection.Rules.GetOrCreateSection(upgradeName); if (upgradeRules != null && upgradeRules.HasKey("Image")) { upgradeName = upgradeRules.ReadString("Image"); } IniFile.IniSection upgradeArt = OwnerCollection.Art.GetOrCreateSection(upgradeName); if (upgradeArt != null && upgradeArt.HasKey("Image")) { upgradeName = upgradeArt.ReadString("Image"); } IniFile.IniSection upgRules = OwnerCollection.Rules.GetOrCreateSection(upgradeName); IniFile.IniSection upgArt = OwnerCollection.Art.GetOrCreateSection(upgradeName); AnimDrawable upgrade = new AnimDrawable(_config, _vfs, upgRules, upgArt); upgrade.OwnerCollection = OwnerCollection; upgrade.Props = inheritProps; upgrade.LoadFromRules(); upgrade.NewTheater = this.NewTheater; upgrade.IsBuildingPart = true; string shpfilename = NewTheater ? OwnerCollection.ApplyNewTheaterIfNeeded(upgradeName, upgradeName + ".shp") : upgradeName + ".shp"; upgrade.Shp = _vfs.Open <ShpFile>(shpfilename); Point powerupOffset = new Point(_powerupSlots[upgradeSlot].X, _powerupSlots[upgradeSlot].Y); upgrade.Props.Offset.Offset(powerupOffset); return(upgrade); }
private void cboxMailManLists_SelectedIndexChanged(object sender, EventArgs e) { try { tbOutput.Clear(); string cur = cboxMailManLists.Items[cboxMailManLists.SelectedIndex].ToString(); IniFile.IniSection section = ini.GetSection(cur); foreach (IniFile.IniSection.IniKey iniKey in section.Keys) { tbOutput.AppendText(iniKey.Name + " = " + iniKey.GetValue() + Environment.NewLine); } } catch (Exception ex) { Console.WriteLine(ex.Message); throw; } }
private void iniSectionTreeView_NodeMouseDoubleClick(object sender, TreeNodeMouseClickEventArgs e) { ExtendedTreeNode selected = (ExtendedTreeNode)iniSectionTreeView.SelectedNode; switch(selected.GetIntegerType()) { //0 is a section, 1 is a key, 2 is a value but 2 is just there as a just in case case(0): currentSection = ini.GetSection(selected.Text); SELECTEDNODE = selected; editSectionLabel.Text = String.Format("Edit Section {0}", currentSection.Name.ToString()); secValueTextBox.Text = currentSection.Name.ToString(); break; case(1): currentSection = ini.GetSection(selected.Parent.Text); currentKey = selected.Text; currentKeyValue = ini.GetKeyValue(currentSection.Name.ToString(), selected.Text); // editSectionLabel.Text = String.Format("Edit Section {0}", currentSection.Name.ToString()); secValueTextBox.Text = currentSection.Name.ToString(); // editKeyLabel.Text = String.Format("Edit Section {0}", currentKey); keyValueTextBox.Text = currentKey; // if (currentKeyValue != null) { string value = currentKeyValue; currentKeyValue = value.Replace("\"", ""); valueTextBox.Text = currentKeyValue; editValueLabel.Text = String.Format("Edit Value {0}", currentKey); } SELECTEDNODE = selected; break; case(2): //invalid???? break; } }