Geyser/Window Layout Question

imany
Posts: 12
Joined: Mon May 16, 2011 7:32 pm

Geyser/Window Layout Question

Post by imany »

Is Geyser or any of the other window layout-oriented stuff able to create a margin above the input area so that you can fit a label at the bottom of the screen without it covering pertinent information?

User avatar
Akaya
Posts: 414
Joined: Thu Apr 19, 2012 1:36 am

Re: Geyser/Window Layout Question

Post by Akaya »

Yes. Use setBorderBottom() to give the margin above the command line. Then place your label appropriately.

imany
Posts: 12
Joined: Mon May 16, 2011 7:32 pm

Re: Geyser/Window Layout Question

Post by imany »

Okay, another question. I'm having trouble with this:

Code: Select all

local prompt_container = Geyser.HBox:new({
  name = "prompt_container",
  x = "0", y = "-30",
  width = "100%", height = "30",
})

local HP1 = Geyser.Label:new({
  name = "HP1",
  width = "30",
  h_policy = Geyser.Fixed,
  },
  prompt_container)
HP1:echo("HP: ", "green", "c")
HP1:setStyleSheet([[
  font-size: 20px;
  background-color: black;
]])
Where my label is respecting background-color but not font-size. Any idea what the problem is?

phasma
Posts: 191
Joined: Sat Aug 03, 2013 7:00 pm
Discord: phasma#4694

Re: Geyser/Window Layout Question

Post by phasma »

Use the setFontSize() method available with Geyser or simply opt for a full Qt stylesheet.

imany
Posts: 12
Joined: Mon May 16, 2011 7:32 pm

Re: Geyser/Window Layout Question

Post by imany »

I may be misunderstanding what you mean, but I tried setFontSize() on the container in question and it didn't seem to be inherited by the labels. It also didn't seem to be able to applied directly to the labels themselves. I'm also not quite sure what you mean by a full Qt stylesheet? Is there an alternative method to tacking a stylesheet onto a label?

User avatar
Akaya
Posts: 414
Joined: Thu Apr 19, 2012 1:36 am

Re: Geyser/Window Layout Question

Post by Akaya »

setFontSize is used for miniconsoles. Not labels.

I personally style my label fonts within my echo's using tags like so:
Code: [show] | [select all] lua
mylabel:echo([[<span style="font-size:20px">My label text</span>]])

imany
Posts: 12
Joined: Mon May 16, 2011 7:32 pm

Re: Geyser/Window Layout Question

Post by imany »

Thanks, that's really helpful!

One more question: Can you use a variable for a color in the <span> tag?

User avatar
Akaya
Posts: 414
Joined: Thu Apr 19, 2012 1:36 am

Re: Geyser/Window Layout Question

Post by Akaya »

Yes.

imany
Posts: 12
Joined: Mon May 16, 2011 7:32 pm

Re: Geyser/Window Layout Question

Post by imany »

How do you get a variable into a color tag?

Code: Select all

  HP:echo([[<span style="color:#]]..HPcolor..[[;font-size: 11pt">]]..currentHP..[[<span><span style="color:#FFFFFF;font-size: 11pt">/]]..maxHP..[[</span><span style="color:#]]..HPcolor..[[;font-size: 11pt"> ]]..percHP..[[%<span>]])
My problem here is that the " " seem to be overriding the [[ ]], so HPcolor isn't being recognized as a variable but rather being eaten by the whole span tag. How do I fix this?

User avatar
Akaya
Posts: 414
Joined: Thu Apr 19, 2012 1:36 am

Re: Geyser/Window Layout Question

Post by Akaya »

You're actually doing it correctly and it should work as is. The color highlighting isn't the greatest in this situation but I tested your snippet and it worked great.

Here's my own snippet in which your echo was successful...
Code: [show] | [select all] lua
HP = Geyser.Label:new({
  name = "HP",
  x = 0,
  y = 0,
  width = 500,
  height = 200,
})

local HPcolor = "FFFF00"
local currentHP = 100
local maxHP = 100
local percHP = 100

HP:echo([[<span style="color:#]]..HPcolor..[[;font-size: 11pt">]]..currentHP..[[<span><span style="color:#FFFFFF;font-size: 11pt">/]]..maxHP..[[</span><span style="color:#]]..HPcolor..[[;font-size: 11pt"> ]]..percHP..[[%<span>]])
I'd make sure that your doing this on a label and that your variables all have values.

Post Reply