Skip to content

Commit

Permalink
new bars
Browse files Browse the repository at this point in the history
  • Loading branch information
Killface1980 committed Dec 31, 2016
1 parent 0907579 commit 17a9b51
Show file tree
Hide file tree
Showing 10 changed files with 41 additions and 55 deletions.
Binary file modified Assemblies/ColonistBarKF.dll
Binary file not shown.
1 change: 1 addition & 0 deletions Languages/ChineseSimplified/Keyed/ColonistBar_KF.xml
Expand Up @@ -33,6 +33,7 @@
<CBKF.Settings.useBottom>底端</CBKF.Settings.useBottom>
<CBKF.Settings.useGender>按性别使用背景颜色</CBKF.Settings.useGender>
<CBKF.Settings.useLeft>左侧</CBKF.Settings.useLeft>
<CBKF.Settings.UseNewMood>Use new MoodBars™</CBKF.Settings.UseNewMood>
<CBKF.Settings.UseExternalMoodBar>使用心情栏™: </CBKF.Settings.UseExternalMoodBar>
<CBKF.Settings.UsePsiOnBar>展示人物状态图标™ 在头像上</CBKF.Settings.UsePsiOnBar>
<CBKF.Settings.useRight>右侧</CBKF.Settings.useRight>
Expand Down
1 change: 1 addition & 0 deletions Languages/English/Keyed/ColonistBar_KF.xml
Expand Up @@ -33,6 +33,7 @@
<CBKF.Settings.useBottom>Bottom</CBKF.Settings.useBottom>
<CBKF.Settings.useGender>Use background color by gender</CBKF.Settings.useGender>
<CBKF.Settings.useLeft>Left</CBKF.Settings.useLeft>
<CBKF.Settings.UseNewMood>Use new MoodBars™</CBKF.Settings.UseNewMood>
<CBKF.Settings.UseExternalMoodBar>Use external MoodBars™: </CBKF.Settings.UseExternalMoodBar>
<CBKF.Settings.UsePsiOnBar>Show Pawn State Icons™ on Bar</CBKF.Settings.UsePsiOnBar>
<CBKF.Settings.useRight>Right</CBKF.Settings.useRight>
Expand Down
3 changes: 2 additions & 1 deletion Languages/German/Keyed/ColonistBar_KF.xml
Expand Up @@ -33,7 +33,8 @@
<CBKF.Settings.useBottom>Unten</CBKF.Settings.useBottom>
<CBKF.Settings.useGender>Hintergrundfarbe nach Geschlecht</CBKF.Settings.useGender>
<CBKF.Settings.useLeft>Links</CBKF.Settings.useLeft>
<CBKF.Settings.UseExternalMoodBar>Zeige externe Stimmungsleiste™: </CBKF.Settings.UseExternalMoodBar>
<CBKF.Settings.UseNewMood>Benutze neue Launeleiste™</CBKF.Settings.UseNewMood>
<CBKF.Settings.UseExternalMoodBar>Zeige externe Launeleiste™: </CBKF.Settings.UseExternalMoodBar>
<CBKF.Settings.UsePsiOnBar>Zeige Pawn State Icons auf Leiste</CBKF.Settings.UsePsiOnBar>
<CBKF.Settings.useRight>Rechts</CBKF.Settings.useRight>
<CBKF.Settings.useTop>Oben</CBKF.Settings.useTop>
Expand Down
2 changes: 1 addition & 1 deletion Source/RW_ColonistBarKF/ColonistBarKF.csproj
Expand Up @@ -74,7 +74,7 @@
<Compile Include="CB_SpecialInjector.cs" />
<Compile Include="MapComponentInjector.cs" />
<Compile Include="ColonistBarTextures.cs" />
<Compile Include="DetourAttribute.cs" />
<Compile Include="NoCCL\DetourAttribute.cs" />
<Compile Include="Fluffy\MapComponent_FollowMe.cs" />
<Compile Include="Fluffy\MapComponent_ZoomToMouse.cs" />
<Compile Include="NoCCL\Detours.cs" />
Expand Down
78 changes: 28 additions & 50 deletions Source/RW_ColonistBarKF/Detouring/ColonistBar_KF.cs
Expand Up @@ -341,6 +341,7 @@ public static void ColonistBarOnGUI()
PawnTextureSize.x = ColBarSettings.BaseSizeFloat - 2f;
PawnTextureSize.y = ColBarSettings.BaseSizeFloat * 1.5f;

