Skip to content

Commit

Permalink
0.74:
Browse files Browse the repository at this point in the history
Fixed a lot of bugfixes/issues related reported by FinalDeath (Jasperre)
Fixes issues from #19, #18, #17, #15, #14
  • Loading branch information
Cjreek committed May 4, 2024
1 parent c52c9d8 commit 0bb6ff8
Show file tree
Hide file tree
Showing 17 changed files with 413 additions and 91 deletions.
2 changes: 1 addition & 1 deletion eos-edit/Views/MainWindow.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="Eos.Views.MainWindow" MinHeight="300" MinWidth="500"
Height="700" Width="1100" Loaded="mainWindow_Loaded"
x:Name="mainWindow" Tag="Eos Toolset v0.73c" FontFamily="Segoe UI"
x:Name="mainWindow" Tag="Eos Toolset v0.74" FontFamily="Segoe UI"
Closing="mainWindow_Closing"
Icon="/Assets/Icons/Eos.ico">
<Window.Title>
Expand Down
11 changes: 11 additions & 0 deletions eos-edit/Views/PrerequisiteTableView.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,13 @@ class RequirementTypeToVisibleConverter : IValueConverter
case RequirementType.ARCSPELL:
case RequirementType.SPELL:
case RequirementType.BAB:
#if SPACEPOPE
case RequirementType.ARCCAST:
case RequirementType.DIVCAST:
case RequirementType.DIVSPELL:
case RequirementType.PANTHEONOR:
case RequirementType.DEITYOR:
#endif
return controlType == "INT";
case RequirementType.FEATOR:
case RequirementType.FEAT:
Expand All @@ -42,7 +49,11 @@ class RequirementTypeToVisibleConverter : IValueConverter
case RequirementType.SAVE:
return controlType == "SAVE";
case RequirementType.SKILL:
#if SPACEPOPE
case RequirementType.SKILLOR:
#endif
return controlType == "SKILL";

}
}
else if (ParamNumber == 2)
Expand Down
8 changes: 4 additions & 4 deletions eos-edit/Views/VisualEffectView.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@
<uc:ModelResourceTextbox ResRef="{Binding Data.ImpactHeadEffect}" Grid.Row="10" Grid.Column="1"/>

<TextBlock Text="Impact Effect" Margin="0,3,5,0" HorizontalAlignment="Right" Grid.Row="10" Grid.Column="2"/>
<uc:ModelResourceTextbox ResRef="{Binding Data.ImpactEffect}" Grid.Row="10" Grid.Column="3"/>
<uc:ModelResourceTextbox ResRef="{Binding Data.ImpactImpactEffect}" Grid.Row="10" Grid.Column="3"/>

<TextBlock Text="Root (Small) Effect" Margin="0,3,5,0" HorizontalAlignment="Right" Grid.Row="11" Grid.Column="0"/>
<uc:ModelResourceTextbox ResRef="{Binding Data.ImpactRootSmallEffect}" Grid.Row="11" Grid.Column="1"/>
Expand Down Expand Up @@ -223,12 +223,12 @@
<RowDefinition Height="25"/>
</Grid.RowDefinitions>

<TextBlock Text="Companion Metadata" HorizontalAlignment="Center" Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="4" FontSize="22" Margin="0,0,0,10" FontWeight="Bold"/>
<TextBlock Text="VFX Metadata" HorizontalAlignment="Center" Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="4" FontSize="22" Margin="0,0,0,10" FontWeight="Bold"/>

