Skip to content

Commit

Permalink
Merge pull request #577 from joecare99/master
Browse files Browse the repository at this point in the history
sync
  • Loading branch information
joecare99 authored Jan 10, 2025
2 parents 54aceb6 + c930d55 commit 0a2e038
Show file tree
Hide file tree
Showing 109 changed files with 5,572 additions and 315 deletions.
27 changes: 11 additions & 16 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,29 @@
*.exe
*.dll
*.bak
*.user
*.bak
/.svn
/.vs
/bin
/obj
/obj.net
/*/.vs
/CSharpBible/*/.vs
/*/obj
/*/bin
/*/TestResults
/*/*/TestResults
/*/*/.vs
/*/*/obj
/*/*/bin
/*/*/*/.vs
/*/*/*/obj
/*/*/*/bin
/*/*/*/TestResults
/CSharpBible/Help
/CSharpBible/Mobile
/CSharpBible/Web
/CSharpBible/WinUI
/CSharpBible/AboutEx/obj
/CSharpBible/AboutEx/publish
/CSharpBible/AboutExTests/bin
Expand All @@ -42,9 +49,12 @@
/CSharpBible/CSV_ViewerTest/obj
/CSharpBible/ConsoleMouseApp/obj
/CSharpBible/ConsoleLib/obj
/CSharpBible/DB/ADO_Test
/CSharpBible/DataGridEx/obj
/CSharpBible/DataGridExWPF/obj
/CSharpBible/packages
/CSharpBible/Basics/.vs
/CSharpBible/Basics/.vs
/NUnitTestProject1/NUnitTestProject1/obj
/TestStatements/.vs
/TestStatements/AsyncExample/obj
Expand All @@ -66,21 +76,6 @@
/CSharpProgrammierHandbuch/Fibonacci2
/TestStatements/AsyncExampleWPF
/TestStatements/Tutorials/obj/Debug
/CSharpBible/Basics/.vs
/CSharpBible/Basics/.vs
*.user
*.bak
/CSharpBible/Calc/.vs
/CSharpBible/DB/.vs
/CSharpBible/Mobile
/CSharpBible/MVVM_Tutorial/.vs
/CSharpBible/Calc/Help
/CSharpBible/DependencyInjection/.vs
/CSharpBible/CSharpBibleTest/.vs
/CSharpBible/Games/.vs
/CSharpBible/Graphics/.vs
/GenFreeWin/.vs
/JC-AMS/.vs
/obj
/obj.net
/TestStatements/Help
Expand Down
25 changes: 25 additions & 0 deletions CSharpBible/ConsoleDisplay/View/ITileDef.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// ***********************************************************************
// Assembly : ConsoleDisplay
// Author : Mir
// Created : 08-19-2022
//
// Last Modified By : Mir
// Last Modified On : 08-27-2022
// ***********************************************************************
// <copyright file="TileDisplay.cs" company="ConsoleDisplay">
// Copyright (c) JC-Soft. All rights reserved.
// </copyright>
// <summary></summary>
// ***********************************************************************
using System;
using System.Drawing;

namespace ConsoleDisplay.View
{
public interface ITileDef
{
Size TileSize { get; }

(string[] lines, (ConsoleColor fgr, ConsoleColor bgr)[] colors) GetTileDef(Enum? tile);
}
}
39 changes: 39 additions & 0 deletions CSharpBible/ConsoleDisplay/View/Interfaces/IConsole.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// ***********************************************************************
// Assembly : ConsoleDisplay
// Author : Mir
// Created : 07-16-2022
//
// Last Modified By : Mir
// Last Modified On : 07-24-2022
// ***********************************************************************
// <copyright file="MyConsoleBase.cs" company="ConsoleDisplay">
// Copyright (c) JC-Soft. All rights reserved.
// </copyright>
// <summary></summary>
// ***********************************************************************
using System;

namespace ConsoleDisplay.View
{
public interface IConsole
{
ConsoleColor ForegroundColor { get; set; }
ConsoleColor BackgroundColor { get; set; }
bool IsOutputRedirected { get; }
bool KeyAvailable { get; }
int LargestWindowHeight { get; }
string Title { get; set; }
int WindowHeight { get; set; }
int WindowWidth { get; set; }

void Beep(int freq, int len);
void Clear();
(int Left, int Top) GetCursorPosition();
ConsoleKeyInfo? ReadKey();
string ReadLine();
void SetCursorPosition(int left, int top);
void Write(char ch);
void Write(string? st);
void WriteLine(string? st = "");
}
}
36 changes: 36 additions & 0 deletions CSharpBible/ConsoleDisplay/View/Interfaces/ITileDisplay.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// ***********************************************************************
// Assembly : ConsoleDisplay
// Author : Mir
// Created : 08-19-2022
//
// Last Modified By : Mir
// Last Modified On : 08-27-2022
// ***********************************************************************
// <copyright file="TileDisplay.cs" company="ConsoleDisplay">
// Copyright (c) JC-Soft. All rights reserved.
// </copyright>
// <summary></summary>
// ***********************************************************************
using System;
using System.Drawing;

