Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(Client): improve chat and widget tree #33

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
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
Binary file modified code/assets/Archives/packed/archive/pc/mod/CyberpunkMP.archive
Binary file not shown.
Binary file not shown.
14 changes: 8 additions & 6 deletions code/assets/redscript/Ink/ChatController.reds
Original file line number Diff line number Diff line change
Expand Up @@ -121,14 +121,16 @@ public class ChatController extends inkHUDGameController {
this.m_chatInputOpen = show;
this.UpdateInputHints();
}

private final func SendChat() -> Void {
let textEntered: String = this.m_input.GetText();
if NotEquals(textEntered, "") {
CMPLog(s"\"\(textEntered)\"");
let text: String = this.m_input.GetText();

GameInstance.GetNetworkWorldSystem().GetChatSystem().Send(textEntered);
};
text = UTF8StrTrim(text);
if UTF8StrEmpty(text) {
return;
}
CMPLog(s"\"\(text)\"");
GameInstance.GetNetworkWorldSystem().GetChatSystem().Send(text);
}

private func Scroll(up: Bool) {
Expand Down
38 changes: 19 additions & 19 deletions code/assets/redscript/Logger.reds
Original file line number Diff line number Diff line change
@@ -1,37 +1,37 @@
module CyberpunkMP

public static func CMPLog(value: script_ref<String>) -> Void {
FTLog(CMPTraceLog(value));
FTLog(CMPTraceLog(value));
}

public static func CMPWarn(value: script_ref<String>) -> Void {
FTLogWarning(CMPTraceLog(value));
FTLogWarning(CMPTraceLog(value));
}

public static func CMPError(value: script_ref<String>) -> Void {
FTLogError(CMPTraceLog(value));
FTLogError(CMPTraceLog(value));
}

private static func CMPTraceLog(value: script_ref<String>) -> String {
let entries = GetStackTrace(1, false);
let entry = entries[0];
let function = NameToString(entry.function);
let tokens = StrSplit(function, ";");
let entries = GetStackTrace(1, false);
let entry = entries[0];
let function = NameToString(entry.function);
let tokens = StrSplit(function, ";");

function = tokens[0];
let trace: String;
function = tokens[0];
let trace: String;

if IsDefined(entry.object) {
let className = NameToString(entry.class);
if IsDefined(entry.object) {
let className = NameToString(entry.class);

if StrFindFirst(className, "CyberpunkMP.") == 0 {
className = StrRight(className, StrLen(className) - StrLen("CyberpunkMP."));
if StrFindFirst(className, "CyberpunkMP.") == 0 {
className = StrRight(className, StrLen(className) - StrLen("CyberpunkMP."));
} else {
className = s"*.\(className)";
}
trace = s"[\(className)][\(function)]";
} else {
className = s"*.\(className)";
trace = s"[\(function)]";
}
trace = s"[\(className)][\(function)]";
} else {
trace = s"[\(function)]";
}
return s"[CMP]\(trace) \(value)";
return s"[CMP]\(trace) \(value)";
}
37 changes: 37 additions & 0 deletions code/assets/redscript/StringHelper.reds
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
module CyberpunkMP

public static func UTF8StrEmpty(value: String) -> Bool {
return UTF8StrLen(value) == 0;
}

public static func UTF8StrNotEmpty(value: String) -> Bool {
return UTF8StrLen(value) != 0;
}

public static func UTF8StrTrim(value: String) -> String {
return UTF8StrTrimRight(UTF8StrTrimLeft(value));
}

public static func UTF8StrTrimLeft(value: String) -> String {
let index = StrFindFirst(value, " ");
let length = UTF8StrLen(value);

while (index == 0) {
value = UTF8StrRight(value, length - 1);
length -= 1;
index = StrFindFirst(value, " ");
}
return value;
}

public static func UTF8StrTrimRight(value: String) -> String {
let index = StrFindLast(value, " ");
let length = UTF8StrLen(value);

while (index == length - 1) {
value = UTF8StrLeft(value, length - 1);
length -= 1;
index = StrFindLast(value, " ");
}
return value;
}