Skip to content
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions LynnaLab/src/BuildDialog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,9 @@ void OnMakeExited(object sender, object args)
{
Helper.MainThreadInvoke(OnMakeExitedBody);
}
string GameString { get {
return Top.GlobalConfig.BuildComboRom ? "combo" : Project.GameString;
}}

void OnMakeExitedBody()
{
Expand Down Expand Up @@ -233,14 +236,14 @@ void OnMakeExitedBody()
"Select Emulator",
() =>
{
ImGui.Text($"Your gameboy emulator path has not been configured.\nSelect your emulator executable file now to run {Project.GameString}.gbc.");
ImGui.Text($"Your gameboy emulator path has not been configured.\nSelect your emulator executable file now to run {GameString}.gbc.");
if (ImGui.Button("OK"))
{
SelectEmulatorDialog((runCommand) =>
{
if (runCommand == null)
{
processView.AppendText($"Emulator not configured, couldn't run {Project.GameString}.gbc.", "error");
processView.AppendText($"Emulator not configured, couldn't run {GameString}.gbc.", "error");
}
else
{
Expand Down Expand Up @@ -303,7 +306,7 @@ void RunGame(string runCommand)

(string, string) SubstituteString(string s)
{
s = s.Replace("{GAME}", Project.GameString);
s = s.Replace("{GAME}", GameString);

// Old format: space separator
if (!s.Contains("|"))
Expand Down
1 change: 1 addition & 0 deletions LynnaLab/src/GlobalConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -115,4 +115,5 @@ public void Save()
// Other
public bool AutoAdjustGroupNumber { get; set; } = true;
public bool ScrollToZoom { get; set; } = true;
public bool BuildComboRom { get; set; } = true;
}
3 changes: 3 additions & 0 deletions LynnaLab/src/SettingsDialog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,9 @@ public override void Render()
ImGuiX.Checkbox("Scroll to Zoom", new Accessor<bool>(() => GlobalConfig.ScrollToZoom));
ImGuiX.TooltipOnHover("Applies to minimaps, scratchpad, and tileset editor.");

ImGuiX.Checkbox("Build Combo ROM", new Accessor<bool>(() => GlobalConfig.BuildComboRom));
ImGuiX.TooltipOnHover("The built ROM will contain both games.");

endSection();
}

Expand Down
78 changes: 72 additions & 6 deletions LynnaLib/FileParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -516,6 +516,8 @@ void ParseLine(string pureLine, DictionaryLinkedList<InstanceResolver<FileCompon
break;
}
case "m_dungeondata":
case "m_dungeondata_ages":
case "m_dungeondata_seasons":
{
if (!(fTokens.Count == 9))
{
Expand Down Expand Up @@ -673,11 +675,13 @@ void ParseLine(string pureLine, DictionaryLinkedList<InstanceResolver<FileCompon
// Check if we're currently skipping over stuff because of .ifdefs
if (ifdefCondition == false)
{
if (tokens[0].ToLower() == ".ifdef" || tokens[0].ToLower() == ".ifndef")
if (tokens[0].ToLower() == ".ifdef" || tokens[0].ToLower() == ".ifndef" ||
tokens[0].ToLower() == ".if")
{
ifdefDepth++;
}
else if (tokens[0].ToLower() == ".else" && failedIfdefDepth == ifdefDepth - 1)
else if ((tokens[0].ToLower() == ".else" || tokens[0].ToLower() == ".elif") &&
failedIfdefDepth == ifdefDepth - 1)
{
ifdefCondition = true;
}
Expand Down Expand Up @@ -782,6 +786,64 @@ void ParseLine(string pureLine, DictionaryLinkedList<InstanceResolver<FileCompon
break;
}

case ".if":
case ".elif":
{
bool definedConditionFound = false;
bool definedCondition = false;
bool logicalOr = true;
for (int j = 1; j < tokens.Count; j++)
{
if (tokens[j] == "&&") {
logicalOr = false;
j++;
}
else if (tokens[j] == "||")
{
logicalOr = true;
j++;
}

if (tokens[j].StartsWith("defined", StringComparison.CurrentCultureIgnoreCase) ||
tokens[j].StartsWith("!defined", StringComparison.CurrentCultureIgnoreCase))
{
if (tokens[j].Contains('(') && tokens[j].Contains(')')) {
definedConditionFound = true;

bool negate = tokens[j].StartsWith('!');
string tokenName = tokens[j].Split("(", 2)[1].TrimEnd(')');

bool exists = Project.GetDefinition(tokenName) != null;
if (negate) exists = !exists;
if (logicalOr)
{
definedCondition = definedCondition || exists;
}
else
{
definedCondition = definedCondition && exists;
}
}
}
}

if (definedConditionFound) {
ifdefDepth++;
if (definedCondition)
{
ifdefCondition = true;
}
else
{
ifdefCondition = false;
failedIfdefDepth = ifdefDepth - 1;
}
break;
}
// fall through if the matching failed
goto default;
}

case ".ifdef":
if (tokens.Count < 2)
{
Expand Down Expand Up @@ -856,11 +918,11 @@ void ParseLine(string pureLine, DictionaryLinkedList<InstanceResolver<FileCompon
if (tokens[0][tokens[0].Length - 1] == ':')
s = tokens[0].Substring(0, tokens[0].Length - 1);

if (s[0] == '@')
/*if (s[0] == '@')
{
log.Info(warningString + "Ignoring label '" + s + "': child labels not supported.");
break;
}
}*/

FileComponent addedComponent;
if (context == "RAMSECTION" || context == "ENUM")
Expand Down Expand Up @@ -943,8 +1005,12 @@ void AddDefinition(string def, string value, bool replace = false)
void AddLabelToDictionaries(Label label)
{
// See above note about RecordChange().
LabelDictionary.Add(label.Name, new(label));
Project.AddLabel(label.Name, this);
if (!(label.Name.StartsWith('@') && LabelDictionary.ContainsKey(label.Name))) {
LabelDictionary.Add(label.Name, new(label));
}
if (!(label.Name.StartsWith('@') && Project.HasLabel(label.Name))) {
Project.AddLabel(label.Name, this);
}
}

public Label GetLabel(string labelStr)
Expand Down
2 changes: 1 addition & 1 deletion LynnaLib/Project.cs
Original file line number Diff line number Diff line change
Expand Up @@ -659,7 +659,7 @@ void VisitDirectoriesRecursively(string directory, Action<string> action)
string ignoreDirectory = (GameString == "ages" ? "seasons" : "ages");
foreach (string d in Helper.GetSortedDirectories(baseDirectory + directory))
{
if (d == ignoreDirectory)
if (d == ignoreDirectory || d == "combo")
continue;
VisitDirectoriesRecursively(directory + d, action);
}
Expand Down