namespace ConsoleDisplay.View
{
public interface ITileDisplay<T>
{
T? this[Point Idx] { get; set; }

Point Position { get; }
Size DispSize { get; }
Size TileSize { get; }
IConsole console { get; }
Point DispOffset { get; set; }
Func<Point, T>? FncGetTile { get; set; }
Func<Point, Point>? FncOldPos { get; set; }

void FullRedraw();
void SetDispSize(Size size);
void Update(bool e);
void WriteTile(PointF p, T tile);
}
}
2 changes: 1 addition & 1 deletion CSharpBible/ConsoleDisplay/View/TileDefBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ namespace ConsoleDisplay.View {
/// Class TileDef.
/// </summary>
/// <typeparam name="Enum">The type of the enum.</typeparam>
public abstract class TileDefBase
public abstract class TileDefBase : ITileDef
{
/// <summary>
/// Gets the tile definition.
Expand Down
45 changes: 18 additions & 27 deletions CSharpBible/ConsoleDisplay/View/TileDisplay.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public class TileDisplay<T>: ITileDisplay<T>
/// it returns the default-tileDef when the local tileDef isn't set.
/// </summary>
/// <value>The tile definition.</value>
public TileDefBase? TileDef { get => _tileDef ?? tileDef; set => _tileDef = value; }
public ITileDef? TileDef { get => _tileDef ?? tileDef; set => _tileDef = value; }

public Point DispOffset { get; set; } = Point.Empty;
public Func<Point, T>? FncGetTile { get; set; }
Expand Down Expand Up @@ -96,7 +96,7 @@ public class TileDisplay<T>: ITileDisplay<T>
/// <summary>
/// The (local) tile-definition
/// </summary>
private TileDefBase? _tileDef;
private ITileDef? _tileDef;
#endregion
#endregion

Expand Down Expand Up @@ -154,46 +154,44 @@ private static void WriteTileChunk(IConsole console,Point Offset, PointF p, (str
/// <summary>
/// Initializes a new instance of the <see cref="TileDisplay{T}"/> class.
/// </summary>
public TileDisplay() : this(new MyConsole(),Point.Empty,Size.Empty){}
public TileDisplay() : this(new MyConsole(),tileDef!,Point.Empty,Size.Empty){}

/// <summary>
/// Initializes a new instance of the <see cref="TileDisplay{T}"/> class.
/// </summary>
public TileDisplay(IConsole console) : this(console, Point.Empty, Size.Empty) { }
public TileDisplay(IConsole console,ITileDef tileDef) : this(console, tileDef, Point.Empty, Size.Empty) { }

/// <summary>
/// Initializes a new instance of the <see cref="TileDisplay{T}"/> class.
/// </summary>
/// <param name="position">The position.</param>
/// <param name="size">The size.</param>
public TileDisplay(IConsole console,Point position, Size size) : this(console, position, size,tileDef?.TileSize ?? new Size(4,2)) { }
public TileDisplay(IConsole console, ITileDef tileDef, Point position, Size size) : this(console, tileDef, position, size,tileDef?.TileSize ?? new Size(4,2)) { }

/// <summary>
/// Initializes a new instance of the <see cref="TileDisplay{T}"/> class.
/// </summary>
/// <param name="position">The position.</param>
/// <param name="size">The size.</param>
/// <param name="aTileDef">The tile-definition.</param>
public TileDisplay(IConsole console,Point position, Size size, TileDefBase aTileDef) : this(console,position, size, aTileDef.TileSize ) {
TileDef = aTileDef;
}

/// <summary>
/// Initializes a new instance of the <see cref="TileDisplay{T}"/> class.
/// </summary>
/// <param name="position">The position.</param>
/// <param name="size">The size.</param>
/// <param name="tileSize">Size of the tile.</param>
public TileDisplay(IConsole console,Point position,Size size, Size tileSize)
public TileDisplay(IConsole console, ITileDef tileDef, Point position,Size size, Size tileSize)
{
this.console = console;
_tileDef = tileDef;
_rect.Location = position;
_tileSize = tileSize != Size.Empty ? tileSize : new Size(4, 2);
SetDispSize(size);
}

public void SetDispSize(Size size)
{
if (size == Size.Empty)
_size = new Size(console.WindowWidth / _tileSize.Width,console.WindowHeight/_tileSize.Height);
_size = new Size(console.WindowWidth / _tileSize.Width, console.WindowHeight / _tileSize.Height);
else
_size = size;
_rect.Size = new Size(_size.Width * _tileSize.Width,_size.Height * _tileSize.Height);
_rect.Size = new Size(_size.Width * _tileSize.Width, _size.Height * _tileSize.Height);
_changed = true;
}

#region private Methods
Expand Down Expand Up @@ -332,28 +330,21 @@ public TileDisplay() : base() { }
/// <summary>
/// Initializes a new instance of the <see cref="TileDisplay{T}"/> class.
/// </summary>
public TileDisplay(IConsole console) : base(console) { }
public TileDisplay(IConsole console, ITileDef tileDef) : base(console,tileDef) { }

/// <summary>
/// Initializes a new instance of the <see cref="TileDisplay{T}"/> class.
/// </summary>
/// <param name="position">The position.</param>
/// <param name="size">The size.</param>
public TileDisplay(IConsole console,Point position, Size size) : base(console, position, size) { }
public TileDisplay(IConsole console,ITileDef tileDef, Point position, Size size) : base(console, tileDef, position, size) { }

/// <summary>
/// Initializes a new instance of the <see cref="TileDisplay{T}"/> class.
/// </summary>
/// <param name="position">The position.</param>
/// <param name="size">The size.</param>
/// <param name="aTileDef">The tile-definition.</param>
public TileDisplay(IConsole console, Point position, Size size, TileDefBase aTileDef) : base(console, position, size, aTileDef) { }

/// <summary>
/// Initializes a new instance of the <see cref="TileDisplay{T}"/> class.
/// </summary>
/// <param name="position">The position.</param>
/// <param name="size">The size.</param>
/// <param name="tileSize">Size of the tile.</param>
public TileDisplay(IConsole console, Point position, Size size, Size tileSize) : base(console, position, size, tileSize) { }
public TileDisplay(IConsole console, ITileDef tileDef, Point position, Size size, Size tileSize) : base(console, tileDef, position, size, tileSize) { }
}
10 changes: 10 additions & 0 deletions CSharpBible/Games/CsEpiphany/Model/Direction.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
namespace CsEpiphany.Model
{
public enum Direction
{
UP,
DOWN,
RIGHT,
LEFT
}
}
22 changes: 22 additions & 0 deletions CSharpBible/Games/Game_Base/Helper/CRandom.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using BaseLib.Interfaces;
using System;

namespace BaseLib.Helper;

public class CRandom :IRandom
{
private Random _random;

public CRandom()
{
_random = new Random();
}

public int Next(int v1, int v2) => v2 !=-1 || v1<v2? _random.Next(v1, v2): _random.Next(v1);

public double NextDouble() => _random.NextDouble();

public int NextInt() => _random.Next();

public void Seed(int value) => _random = new Random(value);
}
12 changes: 12 additions & 0 deletions CSharpBible/Games/Game_Base/Helper/SysTime.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using BaseLib.Interfaces;
using System;

namespace BaseLib.Helper;

public class SysTime : ISysTime
{
public static Func<DateTime> GetNow {get; set;} = () => DateTime.Now;
public DateTime Now => GetNow();
public DateTime Today => GetNow().Date;

}
6 changes: 6 additions & 0 deletions CSharpBible/Games/Game_Base/Model/Interfaces/IHasValue.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
namespace BaseLib.Interfaces;

public interface IHasValue
{
object? Value { get; }
}
10 changes: 10 additions & 0 deletions CSharpBible/Games/Game_Base/Model/Interfaces/ILog.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
using System;

namespace BaseLib.Interfaces;

public interface ILog
{
public void Log(string message);

public void Log(string message, Exception exception);
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public interface IPlacedObject
/// <summary>
/// Occurs when [on place change].
/// </summary>
event EventHandler<(Point oP, Point nP)> OnPlaceChange;
event EventHandler<(Point oP, Point nP)>? OnPlaceChange;
#if NET6_0_OR_GREATER
/// <summary>
/// Gets or sets the place.
Expand Down
31 changes: 31 additions & 0 deletions CSharpBible/Games/Game_Base/Model/Interfaces/IPlayfield2D.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// ***********************************************************************
// Assembly : Snake_Base
// Author : Mir
// Created : 08-24-2022
//
// Last Modified By : Mir
// Last Modified On : 09-09-2022
// ***********************************************************************
// <copyright file="Playfield2D.cs" company="JC-Soft">
// Copyright (c) JC-Soft. All rights reserved.
// </copyright>
// <summary></summary>
// ***********************************************************************
using System;
using System.Collections.Generic;
using System.Drawing;

namespace Game_Base.Model;

public interface IPlayfield2D<T> where T : class
{
T? this[Point p] { get;set; }

Size PfSize { get; set; }
Rectangle Rect { get; }
IEnumerable<T> Items { get; }

event EventHandler<(string prop, object? oldVal, object? newVal)>? OnDataChanged;

bool IsInside(Point P);
}
Loading

0 comments on commit 0a2e038

Please sign in to comment.