A new Version of this Tutorial is or will be includet here (only in german)
Hi
This is a full tutorial how to make a PagePack for GroupInvite. If you don't know how to write an lua-code you should learn this first!
First steps
The first step is to make a folder of your own PagePack. You can call the folder like you want.
In this folder, creat at first the follow three files:
A .toc file to execute the PackPackA .lua file to execute the pagesAt least one .lua file which will be a pageYou can also add own languages, but I will explain this later
Start the PagesTo execute our own pages, you have at first add the name of the .lua file, which executes the pages, to the .toc file. You don't have to add the pages to the .toc file.
In the .lua file, which executes the pages(in the follow i will call it the loader file), you have to insert the follow:
if(not _G["GroupInvite_AddPages"])then _G["GroupInvite_AddPages"]={}; end
The table "GroupInvite_AddPages" is a global table of all pages which were added to GroupInvite. You have to insert your pages to this table, too. To do this, I recomment follow code:
local pages={
"Page1",
"Page2",
...
};
for a=1,table.maxn(pages)do
local f=false;
for b=1,table.maxn(_G["GroupInvite_AddPages"])do
if(_G["GroupInvite_AddPages"][ b ][1]==pages[a] and _G["GroupInvite_AddPages"][ b ][2]=="Interface/Addons/GIPP-PagePacks/")then
f=true;
end
end
if(f==false)then
table.insert(_G["GroupInvite_AddPages"],{pages[a],"Interface/Addons/PagePacks/"});
end
end
As you can see, there will be two things of each page insert in the table: The name of the page and the path to this page. The code i've posted above insert these informations of each page, but only if there are not in the table yet. This is to prevent load problems if the same page will be load twice.
The load file would be ready now, but if you want to you can add any global tables of your page pack or any other thinks to the load file
The pagesNow let's start to make a page
You can find a clean page-example in the folder Interface/Addons/GroupInvite/Lua/Tree/test.lua . This test.lua file won't be loaded by GroupInvite and include also a description of each function, so i won't explain this here.
A little explain to the "default" table: This includes the base of your saves. for example, if you insert the variable "MyTestVariable" as a boolean variable set to true, than you can use this variable in your page as
GroupInvite_Settings.MyTestVariable
But there's also some things to notice: The patch system will make all variables which you've insert in this table, if they don't exist and will delete all variables, which are not in this table(and not in any other page table). It also changes the type of the variables if you've saved the variable for example as a string but it was saved as a number, the patch system will change it back to it's default, so it's a string again but the saved data is lost. But what to do if you don't know the exactly number of a table? like a blacklist, where the player could insert as much names as he want? For this, there's also a nice part included. If you call a variable "$_ _def",(without the space between the "_ _") this means for the system to check all variables of this page which uses numbers as names.
A little example: Let's think we want to make a table which saves the name of a person and if this person is a man or a woman:
default={
MyTestVariable=true,
MyTestTable={
["$_ _def"]={["Name"]="",["Sex"]=""},
},
};
later, the saved things maybe look like this:
GroupInvite_Settings={
MyTestVariable=true, --it could be also false but no other values!
MyTestTable={
["$_ _def"]={["Name"]="",["Sex"]=""},
[1]={["Name"]="Mark",["Sex"]="MAN"},
[2]={["Name"]="Susan",["Sex"]="WOMAN"},
[3]={["Name"]="Mike",["Sex"]="MAN"],
},
};
Now, let's think we want to make a secound table called MyTestTable2 which also saves the name and sex of some people but includes also some new data. For this, there's a keyword called "$_ _inh"(without the space between "_ _"), which allows to copy the BASE of a table to an other table, for example:
default={
MyTestVariable=true,
MyTestTable={
["$_ _def"]={["Name"]="",["Sex"]=""},
},
MyTestTable2={
["SomeNewData"]=0,
["$_ _inh"="MyTestTable.$_ _def",
},
};
This would make the follow save things:
GroupInvite_Settings={
MyTestVariable=true, --it could be also false but no other values!
MyTestTable={
["$_ _def"]={["Name"]="",["Sex"]=""},
[1]={["Name"]="Mark",["Sex"]="MAN"},
[2]={["Name"]="Susan",["Sex"]="WOMAN"},
[3]={["Name"]="Mike",["Sex"]="MAN"],
},
MyTestTable2={
["SomeNewData"]=3, --could be any number
["Name"]="Frank",
["Sex"]="MAN",
},
};
since build 829:There's also the command ["$_ _all"], which sais that all variables in this table have to be like this. This allows to make a list of no-number variables!
Now, let's check the other functions. Most of them are explained, as i said. I can't post here a table of all events because it's too long and changes some times, but all events which were "GroupInvite-Only-Events" like a change of a page or something like that, starts with "GROUPINVITE_"
At last, let's check the "MyFrame" function(please notice that the "partID" system don't work in the GroupInviteEngine v815 and previos versions)
This function will be executed when the player opens the page. This function is also used to show the page, so if you've made a .xml frame of your page you can easyly insert here a :Show() function, but remember to add an :Hide() function at the events function if the player changes the page.
If you don't made a .xml frame, you can also make a page with the functions of the GroupInviteEngine. The idea behind this is realy easy: You make a frame, give him a name, size and position, a text and a tooltip. The OnClick functions or something like that will be done by other functions
Well, to do this now, you have to use 3 functions(you can find other functions if you check the code of the main page pack pages):
local this=GroupInvite_Execute("GroupInvite_Page_GetNextText",page.ID,"Name of the Frame");--this returns the frame part(for example a text)
GroupInvite_Page_SetSizeAnchorsAndID(this,200,24,"TOP","TOP",this:GetParent(),0,9,page.ID);--This function want to get follow things: the frame, the width, the hight, the anchor point and relativeAnchor point, the relative anchor frame, x and y offset and the page ID
GroupInvite_Page_SetTextAndTooltip(this,true);--this sets text and tooltips to the frame: the first value is the frame itself, the secound is the name of the text value in the language table, for example "GUI_MyTestText", so it is the text which was written on the frame! If you insert the value true, it will generate the value name automaticly by follow: GUI_Name of the Page_Name of the frame . The 3. value is the name of the tooltip text in the language table, so it works like the secound value, but you don't have to insert the "Tooltip_" at the beginning of the value name and the "_1" at the end. So, if you insert "MyPage_MyFrame", it would search for the tooltip text "Tooltip_MyPage_MyFrame_1" as the tooltip title and the follow numbers as the text of the tooltip(like Tooltip_MyPage_MyFrame_2, Tooltip_MyPage_MyFrame_3 and so on). It also generates the tooltip name automaticly if you insert the value true like it does at the secound value.
Sometimes, theres a 4th function in use. This could be a function to decline special informations at edit boxes, important values for list objects or something of the Drag and Drop system, or something other. The list-objects also don't use the 2. function("GroupInvite_Page_SetSizeAnchorsAndID"), instead of this it uses "GroupInvite_List_SetListSize". This function work similar to the the other, but it don't want to get the pageID, instead of this it want to get the maximum number of lines which were shown at the same time(without scrolling)
If you have any questions, you can ask me at any time
MfG