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

Better inlining in Printing.wurst #108

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
28 changes: 18 additions & 10 deletions wurst/util/Printing.wurst
@@ -1,6 +1,7 @@
package Printing
import NoWurst
import Player
import MagicFunctions

@configurable public var DEBUG_LEVEL = Loglevel.INFO
@configurable public var DEBUG_MSG_DURATION = 45.
Expand Down Expand Up @@ -30,23 +31,28 @@ public function Loglevel.getTag() returns string
public class Log
/** Prints a trace logmessage */
static function trace(string msg)
printLog(localPlayer, Loglevel.TRACE, msg)
if (DEBUG_LEVEL castTo int) <= (Loglevel.TRACE castTo int)
printLogInternal(localPlayer, compiletime(Loglevel.TRACE.getTag()), msg)

/** Prints a debug logmessage */
static function debug(string msg)
printLog(localPlayer, Loglevel.DEBUG, msg)
if (DEBUG_LEVEL castTo int) <= (Loglevel.DEBUG castTo int)
printLogInternal(localPlayer, compiletime(Loglevel.DEBUG.getTag()), msg)

/** Prints a info logmessage*/
static function info(string msg)
printLog(localPlayer, Loglevel.INFO, msg)
if (DEBUG_LEVEL castTo int) <= (Loglevel.INFO castTo int)
printLogInternal(localPlayer, compiletime(Loglevel.INFO.getTag()), msg)

/** Prints a warning logmessage */
static function warn(string msg)
printLog(localPlayer, Loglevel.WARNING, msg)
if (DEBUG_LEVEL castTo int) <= (Loglevel.WARNING castTo int)
printLogInternal(localPlayer, compiletime(Loglevel.WARNING.getTag()), msg)

/** Prints a warning logmessage */
static function error(string msg)
printLog(localPlayer, Loglevel.ERROR, msg)
if (DEBUG_LEVEL castTo int) <= (Loglevel.ERROR castTo int)
printLogInternal(localPlayer, compiletime(Loglevel.ERROR.getTag()), msg)

static function setLevel(Loglevel lvl)
DEBUG_LEVEL = lvl
Expand Down Expand Up @@ -78,9 +84,12 @@ public function printLog(Loglevel loglvl, string msg)

public function printLog(player showTo, Loglevel loglvl, string msg)
if (DEBUG_LEVEL castTo int) <= (loglvl castTo int)
let compositeMsg = loglvl.getTag() + " - " + msg
DisplayTimedTextToPlayer(showTo, 0., 0., DEBUG_MSG_DURATION, compositeMsg)

printLogInternal(showTo, loglvl.getTag(), msg)

function printLogInternal(player showTo, string prefix, string msg)
let compositeMsg = prefix + " - " + msg
DisplayTimedTextToPlayer(showTo, 0., 0., DEBUG_MSG_DURATION, compositeMsg)

/** Prints a simple message that is shown for the given duration */
public function printTimed(string msg, real duration)
DisplayTimedTextToPlayer(localPlayer, 0., 0., duration, msg)
Expand All @@ -93,5 +102,4 @@ public function printTimedToPlayer(string msg, real duration, player p)
public function printTimedToPlayerClear(string msg, real duration, player p)
if localPlayer == p
ClearTextMessages()
DisplayTimedTextToPlayer(p, 0., 0., duration, msg)

DisplayTimedTextToPlayer(p, 0., 0., duration, msg)