Skip to content

Commit

Permalink
implemented about 10 window_ functions
Browse files Browse the repository at this point in the history
from #64
  • Loading branch information
lofcz committed Dec 17, 2018
1 parent 6f157fd commit 71130a3
Show file tree
Hide file tree
Showing 14 changed files with 117 additions and 8 deletions.
13 changes: 13 additions & 0 deletions SimplexCore/NativeMethods.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Runtime.InteropServices;
using System.Text;

Expand All @@ -19,10 +20,22 @@ public static class NativeMethods
[DllImport("user32.dll")]
static extern bool PostMessage(IntPtr hWnd, UInt32 Msg, int wParam, int lParam);

[DllImport("user32.dll")]
public static extern bool GetCursorInfo(out CursorInfo info);

public static void SimulateKeyPress(byte keyCode)
{
keybd_event(VK_NUMLOCK, 0x45, KEYEVENTF_EXTENDEDKEY, 0);
keybd_event(VK_NUMLOCK, 0x45, KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP, 0);
}
}

[StructLayout(LayoutKind.Sequential)]
public struct CursorInfo
{
public int Size;
public int Flags;
public IntPtr Handle;
public Point Position;
}
}
96 changes: 96 additions & 0 deletions SimplexCore/SgmlWindow.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using System.Text;
using System.Windows.Forms;
using Microsoft.Xna.Framework;
using SimplexIde;

namespace SimplexCore
{
public static partial class Sgml
{
public static Form1 form;
public static Color outsideColor = Color.Black;

public static void window_center()
{
#if EDITOR
form.Location = new System.Drawing.Point((Screen.PrimaryScreen.WorkingArea.Width - form.Width) / 2, (Screen.PrimaryScreen.WorkingArea.Height - form.Height) / 2);
#endif
}

public static string window_get_caption()
{
#if EDITOR
return form.Text;
#endif
}

public static Color window_get_colour()
{
#if EDITOR
return outsideColor;
#endif
}

public static bool window_get_fullscreen()
{
#if EDITOR
return form.WindowState == FormWindowState.Maximized;
#endif
}

public static int window_get_height()
{
#if EDITOR
return form.Height;
#endif
}

public static int window_get_width()
{
#if EDITOR
return form.Width;
#endif
}

public static int window_get_x()
{
#if EDITOR
return form.Location.X;
#endif
}

public static int window_get_y()
{
#if EDITOR
return form.Location.Y;
#endif
}

public static int window_get_cursor()
{
#if EDITOR
CursorInfo ci = new CursorInfo();
ci.Size = Marshal.SizeOf(ci.GetType());

if (NativeMethods.GetCursorInfo(out ci))
{
Cursor c = new Cursor(ci.Handle);
return c.GetHashCode();
}

return -1;
#endif
}

public static int window_get_y()
{
#if EDITOR
return form.Location.Y;
#endif
}

}
}
1 change: 1 addition & 0 deletions SimplexCore/SimplexCore.projitems
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
<Compile Include="$(MSBuildThisFileDirectory)SgmlMovement.cs" />
<Compile Include="$(MSBuildThisFileDirectory)SgmlString.cs" />
<Compile Include="$(MSBuildThisFileDirectory)SgmlSynth.cs" />
<Compile Include="$(MSBuildThisFileDirectory)SgmlWindow.cs" />
<Compile Include="$(MSBuildThisFileDirectory)SimplexCamera.cs" />
<Compile Include="$(MSBuildThisFileDirectory)SimplexMath.cs" />
<Compile Include="$(MSBuildThisFileDirectory)SpatialHash.cs" />
Expand Down
2 changes: 1 addition & 1 deletion SimplexIde/DrawTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public class DrawTest : UpdateWindow
protected override void Initialize()
{
base.Initialize();

Sgml.SceneObjects = SceneObjects;
Sgml.roomLayers = roomLayers;
Sgml.Textures = Textures;
Expand Down
2 changes: 1 addition & 1 deletion SimplexIde/Form1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public partial class Form1 : DarkForm
public Form1()
{
InitializeComponent();

Sgml.form = this;
//Opacity = .5;
}

Expand Down
4 changes: 2 additions & 2 deletions SimplexIde/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
[assembly: AssemblyTitle("SimplexIde")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("HP Inc.")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("SimplexIde")]
[assembly: AssemblyCopyright("Copyright © HP Inc. 2018")]
[assembly: AssemblyCopyright("")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

Expand Down
2 changes: 1 addition & 1 deletion SimplexIde/SimplexIde.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DefineConstants>TRACE;DEBUG;EDITOR</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<AllowUnsafeBlocks>false</AllowUnsafeBlocks>
Expand Down
Binary file modified SimplexIde/bin/Debug/SimplexIde.exe
Binary file not shown.
Binary file modified SimplexIde/bin/Debug/SimplexIde.pdb
Binary file not shown.
Binary file modified SimplexIde/obj/Debug/DesignTimeResolveAssemblyReferences.cache
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1 +1 @@
473d47255d1711cf2dfa9aed412f53fdac8e4c2f
e50e4de07efe3b905ecf1f84127247c4bbac9374
Binary file modified SimplexIde/obj/Debug/SimplexIde.exe
Binary file not shown.
Binary file modified SimplexIde/obj/Debug/SimplexIde.pdb
Binary file not shown.
3 changes: 1 addition & 2 deletions SimplexResources/Objects/Object3.cs
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,7 @@ public override void EvtDraw(SpriteBatch s, SpriteFont f, Texture2D objectTextur

if (keyboard_check_released(Keys.L))
{
MessageBox.Show("kokot", "koko", new[] {"bléééééé"});

window_center();
}

draw_rectangle(Vector2.Zero, new Vector2(1024, 768), true);
Expand Down

0 comments on commit 71130a3

Please sign in to comment.