LoTROInterface

LoTROInterface (https://www.lotrointerface.com/forums/index.php)
-   Lua Programming Help (L) (https://www.lotrointerface.com/forums/forumdisplay.php?f=50)
-   -   Any way to overload or replace turbine.ui methods with my own? (https://www.lotrointerface.com/forums/showthread.php?t=1062)

crazygonuts 09-20-2010 01:23 PM

Any way to overload or replace turbine.ui methods with my own?
 
I can't read any of the fonts in game because they're too small, so I'm trying to write a small little mod to increase their size. The simplest way I can see to do that would be if I could replace SetFont in TextBox and just have it pick a larger font than the one passed in. It seemed like a longshot but I figured I might as well ask and see if there was a way I could replace that method or if those are completely inaccessible. Thanks for any replys.

derk 09-20-2010 05:15 PM

I had to use this little trick myself to do something like you want, however this example is from memory and I haven't checked if it works. You will have to test yourself and check wat kind of arguments go into the functions but you should get the general idea:

Code:

function SomeClass:init()
        -- hook the SetFont and SetText functions
        self.prevLabelSetFont = Turbine.UI.Label.SetFont;
        Turbine.UI.Label.SetFont = function ( --args? )
                self.prevLabelSetFont( Turbine.UI.Lotro.Font.TrajanPro28 )
        end
        self.prevLabelSetText = Turbine.UI.Label.SetText;
        Turbine.UI.Label.SetText = function ( --args? )
                self.prevLabelSetFont(  Turbine.UI.Lotro.Font.TrajanPro28 )
                self.prevLabelSetText( --any args)
        end
       
        -- hook any other functions that don't inherit from Label:SetText and Label:SetFont ( if there are any )
        --  like: Turbine.UI.Window.SetText

        -- above only sets on the SetFont and SetText functions, still need to set existing labels       
        -- set a flag on all Turbine.UI.Label:
        Turbine.UI.Label._IsLabel = true;
       
        -- recusively check the _G table for all loaded tables
        self:enum_tables( _G, { } );

end

function SomeClass:enum_tables( t, seen )
        seen[t] = true;
        for k,v in pairs(t) do
                if ( type(v) == "table" and not seen[v] ) then
                        -- here check our flag
                        if ( v._IsLabel ) then
                                v:SetFont( Turbine.UI.Lotro.Font.TrajanPro28 )               
                        else
                                self:enum_tables( v, seen );
                        end
                end
        end
end

Also I don't know if everything inherits from Turbine.UI.Label and in some class making/overloading constructions it doesn't work (like turbine's TheOneBag example)

Digital_Utopia 09-20-2010 06:40 PM

Quote:

Originally Posted by crazygonuts (Post 4764)
I can't read any of the fonts in game because they're too small, so I'm trying to write a small little mod to increase their size. The simplest way I can see to do that would be if I could replace SetFont in TextBox and just have it pick a larger font than the one passed in. It seemed like a longshot but I figured I might as well ask and see if there was a way I could replace that method or if those are completely inaccessible. Thanks for any replys.

Here's the problem. Unlike some other games, LotRO's interface isn't written in Lua, so the Lua API cannot do anything with existing LotRO UI elements. You can add as many different windows/panels etc, and duplicate existing LotRO UI elements; but even the native Turbine.UI.Lotro elements are the same thing - replications of the existing UI elements. The easiest way to see this is just by creating a Turbine.UI.Lotro.Window. You'll notice that the title bar does not behave the same way as actual Lotro Windows do. It will continue to expand, regardless of how big the window is - even though the title bar of "real" windows only get to about 255px wide.

So short answer? Nothing you can do in Lua, or will ever be able to, will ever change a single existing UI element in the game. The best we'll ever be able to do is to override the display of such elements, and use the necessary data to display that element how we would like. The implementation of Lua in LotRO is more or less its own separate entity, getting only information the game itself is set up explicitly to give.

derk 09-21-2010 06:42 AM

Ah right, I overlooked the fact that he wanted to change the existing ingame menus :)

crazygonuts 09-21-2010 11:16 PM

Yeah, that's what I had figured but I had to ask just in case. Thanks for confirming it for me though.

Quote:

Originally Posted by Digital_Utopia (Post 4770)
Here's the problem. Unlike some other games, LotRO's interface isn't written in Lua, so the Lua API cannot do anything with existing LotRO UI elements. You can add as many different windows/panels etc, and duplicate existing LotRO UI elements; but even the native Turbine.UI.Lotro elements are the same thing - replications of the existing UI elements. The easiest way to see this is just by creating a Turbine.UI.Lotro.Window. You'll notice that the title bar does not behave the same way as actual Lotro Windows do. It will continue to expand, regardless of how big the window is - even though the title bar of "real" windows only get to about 255px wide.

So short answer? Nothing you can do in Lua, or will ever be able to, will ever change a single existing UI element in the game. The best we'll ever be able to do is to override the display of such elements, and use the necessary data to display that element how we would like. The implementation of Lua in LotRO is more or less its own separate entity, getting only information the game itself is set up explicitly to give.


daimon 09-22-2010 12:14 AM

The simplest way might be trying to lower your gaming resolution, in case if you're using some huge 2560·XXXX or something... :)

katarn0 09-22-2010 02:12 PM

I need to get in game, but I remember there being a way to change the ui size and I thought font size was included in that. It may only be the font size of the chat window though, so please don't quote me on that until I get home tonight and check it out.

Digital_Utopia 09-22-2010 09:07 PM

Quote:

Originally Posted by katarn0 (Post 4801)
I need to get in game, but I remember there being a way to change the ui size and I thought font size was included in that. It may only be the font size of the chat window though, so please don't quote me on that until I get home tonight and check it out.

There is, but the resizing is done by "zooming", giving you about the same result as if you took a 15px x 15px image, and blew it up 200%. It would be bigger, sure - but it would also be exceptionally blurry.


All times are GMT -5. The time now is 07:44 AM.

vBulletin® - Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
© MMOUI