Skip to content

Commit

Permalink
Adjust whitespace
Browse files Browse the repository at this point in the history
  • Loading branch information
krafs committed Mar 17, 2024
1 parent 04e8c3b commit 6ed1a4f
Show file tree
Hide file tree
Showing 51 changed files with 298 additions and 566 deletions.
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,4 @@ dotnet_diagnostic.IDE0058.severity = none
dotnet_diagnostic.CS0649.severity = none

# CA1707: Identifiers should not contain underscores
dotnet_diagnostic.CA1707.severity = none
dotnet_diagnostic.CA1707.severity = none
3 changes: 1 addition & 2 deletions About/About.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@
<modVersion>5.0.0</modVersion>
<description>Level up notifications!</description>
<url>https://github.com/krafs/LevelUp</url>
<modIconPath IgnoreIfNoMatchingField="true">LevelUp/Icon</modIconPath>
<modIconPath>LevelUp/Icon</modIconPath>
<supportedVersions>
<li>1.4</li>
<li>1.5</li>
</supportedVersions>
<modDependencies>
Expand Down
4 changes: 3 additions & 1 deletion Defs/Actions.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Defs>

<LevelUp.ActionDef>
<defName>LevelUpActionDef_Sound</defName>
<label>Sound</label>
Expand Down Expand Up @@ -27,4 +28,5 @@
<description>Displays a text message on the colonist.</description>
<actionClass>LevelUp.OverheadMessageAction</actionClass>
</LevelUp.ActionDef>
</Defs>

</Defs>
4 changes: 3 additions & 1 deletion Defs/Flecks.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Defs>

<FleckDef ParentName="FleckBase_Thrown">
<defName>LevelUpAnimation_Radiance</defName>
<label>Radiance</label>
Expand Down Expand Up @@ -76,4 +77,5 @@
<fadeOutTime>0.5</fadeOutTime>
<unattachedDrawOffset>(0,0,2)</unattachedDrawOffset>
</FleckDef>
</Defs>

</Defs>
4 changes: 3 additions & 1 deletion Defs/Sounds.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Defs>

<SoundDef>
<defName>LevelUpSound_Ding</defName>
<label>Ding</label>
Expand Down Expand Up @@ -194,4 +195,5 @@
</li>
</subSounds>
</SoundDef>
</Defs>

</Defs>
2 changes: 1 addition & 1 deletion Languages/ChineseSimplified/Keyed/ChineseSimplified.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
<LanguageData>
<LevelUp.DefaultLevelUpMessage><![CDATA[升级! <color=orange>{PAWN}</color> 的{SKILL}技能到达{LEVEL}级。]]></LevelUp.DefaultLevelUpMessage>
<LevelUp.DefaultLevelDownMessage><![CDATA[降级! <color=orange>{PAWN}</color> 的{SKILL}技能降至{LEVEL}级。]]></LevelUp.DefaultLevelDownMessage>
</LanguageData>
</LanguageData>
2 changes: 1 addition & 1 deletion Languages/English/DefInjected/FleckDefs/FleckDefs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@
<LevelUpAnimation_UpwardChevron.label>Upward Chevron</LevelUpAnimation_UpwardChevron.label>
<LevelUpAnimation_DownwardChevron.label>Downward Chevron</LevelUpAnimation_DownwardChevron.label>

</LanguageData>
</LanguageData>
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@
<LevelUpActionDef_OverheadMessage.label>Overhead message</LevelUpActionDef_OverheadMessage.label>
<LevelUpActionDef_OverheadMessage.description>Displays a text message on the colonist.</LevelUpActionDef_OverheadMessage.description>

</LanguageData>
</LanguageData>
2 changes: 1 addition & 1 deletion Languages/English/DefInjected/SoundDefs/SoundDefs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@
<LevelUpSound_Strum.label>Strum</LevelUpSound_Strum.label>
<LevelUpSound_TadaFanfare.label>Tada Fanfare</LevelUpSound_TadaFanfare.label>

</LanguageData>
</LanguageData>
8 changes: 2 additions & 6 deletions Languages/English/Keyed/English.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,6 @@
<LevelUp.LevelUpActionHeaderDescription>List of actions that, if active, are executed when a colonist levels up a skill.</LevelUp.LevelUpActionHeaderDescription>
<LevelUp.LevelDownActionHeaderDescription>List of actions that, if active, are executed when a colonist levels down a skill.</LevelUp.LevelDownActionHeaderDescription>

