add C++, Typescript and more stuff
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using KernelPanic.Meta;
|
||||
using KernelPanic.Run;
|
||||
using UnityEngine.UIElements;
|
||||
|
||||
namespace KernelPanic.UI
|
||||
{
|
||||
public sealed partial class CombatSceneController
|
||||
{
|
||||
private bool _campaignUnlocksSaved;
|
||||
private string _campaignUnlockNotice;
|
||||
private string _campaignUnlockError;
|
||||
|
||||
private void PersistCampaignUnlocks()
|
||||
{
|
||||
if (_campaignUnlocksSaved || _saveService == null || _runManager?.CurrentConfig == null
|
||||
|| _runManager.CurrentConfig.IsTutorial || _runManager.Journey.FinalWave != RunJourney.BossWave
|
||||
|| !_runManager.Journey.campaign || _runManager.WavesCleared < RunJourney.BossWave) return;
|
||||
try
|
||||
{
|
||||
var data = _saveService.Load();
|
||||
int before = data.campaignClearLanguages.Count;
|
||||
if (LanguageUnlock.RecordCampaignClear(data, _runManager.CurrentConfig, _runManager.Journey, _runManager.WavesCleared))
|
||||
{
|
||||
_saveService.Save(data);
|
||||
var names = data.campaignClearLanguages.GetRange(before, data.campaignClearLanguages.Count - before)
|
||||
.ConvertAll(language => language == Core.Language.C ? "C++" : "TypeScript");
|
||||
_campaignUnlockNotice = "Campaign unlock saved: " + string.Join(" + ", names) + ". Available in collection and run setup.";
|
||||
}
|
||||
_campaignUnlocksSaved = true;
|
||||
_campaignUnlockError = null;
|
||||
}
|
||||
catch (Exception ex) when (ex is IOException || ex is InvalidDataException || ex is UnauthorizedAccessException)
|
||||
{ _campaignUnlockError = "Language unlock could not be saved: " + ex.Message; }
|
||||
}
|
||||
|
||||
private void AddCampaignUnlockNotice(VisualElement parent)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(_campaignUnlockNotice)) parent.Add(TerminalLayout.BodyText(_campaignUnlockNotice));
|
||||
if (string.IsNullOrEmpty(_campaignUnlockError)) return;
|
||||
parent.Add(TerminalLayout.BodyText(_campaignUnlockError));
|
||||
parent.Add(new Button(() => { PersistCampaignUnlocks(); Refresh(); }) { text = "Retry saving language unlock" });
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user