Skip to content

Commit 3a8c24f

Browse files
committed
Merge remote-tracking branch 'upstream/master'
2 parents 58b4ff7 + 5595e27 commit 3a8c24f

File tree

8 files changed

+91
-37
lines changed

8 files changed

+91
-37
lines changed

docs/images/mapeditor.jpg

-33.1 KB
Loading

src/TSMapEditor/CCEngine/CCFileManager.cs

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using System;
33
using System.Collections.Generic;
44
using System.IO;
5+
using TSMapEditor.Settings;
56

67
namespace TSMapEditor.CCEngine
78
{
@@ -143,7 +144,8 @@ private void AddMix(MixFile mixFile)
143144
{
144145
mixFiles.Add(mixFile);
145146

146-
// Logger.Log("Registering " + mixFile.GetEntries().Count + " file entries from " + Path.GetFileName(mixFile.FilePath));
147+
if (UserSettings.Instance.LogFileLoading)
148+
Logger.Log("Registering " + mixFile.GetEntries().Count + " file entries from " + Path.GetFileName(mixFile.FilePath));
147149

148150
foreach (MixFileEntry fileEntry in mixFile.GetEntries())
149151
{
@@ -243,14 +245,17 @@ public string FindFileFromDirectories(string fileName)
243245

244246
public byte[] LoadFile(string name)
245247
{
246-
// Logger.Log("Loading file " + name);
248+
if (UserSettings.Instance.LogFileLoading)
249+
Logger.Log("Loading file " + name);
247250

248251
foreach (string searchDirectory in searchDirectories)
249252
{
250253
string looseFilePath = Path.Combine(searchDirectory, name);
251254
if (File.Exists(looseFilePath))
252255
{
253-
// Logger.Log(" File found from " + searchDirectory);
256+
if (UserSettings.Instance.LogFileLoading)
257+
Logger.Log(" File found from " + searchDirectory);
258+
254259
return File.ReadAllBytes(looseFilePath);
255260
}
256261
}
@@ -259,11 +264,15 @@ public byte[] LoadFile(string name)
259264

260265
if (fileLocationInfos.TryGetValue(id, out FileLocationInfo value))
261266
{
262-
// Logger.Log(" File found from " + Path.GetFileName(value.MixFile.FilePath));
267+
if (UserSettings.Instance.LogFileLoading)
268+
Logger.Log(" File found from " + Path.GetFileName(value.MixFile.FilePath));
269+
263270
return value.MixFile.GetSingleFileData(value.Offset, value.Size);
264271
}
265272

266-
// Logger.Log(" FAILED to find file: " + name);
273+
if (UserSettings.Instance.LogFileLoading)
274+
Logger.Log(" FAILED to find file: " + name);
275+
267276
return null;
268277
}
269278

src/TSMapEditor/Config/Default/ScriptActions.ini

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,14 @@ ParamType=Quarry
1818
Option0=0,N/A (Cancel)
1919
Option1=1,Anything
2020
Option2=2,Structures
21-
Option3=3,Harvesters
21+
Option3=3,Tiberium Processing Objects
2222
Option4=4,Infantry
2323
Option5=5,Vehicles
2424
Option6=6,Factories
2525
Option7=7,Base Defenses
2626
Option8=8,Base Threats
2727
Option9=9,Power Plants
28+
Option10=10,Harvesters (Vinifera)
2829

2930
[AttackWaypoint]
3031
Name=Attack Waypoint
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
; C&C World-Altering Editor (WAE)
2+
; https://github.com/CnCNet/WorldAlteringEditor
3+
4+
; Default settings file.
5+
; This file is loaded as a base settings INI when Settings.ini does not exist in the editor's folder.
6+
7+
; It is a good place for giving defaults to special settings that are not available in the user-interface.
8+
; That way, users checking out the settings INI can see these hidden options.
9+
10+
11+
[Display]
12+
ConserveVRAM=no ; If set, the editor skips loading rarely-used frames of certain graphics
13+
14+
[General]
15+
SidebarWidth=250 ; Width of the editor's sidebar.
16+
AutoSaveInterval=300 ; Seconds between saving a copy of the currently open map to the editor's directory.
17+
MultithreadedTextureLoading=yes ; Set to "no" to disable multi-threaded loading of textures. Can be useful for debugging asset loading issues.
18+
19+
LogFileLoading=no ; If enabled, the editor will log all discovered and loaded files to the logfile.
20+
; Can be useful to track which MIX files the editor loads different files from.
21+
; Note: will result in big log files when enabled.
22+
23+
[MapView]
24+
MapWideOverlayOpacity=50 ; Opacity level of the map-wide overlay. Must be between 0 (completely transparent) and 255 (completely opaque)
25+

src/TSMapEditor/Config/Translations/en/Translation_en.ini

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1457,13 +1457,14 @@ ScriptAction.Attack Quarry.Description=Attack the target type (quarry) and repea
14571457
ScriptAction.Attack Quarry.Option0.PresetText=N/A (Cancel)
14581458
ScriptAction.Attack Quarry.Option1.PresetText=Anything
14591459
ScriptAction.Attack Quarry.Option2.PresetText=Structures
1460-
ScriptAction.Attack Quarry.Option3.PresetText=Harvesters
1460+
ScriptAction.Attack Quarry.Option3.PresetText=Tiberium Processing Objects
14611461
ScriptAction.Attack Quarry.Option4.PresetText=Infantry
14621462
ScriptAction.Attack Quarry.Option5.PresetText=Vehicles
14631463
ScriptAction.Attack Quarry.Option6.PresetText=Factories
14641464
ScriptAction.Attack Quarry.Option7.PresetText=Base Defenses
14651465
ScriptAction.Attack Quarry.Option8.PresetText=Base Threats
14661466
ScriptAction.Attack Quarry.Option9.PresetText=Power Plants
1467+
ScriptAction.Attack Quarry.Option10.PresetText=Harvesters (Vinifera)
14671468
ScriptAction.Attack Waypoint.Name=Attack Waypoint
14681469
ScriptAction.Attack Waypoint.Description=Attack the object if present or the cell at the given waypoint. Action will change accordingly if a structure is present and the team member has attributes of Infiltrate or Engineer or Agent or C4.
14691470
ScriptAction.Go Berzerk.Name=Go Berzerk

src/TSMapEditor/Settings/UserSettings.cs

Lines changed: 29 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using Rampastring.Tools;
22
using System;
3+
using System.IO;
34
using System.Threading.Tasks;
45

56
namespace TSMapEditor.Settings
@@ -17,7 +18,16 @@ public UserSettings()
1718

1819
Instance = this;
1920

20-
UserSettingsIni = new IniFile(Environment.CurrentDirectory + "/MapEditorSettings.ini");
21+
string path = Path.Combine(Environment.CurrentDirectory, "MapEditorSettings.ini");
22+
if (File.Exists(path))
23+
{
24+
UserSettingsIni = new IniFile(path);
25+
}
26+
else
27+
{
28+
UserSettingsIni = new IniFile(Path.Combine(Environment.CurrentDirectory, "Config", "DefaultSettings.ini"));
29+
UserSettingsIni.FileName = path;
30+
}
2131

2232
settings = new IINILoadable[]
2333
{
@@ -40,6 +50,7 @@ public UserSettings()
4050
SidebarWidth,
4151

4252
MultithreadedTextureLoading,
53+
LogFileLoading,
4354

4455
GameDirectory,
4556
LastScenarioPath,
@@ -78,30 +89,31 @@ public async Task SaveSettingsAsync()
7889

7990
private readonly IINILoadable[] settings;
8091

81-
public IntSetting TargetFPS = new IntSetting(Display, "TargetFPS", 240);
92+
public IntSetting TargetFPS = new IntSetting(Display, nameof(TargetFPS), 240);
8293
public IntSetting GraphicsLevel = new IntSetting(Display, nameof(GraphicsLevel), 1);
83-
public IntSetting ResolutionWidth = new IntSetting(Display, "ResolutionWidth", -1);
84-
public IntSetting ResolutionHeight = new IntSetting(Display, "ResolutionHeight", -1);
85-
public DoubleSetting RenderScale = new DoubleSetting(Display, "RenderScale", 1.0);
86-
public BoolSetting Borderless = new BoolSetting(Display, "Borderless", false);
87-
public BoolSetting FullscreenWindowed = new BoolSetting(Display, "FullscreenWindowed", false);
88-
public BoolSetting ConserveVRAM = new BoolSetting(Display, "ConserveVRAM", false);
94+
public IntSetting ResolutionWidth = new IntSetting(Display, nameof(ResolutionWidth), -1);
95+
public IntSetting ResolutionHeight = new IntSetting(Display, nameof(ResolutionHeight), -1);
96+
public DoubleSetting RenderScale = new DoubleSetting(Display, nameof(RenderScale), 1.0);
97+
public BoolSetting Borderless = new BoolSetting(Display, nameof(Borderless), false);
98+
public BoolSetting FullscreenWindowed = new BoolSetting(Display, nameof(FullscreenWindowed), false);
99+
public BoolSetting ConserveVRAM = new BoolSetting(Display, nameof(ConserveVRAM), false);
89100

90101
public IntSetting ScrollRate = new IntSetting(MapView, nameof(ScrollRate), 15);
91-
public IntSetting MapWideOverlayOpacity = new IntSetting(MapView, "MapWideOverlayOpacity", 50);
102+
public IntSetting MapWideOverlayOpacity = new IntSetting(MapView, nameof(MapWideOverlayOpacity), 50);
92103

93-
public StringSetting Theme = new StringSetting(General, "Theme", "Default");
94-
public BoolSetting UseBoldFont = new BoolSetting(General, "UseBoldFont", false);
95-
public BoolSetting SmartScriptActionCloning = new BoolSetting(General, "SmartScriptActionCloning", true);
96-
public IntSetting AutoSaveInterval = new IntSetting(General, "AutoSaveInterval", 300);
97-
public IntSetting SidebarWidth = new IntSetting(General, "SidebarWidth", 350);
104+
public StringSetting Theme = new StringSetting(General, nameof(Theme), "Default");
105+
public BoolSetting UseBoldFont = new BoolSetting(General, nameof(UseBoldFont), false);
106+
public BoolSetting SmartScriptActionCloning = new BoolSetting(General, nameof(SmartScriptActionCloning), true);
107+
public IntSetting AutoSaveInterval = new IntSetting(General, nameof(AutoSaveInterval), 300);
108+
public IntSetting SidebarWidth = new IntSetting(General, nameof(SidebarWidth), 350);
98109

99-
public BoolSetting MultithreadedTextureLoading = new BoolSetting(General, "MultithreadedTextureLoading", true);
110+
public BoolSetting MultithreadedTextureLoading = new BoolSetting(General, nameof(MultithreadedTextureLoading), true);
111+
public BoolSetting LogFileLoading = new BoolSetting(General, nameof(LogFileLoading), false);
100112

101-
public StringSetting GameDirectory = new StringSetting(General, "GameDirectory", string.Empty);
113+
public StringSetting GameDirectory = new StringSetting(General, nameof(GameDirectory), string.Empty);
102114
public StringSetting LastScenarioPath = new StringSetting(General, nameof(LastScenarioPath), "Maps/Custom/");
103115

104-
public StringSetting TextEditorPath = new StringSetting(General, "TextEditorPath", string.Empty);
116+
public StringSetting TextEditorPath = new StringSetting(General, nameof(TextEditorPath), string.Empty);
105117

106118
public StringSetting Language = new StringSetting(General, nameof(Language), string.Empty);
107119

src/TSMapEditor/TSMapEditor.csproj

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@
3838
<Compile Remove="Config\Scripts\Replace Frost With Clear.cs" />
3939
</ItemGroup>
4040
<ItemGroup>
41+
<None Update="Config\DefaultSettings.ini">
42+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
43+
</None>
4144
<None Update="Config\Default\Actions.ini">
4245
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
4346
</None>
@@ -511,7 +514,7 @@
511514
<PackageReference Include="MonoGame.Framework.WindowsDX" Version="3.8.3" />
512515
<PackageReference Include="Rampastring.Tools" Version="2.0.7" />
513516
<PackageReference Include="MonoGame.Content.Builder.Task" Version="3.8.3" />
514-
<PackageReference Include="Rampastring.XNAUI.WindowsDX" Version="3.1.0" />
517+
<PackageReference Include="Rampastring.XNAUI.WindowsDX" Version="3.1.6" />
515518
<PackageReference Include="SixLabors.ImageSharp" Version="2.1.11" />
516519
<PackageReference Include="Westwind.Scripting" Version="1.3.3" />
517520
</ItemGroup>

src/TSMapEditor/UI/IME/IMEHandler.cs

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,11 @@ protected set
4242

4343
public bool CompositionEmpty => string.IsNullOrEmpty(_composition);
4444

45+
/// <summary>
46+
/// Indicates whether an IME event has been received ever. Used to distinguish IME users from non-IME users.
47+
/// </summary>
4548
protected bool IMEEventReceived = false;
49+
4650
protected bool LastActionIMEChatInput = true;
4751

4852
private void OnCompositionChanged(string oldValue, string newValue)
@@ -73,21 +77,12 @@ protected virtual void OnIMETextInput(char character)
7377
{
7478
//Debug.WriteLine($"IME: OnIMETextInput: {character} {(short)character}; IMEFocus is null? {IMEFocus == null}");
7579

76-
IMEEventReceived = true;
7780
LastActionIMEChatInput = true;
7881

7982
if (IMEFocus != null)
8083
{
81-
// Handle ESC
82-
if (character == 27 && CompositionEmpty)
83-
{
84-
IMEFocus.Text = string.Empty;
85-
}
86-
else
87-
{
88-
TextBoxHandleChatInputCallbacks.TryGetValue(IMEFocus, out var handleChatInput);
89-
handleChatInput?.Invoke(character);
90-
}
84+
TextBoxHandleChatInputCallbacks.TryGetValue(IMEFocus, out var handleChatInput);
85+
handleChatInput?.Invoke(character);
9186
}
9287
}
9388

@@ -213,7 +208,15 @@ bool IIMEHandler.HandleEnterKey(XNATextBox sender)
213208
bool IIMEHandler.HandleEscapeKey(XNATextBox sender)
214209
{
215210
//Debug.WriteLine($"IME: HandleEscapeKey: handled: {IMEEventReceived}");
216-
return IMEEventReceived;
211+
212+
// This method disables the ESC handling of the TextBox as long as the user has ever used IME.
213+
// This is because IME users often use ESC to cancel composition. Even if currently the composition is empty,
214+
// the user still expects ESC to cancel composition rather than deleting the whole sentence.
215+
// For example, the user might mistakenly hit ESC key twice to cancel composition -- deleting the whole sentence is definitely a heavy punishment for such a small mistake.
216+
217+
// Note: "!CompositionEmpty => IMEEventReceived" should hold, but just in case
218+
219+
return IMEEventReceived || !CompositionEmpty;
217220
}
218221

219222
void IIMEHandler.OnTextChanged(XNATextBox sender) { }

0 commit comments

Comments
 (0)