<LevelUp.CooldownLabel>Cooldown</LevelUp.CooldownLabel>
<LevelUp.CooldownEntryDescription>The duration of a cooldown specified in real-time seconds.\n\nIf applied to an action, the action will not execute for the same colonist and skill again until the cooldown has run out.</LevelUp.CooldownEntryDescription>
<LevelUp.CooldownOnActionDescription>Whether or not Cooldown should apply for this action.\n\nIf applied, this action will not execute for the same colonist and skill again until the cooldown has run out.</LevelUp.CooldownOnActionDescription>

<LevelUp.GeneralSettingsLabel>General</LevelUp.GeneralSettingsLabel>
<LevelUp.HistoricalLabel>Historical</LevelUp.HistoricalLabel>
<LevelUp.HistoricalDescription>Whether or not the message should be saved in history.</LevelUp.HistoricalDescription>

Expand All @@ -27,4 +22,5 @@
<LevelUp.DefaultLevelDownMessage><![CDATA[<color=orange>{PAWN}</color> reached level {LEVEL} in {SKILL}.]]></LevelUp.DefaultLevelDownMessage>
<LevelUp.DefaultLevelUpOverheadMessage>{SKILL}\nlevel {LEVEL}</LevelUp.DefaultLevelUpOverheadMessage>
<LevelUp.DefaultLevelDownOverheadMessage>{SKILL}\nlevel {LEVEL}</LevelUp.DefaultLevelDownOverheadMessage>
</LanguageData>

</LanguageData>
2 changes: 1 addition & 1 deletion Languages/French/Keyed/French.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
<LanguageData>
<LevelUp.DefaultLevelUpMessage><![CDATA[Niveau Supérieur! <color=orange>{PAWN}</color> a atteint le niveau {LEVEL} en {SKILL}.]]></LevelUp.DefaultLevelUpMessage>
<LevelUp.DefaultLevelDownMessage><![CDATA[Niveau Inférieur! <color=orange>{PAWN}</color> est retombé au niveau {LEVEL} en {SKILL}.]]></LevelUp.DefaultLevelDownMessage>
</LanguageData>
</LanguageData>
2 changes: 1 addition & 1 deletion Languages/German/DefInjected/FleckDefs/FleckDefs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@
<!-- EN: Downward Chevron -->
<LevelUpAnimation_DownwardChevron.label>Doppelspitze nach unten</LevelUpAnimation_DownwardChevron.label>

</LanguageData>
</LanguageData>
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@
<!-- EN: Displays a text message on the colonist. -->
<LevelUpActionDef_OverheadMessage.description>Zeigt eine Textnachricht auf dem Kolonisten an.</LevelUpActionDef_OverheadMessage.description>

</LanguageData>
</LanguageData>
2 changes: 1 addition & 1 deletion Languages/German/DefInjected/SoundDefs/SoundDefs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@
<!-- EN: Tada Fanfare -->
<LevelUpSound_TadaFanfare.label>Tada-Fanfare</LevelUpSound_TadaFanfare.label>

</LanguageData>
</LanguageData>
9 changes: 0 additions & 9 deletions Languages/German/Keyed/German.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,6 @@
<!-- EN: List of actions that, if active, are executed when a colonist levels down a skill. -->
<LevelUp.LevelDownActionHeaderDescription>Eine Liste von Aktionen, die, sofern aktiv, ausgeführt werden, wenn ein Kolonist Fertigkeitsstufen verliert.</LevelUp.LevelDownActionHeaderDescription>

