Exemple #1
0
        public static void ImportSubRaces(this OGLContext context)
        {
            if (context == null || context.Config == null)
            {
                return;
            }
            context.SubRaces.Clear();
            context.SubRacesSimple.Clear();
            var files = SourceManager.EnumerateFiles(context, context.Config.SubRaces_Directory, SearchOption.TopDirectoryOnly);

            foreach (var f in files)
            {
                try
                {
                    using (TextReader reader = new StreamReader(f.Key.FullName))
                    {
                        SubRace s = (SubRace)SubRace.Serializer.Deserialize(reader);
                        s.Source = f.Value;
                        s.Register(context, f.Key.FullName);
                    }
                }
                catch (Exception e)
                {
                    ConfigManager.LogError("Error reading " + f.ToString(), e);
                }
            }
        }
        public List <SubRace> GetSubRaces()
        {
            List <SubRace> returnSubRace = new List <SubRace>();

            try
            {
                using (SqlConnection conn = new SqlConnection(connectionString))
                {
                    conn.Open();

                    SqlCommand    cmd    = new SqlCommand(@"SELECT s.sub_race_id, s.name AS name, r.name AS race from Sub_Race s
                                                        JOIN Race r ON r.race_id = s.race_id", conn);
                    SqlDataReader reader = cmd.ExecuteReader();

                    if (reader.HasRows)
                    {
                        while (reader.Read())
                        {
                            SubRace subrace = new SubRace();
                            subrace.ID   = Convert.ToInt32(reader["sub_race_id"]);
                            subrace.Name = Convert.ToString(reader["name"]);
                            subrace.Race = Convert.ToString(reader["race"]);
                            returnSubRace.Add(subrace);
                        }
                    }
                }
            }
            catch (SqlException)
            {
                throw;
            }

            return(returnSubRace);
        }
Exemple #3
0
 public static void AddControls(SubRace r, List <System.Windows.Forms.Control> control, int level)
 {
     foreach (Description d in r.Descriptions)
     {
         AddControl(control, d);
     }
 }
 public static Bitmap GetImage(this SubRace o)
 {
     if (o.ImageData == null)
     {
         return(null);
     }
     else
     {
         using (MemoryStream ms = new MemoryStream(o.ImageData)) return(new Bitmap(ms));
     }
 }
Exemple #5
0
        public static bool Save(this SubRace r, Boolean overwrite)
        {
            r.Name = r.Name.Replace(ConfigManager.SourceSeperator, '-');
            FileInfo file = SourceManager.GetFileName(r.Name, r.Source, Program.Context.Config.SubRaces_Directory);

            if (file.Exists && (r.FileName == null || !r.FileName.Equals(file.FullName)) && !overwrite)
            {
                return(false);
            }
            using (TextWriter writer = new StreamWriter(file.FullName)) SubRace.Serializer.Serialize(writer, r);
            r.FileName = file.FullName;
            return(true);
        }
Exemple #6
0
        public bool Set(SubRace subRace, RspAttribute attribute, float value)
        {
            var entry    = _rspEntries[subRace.ToRspIndex()];
            var oldValue = entry[attribute];

            if (oldValue == value)
            {
                return(false);
            }

            entry[attribute] = value;
            return(true);
        }
Exemple #7
0
 public bool Redo()
 {
     if (RedoBuffer.Count > 0)
     {
         lastid = "";
         UndoBuffer.AddLast(race);
         race = RedoBuffer.Last.Value;
         RedoBuffer.RemoveLast();
         UnsavedChanges++;
         refresh();
         return(true);
     }
     return(false);
 }
 public List <Feature> FilterSubRaceFeatures(SubRace subrace, Race race, List <Feature> features, int level, IChoiceProvider provider, OGLContext context)
 {
     foreach (IPlugin i in plugins)
     {
         try
         {
             features = i.FilterSubRaceFeatures(subrace, race, features, level, provider, context);
         }
         catch (Exception e)
         {
             ConfigManager.LogError("Error in Plugin " + i.Name, e);
         }
     }
     return(features);
 }
 public static void SetImage(this SubRace o, Bitmap value)
 {
     if (value == null)
     {
         o.ImageData = null;
     }
     else
     {
         using (MemoryStream ms = new MemoryStream())
         {
             value.Save(ms, ImageFormat.Png);
             o.ImageData = ms.ToArray();
         }
     }
 }
Exemple #10
0
        private void edit_Subrace(object sender, EventArgs e)
        {
            if (subRaceList.SelectedItem == null)
            {
                return;
            }
            SubRace selected = Program.Context.GetSubRace((string)subRaceList.SelectedItem, null);

            if (selected != null)
            {
                string      sel = selected.Name;
                SubRaceForm r   = new SubRaceForm(selected.Clone());
                r.Saved += SubRaceSaved;
                r.Show();
            }
        }
Exemple #11
0
        private void subRaceList_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (subRaceList.SelectedItem == null)
            {
                return;
            }
            SubRace selected = Program.Context.GetSubRace((string)subRaceList.SelectedItem, null);

            if (selected != null)
            {
                preview.Navigate("about:blank");
                preview.Document.OpenNew(true);
                preview.Document.Write(selected.ToHTML());
                preview.Refresh();
            }
        }
