Skip to content

Commit

Permalink
Merge pull request #86 from ChrisFeline/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
ChrisFeline authored Oct 16, 2024
2 parents 408d822 + fa433a7 commit ee33a78
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 118 deletions.
15 changes: 3 additions & 12 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,5 @@
# Latest Changelog

- New items added to the Objectives window. Have fun!
- Added new OSC configurable parameter 'ToN_DeathID'
- With this parameter, you can set a list of friends and you will receive OSC events when they die in a round.
- Added new OSC parameter 'ToN_Reborn'
- This parameter is set to true when you get reborn using Maxwell.
- Added event to WebSocket API: 'REBORN'
- 'Auto Copy On Join' only works when you join a ToN lobby now.
- Updated OSC docs for items to reveal more item IDs.
- Finally fixed Double Trouble colors for OSC.

- Added Italian localization (Thank you @TheIceDragonz)
- Updated Simplified Chinese localization (Thank you @Fallen-ice)
- Attempting to fix the False Positives with the two only FREE Anti Viruses. (Avast and AVG) again...
- Updated Simplified Chinese localization (Thank you @Fallen-ice)
- I always knew.
48 changes: 48 additions & 0 deletions Localization/Language/zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@
"SAVE.TAG_D": "🔌",
"SAVE.TAG_L": "💀",
"SAVE.TAG_X": "",
"SAVE.TAG_B": "😇",
"SAVE.TAG_C": "",

"SETTINGS.CHECK_UPDATE": "检查更新",
"SETTINGS.OPEN_DATA_BTN": "数据",
Expand Down Expand Up @@ -193,6 +195,17 @@
"SETTINGS.OSCDAMAGEDEVENT_EDIT": "(设置间隔时间)",
"SETTINGS.OSCDAMAGEDEVENT_EDIT.TT": "设置从发送伤害事件到将其重置为0的时间间隔。(以毫秒为单位)",
"SETTINGS.OSCDAMAGEDEVENT.TITLE": "设置伤害间隔",
"SETTINGS.OSCDEATHEVENT": "发送死亡事件",
"SETTINGS.OSCDEATHEVENT.TT": "向INT参数“ToN_DeathID”发送死亡事件。\n你可以使用此功能跟踪好友在游戏中的死亡时间。\n数字代表刚刚死亡的指定玩家名在列表中的位置,衰减时间结束后,该值将重置为0。",
"SETTINGS.OSCDEATHEVENT.TITLE": "设置玩家名称",
"SETTINGS.OSCDEATHEVENT_EDIT": "(编辑)",
"SETTINGS.OSCDEATHEVENT_EDIT.TT": "设置用于该参数的玩家名称列表。\n使用逗号(,)分隔不同的显示名称。",
"SETTINGS.OSCDEATHEVENT_DECAY": "(衰减)",
"SETTINGS.OSCDEATHEVENT_DECAY.TT": "设置将此值重置为0之前的等待时间(毫秒)。",
"SETTINGS.OSCDEATHEVENT_DECAY.TITLE": "设置衰减时间",
"SETTINGS.OSCDEATHEVENT_COOLDOWN": "(冷却)",
"SETTINGS.OSCDEATHEVENT_COOLDOWN.TT": "设置多名玩家连续死亡后,在设置该参数的ID值之前等待的时间(毫秒)。",
"SETTINGS.OSCDEATHEVENT_COOLDOWN.TITLE": "设置冷却时间",

"SETTINGS.GROUP.NOTIFICATIONS": "通知",

Expand Down Expand Up @@ -253,6 +266,7 @@
"OBJECTIVES.OMORI_PLUSH.TT": "在某物(Something)下存活。",
"OBJECTIVES.PARADISE_LOST": "失乐园(Paradise Lost)",
"OBJECTIVES.PARADISE_LOST.TT": "把使徒(Apostles)打得屁滚尿流。",

"OBJECTIVES.ITEM_SKIN_UNLOCKS": "物品皮肤解锁",
"OBJECTIVES.RED_MEDKIT": "红色医疗箱(Red Medkit)",
"OBJECTIVES.RED_MEDKIT.TT": "使用医疗箱(Medkit)在病毒(Virus)下存活。",
Expand Down Expand Up @@ -284,6 +298,38 @@
"OBJECTIVES.TORCH_OF_OBSESSION": "痴迷的火炬(Torch Of Obsession)",
"OBJECTIVES.TORCH_OF_OBSESSION.TT": "在寒夜(Cold Night)下存活。",