<TextBlock Text="Script Constant" Margin="0,3,5,0" HorizontalAlignment="Right" Grid.Row="1" Grid.Column="0"/>
<DockPanel Grid.Row="1" Grid.Column="1" Grid.ColumnSpan="3">
<TextBox Text="ANIMAL_COMPANION_CREATURE_TYPE_" BorderThickness="1,1,0,1" IsReadOnly="True" VerticalContentAlignment="Center" Margin="2,0,0,3"/>
<TextBox Text="{Binding Data.ScriptConstant}" Margin="-2,0,0,3" BorderThickness="0,1,1,1" VerticalContentAlignment="Center" Watermark="*AUTOGENERATED*" TextChanging="ConstantTextbox_TextChanging"/>
<TextBox Text="VFX_" BorderThickness="1,1,0,1" IsReadOnly="True" VerticalContentAlignment="Center" Margin="2,0,0,3"/>
<TextBox Text="{Binding Data.ScriptConstant}" Margin="-2,0,0,3" BorderThickness="0,1,1,1" VerticalContentAlignment="Center" Watermark="*AUTOGENERATED (using Name)*" TextChanging="ConstantTextbox_TextChanging"/>
</DockPanel>
</Grid>
</Border>
Expand Down
6 changes: 6 additions & 0 deletions eos/Models/Appearance.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,12 @@ public AppearanceSoundset? AppearanceSoundset
public BodyBag BodyBag { get; set; } = BodyBag.Default;
public bool Targetable { get; set; } = true;

protected override void Initialize()
{
base.Initialize();
Name = new TLKStringSet(() => NotifyPropertyChanged(nameof(Name)));
}

protected override TLKStringSet? GetTlkDisplayName()
{
var modelOverride = (Appearance?)MasterRepository.Project.GetOverride(this);
Expand Down
21 changes: 21 additions & 0 deletions eos/Models/BaseModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,8 @@ public String? Icon
}
public bool HasIcon => (Icon?.Trim() ?? "") != "";

public bool NotifyRepository { get; private set; }

public String Hint
{
get { return _hint; }
Expand Down Expand Up @@ -395,6 +397,7 @@ public void ClearReferences()
result.ResolveReferences();
result.ID = Guid.Empty;
result.Index = null;
result.Overrides = null;
if (addCopyHint)
{
result.Hint = (result.Hint + " Copy").Trim();
Expand Down Expand Up @@ -427,5 +430,23 @@ public void NotifyPropertyChanged([CallerMemberName] string propertyName = "")
PropertyChanged(this, new PropertyChangedEventArgs("Label"));
}
}

public void NotifyPropertyChangedWithRepository([CallerMemberName] string propertyName = "")
{
if (PropertyChanged != null)
{
NotifyRepository = true;
try
{
PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
if (propertyName == "Name") // Hacky McHack
PropertyChanged(this, new PropertyChangedEventArgs("Label"));
}
finally
{
NotifyRepository = false;
}
}
}
}
}
2 changes: 1 addition & 1 deletion eos/Models/Feat.cs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ public FeatCategory ToolsetCategory
if (_toolsetCategory != value)
{
_toolsetCategory = value;
NotifyPropertyChanged();
NotifyPropertyChangedWithRepository();
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion eos/Models/Spell.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public SpellSchool School
if (_spellSchool != value)
{
_spellSchool = value;
NotifyPropertyChanged();
NotifyPropertyChangedWithRepository();
}
}
}
Expand Down
10 changes: 10 additions & 0 deletions eos/Models/Tables/PrerequisiteTableItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,13 @@ public object? RequirementParam1
case RequirementType.ARCSPELL:
case RequirementType.BAB:
case RequirementType.SPELL:
#if SPACEPOPE
case RequirementType.ARCCAST:
case RequirementType.DIVCAST:
case RequirementType.DIVSPELL:
case RequirementType.PANTHEONOR:
case RequirementType.DEITYOR:
#endif
return Param1Int;

case RequirementType.CLASSNOT:
Expand All @@ -62,6 +69,9 @@ public object? RequirementParam1
return Param1Race;

case RequirementType.SKILL:
#if SPACEPOPE
case RequirementType.SKILLOR:
#endif
return Param1Skill;

case RequirementType.VAR:
Expand Down
4 changes: 2 additions & 2 deletions eos/Nwn/2da/2daFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -521,9 +521,9 @@ private String ValueToStr(object? value, bool isHex, bool isLowercase, int maxLe
if (str.Contains(' ')) result = "\"" + str + "\"";
}
if (value is double dblValue)
result = dblValue.ToString("0.##", floatFormat);
result = dblValue.ToString("0.####", floatFormat);
else if (value is decimal decValue)
result = decValue.ToString("0.##", floatFormat);
result = decValue.ToString("0.####", floatFormat);
else if ((value is int intValue) && (isHex))
result = "0x" + intValue.ToString("x2");

