Skip to content

Commit

Permalink
Merge pull request #68 from SlaynAndKorpil/fancierConsoleOutput
Browse files Browse the repository at this point in the history
made ConsoleOutput message system fancier
  • Loading branch information
SlaynAndKorpil authored Apr 18, 2020
2 parents 2bb31d0 + d544eb0 commit 3c7ed9f
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 22 deletions.
1 change: 1 addition & 0 deletions .idea/runConfigurations/Main.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion framework/src/framework/BoardMeta.scala
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import scala.language.postfixOps

/**
* Meta information and methods that are needed for a game.
*
*
* @usecase this gets mixed-in in [[framework.ChessBoard ChessBoard]]
* @author Felix Lehner
* @version alpha 0.2
Expand Down
2 changes: 1 addition & 1 deletion framework/src/framework/ChessBoard.scala
Original file line number Diff line number Diff line change
Expand Up @@ -933,7 +933,7 @@ object ChessBoard {
None
} catch {
case _: Throwable =>
Error error "failed to save the data!"
Error write "failed to save the data!"
Some(FileOperationError.FileNotFoundError(fileName))
}
}
Expand Down
8 changes: 1 addition & 7 deletions framework/src/framework/ConsoleDebugger.scala
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
package framework

/**
* [Description]
*
* @author Felix Lehner
* @version
*/
trait ConsoleDebugger extends ConsoleOutput {
override val typeDescription: String = "DEBUG"
def debug (message: String): Unit = println(formatMessage(message))
override val output: String => Unit = println
}
8 changes: 1 addition & 7 deletions framework/src/framework/ConsoleError.scala
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
package framework

/**
* [Description]
*
* @author Felix Lehner
* @version
*/
trait ConsoleError extends ConsoleOutput {
override val typeDescription: String = "ERROR"
def error (message: String): Unit = System.err.println(formatMessage(message))
override val output: String => Unit = System.err.println
}
12 changes: 8 additions & 4 deletions framework/src/framework/ConsoleOutput.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,18 @@ package framework
* An interface to the console for more uniform and coincide messages
*/
trait ConsoleOutput {
/**The type of message*/
/** The type of message */
val typeDescription: String

/**Describes the physical origin (i.e. the package)*/
/** Describes the physical origin (i.e. the package) */
val name: String

/** Describes the output (i.e. System.out.println) */
val output: String => Unit

/**
* Formats [[name]], [[typeDescription]] and the message to a uniform console output.
* Formats [[name]], [[typeDescription]] and the message to a uniform console output
* and then puts it in the [[output]].
*/
def formatMessage (message: String): String = s"$typeDescription $name >> $message"
def write(message: String): Unit = output(s"$typeDescription $name >> $message")
}
2 changes: 1 addition & 1 deletion graphics/src/graphics/CMenuBar.scala
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ trait CMenuBar {
val loaded = gameFrame.load(path)
loaded match {
case Some(errorMessage) =>
Error error errorMessage.description
Error write errorMessage.description
case _ =>
}
case _ =>
Expand Down
2 changes: 1 addition & 1 deletion graphics/src/graphics/Icons.scala
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ object Icons {
private def splitImg (image: BufferedImage): Seq[BufferedImage] =
for (i <- 0 until 6) yield image.getSubimage(i*image.getWidth/6, 0, image.getWidth/6, image.getHeight)

// TODO unnecessary mem alloc, sequences should be deleted after loading => put in method scope
// TODO unnecessary mem alloc, sequences should be deleted after loading => write in method scope
private val blackImages: Seq[BufferedImage] =
splitImg(ImageIO.read(getClass.getResourceAsStream(assetsDir + (dirs \ "BlackPieces" \@ "dir"))))
private val whiteImages: Seq[BufferedImage] =
Expand Down

0 comments on commit 3c7ed9f

Please sign in to comment.