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

Commit 73142fd

Browse files
committed
made blend effect togglable in options
1 parent 9355d4a commit 73142fd

11 files changed

+49
-20
lines changed

Interop/OptionsControl.cs

+9-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ namespace SPCode
1111
[Serializable]
1212
public class OptionsControl
1313
{
14-
public static int SVersion = 15;
14+
public static int SVersion = 16;
15+
1516
public bool Editor_AgressiveIndentation = true;
1617
public bool Editor_AutoCloseBrackets = true;
1718
public bool Editor_AutoCloseStringChars = true;
@@ -90,6 +91,9 @@ public class OptionsControl
9091
// Version 15
9192
public int TranslationsVersion;
9293

94+
// Version 16
95+
public bool Editor_UseBlendEffect;
96+
9397
public int Version = 11;
9498

9599
public void FillNullToDefaults()
@@ -181,6 +185,10 @@ public void FillNullToDefaults()
181185
{
182186
TranslationsVersion = 0;
183187
}
188+
if (Version < 15)
189+
{
190+
Editor_UseBlendEffect = true;
191+
}
184192

185193
//new Optionsversion - reset new fields to default
186194
Version = SVersion; //then Update Version afterwards

UI/Components/EditorElement/EditorElementGoToDefinition.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ private async Task GoToDefinition(MouseButtonEventArgs e)
4545
}
4646

4747
await Task.Delay(100);
48-
if (Program.MainWindow.TryLoadSourceFile(file, out var newEditor, true, false, true) && newEditor != null)
48+
if (Program.MainWindow.TryLoadSourceFile(file, out var newEditor, false, true) && newEditor != null)
4949
{
5050
newEditor.editor.TextArea.Caret.Offset = sm.Index;
5151
newEditor.editor.TextArea.Caret.BringCaretToView();

UI/MainWindow/MainWindow.xaml.cs

+15-7
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ public MainWindow(SplashScreen sc)
159159
{
160160
if (!args[i].EndsWith("exe"))
161161
{
162-
TryLoadSourceFile(args[i], out _, false, true, i == 0);
162+
TryLoadSourceFile(args[i], out _, true, i == 0);
163163
}
164164
if (args[i].ToLowerInvariant() == "--updateok")
165165
{
@@ -315,7 +315,7 @@ private void MetroWindow_Drop(object sender, DragEventArgs e)
315315
Debug.Assert(files != null, nameof(files) + " != null");
316316
for (var i = 0; i < files.Length; ++i)
317317
{
318-
TryLoadSourceFile(files[i], out _, i == 0, true, i == 0);
318+
TryLoadSourceFile(files[i], out _, true, i == 0);
319319
}
320320
}
321321
}
@@ -340,7 +340,7 @@ private void EditorObjectBrowserGridRow_WidthChanged(object sender, EventArgs e)
340340
/// <param name="TryOpenIncludes">Whether to open the includes associated with that file</param>
341341
/// <param name="SelectMe">Whether to focus the editor element once the file gets opened</param>
342342
/// <returns>If the file opening was successful or not</returns>
343-
public bool TryLoadSourceFile(string filePath, out EditorElement outEditor, bool UseBlendoverEffect = true, bool TryOpenIncludes = true, bool SelectMe = false)
343+
public bool TryLoadSourceFile(string filePath, out EditorElement outEditor, bool TryOpenIncludes = true, bool SelectMe = false)
344344
{
345345
outEditor = null;
346346
var fileInfo = new FileInfo(filePath);
@@ -430,10 +430,7 @@ public bool TryLoadSourceFile(string filePath, out EditorElement outEditor, bool
430430
return false;
431431
}
432432

433-
if (UseBlendoverEffect)
434-
{
435-
BlendOverEffect.Begin();
436-
}
433+
BlendEffect();
437434

438435
return true;
439436
}
@@ -584,6 +581,17 @@ private void CloseProgram(bool saveAll)
584581
}
585582
}
586583

