Skip to content
This repository has been archived by the owner on Sep 11, 2023. It is now read-only.

Commit

Permalink
made blend effect togglable in options
Browse files Browse the repository at this point in the history
  • Loading branch information
maxijabase committed Nov 6, 2022
1 parent 9355d4a commit 73142fd
Show file tree
Hide file tree
Showing 11 changed files with 49 additions and 20 deletions.
10 changes: 9 additions & 1 deletion Interop/OptionsControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ namespace SPCode
[Serializable]
public class OptionsControl
{
public static int SVersion = 15;
public static int SVersion = 16;

public bool Editor_AgressiveIndentation = true;
public bool Editor_AutoCloseBrackets = true;
public bool Editor_AutoCloseStringChars = true;
Expand Down Expand Up @@ -90,6 +91,9 @@ public class OptionsControl
// Version 15
public int TranslationsVersion;

// Version 16
public bool Editor_UseBlendEffect;

public int Version = 11;

public void FillNullToDefaults()
Expand Down Expand Up @@ -181,6 +185,10 @@ public void FillNullToDefaults()
{
TranslationsVersion = 0;
}
if (Version < 15)
{
Editor_UseBlendEffect = true;
}

//new Optionsversion - reset new fields to default
Version = SVersion; //then Update Version afterwards
Expand Down
2 changes: 1 addition & 1 deletion UI/Components/EditorElement/EditorElementGoToDefinition.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ private async Task GoToDefinition(MouseButtonEventArgs e)
}

await Task.Delay(100);
if (Program.MainWindow.TryLoadSourceFile(file, out var newEditor, true, false, true) && newEditor != null)
if (Program.MainWindow.TryLoadSourceFile(file, out var newEditor, false, true) && newEditor != null)
{
newEditor.editor.TextArea.Caret.Offset = sm.Index;
newEditor.editor.TextArea.Caret.BringCaretToView();
Expand Down
22 changes: 15 additions & 7 deletions UI/MainWindow/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ public MainWindow(SplashScreen sc)
{
if (!args[i].EndsWith("exe"))
{
TryLoadSourceFile(args[i], out _, false, true, i == 0);
TryLoadSourceFile(args[i], out _, true, i == 0);
}
if (args[i].ToLowerInvariant() == "--updateok")
{
Expand Down Expand Up @@ -315,7 +315,7 @@ private void MetroWindow_Drop(object sender, DragEventArgs e)
Debug.Assert(files != null, nameof(files) + " != null");
for (var i = 0; i < files.Length; ++i)
{
TryLoadSourceFile(files[i], out _, i == 0, true, i == 0);
TryLoadSourceFile(files[i], out _, true, i == 0);
}
}
}
Expand All @@ -340,7 +340,7 @@ private void EditorObjectBrowserGridRow_WidthChanged(object sender, EventArgs e)
/// <param name="TryOpenIncludes">Whether to open the includes associated with that file</param>
/// <param name="SelectMe">Whether to focus the editor element once the file gets opened</param>
/// <returns>If the file opening was successful or not</returns>
public bool TryLoadSourceFile(string filePath, out EditorElement outEditor, bool UseBlendoverEffect = true, bool TryOpenIncludes = true, bool SelectMe = false)
public bool TryLoadSourceFile(string filePath, out EditorElement outEditor, bool TryOpenIncludes = true, bool SelectMe = false)
{
outEditor = null;
var fileInfo = new FileInfo(filePath);
Expand Down Expand Up @@ -430,10 +430,7 @@ public bool TryLoadSourceFile(string filePath, out EditorElement outEditor, bool
return false;
}

if (UseBlendoverEffect)
{
BlendOverEffect.Begin();
}
BlendEffect();

return true;
}
Expand Down Expand Up @@ -584,6 +581,17 @@ private void CloseProgram(bool saveAll)
}
}

