Mercurial > fife-parpg
annotate clients/editor/plugins/LightEdit.py @ 354:dfd48d49c044
* Removed shebang and svn:executable for python files which are not meant to be executed directly
* Made sure all executable files with shebang has svn:executable
author | cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222 |
---|---|
date | Mon, 21 Sep 2009 19:48:00 +0000 |
parents | 22253b2c9b14 |
children | ad5818097cd6 |
rev | line source |
---|---|
307
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
1 # coding: utf-8 |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
2 # ################################################### |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
3 # Copyright (C) 2008 The Zero-Projekt team |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
4 # http://zero-projekt.net |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
5 # info@zero-projekt.net |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
6 # This file is part of Zero "Was vom Morgen blieb" |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
7 # |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
8 # The Zero-Projekt codebase is free software; you can redistribute it and/or modify |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
9 # it under the terms of the GNU General Public License as published by |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
10 # the Free Software Foundation; either version 2 of the License, or |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
11 # (at your option) any later version. |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
12 # |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
13 # This program is distributed in the hope that it will be useful, |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
16 # GNU General Public License for more details. |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
17 # |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
18 # You should have received a copy of the GNU General Public License |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
19 # along with this program; if not, write to the |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
20 # Free Software Foundation, Inc., |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
21 # 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
22 # ################################################### |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
23 |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
24 """ a tool for FIFEdit to test global light """ |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
25 |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
26 import fife |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
27 import pychan |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
28 import pychan.widgets as widgets |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
29 from pychan.tools import callbackWithArguments as cbwa |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
30 |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
31 from fife_timer import Timer |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
32 |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
33 import scripts |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
34 import scripts.plugin as plugin |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
35 from scripts.events import * |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
36 from scripts.gui.action import Action |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
37 |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
38 import random |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
39 |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
40 DEFAULT_GLOBAL_LIGHT = { |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
41 "R" : 1.0, |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
42 "G" : 1.0, |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
43 "B" : 1.0, |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
44 "A" : 1.0, |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
45 } |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
46 DEFAULT_LIGHT_ID = "LightEdit" |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
47 |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
48 class LightEdit(plugin.Plugin): |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
49 """ The B{LightEdit} module is a plugin for FIFedit and allows to change the |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
50 global light value |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
51 |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
52 FEATURES: |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
53 - enable FIFE lighting renderer |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
54 - generate random light values |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
55 - test lightsetups by manipulating the color channels |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
56 - reset to default |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
57 """ |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
58 def __init__(self): |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
59 self.active = False |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
60 |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
61 self._renderer = None |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
62 self._camera = None |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
63 self._enabled = False |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
64 self._light = False |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
65 |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
66 self.map_loaded = False |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
67 |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
68 self._color = {} |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
69 self._color.update(DEFAULT_GLOBAL_LIGHT) |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
70 |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
71 random.seed() |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
72 |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
73 if "LightRenderer" in dir(fife): |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
74 self._renderer_available = True |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
75 else: |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
76 self._renderer_available = False |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
77 |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
78 def _reset(self): |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
79 """ resets all dynamic vars """ |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
80 pass |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
81 |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
82 def enable(self): |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
83 """ plugin method """ |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
84 if not self._renderer_available: |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
85 self._enabled = False |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
86 return |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
87 if self._enabled is True: |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
88 return |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
89 |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
90 self._editor = scripts.editor.getEditor() |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
91 self.engine = self._editor.getEngine() |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
92 |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
93 self._showAction = Action(unicode(self.getName(),"utf-8"), checkable=True) |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
94 scripts.gui.action.activated.connect(self.toggle_gui, sender=self._showAction) |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
95 |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
96 self._editor._toolsMenu.addAction(self._showAction) |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
97 |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
98 events.postMapShown.connect(self.update_renderer) |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
99 events.onMapChanged.connect(self.update_renderer) |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
100 |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
101 self._reset() |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
102 self.create_gui() |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
103 |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
104 def disable(self): |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
105 """ plugin method """ |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
106 if self._enabled is False: |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
107 return |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
108 |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
109 self._reset() |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
110 self.container.hide() |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
111 self.removeAllChildren() |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
112 |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
113 self._editor._toolsMenu.removeAction(self._showAction) |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
114 |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
115 events.postMapShown.disconnect(self.update_renderer) |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
116 events.onMapChanged.disconnect(self.update_renderer) |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
117 |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
118 def isEnabled(self): |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
119 """ plugin method """ |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
120 return self._enabled; |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
121 |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
122 def getName(self): |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
123 """ plugin method """ |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
124 return "Light editor" |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
125 |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
126 def create_gui(self): |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
127 """ create gui container and setup callbacks """ |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
128 self.container = pychan.loadXML('gui/lightedit.xml') |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
129 self.container.mapEvents({ |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
130 "enable_global_light" : self.toggle_light, |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
131 "random_global_light" : self.random_color, |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
132 "reset_global_light" : self.reset_global_light, |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
133 |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
134 "increase_R" : cbwa(self.increase_color, r=True), |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
135 "decrease_R" : cbwa(self.decrease_color, r=True), |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
136 "value_R/mouseWheelMovedUp" : cbwa(self.increase_color, step=0.2, r=True), |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
137 "value_R/mouseWheelMovedDown" : cbwa(self.decrease_color, step=0.2, r=True), |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
138 |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
139 "increase_G" : cbwa(self.increase_color, g=True), |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
140 "decrease_G" : cbwa(self.decrease_color, g=True), |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
141 "value_G/mouseWheelMovedUp" : cbwa(self.increase_color, step=0.2, g=True), |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
142 "value_G/mouseWheelMovedDown" : cbwa(self.decrease_color, step=0.2, g=True), |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
143 |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
144 "increase_B" : cbwa(self.increase_color, b=True), |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
145 "decrease_B" : cbwa(self.decrease_color, b=True), |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
146 "value_B/mouseWheelMovedUp" : cbwa(self.increase_color, step=0.2, b=True), |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
147 "value_B/mouseWheelMovedDown" : cbwa(self.decrease_color, step=0.2, b=True), |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
148 |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
149 "increase_A" : cbwa(self.increase_color, a=True), |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
150 "decrease_A" : cbwa(self.decrease_color, a=True), |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
151 "value_A/mouseWheelMovedUp" : cbwa(self.increase_color, step=0.2, a=True), |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
152 "value_A/mouseWheelMovedDown" : cbwa(self.decrease_color, step=0.2, a=True), |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
153 }) |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
154 self._widgets = { |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
155 "enable_global_light" : self.container.findChild(name="enable_global_light"), |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
156 "random_global_light" : self.container.findChild(name="random_global_light"), |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
157 "reset_global_light" : self.container.findChild(name="reset_global_light"), |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
158 |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
159 "value_R" : self.container.findChild(name="value_R"), |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
160 "value_G" : self.container.findChild(name="value_G"), |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
161 "value_B" : self.container.findChild(name="value_B"), |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
162 "value_A" : self.container.findChild(name="value_A"), |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
163 } |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
164 |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
165 def toggle_gui(self): |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
166 """ show / hide the gui """ |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
167 if self.active: |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
168 self.active = False |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
169 if self.container.isVisible() or self.container.isDocked(): |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
170 self.container.setDocked(False) |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
171 self.container.hide() |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
172 self._showAction.setChecked(False) |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
173 else: |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
174 self.active = True |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
175 self._showAction.setChecked(True) |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
176 self.container.show() |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
177 |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
178 def toggle_light(self): |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
179 """ toggle light on / off """ |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
180 if not self._renderer: |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
181 self._widgets['enable_global_light']._setToggled(False) |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
182 return |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
183 |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
184 if self._light: |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
185 self._light = False |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
186 self.reset_global_light() |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
187 self._renderer.setEnabled(False) |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
188 else: |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
189 self._light = True |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
190 self._renderer.setEnabled(True) |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
191 |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
192 def update_renderer(self): |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
193 """ sets current camera and renderer |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
194 bound to FIFedit core (updated on map change) |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
195 """ |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
196 self._camera = self._editor.getActiveMapView().getCamera() |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
197 self._renderer = fife.LightRenderer.getInstance(self._camera) |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
198 |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
199 def update_gui(self): |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
200 """ update gui widgets according to plugin data """ |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
201 self._widgets["value_R"].text = unicode(str(self._color["R"])) |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
202 self._widgets["value_G"].text = unicode(str(self._color["G"])) |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
203 self._widgets["value_B"].text = unicode(str(self._color["B"])) |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
204 self._widgets["value_A"].text = unicode(str(self._color["A"])) |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
205 |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
206 def reset_global_light(self): |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
207 """ reset global light to default values (1.0) """ |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
208 if not self._renderer: return |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
209 |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
210 self._color.update(DEFAULT_GLOBAL_LIGHT) |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
211 self.update_gui() |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
212 self.set_global_light() |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
213 |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
214 def increase_color(self, step=0.1, r=None, g=None, b=None, a=None): |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
215 """ increase a given color value by step value |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
216 |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
217 @type step float |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
218 @param step the step for changing the color channel |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
219 @type r bool |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
220 @param r flag to alter red color value |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
221 @type g bool |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
222 @param g flag to alter green color value |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
223 @type b bool |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
224 @param b flag to alter blue color value |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
225 @type a bool |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
226 @type a flag to alter alpha channel value (no effect atm) |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
227 """ |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
228 if r: |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
229 self._color["R"] += step |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
230 if g: |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
231 self._color["G"] += step |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
232 if b: |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
233 self._color["B"] += step |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
234 if a: |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
235 self._color["A"] += step |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
236 |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
237 self.update_gui() |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
238 self.set_global_light() |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
239 |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
240 def decrease_color(self, step=0.1, r=None, g=None, b=None, a=None): |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
241 """ decrease a given color value by step value |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
242 |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
243 @type step float |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
244 @param step the step for changing the color channel |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
245 @type r bool |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
246 @param r flag to alter red color value |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
247 @type g bool |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
248 @param g flag to alter green color value |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
249 @type b bool |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
250 @param b flag to alter blue color value |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
251 @type a bool |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
252 @type a flag to alter alpha channel value (no effect atm) |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
253 """ |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
254 if r: |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
255 self._color["R"] -= step |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
256 if g: |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
257 self._color["G"] -= step |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
258 if b: |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
259 self._color["B"] -= step |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
260 if a: |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
261 self._color["A"] -= step |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
262 |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
263 self.update_gui() |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
264 self.set_global_light() |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
265 |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
266 def random_color(self): |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
267 """ generate random values for color channels """ |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
268 if not self._renderer: return |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
269 |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
270 self._color["R"] = random.uniform(0,2) |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
271 self._color["G"] = random.uniform(0,2) |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
272 self._color["B"] = random.uniform(0,2) |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
273 self._color["A"] = random.uniform(0,2) |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
274 |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
275 self.update_gui() |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
276 self.set_global_light() |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
277 |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
278 def set_global_light(self): |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
279 """ update the global light with the current set colors """ |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
280 if not self._renderer: return |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
281 |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
282 self._renderer.removeAll(DEFAULT_LIGHT_ID) |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
283 self._renderer.setglobalLight( |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
284 DEFAULT_LIGHT_ID, |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
285 1, |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
286 self._color["R"], |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
287 self._color["G"], |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
288 self._color["B"], |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
289 self._color["A"] |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
290 ) |
22253b2c9b14
- added LightEdit editor plugin (needs light branch to work; deactivated if lighting renderer is not available)
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
291 |