Exemple #12
0
 public SubRaceForm(SubRace race)
 {
     InitializeComponent();
     this.race            = race;
     userControl11.Editor = this;
     imageChooser1.Image  = this;
     refresh();
     features1.HistoryManager    = this;
     decriptions1.HistoryManager = this;
     imageChooser1.History       = this;
     Program.Context.ImportRaces();
     foreach (string s in Program.Context.RacesSimple.Keys)
     {
         ParentRace.AutoCompleteCustomSource.Add(s);
         ParentRace.Items.Add(s);
     }
 }
Exemple #13
0
 public bool Undo()
 {
     if (UndoBuffer.Count > 0)
     {
         lastid = "";
         RedoBuffer.AddLast(race);
         race = UndoBuffer.Last.Value;
         UndoBuffer.RemoveLast();
         if (UnsavedChanges > 0)
         {
             UnsavedChanges--;
         }
         refresh();
         return(true);
     }
     return(false);
 }
Exemple #14
0
 public static int ToRspIndex(this SubRace subRace)
 {
     return(subRace switch
     {
         SubRace.Midlander => 0,
         SubRace.Highlander => 1,
         SubRace.Wildwood => 10,
         SubRace.Duskwight => 11,
         SubRace.Plainsfolk => 20,
         SubRace.Dunesfolk => 21,
         SubRace.SeekerOfTheSun => 30,
         SubRace.KeeperOfTheMoon => 31,
         SubRace.Seawolf => 40,
         SubRace.Hellsguard => 41,
         SubRace.Raen => 50,
         SubRace.Xaela => 51,
         SubRace.Helion => 60,
         SubRace.Lost => 61,
         SubRace.Rava => 70,
         SubRace.Veena => 71,
         _ => throw new ArgumentOutOfRangeException(nameof(subRace), subRace, null),
     });
Exemple #15
0
        public async static Task ImportSubRacesAsync(this OGLContext context)
        {
            context.SubRaces.Clear();
            context.SubRacesSimple.Clear();
            var files = await PCLSourceManager.EnumerateFilesAsync(context, context.Config.SubRaces_Directory).ConfigureAwait(false);

            foreach (var f in files)
            {
                try
                {
                    using (Stream reader = await f.Key.OpenAsync(FileAccess.Read).ConfigureAwait(false))
                    {
                        SubRace s = (SubRace)SubRace.Serializer.Deserialize(reader);
                        s.Source = f.Value;
                        s.Register(context, f.Key.Path);
                    }
                }
                catch (Exception e)
                {
                    ConfigManager.LogError("Error reading " + Path(f.Key.Path), e);
                }
            }
        }
Exemple #16
0
 public RspEntry this[SubRace subRace]
 => _rspEntries[subRace.ToRspIndex()];
Exemple #17
0
 public float this[SubRace subRace, RspAttribute attribute]
 {
     get => *( float * )(Data + RacialScalingStart + ToRspIndex(subRace) * RspEntry.ByteSize + ( int )attribute * 4);
 public List <Feature> FilterSubRaceFeatures(SubRace sr, Race race, List <Feature> features, int level, IChoiceProvider provider, OGLContext Context)
 {
     return(ScanReplace(features, subrace));
 }