Expand Down
4 changes: 3 additions & 1 deletion eos/Nwn/Ssf/SsfFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public SsfFile(String filename)

public void Load(String filename)
{
var fs = new FileStream(filename, FileMode.Open, FileAccess.Read);
var fs = new FileStream(filename, FileMode.Open, FileAccess.Read, FileShare.Read);
try
{
Load(fs);
Expand All @@ -70,6 +70,8 @@ public void Load(String filename)

public void Load(Stream stream)
{
if (stream.Length == 0) return;

var reader = new BinaryReader(stream, Encoding.GetEncoding(1252));
var header = BinaryHelper.Read<SsfHeader>(reader);

Expand Down
2 changes: 1 addition & 1 deletion eos/Nwn/Tga/TargaImage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public TargaImage(String filename, bool force32Bit = false)

public void Load(String filename, bool force32Bit = false)
{
var fs = new FileStream(filename, FileMode.Open, FileAccess.Read);
var fs = new FileStream(filename, FileMode.Open, FileAccess.Read, FileShare.Read);
try
{
Load(fs, force32Bit);
Expand Down
2 changes: 1 addition & 1 deletion eos/Repositories/EosProject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -964,7 +964,7 @@ public void Load(string projectFilename)
throw;
}

if (Settings.Appearances.Sorted) Appearances.Sort(d => d?.Name);
if (Settings.Appearances.Sorted) Appearances.Sort(d => d?.Name[DefaultLanguage].Text);
if (Settings.AppearanceSoundsets.Sorted) AppearanceSoundsets.Sort(d => d?.Name);
if (Settings.AreaEffects.Sorted) AreaEffects.Sort(d => d?.Name);
if (Settings.AttackBonusTables.Sorted) AttackBonusTables.Sort(d => d?.Name);
Expand Down
14 changes: 10 additions & 4 deletions eos/Repositories/Repository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,10 @@ private void InternalListChanged(object? sender, NotifyCollectionChangedEventArg
if (items != null)
{
foreach (var item in items.Cast<INotifyPropertyChanged>())
item.PropertyChanged -= Item_PropertyChanged;
{
if (item != null)
item.PropertyChanged -= Item_PropertyChanged;
}
}
}
else
Expand All @@ -49,7 +52,10 @@ private void InternalListChanged(object? sender, NotifyCollectionChangedEventArg
if (items != null)
{
foreach (var item in items.Cast<INotifyPropertyChanged>())
item.PropertyChanged += Item_PropertyChanged;
{
if (item != null)
item.PropertyChanged += Item_PropertyChanged;
}
}
}
else
Expand Down Expand Up @@ -83,8 +89,8 @@ protected void RaiseCollectionChanged(NotifyCollectionChangedEventArgs e)

private void Item_PropertyChanged(object? sender, PropertyChangedEventArgs e)
{
// Works better without.. But why did I have it in in the first place? It used to fix *something*...
//RaiseCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset));
if ((sender is BaseModel model) && (model.NotifyRepository))
Task.Delay(5).ContinueWith(t => RaiseCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset)));
}

protected virtual void Changed()
Expand Down
63 changes: 57 additions & 6 deletions eos/Services/CustomDataExport.cs
Original file line number Diff line number Diff line change
Expand Up @@ -703,13 +703,35 @@ private void ExportPrerequisiteTables(EosProject project)
break;

case RequirementType.SKILL:
#if SPACEPOPE
case RequirementType.SKILLOR:
#endif
rec.Set("LABEL", ((Skill?)item.RequirementParam1)?.Name[project.DefaultLanguage].Text.Replace(" ", ""));
break;

case RequirementType.VAR:
rec.Set("LABEL", "ScriptVar");
break;

#if SPACEPOPE
case RequirementType.ARCCAST:
rec.Set("LABEL", "Arcane");
break;

case RequirementType.DIVCAST:
case RequirementType.DIVSPELL:
rec.Set("LABEL", "Divine");
break;

case RequirementType.PANTHEONOR:
rec.Set("LABEL", "Pantheon");
break;

case RequirementType.DEITYOR:
rec.Set("LABEL", "Deity");
break;
#endif

default:
rec.Set("LABEL", "Label");
break;
Expand Down Expand Up @@ -1453,7 +1475,7 @@ private void ExportFeats(EosProject project)
continue;
}

record.Set("LABEL", MakeLabel(feat.Name[project.DefaultLanguage].Text, "_"));
record.Set("LABEL", GetScriptConstant("FEAT_", feat));
record.Set("FEAT", GetTLKIndex(feat.Name));
record.Set("DESCRIPTION", GetTLKIndex(feat.Description));
record.Set("Icon", feat.Icon);
Expand Down Expand Up @@ -2545,7 +2567,7 @@ private void ExportVisualEffects(EosProject project)
}

