Skip to content
This repository was archived by the owner on Aug 18, 2018. It is now read-only.

Commit ddcef4f

Browse files
committed
Initial commit
0 parents  commit ddcef4f

File tree

16 files changed

+1110
-0
lines changed

16 files changed

+1110
-0
lines changed

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
bin
2+
obj
3+
ksp_lib
4+
GameData
5+
NameTag-*.zip
6+
*.userprefs

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
### 1.0.0
2+
3+
* Separated out from kOS.

LICENSE.md

Lines changed: 674 additions & 0 deletions
Large diffs are not rendered by default.

Makefile

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
.PHONY: all install clean
2+
3+
all:
4+
xbuild /p:Configuration=Release NameTag.sln
5+
mkdir -p GameData/NameTag
6+
python tools/ksp-avc.py `tools/version.sh` > GameData/NameTag/NameTag.version
7+
cp LICENSE.md CHANGELOG.md src/bin/Release/NameTag.dll src/module-manager.cfg GameData/NameTag/
8+
zip -r NameTag-`tools/version.sh`.zip GameData
9+
10+
install:
11+
tools/install.sh
12+
13+
clean:
14+
rm -rf src/bin src/obj GameData NameTag-*.zip

NameTag.sln

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio 2012
4+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NameTag", "src/NameTag.csproj", "{01C60DD4-0B7A-4A63-8A3B-E4962E8E16A1}"
5+
EndProject
6+
Global
7+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
8+
Debug|Any CPU = Debug|Any CPU
9+
Release|Any CPU = Release|Any CPU
10+
EndGlobalSection
11+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
12+
{01C60DD4-0B7A-4A63-8A3B-E4962E8E16A1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
13+
{01C60DD4-0B7A-4A63-8A3B-E4962E8E16A1}.Debug|Any CPU.Build.0 = Debug|Any CPU
14+
{01C60DD4-0B7A-4A63-8A3B-E4962E8E16A1}.Release|Any CPU.ActiveCfg = Release|Any CPU
15+
{01C60DD4-0B7A-4A63-8A3B-E4962E8E16A1}.Release|Any CPU.Build.0 = Release|Any CPU
16+
EndGlobalSection
17+
EndGlobal

VERSION.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
1.0.0

src/AssemblyInfo.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
using System.Reflection;
2+
3+
[assembly: AssemblyTitle ("NameTag")]
4+
[assembly: AssemblyVersion ("1.0.0")]

src/Career.cs

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
namespace NameTag
2+
{
3+
public static class Career
4+
{
5+
/// <summary>
6+
/// Detect whether we'll allow you to add a NameTag to a part during the editor.
7+
/// You can always add one post-editor during flight, but during editing it will
8+
/// depend on building level.
9+
/// </summary>
10+
/// <param name="whichEditor">Pass in whether you are checking from the VAB or SPH.</param>
11+
/// <param name="reason">returns a string describing what would need upgrading to change the answer.</param>
12+
/// <returns>true if it can. false if it cannot.</returns>
13+
public static bool CanTagInEditor (EditorFacility whichEditor, out string reason)
14+
{
15+
float buildingLevel;
16+
switch (whichEditor) {
17+
case EditorFacility.VAB:
18+
reason = "vehicle assembly building";
19+
buildingLevel = ScenarioUpgradeableFacilities.GetFacilityLevel (SpaceCenterFacility.VehicleAssemblyBuilding);
20+
break;
21+
case EditorFacility.SPH:
22+
reason = "space plane hangar";
23+
buildingLevel = ScenarioUpgradeableFacilities.GetFacilityLevel (SpaceCenterFacility.SpaceplaneHangar);
24+
break;
25+
default:
26+
reason = "unknown editor building";
27+
return false; // not even sure how you could get here.
28+
}
29+
// We'll attach it to the same point where the game starts unlocking basic action groups:
30+
return GameVariables.Instance.UnlockedActionGroupsStock (buildingLevel, false);
31+
}
32+
33+
/// <summary>
34+
/// Same as CanTagInEditor, but without the 'reason' parameter. (This is a separate method
35+
/// only because you can't default out parameters like 'out string reason' to make them optional.)
36+
/// </summary>
37+
/// <returns>true if you can. false if you cannot.</returns>
38+
public static bool CanTagInEditor (EditorFacility whichEditor)
39+
{
40+
string dummy;
41+
return CanTagInEditor (whichEditor, out dummy);
42+
}
43+
}
44+
}

src/NameTag.cs

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
using UnityEngine;
2+
3+
namespace NameTag
4+
{
5+
// Note: name kept as KOSNameTag for backward compatibility
6+
public class KOSNameTag : PartModule
7+
{
8+
Window typingWindow;
9+
10+
[KSPField (isPersistant = true, guiActive = true, guiActiveEditor = true, guiName = "Name Tag")]
11+
public string nameTag = "";
12+
13+
[KSPEvent (guiActive = true, guiActiveEditor = true, guiName = "Change Name Tag")]
14+
public void PopupNameTagChanger ()
15+
{
16+
if (typingWindow != null)
17+
typingWindow.Close ();
18+
if (HighLogic.LoadedSceneIsEditor) {
19+
EditorFacility whichEditor = EditorLogic.fetch.ship.shipFacility;
20+
if (!(Career.CanTagInEditor (whichEditor))) {
21+
var formattedString = string.Format ("The {0} requires an upgrade to assign name tags", whichEditor);
22+
ScreenMessages.PostScreenMessage (formattedString, 6, ScreenMessageStyle.UPPER_CENTER);
23+
return;
24+
}
25+
}
26+
var gObj = new GameObject ("nametag", typeof(Window));
27+
DontDestroyOnLoad (gObj);
28+
typingWindow = (Window)gObj.GetComponent (typeof(Window));
29+
typingWindow.Invoke (this, nameTag);
30+
}
31+
32+
public void TypingDone (string newValue)
33+
{
34+
nameTag = newValue;
35+
TypingCancel ();
36+
}
37+
38+
public void TypingCancel ()
39+
{
40+
typingWindow.Close ();
41+
typingWindow = null;
42+
}
43+
}
44+
}

src/NameTag.csproj

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<PropertyGroup>
4+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
5+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
6+
<ProjectGuid>{01C60DD4-0B7A-4A63-8A3B-E4962E8E16A1}</ProjectGuid>
7+
<OutputType>Library</OutputType>
8+
<RootNamespace>NameTag</RootNamespace>
9+
<AssemblyName>NameTag</AssemblyName>
10+
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
11+
</PropertyGroup>
12+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
13+
<DebugSymbols>true</DebugSymbols>
14+
<DebugType>full</DebugType>
15+
<Optimize>false</Optimize>
16+
<OutputPath>bin\Debug</OutputPath>
17+
<DefineConstants>DEBUG;</DefineConstants>
18+
<ErrorReport>prompt</ErrorReport>
19+
<WarningLevel>4</WarningLevel>
20+
<ConsolePause>false</ConsolePause>
21+
</PropertyGroup>
22+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
23+
<DebugType>full</DebugType>
24+
<Optimize>true</Optimize>
25+
<OutputPath>bin\Release</OutputPath>
26+
<ErrorReport>prompt</ErrorReport>
27+
<WarningLevel>4</WarningLevel>
28+
<ConsolePause>false</ConsolePause>
29+
</PropertyGroup>
30+
<ItemGroup>
31+
<Reference Include="System" />
32+
<Reference Include="Assembly-CSharp">
33+
<HintPath>..\ksp_lib\KSP_Data\Managed\Assembly-CSharp.dll</HintPath>
34+
</Reference>
35+
<Reference Include="Assembly-CSharp-firstpass">
36+
<HintPath>..\ksp_lib\KSP_Data\Managed\Assembly-CSharp-firstpass.dll</HintPath>
37+
</Reference>
38+
<Reference Include="UnityEngine">
39+
<HintPath>..\ksp_lib\KSP_Data\Managed\UnityEngine.dll</HintPath>
40+
</Reference>
41+
<Reference Include="UnityEngine.UI">
42+
<HintPath>..\ksp_lib\KSP_Data\Managed\UnityEngine.UI.dll</HintPath>
43+
</Reference>
44+
<Reference Include="KSPUtil">
45+
<HintPath>..\ksp_lib\KSP_Data\Managed\KSPUtil.dll</HintPath>
46+
</Reference>
47+
</ItemGroup>
48+
<ItemGroup>
49+
<Compile Include="AssemblyInfo.cs" />
50+
<Compile Include="NameTag.cs" />
51+
<Compile Include="Window.cs" />
52+
<Compile Include="Career.cs" />
53+
</ItemGroup>
54+
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
55+
</Project>

0 commit comments

Comments
 (0)