From 5fe6f503b69a6008e4850201602d257dbda57e3f Mon Sep 17 00:00:00 2001 From: Nathan Hittinger Date: Mon, 27 Oct 2014 00:52:49 -0500 Subject: [PATCH] Log4net change recommit now it compiles, and log4net should be disable-able, unless I've missed something. --- Pulsar4X/Pulsar4X.Lib/Entities/Faction.cs | 2 +- Pulsar4X/Pulsar4X.Lib/Helpers/OrbitTable.cs | 3 ++- Pulsar4X/Pulsar4X.UI/GLUtilities/GLCanvas.cs | 4 ++-- Pulsar4X/Pulsar4X.UI/GLUtilities/GLCircle.cs | 2 ++ Pulsar4X/Pulsar4X.UI/GLUtilities/GLEffect.cs | 5 +++++ .../GLUtilities/GLEffectBasic21.cs | 12 ++++++++++++ .../GLUtilities/GLEffectBasic30.cs | 10 ++++++++++ Pulsar4X/Pulsar4X.UI/GLUtilities/GLFont.cs | 4 +++- Pulsar4X/Pulsar4X.UI/GLUtilities/GLLine.cs | 2 ++ .../Pulsar4X.UI/GLUtilities/GLPrimitive.cs | 4 ++++ Pulsar4X/Pulsar4X.UI/GLUtilities/GLQuad.cs | 2 ++ Pulsar4X/Pulsar4X.UI/Handlers/ClassDesign.cs | 19 ++++++++++++++++++- Pulsar4X/Pulsar4X.UI/Handlers/Components.cs | 6 ++++++ Pulsar4X/Pulsar4X.UI/Handlers/Economics.cs | 13 ++++++++++++- Pulsar4X/Pulsar4X.UI/Handlers/FastOOB.cs | 6 ++++++ Pulsar4X/Pulsar4X.UI/Handlers/SystemMap.cs | 8 +++++++- Pulsar4X/Pulsar4X.UI/Handlers/TaskGroup.cs | 14 ++++++++++++++ .../Pulsar4X.UI/Helpers/ResourceManager.cs | 18 ++++++++++++++++++ Pulsar4X/Pulsar4X.UI/Program.cs | 11 ++++++++++- Pulsar4X/Pulsar4X.UI/SceenGraph/MapMarker.cs | 5 +++++ Pulsar4X/Pulsar4X.UI/SceenGraph/Sceen.cs | 7 ++++++- 21 files changed, 147 insertions(+), 10 deletions(-) diff --git a/Pulsar4X/Pulsar4X.Lib/Entities/Faction.cs b/Pulsar4X/Pulsar4X.Lib/Entities/Faction.cs index 018d829b9..bdf5e8198 100644 --- a/Pulsar4X/Pulsar4X.Lib/Entities/Faction.cs +++ b/Pulsar4X/Pulsar4X.Lib/Entities/Faction.cs @@ -1149,7 +1149,7 @@ public void RemoveContactList(FactionSystemDetection ContactList) /// The second count for the current year. public void SensorSweep(int YearTickValue) { - /// /// clear the fleet preempt list. /// GameState.SE.ClearFleetPreemptList(); diff --git a/Pulsar4X/Pulsar4X.Lib/Helpers/OrbitTable.cs b/Pulsar4X/Pulsar4X.Lib/Helpers/OrbitTable.cs index d0b7b46cb..59e29c356 100644 --- a/Pulsar4X/Pulsar4X.Lib/Helpers/OrbitTable.cs +++ b/Pulsar4X/Pulsar4X.Lib/Helpers/OrbitTable.cs @@ -77,7 +77,8 @@ public void FindPolarPosition(OrbitingEntity theOrbit, long DaysSinceEpoch, out /// /// orbitFraction is essentially mean Anomaly /// - double orbitFraction = 1.0 * ((DaysSinceEpoch + theOrbit.TimeSinceApogee) % orbitPeriod) / orbitPeriod; + //double orbitFraction = 1.0 * ((DaysSinceEpoch + theOrbit.TimeSinceApogee) % orbitPeriod) / orbitPeriod; + double orbitFraction = 1.0 * theOrbit.TimeSinceApogee / orbitPeriod; #warning how can this orbit code be made more efficient? diff --git a/Pulsar4X/Pulsar4X.UI/GLUtilities/GLCanvas.cs b/Pulsar4X/Pulsar4X.UI/GLUtilities/GLCanvas.cs index 9aa3eb2af..8e6a204d2 100644 --- a/Pulsar4X/Pulsar4X.UI/GLUtilities/GLCanvas.cs +++ b/Pulsar4X/Pulsar4X.UI/GLUtilities/GLCanvas.cs @@ -239,8 +239,8 @@ private void InitOpenGL30() #if LOG4NET_ENABLED logger.Info("OpenGL Pre State Config Error Check: " + m_eGLError.ToString()); #endif - } - #endif + } +#endif //GL.ShadeModel(ShadingModel.Smooth); GL.PolygonMode(MaterialFace.FrontAndBack, PolygonMode.Fill); GL.ReadBuffer(ReadBufferMode.Back); diff --git a/Pulsar4X/Pulsar4X.UI/GLUtilities/GLCircle.cs b/Pulsar4X/Pulsar4X.UI/GLUtilities/GLCircle.cs index 653e3ae39..c8712169f 100644 --- a/Pulsar4X/Pulsar4X.UI/GLUtilities/GLCircle.cs +++ b/Pulsar4X/Pulsar4X.UI/GLUtilities/GLCircle.cs @@ -6,8 +6,10 @@ using OpenTK; using OpenTK.Graphics; using OpenTK.Graphics.OpenGL; +#if LOG4NET_ENABLED using log4net.Config; using log4net; +#endif using Pulsar4X.Entities; using Pulsar4X.Lib; diff --git a/Pulsar4X/Pulsar4X.UI/GLUtilities/GLEffect.cs b/Pulsar4X/Pulsar4X.UI/GLUtilities/GLEffect.cs index 2c43f0070..b9710dbd6 100644 --- a/Pulsar4X/Pulsar4X.UI/GLUtilities/GLEffect.cs +++ b/Pulsar4X/Pulsar4X.UI/GLUtilities/GLEffect.cs @@ -6,14 +6,19 @@ using Pulsar4X.UI; using OpenTK.Graphics.OpenGL; using OpenTK; + +#if LOG4NET_ENABLED using log4net.Config; using log4net; +#endif namespace Pulsar4X.UI.GLUtilities { public class GLEffect { +#if LOG4NET_ENABLED public static readonly ILog logger = LogManager.GetLogger(typeof(GLEffect)); +#endif /// Used for getting the last OpenGL Error. protected ErrorCode m_eGLError; diff --git a/Pulsar4X/Pulsar4X.UI/GLUtilities/GLEffectBasic21.cs b/Pulsar4X/Pulsar4X.UI/GLUtilities/GLEffectBasic21.cs index abead5d5c..b6810deba 100644 --- a/Pulsar4X/Pulsar4X.UI/GLUtilities/GLEffectBasic21.cs +++ b/Pulsar4X/Pulsar4X.UI/GLUtilities/GLEffectBasic21.cs @@ -6,8 +6,10 @@ using OpenTK.Graphics.OpenGL; using OpenTK; using Pulsar4X.UI; +#if LOG4NET_ENABLED using log4net.Config; using log4net; +#endif namespace Pulsar4X.UI.GLUtilities { @@ -49,7 +51,9 @@ public GLEffectBasic21(string a_szVertShaderFile, string a_szFragShaderFile) GL.GetShaderInfoLog(iGLVertexShader, out szShaderError); if (iShaderError != 1) { +#if LOG4NET_ENABLED logger.Error("Error " + iShaderError.ToString() + " Compiling Vertex Shader: " + szShaderError); // Log Result! +#endif iShaderError = 1; } @@ -61,7 +65,9 @@ public GLEffectBasic21(string a_szVertShaderFile, string a_szFragShaderFile) GL.GetShaderInfoLog(iGLPixelShader, out szShaderError); if (iShaderError != 1) { +#if LOG4NET_ENABLED logger.Error("Error " + iShaderError.ToString() + " Compiling Fragment/Pixel Shader: " + szShaderError); // Log Result! +#endif iShaderError = 1; } @@ -79,11 +85,15 @@ public GLEffectBasic21(string a_szVertShaderFile, string a_szFragShaderFile) GL.GetShaderInfoLog(iGLPixelShader, out szShaderError); if (iShaderError != 1) { +#if LOG4NET_ENABLED logger.Error("Error " + iShaderError.ToString() + " Creating Shader Program: " + szShaderError); // Log Result! +#endif iShaderError = 1; } +#if LOG4NET_ENABLED logger.Info("OpenGL Pre Bind Matricies to Shader Code: " + GL.GetError().ToString()); +#endif // The Following Bind our Projection, view (camera) and model Matricies in c# to the corosponding vars in the shader program // it is what allows us to update a matrix in c# and have the GPU do all the calculations for Transformations on next render. m_aiShaderMatrixLocations = new int[3]; // create memory. @@ -94,7 +104,9 @@ public GLEffectBasic21(string a_szVertShaderFile, string a_szFragShaderFile) m_eGLError = GL.GetError(); if (m_eGLError != ErrorCode.NoError) { +#if LOG4NET_ENABLED logger.Info("OpenGL Bind Matricies to Shader Code: " + m_eGLError.ToString()); +#endif } // This tells OpenGL to delete the shader objects. // Note that OpenGL wont delete them until all shader programs currently useing them are deleted also. diff --git a/Pulsar4X/Pulsar4X.UI/GLUtilities/GLEffectBasic30.cs b/Pulsar4X/Pulsar4X.UI/GLUtilities/GLEffectBasic30.cs index 2ebdecd60..62a73aed8 100644 --- a/Pulsar4X/Pulsar4X.UI/GLUtilities/GLEffectBasic30.cs +++ b/Pulsar4X/Pulsar4X.UI/GLUtilities/GLEffectBasic30.cs @@ -6,8 +6,10 @@ using OpenTK.Graphics.OpenGL; using OpenTK; using Pulsar4X.UI; +#if LOG4NET_ENABLED using log4net.Config; using log4net; +#endif namespace Pulsar4X.UI.GLUtilities { @@ -49,7 +51,9 @@ public GLEffectBasic30(string a_szVertShaderFile, string a_szFragShaderFile) GL.GetShaderInfoLog(iGLVertexShader, out szShaderError); if (iShaderError != 1) { +#if LOG4NET_ENABLED logger.Error("Error " + iShaderError.ToString() + " Compiling Vertex Shader: " + szShaderError); // Log Result! +#endif iShaderError = 1; } @@ -61,7 +65,9 @@ public GLEffectBasic30(string a_szVertShaderFile, string a_szFragShaderFile) GL.GetShaderInfoLog(iGLPixelShader, out szShaderError); if (iShaderError != 1) { +#if LOG4NET_ENABLED logger.Error("Error " + iShaderError.ToString() + " Compiling Fragment/Pixel Shader: " + szShaderError); // Log Result! +#endif iShaderError = 1; } @@ -80,7 +86,9 @@ public GLEffectBasic30(string a_szVertShaderFile, string a_szFragShaderFile) GL.GetShaderInfoLog(iGLPixelShader, out szShaderError); if (iShaderError != 1) { +#if LOG4NET_ENABLED logger.Error("Error " + iShaderError.ToString() + " Creating Shader Program: " + szShaderError); // Log Result! +#endif iShaderError = 1; } @@ -94,7 +102,9 @@ public GLEffectBasic30(string a_szVertShaderFile, string a_szFragShaderFile) m_eGLError = GL.GetError(); if (m_eGLError != ErrorCode.NoError) { +#if LOG4NET_ENABLED logger.Info("OpenGL Bind Matricies to Shader Code: " + m_eGLError.ToString()); +#endif } // This tells OpenGL to delete the shader objects. // Note that OpenGL wont delete them until all shader programs currently useing them are deleted also. diff --git a/Pulsar4X/Pulsar4X.UI/GLUtilities/GLFont.cs b/Pulsar4X/Pulsar4X.UI/GLUtilities/GLFont.cs index 856796788..27e2c1e81 100644 --- a/Pulsar4X/Pulsar4X.UI/GLUtilities/GLFont.cs +++ b/Pulsar4X/Pulsar4X.UI/GLUtilities/GLFont.cs @@ -6,8 +6,10 @@ using OpenTK; using OpenTK.Graphics; using OpenTK.Graphics.OpenGL; +#if LOG4NET_ENABLED using log4net.Config; using log4net; +#endif namespace Pulsar4X.UI.GLUtilities { @@ -19,7 +21,7 @@ public class GLFont { #if LOG4NET_ENABLED /// - /// TG Logger: + /// GLFONT Logger: /// public static readonly ILog logger = LogManager.GetLogger(typeof(GLFont)); #endif diff --git a/Pulsar4X/Pulsar4X.UI/GLUtilities/GLLine.cs b/Pulsar4X/Pulsar4X.UI/GLUtilities/GLLine.cs index 9d0c411ab..6b4632150 100644 --- a/Pulsar4X/Pulsar4X.UI/GLUtilities/GLLine.cs +++ b/Pulsar4X/Pulsar4X.UI/GLUtilities/GLLine.cs @@ -7,8 +7,10 @@ using OpenTK; using OpenTK.Graphics; using OpenTK.Graphics.OpenGL; +#if LOG4NET_ENABLED using log4net.Config; using log4net; +#endif namespace Pulsar4X.UI.GLUtilities { diff --git a/Pulsar4X/Pulsar4X.UI/GLUtilities/GLPrimitive.cs b/Pulsar4X/Pulsar4X.UI/GLUtilities/GLPrimitive.cs index d8470bb79..084b44319 100644 --- a/Pulsar4X/Pulsar4X.UI/GLUtilities/GLPrimitive.cs +++ b/Pulsar4X/Pulsar4X.UI/GLUtilities/GLPrimitive.cs @@ -6,8 +6,10 @@ using Pulsar4X.UI; using OpenTK.Graphics.OpenGL; using OpenTK; +#if LOG4NET_ENABLED using log4net.Config; using log4net; +#endif namespace Pulsar4X.UI.GLUtilities { @@ -18,7 +20,9 @@ namespace Pulsar4X.UI.GLUtilities public abstract class GLPrimitive { // Note: for AU/KM conversions: Constants.Units.KM_PER_AU +#if LOG4NET_ENABLED public static readonly ILog logger = LogManager.GetLogger(typeof(GLPrimitive)); +#endif /// /// Array of verticies that make up this primative. diff --git a/Pulsar4X/Pulsar4X.UI/GLUtilities/GLQuad.cs b/Pulsar4X/Pulsar4X.UI/GLUtilities/GLQuad.cs index ddbffcd5b..d69df55fa 100644 --- a/Pulsar4X/Pulsar4X.UI/GLUtilities/GLQuad.cs +++ b/Pulsar4X/Pulsar4X.UI/GLUtilities/GLQuad.cs @@ -7,8 +7,10 @@ using OpenTK; using OpenTK.Graphics; using OpenTK.Graphics.OpenGL; +#if LOG4NET_ENABLED using log4net.Config; using log4net; +#endif namespace Pulsar4X.UI.GLUtilities { diff --git a/Pulsar4X/Pulsar4X.UI/Handlers/ClassDesign.cs b/Pulsar4X/Pulsar4X.UI/Handlers/ClassDesign.cs index 6430a4c29..1120b81f2 100644 --- a/Pulsar4X/Pulsar4X.UI/Handlers/ClassDesign.cs +++ b/Pulsar4X/Pulsar4X.UI/Handlers/ClassDesign.cs @@ -9,8 +9,12 @@ using Pulsar4X.UI.ViewModels; using Pulsar4X.Entities; using Pulsar4X.Stargen; + +#if LOG4NET_ENABLED using log4net.Config; using log4net; +#endif + using Newtonsoft.Json; using Pulsar4X.Entities.Components; @@ -70,7 +74,9 @@ public ShipClassTN CurrentShipClass /// /// Class Design Logger: /// +#if LOG4NET_ENABLED public static readonly ILog logger = LogManager.GetLogger(typeof(TaskGroup)); +#endif //Panels.ClassDes_DesignAndInfo m_oDesignAndInformationPanel; Panels.ClassDes_Options m_oOptionsPanel; @@ -1418,6 +1424,7 @@ private void BuildDesignTab() /// /// Almost exactly the same as the above design tab builder, but this one gets the component selected from the grouped list. + /// maybe this should be commented. I'll have to get around to that if/when I refactor this. /// /// Line we want to find /// Component type to be "returned" @@ -1755,8 +1762,8 @@ private void SetupComponentDataGrid() Column.SortMode = DataGridViewColumnSortMode.NotSortable; } +#warning These are needed for debug for right now. /* - * These are needed for debug for right now. m_oOptionsPanel.ComponentDataGrid.Columns[m_oOptionsPanel.ComponentDataGrid.Columns.Count - 1].Visible = false; m_oOptionsPanel.ComponentDataGrid.Columns[m_oOptionsPanel.ComponentDataGrid.Columns.Count - 2].Visible = false; m_oOptionsPanel.ComponentDataGrid.Columns[m_oOptionsPanel.ComponentDataGrid.Columns.Count - 3].Visible = false; @@ -1765,7 +1772,9 @@ private void SetupComponentDataGrid() } catch { +#if LOG4NET_ENABLED logger.Error("Something went wrong Creating Columns for Class Design ComponentGrid screen..."); +#endif } } @@ -2723,7 +2732,9 @@ private void BuildComponentDataGrid() } catch { +#if LOG4NET_ENABLED logger.Error("Something went wrong Creating Rows for Class Design ComponentGrid screen..."); +#endif } } else if( TotalComponents != List.TotalComponents) @@ -3968,7 +3979,9 @@ private void BuildComponentDataGrid() } catch { +#if LOG4NET_ENABLED logger.Error("Something went wrong with updating rows for class design componentGrid screen..."); +#endif } } } @@ -4871,7 +4884,9 @@ private void SetupMissileDataGrid() } catch { +#if LOG4NET_ENABLED logger.Error("Something went wrong Creating Columns for Class Design MissileGrid screen..."); +#endif } } @@ -5020,7 +5035,9 @@ private void BuildMissileDataGrid() } catch { +#if LOG4NET_ENABLED logger.Error("Something went wrong Creating Rows for Class Design MissileGrid screen.."); +#endif } } #endregion diff --git a/Pulsar4X/Pulsar4X.UI/Handlers/Components.cs b/Pulsar4X/Pulsar4X.UI/Handlers/Components.cs index a25b052cd..72090b829 100644 --- a/Pulsar4X/Pulsar4X.UI/Handlers/Components.cs +++ b/Pulsar4X/Pulsar4X.UI/Handlers/Components.cs @@ -10,8 +10,12 @@ using Pulsar4X.Entities; using Pulsar4X.Stargen; using Newtonsoft.Json; + +#if LOG4NET_ENABLED using log4net.Config; using log4net; +#endif + using Pulsar4X.Entities.Components; using System.Runtime.InteropServices; @@ -19,7 +23,9 @@ namespace Pulsar4X.UI.Handlers { public class Components { +#if LOG4NET_ENABLED public static readonly ILog logger = LogManager.GetLogger(typeof(Components)); +#endif Panels.Component_Design m_oComponentDesignPanel; diff --git a/Pulsar4X/Pulsar4X.UI/Handlers/Economics.cs b/Pulsar4X/Pulsar4X.UI/Handlers/Economics.cs index fc6487ca3..42e4b6c85 100644 --- a/Pulsar4X/Pulsar4X.UI/Handlers/Economics.cs +++ b/Pulsar4X/Pulsar4X.UI/Handlers/Economics.cs @@ -6,15 +6,22 @@ using WeifenLuo.WinFormsUI.Docking; using Pulsar4X.UI.ViewModels; using Pulsar4X.Entities; + +#if LOG4NET_ENABLED using log4net.Config; using log4net; +#endif namespace Pulsar4X.UI.Handlers { public class Economics { - // System Map Logger: + /// + /// Economics Logger: + /// +#if LOG4NET_ENABLED public static readonly ILog logger = LogManager.GetLogger(typeof(Economics)); +#endif /// /// Panel that contains the list of populated systems. @@ -210,7 +217,9 @@ private void SetupSummaryDataGrid() } catch { +#if LOG4NET_ENABLED logger.Error("Something whent wrong Creating Colums for Economics summary screen..."); +#endif } } @@ -260,7 +269,9 @@ public void RefreshSummaryCells() } catch { +#if LOG4NET_ENABLED logger.Error("Something whent wrong Refreshing Cells for Economics summary screen..."); +#endif } } diff --git a/Pulsar4X/Pulsar4X.UI/Handlers/FastOOB.cs b/Pulsar4X/Pulsar4X.UI/Handlers/FastOOB.cs index 5e3f12e32..a7059ec8d 100644 --- a/Pulsar4X/Pulsar4X.UI/Handlers/FastOOB.cs +++ b/Pulsar4X/Pulsar4X.UI/Handlers/FastOOB.cs @@ -9,8 +9,12 @@ using Pulsar4X.UI.ViewModels; using Pulsar4X.Entities; using Pulsar4X.Stargen; + +#if LOG4NET_ENABLED using log4net.Config; using log4net; +#endif + using Newtonsoft.Json; using Pulsar4X.Entities.Components; @@ -19,7 +23,9 @@ namespace Pulsar4X.UI.Handlers public class FastOOB { +#if LOG4NET_ENABLED public static readonly ILog logger = LogManager.GetLogger(typeof(FastOOB)); +#endif /// /// Currently selected empire. diff --git a/Pulsar4X/Pulsar4X.UI/Handlers/SystemMap.cs b/Pulsar4X/Pulsar4X.UI/Handlers/SystemMap.cs index 149d05a56..f430ab3e2 100644 --- a/Pulsar4X/Pulsar4X.UI/Handlers/SystemMap.cs +++ b/Pulsar4X/Pulsar4X.UI/Handlers/SystemMap.cs @@ -8,8 +8,12 @@ using Pulsar4X.UI.ViewModels; using Pulsar4X.Entities; using Pulsar4X.Stargen; + +#if LOG4NET_ENABLED using log4net.Config; using log4net; +#endif + using Pulsar4X.UI.GLUtilities; using Pulsar4X.UI.SceenGraph; using OpenTK; @@ -28,7 +32,9 @@ public class SystemMap #region Properties and Member Vars // System Map Logger: +#if LOG4NET_ENABLED public static readonly ILog logger = LogManager.GetLogger(typeof(SystemMap)); +#endif /// /// Panel that contains the System map view port (i.e. openGL canvas). @@ -375,7 +381,7 @@ private void AdvanceTime30D_Click(object sender, EventArgs e) /// /// /// -#warning this may be deprecated +#warning this is deprecated private void StartSim_Click(object sender, EventArgs e) { if (GameState.SE.SimCreated == false) diff --git a/Pulsar4X/Pulsar4X.UI/Handlers/TaskGroup.cs b/Pulsar4X/Pulsar4X.UI/Handlers/TaskGroup.cs index a9d959f34..33a5bbcab 100644 --- a/Pulsar4X/Pulsar4X.UI/Handlers/TaskGroup.cs +++ b/Pulsar4X/Pulsar4X.UI/Handlers/TaskGroup.cs @@ -8,8 +8,12 @@ using Pulsar4X.UI.ViewModels; using Pulsar4X.Entities; using Pulsar4X.Stargen; + +#if LOG4NET_ENABLED using log4net.Config; using log4net; +#endif + using Pulsar4X.UI.GLUtilities; using Pulsar4X.UI.SceenGraph; using OpenTK; @@ -68,7 +72,9 @@ public enum StratCells /// /// TG Logger: /// +#if LOG4NET_ENABLED public static readonly ILog logger = LogManager.GetLogger(typeof(TaskGroup)); +#endif /// /// Panel for taskgroup related stuff. Opengl shouldn't be used here I don't think, but I'm not sure. Included everything from SystemMap.cs anyway. @@ -599,7 +605,9 @@ private void SetupShipDataGrid() } catch { +#if LOG4NET_ENABLED logger.Error("Something went wrong Creating Columns for Taskgroup summary screen..."); +#endif } } @@ -629,7 +637,9 @@ private void RefreshShipCells() } catch { +#if LOG4NET_ENABLED logger.Error("Something went wrong Creating Rows for Taskgroup summary screen..."); +#endif } } } @@ -713,7 +723,9 @@ private void PopulateRow(int row) } catch { +#if LOG4NET_ENABLED logger.Error("Something went wrong Refreshing Cells for Taskgroup Ship summary screen..."); +#endif } } @@ -1049,7 +1061,9 @@ private void CalculateTimeDistance() } catch { +#if LOG4NET_ENABLED logger.Error("No Jumppoint associated with jump point transit order in CalcTimeDistance in taskgroup.cs under handlers."); +#endif } } } diff --git a/Pulsar4X/Pulsar4X.UI/Helpers/ResourceManager.cs b/Pulsar4X/Pulsar4X.UI/Helpers/ResourceManager.cs index 5d8c86416..6fe17d46c 100644 --- a/Pulsar4X/Pulsar4X.UI/Helpers/ResourceManager.cs +++ b/Pulsar4X/Pulsar4X.UI/Helpers/ResourceManager.cs @@ -2,8 +2,12 @@ using System.Collections.Generic; using System.Linq; using System.Text; + +#if LOG4NET_ENABLED using log4net.Config; using log4net; +#endif + using System.Drawing; using OpenTK.Graphics.OpenGL; using OpenTK; @@ -16,7 +20,9 @@ namespace Pulsar4X.UI.Helpers /// public class ResourceManager { +#if LOG4NET_ENABLED public static readonly ILog logger = LogManager.GetLogger(typeof(ResourceManager)); +#endif /// /// Instance of the singelton class. @@ -97,7 +103,9 @@ public uint LoadTexture(string a_szTextureFile) // Second check if the file exists: if (!System.IO.File.Exists(a_szTextureFile)) { +#if LOG4NET_ENABLED logger.Error("Could not find texture file: " + a_szTextureFile); +#endif return 0; // retun 0 if invalid file. } @@ -130,7 +138,9 @@ public uint LoadTexture(string a_szTextureFile) // Load data by telling OpenGL to build mipmaps out of bitmap data GL.TexImage2D(TextureTarget.Texture2D, 0, PixelInternalFormat.Rgba, oTextureBitmap.Width, oTextureBitmap.Height, 0, PixelFormat.Rgba, PixelType.UnsignedByte, oRawTextureData.Scan0); +#if LOG4NET_ENABLED logger.Info("OpenGL Loading Texture " + a_szTextureFile + ": " + GL.GetError().ToString()); +#endif // Now that we have provided the data to OpenGL we can free the texture from system Ram. oTextureBitmap.UnlockBits(oRawTextureData); @@ -257,7 +267,9 @@ public GLFontData LoadGLFont(string a_szFontDataFile) } else { +#if LOG4NET_ENABLED logger.Error("Couldn't find texture path for " + a_szFontDataFile); +#endif } // Move to first Charecter element @@ -313,20 +325,26 @@ public GLFontData LoadGLFont(string a_szFontDataFile) if (r1 == false || r2 == false || r3 == false || r4 == false) { +#if LOG4NET_ENABLED logger.Info("ResourceManager.cs Char: " + szBuffer + " Coordinates: " + oUVCoords.m_v2UVMin.X + "/" + oUVCoords.m_v2UVMin.Y + "," + oUVCoords.m_v2UVMax.X + "/" + oUVCoords.m_v2UVMax.Y + "|" + r1 + " " + r2 + " " + r3 + " " + r4); +#endif } } while (oXMLReader.ReadToNextSibling("Character")); // Move to Next Charcter Element +#if LOG4NET_ENABLED logger.Info("Loaded GLFont Data File " + a_szFontDataFile); +#endif } catch (XmlException e) { // XML Error occured, catch and log. +#if LOG4NET_ENABLED logger.Error("Error: faild to load Font Data file " + a_szFontDataFile); logger.Error("Font Exception: " + e.Message); logger.Info("You May have an unsupported Charcter in thoe font data file, inclundg <, >, &"); +#endif } finally { diff --git a/Pulsar4X/Pulsar4X.UI/Program.cs b/Pulsar4X/Pulsar4X.UI/Program.cs index 9b3a238fb..4818b6cde 100644 --- a/Pulsar4X/Pulsar4X.UI/Program.cs +++ b/Pulsar4X/Pulsar4X.UI/Program.cs @@ -3,16 +3,21 @@ using System.Linq; using System.Windows.Forms; using Pulsar4X.Stargen; + +#if LOG4NET_ENABLED using log4net.Config; using log4net; +#endif + using Pulsar4X.Entities.Components; namespace Pulsar4X.UI { static class Program { - +#if LOG4NET_ENABLED public static readonly ILog logger = LogManager.GetLogger(typeof(Program)); +#endif /// /// The main entry point for the application. @@ -20,8 +25,10 @@ static class Program [STAThread] static void Main() { +#if LOG4NET_ENABLED XmlConfigurator.Configure(); // Enables Log4net based on App.config file. logger.Info("Program Started"); +#endif // gen star system: Entities.StarSystem otest = GameState.Instance.StarSystemFactory.Create("Test"); @@ -214,7 +221,9 @@ static void Main() //Application.SetCompatibleTextRenderingDefault(false); Application.Run(new Forms.MainForm()); +#if LOG4NET_ENABLED logger.Info("Program Ended"); +#endif } } } diff --git a/Pulsar4X/Pulsar4X.UI/SceenGraph/MapMarker.cs b/Pulsar4X/Pulsar4X.UI/SceenGraph/MapMarker.cs index aed113318..2c07872de 100644 --- a/Pulsar4X/Pulsar4X.UI/SceenGraph/MapMarker.cs +++ b/Pulsar4X/Pulsar4X.UI/SceenGraph/MapMarker.cs @@ -7,14 +7,19 @@ using Pulsar4X.UI.GLUtilities; using OpenTK; using Pulsar4X.Entities; + +#if LOG4NET_ENABLED using log4net; +#endif namespace Pulsar4X.UI.SceenGraph { public class MapMarker : SceenElement { +#if LOG4NET_ENABLED public static readonly ILog logger = LogManager.GetLogger(typeof(MapMarker)); +#endif private GameEntity m_oGameEntity; diff --git a/Pulsar4X/Pulsar4X.UI/SceenGraph/Sceen.cs b/Pulsar4X/Pulsar4X.UI/SceenGraph/Sceen.cs index 51e9246e8..8157942a8 100644 --- a/Pulsar4X/Pulsar4X.UI/SceenGraph/Sceen.cs +++ b/Pulsar4X/Pulsar4X.UI/SceenGraph/Sceen.cs @@ -10,8 +10,11 @@ using Pulsar4X.UI.GLUtilities; using OpenTK; using Pulsar4X.Entities; + +#if LOG4NET_ENABLED using log4net.Config; using log4net; +#endif namespace Pulsar4X.UI.SceenGraph { @@ -21,9 +24,11 @@ namespace Pulsar4X.UI.SceenGraph public class Sceen { /// - /// TG Logger: + /// Sceen Logger: /// +#if LOG4NET_ENABLED public static readonly ILog logger = LogManager.GetLogger(typeof(Sceen)); +#endif /// /// List of all top level Sprites That Make up the Sceen.