Et puis la 1.1.1.1.1.1.1 est arrivée. Et bien sûr, mon mod ne fonctionne plus.
Voici le message d'erreur de la console :
[Exception]: TypeLoadException: Could not load type 'Callback' from assembly 'PappoloPanel'.
Évidemment, je n'y comprends que pouik. Voici le code complet du mod :
Code : Tout sélectionner
using UnityEngine;
using System.Collections;
namespace PappoloInstrumentPanel
{
[KSPAddon(KSPAddon.Startup.Flight, false)]
public class PappoloPanel : MonoBehaviour
{
// Variables------------------------------------------------------------------
public Vessel myship;
public float radalt;
public double altitude;
public long apoapsis, periapsis;
public string strNorthing, strEasting;
public static int LineHeight = 25;
public static int lcdXpos = 53, lcdYpos = 17; // initial position of LCD digits
public static int lightXpos = 8, lightYpos = 15; // initial position of LCD digits
public int iconXpos, iconYpos;
private bool activePanel;
private static string iconPath = "GameData/PappoloPanel/Plugins/PluginData/PappoloPanel/";
private static string root = KSPUtil.ApplicationRootPath.Replace("\\", "/"); // get game root directory
private static Rect windowPosition;
private static GUIStyle
iconStyle = new GUIStyle();
// windowStyle = null;
private KSP.IO.PluginConfiguration cfg = KSP.IO.PluginConfiguration.CreateForType<PappoloPanel>(); // access to config.xml
public static Texture2D
iconOn = new Texture2D(32, 32, TextureFormat.ARGB32, false),
iconOff = new Texture2D(32, 32, TextureFormat.ARGB32, false),
panelIcon = new Texture2D(32, 32, TextureFormat.ARGB32, false),
panelBackGround = new Texture2D(152, 150, TextureFormat.ARGB32, false),
blankCharacter = new Texture2D(10, 14, TextureFormat.ARGB32, false),
minusCharacter = new Texture2D(10, 14, TextureFormat.ARGB32, false),
dotCharacter = new Texture2D(10, 14, TextureFormat.ARGB32, false),
radarText = new Texture2D(33, 10, TextureFormat.ARGB32, false);
public Texture2D[] fontImages = new Texture2D[10]; // will contain all digits
public Texture2D[] lightImages = new Texture2D[5];
//------------------------------------------------------------------
public void GetCoordinates(Vessel vessel)
{
double longitude = vessel.longitude;
double latitude = vessel.latitude;
if (longitude > 180) longitude -= 360;
if (longitude < -180) longitude += 360;
this.strNorthing = (latitude).ToString("0.0000");
this.strEasting = (longitude).ToString("0.0000");
}
//------------------------------------------------------------------
public void LoadIcons()
{
var imageLoaderOn = new WWW("file://" + root + iconPath + "pappolopanel_on.png");
var imageLoaderOff = new WWW("file://" + root + iconPath + "pappolopanel_off.png");
var imageLoaderPanel = new WWW("file://" + root + iconPath + "background_panel.png");
var imageBlank = new WWW("file://" + root + iconPath + "blank.png");
var imageMinus = new WWW("file://" + root + iconPath + "minus.png");
var imageDot = new WWW("file://" + root + iconPath + "dot.png");
var imageRadar = new WWW("file://" + root + iconPath + "radar.png");
imageLoaderOn.LoadImageIntoTexture(iconOn);
imageLoaderOff.LoadImageIntoTexture(iconOff);
imageLoaderPanel.LoadImageIntoTexture(panelBackGround);
imageBlank.LoadImageIntoTexture(blankCharacter);
imageMinus.LoadImageIntoTexture(minusCharacter);
imageDot.LoadImageIntoTexture(dotCharacter);
imageRadar.LoadImageIntoTexture(radarText);
panelIcon = iconOn;
for (int i = 0; i < fontImages.Length; i++)
{
Texture2D tex = new Texture2D(10, 14, TextureFormat.ARGB32, false);
var imageLoader = new WWW("file://" + root + iconPath + i + ".png");
imageLoader.LoadImageIntoTexture(tex);
fontImages[i] = tex;
}
for (int i = 0; i < lightImages.Length; i++)
{
Texture2D tex = new Texture2D(31, 18, TextureFormat.ARGB32, false);
var imageLoader = new WWW("file://" + root + iconPath + "light_on_" + i + ".png");
imageLoader.LoadImageIntoTexture(tex);
lightImages[i] = tex;
}
}
//------------------------------------------------------------------
public void MakeDigit(string strValue, int panelLine) // Transform numeric string to image with LCD font at dedicated line
{
int nbChar = (strValue.ToString()).Length;
int shift = 9 - nbChar; // the number of blank characters needed to align right
for (int i = 0; i < shift; i++)
{
GUI.DrawTexture(new Rect(lcdXpos + i * 9, lcdYpos + panelLine * LineHeight, 9, 14), blankCharacter); // insert blank characters
}
for (int i = 0; i < (strValue.ToString()).Length; i++)
{
string strChar = strValue.Substring(i, 1); // extract the character to transform
if (strChar == "-")
GUI.DrawTexture(new Rect(lcdXpos + (i + shift) * 9, lcdYpos + panelLine * LineHeight, 9, 14), minusCharacter);
else if (strChar == ".")
GUI.DrawTexture(new Rect(lcdXpos + (i + shift) * 9, lcdYpos + panelLine * LineHeight, 9, 14), dotCharacter);
else
{
GUI.DrawTexture(new Rect(lcdXpos + (i + shift) * 9, lcdYpos + panelLine * LineHeight, 9, 14), fontImages[int.Parse(strChar)]);
}
}
}
//------------------------------------------------------------------
public void loadConfig()
{
cfg.load();
iconXpos = cfg.GetValue<int>("iconxpos");
iconYpos = cfg.GetValue<int>("iconypos");
windowPosition = new Rect(cfg.GetValue<int>("panelxpos"), cfg.GetValue<int>("panelypos"), 152, 150);
activePanel = cfg.GetValue<bool>("panelOn");
}
public void saveConfig()
{
cfg.SetValue("panelxpos", (int)windowPosition.xMin);
cfg.SetValue("panelypos", (int)windowPosition.yMin);
cfg.SetValue("panelOn", activePanel);
cfg.save();
}
//--------------------------------------------------------------
public void Awake()
{
RenderingManager.AddToPostDrawQueue(0, OnDraw);
}
//------------------------------------------------------------------
public void Start()
{
LoadIcons();
loadConfig();
// windowPosition = new Rect(182, 1, 152, 150); // Instrument Panel position & size
}
//------------------------------------------------------------------
public void Update()
{
if (activePanel == true)
{
panelIcon = iconOn;
}
else
{
panelIcon = iconOff;
}
}
//------------------------------------------------------------------
private void OnDraw()
{
if (GUI.Button(new Rect(iconXpos, iconYpos, 32, 32), panelIcon, iconStyle))
{
if (activePanel == true)
{
activePanel = false;
}
else
{
activePanel = true;
}
}
if (activePanel)
{
// windowPosition = GUI.Window(1234, windowPosition, OnWindow, "Pappolo Panel", windowStyle);
windowPosition = GUI.Window(1234, windowPosition, OnWindow, panelBackGround, iconStyle);
}
myship = FlightGlobals.ActiveVessel;
radalt = myship.GetHeightFromTerrain();
altitude = myship.altitude;
apoapsis = (long)myship.orbit.ApA;
apoapsis = (long)(Mathf.Round(apoapsis / 10)) * 10;
periapsis = (long)myship.orbit.PeA;
periapsis = (long)(Mathf.Round(periapsis / 10)) * 10;
GetCoordinates(myship);
saveConfig();
}
//------------------------------------------------------------------
private void OnWindow(int windowID)
{
if (radalt < 5 || myship.Landed) // When sensor is too high to get altitude or landed
{
MakeDigit("--", 0);
}
else
{
GUI.DrawTexture(new Rect(52, 17, 33, 10), radarText); // add the "RADAR" icon
GUI.DrawTexture(new Rect(lightXpos, lightYpos, 31, 18), lightImages[0]);
if (radalt >= 200 && radalt < 5000)
{
radalt = (Mathf.Round(radalt / 10)) * 10; // increment altitude by 10
}
if (radalt >= 5000)
{
radalt = (Mathf.Round(radalt / 100)) * 100; // increment altitude by 100
}
MakeDigit(((int)radalt).ToString(), 0);
}
if (altitude > 1000000)
{
MakeDigit("--", 1);
MakeDigit("--", 2);
}
else
{
MakeDigit(strNorthing, 1);
MakeDigit(strEasting, 2);
GUI.DrawTexture(new Rect(lightXpos, lightYpos + LineHeight, 31, 18), lightImages[1]);
GUI.DrawTexture(new Rect(lightXpos, lightYpos + LineHeight * 2, 31, 18), lightImages[2]);
}
if (apoapsis < 3000 || apoapsis > 99999999)
MakeDigit("--", 3);
else
{
MakeDigit(apoapsis.ToString(), 3);
GUI.DrawTexture(new Rect(lightXpos, lightYpos + LineHeight * 3, 31, 18), lightImages[3]);
}
if (periapsis < 0 || periapsis > 99999999)
MakeDigit("--", 4); // Periapsis = null id under zero
else
{
MakeDigit(periapsis.ToString(), 4);
GUI.DrawTexture(new Rect(lightXpos, lightYpos + LineHeight * 4, 31, 18), lightImages[4]);
}
GUI.DragWindow();
}
}
}