Skip to content

Commit 10ecc7b

Browse files
committed
Define references (confusing) => Global defines
1 parent 50414e2 commit 10ecc7b

18 files changed

Lines changed: 98 additions & 97 deletions

CardMaker/Card/DeckReader.cs

Lines changed: 29 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -80,18 +80,20 @@ private void ReadDataCore(object zRefData)
8080

8181
// these lists are accumulated across references
8282
var listAllReferenceLines = new List<ReferenceLine>();
83-
var listAllReferenceDefineLines = new List<ReferenceLine>();
83+
// global defines
84+
var listAllGlobalDefineLines = new List<ReferenceLine>();
85+
// legacy project specific defines
8486
var listAllProjectDefineLines = new List<ReferenceLine>();
8587

8688
if (null == zReferenceData || zReferenceData.Length == 0)
8789
{
8890
// (special case) if no data is loaded for a reference try loading up the project definitions
8991
listAllProjectDefineLines = ReadDefaultProjectDefinitions();
90-
listAllReferenceDefineLines.AddRange(ReadDefineReferences());
92+
listAllGlobalDefineLines.AddRange(ReadGlobalDefines());
9193
}
9294
else
9395
{
94-
listAllReferenceDefineLines.AddRange(ReadDefineReferences());
96+
listAllGlobalDefineLines.AddRange(ReadGlobalDefines());
9597

9698
// 2 per reference + 1 for the project wide defines
9799
m_zReporterProxy.ProgressReset(0, zReferenceData.Length * 2 + 1, 0);
@@ -142,7 +144,7 @@ private void ReadDataCore(object zRefData)
142144
listReferenceActions.Add(Task.Factory.StartNew(
143145
() =>
144146
{
145-
listRefLines = zRefReader.GetReferenceData();
147+
listRefLines = zRefReader.GetReferenceData(null);
146148
m_zReporterProxy.ProgressStep();
147149
}));
148150

@@ -162,7 +164,7 @@ private void ReadDataCore(object zRefData)
162164
listRefLines.RemoveAt(0);
163165
}
164166
listAllReferenceLines.AddRange(listRefLines);
165-
listAllReferenceDefineLines.AddRange(listRefDefineLines);
167+
listAllGlobalDefineLines.AddRange(listRefDefineLines);
166168

167169
m_zReporterProxy.ProgressStep();
168170
}
@@ -174,7 +176,7 @@ private void ReadDataCore(object zRefData)
174176
}
175177

176178
// concat all the defines into one list (project + each reference define)
177-
listAllProjectDefineLines.AddRange(listAllReferenceDefineLines);
179+
listAllProjectDefineLines.AddRange(listAllGlobalDefineLines);
178180

