Skip to content

Commit

Permalink
update for 1.2.1, updated toolbarwrapper, update for new rpm
Browse files Browse the repository at this point in the history
  • Loading branch information
hashashin committed Nov 5, 2016
1 parent d575cb2 commit cb288ab
Show file tree
Hide file tree
Showing 9 changed files with 154 additions and 136 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -158,3 +158,5 @@ GameData/notes/Plugins/notes.dll
GameData/notes/Plugins/notesRPM.dll
*.zip
*.scgdat

*.userprefs
4 changes: 2 additions & 2 deletions GameData/notes/BasicMFDnotesPatch.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@
infoButton = 2

//Text tint is also modifiable
textTint = [#009900ff]
textTintUnpowered = [#ffffff3e]
textTint = <color=#009900ff>
textTintUnpowered = <color=#ffffff3e>
}
}
}
Expand Down
3 changes: 3 additions & 0 deletions notes.sln
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,7 @@ Global
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(MonoDevelopProperties) = preSolution
version = 0.14
EndGlobalSection
EndGlobal
6 changes: 3 additions & 3 deletions notes/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Notes plugin for KSP")]
[assembly: AssemblyCopyright("Copyright © 2015 hashashin")]
[assembly: AssemblyCopyright("Copyright © 2016 hashashin")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

Expand All @@ -31,5 +31,5 @@
// Puede especificar todos los valores o establecer como predeterminados los números de compilación y de revisión
// mediante el carácter '*', como se muestra a continuación:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("0.13.0.0")]
[assembly: AssemblyFileVersion("0.13.0.0")]
[assembly: AssemblyVersion("0.14.0.0")]
[assembly: AssemblyFileVersion("0.14.0.0")]
17 changes: 11 additions & 6 deletions notes/notes.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile />
<ReleaseVersion>0.14</ReleaseVersion>
<SynchReleaseVersion>false</SynchReleaseVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
Expand All @@ -24,14 +26,15 @@
<RegisterForComInterop>false</RegisterForComInterop>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<DebugType>
</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>3</WarningLevel>
<RunCodeAnalysis>false</RunCodeAnalysis>
<PlatformTarget>AnyCPU</PlatformTarget>
<PlatformTarget>anycpu</PlatformTarget>
</PropertyGroup>
<PropertyGroup>
<ApplicationIcon>
Expand Down Expand Up @@ -66,12 +69,14 @@
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<Reference Include="Assembly-CSharp">
<HintPath>N:\ksp1.1\KSP_x64_Data\Managed\Assembly-CSharp.dll</HintPath>
<Reference Include="Assembly-CSharp, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\Managed\Assembly-CSharp.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="UnityEngine">
<HintPath>N:\ksp1.1\KSP_x64_Data\Managed\UnityEngine.dll</HintPath>
<Reference Include="UnityEngine, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\Managed\UnityEngine.dll</HintPath>
</Reference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
Expand Down
17 changes: 11 additions & 6 deletions notes/toolbarwrapper.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright (c) 2013-2014, Maik Schreiber
Copyright (c) 2013-2016, Maik Schreiber
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
Expand All @@ -23,9 +23,8 @@ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using UnityEngine;

Expand Down Expand Up @@ -824,9 +823,15 @@ internal ToolbarTypes()

internal static Type getType(string name)
{
return AssemblyLoader.loadedAssemblies
.SelectMany(a => a.assembly.GetExportedTypes())
.SingleOrDefault(t => t.FullName == name);
Type type = null;
AssemblyLoader.loadedAssemblies.TypeOperation(t =>
{
if (t.FullName == name)
{
type = t;
}
});
return type;
}

internal static PropertyInfo getProperty(Type type, string name)
Expand Down
4 changes: 2 additions & 2 deletions notesRPM/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@
// Puede especificar todos los valores o establecer como predeterminados los números de compilación y de revisión
// mediante el carácter '*', como se muestra a continuación:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("0.1")]
[assembly: AssemblyFileVersion("0.1")]
[assembly: AssemblyVersion("0.2")]
[assembly: AssemblyFileVersion("0.2")]
228 changes: 115 additions & 113 deletions notesRPM/notesRPM.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,128 +31,130 @@

namespace notesRPM
{
public class notesRPM : InternalModule
{
//Buttons
[KSPField]
public int noteButton = 0;
[KSPField]
public int downButton = 1;
[KSPField]
public int infoButton = 2;
public class notesRPM : InternalModule
{
//Buttons
[KSPField]
public int noteButton = 0;
[KSPField]
public int downButton = 1;
[KSPField]
public int infoButton = 2;

[KSPField] public int nextnoteButton = 7;
[KSPField] public int prevnoteButton = 8;
[KSPField]
public int nextnoteButton = 7;
[KSPField]
public int prevnoteButton = 8;


//kOS Fields
[KSPField]
public string textTint = "[#009900ff]";
[KSPField]
public string textTintUnpowered = "[#ffffff3e]";
[KSPField]
public int consoleWidth = 40;
[KSPField]
public int consoleHeight = 20;
//kOS Fields
[KSPField]
public string textTint = "<color=#009900ff>";
[KSPField]
public string textTintUnpowered = "<color=#ffffff3e>";
[KSPField]
public int consoleWidth = 40;
[KSPField]
public int consoleHeight = 20;

//General State Variables
private string response = "Notes terminal";
private bool started = false;
private Notes notes;
//General State Variables
private string response = "Notes terminal";
private bool started = false;
private Notes notes;


public string ContentProcessor(int screenWidth, int screenHeight)
{
if (started)
{
return (response);
}
//Check for initialization
notes = FindObjectOfType<Notes>();
response = textFormat(notes._text);
started = true;
return response;
}
public string ContentProcessor(int screenWidth, int screenHeight)
{
if (started)
{
return (response);
}
//Check for initialization
notes = FindObjectOfType<Notes>();
response = textFormat(notes._text);
started = true;
return response;
}

public void ButtonProcessor(int buttonID)
{
if (buttonID == noteButton)
{
response =
textFormat(notes._text);
}
else if (buttonID == downButton)
{
godowntext(response);
}
else if (buttonID == infoButton)
{
notes.GetLogInfo();
response = textFormat(notes._vesselInfo);
}
else if (buttonID == nextnoteButton)
{
notes.SelectNote(true);
response =
textFormat(notes._text);
}
else if (buttonID == prevnoteButton)
{
notes.SelectNote(false);
response =
textFormat(notes._text);
}
}
public void ButtonProcessor(int buttonID)
{
if (buttonID == noteButton)
{
response =
textFormat(notes._text);
}
else if (buttonID == downButton)
{
godowntext(response);
}
else if (buttonID == infoButton)
{
notes.GetLogInfo();
response = textFormat(notes._vesselInfo);
}
else if (buttonID == nextnoteButton)
{
notes.SelectNote(true);
response =
textFormat(notes._text);
}
else if (buttonID == prevnoteButton)
{
notes.SelectNote(false);
response =
textFormat(notes._text);
}
}

private string textFormat(string sentence)
{
var responsetext = string.Empty;
string[] lines = Regex.Split(sentence, "[\r\n]+");
foreach (var line in lines)
{
string[] words = line.Split(' ');
var parts = new Dictionary<int, string>();
string parttext = string.Empty;
int partCounter = 0;

foreach (var word in words)
{
if (parttext.Length + word.Length < consoleWidth)
{
parttext += string.IsNullOrEmpty(parttext) ? word : " " + word;
}
else
{
parts.Add(partCounter, parttext);
parttext = word;
partCounter++;
}
}
parts.Add(partCounter, parttext);
responsetext = parts.Aggregate(responsetext,
(current, item) => current + (item.Value + Environment.NewLine));
}
return (responsetext);
}
private string textFormat(string sentence)
{
var responsetext = string.Empty;
string[] lines = Regex.Split(sentence, "[\r\n]+");
foreach (var line in lines)
{
string[] words = line.Split(' ');
var parts = new Dictionary<int, string>();
string parttext = string.Empty;
int partCounter = 0;

private void godowntext(string sentence)
{
string[] lines = Regex.Split(sentence, "[\r\n]+");
if (lines.Count() > consoleHeight - 1)
{
var responsetext = String.Empty;
var text = lines.Skip(consoleHeight - 1);
foreach (var line in text)
{
responsetext += line + Environment.NewLine;
}
response = textFormat(responsetext);
}
}
}
foreach (var word in words)
{
if (parttext.Length + word.Length < consoleWidth)
{
parttext += string.IsNullOrEmpty(parttext) ? word : " " + word;
}
else
{
parts.Add(partCounter, parttext);
parttext = word;
partCounter++;
}
}
parts.Add(partCounter, parttext);
responsetext = parts.Aggregate(responsetext,
(current, item) => current + (item.Value + Environment.NewLine));
}
return (responsetext);
}

public class RPMConsole : InternalModule
{
}
private void godowntext(string sentence)
{
string[] lines = Regex.Split(sentence, "[\r\n]+");
if (lines.Count() > consoleHeight - 1)
{
var responsetext = String.Empty;
var text = lines.Skip(consoleHeight - 1);
foreach (var line in text)
{
responsetext += line + Environment.NewLine;
}
response = textFormat(responsetext);
}
}
}

public class RPMConsole : InternalModule
{
}
}

Loading

0 comments on commit cb288ab

Please sign in to comment.