diff options
| -rw-r--r-- | .gitmodules | 6 | ||||
| -rw-r--r-- | GOLib.csproj | 6 | ||||
| -rw-r--r-- | GOLib.sln | 28 | ||||
| m--------- | OpenTK | 0 | ||||
| -rw-r--r-- | Tests/Tests.csproj | 12 | ||||
| -rwxr-xr-x | src/GraphicObjects/Checkbox.cs | 2 | ||||
| -rwxr-xr-x | src/GraphicObjects/GraphicObject.cs | 125 | ||||
| -rwxr-xr-x | src/GraphicObjects/Label.cs | 14 | ||||
| -rw-r--r-- | src/Interface.cs | 154 | ||||
| -rwxr-xr-x | src/OpenTKGameWindow.cs | 4 |
10 files changed, 212 insertions, 139 deletions
diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 00000000..d427669f --- /dev/null +++ b/.gitmodules @@ -0,0 +1,6 @@ +[submodule "OpenTK"] + path = OpenTK + url = git://github.com/jpbruyere/opentk.git +[submodule "GGL"] + path = GGL + url = git://github.com/jpbruyere/GGL.git diff --git a/GOLib.csproj b/GOLib.csproj index e30f3573..4aad6152 100644 --- a/GOLib.csproj +++ b/GOLib.csproj @@ -227,6 +227,10 @@ <LogicalName>
</LogicalName>
</Compile>
+ <Compile Include="src\Interface.cs">
+ <LogicalName>
+ </LogicalName>
+ </Compile>
</ItemGroup>
<ItemGroup>
<Reference Include="System" />
@@ -294,7 +298,7 @@ </EmbeddedResource>
</ItemGroup>
<ItemGroup>
- <ProjectReference Include="..\..\..\data\Developpements\Magic3D\OpenTK\Source\OpenTK\OpenTK.csproj">
+ <ProjectReference Include="OpenTK\Source\OpenTK\OpenTK.csproj">
<Project>{A37A7E14-0000-0000-0000-000000000000}</Project>
<Name>OpenTK</Name>
</ProjectReference>
@@ -9,24 +9,52 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MonoDevelop.GOLib", "MonoDe EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MonoDevelop.Diagram", "..\MonoDevelop.Diagram\MonoDevelop.Diagram.csproj", "{232716B4-D19D-4FD7-B310-94A98FD926F0}"
EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenTK", "OpenTK\Source\OpenTK\OpenTK.csproj", "{A37A7E14-0000-0000-0000-000000000000}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Linux_x86 = Debug|Linux_x86
Release|Linux_x86 = Release|Linux_x86
+ Documentation|Any CPU = Documentation|Any CPU
+ Nsis|Any CPU = Nsis|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{232716B4-D19D-4FD7-B310-94A98FD926F0}.Debug|Linux_x86.ActiveCfg = Debug|Any CPU
+ {232716B4-D19D-4FD7-B310-94A98FD926F0}.Documentation|Any CPU.ActiveCfg = Debug|Any CPU
+ {232716B4-D19D-4FD7-B310-94A98FD926F0}.Documentation|Any CPU.Build.0 = Debug|Any CPU
+ {232716B4-D19D-4FD7-B310-94A98FD926F0}.Nsis|Any CPU.ActiveCfg = Debug|Any CPU
+ {232716B4-D19D-4FD7-B310-94A98FD926F0}.Nsis|Any CPU.Build.0 = Debug|Any CPU
{232716B4-D19D-4FD7-B310-94A98FD926F0}.Release|Linux_x86.ActiveCfg = Release|Linux_x86
{232716B4-D19D-4FD7-B310-94A98FD926F0}.Release|Linux_x86.Build.0 = Release|Linux_x86
{74289092-9F70-4941-AFCB-DFD7BE2140B6}.Debug|Linux_x86.ActiveCfg = Debug|Any CPU
{74289092-9F70-4941-AFCB-DFD7BE2140B6}.Debug|Linux_x86.Build.0 = Debug|Any CPU
+ {74289092-9F70-4941-AFCB-DFD7BE2140B6}.Documentation|Any CPU.ActiveCfg = Debug|Any CPU
+ {74289092-9F70-4941-AFCB-DFD7BE2140B6}.Documentation|Any CPU.Build.0 = Debug|Any CPU
+ {74289092-9F70-4941-AFCB-DFD7BE2140B6}.Nsis|Any CPU.ActiveCfg = Debug|Any CPU
+ {74289092-9F70-4941-AFCB-DFD7BE2140B6}.Nsis|Any CPU.Build.0 = Debug|Any CPU
{74289092-9F70-4941-AFCB-DFD7BE2140B6}.Release|Linux_x86.ActiveCfg = Release|Linux_x86
{74289092-9F70-4941-AFCB-DFD7BE2140B6}.Release|Linux_x86.Build.0 = Release|Linux_x86
+ {A37A7E14-0000-0000-0000-000000000000}.Debug|Linux_x86.ActiveCfg = Release|Any CPU
+ {A37A7E14-0000-0000-0000-000000000000}.Debug|Linux_x86.Build.0 = Release|Any CPU
+ {A37A7E14-0000-0000-0000-000000000000}.Documentation|Any CPU.ActiveCfg = Documentation|Any CPU
+ {A37A7E14-0000-0000-0000-000000000000}.Documentation|Any CPU.Build.0 = Documentation|Any CPU
+ {A37A7E14-0000-0000-0000-000000000000}.Nsis|Any CPU.ActiveCfg = Nsis|Any CPU
+ {A37A7E14-0000-0000-0000-000000000000}.Nsis|Any CPU.Build.0 = Nsis|Any CPU
+ {A37A7E14-0000-0000-0000-000000000000}.Release|Linux_x86.ActiveCfg = Release|Any CPU
+ {A37A7E14-0000-0000-0000-000000000000}.Release|Linux_x86.Build.0 = Release|Any CPU
{C2980F9B-4798-4C05-99E2-E174810F7C7B}.Debug|Linux_x86.ActiveCfg = Debug|Any CPU
{C2980F9B-4798-4C05-99E2-E174810F7C7B}.Debug|Linux_x86.Build.0 = Debug|Any CPU
+ {C2980F9B-4798-4C05-99E2-E174810F7C7B}.Documentation|Any CPU.ActiveCfg = Debug|Any CPU
+ {C2980F9B-4798-4C05-99E2-E174810F7C7B}.Documentation|Any CPU.Build.0 = Debug|Any CPU
+ {C2980F9B-4798-4C05-99E2-E174810F7C7B}.Nsis|Any CPU.ActiveCfg = Debug|Any CPU
+ {C2980F9B-4798-4C05-99E2-E174810F7C7B}.Nsis|Any CPU.Build.0 = Debug|Any CPU
{C2980F9B-4798-4C05-99E2-E174810F7C7B}.Release|Linux_x86.ActiveCfg = Release|Linux_x86
{C2980F9B-4798-4C05-99E2-E174810F7C7B}.Release|Linux_x86.Build.0 = Release|Linux_x86
{E9E14DB5-3C67-4E01-B5C3-4D90D7E31A2E}.Debug|Linux_x86.ActiveCfg = Debug|Any CPU
+ {E9E14DB5-3C67-4E01-B5C3-4D90D7E31A2E}.Documentation|Any CPU.ActiveCfg = Debug|Any CPU
+ {E9E14DB5-3C67-4E01-B5C3-4D90D7E31A2E}.Documentation|Any CPU.Build.0 = Debug|Any CPU
+ {E9E14DB5-3C67-4E01-B5C3-4D90D7E31A2E}.Nsis|Any CPU.ActiveCfg = Debug|Any CPU
+ {E9E14DB5-3C67-4E01-B5C3-4D90D7E31A2E}.Nsis|Any CPU.Build.0 = Debug|Any CPU
{E9E14DB5-3C67-4E01-B5C3-4D90D7E31A2E}.Release|Linux_x86.ActiveCfg = Release|Any CPU
{E9E14DB5-3C67-4E01-B5C3-4D90D7E31A2E}.Release|Linux_x86.Build.0 = Release|Any CPU
EndGlobalSection
diff --git a/OpenTK b/OpenTK new file mode 160000 +Subproject 271fc3f235118a8298219387b8de50a2af06ca5 diff --git a/Tests/Tests.csproj b/Tests/Tests.csproj index d5880c46..b65edb44 100644 --- a/Tests/Tests.csproj +++ b/Tests/Tests.csproj @@ -8,7 +8,7 @@ <OutputType>Exe</OutputType> <RootNamespace>Tests</RootNamespace> <AssemblyName>Tests</AssemblyName> - <StartupObject>test.GOLIBTest_3</StartupObject> + <StartupObject>test.GOLIBTest_4</StartupObject> <TargetFrameworkVersion>v4.5</TargetFrameworkVersion> <OutputPath>..\bin\$(configuration)</OutputPath> <IntermediateOutputPath>obj\$(configuration)</IntermediateOutputPath> @@ -38,12 +38,6 @@ <Reference Include="System.Xml" /> <Reference Include="System.Windows.Forms" /> <Reference Include="System.Drawing" /> - <Reference Include="OpenTK.Compatibility, Version=1.1.0.0, Culture=neutral, PublicKeyToken=bad199fe84eb3df4"> - <HintPath>..\dependencies\OpenTK.Compatibility.dll</HintPath> - </Reference> - <Reference Include="OpenTK, Version=1.1.0.0, Culture=neutral, PublicKeyToken=bad199fe84eb3df4"> - <HintPath>..\dependencies\OpenTK.dll</HintPath> - </Reference> </ItemGroup> <ItemGroup> <Compile Include="GOLIBTest_5.cs"> @@ -123,5 +117,9 @@ <Project>{C2980F9B-4798-4C05-99E2-E174810F7C7B}</Project> <Name>GOLib</Name> </ProjectReference> + <ProjectReference Include="..\OpenTK\Source\OpenTK\OpenTK.csproj"> + <Project>{A37A7E14-0000-0000-0000-000000000000}</Project> + <Name>OpenTK</Name> + </ProjectReference> </ItemGroup> </Project> diff --git a/src/GraphicObjects/Checkbox.cs b/src/GraphicObjects/Checkbox.cs index 68704127..91f8e451 100755 --- a/src/GraphicObjects/Checkbox.cs +++ b/src/GraphicObjects/Checkbox.cs @@ -242,7 +242,7 @@ namespace go public override void ReadXml(System.Xml.XmlReader reader)
{
string handler = reader.GetAttribute("OnClick");
- GraphicObject.EventsToResolve.Add(new EventSource
+ Interface.EventsToResolve.Add(new EventSource
{
Source = this,
Handler = handler,
diff --git a/src/GraphicObjects/GraphicObject.cs b/src/GraphicObjects/GraphicObject.cs index 3f6bbc85..3ffda14a 100755 --- a/src/GraphicObjects/GraphicObject.cs +++ b/src/GraphicObjects/GraphicObject.cs @@ -54,11 +54,6 @@ namespace go bool yIsValid = false;
#endregion
- public static int TabSize = 4;
- public static string LineBreak = "\r\n";
- public static bool ReplaceTabsWithSpace = false;
- public static bool DesignerMode = false;
-
#region public fields
public Rectangle Bounds;
public Rectangle Slot = new Rectangle ();
@@ -249,7 +244,7 @@ namespace go }
[XmlAttributeAttribute()][DefaultValue(false)]
public virtual bool Focusable {
- get { return _focusable | DesignerMode; }
+ get { return _focusable | Interface.DesignerMode; }
set { _focusable = value; }
}
[XmlAttributeAttribute()][DefaultValue("Transparent")]
@@ -593,122 +588,6 @@ namespace go }
#endregion
- #region Load/Save
-
- internal static List<EventSource> EventsToResolve;
-
- public static void Save<T>(string file, T graphicObject)
- {
- XmlSerializerNamespaces xn = new XmlSerializerNamespaces();
- xn.Add("", "");
- XmlSerializer xs = new XmlSerializer(typeof(T));
-
- xs = new XmlSerializer(typeof(T));
- using (Stream s = new FileStream(file, FileMode.Create))
- {
- xs.Serialize(s, graphicObject, xn);
- }
- }
- public static GraphicObject Load(string path)
- {
- string root = "Object";
- using (Stream s = new FileStream (path, FileMode.Open)) {
- using (XmlReader reader = XmlReader.Create (s)) {
- while (reader.Read()) {
- // first element is the root element
- if (reader.NodeType == XmlNodeType.Element) {
- root = reader.Name;
- break;
- }
- }
- }
- }
- Type t = Type.GetType("go." + root);
- var go = Activator.CreateInstance(t);
- return Load(path, t);
- }
- public static void Load<T>(string file, out T result, object ClassContainingHandlers = null)
- {
- EventsToResolve = new List<EventSource>();
-
- XmlSerializerNamespaces xn = new XmlSerializerNamespaces();
- xn.Add("", "");
- XmlSerializer xs = new XmlSerializer(typeof(T));
-
- using (Stream s = new FileStream(file, FileMode.Open))
- {
- result = (T)xs.Deserialize(s);
- }
-
- if (ClassContainingHandlers == null)
- return;
-
- foreach (EventSource es in EventsToResolve)
- {
- if (string.IsNullOrEmpty(es.Handler))
- continue;
-
- if (es.Handler.StartsWith ("{")) {
- CompilerServices.CompileEventSource (es);
- } else {
- MethodInfo mi = ClassContainingHandlers.GetType ().GetMethod (es.Handler, BindingFlags.NonPublic | BindingFlags.Public
- | BindingFlags.Instance);
-
- if (mi == null) {
- Debug.WriteLine ("Handler Method not found: " + es.Handler);
- continue;
- }
-
- FieldInfo fi = CompilerServices.getEventHandlerField (es.Source.GetType (), es.EventName);
- Delegate del = Delegate.CreateDelegate(fi.FieldType, ClassContainingHandlers, mi);
- fi.SetValue(es.Source, del);
- }
- }
- }
-
- public static GraphicObject Load(string file, Type type, object ClassContainingHandlers = null)
- {
- GraphicObject result;
- EventsToResolve = new List<EventSource>();
-
- XmlSerializerNamespaces xn = new XmlSerializerNamespaces();
- xn.Add("", "");
- XmlSerializer xs = new XmlSerializer(type);
-
- using (Stream s = new FileStream(file, FileMode.Open))
- {
- result = (GraphicObject)xs.Deserialize(s);
- }
-
- if (ClassContainingHandlers == null)
- return result;
-
- foreach (EventSource es in EventsToResolve)
- {
- if (string.IsNullOrEmpty(es.Handler))
- continue;
-
- if (es.Handler.StartsWith ("{")) {
- CompilerServices.CompileEventSource (es);
- } else {
- MethodInfo mi = ClassContainingHandlers.GetType ().GetMethod (es.Handler, BindingFlags.NonPublic | BindingFlags.Public
- | BindingFlags.Instance);
-
- if (mi == null) {
- Debug.WriteLine ("Handler Method not found: " + es.Handler);
- continue;
- }
-
- FieldInfo fi = CompilerServices.getEventHandlerField (es.Source.GetType (), es.EventName);
- Delegate del = Delegate.CreateDelegate(fi.FieldType, ClassContainingHandlers, mi);
- fi.SetValue(es.Source, del);
- }
- }
- return result;
- }
-
- #endregion
-
public override string ToString ()
{
return Name == "unamed" ? this.GetType ().ToString() : Name;
@@ -732,7 +611,7 @@ namespace go if (string.IsNullOrEmpty (handler))
continue;
- GraphicObject.EventsToResolve.Add(new EventSource
+ Interface.EventsToResolve.Add(new EventSource
{
Source = this,
Handler = handler,
diff --git a/src/GraphicObjects/Label.cs b/src/GraphicObjects/Label.cs index aa93a7e9..ee62a266 100755 --- a/src/GraphicObjects/Label.cs +++ b/src/GraphicObjects/Label.cs @@ -78,7 +78,7 @@ namespace go {
get {
return lines == null ?
- _text : lines.Aggregate((i, j) => i + GraphicObject.LineBreak + j);
+ _text : lines.Aggregate((i, j) => i + Interface.LineBreak + j);
}
set
{
@@ -247,7 +247,7 @@ namespace go te = new TextExtents();
foreach (string s in lines) {
- string l = s.Replace("\t", new String (' ', GraphicObject.TabSize));
+ string l = s.Replace("\t", new String (' ', Interface.TabSize));
#if _WIN32 || _WIN64
TextExtents tmp = gr.TextExtents(str.ToUtf8());
@@ -432,7 +432,7 @@ namespace go gr.FontMatrix = new Matrix(widthRatio * Font.Size, 0, 0, heightRatio * Font.Size, 0, 0);
for (int i = 0; i < lines.Count; i++) {
- string l = lines [i].Replace ("\t", new String (' ', GraphicObject.TabSize));
+ string l = lines [i].Replace ("\t", new String (' ', Interface.TabSize));
if (selRelease >= 0 && i >= selectionStart.Y && i <= selectionEnd.Y) {
gr.Color = selColor;
int lineLength = (int)gr.TextExtents (l).XAdvance;
@@ -536,11 +536,15 @@ namespace go currentLine = (int)(mouseLocalPos.Y / fe.Height);
+ //fix cu
+ if (currentLine >= lines.Count)
+ currentLine = lines.Count - 1;
+
for (int i = 0; i < lines[currentLine].Length; i++)
{
string c = lines [currentLine].Substring (i, 1);
if (c == "\t")
- c = new string (' ', GraphicObject.TabSize);
+ c = new string (' ', Interface.TabSize);
#if _WIN32 || _WIN64
byte[] c = System.Text.UTF8Encoding.UTF8.GetBytes(Text.Substring(i, 1));
@@ -590,7 +594,7 @@ namespace go {
string c = lines [currentLine].Substring (i, 1);
if (c == "\t")
- c = new string (' ', GraphicObject.TabSize);
+ c = new string (' ', Interface.TabSize);
#if _WIN32 || _WIN64
byte[] c = System.Text.UTF8Encoding.UTF8.GetBytes(Text.Substring(i, 1));
te = gr.TextExtents(c);
diff --git a/src/Interface.cs b/src/Interface.cs new file mode 100644 index 00000000..8f862381 --- /dev/null +++ b/src/Interface.cs @@ -0,0 +1,154 @@ +// +// Interface.cs +// +// Author: +// Jean-Philippe Bruyère <jp.bruyere@hotmail.com> +// +// Copyright (c) 2015 jp +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see <http://www.gnu.org/licenses/>. +using System; +using System.Xml.Serialization; +using System.IO; +using System.Reflection; +using System.Diagnostics; +using System.Collections.Generic; +using System.Xml; + +namespace go +{ + public static class Interface + { + public static int TabSize = 4; + public static string LineBreak = "\r\n"; + public static bool ReplaceTabsWithSpace = false; + public static bool DesignerMode = false; + + #region Load/Save + + internal static List<EventSource> EventsToResolve; + + public static void Save<T>(string file, T graphicObject) + { + XmlSerializerNamespaces xn = new XmlSerializerNamespaces(); + xn.Add("", ""); + XmlSerializer xs = new XmlSerializer(typeof(T)); + + xs = new XmlSerializer(typeof(T)); + using (Stream s = new FileStream(file, FileMode.Create)) + { + xs.Serialize(s, graphicObject, xn); + } + } + public static GraphicObject Load(string path) + { + string root = "Object"; + using (Stream s = new FileStream (path, FileMode.Open)) { + using (XmlReader reader = XmlReader.Create (s)) { + while (reader.Read()) { + // first element is the root element + if (reader.NodeType == XmlNodeType.Element) { + root = reader.Name; + break; + } + } + } + } + Type t = Type.GetType("go." + root); + var go = Activator.CreateInstance(t); + return Load(path, t); + } + public static void Load<T>(string file, out T result, object ClassContainingHandlers = null) + { + EventsToResolve = new List<EventSource>(); + + XmlSerializerNamespaces xn = new XmlSerializerNamespaces(); + xn.Add("", ""); + XmlSerializer xs = new XmlSerializer(typeof(T)); + + using (Stream s = new FileStream(file, FileMode.Open)) + { + result = (T)xs.Deserialize(s); + } + + if (ClassContainingHandlers == null) + return; + + foreach (EventSource es in EventsToResolve) + { + if (string.IsNullOrEmpty(es.Handler)) + continue; + + if (es.Handler.StartsWith ("{")) { + CompilerServices.CompileEventSource (es); + } else { + MethodInfo mi = ClassContainingHandlers.GetType ().GetMethod (es.Handler, BindingFlags.NonPublic | BindingFlags.Public + | BindingFlags.Instance); + + if (mi == null) { + Debug.WriteLine ("Handler Method not found: " + es.Handler); + continue; + } + + FieldInfo fi = CompilerServices.getEventHandlerField (es.Source.GetType (), es.EventName); + Delegate del = Delegate.CreateDelegate(fi.FieldType, ClassContainingHandlers, mi); + fi.SetValue(es.Source, del); + } + } + } + public static GraphicObject Load(string file, Type type, object ClassContainingHandlers = null) + { + GraphicObject result; + EventsToResolve = new List<EventSource>(); + + XmlSerializerNamespaces xn = new XmlSerializerNamespaces(); + xn.Add("", ""); + XmlSerializer xs = new XmlSerializer(type); + + using (Stream s = new FileStream(file, FileMode.Open)) + { + result = (GraphicObject)xs.Deserialize(s); + } + + if (ClassContainingHandlers == null) + return result; + + foreach (EventSource es in EventsToResolve) + { + if (string.IsNullOrEmpty(es.Handler)) + continue; + + if (es.Handler.StartsWith ("{")) { + CompilerServices.CompileEventSource (es); + } else { + MethodInfo mi = ClassContainingHandlers.GetType ().GetMethod (es.Handler, BindingFlags.NonPublic | BindingFlags.Public + | BindingFlags.Instance); + + if (mi == null) { + Debug.WriteLine ("Handler Method not found: " + es.Handler); + continue; + } + + FieldInfo fi = CompilerServices.getEventHandlerField (es.Source.GetType (), es.EventName); + Delegate del = Delegate.CreateDelegate(fi.FieldType, ClassContainingHandlers, mi); + fi.SetValue(es.Source, del); + } + } + return result; + } + + #endregion + } +} + diff --git a/src/OpenTKGameWindow.cs b/src/OpenTKGameWindow.cs index 234c4be2..644c65c8 100755 --- a/src/OpenTKGameWindow.cs +++ b/src/OpenTKGameWindow.cs @@ -300,13 +300,13 @@ namespace go public void LoadInterface<T>(string path, out T result)
{
- GraphicObject.Load<T> (path, out result, this);
+ Interface.Load<T> (path, out result, this);
AddWidget (result as GraphicObject);
}
public T LoadInterface<T> (string Path)
{
T result;
- GraphicObject.Load<T> (Path, out result, this);
+ Interface.Load<T> (Path, out result, this);
AddWidget (result as GraphicObject);
return result;
}
|