Skip to content

Commit

Permalink
feat(Client): add custom Logger for redscript
Browse files Browse the repository at this point in the history
Use Codeware's stracktrace to log context of execution of the function. Easier to read, easy to copy/paste, log will tell which module > class > function is executed, along with a custom optional message.
  • Loading branch information
poirierlouis committed Nov 25, 2024
1 parent f0636c6 commit 06be799
Show file tree
Hide file tree
Showing 18 changed files with 130 additions and 93 deletions.
10 changes: 5 additions & 5 deletions code/assets/redscript/Ink/ChatController.reds
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ public class ChatController extends inkHUDGameController {
private let m_lastMessageData: ref<ChatMessageData>;
protected cb func OnInitialize() -> Bool {
LogChannel(n"DEBUG", s"[ChatController] OnInitialize");
CMPLog(s"");
this.m_player = this.GetPlayerControlledObject() as PlayerPuppet;
if !IsDefined(this.m_player) {
LogChannel(n"DEBUG", s"[ChatController] NO PLAYER");
CMPLog(s"NO PLAYER");
}
this.m_uiSystem = GameInstance.GetUISystem(this.m_player.GetGame());
this.m_messageController = inkWidgetRef.GetController(this.m_messagesRef) as ListController;
Expand All @@ -39,7 +39,7 @@ public class ChatController extends inkHUDGameController {
}
protected cb func OnUninitialize() -> Bool {
LogChannel(n"DEBUG", s"[ChatController] OnUninitialize");
CMPLog(s"");
this.m_player.UnregisterInputListener(this, n"UIEnterChatMessage");
}
Expand All @@ -57,7 +57,7 @@ public class ChatController extends inkHUDGameController {
}
protected cb func OnChatMessageUIEvent(evt: ref<ChatMessageUIEvent>) -> Bool {
LogChannel(n"DEBUG", s"[ChatController] OnChatMessageUIEvent");
CMPLog(s"");
let messageData = new ChatMessageData();
messageData.m_author = evt.author;
messageData.m_message = evt.message;
Expand Down Expand Up @@ -125,7 +125,7 @@ public class ChatController extends inkHUDGameController {
private final func SendChat() -> Void {
let textEntered: String = this.m_input.GetText();
if NotEquals(textEntered, "") {
LogChannel(n"DEBUG", s"[ChatController] SendChat \"\(textEntered)\"");
CMPLog(s"\"\(textEntered)\"");
GameInstance.GetNetworkWorldSystem().GetChatSystem().Send(textEntered);
};
Expand Down
8 changes: 4 additions & 4 deletions code/assets/redscript/Ink/ChatMessageController.reds
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public class ChatMessageController extends ListItemController {
public let m_messageLabel: wref<inkText>;
protected cb func OnInitialize() -> Bool {
LogChannel(n"DEBUG", s"[ChatMessageController] OnInitialize");
CMPLog(s"");
// super.OnInitialize();
this.m_authorLabel = inkTextRef.Get(this.m_authorWidget) as inkText;
this.m_messageLabel = inkTextRef.Get(this.m_messageWidget) as inkText;
Expand All @@ -23,7 +23,7 @@ public class ChatMessageController extends ListItemController {
}
protected cb func OnDataChanged(value: ref<IScriptable>) -> Bool {
LogChannel(n"DEBUG", s"[ChatMessageController] OnDataChanged");
CMPLog(s"");
// super.OnDataChanged(value);
this.m_data = value as ChatMessageData;
if this.m_data.m_needsAuthorLabel {
Expand All @@ -42,7 +42,7 @@ public class ChatMessageController extends ListItemController {
}
public final func Refresh(value: ref<IScriptable>) -> Void {
// LogChannel(n"DEBUG", s"[ChatMessageController] Refresh");
// CMPLog(s"");
this.m_data = value as ChatMessageData;
if this.m_data.m_needsAuthorLabel {
this.m_authorLabel.SetVisible(true);
Expand All @@ -60,7 +60,7 @@ public class ChatMessageController extends ListItemController {
}
protected cb func OnAddedToList(target: wref<ListItemController>) -> Bool {
// LogChannel(n"DEBUG", s"[ChatMessageController] OnAddedToList");
// CMPLog(s"");
let m_animListText: ref<inkAnimDef>;
let m_animTextInterp: ref<inkAnimTextOffset>;
let stageOneTime: Float;
Expand Down
8 changes: 4 additions & 4 deletions code/assets/redscript/Ink/DeliveryListController.reds
Original file line number Diff line number Diff line change
Expand Up @@ -112,16 +112,16 @@ public class DeliveryListController extends inkLogicController {
this.m_headerText.SetText("Select job");
this.m_scrollArea = this.GetWidget(n"container/scrollarea") as inkScrollArea;
if !IsDefined(this.m_scrollArea) {
LogChannel(n"DEBUG", s"[DeliveryListController] COULD NOT FIND SCROLLAREA");
CMPLog(s"COULD NOT FIND SCROLLAREA");
}
this.m_listController = this.GetWidget(n"container/scrollarea/list").GetController() as ListController;
if !IsDefined(this.m_listController) {
LogChannel(n"DEBUG", s"[DeliveryListController] COULD NOT FIND LIST CONTROLLER");
CMPLog(s"COULD NOT FIND LIST CONTROLLER");
}
this.m_scrollArea.RegisterToCallback(n"OnScrollChanged", this, n"OnScrollChanged");
this.m_scrollController = this.m_scrollArea.GetControllerByType(n"inkScrollController") as inkScrollController;
if !IsDefined(this.m_scrollController) {
LogChannel(n"DEBUG", s"[DeliveryListController] COULD NOT FIND SCROLL CONTROLLER");
CMPLog(s"COULD NOT FIND SCROLL CONTROLLER");
}
// this.m_leftMargin = new inkMargin(35.00, 10.00, 0.00, 0.00);
// this.m_rightMargin = new inkMargin(1400.00, 10.00, 0.00, 0.00);
Expand Down Expand Up @@ -162,7 +162,7 @@ public class DeliveryListController extends inkLogicController {
}
protected cb func OnItemSelected(previous: ref<inkVirtualCompoundItemController>, next: ref<inkVirtualCompoundItemController>) -> Bool {
LogChannel(n"DEBUG", s"[DeliveryListController] OnItemSelected");
CMPLog(s"");
// let selectionChangeEvent: ref<ContactSelectionChangedEvent>;
// let contactData: ref<ContactData> = FromVariant<ref<IScriptable>>(next.GetData()) as ContactData;
// InkImageUtils.RequestAvatarOrUnknown(this, this.m_avatarImage, contactData.avatarID);
Expand Down
8 changes: 4 additions & 4 deletions code/assets/redscript/Ink/DeliveryListItemController.reds
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public class DeliveryListItemController extends ListItemController {
public let m_itemIcon: wref<inkImage>;
protected cb func OnInitialize() -> Bool {
LogChannel(n"DEBUG", s"[DeliveryListItemController] OnInitialize");
CMPLog(s"");
// super.OnInitialize();
this.RegisterToCallback(n"OnSelected", this, n"OnSelected");
this.RegisterToCallback(n"OnDeselected", this, n"OnDeselected");
Expand All @@ -21,7 +21,7 @@ public class DeliveryListItemController extends ListItemController {
this.m_itemDescription = this.GetWidget(n"textContainer/NamePreviewContainer/preview") as inkText;
this.m_itemIcon = this.GetWidget(n"icon") as inkImage;
if !IsDefined(this.m_itemName) {
LogChannel(n"DEBUG", s"[DeliveryListItemController] COULD NOT FIND LABEL");
CMPLog(s"COULD NOT FIND LABEL");
}
// this.RegisterToCallback(n"OnAddedToList", this, n"OnAddedToList");
}
Expand All @@ -31,7 +31,7 @@ public class DeliveryListItemController extends ListItemController {
}
protected cb func OnSelected(itemController: wref<inkVirtualCompoundItemController>, discreteNav: Bool) -> Bool {
LogChannel(n"DEBUG", s"[DeliveryListItemController] OnSelected");
CMPLog(s"");
// let animOptions: inkAnimOptions;
// if IsDefined(this.m_animProxySelection) {
// this.m_animProxySelection.GotoStartAndStop(true);
Expand All @@ -53,7 +53,7 @@ public class DeliveryListItemController extends ListItemController {
}
protected cb func OnDataChanged(value: ref<IScriptable>) -> Bool {
LogChannel(n"DEBUG", s"[DeliveryListItemController] OnDataChanged");
CMPLog(s"");
// super.OnDataChanged(value);
this.m_data = value as JobEntry;
// let itemid = ItemID.FromTDBID(this.m_data.item);
Expand Down
4 changes: 2 additions & 2 deletions code/assets/redscript/Ink/EmoteSelector.reds
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public class EmoteSelector extends inkLogicController {
this.m_listController = this.GetWidget(n"container").GetController() as ListController;
this.m_indicator = this.GetWidget(n"indicator");
if !IsDefined(this.m_listController) {
LogChannel(n"DEBUG", s"[EmoteSelector] COULD NOT FIND LIST CONTROLLER");
CMPLog(s"COULD NOT FIND LIST CONTROLLER");
}
// let setMenuModeEvent: ref<inkMenuLayer_SetMenuModeEvent>;
Expand Down Expand Up @@ -198,7 +198,7 @@ public class EmoteSelector extends inkLogicController {
}
protected cb func OnItemSelected(previous: ref<inkVirtualCompoundItemController>, next: ref<inkVirtualCompoundItemController>) -> Bool {
LogChannel(n"DEBUG", s"[EmoteSelector] OnItemSelected");
CMPLog(s"");
// let selectionChangeEvent: ref<ContactSelectionChangedEvent>;
// let contactData: ref<ContactData> = FromVariant<ref<IScriptable>>(next.GetData()) as ContactData;
// InkImageUtils.RequestAvatarOrUnknown(this, this.m_avatarImage, contactData.avatarID);
Expand Down
8 changes: 4 additions & 4 deletions code/assets/redscript/Ink/EmoteSelectorItem.reds
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public class EmoteSelectorItem extends ListItemController {
public let m_serverDescription: wref<inkText>;
protected cb func OnInitialize() -> Bool {
// LogChannel(n"DEBUG", s"[EmoteSelectorItem] OnInitialize");
// CMPLog(s"");
// super.OnInitialize();
this.RegisterToCallback(n"OnSelected", this, n"OnSelected");
this.RegisterToCallback(n"OnDeselected", this, n"OnDeselected");
Expand All @@ -22,7 +22,7 @@ public class EmoteSelectorItem extends ListItemController {
this.m_container = this.GetWidget(n"container") as inkWidget;
// this.m_serverDescription = this.GetWidget(n"textContainer/NamePreviewContainer/preview") as inkText;
if !IsDefined(this.m_name) {
LogChannel(n"DEBUG", s"[EmoteSelectorItem] COULD NOT FIND LABEL");
CMPLog(s"COULD NOT FIND LABEL");
}
this.RegisterToCallback(n"OnAddedToList", this, n"OnAddedToList");
}
Expand All @@ -47,7 +47,7 @@ public class EmoteSelectorItem extends ListItemController {
protected cb func OnSelected(itemController: wref<inkVirtualCompoundItemController>, discreteNav: Bool) -> Bool {
this.UnregisterFromCallback(n"OnHoverOver", this, n"OnHoverOver");
this.UnregisterFromCallback(n"OnHoverOut", this, n"OnHoverOut");
// LogChannel(n"DEBUG", s"[EmoteSelectorItem] OnSelected");
// CMPLog(s"");
// let animOptions: inkAnimOptions;
// if IsDefined(this.m_animProxySelection) {
// this.m_animProxySelection.GotoStartAndStop(true);
Expand Down Expand Up @@ -86,7 +86,7 @@ public class EmoteSelectorItem extends ListItemController {
}
protected cb func OnDataChanged(value: ref<IScriptable>) -> Bool {
// LogChannel(n"DEBUG", s"[EmoteSelectorItem] OnDataChanged");
// CMPLog(s"");
// super.OnDataChanged(value);
this.m_data = value as EmoteData;
this.m_name.SetText(this.m_data.m_name);
Expand Down
8 changes: 4 additions & 4 deletions code/assets/redscript/Ink/JobListController.reds
Original file line number Diff line number Diff line change
Expand Up @@ -108,16 +108,16 @@ public class JobListController extends inkLogicController {
this.m_headerText.SetText("Select job type");
this.m_scrollArea = this.GetWidget(n"container/scrollarea") as inkScrollArea;
if !IsDefined(this.m_scrollArea) {
LogChannel(n"DEBUG", s"[JobListController] COULD NOT FIND SCROLLAREA");
CMPLog(s"COULD NOT FIND SCROLLAREA");
}
this.m_listController = this.GetWidget(n"container/scrollarea/list").GetController() as ListController;
if !IsDefined(this.m_listController) {
LogChannel(n"DEBUG", s"[JobListController] COULD NOT FIND LIST CONTROLLER");
CMPLog(s"COULD NOT FIND LIST CONTROLLER");
}
this.m_scrollArea.RegisterToCallback(n"OnScrollChanged", this, n"OnScrollChanged");
this.m_scrollController = this.m_scrollArea.GetControllerByType(n"inkScrollController") as inkScrollController;
if !IsDefined(this.m_scrollController) {
LogChannel(n"DEBUG", s"[JobListController] COULD NOT FIND SCROLL CONTROLLER");
CMPLog(s"COULD NOT FIND SCROLL CONTROLLER");
}
// this.m_leftMargin = new inkMargin(35.00, 10.00, 0.00, 0.00);
// this.m_rightMargin = new inkMargin(1400.00, 10.00, 0.00, 0.00);
Expand Down Expand Up @@ -155,7 +155,7 @@ public class JobListController extends inkLogicController {
}
protected cb func OnItemSelected(previous: ref<inkVirtualCompoundItemController>, next: ref<inkVirtualCompoundItemController>) -> Bool {
LogChannel(n"DEBUG", s"[JobListController] OnItemSelected");
CMPLog(s"");
// let selectionChangeEvent: ref<ContactSelectionChangedEvent>;
// let contactData: ref<ContactData> = FromVariant<ref<IScriptable>>(next.GetData()) as ContactData;
// InkImageUtils.RequestAvatarOrUnknown(this, this.m_avatarImage, contactData.avatarID);
Expand Down
8 changes: 4 additions & 4 deletions code/assets/redscript/Ink/JobListItemController.reds
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ public class JobListItemController extends ListItemController {
public let m_shopDescription: wref<inkText>;
protected cb func OnInitialize() -> Bool {
LogChannel(n"DEBUG", s"[JobListItemController] OnInitialize");
CMPLog(s"");
// super.OnInitialize();
this.RegisterToCallback(n"OnSelected", this, n"OnSelected");
this.RegisterToCallback(n"OnDeselected", this, n"OnDeselected");
this.m_root = this.GetRootWidget();
this.m_shopName = this.GetWidget(n"textContainer/NamePreviewContainer/NameContainer/contactLabel") as inkText;
this.m_shopDescription = this.GetWidget(n"textContainer/NamePreviewContainer/preview") as inkText;
if !IsDefined(this.m_shopName) {
LogChannel(n"DEBUG", s"[JobListItemController] COULD NOT FIND LABEL");
CMPLog(s"COULD NOT FIND LABEL");
}
// this.RegisterToCallback(n"OnAddedToList", this, n"OnAddedToList");
}
Expand All @@ -29,7 +29,7 @@ public class JobListItemController extends ListItemController {
}
protected cb func OnSelected(itemController: wref<inkVirtualCompoundItemController>, discreteNav: Bool) -> Bool {
LogChannel(n"DEBUG", s"[JobListItemController] OnSelected");
CMPLog(s"");
// let animOptions: inkAnimOptions;
// if IsDefined(this.m_animProxySelection) {
// this.m_animProxySelection.GotoStartAndStop(true);
Expand All @@ -51,7 +51,7 @@ public class JobListItemController extends ListItemController {
}
protected cb func OnDataChanged(value: ref<IScriptable>) -> Bool {
LogChannel(n"DEBUG", s"[JobListItemController] OnDataChanged");
CMPLog(s"");
// super.OnDataChanged(value);
this.m_data = value as JobType;
this.m_shopName.SetText(s"\(this.m_data.m_name)");
Expand Down
Loading

0 comments on commit 06be799

Please sign in to comment.