#!/usr/bin/env python

import sys
from xml.etree.ElementTree import ElementTree

from PyQt4.QtGui import *
from PyQt4.QtCore import *

from structdata.world import g_world

class RoomEditor(QWidget):

    def __init__(self, room=None, parent=None):
        super(RoomEditor, self).__init__(parent)
        self.setSizePolicy(QSizePolicy(QSizePolicy.Expanding,
                                       QSizePolicy.Expanding))
        self.setMinimumSize(1000, 1000)
        self.label = QLabel()
        self.scroll_area = QScrollArea(self)
        self.scroll_area.setMinimumSize(900, 900)
        self.scroll_area.setSizePolicy(QSizePolicy.Expanding,
                                       QSizePolicy.Expanding)
        self.scroll_area.setBackgroundRole(QPalette.Dark)
        self.scroll_area.setAlignment(Qt.AlignCenter)
        self.change_room_name = QLineEdit(self)
        self.change_room_name.setText(g_world.selected_room)
        self.change_room_name.setAlignment(Qt.AlignCenter)
        self.change_room_name.move(self.scroll_area.height() / 2,
                                   self.scroll_area.width())
        image = QPixmap(g_world.rooms[g_world.selected_room].bg)
        self.label.setPixmap(image)
        self.scroll_area.setWidget(self.label)
        self.connect(self.change_room_name,
                     SIGNAL("textEdited(const QString &)"),
                     self.setRoomName)

    def setRoomName(self, new_room_name):
        old_room = g_world.selected_room
        if g_world.informations.start == g_world.selected_room:
            g_world.informations.start = str(new_room_name)
        g_world.selected_room = str(new_room_name)
        room = g_world.rooms[old_room]
        room.id = str(new_room_name)
        del g_world.rooms[old_room]
        g_world.rooms[room.id] = room
        g_world.notify()

    def changeCurrentRoom(self, room_id):
        self.room = str(room_id)
        self.label.setPixmap(QPixmap(g_world.rooms[self.room].bg))
        self.change_room_name.setText(room_id)

if __name__ == "__main__":
    app = QApplication(sys.argv)
    rm = RoomEditor()
    rm.show()
    app.exec_()

@@ -144,21 +144,23 @@
 uctdata.
-world
+project
  import 
@@ -161,21 +161,23 @@
 mport g_
-world
+project
 %0A%0Aclass 
@@ -295,16 +295,65 @@
 parent)%0A
+        self.room_name = room.id if room else %22%22%0A
         
@@ -922,69 +922,8 @@
 lf)%0A
-        self.change_room_name.setText(g_world.selected_room)%0A
     
@@ -1116,99 +1116,25 @@
     
-image = QPixmap(g_world.rooms%5Bg_world.selected_room%5D.bg)%0A        self.label.setPixmap(image
+self.setRoom(room
 )%0A  
@@ -1387,183 +1387,118 @@
 m = 
-g_world.selected_room%0A        if g_world.informations.start == g_world.selected_room:%0A            g_world.informations.start = str(new_room_name)%0A        g_world.selected_room
+self.room_name%0A        if g_project.data%5B'world'%5D.start == old_room:%0A            g_project.data%5B'world'%5D.start
  = s
@@ -1532,27 +1532,37 @@
 oom = g_
-world.
+project.data%5B'
 rooms
+'%5D
 %5Bold_roo
@@ -1615,27 +1615,37 @@
   del g_
-world.
+project.data%5B'
 rooms
+'%5D
 %5Bold_roo
@@ -1657,27 +1657,37 @@
       g_
-world.
+project.data%5B'
 rooms
+'%5D
 %5Broom.id
@@ -1709,21 +1709,209 @@
   g_
-world.notify(
+project.notify()%0A%0A    def setRoom(self, room):%0A        if room:%0A            self.room_name = room.id%0A            self.label.setPixmap(QPixmap(room.bg))%0A            self.change_room_name.setText(room.id
 )%0A%0A 
@@ -1964,24 +1964,29 @@
    self.room
+_name
  = str(room_
@@ -2001,50 +2001,134 @@
     
-self.label.setPixmap(QPixmap(g_world.rooms
+if self.room_name:%0A            self.label.setPixmap(QPixmap(g_project.data%5B'rooms'%5D%5C%0A                                         
 %5Bsel
@@ -2137,15 +2137,24 @@
 room
+_name
 %5D.bg))%0A
+    
     

update to use g_project structure, add setRoom function to show the current room