ifmapper 0.9 → 0.9.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/HISTORY.txt +132 -5
- data/IFMapper.gemspec +2 -2
- data/TODO.txt +0 -5
- data/lib/IFMapper/AStar.rb +15 -8
- data/lib/IFMapper/Connection.rb +137 -25
- data/lib/IFMapper/FXConnection.rb +54 -40
- data/lib/IFMapper/FXConnectionDialogBox.rb +12 -4
- data/lib/IFMapper/FXMap.rb +161 -60
- data/lib/IFMapper/FXMapperWindow.rb +205 -70
- data/lib/IFMapper/FXRoom.rb +7 -2
- data/lib/IFMapper/FXRoomDialogBox.rb +2 -1
- data/lib/IFMapper/FXRoomList.rb +95 -0
- data/lib/IFMapper/PDFMapExporter.rb +10 -1
- data/lib/IFMapper/Room.rb +22 -0
- data/lib/IFMapper/TranscriptDialogBox.rb +117 -0
- data/lib/IFMapper/TranscriptReader.rb +320 -96
- data/maps/AllRoads.map +0 -0
- data/maps/Bureaucracy.map +0 -0
- data/maps/CityOfSecrets.map +0 -0
- data/maps/DDIV.map +0 -0
- data/maps/Heroine.map +0 -0
- data/maps/SavoirFare.map +0 -0
- data/maps/Tangle.map +0 -0
- data/maps/anchor.map +0 -0
- data/maps/ballerina.map +0 -0
- data/maps/bluechairs.map +0 -0
- data/maps/break_in.map +0 -0
- data/maps/christminster.map +0 -0
- data/maps/deadline.map +0 -0
- data/maps/delusions.map +0 -0
- data/maps/dreamhold.map +0 -0
- data/maps/eas.map +0 -0
- data/maps/eas2.map +0 -0
- data/maps/eas3.map +0 -0
- data/maps/inhumane.map +0 -0
- data/maps/lurkinghorror.map +0 -0
- data/maps/metamorphoses.map +0 -0
- data/maps/moonmist.map +0 -0
- data/maps/muldoon_legacy.map +0 -0
- data/maps/pawn.map +0 -0
- data/maps/pytho.map +0 -0
- data/maps/risorgimento.map +0 -0
- data/maps/sherbet.map +0 -0
- data/maps/slouch.map +0 -0
- data/maps/spring.map +0 -0
- data/maps/trinity.map +0 -0
- data/maps/worlds.map +0 -0
- data/maps/zdungeon.map +0 -0
- metadata +42 -8
@@ -20,8 +20,7 @@ class FXConnectionDialogBox < FXDialogBox
|
|
20
20
|
|
21
21
|
DIR_TEXT = [
|
22
22
|
'Both',
|
23
|
-
'
|
24
|
-
'B to A',
|
23
|
+
'One Way',
|
25
24
|
]
|
26
25
|
|
27
26
|
EXIT_TEXT = [
|
@@ -65,6 +64,11 @@ class FXConnectionDialogBox < FXDialogBox
|
|
65
64
|
@exitA.enable
|
66
65
|
@exitB.enable
|
67
66
|
end
|
67
|
+
if conn.loop? or conn.stub?
|
68
|
+
@type.disable
|
69
|
+
@dir.disable
|
70
|
+
@exitB.disable
|
71
|
+
end
|
68
72
|
end
|
69
73
|
|
70
74
|
def initialize(map, conn, event = nil)
|
@@ -122,8 +126,12 @@ class FXConnectionDialogBox < FXDialogBox
|
|
122
126
|
JUSTIFY_HZ_APART|ICON_AFTER_TEXT|
|
123
127
|
LAYOUT_CENTER_X|LAYOUT_CENTER_Y)
|
124
128
|
|
125
|
-
@dir.connect(SEL_COMMAND) {
|
126
|
-
|
129
|
+
@dir.connect(SEL_COMMAND) {
|
130
|
+
copy_to()
|
131
|
+
title = @conn.to_s
|
132
|
+
self.title = title
|
133
|
+
}
|
134
|
+
@type.connect(SEL_COMMAND) { copy_to() }
|
127
135
|
@exitA.connect(SEL_COMMAND) { copy_to() }
|
128
136
|
@exitB.connect(SEL_COMMAND) { copy_to() }
|
129
137
|
@map = map
|
data/lib/IFMapper/FXMap.rb
CHANGED
@@ -6,6 +6,7 @@ require 'IFMapper/FXSection'
|
|
6
6
|
require 'IFMapper/FXMapDialogBox'
|
7
7
|
require 'IFMapper/FXSectionDialogBox'
|
8
8
|
require 'IFMapper/AStar'
|
9
|
+
require 'thread'
|
9
10
|
|
10
11
|
|
11
12
|
class FXMap < Map
|
@@ -21,6 +22,9 @@ class FXMap < Map
|
|
21
22
|
attr_accessor :options # Map options
|
22
23
|
attr_reader :window # Fox Window for this map
|
23
24
|
attr :version # file format version
|
25
|
+
attr_reader :mutex # Mutex to avoid racing conditions while
|
26
|
+
# automapping
|
27
|
+
attr_reader :automap # automapping transcript
|
24
28
|
|
25
29
|
# pmap is a path map (a matrix or grid used for path finding).
|
26
30
|
# Rooms and paths are recorded there. Path finding is needed
|
@@ -28,7 +32,8 @@ class FXMap < Map
|
|
28
32
|
# We now also use this for selecting of stuff, particularly complex paths.
|
29
33
|
attr :pmap
|
30
34
|
|
31
|
-
@@win
|
35
|
+
@@win = nil # Map Info window
|
36
|
+
@@roomlist = nil # Room List Window
|
32
37
|
|
33
38
|
@@tooltip = nil
|
34
39
|
@@cursor_arrow = nil
|
@@ -58,6 +63,7 @@ class FXMap < Map
|
|
58
63
|
# Jump to a certain section #
|
59
64
|
#
|
60
65
|
def section=(x)
|
66
|
+
clear_selection
|
61
67
|
super
|
62
68
|
@complexConnection = false
|
63
69
|
_changed
|
@@ -127,9 +133,9 @@ class FXMap < Map
|
|
127
133
|
(0...@height).each { |y|
|
128
134
|
m[y * (@width+2)] = (y % 10).to_s
|
129
135
|
loc = y * (@width+2) + x + 1
|
130
|
-
if @pmap
|
136
|
+
if @pmap.at(x).at(y).kind_of?(Connection)
|
131
137
|
m[loc] = '-'
|
132
|
-
elsif @pmap
|
138
|
+
elsif @pmap.at(x).at(y).kind_of?(Room)
|
133
139
|
m[loc] = 'R'
|
134
140
|
end
|
135
141
|
}
|
@@ -145,7 +151,7 @@ class FXMap < Map
|
|
145
151
|
def _free_area?(x, y, w, h)
|
146
152
|
x.upto(x+w) { |xx|
|
147
153
|
y.upto(x+h) { |yy|
|
148
|
-
return false if @pmap
|
154
|
+
return false if @pmap.at(xx).at(yy).kind_of?(Room)
|
149
155
|
}
|
150
156
|
}
|
151
157
|
return true
|
@@ -230,13 +236,9 @@ class FXMap < Map
|
|
230
236
|
end
|
231
237
|
|
232
238
|
# Complex path... Generate points.
|
233
|
-
a = c.
|
234
|
-
|
235
|
-
|
236
|
-
dirA = a.exits.index(c)
|
239
|
+
a, b = c.room
|
240
|
+
dirA, dirB = c.dirs
|
237
241
|
raise "A connection not found #{c} at #{a}" unless dirA
|
238
|
-
|
239
|
-
dirB = b.exits.rindex(c)
|
240
242
|
raise "B connection not found #{c} at #{b}" unless dirB
|
241
243
|
|
242
244
|
vA = FXRoom::DIR_TO_VECTOR[dirA]
|
@@ -271,8 +273,8 @@ class FXMap < Map
|
|
271
273
|
pB[0] < 0 or pB[0] >= @width or
|
272
274
|
pA[1] < 0 or pA[1] >= @height or
|
273
275
|
pB[1] < 0 or pB[1] >= @height or
|
274
|
-
@pmap
|
275
|
-
@pmap
|
276
|
+
@pmap.at(pA[0]).at(pA[1]).kind_of?(Room) or
|
277
|
+
@pmap.at(pB[0]).at(pB[1]).kind_of?(Room)
|
276
278
|
remove_connection(c)
|
277
279
|
return false
|
278
280
|
end
|
@@ -387,6 +389,7 @@ class FXMap < Map
|
|
387
389
|
return nil
|
388
390
|
end
|
389
391
|
end
|
392
|
+
update_roomlist
|
390
393
|
return r
|
391
394
|
end
|
392
395
|
|
@@ -413,7 +416,7 @@ class FXMap < Map
|
|
413
416
|
def to_room(x,y)
|
414
417
|
xx = x / WW
|
415
418
|
yy = y / HH
|
416
|
-
return @pmap
|
419
|
+
return @pmap.at(xx).at(yy)
|
417
420
|
end
|
418
421
|
|
419
422
|
# Given a mouse click x/y position, return object(s) if any or nil
|
@@ -426,7 +429,7 @@ class FXMap < Map
|
|
426
429
|
xx = x / WW
|
427
430
|
yy = y / HH
|
428
431
|
return nil if xx >= @width or yy >= @height
|
429
|
-
return @pmap
|
432
|
+
return @pmap.at(xx).at(yy)
|
430
433
|
else
|
431
434
|
# Possible arrow
|
432
435
|
@sections[@section].connections.each { |c|
|
@@ -536,8 +539,10 @@ class FXMap < Map
|
|
536
539
|
|
537
540
|
# Then, create an off-screen image with that same size for double
|
538
541
|
# buffering
|
542
|
+
@image.release
|
539
543
|
@image.destroy
|
540
544
|
GC.start
|
545
|
+
|
541
546
|
@image = FXBMPImage.new(@window.getApp, nil, IMAGE_SHMI|IMAGE_SHMP,
|
542
547
|
width, height)
|
543
548
|
@image.create
|
@@ -794,7 +799,7 @@ class FXMap < Map
|
|
794
799
|
# Based on mouse position on canvas, create a tooltip
|
795
800
|
#
|
796
801
|
def tooltip_cb(sender, id, ptr)
|
797
|
-
if @tooltip_msg != ''
|
802
|
+
if @zoom < 0.6 and @tooltip_msg != ''
|
798
803
|
sender.text = @tooltip_msg.to_s
|
799
804
|
sender.show
|
800
805
|
else
|
@@ -821,7 +826,7 @@ class FXMap < Map
|
|
821
826
|
@canvas.defaultCursor = @@cursor_arrow
|
822
827
|
if sel.kind_of?(Room)
|
823
828
|
@tooltip_msg = sel.name
|
824
|
-
status "Click to select and move. Double click to edit
|
829
|
+
status "\"#{sel.name}\": Click to select and move. Double click to edit."
|
825
830
|
elsif sel.kind_of?(Connection)
|
826
831
|
status "Click to change direction of connection."
|
827
832
|
end
|
@@ -1043,19 +1048,26 @@ class FXMap < Map
|
|
1043
1048
|
a = c.roomA
|
1044
1049
|
b = c.roomB
|
1045
1050
|
menu = FXMenuPane.new(@window)
|
1051
|
+
if c.dir == Connection::AtoB
|
1052
|
+
cmd = FXMenuCommand.new(menu, "Flip Direction")
|
1053
|
+
cmd.connect(SEL_COMMAND) { c.flip; draw }
|
1054
|
+
FXMenuSeparator.new(menu)
|
1055
|
+
end
|
1056
|
+
|
1046
1057
|
submenu = FXMenuPane.new(@window)
|
1047
1058
|
old_idx = a.exits.index(c)
|
1048
1059
|
0.upto(7) { |idx|
|
1049
1060
|
rmb_link_menu( submenu, c, a, idx, old_idx )
|
1050
1061
|
}
|
1051
1062
|
FXMenuCascade.new(menu, a.name, nil, submenu)
|
1052
|
-
|
1053
|
-
|
1054
|
-
|
1055
|
-
|
1056
|
-
|
1057
|
-
|
1058
|
-
|
1063
|
+
if b
|
1064
|
+
submenu = FXMenuPane.new(@window)
|
1065
|
+
old_idx = b.exits.rindex(c)
|
1066
|
+
0.upto(7) { |idx|
|
1067
|
+
rmb_link_menu( submenu, c, b, idx, old_idx )
|
1068
|
+
}
|
1069
|
+
FXMenuCascade.new(menu, b.name, nil, submenu)
|
1070
|
+
end
|
1059
1071
|
end
|
1060
1072
|
if menu
|
1061
1073
|
menu.create
|
@@ -1227,7 +1239,6 @@ class FXMap < Map
|
|
1227
1239
|
@automap.destroy if @automap
|
1228
1240
|
@automap = nil
|
1229
1241
|
@window.close
|
1230
|
-
GC.start
|
1231
1242
|
return true
|
1232
1243
|
end
|
1233
1244
|
|
@@ -1285,9 +1296,6 @@ class FXMap < Map
|
|
1285
1296
|
0, 0, width, height)
|
1286
1297
|
@dirty = true
|
1287
1298
|
# @canvas.connect(SEL_UPDATE, method(:update_cb))
|
1288
|
-
if fxversion =~ /^1.4/
|
1289
|
-
@canvas.connect(SEL_QUERY_TIP, method(:tooltip_cb))
|
1290
|
-
end
|
1291
1299
|
|
1292
1300
|
@canvas.connect(SEL_PAINT, method(:draw))
|
1293
1301
|
@canvas.backColor = @options['BG Color']
|
@@ -1301,8 +1309,10 @@ class FXMap < Map
|
|
1301
1309
|
@canvas.connect(SEL_RIGHTBUTTONPRESS, method(:rmb_click_cb))
|
1302
1310
|
@canvas.connect(SEL_KEYPRESS, method(:keypress_cb))
|
1303
1311
|
|
1304
|
-
if
|
1312
|
+
if fxversion !~ /^1.2/
|
1305
1313
|
@@tooltip = FXToolTip.new(@canvas.app, FXToolTip::TOOLTIP_PERMANENT)
|
1314
|
+
# Tooltip is too buggy and annoying. Turning it off for now.
|
1315
|
+
# @canvas.connect(SEL_QUERY_TIP, method(:tooltip_cb))
|
1306
1316
|
end
|
1307
1317
|
end
|
1308
1318
|
|
@@ -1314,6 +1324,7 @@ class FXMap < Map
|
|
1314
1324
|
icon = nil, menu = nil, mode = nil,
|
1315
1325
|
x = 0, y = 0, w = 0, h = 0)
|
1316
1326
|
super(name)
|
1327
|
+
@mutex = Mutex.new
|
1317
1328
|
@automap = nil
|
1318
1329
|
@navigation = false
|
1319
1330
|
if parent
|
@@ -1381,6 +1392,7 @@ class FXMap < Map
|
|
1381
1392
|
}
|
1382
1393
|
|
1383
1394
|
modified = true
|
1395
|
+
create_pathmap
|
1384
1396
|
draw
|
1385
1397
|
end
|
1386
1398
|
|
@@ -1423,6 +1435,29 @@ class FXMap < Map
|
|
1423
1435
|
}
|
1424
1436
|
end
|
1425
1437
|
|
1438
|
+
def show_roomlist
|
1439
|
+
if @@roomlist
|
1440
|
+
@@roomlist.copy_from(self)
|
1441
|
+
else
|
1442
|
+
@@roomlist = FXRoomList.new(self)
|
1443
|
+
end
|
1444
|
+
@@roomlist.show
|
1445
|
+
end
|
1446
|
+
|
1447
|
+
def self.no_maps
|
1448
|
+
@@roomlist.hide if @@roomlist
|
1449
|
+
@@win.hide if @@win
|
1450
|
+
FXRoom::no_maps
|
1451
|
+
FXConnection::no_maps
|
1452
|
+
end
|
1453
|
+
|
1454
|
+
#
|
1455
|
+
# If roomlist window is present, update it
|
1456
|
+
#
|
1457
|
+
def update_roomlist
|
1458
|
+
@@roomlist.copy_from(self) if @@roomlist
|
1459
|
+
@@win.copy_from(self) if @@win
|
1460
|
+
end
|
1426
1461
|
|
1427
1462
|
#
|
1428
1463
|
# Find and update all paths in path map for a room
|
@@ -1443,8 +1478,10 @@ class FXMap < Map
|
|
1443
1478
|
end
|
1444
1479
|
|
1445
1480
|
def cannot_automap(why)
|
1481
|
+
p '----CANNOT AUTOMAP'
|
1446
1482
|
w = FXWarningBox.new(@window, "Cannot automap.\n#{why}")
|
1447
1483
|
w.execute
|
1484
|
+
p '----CANNOT AUTOMAP AFTER EXECUTE'
|
1448
1485
|
end
|
1449
1486
|
|
1450
1487
|
|
@@ -1474,7 +1511,7 @@ class FXMap < Map
|
|
1474
1511
|
x = r.x + dx
|
1475
1512
|
y = r.y + dy
|
1476
1513
|
if x < 0 or y < 0 or x >= @width or y >= @height or
|
1477
|
-
@pmap
|
1514
|
+
@pmap.at(x).at(y).kind_of?(Room)
|
1478
1515
|
store_room_selection(selection)
|
1479
1516
|
dir = Room::DIRECTIONS[idx]
|
1480
1517
|
status "Cannot move selection #{dir}."
|
@@ -1516,7 +1553,7 @@ class FXMap < Map
|
|
1516
1553
|
y = 0 if y < 0
|
1517
1554
|
x = @width-1 if x > @width-1
|
1518
1555
|
y = @height-1 if y > @height-1
|
1519
|
-
if not @pmap
|
1556
|
+
if not @pmap.at(x).at(y).kind_of?(Room)
|
1520
1557
|
room.selected = false
|
1521
1558
|
roomB = new_xy_room(x * WW, y * HH)
|
1522
1559
|
exitB = roomB.next_to?(room)
|
@@ -1621,7 +1658,7 @@ class FXMap < Map
|
|
1621
1658
|
|
1622
1659
|
(0...@height).each { |yy|
|
1623
1660
|
(0...@width).each { |xx|
|
1624
|
-
next if @pmap
|
1661
|
+
next if @pmap.at(xx).at(yy).kind_of?(Connection)
|
1625
1662
|
x = xx * ww
|
1626
1663
|
y = yy * hh
|
1627
1664
|
|
@@ -1663,15 +1700,13 @@ class FXMap < Map
|
|
1663
1700
|
hs_2 = HS_2 * @zoom
|
1664
1701
|
|
1665
1702
|
#---- dummy check to catch an ugly bug that I cannot track...
|
1666
|
-
if @pmap.size
|
1667
|
-
puts "**********ERROR: pmap sizes not != #{@width}x#{@height}"
|
1668
|
-
end
|
1703
|
+
create_pathmap if @pmap.size < @width or @pmap[0].size < @height
|
1669
1704
|
|
1670
1705
|
# First, draw horizontal lines
|
1671
1706
|
(0...@height).each { |yy|
|
1672
1707
|
(0..@width-2).each { |xx|
|
1673
|
-
next if @pmap
|
1674
|
-
@pmap
|
1708
|
+
next if @pmap.at(xx).at(yy).kind_of?(Connection) or
|
1709
|
+
@pmap.at(xx+1).at(yy).kind_of?(Connection)
|
1675
1710
|
x1 = xx * ww + w + ws_2
|
1676
1711
|
x2 = (xx + 1) * ww + ws_2
|
1677
1712
|
y1 = yy * hh + h / 2 + hs_2
|
@@ -1683,8 +1718,8 @@ class FXMap < Map
|
|
1683
1718
|
# Then, draw vertical lines
|
1684
1719
|
(0...@width).each { |xx|
|
1685
1720
|
(0..@height-2).each { |yy|
|
1686
|
-
next if @pmap
|
1687
|
-
@pmap
|
1721
|
+
next if @pmap.at(xx).at(yy).kind_of?(Connection) or
|
1722
|
+
@pmap.at(xx).at(yy+1).kind_of?(Connection)
|
1688
1723
|
x1 = xx * ww + w / 2 + ws_2
|
1689
1724
|
y1 = yy * hh + h + hs_2
|
1690
1725
|
y2 = (yy + 1) * hh + hs_2
|
@@ -1716,7 +1751,7 @@ class FXMap < Map
|
|
1716
1751
|
|
1717
1752
|
(0...@width).each { |xx|
|
1718
1753
|
(0...@height).each { |yy|
|
1719
|
-
next if @pmap
|
1754
|
+
next if @pmap.at(xx).at(yy)
|
1720
1755
|
x = xx * ww + ws_2
|
1721
1756
|
y = yy * hh + hs_2
|
1722
1757
|
dc.drawRectangle( x, y, w, h )
|
@@ -1743,7 +1778,23 @@ class FXMap < Map
|
|
1743
1778
|
end
|
1744
1779
|
|
1745
1780
|
#
|
1746
|
-
# Draw
|
1781
|
+
# Draw a single room (callback used when editing room dialog box)
|
1782
|
+
#
|
1783
|
+
def draw_room(room)
|
1784
|
+
idx = @sections[@section].rooms.index(room)
|
1785
|
+
return unless idx
|
1786
|
+
|
1787
|
+
dc = FXDCWindow.new(@canvas)
|
1788
|
+
dc.font = @font
|
1789
|
+
data = { }
|
1790
|
+
data['font'] = @font
|
1791
|
+
data['objfont'] = @objfont
|
1792
|
+
room.draw(dc, @zoom, idx, @options, data)
|
1793
|
+
dc.end
|
1794
|
+
end
|
1795
|
+
|
1796
|
+
#
|
1797
|
+
# Draw all rooms in current section
|
1747
1798
|
#
|
1748
1799
|
def draw_rooms(dc)
|
1749
1800
|
data = { }
|
@@ -1778,7 +1829,6 @@ class FXMap < Map
|
|
1778
1829
|
self.zoom = 1.0
|
1779
1830
|
|
1780
1831
|
num = pack_sections( @width, @height )
|
1781
|
-
puts "Would pack #{@sections.size} into #{num} pages."
|
1782
1832
|
begin
|
1783
1833
|
dc = FXDCPostscript.new(@window.getApp)
|
1784
1834
|
xmax = @width * WW
|
@@ -1813,29 +1863,23 @@ class FXMap < Map
|
|
1813
1863
|
draw
|
1814
1864
|
end
|
1815
1865
|
|
1816
|
-
#
|
1817
|
-
# Draw a single room (callback used when editing room dialog box)
|
1818
|
-
#
|
1819
|
-
def draw_room(room)
|
1820
|
-
idx = @sections[@section].rooms.index(room)
|
1821
|
-
return unless idx
|
1822
|
-
|
1823
|
-
dc = FXDCWindow.new(@canvas)
|
1824
|
-
dc.font = @font
|
1825
|
-
data = { }
|
1826
|
-
data['font'] = @font
|
1827
|
-
data['objfont'] = @objfont
|
1828
|
-
room.draw(dc, @zoom, idx, @options, data)
|
1829
|
-
dc.end
|
1830
|
-
end
|
1831
1866
|
|
1832
1867
|
#
|
1833
1868
|
# Draw map
|
1834
1869
|
#
|
1835
1870
|
def draw(sender = nil, sel = nil, event = nil)
|
1871
|
+
return if @mutex.locked?
|
1872
|
+
|
1873
|
+
if not @image.created?
|
1874
|
+
puts "Image was not created. Try again"
|
1875
|
+
self.zoom = @zoom
|
1876
|
+
end
|
1877
|
+
|
1836
1878
|
pos = @scrollwindow.position
|
1837
1879
|
w = @scrollwindow.getViewportWidth
|
1838
1880
|
h = @scrollwindow.getViewportHeight
|
1881
|
+
|
1882
|
+
# The -5 seems to be a bug in fox. don't ask me.
|
1839
1883
|
cx = -pos[0]-5
|
1840
1884
|
cx = 0 if cx < 0
|
1841
1885
|
cy = -pos[1]-5
|
@@ -1864,6 +1908,7 @@ class FXMap < Map
|
|
1864
1908
|
dc.setClipRectangle( cx, cy, w, h)
|
1865
1909
|
dc.drawImage(@image,0,0)
|
1866
1910
|
dc.end
|
1911
|
+
|
1867
1912
|
end
|
1868
1913
|
|
1869
1914
|
|
@@ -1913,14 +1958,57 @@ class FXMap < Map
|
|
1913
1958
|
end
|
1914
1959
|
end
|
1915
1960
|
|
1961
|
+
|
1962
|
+
#
|
1963
|
+
# Export map as an IFM map file
|
1964
|
+
#
|
1965
|
+
def export_ifm(file)
|
1966
|
+
require 'IFMapper/IFMWriter'
|
1967
|
+
file += '.ifm' if file !~ /\.ifm$/
|
1968
|
+
IFMWriter.new(map, file)
|
1969
|
+
end
|
1970
|
+
|
1971
|
+
|
1972
|
+
#
|
1973
|
+
# Export map as a set of TADS3 source code files
|
1974
|
+
#
|
1975
|
+
def export_tads(file)
|
1976
|
+
require 'IFMapper/TADSWriter'
|
1977
|
+
file.sub!(/(-\d+)?\.t/, '')
|
1978
|
+
TADSWriter.new(self, file)
|
1979
|
+
end
|
1980
|
+
|
1981
|
+
#
|
1982
|
+
# Export map as a set of Inform source code files
|
1983
|
+
#
|
1984
|
+
def export_inform(file)
|
1985
|
+
require 'IFMapper/InformWriter'
|
1986
|
+
file.sub!(/(-\d+)?\.inf/, '')
|
1987
|
+
InformWriter.new(self, file)
|
1988
|
+
end
|
1989
|
+
|
1916
1990
|
#
|
1917
1991
|
# Save the map under a new filename, bringing up a filerequester
|
1918
1992
|
#
|
1919
1993
|
def save_as
|
1920
1994
|
file = FXMapFileDialog.new(@window, "Save Map #{@name}").filename
|
1921
1995
|
if file != ''
|
1922
|
-
|
1923
|
-
|
1996
|
+
if File.exists?(file)
|
1997
|
+
dlg = FXWarningBox.new(@window, "#{file}\nalready exists. Are you sure you want to overwrite it?")
|
1998
|
+
return if dlg.execute == 0
|
1999
|
+
end
|
2000
|
+
|
2001
|
+
case file
|
2002
|
+
when /\.inf$/
|
2003
|
+
export_inform(file)
|
2004
|
+
when /\.ifm$/
|
2005
|
+
export_ifm(file)
|
2006
|
+
when /\.t$/
|
2007
|
+
export_tads(file)
|
2008
|
+
else
|
2009
|
+
@filename = file
|
2010
|
+
return _save
|
2011
|
+
end
|
1924
2012
|
end
|
1925
2013
|
return false
|
1926
2014
|
end
|
@@ -1951,12 +2039,25 @@ class FXMap < Map
|
|
1951
2039
|
|
1952
2040
|
file = FXMapFileDialog.new(@window, "Load Transcript",
|
1953
2041
|
[
|
1954
|
-
"Transcript File (*.log)",
|
2042
|
+
"Transcript File (*.log,*.scr,*.txt)",
|
1955
2043
|
"All Files (*)"
|
1956
2044
|
]).filename
|
1957
2045
|
return if file == ''
|
1958
2046
|
require 'IFMapper/TranscriptReader'
|
1959
|
-
|
2047
|
+
|
2048
|
+
begin
|
2049
|
+
@automap = TranscriptReader.new(self, file)
|
2050
|
+
@automap.properties(true)
|
2051
|
+
rescue Errno::EACCES, Errno::ENOENT => e
|
2052
|
+
dlg = FXWarningBox.new(@window, "Cannot open transcript\n#{e}")
|
2053
|
+
dlg.execute
|
2054
|
+
return
|
2055
|
+
rescue => e
|
2056
|
+
puts e.backtrace
|
2057
|
+
dlg = FXWarningBox.new(@window, "Internal error parsing transcript\nPlease report as a bug\n#{e}\n#{e.backtrace}")
|
2058
|
+
dlg.execute
|
2059
|
+
raise
|
2060
|
+
end
|
1960
2061
|
@automap.start
|
1961
2062
|
create_pathmap
|
1962
2063
|
draw
|