mirror of
https://git.do.srb2.org/STJr/UltimateZoneBuilder.git
synced 2024-12-02 08:32:55 +00:00
Merge anotak's optimizations - stage 1
This commit is contained in:
parent
34d1af9446
commit
09b8c27dab
19 changed files with 918 additions and 808 deletions
|
@ -64,7 +64,7 @@ namespace CodeImp.DoomBuilder.Actions
|
||||||
#region ================== Properties
|
#region ================== Properties
|
||||||
|
|
||||||
internal SortedDictionary<string, string> Categories { get { return categories; } }
|
internal SortedDictionary<string, string> Categories { get { return categories; } }
|
||||||
internal Action this[string action] { get { if(actions.ContainsKey(action)) return actions[action]; else throw new ArgumentException("There is no such action \"" + action + "\""); } }
|
internal Action this[string action] { get { if (actions.ContainsKey(action)) return actions[action]; else throw new ArgumentException("There is no such action \"" + action + "\""); } }
|
||||||
public bool IsDisposed { get { return isdisposed; } }
|
public bool IsDisposed { get { return isdisposed; } }
|
||||||
internal bool ExclusiveRequested { get { return exclusiverequested; } }
|
internal bool ExclusiveRequested { get { return exclusiverequested; } }
|
||||||
|
|
||||||
|
@ -98,7 +98,7 @@ namespace CodeImp.DoomBuilder.Actions
|
||||||
internal void Dispose()
|
internal void Dispose()
|
||||||
{
|
{
|
||||||
// Not already disposed?
|
// Not already disposed?
|
||||||
if(!isdisposed)
|
if (!isdisposed)
|
||||||
{
|
{
|
||||||
// Clean up
|
// Clean up
|
||||||
|
|
||||||
|
@ -118,10 +118,10 @@ namespace CodeImp.DoomBuilder.Actions
|
||||||
|
|
||||||
// Find a resource named Actions.cfg
|
// Find a resource named Actions.cfg
|
||||||
string[] resnames = asm.GetManifestResourceNames();
|
string[] resnames = asm.GetManifestResourceNames();
|
||||||
foreach(string rn in resnames)
|
foreach (string rn in resnames)
|
||||||
{
|
{
|
||||||
// Found one?
|
// Found one?
|
||||||
if(rn.EndsWith(ACTIONS_RESOURCE, StringComparison.OrdinalIgnoreCase))
|
if (rn.EndsWith(ACTIONS_RESOURCE, StringComparison.OrdinalIgnoreCase))
|
||||||
{
|
{
|
||||||
// Get a stream from the resource
|
// Get a stream from the resource
|
||||||
Stream actionsdata = asm.GetManifestResourceStream(rn);
|
Stream actionsdata = asm.GetManifestResourceStream(rn);
|
||||||
|
@ -130,7 +130,7 @@ namespace CodeImp.DoomBuilder.Actions
|
||||||
// Load configuration from stream
|
// Load configuration from stream
|
||||||
Configuration cfg = new Configuration();
|
Configuration cfg = new Configuration();
|
||||||
cfg.InputConfiguration(actionsreader.ReadToEnd());
|
cfg.InputConfiguration(actionsreader.ReadToEnd());
|
||||||
if(cfg.ErrorResult)
|
if (cfg.ErrorResult)
|
||||||
{
|
{
|
||||||
string errordesc = "Error in Actions configuration on line " + cfg.ErrorLine + ": " + cfg.ErrorDescription;
|
string errordesc = "Error in Actions configuration on line " + cfg.ErrorLine + ": " + cfg.ErrorDescription;
|
||||||
General.CancelAutoMapLoad();
|
General.CancelAutoMapLoad();
|
||||||
|
@ -142,15 +142,15 @@ namespace CodeImp.DoomBuilder.Actions
|
||||||
{
|
{
|
||||||
// Read the categories structure
|
// Read the categories structure
|
||||||
IDictionary cats = cfg.ReadSetting("categories", new Hashtable());
|
IDictionary cats = cfg.ReadSetting("categories", new Hashtable());
|
||||||
foreach(DictionaryEntry c in cats)
|
foreach (DictionaryEntry c in cats)
|
||||||
{
|
{
|
||||||
// Make the category if not already added
|
// Make the category if not already added
|
||||||
if(!categories.ContainsKey(c.Key.ToString()))
|
if (!categories.ContainsKey(c.Key.ToString()))
|
||||||
categories.Add(c.Key.ToString(), c.Value.ToString());
|
categories.Add(c.Key.ToString(), c.Value.ToString());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Go for all objects in the configuration
|
// Go for all objects in the configuration
|
||||||
foreach(DictionaryEntry a in cfg.Root)
|
foreach (DictionaryEntry a in cfg.Root)
|
||||||
{
|
{
|
||||||
// Get action properties
|
// Get action properties
|
||||||
string shortname = a.Key.ToString();
|
string shortname = a.Key.ToString();
|
||||||
|
@ -158,10 +158,10 @@ namespace CodeImp.DoomBuilder.Actions
|
||||||
bool debugonly = cfg.ReadSetting(a.Key + ".debugonly", false);
|
bool debugonly = cfg.ReadSetting(a.Key + ".debugonly", false);
|
||||||
|
|
||||||
// Not the categories structure?
|
// Not the categories structure?
|
||||||
if(shortname.ToLowerInvariant() != "categories")
|
if (shortname.ToLowerInvariant() != "categories")
|
||||||
{
|
{
|
||||||
// Check if action should be included
|
// Check if action should be included
|
||||||
if(General.DebugBuild || !debugonly)
|
if (General.DebugBuild || !debugonly)
|
||||||
{
|
{
|
||||||
// Create an action
|
// Create an action
|
||||||
CreateAction(cfg, name, shortname);
|
CreateAction(cfg, name, shortname);
|
||||||
|
@ -181,7 +181,7 @@ namespace CodeImp.DoomBuilder.Actions
|
||||||
private void CreateAction(Configuration cfg, string name, string shortname)
|
private void CreateAction(Configuration cfg, string name, string shortname)
|
||||||
{
|
{
|
||||||
// Action does not exist yet?
|
// Action does not exist yet?
|
||||||
if(!actions.ContainsKey(name))
|
if (!actions.ContainsKey(name))
|
||||||
{
|
{
|
||||||
// Read the key from configuration
|
// Read the key from configuration
|
||||||
int key = General.Settings.ReadSetting("shortcuts." + name, -1);
|
int key = General.Settings.ReadSetting("shortcuts." + name, -1);
|
||||||
|
@ -213,21 +213,28 @@ namespace CodeImp.DoomBuilder.Actions
|
||||||
// This binds all methods marked with this attribute
|
// This binds all methods marked with this attribute
|
||||||
private void BindMethods(object obj, Type type)
|
private void BindMethods(object obj, Type type)
|
||||||
{
|
{
|
||||||
if(obj == null)
|
if (obj == null)
|
||||||
General.WriteLogLine("Binding static action methods for class " + type.Name + "...");
|
General.WriteLogLine("Binding static action methods for class " + type.Name + "...");
|
||||||
else
|
else
|
||||||
General.WriteLogLine("Binding action methods for " + type.Name + " object...");
|
General.WriteLogLine("Binding action methods for " + type.Name + " object...");
|
||||||
|
|
||||||
// Go for all methods on obj
|
// Go for all methods on obj
|
||||||
MethodInfo[] methods = type.GetMethods(BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Static);
|
MethodInfo[] methods = type.GetMethods(BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Static);
|
||||||
foreach(MethodInfo m in methods)
|
//foreach(MethodInfo m in methods)
|
||||||
|
int methodsCount = methods.Length;
|
||||||
|
for (int i = 0; i < methodsCount; i++)
|
||||||
{
|
{
|
||||||
|
MethodInfo m = methods[i];
|
||||||
// Check if the method has this attribute
|
// Check if the method has this attribute
|
||||||
ActionAttribute[] attrs = (ActionAttribute[])m.GetCustomAttributes(typeof(BeginActionAttribute), true);
|
ActionAttribute[] attrs = (ActionAttribute[])methods[i].GetCustomAttributes(typeof(BeginActionAttribute), true);
|
||||||
|
|
||||||
|
int attrsCount = attrs.Length;
|
||||||
// Go for all attributes
|
// Go for all attributes
|
||||||
foreach(ActionAttribute a in attrs)
|
//foreach(ActionAttribute a in attrs)
|
||||||
|
for (int j = 0; j < attrsCount; j++)
|
||||||
{
|
{
|
||||||
|
ActionAttribute a = attrs[j];
|
||||||
|
|
||||||
// Create a delegate for this method
|
// Create a delegate for this method
|
||||||
ActionDelegate del = (ActionDelegate)Delegate.CreateDelegate(typeof(ActionDelegate), obj, m);
|
ActionDelegate del = (ActionDelegate)Delegate.CreateDelegate(typeof(ActionDelegate), obj, m);
|
||||||
|
|
||||||
|
@ -235,7 +242,7 @@ namespace CodeImp.DoomBuilder.Actions
|
||||||
string actionname = a.GetFullActionName(type.Assembly);
|
string actionname = a.GetFullActionName(type.Assembly);
|
||||||
|
|
||||||
// Bind method to action
|
// Bind method to action
|
||||||
if(Exists(actionname))
|
if (Exists(actionname))
|
||||||
actions[actionname].BindBegin(del);
|
actions[actionname].BindBegin(del);
|
||||||
else
|
else
|
||||||
throw new ArgumentException("Could not bind " + m.ReflectedType.Name + "." + m.Name + " to action \"" + actionname + "\", that action does not exist! Refer to, or edit Actions.cfg for all available application actions.");
|
throw new ArgumentException("Could not bind " + m.ReflectedType.Name + "." + m.Name + " to action \"" + actionname + "\", that action does not exist! Refer to, or edit Actions.cfg for all available application actions.");
|
||||||
|
@ -243,10 +250,13 @@ namespace CodeImp.DoomBuilder.Actions
|
||||||
|
|
||||||
// Check if the method has this attribute
|
// Check if the method has this attribute
|
||||||
attrs = (ActionAttribute[])m.GetCustomAttributes(typeof(EndActionAttribute), true);
|
attrs = (ActionAttribute[])m.GetCustomAttributes(typeof(EndActionAttribute), true);
|
||||||
|
attrsCount = attrs.Length;
|
||||||
// Go for all attributes
|
// Go for all attributes
|
||||||
foreach(ActionAttribute a in attrs)
|
//foreach (ActionAttribute a in attrs)
|
||||||
|
for (int j = 0; j < attrsCount; j++)
|
||||||
{
|
{
|
||||||
|
ActionAttribute a = attrs[j];
|
||||||
|
|
||||||
// Create a delegate for this method
|
// Create a delegate for this method
|
||||||
ActionDelegate del = (ActionDelegate)Delegate.CreateDelegate(typeof(ActionDelegate), obj, m);
|
ActionDelegate del = (ActionDelegate)Delegate.CreateDelegate(typeof(ActionDelegate), obj, m);
|
||||||
|
|
||||||
|
@ -254,7 +264,7 @@ namespace CodeImp.DoomBuilder.Actions
|
||||||
string actionname = a.GetFullActionName(type.Assembly);
|
string actionname = a.GetFullActionName(type.Assembly);
|
||||||
|
|
||||||
// Bind method to action
|
// Bind method to action
|
||||||
if(Exists(actionname))
|
if (Exists(actionname))
|
||||||
actions[actionname].BindEnd(del);
|
actions[actionname].BindEnd(del);
|
||||||
else
|
else
|
||||||
throw new ArgumentException("Could not bind " + m.ReflectedType.Name + "." + m.Name + " to action \"" + actionname + "\", that action does not exist. Refer to, or edit Actions.cfg for all available application actions.");
|
throw new ArgumentException("Could not bind " + m.ReflectedType.Name + "." + m.Name + " to action \"" + actionname + "\", that action does not exist. Refer to, or edit Actions.cfg for all available application actions.");
|
||||||
|
@ -269,7 +279,7 @@ namespace CodeImp.DoomBuilder.Actions
|
||||||
string actionname = a.GetFullActionName(asm);
|
string actionname = a.GetFullActionName(asm);
|
||||||
|
|
||||||
// Bind delegate to action
|
// Bind delegate to action
|
||||||
if(Exists(actionname))
|
if (Exists(actionname))
|
||||||
actions[actionname].BindBegin(d);
|
actions[actionname].BindBegin(d);
|
||||||
else
|
else
|
||||||
General.ErrorLogger.Add(ErrorType.Warning, "Could not bind delegate for " + d.Method.Name + " to action \"" + a.ActionName + "\" (" + actionname + "), that action does not exist. Refer to, or edit Actions.cfg for all available application actions.");
|
General.ErrorLogger.Add(ErrorType.Warning, "Could not bind delegate for " + d.Method.Name + " to action \"" + a.ActionName + "\" (" + actionname + "), that action does not exist. Refer to, or edit Actions.cfg for all available application actions.");
|
||||||
|
@ -282,7 +292,7 @@ namespace CodeImp.DoomBuilder.Actions
|
||||||
string actionname = a.GetFullActionName(asm);
|
string actionname = a.GetFullActionName(asm);
|
||||||
|
|
||||||
// Bind delegate to action
|
// Bind delegate to action
|
||||||
if(Exists(actionname))
|
if (Exists(actionname))
|
||||||
actions[actionname].BindEnd(d);
|
actions[actionname].BindEnd(d);
|
||||||
else
|
else
|
||||||
General.ErrorLogger.Add(ErrorType.Warning, "Could not bind delegate for " + d.Method.Name + " to action \"" + a.ActionName + "\" (" + actionname + "), that action does not exist. Refer to, or edit Actions.cfg for all available application actions.");
|
General.ErrorLogger.Add(ErrorType.Warning, "Could not bind delegate for " + d.Method.Name + " to action \"" + a.ActionName + "\" (" + actionname + "), that action does not exist. Refer to, or edit Actions.cfg for all available application actions.");
|
||||||
|
@ -305,21 +315,27 @@ namespace CodeImp.DoomBuilder.Actions
|
||||||
// This unbinds all methods marked with this attribute
|
// This unbinds all methods marked with this attribute
|
||||||
private void UnbindMethods(object obj, Type type)
|
private void UnbindMethods(object obj, Type type)
|
||||||
{
|
{
|
||||||
if(obj == null)
|
if (obj == null)
|
||||||
General.WriteLogLine("Unbinding static action methods for class " + type.Name + "...");
|
General.WriteLogLine("Unbinding static action methods for class " + type.Name + "...");
|
||||||
else
|
else
|
||||||
General.WriteLogLine("Unbinding action methods for " + type.Name + " object...");
|
General.WriteLogLine("Unbinding action methods for " + type.Name + " object...");
|
||||||
|
|
||||||
// Go for all methods on obj
|
// Go for all methods on obj
|
||||||
MethodInfo[] methods = type.GetMethods(BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Static);
|
MethodInfo[] methods = type.GetMethods(BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Static);
|
||||||
foreach(MethodInfo m in methods)
|
//foreach (MethodInfo m in methods)
|
||||||
|
int methodsCount = methods.Length;
|
||||||
|
for(int i = 0; i < methodsCount; i++)
|
||||||
{
|
{
|
||||||
|
MethodInfo m = methods[i];
|
||||||
// Check if the method has this attribute
|
// Check if the method has this attribute
|
||||||
ActionAttribute[] attrs = (ActionAttribute[])m.GetCustomAttributes(typeof(BeginActionAttribute), true);
|
ActionAttribute[] attrs = (ActionAttribute[])m.GetCustomAttributes(typeof(BeginActionAttribute), true);
|
||||||
|
|
||||||
// Go for all attributes
|
// Go for all attributes
|
||||||
foreach(ActionAttribute a in attrs)
|
//foreach (ActionAttribute a in attrs)
|
||||||
|
int attrsCount = attrs.Length;
|
||||||
|
for(int j = 0; j < attrsCount; j++)
|
||||||
{
|
{
|
||||||
|
ActionAttribute a = attrs[j];
|
||||||
// Create a delegate for this method
|
// Create a delegate for this method
|
||||||
ActionDelegate del = (ActionDelegate)Delegate.CreateDelegate(typeof(ActionDelegate), obj, m);
|
ActionDelegate del = (ActionDelegate)Delegate.CreateDelegate(typeof(ActionDelegate), obj, m);
|
||||||
|
|
||||||
|
@ -334,8 +350,11 @@ namespace CodeImp.DoomBuilder.Actions
|
||||||
attrs = (ActionAttribute[])m.GetCustomAttributes(typeof(EndActionAttribute), true);
|
attrs = (ActionAttribute[])m.GetCustomAttributes(typeof(EndActionAttribute), true);
|
||||||
|
|
||||||
// Go for all attributes
|
// Go for all attributes
|
||||||
foreach(ActionAttribute a in attrs)
|
//foreach (ActionAttribute a in attrs)
|
||||||
|
attrsCount = attrs.Length;
|
||||||
|
for (int j = 0; j < attrsCount; j++)
|
||||||
{
|
{
|
||||||
|
ActionAttribute a = attrs[j];
|
||||||
// Create a delegate for this method
|
// Create a delegate for this method
|
||||||
ActionDelegate del = (ActionDelegate)Delegate.CreateDelegate(typeof(ActionDelegate), obj, m);
|
ActionDelegate del = (ActionDelegate)Delegate.CreateDelegate(typeof(ActionDelegate), obj, m);
|
||||||
|
|
||||||
|
@ -392,7 +411,7 @@ namespace CodeImp.DoomBuilder.Actions
|
||||||
internal void SaveSettings()
|
internal void SaveSettings()
|
||||||
{
|
{
|
||||||
// Go for all actions
|
// Go for all actions
|
||||||
foreach(KeyValuePair<string, Action> a in actions)
|
foreach (KeyValuePair<string, Action> a in actions)
|
||||||
{
|
{
|
||||||
// Write to configuration
|
// Write to configuration
|
||||||
General.Settings.WriteSetting("shortcuts." + a.Key, a.Value.ShortcutKey);
|
General.Settings.WriteSetting("shortcuts." + a.Key, a.Value.ShortcutKey);
|
||||||
|
@ -402,7 +421,7 @@ namespace CodeImp.DoomBuilder.Actions
|
||||||
// This invokes the Begin and End of the given action
|
// This invokes the Begin and End of the given action
|
||||||
public bool InvokeAction(string actionname)
|
public bool InvokeAction(string actionname)
|
||||||
{
|
{
|
||||||
if(Exists(actionname))
|
if (Exists(actionname))
|
||||||
{
|
{
|
||||||
actions[actionname].Invoke();
|
actions[actionname].Invoke();
|
||||||
return true;
|
return true;
|
||||||
|
@ -418,18 +437,18 @@ namespace CodeImp.DoomBuilder.Actions
|
||||||
internal void ApplyDefaultShortcutKeys()
|
internal void ApplyDefaultShortcutKeys()
|
||||||
{
|
{
|
||||||
// Find actions that have no key set
|
// Find actions that have no key set
|
||||||
foreach(KeyValuePair<string, Action> a in actions)
|
foreach (KeyValuePair<string, Action> a in actions)
|
||||||
{
|
{
|
||||||
// Key set?
|
// Key set?
|
||||||
if(a.Value.ShortcutKey == -1)
|
if (a.Value.ShortcutKey == -1)
|
||||||
{
|
{
|
||||||
// Check if the default key is not already used
|
// Check if the default key is not already used
|
||||||
bool keyused = false;
|
bool keyused = false;
|
||||||
foreach(KeyValuePair<string, Action> d in actions)
|
foreach (KeyValuePair<string, Action> d in actions)
|
||||||
{
|
{
|
||||||
// Check if the keys are the same
|
// Check if the keys are the same
|
||||||
// Note that I use the mask of the source action to check if they match any combination
|
// Note that I use the mask of the source action to check if they match any combination
|
||||||
if((d.Value.ShortcutKey & a.Value.ShortcutMask) == (a.Value.DefaultShortcutKey & a.Value.ShortcutMask))
|
if ((d.Value.ShortcutKey & a.Value.ShortcutMask) == (a.Value.DefaultShortcutKey & a.Value.ShortcutMask))
|
||||||
{
|
{
|
||||||
// No party.
|
// No party.
|
||||||
keyused = true;
|
keyused = true;
|
||||||
|
@ -438,7 +457,7 @@ namespace CodeImp.DoomBuilder.Actions
|
||||||
}
|
}
|
||||||
|
|
||||||
// Party?
|
// Party?
|
||||||
if(!keyused)
|
if (!keyused)
|
||||||
{
|
{
|
||||||
// Apply the default key
|
// Apply the default key
|
||||||
a.Value.SetShortcutKey(a.Value.DefaultShortcutKey);
|
a.Value.SetShortcutKey(a.Value.DefaultShortcutKey);
|
||||||
|
@ -455,13 +474,13 @@ namespace CodeImp.DoomBuilder.Actions
|
||||||
// This checks if a given action is active
|
// This checks if a given action is active
|
||||||
public bool CheckActionActive(Assembly asm, string actionname)
|
public bool CheckActionActive(Assembly asm, string actionname)
|
||||||
{
|
{
|
||||||
if(asm == null) asm = General.ThisAssembly;
|
if (asm == null) asm = General.ThisAssembly;
|
||||||
|
|
||||||
// Find active action
|
// Find active action
|
||||||
string fullname = asm.GetName().Name.ToLowerInvariant() + "_" + actionname;
|
string fullname = asm.GetName().Name.ToLowerInvariant() + "_" + actionname;
|
||||||
foreach(Action a in activeactions)
|
foreach (Action a in activeactions)
|
||||||
{
|
{
|
||||||
if(a.Name == fullname) return true;
|
if (a.Name == fullname) return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// No such active action
|
// No such active action
|
||||||
|
@ -472,7 +491,7 @@ namespace CodeImp.DoomBuilder.Actions
|
||||||
internal void RemoveShortcutKeys()
|
internal void RemoveShortcutKeys()
|
||||||
{
|
{
|
||||||
// Clear all keys
|
// Clear all keys
|
||||||
foreach(KeyValuePair<string, Action> a in actions)
|
foreach (KeyValuePair<string, Action> a in actions)
|
||||||
a.Value.SetShortcutKey(0);
|
a.Value.SetShortcutKey(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -481,16 +500,16 @@ namespace CodeImp.DoomBuilder.Actions
|
||||||
internal bool KeyPressed(int key)
|
internal bool KeyPressed(int key)
|
||||||
{
|
{
|
||||||
int strippedkey = key & ~((int)Keys.Alt | (int)Keys.Shift | (int)Keys.Control);
|
int strippedkey = key & ~((int)Keys.Alt | (int)Keys.Shift | (int)Keys.Control);
|
||||||
if((strippedkey == (int)Keys.ShiftKey) || (strippedkey == (int)Keys.ControlKey) || (strippedkey == (int)Keys.Alt)) key = strippedkey;
|
if ((strippedkey == (int)Keys.ShiftKey) || (strippedkey == (int)Keys.ControlKey) || (strippedkey == (int)Keys.Alt)) key = strippedkey;
|
||||||
bool repeat = pressedkeys.Contains(strippedkey);
|
bool repeat = pressedkeys.Contains(strippedkey);
|
||||||
|
|
||||||
// Update pressed keys
|
// Update pressed keys
|
||||||
if(!repeat) pressedkeys.Add(strippedkey);
|
if (!repeat) pressedkeys.Add(strippedkey);
|
||||||
|
|
||||||
// Add action to active list
|
// Add action to active list
|
||||||
Action[] acts = GetActionsByKey(key);
|
Action[] acts = GetActionsByKey(key);
|
||||||
bool absorbed = acts.Length > 0;
|
bool absorbed = acts.Length > 0;
|
||||||
foreach(Action a in acts) if(!activeactions.Contains(a)) activeactions.Add(a);
|
foreach (Action a in acts) if (!activeactions.Contains(a)) activeactions.Add(a);
|
||||||
|
|
||||||
// Invoke actions
|
// Invoke actions
|
||||||
absorbed |= BeginActionByKey(key, repeat);
|
absorbed |= BeginActionByKey(key, repeat);
|
||||||
|
@ -505,7 +524,7 @@ namespace CodeImp.DoomBuilder.Actions
|
||||||
int strippedkey = key & ~((int)Keys.Alt | (int)Keys.Shift | (int)Keys.Control);
|
int strippedkey = key & ~((int)Keys.Alt | (int)Keys.Shift | (int)Keys.Control);
|
||||||
|
|
||||||
// Update pressed keys
|
// Update pressed keys
|
||||||
if(pressedkeys.Contains(strippedkey)) pressedkeys.Remove(strippedkey);
|
if (pressedkeys.Contains(strippedkey)) pressedkeys.Remove(strippedkey);
|
||||||
|
|
||||||
// End actions that no longer match
|
// End actions that no longer match
|
||||||
return EndActiveActions();
|
return EndActiveActions();
|
||||||
|
@ -539,19 +558,19 @@ namespace CodeImp.DoomBuilder.Actions
|
||||||
|
|
||||||
// Get all actions for which a begin is bound
|
// Get all actions for which a begin is bound
|
||||||
List<Action> boundactions = new List<Action>(actions.Count);
|
List<Action> boundactions = new List<Action>(actions.Count);
|
||||||
foreach(KeyValuePair<string, Action> a in actions)
|
foreach (KeyValuePair<string, Action> a in actions)
|
||||||
if(a.Value.BeginBound) boundactions.Add(a.Value);
|
if (a.Value.BeginBound) boundactions.Add(a.Value);
|
||||||
|
|
||||||
// Go for all actions
|
// Go for all actions
|
||||||
foreach(Action a in boundactions)
|
foreach (Action a in boundactions)
|
||||||
{
|
{
|
||||||
// This action is associated with this key?
|
// This action is associated with this key?
|
||||||
if(a.KeyMatches(key))
|
if (a.KeyMatches(key))
|
||||||
{
|
{
|
||||||
invoked = true;
|
invoked = true;
|
||||||
|
|
||||||
// Allowed to repeat?
|
// Allowed to repeat?
|
||||||
if(a.Repeat || !repeated)
|
if (a.Repeat || !repeated)
|
||||||
{
|
{
|
||||||
// Invoke action
|
// Invoke action
|
||||||
a.Begin();
|
a.Begin();
|
||||||
|
@ -577,22 +596,22 @@ namespace CodeImp.DoomBuilder.Actions
|
||||||
{
|
{
|
||||||
// Go for all active actions
|
// Go for all active actions
|
||||||
listchanged = false;
|
listchanged = false;
|
||||||
for(int i = 0; i < activeactions.Count; i++)
|
for (int i = 0; i < activeactions.Count; i++)
|
||||||
{
|
{
|
||||||
Action a = activeactions[i];
|
Action a = activeactions[i];
|
||||||
|
|
||||||
// Go for all pressed keys
|
// Go for all pressed keys
|
||||||
bool stillactive = false;
|
bool stillactive = false;
|
||||||
foreach(int k in pressedkeys)
|
foreach (int k in pressedkeys)
|
||||||
{
|
{
|
||||||
if((k == (int)Keys.ShiftKey) || (k == (int)Keys.ControlKey))
|
if ((k == (int)Keys.ShiftKey) || (k == (int)Keys.ControlKey))
|
||||||
stillactive |= a.KeyMatches(k);
|
stillactive |= a.KeyMatches(k);
|
||||||
else
|
else
|
||||||
stillactive |= a.KeyMatches(k | modifiers);
|
stillactive |= a.KeyMatches(k | modifiers);
|
||||||
}
|
}
|
||||||
|
|
||||||
// End the action if no longer matches any of the keys
|
// End the action if no longer matches any of the keys
|
||||||
if(!stillactive)
|
if (!stillactive)
|
||||||
{
|
{
|
||||||
actionsended = true;
|
actionsended = true;
|
||||||
activeactions.RemoveAt(i);
|
activeactions.RemoveAt(i);
|
||||||
|
@ -602,7 +621,7 @@ namespace CodeImp.DoomBuilder.Actions
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
while(listchanged);
|
while (listchanged);
|
||||||
|
|
||||||
return actionsended;
|
return actionsended;
|
||||||
}
|
}
|
||||||
|
@ -613,10 +632,10 @@ namespace CodeImp.DoomBuilder.Actions
|
||||||
List<string> actionnames = new List<string>();
|
List<string> actionnames = new List<string>();
|
||||||
|
|
||||||
// Go for all actions
|
// Go for all actions
|
||||||
foreach(KeyValuePair<string, Action> a in actions)
|
foreach (KeyValuePair<string, Action> a in actions)
|
||||||
{
|
{
|
||||||
// This action is associated with this key?
|
// This action is associated with this key?
|
||||||
if(a.Value.KeyMatches(key))
|
if (a.Value.KeyMatches(key))
|
||||||
{
|
{
|
||||||
// List short name
|
// List short name
|
||||||
actionnames.Add(a.Value.ShortName);
|
actionnames.Add(a.Value.ShortName);
|
||||||
|
@ -633,10 +652,10 @@ namespace CodeImp.DoomBuilder.Actions
|
||||||
List<Action> actionnames = new List<Action>();
|
List<Action> actionnames = new List<Action>();
|
||||||
|
|
||||||
// Go for all actions
|
// Go for all actions
|
||||||
foreach(KeyValuePair<string, Action> a in actions)
|
foreach (KeyValuePair<string, Action> a in actions)
|
||||||
{
|
{
|
||||||
// This action is associated with this key?
|
// This action is associated with this key?
|
||||||
if(a.Value.KeyMatches(key))
|
if (a.Value.KeyMatches(key))
|
||||||
{
|
{
|
||||||
// List short name
|
// List short name
|
||||||
actionnames.Add(a.Value);
|
actionnames.Add(a.Value);
|
||||||
|
@ -663,7 +682,7 @@ namespace CodeImp.DoomBuilder.Actions
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool RequestExclusiveInvokation()
|
public bool RequestExclusiveInvokation()
|
||||||
{
|
{
|
||||||
if(exclusiverequested) return false; // Already given out
|
if (exclusiverequested) return false; // Already given out
|
||||||
|
|
||||||
// Success
|
// Success
|
||||||
exclusiverequested = true;
|
exclusiverequested = true;
|
||||||
|
|
|
@ -53,20 +53,31 @@ namespace CodeImp.DoomBuilder.Controls
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
|
||||||
|
Reset();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region ================== Setup
|
||||||
|
|
||||||
|
public void Reset()
|
||||||
|
{
|
||||||
// Only when running (this.DesignMode won't do when not this, but one of parent controls is in design mode)
|
// Only when running (this.DesignMode won't do when not this, but one of parent controls is in design mode)
|
||||||
if(LicenseManager.UsageMode != LicenseUsageMode.Designtime)
|
if (LicenseManager.UsageMode != LicenseUsageMode.Designtime)
|
||||||
{
|
{
|
||||||
//mxd. Setup script numbers
|
//mxd. Setup script numbers
|
||||||
scriptnumbers.Location = new Point(arg0.Location.X, arg0.Location.Y + 2);
|
scriptnumbers.Location = new Point(arg0.Location.X, arg0.Location.Y + 2);
|
||||||
foreach(ScriptItem si in General.Map.NumberedScripts.Values)
|
scriptnumbers.Items.Clear();
|
||||||
|
foreach (ScriptItem si in General.Map.NumberedScripts.Values)
|
||||||
scriptnumbers.Items.Add(new ColoredComboBoxItem(si, si.IsInclude ? SystemColors.HotTrack : SystemColors.WindowText));
|
scriptnumbers.Items.Add(new ColoredComboBoxItem(si, si.IsInclude ? SystemColors.HotTrack : SystemColors.WindowText));
|
||||||
scriptnumbers.DropDownWidth = Tools.GetDropDownWidth(scriptnumbers);
|
scriptnumbers.DropDownWidth = Tools.GetDropDownWidth(scriptnumbers);
|
||||||
|
|
||||||
//mxd. Setup script names
|
//mxd. Setup script names
|
||||||
if(General.Map.UDMF)
|
if (General.Map.UDMF)
|
||||||
{
|
{
|
||||||
|
scriptnames.Items.Clear();
|
||||||
scriptnames.Location = scriptnumbers.Location;
|
scriptnames.Location = scriptnumbers.Location;
|
||||||
foreach(ScriptItem nsi in General.Map.NamedScripts.Values)
|
foreach (ScriptItem nsi in General.Map.NamedScripts.Values)
|
||||||
scriptnames.Items.Add(new ColoredComboBoxItem(nsi, nsi.IsInclude ? SystemColors.HotTrack : SystemColors.WindowText));
|
scriptnames.Items.Add(new ColoredComboBoxItem(nsi, nsi.IsInclude ? SystemColors.HotTrack : SystemColors.WindowText));
|
||||||
scriptnames.DropDownWidth = Tools.GetDropDownWidth(scriptnames);
|
scriptnames.DropDownWidth = Tools.GetDropDownWidth(scriptnames);
|
||||||
}
|
}
|
||||||
|
@ -78,10 +89,6 @@ namespace CodeImp.DoomBuilder.Controls
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region ================== Setup
|
|
||||||
|
|
||||||
public void SetValue(Linedef l, bool first)
|
public void SetValue(Linedef l, bool first)
|
||||||
{
|
{
|
||||||
SetValue(l.Fields, l.Args, first);
|
SetValue(l.Fields, l.Args, first);
|
||||||
|
|
|
@ -585,7 +585,7 @@ namespace CodeImp.DoomBuilder.Controls
|
||||||
|
|
||||||
// Show the whole thing
|
// Show the whole thing
|
||||||
this.Show();
|
this.Show();
|
||||||
this.Update();
|
//this.Update(); // ano - don't think this is needed, and is slow
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void UpdateTexturePanel(Panel panel, string texturename, Label texturenamelabel, Label sizelabel, int maxlabelright, Panel image, int sizeref, bool extendedinfoshown, bool required)
|
private static void UpdateTexturePanel(Panel panel, string texturename, Label texturenamelabel, Label sizelabel, int maxlabelright, Panel image, int sizeref, bool extendedinfoshown, bool required)
|
||||||
|
|
|
@ -369,7 +369,7 @@ namespace CodeImp.DoomBuilder.Controls
|
||||||
|
|
||||||
// Show the whole thing
|
// Show the whole thing
|
||||||
this.Show();
|
this.Show();
|
||||||
this.Update();
|
//this.Update(); // ano - don't think this is needed, and is slow
|
||||||
}
|
}
|
||||||
|
|
||||||
//mxd
|
//mxd
|
||||||
|
|
|
@ -41,12 +41,7 @@ namespace CodeImp.DoomBuilder.Controls
|
||||||
public TagsSelector()
|
public TagsSelector()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
Reset();
|
||||||
tagspermapelement = new List<List<int>>();
|
|
||||||
usedtags = new List<int>();
|
|
||||||
rangemodes = new List<int>();
|
|
||||||
offsetmodes = new List<int>();
|
|
||||||
infos = new List<TagInfo>();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
@ -154,7 +149,6 @@ namespace CodeImp.DoomBuilder.Controls
|
||||||
else
|
else
|
||||||
infos.Add(new TagInfo(tag, string.Empty));
|
infos.Add(new TagInfo(tag, string.Empty));
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach(TagInfo info in infos) tagpicker.Items.Add(info);
|
foreach(TagInfo info in infos) tagpicker.Items.Add(info);
|
||||||
tagpicker.DropDownWidth = DoomBuilder.Geometry.Tools.GetDropDownWidth(tagpicker);
|
tagpicker.DropDownWidth = DoomBuilder.Geometry.Tools.GetDropDownWidth(tagpicker);
|
||||||
}
|
}
|
||||||
|
@ -219,6 +213,18 @@ namespace CodeImp.DoomBuilder.Controls
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region ================== Methods
|
#region ================== Methods
|
||||||
|
public void Reset()
|
||||||
|
{
|
||||||
|
tagspermapelement = new List<List<int>>();
|
||||||
|
usedtags = new List<int>();
|
||||||
|
rangemodes = new List<int>();
|
||||||
|
offsetmodes = new List<int>();
|
||||||
|
infos = new List<TagInfo>();
|
||||||
|
tagslist.Links.Clear();
|
||||||
|
infos.Clear();
|
||||||
|
tagpicker.Items.Clear();
|
||||||
|
usedtags.Clear();
|
||||||
|
}
|
||||||
|
|
||||||
// Creates a single tag collection to display. int.MinValue means "mixed tag"
|
// Creates a single tag collection to display. int.MinValue means "mixed tag"
|
||||||
private List<int> GetDisplayTags()
|
private List<int> GetDisplayTags()
|
||||||
|
@ -251,7 +257,7 @@ namespace CodeImp.DoomBuilder.Controls
|
||||||
tagslist.Links.Clear();
|
tagslist.Links.Clear();
|
||||||
|
|
||||||
// Gather tags into a single string collection
|
// Gather tags into a single string collection
|
||||||
for(int i = 0; i < tags.Count; i++)
|
for (int i = 0; i < tags.Count; i++)
|
||||||
{
|
{
|
||||||
displaytags[i] = (tags[i] == int.MinValue ? "???" : tags[i].ToString());
|
displaytags[i] = (tags[i] == int.MinValue ? "???" : tags[i].ToString());
|
||||||
|
|
||||||
|
|
|
@ -240,7 +240,7 @@ namespace CodeImp.DoomBuilder.Controls
|
||||||
|
|
||||||
// Show the whole thing
|
// Show the whole thing
|
||||||
this.Show();
|
this.Show();
|
||||||
this.Update();
|
//this.Update(); // ano - don't think this is needed, and is slow
|
||||||
}
|
}
|
||||||
|
|
||||||
//mxd
|
//mxd
|
||||||
|
|
|
@ -58,7 +58,7 @@ namespace CodeImp.DoomBuilder.Controls
|
||||||
|
|
||||||
// Show the whole thing
|
// Show the whole thing
|
||||||
this.Show();
|
this.Show();
|
||||||
this.Update();
|
//this.Update(); // ano - don't think this is needed, and is slow
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -986,6 +986,7 @@ namespace CodeImp.DoomBuilder.Map
|
||||||
// Limit intersection offset to the line
|
// Limit intersection offset to the line
|
||||||
if(bounded) if(u < lengthinv) u = lengthinv; else if(u > (1f - lengthinv)) u = 1f - lengthinv;
|
if(bounded) if(u < lengthinv) u = lengthinv; else if(u > (1f - lengthinv)) u = 1f - lengthinv;
|
||||||
|
|
||||||
|
/*
|
||||||
// Calculate intersection point
|
// Calculate intersection point
|
||||||
Vector2D i = v1 + u * (v2 - v1);
|
Vector2D i = v1 + u * (v2 - v1);
|
||||||
|
|
||||||
|
@ -993,6 +994,12 @@ namespace CodeImp.DoomBuilder.Map
|
||||||
// which is the shortest distance to the line
|
// which is the shortest distance to the line
|
||||||
float ldx = p.x - i.x;
|
float ldx = p.x - i.x;
|
||||||
float ldy = p.y - i.y;
|
float ldy = p.y - i.y;
|
||||||
|
*/
|
||||||
|
|
||||||
|
// ano - let's check to see if we can do the previous faster without using operator overloading and etc
|
||||||
|
// the answer: running it int.MaxValue / 64 times it tended to be around 100ms faster
|
||||||
|
float ldx = p.x - (v1.x + u * (v2.x - v1.x));
|
||||||
|
float ldy = p.y - (v1.y + u * (v2.y - v1.y));
|
||||||
return ldx * ldx + ldy * ldy;
|
return ldx * ldx + ldy * ldy;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2194,12 +2194,16 @@ namespace CodeImp.DoomBuilder.Map
|
||||||
//DebugConsole.Clear();
|
//DebugConsole.Clear();
|
||||||
//DebugConsole.WriteLine("CorrectSectorReferences for " + lines.Count + " lines");
|
//DebugConsole.WriteLine("CorrectSectorReferences for " + lines.Count + " lines");
|
||||||
|
|
||||||
|
// ano - set a bunch of foreaches to be for()s because they're faster
|
||||||
|
|
||||||
// Create a list of sidedefs to perform sector creation with
|
// Create a list of sidedefs to perform sector creation with
|
||||||
List<LinedefSide> edges = new List<LinedefSide>();
|
List<LinedefSide> edges = new List<LinedefSide>();
|
||||||
if(existing_only)
|
if(existing_only)
|
||||||
{
|
{
|
||||||
foreach(Linedef l in lines)
|
int lineCount = lines.Count;
|
||||||
|
for(int i = 0; i < lineCount; i++)
|
||||||
{
|
{
|
||||||
|
Linedef l = lines[i];
|
||||||
// Add only existing sides as edges (or front side if line has none)
|
// Add only existing sides as edges (or front side if line has none)
|
||||||
if(l.Front != null || l.Back == null)
|
if(l.Front != null || l.Back == null)
|
||||||
edges.Add(new LinedefSide(l, true));
|
edges.Add(new LinedefSide(l, true));
|
||||||
|
@ -2209,8 +2213,10 @@ namespace CodeImp.DoomBuilder.Map
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
foreach(Linedef l in lines)
|
int lineCount = lines.Count;
|
||||||
|
for (int i = 0; i < lineCount; i++)
|
||||||
{
|
{
|
||||||
|
Linedef l = lines[i];
|
||||||
// Add front side
|
// Add front side
|
||||||
edges.Add(new LinedefSide(l, true));
|
edges.Add(new LinedefSide(l, true));
|
||||||
|
|
||||||
|
@ -2221,9 +2227,11 @@ namespace CodeImp.DoomBuilder.Map
|
||||||
}
|
}
|
||||||
|
|
||||||
HashSet<Sidedef> sides_correct = new HashSet<Sidedef>();
|
HashSet<Sidedef> sides_correct = new HashSet<Sidedef>();
|
||||||
foreach(LinedefSide ls in edges)
|
int edgeCount = edges.Count;
|
||||||
|
for (int i = 0; i < edgeCount; i++)
|
||||||
{
|
{
|
||||||
if(ls.Front && ls.Line.Front != null)
|
LinedefSide ls = edges[i];
|
||||||
|
if (ls.Front && ls.Line.Front != null)
|
||||||
sides_correct.Add(ls.Line.Front);
|
sides_correct.Add(ls.Line.Front);
|
||||||
else if(!ls.Front && ls.Line.Back != null)
|
else if(!ls.Front && ls.Line.Back != null)
|
||||||
sides_correct.Add(ls.Line.Back);
|
sides_correct.Add(ls.Line.Back);
|
||||||
|
@ -2241,11 +2249,12 @@ namespace CodeImp.DoomBuilder.Map
|
||||||
SectorBuilder builder = new SectorBuilder();
|
SectorBuilder builder = new SectorBuilder();
|
||||||
List<Sector> sectors_reused = new List<Sector>();
|
List<Sector> sectors_reused = new List<Sector>();
|
||||||
|
|
||||||
foreach(LinedefSide ls in edges)
|
for (int i = 0; i < edgeCount; i++)
|
||||||
{
|
{
|
||||||
|
LinedefSide ls = edges[i];
|
||||||
// Skip if edge is ignored
|
// Skip if edge is ignored
|
||||||
//DebugConsole.WriteLine((ls.Ignore ? "Ignoring line " : "Processing line ") + ls.Line.Index);
|
//DebugConsole.WriteLine((ls.Ignore ? "Ignoring line " : "Processing line ") + ls.Line.Index);
|
||||||
if(ls.Ignore) continue;
|
if (ls.Ignore) continue;
|
||||||
|
|
||||||
// Run sector builder on current edge
|
// Run sector builder on current edge
|
||||||
if(!builder.TraceSector(ls.Line, ls.Front)) continue; // Don't create sector if trace failed
|
if(!builder.TraceSector(ls.Line, ls.Front)) continue; // Don't create sector if trace failed
|
||||||
|
@ -2263,9 +2272,10 @@ namespace CodeImp.DoomBuilder.Map
|
||||||
if(side_exists && sectorsides.Contains(edge.Front ? edge.Line.Front : edge.Line.Back))
|
if(side_exists && sectorsides.Contains(edge.Front ? edge.Line.Front : edge.Line.Back))
|
||||||
has_dragged_sides = true; //mxd
|
has_dragged_sides = true; //mxd
|
||||||
|
|
||||||
foreach(LinedefSide ls2 in edges)
|
for (int k = 0; k < edgeCount; k++)
|
||||||
{
|
{
|
||||||
if(ls2.Line == edge.Line)
|
LinedefSide ls2 = edges[k];
|
||||||
|
if (ls2.Line == edge.Line)
|
||||||
{
|
{
|
||||||
line_is_ours = true;
|
line_is_ours = true;
|
||||||
if(ls2.Front == edge.Front)
|
if(ls2.Front == edge.Front)
|
||||||
|
@ -2276,12 +2286,16 @@ namespace CodeImp.DoomBuilder.Map
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(line_is_ours)
|
// ano - so this inner part was already commented out
|
||||||
|
// so i just put the /* */ around it
|
||||||
|
/*if(line_is_ours)
|
||||||
{
|
{
|
||||||
//if(edge.Line.Front == null && edge.Line.Back == null)
|
//if(edge.Line.Front == null && edge.Line.Back == null)
|
||||||
//has_zero_sided_lines = true;
|
//has_zero_sided_lines = true;
|
||||||
}
|
}
|
||||||
else
|
else*/
|
||||||
|
|
||||||
|
if(!line_is_ours)
|
||||||
{
|
{
|
||||||
has_existing_lines = true;
|
has_existing_lines = true;
|
||||||
has_existing_sides |= side_exists; //mxd
|
has_existing_sides |= side_exists; //mxd
|
||||||
|
@ -2331,9 +2345,10 @@ namespace CodeImp.DoomBuilder.Map
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove any sides that weren't part of a sector
|
// Remove any sides that weren't part of a sector
|
||||||
foreach(LinedefSide ls in edges)
|
for (int i = 0; i < edgeCount; i++)
|
||||||
{
|
{
|
||||||
if(ls.Ignore || ls.Line == null) continue;
|
LinedefSide ls = edges[i];
|
||||||
|
if (ls.Ignore || ls.Line == null) continue;
|
||||||
|
|
||||||
if(ls.Front)
|
if(ls.Front)
|
||||||
{
|
{
|
||||||
|
|
|
@ -30,6 +30,6 @@ using CodeImp.DoomBuilder;
|
||||||
// Build Number
|
// Build Number
|
||||||
// Revision
|
// Revision
|
||||||
//
|
//
|
||||||
[assembly: AssemblyVersion("2.3.0.2859")]
|
[assembly: AssemblyVersion("2.3.0.2866")]
|
||||||
[assembly: NeutralResourcesLanguageAttribute("en")]
|
[assembly: NeutralResourcesLanguageAttribute("en")]
|
||||||
[assembly: AssemblyHash("5a5c6d0")]
|
[assembly: AssemblyHash("34d1af9")]
|
||||||
|
|
|
@ -94,6 +94,11 @@ namespace CodeImp.DoomBuilder.Rendering
|
||||||
// Disposing
|
// Disposing
|
||||||
private bool isdisposed;
|
private bool isdisposed;
|
||||||
|
|
||||||
|
// ano - static stuff to prevent often alloc/dealloc performance hits
|
||||||
|
private static StringFormat strFormat;
|
||||||
|
private static SolidBrush brush;
|
||||||
|
private static Pen pen;
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region ================== Properties
|
#region ================== Properties
|
||||||
|
@ -157,6 +162,8 @@ namespace CodeImp.DoomBuilder.Rendering
|
||||||
this.updateneeded = true;
|
this.updateneeded = true;
|
||||||
this.textureupdateneeded = true; //mxd
|
this.textureupdateneeded = true; //mxd
|
||||||
|
|
||||||
|
InitializeStatics();
|
||||||
|
|
||||||
// Register as resource
|
// Register as resource
|
||||||
General.Map.Graphics.RegisterResource(this);
|
General.Map.Graphics.RegisterResource(this);
|
||||||
|
|
||||||
|
@ -181,6 +188,8 @@ namespace CodeImp.DoomBuilder.Rendering
|
||||||
this.updateneeded = true;
|
this.updateneeded = true;
|
||||||
this.textureupdateneeded = true;
|
this.textureupdateneeded = true;
|
||||||
|
|
||||||
|
InitializeStatics();
|
||||||
|
|
||||||
// Register as resource
|
// Register as resource
|
||||||
General.Map.Graphics.RegisterResource(this);
|
General.Map.Graphics.RegisterResource(this);
|
||||||
|
|
||||||
|
@ -210,6 +219,27 @@ namespace CodeImp.DoomBuilder.Rendering
|
||||||
|
|
||||||
#region ================== Methods
|
#region ================== Methods
|
||||||
|
|
||||||
|
// ano - share resources instead of constantly alloc/dealloc
|
||||||
|
public void InitializeStatics()
|
||||||
|
{
|
||||||
|
if (strFormat == null)
|
||||||
|
{
|
||||||
|
strFormat = new StringFormat();
|
||||||
|
strFormat.FormatFlags = StringFormatFlags.FitBlackBox | StringFormatFlags.NoWrap;
|
||||||
|
strFormat.Alignment = StringAlignment.Center;
|
||||||
|
strFormat.LineAlignment = StringAlignment.Center;
|
||||||
|
}
|
||||||
|
if (brush == null)
|
||||||
|
{
|
||||||
|
// if we actually see magenta, know we made a mistake somewhere
|
||||||
|
brush = new SolidBrush(System.Drawing.Color.Magenta);
|
||||||
|
}
|
||||||
|
if (pen == null)
|
||||||
|
{
|
||||||
|
pen = new Pen(System.Drawing.Color.Magenta);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// This updates the text if needed
|
// This updates the text if needed
|
||||||
public void Update(float translatex, float translatey, float scalex, float scaley)
|
public void Update(float translatex, float translatey, float scalex, float scaley)
|
||||||
{
|
{
|
||||||
|
@ -354,12 +384,6 @@ namespace CodeImp.DoomBuilder.Rendering
|
||||||
g.CompositingQuality = CompositingQuality.HighQuality;
|
g.CompositingQuality = CompositingQuality.HighQuality;
|
||||||
|
|
||||||
// Draw text
|
// Draw text
|
||||||
using(StringFormat sf = new StringFormat())
|
|
||||||
{
|
|
||||||
sf.FormatFlags = StringFormatFlags.FitBlackBox | StringFormatFlags.NoWrap;
|
|
||||||
sf.Alignment = StringAlignment.Center;
|
|
||||||
sf.LineAlignment = StringAlignment.Center;
|
|
||||||
|
|
||||||
// Draw text with BG
|
// Draw text with BG
|
||||||
if(drawbg)
|
if(drawbg)
|
||||||
{
|
{
|
||||||
|
@ -388,16 +412,19 @@ namespace CodeImp.DoomBuilder.Rendering
|
||||||
p.AddArc(pathrect.Left, pathrect.Bottom - radius, radius, radius, 90, 90);
|
p.AddArc(pathrect.Left, pathrect.Bottom - radius, radius, radius, 90, 90);
|
||||||
|
|
||||||
// Fill'n'draw bg
|
// Fill'n'draw bg
|
||||||
using(SolidBrush brush = new SolidBrush(color.ToColor()))
|
brush.Color = color.ToColor();
|
||||||
|
|
||||||
g.FillPath(brush, p);
|
g.FillPath(brush, p);
|
||||||
|
|
||||||
using(Pen pen = new Pen(backcolor.ToColor(), outlinewidth))
|
pen.Color = backcolor.ToColor();
|
||||||
|
|
||||||
g.DrawPath(pen, p);
|
g.DrawPath(pen, p);
|
||||||
|
|
||||||
// Draw text
|
// Draw text
|
||||||
textrect.Inflate(4, 2);
|
textrect.Inflate(4, 2);
|
||||||
using(SolidBrush brush = new SolidBrush(backcolor.ToColor()))
|
brush.Color = backcolor.ToColor();
|
||||||
g.DrawString(text, font, brush, textrect, sf);
|
|
||||||
|
g.DrawString(text, font, brush, textrect, strFormat);
|
||||||
}
|
}
|
||||||
// Draw plain text
|
// Draw plain text
|
||||||
else
|
else
|
||||||
|
@ -408,13 +435,13 @@ namespace CodeImp.DoomBuilder.Rendering
|
||||||
RectangleF plaintextrect = textrect;
|
RectangleF plaintextrect = textrect;
|
||||||
plaintextrect.Inflate(6, 4);
|
plaintextrect.Inflate(6, 4);
|
||||||
|
|
||||||
using(SolidBrush brush = new SolidBrush(backcolor.ToColor()))
|
brush.Color = backcolor.ToColor();
|
||||||
g.FillRectangle(brush, plainbgrect);
|
g.FillRectangle(brush, plainbgrect);
|
||||||
|
|
||||||
using(SolidBrush brush = new SolidBrush(color.ToColor()))
|
brush.Color = color.ToColor();
|
||||||
g.DrawString(text, font, brush, plaintextrect, sf);
|
g.DrawString(text, font, brush, plaintextrect, strFormat);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
|
|
@ -152,6 +152,8 @@ namespace CodeImp.DoomBuilder.Windows
|
||||||
{
|
{
|
||||||
preventchanges = true;
|
preventchanges = true;
|
||||||
|
|
||||||
|
argscontrol.Reset();
|
||||||
|
undocreated = false;
|
||||||
// Keep this list
|
// Keep this list
|
||||||
this.lines = lines;
|
this.lines = lines;
|
||||||
if(lines.Count > 1) this.Text = "Edit Linedefs (" + lines.Count + ")";
|
if(lines.Count > 1) this.Text = "Edit Linedefs (" + lines.Count + ")";
|
||||||
|
|
|
@ -245,10 +245,27 @@ namespace CodeImp.DoomBuilder.Windows
|
||||||
// This sets up the form to edit the given lines
|
// This sets up the form to edit the given lines
|
||||||
public void Setup(ICollection<Linedef> lines)
|
public void Setup(ICollection<Linedef> lines)
|
||||||
{
|
{
|
||||||
|
// Window setup
|
||||||
|
// ano - moved this here because we don't reinstantiate the thing every time anymore
|
||||||
|
if (General.Settings.StoreSelectedEditTab)
|
||||||
|
{
|
||||||
|
int activetab = General.Settings.ReadSetting("windows." + configname + ".activetab", 0);
|
||||||
|
|
||||||
|
// When front or back tab was previously selected, switch to appropriate side (selectfront/selectback are set in BaseVisualGeometrySidedef.OnEditEnd)
|
||||||
|
if ((selectfront || selectback) && (activetab == 1 || activetab == 2))
|
||||||
|
tabs.SelectTab(selectfront ? 1 : 2);
|
||||||
|
else
|
||||||
|
tabs.SelectTab(activetab);
|
||||||
|
}
|
||||||
|
|
||||||
preventchanges = true;
|
preventchanges = true;
|
||||||
|
undocreated = false;
|
||||||
|
argscontrol.Reset();
|
||||||
|
tagsselector.Reset();
|
||||||
|
|
||||||
// Keep this list
|
// Keep this list
|
||||||
this.lines = lines;
|
this.lines = lines;
|
||||||
|
|
||||||
if(lines.Count > 1) this.Text = "Edit Linedefs (" + lines.Count + ")";
|
if(lines.Count > 1) this.Text = "Edit Linedefs (" + lines.Count + ")";
|
||||||
linedefprops = new List<LinedefProperties>();
|
linedefprops = new List<LinedefProperties>();
|
||||||
|
|
||||||
|
|
|
@ -850,7 +850,7 @@ namespace CodeImp.DoomBuilder.Windows
|
||||||
|
|
||||||
// Refresh
|
// Refresh
|
||||||
statusbar.Invalidate();
|
statusbar.Invalidate();
|
||||||
this.Update();
|
//this.Update(); // ano - this is unneeded afaict and slow
|
||||||
}
|
}
|
||||||
|
|
||||||
// This changes status text to Ready
|
// This changes status text to Ready
|
||||||
|
@ -2116,18 +2116,21 @@ namespace CodeImp.DoomBuilder.Windows
|
||||||
internal void CheckEditModeButton(string modeclassname)
|
internal void CheckEditModeButton(string modeclassname)
|
||||||
{
|
{
|
||||||
// Go for all items
|
// Go for all items
|
||||||
foreach(ToolStripItem i in editmodeitems)
|
//foreach(ToolStripItem item in editmodeitems)
|
||||||
|
int itemCount = editmodeitems.Count;
|
||||||
|
for(int i = 0; i < itemCount; i++)
|
||||||
{
|
{
|
||||||
|
ToolStripItem item = editmodeitems[i];
|
||||||
// Check what type it is
|
// Check what type it is
|
||||||
if(i is ToolStripMenuItem)
|
if(item is ToolStripMenuItem)
|
||||||
{
|
{
|
||||||
// Check if mode type matches with given name
|
// Check if mode type matches with given name
|
||||||
(i as ToolStripMenuItem).Checked = ((i.Tag as EditModeInfo).Type.Name == modeclassname);
|
(item as ToolStripMenuItem).Checked = ((item.Tag as EditModeInfo).Type.Name == modeclassname);
|
||||||
}
|
}
|
||||||
else if(i is ToolStripButton)
|
else if(item is ToolStripButton)
|
||||||
{
|
{
|
||||||
// Check if mode type matches with given name
|
// Check if mode type matches with given name
|
||||||
(i as ToolStripButton).Checked = ((i.Tag as EditModeInfo).Type.Name == modeclassname);
|
(item as ToolStripButton).Checked = ((item.Tag as EditModeInfo).Type.Name == modeclassname);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2136,11 +2139,14 @@ namespace CodeImp.DoomBuilder.Windows
|
||||||
internal void RemoveEditModeButtons()
|
internal void RemoveEditModeButtons()
|
||||||
{
|
{
|
||||||
// Go for all items
|
// Go for all items
|
||||||
foreach(ToolStripItem i in editmodeitems)
|
//foreach(ToolStripItem item in editmodeitems)
|
||||||
|
int itemCount = editmodeitems.Count;
|
||||||
|
for (int i = 0; i < itemCount; i++)
|
||||||
{
|
{
|
||||||
|
ToolStripItem item = editmodeitems[i];
|
||||||
// Remove it and restart
|
// Remove it and restart
|
||||||
menumode.DropDownItems.Remove(i);
|
menumode.DropDownItems.Remove(item);
|
||||||
i.Dispose();
|
item.Dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Done
|
// Done
|
||||||
|
|
|
@ -90,7 +90,7 @@ namespace CodeImp.DoomBuilder.Windows
|
||||||
public void Setup(ICollection<Sector> sectors)
|
public void Setup(ICollection<Sector> sectors)
|
||||||
{
|
{
|
||||||
preventchanges = true; //mxd
|
preventchanges = true; //mxd
|
||||||
|
undocreated = false;
|
||||||
// Keep this list
|
// Keep this list
|
||||||
this.sectors = sectors;
|
this.sectors = sectors;
|
||||||
if(sectors.Count > 1) this.Text = "Edit Sectors (" + sectors.Count + ")";
|
if(sectors.Count > 1) this.Text = "Edit Sectors (" + sectors.Count + ")";
|
||||||
|
|
|
@ -292,7 +292,7 @@ namespace CodeImp.DoomBuilder.Windows
|
||||||
public void Setup(ICollection<Sector> sectors)
|
public void Setup(ICollection<Sector> sectors)
|
||||||
{
|
{
|
||||||
preventchanges = true; //mxd
|
preventchanges = true; //mxd
|
||||||
|
undocreated = false;
|
||||||
// Keep this list
|
// Keep this list
|
||||||
this.sectors = sectors;
|
this.sectors = sectors;
|
||||||
if(sectors.Count > 1) this.Text = "Edit Sectors (" + sectors.Count + ")";
|
if(sectors.Count > 1) this.Text = "Edit Sectors (" + sectors.Count + ")";
|
||||||
|
|
|
@ -141,6 +141,8 @@ namespace CodeImp.DoomBuilder.Windows
|
||||||
public void Setup(ICollection<Thing> things)
|
public void Setup(ICollection<Thing> things)
|
||||||
{
|
{
|
||||||
preventchanges = true;
|
preventchanges = true;
|
||||||
|
undocreated = false;
|
||||||
|
argscontrol.Reset();
|
||||||
|
|
||||||
// Keep this list
|
// Keep this list
|
||||||
this.things = things;
|
this.things = things;
|
||||||
|
|
|
@ -164,6 +164,8 @@ namespace CodeImp.DoomBuilder.Windows
|
||||||
public void Setup(ICollection<Thing> things)
|
public void Setup(ICollection<Thing> things)
|
||||||
{
|
{
|
||||||
preventchanges = true;
|
preventchanges = true;
|
||||||
|
undocreated = false;
|
||||||
|
argscontrol.Reset();
|
||||||
|
|
||||||
// Keep this list
|
// Keep this list
|
||||||
this.things = things;
|
this.things = things;
|
||||||
|
|
|
@ -29,5 +29,5 @@ using System.Resources;
|
||||||
// Build Number
|
// Build Number
|
||||||
// Revision
|
// Revision
|
||||||
//
|
//
|
||||||
[assembly: AssemblyVersion("2.3.0.2859")]
|
[assembly: AssemblyVersion("2.3.0.2866")]
|
||||||
[assembly: NeutralResourcesLanguageAttribute("en")]
|
[assembly: NeutralResourcesLanguageAttribute("en")]
|
||||||
|
|
Loading…
Reference in a new issue