<!-- EN: Cooldown -->
<LevelUp.CooldownLabel>Abklingzeit</LevelUp.CooldownLabel>
<!-- EN: The duration of a cooldown specified in real-time seconds.\n\nIf applied to an action, the action will not execute for the same colonist and skill again until the cooldown has run out. -->
<LevelUp.CooldownEntryDescription>Die Dauer einer Abklingzeit in echten Sekunden.\n\nAktiviert man eine Abklingzeit bei einer Aktion, wird die Aktion für denselben Kolonisten und dieselbe Fertigkeit erst nach einer gewissen Zeit wieder ausgeführt.</LevelUp.CooldownEntryDescription>
<!-- EN: Whether or not Cooldown should apply for this action.\n\nIf applied, this action will not execute for the same colonist and skill again until the cooldown has run out. -->
<LevelUp.CooldownOnActionDescription>Ob eine Abklingzeit bei dieser Aktion aktiviert werden soll oder nicht.\n\nIm aktivierten Zustand wird die Aktion für denselben Kolonisten und dieselbe Fertigkeit erst nach einer gewissen Zeit wieder ausgeführt.</LevelUp.CooldownOnActionDescription>

<!-- EN: General -->
<LevelUp.GeneralSettingsLabel>Allgemein</LevelUp.GeneralSettingsLabel>
<!-- EN: Historical -->
<LevelUp.HistoricalLabel>Im Nachrichtenverlauf anzeigen</LevelUp.HistoricalLabel>
<!-- EN: Whether or not the message should be saved in history. -->
Expand Down
2 changes: 1 addition & 1 deletion Languages/Italian/Deflnjected/FleckDefs/FleckDefs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
<LevelUpAnimation_UpwardChevron.label>Chevron verso l'alto</LevelUpAnimation_UpwardChevron.label>
<LevelUpAnimation_DownwardChevron.label>Chevron verso il basso</LevelUpAnimation_DownwardChevron.label>

</LanguageData>
</LanguageData>
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@
<LevelUpActionDef_OverheadMessage.label>Messaggio in alto</LevelUpActionDef_OverheadMessage.label>
<LevelUpActionDef_OverheadMessage.description>Mostra un messaggio testuale sul colono.</LevelUpActionDef_OverheadMessage.description>

</LanguageData>
</LanguageData>
2 changes: 1 addition & 1 deletion Languages/Italian/Deflnjected/SoundDefs/SoundDefs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@
<LevelUpSound_Strum.label>Strum</LevelUpSound_Strum.label>
<LevelUpSound_TadaFanfare.label>Tada-Fanfare</LevelUpSound_TadaFanfare.label>

</LanguageData>
</LanguageData>
10 changes: 3 additions & 7 deletions Languages/Italian/Keyed/Italian.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,7 @@

<LevelUp.LevelUpActionHeaderDescription>Elenco di azioni che, se attive, vengono eseguite quando un colono aumenta di livello un'abilità.</LevelUp.LevelUpActionHeaderDescription>
<LevelUp.LevelDownActionHeaderDescription>Elenco di azioni che, se attive, vengono eseguite quando un colono diminuisce di livello un'abilità.</LevelUp.LevelDownActionHeaderDescription>

<LevelUp.CooldownLabel>Cooldown</LevelUp.CooldownLabel>
<LevelUp.CooldownEntryDescription>La durata di un cooldown è specificato in secondi (del tempo reale).\n\nSe viene applicato a un'azione, questa non verrà eseguita per lo stesso colono e stessa abilità fino a quando il cooldown non sarà terminato.</LevelUp.CooldownEntryDescription>
<LevelUp.CooldownOnActionDescription>Indipendentemente dal fatto che il cooldown debba essere applicato per questa azione.\n\nSe applicato, l'azione non verrà eseguita nuovamente per lo stesso colono e stessa abilità fino a quando il cooldown non sarà terminato.</LevelUp.CooldownOnActionDescription>

<LevelUp.GeneralSettingsLabel>Generale</LevelUp.GeneralSettingsLabel>

<LevelUp.HistoricalLabel>Cronologia</LevelUp.HistoricalLabel>
<LevelUp.HistoricalDescription>Indipendentemente dal fatto che il messaggio debba essere salvato nella cronologia.</LevelUp.HistoricalDescription>

Expand All @@ -27,4 +22,5 @@
<LevelUp.DefaultLevelDownMessage><![CDATA[<color=orange>{PAWN}</color> ha raggiunto il livello {LEVEL} in {SKILL}.]]></LevelUp.DefaultLevelDownMessage>
<LevelUp.DefaultLevelUpOverheadMessage>{SKILL}\nlivello {LEVEL}</LevelUp.DefaultLevelUpOverheadMessage>
<LevelUp.DefaultLevelDownOverheadMessage>{SKILL}\nlivello {LEVEL}</LevelUp.DefaultLevelDownOverheadMessage>
</LanguageData>

