├── SimpleDota2EditorWPF
├── Properties
│ ├── Resources.ru-RU.Designer.cs
│ ├── Settings.settings
│ ├── Settings.Designer.cs
│ └── AssemblyInfo.cs
├── Images
│ ├── Up.png
│ ├── Down.png
│ ├── Items.ico
│ ├── Units.ico
│ ├── Units.png
│ ├── about.png
│ ├── close.png
│ ├── exit.png
│ ├── help.png
│ ├── open.png
│ ├── redo.ico
│ ├── save.png
│ ├── undo.ico
│ ├── AutoTab.png
│ ├── Comment.png
│ ├── Delete.png
│ ├── EditKV.png
│ ├── Folder.png
│ ├── Heroes.ico
│ ├── Heroes.png
│ ├── Object.png
│ ├── Rename.png
│ ├── Abilities.ico
│ ├── CreateKV.png
│ ├── FindHide.png
│ ├── FindNext.png
│ ├── FindPrev.png
│ ├── FindShow.png
│ ├── UnComment.png
│ ├── settings.png
│ ├── FolderClosed.png
│ ├── CreateKVBlock.png
│ ├── FolderOpenned.png
│ └── AbilitiesOverride.ico
├── App.xaml
├── packages.config
├── ScriptsUtils
│ └── KV
│ │ ├── BasicCompletionValues.kv
│ │ ├── BasicCompletionKV.cs
│ │ ├── KVScriptResourcesKeys.Designer.cs
│ │ ├── KVScriptResourcesValues.Designer.cs
│ │ ├── KVScriptResourcesKeys.resx
│ │ └── KVScriptResourcesValues.resx
├── App.config
├── App.xaml.cs
├── Dialogs
│ ├── RenameDialog.xaml
│ ├── SystemCommentEditorDialog.xaml
│ ├── RenameDialog.xaml.cs
│ ├── FindWindowDialog.xaml
│ ├── SystemCommentEditorDialog.xaml.cs
│ └── FindWindowDialog.xaml.cs
├── Panels
│ ├── TextEditorKVPanel.xaml
│ ├── TextEditorLUAPanel.xaml
│ ├── KV
│ │ ├── MyCompletionData.cs
│ │ └── OffsetColorizer.cs
│ ├── EditorsCollectionPanel.xaml
│ ├── StartPagePanel.xaml
│ ├── StartPagePanel.xaml.cs
│ ├── ObjectsViewPanel.xaml
│ └── EditorsCollectionPanel.xaml.cs
├── AboutBoxWindow.xaml.cs
├── IEditor.cs
├── LuaEditorMainWindow.xaml
├── LuaEditorMainWindow.xaml.cs
├── AboutBoxWindow.xaml
└── Lua.xshd
├── KVGridUIWPF
├── KVType.cs
├── ItemTypes.cs
├── packages.config
├── KVGridSubFieldItemInterface.cs
├── App.config
├── Properties
│ ├── Settings.settings
│ ├── Settings.Designer.cs
│ ├── AssemblyInfo.cs
│ ├── Resources.Designer.cs
│ └── Resources.resx
├── KVGridItemAbstract.cs
├── App.xaml
├── App.xaml.cs
├── KVGridItemInterface.cs
├── KVGrid.xaml
├── Items
│ ├── SubFieldItems
│ │ ├── KVSFITextBox.xaml
│ │ └── KVSFITextBox.xaml.cs
│ ├── KeyValueItems
│ │ ├── KVGridItem_TextText.xaml
│ │ └── KVGridItem_TextText.xaml.cs
│ ├── KVGridBlock.xaml
│ └── KVGridBlock.xaml.cs
├── MainWindow.xaml
├── MainWindow.xaml.cs
├── KVGrid.xaml.cs
└── KVGridUIWPF.csproj
├── SomeUtils
├── packages.config
├── ObjectCloner.cs
├── DotaResourceManager.cs
├── Properties
│ └── AssemblyInfo.cs
├── StringUtils.cs
├── UndoRedoManager.cs
└── SomeUtils.csproj
├── CodeAnalysGenerators
├── App.config
├── Program.cs
├── Files
│ └── npc_heroes_custom.txt
├── Properties
│ └── AssemblyInfo.cs
├── KVKeys.cs
└── CodeAnalysGenerators.csproj
├── KV reloaded
├── KVreloaded.cs
├── Attibute
│ └── KeyValue.cs
├── ParserToken.cs
├── KVSettings.cs
├── Properties
│ └── AssemblyInfo.cs
├── ErrorParser.cs
├── SystemComment.cs
├── KV reloaded.csproj
├── KVToken.cs
├── TokenAnalizer.cs
└── ParserUtils.cs
├── README.md
├── .gitattributes
├── SimpleDota2EditorWPF.sln
└── .gitignore
/SimpleDota2EditorWPF/Properties/Resources.ru-RU.Designer.cs:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/KVGridUIWPF/KVType.cs:
--------------------------------------------------------------------------------
1 | namespace KVGridUIWPF
2 | {
3 | public enum KVType
4 | {
5 | Key, Value,
6 | }
7 | }
--------------------------------------------------------------------------------
/SimpleDota2EditorWPF/Images/Up.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Oplkill/Simple-Dota-2-Editor/HEAD/SimpleDota2EditorWPF/Images/Up.png
--------------------------------------------------------------------------------
/SimpleDota2EditorWPF/Images/Down.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Oplkill/Simple-Dota-2-Editor/HEAD/SimpleDota2EditorWPF/Images/Down.png
--------------------------------------------------------------------------------
/SimpleDota2EditorWPF/Images/Items.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Oplkill/Simple-Dota-2-Editor/HEAD/SimpleDota2EditorWPF/Images/Items.ico
--------------------------------------------------------------------------------
/SimpleDota2EditorWPF/Images/Units.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Oplkill/Simple-Dota-2-Editor/HEAD/SimpleDota2EditorWPF/Images/Units.ico
--------------------------------------------------------------------------------
/SimpleDota2EditorWPF/Images/Units.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Oplkill/Simple-Dota-2-Editor/HEAD/SimpleDota2EditorWPF/Images/Units.png
--------------------------------------------------------------------------------
/SimpleDota2EditorWPF/Images/about.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Oplkill/Simple-Dota-2-Editor/HEAD/SimpleDota2EditorWPF/Images/about.png
--------------------------------------------------------------------------------
/SimpleDota2EditorWPF/Images/close.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Oplkill/Simple-Dota-2-Editor/HEAD/SimpleDota2EditorWPF/Images/close.png
--------------------------------------------------------------------------------
/SimpleDota2EditorWPF/Images/exit.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Oplkill/Simple-Dota-2-Editor/HEAD/SimpleDota2EditorWPF/Images/exit.png
--------------------------------------------------------------------------------
/SimpleDota2EditorWPF/Images/help.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Oplkill/Simple-Dota-2-Editor/HEAD/SimpleDota2EditorWPF/Images/help.png
--------------------------------------------------------------------------------
/SimpleDota2EditorWPF/Images/open.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Oplkill/Simple-Dota-2-Editor/HEAD/SimpleDota2EditorWPF/Images/open.png
--------------------------------------------------------------------------------
/SimpleDota2EditorWPF/Images/redo.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Oplkill/Simple-Dota-2-Editor/HEAD/SimpleDota2EditorWPF/Images/redo.ico
--------------------------------------------------------------------------------
/SimpleDota2EditorWPF/Images/save.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Oplkill/Simple-Dota-2-Editor/HEAD/SimpleDota2EditorWPF/Images/save.png
--------------------------------------------------------------------------------
/SimpleDota2EditorWPF/Images/undo.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Oplkill/Simple-Dota-2-Editor/HEAD/SimpleDota2EditorWPF/Images/undo.ico
--------------------------------------------------------------------------------
/SimpleDota2EditorWPF/Images/AutoTab.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Oplkill/Simple-Dota-2-Editor/HEAD/SimpleDota2EditorWPF/Images/AutoTab.png
--------------------------------------------------------------------------------
/SimpleDota2EditorWPF/Images/Comment.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Oplkill/Simple-Dota-2-Editor/HEAD/SimpleDota2EditorWPF/Images/Comment.png
--------------------------------------------------------------------------------
/SimpleDota2EditorWPF/Images/Delete.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Oplkill/Simple-Dota-2-Editor/HEAD/SimpleDota2EditorWPF/Images/Delete.png
--------------------------------------------------------------------------------
/SimpleDota2EditorWPF/Images/EditKV.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Oplkill/Simple-Dota-2-Editor/HEAD/SimpleDota2EditorWPF/Images/EditKV.png
--------------------------------------------------------------------------------
/SimpleDota2EditorWPF/Images/Folder.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Oplkill/Simple-Dota-2-Editor/HEAD/SimpleDota2EditorWPF/Images/Folder.png
--------------------------------------------------------------------------------
/SimpleDota2EditorWPF/Images/Heroes.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Oplkill/Simple-Dota-2-Editor/HEAD/SimpleDota2EditorWPF/Images/Heroes.ico
--------------------------------------------------------------------------------
/SimpleDota2EditorWPF/Images/Heroes.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Oplkill/Simple-Dota-2-Editor/HEAD/SimpleDota2EditorWPF/Images/Heroes.png
--------------------------------------------------------------------------------
/SimpleDota2EditorWPF/Images/Object.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Oplkill/Simple-Dota-2-Editor/HEAD/SimpleDota2EditorWPF/Images/Object.png
--------------------------------------------------------------------------------
/SimpleDota2EditorWPF/Images/Rename.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Oplkill/Simple-Dota-2-Editor/HEAD/SimpleDota2EditorWPF/Images/Rename.png
--------------------------------------------------------------------------------
/KVGridUIWPF/ItemTypes.cs:
--------------------------------------------------------------------------------
1 | namespace KVGridUIWPF
2 | {
3 | public enum ItemTypes
4 | {
5 | TextText,
6 | Block,
7 | }
8 | }
--------------------------------------------------------------------------------
/SimpleDota2EditorWPF/Images/Abilities.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Oplkill/Simple-Dota-2-Editor/HEAD/SimpleDota2EditorWPF/Images/Abilities.ico
--------------------------------------------------------------------------------
/SimpleDota2EditorWPF/Images/CreateKV.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Oplkill/Simple-Dota-2-Editor/HEAD/SimpleDota2EditorWPF/Images/CreateKV.png
--------------------------------------------------------------------------------
/SimpleDota2EditorWPF/Images/FindHide.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Oplkill/Simple-Dota-2-Editor/HEAD/SimpleDota2EditorWPF/Images/FindHide.png
--------------------------------------------------------------------------------
/SimpleDota2EditorWPF/Images/FindNext.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Oplkill/Simple-Dota-2-Editor/HEAD/SimpleDota2EditorWPF/Images/FindNext.png
--------------------------------------------------------------------------------
/SimpleDota2EditorWPF/Images/FindPrev.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Oplkill/Simple-Dota-2-Editor/HEAD/SimpleDota2EditorWPF/Images/FindPrev.png
--------------------------------------------------------------------------------
/SimpleDota2EditorWPF/Images/FindShow.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Oplkill/Simple-Dota-2-Editor/HEAD/SimpleDota2EditorWPF/Images/FindShow.png
--------------------------------------------------------------------------------
/SimpleDota2EditorWPF/Images/UnComment.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Oplkill/Simple-Dota-2-Editor/HEAD/SimpleDota2EditorWPF/Images/UnComment.png
--------------------------------------------------------------------------------
/SimpleDota2EditorWPF/Images/settings.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Oplkill/Simple-Dota-2-Editor/HEAD/SimpleDota2EditorWPF/Images/settings.png
--------------------------------------------------------------------------------
/SimpleDota2EditorWPF/Images/FolderClosed.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Oplkill/Simple-Dota-2-Editor/HEAD/SimpleDota2EditorWPF/Images/FolderClosed.png
--------------------------------------------------------------------------------
/SimpleDota2EditorWPF/Images/CreateKVBlock.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Oplkill/Simple-Dota-2-Editor/HEAD/SimpleDota2EditorWPF/Images/CreateKVBlock.png
--------------------------------------------------------------------------------
/SimpleDota2EditorWPF/Images/FolderOpenned.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Oplkill/Simple-Dota-2-Editor/HEAD/SimpleDota2EditorWPF/Images/FolderOpenned.png
--------------------------------------------------------------------------------
/SimpleDota2EditorWPF/Images/AbilitiesOverride.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Oplkill/Simple-Dota-2-Editor/HEAD/SimpleDota2EditorWPF/Images/AbilitiesOverride.ico
--------------------------------------------------------------------------------
/SomeUtils/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/KVGridUIWPF/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/KVGridUIWPF/KVGridSubFieldItemInterface.cs:
--------------------------------------------------------------------------------
1 | namespace KVGridUIWPF
2 | {
3 | public interface KVGridSubFieldItemInterface
4 | {
5 | string Text { get; set; }
6 | }
7 | }
--------------------------------------------------------------------------------
/KVGridUIWPF/App.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/CodeAnalysGenerators/App.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/CodeAnalysGenerators/Program.cs:
--------------------------------------------------------------------------------
1 | namespace CodeAnalysGenerators
2 | {
3 | class Program
4 | {
5 | static void Main(string[] args)
6 | {
7 | KVKeys.Start();
8 | }
9 |
10 |
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/KVGridUIWPF/Properties/Settings.settings:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/SimpleDota2EditorWPF/Properties/Settings.settings:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/KV reloaded/KVreloaded.cs:
--------------------------------------------------------------------------------
1 | using System.Linq;
2 |
3 | namespace KV_reloaded
4 | {
5 | public class KVreloaded
6 | {
7 | public KVToken MainToken;
8 |
9 | public void LoadKVText(string text)
10 | {
11 | MainToken = TokenAnalizer.AnaliseText(text).FirstOrDefault();
12 | }
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/KV reloaded/Attibute/KeyValue.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace KV_reloaded
4 | {
5 | [AttributeUsage(AttributeTargets.Method)]
6 | public class KeyValue : Attribute
7 | {
8 | public string place { get; set; }
9 | public KeyValue(string place)
10 | {
11 | this.place = place;
12 | }
13 | }
14 | }
--------------------------------------------------------------------------------
/CodeAnalysGenerators/Files/npc_heroes_custom.txt:
--------------------------------------------------------------------------------
1 | //File edited with Simple Dota 2 Editor
2 | //https://github.com/Oplkill/Simple-Dota-2-Editor
3 |
4 |
5 | "DOTAHeroes"
6 | {//@ #Folder="New folder 85924072"
7 |
8 |
9 |
10 |
11 | "New_object_85925210"{"Name" "Oplkill"}"New_object_81324681"{"bla" "000"}//@ #Folder="New folder 85924072"
12 | "New_object_81567660"{}}}
13 |
--------------------------------------------------------------------------------
/KVGridUIWPF/KVGridItemAbstract.cs:
--------------------------------------------------------------------------------
1 | using System.Windows.Controls;
2 |
3 | namespace KVGridUIWPF
4 | {
5 | public abstract class KVGridItemAbstract : UserControl
6 | {
7 |
8 |
9 | public new KVGrid.TextChangedFunc OnTextChanged;
10 |
11 |
12 | public string[] comments; //todo удалить и изменить, временное решение оформления
13 | }
14 | }
--------------------------------------------------------------------------------
/SimpleDota2EditorWPF/App.xaml:
--------------------------------------------------------------------------------
1 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/KVGridUIWPF/App.xaml:
--------------------------------------------------------------------------------
1 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/KVGridUIWPF/App.xaml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Configuration;
4 | using System.Data;
5 | using System.Linq;
6 | using System.Threading.Tasks;
7 | using System.Windows;
8 |
9 | namespace KVGridUIWPF
10 | {
11 | ///
12 | /// Логика взаимодействия для App.xaml
13 | ///
14 | public partial class App : Application
15 | {
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/KV reloaded/ParserToken.cs:
--------------------------------------------------------------------------------
1 | namespace KV_reloaded
2 | {
3 | public class ParserToken
4 | {
5 | public string Text = "";
6 | public ParserTokenType Type = ParserTokenType.Nil;
7 | }
8 |
9 | public enum ParserTokenType
10 | {
11 | Nil,
12 | NewLine,
13 | Space,
14 | Comment,
15 | Text,
16 | NewBlock,
17 | EndBlock,
18 | Eof,
19 | }
20 | }
--------------------------------------------------------------------------------
/SimpleDota2EditorWPF/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/SomeUtils/ObjectCloner.cs:
--------------------------------------------------------------------------------
1 | using System.IO;
2 | using System.Runtime.Serialization.Formatters.Binary;
3 |
4 | namespace SomeUtils
5 | {
6 | public static class ObjectCloner
7 | {
8 | public static T DeepClone(this T source) where T : class
9 | {
10 | MemoryStream stream = new MemoryStream();
11 | BinaryFormatter formatter = new BinaryFormatter();
12 | formatter.Serialize(stream, source);
13 | stream.Position = 0;
14 | return (T)formatter.Deserialize(stream);
15 | }
16 | }
17 | }
--------------------------------------------------------------------------------
/SimpleDota2EditorWPF/ScriptsUtils/KV/BasicCompletionValues.kv:
--------------------------------------------------------------------------------
1 |
2 | "Values"
3 | {
4 | "BaseClass"
5 | {
6 | "ability_datadriven" "#AbilityDataDriven"
7 | "ability_lua" "#AbilityLua"
8 | }
9 |
10 | "var_type"
11 | {
12 | "FIELD_INTEGER" "#FieldInteger"
13 | "FIELD_FLOAT" "#FieldFloat"
14 | }
15 |
16 | "AbilityUnitTargetTeam"
17 | {
18 | "DOTA_UNIT_TARGET_TEAM_ENEMY" "descr"
19 | "DOTA_UNIT_TARGET_TEAM_FRIENDLY" "descr"
20 | }
21 |
22 | "AbilityBehavior"
23 | {
24 | "DOTA_ABILITY_BEHAVIOR_PASSIVE" "Descr"
25 | "DOTA_ABILITY_BEHAVIOR_HIDDEN" "Descr"
26 | }
27 | }
--------------------------------------------------------------------------------
/SimpleDota2EditorWPF/App.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Simple-Dota-2-Editor
2 | Simple Dota 2 editor txt files with KV style objects and lua editing.
3 |
4 | Download binars there https://github.com/Oplkill/Simple-Dota-2-Editor/releases
5 |
6 | See plans there https://trello.com/b/EtSKnLuW/simple-dota-2-editor
7 |
8 | 
9 | 
10 | 
11 | 
12 |
13 |
14 | Video v0.04Alpha
15 | https://youtu.be/gE4UOq4E0Ow
16 |
--------------------------------------------------------------------------------
/SimpleDota2EditorWPF/App.xaml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Configuration;
4 | using System.Data;
5 | using System.Linq;
6 | using System.Threading.Tasks;
7 | using System.Windows;
8 |
9 | namespace SimpleDota2EditorWPF
10 | {
11 | ///
12 | /// Логика взаимодействия для App.xaml
13 | ///
14 | public partial class App : Application
15 | {
16 | public App()
17 | {
18 |
19 | }
20 | public void Run()
21 | {
22 | Run(new ObjectEditorMainWindow());
23 | }
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/KVGridUIWPF/KVGridItemInterface.cs:
--------------------------------------------------------------------------------
1 | namespace KVGridUIWPF
2 | {
3 | public interface KVGridItemInterface
4 | {
5 | int ItemHeight { get; }
6 |
7 | ItemTypes ItemType { get; }
8 |
9 | KVGridBlock ParentBlock { get; set; }
10 |
11 | KVGrid GridOwner { get; set; }
12 |
13 | string KeyText { get; set; }
14 |
15 | ///
16 | /// Can be null if doesnt contain value (eq Block)
17 | /// Will be empty if value empty
18 | ///
19 | string ValueText { get; set; }
20 |
21 | bool Selected { get; set; }
22 |
23 | int Id { get; set; }
24 |
25 | KVGrid.TextChangedFunc OnTextChanged { get; set; }
26 | }
27 | }
--------------------------------------------------------------------------------
/KV reloaded/KVSettings.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Reflection;
3 |
4 | namespace KV_reloaded
5 | {
6 | public static class KVSettings
7 | {
8 | public static string MakeClassInKV(Type t, string headerKV)
9 | {
10 | //KeyValue kvAttributes = (KeyValue)Attribute.GetCustomAttribute(t, typeof(KeyValue));
11 |
12 | var fields = t.GetFields();
13 | KVToken token = new KVToken(string.IsNullOrWhiteSpace(headerKV) ? "Settings" : headerKV);
14 |
15 | foreach (var f in fields)
16 | {
17 | KeyValue kvAtr = (KeyValue)Attribute.GetCustomAttribute(f, typeof(KeyValue));
18 | }
19 |
20 | return token.ToString();
21 | }
22 | }
23 | }
--------------------------------------------------------------------------------
/KVGridUIWPF/KVGrid.xaml:
--------------------------------------------------------------------------------
1 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/KVGridUIWPF/Items/SubFieldItems/KVSFITextBox.xaml:
--------------------------------------------------------------------------------
1 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/SimpleDota2EditorWPF/ScriptsUtils/KV/BasicCompletionKV.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.IO;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 | using ICSharpCode.AvalonEdit.CodeCompletion;
8 | using KV_reloaded;
9 | using SimpleDota2EditorWPF.Panels;
10 |
11 | namespace SimpleDota2EditorWPF.ScriptsUtils.KV
12 | {
13 | public static class BasicCompletionKV
14 | {
15 | public static KVToken Keys = new KVToken("");
16 | public static KVToken Values = new KVToken("");
17 |
18 | public static void Init()
19 | {
20 | loadKv("ScriptsUtils\\KV\\BasicCompletionKeys.kv", ref Keys);
21 | loadKv("ScriptsUtils\\KV\\BasicCompletionValues.kv", ref Values);
22 | }
23 |
24 | private static void loadKv(string file, ref KVToken token)
25 | {
26 | if (!File.Exists(file))
27 | return;
28 |
29 | token = TokenAnalizer.AnaliseText(File.ReadAllText(file)).FirstOrDefault();
30 | }
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/KVGridUIWPF/MainWindow.xaml:
--------------------------------------------------------------------------------
1 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/KVGridUIWPF/MainWindow.xaml.cs:
--------------------------------------------------------------------------------
1 | using System.Windows;
2 | using KVGridUIWPF.Items.KeyValueItems;
3 |
4 | namespace KVGridUIWPF
5 | {
6 | ///
7 | /// Логика взаимодействия для MainWindow.xaml
8 | ///
9 | public partial class MainWindow : Window
10 | {
11 | public MainWindow()
12 | {
13 | InitializeComponent();
14 |
15 | KvGrid1.MainBlock.AddItem(KvGrid1, new KVGridItem_TextText(), -1);
16 | KvGrid1.MainBlock.AddItem(KvGrid1, new KVGridItem_TextText(), -1);
17 | var block = KvGrid1.MainBlock.AddItem(KvGrid1, new KVGridBlock(), 0);
18 | ((KVGridBlock)block).AddItem(KvGrid1, new KVGridItem_TextText(), -1);
19 | for (int i = 0; i < 30; i++)
20 | {
21 | KvGrid1.MainBlock.AddItem(KvGrid1, new KVGridItem_TextText(), -1);
22 | ((KVGridBlock)block).AddItem(KvGrid1, new KVGridItem_TextText(), -1);
23 | }
24 | }
25 |
26 | private void button_Click(object sender, RoutedEventArgs e)
27 | {
28 | KvGrid1.SelectedItem?.ParentBlock.RemoveItem(KvGrid1.SelectedItem, true);
29 |
30 | }
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/KVGridUIWPF/Properties/Settings.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated by a tool.
4 | // Runtime Version:4.0.30319.42000
5 | //
6 | // Changes to this file may cause incorrect behavior and will be lost if
7 | // the code is regenerated.
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | namespace KVGridUIWPF.Properties
12 | {
13 |
14 |
15 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
16 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
17 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
18 | {
19 |
20 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
21 |
22 | public static Settings Default
23 | {
24 | get
25 | {
26 | return defaultInstance;
27 | }
28 | }
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/SimpleDota2EditorWPF/Properties/Settings.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated by a tool.
4 | // Runtime Version:4.0.30319.42000
5 | //
6 | // Changes to this file may cause incorrect behavior and will be lost if
7 | // the code is regenerated.
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | namespace SimpleDota2EditorWPF.Properties
12 | {
13 |
14 |
15 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
16 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
17 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
18 | {
19 |
20 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
21 |
22 | public static Settings Default
23 | {
24 | get
25 | {
26 | return defaultInstance;
27 | }
28 | }
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/SimpleDota2EditorWPF/Dialogs/RenameDialog.xaml:
--------------------------------------------------------------------------------
1 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/SimpleDota2EditorWPF/Panels/TextEditorKVPanel.xaml:
--------------------------------------------------------------------------------
1 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/SimpleDota2EditorWPF/Panels/TextEditorLUAPanel.xaml:
--------------------------------------------------------------------------------
1 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/SimpleDota2EditorWPF/Panels/KV/MyCompletionData.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using ICSharpCode.AvalonEdit.CodeCompletion;
3 | using ICSharpCode.AvalonEdit.Document;
4 | using ICSharpCode.AvalonEdit.Editing;
5 |
6 | namespace SimpleDota2EditorWPF.Panels.KV
7 | {
8 | /// Implements AvalonEdit ICompletionData interface to provide the entries in the
9 | /// completion drop down.
10 | public class MyCompletionData : ICompletionData
11 | {
12 | public MyCompletionData(string text, string description)
13 | {
14 | this.Text = text;
15 | this.description = description;
16 | }
17 |
18 | public void Complete(TextArea textArea, ISegment completionSegment, EventArgs insertionRequestEventArgs)
19 | {
20 | textArea.Document.Replace(completionSegment, this.Text);
21 | }
22 |
23 | public System.Windows.Media.ImageSource Image
24 | {
25 | get { return null; }
26 | }
27 |
28 | public string Text { get; private set; }
29 |
30 | // Use this property if you want to show a fancy UIElement in the list.
31 | public object Content
32 | {
33 | get { return this.Text; }
34 | }
35 |
36 | public object Description
37 | {
38 | get { return this.description; }
39 | }
40 |
41 | public double Priority { get; }
42 | public string description;
43 | }
44 | }
--------------------------------------------------------------------------------
/SimpleDota2EditorWPF/Panels/EditorsCollectionPanel.xaml:
--------------------------------------------------------------------------------
1 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/KVGridUIWPF/Items/KeyValueItems/KVGridItem_TextText.xaml:
--------------------------------------------------------------------------------
1 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/SomeUtils/DotaResourceManager.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using System.IO;
3 | using SteamDatabase.ValvePak;
4 |
5 | namespace SomeUtils
6 | {
7 | public static class DotaResourceManager
8 | {
9 | public static void CreateCacheIcons(string dotaPathPak01DirVpk, string path)
10 | {
11 | if (!File.Exists(dotaPathPak01DirVpk))
12 | return;
13 | DirectoryInfo dirInfo = new DirectoryInfo(path);
14 | if (!dirInfo.Exists)
15 | {
16 | dirInfo.Create();
17 | }
18 |
19 | SteamDatabase.ValvePak.Package package = new Package();
20 | package.Read(dotaPathPak01DirVpk);
21 |
22 | var imagesList = new List();
23 |
24 | foreach (var file in package.Entries["png"])
25 | {
26 | if (file.DirectoryName.Contains("resource/flash3/images") && !file.DirectoryName.Contains("hud_skins"))
27 | {
28 | imagesList.Add(file);
29 | }
30 | }
31 |
32 | foreach (var img in imagesList)
33 | {
34 | byte[] bytes;
35 | package.ReadEntry(img, out bytes);
36 | dirInfo.CreateSubdirectory(img.DirectoryName);
37 | var file = File.Create("DotaCache\\" + img.GetFullPath());
38 | file.Write(bytes, 0, bytes.Length);
39 | file.Close();
40 | }
41 | }
42 | }
43 | }
--------------------------------------------------------------------------------
/SimpleDota2EditorWPF/AboutBoxWindow.xaml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using System.Windows;
7 | using System.Windows.Controls;
8 | using System.Windows.Data;
9 | using System.Windows.Documents;
10 | using System.Windows.Input;
11 | using System.Windows.Media;
12 | using System.Windows.Media.Imaging;
13 | using System.Windows.Shapes;
14 |
15 | namespace SimpleDota2EditorWPF
16 | {
17 | ///
18 | /// Логика взаимодействия для AboutBoxWindow.xaml
19 | ///
20 | public partial class AboutBoxWindow : Window
21 | {
22 | public AboutBoxWindow()
23 | {
24 | InitializeComponent();
25 | }
26 |
27 | private void Button_Click(object sender, RoutedEventArgs e)
28 | {
29 | this.Close();
30 | }
31 |
32 | private void label1_Clicked(object sender, MouseButtonEventArgs e)
33 | {
34 | System.Diagnostics.Process.Start("https://github.com/Oplkill");
35 | }
36 |
37 | private void label2_Clicked(object sender, MouseButtonEventArgs e)
38 | {
39 | System.Diagnostics.Process.Start("https://github.com/Oplkill/Simple-Dota-2-Editor");
40 | }
41 |
42 | private void label3_Clicked(object sender, MouseButtonEventArgs e)
43 | {
44 | System.Diagnostics.Process.Start("https://github.com/Oplkill/Simple-Dota-2-Editor/blob/master/ChangeLog.txt");
45 | }
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/SomeUtils/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // Управление общими сведениями о сборке осуществляется с помощью
6 | // набора атрибутов. Измените значения этих атрибутов, чтобы изменить сведения,
7 | // связанные со сборкой.
8 | [assembly: AssemblyTitle("SomeUtils")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("SomeUtils")]
13 | [assembly: AssemblyCopyright("Copyright © 2016")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Параметр ComVisible со значением FALSE делает типы в сборке невидимыми
18 | // для COM-компонентов. Если требуется обратиться к типу в этой сборке через
19 | // COM, задайте атрибуту ComVisible значение TRUE для этого типа.
20 | [assembly: ComVisible(false)]
21 |
22 | // Следующий GUID служит для идентификации библиотеки типов, если этот проект будет видимым для COM
23 | [assembly: Guid("a16b4834-1b73-41cd-ae1e-ce23fa3ae89a")]
24 |
25 | // Сведения о версии сборки состоят из следующих четырех значений:
26 | //
27 | // Основной номер версии
28 | // Дополнительный номер версии
29 | // Номер сборки
30 | // Редакция
31 | //
32 | // Можно задать все значения или принять номера сборки и редакции по умолчанию
33 | // используя "*", как показано ниже:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/KV reloaded/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // Управление общими сведениями о сборке осуществляется с помощью
6 | // набора атрибутов. Измените значения этих атрибутов, чтобы изменить сведения,
7 | // связанные со сборкой.
8 | [assembly: AssemblyTitle("KV reloaded")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("KV reloaded")]
13 | [assembly: AssemblyCopyright("Copyright © 2016")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Параметр ComVisible со значением FALSE делает типы в сборке невидимыми
18 | // для COM-компонентов. Если требуется обратиться к типу в этой сборке через
19 | // COM, задайте атрибуту ComVisible значение TRUE для этого типа.
20 | [assembly: ComVisible(false)]
21 |
22 | // Следующий GUID служит для идентификации библиотеки типов, если этот проект будет видимым для COM
23 | [assembly: Guid("7fae26f2-e820-4be6-9781-313953a122df")]
24 |
25 | // Сведения о версии сборки состоят из следующих четырех значений:
26 | //
27 | // Основной номер версии
28 | // Дополнительный номер версии
29 | // Номер сборки
30 | // Редакция
31 | //
32 | // Можно задать все значения или принять номера сборки и редакции по умолчанию
33 | // используя "*", как показано ниже:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/CodeAnalysGenerators/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // Управление общими сведениями о сборке осуществляется с помощью
6 | // набора атрибутов. Измените значения этих атрибутов, чтобы изменить сведения,
7 | // связанные со сборкой.
8 | [assembly: AssemblyTitle("CodeAnalysGenerators")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("CodeAnalysGenerators")]
13 | [assembly: AssemblyCopyright("Copyright © 2016")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Параметр ComVisible со значением FALSE делает типы в сборке невидимыми
18 | // для COM-компонентов. Если требуется обратиться к типу в этой сборке через
19 | // COM, задайте атрибуту ComVisible значение TRUE для этого типа.
20 | [assembly: ComVisible(false)]
21 |
22 | // Следующий GUID служит для идентификации библиотеки типов, если этот проект будет видимым для COM
23 | [assembly: Guid("a9b92e7e-6ca9-47b5-ac7e-a0498b5ed5a1")]
24 |
25 | // Сведения о версии сборки состоят из следующих четырех значений:
26 | //
27 | // Основной номер версии
28 | // Дополнительный номер версии
29 | // Номер сборки
30 | // Редакция
31 | //
32 | // Можно задать все значения или принять номера сборки и редакции по умолчанию
33 | // используя "*", как показано ниже:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/SomeUtils/StringUtils.cs:
--------------------------------------------------------------------------------
1 | using System.Linq;
2 |
3 | namespace SomeUtils
4 | {
5 | public static class StringUtils
6 | {
7 | ///
8 | /// Умножает строку str на number раз
9 | ///
10 | public static string GetStringInNumber(string str, int number)
11 | {
12 | string text = "";
13 |
14 | for (int i = 0; i < number; i++)
15 | {
16 | text += str;
17 | }
18 |
19 | return text;
20 | }
21 |
22 | ///
23 | /// Char c is " ", "\t", "\r"
24 | ///
25 | public static bool IsSpaceOrTab(char c)
26 | {
27 | return c == ' ' || c == '\t' || c == '\r';
28 | }
29 |
30 | public static bool IsDigit(string str)
31 | {
32 | return str.All(ch => char.IsDigit(ch) || ch == '.' || ch == '-');
33 | }
34 |
35 | public static int FindFirstPrevSymbol(string text, char symbol, int start)
36 | {
37 | if (text.Length <= start)
38 | return -1;
39 | while (start > 0)
40 | {
41 | if (text[start] == symbol)
42 | {
43 | return start;
44 | }
45 |
46 | start--;
47 | }
48 |
49 | return -1;
50 | }
51 |
52 | public static string GetCharMultip(char ch, int num)
53 | {
54 | string str = "";
55 |
56 | for (int i = 0; i <= num; i++)
57 | {
58 | str += ch;
59 | }
60 |
61 | return str;
62 | }
63 | }
64 | }
--------------------------------------------------------------------------------
/KVGridUIWPF/Items/KVGridBlock.xaml:
--------------------------------------------------------------------------------
1 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
--------------------------------------------------------------------------------
/SimpleDota2EditorWPF/Dialogs/SystemCommentEditorDialog.xaml:
--------------------------------------------------------------------------------
1 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/SimpleDota2EditorWPF/Panels/StartPagePanel.xaml:
--------------------------------------------------------------------------------
1 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
24 |
25 |
26 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/SimpleDota2EditorWPF/IEditor.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.ComponentModel;
3 | using KV_reloaded;
4 | using SimpleDota2EditorWPF.Dialogs;
5 | using SimpleDota2EditorWPF.Panels;
6 | using Xceed.Wpf.AvalonDock.Layout;
7 |
8 | namespace SimpleDota2EditorWPF
9 | {
10 | public interface IEditor
11 | {
12 | bool Edited { get; set; }
13 | string PanelName { get; set; }
14 | KVToken ObjectRef { get; set; }
15 | ObjectsViewPanel.ObjectTypePanel ObjectType { get; set; }
16 | Settings.EditorType EditorType { get; }
17 | void ForceClose();
18 | ErrorParser SaveChanges();
19 | void Closing(object sender, CancelEventArgs e);
20 | LayoutDocument PanelDocument { get; set; }
21 | void Update();
22 | void IsActiveChanged(object sender, EventArgs e);
23 | IEditor ParentEditor { get; set; }
24 |
25 | ///
26 | /// Find next, after caret selection
27 | ///
28 | /// Reached end of document? null - Didnt finded
29 | bool? FindNext(FindStruct find);
30 | ///
31 | /// Find prev, before caret selection
32 | ///
33 | /// Reached start of document? null - Didnt finded
34 | bool? FindPrev(FindStruct find);
35 | ///
36 | /// Count all substrings of text in document
37 | ///
38 | /// Number substrings of text in document
39 | int CountIt(FindStruct find);
40 | ///
41 | /// Replacing one pare of text in document and finding next
42 | ///
43 | /// Is all replaced? null - Didnt finded
44 | bool? Replace(FindStruct find);
45 | }
46 | }
--------------------------------------------------------------------------------
/SimpleDota2EditorWPF/Dialogs/RenameDialog.xaml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using System.Windows;
7 | using System.Windows.Controls;
8 | using System.Windows.Data;
9 | using System.Windows.Documents;
10 | using System.Windows.Input;
11 | using System.Windows.Media;
12 | using System.Windows.Media.Imaging;
13 | using System.Windows.Shapes;
14 |
15 | namespace SimpleDota2EditorWPF
16 | {
17 | ///
18 | /// Логика взаимодействия для RenameDialog.xaml
19 | ///
20 | public partial class RenameDialog : Window
21 | {
22 | public RenameDialog()
23 | {
24 | InitializeComponent();
25 | }
26 |
27 | private string startText = "";
28 | private string[] lockedNames;
29 |
30 | public string ShowDialog(string oldName, string[] lockedNames)
31 | {
32 | this.lockedNames = lockedNames;
33 | textBox.Text = startText = oldName;
34 | this.ShowDialog();
35 | return textBox.Text;
36 | }
37 |
38 | private void ButtonCancel_Click(object sender, RoutedEventArgs e)
39 | {
40 | textBox.Text = startText;
41 | this.Close();
42 | }
43 |
44 | private void ButtonOk_Click(object sender, RoutedEventArgs e)
45 | {
46 | if (textBox.Text == startText)
47 | { ButtonCancel_Click(sender, e); return; }
48 |
49 | if (lockedNames.FirstOrDefault(name => String.Equals(name, textBox.Text, StringComparison.CurrentCultureIgnoreCase)) == null)
50 | this.Close();
51 | else
52 | {
53 | label.Content = Properties.Resources.RenameThisNameAlreadyUsing;
54 | }
55 | }
56 |
57 | private void textBox_PreviewKeyDown(object sender, KeyEventArgs e)
58 | {
59 | label.Content = "";
60 | }
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/KV reloaded/ErrorParser.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Windows.Forms;
4 |
5 | namespace KV_reloaded
6 | {
7 | public class ErrorParser : Exception
8 | {
9 | public int Line;
10 | public int Symbol;
11 | public KvError KvError;
12 |
13 | public ErrorParser(KvError error, int line, int symbol)
14 | {
15 | KvError = error;
16 | Line = line;
17 | Symbol = symbol;
18 | }
19 |
20 | public string GetMessage()
21 | {
22 | string errorText = "";
23 | errorText += "\n" + "Line - " + Line;
24 | errorText += "\n" + "Symbol - " + Symbol;
25 | errorText += "\n" + KvError.ToStringLang();
26 |
27 | return errorText;
28 | }
29 | }
30 |
31 | public enum KvError
32 | {
33 | NotOveredComment, // Незавершенный комментарий. "/ Коммент"
34 | EmptyKey,
35 | NotStartedBlock,
36 | NotEndedBlock,
37 | UndefinitedSymbols,
38 | LonelyKey,
39 | }
40 |
41 | public static class KvErrorStatic
42 | {
43 | public static string ToStringLang(this KvError kvError)
44 | {
45 | switch (kvError)
46 | {
47 | case KvError.NotOveredComment:
48 | return "Comment is not overed!"; //todo пихнуть в ресурсы и руссифицировать
49 |
50 | case KvError.EmptyKey:
51 | return "Empty key!";
52 |
53 | case KvError.NotStartedBlock:
54 | return "Not started block";
55 |
56 | case KvError.NotEndedBlock:
57 | return "Not ended block";
58 |
59 | case KvError.UndefinitedSymbols:
60 | return "Undefinited symbols";
61 |
62 | case KvError.LonelyKey:
63 | return "Lonely key";
64 |
65 | default:
66 | return "Undefinited error!";
67 | }
68 | }
69 | }
70 | }
--------------------------------------------------------------------------------
/SimpleDota2EditorWPF/Dialogs/FindWindowDialog.xaml:
--------------------------------------------------------------------------------
1 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/SimpleDota2EditorWPF/LuaEditorMainWindow.xaml:
--------------------------------------------------------------------------------
1 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
35 |
36 |
37 |
--------------------------------------------------------------------------------
/SimpleDota2EditorWPF/LuaEditorMainWindow.xaml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using System.Windows;
7 | using System.Windows.Controls;
8 | using System.Windows.Data;
9 | using System.Windows.Documents;
10 | using System.Windows.Input;
11 | using System.Windows.Media;
12 | using System.Windows.Media.Imaging;
13 | using System.Windows.Shapes;
14 |
15 | namespace SimpleDota2EditorWPF
16 | {
17 | ///
18 | /// Логика взаимодействия для LuaEditorMainWindow.xaml
19 | ///
20 | public partial class LuaEditorMainWindow : Window
21 | {
22 | public LuaEditorMainWindow()
23 | {
24 | InitializeComponent();
25 | }
26 |
27 | #region Menu
28 |
29 | public void MenuItem_Open_Click(object sender, RoutedEventArgs e)
30 | {
31 | //bool? res = DataBase.openDialogView.Show();
32 | //if (res != true) return;
33 |
34 | //DataBase.LoadAddon(DataBase.openDialogView.SelectedFilePath + "\\");
35 | }
36 |
37 | private void MenuItem_Save_Click(object sender, RoutedEventArgs e)
38 | {
39 | DataBase.SaveAddon();
40 | }
41 |
42 | private void MenuItem_Close_Click(object sender, RoutedEventArgs e)
43 | {
44 | DataBase.CloseAddon();
45 | }
46 |
47 | private void MenuItem_Exit_Click(object sender, RoutedEventArgs e)
48 | {
49 | this.Close();
50 | }
51 |
52 | private void MenuItem_Settings_Click(object sender, RoutedEventArgs e)
53 | {
54 | AllPanels.settingForm.ShowDialog();
55 | }
56 |
57 | private void OpenObjectEditor_Click(object sender, RoutedEventArgs e)
58 | {
59 |
60 | }
61 |
62 | private void MenuItem_SendBug_Click(object sender, RoutedEventArgs e)
63 | {
64 | System.Diagnostics.Process.Start(Settings.GithubIssuesLink);
65 | }
66 |
67 | private void MenuItem_About_Click(object sender, RoutedEventArgs e)
68 | {
69 | AboutBoxWindow aboutBox = new AboutBoxWindow();
70 | aboutBox.ShowDialog();
71 | }
72 |
73 | #endregion
74 |
75 |
76 | }
77 | }
78 |
--------------------------------------------------------------------------------
/KVGridUIWPF/Items/SubFieldItems/KVSFITextBox.xaml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Windows;
3 | using System.Windows.Controls;
4 | using System.Windows.Input;
5 | using System.Windows.Threading;
6 |
7 | namespace KVGridUIWPF.Items.SubFieldItems
8 | {
9 | ///
10 | /// Логика взаимодействия для KVSFITextBox.xaml
11 | ///
12 | public partial class KVSFITextBox : UserControl, KVGridSubFieldItemInterface
13 | {
14 | public KVSFITextBox()
15 | {
16 | InitializeComponent();
17 |
18 | timer = new DispatcherTimer();
19 | timer.Interval = new TimeSpan(0, 0, 0, 1);
20 | timer.Tick += timerExperied;
21 | }
22 |
23 | public EventHandler OnActivateClick;
24 |
25 | public delegate void TextChangedFunc(string oldText, string newText);
26 | public new TextChangedFunc OnTextChanged;
27 |
28 | public string Text
29 | {
30 | get { return textBox1.Text; }
31 | set
32 | {
33 | loading = true;
34 | textBox1.Text = value;
35 | }
36 | }
37 |
38 | private string oldText;
39 | private DispatcherTimer timer;
40 | private bool loading;
41 |
42 | private void timerExperied(object obj, EventArgs e)
43 | {
44 | if (oldText == null) return;
45 |
46 | var old = oldText;
47 | oldText = null;
48 | OnTextChanged?.Invoke(old, Text);
49 |
50 | timer.Stop();
51 | }
52 |
53 | private void textBox1_KeyDown(object sender, KeyEventArgs e)
54 | {
55 | if (oldText == null)
56 | oldText = Text;
57 | }
58 |
59 | private void textBox1_TextChanged(object sender, TextChangedEventArgs e)
60 | {
61 | if (loading)
62 | {
63 | loading = false;
64 | return;
65 | }
66 |
67 | if (timer.IsEnabled)
68 | timer.Stop();
69 |
70 | timer.Start();
71 | }
72 |
73 | private void textBox1_MouseDown(object sender, MouseButtonEventArgs e)
74 | {
75 | OnActivateClick?.Invoke(this, e);
76 | }
77 |
78 | private void TextBox1_OnGotFocus(object sender, RoutedEventArgs e)
79 | {
80 | OnActivateClick?.Invoke(this, e);
81 | }
82 | }
83 | }
84 |
--------------------------------------------------------------------------------
/SimpleDota2EditorWPF/Panels/StartPagePanel.xaml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.IO;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 | using System.Windows;
8 | using System.Windows.Controls;
9 | using System.Windows.Data;
10 | using System.Windows.Documents;
11 | using System.Windows.Input;
12 | using System.Windows.Media;
13 | using System.Windows.Media.Imaging;
14 | using System.Windows.Navigation;
15 | using System.Windows.Shapes;
16 |
17 | namespace SimpleDota2EditorWPF.Panels
18 | {
19 | ///
20 | /// Логика взаимодействия для StartPagePanel.xaml
21 | ///
22 | public partial class StartPagePanel : UserControl
23 | {
24 | private List projectsInDotaFolder;
25 |
26 | public StartPagePanel()
27 | {
28 | projectsInDotaFolder = new List();
29 |
30 | InitializeComponent();
31 | LoadProjectsInDotaFolder();
32 | }
33 |
34 | private void ButtonLoadAddon_clicked(object sender, EventArgs e)
35 | {
36 | AllPanels.ObjectEditorForm.MenuItem_Open_Click(sender, null);
37 | }
38 |
39 | private void LoadProjectsInDotaFolder()
40 | {
41 | try
42 | {
43 | System.IO.DirectoryInfo info = new System.IO.DirectoryInfo(DataBase.Settings.DotaPath + DataBase.Settings.AddonsPath);
44 | var dirs = DataBase.Settings.HideStandartDota2Projects ? info.GetDirectories().Where(dir => !DataBase.Settings.StandartsDota2Projects.Contains(dir.Name)) :
45 | info.GetDirectories();
46 |
47 | projectsInDotaFolder.Clear();
48 | ListBoxProjectsInDota.Items.Clear();
49 |
50 | foreach (var dir in dirs)
51 | {
52 | if (DataBase.IsDotaProjectFolder(dir.FullName))
53 | {
54 | projectsInDotaFolder.Add(dir.FullName);
55 | ListBoxProjectsInDota.Items.Add(dir.Name);
56 | }
57 | }
58 | }
59 | catch (Exception e)
60 | {
61 |
62 | return;
63 | }
64 | }
65 |
66 | private void ListBoxProjectsInDota_SelectionChanged(object sender, SelectionChangedEventArgs e)
67 | {
68 | if (ListBoxProjectsInDota.SelectedItems.Count == 0) return;
69 |
70 | DataBase.LoadAddon(projectsInDotaFolder[ListBoxProjectsInDota.Items.IndexOf(ListBoxProjectsInDota.SelectedItems[0])] + "\\");
71 | }
72 | }
73 | }
74 |
--------------------------------------------------------------------------------
/KVGridUIWPF/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Resources;
3 | using System.Runtime.CompilerServices;
4 | using System.Runtime.InteropServices;
5 | using System.Windows;
6 |
7 | // Управление общими сведениями о сборке осуществляется с помощью
8 | // набора атрибутов. Измените значения этих атрибутов, чтобы изменить сведения,
9 | // связанные со сборкой.
10 | [assembly: AssemblyTitle("KVGridUIWPF")]
11 | [assembly: AssemblyDescription("")]
12 | [assembly: AssemblyConfiguration("")]
13 | [assembly: AssemblyCompany("")]
14 | [assembly: AssemblyProduct("KVGridUIWPF")]
15 | [assembly: AssemblyCopyright("Copyright © 2016")]
16 | [assembly: AssemblyTrademark("")]
17 | [assembly: AssemblyCulture("")]
18 |
19 | // Параметр ComVisible со значением FALSE делает типы в сборке невидимыми
20 | // для COM-компонентов. Если требуется обратиться к типу в этой сборке через
21 | // COM, задайте атрибуту ComVisible значение TRUE для этого типа.
22 | [assembly: ComVisible(false)]
23 |
24 | //Чтобы начать сборку локализованных приложений, задайте
25 | //CultureYouAreCodingWith в файле .csproj
26 | //внутри . Например, если используется английский США
27 | //в своих исходных файлах установите в en-US. Затем отмените преобразование в комментарий
28 | //атрибута NeutralResourceLanguage ниже. Обновите "en-US" в
29 | //строка внизу для обеспечения соответствия настройки UICulture в файле проекта.
30 |
31 | //[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]
32 |
33 |
34 | [assembly: ThemeInfo(
35 | ResourceDictionaryLocation.None, //где расположены словари ресурсов по конкретным тематикам
36 | //(используется, если ресурс не найден на странице
37 | // или в словарях ресурсов приложения)
38 | ResourceDictionaryLocation.SourceAssembly //где расположен словарь универсальных ресурсов
39 | //(используется, если ресурс не найден на странице,
40 | // в приложении или в каких-либо словарях ресурсов для конкретной темы)
41 | )]
42 |
43 |
44 | // Сведения о версии сборки состоят из следующих четырех значений:
45 | //
46 | // Основной номер версии
47 | // Дополнительный номер версии
48 | // Номер сборки
49 | // Редакция
50 | //
51 | // Можно задать все значения или принять номера сборки и редакции по умолчанию
52 | // используя "*", как показано ниже:
53 | // [assembly: AssemblyVersion("1.0.*")]
54 | [assembly: AssemblyVersion("1.0.0.0")]
55 | [assembly: AssemblyFileVersion("1.0.0.0")]
56 |
--------------------------------------------------------------------------------
/SimpleDota2EditorWPF/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Resources;
3 | using System.Runtime.CompilerServices;
4 | using System.Runtime.InteropServices;
5 | using System.Windows;
6 |
7 | // Управление общими сведениями о сборке осуществляется с помощью
8 | // набора атрибутов. Измените значения этих атрибутов, чтобы изменить сведения,
9 | // связанные со сборкой.
10 | [assembly: AssemblyTitle("SimpleDota2EditorWPF")]
11 | [assembly: AssemblyDescription("")]
12 | [assembly: AssemblyConfiguration("")]
13 | [assembly: AssemblyCompany("")]
14 | [assembly: AssemblyProduct("SimpleDota2EditorWPF")]
15 | [assembly: AssemblyCopyright("Copyright © 2016")]
16 | [assembly: AssemblyTrademark("")]
17 | [assembly: AssemblyCulture("")]
18 |
19 | // Параметр ComVisible со значением FALSE делает типы в сборке невидимыми
20 | // для COM-компонентов. Если требуется обратиться к типу в этой сборке через
21 | // COM, задайте атрибуту ComVisible значение TRUE для этого типа.
22 | [assembly: ComVisible(false)]
23 |
24 | //Чтобы начать сборку локализованных приложений, задайте
25 | //CultureYouAreCodingWith в файле .csproj
26 | //внутри . Например, если используется английский США
27 | //в своих исходных файлах установите в en-US. Затем отмените преобразование в комментарий
28 | //атрибута NeutralResourceLanguage ниже. Обновите "en-US" в
29 | //строка внизу для обеспечения соответствия настройки UICulture в файле проекта.
30 |
31 | //[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]
32 |
33 |
34 | [assembly: ThemeInfo(
35 | ResourceDictionaryLocation.None, //где расположены словари ресурсов по конкретным тематикам
36 | //(используется, если ресурс не найден на странице
37 | // или в словарях ресурсов приложения)
38 | ResourceDictionaryLocation.SourceAssembly //где расположен словарь универсальных ресурсов
39 | //(используется, если ресурс не найден на странице,
40 | // в приложении или в каких-либо словарях ресурсов для конкретной темы)
41 | )]
42 |
43 |
44 | // Сведения о версии сборки состоят из следующих четырех значений:
45 | //
46 | // Основной номер версии
47 | // Дополнительный номер версии
48 | // Номер сборки
49 | // Редакция
50 | //
51 | // Можно задать все значения или принять номера сборки и редакции по умолчанию
52 | // используя "*", как показано ниже:
53 | // [assembly: AssemblyVersion("1.0.*")]
54 | [assembly: AssemblyVersion("1.0.0.0")]
55 | [assembly: AssemblyFileVersion("1.0.0.0")]
56 |
--------------------------------------------------------------------------------
/.gitattributes:
--------------------------------------------------------------------------------
1 | ###############################################################################
2 | # Set default behavior to automatically normalize line endings.
3 | ###############################################################################
4 | * text=auto
5 |
6 | ###############################################################################
7 | # Set default behavior for command prompt diff.
8 | #
9 | # This is need for earlier builds of msysgit that does not have it on by
10 | # default for csharp files.
11 | # Note: This is only used by command line
12 | ###############################################################################
13 | #*.cs diff=csharp
14 |
15 | ###############################################################################
16 | # Set the merge driver for project and solution files
17 | #
18 | # Merging from the command prompt will add diff markers to the files if there
19 | # are conflicts (Merging from VS is not affected by the settings below, in VS
20 | # the diff markers are never inserted). Diff markers may cause the following
21 | # file extensions to fail to load in VS. An alternative would be to treat
22 | # these files as binary and thus will always conflict and require user
23 | # intervention with every merge. To do so, just uncomment the entries below
24 | ###############################################################################
25 | #*.sln merge=binary
26 | #*.csproj merge=binary
27 | #*.vbproj merge=binary
28 | #*.vcxproj merge=binary
29 | #*.vcproj merge=binary
30 | #*.dbproj merge=binary
31 | #*.fsproj merge=binary
32 | #*.lsproj merge=binary
33 | #*.wixproj merge=binary
34 | #*.modelproj merge=binary
35 | #*.sqlproj merge=binary
36 | #*.wwaproj merge=binary
37 |
38 | ###############################################################################
39 | # behavior for image files
40 | #
41 | # image files are treated as binary by default.
42 | ###############################################################################
43 | #*.jpg binary
44 | #*.png binary
45 | #*.gif binary
46 |
47 | ###############################################################################
48 | # diff behavior for common document formats
49 | #
50 | # Convert binary document formats to text before diffing them. This feature
51 | # is only available from the command line. Turn it on by uncommenting the
52 | # entries below.
53 | ###############################################################################
54 | #*.doc diff=astextplain
55 | #*.DOC diff=astextplain
56 | #*.docx diff=astextplain
57 | #*.DOCX diff=astextplain
58 | #*.dot diff=astextplain
59 | #*.DOT diff=astextplain
60 | #*.pdf diff=astextplain
61 | #*.PDF diff=astextplain
62 | #*.rtf diff=astextplain
63 | #*.RTF diff=astextplain
64 |
--------------------------------------------------------------------------------
/SomeUtils/UndoRedoManager.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 |
3 | namespace SomeUtils
4 | {
5 | public interface ICommand
6 | {
7 | string Name { get; }
8 | void Execute();
9 | void UnExecute();
10 | }
11 |
12 | public class UndoRedoManager
13 | {
14 | Stack UndoStack { get; set; }
15 | Stack RedoStack { get; set; }
16 |
17 | public UndoRedoManager()
18 | {
19 | UndoStack = new Stack();
20 | RedoStack = new Stack();
21 | }
22 |
23 | public void Undo()
24 | {
25 | if (UndoStack.Count > 0)
26 | {
27 | //изымаем команду из стека
28 | var command = UndoStack.Pop();
29 | //отменяем действие команды
30 | command.UnExecute();
31 | //заносим команду в стек Redo
32 | RedoStack.Push(command);
33 | //сигнализируем об изменениях
34 | //StateChanged(this, EventArgs.Empty);
35 | }
36 | }
37 |
38 | public void Redo()
39 | {
40 | if (RedoStack.Count > 0)
41 | {
42 | //изымаем команду из стека
43 | var command = RedoStack.Pop();
44 | //выполняем действие команды
45 | command.Execute();
46 | //заносим команду в стек Undo
47 | UndoStack.Push(command);
48 | //сигнализируем об изменениях
49 | //StateChanged(this, EventArgs.Empty);
50 | }
51 | }
52 |
53 | //выполняем команду
54 | public void Execute(ICommand command)
55 | {
56 | //выполняем команду
57 | command.Execute();
58 | //заносим в стек Undo
59 | UndoStack.Push(command);
60 | //очищаем стек Redo
61 | RedoStack.Clear();
62 | //сигнализируем об изменениях
63 | //StateChanged(this, EventArgs.Empty);
64 | }
65 |
66 | public bool CanUndo()
67 | {
68 | return UndoStack.Count != 0;
69 | }
70 |
71 | public bool CanRedo()
72 | {
73 | return RedoStack.Count != 0;
74 | }
75 |
76 | public string GetUndoActionName()
77 | {
78 | if (!CanUndo())
79 | return "";
80 |
81 | return UndoStack.Peek().Name;
82 | }
83 |
84 | public string GetRedoActionName()
85 | {
86 | if (!CanRedo())
87 | return "";
88 |
89 | return RedoStack.Peek().Name;
90 | }
91 |
92 | public void ClearAll()
93 | {
94 | UndoStack.Clear();
95 | RedoStack.Clear();
96 | }
97 | }
98 | }
--------------------------------------------------------------------------------
/SimpleDota2EditorWPF/AboutBoxWindow.xaml:
--------------------------------------------------------------------------------
1 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
--------------------------------------------------------------------------------
/KVGridUIWPF/Items/KeyValueItems/KVGridItem_TextText.xaml.cs:
--------------------------------------------------------------------------------
1 | using System.Windows;
2 | using System.Windows.Controls;
3 | using System.Windows.Media;
4 |
5 | namespace KVGridUIWPF.Items.KeyValueItems
6 | {
7 | ///
8 | /// Логика взаимодействия для KVGridItem_TextText.xaml
9 | ///
10 | public partial class KVGridItem_TextText : UserControl, KVGridItemInterface
11 | {
12 | public KVGridItem_TextText(int id = -1)
13 | {
14 | this.Id = id;
15 | ItemType = ItemTypes.TextText;
16 |
17 | InitializeComponent();
18 |
19 | kvsfiTextBoxKey.OnActivateClick += select_Click;
20 | kvsfiTextBoxValue.OnActivateClick += select_Click;
21 |
22 | kvsfiTextBoxKey.OnTextChanged += KeyTextChanged;
23 | kvsfiTextBoxValue.OnTextChanged += ValueTextChanged;
24 | }
25 |
26 | private void select_Click(object sender, System.EventArgs e)
27 | {
28 | GridOwner.SelectedItem = this;
29 | }
30 |
31 | private void KeyTextChanged(string oldText, string newText)
32 | {
33 | OnTextChanged?.Invoke(this, oldText, newText, KVType.Key);
34 | }
35 |
36 | private void ValueTextChanged(string oldText, string newText)
37 | {
38 | OnTextChanged?.Invoke(this, oldText, newText, KVType.Value);
39 | }
40 |
41 | #region variables
42 |
43 | private static Brush selectedBrush = new SolidColorBrush(Colors.Blue);
44 | private static Brush normalBrush = new SolidColorBrush(SystemColors.ControlColor);
45 | public bool Selected
46 | {
47 | get
48 | {
49 | return Equals(GridSplitter.Background, selectedBrush);
50 | }
51 | set
52 | {
53 | if (this.Selected == value) return;
54 |
55 | if (value)
56 | {
57 | GridSplitter.Background = selectedBrush;
58 | }
59 | else
60 | {
61 | GridSplitter.Background = normalBrush;
62 | }
63 | }
64 | }
65 |
66 | public int Id { get; set; }
67 | public KVGrid.TextChangedFunc OnTextChanged { get; set; }
68 |
69 | public int ItemHeight => (int)this.Height;
70 |
71 | public ItemTypes ItemType { get; }
72 | public KVGridBlock ParentBlock { get; set; }
73 | public KVGrid GridOwner { get; set; }
74 |
75 | public string KeyText
76 | {
77 | get { return kvsfiTextBoxKey.Text; }
78 | set { kvsfiTextBoxKey.Text = value; }
79 | }
80 |
81 | public string ValueText
82 | {
83 | get { return kvsfiTextBoxValue.Text; }
84 | set { kvsfiTextBoxValue.Text = value; }
85 | }
86 |
87 | #endregion
88 | }
89 | }
90 |
--------------------------------------------------------------------------------
/SomeUtils/SomeUtils.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {A16B4834-1B73-41CD-AE1E-CE23FA3AE89A}
8 | Library
9 | Properties
10 | SomeUtils
11 | SomeUtils
12 | v4.6.1
13 | 512
14 |
15 |
16 | true
17 | full
18 | false
19 | bin\Debug\
20 | DEBUG;TRACE
21 | prompt
22 | 4
23 |
24 |
25 | pdbonly
26 | true
27 | bin\Release\
28 | TRACE
29 | prompt
30 | 4
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 | ..\packages\ValvePak.0.4.0.11\lib\net40\ValvePak.dll
43 | True
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
64 |
--------------------------------------------------------------------------------
/SimpleDota2EditorWPF.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio 14
4 | VisualStudioVersion = 14.0.25123.0
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SimpleDota2EditorWPF", "SimpleDota2EditorWPF\SimpleDota2EditorWPF.csproj", "{B5D0682D-76D5-4391-9468-8655CF04A9EE}"
7 | EndProject
8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "KV reloaded", "KV reloaded\KV reloaded.csproj", "{7FAE26F2-E820-4BE6-9781-313953A122DF}"
9 | EndProject
10 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SomeUtils", "SomeUtils\SomeUtils.csproj", "{A16B4834-1B73-41CD-AE1E-CE23FA3AE89A}"
11 | EndProject
12 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "KVGridUIWPF", "KVGridUIWPF\KVGridUIWPF.csproj", "{E8420BB9-95C6-448A-B11C-88552D073C00}"
13 | EndProject
14 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CodeAnalysGenerators", "CodeAnalysGenerators\CodeAnalysGenerators.csproj", "{A9B92E7E-6CA9-47B5-AC7E-A0498B5ED5A1}"
15 | EndProject
16 | Global
17 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
18 | Debug|Any CPU = Debug|Any CPU
19 | Release|Any CPU = Release|Any CPU
20 | EndGlobalSection
21 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
22 | {B5D0682D-76D5-4391-9468-8655CF04A9EE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
23 | {B5D0682D-76D5-4391-9468-8655CF04A9EE}.Debug|Any CPU.Build.0 = Debug|Any CPU
24 | {B5D0682D-76D5-4391-9468-8655CF04A9EE}.Release|Any CPU.ActiveCfg = Release|Any CPU
25 | {B5D0682D-76D5-4391-9468-8655CF04A9EE}.Release|Any CPU.Build.0 = Release|Any CPU
26 | {7FAE26F2-E820-4BE6-9781-313953A122DF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
27 | {7FAE26F2-E820-4BE6-9781-313953A122DF}.Debug|Any CPU.Build.0 = Debug|Any CPU
28 | {7FAE26F2-E820-4BE6-9781-313953A122DF}.Release|Any CPU.ActiveCfg = Release|Any CPU
29 | {7FAE26F2-E820-4BE6-9781-313953A122DF}.Release|Any CPU.Build.0 = Release|Any CPU
30 | {A16B4834-1B73-41CD-AE1E-CE23FA3AE89A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
31 | {A16B4834-1B73-41CD-AE1E-CE23FA3AE89A}.Debug|Any CPU.Build.0 = Debug|Any CPU
32 | {A16B4834-1B73-41CD-AE1E-CE23FA3AE89A}.Release|Any CPU.ActiveCfg = Release|Any CPU
33 | {A16B4834-1B73-41CD-AE1E-CE23FA3AE89A}.Release|Any CPU.Build.0 = Release|Any CPU
34 | {E8420BB9-95C6-448A-B11C-88552D073C00}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
35 | {E8420BB9-95C6-448A-B11C-88552D073C00}.Debug|Any CPU.Build.0 = Debug|Any CPU
36 | {E8420BB9-95C6-448A-B11C-88552D073C00}.Release|Any CPU.ActiveCfg = Release|Any CPU
37 | {E8420BB9-95C6-448A-B11C-88552D073C00}.Release|Any CPU.Build.0 = Release|Any CPU
38 | {A9B92E7E-6CA9-47B5-AC7E-A0498B5ED5A1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
39 | {A9B92E7E-6CA9-47B5-AC7E-A0498B5ED5A1}.Debug|Any CPU.Build.0 = Debug|Any CPU
40 | {A9B92E7E-6CA9-47B5-AC7E-A0498B5ED5A1}.Release|Any CPU.ActiveCfg = Release|Any CPU
41 | {A9B92E7E-6CA9-47B5-AC7E-A0498B5ED5A1}.Release|Any CPU.Build.0 = Release|Any CPU
42 | EndGlobalSection
43 | GlobalSection(SolutionProperties) = preSolution
44 | HideSolutionNode = FALSE
45 | EndGlobalSection
46 | EndGlobal
47 |
--------------------------------------------------------------------------------
/KVGridUIWPF/Properties/Resources.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // Этот код создан программным средством.
4 | // Версия среды выполнения: 4.0.30319.42000
5 | //
6 | // Изменения в этом файле могут привести к неправильному поведению и будут утрачены, если
7 | // код создан повторно.
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | namespace KVGridUIWPF.Properties
12 | {
13 |
14 |
15 | ///
16 | /// Класс ресурсов со строгим типом для поиска локализованных строк и пр.
17 | ///
18 | // Этот класс был автоматически создан при помощи StronglyTypedResourceBuilder
19 | // класс с помощью таких средств, как ResGen или Visual Studio.
20 | // Для добавления или удаления члена измените файл .ResX, а затем перезапустите ResGen
21 | // с параметром /str или заново постройте свой VS-проект.
22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
25 | internal class Resources
26 | {
27 |
28 | private static global::System.Resources.ResourceManager resourceMan;
29 |
30 | private static global::System.Globalization.CultureInfo resourceCulture;
31 |
32 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
33 | internal Resources()
34 | {
35 | }
36 |
37 | ///
38 | /// Возврат кэшированного экземпляра ResourceManager, используемого этим классом.
39 | ///
40 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
41 | internal static global::System.Resources.ResourceManager ResourceManager
42 | {
43 | get
44 | {
45 | if ((resourceMan == null))
46 | {
47 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("KVGridUIWPF.Properties.Resources", typeof(Resources).Assembly);
48 | resourceMan = temp;
49 | }
50 | return resourceMan;
51 | }
52 | }
53 |
54 | ///
55 | /// Переопределяет свойство CurrentUICulture текущего потока для всех
56 | /// подстановки ресурсов с помощью этого класса ресурсов со строгим типом.
57 | ///
58 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
59 | internal static global::System.Globalization.CultureInfo Culture
60 | {
61 | get
62 | {
63 | return resourceCulture;
64 | }
65 | set
66 | {
67 | resourceCulture = value;
68 | }
69 | }
70 | }
71 | }
72 |
--------------------------------------------------------------------------------
/KV reloaded/SystemComment.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using System.Linq;
3 |
4 | namespace KV_reloaded
5 | {
6 | public class SystemComment
7 | {
8 | public List KVList = new List();
9 |
10 | public override string ToString()
11 | {
12 | if (KVList.Count == 0)
13 | return "";
14 |
15 | string text = KVList.Aggregate("//@", (current, kv) => current + (" #" + kv.Key + "=\"" + kv.Value + "\""));
16 | return text + "\n";
17 | }
18 |
19 | public bool HasAnyKeyWhichContainingString(string str)
20 | {
21 | if (KVList.Any(kv => kv.Key.Contains(str)))
22 | {
23 | return true;
24 | }
25 | return false;
26 | }
27 |
28 | public KV FindKV(string key)
29 | {
30 | return KVList.FirstOrDefault(kv => kv.Key == key);
31 | }
32 |
33 | public void AddKV(KV kv)
34 | {
35 | KVList.Add(kv);
36 | }
37 |
38 | public void AddKV(string key, string value)
39 | {
40 | AddKV(new KV(key, value));
41 | }
42 |
43 | public void DeleteKV(string key)
44 | {
45 | var kv = FindKV(key);
46 | if(kv != null)
47 | KVList.Remove(kv);
48 | }
49 |
50 | public static SystemComment AnalyseSystemComment(string comment)
51 | {
52 | SystemComment sysComm = new SystemComment();
53 |
54 | int findedKey = comment.IndexOf('#');
55 | while (findedKey != -1)
56 | {
57 | comment = comment.Substring(findedKey);
58 | KV kv = new KV();
59 | kv.Key = comment.Substring(1, FindEnd(comment, false) - 1);
60 | int findedValue = comment.IndexOf('\"') + 1;
61 | kv.Value = comment.Substring(findedValue, FindEnd(comment.Substring(findedValue), true));
62 | sysComm.KVList.Add(kv);
63 | comment = comment.Substring(findedValue);
64 |
65 | findedKey = comment.IndexOf('#');
66 | }
67 |
68 | return sysComm;
69 | }
70 |
71 | private static int FindEnd(string text, bool inValue)
72 | {
73 | int n = 0;
74 | while (n < text.Length)
75 | {
76 | if ((text[n] == ' ' || text[n] == '=') && !inValue)
77 | {
78 | return n;
79 | }
80 | if (text[n] == '\"')
81 | return n;
82 | n++;
83 | }
84 |
85 | return -1;
86 | }
87 | }
88 |
89 | public class KV
90 | {
91 | public string Key;
92 | public string Value;
93 |
94 | public KV()
95 | {
96 | Key = "";
97 | Value = "";
98 | }
99 |
100 | public KV(string key, string value)
101 | {
102 | Key = key;
103 | Value = value;
104 | }
105 | }
106 | }
--------------------------------------------------------------------------------
/KV reloaded/KV reloaded.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {7FAE26F2-E820-4BE6-9781-313953A122DF}
8 | Library
9 | Properties
10 | KV_reloaded
11 | KV reloaded
12 | v4.6.1
13 | 512
14 |
15 |
16 | true
17 | full
18 | false
19 | bin\Debug\
20 | DEBUG;TRACE
21 | prompt
22 | 4
23 |
24 |
25 | pdbonly
26 | true
27 | bin\Release\
28 | TRACE
29 | prompt
30 | 4
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 | {a16b4834-1b73-41cd-ae1e-ce23fa3ae89a}
58 | SomeUtils
59 |
60 |
61 |
62 |
69 |
--------------------------------------------------------------------------------
/CodeAnalysGenerators/KVKeys.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.IO;
4 | using System.Linq;
5 | using KV_reloaded;
6 |
7 | namespace CodeAnalysGenerators
8 | {
9 | public static class KVKeys
10 | {
11 | public static void Start()
12 | {
13 | KVToken parsedKVs = new KVToken("Keys");
14 | parsedKVs.Children.Add(new KVToken("ROOT"));
15 |
16 | AnalysFile("Files\\npc_units_custom.txt", ref parsedKVs);
17 | AnalysFile("Files\\npc_abilities_custom.txt", ref parsedKVs);
18 | AnalysFile("Files\\npc_heroes_custom.txt", ref parsedKVs);
19 | AnalysFile("Files\\npc_items_custom.txt", ref parsedKVs);
20 |
21 | parsedKVs.ForceSetStandartStyle();
22 | StreamWriter file = new StreamWriter("parsedKVs.txt", false);
23 | file.WriteLine(parsedKVs.ToString());
24 | file.Close();
25 | }
26 |
27 | private static void AnalysFile(string filePath, ref KVToken parsedKVs)
28 | {
29 | string unitsFileCode = File.ReadAllText(filePath);
30 |
31 | KVToken kvToken;
32 | kvToken = TokenAnalizer.AnaliseText(unitsFileCode).FirstOrDefault();
33 |
34 | foreach (var tok in kvToken.Children)
35 | {
36 | if (tok.Type == KVTokenType.KVblock)
37 | Parse(ref parsedKVs, tok, "ROOT");
38 | }
39 | }
40 |
41 | private static void Parse(ref KVToken parsedKv, KVToken token, string parentName)
42 | {
43 | foreach (var tok in token.Children)
44 | {
45 | if (string.IsNullOrEmpty(tok.Key))
46 | continue;
47 | if (parentName == "AbilitySpecial")
48 | continue;
49 | if (parentName == "RunScript" && (tok.Key != "ScriptFile" || tok.Key != "Function"))
50 | continue;
51 |
52 | if (parentName == "Modifiers")
53 | {
54 | if (parsedKv.GetChild(parentName) == null)
55 | parsedKv.Children.Add(new KVToken(parentName));
56 | if (parsedKv.GetChild("MODIFIERS") == null)
57 | parsedKv.Children.Add(new KVToken("MODIFIERS"));
58 | if (tok.Type == KVTokenType.KVblock)
59 | Parse(ref parsedKv, tok, "MODIFIERS");
60 | continue;
61 | }
62 |
63 | if (parsedKv.GetChild(parentName) == null || parsedKv.GetChild(parentName).GetChild(tok.Key) == null)
64 | {
65 | KVToken kv = new KVToken(tok.Key);
66 | kv.Children.Add(new KVToken("Description", String.Concat("#", kv.Key)));
67 | kv.Children.Add(new KVToken("SimpleKey", (tok.Type != KVTokenType.KVblock).ToString()));
68 | if (parsedKv.GetChild(parentName) == null)
69 | parsedKv.Children.Add(new KVToken(parentName));
70 |
71 | parsedKv.GetChild(parentName).Children.Add(kv);
72 | }
73 |
74 | if (tok.Type == KVTokenType.KVblock)
75 | Parse(ref parsedKv, tok, tok.Key);
76 | }
77 | }
78 | }
79 | }
--------------------------------------------------------------------------------
/CodeAnalysGenerators/CodeAnalysGenerators.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {A9B92E7E-6CA9-47B5-AC7E-A0498B5ED5A1}
8 | Exe
9 | Properties
10 | CodeAnalysGenerators
11 | CodeAnalysGenerators
12 | v4.6.1
13 | 512
14 | true
15 |
16 |
17 | AnyCPU
18 | true
19 | full
20 | false
21 | bin\Debug\
22 | DEBUG;TRACE
23 | prompt
24 | 4
25 |
26 |
27 | AnyCPU
28 | pdbonly
29 | true
30 | bin\Release\
31 | TRACE
32 | prompt
33 | 4
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 | Always
56 |
57 |
58 | Always
59 |
60 |
61 | Always
62 |
63 |
64 | Always
65 |
66 |
67 |
68 |
69 | {7fae26f2-e820-4be6-9781-313953a122df}
70 | KV reloaded
71 |
72 |
73 |
74 |
81 |
--------------------------------------------------------------------------------
/SimpleDota2EditorWPF/ScriptsUtils/KV/KVScriptResourcesKeys.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // Этот код создан программой.
4 | // Исполняемая версия:4.0.30319.42000
5 | //
6 | // Изменения в этом файле могут привести к неправильной работе и будут потеряны в случае
7 | // повторной генерации кода.
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | namespace SimpleDota2EditorWPF.ScriptsUtils.KV {
12 | using System;
13 |
14 |
15 | ///
16 | /// Класс ресурса со строгой типизацией для поиска локализованных строк и т.д.
17 | ///
18 | // Этот класс создан автоматически классом StronglyTypedResourceBuilder
19 | // с помощью такого средства, как ResGen или Visual Studio.
20 | // Чтобы добавить или удалить член, измените файл .ResX и снова запустите ResGen
21 | // с параметром /str или перестройте свой проект VS.
22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
25 | internal class KVScriptResourcesKeys {
26 |
27 | private static global::System.Resources.ResourceManager resourceMan;
28 |
29 | private static global::System.Globalization.CultureInfo resourceCulture;
30 |
31 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
32 | internal KVScriptResourcesKeys() {
33 | }
34 |
35 | ///
36 | /// Возвращает кэшированный экземпляр ResourceManager, использованный этим классом.
37 | ///
38 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
39 | internal static global::System.Resources.ResourceManager ResourceManager {
40 | get {
41 | if (object.ReferenceEquals(resourceMan, null)) {
42 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("SimpleDota2EditorWPF.ScriptsUtils.KV.KVScriptResourcesKeys", typeof(KVScriptResourcesKeys).Assembly);
43 | resourceMan = temp;
44 | }
45 | return resourceMan;
46 | }
47 | }
48 |
49 | ///
50 | /// Перезаписывает свойство CurrentUICulture текущего потока для всех
51 | /// обращений к ресурсу с помощью этого класса ресурса со строгой типизацией.
52 | ///
53 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
54 | internal static global::System.Globalization.CultureInfo Culture {
55 | get {
56 | return resourceCulture;
57 | }
58 | set {
59 | resourceCulture = value;
60 | }
61 | }
62 |
63 | ///
64 | /// Ищет локализованную строку, похожую на Base class description.
65 | ///
66 | internal static string BaseClass {
67 | get {
68 | return ResourceManager.GetString("BaseClass", resourceCulture);
69 | }
70 | }
71 |
72 | ///
73 | /// Ищет локализованную строку, похожую на Particle description.
74 | ///
75 | internal static string Particle {
76 | get {
77 | return ResourceManager.GetString("Particle", resourceCulture);
78 | }
79 | }
80 | }
81 | }
82 |
--------------------------------------------------------------------------------
/SimpleDota2EditorWPF/Dialogs/SystemCommentEditorDialog.xaml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using System.Windows;
7 | using System.Windows.Controls;
8 | using System.Windows.Data;
9 | using System.Windows.Documents;
10 | using System.Windows.Input;
11 | using System.Windows.Media;
12 | using System.Windows.Media.Imaging;
13 | using System.Windows.Shapes;
14 | using KV_reloaded;
15 | using Microsoft.Win32;
16 |
17 | namespace SimpleDota2EditorWPF.Dialogs
18 | {
19 | ///
20 | /// Логика взаимодействия для SystemCommentEditorDialog.xaml
21 | ///
22 | public partial class SystemCommentEditorDialog : Window
23 | {
24 | public SystemCommentEditorDialog(SystemComment SystemComment)
25 | {
26 | this.SystemComment = SystemComment;
27 |
28 | InitializeComponent();
29 |
30 | foreach (var kv in SystemComment.KVList)
31 | {
32 | if (kv.Key.Contains("lua"))
33 | ListBox.Items.Add(kv.Value);
34 | }
35 | }
36 |
37 | public SystemComment SystemComment;
38 | private bool Okayed;
39 |
40 | public static SystemComment ShowDialog(SystemComment sysComment)
41 | {
42 | var dialog = new SystemCommentEditorDialog(sysComment);
43 | dialog.ShowDialog();
44 | sysComment = dialog.SystemComment;
45 |
46 | return sysComment;
47 | }
48 |
49 | private void ListBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
50 | {
51 |
52 | }
53 |
54 | private void buttonAdd_Click(object sender, RoutedEventArgs e)
55 | {
56 | OpenFileDialog dialog = new OpenFileDialog();
57 | dialog.DefaultExt = ".lua";
58 | dialog.Filter = "Lua codes (.lua)|*.lua";
59 | dialog.InitialDirectory = DataBase.AddonPath + DataBase.Settings.VScriptPath;
60 | dialog.Multiselect = true;
61 |
62 | bool? result = dialog.ShowDialog();
63 | if (result == true)
64 | {
65 | var paths = dialog.FileNames;
66 | foreach (var path in paths)
67 | {
68 | if (!path.Contains(DataBase.AddonPath + DataBase.Settings.VScriptPath)) return; //todo make messagebox
69 | int len = string.Concat(DataBase.AddonPath, DataBase.Settings.VScriptPath).Length;
70 |
71 | ListBox.Items.Add(path.Substring(len));
72 | }
73 | }
74 | }
75 |
76 | private void buttonRemove_Click(object sender, RoutedEventArgs e)
77 | {
78 | if (ListBox.SelectedItems == null || ListBox.SelectedItems?.Count == 0)
79 | return;
80 |
81 | ListBox.Items.Remove(ListBox.SelectedItems[0]);
82 | }
83 |
84 | private void buttonCancel_Click(object sender, RoutedEventArgs e)
85 | {
86 | SystemComment = null;
87 | this.Close();
88 | }
89 |
90 | private void buttonOk_Click(object sender, RoutedEventArgs e)
91 | {
92 | Okayed = true;
93 | List deleteKvTokens = new List();
94 |
95 | foreach (var kv in SystemComment.KVList)
96 | {
97 | if(kv.Key.Contains("lua"))
98 | deleteKvTokens.Add(kv);
99 | }
100 | foreach (var kv in deleteKvTokens)
101 | {
102 | SystemComment.DeleteKV(kv.Key);
103 | }
104 |
105 | int i = 0;
106 | foreach (var item in ListBox.Items)
107 | {
108 | SystemComment.AddKV(string.Concat("lua", i++), (string)item);
109 | }
110 |
111 | DataBase.Edited = true;
112 | this.Close();
113 | }
114 |
115 | private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
116 | {
117 | if (!Okayed)
118 | SystemComment = null;
119 | }
120 | }
121 | }
122 |
--------------------------------------------------------------------------------
/SimpleDota2EditorWPF/ScriptsUtils/KV/KVScriptResourcesValues.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // Этот код создан программой.
4 | // Исполняемая версия:4.0.30319.42000
5 | //
6 | // Изменения в этом файле могут привести к неправильной работе и будут потеряны в случае
7 | // повторной генерации кода.
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | namespace SimpleDota2EditorWPF.ScriptsUtils.KV {
12 | using System;
13 |
14 |
15 | ///
16 | /// Класс ресурса со строгой типизацией для поиска локализованных строк и т.д.
17 | ///
18 | // Этот класс создан автоматически классом StronglyTypedResourceBuilder
19 | // с помощью такого средства, как ResGen или Visual Studio.
20 | // Чтобы добавить или удалить член, измените файл .ResX и снова запустите ResGen
21 | // с параметром /str или перестройте свой проект VS.
22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
25 | internal class KVScriptResourcesValues {
26 |
27 | private static global::System.Resources.ResourceManager resourceMan;
28 |
29 | private static global::System.Globalization.CultureInfo resourceCulture;
30 |
31 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
32 | internal KVScriptResourcesValues() {
33 | }
34 |
35 | ///
36 | /// Возвращает кэшированный экземпляр ResourceManager, использованный этим классом.
37 | ///
38 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
39 | internal static global::System.Resources.ResourceManager ResourceManager {
40 | get {
41 | if (object.ReferenceEquals(resourceMan, null)) {
42 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("SimpleDota2EditorWPF.ScriptsUtils.KV.KVScriptResourcesValues", typeof(KVScriptResourcesValues).Assembly);
43 | resourceMan = temp;
44 | }
45 | return resourceMan;
46 | }
47 | }
48 |
49 | ///
50 | /// Перезаписывает свойство CurrentUICulture текущего потока для всех
51 | /// обращений к ресурсу с помощью этого класса ресурса со строгой типизацией.
52 | ///
53 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
54 | internal static global::System.Globalization.CultureInfo Culture {
55 | get {
56 | return resourceCulture;
57 | }
58 | set {
59 | resourceCulture = value;
60 | }
61 | }
62 |
63 | ///
64 | /// Ищет локализованную строку, похожую на Ability descr.
65 | ///
66 | internal static string AbilityDataDriven {
67 | get {
68 | return ResourceManager.GetString("AbilityDataDriven", resourceCulture);
69 | }
70 | }
71 |
72 | ///
73 | /// Ищет локализованную строку, похожую на Spell by lua.
74 | ///
75 | internal static string AbilityLua {
76 | get {
77 | return ResourceManager.GetString("AbilityLua", resourceCulture);
78 | }
79 | }
80 |
81 | ///
82 | /// Ищет локализованную строку, похожую на Float.
83 | ///
84 | internal static string FieldFloat {
85 | get {
86 | return ResourceManager.GetString("FieldFloat", resourceCulture);
87 | }
88 | }
89 |
90 | ///
91 | /// Ищет локализованную строку, похожую на Integer.
92 | ///
93 | internal static string FieldInteger {
94 | get {
95 | return ResourceManager.GetString("FieldInteger", resourceCulture);
96 | }
97 | }
98 | }
99 | }
100 |
--------------------------------------------------------------------------------
/KV reloaded/KVToken.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using System.Linq;
3 |
4 | namespace KV_reloaded
5 | {
6 | public class KVToken
7 | {
8 | public string Key = "";
9 | public string Value = "";
10 |
11 | public KVTokenType Type;
12 |
13 | public List Children = null;
14 | public KVToken Parent = null;
15 | public SystemComment SystemComment = null;
16 |
17 | //--------------------------------
18 |
19 | public string[] comments = new string[3]; // 3 - это количество элементов в enum CommentPlace
20 |
21 | public KVToken()
22 | { }
23 |
24 | ///
25 | /// Simple Key-Value
26 | ///
27 | ///
28 | ///
29 | public KVToken(string key, string value)
30 | {
31 | this.Key = key;
32 | this.Value = value;
33 | Type = KVTokenType.KVsimple;
34 | }
35 |
36 | ///
37 | /// If it BLOCK
38 | ///
39 | ///
40 | public KVToken(string key)
41 | {
42 | this.Key = key;
43 | Type = KVTokenType.KVblock;
44 | Children = new List();
45 | }
46 |
47 | public void RemoveChild(string childKey)
48 | {
49 | KVToken child = null;
50 | foreach (var ch in Children.Where(ch => ch.Key == childKey && ch.Type == KVTokenType.KVblock))
51 | {
52 | child = ch;
53 | }
54 | if(child != null)
55 | Children.Remove(child);
56 | }
57 |
58 | public KVToken GetChild(string childKey)
59 | {
60 | return Children?.FirstOrDefault(ch => ch.Key == childKey);
61 | }
62 |
63 | public string ChilderToString()
64 | {
65 | if (Children == null)
66 | return "";
67 | return Children.Aggregate("", (current, ch) => current + ch.ToString());
68 | }
69 |
70 | ///
71 | /// Deleting all old comments and formating.
72 | /// Setting new formatting style for all childs and this token.
73 | ///
74 | public void ForceSetStandartStyle(string beforeKey = "", int tabNum = 0)
75 | {
76 | comments[(int) CommentPlace.BeforeKey] = beforeKey + SomeUtils.StringUtils.GetStringInNumber("\t", tabNum);
77 | if (Type == KVTokenType.KVsimple)
78 | comments[(int)CommentPlace.AfterKey] = SomeUtils.StringUtils.GetStringInNumber("\t", tabNum);
79 | else if (Type == KVTokenType.KVblock)
80 | comments[(int)CommentPlace.AfterKey] = "\n" + SomeUtils.StringUtils.GetStringInNumber("\t", tabNum);
81 |
82 | if (Children != null)
83 | {
84 | foreach (var tok in Children)
85 | {
86 | tok.ForceSetStandartStyle("\n", tabNum + 1);
87 | }
88 | comments[(int) CommentPlace.BeforeEndBlock] = "\n" + SomeUtils.StringUtils.GetStringInNumber("\t", tabNum);
89 | }
90 | }
91 |
92 | public override string ToString()
93 | {
94 | string str = "";
95 |
96 | if (Type == KVTokenType.KVsimple)
97 | {
98 | str += comments[(int)CommentPlace.BeforeKey] ?? "";
99 | str += "\"" + Key + "\"";
100 | str += comments[(int) CommentPlace.AfterKey] ?? "";
101 | str += "\"" + Value + "\"";
102 | }
103 | else if(Type == KVTokenType.Comment)
104 | {
105 | str += Value;
106 | }
107 | else
108 | {
109 | str += SystemComment?.ToString();
110 | str += comments[(int)CommentPlace.BeforeKey] ?? "";
111 | str += "\"" + Key + "\"";
112 | str += comments[(int) CommentPlace.AfterKey] ?? "";
113 | str += "{";
114 | if (Children == null)
115 | str += "";
116 | else
117 | str = Children.Aggregate(str, (current, child) => current + child.ToString());
118 | str += comments[(int)CommentPlace.BeforeEndBlock] ?? "";
119 | str += "}";
120 | }
121 |
122 | return str;
123 | }
124 | }
125 |
126 | ///
127 | /// Комментарии и/или пробелы/табы в определенных местах
128 | ///
129 | public enum CommentPlace
130 | {
131 | BeforeKey,
132 | AfterKey,
133 | BeforeEndBlock,
134 | }
135 |
136 | public enum KVTokenType
137 | {
138 | KVsimple,
139 | KVblock,
140 | Comment,
141 | }
142 | }
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | ## Ignore Visual Studio temporary files, build results, and
2 | ## files generated by popular Visual Studio add-ons.
3 |
4 | # User-specific files
5 | *.suo
6 | *.user
7 | *.userosscache
8 | *.sln.docstates
9 |
10 | # User-specific files (MonoDevelop/Xamarin Studio)
11 | *.userprefs
12 |
13 | # Build results
14 | [Dd]ebug/
15 | [Dd]ebugPublic/
16 | [Rr]elease/
17 | [Rr]eleases/
18 | [Xx]64/
19 | [Xx]86/
20 | [Bb]uild/
21 | bld/
22 | [Bb]in/
23 | [Oo]bj/
24 |
25 | # Visual Studio 2015 cache/options directory
26 | .vs/
27 | # Uncomment if you have tasks that create the project's static files in wwwroot
28 | #wwwroot/
29 |
30 | # MSTest test Results
31 | [Tt]est[Rr]esult*/
32 | [Bb]uild[Ll]og.*
33 |
34 | # NUNIT
35 | *.VisualState.xml
36 | TestResult.xml
37 |
38 | # Build Results of an ATL Project
39 | [Dd]ebugPS/
40 | [Rr]eleasePS/
41 | dlldata.c
42 |
43 | # DNX
44 | project.lock.json
45 | artifacts/
46 |
47 | *_i.c
48 | *_p.c
49 | *_i.h
50 | *.ilk
51 | *.meta
52 | *.obj
53 | *.pch
54 | *.pdb
55 | *.pgc
56 | *.pgd
57 | *.rsp
58 | *.sbr
59 | *.tlb
60 | *.tli
61 | *.tlh
62 | *.tmp
63 | *.tmp_proj
64 | *.log
65 | *.vspscc
66 | *.vssscc
67 | .builds
68 | *.pidb
69 | *.svclog
70 | *.scc
71 |
72 | # Chutzpah Test files
73 | _Chutzpah*
74 |
75 | # Visual C++ cache files
76 | ipch/
77 | *.aps
78 | *.ncb
79 | *.opendb
80 | *.opensdf
81 | *.sdf
82 | *.cachefile
83 | *.VC.db
84 |
85 | # Visual Studio profiler
86 | *.psess
87 | *.vsp
88 | *.vspx
89 | *.sap
90 |
91 | # TFS 2012 Local Workspace
92 | $tf/
93 |
94 | # Guidance Automation Toolkit
95 | *.gpState
96 |
97 | # ReSharper is a .NET coding add-in
98 | _ReSharper*/
99 | *.[Rr]e[Ss]harper
100 | *.DotSettings.user
101 |
102 | # JustCode is a .NET coding add-in
103 | .JustCode
104 |
105 | # TeamCity is a build add-in
106 | _TeamCity*
107 |
108 | # DotCover is a Code Coverage Tool
109 | *.dotCover
110 |
111 | # NCrunch
112 | _NCrunch_*
113 | .*crunch*.local.xml
114 | nCrunchTemp_*
115 |
116 | # MightyMoose
117 | *.mm.*
118 | AutoTest.Net/
119 |
120 | # Web workbench (sass)
121 | .sass-cache/
122 |
123 | # Installshield output folder
124 | [Ee]xpress/
125 |
126 | # DocProject is a documentation generator add-in
127 | DocProject/buildhelp/
128 | DocProject/Help/*.HxT
129 | DocProject/Help/*.HxC
130 | DocProject/Help/*.hhc
131 | DocProject/Help/*.hhk
132 | DocProject/Help/*.hhp
133 | DocProject/Help/Html2
134 | DocProject/Help/html
135 |
136 | # Click-Once directory
137 | publish/
138 |
139 | # Publish Web Output
140 | *.[Pp]ublish.xml
141 | *.azurePubxml
142 |
143 | # TODO: Un-comment the next line if you do not want to checkin
144 | # your web deploy settings because they may include unencrypted
145 | # passwords
146 | #*.pubxml
147 | *.publishproj
148 |
149 | # NuGet Packages
150 | *.nupkg
151 | # The packages folder can be ignored because of Package Restore
152 | **/packages/*
153 | # except build/, which is used as an MSBuild target.
154 | !**/packages/build/
155 | # Uncomment if necessary however generally it will be regenerated when needed
156 | #!**/packages/repositories.config
157 | # NuGet v3's project.json files produces more ignoreable files
158 | *.nuget.props
159 | *.nuget.targets
160 |
161 | # Microsoft Azure Build Output
162 | csx/
163 | *.build.csdef
164 |
165 | # Microsoft Azure Emulator
166 | ecf/
167 | rcf/
168 |
169 | # Microsoft Azure ApplicationInsights config file
170 | ApplicationInsights.config
171 |
172 | # Windows Store app package directory
173 | AppPackages/
174 | BundleArtifacts/
175 |
176 | # Visual Studio cache files
177 | # files ending in .cache can be ignored
178 | *.[Cc]ache
179 | # but keep track of directories ending in .cache
180 | !*.[Cc]ache/
181 |
182 | # Others
183 | ClientBin/
184 | [Ss]tyle[Cc]op.*
185 | ~$*
186 | *~
187 | *.dbmdl
188 | *.dbproj.schemaview
189 | *.pfx
190 | *.publishsettings
191 | node_modules/
192 | orleans.codegen.cs
193 |
194 | # RIA/Silverlight projects
195 | Generated_Code/
196 |
197 | # Backup & report files from converting an old project file
198 | # to a newer Visual Studio version. Backup files are not needed,
199 | # because we have git ;-)
200 | _UpgradeReport_Files/
201 | Backup*/
202 | UpgradeLog*.XML
203 | UpgradeLog*.htm
204 |
205 | # SQL Server files
206 | *.mdf
207 | *.ldf
208 |
209 | # Business Intelligence projects
210 | *.rdl.data
211 | *.bim.layout
212 | *.bim_*.settings
213 |
214 | # Microsoft Fakes
215 | FakesAssemblies/
216 |
217 | # GhostDoc plugin setting file
218 | *.GhostDoc.xml
219 |
220 | # Node.js Tools for Visual Studio
221 | .ntvs_analysis.dat
222 |
223 | # Visual Studio 6 build log
224 | *.plg
225 |
226 | # Visual Studio 6 workspace options file
227 | *.opt
228 |
229 | # Visual Studio LightSwitch build output
230 | **/*.HTMLClient/GeneratedArtifacts
231 | **/*.DesktopClient/GeneratedArtifacts
232 | **/*.DesktopClient/ModelManifest.xml
233 | **/*.Server/GeneratedArtifacts
234 | **/*.Server/ModelManifest.xml
235 | _Pvt_Extensions
236 |
237 | # LightSwitch generated files
238 | GeneratedArtifacts/
239 | ModelManifest.xml
240 |
241 | # Paket dependency manager
242 | .paket/paket.exe
243 |
244 | # FAKE - F# Make
245 | .fake/
--------------------------------------------------------------------------------
/SimpleDota2EditorWPF/Panels/ObjectsViewPanel.xaml:
--------------------------------------------------------------------------------
1 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
38 |
41 |
44 |
47 |
50 |
53 |
56 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
71 |
72 |
73 |
78 |
79 |
80 |
83 |
84 |
95 |
96 |
97 |
98 |
99 |
--------------------------------------------------------------------------------
/SimpleDota2EditorWPF/Dialogs/FindWindowDialog.xaml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using System.Windows;
7 | using System.Windows.Controls;
8 | using System.Windows.Data;
9 | using System.Windows.Documents;
10 | using System.Windows.Input;
11 | using System.Windows.Media;
12 | using System.Windows.Media.Imaging;
13 | using System.Windows.Shapes;
14 |
15 | namespace SimpleDota2EditorWPF.Dialogs
16 | {
17 | ///
18 | /// Логика взаимодействия для FindWindowDialog.xaml
19 | ///
20 | public partial class FindWindowDialog : Window
21 | {
22 | public FindWindowDialog()
23 | {
24 | InitializeComponent();
25 | }
26 |
27 | public FindStruct GetFindSettingsStruct()
28 | {
29 | return new FindStruct()
30 | {
31 | text = textBoxFind.Text,
32 | replaceText = textBoxReplace.Text,
33 | loop = checkBoxLoop.IsChecked != null && checkBoxLoop.IsChecked.Value,
34 | registr = checkBoxRegister.IsChecked != null && checkBoxRegister.IsChecked.Value ?
35 | StringComparison.Ordinal : StringComparison.OrdinalIgnoreCase,
36 | };
37 | }
38 |
39 | private void buttonPrev_Click(object sender, RoutedEventArgs e)
40 | {
41 | var selectedContent = AllPanels.LayoutDocumentPane.SelectedContent?.Content as IEditor;
42 | if (selectedContent == null) return;
43 | if (String.IsNullOrEmpty(textBoxFind.Text))
44 | {
45 | this.Title = "Find" + " - " + "Find box is empty!"; //todo move to resource
46 | textBoxFind.Focus();
47 | return;
48 | }
49 |
50 | var reachedStart = selectedContent.FindPrev(GetFindSettingsStruct());
51 | if (reachedStart == null)
52 | this.Title = "Find" + " - " + "Didn't finded anything"; //todo move to resource
53 | else if (reachedStart == true)
54 | this.Title = "Find" + " - " + "Reached start of document"; //todo move to resource
55 | else if (this.Title != "Find")
56 | this.Title = "Find"; //todo move to resource
57 |
58 | }
59 |
60 | private void buttonNext_Click(object sender, RoutedEventArgs e)
61 | {
62 | var selectedContent = AllPanels.LayoutDocumentPane.SelectedContent?.Content as IEditor;
63 | if (selectedContent == null) return;
64 | if (String.IsNullOrEmpty(textBoxFind.Text))
65 | {
66 | this.Title = "Find" + " - " + "Find box is empty!"; //todo move to resource
67 | textBoxFind.Focus();
68 | return;
69 | }
70 |
71 | var reachedEnd = selectedContent.FindNext(GetFindSettingsStruct());
72 | if (reachedEnd == null)
73 | this.Title = "Find" + " - " + "Didn't finded anything"; //todo move to resource
74 | else if (reachedEnd == true)
75 | this.Title = "Find" + " - " + "Reached end of document"; //todo move to resource
76 | else if (this.Title != "Find")
77 | this.Title = "Find"; //todo move to resource
78 | }
79 |
80 | private void buttonCount_Click(object sender, RoutedEventArgs e)
81 | {
82 | var selectedContent = AllPanels.LayoutDocumentPane.SelectedContent?.Content as IEditor;
83 | if (selectedContent == null) return;
84 | if (String.IsNullOrEmpty(textBoxFind.Text))
85 | {
86 | this.Title = "Find" + " - " + "Find box is empty!"; //todo move to resource
87 | textBoxFind.Focus();
88 | return;
89 | }
90 |
91 | int number = selectedContent.CountIt(GetFindSettingsStruct());
92 | this.Title = "Find" + " - " + "Number items " + number; //todo move to resource
93 | }
94 |
95 | private void buttonReplace_Click(object sender, RoutedEventArgs e)
96 | {
97 | var selectedContent = AllPanels.LayoutDocumentPane.SelectedContent?.Content as IEditor;
98 | if (selectedContent == null) return;
99 | if (String.IsNullOrEmpty(textBoxFind.Text))
100 | {
101 | this.Title = "Find" + " - " + "Find box is empty!"; //todo move to resource
102 | textBoxFind.Focus();
103 | return;
104 | }
105 |
106 | var allReplaced = selectedContent.Replace(GetFindSettingsStruct());
107 | if (allReplaced == null)
108 | this.Title = "Find" + " - " + "Didn't finded anything"; //todo move to resource
109 | else if (allReplaced == true)
110 | this.Title = "Find" + " - " + "Nothing left to replace"; //todo move to resource
111 | else if (this.Title != "Find")
112 | this.Title = "Find"; //todo move to resource
113 | }
114 |
115 | private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
116 | {
117 | e.Cancel = true;
118 | this.Hide();
119 | }
120 |
121 | private void Window_IsVisibleChanged(object sender, DependencyPropertyChangedEventArgs e)
122 | {
123 | if (this.Title != "Find")
124 | this.Title = "Find"; //todo move to resource
125 | }
126 | }
127 |
128 | //todo rename it
129 | public struct FindStruct
130 | {
131 | public StringComparison registr;
132 | public string text;
133 | public string replaceText;
134 | public bool loop;
135 | }
136 | }
137 |
--------------------------------------------------------------------------------
/KVGridUIWPF/KVGrid.xaml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Windows;
5 | using System.Windows.Controls;
6 | using System.Windows.Controls.Primitives;
7 | using KVGridUIWPF.Items.KeyValueItems;
8 |
9 | namespace KVGridUIWPF
10 | {
11 | ///
12 | /// Логика взаимодействия для KVGrid.xaml
13 | ///
14 | public partial class KVGrid : UserControl
15 | {
16 | public delegate void TextChangedFunc(KVGridItemInterface item, string oldText, string newText, KVType type);
17 | public KVGrid()
18 | {
19 | InitializeComponent();
20 |
21 | kvGridBlock1.HideKVBlockControls(true);
22 | kvGridBlock1.GridOwner = this;
23 | currentUnicId = 0; //todo generic id random
24 |
25 | kvGridBlock1.Id = GetMyId();
26 | }
27 |
28 | public List Items => kvGridBlock1.Items;
29 |
30 | public KVGridBlock MainBlock => kvGridBlock1;
31 |
32 | public void AddItem(ItemTypes type, string key, string value)
33 | {
34 | Control item = null;
35 | switch (type)
36 | {
37 | case ItemTypes.TextText:
38 | item = new KVGridItem_TextText() { KeyText = key, ValueText = value };
39 | break;
40 |
41 | case ItemTypes.Block:
42 | item = new KVGridBlock() { KeyText = key };
43 | break;
44 |
45 | default:
46 | return;
47 | }
48 | kvGridBlock1.AddItem(this, (KVGridItemInterface)item, -1);
49 | this.Height = kvGridBlock1.Height;
50 | }
51 |
52 | ///
53 | /// Swapping items
54 | ///
55 | public void SwapItems(KVGridItemInterface item1, KVGridItemInterface item2)
56 | {
57 | if (item1.ParentBlock == item2.ParentBlock)
58 | { item1.ParentBlock.SwapItems(item1, item2); return; }
59 |
60 | //todo
61 | }
62 |
63 | ///
64 | /// Getting item which upper @item. If @item first in block, it will be return block which contain @item.
65 | /// Returns null if @item uppest of all items of this kvGrid.
66 | ///
67 | public KVGridItemInterface GetItemUpperThatItem(KVGridItemInterface item)
68 | {
69 | var block = item.ParentBlock;
70 | var index = block.Items.IndexOf(item);
71 |
72 | if (index == 0)
73 | {
74 | if (block == MainBlock)
75 | return null;
76 | else
77 | return block;
78 | }
79 | else
80 | return block.Items[index - 1];
81 | }
82 |
83 | ///
84 | /// Getting item which downer @item.
85 | /// returns null if @item downer of all items of this kvGrid.
86 | ///
87 | public KVGridItemInterface GetItemDownerThatItem(KVGridItemInterface item)
88 | {
89 | var block = item.ParentBlock;
90 | var index = block.Items.IndexOf(item);
91 |
92 | if (index == block.Items.Count - 1)
93 | {
94 | if (block == MainBlock)
95 | return null;
96 | else
97 | return GetItemDownerThatItem(block);
98 | }
99 | else
100 | return block.Items[index + 1];
101 | }
102 |
103 | public void MoveItemUpThrough(KVGridItemInterface item)
104 | {
105 | var block = item.ParentBlock;
106 | var index = block.Items.IndexOf(item);
107 |
108 | if (index == 0)
109 | {
110 | if (block == MainBlock)
111 | return;
112 | block.RemoveItem(item, false);
113 | block.ParentBlock.AddItem(this, item, block.ParentBlock.Items.IndexOf(block));
114 | }
115 | else
116 | block.SwapItems(block.Items[index - 1], item);
117 | }
118 |
119 | public void MoveItemDownThrough(KVGridItemInterface item)
120 | {
121 | var block = item.ParentBlock;
122 | var index = block.Items.IndexOf(item);
123 |
124 | if (index == block.Items.Count - 1)
125 | {
126 | if (block == MainBlock)
127 | return;
128 | block.RemoveItem(item, false);
129 | block.ParentBlock.AddItem(this, item, block.ParentBlock.Items.IndexOf(block) + 1);
130 | }
131 | else
132 | block.SwapItems(block.Items[index + 1], item);
133 | }
134 |
135 | public KVGridItemInterface SelectedItem
136 | {
137 | get { return selectedItem; }
138 | set
139 | {
140 | if (selectedItem == value) return;
141 |
142 | if (selectedItem != null) selectedItem.Selected = false;
143 | if (value == null)
144 | {
145 | selectedItem = null;
146 | return;
147 | }
148 | if (value.GridOwner != this) return;
149 |
150 | selectedItem = value;
151 | selectedItem.Selected = true;
152 | }
153 | }
154 |
155 | public KVGridItemInterface GetItemById(int id)
156 | {
157 | return MainBlock.FindItemId(id);
158 | }
159 |
160 | public int GetMyId()
161 | {
162 | return currentUnicId++;
163 | }
164 |
165 | private KVGridItemInterface selectedItem;
166 | private int currentUnicId;
167 | }
168 | }
169 |
--------------------------------------------------------------------------------
/KVGridUIWPF/Properties/Resources.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 | text/microsoft-resx
107 |
108 |
109 | 2.0
110 |
111 |
112 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
113 |
114 |
115 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
--------------------------------------------------------------------------------
/SimpleDota2EditorWPF/Panels/EditorsCollectionPanel.xaml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.ComponentModel;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 | using System.Windows;
8 | using System.Windows.Controls;
9 | using System.Windows.Data;
10 | using System.Windows.Documents;
11 | using System.Windows.Input;
12 | using System.Windows.Media;
13 | using System.Windows.Media.Imaging;
14 | using System.Windows.Navigation;
15 | using System.Windows.Shapes;
16 | using KV_reloaded;
17 | using SimpleDota2EditorWPF.Dialogs;
18 | using Xceed.Wpf.AvalonDock.Layout;
19 |
20 | namespace SimpleDota2EditorWPF.Panels
21 | {
22 | ///
23 | /// Логика взаимодействия для EditorsCollectionPanel.xaml
24 | ///
25 | public partial class EditorsCollectionPanel : UserControl, IEditor
26 | {
27 | public IEditor ParentEditor { get; set; }
28 | public bool? FindNext(FindStruct find)
29 | {
30 | if (DocumentsPane.SelectedContent.Content is IEditor)
31 | return ((IEditor) DocumentsPane.SelectedContent.Content).FindNext(find);
32 | return null;
33 | }
34 |
35 | public bool? FindPrev(FindStruct find)
36 | {
37 | if (DocumentsPane.SelectedContent.Content is IEditor)
38 | return ((IEditor)DocumentsPane.SelectedContent.Content).FindPrev(find);
39 | return null;
40 | }
41 |
42 | public int CountIt(FindStruct find)
43 | {
44 | if (DocumentsPane.SelectedContent.Content is IEditor)
45 | return ((IEditor)DocumentsPane.SelectedContent.Content).CountIt(find);
46 | return 0;
47 | }
48 |
49 | public bool? Replace(FindStruct find)
50 | {
51 | if (DocumentsPane.SelectedContent.Content is IEditor)
52 | return ((IEditor)DocumentsPane.SelectedContent.Content).Replace(find);
53 | return null;
54 | }
55 |
56 | public bool Edited
57 | {
58 | get { return edited; }
59 | set
60 | {
61 | PanelDocument.Title = PanelName + (value ? @" *" : "");
62 | edited = value;
63 | }
64 | }
65 | private bool edited;
66 | public EditorsCollectionPanel()
67 | {
68 | InitializeComponent();
69 | }
70 |
71 | public string PanelName
72 | {
73 | get { return panelName; }
74 | set
75 | {
76 | PanelDocument.Title = value + (Edited ? @" *" : "");
77 | var panels = DocumentsPane.Children.Where(doc => doc.Content is IEditor);
78 | foreach (var panel in panels)
79 | {
80 | if (((IEditor) panel.Content).PanelName == panelName)
81 | {
82 | ((IEditor) panel.Content).PanelName = value;
83 | }
84 | }
85 | panelName = value;
86 | }
87 | }
88 |
89 | private string panelName;
90 | public KVToken ObjectRef { get; set; }
91 | public ObjectsViewPanel.ObjectTypePanel ObjectType { get; set; }
92 | public Settings.EditorType EditorType { get; }
93 | public void ForceClose()
94 | {
95 | var panels = DocumentsPane.Children.Where(doc => doc.Content is IEditor);
96 |
97 | foreach (var panel in panels)
98 | {
99 | ((IEditor)panel.Content).ForceClose();
100 | }
101 | }
102 |
103 | public ErrorParser SaveChanges()
104 | {
105 | ErrorParser errors = null;
106 | var panels = DocumentsPane.Children.Where(doc => doc.Content is IEditor);
107 |
108 | foreach (var panel in panels)
109 | {
110 | var error = ((IEditor) panel.Content).SaveChanges();
111 | if (error != null)
112 | errors = error;
113 | }
114 |
115 | return errors;
116 | }
117 |
118 | public void Closing(object sender, CancelEventArgs e)
119 | {
120 | var errors = SaveChanges();
121 |
122 | if (errors == null)
123 | return;
124 |
125 | var dialog = MessageBox.Show(Properties.Resources.TextContainErrors, Properties.Resources.TextContainErrorsCapture, MessageBoxButton.YesNo);
126 | switch (dialog)
127 | {
128 | case MessageBoxResult.Yes:
129 | break;
130 |
131 | case MessageBoxResult.No:
132 | e.Cancel = true;
133 | break;
134 | }
135 | }
136 |
137 | public LayoutDocument PanelDocument { get; set; }
138 | public void Update()
139 | {
140 | var panels = DocumentsPane.Children.Where(doc => doc.Content is IEditor);
141 |
142 | foreach (var panel in panels)
143 | {
144 | ((IEditor)panel.Content).Update();
145 | }
146 | }
147 |
148 | public void IsActiveChanged(object sender, EventArgs e)
149 | {
150 | var selectedContent = AllPanels.LayoutDocumentPane.SelectedContent?.Content;
151 |
152 | bool showKv = selectedContent is TextEditorKVPanel;
153 | bool showLua = selectedContent is TextEditorLUAPanel;
154 | if (selectedContent is EditorsCollectionPanel)
155 | {
156 | var content = ((EditorsCollectionPanel)selectedContent).DocumentsPane.SelectedContent.Content;
157 | showKv = content is TextEditorKVPanel;
158 | showLua = content is TextEditorLUAPanel;
159 | }
160 | AllPanels.ObjectEditorForm.ShowEditorsMenu(showKv, showLua);
161 | }
162 |
163 |
164 | }
165 | }
166 |
--------------------------------------------------------------------------------
/KV reloaded/TokenAnalizer.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 |
4 | namespace KV_reloaded
5 | {
6 | public static class TokenAnalizer
7 | {
8 | public static List AnaliseText(string text)
9 | {
10 | List tokens = new List();
11 | int n = 0;
12 | int line = 1;
13 | int symbol = 0;
14 |
15 | while (text.Length > n)
16 | {
17 | var tok = GetKVToken(text, null, ref n, ref line, ref symbol);
18 | if(tok == null)
19 | break;
20 | tokens.Add(tok);
21 | }
22 |
23 | return tokens;
24 | }
25 |
26 | public static KVToken GetKVToken(string text, KVToken parent, ref int n, ref int line, ref int symbol)
27 | {
28 | KVToken kvToken = new KVToken {Parent = parent};
29 | CommentPlace commentPlace = CommentPlace.BeforeKey;
30 | ParserToken tok;
31 | bool key = true;
32 |
33 | tok = GetToken(text, ref n, ref line, ref symbol);
34 | while (true)
35 | {
36 | if (tok.Type == ParserTokenType.NewLine || tok.Type == ParserTokenType.Space || tok.Type == ParserTokenType.Comment)
37 | {
38 | if (kvToken.comments[(int) commentPlace] == null)
39 | kvToken.comments[(int) commentPlace] = "";
40 |
41 | if (tok.Type == ParserTokenType.Comment && tok.Text.IndexOf("//@", StringComparison.Ordinal) == 0)
42 | {
43 | kvToken.SystemComment = SystemComment.AnalyseSystemComment(tok.Text);
44 | }
45 | else
46 | kvToken.comments[(int) commentPlace] += tok.Text;
47 | }
48 | else if(tok.Type == ParserTokenType.Text)
49 | {
50 | if (key)
51 | {
52 | if(string.IsNullOrEmpty(tok.Text))
53 | throw new ErrorParser(KvError.EmptyKey, line, symbol);
54 | kvToken.Key = tok.Text;
55 | commentPlace = CommentPlace.AfterKey;
56 | key = false;
57 | }
58 | else
59 | {
60 | kvToken.Value = tok.Text;
61 | kvToken.Type = KVTokenType.KVsimple;
62 | break;
63 | }
64 | }
65 | else if (tok.Type == ParserTokenType.NewBlock)
66 | {
67 | kvToken.Type = KVTokenType.KVblock;
68 | kvToken.Children = new List();
69 | KVToken childKvToken = GetKVToken(text, kvToken, ref n, ref line, ref symbol);
70 | while (childKvToken != null)
71 | {
72 | kvToken.Children.Add(childKvToken);
73 | if(childKvToken.Type == KVTokenType.Comment)
74 | break;
75 | childKvToken = GetKVToken(text, kvToken, ref n, ref line, ref symbol);
76 | }
77 | return kvToken;
78 | }
79 | else if(tok.Type == ParserTokenType.EndBlock)
80 | {
81 | if (kvToken.comments[(int) commentPlace] == null)
82 | return null;
83 |
84 | kvToken.Type = KVTokenType.Comment;
85 | kvToken.Value = kvToken.comments[(int) commentPlace];
86 | kvToken.comments[(int) commentPlace] = null;
87 | return kvToken;
88 | }
89 | else
90 | {
91 | return null;
92 | }
93 | tok = GetToken(text, ref n, ref line, ref symbol);
94 | }
95 |
96 |
97 | return kvToken;
98 | }
99 |
100 | public static ParserToken GetToken(string text, ref int n, ref int line, ref int symbol)
101 | {
102 | ParserToken tok = new ParserToken();
103 |
104 | if (n >= text.Length)
105 | {
106 | tok.Type = ParserTokenType.Eof;
107 | return tok;
108 | }
109 |
110 | if (SomeUtils.StringUtils.IsSpaceOrTab(text[n]))
111 | {
112 | tok.Type = ParserTokenType.Space;
113 | tok.Text = ParserUtils.SkipSpace(text, ref n, ref line, ref symbol);
114 |
115 | return tok;
116 | }
117 |
118 | switch (text[n])
119 | {
120 | case '\n':
121 | tok.Type = ParserTokenType.NewLine;
122 | tok.Text = "\n";
123 | n++;
124 | line++;
125 | symbol = 0;
126 | return tok;
127 |
128 | case '/':
129 | tok.Type = ParserTokenType.Comment;
130 | tok.Text = ParserUtils.SkipComment(text, ref n, ref line, ref symbol);
131 | return tok;
132 |
133 | case '\"':
134 | tok.Type = ParserTokenType.Text;
135 | tok.Text = ParserUtils.SkipText(text, ref n, ref line, ref symbol);
136 | return tok;
137 |
138 | case '{':
139 | tok.Type = ParserTokenType.NewBlock;
140 | n++;
141 | symbol++;
142 | return tok;
143 |
144 | case '}':
145 | tok.Type = ParserTokenType.EndBlock;
146 | n++;
147 | symbol++;
148 | return tok;
149 | }
150 |
151 | throw new ErrorParser(KvError.UndefinitedSymbols, line, symbol);
152 | }
153 | }
154 | }
--------------------------------------------------------------------------------
/SimpleDota2EditorWPF/ScriptsUtils/KV/KVScriptResourcesKeys.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 | text/microsoft-resx
110 |
111 |
112 | 2.0
113 |
114 |
115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
119 |
120 |
121 | Base class description
122 |
123 |
124 | Particle description
125 |
126 |
--------------------------------------------------------------------------------
/SimpleDota2EditorWPF/ScriptsUtils/KV/KVScriptResourcesValues.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 | text/microsoft-resx
110 |
111 |
112 | 2.0
113 |
114 |
115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
119 |
120 |
121 | Ability descr
122 |
123 |
124 | Spell by lua
125 |
126 |
127 | Float
128 |
129 |
130 | Integer
131 |
132 |
--------------------------------------------------------------------------------
/SimpleDota2EditorWPF/Lua.xshd:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 | &<>~!%^*()-+=|\/{}[]:;"' , .?
15 |
16 |
17 | --[[
18 | ]]
19 |
20 |
21 |
22 | --
23 |
24 |
25 |
26 | '
27 | '
28 |
29 |
30 |
31 |
32 | "
33 | "
34 |
35 |
36 |
37 | [[
38 | ]]
39 |
40 |
41 |
42 | (
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
124 |
125 |
126 |
127 |
128 |
129 |
130 |
131 |
132 |
133 |
134 |
135 |
136 |
137 |
138 |
139 | <>~!@%^*()-+=|\#/{}[]:;"' , .?
140 |
141 |
142 |
143 |
144 |
145 |
146 |
147 |
148 |
149 |
150 |
--------------------------------------------------------------------------------
/KV reloaded/ParserUtils.cs:
--------------------------------------------------------------------------------
1 | using System.IO;
2 | using System.Linq;
3 |
4 | namespace KV_reloaded
5 | {
6 | public static class ParserUtils
7 | {
8 | public static string SkipComment(string text, ref int n, ref int line, ref int symbol)
9 | {
10 | int i = n;
11 | n++;
12 | symbol++;
13 | if (text[n] != '/')
14 | throw new ErrorParser(KvError.NotOveredComment, line, symbol);
15 | n++;
16 |
17 | n = SkipComment(text, n);
18 | if (n == text.Length)
19 | return text.Substring(i);
20 | n++;
21 | line++;
22 | symbol = 0;
23 |
24 | return text.Substring(i, n - i);
25 | }
26 |
27 | ///
28 | /// returning end of comment (position '\n' symbol or text.Length)
29 | ///
30 | public static int SkipComment(string text, int offset)
31 | {
32 | int end = FindSymbol(text, '\n', offset);
33 | return (end != -1) ? end : text.Length;
34 | }
35 |
36 | public static string SkipText(string text, ref int n, ref int line, ref int symbol)
37 | {
38 | n++;
39 | symbol++;
40 | int i = n;
41 | while (text[n] != '\"')
42 | {
43 | n++;
44 | symbol++;
45 | }
46 | string str = text.Substring(i, n - i);
47 | n++;
48 | symbol++;
49 |
50 | return str;
51 | }
52 |
53 | public static string SkipSpace(string text, ref int n, ref int line, ref int symbol)
54 | {
55 | int i = n;
56 | symbol = n = SkipSpace(text, n);
57 | return text.Substring(i, n - i);
58 | }
59 |
60 | public static int SkipSpace(string text, int offset)
61 | {
62 | while (offset < text.Length && SomeUtils.StringUtils.IsSpaceOrTab(text[offset]))
63 | {
64 | offset++;
65 | }
66 |
67 | return offset;
68 | }
69 |
70 | public static bool AllBlocksHasPare(string str)
71 | {
72 | return str.Count(s => s == '{') == str.Count(s => s == '}');
73 | }
74 |
75 | public static int FindSymbol(string text, char symbol, int start)
76 | {
77 | int len = text.Length;
78 | while (start < len)
79 | {
80 | if (text[start] == symbol)
81 | {
82 | int symb = thisSymbolInCommentZone(text, start);
83 | if (symb == -1)
84 | return start;
85 | else
86 | start = symb;
87 | }
88 |
89 | start++;
90 | }
91 |
92 | return -1;
93 | }
94 |
95 | ///
96 | /// Getting first prev symbol thruegh comments
97 | ///
98 | public static int GetPositionFirstPrevSymbol(string text, char symbol, int start)
99 | {
100 | if (text.Length <= start)
101 | return -1;
102 | while (start > 0)
103 | {
104 | if (text[start] == symbol)
105 | {
106 | int symb = thisSymbolInCommentZone(text, start);
107 | if (symb == -1)
108 | return start;
109 | else
110 | start = symb;
111 | }
112 |
113 | start--;
114 | }
115 |
116 | return -1;
117 | }
118 |
119 | ///
120 | /// Getting first next symbol thruegh comments
121 | ///
122 | public static int GetPositionFirstNextSymbol(string text, char symbol, int start)
123 | {
124 | if (text.Length <= start)
125 | return -1;
126 | int len = text.Length;
127 | while (start < len)
128 | {
129 | if (text[start] == symbol)
130 | {
131 | int symb = thisSymbolInCommentZone(text, start);
132 | if (symb == -1)
133 | break;
134 | else if ((symb = SkipComment(text, symb)) != len)
135 | start = symb;
136 | else
137 | return -1;
138 | }
139 |
140 | start++;
141 | }
142 |
143 | return start;
144 | }
145 |
146 | ///
147 | /// If it in comment zone - returns start of comment, else - "-1"
148 | ///
149 | public static int thisSymbolInCommentZone(string text, int symbPos)
150 | {
151 | while (symbPos > 0 && symbPos < text.Length)
152 | {
153 | if (text[symbPos] == '/' && text[symbPos-1] == '/')
154 | return symbPos - 1;
155 | else if (text[symbPos] == '\n')
156 | return -1;
157 |
158 | symbPos--;
159 | }
160 |
161 | return -1;
162 | }
163 |
164 | public static string GetKeyText(string text, int offset)
165 | {
166 | int pos = GetPositionFirstPrevSymbol(text, '\n', offset);
167 | string line = text.Substring(pos + 1, offset - pos);
168 |
169 | int posStart = GetPositionFirstNextSymbol(line, '\"', 0);
170 | pos = GetPositionFirstNextSymbol(line, '\"', posStart + 1);
171 |
172 | return line.Substring(posStart + 1, pos - posStart - 1);
173 | }
174 |
175 | ///
176 | /// true - значит это ключ
177 | /// false - это значение
178 | /// null - это ни ключ, ни значение. Неопределенно
179 | ///
180 | public static bool? ItsKey(string text, int offset)
181 | {
182 | int pos = GetPositionFirstPrevSymbol(text, '\n', offset);
183 | int localOfsset = offset - pos;
184 | string line = text.Substring(pos + 1, localOfsset);
185 |
186 | pos = GetPositionFirstNextSymbol(line, '\"', 0);
187 | if (pos == -1)
188 | return null;
189 | if (pos + 1 >= line.Length)
190 | return true;
191 | pos = GetPositionFirstNextSymbol(line, '\"', pos + 1);
192 | if (pos == -1)
193 | return true;
194 |
195 | pos = GetPositionFirstNextSymbol(line, '\"', pos + 1);
196 | if (pos == -1 || pos == localOfsset)
197 | return null;
198 | pos = GetPositionFirstNextSymbol(line, '\"', pos + 1);
199 | if (pos == -1)
200 | return false;
201 | if (pos < localOfsset)
202 | return null;
203 | else
204 | return false;
205 |
206 | return null;
207 | }
208 |
209 | ///
210 | /// Возвращает текст ключа блока, который содержит этот offset
211 | /// Если это корень, то возвращается пустая строка
212 | /// Null если есть ошибка
213 | ///
214 | public static string GetOwnerKeyBlockText(string text, int offset)
215 | {
216 | int pos = GetPositionFirstPrevSymbol(text, '{', offset);
217 | if (pos == -1) return "";
218 | pos = GetPositionFirstPrevSymbol(text, '\"', pos);
219 | if (pos == -1) return null;
220 | int posStart = GetPositionFirstPrevSymbol(text, '\"', pos - 1);
221 | if (posStart == -1) return null;
222 | if (posStart + 1 >= pos) return null;
223 |
224 | return text.Substring(posStart + 1, pos - posStart - 1);
225 | }
226 |
227 | public static bool ThisPositionStartOfComment(string text, int offset)
228 | {
229 | return offset + 1 <= text.Length
230 | && text[offset] == '/'
231 | && text[offset + 1] == '/';
232 | }
233 | }
234 | }
--------------------------------------------------------------------------------
/KVGridUIWPF/KVGridUIWPF.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {E8420BB9-95C6-448A-B11C-88552D073C00}
8 | WinExe
9 | Properties
10 | KVGridUIWPF
11 | KVGridUIWPF
12 | v4.6.1
13 | 512
14 | {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
15 | 4
16 | true
17 |
18 |
19 | AnyCPU
20 | true
21 | full
22 | false
23 | bin\Debug\
24 | DEBUG;TRACE
25 | prompt
26 | 4
27 |
28 |
29 | AnyCPU
30 | pdbonly
31 | true
32 | bin\Release\
33 | TRACE
34 | prompt
35 | 4
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 | 4.0
48 |
49 |
50 |
51 |
52 |
53 | ..\packages\Extended.Wpf.Toolkit.2.9\lib\net40\Xceed.Wpf.AvalonDock.dll
54 | True
55 |
56 |
57 | ..\packages\Extended.Wpf.Toolkit.2.9\lib\net40\Xceed.Wpf.AvalonDock.Themes.Aero.dll
58 | True
59 |
60 |
61 | ..\packages\Extended.Wpf.Toolkit.2.9\lib\net40\Xceed.Wpf.AvalonDock.Themes.Metro.dll
62 | True
63 |
64 |
65 | ..\packages\Extended.Wpf.Toolkit.2.9\lib\net40\Xceed.Wpf.AvalonDock.Themes.VS2010.dll
66 | True
67 |
68 |
69 | ..\packages\Extended.Wpf.Toolkit.2.9\lib\net40\Xceed.Wpf.DataGrid.dll
70 | True
71 |
72 |
73 | ..\packages\Extended.Wpf.Toolkit.2.9\lib\net40\Xceed.Wpf.Toolkit.dll
74 | True
75 |
76 |
77 |
78 |
79 | MSBuild:Compile
80 | Designer
81 |
82 |
83 | Designer
84 | MSBuild:Compile
85 |
86 |
87 | Designer
88 | MSBuild:Compile
89 |
90 |
91 | Designer
92 | MSBuild:Compile
93 |
94 |
95 | Designer
96 | MSBuild:Compile
97 |
98 |
99 | MSBuild:Compile
100 | Designer
101 |
102 |
103 | App.xaml
104 | Code
105 |
106 |
107 | KVGridItem_TextText.xaml
108 |
109 |
110 | KVSFITextBox.xaml
111 |
112 |
113 |
114 | KVGrid.xaml
115 |
116 |
117 | KVGridBlock.xaml
118 |
119 |
120 |
121 |
122 |
123 |
124 | MainWindow.xaml
125 | Code
126 |
127 |
128 |
129 |
130 | Code
131 |
132 |
133 | True
134 | True
135 | Resources.resx
136 |
137 |
138 | True
139 | Settings.settings
140 | True
141 |
142 |
143 | ResXFileCodeGenerator
144 | Resources.Designer.cs
145 |
146 |
147 |
148 | SettingsSingleFileGenerator
149 | Settings.Designer.cs
150 |
151 |
152 |
153 |
154 |
155 |
156 |
157 |
158 | {AC78AC0C-F24C-440C-89DC-AF8DA50CCC13}
159 | SplitContainer
160 |
161 |
162 |
163 |
164 |
171 |
--------------------------------------------------------------------------------
/SimpleDota2EditorWPF/Panels/KV/OffsetColorizer.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Diagnostics.CodeAnalysis;
3 | using System.Windows.Media;
4 | using ICSharpCode.AvalonEdit.Document;
5 | using ICSharpCode.AvalonEdit.Rendering;
6 |
7 | namespace SimpleDota2EditorWPF.Panels.KV
8 | {
9 | public class OffsetColorizer : DocumentColorizingTransformer
10 | {
11 | public string tempText;
12 | private SolidColorBrush[] brushes;
13 | private SolidColorBrush sameSelectionsBrush;
14 | public string selectedText;
15 |
16 | public OffsetColorizer()
17 | {
18 | Update();
19 | }
20 |
21 | public void Update()
22 | {
23 | brushes = new SolidColorBrush[6];
24 | brushes[(int)KV_STYLES.STYLE_DEFAULT] = new SolidColorBrush((Color)ColorConverter.ConvertFromString(DataBase.Settings.HighSetts.DefaultWordColor));
25 | brushes[(int)KV_STYLES.STYLE_COMMENT] = new SolidColorBrush((Color)ColorConverter.ConvertFromString(DataBase.Settings.HighSetts.CommentColor));
26 | brushes[(int)KV_STYLES.STYLE_KVBLOCK] = new SolidColorBrush((Color)ColorConverter.ConvertFromString(DataBase.Settings.HighSetts.KVBlockColor));
27 | brushes[(int)KV_STYLES.STYLE_KEY] = new SolidColorBrush((Color)ColorConverter.ConvertFromString(DataBase.Settings.HighSetts.KeyColor));
28 | brushes[(int)KV_STYLES.STYLE_VALUE_STRING] = new SolidColorBrush((Color)ColorConverter.ConvertFromString(DataBase.Settings.HighSetts.ValueStringColor));
29 | brushes[(int)KV_STYLES.STYLE_VALUE_NUMBER] = new SolidColorBrush((Color)ColorConverter.ConvertFromString(DataBase.Settings.HighSetts.ValueNumberColor));
30 |
31 | sameSelectionsBrush = new SolidColorBrush(Colors.Blue);
32 | sameSelectionsBrush.Opacity = 0.5;
33 | }
34 |
35 | protected override void ColorizeLine(DocumentLine line)
36 | {
37 | if (line.Length == 0)
38 | return;
39 |
40 | try
41 | {
42 | var pos = line.Offset;
43 | var endPos = line.EndOffset;
44 | bool key = true; // Ожидается, что будет далее, ключ(true) или значение(false)
45 |
46 | var ch = tempText[pos];
47 | colorizeSelectedWordInLine(tempText.Substring(pos, line.Length), pos);
48 | while (pos < endPos)
49 | {
50 | ch = tempText[pos];
51 | if (!SomeUtils.StringUtils.IsSpaceOrTab(ch) || ch != '\n')
52 | switch (ch)
53 | {
54 | case '\"':
55 | int end = nextCharThroughIs(tempText, pos, '\"');
56 | if (end == -1)
57 | {
58 | ChangeLinePart(pos, endPos + 1, element => element.TextRunProperties.SetForegroundBrush(
59 | brushes[key ? (int)KV_STYLES.STYLE_KEY : (int)KV_STYLES.STYLE_VALUE_STRING]));
60 | return;
61 | }
62 |
63 | int isBlock = nextCharThroughIs(tempText, end + 1, '{');
64 | if (isBlock != -1)
65 | {
66 | key = true;
67 | if (end > endPos) end = endPos;
68 | ChangeLinePart(pos, end + 1, element => element.TextRunProperties.SetForegroundBrush(
69 | brushes[(int)KV_STYLES.STYLE_KVBLOCK]));
70 | pos = end;
71 | }
72 | else
73 | {
74 | string str = tempText.Substring(pos + 1, end - (pos + 1));
75 | int style = 0;
76 | if (SomeUtils.StringUtils.IsDigit(str))
77 | style = (int)KV_STYLES.STYLE_VALUE_NUMBER;
78 | else
79 | style = key ? (int)KV_STYLES.STYLE_KEY : (int)KV_STYLES.STYLE_VALUE_STRING;
80 |
81 | if (end > endPos) end = endPos;
82 | ChangeLinePart(pos, end + 1, element => element.TextRunProperties.SetForegroundBrush(
83 | brushes[style]));
84 | pos = end;
85 | key = !key;
86 | }
87 | break;
88 |
89 | case '/':
90 | if (pos + 1 >= tempText.Length)
91 | return;
92 | if (tempText[pos + 1] != '/')
93 | break;
94 |
95 | ChangeLinePart(pos, endPos, element => element.TextRunProperties.SetForegroundBrush(
96 | brushes[(int)KV_STYLES.STYLE_COMMENT]));
97 | return;
98 | break;
99 |
100 | case '{':
101 | case '}':
102 | ChangeLinePart(pos, pos + 1, element => element.TextRunProperties.SetForegroundBrush(
103 | brushes[(int)KV_STYLES.STYLE_DEFAULT]));
104 | break;
105 | }
106 |
107 | pos++;
108 | }
109 | }
110 | catch (Exception ex)
111 | {
112 | //Console.WriteLine(@"Error - " + ex.Message);
113 |
114 | }
115 | }
116 |
117 | private void colorizeSelectedWordInLine(string line, int offset)
118 | {
119 | if (String.IsNullOrWhiteSpace(selectedText) || String.IsNullOrWhiteSpace(line))
120 | return;
121 |
122 | int i = line.IndexOf(selectedText, StringComparison.Ordinal);
123 | int end = 0;
124 | while (i != -1)
125 | {
126 | end = i + selectedText.Length;
127 | i += offset;
128 |
129 | ChangeLinePart(i, end + offset, element => element.TextRunProperties.SetBackgroundBrush(
130 | sameSelectionsBrush));
131 |
132 | if (line.Length <= end)
133 | return;
134 |
135 | line = line.Substring(end);
136 |
137 | offset += end;
138 | i = line.IndexOf(selectedText, StringComparison.Ordinal);
139 | }
140 |
141 | }
142 |
143 | [SuppressMessage("ReSharper", "InconsistentNaming")]
144 | public enum KV_STYLES
145 | {
146 | STYLE_DEFAULT,
147 | STYLE_KEY,
148 | STYLE_KVBLOCK,
149 | STYLE_VALUE_NUMBER,
150 | STYLE_VALUE_STRING,
151 | STYLE_COMMENT,
152 | }
153 |
154 | private int nextCharThroughIs(string str, int pos, char target)
155 | {
156 | int n = pos;
157 | while (n < str.Length)
158 | {
159 | switch (str[n])
160 | {
161 | case '{':
162 | if (target == '{')
163 | return n;
164 | break;
165 |
166 | case '/':
167 | while (str[n] != '\n')
168 | {
169 | n++;
170 | }
171 | break;
172 |
173 | case '\"':
174 | if (target == '{')
175 | return -1;
176 | n++;
177 | if (n >= str.Length)
178 | return -1;
179 |
180 | while (str[n] != '\"')
181 | {
182 | n++;
183 | if (n >= str.Length)
184 | return -1;
185 | }
186 | if (target == '\"')
187 | return n;
188 | break;
189 | }
190 |
191 | n++;
192 | }
193 |
194 | return -1;
195 | }
196 |
197 |
198 | }
199 | }
--------------------------------------------------------------------------------
/KVGridUIWPF/Items/KVGridBlock.xaml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Windows;
5 | using System.Windows.Controls;
6 | using System.Windows.Media;
7 |
8 | namespace KVGridUIWPF
9 | {
10 | ///
11 | /// Логика взаимодействия для KVGridBlock.xaml
12 | ///
13 | public partial class KVGridBlock : UserControl, KVGridItemInterface
14 | {
15 | public KVGridBlock()
16 | {
17 | InitConstructor(-1);
18 | }
19 |
20 | public KVGridBlock(int id = -1)
21 | {
22 | InitConstructor(id);
23 | }
24 |
25 | private void InitConstructor(int id)
26 | {
27 | this.Id = id;
28 | kvItems = new List();
29 | ItemType = ItemTypes.Block;
30 |
31 | InitializeComponent();
32 |
33 | kvsfiTextBoxKey.OnActivateClick += select_Click;
34 | kvsfiTextBoxKey.OnTextChanged += KeyTextChanged;
35 | }
36 |
37 | private void KeyTextChanged(string oldText, string newText)
38 | {
39 | OnTextChanged?.Invoke(this, oldText, newText, KVType.Key);
40 | }
41 |
42 | ///
43 | /// Hides Plus/Minus and Main key controls
44 | ///
45 | public void HideKVBlockControls(bool hide)
46 | {
47 | if (hide)
48 | {
49 | Grid1.ColumnDefinitions[0].Width = new GridLength(0);
50 | Grid1.RowDefinitions[0].Height = new GridLength(0);
51 | }
52 | else
53 | {
54 | Grid1.ColumnDefinitions[0].Width = new GridLength(1, GridUnitType.Star);
55 | Grid1.RowDefinitions[0].Height = new GridLength(1, GridUnitType.Star);
56 | }
57 | }
58 |
59 | public KVGridItemInterface AddItem(KVGrid owner, KVGridItemInterface item, int position)
60 | {
61 | if (item == null) return null;
62 |
63 | if (item.Id == -1)
64 | item.Id = owner.GetMyId();
65 | item.ParentBlock = this;
66 | item.GridOwner = owner;
67 | if (position == -1)
68 | {
69 | kvItems.Add(item);
70 | position = kvItems.Count - 1;
71 | Grid2.RowDefinitions.Add(new RowDefinition());
72 | }
73 | else
74 | {
75 | kvItems.Insert(position, item);
76 | Grid2.RowDefinitions.Add(new RowDefinition());
77 | for (int i = position; i < Grid2.Children.Count; i++)
78 | {
79 | Grid2.Children[i].SetValue(Grid.RowProperty, i + 1);
80 | //Grid2.RowDefinitions[i].Height = GridLength.Auto;
81 | }
82 | }
83 | var ctrl = ((UserControl)item);
84 |
85 |
86 | ctrl.HorizontalAlignment = HorizontalAlignment.Stretch;
87 | ctrl.VerticalAlignment = VerticalAlignment.Top;
88 | ctrl.SetValue(Grid.ColumnProperty, 1);
89 | ctrl.SetValue(Grid.RowProperty, position);
90 | Grid2.Children.Insert(position, ctrl);
91 | Grid2.RowDefinitions[position].Height = GridLength.Auto;
92 |
93 | return item;
94 | }
95 |
96 | public void RemoveItem(KVGridItemInterface item, bool disposeItem)
97 | {
98 | if (item == null) return;
99 |
100 | if (GridOwner.SelectedItem == item)
101 | GridOwner.SelectedItem = null;
102 |
103 | int id = Items.IndexOf(item);
104 | Items.Remove(item);
105 | Grid2.Children.Remove((UserControl)item);
106 |
107 | for (int i = id; i < Grid2.Children.Count; i++)
108 | {
109 | Grid2.Children[i].SetValue(Grid.RowProperty, i);
110 | }
111 | Grid2.RowDefinitions.RemoveAt(Grid2.RowDefinitions.Count - 1);
112 | }
113 |
114 | public void MoveItemTo(KVGridItemInterface item, int index)
115 | {
116 | //todo Oplkill wpf
117 | if (!Equals(item.ParentBlock, this)) return;
118 |
119 | bool selectedItem = GridOwner.SelectedItem == item;
120 | RemoveItem(item, false);
121 | if (index >= Items.Count)
122 | Items.Add(item);
123 | else
124 | Items.Insert(index, item);
125 |
126 | if (selectedItem)
127 | GridOwner.SelectedItem = item;
128 | }
129 |
130 | public KVGridItemInterface FindItem(string key, string value)
131 | {
132 | return Items.FirstOrDefault(item => item.KeyText == key && item.ValueText == value);
133 | }
134 |
135 | public KVGridItemInterface FindItemId(int id)
136 | {
137 | if (this.Id == id) return this;
138 |
139 | foreach (var item in Items)
140 | {
141 | if (item.Id == id) return item;
142 |
143 | if (item is KVGridBlock)
144 | {
145 | var itemTemp = ((KVGridBlock)item).FindItemId(id);
146 | if (itemTemp != null)
147 | return itemTemp;
148 | }
149 | }
150 |
151 | return null;
152 | }
153 |
154 | ///
155 | /// Swapping items only if they both in this block
156 | ///
157 | public void SwapItems(KVGridItemInterface item1, KVGridItemInterface item2)
158 | {
159 | if (!Items.Contains(item1) || !Items.Contains(item2)) return;
160 |
161 | int index1 = Items.IndexOf(item1);
162 | int index2 = Items.IndexOf(item2);
163 |
164 | Items[index1] = item2;
165 | Items[index2] = item1;
166 |
167 | Grid2.Children[index1].SetValue(Grid.RowProperty, index2);
168 | Grid2.Children[index2].SetValue(Grid.RowProperty, index1);
169 | }
170 |
171 | private void buttonCollapse_Click(object sender, EventArgs e)
172 | {
173 | select_Click(sender, e);
174 |
175 | if (collapsed)
176 | {
177 | collapsed = false;
178 | Grid1.RowDefinitions[1].Height = new GridLength(1, GridUnitType.Star);
179 | buttonCollapse.Content = @"-";
180 | }
181 | else
182 | {
183 | collapsed = true;
184 | Grid1.RowDefinitions[1].Height = new GridLength(0);
185 | buttonCollapse.Content = @"+";
186 | }
187 | }
188 |
189 | private void select_Click(object sender, EventArgs e)
190 | {
191 | GridOwner.SelectedItem = this;
192 | }
193 |
194 |
195 | #region variables
196 |
197 |
198 |
199 | public bool Selected
200 | {
201 | get
202 | {
203 | //todo Oplkill wpf
204 | //return splitContainer1.BackColor != Control.DefaultBackColor;
205 | return false;
206 | }
207 | set
208 | {
209 | //todo Oplkill wpf
210 | //if (this.Selected == value) return;
211 |
212 | //if (value)
213 | //{
214 | // splitContainer1.BackColor = Color.DarkBlue;
215 | // //GridOwner.SelectedItem = this;
216 | //}
217 | //else
218 | //{
219 | // splitContainer1.BackColor = Control.DefaultBackColor;
220 | // //GridOwner.SelectedItem = null;
221 | //}
222 | }
223 | }
224 |
225 | public int Id { get; set; }
226 | public KVGrid.TextChangedFunc OnTextChanged { get; set; }
227 |
228 | public int ItemHeight { get; private set; }
229 | public KVGridBlock ParentBlock { get; set; }
230 | public ItemTypes ItemType { get; private set; }
231 | ///
232 | /// KVgrid owner
233 | ///
234 | public KVGrid GridOwner { get; set; }
235 |
236 | public string KeyText
237 | {
238 | get { return kvsfiTextBoxKey.Text; }
239 | set { kvsfiTextBoxKey.Text = value; }
240 | }
241 | public string ValueText { get { return null; } set { } }
242 | public List Items => kvItems;
243 |
244 | private List kvItems;
245 | private bool collapsed;
246 |
247 | #endregion
248 | }
249 | }
250 |
--------------------------------------------------------------------------------