"OBJECTIVES.HAVE_PLUSH": "Have玩偶(Have Plush)",
"OBJECTIVES.HAVE_PLUSH.TT": "在观察者(The Observation)下存活。",
"OBJECTIVES.PORTABLE_SLOTS": "便携式老虎机(Portable Slots)",
"OBJECTIVES.PORTABLE_SLOTS.TT": "使用Have的神秘啤酒(Have's Mysterious Brew)在无束(Unbound)回合中存活。",
"OBJECTIVES.SOUL_VISITOR": "灵魂访客(Soul Visitor)",
"OBJECTIVES.SOUL_VISITOR.TT": "使用传送器(Teleporter)在无束(Unbound)回合中存活。",
"OBJECTIVES.DEFLECT_COIL": "偏折线圈(Deflect Coil)",
"OBJECTIVES.DEFLECT_COIL.TT": "使用再生线圈(Regen Coil)在变异(Alternate)回合中存活。",
"OBJECTIVES.ROOT_COIL": "根植线圈(Root Coil)",
"OBJECTIVES.ROOT_COIL.TT": "触摸草地。",
"OBJECTIVES.GHOST_BAT": "幽灵球棒(Ghost Bat)",
"OBJECTIVES.GHOST_BAT.TT": "使用金属球棒(Metal Bat)在幽灵(Ghost)回合中存活。",
"OBJECTIVES.BLOODY_CHARM": "血腥护身符(Bloody Charm)",
"OBJECTIVES.BLOODY_CHARM.TT": "使用银猫护身符(Silver Kat Charm)在血浴(Bloodbath)回合中存活。",
"OBJECTIVES.LUNA_CHARM": "月之护身符(Luna Charm)",
"OBJECTIVES.LUNA_CHARM.TT": "在奇美拉(Kimera)下存活。",
"OBJECTIVES.DESTROYER_COIL": "毁灭者线圈(Destroyer Coil)",
"OBJECTIVES.DESTROYER_COIL.TT": "使用螺旋线圈(Corkscrew Coil)在午夜(Midnight)回合中存活。",
"OBJECTIVES.BLOODY_REVOLVER": "血腥左轮手枪(Bloody Revolver)",
"OBJECTIVES.BLOODY_REVOLVER.TT": "使用古董左轮手枪(Antique Revolver)在血浴(Bloodbath)回合中存活。",
"OBJECTIVES.HAUNTED_HAMBURGER": "闹鬼汉堡(Haunted Hamburger)",
"OBJECTIVES.HAUNTED_HAMBURGER.TT": "使用汉堡(Hamburger)在幽灵(Ghost)回合中存活。",

"OBJECTIVES.CLAW_MACHINE_UNLOCKS": "抓娃娃机解锁",
"OBJECTIVES.NORA_PLUSH": "Nora玩偶(Nora Plush)",
"OBJECTIVES.NORA_PLUSH.TT": "需要:Beyond玩偶(Beyond Plush)。",
"OBJECTIVES.ROBLANDER_PLUSH": "奇袭者玩偶(Roblander Plush)",
"OBJECTIVES.ROBLANDER_PLUSH.TT": "需要:深灰色玩偶(Darkgrey Plush)。",
"OBJECTIVES.OBSERVATION_PLUSH": "观察者玩偶(Observation Plush)",
"OBJECTIVES.OBSERVATION_PLUSH.TT": "需要:Have玩偶(Have Plush)。",


