-
Notifications
You must be signed in to change notification settings - Fork 26
/
default_init.py
129 lines (106 loc) · 3.82 KB
/
default_init.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
# This script is executed when the omegalib python interpreter (orun) starts,
# before running application scripts.
# It sets up a system menu with several config options for sound, navigation,
# graphics etc. If you want to change (or remove) the default menu, use the
# orun/initScript config option to specify a new or an empty script.
# You can also change the orun/appStartFunction config option to change the
# entry point into this script (by default it is set to _onAppStart)
orun('system/quickCommands.py')
speedLabel = None
mainmnu = None
# add the current path to the data search paths.
import os
addDataPath(os.getcwd())
def _setCamSpeed(speedLevel):
global speedLabel
s = 10 ** (speedLevel - 4)
speedLabel.setText("Navigation Speed: " + str(s) + "x")
cc = getDefaultCamera().getController()
if(cc != None):
cc.setSpeed(s)
def _autonearfar(value):
if(value):
queueCommand(":autonearfar on")
else:
queueCommand(":autonearfar off")
def _displayWand(value):
if(value):
queueCommand("getSceneManager().displayWand(0, 1)")
else:
queueCommand("getSceneManager().hideWand(0)")
def _setSoundServerVolume( value ):
newVolume = value - 30
globalVolumeLabel.setText("Global Volume: " + str(newVolume) )
soundEnv.setServerVolume(newVolume)
def _onAppStart():
global mainmnu
# mm = getViewer().getMenuManager()
mm = MenuManager.createAndInitialize()
mainmnu = mm.createMenu("Main Menu")
# If menus are in 2d mode, add a menu open button
# Disabled, just press middle mouse to enable the system
# menu anywhere..
# if(not getBoolSetting('config/ui', 'menu3dEnabled', False)):
# uim = UiModule.instance()
# wf = uim.getWidgetFactory()
# mainButton = wf.createButton('mainButton', uim.getUi())
# mainButton.setText("Main Menu")
# mainButton.setUIEventCommand('mainmnu.show()')
# mainButton.setStyleValue('fill', 'black')
# mainmnu.getContainer().setPosition(Vector2(5, 25))
mi = mainmnu.addImage(loadImage("omegalib-transparent-white.png"))
ics = mi.getImage().getSize() * 0.1
mi.getImage().setSize(ics)
mm.setMainMenu(mainmnu)
sysmnu = mainmnu.addSubMenu("System")
mi = sysmnu.addButton("Toggle freefly", ":freefly")
mi.getButton().setCheckable(True)
mi = sysmnu.addButton("Reset", ":rc")
mi = sysmnu.addButton("Auto Near / Far", "_autonearfar(%value%)")
mi.getButton().setCheckable(True)
mi = sysmnu.addButton("Display Wand", "_displayWand(%value%)")
mi.getButton().setCheckable(True)
global speedLabel
speedLabel = sysmnu.addLabel("sd")
_setCamSpeed(4)
ss = sysmnu.addSlider(10, "_setCamSpeed(%value%)")
ss.getSlider().setValue(4)
ss.getWidget().setWidth(200)
if( isSoundEnabled() ):
global soundEnv
global serverVolume
global globalVolumeLabel
soundEnv = getSoundEnvironment()
serverVolume = soundEnv.getServerVolume();
globalVolumeLabel = sysmnu.addLabel("Global Volume: --")
value = serverVolume + 30
globalVolumeLabel.setText("Global Volume: " + str(serverVolume))
ss = sysmnu.addSlider(39, "_setSoundServerVolume(%value%)")
ss.getSlider().setValue(30)
ss.getWidget().setWidth(200)
ss.getSlider().setValue(value)
mi = sysmnu.addButton("Enable Stereo", "toggleStereo()")
mi.getButton().setCheckable(True)
mi.getButton().setChecked(isStereoEnabled())
mi = sysmnu.addButton("Toggle Console", ":c")
mi = sysmnu.addButton("List Active Modules", "printModules()")
mi = sysmnu.addButton("Exit omegalib", "_shutdown()")
shuttingDown = False
fadeOutVal = 0
def _shutdown():
global shuttingDown
global fadeOutVal
shuttingDown = True
fadeOutVal = 0
def onUpdate(frame, t, dt):
global shuttingDown
global fadeOutVal
if(shuttingDown):
if(fadeOutVal >= 1): oexit()
else:
uim = UiModule.instance()
ui = uim.getUi()
alpha = int(fadeOutVal * 256)
ui.setStyleValue('fill', '#000000' + hex(alpha)[2:])
fadeOutVal += dt
setUpdateFunction(onUpdate)