Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions Assets/LiveDataEditor/LiveDataEditTool.css
Original file line number Diff line number Diff line change
Expand Up @@ -116,12 +116,29 @@ a.button:hover {
resize: none;
outline: none;
}

#main-container > textarea {
height: 200px;
resize: vertical;
}

#format-preview {
width: 80%;
font-family: monospace;
border-radius: 5px;
border: 1px solid rgb(5, 5, 5);
padding: 10px;
background: rgb(77, 77, 77);
overflow-y: auto;
height: 200px;
resize: vertical;
}

#format-preview p {
margin: 0;
padding: 0;
font-size: 0.9rem;
}

#sidebar-right {
flex: 30;
Expand Down
2 changes: 1 addition & 1 deletion Assets/LiveDataEditor/LiveDataEditTool.html
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ <h2>Editor</h2>
<textarea id="format-text" placeholder="Text"></textarea>
<hr>
<p>Preview</p>
<textarea id="format-preview" disabled></textarea>
<div id="format-preview"></div>
<hr>
<a id="format-save-button" class="button" disabled>Select a format</a>
</div>
Expand Down
48 changes: 43 additions & 5 deletions Assets/LiveDataEditor/LiveDataEditTool.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,10 @@ function showError(errorCode, errorMessage){
if(CurrentState === ViewStates.MainView){
Elements.LoadingText.innerText = message;
}else if(CurrentState === ViewStates.InspectorView){
Elements.FormatPreview.value = message;
Elements.FormatPreview.innerHTML = "";
let previewLine = document.createElement("p");
previewLine.textContent = errorMessage;
Elements.FormatPreview.appendChild(previewLine);
}
}
//#endregion
Expand Down Expand Up @@ -419,11 +422,35 @@ function setPlaceholderExplanationText(name, description){
Elements.PlaceholderExplanationDescription.innerText = description;
}

function parseLine(line) {
let color = "#FFFFFF";
let text = line;

if (line.startsWith("[")) {
let colorLength = line[1] === "#" ? 7 : 6
if (line.length >= colorLength + 2 && line[colorLength + 1] === "]") {
let parsedColor = line.substring(1, colorLength + 1);

if (!parsedColor.startsWith("#")) {
parsedColor = "#" + parsedColor;
}

color = parsedColor;
text = text.substring(colorLength + 2);
}
}

return {
Color: color,
Text: text
};
}

