Please advise.
Is there a simple module/function ???
| Author | Comment | ||
|---|---|---|---|
ggaliens |
How can plugin acquire Wings version # at run-time ??? |
Lead | |
|
(07/05/09 13:04:16) |
How can plugin acquire Wings version # at run-time ???
Please advise. Is there a simple module/function ??? |
||
optigon |
|||
|
(07/05/09 13:21:23) |
There's a macro located in the wings.hrl.
?WINGS_VERSION |
||
ggaliens |
|||
|
(07/05/09 14:27:44) |
I want my plugin to be able to COMPARE itself to it's owning
environment, so that macro won't help, I don't think. I need to call a function in the wings3D API that will have been compiled by the devs. |
||
ggaliens |
|||
|
(07/05/09 14:29:06) |
I have scoured the code looking for a place where wings3D exports a sting with this MACRO
value embedded in it. I can't find it. There was a close call in wing_u:wings() but does not get exported. |
||
ggaliens |
|||
|
(07/05/09 14:46:26) |
Maybe I could have wings3d export an OBJ file and discover the version.
Man that's gross. Could you guys please add a proper way for a plugin to discover the wings3D version by just returning the macro value from a designated function ???
Last Edited By: ggaliens
07/05/09 14:48:52.
Edited 1 times.
|
||
optigon |
|||
|
(07/05/09 15:48:32) |
why not do
MyVersionNumber = 1.1.5, case MyVersionNumber == ?WINGS_VERSION of true -> do_this(); false -> do_that() end. |
||
deerwood |
|||
|
(07/05/09 18:04:44) |
optigon: >> case MyVersionNumber == ?WINGS_VERSION of ... As of "Programming Erlang" page 99: "Macros are expanded by the Erlang preprocessor ..." meaning at compile time. So ggaliens could find out what version of Wings he is compiling his plugin(s) against. But, as he also clearly stated, his intention is to behave differently, when his already compiled plugin(s) are run on some foreign users Wings installation. So, yes, I second his request to have a function (say in module wings_u) to get hands on the users version of Wings to help plugin developers. Should be easy to do: -export([wings_version/O]). wings_version() -> ?WINGS_VERSION. or similar; maybe just export and enhace the existing function wings() a little bit (I would like to see the version number in the title bar too, because I work with different versions, would also help in screenshots)? Best regards |
||
ggaliens |
|||
|
(07/05/09 19:14:39) |
Deerwood, you have understood and clarified my request.
Thanks. Edit : I also was thinking that the version # would not hurt so much in the title-bar.
Last Edited By: ggaliens
07/06/09 05:53:44.
Edited 1 times.
|
||
Ran13 |
|||
|
(07/06/09 06:23:07) |
Edit : I also was thinking that the version # would not hurt so much in the title-bar. Would really like this for doing troubleshooting/bug hunting on the new snapshots when I have several different versions of Wings installed!!! |
||
optigon |
|||
|
(07/06/09 06:26:55) |
Maybe we could add an option to the Develop menu to add the version number to the titlebar, it is helpful to know what verisons are installed. Currently the
verison number is available in the Help|About panel and for windows users, the Erlang shell that opens with wings. If a funciton to pull the version number
would be useful, it can be added.
|
||
ggaliens |
|||
|
(07/06/09 08:58:44) |
Please guys. Do add. It's more than useful. It's the right course of
action for core developers who want to be open to plugins. Additionally ... the plugin ought to be able to create a nice ordering and make the proper assumptions about the PART of the version number. So Bjorn and Dan should really take the lead on this and make a good choice that we can live with. 1.1.5 is maybe not even standard. I think it is more standard to have 4 Parts. Perhaps the Wings3D API can do the version comparison internally as well. So we need ... wings:version_compare( A, B) wings:version() and wings:version_equal(A,B). Something like that ... something complete and thought out that will last for a few years. |
||
ggaliens |
|||
|
(07/28/09 17:18:34) |
What is the plugin init function used for ???
Please advise. I was thinking that if it returned false ... this meant the function was not working right. Maybe the pluging makes this determination at load time ??? I want to my plugin to check which wings3D version it has been installed into. Please advise on a good run-time approach. I don't want to do only during install. |
||
bjorng |
|||
|
(07/28/09 20:28:50) |
Returning false from init/0 means that the plug-in will be disabled (i.e. menu/2 and command/2 in the plug-in module will never be called).
|
||
ggaliens |
|||
|
(07/29/09 05:34:54) |
OK ... that's fine ... but seems like it would be reasnable for at least one of my plugins to pop-up an ALERT/DIALOG with a message about incompatibility
based on the init/0 return value. I know this could be annoying for a user, but my plugins are WIP and probably have always been a little anoying because of the rough nature. On balance ... I think we are getting to less anoying place. It seemed like a lot of things were not possible during init/0 call. For example .... erlang:display didn't seem to work (odd). I think I tried a few dialogs. No luck. Can I get the user a message (in your face message) based on the init/0 passing back false ??? If this is simply enable vs disable ... maybe you could provide an additional API ... call vet or configure or something that would be optional for plugins ???? By which they could test themselves againt the wings and provide a message even if that message has to be passed to the core first. Please Bjorn ... give me an idea here. |
||
deerwood |
|||
|
(08/12/09 18:26:16) |
ggaliens: > the plugin ought to be able to create a nice ordering and make the proper assumptions about the PART of the version number ... For some test plugin I also needed to check/compare the required Wings version number and came up with this code/function in my plugin:
%% This is the first function that wings will call when wings starts.
%% Returning false disables the plugin completely.
%%
%% In our case we have to check by version, if the 'table'
%% element in dialogs accepts the col_widths flag.
init() ->
wings_version() >= [1, 1, 10].
%% Returns the Wings version as a (comparable) list of integers.
wings_version() ->
IsCheckable = erlang:function_exported(wpa,version,0),
VersionString =
if IsCheckable ->
string:tokens(wpa:version(), ".");
true ->
["0", "0", "0"]
end,
Fun =
fun(A) ->
try list_to_integer(A) of
B -> B
catch
% ignore git hash elements, they ain't integers base 10;
% and though one could use list_to_integer/2 (with a good
% base) it wouldn't make any sense to do so (they are hashes
% after all).
_:_ -> 0
end
end,
Version = lists:map(Fun, VersionString),
io:format("Version: ~p~n", [Version]),
Version.
note, that I'm an Erlang/Wings beginner, so this code might not be the best way to go (and obviously again very verbose, but then readable [?] and seems to work for me). If there is a better approach I would like to see it and learn. ggaliens: > ... ALERT/DIALOG with a message about incompatibility ...
The your_plugin:wings_version/0 function above can be used anywhere, so, if you just return true from init (instead of my approach disabling the plugin completely) you can decide e.g. in the menu callback, to only show an INFO entry instead of a full blown menu and/or in the command callback to show that alert, when the user is using an outdated version of Wings. Sorry, that I couldn't get around to test out your manifold lab yet (so busy with other things), probably you already have done that better. Best regards |
||
deerwood |
|||
|
(08/13/09 20:05:13) |
Slightly better code:
wings_version() ->
VersionString =
case erlang:function_exported(wpa,version,0) of
true ->
string:tokens(wpa:version(), ".");
false ->
["0", "0"]
end,
Fun =
fun(A) ->
try list_to_integer(A) of
B -> B
catch
% ignore git hash elements
_:_ -> 0
end
end,
lists:map(Fun, VersionString).
this avoids if (required to use guard expressions) in favour of case, thus eliminating a helper variable (and is less verbose and without the debug io:format). Best regards |
||
deerwood |
|||
|
(08/13/09 20:06:54) |
Slightly better code:
wings_version() ->
VersionString =
case erlang:function_exported(wpa,version,0) of
true ->
string:tokens(wpa:version(), ".");
false ->
["0", "0"]
end,
Fun =
fun(A) ->
try list_to_integer(A) of
B -> B
catch
% ignore git hash elements
_:_ -> 0
end
end,
lists:map(Fun, VersionString).
this avoids if (required to use guard expressions) in favour of case, thus eliminating a helper variable (and is less verbose and without the debug io:format). Best regards |
||