Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
Martenfur committed Oct 25, 2019
2 parents ec2649b + 9ef76ed commit b07ca6e
Show file tree
Hide file tree
Showing 26 changed files with 324 additions and 458 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
- All Monofoxe libraries are .NET Standard now.
- Nopipeline is now embedded into Monofoxe.
- All projects reference Monofoxe libraries from common place instead of raw per-project libraries.
- Replaced static methods in `TimeKeeper` with static `Global` instance.
- Removed drawing methods which work with raw x;y.
- Project templates for VS2019 now have tags.

### FIXES:

Expand All @@ -31,6 +34,7 @@
- Fixed `BasicTilemapSystem` not drawing the very last row and column of tiles.
- Nopipeline now works with paths which contain spaces.
- Angle difference formula now works properly.
- Uninstaller now appears in Add\Remove Programs section.



Expand Down
2 changes: 1 addition & 1 deletion Docs/MonofoxeBasics.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ while(!quit)
{
Update();
Draw();
WaitForNextFrame();
WaitForNextFrame();
}
```

Expand Down
2 changes: 1 addition & 1 deletion Docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ You're expected to know:
- Basics of OOP.
- At least five different fox species.

Docs will not describe each and every function of Monofoxe. For that you'll need to look in the source code - don't worry, it's all described and documented in there. Main purpose of the docs is to tell you how and when to use main features of the engine.
Docs will not describe each and every function of Monofoxe. For that you'll need to look in the source code - don't worry, it's all nice and documented in there. Main purpose of the docs is to tell you how and when to use main features of the engine.

A good place to start is the [Table of Contents](Contents.md).

Expand Down
14 changes: 14 additions & 0 deletions Installer/packInstaller.nsi
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
!define NOPIPELINEROOT "..\NoPipeline\NoPipeline\NoPipeline\bin\Release"
!define TEMPLATES_DIRECTORY "Templates\ProjectTemplates\Visual C#\${APPNAME} ${APPVERSION}"

!define REGISTRY_DIRECTORY "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APPNAME} ${APPVERSION}"

!include "Sections.nsh"
!include "MUI2.nsh"
!include "InstallOptions.nsh"
Expand Down Expand Up @@ -72,6 +74,17 @@ Section "Monofoxe" Monofoxe

File /r "Externals\Monofoxe.NoPipeline.targets"
# NoPipeline.

# Registering the installation.

WriteRegStr HKLM "${REGISTRY_DIRECTORY}" "DisplayName" "${APPNAME}"
WriteRegStr HKLM "${REGISTRY_DIRECTORY}" "UninstallString" "$\"$INSTDIR\uninstall.exe$\""
WriteRegStr HKLM "${REGISTRY_DIRECTORY}" "QuietUninstallString" "$\"$INSTDIR\uninstall.exe$\""
WriteRegStr HKLM "${REGISTRY_DIRECTORY}" "DisplayIcon" "$\"$INSTDIR\uninstall.exe$\""
WriteRegStr HKLM "${REGISTRY_DIRECTORY}" "DisplayVersion" "${APPVERSION}"


# Registering the installation.
SectionEnd

Section "MonoGame" Monogame
Expand Down Expand Up @@ -172,6 +185,7 @@ Section "Uninstall"
RMDir /r "$DOCUMENTS\Visual Studio 2019\${TEMPLATES_DIRECTORY}"
Delete "$INSTDIR\Uninstall.exe"
RMDir /r "$INSTDIR"
DeleteRegKey HKLM "${REGISTRY_DIRECTORY}"
SectionEnd


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,3 @@
/processor:TiledMapProcessor
/build:Maps/test.tmx


Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public override void Update(List<Component> components)
var position = actor.Owner.GetComponent<PositionComponent>();

position.PreviousPosition = position.Position;
position.Position += TimeKeeper.GlobalTime(actor.Speed) * actor.Direction.ToVector2();
position.Position += TimeKeeper.Global.Time(actor.Speed) * actor.Direction.ToVector2();
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public override void Update(List<Component> components)
{
var actor = bot.Owner.GetComponent<ActorComponent>();
actor.Move = true;
actor.Direction += TimeKeeper.GlobalTime(bot.TurningSpeed); // ni-ni-ni-ni-ni-ni-ni-ni-ni-ni-ni-ni-ni-ni
actor.Direction += TimeKeeper.Global.Time(bot.TurningSpeed); // ni-ni-ni-ni-ni-ni-ni-ni-ni-ni-ni-ni-ni-ni
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public SpriteDemo(Layer layer) : base(layer)
public override void Update()
{
// Basic animation code.
_animation += TimeKeeper.GlobalTime(_animationSpeed);
_animation += TimeKeeper.Global.Time(_animationSpeed);
if (_animation > 1)
{
_animation -= 1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,12 @@ public override void Update()

var rotatedMovementVector = new Vector2(movementVector3.X, movementVector3.Y);

Camera.Position += TimeKeeper.GlobalTime(_cameraSpeed / Camera.Zoom) * rotatedMovementVector;
Camera.Position += TimeKeeper.Global.Time(_cameraSpeed / Camera.Zoom) * rotatedMovementVector;
// Movement.

// Zoom.
var zoomDirection = Input.CheckButton(ZoomInButton).ToInt() - Input.CheckButton(ZoomOutButton).ToInt();
Camera.Zoom += TimeKeeper.GlobalTime(_zoomSpeed) * zoomDirection;
Camera.Zoom += TimeKeeper.Global.Time(_zoomSpeed) * zoomDirection;

if (Camera.Zoom < _minZoom)
{
Expand All @@ -74,7 +74,7 @@ public override void Update()

// Rotation.
var rotationDirection = Input.CheckButton(RotateLeftButton).ToInt() - Input.CheckButton(RotateRightButton).ToInt();
Camera.Rotation += TimeKeeper.GlobalTime(_rotationSpeed) * rotationDirection;
Camera.Rotation += TimeKeeper.Global.Time(_rotationSpeed) * rotationDirection;
// Rotation.

}
Expand Down
23 changes: 6 additions & 17 deletions Monofoxe/Monofoxe.Engine/Drawing/CircleShape.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public class CircleShape : IDrawable
public Color Color = Color.White;

public void Draw() =>
Draw(Position.X, Position.Y, Radius, IsOutline, Color);
Draw(Position, Radius, IsOutline, Color);



Expand Down Expand Up @@ -54,24 +54,13 @@ public static int CircleVerticesCount
/// Draws a circle.
/// </summary>
public static void Draw(Vector2 p, float r, bool isOutline) =>
Draw(p.X, p.Y, r, isOutline, GraphicsMgr.CurrentColor);
Draw(p, r, isOutline, GraphicsMgr.CurrentColor);


/// <summary>
/// Draws a circle.
/// </summary>
public static void Draw(float x, float y, float r, bool isOutline) =>
Draw(x, y, r, isOutline, GraphicsMgr.CurrentColor);

/// <summary>
/// Draws a circle.
/// </summary>
public static void Draw(Vector2 p, float r, bool isOutline, Color color) =>
Draw(p.X, p.Y, r, isOutline, color);

/// <summary>
/// Draws a circle.
/// </summary>
public static void Draw(float x, float y, float r, bool isOutline, Color color)
public static void Draw(Vector2 p, float r, bool isOutline, Color color)
{
short[] indexArray;
GraphicsMode prType;
Expand Down Expand Up @@ -109,8 +98,8 @@ public static void Draw(float x, float y, float r, bool isOutline, Color color)
vertices.Add(
new VertexPositionColorTexture(
new Vector3(
x + r * _circleVectors[i].X,
y + r * _circleVectors[i].Y,
p.X + r * _circleVectors[i].X,
p.Y + r * _circleVectors[i].Y,
0
),
color,
Expand Down
23 changes: 4 additions & 19 deletions Monofoxe/Monofoxe.Engine/Drawing/LineShape.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,37 +29,22 @@ public class LineShape : IDrawable
public void Draw() =>
Draw(Point1 + Position, Point2 + Position, Color, Color);


private static readonly short[] _lineIndices = new short[]{0, 1, 3, 1, 2, 3};


/// <summary>
/// Draws a line.
/// </summary>
public static void Draw(Vector2 p1, Vector2 p2) =>
Draw(p1.X, p1.Y, p2.X, p2.Y, GraphicsMgr.CurrentColor, GraphicsMgr.CurrentColor);

/// <summary>
/// Draws a line with specified colors.
/// </summary>
public static void Draw(Vector2 p1, Vector2 p2, Color c1, Color c2) =>
Draw(p1.X, p1.Y, p2.X, p2.Y, c1, c2);
Draw(p1, p2, GraphicsMgr.CurrentColor, GraphicsMgr.CurrentColor);

/// <summary>
/// Draws a line.
/// </summary>
public static void Draw(float x1, float y1, float x2, float y2) =>
Draw(x1, y1, x2, y2, GraphicsMgr.CurrentColor, GraphicsMgr.CurrentColor);

/// <summary>
/// Draws a line with specified colors.
/// </summary>
public static void Draw(float x1, float y1, float x2, float y2, Color c1, Color c2)
public static void Draw(Vector2 p1, Vector2 p2, Color c1, Color c2)
{
var vertices = new List<VertexPositionColorTexture>
{
new VertexPositionColorTexture(new Vector3(x1, y1, 0), c1, Vector2.Zero),
new VertexPositionColorTexture(new Vector3(x2, y2, 0), c2, Vector2.Zero)
new VertexPositionColorTexture(p1.ToVector3(), c1, Vector2.Zero),
new VertexPositionColorTexture(p2.ToVector3(), c2, Vector2.Zero)
};

GraphicsMgr.AddVertices(GraphicsMode.LinePrimitives, null, vertices, new short[]{0, 1});
Expand Down
50 changes: 18 additions & 32 deletions Monofoxe/Monofoxe.Engine/Drawing/RectangleShape.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@ public class RectangleShape : IDrawable
public void Draw()
{
Draw(
Position.X - Size.X / 2, Position.Y - Size.Y / 2,
Position.X + Size.X / 2, Position.Y + Size.Y / 2,
Position - Size / 2, Position - Size / 2,
IsOutline,
Color, Color, Color, Color
);
Expand All @@ -44,24 +43,20 @@ public void Draw()
/// Draws a rectangle using top left and bottom right point.
/// </summary>
public static void Draw(Vector2 p1, Vector2 p2, bool isOutline) =>
Draw(p1.X, p1.Y, p2.X, p2.Y, isOutline, GraphicsMgr.CurrentColor, GraphicsMgr.CurrentColor, GraphicsMgr.CurrentColor, GraphicsMgr.CurrentColor);
Draw(p1, p2, isOutline, GraphicsMgr.CurrentColor, GraphicsMgr.CurrentColor, GraphicsMgr.CurrentColor, GraphicsMgr.CurrentColor);

/// <summary>
/// Draws a rectangle using top left and bottom right point with specified colors for each corner.
/// </summary>
public static void Draw(Vector2 p1, Vector2 p2, bool isOutline, Color c1, Color c2, Color c3, Color c4) =>
Draw(p1.X, p1.Y, p2.X, p2.Y, isOutline, c1, c2, c3, c4);

/// <summary>
/// Draws a rectangle using top left and bottom right point.
/// </summary>
public static void Draw(float x1, float y1, float x2, float y2, bool isOutline) =>
Draw(x1, y1, x2, y2, isOutline, GraphicsMgr.CurrentColor, GraphicsMgr.CurrentColor, GraphicsMgr.CurrentColor, GraphicsMgr.CurrentColor);

/// <summary>
/// Draws a rectangle using top left and bottom right point with specified colors for each corner.
/// </summary>
public static void Draw(float x1, float y1, float x2, float y2, bool isOutline, Color c1, Color c2, Color c3, Color c4)
public static void Draw(
Vector2 p1,
Vector2 p2,
bool isOutline,
Color c1,
Color c2,
Color c3,
Color c4
)
{
GraphicsMode mode;
short[] indices;
Expand All @@ -75,7 +70,11 @@ public static void Draw(float x1, float y1, float x2, float y2, bool isOutline,
mode = GraphicsMode.TrianglePrimitives;
indices = _rectangleIndices[0];
}

var x1 = p1.X;
var y1 = p1.Y;
var x2 = p2.X;
var y2 = p2.Y;

var vertices = new List<VertexPositionColorTexture>
{
new VertexPositionColorTexture(new Vector3(x1, y1, 0), c1, Vector2.Zero),
Expand All @@ -92,27 +91,14 @@ public static void Draw(float x1, float y1, float x2, float y2, bool isOutline,
/// Draws a rectangle using center point and size.
/// </summary>
public static void DrawBySize(Vector2 p, Vector2 size, bool isOutline) =>
Draw(p.X - size.X / 2, p.Y - size.Y / 2, p.X + size.X / 2, p.Y + size.Y / 2, isOutline, GraphicsMgr.CurrentColor, GraphicsMgr.CurrentColor, GraphicsMgr.CurrentColor, GraphicsMgr.CurrentColor);
Draw(p - size / 2, p + size / 2f, isOutline, GraphicsMgr.CurrentColor, GraphicsMgr.CurrentColor, GraphicsMgr.CurrentColor, GraphicsMgr.CurrentColor);

/// <summary>
/// Draws a rectangle using center point and size with specified colors for each corner.
/// </summary>
public static void DrawBySize(Vector2 p, Vector2 size, bool isOutline, Color c1, Color c2, Color c3, Color c4) =>
Draw(p.X - size.X / 2, p.Y - size.Y / 2, p.X + size.X / 2, p.Y + size.Y / 2, isOutline, c1, c2, c3, c4);
Draw(p - size / 2f, p + size / 2f, isOutline, c1, c2, c3, c4);

/// <summary>
/// Draws a rectangle using center point and size.
/// </summary>
public static void DrawBySize(float x, float y, float w, float h, bool isOutline) =>
Draw(x - w / 2, y - h / 2, x + w / 2, y + h / 2, isOutline, GraphicsMgr.CurrentColor, GraphicsMgr.CurrentColor, GraphicsMgr.CurrentColor, GraphicsMgr.CurrentColor);

/// <summary>
/// Draws a rectangle using center point and size with specified colors for each corner.
/// </summary>
public static void DrawBySize(float x, float y, float w, float h, bool isOutline, Color c1, Color c2, Color c3, Color c4) =>
Draw(x - w / 2, y - h / 2, x + w / 2, y + h / 2, isOutline, c1, c2, c3, c4);




}
Expand Down
32 changes: 7 additions & 25 deletions Monofoxe/Monofoxe.Engine/Drawing/Text.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,6 @@ public Text(string str, Vector2 position, Vector2 scale, Vector2 origin, Angle r
public void Draw() =>
Draw(String, Position, Scale, Origin, Rotation);



/// <summary>
/// Draws text in specified coordinates.
/// </summary>
public static void Draw(string text, float x, float y) =>
Draw(text, new Vector2(x, y));

/// <summary>
/// Draws text in specified coordinates.
/// </summary>
Expand Down Expand Up @@ -75,23 +67,13 @@ public static void Draw(string text, Vector2 position)
CurrentFont.Draw(GraphicsMgr._batch, text, position, HorAlign, VerAlign);
}

/// <summary>
/// Draws text in specified coordinates with rotation, scale and origin.
/// </summary>
public static void Draw(string text, Vector2 position, Vector2 scale, Vector2 origin, Angle rotation) =>
Draw(text, position.X, position.Y, scale.X, scale.Y, origin.X, origin.Y, rotation);

/// <summary>
/// Draws text in specified coordinates with rotation, scale and origin.
/// </summary>
public static void Draw(
string text,
float x,
float y,
float scaleX,
float scaleY,
float originX,
float originY,
string text,
Vector2 position,
Vector2 scale, Vector2 origin,
Angle rotation
)
{
Expand All @@ -101,10 +83,10 @@ Angle rotation
}

var transformMatrix =
Matrix.CreateTranslation(new Vector3(-originX, -originY, 0)) * // Origin.
Matrix.CreateRotationZ(-rotation.RadiansF) * // Rotation.
Matrix.CreateScale(new Vector3(scaleX, scaleY, 1)) * // Scale.
Matrix.CreateTranslation(new Vector3(x, y, 0)); // Position.
Matrix.CreateTranslation(new Vector3(-origin.X, -origin.Y, 0)) * // Origin.
Matrix.CreateRotationZ(-rotation.RadiansF) * // Rotation.
Matrix.CreateScale(new Vector3(scale.X, scale.Y, 1)) * // Scale.
Matrix.CreateTranslation(new Vector3(position.X, position.Y, 0)); // Position.

GraphicsMgr.AddTransformMatrix(transformMatrix);

Expand Down
Loading

0 comments on commit b07ca6e

Please sign in to comment.