Page 2 of 2

Re: Setting Word Wrap for MiniConsoles in Geyser

Posted: Tue Apr 30, 2013 9:52 am
by kevutian
That'd certainly explain why I have never experienced this issue despite having used Geyser extensively for a long time.

Re: Setting Word Wrap for MiniConsoles in Geyser

Posted: Tue Apr 30, 2013 1:20 pm
by Jor'Mox
If you look at my initial example, the two consoles are, in fact, being placed in different containers, and yet the problem still occurs. Also, a quick check shows that while the consoles are reporting a changed font size, the containers are not. (Also, for the sceptical, hiding the containers individually properly hides just the consoles that are supposed to be in them.) Interestingly, when I call the display function for a console, it doesn't even list a font size, and as font size is clearly relevant to them, that seems strange. Possibly the value is getting stored in the generic "MiniConsole" that all the others are based off of, since the new versions don't have a value of their own.

Re: Setting Word Wrap for MiniConsoles in Geyser

Posted: Wed May 01, 2013 3:33 pm
by Jor'Mox
I tracked down the problem, and posted it in the Development forum. Hopefully it will be enough to allow someone to resolve the issue. I'm thinking that replacing the "self.parent:setFontSize(size)" with "self.parent.setFontSize(self,size)" or perhaps "self.fontSize = size" should work.

If I changed that in the GeyserMiniConsole.lua file that is stored locally on my computer, it will change how it behaves for me, won't it?

Re: Setting Word Wrap for MiniConsoles in Geyser

Posted: Wed May 01, 2013 8:32 pm
by Vadi
It would, yes.

I'm still not sure why does it do this however, whenever that is the intended design or not. We won't really know as the person who designed it is inactive now.

self.parent:setFontSize(size) is the same as self.parent.setFontSize(self,size) by the way, the : notation is a shortcut for adding self at as the first argument.

Re: Setting Word Wrap for MiniConsoles in Geyser

Posted: Wed May 01, 2013 8:40 pm
by Jor'Mox
If I understand how this works correctly, I am going to have to disagree with you.

self:setFontSize(size) -- > self.setFontSize(self,size)

However, when using the function in self.parent:setFontSize(size), the "self" that will be passed is "self.parent", not "self". Hence the problem. Or, to be clear in what I'm thinking, this:

self.parent:setFontSize(size) -- > self.parent.setFontSize(self.parent,size)

Re: Setting Word Wrap for MiniConsoles in Geyser

Posted: Wed May 01, 2013 9:09 pm
by Vadi
Well, either way - the question is why is the the parent's font size is getting set. That doesn't seem necessary at all, yet there must have been a reason it was put in place... that is the issue with fixing this. Either we ignore and do what seems logical right now, breaking some purpose it was intended to do... hm.
Code: [show] | [select all] lua
function Geyser.MiniConsole:setFontSize(size)
   print("(Geyser.MiniConsole:setFontSize) self: "..tostring(self))
   print("(Geyser.MiniConsole:setFontSize) self.parent: "..tostring(self.parent))
   self.parent:setFontSize(size)
   setMiniConsoleFontSize(self.name, size)
end

function Geyser.Container:setFontSize (fontSize)
   if type(fontSize) ~= "number" then
      error("fontSize must be a number")
      return
   end
   print("(Geyser.Container:setFontSize) self: "..tostring(self))
   self.fontSize = fontSize or self.fontSize
   self:set_constraints()
end
(Geyser.MiniConsole:setFontSize) self: table: 0xe673a90
(Geyser.MiniConsole:setFontSize) self.parent: table: 0x74ad4a0
(Geyser.Container:setFontSize) self: table: 0x74ad4a0
Yep, that is the case indeed. I'm thinking that to change this, replacing that line altogether with "self.fontSize = size" would be the proper measure to go ahead with, unless a reason for keeping the parent propagation can be found.

Re: Setting Word Wrap for MiniConsoles in Geyser

Posted: Wed May 01, 2013 9:17 pm
by Jor'Mox
I'm pretty sure I understand the reasoning, and it is as follows.

Geyser.MiniConsole doesn't have a "setFontSize" function, nor does "Geyser.Window". "Geyser.Container" DOES have a setFontSize function. So the intent was to do whatever is in the Geyser.Container.setFontSize function and, in addition, set the font size in the console. To do that, you need to call setFontSize higher up. The person coding it just made the faulty assumption that the "self" getting passed in the function call was the same self that was defined as the variable "self", but it wasn't. "self.parent" was doing the function calling, so they should have passed "self" explicitly, instead of using the shorthand notation and passing "self.parent" by mistake.

So, the correct replacement would be: self.parent.setFontSize(self, size) , that way any changes in the setFontSize function in the future are properly propagated down to miniconsoles.

Re: Setting Word Wrap for MiniConsoles in Geyser

Posted: Wed May 01, 2013 9:48 pm
by Vadi
Why doesn't Geyser.MiniConsole have a "setFontSize" function? It has it, they defined it to call upwards to the Container instead. setFontSize is similar to setBold and other wrappers, but none of those propatage it.

Re: Setting Word Wrap for MiniConsoles in Geyser

Posted: Wed May 01, 2013 10:00 pm
by Jor'Mox
Geyser.MiniConsole is an instance of the Geyser.Window class, which is an instance of the Geyser.Container class. The metatable for Geyser.MiniConsole is set so that any calls to Geyser.MiniConsole that aren't recognized are passed up to Geyser.Window, and from there to Geyser.Container if necessary. The reason for calling the higher level of setFontSize is to ensure that all objects have the same implementation of each function, with variation only as necessary for actually making the correct behavior occur, in this case actually setting the font size in the mini console being referenced.

If you look in Geyser.Label, there is no reference anywhere to setFontSize, and yet you can call it, and it works. The same sort of behavior should work for Geyser.MiniConsole. There is a bit of code in Geyser.Container.setFontSize, and there is no reason to duplicated it just because we also need to use that function for a mini console. It does error checking, sets the variable, and calls self:set_constraints(). We could all of those things, or just call it the correct way, and then any changes are automatically applied to the Geyser.Miniconsole version of setFontSize when they are made in Geyser.Container.

Also, I have tested it, and using self.parent.setFontSize(self, size) works perfectly and does not propagate the actual font size value upward as it did before. It simple sets it for the item that is calling the function, as you would expect. So why not use an implementation that is as close as possible to the original, so as to preserve whatever original reasoning behind the design?