Skip to content

Commit

Permalink
save unused materials option for .wings files
Browse files Browse the repository at this point in the history
git-svn-id: https://wings.svn.sourceforge.net/svnroot/wings/trunk@529 a0a82711-911a-0410-9f52-85ee3e23afd8
  • Loading branch information
Richard Jones committed Mar 28, 2009
1 parent 7b21d6b commit 7b5fbe5
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 3 deletions.
4 changes: 4 additions & 0 deletions NOTES
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@
camera position dialog, and rmb accepts the current view and exits the
preview. [optigon]

- New option, File|Save Unused Materials, can be checkmarked if you want to save
all the materials from a scene, including the ones not applied to your model,
to a .wings file. [optigon]

--- 0.99.53 -----------------------------------------------------------------
- Kerkythea exporter added to Wings. [contributed by Chris Hegarty (Avariant)]

Expand Down
10 changes: 8 additions & 2 deletions src/wings_ff_wings.erl
Original file line number Diff line number Diff line change
Expand Up @@ -476,9 +476,15 @@ export(Name, St0) ->
wings_pb:start( ?__(1,"saving")),
wings_pb:update(0.01, ?__(2,"lights")),
Lights = wings_light:export(St0),
Materials = wings_material:used_materials(St0),
Materials = case wings_pref:get_value(save_unused_materials) of
true ->
#st{mat=Mat} = St0,
gb_trees:to_list(Mat);
false ->
wings_material:used_materials(St0)
end,
#st{shapes=Shs0,views={CurrentView,_}} = St =
remove_lights(St0),
remove_lights(St0),
Sel0 = collect_sel(St),
wings_pb:update(0.65, ?__(3,"renumbering")),
{Shs1,Sel} = renumber(gb_trees:to_list(Shs0), Sel0, 0, [], []),
Expand Down
17 changes: 16 additions & 1 deletion src/wings_file.erl
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ export_filename(Prop0, Cont) ->
wings_plugin:call_ui({file,save_dialog,Prop++[{title,String}],Fun}).

init() ->
wings_pref:set_default(save_unused_materials,false),
case wings_pref:get_value(current_directory) of
undefined ->
case file:get_cwd() of
Expand Down Expand Up @@ -123,6 +124,10 @@ menu(_) ->
?__(14,"Save only the selected objects or faces")},
{?__(15,"Save Incrementally"),save_incr,
?__(26,"Generate new filename and save")},
%% if there are more options we'll make a panel
{?__(29,"Save Unused Materials"),save_unused_materials,
?__(30,"Include unused materials when saving a .wings file"),
save_unused_mats()},
separator,
{?__(16,"Revert"),revert,
?__(17,"Revert current scene to the saved contents")},
Expand All @@ -138,7 +143,13 @@ menu(_) ->
{?__(24,"Install Plug-In"),install_plugin,
?__(27,"Install a plug-in")},
separator|recent_files(Tail)].


save_unused_mats() ->
case wings_pref:get_value(save_unused_materials) of
true -> [crossmark];
false -> []
end.

command(new, St) ->
new(St);
command(confirmed_new, St) ->
Expand Down Expand Up @@ -176,6 +187,10 @@ command(revert, St0) ->
St0;
#st{}=St -> {save_state,St}
end;
command(save_unused_materials, St) ->
Bool = wings_pref:get_value(save_unused_materials),
wings_pref:set_value(save_unused_materials, not Bool),
St;
command({import,ndo}, _St) ->
import_ndo();
command({import,{ndo,Filename}}, St) ->
Expand Down

0 comments on commit 7b5fbe5

Please sign in to comment.