Author Topic: BearLibTerminal: a pseudo-terminal window library for roguelike  (Read 67762 times)

Nekoninja

  • Acolyte
  • *
  • Posts: 33
    • View Profile
Re: BearLibTerminal: a pseudo-terminal window library for roguelike
« Reply #255 on: February 14, 2018, 11:52:36 PM »
I was able to get the BearLibTerminal to work with Larazus. The BearLibTerminal.pas file need one small additional. Add this "{$mode objfpc}" in before {$H+} on line 22. After this, it works beautiful. Will test it with Free Pascal and Delphi 10.2 (32 bit only since I got it free). For some reason I cannot explain why, perhaps someone can, I had to use the 64 bits BearLibTerminal.dll.

Will keep it post of my research results.
Bow to me, your evil programmer or I will destroy the internet with my 'delete' button!

Zireael

  • Protector of the @
  • *****
  • Posts: 604
    • View Profile
Re: BearLibTerminal: a pseudo-terminal window library for roguelike
« Reply #256 on: February 17, 2018, 04:09:11 PM »
Quote from: The Saber Cat
Is there a way to use fonts of two different pixel sizes as ttf imports, without converting one of them in .png? If yes, how codepoints are shared between them?
Well it is indeed hard to guess what exactly do you have trouble with, but probably you're trying to put both fonts in a single codespace, i. e. make the them all have different code points similar to font + tiles. BearLibTerminal support multiple codespaces for this purpose exactly, to have two (or more) separate fonts, with each one using the same (yet their own) code points for the same characters/tiles:

Code: [Select]
terminal.set('font: one.ttf, size=8x16')
terminal.set('another font: two.ttf, size=10x20')

Would it be possible to load the same font twice (the default one shipped with BLT), but with one of them having the codepoints overriden by tiles and the other not? Or does it have to be two different .ttf files?

Where 'another' is an arbitrary name to your liking. And then there are two ways to use it:

Code: [Select]
# Inline string formatting
terminal.puts(2, 1, 'Hello, [font=another]World')

# Global state
terminal.puts(2, 2, 'Hello, ')
terminal.font('another')
terminal.puts(2+7, 2, 'World')

BrodyDuderson

  • Acolyte
  • *
  • Posts: 3
    • View Profile
Re: BearLibTerminal: a pseudo-terminal window library for roguelike
« Reply #257 on: October 01, 2018, 11:43:19 PM »
What is the best way to start printing where the last print left off? I've been using the measure function but things aren't lining up properly. I think I'm just not using it properly. Here's an example of how I've been trying to use it.

Code: [Select]
#define TEXT_WIDTH 60
#define TEXT_HEIGHT 30
#define TEXT_X ((SCREEN_WIDTH / 2) - (TEXT_WIDTH / 2))
#define TEXT_Y 2

char *awesomeText= "I don't know anything about anything. In fact, I can't even say for sure if what I just said is true; and truth be told, I'm not even sure if I can or cannot say anything for sure. I think - not know - that you should, perhaps, ignore me, maybe.";

terminal_print_ext(TEXT_X, TEXT_Y, TEXT_WIDTH, 0, 0, awesomeText);

dimensions_t mark = terminal_measure_ext(TEXT_WIDTH, TEXT_HEIGHT, awesomeText);

terminal_print_ext(mark.width, mark.height, 0, 0, 0, "[color=red]@");

When I do this, the aweomseText is wrapped correctly but the red @ is printed on the second - at "I think - not know -", rather than the end of the string.

BrodyDuderson

  • Acolyte
  • *
  • Posts: 3
    • View Profile
Re: BearLibTerminal: a pseudo-terminal window library for roguelike
« Reply #258 on: October 02, 2018, 11:27:41 AM »
A somewhat related question. My "game" has color themes that the user can choose from. So for example, I do things like
 
Code: [Select]
terminal_bkcolor(activeTheme->bkColor);
Say I wanted to change the color of one of the words in awesomeText to a custom color (activeTheme->crazyColor). What would be the best way to do it?

Cfyz

  • Bishop
  • ***
  • Posts: 194
    • View Profile
    • Email
Re: BearLibTerminal: a pseudo-terminal window library for roguelike
« Reply #259 on: October 06, 2018, 10:24:17 PM »
Contrary to how it may look, I am not dead, yet =|.

Quote from: BrodyDuderson
What is the best way to start printing where the last print left off?
If you want to print phrase by phrase (actually more like paragraph by paragraph), then it is easy to do with measuring. Just remember that dimensions_t returned from print/measure is a size, not coordinates, so you have to add it to the last printing position. Note that print function also returns dimensions_t, you do not need a separate measure call if you've already printed the text.

However, if you want to literally continue printing, i. e. from the place of the last output symbol, there is no exact way. But I think there is no need. You can just concatenate the strings and print them in one go.

Quote from: BrodyDuderson
Say I wanted to change the color of one of the words in awesomeText to a custom color (activeTheme->crazyColor). What would be the best way to do it?
You can use some formatting tags in the string, e. g.
Code: [Select]
terminal_printf(x, y, "Some text with a [color=%d]word[/color] in another color", crazyColor); // choose %d or %s depending on the way you store the color (color_t or char*)

See terminal_print reference.

BrodyDuderson

  • Acolyte
  • *
  • Posts: 3
    • View Profile
Re: BearLibTerminal: a pseudo-terminal window library for roguelike
« Reply #260 on: October 07, 2018, 01:22:38 PM »
Just remember that dimensions_t returned from print/measure is a size, not coordinates, so you have to add it to the last printing position.
What is the proper way to do this for wrapped text? Everything I've tried has been off so far and I can't figure out why.

It's true that I might not need to do this anymore, now that you made me aware of string formatting + concatenate. It would be nice to know, just in case.

Thanks for the help, and thanks for bearlibterminal. It's great.