forked from Moo-Ack-Productions/MCprep
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mcprep_ui.py
2125 lines (1882 loc) · 65.3 KB
/
mcprep_ui.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# ##### BEGIN GPL LICENSE BLOCK #####
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software Foundation,
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# ##### END GPL LICENSE BLOCK #####
# library imports
import bpy
import os
from bpy.types import DATA_PT_EEVEE_shadow, WM_MT_splash_quick_setup
from bpy.utils import register_class
# addon imports
from . import addon_updater_ops
from . import conf
from . import optimize_scene
from . import tracking
from . import util
from . import world_tools
from .materials import material_manager
from .materials.generate import update_mcprep_texturepack_path
from .materials.skin import update_skin_path
from .spawner import effects
from .spawner import entities
from .spawner import mcmodel
from .spawner import meshswap
from .spawner import mobs
from .spawner import spawn_util
# from .import_bridge import bridge
# blender 2.7 vs 2.8 icon selections
LOAD_FACTORY = 'LOOP_BACK' if util.bv28() else 'LOAD_FACTORY'
HAND_ICON = 'FILE_REFRESH' if util.bv28() else 'HAND'
OPT_IN = 'URL' if util.bv28() else 'HAND'
SIMPLE_UI = []
# -----------------------------------------------------------------------------
# Above for class functions/operators
# Below for UI
# -----------------------------------------------------------------------------
class MCPREP_MT_mob_spawner(bpy.types.Menu):
"""Shift-A menu in the 3D view"""
bl_label = "Mob Spawner"
bl_idname = "MCPREP_MT_mob_spawner"
bl_description = "Menu for placing in the shift-A add object menu"
def draw(self, context):
layout = self.layout
scn_props = context.scene.mcprep_props
# if mobs not loaded yet
if not scn_props.mob_list_all:
row = layout.row()
row.operator(
"mcprep.reload_mobs", text="Load mobs", icon=HAND_ICON)
row.scale_y = 2
row.alignment = 'CENTER'
return
keys = sorted(scn_props.mob_list_all.keys())
for mobkey in keys:
# show icon if available
mob = scn_props.mob_list_all[mobkey]
icn = "mob-{}".format(mob.index)
if conf.use_icons and icn in conf.preview_collections["mobs"]:
ops = layout.operator(
"mcprep.mob_spawner",
text=mob.name,
icon_value=conf.preview_collections["mobs"][icn].icon_id)
elif conf.use_icons:
ops = layout.operator(
"mcprep.mob_spawner", text=mob.name, icon="BLANK1")
else:
ops = layout.operator("mcprep.mob_spawner", text=mob.name)
ops.mcmob_type = mob.mcmob_type
# Skip prep materials in case of unique shader.
if conf.json_data and mob.name in conf.json_data.get("mob_skip_prep", []):
ops.prep_materials = False
class MCPREP_MT_meshswap_place(bpy.types.Menu):
"""Menu for all the meshswap objects"""
bl_label = "Meshswap Objects"
bl_idname = "MCPREP_MT_meshswap_place"
def draw(self, context):
layout = self.layout
meshswap_blocks = meshswap.getMeshswapList(context)
if not meshswap_blocks:
layout.label(text="No meshswap blocks found!")
for blockset in meshswap_blocks:
# do some kind of check for if no blocks found
icn = "BLANK1"
if blockset[0].startswith("Group"):
icn = "GROUP"
opr = layout.operator(
"mcprep.meshswap_spawner",
text=blockset[1],
icon=icn
)
opr.block = blockset[0]
opr.location = util.get_cuser_location(context)
# Ensure meshswap with rigs is made real, so the rigs can be used.
if conf.json_data and blockset[1] in conf.json_data.get("make_real", []):
opr.make_real = True
class MCPREP_MT_item_spawn(bpy.types.Menu):
"""Menu for loaded item spawners"""
bl_label = "Item Spawner"
bl_idname = "MCPREP_MT_item_spawn"
def draw(self, context):
layout = self.layout
if not context.scene.mcprep_props.item_list:
layout.label(text="No items found!")
for item in context.scene.mcprep_props.item_list:
icn = "item-{}".format(item.index)
if conf.use_icons and icn in conf.preview_collections["items"]:
ops = layout.operator(
"mcprep.spawn_item", text=item.name,
icon_value=conf.preview_collections["items"][icn].icon_id)
elif conf.use_icons:
ops = layout.operator(
"mcprep.spawn_item", text=item.name, icon="BLANK1")
else:
ops = layout.operator("mcprep.spawn_item", text=item.name)
ops.filepath = item.path
class MCPREP_MT_effect_spawn(bpy.types.Menu):
"""Menu for loaded effect spawners"""
bl_label = "Effects Spawner"
bl_idname = "MCPREP_MT_effect_spawn"
def draw(self, context):
col = self.layout.column()
loc = util.get_cuser_location(context)
for effect in context.scene.mcprep_props.effects_list:
if effect.effect_type in (effects.GEO_AREA, effects.PARTICLE_AREA):
if effect.effect_type == effects.GEO_AREA:
icon = "NODETREE"
else:
icon = "PARTICLES"
ops = col.operator(
"mcprep.spawn_global_effect",
text=effect.name,
icon=icon)
ops.effect_id = str(effect.index)
elif effect.effect_type == effects.COLLECTION:
ops = col.operator(
"mcprep.spawn_instant_effect",
text=effect.name, icon=spawn_util.COLL_ICON)
ops.effect_id = str(effect.index)
ops.location = loc
ops.frame = context.scene.frame_current
elif effect.effect_type == effects.IMG_SEQ:
icon = "effects-{}".format(effect.index)
if conf.use_icons and icon in conf.preview_collections["effects"]:
ops = col.operator(
"mcprep.spawn_instant_effect",
text=effect.name,
icon_value=conf.preview_collections["effects"][icon].icon_id)
else:
ops = col.operator(
"mcprep.spawn_instant_effect",
text=effect.name,
icon="RENDER_RESULT")
ops.effect_id = str(effect.index)
ops.location = loc
ops.frame = context.scene.frame_current
class MCPREP_MT_entity_spawn(bpy.types.Menu):
"""Menu for loaded entity spawners"""
bl_label = "Entity Spawner"
bl_idname = "MCPREP_MT_entity_spawn"
def draw(self, context):
layout = self.layout
entity_list = entities.getEntityList(context)
if not entity_list:
layout.label(text="No entities found!")
for entity in entity_list:
# do some kind of check for if no entities found
icn = "BLANK1"
if entity[0].startswith("Group"):
icn = "GROUP"
opr = layout.operator(
"mcprep.entity_spawner",
text=entity[1],
icon=icn)
opr.entity = entity[0]
class MCPREP_MT_model_spawn(bpy.types.Menu):
"""Menu for loaded model spawners"""
bl_label = "Model Spawner"
bl_idname = "MCPREP_MT_model_spawn"
def draw(self, context):
layout = self.layout
if not util.bv28():
layout.label(text="Requires blender 2.8 or newer")
return
if not context.scene.mcprep_props.model_list:
layout.label(text="No models found!")
for model in context.scene.mcprep_props.model_list:
opr = layout.operator(
mcmodel.MCPREP_OT_spawn_minecraft_model.bl_idname,
text=model.name)
opr.filepath = model.filepath
opr.location = util.get_cuser_location(context)
class MCPREP_MT_3dview_add(bpy.types.Menu):
"""MCprep Shift-A menu for spawners"""
bl_label = "MCprep"
bl_idname = "MCPREP_MT_3dview_add"
def draw(self, context):
layout = self.layout
props = context.scene.mcprep_props
if conf.preview_collections["main"] != "":
spawner_icon = conf.preview_collections["main"].get("spawner_icon")
meshswap_icon = conf.preview_collections["main"].get("meshswap_icon")
sword_icon = conf.preview_collections["main"].get("sword_icon")
effects_icon = conf.preview_collections["main"].get("effects_icon")
entity_icon = conf.preview_collections["main"].get("entity_icon")
model_icon = conf.preview_collections["main"].get("model_icon")
else:
spawner_icon = None
meshswap_icon = None
sword_icon = None
effects_icon = None
entity_icon = None
model_icon = None
all_loaded = props.mob_list and props.meshswap_list and props.item_list
if not conf.loaded_all_spawners and not all_loaded:
row = layout.row()
row.operator(
"mcprep.reload_spawners", text="Load spawners", icon=HAND_ICON)
row.scale_y = 2
row.alignment = 'CENTER'
return
if spawner_icon is not None:
layout.menu(
MCPREP_MT_mob_spawner.bl_idname,
icon_value=spawner_icon.icon_id)
else:
layout.menu(MCPREP_MT_mob_spawner.bl_idname)
if model_icon is not None:
layout.menu(
MCPREP_MT_model_spawn.bl_idname, icon_value=model_icon.icon_id)
else:
layout.menu(MCPREP_MT_model_spawn.bl_idname)
if sword_icon is not None:
layout.menu(
MCPREP_MT_item_spawn.bl_idname, icon_value=sword_icon.icon_id)
else:
layout.menu(MCPREP_MT_item_spawn.bl_idname)
if effects_icon is not None:
layout.menu(
MCPREP_MT_effect_spawn.bl_idname, icon_value=effects_icon.icon_id)
else:
layout.menu(MCPREP_MT_effect_spawn.bl_idname)
if entity_icon is not None:
layout.menu(
MCPREP_MT_entity_spawn.bl_idname, icon_value=entity_icon.icon_id)
else:
layout.menu(MCPREP_MT_entity_spawn.bl_idname)
if meshswap_icon is not None:
layout.menu(
MCPREP_MT_meshswap_place.bl_idname,
icon_value=meshswap_icon.icon_id)
else:
layout.menu(MCPREP_MT_meshswap_place.bl_idname)
def mineways_update(self, context):
"""For updating the mineways path on OSX."""
if ".app/" in self.open_mineways_path:
# will run twice inherently
temp = self.open_mineways_path.split(".app/")[0]
self.open_mineways_path = temp + ".app"
def feature_set_update(self, context):
tracking.Tracker.feature_set = self.feature_set
tracking.trackUsage("feature_set", param=self.feature_set)
def get_unsimple_list(mcprep_add, skins, world_tools, spawner):
classes = []
if mcprep_add:
classes.append(MCPREP_MT_3dview_add)
if skins:
classes.append(MCPREP_PT_skins)
if world_tools:
classes.append(MCPREP_PT_world_tools)
if spawner:
spawn_classes = (
MCPREP_PT_spawn,
MCPREP_PT_mob_spawner,
MCPREP_PT_item_spawner,
MCPREP_PT_model_spawner,
MCPREP_PT_entity_spawner,
MCPREP_PT_effects_spawner,
MCPREP_PT_meshswap_spawner,
)
classes = classes + [cls for cls in spawn_classes]
return classes
def simple_class_reregister(mcprep_add, skins, world_tools, spawner):
global SIMPLE_UI
if not mcprep_add:
if MCPREP_MT_3dview_add in SIMPLE_UI:
bpy.utils.register_class(MCPREP_MT_3dview_add)
SIMPLE_UI.remove(MCPREP_MT_3dview_add)
if not skins:
if MCPREP_PT_skins in SIMPLE_UI:
bpy.utils.register_class(MCPREP_PT_skins)
SIMPLE_UI.remove(MCPREP_PT_skins)
if not world_tools:
if MCPREP_PT_world_tools in SIMPLE_UI:
bpy.utils.register_class(MCPREP_PT_world_tools)
SIMPLE_UI.remove(MCPREP_PT_world_tools)
if not spawner:
spawn_classes = (
MCPREP_PT_spawn,
MCPREP_PT_mob_spawner,
MCPREP_PT_item_spawner,
MCPREP_PT_model_spawner,
MCPREP_PT_entity_spawner,
MCPREP_PT_effects_spawner,
MCPREP_PT_meshswap_spawner,
)
# Only get the classes that are in the SIMPLE_UI variable
rereg_classes = [cls for cls in spawn_classes if cls in SIMPLE_UI]
for cls in rereg_classes:
bpy.utils.register_class(cls)
SIMPLE_UI.remove(cls)
def simple_prep_func(self, context):
global SIMPLE_UI
if self.simple_prep:
unsimple_list = get_unsimple_list(self.simple_prep_remove_mcprep_add,
self.simple_prep_remove_skins,
self.simple_prep_remove_world_tools,
self.simple_prep_remove_spawner)
# Remove classes that are already in SIMPLE_UI
unsimple_list = [cls for cls in unsimple_list if cls not in SIMPLE_UI]
for cls in unsimple_list:
bpy.utils.unregister_class(cls)
# Reregister classes
simple_class_reregister(self.simple_prep_remove_mcprep_add,
self.simple_prep_remove_skins,
self.simple_prep_remove_world_tools,
self.simple_prep_remove_spawner)
else:
# Check to make sure we have classes in this list as to avoid unregistering already unregistered classes
if len(SIMPLE_UI) > 0:
for cls in SIMPLE_UI:
bpy.utils.register_class(cls)
SIMPLE_UI = []
class McprepPreference(bpy.types.AddonPreferences):
bl_idname = __package__
scriptdir = bpy.path.abspath(os.path.dirname(__file__))
def change_verbose(self, context):
conf.v = self.verbose
"""
SimplePrep Options
"""
simple_prep = bpy.props.BoolProperty(
name="SimplePrep",
description="Strips the MCprep UI to the bare minimum",
default=False,
update=simple_prep_func,
)
simple_prep_remove_spawner = bpy.props.BoolProperty(
name="Remove Spawn Panel",
description="Removes the spawn panel",
default=True,
update=simple_prep_func
)
simple_prep_remove_mcprep_add = bpy.props.BoolProperty(
name="Remove MCprep Shift+A panel",
description="Removes the MCprep part of the Shift+A menu",
default=True,
update=simple_prep_func
)
simple_prep_remove_skins = bpy.props.BoolProperty(
name="Remove Skins Panel",
description="Removes skin panel",
default=True,
update=simple_prep_func
)
simple_prep_remove_world_tools = bpy.props.BoolProperty(
name="Remove World Tools",
description="Removes world tools panel",
default=True,
update=simple_prep_func
)
"""
Everything Else
"""
meshswap_path = bpy.props.StringProperty(
name="Meshswap path",
description=(
"Default path to the meshswap asset file, for "
"meshswapable objects and groups"),
subtype='FILE_PATH',
default=scriptdir + "/MCprep_resources/mcprep_meshSwap.blend")
entity_path = bpy.props.StringProperty(
name="Entity path",
description="Default path to the entity asset file, for entities",
subtype='FILE_PATH',
default=os.path.join(scriptdir, "MCprep_resources", "mcprep_entities.blend"))
mob_path = bpy.props.StringProperty(
name="Mob path",
description="Default folder for rig loads/spawns in new blender instances",
subtype='DIR_PATH',
default=scriptdir + "/MCprep_resources/rigs/")
custom_texturepack_path = bpy.props.StringProperty(
name="Texture pack path",
description=(
"Path to a folder containing resources and textures to use "
"with material prepping"),
subtype='DIR_PATH',
default=scriptdir + "/MCprep_resources/resourcepacks/mcprep_default/")
skin_path = bpy.props.StringProperty(
name="Skin path",
description="Folder for skin textures, used in skin swapping",
subtype='DIR_PATH',
default=scriptdir + "/MCprep_resources/skins/")
effects_path = bpy.props.StringProperty(
name="Effects path",
description="Folder for effects blend files and assets",
subtype='DIR_PATH',
default=scriptdir + "/MCprep_resources/effects/")
world_obj_path = bpy.props.StringProperty(
name="World Folder",
description=(
"Default folder for opening world objs from programs "
"like jmc2obj or Mineways"),
subtype='DIR_PATH',
default="//")
MCprep_groupAppendLayer = bpy.props.IntProperty(
name="Group Append Layer",
description=(
"When groups are appended instead of linked, "
"the objects part of the group will be placed in this "
"layer, 0 means same as active layer"),
min=0,
max=20,
default=20)
MCprep_exporter_type = bpy.props.EnumProperty(
items=[
('(choose)', '(choose)', 'Select your exporter'),
('jmc2obj', 'jmc2obj', 'Select if exporter used was jmc2obj'),
('Mineways', 'Mineways', 'Select if exporter used was Mineways')],
name="Exporter")
preferences_tab = bpy.props.EnumProperty(
items=[
('settings', 'Settings', 'Change MCprep settings'),
('tutorials', 'Tutorials', 'View MCprep tutorials & other help'),
('tracker_updater', 'Tracking/Updater',
'Change tracking and updating settings')],
name="Exporter")
verbose = bpy.props.BoolProperty(
name="Verbose logging",
description="Print out more information in the console",
default=False,
update=change_verbose)
open_jmc2obj_path = bpy.props.StringProperty(
name="jmc2obj path",
description="Path to the jmc2obj executable",
subtype='FILE_PATH',
default="jmc2obj.jar")
open_mineways_path = bpy.props.StringProperty(
name="Mineways path",
description="Path to the Mineways executable",
subtype='FILE_PATH',
update=mineways_update,
default="Mineways")
save_folder = bpy.props.StringProperty(
name="MC saves folder",
description=(
"Folder containing Minecraft world saves directories, "
"for the direct import bridge"),
subtype='FILE_PATH',
default='')
feature_set = bpy.props.EnumProperty(
items=[
('supported', 'Supported', 'Use only supported features'),
('experimental', 'Experimental', 'Enable experimental features')],
name="Feature set",
update=feature_set_update)
# addon updater preferences
auto_check_update = bpy.props.BoolProperty(
name="Auto-check for Update",
description="If enabled, auto-check for updates using an interval",
default=True,
)
updater_interval_months = bpy.props.IntProperty(
name='Months',
description="Number of months between checking for updates",
default=0,
min=0
)
updater_interval_days = bpy.props.IntProperty(
name='Days',
description="Number of days between checking for updates",
default=1,
min=0,
)
updater_interval_hours = bpy.props.IntProperty(
name='Hours',
description="Number of hours between checking for updates",
default=0,
min=0,
max=23
)
updater_interval_minutes = bpy.props.IntProperty(
name='Minutes',
description="Number of minutes between checking for updates",
default=0,
min=0,
max=59
)
def draw(self, context):
layout = self.layout
row = layout.row()
row.prop(self, "preferences_tab", expand=True)
factor_width = 0.3
if util.bv28():
factor_width = 0.3
if self.preferences_tab == "settings":
row = layout.row()
row.scale_y = 0.7
row.label(text="World Importing & Meshswapping")
box = layout.box()
split = util.layout_split(box, factor=factor_width)
col = split.column()
col.label(text="Default Exporter:")
col = split.column()
col.prop(self, "MCprep_exporter_type", text="")
split = util.layout_split(box, factor=factor_width)
col = split.column()
col.label(text="jmc2obj executable")
col = split.column()
col.prop(self, "open_jmc2obj_path", text="")
split = util.layout_split(box, factor=factor_width)
col = split.column()
col.label(text="Mineways executable")
col = split.column()
col.prop(self, "open_mineways_path", text="")
split = util.layout_split(box, factor=factor_width)
col = split.column()
col.label(text="World OBJ Exports Folder")
col = split.column()
col.prop(self, "world_obj_path", text="")
split = util.layout_split(box, factor=factor_width)
col = split.column()
col.label(text="Meshwap assets")
col = split.column()
col.prop(self, "meshswap_path", text="")
if not os.path.isfile(bpy.path.abspath(self.meshswap_path)):
row = box.row()
row.label(text="MeshSwap file not found", icon="ERROR")
split = util.layout_split(box, factor=factor_width)
col = split.column()
col.label(text="Entity assets")
col = split.column()
col.prop(self, "entity_path", text="")
if not os.path.isfile(bpy.path.abspath(self.entity_path)):
row = box.row()
row.label(text="Entity file not found", icon="ERROR")
col = split.column()
col.prop(self, "effects_path", text="")
if not os.path.isdir(bpy.path.abspath(self.effects_path)):
row = box.row()
row.label(text="Effects folder not found", icon="ERROR")
row = layout.row()
row.scale_y = 0.7
row.label(text="Texture / Resource packs")
box = layout.box()
split = util.layout_split(box, factor=factor_width)
col = split.column()
col.label(text="Texture pack folder")
col = split.column()
col.prop(self, "custom_texturepack_path", text="")
split = util.layout_split(box, factor=factor_width)
col = split.column()
col.label(text="Install to folder")
# col = split.column()
# col.operator("mcprep.skin_swapper", text="Install resource pack")
col = split.column()
p = col.operator("mcprep.openfolder", text="Open texture pack folder")
p.folder = self.custom_texturepack_path
row = layout.row()
row.scale_y = 0.7
row.label(text="Mob spawning")
box = layout.box()
split = util.layout_split(box, factor=factor_width)
col = split.column()
col.label(text="Rig Folder")
col = split.column()
col.prop(self, "mob_path", text="")
split = util.layout_split(box, factor=factor_width)
col = split.column()
col.label(text="Select/install mobs")
col = split.column()
col.operator(
"mcprep.mob_install_menu", text="Install file for mob spawning")
col = split.column()
p = col.operator("mcprep.openfolder", text="Open rig folder")
p.folder = self.mob_path
row = layout.row()
row.scale_y = 0.7
row.label(text="Skin swapping")
box = layout.box()
split = util.layout_split(box, factor=factor_width)
col = split.column()
col.label(text="Skin Folder")
col = split.column()
col.prop(self, "skin_path", text="")
split = util.layout_split(box, factor=factor_width)
col = split.column()
col.label(text="Install skins")
col = split.column()
col.operator("mcprep.add_skin", text="Install skin file for swapping")
col = split.column()
p = col.operator("mcprep.openfolder", text="Open skin folder")
p.folder = self.skin_path
row = layout.row()
row.scale_y = 0.7
row.label(text="Effects")
box = layout.box()
split = util.layout_split(box, factor=factor_width)
col = split.column()
col.label(text="Effect folder")
col = split.column()
col.prop(self, "effects_path", text="")
split = util.layout_split(box, factor=factor_width)
col = split.column()
col = split.column()
p = col.operator("mcprep.openfolder", text="Open effects folder")
p.folder = self.effects_path
# misc settings
row = layout.row()
row.prop(self, "verbose")
row.prop(self, "feature_set")
row = layout.row()
row.prop(self, "simple_prep")
if self.simple_prep:
box = layout.box()
box.prop(self, "simple_prep_remove_mcprep_add")
box.prop(self, "simple_prep_remove_skins")
box.prop(self, "simple_prep_remove_world_tools")
box.prop(self, "simple_prep_remove_spawner")
if self.feature_set != "supported":
row = layout.row()
box = row.box()
box.scale_y = 0.7
box.label(text="Using MCprep in experimental mode!", icon="ERROR")
box.label(text="Early access features and requests for feedback")
box.label(text="will be made visible. Thank you for contributing.")
elif self.preferences_tab == "tutorials":
layout.label(
text="Unsure on how to use the addon? Check out these resources")
row = layout.row()
row.scale_y = 2
row.operator(
"wm.url_open",
text="MCprep page for instructions and updates",
icon="WORLD"
).url = "https://theduckcow.com/dev/blender/mcprep/"
row = layout.row()
row.scale_y = 2
row.operator(
"wm.url_open",
text="Learn MCprep + Blender, 1-minute tutorials",
icon="FILE_MOVIE"
).url = "https://bit.ly/MCprepTutorials"
row = layout.row()
row.scale_y = 1.5
row.operator(
"wm.url_open", text="Import Minecraft worlds"
).url = "https://theduckcow.com/dev/blender/mcprep/mcprep-minecraft-world-imports/"
row.operator(
"wm.url_open", text="Mob (rig) spawning"
).url = "https://theduckcow.com/dev/blender/mcprep/mcprep-spawner/"
row.operator(
"wm.url_open", text="Skin swapping"
).url = "https://theduckcow.com/dev/blender/mcprep/skin-swapping/"
row = layout.row()
row.scale_y = 1.5
row.operator(
"wm.url_open", text="jmc2obj/Mineways"
).url = "https://theduckcow.com/dev/blender/mcprep/setup-world-exporters/"
row.operator(
"wm.url_open", text="World Tools"
).url = "https://theduckcow.com/dev/blender/mcprep/world-tools/"
row.operator(
"wm.url_open", text="Tutorial Series"
).url = "https://bit.ly/MCprepTutorials"
elif self.preferences_tab == "tracker_updater":
layout = self.layout
row = layout.row()
box = row.box()
brow = box.row()
brow.label(text="Anonymous user tracking settings")
brow = box.row()
bcol = brow.column()
bcol.scale_y = 2
if tracking.Tracker.tracking_enabled is False:
bcol.operator(
"mcprep.toggle_enable_tracking",
text="Opt into anonymous usage tracking",
icon=OPT_IN)
else:
bcol.operator(
"mcprep.toggle_enable_tracking",
text="Opt OUT of anonymous usage tracking",
icon="CANCEL")
bcol = brow.column()
bcol.label(text="For info on anonymous usage tracking:")
brow = box.row()
bcol.operator(
"wm.url_open", text="Open the Privacy Policy"
).url = "https://theduckcow.com/privacy-policy"
# updater draw function
addon_updater_ops.update_settings_ui(self, context)
if not util.bv28():
layout.label(text="Don't forget to save user preferences!")
class MCPREP_PT_world_imports(bpy.types.Panel):
"""World importing related settings and tools"""
bl_label = "World Imports"
bl_space_type = 'VIEW_3D'
bl_region_type = 'TOOLS' if not util.bv28() else 'UI'
# bl_context = "objectmode"
bl_category = "MCprep"
def draw(self, context):
addon_prefs = util.get_user_preferences(context)
scn_props = context.scene.mcprep_props
# check for update in background thread if appropraite
addon_updater_ops.check_for_update_background()
layout = self.layout
split = layout.split()
col = split.column(align=True)
row = col.row()
row.label(text="World exporter")
row.operator(
"mcprep.open_help", text="", icon="QUESTION", emboss=False
).url = "https://theduckcow.com/dev/blender/mcprep/mcprep-minecraft-world-imports/"
split = layout.split()
col = split.column(align=True)
row = col.row(align=True)
row.prop(addon_prefs, "MCprep_exporter_type", expand=True)
row = col.row(align=True)
if addon_prefs.MCprep_exporter_type == "(choose)":
row.operator(
"mcprep.open_jmc2obj", text="Select exporter!", icon='ERROR')
row.enabled = False
elif addon_prefs.MCprep_exporter_type == "Mineways":
row.operator("mcprep.open_mineways")
else:
row.operator("mcprep.open_jmc2obj")
wpath = addon_prefs.world_obj_path
if util.bv28():
# custom operator for splitting via mats after importing
col.operator(
"mcprep.import_world_split",
text="OBJ world import").filepath = wpath
else:
col.operator(
"import_scene.obj", text="OBJ world import").filepath = wpath
split = layout.split()
col = split.column(align=True)
col.label(text="MCprep tools")
col.operator("mcprep.prep_materials", text="Prep Materials")
p = col.operator("mcprep.swap_texture_pack")
p.filepath = context.scene.mcprep_texturepack_path
if context.mode == "OBJECT":
col.operator("mcprep.meshswap", text="Mesh Swap")
if addon_prefs.MCprep_exporter_type == "(choose)":
col.label(text="Select exporter!", icon='ERROR')
if context.mode == 'EDIT_MESH':
col.operator("mcprep.scale_uv")
col.operator("mcprep.select_alpha_faces")
split = layout.split()
col = split.column(align=True)
# Indicate whether UI can be improved or not.
view27 = ['TEXTURED', 'MATEIRAL', 'RENDERED']
view28 = ['SOLID', 'MATERIAL', 'RENDERED']
improved_27 = not util.bv28()
if improved_27:
improved_27 &= util.viewport_textured(context) is True
improved_27 &= context.space_data.viewport_shade in view27
improved_27 &= util.get_preferences(context).system.use_mipmaps is False
improved_28 = util.bv28()
if improved_28:
improved_28 &= util.viewport_textured(context) is True
improved_28 &= context.scene.display.shading.type in view28
improved_28 &= context.scene.display.shading.background_type == "WORLD"
if improved_27 or improved_28:
row = col.row(align=True)
row.enabled = False
row.operator(
"mcprep.improve_ui",
text="(UI already improved)", icon='SETTINGS')
else:
col.operator(
"mcprep.improve_ui", text="Improve UI", icon='SETTINGS')
# Optimizer Panel.
row = col.row(align=True)
icon = "TRIA_DOWN" if scn_props.show_settings_optimizer else "TRIA_RIGHT"
row.prop(
scn_props, "show_settings_optimizer",
text="Cycles Optimizer", icon=icon)
if scn_props.show_settings_optimizer:
row = col.row(align=True)
optimize_scene.panel_draw(context, row)
# Advanced settings.
row = col.row(align=True)
if not scn_props.show_settings_material:
row.prop(
scn_props, "show_settings_material",
text="Advanced", icon="TRIA_RIGHT")
row.operator(
"mcprep.open_preferences",
text="", icon="PREFERENCES").tab = "settings"
else:
row.prop(
scn_props, "show_settings_material",
text="Advanced", icon="TRIA_DOWN")
row.operator(
"mcprep.open_preferences",
text="", icon="PREFERENCES").tab = "settings"
box = col.box()
b_row = box.row()
b_col = b_row.column(align=False)
b_col.label(text="Texture pack folder")
row = b_col.row(align=True)
row.prop(context.scene, "mcprep_texturepack_path", text="")
row.operator("mcprep.reset_texture_path", text="", icon=LOAD_FACTORY)
b_row = box.row()
b_col = b_row.column(align=True)
b_col.operator("mcprep.sync_materials")
b_col.operator("mcprep.replace_missing_textures")
b_col.operator("mcprep.animate_textures")
# TODO: operator to make all local, all packed, or set to other location
b_col.operator(
"mcprep.combine_materials",
text="Combine Materials").selection_only = True
if bpy.app.version > (2, 77):
b_col.operator("mcprep.combine_images", text="Combine Images")
b_col.label(text="Meshswap source:")
subrow = b_col.row(align=True)
subrow.prop(context.scene, "meshswap_path", text="")
subrow.operator(
"mcprep.meshswap_path_reset", icon=LOAD_FACTORY, text="")
if not context.scene.meshswap_path.lower().endswith('.blend'):
b_col.label(text="MeshSwap file must be .blend", icon="ERROR")
if not os.path.isfile(bpy.path.abspath(context.scene.meshswap_path)):
b_col.label(text="MeshSwap file not found", icon="ERROR")
layout = self.layout # clear out the box formatting
split = layout.split()
row = split.row(align=True)
# show update ready if available
addon_updater_ops.update_notice_box_ui(self, context)
class MCPREP_PT_bridge(bpy.types.Panel):
"""MCprep panel for directly importing and reloading minecraft saves"""
bl_label = "World Bridge"
bl_space_type = "VIEW_3D"
bl_region_type = 'TOOLS' if not util.bv28() else 'UI'
bl_context = "objectmode"
bl_category = "MCprep"
def draw(self, context):
# bridge.panel_draw(self, context)
pass
class MCPREP_PT_world_tools(bpy.types.Panel):
"""World settings and tools"""
bl_label = "World Tools"
bl_space_type = 'VIEW_3D'
bl_region_type = 'TOOLS' if not util.bv28() else 'UI'
bl_category = "MCprep"
def draw(self, context):
layout = self.layout
rw = layout.row()
col = rw.column()
row = col.row(align=True)
row.label(text="World settings and lighting") # world time
row.operator(
"mcprep.open_help", text="", icon="QUESTION", emboss=False
).url = "https://theduckcow.com/dev/blender/mcprep/world-tools/"
rw = layout.row()
col = rw.column(align=True)
col.operator("mcprep.add_mc_sky")
col.operator("mcprep.world")
col.operator("mcprep.render_panorama")
layout.split()
rw = layout.row()
col = rw.column(align=True)
obj = world_tools.get_time_object()
col.label(text="Time of day")
if obj and "MCprepHour" in obj:
time = obj["MCprepHour"]