179181
ProcessLines(
180182
listAllReferenceLines,
@@ -280,29 +282,29 @@ public void ProcessLines(List<ReferenceLine> listLines,
280282
{
281283
var dictionaryCurrentDefineColumns = new Dictionary<int, string>();
282284
var sCurrentReferenceSource = string.Empty;
283-
// first row is critical as it is an indicator of a new define reference (as there may be multiple with unique column names)
284-
foreach (var zReferenceDefineLine in listDefineLines)
285+
// first row is critical as it is an indicator of a new define file (as there may be multiple with unique column names)
286+
foreach (var zDefineLine in listDefineLines)
285287
{
286-
if (zReferenceDefineLine.LineNumber == 0 && sCurrentReferenceSource != zReferenceDefineLine.ReferenceInfo.Source)
288+
if (zDefineLine.LineNumber == 0 && sCurrentReferenceSource != zDefineLine.ReferenceInfo.Source)
287289
{
288-
sCurrentReferenceSource = zReferenceDefineLine.ReferenceInfo.Source;
289-
dictionaryCurrentDefineColumns = zReferenceDefineLine.Entries
290+
sCurrentReferenceSource = zDefineLine.ReferenceInfo.Source;
291+
dictionaryCurrentDefineColumns = zDefineLine.Entries
290292
.Skip(1) // skip the first column as it is the define name column itself (note the idx+1 below!)
291293
.Where(x => x != null && !x.StartsWith(IGNORED_DEFINE_COLUMN_PREFIX))
292294
.Select((x, idx) => new KeyValuePair<int, string>(idx+1, x))
293295
.ToDictionary(x => x.Key, x => x.Value);
294296
continue;
295297
}
296298

297-
var listRowEntries = zReferenceDefineLine.Entries;
299+
var listRowEntries = zDefineLine.Entries;
298300
if (listRowEntries.Count == 0)
299301
{
300302
continue;
301303
}
302304

303-
var sKeyPrefix = string.IsNullOrWhiteSpace(zReferenceDefineLine.ReferenceInfo.ReferencePrefix)
305+
var sKeyPrefix = string.IsNullOrWhiteSpace(zDefineLine.ReferenceInfo.ReferencePrefix)
304306
? string.Empty
305-
: $"{zReferenceDefineLine.ReferenceInfo.ReferencePrefix}{sDefineSeparator}";
307+
: $"{zDefineLine.ReferenceInfo.ReferencePrefix}{sDefineSeparator}";
306308
var sKey = $"{sKeyPrefix}{listRowEntries[0]}";
307309
int nIdx;
308310
if (string.IsNullOrWhiteSpace(sKey))
@@ -318,7 +320,7 @@ public void ProcessLines(List<ReferenceLine> listLines,
318320
}
319321
else if (dictionaryColumnNames.TryGetValue(sKey.ToLower(), out nIdx))
320322
{
321-
var sMsg = "Overlapping column name and define found in: " + zReferenceDefineLine.ReferenceInfo.Source + "::" + "Column [" + nIdx + "]: " + sKey;
323+
var sMsg = "Overlapping column name and define found in: " + zDefineLine.ReferenceInfo.Source + "::" + "Column [" + nIdx + "]: " + sKey;
322324
IssueManager.Instance.FireAddIssueEvent(sMsg);
323325
m_zReporterProxy.AddIssue(sMsg);
324326
}
@@ -335,7 +337,7 @@ public void ProcessLines(List<ReferenceLine> listLines,
335337
if (dictionaryColumnNames.TryGetValue(sCompositeKey, out nIdx))
336338
{
337339
var sMsg = $"Overlapping composite column name {sCompositeKey} and define found in: " +
338-
zReferenceDefineLine.ReferenceInfo.Source + "::" + "Column [" + nIdx + "]: " +
340+
zDefineLine.ReferenceInfo.Source + "::" + "Column [" + nIdx + "]: " +
339341
sKey;
340342
IssueManager.Instance.FireAddIssueEvent(sMsg);
341343
m_zReporterProxy.AddIssue(sMsg);
@@ -448,35 +450,34 @@ private List<ReferenceLine> ReadDefaultProjectDefinitions()
448450
return listDefineLines;
449451
}
450452

451-
private List<ReferenceLine> ReadDefineReferences()
453+
private List<ReferenceLine> ReadGlobalDefines()
452454
{
453-
var listAllReferenceDefineLines = new List<ReferenceLine>();
454-
// load the define references (if project saved)
455-
if ((ProjectManager.Instance.LoadedProject.DefineReferences?.Length ?? 0) > 0)
455+
var listAllGlobalDefinesLines = new List<ReferenceLine>();
456+
if ((ProjectManager.Instance.LoadedProject.GlobalDefines?.Length ?? 0) > 0)
456457
{
457-
m_zReporterProxy.ProgressReset(0, ProjectManager.Instance.LoadedProject.DefineReferences.Length, 0);
458-
var listDefineReferenceActions = new List<Task>();
459-
foreach (var zReference in ProjectManager.Instance.LoadedProject.DefineReferences)
458+
m_zReporterProxy.ProgressReset(0, ProjectManager.Instance.LoadedProject.GlobalDefines.Length, 0);
459+
var listGlobalDefinesActions = new List<Task>();
460+
foreach (var zReference in ProjectManager.Instance.LoadedProject.GlobalDefines)
460461
{
461-
listDefineReferenceActions.Add(Task.Factory.StartNew(
462+
listGlobalDefinesActions.Add(Task.Factory.StartNew(
462463
() =>
463464
{
464465
var zRefReader = GetReferenceReader(zReference);
465466
if (zRefReader != null)
466467
{
467-
var listReferenceLines = zRefReader.GetReferenceData(zReference.DefineReferencePrefix);
468+
var listReferenceLines = zRefReader.GetReferenceData(zReference.DefinePrefix);
468469
lock (s_zLoadLock)
469470
{
470-
listAllReferenceDefineLines.AddRange(listReferenceLines);
471+
listAllGlobalDefinesLines.AddRange(listReferenceLines);
471472
}
472473
}
473474
m_zReporterProxy.ProgressStep();
474475
}));
475476
}
476-
Task.WaitAll(listDefineReferenceActions.ToArray());
477+
Task.WaitAll(listGlobalDefinesActions.ToArray());
477478
}
478479

479-
return listAllReferenceDefineLines;
480+
return listAllGlobalDefinesLines;
480481
}
481482

482483
public void InitiateReferenceRead(ProjectLayoutReference[] arrayProjectLayoutReferences, bool bExporting)

CardMaker/Card/Import/CSVReferenceReader.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public CSVReferenceReader(ProjectLayoutReference zReference)
4646
m_zSpreadsheetReference = CSVSpreadsheetReference.Parse(zReference.RelativePath);
4747
}
4848

49-
private List<ReferenceLine> GetData(string sPath, bool bLogNotFound, int nStartRow, string nameAppend = "", string defineReferencePrefix = null)
49+
private List<ReferenceLine> GetData(string sPath, bool bLogNotFound, int nStartRow, string nameAppend = "", string sDefinePrefix = null)
5050
{
5151
CSVFile zCSVParser = null;
5252
var listReferenceLines = new List<ReferenceLine>();
@@ -55,7 +55,7 @@ private List<ReferenceLine> GetData(string sPath, bool bLogNotFound, int nStartR
5555
var sCombinedPath =
5656
Path.GetDirectoryName(sPath) + Path.DirectorySeparatorChar + Path.GetFileNameWithoutExtension(sPath) + nameAppend + Path.GetExtension(sPath);
5757

58-
var zReferenceInfo = new ReferenceInfo(sPath, defineReferencePrefix);
58+
var zReferenceInfo = new ReferenceInfo(sPath, sDefinePrefix);
5959

6060
if (ReferenceCache.TryGetCachedReference(sCombinedPath, out var listCachedReferenceLines))
6161
{
@@ -124,13 +124,13 @@ public override List<ReferenceLine> GetDefineData()
124124
Deck.DEFINES_DATA_SUFFIX);
125125
}
126126

127-
public override List<ReferenceLine> GetReferenceData(string defineReferencePrefix)
127+
public override List<ReferenceLine> GetReferenceData(string sDefinePrefix)
128128
{
129129
return GetData(
130130
ReferenceUtil.ConvertRelativeProjectPathToFullPath(m_zSpreadsheetReference.RelativePath),
131131
true,
132132
0,
133-
defineReferencePrefix: defineReferencePrefix);
133+
sDefinePrefix: sDefinePrefix);
134134
}
135135
}
136136
}

CardMaker/Card/Import/ExcelReferenceReader.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,11 @@ public ExcelReferenceReader(ProjectLayoutReference zReference)
4747
m_zSpreadsheetReference = ExcelSpreadsheetReference.Parse(zReference.RelativePath);
4848
}
4949

50-
public List<ReferenceLine> GetData(string sPath, bool bLogNotFound, string sSheetName, int nStartRow, string sNameAppend = "", string defineReferencePrefix = null)
50+
public List<ReferenceLine> GetData(string sPath, bool bLogNotFound, string sSheetName, int nStartRow, string sNameAppend = "", string sDefinePrefix = null)
5151
{
5252
sSheetName += sNameAppend;
5353
var listReferenceLines = new List<ReferenceLine>();
54-
var zReferenceInfo = new ReferenceInfo(sPath, defineReferencePrefix);
54+
var zReferenceInfo = new ReferenceInfo(sPath, sDefinePrefix);
5555

5656
var sCacheKey = sPath + "::" + sSheetName;
5757
if (ReferenceCache.TryGetCachedReference(sCacheKey, out var listCachedReferenceLines))
@@ -150,14 +150,14 @@ public override List<ReferenceLine> GetDefineData()
150150
#warning todo other defines
151151
}
152152

153-
public override List<ReferenceLine> GetReferenceData(string defineReferencePrefix)
153+
public override List<ReferenceLine> GetReferenceData(string sDefinePrefix)
154154
{
155155
return GetData(
156156
ReferenceUtil.ConvertRelativeProjectPathToFullPath(m_zSpreadsheetReference.RelativePath),
157157
true,
158158
m_zSpreadsheetReference.SheetName,
159159
0,
160-
defineReferencePrefix: defineReferencePrefix);
160+
sDefinePrefix: sDefinePrefix);
161161
}
162162
}
163163
}

