Implement "Log" Component
See original GitHub issueSummary
A “Log” refers to a GUI component, often used in roguelike games to display information to the user about a variety of events.
A dedicated “Log” Component would be a useful way to easily provide this functionality in a GUI.
Example
The Orc’s attack hits! The Orc attacks you! You missed… You attacked the Orc!
Work Around
The current work around is to use a TextImage:
- Create TextImage for your preferred size
- Draw a box around it via BoxBuilder
- Update TextImage with each of your log messages via TextImage’s putText() method
For Example
public class Playground {
public static void main(String[] args) {
final Terminal terminal = TerminalBuilder.newBuilder()
.font(CP437TilesetResource.REX_PAINT_20X20.toFont())
.initialTerminalSize(Size.of(10, 5))
.build();
final TextImage img = TextImageBuilder.newBuilder()
.size(Size.of(10, 5))
.build(); // we create a new image to draw onto the terminal
img.setForegroundColor(ANSITextColor.WHITE);
img.setBackgroundColor(ANSITextColor.BLUE); // `putText` will use these
BoxBuilder.newBuilder()
.boxType(BoxType.DOUBLE)
.size(Size.of(10, 5))
.style(StyleSetBuilder.newBuilder()
.foregroundColor(ANSITextColor.CYAN)
.backgroundColor(ANSITextColor.BLUE)
.build())
.build()
.drawOnto(img, Position.DEFAULT_POSITION); // we create a box and draw it onto the image
final List<String> logElements = new ArrayList<>();
logElements.add("foo");
logElements.add("bar"); // our log entries
for(int i = 0; i < logElements.size(); i++) {
img.putText(logElements.get(i), Position.OFFSET_1x1.withRelativeRow(i)); // we have to offset because of the box
}
terminal.draw(img, Position.DEFAULT_POSITION); // you have to draw each time the image changes
terminal.flush();
}
}
Issue Analytics
- State:
- Created 6 years ago
- Reactions:2
- Comments:7 (6 by maintainers)
Top Results From Across the Web
Log - Apache Camel
The Log component logs message exchanges to the underlying logging mechanism. Camel uses SLF4J which allows you to configure logging via, among others:....
Read more >Logging component
The Logging component can write to ASCII or Unicode files as well as database targets supported by OLE DB. The Logging component can...
Read more >Adding the log component to an Angular application
ngx-logger is a simple log component library and allows messages to be displayed on the console and sent to the server using an...
Read more >Logger in Java | Java Logging Basics with Log4j and util
The Java logging components help the developer to create logs, pass the logs to the respective destination and maintain an proper format.
Read more >Getting Started with Logging in React - Meticulous
We all start with writing a bunch of console.log statements in our work-in-progress React components. But then, you find yourself tracking ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Hi All! Just saw the post on /r/roguelikedev and am so excited to see this control in Zircon! I know I’m preaching to the choir here but, great work- on everything!
Thanks, you can now use it!