Replace debug.debug() with a dummy function

This commit is contained in:
Alessandro Proto 2023-05-19 08:17:07 +02:00
parent efe510d0da
commit b44f943456
2 changed files with 40 additions and 24 deletions

View file

@ -41,7 +41,6 @@ public enum EngineMode
Free
}
public class Capy64 : Game, IGame
{
public const string Version = "1.0.0-beta";
@ -59,18 +58,20 @@ public class Capy64 : Game, IGame
}
public static string AppDataPath
{
get
{
public static string AppDataPath {
get {
string baseDir =
RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ?
Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData, Environment.SpecialFolderOption.Create) :
RuntimeInformation.IsOSPlatform(OSPlatform.Linux) ?
Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData, Environment.SpecialFolderOption.Create) :
RuntimeInformation.IsOSPlatform(OSPlatform.OSX) ?
Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData, Environment.SpecialFolderOption.Create) :
"./";
RuntimeInformation.IsOSPlatform(OSPlatform.Windows)
?
Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData, Environment.SpecialFolderOption.Create)
: RuntimeInformation.IsOSPlatform(OSPlatform.Linux)
? Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData,
Environment.SpecialFolderOption.Create)
: RuntimeInformation.IsOSPlatform(OSPlatform.OSX)
? Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData,
Environment.SpecialFolderOption.Create)
:
"./";
return Path.Combine(baseDir, "Capy64");
}
@ -92,13 +93,14 @@ public class Capy64 : Game, IGame
public int TickRate => tickrate;
public Color BorderColor { get; set; } = Color.Black;
public Borders Borders = new()
{
public Borders Borders = new() {
Top = 0,
Bottom = 0,
Left = 0,
Right = 0,
};
public SpriteBatch SpriteBatch;
@ -147,6 +149,7 @@ public class Capy64 : Game, IGame
Window.AllowUserResizing = true;
break;
}
UpdateSize(true);
}
@ -199,14 +202,12 @@ public class Capy64 : Game, IGame
ResetBorder();
UpdateSize();
}
}
private void ResetBorder()
{
var size = (int)(Scale * DefaultParameters.BorderMultiplier);
Borders = new Borders
{
Borders = new Borders {
Top = size,
Bottom = size,
Left = size,
@ -256,6 +257,7 @@ public class Capy64 : Game, IGame
var instance = (IComponent)ActivatorUtilities.CreateInstance(_serviceProvider, type)!;
plugins.Add(instance);
}
return plugins;
}
@ -272,11 +274,10 @@ public class Capy64 : Game, IGame
// Register user input
_inputManager.Update(IsActive);
EventEmitter.RaiseTick(new()
{
EventEmitter.RaiseTick(new() {
GameTime = gameTime,
TotalTicks = _totalTicks,
IsActiveTick = (int)_totalTicks % everyTick == 0,
IsActiveTick = (int)_totalTicks % everyTick == 0,
});
Drawing.End();
@ -292,12 +293,13 @@ public class Capy64 : Game, IGame
GraphicsDevice.Clear(BorderColor);
SpriteBatch.DrawRectangle(renderTarget.Bounds.Location.ToVector2() + new Vector2(Borders.Left, Borders.Top),
new Size2(renderTarget.Bounds.Width * Scale, renderTarget.Bounds.Height * Scale), Color.Black, Math.Min(renderTarget.Bounds.Width, renderTarget.Bounds.Height), 0);
new Size2(renderTarget.Bounds.Width * Scale, renderTarget.Bounds.Height * Scale), Color.Black,
Math.Min(renderTarget.Bounds.Width, renderTarget.Bounds.Height), 0);
SpriteBatch.Draw(renderTarget, new(Borders.Left, Borders.Top), null, Color.White, 0f, Vector2.Zero, Scale, SpriteEffects.None, 0);
SpriteBatch.Draw(renderTarget, new(Borders.Left, Borders.Top), null, Color.White, 0f, Vector2.Zero, Scale,
SpriteEffects.None, 0);
EventEmitter.RaiseOverlay(new()
{
EventEmitter.RaiseOverlay(new() {
GameTime = gameTime,
TotalTicks = _totalTicks,
});

View file

@ -121,6 +121,20 @@ internal class Sandbox
L.SetTable(-3);
L.Pop(1);
// Replace debug.debug with a dummy function to avoid stalling the program
L.GetGlobal("debug");
L.PushString("debug");
L.PushCFunction(L_Dummy);
L.SetTable(-3);
L.Pop(1);
}
internal static int L_Dummy(IntPtr state)
{
return 0;
}
internal static int L_Searcher(IntPtr state)