public static void ExportMain(string[] args) { var filename = args[1]; var outDir = "Export/QMaps/" + filename + ".gbh2map"; Log.Initialize(LogLevel.All); Log.AddListener(new ConsoleLogListener()); ConVar.Initialize(); FileSystem.Initialize(); MapManager.Load("Maps/" + filename + ".gmp"); // export cell files var cellWidth = 32; var cellHeight = 32; var blockScale = 4.5f; var mapFile = File.Open(string.Format("{0}/cells.lua", outDir), FileMode.Create, FileAccess.Write); var mapWriter = new StreamWriter(mapFile); for (int x = 0; x < (256 / cellWidth); x++) { for (int y = 0; y < (256 / cellHeight); y++) { var cellName = string.Format("{0}_{1}_{2}", filename, x, y); var cellFile = File.OpenWrite(string.Format("{0}/cells/{1}.cell", outDir, cellName)); var cellWriter = new BinaryWriter(cellFile); for (int c = 0; c < 7; c++) { for (int b = (y * cellHeight); b < (y * cellHeight) + cellHeight; b++) { for (int a = (x * cellWidth); a < (x * cellWidth) + cellWidth; a++) { var block = MapManager.GetBlock(a, b, c); cellWriter.Write(block.Left.Value); cellWriter.Write(block.Right.Value); cellWriter.Write(block.Top.Value); cellWriter.Write(block.Bottom.Value); cellWriter.Write(block.Lid.Value); cellWriter.Write(block.SlopeType.Value); } } } cellFile.Close(); mapWriter.WriteLine(string.Format("class \"cells/{0}\" (GBHClass) {{ castShadows = false, renderingDistance = {1} }}", cellName, 300)); mapWriter.WriteLine(string.Format("object \"cells/{0}\" ({1}, {2}, {3}) {{}}", cellName, (x * cellWidth * blockScale), -(y * cellWidth * blockScale), 0)); } } }
protected override void Initialize() { //EventInput.Initialize(this.Window); Log.Initialize(LogLevel.All); Log.AddListener(new ConsoleLogListener()); Log.AddListener(new GameLogListener()); ConVar.Initialize(); FileSystem.Initialize(); StyleManager.Load("Styles/bil.sty"); MapManager.Load("Maps/MP1-comp.gmp"); MapGeometry.Initialize(); Camera.Initialize(); base.Initialize(); }
public static void ExportMain(string[] args) { var filename = args[1]; var outDir = "Export/Maps/" + filename + "/"; Directory.CreateDirectory(outDir); Directory.CreateDirectory(outDir + "cells"); Log.Initialize(LogLevel.All); Log.AddListener(new ConsoleLogListener()); ConVar.Initialize(); FileSystem.Initialize(); StyleManager.Load("Styles/" + filename + ".sty"); var bitmap = StyleManager.GetBitmap(); bitmap.Save(string.Format("{0}/{1}.png", outDir, filename), System.Drawing.Imaging.ImageFormat.Png); }
public static void ToolMain(string[] args) { var filename = args[1]; var outMaterialFile = "Data/Styles/" + filename + ".material"; var outBitmap = "Data/Styles/" + filename + ".png"; Log.Initialize(LogLevel.All); Log.AddListener(new ConsoleLogListener()); ConVar.Initialize(); FileSystem.Initialize(); StyleManager.Load("Styles/" + filename + ".sty"); // save the texture Vector2 uv; var bitmap = StyleManager.GetBitmap(); bitmap.Save(outBitmap, System.Drawing.Imaging.ImageFormat.Png); // create a material file var writer = new StreamWriter(outMaterialFile); for (int i = 0; i < 992; i++) { StyleManager.GetTileTextureBordered(i, out uv); writer.WriteLine(string.Format("gbh/{0}/{1}", filename, i)); writer.WriteLine("{"); writer.WriteLine(string.Format("\ttexture Styles/{0}.png", filename)); writer.WriteLine(string.Format("\tuv {0} {1} {2} {3}", uv.X, uv.Y, uv.X + 0.03125f, uv.Y + (0.03125f / 2))); writer.WriteLine("}"); writer.WriteLine(); } writer.Close(); }
public static void Initialize() { // set the current culture to the invariant culture Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture; // initialize the logging service Log.Initialize(LogLevel.All); Log.AddListener(new ConsoleLogListener()); Log.AddListener(new GameLogListener()); Log.AddListener(new FileLogListener("GBHGame.log", false)); Log.Write(LogLevel.Info, "GBH2 v0 initializing"); Log.Write(LogLevel.Critical, "jeremych is an egghead and a nabsalad"); ConVar.Initialize(); FileSystem.Initialize(); Win32System.Initialize(); MapGeometry.Initialize(); //StyleManager.Load("Styles/bil.sty"); //MapManager.Load("Maps/MP1-comp.gmp"); Camera.Initialize(); NetManager.Initialize(29960); Client.Initialize(); Server.Initialize(); GameWindow.Initialize(); com_maxFPS = ConVar.Register("com_maxFPS", 0, "Maximum framerate for the game loop.", ConVarFlags.Archived); timescale = ConVar.Register("timescale", 1.0f, "Scale time by this amount", ConVarFlags.Cheat); sv_running = ConVar.Register("sv_running", true, "Is the server running?", ConVarFlags.ReadOnly); cl_running = ConVar.Register("cl_running", false, "Is the client running?", ConVarFlags.ReadOnly); sv_paused = ConVar.Register("sv_paused", false, "Is the server paused?", ConVarFlags.ReadOnly); cl_paused = ConVar.Register("cl_paused", false, "Is the client paused?", ConVarFlags.ReadOnly); net_showpackets = ConVar.Register("net_showpackets", false, "Show network packets.", ConVarFlags.None); mapname = ConVar.Register("mapname", "", "Current mapname", ConVarFlags.ReadOnly); nickname = ConVar.Register("nickname", Environment.GetEnvironmentVariable("username"), "Your nickname", ConVarFlags.Archived); Renderer.Initialize(); MaterialManager.ReadMaterialFile("base.material"); MaterialManager.ReadMaterialFile("Styles/bil.material"); ConsoleRenderer.Initialize(); //StyleManager.CreateTextures(Renderer.Device); MapRenderer.Initialize(Renderer.Device); DeferredRenderer.Initialize(Renderer.Device); Renderer2D.Initialize(Renderer.Device); // jeez, people these days just need to get a *proper* nickname if (ConVar.GetValue <string>("nicknamee") == Environment.GetEnvironmentVariable("username")) { Log.Write(LogLevel.Info, "It looks it's your first time running GBH2. Please type 'nickname <WANTED NICKNAME>' to set your nickname."); } var path = Directory.GetCurrentDirectory() + "\\config.ini"; IniFile ini = new IniFile(path); var value = ini.IniReadValue("CONFIG", "nickname"); if (value != null) { ConVar.SetValue <string>("nicknamee", value); } }
public static void ExportMain(string[] args) { var filename = args[1]; var outDir = "Export/Maps/" + filename + "/"; Directory.CreateDirectory(outDir); Directory.CreateDirectory(outDir + "cells"); Log.Initialize(LogLevel.All); Log.AddListener(new ConsoleLogListener()); ConVar.Initialize(); FileSystem.Initialize(); MapManager.Load("Maps/" + filename + ".gmp"); // export cell files var cellWidth = 32; var cellHeight = 32; var blockScale = 4.5f; var mapFile = File.Open(string.Format("{0}/cells.lua", outDir), FileMode.Create, FileAccess.Write); var mapWriter = new StreamWriter(mapFile); for (int x = 0; x < (256 / cellWidth); x++) { for (int y = 0; y < (256 / cellHeight); y++) { var cellName = string.Format("{0}_{1}_{2}", filename, x, y); var cellFile = File.OpenWrite(string.Format("{0}/cells/{1}.cell", outDir, cellName)); var cellWriter = new BinaryWriter(cellFile); for (int c = 0; c < 7; c++) { for (int b = (y * cellHeight); b < (y * cellHeight) + cellHeight; b++) { for (int a = (x * cellWidth); a < (x * cellWidth) + cellWidth; a++) { var block = MapManager.GetBlock(a, b, c); cellWriter.Write(block.Left.Value); cellWriter.Write(block.Right.Value); cellWriter.Write(block.Top.Value); cellWriter.Write(block.Bottom.Value); cellWriter.Write(block.Lid.Value); cellWriter.Write(block.SlopeType.Value); } } } cellFile.Close(); mapWriter.WriteLine(string.Format("class \"cells/{0}\" (GBHClass) {{ castShadows = false, renderingDistance = {1} }}", cellName, 300)); mapWriter.WriteLine(string.Format("object \"cells/{0}\" ({1}, {2}, {3}) {{}}", cellName, (x * cellWidth * blockScale), -(y * cellWidth * blockScale), 0)); } } mapWriter.Close(); // export lights mapFile = File.Open(string.Format("{0}/lights.lua", outDir), FileMode.Create, FileAccess.Write); mapWriter = new StreamWriter(mapFile); mapWriter.WriteLine("local l"); mapWriter.WriteLine("gbh_lights = {}"); foreach (var light in MapManager.Lights) { mapWriter.WriteLine(string.Format("l = light_from_table({{ pos = vector3({0}, {1}, {2}), diff = vector3({3}, {4}, {5}), range = {6}, coronaColour = V_ZERO }})", light.Position.X * 4.5f, light.Position.Y * -4.5f, light.Position.Z * 4.5f, light.Color.R / 255.0f, light.Color.G / 255.0f, light.Color.B / 255.0f, light.Radius * 4.5f)); mapWriter.WriteLine("l.enabled = true"); mapWriter.WriteLine("table.insert(gbh_lights, l)"); mapWriter.WriteLine(); } mapWriter.Close(); }