Class: FXRoomDialogBox

Inherits:
FXDialogBox
  • Object
show all
Defined in:
lib/IFMapper/FXRoomDialogBox.rb

Overview

Class used to display a room dialog box

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(map, room, event = nil, modal = nil) ⇒ FXRoomDialogBox

Returns a new instance of FXRoomDialogBox.



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
# File 'lib/IFMapper/FXRoomDialogBox.rb', line 77

def initialize(map, room, event = nil, modal = nil)
  pos = [40, 40]
  if event
    pos  = [ event.last_x, event.last_y ]
  end
  maxW = map.window.width  - 390
  maxH = map.window.height - 300
  pos[0] = maxW if pos[0] > maxW
  pos[1] = maxH if pos[1] > maxH
  
  if modal
    decor = DECOR_TITLE|DECOR_BORDER
  else
    decor = DECOR_TITLE|DECOR_BORDER|DECOR_CLOSE
  end

  super( map.window, BOX_ROOM_INFORMATION, decor, pos[0], pos[1], 0, 0 )
  mainFrame = FXVerticalFrame.new(self,
		    FRAME_SUNKEN|FRAME_THICK|
		    LAYOUT_FILL_X|LAYOUT_FILL_Y)

  frame = FXHorizontalFrame.new(mainFrame, LAYOUT_SIDE_TOP|LAYOUT_FILL_X)

  FXLabel.new(frame, BOX_LOCATION, nil, 0, LAYOUT_FILL_X)
  @name = FXTextField.new(frame, 40, nil, 0, LAYOUT_FILL_ROW)


  all = FXHorizontalFrame.new(mainFrame,
		LAYOUT_SIDE_TOP|LAYOUT_FILL_X|LAYOUT_FILL_Y)

  leftFrame = FXVerticalFrame.new(all, 
		    LAYOUT_SIDE_TOP|LAYOUT_SIDE_LEFT|
		    LAYOUT_FILL_X|LAYOUT_FILL_Y)

  @darkness = FXCheckButton.new(leftFrame, BOX_DARKNESS, nil, 0,
		  ICON_BEFORE_TEXT|LAYOUT_LEFT|
		  LAYOUT_SIDE_RIGHT)
  @tab = FXTabBook.new(leftFrame, :opts => LAYOUT_FILL_X|LAYOUT_FILL_Y|
                       LAYOUT_LEFT)
  
  FXTabItem.new(@tab, BOX_OBJECTS, nil, 0, LAYOUT_FILL_X)
  boxFrame = FXHorizontalFrame.new(@tab, FRAME_THICK|FRAME_RAISED)
  @objects = FXText.new(boxFrame, nil, 0, LAYOUT_FILL_X|LAYOUT_FILL_Y)
  @objects.visibleRows = 8
  @objects.visibleColumns = 40

  @tasksFrame = FXTabItem.new(@tab, BOX_TASKS, nil)
  frame = FXHorizontalFrame.new(@tab, FRAME_THICK|FRAME_RAISED)
  @tasks = FXText.new(frame, nil, 0, LAYOUT_FILL_X|LAYOUT_FILL_Y)
  @tasks.visibleRows = 8
  @tasks.visibleColumns = 40

  FXTabItem.new(@tab, BOX_COMMENTS, nil)
  @commentFrame = FXHorizontalFrame.new(@tab, FRAME_THICK|FRAME_RAISED)
  @comment = FXText.new(@commentFrame, nil, 0, LAYOUT_FILL_X|LAYOUT_FILL_Y)
  @comment.visibleRows = 8
  @comment.visibleColumns = 40

  ######## Add description
  @descFrame = FXTabItem.new(@tab, BOX_DESCRIPTION, nil)
  frame = FXVerticalFrame.new(@tab, FRAME_THICK|FRAME_RAISED)
  @desc = FXText.new(frame, nil, 0, 
       LAYOUT_FILL_X|LAYOUT_FILL_Y|TEXT_WORDWRAP)
  @desc.visibleColumns = 70
  @desc.visibleRows = 18


  if modal
    buttons = FXHorizontalFrame.new(mainFrame, 
		      LAYOUT_SIDE_BOTTOM|LAYOUT_FILL_X|
		      PACK_UNIFORM_WIDTH)
    # Accept
    @ok = FXButton.new(buttons, BUTTON_ACCEPT, nil, self, 
	 FXDialogBox::ID_ACCEPT,
	 FRAME_RAISED|FRAME_THICK|LAYOUT_RIGHT|LAYOUT_CENTER_Y)
    
    # Cancel
    FXButton.new(buttons, BUTTON_CANCEL, nil, self, 
                 FXDialogBox::ID_CANCEL,
                 FRAME_RAISED|FRAME_THICK|LAYOUT_RIGHT|LAYOUT_CENTER_Y)
  else
    @name.connect(SEL_CHANGED) { copy_to() }
    @objects.connect(SEL_CHANGED) { copy_to()}
    @tasks.connect(SEL_CHANGED) { @room.tasks = @tasks.text }
    @darkness.connect(SEL_COMMAND) { copy_to() }
    @desc.connect(SEL_CHANGED) { @room.desc = @desc.text }
    @comment.connect(SEL_CHANGED) { @room.comment = @comment.text }
  end
  
  @map = map

  # We need to create the dialog box first, so we can use select text.
  create
end

Instance Attribute Details

#map=(value) ⇒ Object (writeonly)

Sets the attribute map

Parameters:

  • value

    the value to set the attribute map to.



8
9
10
# File 'lib/IFMapper/FXRoomDialogBox.rb', line 8

def map=(value)
  @map = value
end

Instance Method Details

#copy_from(room) ⇒ Object



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
# File 'lib/IFMapper/FXRoomDialogBox.rb', line 25

def copy_from(room)
  @room                = room
  @name.text           = room.name
  @darkness.checkState = room.darkness
  @objects.text        = room.objects
  @tasks.text          = room.tasks
  @desc.text           = room.desc
  @comment.text        = room.comment

  # Select text for quick editing if it uses default location name
  @name.setCursorPos room.name.size 
  if room.name == MSG_NEW_LOCATION
    self.setFocus
    @name.selectAll
    @name.setFocus
  end
  if @map.navigation
    @name.disable
    @darkness.disable
    @objects.disable
    @tasks.disable
    @desc.disable
    @comment.disable
  else
    @name.enable
    @darkness.enable
    @objects.enable
    @tasks.enable
    @desc.enable
    @comment.enable
  end

  if @map.options['Location Tasks']
    @tasksFrame.show
  else
    @tasksFrame.hide
  end
  if @map.options['Location Description']
    @descFrame.show
  else
    @descFrame.hide
  end

  @desc.connect(SEL_CHANGED) { @room.desc = @desc.text }

  # Yuck!  Fox's packer is absolutely oblivious to hiding/showing of
  # elements, so we need to force a dummy resize so the layout is
  # recalculated.  But FUCK!  This completely fucks up the focus.
  # Fox is a piece of ****.  I **REALLY** need to go back to FLTK.
  ##  self.resize(self.defaultWidth, self.defaultHeight)
end

#copy_toObject



10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/IFMapper/FXRoomDialogBox.rb', line 10

def copy_to()

  @room.name    = @name.text
  @room.objects = @objects.text
  @room.objects.gsub!(/[,\t]+/, "\n")
  @room.tasks = @tasks.text
  @room.darkness = (@darkness.checkState == 1)
  @room.desc = @desc.text
  @room.comment = @comment.text

  @map.draw_room(@room)
  @map.update_roomlist
end