/// <summary>
/// Begin blend effect if enabled
/// </summary>
private void BlendEffect()
{
if (Program.OptionsObject.Editor_UseBlendEffect)
{
BlendOverEffect.Begin();
}
}

public void DimmMainWindow()
{
BlendEffectPlane.Fill = new SolidColorBrush(Colors.Black);
Expand Down
12 changes: 6 additions & 6 deletions UI/MainWindow/MainWindowCommands.cs
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ private void Command_Open()
{
for (var i = 0; i < ofd.FileNames.Length; ++i)
{
AnyFileLoaded |= TryLoadSourceFile(ofd.FileNames[i], out _, i == 0, true, i == 0);
AnyFileLoaded |= TryLoadSourceFile(ofd.FileNames[i], out _, true, i == 0);
}

if (!AnyFileLoaded)
Expand Down Expand Up @@ -189,7 +189,7 @@ private void Command_Save()
if (ee != null && !ee.IsTemplateEditor)
{
ee.Save(true);
BlendOverEffect.Begin();
BlendEffect();
}
}
catch (Exception ex)
Expand All @@ -214,7 +214,7 @@ private void Command_SaveAs()
{
ee.FullFilePath = sfd.FileName;
ee.Save(true);
BlendOverEffect.Begin();
BlendEffect();
}
}
}
Expand Down Expand Up @@ -304,7 +304,7 @@ private void Command_SaveAll()
{
try
{
if (!EditorReferences.Any()|| GetCurrentEditorElement().IsTemplateEditor)
if (!EditorReferences.Any() || GetCurrentEditorElement().IsTemplateEditor)
{
return;
}
Expand All @@ -316,7 +316,7 @@ private void Command_SaveAll()
editor.Save();
}

BlendOverEffect.Begin();
BlendEffect();
}
}
catch (Exception ex)
Expand Down Expand Up @@ -642,7 +642,7 @@ private void Command_ReopenLastClosedTab()
{
if (Program.RecentFilesStack.Count > 0)
{
TryLoadSourceFile(Program.RecentFilesStack.Pop(), out _, true, false, true);
TryLoadSourceFile(Program.RecentFilesStack.Pop(), out _, false, true);
}

MenuI_ReopenLastClosedTab.IsEnabled = Program.RecentFilesStack.Count > 0;
Expand Down
2 changes: 1 addition & 1 deletion UI/MainWindow/MainWindowErrorResultGrid.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ private async void ErrorResultGrid_SelectionChanged(object sender, SelectionChan
}

// If it's not opened, open it and go to the error line
if (TryLoadSourceFile(fInfo.FullName, out var editor, true, false, true) && editor != null)
if (TryLoadSourceFile(fInfo.FullName, out var editor, false, true) && editor != null)
{
await Task.Delay(50);
GoToErrorLine(editor, row);
Expand Down
2 changes: 1 addition & 1 deletion UI/MainWindow/MainWindowMenuHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,7 @@ private MenuItem BuildRecentFileItem(string file)
// Set the click callback to open the file
mi.Click += delegate
{
TryLoadSourceFile(fInfo.FullName, out _, true, false, true);
TryLoadSourceFile(fInfo.FullName, out _, false, true);
};

// Return the MenuItem
Expand Down
2 changes: 1 addition & 1 deletion UI/MainWindow/MainWindowObjectBrowser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ private void TreeViewOBItemFile_DoubleClicked(object sender, MouseButtonEventArg
var itemInfo = (ObjectBrowserTag)item.Tag;
if (itemInfo.Kind == ObjectBrowserItemKind.File)
{
TryLoadSourceFile(itemInfo.Value, out _, true, false, true);
TryLoadSourceFile(itemInfo.Value, out _, false, true);
}
}

Expand Down
2 changes: 1 addition & 1 deletion UI/Windows/NewFileWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ private void GoToSelectedTemplate()
if ((TemplateListBox.SelectedItem as ListBoxItem)?.Tag is TemplateInfo templateInfo)
{
File.Copy(templateInfo.Path, destFile.FullName, true);
Program.MainWindow.TryLoadSourceFile(destFile.FullName, out _, true, true, true);
Program.MainWindow.TryLoadSourceFile(destFile.FullName, out _, true, true);
}

Close();
Expand Down
1 change: 1 addition & 0 deletions UI/Windows/OptionsWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@
<CheckBox Name="DynamicISAC" Checked="DynamicISAC_Changed" Unchecked="DynamicISAC_Changed" />
<CheckBox Name="DarkTheme" Checked="DarkTheme_Changed" Unchecked="DarkTheme_Changed" />
<CheckBox Name="HardwareSalts" Checked="HardwareSalts_Changed" Unchecked="HardwareSalts_Changed" />
<CheckBox Name="UseBlendEffect" Checked="UseBlendEffect_Changed" Unchecked="UseBlendEffect_Changed" />
<CheckBox Name="DiscordPresence" Checked="DiscordPresence_Changed" Unchecked="DiscordPresence_Changed" />
<CheckBox Name="DiscordPresenceTime" Style="{StaticResource IndentedCheckBox}" Checked="DiscordPresenceTime_Changed" Unchecked="DiscordPresenceTime_Changed" />
<CheckBox Name="DiscordPresenceFile" Style="{StaticResource IndentedCheckBox}" Checked="DiscordPresenceFile_Changed" Unchecked="DiscordPresenceFile_Changed" />
Expand Down
12 changes: 12 additions & 0 deletions UI/Windows/OptionsWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,16 @@ private void HardwareSalts_Changed(object sender, RoutedEventArgs e)
Program.MakeRCCKAlert();
}

private void UseBlendEffect_Changed(object sender, RoutedEventArgs e)
{
if (!AllowChanging)
{
return;
}

Program.OptionsObject.Editor_UseBlendEffect = UseBlendEffect.IsChecked.Value;
}

private void DiscordPresence_Changed(object sender, RoutedEventArgs e)
{
if (!AllowChanging)
Expand Down Expand Up @@ -664,6 +674,7 @@ private void LoadSettings()
FontFamilyCB.SelectedValue = new FontFamily(Program.OptionsObject.Editor_FontFamily);
IndentationSize.Value = Program.OptionsObject.Editor_IndentationSize;
HardwareSalts.IsChecked = Program.OptionsObject.Program_UseHardwareSalts;
UseBlendEffect.IsChecked = Program.OptionsObject.Editor_UseBlendEffect;
DiscordPresence.IsChecked = Program.OptionsObject.Program_DiscordPresence;
DiscordPresenceTime.IsChecked = Program.OptionsObject.Program_DiscordPresenceTime;
DiscordPresenceFile.IsChecked = Program.OptionsObject.Program_DiscordPresenceFile;
Expand All @@ -690,6 +701,7 @@ private void Language_Translate()
{
Title = Translate("Options");
HardwareSalts.Content = Translate("HardwareEncryption");
UseBlendEffect.Content = Translate("UseBlendEffect");
ProgramHeader.Header = Translate("Program");
HardwareAcc.Content = Translate("HardwareAcc");
UIAnimation.Content = Translate("UIAnim");
Expand Down
2 changes: 1 addition & 1 deletion UI/Windows/SPDefinitionWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ private void GoToDefinition()

foreach (var cfg in config)
{
if (Program.MainWindow.TryLoadSourceFile(Path.GetFullPath(Path.Combine(cfg, "include", sm.File)) + ".inc", out var ee, true, false, true) && ee != null)
if (Program.MainWindow.TryLoadSourceFile(Path.GetFullPath(Path.Combine(cfg, "include", sm.File)) + ".inc", out var ee, false, true) && ee != null)
{
ee.editor.TextArea.Caret.Offset = sm.Index;
ee.editor.TextArea.Caret.BringCaretToView();
Expand Down

0 comments on commit 73142fd

Please sign in to comment.