Skip to content

Commit

Permalink
Merge pull request #18 from DMagic1/dev
Browse files Browse the repository at this point in the history
Version 2.8
  • Loading branch information
DMagic1 committed Mar 16, 2018
2 parents 4404982 + a322ba3 commit deff8c2
Show file tree
Hide file tree
Showing 5 changed files with 84 additions and 43 deletions.
12 changes: 6 additions & 6 deletions GameData/DMagicUtilities/CapCom/CapCom.version
@@ -1,7 +1,7 @@
{
"NAME":"CapCom Mission Control On The Go",
"URL":"https://raw.githubusercontent.com/DMagic1/CapCom/master/GameData/DMagicUtilities/CapCom/CapCom.version",
"DOWNLOAD":"http://spacedock.info/mod/131/CapCom%20-%20Mission%20Control%20On%20The%20Go/download/2.7",
"DOWNLOAD":"http://spacedock.info/mod/131/CapCom%20-%20Mission%20Control%20On%20The%20Go/download/2.8",
"GITHUB":{
"USERNAME":"DMagic1",
"REPOSITORY":"CapCom",
Expand All @@ -11,21 +11,21 @@
"MAJOR":1,
"MINOR":0,
"PATCH":2,
"BUILD":7
"BUILD":8
},
"KSP_VERSION":{
"MAJOR":1,
"MINOR":3,
"PATCH":0
"MINOR":4,
"PATCH":1
},
"KSP_VERSION_MIN":{
"MAJOR":1,
"MINOR":3,
"MINOR":4,
"PATCH":0
},
"KSP_VERSION_MAX":{
"MAJOR":1,
"MINOR":3,
"MINOR":4,
"PATCH":8
}
}
99 changes: 70 additions & 29 deletions Source/CapCom.cs
Expand Up @@ -83,47 +83,88 @@ protected override void Awake()
if (!textureLoaded)
{
textureLoaded = true;

Texture original = null;


foreach (Texture2D t in Resources.FindObjectsOfTypeAll<Texture2D>())
{
if (t.name == "SpriteAtlasTexture-MissionControl (Group 0)-1024x1024-fmt5")
{
LogFormatted("Texture Found...");
original = t;
break;
}
}
if (t.name == "missc_btn_acceptcontract_normal")
CapComSkins.acceptButtonNormal = t;
else if (t.name == "missc_btn_acceptcontract_over")
CapComSkins.acceptButtonHover = t;
else if (t.name == "missc_btn_acceptcontract_disabled")
CapComSkins.acceptButtonInactive = t;
else if (t.name == "missc_btn_acceptcontract_active")
CapComSkins.acceptButtonActive = t;
else if (t.name == "missc_btn_cancelcontract_normal")
CapComSkins.cancelButtonNormal = t;
else if (t.name == "missc_btn_cancelcontract_over")
CapComSkins.cancelButtonHover = t;
else if (t.name == "missc_btn_cancelcontract_disabled")
CapComSkins.cancelButtonInactive = t;
else if (t.name == "missc_btn_cancelcontract_active")
CapComSkins.cancelButtonActive = t;
else if (t.name == "missc_btn_declinecontract_normal")
CapComSkins.declineButtonNormal = t;
else if (t.name == "missc_btn_declinecontract_over")
CapComSkins.declineButtonHover = t;
else if (t.name == "missc_btn_declinecontract_disabled")
CapComSkins.declineButtonInactive = t;
else if (t.name == "missc_btn_declinecontract_active")
CapComSkins.declineButtonActive = t;
else if (t.name == "missc_listitem_true")
{
Texture2D newT = new Texture2D(77, 50);

if (original == null)
{
LogFormatted("Error loading Mission Control Center Texture atlas; some CapCom UI elements will not appear correctly");
return;
}
var rt = RenderTexture.GetTemporary(t.width, t.height, 0, RenderTextureFormat.ARGB32, RenderTextureReadWrite.sRGB, 1);

Graphics.Blit(t, rt);

Texture2D missionControlTexture = new Texture2D(original.width, original.height);
RenderTexture.active = rt;

var rt = RenderTexture.GetTemporary(original.width, original.height, 0, RenderTextureFormat.ARGB32, RenderTextureReadWrite.sRGB, 1);
newT.ReadPixels(new Rect(0, 0, t.width, t.height), 0, 0);

Graphics.Blit(original, rt);
RenderTexture.active = null;
RenderTexture.ReleaseTemporary(rt);

RenderTexture.active = rt;
rt = null;

missionControlTexture.ReadPixels(new Rect(0, 0, original.width, original.height), 0, 0);
newT.Apply();

RenderTexture.active = null;
RenderTexture.ReleaseTemporary(rt);
var pix = newT.GetPixels(0, 0, 77, 50);

rt = null;
CapComSkins.titleButtonOnLeft = new Texture2D(77, 50);
CapComSkins.titleButtonOnLeft.SetPixels(pix);
CapComSkins.titleButtonOnLeft.Apply();
}
else if (t.name == "missc_listitem_false")
{
Texture2D newT = new Texture2D(77, 50);

original = null;
var rt = RenderTexture.GetTemporary(t.width, t.height, 0, RenderTextureFormat.ARGB32, RenderTextureReadWrite.sRGB, 1);

missionControlTexture.Apply();
Graphics.Blit(t, rt);

CapComSkins.texturesFromAtlas(missionControlTexture);
RenderTexture.active = rt;

Destroy(missionControlTexture);
newT.ReadPixels(new Rect(0, 0, t.width, t.height), 0, 0);

RenderTexture.active = null;
RenderTexture.ReleaseTemporary(rt);

rt = null;

newT.Apply();

var pix = newT.GetPixels(0, 0, 77, 50);

CapComSkins.titleButtonOffLeft = new Texture2D(77, 50);
CapComSkins.titleButtonOffLeft.SetPixels(pix);
CapComSkins.titleButtonOffLeft.Apply();
}
else if (t.name == "missc_logo_bg")
CapComSkins.flagTex = t;
}