"STATS.TITLE": "ToN统计跟踪",
"STATS.SHOW_LOBBY": "显示房间统计",
"STATS.SHOW_TOTAL": "显示全部统计",
Expand Down Expand Up @@ -343,6 +389,8 @@
"STATS.LABEL_MAPORIGIN.TT": "显示该地图的来源。",
"STATS.LABEL_ISALIVE": "是否存活",
"STATS.LABEL_ISALIVE.TT": "如果玩家在当前回合中还活着,则为 True。",
"STATS.LABEL_ISREBORN": "是否复活",
"STATS.LABEL_ISREBORN.TT": "如果玩家在当前回合中使用麦克斯韦(Maxwell)复活过,则为True。",
"STATS.LABEL_ISSTARTED": "是否开始",
"STATS.LABEL_ISSTARTED.TT": "如果一轮回合已开始并正在进行,则为True。",
"STATS.LABEL_INSTANCEURL": "房间链接",
Expand Down
111 changes: 5 additions & 106 deletions Updater.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,57 +9,6 @@ internal static class Updater {
[return: MarshalAs(UnmanagedType.Bool)]
static extern bool AllocConsole();

internal class UpdateProgressBar : IProgress<float> {
string start = "[";
string end = "]";
char fill = '#';
char back = '-';

int top = 0;
int left = 0;
int length = 0;

int full_len = 0;

string final = "Done.";

internal UpdateProgressBar (int length = 20) {
this.top = Console.CursorTop;
this.left = Console.CursorLeft;
this.length = length;
}

public void Start() {
Console.CursorVisible = false;
}

public void Report(float value) {
lock (start) {
Console.SetCursorPosition(left, top);


int c = (int)Math.Round(value * length);
Console.Write(start);
Console.Write(new string(fill, c).PadRight(length, back));
Console.Write(end);
Console.Write(' ');

float percent = value * 100;
Console.Write(percent.ToString("0.00").PadLeft(6, ' '));
Console.Write('%');

full_len = Console.CursorLeft - left;
}
}

public void Done() {
Report(1);
Console.SetCursorPosition(left, top);
Console.WriteLine((start + final + end).PadRight(full_len));
Console.CursorVisible = true;
}
}

const string POST_UPDATE_ARG = "--clean-update";
internal static void Start(GitHubRelease release, GitHubRelease.Asset asset) {
AllocConsole();
Expand All @@ -75,20 +24,15 @@ internal static void Start(GitHubRelease release, GitHubRelease.Asset asset) {

Console.Write($"Downloading '{asset.name}' . . . ");

UpdateProgressBar progress = new UpdateProgressBar();
progress.Start();
string downloadUrl = asset.browser_download_url;

using (HttpClient client = new HttpClient()) {
client.Timeout = TimeSpan.FromMinutes(5);

using (var file = new FileStream(TempFileLocation, FileMode.Create, FileAccess.Write, FileShare.None)) {
client.Download(downloadUrl, file, progress);
using (var s = client.GetStreamAsync(downloadUrl).Result) {
using (var fs = new FileStream(TempFileLocation, FileMode.CreateNew)) {
s.CopyTo(fs);
}
}
}

progress.Done();

// Move current executable
Logger.Info("Moving from: " + Program.ProgramLocation);
Logger.Info("Moving to: " + Program.ProgramLocationTemporary);
Expand Down Expand Up @@ -180,58 +124,13 @@ internal static void CheckPostUpdate(string[] args) {
}

Logger.Info("Post-update success.");
MessageBox.Show("Successfully updated to version " + Program.GetVersion(), Program.ProgramName, MessageBoxButtons.OK, MessageBoxIcon.Information);
// MessageBox.Show("Successfully updated to version " + Program.GetVersion(), Program.ProgramName, MessageBoxButtons.OK, MessageBoxIcon.Information);
} catch (Exception ex) {
Logger.Error("Failed to run post-update.");
Logger.Error(ex);

MessageBox.Show("Failed to run post-update.\nPlease report this issue on the GitHub page.\n\n" + ex, "Update Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}

#region Extensions
static void CopyTo(this Stream source, Stream destination, int bufferSize, IProgress<long>? progress = null) {
ArgumentNullException.ThrowIfNull(source);
ArgumentNullException.ThrowIfNull(destination);
ArgumentOutOfRangeException.ThrowIfNegative(bufferSize);

if (!source.CanRead)
throw new ArgumentException("Has to be readable", nameof(source));
if (!destination.CanWrite)
throw new ArgumentException("Has to be writable", nameof(destination));

var buffer = new byte[bufferSize];
long totalBytesRead = 0;
int bytesRead;
while ((bytesRead = source.Read(buffer, 0, buffer.Length)) != 0) {
destination.Write(buffer, 0, bytesRead);
totalBytesRead += bytesRead;
progress?.Report(totalBytesRead);
}
}

static void Download(this HttpClient client, string requestUri, Stream destination, IProgress<float>? progress = null) {
// Get the http headers first to examine the content length
using (var response = client.GetAsync(requestUri, HttpCompletionOption.ResponseHeadersRead).Result) {
var contentLength = response.Content.Headers.ContentLength;

using (var download = response.Content.ReadAsStream()) {

// Ignore progress reporting when no progress reporter was
// passed or when the content length is unknown
if (progress == null || !contentLength.HasValue) {
download.CopyTo(destination);
return;
}

// Convert absolute progress (bytes downloaded) into relative progress (0% - 100%)
var relativeProgress = new Progress<long>(totalBytes => progress.Report((float)totalBytes / contentLength.Value));
// Use extension method to report progress while downloading
download.CopyTo(destination, 81920, relativeProgress);
progress.Report(1);
}
}
}
#endregion
}
}

0 comments on commit ee33a78

Please sign in to comment.