Kayl Posted March 10, 2010 Share Posted March 10, 2010 (edited) Hello there! Some more questions today. As usual I hope they were not already answered. A quick search on both the forum and mantis didn't give me anything conclusive. Q1: Is the event onClientDoubleClick known to work? I receive perfectly (when cursor is shown) onClientClick but I can't seem to receive onClientDoubleClick. Any idea why? I don't want to use it on GUI elements but to test the reason of failure of onClientDoubleClick I tried to listen to onClientGUIDoubleClick also which I receive correctly (on gui elements only of course) Also, when/if I get to receive it, is onClientClick also sent when onClientDoubleClick is (just for information). Q2: In the MTA client, folder MTA/cgui/images can be found images that are used, I guess, for the default F11 map. Is there a way to use any of those images without having to copy them in our resource folder (small files but the total is pretty big, especially knowing that the client already has them in this location)? I tried to use a path relative to the resource calling (with ../.. etc) but it didn't work. Q3: When disabling the "radar" control (toggleControl) in order to use a custom commandHandler for the "radar" command, it works fine but the console is filled with "Unknown command or cvar: radar". Any way to disable that? Q4: When using dxDrawImage a file path has to be used. The first time it's called, the image is loaded and further references to the same image will use the memory version of the image. However it seems that if an image is not used for a while, it gets destroyed. In my case this is quite a big image so any time it needs to be displayed again, it creates a small freeze while it's loading. Any way to work around that problem? (prevent deletion of a specific image from cache if resource creating it is still running?) Thank you in advance Edited March 11, 2010 by Guest Link to comment
karlis Posted March 10, 2010 Share Posted March 10, 2010 most profesional questions i saw in this section so far, tought have no ansvers on any, exept u could try find "maximap" and "maximap_examples" resources for some map engine changing examples Link to comment
Gamesnert Posted March 10, 2010 Share Posted March 10, 2010 Q1: Is the event onClientDoubleClick known to work? I have been scripting something with onClientGUIDoubleClick just yesterday. Works fine, for gridlists, that is. Are you sure you didn't mistype it? Otherwise, just check the time between clicks. Q2: In the MTA client, folder MTA/cgui/images can be found images that are used, I guess, for the default F11 map. Is there a way to use any of those images without having to copy them in our resource folder (small files but the total is pretty big, especially knowing that the client already has them in this location)? The F11 map image in there isn't big. (± 100 kB if I recall correctly) But no, except for copying there is no other way. Q3: When disabling the "radar" control (toggleControl) in order to use a custom commandHandler for the "radar" command, it works fine but the console is filled with "Unknown command or cvar: radar". Any way to disable that? Nope, should be fixed by someone IMO too. Q4: When using dxDrawImage a file path has to be used. The first time it's called, the image is loaded and further references to the same image will use the memory version of the image. However it seems that if an image is not used for a while, it gets destroyed. In my case this is quite a big image so any time it needs to be displayed again, it creates a small freeze while it's loading. Any way to work around that problem? (prevent deletion of a specific image from cache if resource creating it is still running?) I've ran across this problem some time ago too, and was annoyed. (expressed VERY softly) I found a way around it, however. I've got to nominate it to the Guinness Book Of Records as dirtiest hack ever sometime, but oh well, it works. (It can be seen in my maximap resource) function keepImageLoaded() dxDrawImage(0,0,0,0,"imagefile.ext") end addEventHandler("onClientRender",getRootElement(),keepImageLoaded) This is basically what it comes down to. You just draw *cough* the image with size 0x0. This means you can't see it, but the picture is still being loaded. I prefer having something like: image = fileOpen("lol.png") ... dxDrawImage(x, y, w, h, image) Would at least be less hacky, and easier to come up with. But that might just be me. Link to comment
Kayl Posted March 10, 2010 Author Share Posted March 10, 2010 Q1: Is the event onClientDoubleClick known to work? I have been scripting something with onClientGUIDoubleClick just yesterday. Works fine, for gridlists, that is. Are you sure you didn't mistype it? As you say yourself, you played with onClientGUIDoubleClick on a gridlist, I'm asking about onClientDoubleClick (and on non gui elements) Otherwise, just check the time between clicks. The F11 map image in there isn't big. (± 100 kB if I recall correctly) But no, except for copying there is no other way. Ok thanks. The funniest part is that the radarset folder is only 12,5KB theoretical but 252KB on disk, that's why I was worried about saving space (more than the map itself). Nope, should be fixed by someone IMO too. Indeed, I guess you felt the same when implementing your maximap. Image hack answer Me like it Well no I don't like having to do it but I like the idea. Thanks a lot. I understand that in most cases the string argument is easier for most scripts but it would be great if indeed it could receive a data variable referring to an already loaded image. ----- Current status: Q2, Q3, Q4 answered. Q1 still needs solving. Link to comment
blas95 Posted March 11, 2010 Share Posted March 11, 2010 Ok thanks. The funniest part is that the radarset folder is only 12,5KB theoretical but 252KB on disk, that's why I was worried about saving space (more than the map itself). And here, we see the use of requested in suggestions forum bounding box for images. You should then create one sprite image, and save ~230KB, then alter it with bounding box. Link to comment
Gamesnert Posted March 11, 2010 Share Posted March 11, 2010 Ok thanks. The funniest part is that the radarset folder is only 12,5KB theoretical but 252KB on disk, that's why I was worried about saving space (more than the map itself). And here, we see the use of requested in suggestions forum bounding box for images. You should then create one sprite image, and save ~230KB, then alter it with bounding box. I don't know what you think he was talking about, but he was talking about if you right-click a file and select properties, you can see "Size" and "Size on disk" for as far as I can see. No bounding box that can change any of that. Link to comment
Kayl Posted March 11, 2010 Author Share Posted March 11, 2010 I guess he means that it would save space if we could use only one image with all icons (less png + filesystem overhead) Anyway, as discussed on IRC, it seems indeed that the onClientDoubleClick is not triggered as such. Here is a small hack for those interested (will provide a working onClientDoubleClick for your other resources too): local g_DoubleClickHack = {} local DOUBLE_CLICK_DURATION = 250 function onMouseDoubleClickHack(button, state, x, y, wX, wY, wZ, element) if not g_DoubleClickHack[button] then g_DoubleClickHack[button] = {} end local lastTick = g_DoubleClickHack[button][state] local now = getTickCount() if lastTick and (now - lastTick) <= DOUBLE_CLICK_DURATION then triggerEvent("onClientDoubleClick", g_Root, button, state, x, y, wX, wY, wZ, element) end g_DoubleClickHack[button][state] = now end addEventHandler("onClientClick", g_Root, onMouseDoubleClickHack) In the code above, g_Root is of course getRootElement() Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now