CapComSkins.atlasStyles();
}

CapComSkins.currentFlag = GameDatabase.Instance.GetTexture(HighLogic.CurrentGame.flagURL, false);
Expand All @@ -143,8 +184,8 @@ protected override void Awake()
default: version = ainfoV.InformationalVersion; break;
}
}

protected override void Start()
protected override void Start()
{
instance = this;

Expand Down
2 changes: 1 addition & 1 deletion Source/CapComSkins.cs
Expand Up @@ -418,7 +418,7 @@ internal static void texturesFromAtlas(Texture2D atlas)
atlasStyles();
}

private static void atlasStyles()
public static void atlasStyles()
{
acceptButton = new GUIStyle(CC_SkinsLibrary.DefUnitySkin.button);
acceptButton.padding = new RectOffset(0, 0, 0, 0);
Expand Down
2 changes: 1 addition & 1 deletion Source/Framework/CC_MonoBehaviourExtended.cs
Expand Up @@ -413,7 +413,7 @@ internal static void LogFormatted_DebugOnly(String Message, params object[] strP
internal static void LogFormatted(String Message, params object[] strParams)
{
Message = String.Format(Message, strParams); // This fills the params into the message
String strMessageLine = String.Format("{0},{2},{1}",
String strMessageLine = String.Format("{2},{0},{1}",
DateTime.Now, Message,
_AssemblyName); // This adds our standardised wrapper to each line
UnityEngine.Debug.Log(strMessageLine); // And this puts it in the log
Expand Down
12 changes: 6 additions & 6 deletions Source/Properties/AssemblyInfo.cs
Expand Up @@ -21,9 +21,9 @@

// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("64f03873-36c9-4580-9b03-4a236465a892")]
[assembly: AssemblyVersion("1.0.2.7")]
[assembly: AssemblyFileVersion("1.0.2.7")]
[assembly: AssemblyInformationalVersion("v2.7")]
[assembly: KSPAssembly("CapCom", 2, 7)]
[assembly: KSPAssemblyDependency("Progress Parser", 0, 8)]
[assembly: KSPAssemblyDependency("Contract Parser", 0, 7)]
[assembly: AssemblyVersion("1.0.2.8")]
[assembly: AssemblyFileVersion("1.0.2.8")]
[assembly: AssemblyInformationalVersion("v2.8")]
[assembly: KSPAssembly("CapCom", 2, 8)]
[assembly: KSPAssemblyDependency("Progress Parser", 0, 9)]
[assembly: KSPAssemblyDependency("Contract Parser", 0, 8)]

0 comments on commit deff8c2

Please sign in to comment.