Skip to content

Commit

Permalink
add - doc - Added copying colors to the theme studio
Browse files Browse the repository at this point in the history
---

We've added a new powerful option that allows you to copy colors to other color types.

---

Type: add
Breaking: False
Doc Required: True
Part: 1/1
  • Loading branch information
AptiviCEO committed Jun 7, 2024
1 parent 54a438c commit 2952dfb
Showing 1 changed file with 53 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
using Terminaux.Base;
using Nitrocid.ConsoleBase.Inputs;
using Terminaux.Inputs.Styles;
using Terminaux.Inputs.Styles.Infobox;

namespace Nitrocid.Extras.ThemeStudio.Studio
{
Expand Down Expand Up @@ -62,23 +63,25 @@ public static void StartThemeStudio(string ThemeName)

// Make a list of choices
List<InputChoiceInfo> choices = [];
for (int key = 0; key < ThemeStudioTools.SelectedColors.Count; key++)
var colors = ThemeStudioTools.SelectedColors;
for (int key = 0; key < colors.Count; key++)
{
var colorType = ThemeStudioTools.SelectedColors.Keys.ElementAt(key);
var color = ThemeStudioTools.SelectedColors.Values.ElementAt(key).PlainSequence;
var colorType = colors.Keys.ElementAt(key);
var color = colors.Values.ElementAt(key).PlainSequence;
choices.Add(new InputChoiceInfo($"{key + 1}", $"{colorType}: [{color}] "));
}
List<InputChoiceInfo> altChoices =
[
new InputChoiceInfo($"{ThemeStudioTools.SelectedColors.Count + 1}", Translate.DoTranslation("Save Theme to Current Directory")),
new InputChoiceInfo($"{ThemeStudioTools.SelectedColors.Count + 2}", Translate.DoTranslation("Save Theme to Another Directory...")),
new InputChoiceInfo($"{ThemeStudioTools.SelectedColors.Count + 3}", Translate.DoTranslation("Save Theme to Current Directory as...")),
new InputChoiceInfo($"{ThemeStudioTools.SelectedColors.Count + 4}", Translate.DoTranslation("Save Theme to Another Directory as...")),
new InputChoiceInfo($"{ThemeStudioTools.SelectedColors.Count + 5}", Translate.DoTranslation("Load Theme From File...")),
new InputChoiceInfo($"{ThemeStudioTools.SelectedColors.Count + 6}", Translate.DoTranslation("Load Theme From Prebuilt Themes...")),
new InputChoiceInfo($"{ThemeStudioTools.SelectedColors.Count + 7}", Translate.DoTranslation("Load Current Colors")),
new InputChoiceInfo($"{ThemeStudioTools.SelectedColors.Count + 8}", Translate.DoTranslation("Preview...")),
new InputChoiceInfo($"{ThemeStudioTools.SelectedColors.Count + 9}", Translate.DoTranslation("Exit")),
new InputChoiceInfo($"{colors.Count + 1}", Translate.DoTranslation("Save Theme to Current Directory")),
new InputChoiceInfo($"{colors.Count + 2}", Translate.DoTranslation("Save Theme to Another Directory...")),
new InputChoiceInfo($"{colors.Count + 3}", Translate.DoTranslation("Save Theme to Current Directory as...")),
new InputChoiceInfo($"{colors.Count + 4}", Translate.DoTranslation("Save Theme to Another Directory as...")),
new InputChoiceInfo($"{colors.Count + 5}", Translate.DoTranslation("Load Theme From File...")),
new InputChoiceInfo($"{colors.Count + 6}", Translate.DoTranslation("Load Theme From Prebuilt Themes...")),
new InputChoiceInfo($"{colors.Count + 7}", Translate.DoTranslation("Load Current Colors")),
new InputChoiceInfo($"{colors.Count + 8}", Translate.DoTranslation("Preview...")),
new InputChoiceInfo($"{colors.Count + 9}", Translate.DoTranslation("Copy Color To...")),
new InputChoiceInfo($"{colors.Count + 10}", Translate.DoTranslation("Exit")),
];
TextWriterColor.Write(Translate.DoTranslation("Making a new theme \"{0}\".") + CharManager.NewLine, ThemeName);

Expand All @@ -89,12 +92,12 @@ public static void StartThemeStudio(string ThemeName)
// Check for response integrity
DebugWriter.WriteDebug(DebugLevel.I, "Numeric response {0} is >= 1 and <= {1}.", response, MaximumOptions);
Color SelectedColorInstance;
if (response == ThemeStudioTools.SelectedColors.Count + 1)
if (response == colors.Count + 1)
{
// Save theme to current directory
ThemeStudioTools.SaveThemeToCurrentDirectory(ThemeName);
}
else if (response == ThemeStudioTools.SelectedColors.Count + 2)
else if (response == colors.Count + 2)
{
// Save theme to another directory...
DebugWriter.WriteDebug(DebugLevel.I, "Prompting user for directory name...");
Expand All @@ -104,7 +107,7 @@ public static void StartThemeStudio(string ThemeName)
DebugWriter.WriteDebug(DebugLevel.I, "Got directory name {0}.", DirectoryName);
ThemeStudioTools.SaveThemeToAnotherDirectory(ThemeName, DirectoryName);
}
else if (response == ThemeStudioTools.SelectedColors.Count + 3)
else if (response == colors.Count + 3)
{
// Save theme to current directory as...
DebugWriter.WriteDebug(DebugLevel.I, "Prompting user for theme name...");
Expand All @@ -114,7 +117,7 @@ public static void StartThemeStudio(string ThemeName)
DebugWriter.WriteDebug(DebugLevel.I, "Got theme name {0}.", AltThemeName);
ThemeStudioTools.SaveThemeToCurrentDirectory(AltThemeName);
}
else if (response == ThemeStudioTools.SelectedColors.Count + 4)
else if (response == colors.Count + 4)
{
// Save theme to another directory as...
DebugWriter.WriteDebug(DebugLevel.I, "Prompting user for theme and directory name...");
Expand All @@ -129,7 +132,7 @@ public static void StartThemeStudio(string ThemeName)
DebugWriter.WriteDebug(DebugLevel.I, "Got theme name {0}.", AltThemeName);
ThemeStudioTools.SaveThemeToAnotherDirectory(AltThemeName, DirectoryName);
}
else if (response == ThemeStudioTools.SelectedColors.Count + 5)
else if (response == colors.Count + 5)
{
// Load Theme From File...
DebugWriter.WriteDebug(DebugLevel.I, "Prompting user for theme name...");
Expand All @@ -138,29 +141,53 @@ public static void StartThemeStudio(string ThemeName)
DebugWriter.WriteDebug(DebugLevel.I, "Got theme name {0}.", AltThemeName);
ThemeStudioTools.LoadThemeFromFile(AltThemeName);
}
else if (response == ThemeStudioTools.SelectedColors.Count + 6)
else if (response == colors.Count + 6)
{
// Load Theme From Prebuilt Themes...
DebugWriter.WriteDebug(DebugLevel.I, "Prompting user for theme name...");
TextWriters.Write(Translate.DoTranslation("Specify theme name:") + " ", false, KernelColorType.Input);
string AltThemeName = InputTools.ReadLine();
DebugWriter.WriteDebug(DebugLevel.I, "Got theme name {0}.", AltThemeName);
ThemeStudioTools.LoadThemeFromResource(AltThemeName);
break;
}
else if (response == ThemeStudioTools.SelectedColors.Count + 7)
else if (response == colors.Count + 7)
{
// Load Current Colors
DebugWriter.WriteDebug(DebugLevel.I, "Loading current colors...");
ThemeStudioTools.LoadThemeFromCurrentColors();
}
else if (response == ThemeStudioTools.SelectedColors.Count + 8)
else if (response == colors.Count + 8)
{
// Preview...
DebugWriter.WriteDebug(DebugLevel.I, "Printing text with colors of theme...");
ThemePreviewTools.PreviewThemeSimple(ThemeStudioTools.SelectedColors);
ThemePreviewTools.PreviewThemeSimple(colors);
}
else if (response == ThemeStudioTools.SelectedColors.Count + 9)
else if (response == colors.Count + 9)
{
// Copy Color To...
DebugWriter.WriteDebug(DebugLevel.I, "Copying color to...");

// Specify the source...
int sourceColorIdx = InfoBoxSelectionColor.WriteInfoBoxSelection([.. choices], Translate.DoTranslation("Select the source color type to copy the color from."));
if (sourceColorIdx < 0)
continue;
var sourceType = (KernelColorType)sourceColorIdx;
var sourceColorType = choices[sourceColorIdx];
var sourceColor = colors[sourceType];

// Specify the target...
int[] targetColors = InfoBoxSelectionMultipleColor.WriteInfoBoxSelectionMultiple([.. choices], Translate.DoTranslation("Select the target color types to copy the source color type, {0}, to.").FormatString(sourceColorType.ChoiceTitle));
if (targetColors.Length == 0)
continue;

// Copying...
foreach (int idx in targetColors)
{
var type = (KernelColorType)idx;
colors[type] = sourceColor;
}
}
else if (response == colors.Count + 10)
{
// Exit
DebugWriter.WriteDebug(DebugLevel.I, "Exiting studio...");
Expand All @@ -169,9 +196,9 @@ public static void StartThemeStudio(string ThemeName)
else
{
ColorTools.LoadBackDry(0);
SelectedColorInstance = ThemeStudioTools.SelectedColors[ThemeStudioTools.SelectedColors.Keys.ElementAt(response - 1)];
string ColorWheelReturn = ColorSelector.OpenColorSelector(SelectedColorInstance).PlainSequence;
ThemeStudioTools.SelectedColors[ThemeStudioTools.SelectedColors.Keys.ElementAt(response - 1)] = new Color(ColorWheelReturn);
SelectedColorInstance = colors[colors.Keys.ElementAt(response - 1)];
var finalColor = ColorSelector.OpenColorSelector(SelectedColorInstance);
colors[colors.Keys.ElementAt(response - 1)] = finalColor;
}
}

Expand Down

0 comments on commit 2952dfb

Please sign in to comment.