</LanguageData>
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
<LanguageData>
<LevelUp.DefaultLevelUpMessage><![CDATA[Subiu de Nível! <color=orange>{PAWN}</color> chegou ao nível {LEVEL} em {SKILL}.]]></LevelUp.DefaultLevelUpMessage>
<LevelUp.DefaultLevelDownMessage><![CDATA[Desceu de Nível! <color=orange>{PAWN}</color> desceu para o nível {LEVEL} em {SKILL}.]]></LevelUp.DefaultLevelDownMessage>
</LanguageData>
</LanguageData>
2 changes: 1 addition & 1 deletion Languages/Russian/Keyed/Russian.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
<LanguageData>
<LevelUp.DefaultLevelUpMessage><![CDATA[Уровень повышен! <color=orange>{PAWN}</color> достигнут уровень {LEVEL} в {SKILL}.]]></LevelUp.DefaultLevelUpMessage>
<LevelUp.DefaultLevelDownMessage><![CDATA[Уровень понижен! <color=orange>{PAWN}</color> понижен уровень {LEVEL} в {SKILL}.]]></LevelUp.DefaultLevelDownMessage>
</LanguageData>
</LanguageData>
2 changes: 1 addition & 1 deletion Languages/Spanish/DefInjected/FleckDefs/FleckDefs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
<LevelUpAnimation_UpwardChevron.label>Chevron ascendente</LevelUpAnimation_UpwardChevron.label>
<LevelUpAnimation_DownwardChevron.label>Chevron descendente</LevelUpAnimation_DownwardChevron.label>

</LanguageData>
</LanguageData>
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@
<LevelUpActionDef_OverheadMessage.label>Mensaje superior</LevelUpActionDef_OverheadMessage.label>
<LevelUpActionDef_OverheadMessage.description>Muestra un mensaje de texto en el colono.</LevelUpActionDef_OverheadMessage.description>

</LanguageData>
</LanguageData>
2 changes: 1 addition & 1 deletion Languages/Spanish/DefInjected/SoundDefs/SoundDefs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@
<LevelUpSound_Strum.label>Rasgueo</LevelUpSound_Strum.label>
<LevelUpSound_TadaFanfare.label>Fanfarria de Tada</LevelUpSound_TadaFanfare.label>

</LanguageData>
</LanguageData>
7 changes: 1 addition & 6 deletions Languages/Spanish/Keyed/Spanish.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,6 @@
<LevelUp.LevelUpActionHeaderDescription>Lista de acciones que, si están activas, se ejecutan cuando un colono sube de nivel una habilidad.</LevelUp.LevelUpActionHeaderDescription>
<LevelUp.LevelDownActionHeaderDescription>Lista de acciones que, si están activas, se ejecutan cuando un colono baja de nivel una habilidad.</LevelUp.LevelDownActionHeaderDescription>

<LevelUp.CooldownLabel>Enfriamiento</LevelUp.CooldownLabel>
<LevelUp.CooldownEntryDescription>La duración de un enfriamiento especificado en segundos en tiempo real.\n\nSi se aplica a una acción, la acción no se ejecutará para el mismo colono y habilidad de nuevo hasta que el enfriamiento se haya agotado.</LevelUp.CooldownEntryDescription>
<LevelUp.CooldownOnActionDescription>Si se aplica o no el enfriamiento para esta acción.\n\nSi se aplica, esta acción no se ejecutará para el mismo colono y habilidad nuevamente hasta que se agote el tiempo de reutilización.</LevelUp.CooldownOnActionDescription>

<LevelUp.GeneralSettingsLabel>General</LevelUp.GeneralSettingsLabel>
<LevelUp.HistoricalLabel>Histórico</LevelUp.HistoricalLabel>
<LevelUp.HistoricalDescription>Si el mensaje debe guardarse o no en el historial.</LevelUp.HistoricalDescription>