584+
/// <summary>
585+
/// Begin blend effect if enabled
586+
/// </summary>
587+
private void BlendEffect()
588+
{
589+
if (Program.OptionsObject.Editor_UseBlendEffect)
590+
{
591+
BlendOverEffect.Begin();
592+
}
593+
}
594+
587595
public void DimmMainWindow()
588596
{
589597
BlendEffectPlane.Fill = new SolidColorBrush(Colors.Black);

UI/MainWindow/MainWindowCommands.cs

+6-6
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ private void Command_Open()
157157
{
158158
for (var i = 0; i < ofd.FileNames.Length; ++i)
159159
{
160-
AnyFileLoaded |= TryLoadSourceFile(ofd.FileNames[i], out _, i == 0, true, i == 0);
160+
AnyFileLoaded |= TryLoadSourceFile(ofd.FileNames[i], out _, true, i == 0);
161161
}
162162

163163
if (!AnyFileLoaded)
@@ -189,7 +189,7 @@ private void Command_Save()
189189
if (ee != null && !ee.IsTemplateEditor)
190190
{
191191
ee.Save(true);
192-
BlendOverEffect.Begin();
192+
BlendEffect();
193193
}
194194
}
195195
catch (Exception ex)
@@ -214,7 +214,7 @@ private void Command_SaveAs()
214214
{
215215
ee.FullFilePath = sfd.FileName;
216216
ee.Save(true);
217-
BlendOverEffect.Begin();
217+
BlendEffect();
218218
}
219219
}
220220
}
@@ -304,7 +304,7 @@ private void Command_SaveAll()
304304
{
305305
try
306306
{
307-
if (!EditorReferences.Any()|| GetCurrentEditorElement().IsTemplateEditor)
307+
if (!EditorReferences.Any() || GetCurrentEditorElement().IsTemplateEditor)
308308
{
309309
return;
310310
}
@@ -316,7 +316,7 @@ private void Command_SaveAll()
316316
editor.Save();
317317
}
318318

319-
BlendOverEffect.Begin();
319+
BlendEffect();
320320
}
321321
}
322322
catch (Exception ex)
@@ -642,7 +642,7 @@ private void Command_ReopenLastClosedTab()
642642
{
643643
if (Program.RecentFilesStack.Count > 0)
644644
{
645-
TryLoadSourceFile(Program.RecentFilesStack.Pop(), out _, true, false, true);
645+
TryLoadSourceFile(Program.RecentFilesStack.Pop(), out _, false, true);
646646
}
647647

648648
MenuI_ReopenLastClosedTab.IsEnabled = Program.RecentFilesStack.Count > 0;

UI/MainWindow/MainWindowErrorResultGrid.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ private async void ErrorResultGrid_SelectionChanged(object sender, SelectionChan
7070
}
7171

7272
// If it's not opened, open it and go to the error line
73-
if (TryLoadSourceFile(fInfo.FullName, out var editor, true, false, true) && editor != null)
73+
if (TryLoadSourceFile(fInfo.FullName, out var editor, false, true) && editor != null)
7474
{
7575
await Task.Delay(50);
7676
GoToErrorLine(editor, row);

UI/MainWindow/MainWindowMenuHandler.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -454,7 +454,7 @@ private MenuItem BuildRecentFileItem(string file)
454454
// Set the click callback to open the file
455455
mi.Click += delegate
456456
{
457-
TryLoadSourceFile(fInfo.FullName, out _, true, false, true);
457+
TryLoadSourceFile(fInfo.FullName, out _, false, true);
458458
};
459459

460460
// Return the MenuItem

UI/MainWindow/MainWindowObjectBrowser.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ private void TreeViewOBItemFile_DoubleClicked(object sender, MouseButtonEventArg
102102
var itemInfo = (ObjectBrowserTag)item.Tag;
103103
if (itemInfo.Kind == ObjectBrowserItemKind.File)
104104
{
105-
TryLoadSourceFile(itemInfo.Value, out _, true, false, true);
105+
TryLoadSourceFile(itemInfo.Value, out _, false, true);
106106
}
107107
}
108108

UI/Windows/NewFileWindow.xaml.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,7 @@ private void GoToSelectedTemplate()
380380
if ((TemplateListBox.SelectedItem as ListBoxItem)?.Tag is TemplateInfo templateInfo)
381381
{
382382
File.Copy(templateInfo.Path, destFile.FullName, true);
383-
Program.MainWindow.TryLoadSourceFile(destFile.FullName, out _, true, true, true);
383+
Program.MainWindow.TryLoadSourceFile(destFile.FullName, out _, true, true);
384384
}
385385

386386
Close();

UI/Windows/OptionsWindow.xaml

+1
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@
105105
<CheckBox Name="DynamicISAC" Checked="DynamicISAC_Changed" Unchecked="DynamicISAC_Changed" />
106106
<CheckBox Name="DarkTheme" Checked="DarkTheme_Changed" Unchecked="DarkTheme_Changed" />
107107
<CheckBox Name="HardwareSalts" Checked="HardwareSalts_Changed" Unchecked="HardwareSalts_Changed" />
108+
<CheckBox Name="UseBlendEffect" Checked="UseBlendEffect_Changed" Unchecked="UseBlendEffect_Changed" />
108109
<CheckBox Name="DiscordPresence" Checked="DiscordPresence_Changed" Unchecked="DiscordPresence_Changed" />
109110
<CheckBox Name="DiscordPresenceTime" Style="{StaticResource IndentedCheckBox}" Checked="DiscordPresenceTime_Changed" Unchecked="DiscordPresenceTime_Changed" />
110111
<CheckBox Name="DiscordPresenceFile" Style="{StaticResource IndentedCheckBox}" Checked="DiscordPresenceFile_Changed" Unchecked="DiscordPresenceFile_Changed" />

UI/Windows/OptionsWindow.xaml.cs

+12
Original file line numberDiff line numberDiff line change
@@ -434,6 +434,16 @@ private void HardwareSalts_Changed(object sender, RoutedEventArgs e)
434434
Program.MakeRCCKAlert();
435435
}
436436

437+
private void UseBlendEffect_Changed(object sender, RoutedEventArgs e)
438+
{
439+
if (!AllowChanging)
440+
{
441+
return;
442+
}
443+
444+
Program.OptionsObject.Editor_UseBlendEffect = UseBlendEffect.IsChecked.Value;
445+
}
446+
437447
private void DiscordPresence_Changed(object sender, RoutedEventArgs e)
438448
{
439449
if (!AllowChanging)
@@ -664,6 +674,7 @@ private void LoadSettings()
664674
FontFamilyCB.SelectedValue = new FontFamily(Program.OptionsObject.Editor_FontFamily);
665675
IndentationSize.Value = Program.OptionsObject.Editor_IndentationSize;
666676
HardwareSalts.IsChecked = Program.OptionsObject.Program_UseHardwareSalts;
677+
UseBlendEffect.IsChecked = Program.OptionsObject.Editor_UseBlendEffect;
667678
DiscordPresence.IsChecked = Program.OptionsObject.Program_DiscordPresence;
668679
DiscordPresenceTime.IsChecked = Program.OptionsObject.Program_DiscordPresenceTime;
669680
DiscordPresenceFile.IsChecked = Program.OptionsObject.Program_DiscordPresenceFile;
@@ -690,6 +701,7 @@ private void Language_Translate()
690701
{
691702
Title = Translate("Options");
692703
HardwareSalts.Content = Translate("HardwareEncryption");
704+
UseBlendEffect.Content = Translate("UseBlendEffect");
693705
ProgramHeader.Header = Translate("Program");
694706
HardwareAcc.Content = Translate("HardwareAcc");
695707
UIAnimation.Content = Translate("UIAnim");

UI/Windows/SPDefinitionWindow.xaml.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ private void GoToDefinition()
287287

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

0 commit comments

Comments
 (0)