diff --git a/editor/basic_toolbar.py b/editor/basic_toolbar.py
index bf8e610..5ceb4af 100644
--- a/editor/basic_toolbar.py
+++ b/editor/basic_toolbar.py
@@ -33,39 +33,11 @@ class BasicToolbar(ToolbarPage):
def __init__(self, editor):
ToolbarPage.__init__(self, editor, "Basic")
self.is_active = False
- x_adjust = 5
- pos = self.gui.getPosition()
- y_pos = pos.d_y
- x_pos = PyCEGUI.UDim(0, x_adjust)
- width = PyCEGUI.UDim(0.9, 0.0)
- label = self.gui.createChild("TaharezLook/Label",
- "LayersLabel")
- label.setText(_("Layer"))
- label.setWidth(width)
- label.setXPosition(x_pos)
- label.setProperty("HorzFormatting", "LeftAligned")
- self.layers_combo = self.gui.createChild("TaharezLook/Combobox",
- "LayerCombo")
- self.layers_combo.setReadOnly(True)
- y_pos.d_scale = y_pos.d_scale + 0.02
- self.layers_combo.setPosition(pos)
- self.layers = []
- self.layers_combo.setWidth(width)
- self.layers_combo.setXPosition(x_pos)
- self.editor.add_map_switch_callback(self.cb_map_changed)
self.outliner = BasicToolbarOutliner(self)
mode = self.editor.current_mode
mode.listener.add_callback("mouse_pressed",
self.cb_map_clicked)
- @property
- def selected_layer(self):
- """Returns the selected layer in the combo box"""
- item = self.layers_combo.getSelectedItem()
- if item is not None:
- return str(item.getText())
- return None
-
def update_contents(self):
"""Update the contents of the toolbar page"""
pass
@@ -84,26 +56,6 @@ def deactivate(self):
mode.outliner = None
mode.listener.is_outlined = False
- def cb_map_changed(self, old_map_name, new_map_name):
- """Called when the map of the editor changed
-
- Args:
-
- old_map_name: Name of the map that was previously loaded
-
- new_map_name: Name of the map that was changed to
- """
- game_map = self.editor.maps[new_map_name]
- self.layers_combo.resetList()
- self.layers = []
- self.layers_combo.setText("")
- layers = game_map.fife_map.getLayers()
- for layer in layers:
- item = PyCEGUI.ListboxTextItem(layer.getId())
- item.setSelectionBrushImage("TaharezLook/MultiListSelectionBrush")
- self.layers_combo.addItem(item)
- self.layers.append(item)
-
def cb_map_clicked(self, click_point, button):
"""Called when a position on the screen was clicked
@@ -114,7 +66,7 @@ def cb_map_clicked(self, click_point, button):
button: The button that was clicked
"""
- if self.selected_layer is None or not self.is_active:
+ if self.editor.selected_layer is None or not self.is_active:
return
game_map = self.editor.current_map
if game_map:
@@ -145,7 +97,7 @@ def get_outlines(self, world, instances):
"""
for instance in instances:
inst_layer = instance.getLocationRef().getLayer().getId()
- if self.toolbar.selected_layer == inst_layer:
+ if self.toolbar.editor.selected_layer == inst_layer:
self.last_instance = instance
return ((instance, (255, 255, 255, 1)),)
self.last_instance = None
diff --git a/editor/object_toolbar.py b/editor/object_toolbar.py
index e8d872d..85942ff 100644
--- a/editor/object_toolbar.py
+++ b/editor/object_toolbar.py
@@ -262,26 +262,10 @@ def __init__(self, editor):
y_pos = pos.d_y
x_pos = PyCEGUI.UDim(0, x_adjust)
width = PyCEGUI.UDim(0.9, 0.0)
- label = self.gui.createChild("TaharezLook/Label",
- "LayersLabel")
- label.setText(_("Layer"))
- label.setWidth(width)
- label.setXPosition(x_pos)
- label.setProperty("HorzFormatting", "LeftAligned")
- self.layers_combo = self.gui.createChild("TaharezLook/Combobox",
- "LayerCombo")
- self.layers_combo.setReadOnly(True)
- y_pos.d_scale = y_pos.d_scale + 0.02
- self.layers_combo.setPosition(pos)
- self.layers = []
- self.layers_combo.setWidth(width)
- self.layers_combo.setXPosition(x_pos)
label = self.gui.createChild("TaharezLook/Label",
"ObjectsLabel")
label.setText(_("Objects"))
label.setWidth(width)
- y_pos.d_scale = y_pos.d_scale + 0.04
- label.setYPosition(y_pos)
label.setXPosition(x_pos)
label.setProperty("HorzFormatting", "LeftAligned")
items_panel = self.gui.createChild("TaharezLook/ScrollablePane",
@@ -311,14 +295,6 @@ def __init__(self, editor):
self.editor.add_project_clear_callback(self.cb_project_closed)
self.editor.add_objects_imported_callback(self.cb_objects_imported)
- @property
- def selected_layer(self):
- """Returns the selected layer in the combo box"""
- item = self.layers_combo.getSelectedItem()
- if item is not None:
- return str(item.getText())
- return None
-
def image_clicked(self, args):
"""Called when the user clicked on an image
@@ -578,16 +554,6 @@ def cb_map_changed(self, old_map_name, new_map_name):
new_map_name: Name of the map that was changed to
"""
self.have_objects_changed = True
- game_map = self.editor.maps[new_map_name]
- self.layers_combo.resetList()
- self.layers = []
- layers = game_map.fife_map.getLayers()
- self.layers_combo.setText("")
- for layer in layers:
- item = PyCEGUI.ListboxTextItem(layer.getId())
- item.setSelectionBrushImage("TaharezLook/MultiListSelectionBrush")
- self.layers_combo.addItem(item)
- self.layers.append(item)
def cb_map_clicked(self, click_point, button):
"""Called when a position on the screen was clicked
@@ -600,16 +566,16 @@ def cb_map_clicked(self, click_point, button):
button: The button that was clicked
"""
self.clean_mouse_instance()
- if self.selected_layer is None or not self.is_active:
+ if self.editor.selected_layer is None or not self.is_active:
return
if button == fife.MouseEvent.MIDDLE:
return
namespace, name = self.selected_object
if namespace is None and button == fife.MouseEvent.LEFT:
return
- layer = self.editor.current_map.get_layer(self.selected_layer)
+ layer = self.editor.current_map.get_layer(self.editor.selected_layer)
location = self.editor.screen_coords_to_map_coords(
- click_point, self.selected_layer
+ click_point, self.editor.selected_layer
)
world = self.editor.world
for instance in layer.getInstancesAt(location):
@@ -655,14 +621,14 @@ def cb_map_moved(self, click_point):
if not self.is_active:
return
self.clean_mouse_instance()
- if self.selected_layer is None or not self.is_active:
+ if self.editor.selected_layer is None or not self.is_active:
return
namespace, name = self.selected_object
if namespace is None:
return
- layer = self.editor.current_map.get_layer(self.selected_layer)
+ layer = self.editor.current_map.get_layer(self.editor.selected_layer)
location = self.editor.screen_coords_to_map_coords(
- click_point, self.selected_layer
+ click_point, self.editor.selected_layer
)
coords = location.getLayerCoordinates()
self.last_mouse_pos = location
@@ -692,9 +658,6 @@ def cb_project_closed(self):
self.namespaces = {}
self.images = {}
self.selected_object = [None, None]
- self.layers = None
- self.layers_combo.resetList()
- self.layers_combo.setText("")
if self.items:
self.items_panel.destroyChild(self.items)
self.items = self.items_panel.createChild("VerticalLayoutContainer",
diff --git a/fife_rpg_editor.py b/fife_rpg_editor.py
index f7360f4..c1372f6 100755
--- a/fife_rpg_editor.py
+++ b/fife_rpg_editor.py
@@ -124,12 +124,11 @@ def __init__(self, setting):
layer_box.setHeight(PyCEGUI.UDim(0.175, 0.0))
layer_box.setWidth(PyCEGUI.UDim(1.0, 0.0))
- self.listbox = layer_box.createChild("TaharezLook/Listbox", "Listbox")
+ self.listbox = layer_box.createChild("TaharezLook/ItemListbox",
+ "Listbox")
+
self.listbox.setHeight(PyCEGUI.UDim(0.99, 0.0))
self.listbox.setWidth(PyCEGUI.UDim(0.99, 0.0))
- self.listbox.setMultiselectEnabled(True)
- self.listbox.subscribeEvent(PyCEGUI.Listbox.EventSelectionChanged,
- self.cb_layer_selection_changed)
self.show_agents_check = right_area_container.createChild("TaharezLook"
"/Checkbox",
"show_agents"
@@ -169,6 +168,14 @@ def __loadData(self): # pylint: disable=no-self-use, invalid-name
PyCEGUI.FontManager.getSingleton().createFromFile("DejaVuSans-12.font")
PyCEGUI.FontManager.getSingleton().createFromFile("DejaVuSans-14.font")
+ @property
+ def selected_layer(self):
+ """Returns the currently selected layer"""
+ selected = self.listbox.getFirstSelectedItem()
+ if selected is not None:
+ return selected.getText().encode()
+ return None
+
def setup(self):
"""Actions that should to be done with an active mode"""
self.create_menu()
@@ -841,13 +848,26 @@ def cb_map_switch(self, args):
if self.current_map:
layers = self.current_map.fife_map.getLayers()
for layer in layers:
- item = PyCEGUI.ListboxTextItem(layer.getId())
- item.setSelectionBrushImage("TaharezLook/"
- "MultiListSelectionBrush")
- self.listbox.addItem(item)
- item.setSelected(True)
+ layer_name = layer.getId()
+ item = self.listbox.createChild(
+ "TaharezLook/CheckListboxItem",
+ "layer_%s" % layer_name)
+ checkbox = item.getChild(0)
+
+ checkbox.setSelected(True)
+ checkbox.subscribeEvent(
+ PyCEGUI.ToggleButton.EventSelectStateChanged,
+ # pylint:disable=cell-var-from-loop
+ lambda args, layer=layer_name:
+ # pylint:enable=cell-var-from-loop
+ self.cb_layer_checkbox_changed(
+ args, layer)
+ )
+ item.setText(layer_name)
+
if not self.show_agents_check.isSelected():
self.hide_map_entities(self.current_map.name)
+ self.listbox.performChildWindowLayout()
except Exception as error:
print error
raise
@@ -864,13 +884,15 @@ def cb_tb_page_changed(self, args):
new_toolbar.activate()
self.old_toolbar_index = index
- def cb_layer_selection_changed(self, args):
- """Called when the layer selection in the listbox changed"""
- layers = self.current_map.fife_map.getLayers()
- for layer in layers:
- listitem = self.listbox.findItemWithText(layer.getId(), None)
- is_selected = listitem.isSelected()
- layer.setInstancesVisible(is_selected)
+ def cb_layer_checkbox_changed(self, args, layer_name):
+ """Called when a layer checkbox state was changed
+
+ Args:
+ layer_name: Name of the layer the checkbox is for
+ """
+ layer = self.current_map.fife_map.getLayer(layer_name)
+ is_selected = args.window.isSelected()
+ layer.setInstancesVisible(is_selected)
def update_property_editor(self):
"""Update the property editor"""
@@ -1071,6 +1093,11 @@ def cb_import_objects(self, args):
for callback in self._objects_imported_callbacks:
callback()
+ def cb_layerbox_item_click(self, args):
+ """Callback when an item was clicked in the layerbox"""
+ pass
+ args.window.setSelected(True)
+
def update_settings(project, settings, values):
"""Update the fife-rpg settings of a project
diff --git a/gui/looksnfeels/TaharezLook.looknfeel b/gui/looksnfeels/TaharezLook.looknfeel
index 330da61..5d64beb 100644
--- a/gui/looksnfeels/TaharezLook.looknfeel
+++ b/gui/looksnfeels/TaharezLook.looknfeel
@@ -56,7 +56,8 @@
-
+
+
@@ -2759,16 +2760,16 @@
-
+
-
+
-
+
@@ -2778,7 +2779,7 @@
-
+
@@ -4147,7 +4148,116 @@
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/gui/schemes/TaharezLook.scheme b/gui/schemes/TaharezLook.scheme
index 5893bf0..fd52c48 100644
--- a/gui/schemes/TaharezLook.scheme
+++ b/gui/schemes/TaharezLook.scheme
@@ -46,7 +46,8 @@
+
-
+