Expand All @@ -27,5 +22,5 @@
<LevelUp.DefaultLevelDownMessage><![CDATA[<color=orange>{PAWN}</color> ha alcanzado el nivel {LEVEL} en {SKILL}.]]></LevelUp.DefaultLevelDownMessage>
<LevelUp.DefaultLevelUpOverheadMessage>{SKILL}\nnivel {LEVEL}</LevelUp.DefaultLevelUpOverheadMessage>
<LevelUp.DefaultLevelDownOverheadMessage>{SKILL}\nnivel {LEVEL}</LevelUp.DefaultLevelDownOverheadMessage>

</LanguageData>

6 changes: 2 additions & 4 deletions Source/ActionDef.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,9 @@

namespace LevelUp;

[Serializable]
public class ActionDef : Def
public sealed class ActionDef : Def
{
private readonly Type actionClass = null!;
public Type ActionClass => actionClass;
internal readonly Type actionClass = null!;

public override IEnumerable<string> ConfigErrors()
{
Expand Down
49 changes: 11 additions & 38 deletions Source/ActionMaker.cs
Original file line number Diff line number Diff line change
@@ -1,47 +1,35 @@
using RimWorld;
using System;
using System.Collections.Generic;
using UnityEngine;
using Verse;
using Verse.Sound;

namespace LevelUp;

[Serializable]
public class ActionMaker : IExposable
public sealed class ActionMaker : IExposable
{
private List<LevelingAction> actions = [];
internal List<LevelingAction> actions = [];
private Vector2 scrollPosition;
private readonly List<LevelingAction> preparedActions = [];
private readonly List<LevelingAction> preparedCooldownActions = [];
public List<LevelingAction> Actions => actions;

public void Prepare()
internal void Prepare()
{
preparedActions.Clear();
preparedCooldownActions.Clear();

foreach (LevelingAction action in actions)
{
if (!action.Active)
if (!action.active)
{
continue;
}

if (action.Cooldown)
{
preparedCooldownActions.Add(action);
}
else
{
preparedActions.Add(action);
}
preparedActions.Add(action);

action.Prepare();
}
}

public void ExecuteActions(LevelingInfo levelingInfo)
internal void ExecuteActions(LevelingInfo levelingInfo)
{
if (!levelingInfo.Pawn.IsFreeColonist)
{
Expand All @@ -52,24 +40,9 @@ public void ExecuteActions(LevelingInfo levelingInfo)
{
preparedActions[i].Execute(levelingInfo);
}

bool changedExactlyOneLevel = Math.Abs(levelingInfo.OldLevel - levelingInfo.SkillRecord.Level) == 1;
bool cooldownPassed = PawnSkillTimerCache.EnoughTimeHasPassed(levelingInfo);

// If changed more than one level we want to ignore cooldown, because this is an event the player probably wants to know about
// E.g. used neurotrainer directly after leveled in that same skill
if (changedExactlyOneLevel && !cooldownPassed)
{
return;
}

for (int i = 0; i < preparedCooldownActions.Count; i++)
{
preparedCooldownActions[i].Execute(levelingInfo);
}
}

public void Draw(Rect rect, ref IDrawer selectedAction)
internal void Draw(Rect rect, ref LevelingAction? selectedAction)
{
float listHeight = actions.Count * 24f;
Rect viewRect = new(rect) { xMax = rect.xMax - 15f, height = listHeight };
Expand All @@ -79,17 +52,17 @@ public void Draw(Rect rect, ref IDrawer selectedAction)
{
LevelingAction action = actions[i];
Rect checkboxRect = new(rowRect) { xMin = rowRect.xMax - rowRect.height, width = rowRect.height };
bool isActive = action.Active;
bool isActive = action.active;
Widgets.Checkbox(checkboxRect.x, checkboxRect.y, ref isActive);
action.Active = isActive;
action.active = isActive;

Rect labelRect = new(rowRect) { xMax = checkboxRect.xMin };
Widgets.Label(labelRect, action.ActionDef.label);
Widgets.Label(labelRect, action.actionDef.label);

if (Widgets.ButtonInvisible(labelRect))
{
SoundDefOf.Click.PlayOneShotOnCamera();
selectedAction = selectedAction == action ? Drawer.Empty : action;
selectedAction = selectedAction == action ? null : action;
}

if (selectedAction == action)
Expand Down
Loading

0 comments on commit 6ed1a4f

Please sign in to comment.