var record = vfx2da[index];
record.Set("Label", MakeLabel(vfx.Name, ""));
record.Set("Label", MakeLabel(vfx.Name, "_"));
record.Set("Type_FD", vfx.Type.ToString());
record.Set("OrientWithGround", vfx.OrientWithGround);
record.Set("Imp_HeadCon_Node", vfx.ImpactHeadEffect);
Expand Down Expand Up @@ -3789,14 +3811,19 @@ private void ExportIncludeFile(EosProject project)
}

// Classes
var customClasses = project.Classes.Where(cls => cls != null && cls.Overrides == null);
var customClasses = project.Classes.Where(cls => (cls != null) && ((cls.Overrides == null) || (MasterRepository.Standard.Classes.GetByID(cls.Overrides ?? Guid.Empty)?.Hint == "Cut")));
if (customClasses.Any())
{
incFile.Add("// Classes");
foreach (var cls in customClasses)
{
if (cls == null) continue;
var index = project.Classes.GetCustomDataStartIndex() + cls.Index;

int? index = -1;
if (cls.Overrides != null)
index = MasterRepository.Standard.Classes.GetByID(cls.Overrides ?? Guid.Empty)?.Index ?? -1;
else
index = project.Classes.GetCustomDataStartIndex() + cls.Index;
incFile.Add("const int " + GetScriptConstant("CLASS_TYPE_", cls) + " = " + index.ToString() + ";");
}
incFile.Add("");
Expand Down Expand Up @@ -3859,14 +3886,20 @@ private void ExportIncludeFile(EosProject project)
}

// Feats
var customFeats = project.Feats.Where(feat => feat != null && feat.Overrides == null);
var customFeats = project.Feats.Where(feat => (feat != null) && ((feat.Overrides == null) || (MasterRepository.Standard.Feats.GetByID(feat.Overrides ?? Guid.Empty)?.Hint == "Cut")));
if (customFeats.Any())
{
incFile.Add("// Feats");
foreach (var feat in customFeats)
{
if (feat == null) continue;
var index = project.Feats.GetCustomDataStartIndex() + feat.Index;

int? index = -1;
if (feat.Overrides != null)
index = MasterRepository.Standard.Feats.GetByID(feat.Overrides ?? Guid.Empty)?.Index ?? -1;
else
index = project.Feats.GetCustomDataStartIndex() + feat.Index;

incFile.Add("const int " + GetScriptConstant("FEAT_", feat) + " = " + index.ToString() + ";");
}
incFile.Add("");
Expand Down Expand Up @@ -4040,6 +4073,24 @@ private void ExportIncludeFile(EosProject project)
incFile.Add("");
}

// VFX
var customVFX = project.VisualEffects.Where(vfx => vfx != null && vfx.Overrides == null);
if (customVFX.Any())
{
incFile.Add("// Visual Effects");
foreach (var vfx in customVFX)
{
if (vfx == null) continue;
var index = project.VisualEffects.GetCustomDataStartIndex() + vfx.Index;

if (vfx.ScriptConstant != "")
incFile.Add("const int " + GetScriptConstant("VFX_", vfx) + " = " + index.ToString() + ";");
else
incFile.Add("const int " + vfx.Name.ToUpper() + " = " + index.ToString() + ";");
}
incFile.Add("");
}

Directory.CreateDirectory(project.Settings.Export.IncludeFolder);
var filename = project.Settings.Export.IncludeFolder + project.Settings.Export.IncludeFilename + ".nss";
File.WriteAllLines(filename, incFile);
Expand Down
Loading

0 comments on commit 0bb6ff8

Please sign in to comment.