MarkColonistsDirty();
RecacheDrawLocs();
}

Expand Down Expand Up @@ -668,7 +669,7 @@ public static void RecacheDrawLocs()
break;

default:
break;
break;
}

cachedDrawLocs.Clear();
Expand Down Expand Up @@ -1012,12 +1013,10 @@ public static void DrawColonist(Rect rect, Pawn colonist, Map pawnMap)
mb = null;
}

Rect moodBorderRect = new Rect(rect);
if (ColBarSettings.UseExternalMoodBar)
{
// draw mood border
Rect moodBorderRect = new Rect(rect);


switch (ColBarSettings.MoodBarPos)
{
case Alignment.Right:
Expand All @@ -1039,28 +1038,29 @@ public static void DrawColonist(Rect rect, Pawn colonist, Map pawnMap)
moodBorderRect.height /= 4;
break;
}
}

if (mood != null && mb != null)
if (ColBarSettings.UseNewMood || ColBarSettings.UseExternalMoodBar)
if (mood != null && mb != null)
{
if (mood.CurLevelPercentage <= mb.BreakThresholdExtreme)
{
if (mood.CurLevelPercentage <= mb.BreakThresholdExtreme)
{
GUI.DrawTexture(moodBorderRect, ColonistBarTextures.MoodNeutral);
GUI.DrawTexture(moodBorderRect, ColonistBarTextures.MoodExtremeCrossedTex);
}
else if (mood.CurLevelPercentage <= mb.BreakThresholdMajor)
{
GUI.DrawTexture(moodBorderRect, ColonistBarTextures.MoodNeutral);
GUI.DrawTexture(moodBorderRect, ColonistBarTextures.MoodMajorCrossedTex);
}
else if (mood.CurLevelPercentage <= mb.BreakThresholdMinor)
{
GUI.DrawTexture(moodBorderRect, ColonistBarTextures.MoodNeutral);
GUI.DrawTexture(moodBorderRect, ColonistBarTextures.MoodMinorCrossedTex);
}
else
{
GUI.DrawTexture(moodBorderRect, ColonistBarTextures.MoodNeutral);
}
GUI.DrawTexture(moodBorderRect, ColonistBarTextures.MoodNeutral);
GUI.DrawTexture(moodBorderRect, ColonistBarTextures.MoodExtremeCrossedTex);
}
else if (mood.CurLevelPercentage <= mb.BreakThresholdMajor)
{
GUI.DrawTexture(moodBorderRect, ColonistBarTextures.MoodNeutral);
GUI.DrawTexture(moodBorderRect, ColonistBarTextures.MoodMajorCrossedTex);
}
else if (mood.CurLevelPercentage <= mb.BreakThresholdMinor)
{
GUI.DrawTexture(moodBorderRect, ColonistBarTextures.MoodNeutral);
GUI.DrawTexture(moodBorderRect, ColonistBarTextures.MoodMinorCrossedTex);
}
else
{
GUI.DrawTexture(moodBorderRect, ColonistBarTextures.MoodNeutral);
}
}

Expand Down Expand Up @@ -1090,10 +1090,10 @@ public static void DrawColonist(Rect rect, Pawn colonist, Map pawnMap)

GUI.color = color;

