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

align CBA debug/warning/error messages to ACE versions #466

Merged
merged 1 commit into from
Aug 19, 2016
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
1 change: 1 addition & 0 deletions addons/diagnostic/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@ class CfgPatches {
#include "CfgEventHandlers.hpp"

#include "CfgDisplay3DEN.hpp"
#include "gui.hpp"
54 changes: 35 additions & 19 deletions addons/diagnostic/fnc_error.sqf
Original file line number Diff line number Diff line change
@@ -1,43 +1,59 @@
/* ----------------------------------------------------------------------------
Function: CBA_fnc_error
Internal Function: CBA_fnc_error

Description:
Logs an error message to the RPT log.

Should not be used directly, but rather via macros (<ERROR()>,
<ERROR_WITH_TITLE()> or the <Assertions>).
Should not be used directly, but rather via macros (<ERROR_WITH_TITLE()>
or the <Assertions>).

Parameters:
_file - Name of file [String]
_lineNum - Line of file (starting at 0) [Number]
_title - Title of the error [String]
_message - Error message [String, which may contain \n]
_prefix - Addon name (optional, defaut: "cba") <STRING>
_component - Component name (optional, default: "diagnostic") <STRING>
_title - Title of the error <STRING>
_message - Error message (use "\n" for newline) <STRING>
_file - Name of file <STRING>
_lineNum - Line of file <NUMEBR>

Returns:
nil

Author:
Spooner
Spooner, commy2
---------------------------------------------------------------------------- */

#include "script_component.hpp"

SCRIPT(error);

// -----------------------------------------------------------------------------
params ["_file","_lineNum","_title","_message"];

private ["_time", "_lines"];
params [
["_prefix", 'PREFIX', [""]],
["_component", 'COMPONENT'],
["_title", "", [""]],
["_message", "", [""]],
["_file", "", [""]],
["_lineNum", -1, [0]]
];

// TODO: popup window with error message in it.
_time = [diag_tickTime, "H:MM:SS.mmm"] call CBA_fnc_formatElapsedTime;
_prefix = toUpper _prefix;

diag_log text format ["%1 (%2) [%3:%4] -ERROR- %5", _time, time, _file, _lineNum + 1, _title];
// RPT log
diag_log text format ["[%1] (%2) ERROR: %3 File: %4 Line: %5", _prefix, _component, _title, _file, _lineNum];

_lines = [_message, "\n"] call CBA_fnc_split;
private _lines = [_message, "\n"] call CBA_fnc_split;

{
diag_log text format [" %1", _x];
} forEach _lines;

nil;
// error pop up
QGVAR(Error) cutRsc [QGVAR(Error), "PLAIN"];
private _control = uiNamespace getVariable QGVAR(Error);

private _compose = [lineBreak, parseText format ["<t align='center' size='1.65'>[%1] (%2) %3<\t>", _prefix, _component, _title], lineBreak];

{
_compose append [lineBreak, format [" %1", _x]];
} forEach _lines;

_control ctrlSetStructuredText composeText _compose;

nil
60 changes: 20 additions & 40 deletions addons/diagnostic/fnc_log.sqf
Original file line number Diff line number Diff line change
@@ -1,65 +1,45 @@
/* ----------------------------------------------------------------------------
Function: CBA_fnc_log
Internal Function: CBA_fnc_log

Description:
Logs a message to the RPT log.

Should not be used directly, but rather via macro (<LOG()>).

This function is unaffected by the debug level (<DEBUG_MODE_x>).

Parameters:
_file - File error occurred in [String]
_lineNum - Line number error occurred on (starting from 0) [Number]
_message - Message [String]
_message - Message <STRING>

Returns:
nil

Author:
Spooner and Rommel
Spooner, Rommel, commy2
-----------------------------------------------------------------------------*/
#define DEBUG_MODE_NORMAL
#include "script_component.hpp"

SCRIPT(log);

// ----------------------------------------------------------------------------
params [["_message", "", [""]]];

if (isNil QGVAR(logArray)) then {
GVAR(logArray) = [];
GVAR(logScript) = scriptNull;
};

#ifndef DEBUG_SYNCHRONOUS
if (isNil "CBA_LOG_ARRAY") then { CBA_LOG_ARRAY = [] };
private ["_msg"];
_msg = [_this select 0, _this select 1, _this select 2, diag_frameNo, diag_tickTime, time]; // Save it here because we want to know when it was happening, not when it is outputted
CBA_LOG_ARRAY pushBack _msg;
GVAR(logArray) pushBack text _message;

if (isNil "CBA_LOG_VAR") then
{
CBA_LOG_VAR = true;
SLX_XEH_STR spawn
{
_fnc_log =
{
params ["_file","_lineNum","_message","_frameNo","_tickTime","_gameTime"];
// TODO: Add log message to trace log
diag_log [_frameNo,
_tickTime, _gameTime, //[_tickTime, "H:MM:SS.mmm"] call CBA_fnc_formatElapsedTime, [_gameTime, "H:MM:SS.mmm"] call CBA_fnc_formatElapsedTime,
_file + ":"+str(_lineNum + 1), _message];
};
if (scriptDone GVAR(logScript)) then {
GVAR(logScript) = 0 spawn {
private "_selected";

_selected = "";
while {_selected = CBA_LOG_ARRAY deleteAt 0; !isNil "_selected"} do
{
_selected call _fnc_log;
};
CBA_LOG_VAR = nil;
while {
_selected = GVAR(logArray) deleteAt 0;
!isNil "_selected"
} do {
diag_log _selected;
};
};
#else
params ["_file","_lineNum","_message"];
// TODO: Add log message to trace log
diag_log [diag_frameNo,
diag_tickTime, time, // [diag_tickTime, "H:MM:SS.mmm"] call CBA_fnc_formatElapsedTime, [time, "H:MM:SS.mmm"] call CBA_fnc_formatElapsedTime
_file + ":"+str(_lineNum + 1), _message];
#endif
};

nil;
nil
26 changes: 26 additions & 0 deletions addons/diagnostic/gui.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@

class RscStructuredText;

class RscTitles {
class GVAR(Error) {
idd = -1;
duration = 5;
fadeIn = 0;
fadeOut = 0.5;
movingEnable = 0;

class Controls {
class GVAR(Error): RscStructuredText {
onLoad = QUOTE(uiNamespace setVariable [ARR_2('GVAR(Error)',_this select 0)]);
idc = -1;
font = "RobotoCondensedBold";
sizeEx = 0.55 * GUI_GRID_CENTER_H;
x = 0 * GUI_GRID_CENTER_W + GUI_GRID_CENTER_X;
y = 0 * GUI_GRID_CENTER_H + GUI_GRID_CENTER_Y;
w = 40 * GUI_GRID_CENTER_W;
h = 10 * GUI_GRID_CENTER_H;
colorBackground[] = {1,0.4,0,0.8};
};
};
};
};
1 change: 1 addition & 0 deletions addons/diagnostic/script_component.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@
#include "\x\cba\addons\main\script_macros.hpp"

#include "\a3\ui_f\hpp\defineDIKCodes.inc"
#include "\a3\ui_f\hpp\defineCommonGrids.inc"
Loading