[UT] How to Dynamicly load Packages...

  • Two Factor Authentication is now available on BeyondUnreal Forums. To configure it, visit your Profile and look for the "Two Step Verification" option on the left side. We can send codes via email (may be slower) or you can set up any TOTP Authenticator app on your phone (Authy, Google Authenticator, etc) to deliver codes. It is highly recommended that you configure this to keep your account safe.

Qjahe

New Member
Nov 15, 2003
36
0
0
(UTScript) How to Dynamicly load Packages...

Hi,

I started to learn unreal scripting. I thought I'd undertake a GUI for Administrating a UT Server within the game. I know it already exists, its just for my learning experience.

my Question is the following:

I duplicated the class UBrowserMainClientWindow and removed the unwanted parts. so I can have my own browser with my tabs.

Like the IRC class it will have "Sub Tabs" so I was thinking of putting the top tabs like Packages..

Tab=1 : About
Tab=2 : QAdmin
Tab=3 : QStats
Tab=4 : QVote

Each would be a sperate package. and the "interface" which is the UBrowserMainClientWindow clone would be a package itself. so if someone would just want to have the QAdmin within the "interface" (QPanel :D) they would just install that QPanel Package and QAdmin Package and leave the others alone.

So within UBrowserMainClientWindow I would have to check if the package Exists.. if it does Add the tab to access it, if it doesn't exist do no create the tab.

Another question that comes to mind is that some people maybe would want to add Tabs (thier Packages) to the QPanel... then how could I create dynamicly a Tab for them? Would they have to Sub Class the cloned UBrowserMainClientWindow and add to it?

Thanks for the help :)

Qjahe
P.S: This is for UT not UT2003, thanks.
 

Wormbo

Administrator
Staff member
Jun 4, 2001
5,913
36
48
Germany
www.koehler-homepage.de
UnrealScript is UnrealScript, whether you use it in Unreal, UT, or UT2003, so let's change that thread tag to [UT]... ;)

Now to the question:
You don't load packages directly. Instead you load objects from packages, even when the package itself or even the object might already be loaded you will use the DynamicLoadObject() function for this.
(Some people abbreviate this as "DLO", just in case you come across this term.)

When you dynamically load an object, you basically do it like this:
Code:
local Object O;

O = DynamicLoadObject("Package.ObjectName", class'ObjectClass');
In your example you will want to load a panel class, i.e. your code will probably look like this:
Code:
local class<UWindowBrowserPanel> MyPanelClass;

MyPanelClass = class<UWindowBrowserPanel>(DynamicLoadObject("QStats.QStatsPanel", class'Class'));
Notice how the ObjectClass says "class'Class'" now because you load a class you can use to create the actual panel object later. Also notice how the result of DynamicLoadObject() has to be typecasted because DynamicLoadObject() always returns an object of class "Object".

Now if the QStats package doesn't exist, DynamicLoadObject() will return None to indicate it could not load the object you requested. To handle this case you only need a simple "if" statement like this:
Code:
if ( MyPanelClass != None ) {
  // create the panel
}

If you need more information you can have a look at the Unreal Wiki, just search for DynamicLoadObject there. Other examples can be found in the UT code itself. Just use e.g. UnCodeX or any similar tool to do a full text search for DynamicLoadObject and you should find more than enough examples. ;)
 

Qjahe

New Member
Nov 15, 2003
36
0
0
trying to understand...

Code:
local class<UWindowBrowserPanel> MyPanelClass;
MyPanelClass = class<UWindowBrowserPanel>(DynamicLoadObject("QStats.QStatsPanel", class'Class'));
Thanks for the quick answer, i'll remember the [UT] tag thing :p
I'm a bit new to all this so bare with me plz.

I was thinking having the Panel (sub of UBrowser Class) and within that load packages if they exists. There is only 1 Panel with Many little tabs (which represent packages) we agree?

So are you saying that I should instead be Loading and creating the tab within Each Packages Class instead of the Panel class?

So in the QStats for example I would Sub class the Panel (Which create the Browser window and static Tabs) and then use that Panel Objet to add the proper tab?

Then... I dont need to check if(myClass != None).. ?
i'm sorry, i'm a bit slow...

Qjahe
 

Qjahe

New Member
Nov 15, 2003
36
0
0
i'm a OOP Noob...

I figured it out...

I was a bit unsure if I got the concept right but it works right now and packages that are not existing are not getting a tab or errors.

What I was wondering is that this is "hardcoded" in the QPanel class. so if I release it and give it to people and then 1 month later decide to add another Feature to it for example QAdmin (tab) they will all have to redownload the QPanel Packages because its not calling the new Package...

So my question is:
is there a way to make it Dynamicly load packages without me having to update the PanelClass each time I add a Package (Tab) to it? Like have the packages create their Own tab within the PanelClass instead of hardcoding them within the PanelClass like I did?

Thanks :)

Qjahe
 
Last edited:

Mr.Mitchell

New Member
Sep 5, 2001
140
0
0
the Netherlands
home.ict.nl
You could read the installed packages from an .ini file (use an array of strings). When a user downloads a new "plugin" he has to add it to the ini file and then it can be loaded. Or you could even have a Add button in the main application where the user has to type then name of the new package and then add it to the list of installed packages.
 

Qjahe

New Member
Nov 15, 2003
36
0
0
Interresting...

Mr.Mitchell said:
You could read the installed packages from an .ini file (use an array of strings).

I've been wondering about that... it would be the UnrealTournament.ini? or can my Package have its own .ini file?

Either way how can I list, for example, the Favorites listed in the UnrealTournament.ini or the Packages like you mentionned?

i've been told that UT doesn't have Dynamic Arrays so how do I "fetch" the Settings? got a code sample? :D

Thanks again :)

Qjahe
 

Mr.Mitchell

New Member
Sep 5, 2001
140
0
0
the Netherlands
home.ict.nl
You can create your own .ini files. You can use the config keyword for that.

But there is even an better way than using the .ini file. You could read the installed package from .int files. So you can create a new package and a .int, drop those 2 in the UT/System folder and thats it. I used a similar system for the AirfightUT mod to have custom backgrounds for the menus