Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove the SaintCoinach Schema #170

Open
wants to merge 21 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@v1
with:
dotnet-version: '7.x.x'
dotnet-version: '8.x.x'
- name: Define Version
id: define-version
run: |
Expand Down
2 changes: 1 addition & 1 deletion DotSquish/DotSquish.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<ProjectGuid>{F9681545-4BEA-4FD3-9AB9-A67BD37AB36D}</ProjectGuid>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<OutputPath>bin\$(Configuration)\</OutputPath>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
Expand Down
6 changes: 3 additions & 3 deletions Godbert/Controls/ColumnFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public static DataGridColumn Create(RelationalColumn column) {
var sheetDef = column.Header.SheetDefinition;
Type defType = null;
if (sheetDef != null)
defType = sheetDef.GetValueType(column.Index);
defType = sheetDef.GetValueType(column.ColumnBasedIndex);
var targetType = defType ?? column.Reader.Type;

var header = BuildHeader(column);
Expand Down Expand Up @@ -47,7 +47,7 @@ public static DataGridColumn Create(RelationalColumn column) {
private static string BuildHeader(RelationalColumn column) {
var sb = new StringBuilder();

sb.Append(column.Index);
sb.Append(column.ColumnBasedIndex);
if (!string.IsNullOrWhiteSpace(column.Name))
sb.AppendFormat(": {0}", column.Name);
sb.Append(Environment.NewLine);
Expand All @@ -68,7 +68,7 @@ private static string BuildHeader(RelationalColumn column) {
private static Binding CreateCellBinding(RelationalColumn column) {
return new Binding {
Converter = CellConverterInstance,
ConverterParameter = column.Index,
ConverterParameter = column.ColumnBasedIndex,
Mode = BindingMode.OneWay
};
}
Expand Down
6 changes: 3 additions & 3 deletions Godbert/Controls/RawDataGrid.cs
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ cellHeader.Column is RawDataGridTextColumn ||
cellHeader.Column is RawDataGridColorColumn)
{

var columnIndex = ((IRawDataColumn) cellHeader.Column).Column.Index;
var columnIndex = ((IRawDataColumn) cellHeader.Column).Column.ColumnBasedIndex;
ColumnSetToRaw[columnIndex] = !ColumnSetToRaw[columnIndex];
Items.Refresh();
e.Handled = true;
Expand Down Expand Up @@ -167,7 +167,7 @@ cellHeader.Column is RawDataGridTextColumn ||
Key = row.Key,
RowDefault = row.ToString(),
ColumnName = dataColumn.Column?.Name,
ColumnIndex = dataColumn.Column?.Index
ColumnIndex = dataColumn.Column?.ColumnBasedIndex
};

if (dataViewModel.Bookmarks.Contains(bookmark)) {
Expand Down Expand Up @@ -236,7 +236,7 @@ public void SelectRow(IRow row, int? columnIndex) {

DataGridColumn selectedColumn = null;
if (columnIndex != null)
selectedColumn = (DataGridColumn)this.Columns.OfType<IRawDataColumn>().FirstOrDefault(c => c.Column?.Index == columnIndex);
selectedColumn = (DataGridColumn)this.Columns.OfType<IRawDataColumn>().FirstOrDefault(c => c.Column?.ColumnBasedIndex == columnIndex);

this.ScrollIntoView(this.SelectedItem, selectedColumn);
}
Expand Down
4 changes: 2 additions & 2 deletions Godbert/Controls/RawDataGridColorColumn.cs
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,8 @@ private int InnerCompare(object x, object y) {
if (ry == null)
return 1;

var vx = rx[Column.Index];
var vy = ry[Column.Index];
var vx = rx[Column.ColumnBasedIndex];
var vy = ry[Column.ColumnBasedIndex];

if (vx == vy)
return 0;
Expand Down
6 changes: 3 additions & 3 deletions Godbert/Controls/RawDataGridImageColumn.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ void OnSaveImageClick(object sender, RoutedEventArgs e) {
if (ctx == null)
return;

var img = ctx[_Column.Index] as SaintCoinach.Imaging.ImageFile;
var img = ctx[_Column.ColumnBasedIndex] as SaintCoinach.Imaging.ImageFile;
if (img == null)
return;

Expand Down Expand Up @@ -118,8 +118,8 @@ private int InnerCompare(object x, object y) {
if (ry == null)
return 1;

var vx = rx[Column.Index] as SaintCoinach.Imaging.ImageFile;
var vy = ry[Column.Index] as SaintCoinach.Imaging.ImageFile;
var vx = rx[Column.ColumnBasedIndex] as SaintCoinach.Imaging.ImageFile;
var vy = ry[Column.ColumnBasedIndex] as SaintCoinach.Imaging.ImageFile;

if (vx == vy)
return 0;
Expand Down
8 changes: 4 additions & 4 deletions Godbert/Controls/RawDataGridTextColumn.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ void OnCopyClick(object sender, RoutedEventArgs e) {
if (ctx == null)
return;

var val = ctx[_Column.Index];
var val = ctx[_Column.ColumnBasedIndex];
if (val == null)
return;

Expand All @@ -50,7 +50,7 @@ public IRow OnNavigate(object sender, RoutedEventArgs e) {
if (ctx == null)
return null;

return ctx[_Column.Index] as IRow;
return ctx[_Column.ColumnBasedIndex] as IRow;
}

protected override FrameworkElement GenerateElement(DataGridCell cell, object dataItem) {
Expand Down Expand Up @@ -94,8 +94,8 @@ private int InnerCompare(object x, object y) {
return 1;


var vx = ColumnFactory.ForceRaw || RawDataGrid.ColumnSetToRaw[Column.Index] ? rx.GetRaw(Column.Index) : rx[Column.Index];
var vy = ColumnFactory.ForceRaw || RawDataGrid.ColumnSetToRaw[Column.Index] ? ry.GetRaw(Column.Index) : ry[Column.Index];
var vx = ColumnFactory.ForceRaw || RawDataGrid.ColumnSetToRaw[Column.ColumnBasedIndex] ? rx.GetRaw(Column.ColumnBasedIndex) : rx[Column.ColumnBasedIndex];
var vy = ColumnFactory.ForceRaw || RawDataGrid.ColumnSetToRaw[Column.ColumnBasedIndex] ? ry.GetRaw(Column.ColumnBasedIndex) : ry[Column.ColumnBasedIndex];

if (vx == vy)
return 0;
Expand Down
2 changes: 1 addition & 1 deletion Godbert/Godbert.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<ProjectGuid>{6A5DA7FF-791E-4A43-BF65-B6942917F7D9}</ProjectGuid>
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<OutputType>WinExe</OutputType>
<TargetFramework>net7.0-windows</TargetFramework>
<TargetFramework>net8.0-windows</TargetFramework>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<ApplicationRevision>0</ApplicationRevision>
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
Expand Down
6 changes: 4 additions & 2 deletions Godbert/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
<Window.DataContext>
<vm:MainViewModel />
</Window.DataContext>
<DockPanel LastChildFill="True">
<Menu DockPanel.Dock="Top">
<DockPanel>
<Menu DockPanel.Dock="Top" HorizontalAlignment="Stretch">
<MenuItem Header="Language">
<MenuItem Header="English"
IsChecked="{Binding Path=IsEnglish, Mode=OneWay}"
Expand Down Expand Up @@ -51,6 +51,8 @@
IsChecked="{Binding Path=SortByOffsets, Mode=OneWay}"
Command="{Binding Path=SortByOffsetsCommand}" />
</MenuItem>
<MenuItem Header="{Binding Realm.GameVersion}" HeaderStringFormat="Game: {0}" IsEnabled="False" HorizontalAlignment="Right"/>
<MenuItem Header="{Binding Realm.DefinitionVersion}" HeaderStringFormat="Definition: {0}" IsEnabled="False" HorizontalAlignment="Right" />
</Menu>
<TabControl>
<TabItem Header="Data" DataContext="{Binding Path=Data}">
Expand Down
15 changes: 1 addition & 14 deletions Godbert/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,18 +1,5 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.ComponentModel;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace Godbert {
/// <summary>
Expand Down
4 changes: 2 additions & 2 deletions Godbert/ViewModels/DataViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -133,11 +133,11 @@ static void SaveAsCsv(IRelationalSheet sheet, string path) {

var colIndices = new List<int>();
foreach (var col in sheet.Header.Columns) {
indexLine.AppendFormat(",{0}", col.Index);
indexLine.AppendFormat(",{0}", col.ColumnBasedIndex);
nameLine.AppendFormat(",{0}", col.Name);
typeLine.AppendFormat(",{0}", col.ValueType);

colIndices.Add(col.Index);
colIndices.Add(col.ColumnBasedIndex);
}

s.WriteLine(indexLine);
Expand Down
20 changes: 15 additions & 5 deletions Godbert/ViewModels/MainViewModel.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

using System.Windows.Forms;
using System.Windows.Input;
using Cursors = System.Windows.Input.Cursors;

namespace Godbert.ViewModels {
using Commands;
Expand Down Expand Up @@ -50,6 +52,18 @@ public MainViewModel() {
foreach (var language in languages) {
try {
var realm = new ARealmReversed(Properties.Settings.Default.GamePath, language);

if (realm.IsUpdateAvailable()) {
var result = MessageBox.Show("A definition update is available, download now?", "Update available", MessageBoxButtons.YesNo, MessageBoxIcon.Information);
if (result == DialogResult.Yes) {
var time = Stopwatch.StartNew();
realm.UpdateDefinition();
MessageBox.Show($"Updated in {TimeSpan.FromMilliseconds(time.ElapsedMilliseconds):c}\nPlease restart the application.", "Update complete", MessageBoxButtons.OK, MessageBoxIcon.Information);
Environment.Exit(0);
} else
Console.WriteLine("Skipping update.");
}

Initialize(realm);
lastException = null;
break;
Expand Down Expand Up @@ -140,16 +154,12 @@ private void OnShowOffsetsCommand() {
Settings.Default.ShowOffsets = !Settings.Default.ShowOffsets;

OnPropertyChanged(() => ShowOffsets);

DataGridChanged?.Invoke(this, EventArgs.Empty);
}

private void OnSortByOffsetsCommand() {
Settings.Default.SortByOffsets = !Settings.Default.SortByOffsets;

OnPropertyChanged(() => SortByOffsets);

DataGridChanged?.Invoke(this, EventArgs.Empty);
}
#endregion
}
Expand Down
6 changes: 3 additions & 3 deletions SaintCoinach.Cmd/Commands/SqlExport.cs
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ private void WriteVariant1Rows(ISheet sheet, StringBuilder sb)

foreach (var col in sheet.Header.Columns.Cast<RelationalColumn>())
{
string name = string.IsNullOrEmpty(col.Name) ? $"unk{col.Index}" : col.Name;
string name = string.IsNullOrEmpty(col.Name) ? $"unk{col.ColumnBasedIndex}" : col.Name;

cols.Add($"`{name}`");
}
Expand Down Expand Up @@ -144,7 +144,7 @@ private void WriteVairant2Rows(ISheet sheet, StringBuilder sb)

foreach (var col in sheet.Header.Columns.Cast<RelationalColumn>())
{
string name = string.IsNullOrEmpty(col.Name) ? $"unk{col.Index}" : col.Name;
string name = string.IsNullOrEmpty(col.Name) ? $"unk{col.ColumnBasedIndex}" : col.Name;

cols.Add($"`{name}`");
}
Expand Down Expand Up @@ -208,7 +208,7 @@ public override async Task InvokeAsync(string[] paramList)
{
var colName = column.Name;
if (string.IsNullOrEmpty(colName))
colName = $"unk{column.Index}";
colName = $"unk{column.ColumnBasedIndex}";

sb.AppendLine($" `{colName}` {GetSqlType(column.Reader.Type)},");
}
Expand Down
4 changes: 2 additions & 2 deletions SaintCoinach.Cmd/ExdHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ public static void SaveAsCsv(Ex.Relational.IRelationalSheet sheet, Language lang

var colIndices = new List<int>();
foreach (var col in sheet.Header.Columns) {
indexLine.AppendFormat(",{0}", col.Index);
indexLine.AppendFormat(",{0}", col.ColumnBasedIndex);
nameLine.AppendFormat(",{0}", col.Name);
typeLine.AppendFormat(",{0}", col.ValueType);

colIndices.Add(col.Index);
colIndices.Add(col.ColumnBasedIndex);
}

s.WriteLine(indexLine);
Expand Down
29 changes: 10 additions & 19 deletions SaintCoinach.Cmd/Program.cs
Original file line number Diff line number Diff line change
@@ -1,20 +1,11 @@
using System;
using System.Diagnostics;
using System.Linq;
using Tharga.Console;
using Tharga.Console.Commands;
using Tharga.Console.Commands.Base;

namespace SaintCoinach.Cmd {
class ConsoleProgressReporter : IProgress<Ex.Relational.Update.UpdateProgress> {

#region IProgress<UpdateProgress> Members

public void Report(Ex.Relational.Update.UpdateProgress value) {
Console.WriteLine(value);
}

#endregion
}
class Program {
private static void Main(string[] args) {
var dataPath = Properties.Settings.Default.DataPath;
Expand All @@ -32,23 +23,23 @@ private static void Main(string[] args) {
return;
}

var realm = new ARealmReversed(dataPath, @"SaintCoinach.History.zip", Ex.Language.English, @"app_data.sqlite");
var realm = new ARealmReversed(dataPath, Ex.Language.English, @"app_data.sqlite");
realm.Packs.GetPack(new IO.PackIdentifier("exd", IO.PackIdentifier.DefaultExpansion, 0)).KeepInMemory = true;

Console.WriteLine("Game version: {0}", realm.GameVersion);
Console.WriteLine("Definition version: {0}", realm.DefinitionVersion);

if (!realm.IsCurrentVersion) {
Console.Write("Update is available, perform update (Y/n)? ");
if (realm.IsUpdateAvailable()) {
Console.Write("Update is available, download update (Y/n)? ");
var updateQuery = Console.ReadLine();
if (string.IsNullOrEmpty(updateQuery) || string.Equals("y", updateQuery, StringComparison.OrdinalIgnoreCase)) {
var stopWatch = new System.Diagnostics.Stopwatch();
stopWatch.Start();
realm.Update(true, new ConsoleProgressReporter());
stopWatch.Stop();
Console.WriteLine(stopWatch.Elapsed);
var time = Stopwatch.StartNew();
realm.UpdateDefinition();
Console.WriteLine($"Updated in {TimeSpan.FromMilliseconds(time.ElapsedMilliseconds):c}");
Console.WriteLine($"Please restart the application.");
return;
} else
Console.WriteLine("Skipping update");
Console.WriteLine("Skipping update.");
}

var cns = new Tharga.Console.Consoles.ClientConsole();
Expand Down
2 changes: 1 addition & 1 deletion SaintCoinach.Cmd/SaintCoinach.Cmd.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<PropertyGroup>
<ProjectGuid>{957699E4-8310-4D1E-BA83-13B7A4932807}</ProjectGuid>
<OutputType>Exe</OutputType>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<AssemblyTitle>SaintCoinach.Cmd</AssemblyTitle>
<Product>SaintCoinach.Cmd</Product>
<Copyright>Copyright © Rogueadyn 2014</Copyright>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<ProjectGuid>{226BF71E-334F-4585-8FEC-4239704CF539}</ProjectGuid>
<TargetFramework>net7.0-windows</TargetFramework>
<TargetFramework>net8.0-windows</TargetFramework>
<AssemblyTitle>SaintCoinach.Graphics.Viewer</AssemblyTitle>
<Product>SaintCoinach.Graphics.Viewer</Product>
<Copyright>Copyright © 2015</Copyright>
Expand Down
5 changes: 5 additions & 0 deletions SaintCoinach.sln
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SaintCoinach.Graphics.Viewe
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Godbert", "Godbert\Godbert.csproj", "{6A5DA7FF-791E-4A43-BF65-B6942917F7D9}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "lib", "lib", "{B609958F-59B9-4128-8500-13FF8C12B201}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -53,4 +55,7 @@ Global
SolutionGuid = {38B9D19B-5177-445E-8E3F-6C69A809DAB9}
EnterpriseLibraryConfigurationToolBinariesPathV6 = packages\EnterpriseLibrary.Common.6.0.1304.0\lib\NET45;packages\EnterpriseLibrary.Logging.6.0.1304.0\lib\NET45;packages\EnterpriseLibrary.ExceptionHandling.6.0.1304.0\lib\NET45
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{F9681545-4BEA-4FD3-9AB9-A67BD37AB36D} = {B609958F-59B9-4128-8500-13FF8C12B201}
EndGlobalSection
EndGlobal
Loading