if (ColBarSettings.UseExternalMoodBar)
if (ColBarSettings.UseExternalMoodBar || ColBarSettings.UseNewMood)
{
// Rect moodRect = new Rect(rect.xMax, rect.y, rect.width/4, rect.height);
DrawExternalMoodRect(rect, mood, mb);
Rect moodRect = moodBorderRect.ContractedBy(2f);
DrawNewMoodRect(moodRect, mood, mb);
}
else
{
Expand Down Expand Up @@ -1140,30 +1140,8 @@ public static void DrawColonist(Rect rect, Pawn colonist, Map pawnMap)
GUI.color = Color.white;
}

private static void DrawExternalMoodRect(Rect rect, Need_Mood mood, MentalBreaker mb)
private static void DrawNewMoodRect(Rect moodRect, Need_Mood mood, MentalBreaker mb)
{
Rect moodRect = rect.ContractedBy(2.0f);
switch (ColBarSettings.MoodBarPos)
{
case Alignment.Right:
moodRect.x = rect.xMax;
moodRect.width /= 4;
break;
case Alignment.Left:
moodRect.x = rect.xMin - rect.width / 4;
moodRect.width /= 4;
break;
case Alignment.Top:
moodRect.x = rect.xMin;
moodRect.y = rect.yMin - rect.height / 4;
moodRect.height /= 4;
break;
case Alignment.Bottom:
moodRect.x = rect.xMin;
moodRect.y = moodRect.yMax + SpacingLabel;
moodRect.height /= 4;
break;
}

if (mood != null && mb != null)
{
Expand Down
3 changes: 3 additions & 0 deletions Source/RW_ColonistBarKF/ModConfigMenu.cs
Expand Up @@ -606,6 +606,9 @@ private void FillPageMain()
#region Mood Bar

BeginVertical(this._fondBoxes);
ColBarSettings.UseNewMood = Toggle(
ColBarSettings.UseNewMood,
"CBKF.Settings.UseNewMood".Translate());
ColBarSettings.UseExternalMoodBar = Toggle(
ColBarSettings.UseExternalMoodBar,
"CBKF.Settings.UseExternalMoodBar".Translate());
Expand Down
File renamed without changes.
6 changes: 3 additions & 3 deletions Source/RW_ColonistBarKF/PSI/PSI.cs
Expand Up @@ -447,7 +447,7 @@ private static void UpdateColonistStats(Pawn colonist)

PawnStats pawnStats = _statsDict[colonist];

if (pawnStats.lastStatUpdate + Rand.Range(100, 800) > Find.TickManager.TicksGame)
if (pawnStats.lastStatUpdate + Rand.Range(20, 60) > Find.TickManager.TicksGame)
return;

pawnStats.thoughts = colonist.needs.mood.thoughts.DistinctThoughtGroups();
Expand Down Expand Up @@ -481,7 +481,7 @@ private static void UpdateColonistStats(Pawn colonist)
LocalTargetInfo targetInfo = curJob.targetA;
if (curDriver is JobDriver_HaulToContainer || curDriver is JobDriver_HaulToCell ||
curDriver is JobDriver_FoodDeliver || curDriver is JobDriver_FoodFeedPatient ||
curDriver is JobDriver_TakeToBed)
curDriver is JobDriver_TakeToBed || curDriver is JobDriver_TakeBeerOutOfFermentingBarrel)
{
targetInfo = curJob.targetB;
}
Expand Down Expand Up @@ -695,7 +695,7 @@ public virtual void FixedUpdate()

_fDelta += Time.fixedDeltaTime;

if (_fDelta < 0.2)
if (_fDelta < 0.1)
return;
_fDelta = 0.0;

Expand Down
2 changes: 2 additions & 0 deletions Source/RW_ColonistBarKF/Settings/SettingsColonistBar.cs
Expand Up @@ -204,5 +204,7 @@ public enum SortByWhat

byName
}

public bool UseNewMood = true;
}
}

0 comments on commit 17a9b51

Please sign in to comment.