ifmapper 2.2.3 → 2.2.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/IFMapper.gemspec +4 -2
- data/IFMapper.rbw +1 -2
- data/lib/IFMapper/FXMapperWindow.rb +202 -201
- data/lib/IFMapper/MapPrinting.rb +104 -101
- data/lib/IFMapper/PDFMapExporter.rb +1 -1
- data/lib/IFMapper/PDFMapExporter_prawn.rb +43 -14
- metadata +23 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 14f669750e8ead77e5ec1695ec7a405802d8b5ceb1963acf6381c9a144c22d15
|
4
|
+
data.tar.gz: da6273f224a55b9115d69448ba236074fd119d913b276716685fdad775798234
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 59af5e2198ec63db012f1575716198e96b79603391375c5bf5f2762a1543bc90b6b9b214358757c53a56fc2c710ba87a60e2963cd58ae1f7c30e81c3448fa21c
|
7
|
+
data.tar.gz: fd1fa45b5f32fe3a3fc2bc24424080b5549d6c158e3e8209744eba5986e81746d727fe5ebe31b634f14713ba5a8f7eacf3b1cb5fb14b4bfaf92928b4cefe3f79
|
data/IFMapper.gemspec
CHANGED
@@ -1,7 +1,8 @@
|
|
1
|
+
# coding: utf-8
|
1
2
|
require "rubygems"
|
2
3
|
|
3
|
-
VERSION = '2.2.
|
4
|
-
AUTHOR = "Gonzalo
|
4
|
+
VERSION = '2.2.4'
|
5
|
+
AUTHOR = "Gonzalo Garramuño"
|
5
6
|
HOMEPAGE = 'http://ggarra13.github.io/ifmapper/en/start.html'
|
6
7
|
EMAIL = 'ggarra13@gmail.com'
|
7
8
|
|
@@ -29,6 +30,7 @@ EOF
|
|
29
30
|
s.add_runtime_dependency("rake-compiler", "~> 0.7.1", ">= 0.7.1" )
|
30
31
|
s.add_runtime_dependency("fxruby", "~> 1.6.0", ">= 1.6.0")
|
31
32
|
s.add_runtime_dependency("prawn", "~> 1.0.0", ">= 1.0.0")
|
33
|
+
s.add_runtime_dependency("pdf-writer", "~> 1.0.0", ">= 1.0.0")
|
32
34
|
s.extra_rdoc_files = ["HISTORY.txt", "TODO.txt"] +
|
33
35
|
Dir.glob("docs/*/*")
|
34
36
|
# s.rubyforge_project = 'ifmapper'
|
data/IFMapper.rbw
CHANGED
@@ -8,6 +8,8 @@ begin
|
|
8
8
|
rescue LoadError
|
9
9
|
end
|
10
10
|
|
11
|
+
load "IFMapper.gemspec"
|
12
|
+
|
11
13
|
def no_fox
|
12
14
|
require "IFMapper/locales/en/Messages.rb"
|
13
15
|
$stderr.puts ERR_NO_FOX
|
@@ -20,7 +22,7 @@ end
|
|
20
22
|
def get_fox
|
21
23
|
##### ARRRGH!!!! Why does Lyle keep changing the fxruby name on each
|
22
24
|
##### release!
|
23
|
-
foxes = [ 'fox16', 'fox14', 'fox12', 'fox' ]
|
25
|
+
foxes = [ 'fox18', 'fox17', 'fox16', 'fox14', 'fox12', 'fox' ]
|
24
26
|
foxes.each { |fox|
|
25
27
|
begin
|
26
28
|
require "#{fox}"
|
@@ -30,7 +32,7 @@ def get_fox
|
|
30
32
|
no_fox if fox == foxes[-1]
|
31
33
|
end
|
32
34
|
}
|
33
|
-
|
35
|
+
|
34
36
|
# verify fxruby version
|
35
37
|
ver, rev, = Fox::fxrubyversion().split('.')
|
36
38
|
no_fox if ver.to_i < 1 or rev.to_i < 2
|
@@ -40,7 +42,6 @@ end
|
|
40
42
|
get_fox
|
41
43
|
include Fox
|
42
44
|
|
43
|
-
load "IFMapper.gemspec"
|
44
45
|
require 'IFMapper/FXMap'
|
45
46
|
require 'IFMapper/FXMapperSettings'
|
46
47
|
require 'IFMapper/FXWarningBox'
|
@@ -185,8 +186,8 @@ class FXMapperWindow < FXMainWindow
|
|
185
186
|
# First, make sure we don't have it loaded already...
|
186
187
|
@maps.each { |m|
|
187
188
|
if m.filename == file
|
188
|
-
|
189
|
-
|
189
|
+
@mdiclient.setActiveChild(m.window)
|
190
|
+
return
|
190
191
|
end
|
191
192
|
}
|
192
193
|
|
@@ -196,10 +197,10 @@ class FXMapperWindow < FXMainWindow
|
|
196
197
|
make_new_map = false
|
197
198
|
if @maps.size == 1
|
198
199
|
@maps[0].sections.each { |p|
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
200
|
+
if p.rooms.size != 0
|
201
|
+
make_new_map = true
|
202
|
+
break
|
203
|
+
end
|
203
204
|
}
|
204
205
|
else
|
205
206
|
make_new_map = true
|
@@ -229,20 +230,20 @@ class FXMapperWindow < FXMainWindow
|
|
229
230
|
|
230
231
|
if not tmp.kind_of?(Map) and not tmp.kind_of?(FXMap)
|
231
232
|
$stderr.puts tmp
|
232
|
-
w = FXWarningBox.new( self,
|
233
|
-
|
233
|
+
w = FXWarningBox.new( self,
|
234
|
+
"#{tmp}")
|
234
235
|
w.execute
|
235
|
-
status "#{ERR_COULD_NOT_LOAD} '#{file}'."
|
236
|
+
status "#{ERR_COULD_NOT_LOAD} '#{file}'."
|
236
237
|
if make_new_map
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
238
|
+
if map.close_cb
|
239
|
+
@maps.delete(map)
|
240
|
+
GC.start
|
241
|
+
end
|
241
242
|
end
|
242
243
|
sleep 2
|
243
244
|
return
|
244
245
|
end
|
245
|
-
|
246
|
+
|
246
247
|
copy_map(map, tmp, file)
|
247
248
|
end
|
248
249
|
|
@@ -308,7 +309,7 @@ class FXMapperWindow < FXMainWindow
|
|
308
309
|
#
|
309
310
|
def language_cb(sender, msg, opts)
|
310
311
|
@@default_options['Language'] = LANGUAGES[sender.text]
|
311
|
-
|
312
|
+
|
312
313
|
require "IFMapper/locales/#{language}/Messages.rb"
|
313
314
|
recreate
|
314
315
|
end
|
@@ -319,19 +320,19 @@ class FXMapperWindow < FXMainWindow
|
|
319
320
|
def new_map
|
320
321
|
mapname = "#{MSG_EMPTY_MAP} \##{@maps.size+1}"
|
321
322
|
@maps.push( FXMap.new(mapname, @mdiclient, @@default_options.dup,
|
322
|
-
|
323
|
+
@mdiicon, @mdimenu, MDI_NORMAL, 0, 0, 790, 500) )
|
323
324
|
map = @maps[-1]
|
324
325
|
map.window.connect(SEL_PAINT) {
|
325
326
|
map.draw
|
326
327
|
}
|
327
328
|
map.window.connect(SEL_CLOSE) {
|
328
329
|
if map.close_cb
|
329
|
-
|
330
|
+
@maps.delete(map)
|
330
331
|
end
|
331
332
|
if @maps[-1]
|
332
|
-
|
333
|
+
@maps[-1].update_roomlist
|
333
334
|
else
|
334
|
-
|
335
|
+
FXMap::no_maps
|
335
336
|
end
|
336
337
|
}
|
337
338
|
|
@@ -381,7 +382,7 @@ class FXMapperWindow < FXMainWindow
|
|
381
382
|
def printer_dialog(title = MSG_PRINT_MAP)
|
382
383
|
map = current_map
|
383
384
|
dlg = FXPrintDialog.new(self, title + " for #{map.name}")
|
384
|
-
dlg.printer.flags |= PRINT_DEST_PAPER
|
385
|
+
dlg.printer.flags |= PRINT_DEST_PAPER
|
385
386
|
return dlg.printer if dlg.execute != 0
|
386
387
|
return false
|
387
388
|
end
|
@@ -409,10 +410,10 @@ class FXMapperWindow < FXMainWindow
|
|
409
410
|
return unless map
|
410
411
|
|
411
412
|
require 'IFMapper/FXMapFileDialog'
|
412
|
-
d = FXMapFileDialog.new(self, MSG_SAVE_MAP_AS_IFM,
|
413
|
-
|
414
|
-
|
415
|
-
|
413
|
+
d = FXMapFileDialog.new(self, MSG_SAVE_MAP_AS_IFM,
|
414
|
+
[
|
415
|
+
FMT_IFM
|
416
|
+
])
|
416
417
|
map.export_ifm(d.filename) if d.filename != ''
|
417
418
|
end
|
418
419
|
|
@@ -424,10 +425,10 @@ class FXMapperWindow < FXMainWindow
|
|
424
425
|
return unless map
|
425
426
|
|
426
427
|
require 'IFMapper/FXMapFileDialog'
|
427
|
-
d = FXMapFileDialog.new(self, MSG_SAVE_MAP_AS_TRIZBORT,
|
428
|
-
|
429
|
-
|
430
|
-
|
428
|
+
d = FXMapFileDialog.new(self, MSG_SAVE_MAP_AS_TRIZBORT,
|
429
|
+
[
|
430
|
+
FMT_TRIZBORT
|
431
|
+
])
|
431
432
|
map.export_trizbort(d.filename) if d.filename != ''
|
432
433
|
end
|
433
434
|
|
@@ -439,10 +440,10 @@ class FXMapperWindow < FXMainWindow
|
|
439
440
|
return unless map
|
440
441
|
|
441
442
|
require 'IFMapper/FXMapFileDialog'
|
442
|
-
d = FXMapFileDialog.new(self, MSG_SAVE_MAP_AS_INFORM6,
|
443
|
-
|
444
|
-
|
445
|
-
|
443
|
+
d = FXMapFileDialog.new(self, MSG_SAVE_MAP_AS_INFORM6,
|
444
|
+
[
|
445
|
+
FMT_INFORM6,
|
446
|
+
])
|
446
447
|
map.export_inform( d.filename ) if d.filename != ''
|
447
448
|
end
|
448
449
|
|
@@ -454,10 +455,10 @@ class FXMapperWindow < FXMainWindow
|
|
454
455
|
return unless map
|
455
456
|
|
456
457
|
require 'IFMapper/FXMapFileDialog'
|
457
|
-
d = FXMapFileDialog.new(self, MSG_SAVE_MAP_AS_INFORM7,
|
458
|
-
|
459
|
-
|
460
|
-
|
458
|
+
d = FXMapFileDialog.new(self, MSG_SAVE_MAP_AS_INFORM7,
|
459
|
+
[
|
460
|
+
FMT_INFORM7,
|
461
|
+
])
|
461
462
|
map.export_inform7( d.filename ) if d.filename != ''
|
462
463
|
end
|
463
464
|
|
@@ -471,10 +472,10 @@ class FXMapperWindow < FXMainWindow
|
|
471
472
|
|
472
473
|
require 'IFMapper/TADSWriter'
|
473
474
|
require 'IFMapper/FXMapFileDialog'
|
474
|
-
d = FXMapFileDialog.new(self, MSG_SAVE_MAP_AS_TADS,
|
475
|
-
|
476
|
-
|
477
|
-
|
475
|
+
d = FXMapFileDialog.new(self, MSG_SAVE_MAP_AS_TADS,
|
476
|
+
[
|
477
|
+
FMT_TADS
|
478
|
+
])
|
478
479
|
map.export_tads( d.filename ) if d.filename != ''
|
479
480
|
end
|
480
481
|
|
@@ -492,15 +493,15 @@ class FXMapperWindow < FXMainWindow
|
|
492
493
|
w.execute
|
493
494
|
return
|
494
495
|
end
|
495
|
-
|
496
|
+
|
496
497
|
require 'IFMapper/FXSVGMapExporterOptionsDialogBox'
|
497
|
-
cmd = FXSVGMapExporterOptionsDialogBox.new(self, MSG_SAVE_MAP_AS_SVG,
|
498
|
+
cmd = FXSVGMapExporterOptionsDialogBox.new(self, MSG_SAVE_MAP_AS_SVG,
|
498
499
|
map).execute
|
499
500
|
|
500
501
|
return if cmd == 0
|
501
502
|
|
502
503
|
require 'IFMapper/FXMapFileDialog'
|
503
|
-
d = FXMapFileDialog.new(self, MSG_SAVE_MAP_AS_SVG,
|
504
|
+
d = FXMapFileDialog.new(self, MSG_SAVE_MAP_AS_SVG,
|
504
505
|
[
|
505
506
|
FMT_SVG
|
506
507
|
])
|
@@ -524,22 +525,22 @@ class FXMapperWindow < FXMainWindow
|
|
524
525
|
w.execute
|
525
526
|
return
|
526
527
|
end
|
527
|
-
|
528
|
+
|
528
529
|
# PRE: Let's ask for a page size and orientation for the PDF
|
529
530
|
# and whether the user wants to include location numbers
|
530
531
|
map.pdfpapersize = 0
|
531
532
|
map.pdflocationnos = 1
|
532
533
|
require 'IFMapper/FXPDFMapExporterOptionsDialogBox'
|
533
|
-
cmd = FXPDFMapExporterOptionsDialogBox.new(self, MSG_SAVE_MAP_AS_PDF,
|
534
|
+
cmd = FXPDFMapExporterOptionsDialogBox.new(self, MSG_SAVE_MAP_AS_PDF,
|
534
535
|
map).execute
|
535
536
|
|
536
537
|
return if cmd == 0
|
537
538
|
|
538
539
|
require 'IFMapper/FXMapFileDialog'
|
539
|
-
d = FXMapFileDialog.new(self, MSG_SAVE_MAP_AS_PDF,
|
540
|
-
|
541
|
-
|
542
|
-
|
540
|
+
d = FXMapFileDialog.new(self, MSG_SAVE_MAP_AS_PDF,
|
541
|
+
[
|
542
|
+
FMT_PDF
|
543
|
+
])
|
543
544
|
if d.filename != ''
|
544
545
|
map.pdf_export(d.filename)
|
545
546
|
end
|
@@ -576,7 +577,7 @@ class FXMapperWindow < FXMainWindow
|
|
576
577
|
@maps = []
|
577
578
|
|
578
579
|
@mdiclient = FXMDIClient.new(self, LAYOUT_FILL_X|LAYOUT_FILL_Y)
|
579
|
-
@mdiclient.connect(SEL_CHANGED) {
|
580
|
+
@mdiclient.connect(SEL_CHANGED) {
|
580
581
|
update_map
|
581
582
|
}
|
582
583
|
|
@@ -601,7 +602,7 @@ class FXMapperWindow < FXMainWindow
|
|
601
602
|
end
|
602
603
|
|
603
604
|
#
|
604
|
-
# Return the copied elements
|
605
|
+
# Return the copied elements
|
605
606
|
#
|
606
607
|
def self.copy_buffer
|
607
608
|
return @@copy_buffer
|
@@ -624,9 +625,9 @@ class FXMapperWindow < FXMainWindow
|
|
624
625
|
# those rooms we selected
|
625
626
|
delete = []
|
626
627
|
links.each { |c|
|
627
|
-
if not rooms.include?(c.roomA) or
|
628
|
-
|
629
|
-
|
628
|
+
if not rooms.include?(c.roomA) or
|
629
|
+
(c.roomB and not rooms.include?(c.roomB))
|
630
|
+
delete << c
|
630
631
|
end
|
631
632
|
}
|
632
633
|
links -= delete
|
@@ -665,52 +666,52 @@ class FXMapperWindow < FXMainWindow
|
|
665
666
|
r_to_nr = {} # orig room to new room hash
|
666
667
|
rooms = sel[0]
|
667
668
|
rooms.each { |r|
|
668
|
-
|
669
|
-
|
670
|
-
|
671
|
-
|
669
|
+
nr = map.new_room(r.x + pos[0], r.y + pos[1])
|
670
|
+
nr.selected = true
|
671
|
+
nr.copy(r) # copy the room data
|
672
|
+
r_to_nr[r] = nr
|
672
673
|
}
|
673
674
|
|
674
675
|
if rooms.empty?
|
675
|
-
|
676
|
-
|
677
|
-
|
678
|
-
|
679
|
-
|
680
|
-
|
681
|
-
|
682
|
-
|
683
|
-
|
684
|
-
|
685
|
-
|
686
|
-
|
687
|
-
|
688
|
-
|
689
|
-
|
690
|
-
|
691
|
-
|
692
|
-
|
676
|
+
# Add connections only (no rooms copied)
|
677
|
+
sel[1].each { |c|
|
678
|
+
exitA, exitB = c.dirs
|
679
|
+
roomA = c.roomA
|
680
|
+
roomB = c.roomB
|
681
|
+
sect = map.sections[map.section]
|
682
|
+
if not sect.rooms.include?(roomA) or
|
683
|
+
(roomB and not sect.rooms.include?(roomB))
|
684
|
+
next
|
685
|
+
end
|
686
|
+
begin
|
687
|
+
nc = map.new_connection(roomA, exitA, roomB, exitB)
|
688
|
+
nc.selected = true
|
689
|
+
nc.dir = c.dir
|
690
|
+
nc.type = c.type
|
691
|
+
rescue
|
692
|
+
end
|
693
|
+
}
|
693
694
|
else
|
694
|
-
|
695
|
-
|
696
|
-
|
697
|
-
|
698
|
-
|
699
|
-
|
700
|
-
|
701
|
-
|
702
|
-
|
703
|
-
|
704
|
-
|
705
|
-
|
706
|
-
|
707
|
-
|
708
|
-
|
709
|
-
|
710
|
-
|
711
|
-
|
712
|
-
|
713
|
-
|
695
|
+
# Add connections
|
696
|
+
sel[1].each { |c|
|
697
|
+
exitA, exitB = c.dirs
|
698
|
+
roomA = r_to_nr[c.roomA]
|
699
|
+
if c.roomB
|
700
|
+
roomB = r_to_nr[c.roomB]
|
701
|
+
else
|
702
|
+
roomB = nil
|
703
|
+
end
|
704
|
+
next if not roomA
|
705
|
+
begin
|
706
|
+
nc = map.new_connection(roomA, exitA, roomB, exitB)
|
707
|
+
nc.selected = true
|
708
|
+
nc.dir = c.dir
|
709
|
+
nc.type = c.type
|
710
|
+
rescue Section::ConnectionError => e
|
711
|
+
puts c
|
712
|
+
puts e
|
713
|
+
end
|
714
|
+
}
|
714
715
|
end
|
715
716
|
|
716
717
|
map.create_pathmap
|
@@ -756,7 +757,7 @@ class FXMapperWindow < FXMainWindow
|
|
756
757
|
s.rooms.each { |r| r.selected = false }
|
757
758
|
}
|
758
759
|
|
759
|
-
matches.each { |p, r|
|
760
|
+
matches.each { |p, r|
|
760
761
|
next if p != map.section
|
761
762
|
r.selected = true
|
762
763
|
}
|
@@ -781,8 +782,8 @@ class FXMapperWindow < FXMainWindow
|
|
781
782
|
matches = []
|
782
783
|
(0...map.sections.size).each { |p|
|
783
784
|
map.sections[p].rooms.each { |r|
|
784
|
-
|
785
|
-
|
785
|
+
next unless r.name =~ re
|
786
|
+
matches.push( [p, r] )
|
786
787
|
}
|
787
788
|
}
|
788
789
|
idx = @search.index
|
@@ -850,8 +851,8 @@ class FXMapperWindow < FXMainWindow
|
|
850
851
|
matches = []
|
851
852
|
(0...map.sections.size).each { |p|
|
852
853
|
map.sections[p].rooms.each { |r|
|
853
|
-
|
854
|
-
|
854
|
+
next unless r.objects =~ re
|
855
|
+
matches.push( [p, r] )
|
855
856
|
}
|
856
857
|
}
|
857
858
|
idx = @search.index
|
@@ -870,8 +871,8 @@ class FXMapperWindow < FXMainWindow
|
|
870
871
|
matches = []
|
871
872
|
(0...map.sections.size).each { |p|
|
872
873
|
map.sections[p].rooms.each { |r|
|
873
|
-
|
874
|
-
|
874
|
+
next unless r.tasks =~ re
|
875
|
+
matches.push( [p, r] )
|
875
876
|
}
|
876
877
|
}
|
877
878
|
idx = @search.index
|
@@ -926,8 +927,8 @@ class FXMapperWindow < FXMainWindow
|
|
926
927
|
matches = []
|
927
928
|
(0...map.sections.size).each { |p|
|
928
929
|
map.sections[p].rooms.each { |r|
|
929
|
-
|
930
|
-
|
930
|
+
next unless r.desc =~ re
|
931
|
+
matches.push( [p, r] )
|
931
932
|
}
|
932
933
|
}
|
933
934
|
idx = @search.index
|
@@ -1003,8 +1004,8 @@ class FXMapperWindow < FXMainWindow
|
|
1003
1004
|
|
1004
1005
|
def about_cb(sender, id, event )
|
1005
1006
|
require 'IFMapper/FXAboutDialogBox'
|
1006
|
-
FXAboutDialogBox.new(self, MSG_ABOUT_SOFTWARE,
|
1007
|
-
|
1007
|
+
FXAboutDialogBox.new(self, MSG_ABOUT_SOFTWARE,
|
1008
|
+
eval("\"#{MSG_ABOUT}\"")).execute
|
1008
1009
|
end
|
1009
1010
|
|
1010
1011
|
|
@@ -1026,7 +1027,7 @@ class FXMapperWindow < FXMainWindow
|
|
1026
1027
|
cmd = FXMenuCommand.new(filemenu, MENU_SAVE, savedoc)
|
1027
1028
|
cmd.connect(SEL_COMMAND, method(:save_cb))
|
1028
1029
|
cmd = FXMenuCommand.new(filemenu, MENU_SAVE_AS,
|
1029
|
-
|
1030
|
+
saveasdoc)
|
1030
1031
|
cmd.connect(SEL_COMMAND, method(:save_as_cb))
|
1031
1032
|
|
1032
1033
|
# Export submenu
|
@@ -1034,7 +1035,7 @@ class FXMapperWindow < FXMainWindow
|
|
1034
1035
|
|
1035
1036
|
cmd = FXMenuCommand.new(submenu, MENU_EXPORT_PDF, nil)
|
1036
1037
|
cmd.connect(SEL_COMMAND, method(:pdf_export_cb))
|
1037
|
-
|
1038
|
+
|
1038
1039
|
cmd = FXMenuCommand.new(submenu, MENU_EXPORT_SVG, nil)
|
1039
1040
|
cmd.connect(SEL_COMMAND, method(:svg_export_cb))
|
1040
1041
|
|
@@ -1074,9 +1075,9 @@ class FXMapperWindow < FXMainWindow
|
|
1074
1075
|
cmd.connect(SEL_COMMAND, method(:copy_selected_cb))
|
1075
1076
|
cmd = FXMenuCommand.new(editmenu, MENU_CUT, nil)
|
1076
1077
|
cmd.connect(SEL_COMMAND, method(:cut_selected_cb))
|
1077
|
-
cmd = FXMenuCommand.new(editmenu, MENU_PASTE, nil)
|
1078
|
+
cmd = FXMenuCommand.new(editmenu, MENU_PASTE, nil)
|
1078
1079
|
cmd.connect(SEL_COMMAND, method(:paste_selected_cb))
|
1079
|
-
#cmd = FXMenuCommand.new(editmenu, MENU_UNDO, nil)
|
1080
|
+
#cmd = FXMenuCommand.new(editmenu, MENU_UNDO, nil)
|
1080
1081
|
#cmd.connect(SEL_COMMAND, method(:undo_cb))
|
1081
1082
|
|
1082
1083
|
# Select submenu
|
@@ -1139,55 +1140,55 @@ class FXMapperWindow < FXMainWindow
|
|
1139
1140
|
# Sections submenu
|
1140
1141
|
submenu = FXMenuPane.new(self)
|
1141
1142
|
cmd = FXMenuCommand.new(submenu, MENU_NEXT_SECTION)
|
1142
|
-
cmd.connect(SEL_COMMAND) {
|
1143
|
+
cmd.connect(SEL_COMMAND) {
|
1143
1144
|
next_section
|
1144
1145
|
}
|
1145
1146
|
cmd = FXMenuCommand.new(submenu, MENU_PREVIOUS_SECTION)
|
1146
|
-
cmd.connect(SEL_COMMAND) {
|
1147
|
+
cmd.connect(SEL_COMMAND) {
|
1147
1148
|
previous_section
|
1148
1149
|
}
|
1149
1150
|
FXMenuSeparator.new(submenu)
|
1150
1151
|
cmd = FXMenuCommand.new(submenu, MENU_ADD_SECTION)
|
1151
|
-
cmd.connect(SEL_COMMAND) {
|
1152
|
+
cmd.connect(SEL_COMMAND) {
|
1152
1153
|
map = current_map
|
1153
1154
|
if map
|
1154
|
-
|
1155
|
-
|
1156
|
-
|
1155
|
+
map.new_section
|
1156
|
+
map.modified = true
|
1157
|
+
update_section
|
1157
1158
|
end
|
1158
1159
|
}
|
1159
1160
|
cmd = FXMenuCommand.new(submenu, MENU_SECTION_INFO)
|
1160
|
-
cmd.connect(SEL_COMMAND) {
|
1161
|
+
cmd.connect(SEL_COMMAND) {
|
1161
1162
|
map = current_map
|
1162
1163
|
if map
|
1163
|
-
|
1164
|
-
|
1164
|
+
map.rename_section
|
1165
|
+
map.modified = true
|
1165
1166
|
end
|
1166
1167
|
}
|
1167
1168
|
FXMenuSeparator.new(submenu)
|
1168
1169
|
cmd = FXMenuCommand.new(submenu, MENU_DELETE_SECTION)
|
1169
|
-
cmd.connect(SEL_COMMAND) {
|
1170
|
+
cmd.connect(SEL_COMMAND) {
|
1170
1171
|
map = current_map
|
1171
1172
|
if map
|
1172
|
-
|
1173
|
-
|
1174
|
-
|
1173
|
+
map.delete_section
|
1174
|
+
map.modified = true
|
1175
|
+
update_section
|
1175
1176
|
end
|
1176
1177
|
}
|
1177
1178
|
FXMenuCascade.new(mapmenu, MENU_SECTIONS, nil, submenu)
|
1178
|
-
|
1179
|
+
|
1179
1180
|
#
|
1180
1181
|
# Zoom submenu
|
1181
1182
|
#
|
1182
1183
|
submenu = FXMenuPane.new(self)
|
1183
|
-
[25, 50, 75, 100, 125].each { |v|
|
1184
|
+
[25, 50, 75, 100, 125].each { |v|
|
1184
1185
|
cmd = FXMenuCommand.new(submenu, eval("\"#{MENU_ZOOM_PERCENT}\""))
|
1185
|
-
cmd.connect(SEL_COMMAND) {
|
1186
|
-
|
1187
|
-
|
1188
|
-
|
1189
|
-
|
1190
|
-
|
1186
|
+
cmd.connect(SEL_COMMAND) {
|
1187
|
+
map = current_map
|
1188
|
+
if map
|
1189
|
+
map.zoom = v / 100.0
|
1190
|
+
map.draw
|
1191
|
+
end
|
1191
1192
|
}
|
1192
1193
|
}
|
1193
1194
|
FXMenuCascade.new(mapmenu, MENU_ZOOM, nil, submenu)
|
@@ -1199,7 +1200,7 @@ class FXMapperWindow < FXMainWindow
|
|
1199
1200
|
cmd.connect(SEL_COMMAND) { |s, m, e|
|
1200
1201
|
map = current_map
|
1201
1202
|
if map
|
1202
|
-
|
1203
|
+
map.options['Edit on Creation'] = (s.check == true)
|
1203
1204
|
end
|
1204
1205
|
}
|
1205
1206
|
cmd.connect(SEL_UPDATE) { |s, m, e|
|
@@ -1212,7 +1213,7 @@ class FXMapperWindow < FXMainWindow
|
|
1212
1213
|
cmd.connect(SEL_COMMAND) { |s, m, e|
|
1213
1214
|
map = current_map
|
1214
1215
|
if map
|
1215
|
-
|
1216
|
+
map.options['Automatic Connection'] = (s.check == true)
|
1216
1217
|
end
|
1217
1218
|
}
|
1218
1219
|
cmd.connect(SEL_UPDATE) { |s, m, e|
|
@@ -1242,8 +1243,8 @@ class FXMapperWindow < FXMainWindow
|
|
1242
1243
|
cmd.connect(SEL_COMMAND) { |s, m, e|
|
1243
1244
|
map = current_map
|
1244
1245
|
if map
|
1245
|
-
|
1246
|
-
|
1246
|
+
map.options['Use Room Cursor'] = (s.check == true)
|
1247
|
+
map.draw
|
1247
1248
|
end
|
1248
1249
|
}
|
1249
1250
|
cmd.connect(SEL_UPDATE) { |s, m, e|
|
@@ -1256,8 +1257,8 @@ class FXMapperWindow < FXMainWindow
|
|
1256
1257
|
cmd.connect(SEL_COMMAND) { |s, m, e|
|
1257
1258
|
map = current_map
|
1258
1259
|
if map
|
1259
|
-
|
1260
|
-
|
1260
|
+
map.options['Paths as Curves'] = (s.check == true)
|
1261
|
+
map.draw
|
1261
1262
|
end
|
1262
1263
|
}
|
1263
1264
|
cmd.connect(SEL_UPDATE) { |s, m, e|
|
@@ -1269,8 +1270,8 @@ class FXMapperWindow < FXMainWindow
|
|
1269
1270
|
cmd.connect(SEL_COMMAND) { |s, m, e|
|
1270
1271
|
map = current_map
|
1271
1272
|
if map
|
1272
|
-
|
1273
|
-
|
1273
|
+
map.options['Location Numbers'] = (s.check == true)
|
1274
|
+
map.draw
|
1274
1275
|
end
|
1275
1276
|
}
|
1276
1277
|
cmd.connect(SEL_UPDATE) { |s, m, e|
|
@@ -1283,8 +1284,8 @@ class FXMapperWindow < FXMainWindow
|
|
1283
1284
|
cmd.connect(SEL_COMMAND) { |s, m, e|
|
1284
1285
|
map = current_map
|
1285
1286
|
if map
|
1286
|
-
|
1287
|
-
|
1287
|
+
map.options['Location Tasks'] = (s.check == true)
|
1288
|
+
map.draw
|
1288
1289
|
end
|
1289
1290
|
}
|
1290
1291
|
cmd.connect(SEL_UPDATE) { |s, m, e|
|
@@ -1297,8 +1298,8 @@ class FXMapperWindow < FXMainWindow
|
|
1297
1298
|
cmd.connect(SEL_COMMAND) { |s, m, e|
|
1298
1299
|
map = current_map
|
1299
1300
|
if map
|
1300
|
-
|
1301
|
-
|
1301
|
+
map.options['Location Description'] = (s.check == true)
|
1302
|
+
map.draw
|
1302
1303
|
end
|
1303
1304
|
}
|
1304
1305
|
cmd.connect(SEL_UPDATE) { |s, m, e|
|
@@ -1311,8 +1312,8 @@ class FXMapperWindow < FXMainWindow
|
|
1311
1312
|
cmd.connect(SEL_COMMAND) { |s, m, e|
|
1312
1313
|
map = current_map
|
1313
1314
|
if map
|
1314
|
-
|
1315
|
-
|
1315
|
+
map.options['Grid Boxes'] = (s.check == true)
|
1316
|
+
map.draw
|
1316
1317
|
end
|
1317
1318
|
}
|
1318
1319
|
cmd.connect(SEL_UPDATE) { |s, m, e|
|
@@ -1325,8 +1326,8 @@ class FXMapperWindow < FXMainWindow
|
|
1325
1326
|
cmd.connect(SEL_COMMAND) { |s, m, e|
|
1326
1327
|
map = current_map
|
1327
1328
|
if map
|
1328
|
-
|
1329
|
-
|
1329
|
+
map.options['Grid Straight Connections'] = (s.check == true)
|
1330
|
+
map.draw
|
1330
1331
|
end
|
1331
1332
|
}
|
1332
1333
|
cmd.connect(SEL_UPDATE) { |s, m, e|
|
@@ -1339,8 +1340,8 @@ class FXMapperWindow < FXMainWindow
|
|
1339
1340
|
cmd.connect(SEL_COMMAND) { |s, m, e|
|
1340
1341
|
map = current_map
|
1341
1342
|
if map
|
1342
|
-
|
1343
|
-
|
1343
|
+
map.options['Grid Diagonal Connections'] = s.check
|
1344
|
+
map.draw
|
1344
1345
|
end
|
1345
1346
|
}
|
1346
1347
|
cmd.connect(SEL_UPDATE) { |s, m, e|
|
@@ -1363,11 +1364,11 @@ class FXMapperWindow < FXMainWindow
|
|
1363
1364
|
# }
|
1364
1365
|
|
1365
1366
|
# FXMenuCascade.new(mapmenu, MENU_LANGUAGE, nil, langmenu)
|
1366
|
-
|
1367
|
+
|
1367
1368
|
|
1368
1369
|
FXMenuSeparator.new(submenu)
|
1369
1370
|
cmd = FXMenuCommand.new(submenu, MENU_SAVE_PREFS)
|
1370
|
-
cmd.connect(SEL_COMMAND) {
|
1371
|
+
cmd.connect(SEL_COMMAND) {
|
1371
1372
|
map = current_map
|
1372
1373
|
map.options.write if map
|
1373
1374
|
}
|
@@ -1392,8 +1393,8 @@ class FXMapperWindow < FXMainWindow
|
|
1392
1393
|
FXMenuCommand.new(windowmenu, nil, nil, @mdiclient, FXMDIClient::ID_MDI_2)
|
1393
1394
|
FXMenuCommand.new(windowmenu, nil, nil, @mdiclient, FXMDIClient::ID_MDI_3)
|
1394
1395
|
FXMenuCommand.new(windowmenu, nil, nil, @mdiclient, FXMDIClient::ID_MDI_4)
|
1395
|
-
FXMenuCommand.new(windowmenu, MENU_OTHERS, nil, @mdiclient,
|
1396
|
-
|
1396
|
+
FXMenuCommand.new(windowmenu, MENU_OTHERS, nil, @mdiclient,
|
1397
|
+
FXMDIClient::ID_MDI_OVER_5)
|
1397
1398
|
FXMenuTitle.new(@menubar, MENU_WINDOW, nil, windowmenu)
|
1398
1399
|
|
1399
1400
|
# Help menu
|
@@ -1409,14 +1410,14 @@ class FXMapperWindow < FXMainWindow
|
|
1409
1410
|
cmd = FXMenuCommand.new(helpmenu, MENU_RESOURCE, nil)
|
1410
1411
|
cmd.connect(SEL_COMMAND) {
|
1411
1412
|
require 'IFMapper/FXMapFileDialog'
|
1412
|
-
file = FXMapFileDialog.new(self, "Resource a Ruby File",
|
1413
|
-
|
1413
|
+
file = FXMapFileDialog.new(self, "Resource a Ruby File",
|
1414
|
+
['Ruby File (*.rb)']).filename
|
1414
1415
|
if file != ''
|
1415
|
-
|
1416
|
-
|
1417
|
-
|
1418
|
-
|
1419
|
-
|
1416
|
+
begin
|
1417
|
+
Kernel.load file
|
1418
|
+
rescue => e
|
1419
|
+
p e
|
1420
|
+
end
|
1420
1421
|
end
|
1421
1422
|
}
|
1422
1423
|
FXMenuTitle.new(@menubar, MENU_HELP, nil, helpmenu)
|
@@ -1456,7 +1457,7 @@ class FXMapperWindow < FXMainWindow
|
|
1456
1457
|
|
1457
1458
|
# File manipulation
|
1458
1459
|
cmd = FXButton.new(toolbar, ICON_NEW, newdoc, nil, 0,
|
1459
|
-
|
1460
|
+
FRAME_THICK|FRAME_RAISED|LAYOUT_TOP|LAYOUT_LEFT)
|
1460
1461
|
cmd.connect(SEL_COMMAND, method(:new_map_cb))
|
1461
1462
|
|
1462
1463
|
cmd = FXButton.new(toolbar, ICON_OPEN, opendoc, nil, 0,
|
@@ -1484,15 +1485,15 @@ class FXMapperWindow < FXMainWindow
|
|
1484
1485
|
FXFrame.new(toolbar,
|
1485
1486
|
LAYOUT_TOP|LAYOUT_LEFT|LAYOUT_FIX_WIDTH|LAYOUT_FIX_HEIGHT, 0, 0, 4, 20)
|
1486
1487
|
cmd = FXButton.new(toolbar, ICON_PRINT,
|
1487
|
-
|
1488
|
-
|
1488
|
+
load_icon("printicon"), @mdiclient, FXGLViewer::ID_PRINT_IMAGE,
|
1489
|
+
BUTTON_AUTOGRAY|FRAME_THICK|FRAME_RAISED|LAYOUT_TOP|LAYOUT_LEFT)
|
1489
1490
|
cmd.connect(SEL_COMMAND, method(:print_cb))
|
1490
1491
|
cmd.connect(SEL_UPDATE) { |sender, sel, ptr|
|
1491
1492
|
map = current_map
|
1492
1493
|
message = map ? FXWindow::ID_ENABLE : FXWindow::ID_DISABLE
|
1493
1494
|
sender.handle(self, MKUINT(message, SEL_COMMAND), nil)
|
1494
1495
|
}
|
1495
|
-
|
1496
|
+
|
1496
1497
|
# Editing
|
1497
1498
|
FXFrame.new(toolbar,
|
1498
1499
|
LAYOUT_TOP|LAYOUT_LEFT|LAYOUT_FIX_WIDTH|LAYOUT_FIX_HEIGHT, 0, 0, 4, 20)
|
@@ -1528,43 +1529,43 @@ class FXMapperWindow < FXMainWindow
|
|
1528
1529
|
FXFrame.new(toolbar,
|
1529
1530
|
LAYOUT_TOP|LAYOUT_LEFT|LAYOUT_FIX_WIDTH|LAYOUT_FIX_HEIGHT, 0, 0, 4, 20)
|
1530
1531
|
cmd = FXButton.new(toolbar, ICON_ZOOM_IN, load_icon("zoom"), @mdiclient,
|
1531
|
-
|
1532
|
+
0, FRAME_THICK|FRAME_RAISED|LAYOUT_TOP|LAYOUT_LEFT)
|
1532
1533
|
cmd.connect(SEL_COMMAND) { zoom_in }
|
1533
1534
|
|
1534
|
-
cmd = FXButton.new(toolbar, ICON_ZOOM_OUT, load_icon("zoom"), @mdiclient,
|
1535
|
-
|
1535
|
+
cmd = FXButton.new(toolbar, ICON_ZOOM_OUT, load_icon("zoom"), @mdiclient,
|
1536
|
+
0, FRAME_THICK|FRAME_RAISED|LAYOUT_TOP|LAYOUT_LEFT)
|
1536
1537
|
cmd.connect(SEL_COMMAND) { zoom_out }
|
1537
1538
|
|
1538
1539
|
|
1539
1540
|
# Section travel
|
1540
1541
|
frame = FXHorizontalFrame.new(toolbar,
|
1541
|
-
|
1542
|
-
cmd = FXButton.new(frame, ICON_PREV_SECTION, load_icon("prevpage"),
|
1543
|
-
|
1544
|
-
|
1542
|
+
LAYOUT_RIGHT|FRAME_THICK|FRAME_RAISED)
|
1543
|
+
cmd = FXButton.new(frame, ICON_PREV_SECTION, load_icon("prevpage"),
|
1544
|
+
@mdiclient,
|
1545
|
+
0, FRAME_THICK|FRAME_RAISED|LAYOUT_TOP|LAYOUT_LEFT)
|
1545
1546
|
cmd.connect(SEL_COMMAND) { previous_section }
|
1546
1547
|
|
1547
|
-
@section = FXTextField.new(frame, 5, nil, 0,
|
1548
|
-
|
1548
|
+
@section = FXTextField.new(frame, 5, nil, 0,
|
1549
|
+
TEXTFIELD_INTEGER|LAYOUT_FILL_ROW)
|
1549
1550
|
@section.text = '1'
|
1550
|
-
@section.connect(SEL_COMMAND) { |s,m,e|
|
1551
|
+
@section.connect(SEL_COMMAND) { |s,m,e|
|
1551
1552
|
v = s.text.to_i
|
1552
1553
|
map = current_map
|
1553
1554
|
if map
|
1554
|
-
|
1555
|
-
|
1556
|
-
|
1555
|
+
map.section = v - 1
|
1556
|
+
map.draw
|
1557
|
+
update_section
|
1557
1558
|
end
|
1558
1559
|
}
|
1559
|
-
@section.connect(SEL_UPDATE) { |s,m,e|
|
1560
|
+
@section.connect(SEL_UPDATE) { |s,m,e|
|
1560
1561
|
map = current_map
|
1561
1562
|
update_section if map
|
1562
1563
|
}
|
1563
1564
|
|
1564
|
-
cmd = FXButton.new(frame, ICON_NEXT_SECTION, load_icon("nextpage"),
|
1565
|
-
|
1566
|
-
|
1567
|
-
cmd.connect(SEL_COMMAND) { next_section }
|
1565
|
+
cmd = FXButton.new(frame, ICON_NEXT_SECTION, load_icon("nextpage"),
|
1566
|
+
@mdiclient,
|
1567
|
+
0, FRAME_THICK|FRAME_RAISED|LAYOUT_TOP|LAYOUT_LEFT)
|
1568
|
+
cmd.connect(SEL_COMMAND) { next_section }
|
1568
1569
|
end
|
1569
1570
|
|
1570
1571
|
#
|
@@ -1588,7 +1589,7 @@ class FXMapperWindow < FXMainWindow
|
|
1588
1589
|
#
|
1589
1590
|
# Go to previous section in current map
|
1590
1591
|
#
|
1591
|
-
def previous_section
|
1592
|
+
def previous_section
|
1592
1593
|
map = current_map
|
1593
1594
|
map.previous_section if map
|
1594
1595
|
update_section
|
@@ -1640,20 +1641,20 @@ class FXMapperWindow < FXMainWindow
|
|
1640
1641
|
@menubar = FXMenuBar.new(self, LAYOUT_SIDE_TOP|LAYOUT_FILL_X)
|
1641
1642
|
|
1642
1643
|
FXHorizontalSeparator.new(self,
|
1643
|
-
|
1644
|
+
LAYOUT_SIDE_TOP|SEPARATOR_GROOVE|LAYOUT_FILL_X)
|
1644
1645
|
toolbar = FXToolBar.new(self, LAYOUT_SIDE_TOP|LAYOUT_FILL_X,
|
1645
1646
|
0, 0, 0, 0, 4, 4, 0, 0, 0, 0)
|
1646
|
-
|
1647
|
+
|
1647
1648
|
# Status bar
|
1648
1649
|
@statusbar = FXStatusBar.new(self,
|
1649
|
-
|
1650
|
-
|
1650
|
+
LAYOUT_SIDE_BOTTOM|LAYOUT_FILL_X|
|
1651
|
+
STATUSBAR_WITH_DRAGCORNER)
|
1651
1652
|
|
1652
1653
|
|
1653
1654
|
create_mdiclient
|
1654
1655
|
create_menus
|
1655
1656
|
create_toolbar(toolbar)
|
1656
|
-
|
1657
|
+
|
1657
1658
|
|
1658
1659
|
self.connect(SEL_CLOSE, method(:close_cb))
|
1659
1660
|
show
|
@@ -1663,13 +1664,13 @@ class FXMapperWindow < FXMainWindow
|
|
1663
1664
|
|
1664
1665
|
def initialize(app)
|
1665
1666
|
super(app, eval("\"#{TITLE}\""), nil, nil, DECOR_ALL, 0, 0, 800, 600)
|
1666
|
-
|
1667
|
+
|
1667
1668
|
@colors = nil
|
1668
1669
|
@mdimenu = nil
|
1669
1670
|
@search = nil
|
1670
1671
|
|
1671
1672
|
create_widgets
|
1672
|
-
|
1673
|
+
|
1673
1674
|
|
1674
1675
|
# Trap CTRL-C signals and exit nicely
|
1675
1676
|
trap('SIGINT') {
|
@@ -1680,13 +1681,13 @@ class FXMapperWindow < FXMainWindow
|
|
1680
1681
|
|
1681
1682
|
def close_cb(*args)
|
1682
1683
|
exit = true
|
1683
|
-
@maps.each { |m|
|
1684
|
-
|
1685
|
-
|
1686
|
-
|
1687
|
-
|
1688
|
-
|
1689
|
-
|
1684
|
+
@maps.each { |m|
|
1685
|
+
if not m.close_cb
|
1686
|
+
exit = false
|
1687
|
+
break
|
1688
|
+
else
|
1689
|
+
@maps.delete(m)
|
1690
|
+
end
|
1690
1691
|
}
|
1691
1692
|
self.close if exit
|
1692
1693
|
end
|
data/lib/IFMapper/MapPrinting.rb
CHANGED
@@ -1,3 +1,7 @@
|
|
1
|
+
# Default constants
|
2
|
+
FIG_NONE = false
|
3
|
+
FIG_PORTRAIT = :portrait
|
4
|
+
FIG_LANDSCAPE = :landscape
|
1
5
|
|
2
6
|
# Common printing add-ons
|
3
7
|
class FXSection
|
@@ -14,7 +18,7 @@ class Page
|
|
14
18
|
end
|
15
19
|
end
|
16
20
|
|
17
|
-
class Map
|
21
|
+
class Map
|
18
22
|
#
|
19
23
|
# This code section is largely a copy of similar code used in
|
20
24
|
# IFM's C code.
|
@@ -31,8 +35,8 @@ class Map
|
|
31
35
|
sect.yoff = 0.0
|
32
36
|
|
33
37
|
page = Page.new(xlen+2, ylen+2)
|
34
|
-
pages.push page
|
35
38
|
page.sections << sect
|
39
|
+
pages << page
|
36
40
|
}
|
37
41
|
|
38
42
|
ratio = xmax.to_f / ymax
|
@@ -42,100 +46,100 @@ class Map
|
|
42
46
|
newpages = []
|
43
47
|
pos = packed = 0
|
44
48
|
while pos < pages.size
|
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
|
-
|
76
|
-
|
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
|
-
|
49
|
+
p1 = pages[pos]
|
50
|
+
x1 = p1.xlen
|
51
|
+
y1 = p1.ylen
|
52
|
+
|
53
|
+
# Check if it's better off rotated
|
54
|
+
p1.rotate = ((x1 < y1 and xmax > ymax) or
|
55
|
+
(x1 > y1 and xmax < ymax))
|
56
|
+
|
57
|
+
# Check if this is the last page
|
58
|
+
if pos + 1 == pages.size
|
59
|
+
newpages.push p1
|
60
|
+
break
|
61
|
+
end
|
62
|
+
|
63
|
+
# Get following page
|
64
|
+
p2 = pages[pos+1]
|
65
|
+
x2 = p2.xlen
|
66
|
+
y2 = p2.ylen
|
67
|
+
|
68
|
+
# Try combining pages in X direction
|
69
|
+
xc1 = x1 + x2 + spacing
|
70
|
+
yc1 = [y1, y2].max
|
71
|
+
v1 = (xc1 <= xmax and yc1 <= ymax)
|
72
|
+
r1 = xc1.to_f / yc1
|
73
|
+
|
74
|
+
# Try combining pages in Y direction
|
75
|
+
xc2 = [x1, x2].max
|
76
|
+
yc2 = y1 + y2 + spacing
|
77
|
+
v2 = (xc2 <= xmax and yc2 <= ymax)
|
78
|
+
r2 = xc2.to_f / yc2
|
79
|
+
|
80
|
+
# See which is best
|
81
|
+
if v1 and v2
|
82
|
+
if (ratio - r1).abs < (ratio - r2).abs
|
83
|
+
v2 = false
|
84
|
+
else
|
85
|
+
v1 = false
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
# Just copy page if nothing can be done
|
90
|
+
if not v1 and not v2
|
91
|
+
newpages.push(p1)
|
92
|
+
pos += 1
|
93
|
+
next
|
94
|
+
end
|
95
|
+
|
96
|
+
# Create merged page
|
97
|
+
page = Page.new
|
98
|
+
xo1 = yo1 = xo2 = yo2 = 0
|
99
|
+
|
100
|
+
if v1
|
101
|
+
page.xlen = xc1
|
102
|
+
page.ylen = yc1
|
103
|
+
xo2 = x1 + spacing
|
104
|
+
|
105
|
+
if y1 < y2
|
106
|
+
yo1 = (yc1 - y1) / 2
|
107
|
+
else
|
108
|
+
yo2 = (yc1 - y2) / 2
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
if v2
|
113
|
+
page.xlen = xc2
|
114
|
+
page.ylen = yc2
|
115
|
+
yo1 = y2 + spacing
|
116
|
+
|
117
|
+
if x1 < x2
|
118
|
+
xo1 = (xc2 - x1) / 2
|
119
|
+
else
|
120
|
+
xo2 = (xc2 - x2) / 2
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
124
|
+
# Copy sections to new page, updating offsets
|
125
|
+
opsects = p1.sections
|
126
|
+
opsects.each { |sect|
|
127
|
+
page.sections.push sect
|
128
|
+
sect.xoff += xo1
|
129
|
+
sect.yoff += yo1
|
130
|
+
}
|
131
|
+
|
132
|
+
opsects = p2.sections
|
133
|
+
opsects.each { |sect|
|
134
|
+
page.sections.push sect
|
135
|
+
sect.xoff += xo2
|
136
|
+
sect.yoff += yo2
|
137
|
+
}
|
138
|
+
|
139
|
+
# Add merged page to list and go to next page pair
|
140
|
+
newpages.push page
|
141
|
+
pos += 2
|
142
|
+
packed += 1
|
139
143
|
end
|
140
144
|
pages = newpages
|
141
145
|
end
|
@@ -150,13 +154,12 @@ class Map
|
|
150
154
|
|
151
155
|
num += 1
|
152
156
|
psects.each { |sect|
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
+
sect.page = num
|
158
|
+
sect.pxlen = xlen
|
159
|
+
sect.pylen = ylen
|
160
|
+
sect.rotate = rflag
|
157
161
|
}
|
158
162
|
}
|
159
163
|
return num
|
160
164
|
end
|
161
165
|
end
|
162
|
-
|
@@ -21,6 +21,8 @@ PDF_ROOM_WS = WS * PDF_ZOOM
|
|
21
21
|
PDF_ROOM_HS = HS * PDF_ZOOM
|
22
22
|
PDF_MARGIN = 20.0
|
23
23
|
|
24
|
+
|
25
|
+
|
24
26
|
#
|
25
27
|
# Open all the map class and add all pdf methods there
|
26
28
|
# Gotta love Ruby's flexibility to just inject in new methods.
|
@@ -186,14 +188,16 @@ class FXConnection
|
|
186
188
|
dir = @room[0].exits.index(self)
|
187
189
|
x, y = @room[0].pdf_corner(opts, self, dir)
|
188
190
|
pdf.move_to(x, y)
|
189
|
-
|
191
|
+
# WAS: y+4 below
|
192
|
+
pdf_draw_text( pdf, x, y, dir,
|
190
193
|
EXIT_TEXT[@exitText[0]], @dir == BtoA)
|
191
194
|
end
|
192
195
|
|
193
196
|
if @exitText[1] != 0
|
194
197
|
dir = @room[1].exits.rindex(self)
|
195
198
|
x, y = @room[1].pdf_corner(opts, self, dir)
|
196
|
-
|
199
|
+
# WAS: y+4 below
|
200
|
+
pdf_draw_text( pdf, x, y, dir,
|
197
201
|
EXIT_TEXT[@exitText[1]], @dir == AtoB)
|
198
202
|
end
|
199
203
|
end
|
@@ -273,18 +277,31 @@ class FXRoom
|
|
273
277
|
pdf.stroke_color '000000'
|
274
278
|
pdf.fill_color '000000'
|
275
279
|
|
280
|
+
# WAS: y+7
|
276
281
|
pdf.text_box locationno,
|
277
|
-
:at => [(x+((opts['w']/4)*3)+2), y+
|
282
|
+
:at => [(x+((opts['w']/4)*3)+2), y+2], :size => 8
|
278
283
|
end
|
279
284
|
|
280
285
|
end
|
281
286
|
|
282
287
|
def pdf_draw_text( pdf, opts, x, y, text, font_size, pdflocationnos )
|
283
288
|
miny = (opts['height'] - @y) * opts['hh'] + opts['hs_2'] +
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
289
|
+
opts['margin_2']
|
290
|
+
while text != ''
|
291
|
+
# PRE: Wrap the text to avoid the location number box
|
292
|
+
if (y >= miny) and (y <= (miny+font_size)) and (pdflocationnos == 1)
|
293
|
+
wrapwidthmodifier = 15
|
294
|
+
else
|
295
|
+
wrapwidthmodifier = 2
|
296
|
+
end
|
297
|
+
text = pdf.text_box text, :at => [x, y+6], :size => font_size,
|
298
|
+
:width => opts['w'] - wrapwidthmodifier,
|
299
|
+
:height => opts['h'], :valign => :top,
|
300
|
+
:align => :left, :overflow => :shrink_to_fit
|
301
|
+
y -= font_size
|
302
|
+
break if y <= miny
|
303
|
+
end
|
304
|
+
|
288
305
|
return [x, y]
|
289
306
|
end
|
290
307
|
|
@@ -292,7 +309,7 @@ class FXRoom
|
|
292
309
|
font_size = 6
|
293
310
|
objs = @objects.split("\n")
|
294
311
|
objs = objs.join(', ')
|
295
|
-
return pdf_draw_text( pdf, opts, x, y
|
312
|
+
return pdf_draw_text( pdf, opts, x, y,
|
296
313
|
objs, font_size, pdflocationnos )
|
297
314
|
end
|
298
315
|
|
@@ -356,7 +373,7 @@ class FXSection
|
|
356
373
|
|
357
374
|
pdf.save_graphics_state
|
358
375
|
|
359
|
-
if rotate
|
376
|
+
if rotate
|
360
377
|
pdf.rotate 90.0
|
361
378
|
pdf.translate( 0, -pdf.margin_box.height )
|
362
379
|
end
|
@@ -398,7 +415,7 @@ class FXSection
|
|
398
415
|
|
399
416
|
xi = opts['width']
|
400
417
|
yi = opts['height']
|
401
|
-
if rotate
|
418
|
+
if rotate
|
402
419
|
xi = (pdf.margin_box.height / opts['ww']).to_i - 1
|
403
420
|
yi = (pdf.margin_box.width / opts['hh']).to_i - 1
|
404
421
|
end
|
@@ -410,7 +427,7 @@ class FXSection
|
|
410
427
|
break if y >= h
|
411
428
|
end
|
412
429
|
|
413
|
-
if rotate
|
430
|
+
if rotate
|
414
431
|
pdf.rotate(-90.0)
|
415
432
|
pdf.translate( 0, pdf.page_height )
|
416
433
|
end
|
@@ -481,7 +498,6 @@ class FXMap
|
|
481
498
|
end
|
482
499
|
|
483
500
|
# Open a new PDF writer with paper selected
|
484
|
-
# PRE: Let's also set the paper orientation based on user selection
|
485
501
|
|
486
502
|
pdf = Prawn::Document.new :page_size => paper
|
487
503
|
|
@@ -509,10 +525,23 @@ class FXMap
|
|
509
525
|
|
510
526
|
|
511
527
|
begin
|
528
|
+
ratio = pdf.margin_box.height / pdf.margin_box.width.to_f;
|
512
529
|
# See if it is possible to pack several map sections (sections) into
|
513
530
|
# a single print page.
|
514
|
-
|
515
|
-
|
531
|
+
loop do
|
532
|
+
|
533
|
+
num = pack_sections( pdf_options['width'],
|
534
|
+
pdf_options['height'] )
|
535
|
+
|
536
|
+
if num > 0
|
537
|
+
break
|
538
|
+
end
|
539
|
+
|
540
|
+
width += 1
|
541
|
+
height = (width * ratio).to_i + 1;
|
542
|
+
end
|
543
|
+
|
544
|
+
|
516
545
|
pdf_draw_sections(pdf, pdf_options)
|
517
546
|
if pdffile !~ /\.pdf$/
|
518
547
|
pdffile << ".pdf"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ifmapper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.2.
|
4
|
+
version: 2.2.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
-
- Gonzalo
|
7
|
+
- Gonzalo Garramuño
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-06-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake-compiler
|
@@ -70,6 +70,26 @@ dependencies:
|
|
70
70
|
- - ">="
|
71
71
|
- !ruby/object:Gem::Version
|
72
72
|
version: 1.0.0
|
73
|
+
- !ruby/object:Gem::Dependency
|
74
|
+
name: pdf-writer
|
75
|
+
requirement: !ruby/object:Gem::Requirement
|
76
|
+
requirements:
|
77
|
+
- - "~>"
|
78
|
+
- !ruby/object:Gem::Version
|
79
|
+
version: 1.0.0
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 1.0.0
|
83
|
+
type: :runtime
|
84
|
+
prerelease: false
|
85
|
+
version_requirements: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: 1.0.0
|
90
|
+
- - ">="
|
91
|
+
- !ruby/object:Gem::Version
|
92
|
+
version: 1.0.0
|
73
93
|
description: " Interactive Fiction Mapping Tool.\n"
|
74
94
|
email: ggarra13@gmail.com
|
75
95
|
executables:
|