North Posted May 28, 2012 Share Posted May 28, 2012 Hi, I've started working on an addon that revamps the Teleport dialog and the HearthStone dialog to fix those inconsistent map names. Example: Dead Thicket, Lightwood should be Lightwood, Dead Thicket .... First the map name and then the zone I have the code part for the locations list done: Code: function normalizeLocationName(name) local maps = { "Novograd", "Lightwood", "Siveria", "Frozen Frontier", "Darkwater", "Tenebra", "Asee-Teph", "Eljune", "Coba Plateau" }; for i, mapName in pairs(maps) do local pos = string.find(name, mapName); if pos and pos > 1 then return mapName .. ", " .. string.sub(name, 1, pos - 3); end end return name; end ------------------------------------------------------------------------------- function getSortedLocations() local locations = {}; local avatarTpLocations = avatar.GetTeleportLocations() for id, objectId in avatarTpLocations do local info = avatar.GetTeleportLocationInfo(objectId) if info then table.insert(locations, { id = info.id, name = normalizeLocationName(userMods.FromWString(info.name)) }); end end table.sort(locations, function (a, return a.name < b.name; end); return locations; end I also cleared the list of locations (populated by the script). The problem is I don't have the widget resource object to be able to call: Code: mainForm:CreateWidgetByDesc( wtTeleportButtonDesc ) I would use the one already defined by the game but I couldn't do it because it isn't named. Can anyone help me with this? PS: I learned the LUA programming language so that isn't a problem. The allods API is giving me a hard time. Quote Link to comment Share on other sites More sharing options...
Nikon Posted May 29, 2012 Share Posted May 29, 2012 wtTeleportButtonDesc - где и как задается? Quote Link to comment Share on other sites More sharing options...
North Posted May 29, 2012 Author Share Posted May 29, 2012 Yes, the problem I have is how to get that description (wtTeleportButtonDesc). I looked into ContextNPCTeleport lua (the old one) to find the rest of the information. Code: -- wtMain - the widget for ContextNpcTeleport wtTeleportButton = wtMain:GetChildChecked( "TeleportButton", false ) wtTeleportButtonDesc = wtTeleportButton:GetWidgetDesc() The problem is I can't get wtTeleportButton because it is not named. I think it is not possible. I've looked though the API, and only named widgets can be accessed. I'm thinking of enhancing it anyhow. I want to list only the Map names. When clicked it either opens a drop down that lists all the locations on that map and select the first by default or clears the list and adds only the locations from that map. I'll try to dig some information on how to create the widgets (buttons). I think I can't get to the default buttons. LE: I just read the GUI tutorial here. I'll try creating my own resources. Quote Link to comment Share on other sites More sharing options...
Setras Posted May 29, 2012 Share Posted May 29, 2012 I wonder if it's possible. I think you need to delete all container content and refill it with your buttons. Quote Link to comment Share on other sites More sharing options...
Nikon Posted May 29, 2012 Share Posted May 29, 2012 wtTeleportButton == nil ? Возможно дерево виджетов в аддоне ContextNpcTeleport другое и кнопка находится в другом месте или называется по другому Как задается wtMain ? Что выдает wtMain:GetNamedChildren() ? В любом случае, если предполагается замена функционала стандартной кнопки, нужно будет ее скрывать(удалять) и подставлять готовую свою (из своих ресурсов) Quote Link to comment Share on other sites More sharing options...
North Posted May 29, 2012 Author Share Posted May 29, 2012 I already managed to delete all the container contents. I was also able to add a duplicate of the Teleport button (the one near Cancel). I think I'll also have to replace the Teleport button inside the widget. This is turning into an interesting challenge. I'll see to creating my own resources when I get home. I'll use the AOTextureViewer to see what I can use. Quote Link to comment Share on other sites More sharing options...
North Posted May 29, 2012 Author Share Posted May 29, 2012 I don't think the button I was looking for was a named child. I inspected the widget with InterfaceManager to see what I can access and couldn't find it. If I'm not mistaken, the InterfaceManager uses GetNamedChildren to display the child list. I'll try to create my own resources (buttons). I'll keep you updated. Thank you for your quick replies. Quote Link to comment Share on other sites More sharing options...
North Posted May 30, 2012 Author Share Posted May 30, 2012 I've made steady progress with this addon. Right now I don't know why I can't attach an event handler for Button clicked. Here is the addon code. From line 109 you can see where I tried this but without success. It would be great if anyone can tell me what I did wrong. http://www.2shared.com/file/3QvDHvjy/TeleportSort.html PS: Please don't mind the mess inside init.lua. That is the testing ground. After something works it gets refactored and done right. PPS: To test it you have to open the ContextNPCTeleport window (talk to the NPC) then unload and load the script from the addon manager. Quote Link to comment Share on other sites More sharing options...
Setras Posted May 30, 2012 Share Posted May 30, 2012 If you add a child to some other addon, that child sends you reactions no more. Instead it sends reactions to his new parent. So the easiest way to do what you want is just COPY buttons. 100% copy, Same reactions etc. Didnt read your addon, so idk what method do u use, but i doubt that you had totally rewrote the teleporter addon. Quote Link to comment Share on other sites More sharing options...
Nikon Posted May 30, 2012 Share Posted May 30, 2012 Quote: If you add a child to some other addon, that child sends you reactions no more. Instead it sends reactions to his new parent. К примеру в PaneLocker единственная кнопка (пардон, там ребенком является вся форма, подзабыл уже, но это ничего не меняет) является ребенком стандартного аддона ContextBag. ХЗ даже как это она работаетQuote: So the easiest way to do what you want is just COPY buttons. 100% copy, Same reactions etc. Это как? Копировать кнопки стандартных аддонов?Известны названия их reactions? Где посмотреть или как узнать можно?Quote: I've made steady progress with this addon. Right now I don't know why I can't attach an event handler for Button clicked. Here is the addon code. From line 109 you can see where I tried this but without success. It would be great if anyone can tell me what I did wrong. Не могу сейчас проверитьДо присоединения к чужому родителю ребенка реакции от кнопки приходят? Quote Link to comment Share on other sites More sharing options...
North Posted May 30, 2012 Author Share Posted May 30, 2012 I imagined the reason why the reactions aren't sent to my addon is because I added my buttons to another form. I am used to functional programming, mainly JavaScript, and I was expecting the same type of flexibility. I don't know what you mean by copying the buttons. For one, as you know, we only have access to a very old version of that addon, and only the lua files for it. If you have the xdb files defining the gui elements could you please give me a link to them or tell me how I can get to them? Also, having a copy of those buttons isn't going to help me handle the reactions unless I replicate the panel. Replicating the panel doesn't help if I'm not mistaken. There needs to be interaction with a teleportNPC to be able to teleport (this claim isn't tested). Also, I would need to hide the original addon (easy part) and show mine when the teleport option is selected. This is the difficult part. I couldn't find events related to the Teleport Widget. I am starting to think that it is impossible to do what I want. The best I can think of is set the same reaction on click for my buttons and keep the name for each location button. This is how they seemed to keep their data. I think this is what you meant by copying their buttons. This is a poor replacement for what I had in mind in terms of usability. Also, I can't really get the actual buttons from the list because they are not named resources. So I don't have access to their name or label. The best I could do is guess what the order is. This means you could get scenarios when you click to teleport to a location and wake up to be in a totally different place. Thank you for your answer. Quote Link to comment Share on other sites More sharing options...
North Posted May 30, 2012 Author Share Posted May 30, 2012 I have defined the button as a child of my widgets form. I got a reference to it and then duplicated it to add it to the standard NPC Teleport addon panel. I don't need a form. Can I add the button to the game so I can access it from lua without adding it to a form? I'll take a look at PaneLocker but I don't think it is the same context. Thank you. Quote Link to comment Share on other sites More sharing options...
Nikon Posted May 30, 2012 Share Posted May 30, 2012 Quote: For one, as you know, we only have access to a very old version of that addon, and only the lua files for it. If you have the xdb files defining the gui elements could you please give me a link to them or tell me how I can get to them? Вся документация обновляется вместе с клиентомhttp://ui9.ru/forum/develop/topic/1517/t1517-Looking-for-Modding-Docs-for-2-0-0-6-EUВ этом же архиве находятся шаблоны виджетов(*.xdb) в отдельной папкеupd:Примерная методика переноса своей кнопки на чужой виджет:- В ресурсах создается своя кнопка(*.xdb) на своей форме- В коде объявляется переменная, содержащая этот ресурс и- Добавляется ребенком к чужому виджету методом AddChild()В простейшем случае эти пункты можно записать 1 строчкой:Code: stateMainForm:GetChildUnchecked("ParentWidget",false):AddChild(mainForm:GetChildUnchecked("MyButton",false)) Quote Link to comment Share on other sites More sharing options...
North Posted May 30, 2012 Author Share Posted May 30, 2012 I know about that documentation but the last time I looked there weren't any xdb files in there. There are some sample widgets and sample common. That is where I took the button from and modified it to have align_both for X direction. I'll look over them again to see if there are more details on this. This is what I used to add a button. Also, I created buttons dynamically for each Zone. Code: wtScrollableContainer:PushBack (wtButton) I used stateMainForm to get my button too. I'll try using mainForm. I did add the buttons to the ScrollableContainer from the standard addon. It is just that the function I wrote to run on click didn't run. PS: I think I found the problem. I used the mainForm of the standards addon to create the buttons. I'll use the mainForm of my widget. I think this will solve the issue. I'll post here how it goes. Quote Link to comment Share on other sites More sharing options...
Setras Posted May 31, 2012 Share Posted May 31, 2012 By "copying" i mean to copy name and reaction, which you don't know. So your button will react to another script, not your addon, but the teleport addon instead. The only things we have is CategoryTeleportMaster, which works together with CategoryInteraction. Once interaction started, you can check object.GetInteractorInfo(objectId).isTeleportMaster, but as far as i know you can't tell if a player has opened teleport menu or not. But you can check if standart telport menu is visible or not, and hide it and show your own. Then use FunctionAvatarGetTeleportLocations FunctionAvatarGetTeleportLocationInfo And finally, FunctionAvatarTeleportToLocation. But this will require total standart addon functionality replacement. Which seems to be more possible than trying to get standart button's reactions name. Quote Link to comment Share on other sites More sharing options...
Setras Posted May 31, 2012 Share Posted May 31, 2012 As for paneLocker, the whole main form is a child of another form, so this may be the reason it still gets the reactions from it's button. If you move your button to another addon - it stops sending you reactions. Quote Link to comment Share on other sites More sharing options...
Nikon Posted May 31, 2012 Share Posted May 31, 2012 ОкОк. Ты даже меня убедил. Пусть будет так, если хочешь Так чего там по поводу этого то? Quote: So the easiest way to do what you want is just COPY buttons. 100% copy, Same reactions etc. Quote Link to comment Share on other sites More sharing options...
Setras Posted May 31, 2012 Share Posted May 31, 2012 Что по поводу этого? Делаем копии кнопок и сажаем их в системный аддон. Копии кнопок посылают ему реакции. Профит? Quote Link to comment Share on other sites More sharing options...
Nikon Posted May 31, 2012 Share Posted May 31, 2012 Code: посылают ему реакции ЕМУ реакции?И?За каким нам(тебе) нужна куча одинаковых кнопок, которые выполняют одно и то же?(Ты ведь для чего то это советовал дельного, не?)Я уж было подумал что ты научился определять имена реакций для их перехвата Quote Link to comment Share on other sites More sharing options...
North Posted May 31, 2012 Author Share Posted May 31, 2012 I moved the NpcTeleportPanel to my form and now I get the reactions and everything look fine. If I'm not mistaken, you only get reactions from children of your form. Setras was ahead of me to predict the trouble catching the moment when the Teleport Panel is opened. In the old lua files, the NPC would send an event when the user clicked teleport: Code: common.SendEvent( "SCRIPT_TOGGLE_TELEPORT", {} ) I don't know if this is still the case. I would need to extract the files from LuaCompiledIngame.pak and LuaCompiledSystem.pak .I know that the files are luac (compiled) but the strings and the function names can easily be read. This way I can see what events the game generates. This would be cleaner then checking in any other way. LE: I found that WinZip can decompress them. I'm on a roll here. LLE: I looked over the luac files and it seems they register a handler for the "SCRIPT_TOGGLE_TELEPORT" event. It seems I can't handle it. Can anyone of you check to see if it's just me? Quote Link to comment Share on other sites More sharing options...
North Posted May 31, 2012 Author Share Posted May 31, 2012 The addon enters beta. Beta2 (if there is only one location on a certain map, the button will teleport to it instead of opening a list of locations) http://www.fileshare.ro/64852174498 I know there are quirks to fix but it's an improvement. Feedback is welcome. Stuff to fix if anyone can help: Center the widgetAlign button text: left LE: If the teleport panel doesn't appear, unload my addon, unload and then loac the ContextNpcTeleport standard addon. After that load my addon again (TeleportSort). Quote Link to comment Share on other sites More sharing options...
Setras Posted May 31, 2012 Share Posted May 31, 2012 Мы не можем переделать кнопки к которым у нас нет доступа. Но мы можем удалить их, и вставить вместо них свои, переделанные. Quote Link to comment Share on other sites More sharing options...
Setras Posted June 1, 2012 Share Posted June 1, 2012 Also don't forget avatar.UseHearthStoneToLocation() Quote Link to comment Share on other sites More sharing options...
North Posted June 1, 2012 Author Share Posted June 1, 2012 Yes. I did think about it. Portal Keepers are used more often though. That's why I did that first. It shouldn't be difficult to add this to the HearthStone too. The problem is I'll have to rewrite everthing for it (I will reuse the code I wrote until now but there are changes that need to be done). I want to center it and make sure there aren't issues when loading it before going over to HearthStone. After I've done that I will upload it as an addon. If there is one thing that I don't like is that I can't catch the event when the Panel is opened (even if I know it's name). Quote Link to comment Share on other sites More sharing options...
North Posted June 2, 2012 Author Share Posted June 2, 2012 The addon is ready to be used and can be found here. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.