CardMaker/Card/Import/GoogleReferenceReader.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -109,13 +109,13 @@ private bool IsAllDataCached()
109109
GoogleReferenceCache.IsEntryInCache(GetCacheKey(m_sCacheKeyBase, Deck.DEFINES_DATA_SUFFIX));
110110
}
111111

112-
private List<ReferenceLine> GetData(GoogleSpreadsheetReference zReference, int nStartRow, string sNameAppend = "", string defineReferencePrefix = null)
112+
private List<ReferenceLine> GetData(GoogleSpreadsheetReference zReference, int nStartRow, string sNameAppend = "", string sDefinePrefix = null)
113113
{
114114
var sCacheKey = GetCacheKey(zReference.GenerateFullReference(), sNameAppend);
115115
var listReferenceLines = new List<ReferenceLine>();
116116
List<List<string>> listCacheData;
117117

118-
var zReferenceInfo = new ReferenceInfo(zReference.SpreadsheetName, defineReferencePrefix);
118+
var zReferenceInfo = new ReferenceInfo(zReference.SpreadsheetName, sDefinePrefix);
119119

120120
if (CardMakerSettings.EnableGoogleCache
121121
&& !CardMakerInstance.ForceDataCacheRefresh
@@ -203,9 +203,9 @@ public override List<ReferenceLine> GetDefineData()
203203
return GetData(m_zSpreadsheetReference, 0, Deck.DEFINES_DATA_SUFFIX);
204204
}
205205

206-
public override List<ReferenceLine> GetReferenceData(string defineReferencePrefix)
206+
public override List<ReferenceLine> GetReferenceData(string sDefinePrefix)
207207
{
208-
return GetData(m_zSpreadsheetReference, 0, defineReferencePrefix: defineReferencePrefix);
208+
return GetData(m_zSpreadsheetReference, 0, sDefinePrefix: sDefinePrefix);
209209
}
210210

211211
private static GoogleSpreadsheetReference GetDefinesReference()

CardMaker/Card/Import/ReferenceReader.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public abstract class ReferenceReader
4242
/// </summary>
4343
/// <param name="zReference">The reference meta data</param>
4444
/// <param name="listReferenceData">The list to append</param>
45-
public abstract List<ReferenceLine> GetReferenceData(string defineReferencePrefix = null);
45+
public abstract List<ReferenceLine> GetReferenceData(string sDefinePrefix);
4646
/// <summary>
4747
/// Reads the project define data into the specified list
4848
/// </summary>

CardMaker/CardMaker.csproj

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -235,11 +235,11 @@
235235
<Compile Include="Forms\CardMakerMDI.Designer.cs">
236236
<DependentUpon>CardMakerMDI.cs</DependentUpon>
237237
</Compile>
238-
<Compile Include="Forms\Dialogs\DefineReferencesDialog.cs">
238+
<Compile Include="Forms\Dialogs\GlobalDefinesDialog.cs">
239239
<SubType>Form</SubType>
240240
</Compile>
241-
<Compile Include="Forms\Dialogs\DefineReferencesDialog.Designer.cs">
242-
<DependentUpon>DefineReferencesDialog.cs</DependentUpon>
241+
<Compile Include="Forms\Dialogs\GlobalDefinesDialog.Designer.cs">
242+
<DependentUpon>GlobalDefinesDialog.cs</DependentUpon>
243243
</Compile>
244244
<Compile Include="Forms\Dialogs\ProjectSettingsDialog.cs" />
245245
<Compile Include="Forms\FormUtils.cs" />
@@ -390,8 +390,8 @@
390390
<SubType>Designer</SubType>
391391
<DependentUpon>CardMakerMDI.cs</DependentUpon>
392392
</EmbeddedResource>
393-
<EmbeddedResource Include="Forms\Dialogs\DefineReferencesDialog.resx">
394-
<DependentUpon>DefineReferencesDialog.cs</DependentUpon>
393+
<EmbeddedResource Include="Forms\Dialogs\GlobalDefinesDialog.resx">
394+
<DependentUpon>GlobalDefinesDialog.cs</DependentUpon>
395395
</EmbeddedResource>
396396
<EmbeddedResource Include="Forms\GoogleCredentialsDialog.resx">
397397
<DependentUpon>GoogleCredentialsDialog.cs</DependentUpon>

CardMaker/CardMaker_Mono.csproj

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -234,11 +234,11 @@
234234
<Compile Include="Forms\CardMakerMDI.Designer.cs">
235235
<DependentUpon>CardMakerMDI.cs</DependentUpon>
236236
</Compile>
237-
<Compile Include="Forms\Dialogs\DefineReferencesDialog.cs">
237+
<Compile Include="Forms\Dialogs\GlobalDefinesDialog.cs">
238238
<SubType>Form</SubType>
239239
</Compile>
240-
<Compile Include="Forms\Dialogs\DefineReferencesDialog.Designer.cs">
241-
<DependentUpon>DefineReferencesDialog.cs</DependentUpon>
240+
<Compile Include="Forms\Dialogs\GlobalDefinesDialog.Designer.cs">
241+
<DependentUpon>GlobalDefinesDialog.cs</DependentUpon>
242242
</Compile>
243243
<Compile Include="Forms\Dialogs\ProjectSettingsDialog.cs" />
244244
<Compile Include="Forms\FormUtils.cs" />
@@ -389,8 +389,8 @@
389389
<SubType>Designer</SubType>
390390
<DependentUpon>CardMakerMDI.cs</DependentUpon>
391391
</EmbeddedResource>
392-
<EmbeddedResource Include="Forms\Dialogs\DefineReferencesDialog.resx">
393-
<DependentUpon>DefineReferencesDialog.cs</DependentUpon>
392+
<EmbeddedResource Include="Forms\Dialogs\GlobalDefinesDialog.resx">
393+
<DependentUpon>GlobalDefinesDialog.cs</DependentUpon>
394394
</EmbeddedResource>
395395
<EmbeddedResource Include="Forms\GoogleCredentialsDialog.resx">
396396
<DependentUpon>GoogleCredentialsDialog.cs</DependentUpon>

0 commit comments

Comments
 (0)