//Launch POST request to /cct/parseFormat with the format text as body
function fetchPreview(){
let formatText = Elements.FormatText.value;
if(formatText === null || formatText === undefined || formatText === ""){
Elements.FormatPreview.value = "";
Elements.FormatPreview.innerHTML = "";
return;
}

Expand All @@ -435,11 +462,22 @@ function fetchPreview(){
.then(responseObj => {
if(responseObj.errorCode !== 0){
console.log(responseObj.errorMessage);
Elements.FormatPreview.value = "Could not fetch preview, error code (" + responseObj.errorCode + "): " + responseObj.errorMessage;

Elements.FormatPreview.innerHTML = "";
let errorLine = document.createElement("p");
errorLine.textContent = "Could not fetch preview, error code (" + responseObj.errorCode + "): " + responseObj.errorMessage;
Elements.FormatPreview.appendChild(errorLine);
return;
}

Elements.FormatPreview.value = responseObj.formats[0];

Elements.FormatPreview.innerHTML = "";
responseObj.formats[0].split("\n").forEach(line => {
let previewLine = document.createElement("p");
let parsedLine = parseLine(line);
previewLine.textContent = parsedLine.Text;
previewLine.style.color = parsedLine.Color;
Elements.FormatPreview.appendChild(previewLine);
});
}).catch(error => showError(-1, "Could not fetch preview (is CCT running?)"));
}
//#endregion
Expand Down
6 changes: 4 additions & 2 deletions ConsistencyTracker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public class ConsistencyTrackerModule : EverestModule {
public static class VersionsNewest {
public static string Mod => "2.9.8";
public static string Overlay => "2.0.0";
public static string LiveDataEditor => "1.0.1";
public static string LiveDataEditor => "1.0.2";
public static string PhysicsInspector => "1.4.2";
}
public static class VersionsCurrent {
Expand Down Expand Up @@ -853,10 +853,12 @@ private void Events_OnResetRun() {
}

private void EventsOnRunStarted() {

IngameOverlay?.SetGoldenState(true);
}

private void EventsOnRunEnded(bool died, bool won) {
ChokeRateStat.ChokeRateData = null; //Reset caching
IngameOverlay?.SetGoldenState(false);
}
private void Events_OnChangedRoom(string roomName, bool isPreviousRoom) {
if (DoRecordPath) {
Expand Down
2 changes: 1 addition & 1 deletion ConsistencyTracker.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<CelesteIsCore Condition="Exists('$(CelestePrefix)\Celeste.dll')">true</CelesteIsCore>
<CelestePrefix Condition="$(CelesteIsCore)">$(CelestePrefix)\legacyRef</CelestePrefix>

<CelesteType Condition="'$(CelesteType)' == '' And Exists('$(CelesteGamePath)\BuildIsXNA.txt')">XNA</CelesteType>
<CelesteType Condition="'$(CelesteType)' == '' And Exists('$(CelestePrefix)\BuildIsXNA.txt')">XNA</CelesteType>
<CelesteType Condition="'$(CelesteType)' == ''">FNA</CelesteType>
<XNAPath Condition="'$(XNAPath)' == ''">$(WINDIR)\Microsoft.NET\assembly\GAC_32\{0}\v4.0_4.0.0.0__842cf8be1de50553\{0}.dll</XNAPath>
</PropertyGroup>
Expand Down
78 changes: 77 additions & 1 deletion ConsistencyTrackerSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,7 @@
public void CreatePathGoldenTierSettingsEntry(TextMenu menu, bool inGame) {
TextMenuExt.SubMenu subMenu = new TextMenuExt.SubMenu("Path Golden Tier Settings", false);
menu.Add(subMenu);
TextMenu.Item menuItem;

Check warning on line 483 in ConsistencyTrackerSettings.cs

View workflow job for this annotation

GitHub Actions / build

The variable 'menuItem' is declared but never used

Check warning on line 483 in ConsistencyTrackerSettings.cs

View workflow job for this annotation

GitHub Actions / build

The variable 'menuItem' is declared but never used

if (!inGame) {
subMenu.Add(new TextMenu.SubHeader(Dialog.Clean("MODOPTION_CCT_PATH_MANAGEMENT_NOT_IN_GAME_HINT"), false));
Expand Down Expand Up @@ -1189,6 +1189,12 @@
[SettingIgnore]
public bool IngameOverlayText1Enabled { get; set; } = true;

[SettingIgnore]
public bool IngameOverlayText1Outline { get; set; } = true;

[SettingIgnore]
public Color IngameOverlayText1Color { get; set; } = Color.White;

[SettingIgnore]
public StatTextPosition IngameOverlayText1Position { get; set; } = StatTextPosition.TopLeft;

Expand All @@ -1215,6 +1221,12 @@
[SettingIgnore]
public bool IngameOverlayText2Enabled { get; set; } = true;

[SettingIgnore]
public bool IngameOverlayText2Outline { get; set; } = true;

[SettingIgnore]
public Color IngameOverlayText2Color { get; set; } = Color.White;

[SettingIgnore]
public StatTextPosition IngameOverlayText2Position { get; set; } = StatTextPosition.TopRight;

Expand All @@ -1241,6 +1253,12 @@
[SettingIgnore]
public bool IngameOverlayText3Enabled { get; set; } = false;

[SettingIgnore]
public bool IngameOverlayText3Outline { get; set; } = true;

[SettingIgnore]
public Color IngameOverlayText3Color { get; set; } = Color.White;

[SettingIgnore]
public StatTextPosition IngameOverlayText3Position { get; set; } = StatTextPosition.BottomLeft;

Expand All @@ -1267,6 +1285,12 @@
[SettingIgnore]
public bool IngameOverlayText4Enabled { get; set; } = false;

[SettingIgnore]
public bool IngameOverlayText4Outline { get; set; } = true;

[SettingIgnore]
public Color IngameOverlayText4Color { get; set; } = Color.White;

[SettingIgnore]
public StatTextPosition IngameOverlayText4Position { get; set; } = StatTextPosition.BottomRight;

Expand Down Expand Up @@ -1448,7 +1472,7 @@
string descAvailableFormats = $"{Dialog.Clean("MODOPTION_CCT_IN_GAME_OVERLAY_SETTINGS_TEXT_OVERLAY_FORMAT_EDIT_HINT")} 'Celeste/ConsistencyTracker/{StatManager.BaseFolder}/{StatManager.FormatFileName}'";
string descAvailableFormatsGolden = $"{Dialog.Clean("MODOPTION_CCT_IN_GAME_OVERLAY_SETTINGS_TEXT_OVERLAY_FORMAT_GOLDEN_HINT_1")} '{noneFormat}' {Dialog.Clean("MODOPTION_CCT_IN_GAME_OVERLAY_SETTINGS_TEXT_OVERLAY_FORMAT_GOLDEN_HINT_2")}";
string descHideWithGolden = Dialog.Clean("MODOPTION_CCT_IN_GAME_OVERLAY_SETTINGS_TEXT_OVERLAY_FORMAT_GOLDEN_HINT_0");

string descColorOption = Dialog.Clean("MODOPTION_CCT_COLOR_OPTION_DESCRIPTION");

bool hasStats = Mod.CurrentChapterStats != null;
bool holdingGolden = Mod.CurrentChapterStats.ModState.PlayerIsHoldingGolden;
Expand Down Expand Up @@ -1490,6 +1514,19 @@
}
});
subMenu.AddDescription(menu, menuItem, descHideWithGolden);
subMenu.Add(new TextMenu.OnOff(Dialog.Clean("MODOPTION_CCT_IN_GAME_OVERLAY_SETTINGS_TEXT_OVERLAY_TEXT_OUTLINE"), IngameOverlayText1Outline) {
OnValueChange = v => {
IngameOverlayText1Outline = v;
Mod.IngameOverlay.SetTextOutline(1, v);
}
});
subMenu.Add(menuItem = new ColorOption(Dialog.Clean("MODOPTION_CCT_IN_GAME_OVERLAY_SETTINGS_TEXT_OVERLAY_TEXT_COLOR"), IngameOverlayText1Color) {
OnValueChange = v => {
IngameOverlayText1Color = v;
Mod.IngameOverlay.SetTextColor(1, v);
}
});
subMenu.AddDescription(menu, menuItem, descColorOption);
subMenu.Add(menuItem = new TextMenuExt.EnumerableSlider<int>(Dialog.Clean("MODOPTION_CCT_IN_GAME_OVERLAY_SETTINGS_TEXT_OVERLAY_TEXT_SIZE"), PercentageSlider(5, 5, 500), IngameOverlayText1Size) {
OnValueChange = (value) => {
IngameOverlayText1Size = value;
Expand Down Expand Up @@ -1547,6 +1584,19 @@
}
});
subMenu.AddDescription(menu, menuItem, descHideWithGolden);
subMenu.Add(new TextMenu.OnOff(Dialog.Clean("MODOPTION_CCT_IN_GAME_OVERLAY_SETTINGS_TEXT_OVERLAY_TEXT_OUTLINE"), IngameOverlayText2Outline) {
OnValueChange = v => {
IngameOverlayText2Outline = v;
Mod.IngameOverlay.SetTextOutline(2, v);
}
});
subMenu.Add(menuItem = new ColorOption(Dialog.Clean("MODOPTION_CCT_IN_GAME_OVERLAY_SETTINGS_TEXT_OVERLAY_TEXT_COLOR"), IngameOverlayText2Color) {
OnValueChange = v => {
IngameOverlayText2Color = v;
Mod.IngameOverlay.SetTextColor(2, v);
}
});
subMenu.AddDescription(menu, menuItem, descColorOption);
subMenu.Add(menuItem = new TextMenuExt.EnumerableSlider<int>(Dialog.Clean("MODOPTION_CCT_IN_GAME_OVERLAY_SETTINGS_TEXT_OVERLAY_TEXT_SIZE"), PercentageSlider(5, 5, 500), IngameOverlayText2Size) {
OnValueChange = (value) => {
IngameOverlayText2Size = value;
Expand Down Expand Up @@ -1603,6 +1653,19 @@
}
});
subMenu.AddDescription(menu, menuItem, descHideWithGolden);
subMenu.Add(new TextMenu.OnOff(Dialog.Clean("MODOPTION_CCT_IN_GAME_OVERLAY_SETTINGS_TEXT_OVERLAY_TEXT_OUTLINE"), IngameOverlayText3Outline) {
OnValueChange = v => {
IngameOverlayText3Outline = v;
Mod.IngameOverlay.SetTextOutline(3, v);
}
});
subMenu.Add(menuItem = new ColorOption(Dialog.Clean("MODOPTION_CCT_IN_GAME_OVERLAY_SETTINGS_TEXT_OVERLAY_TEXT_COLOR"), IngameOverlayText3Color) {
OnValueChange = v => {
IngameOverlayText3Color = v;
Mod.IngameOverlay.SetTextColor(3, v);
}
});
subMenu.AddDescription(menu, menuItem, descColorOption);
subMenu.Add(menuItem = new TextMenuExt.EnumerableSlider<int>(Dialog.Clean("MODOPTION_CCT_IN_GAME_OVERLAY_SETTINGS_TEXT_OVERLAY_TEXT_SIZE"), PercentageSlider(5, 5, 500), IngameOverlayText3Size) {
OnValueChange = (value) => {
IngameOverlayText3Size = value;
Expand Down Expand Up @@ -1660,6 +1723,19 @@
}
});
subMenu.AddDescription(menu, menuItem, descHideWithGolden);
subMenu.Add(new TextMenu.OnOff(Dialog.Clean("MODOPTION_CCT_IN_GAME_OVERLAY_SETTINGS_TEXT_OVERLAY_TEXT_OUTLINE"), IngameOverlayText4Outline) {
OnValueChange = v => {
IngameOverlayText4Outline = v;
Mod.IngameOverlay.SetTextOutline(4, v);
}
});
subMenu.Add(menuItem = new ColorOption(Dialog.Clean("MODOPTION_CCT_IN_GAME_OVERLAY_SETTINGS_TEXT_OVERLAY_TEXT_COLOR"), IngameOverlayText4Color) {
OnValueChange = v => {
IngameOverlayText4Color = v;
Mod.IngameOverlay.SetTextColor(4, v);
}
});
subMenu.AddDescription(menu, menuItem, descColorOption);
subMenu.Add(menuItem = new TextMenuExt.EnumerableSlider<int>(Dialog.Clean("MODOPTION_CCT_IN_GAME_OVERLAY_SETTINGS_TEXT_OVERLAY_TEXT_SIZE"), PercentageSlider(5, 5, 500), IngameOverlayText4Size) {
OnValueChange = (value) => {
IngameOverlayText4Size = value;
Expand Down
6 changes: 6 additions & 0 deletions Dialog/English.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@

MODOPTION_CCT_NAME= Consistency Tracker

MODOPTION_CCT_COLOR_OPTION_DESCRIPTION= Press this button to import a color from clipboard!

MODOPTION_CCT_PAUSE_DEATH_TRACKING= Pause Death Tracking

MODOPTION_CCT_TRACKING_SETTINGS_ON= On
Expand Down Expand Up @@ -298,6 +300,8 @@ MODOPTION_CCT_IN_GAME_OVERLAY_SETTINGS_TEXT_OVERLAY_TEXT_SELECTED_FORMAT= Select
MODOPTION_CCT_IN_GAME_OVERLAY_SETTINGS_TEXT_OVERLAY_TEXT_SELECTED_FORMAT_GOLDEN= Selected Format With Golden
MODOPTION_CCT_IN_GAME_OVERLAY_SETTINGS_TEXT_OVERLAY_TEXT_HIDE_IN_GOLDEN= Hide In Golden Run
MODOPTION_CCT_IN_GAME_OVERLAY_SETTINGS_TEXT_OVERLAY_TEXT_SIZE= Size
MODOPTION_CCT_IN_GAME_OVERLAY_SETTINGS_TEXT_OVERLAY_TEXT_OUTLINE= Text Outline
MODOPTION_CCT_IN_GAME_OVERLAY_SETTINGS_TEXT_OVERLAY_TEXT_COLOR= Text Color
MODOPTION_CCT_IN_GAME_OVERLAY_SETTINGS_TEXT_OVERLAY_TEXT_OFFSET_X= Offset X
MODOPTION_CCT_IN_GAME_OVERLAY_SETTINGS_TEXT_OVERLAY_TEXT_OFFSET_Y= Offset Y

Expand Down Expand Up @@ -643,6 +647,8 @@ MODOPTION_CCT_FAQ_OTHER_LOVE_A=

MODOPTION_CCT_FAQ_OTHER_HATE_Q= I hate this mod >:(



# +--------------------+
# | Stats Format |
# +--------------------+
Expand Down
68 changes: 68 additions & 0 deletions Entities/Menu/ColorOption.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
using System;
using Celeste;
using Celeste.Mod;
using Celeste.Mod.ConsistencyTracker.Utility;
using System.Globalization;
using Microsoft.Xna.Framework;
using Monocle;
using static Celeste.TextMenu;

public class ColorOption : Item {

private static string ConfirmSfx = "event:/ui/main/button_select";

private string _Label;

public string Label { get; set; }

public Color Color { get; set; }

public Action<Color> OnValueChange { get; set; }

public ColorOption(string label, Color color) {
Selectable = true;
Color = color;
_Label = label;

Label = GetLabel(_Label, Color);
}

public override float LeftWidth() {
return ActiveFont.Measure(Label).X;
}

public override float Height() {
return ActiveFont.LineHeight;
}

public override void ConfirmPressed() {
Audio.Play(ConfirmSfx);

if (Util.TryParseColor(TextInput.GetClipboardText(), out Color color)) {
Color = color;
Label = GetLabel(_Label, Color);
OnValueChange?.Invoke(color);
}
}

public override void Render(Vector2 position, bool highlighted) {
// Stolen from Celeste.TextMenu
float alpha = Container.Alpha;
Color color = Disabled ? Color.DarkSlateGray : ((highlighted ? Container.HighlightColor : Color.White) * alpha);
Color strokeColor = Color.Black * (alpha * alpha * alpha);
ActiveFont.DrawOutline(Label, position, Vector2.UnitY / 2f, Vector2.One, color, 2f, strokeColor);

// Render the color box
Vector2 measure = ActiveFont.Measure(Label);
Vector2 colorBoxPosition = DrawHelper.MoveCopy(position, measure.X + 10f, -20f);
Draw.Rect(colorBoxPosition, 40f, 40f, Color);
Draw.HollowRect(colorBoxPosition, 40f, 40f, Color.White);
}

private static string GetLabel(string label, Color color) {
return $"{label}: {Util.ColorToHex(color)}";
}



}
Loading
Loading