Class: FXMapperWindow
- Inherits:
-
FXMainWindow
- Object
- FXMainWindow
- FXMapperWindow
- Defined in:
- lib/IFMapper/FXMapperWindow.rb
Constant Summary collapse
- PROGRAM_NAME =
"Interactive Fiction Mapper"
- VERSION =
'1.2.4'
- AUTHOR =
"Gonzalo Garramuno"
- LANGUAGES =
{ 'English' => 'en', 'EspaƱol' => 'es', # todo1 'Deutsch' => 'de', 'Italiano' => 'it', 'Francais' => 'fr', # todo2 'Japanese' => 'ja', 'Chinese' => 'ch', 'Korean' => 'ko', 'Arabic' => 'ar', }
- @@copy_buffer =
nil
- @@default_options =
FXMapperSettings.new
Class Method Summary collapse
-
.copy_buffer ⇒ Object
Return the copied elements.
-
.copy_selected(map) ⇒ Object
Copy selected elements.
-
.cut_selected(map) ⇒ Object
Cut selected elements.
- .default_options ⇒ Object
-
.paste_selected(map) ⇒ Object
Paste selected elements.
Instance Method Summary collapse
- #about_cb(sender, id, event) ⇒ Object
-
#automap_properties_cb(sender, sel, ptr) ⇒ Object
Properties of the automapper callback.
-
#autosave ⇒ Object
In case of crash or runtime error, autosave all maps, so user does not loose any data.
- #close_cb(*args) ⇒ Object
-
#colors_cb(sender, id, msg) ⇒ Object
Pop-up color preferences.
-
#complex_connection_cb(sender, sel, msg) ⇒ Object
Start a complex connection.
- #copy_map(map, tmp, file) ⇒ Object
- #copy_selected_cb(*o) ⇒ Object
-
#create_mdiclient ⇒ Object
Creates the MDI (multi-document) client.
- #create_menus ⇒ Object
- #create_toolbar(toolbar) ⇒ Object
- #create_widgets ⇒ Object
-
#current_map ⇒ Object
Returns current active map or nil if no maps.
- #cut_selected_cb(*o) ⇒ Object
-
#delete_selected_cb(sender, sel, msg) ⇒ Object
Delete selected elements in map.
- #docs(*opts) ⇒ Object
-
#find_desc_in_map(s, m, e) ⇒ Object
Find task in map.
-
#find_desc_in_map_cb(s, m, e) ⇒ Object
Find description in map.
-
#find_in_map(s, m, e) ⇒ Object
Find location in map.
- #find_in_map_cb(s, m, e) ⇒ Object
-
#find_in_section(s, m, e) ⇒ Object
Find location in section.
-
#find_in_section_cb(s, m, e) ⇒ Object
Callback.
-
#find_object_in_map(s, m, e) ⇒ Object
Find object in map.
-
#find_object_in_map_cb(s, m, e) ⇒ Object
Find object in map.
-
#find_task_in_map(s, m, e) ⇒ Object
Find task in map.
-
#find_task_in_map_cb(s, m, e) ⇒ Object
Find task in map.
-
#hilite_matches(map, matches, re, idx = 0) ⇒ Object
Hilite matches after a search.
- #hotkeys(*opts) ⇒ Object
-
#ifm_export_cb(sender, sel, msg) ⇒ Object
Export current map as an IFM file.
-
#inform7_export_cb(sender, sel, msg) ⇒ Object
Export current map as an Inform source file.
-
#inform_export_cb(sender, sel, msg) ⇒ Object
Export current map as an Inform source file.
-
#initialize(app) ⇒ FXMapperWindow
constructor
A new instance of FXMapperWindow.
- #itemlist(sender, sel, event) ⇒ Object
- #language ⇒ Object
-
#language_cb(sender, msg, opts) ⇒ Object
Callback used to change language.
-
#load_icon(filename) ⇒ Object
Load the named PNG icon from a file.
-
#map_properties ⇒ Object
Bring up the map property requester for current map.
-
#new_map ⇒ Object
Create a new map.
-
#new_map_cb(*args) ⇒ Object
Callback used to create new map.
-
#next_section ⇒ Object
Go to next section in current map.
-
#open_cb(sender, sel, ptr) ⇒ Object
Callback to Open File.
- #open_file(file) ⇒ Object
- #open_guemap(file, map) ⇒ Object
- #open_ifm(file, map) ⇒ Object
- #open_inform(file, map) ⇒ Object
- #open_map(file) ⇒ Object
- #open_tads(file, map) ⇒ Object
- #open_trizbort(file, map) ⇒ Object
- #paste_selected_cb(*o) ⇒ Object
-
#pdf_export_cb(sender, sel, msg) ⇒ Object
Export current map as Acrobat PDF.
-
#previous_section ⇒ Object
Go to previous section in current map.
-
#print_cb(sender, sel, msg) ⇒ Object
Print current map graphically.
-
#print_locations_cb(sender, sel, msg) ⇒ Object
Print out all the locations in map.
-
#printer_dialog(title = MSG_PRINT_MAP) ⇒ Object
Popup a printer dialog and return the settings or false if user cancels.
- #roomlist(sender, sel, event) ⇒ Object
-
#save_as_cb(sender, sel, ptr) ⇒ Object
Callback for Save As.
-
#save_cb(sender, sel, ptr) ⇒ Object
Callback for Save.
-
#select_all_cb(sender, id, event) ⇒ Object
Select all.
-
#select_none_cb(sender, id, event) ⇒ Object
Unselect all.
-
#start_automap_cb(sender, sel, ptr) ⇒ Object
Start automapping from a transcript.
-
#status(msg) ⇒ Object
Write a message to the status bar.
-
#stop_automap_cb(sender, sel, ptr) ⇒ Object
Stop automapping from a transcript.
-
#svg_export_cb(sender, sel, msg) ⇒ Object
Export current map as Structured Vector Graphics (SVG).
-
#tads_export_cb(sender, sel, msg) ⇒ Object
Export current map as a TADs source file.
-
#trizbort_export_cb(sender, sel, msg) ⇒ Object
Export current map as an IFM file.
- #update_map ⇒ Object
-
#update_section ⇒ Object
Update section # in toolbar widget.
-
#zoom_in ⇒ Object
Zoom in into current map.
-
#zoom_out ⇒ Object
Zoom out from current map.
Constructor Details
#initialize(app) ⇒ FXMapperWindow
Returns a new instance of FXMapperWindow.
1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 |
# File 'lib/IFMapper/FXMapperWindow.rb', line 1660 def initialize(app) super(app, eval("\"#{TITLE}\""), nil, nil, DECOR_ALL, 0, 0, 800, 600) @colors = nil @mdimenu = nil @search = nil # Trap CTRL-C signals and exit nicely trap('SIGINT') { close_cb exit(0) } end |
Class Method Details
.copy_buffer ⇒ Object
Return the copied elements
599 600 601 |
# File 'lib/IFMapper/FXMapperWindow.rb', line 599 def self.copy_buffer return @@copy_buffer end |
.copy_selected(map) ⇒ Object
Copy selected elements
606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 |
# File 'lib/IFMapper/FXMapperWindow.rb', line 606 def self.copy_selected(map) sect = map.sections[map.section] # Get all selected rooms rooms = sect.rooms.find_all { |r| r.selected } return if rooms.size < 1 # Get all selected connections links = sect.connections.find_all { |c| c.selected } # Make sure we store only those connections for # those rooms we selected delete = [] links.each { |c| if not rooms.include?(c.roomA) or (c.roomB and not rooms.include?(c.roomB)) delete << c end } links -= delete selection = [ rooms, links ] @@copy_buffer = selection end |
.cut_selected(map) ⇒ Object
Cut selected elements
635 636 637 638 639 |
# File 'lib/IFMapper/FXMapperWindow.rb', line 635 def self.cut_selected(map) return map. if map. FXMapperWindow::copy_selected(map) map.cut_selected end |
.default_options ⇒ Object
57 58 59 |
# File 'lib/IFMapper/FXMapperWindow.rb', line 57 def self. return @@default_options end |
.paste_selected(map) ⇒ Object
Paste selected elements
644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 |
# File 'lib/IFMapper/FXMapperWindow.rb', line 644 def self.paste_selected(map) return if not @@copy_buffer return map. if map. sel = @@copy_buffer pos = map.find_empty_area( sel[0] ) if not pos w = FXWarningBox.new( map.window, ERR_NO_FREE_ROOM) w.execute else map.clear_selection # Add rooms r_to_nr = {} # orig room to new room hash rooms = sel[0] rooms.each { |r| nr = map.new_room(r.x + pos[0], r.y + pos[1]) nr.selected = true nr.copy(r) # copy the room data r_to_nr[r] = nr } if rooms.empty? # Add connections only (no rooms copied) sel[1].each { |c| exitA, exitB = c.dirs roomA = c.roomA roomB = c.roomB sect = map.sections[map.section] if not sect.rooms.include?(roomA) or (roomB and not sect.rooms.include?(roomB)) next end begin nc = map.new_connection(roomA, exitA, roomB, exitB) nc.selected = true nc.dir = c.dir nc.type = c.type rescue end } else # Add connections sel[1].each { |c| exitA, exitB = c.dirs roomA = r_to_nr[c.roomA] if c.roomB roomB = r_to_nr[c.roomB] else roomB = nil end next if not roomA begin nc = map.new_connection(roomA, exitA, roomB, exitB) nc.selected = true nc.dir = c.dir nc.type = c.type rescue Section::ConnectionError => e puts c puts e end } end map.create_pathmap map.draw end end |
Instance Method Details
#about_cb(sender, id, event) ⇒ Object
996 997 998 999 1000 |
# File 'lib/IFMapper/FXMapperWindow.rb', line 996 def about_cb(sender, id, event ) require 'IFMapper/FXAboutDialogBox' FXAboutDialogBox.new(self, MSG_ABOUT_SOFTWARE, eval("\"#{MSG_ABOUT}\"")).execute end |
#automap_properties_cb(sender, sel, ptr) ⇒ Object
Properties of the automapper callback
150 151 152 153 154 |
# File 'lib/IFMapper/FXMapperWindow.rb', line 150 def automap_properties_cb(sender, sel, ptr) map = current_map return if not map or not map.automap map.automap.properties(true) end |
#autosave ⇒ Object
In case of crash or runtime error, autosave all maps, so user does not loose any data.
1627 1628 1629 1630 1631 |
# File 'lib/IFMapper/FXMapperWindow.rb', line 1627 def autosave @maps.each { |m| m.save } end |
#close_cb(*args) ⇒ Object
1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 |
# File 'lib/IFMapper/FXMapperWindow.rb', line 1677 def close_cb(*args) exit = true @maps.each { |m| if not m.close_cb exit = false break else @maps.delete(m) end } self.close if exit end |
#colors_cb(sender, id, msg) ⇒ Object
Pop-up color preferences
952 953 954 955 956 957 958 959 960 961 962 963 |
# File 'lib/IFMapper/FXMapperWindow.rb', line 952 def colors_cb(sender, id, msg) map = current_map return if not map if not @colors require 'IFMapper/FXMapColorBox' @colors = FXMapColorBox.new(self) else @colors.show end @colors.copy_from(map) end |
#complex_connection_cb(sender, sel, msg) ⇒ Object
Start a complex connection
356 357 358 359 360 |
# File 'lib/IFMapper/FXMapperWindow.rb', line 356 def complex_connection_cb(sender, sel, msg) map = current_map return unless map map.complex_connection end |
#copy_map(map, tmp, file) ⇒ Object
242 243 244 245 246 247 248 249 250 251 |
# File 'lib/IFMapper/FXMapperWindow.rb', line 242 def copy_map(map, tmp, file) map.copy(tmp) map..replace( @@default_options.merge(map.) ) map.verify_integrity map.fit map.window.create map.modified = false update_map status "#{MSG_LOADED} '#{file}'." end |
#copy_selected_cb(*o) ⇒ Object
719 720 721 722 723 |
# File 'lib/IFMapper/FXMapperWindow.rb', line 719 def copy_selected_cb(*o) map = current_map return unless map FXMapperWindow::copy_selected(map) end |
#create_mdiclient ⇒ Object
Creates the MDI (multi-document) client
567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 |
# File 'lib/IFMapper/FXMapperWindow.rb', line 567 def create_mdiclient # MDI Client @maps = [] @mdiclient = FXMDIClient.new(self, LAYOUT_FILL_X|LAYOUT_FILL_Y) @mdiclient.connect(SEL_CHANGED) { update_map } # MDI buttons in menu:- note the message ID's!!!!! # Normally, MDI commands are simply sensitized or desensitized; # Under the @menubar, however, they're hidden if the MDI Client is # not maximized. To do this, they must have different ID's. FXMDIWindowButton.new(@menubar, @mdimenu, @mdiclient, FXMDIClient::ID_MDI_MENUWINDOW, LAYOUT_LEFT) FXMDIDeleteButton.new(@menubar, @mdiclient, FXMDIClient::ID_MDI_MENUCLOSE, FRAME_RAISED|LAYOUT_RIGHT) FXMDIRestoreButton.new(@menubar, @mdiclient, FXMDIClient::ID_MDI_MENURESTORE, FRAME_RAISED|LAYOUT_RIGHT) FXMDIMinimizeButton.new(@menubar, @mdiclient, FXMDIClient::ID_MDI_MENUMINIMIZE, FRAME_RAISED|LAYOUT_RIGHT) # Icon for MDI Child @mdiicon = load_icon("winapp") # Make MDI Window Menu @mdimenu = FXMDIMenu.new(self, @mdiclient) end |
#create_menus ⇒ Object
1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 |
# File 'lib/IFMapper/FXMapperWindow.rb', line 1003 def # Construct these icons newdoc = load_icon("filenew") opendoc = load_icon("fileopen") savedoc = load_icon("filesave") saveasdoc = load_icon("filesaveas") # File Menu = FXMenuPane.new(self) FXMenuTitle.new(@menubar, MENU_FILE, nil, ) cmd = FXMenuCommand.new(, MENU_NEW, newdoc) cmd.connect(SEL_COMMAND, method(:new_map_cb)) cmd = FXMenuCommand.new(, MENU_OPEN, opendoc) cmd.connect(SEL_COMMAND, method(:open_cb)) cmd = FXMenuCommand.new(, MENU_SAVE, savedoc) cmd.connect(SEL_COMMAND, method(:save_cb)) cmd = FXMenuCommand.new(, MENU_SAVE_AS, saveasdoc) cmd.connect(SEL_COMMAND, method(:save_as_cb)) # Export submenu = FXMenuPane.new(self) cmd = FXMenuCommand.new(, MENU_EXPORT_PDF, nil) cmd.connect(SEL_COMMAND, method(:pdf_export_cb)) cmd = FXMenuCommand.new(, MENU_EXPORT_SVG, nil) cmd.connect(SEL_COMMAND, method(:svg_export_cb)) cmd = FXMenuCommand.new(, MENU_EXPORT_TRIZBORT, nil) cmd.connect(SEL_COMMAND, method(:trizbort_export_cb)) cmd = FXMenuCommand.new(, MENU_EXPORT_IFM, nil) cmd.connect(SEL_COMMAND, method(:ifm_export_cb)) cmd = FXMenuCommand.new(, MENU_EXPORT_INFORM6, nil) cmd.connect(SEL_COMMAND, method(:inform_export_cb)) cmd = FXMenuCommand.new(, MENU_EXPORT_INFORM7, nil) cmd.connect(SEL_COMMAND, method(:inform7_export_cb)) cmd = FXMenuCommand.new(, MENU_EXPORT_TADS, nil) cmd.connect(SEL_COMMAND, method(:tads_export_cb)) FXMenuCascade.new(, MENU_EXPORT, nil, ) = FXMenuPane.new(self) cmd = FXMenuCommand.new(, MENU_PRINT_MAP, nil) cmd.connect(SEL_COMMAND, method(:print_cb)) cmd = FXMenuCommand.new(, MENU_PRINT_LOCATIONS, nil) cmd.connect(SEL_COMMAND, method(:print_locations_cb)) FXMenuCascade.new(, MENU_PRINT, nil, ) cmd = FXMenuCommand.new(, MENU_QUIT, nil) cmd.connect( SEL_COMMAND, method(:close_cb) ) # Edit Menu = FXMenuPane.new(self) FXMenuTitle.new(@menubar, MENU_EDIT, nil, ) cmd = FXMenuCommand.new(, MENU_COPY, nil) cmd.connect(SEL_COMMAND, method(:copy_selected_cb)) cmd = FXMenuCommand.new(, MENU_CUT, nil) cmd.connect(SEL_COMMAND, method(:cut_selected_cb)) cmd = FXMenuCommand.new(, MENU_PASTE, nil) cmd.connect(SEL_COMMAND, method(:paste_selected_cb)) #cmd = FXMenuCommand.new(editmenu, MENU_UNDO, nil) #cmd.connect(SEL_COMMAND, method(:undo_cb)) # Select submenu FXMenuSeparator.new() = FXMenuPane.new(self) cmd = FXMenuCommand.new( , MENU_SELECT_ALL ) cmd.connect(SEL_COMMAND, method(:select_all_cb)) cmd = FXMenuCommand.new( , MENU_SELECT_NONE ) cmd.connect(SEL_COMMAND, method(:select_none_cb)) FXMenuCascade.new( , MENU_SELECT, nil, ) # Searching submenu FXMenuSeparator.new() = FXMenuPane.new(self) cmd = FXMenuCommand.new(, MENU_SEARCH_MAP) cmd.connect(SEL_COMMAND, method(:find_in_map_cb)) cmd = FXMenuCommand.new(, MENU_SEARCH_SECTION) cmd.connect(SEL_COMMAND, method(:find_in_section_cb)) cmd = FXMenuCommand.new(, MENU_SEARCH_OBJECT) cmd.connect(SEL_COMMAND, method(:find_object_in_map_cb)) cmd = FXMenuCommand.new(, MENU_SEARCH_TASK) cmd.connect(SEL_COMMAND, method(:find_task_in_map_cb)) cmd = FXMenuCommand.new(, MENU_SEARCH_DESCRIPTION) cmd.connect(SEL_COMMAND, method(:find_desc_in_map_cb)) FXMenuCascade.new(, MENU_SEARCH, nil, ) # Complex Connection FXMenuSeparator.new() cmd = FXMenuCommand.new(, MENU_COMPLEX_CONNECTION, nil) cmd.connect( SEL_COMMAND, method(:complex_connection_cb) ) FXMenuSeparator.new() cmd = FXMenuCommand.new(, MENU_DELETE, nil) cmd.connect( SEL_COMMAND, method(:delete_selected_cb) ) # Map menu = FXMenuPane.new(self) cmd = FXMenuCommand.new(, MENU_MAP_INFO) cmd.connect(SEL_COMMAND) { map_properties } cmd = FXMenuCommand.new(, MENU_ROOM_LIST) cmd.connect(SEL_COMMAND, method(:roomlist) ) cmd = FXMenuCommand.new(, MENU_ITEM_LIST) cmd.connect(SEL_COMMAND, method(:itemlist) ) # Automap submenu # = FXMenuPane.new(self) cmd = FXMenuCommand.new(, MENU_AUTOMAP_START) cmd.connect(SEL_COMMAND, method(:start_automap_cb)) cmd = FXMenuCommand.new(, MENU_AUTOMAP_STOP) cmd.connect(SEL_COMMAND, method(:stop_automap_cb)) FXMenuSeparator.new() cmd = FXMenuCommand.new(, MENU_AUTOMAP_PROPERTIES) cmd.connect(SEL_COMMAND, method(:automap_properties_cb)) FXMenuCascade.new(, MENU_AUTOMAP, nil, ) # Sections submenu = FXMenuPane.new(self) cmd = FXMenuCommand.new(, MENU_NEXT_SECTION) cmd.connect(SEL_COMMAND) { next_section } cmd = FXMenuCommand.new(, MENU_PREVIOUS_SECTION) cmd.connect(SEL_COMMAND) { previous_section } FXMenuSeparator.new() cmd = FXMenuCommand.new(, MENU_ADD_SECTION) cmd.connect(SEL_COMMAND) { map = current_map if map map.new_section map.modified = true update_section end } cmd = FXMenuCommand.new(, MENU_SECTION_INFO) cmd.connect(SEL_COMMAND) { map = current_map if map map.rename_section map.modified = true end } FXMenuSeparator.new() cmd = FXMenuCommand.new(, MENU_DELETE_SECTION) cmd.connect(SEL_COMMAND) { map = current_map if map map.delete_section map.modified = true update_section end } FXMenuCascade.new(, MENU_SECTIONS, nil, ) # # Zoom submenu # = FXMenuPane.new(self) [25, 50, 75, 100, 125].each { |v| cmd = FXMenuCommand.new(, eval("\"#{MENU_ZOOM_PERCENT}\"")) cmd.connect(SEL_COMMAND) { map = current_map if map map.zoom = v / 100.0 map.draw end } } FXMenuCascade.new(, MENU_ZOOM, nil, ) = FXMenuPane.new(self) cmd = FXMenuCheck.new(, MENU_EDIT_ON_CREATION) cmd.check = @@default_options['Edit on Creation'] cmd.connect(SEL_COMMAND) { |s, m, e| map = current_map if map map.['Edit on Creation'] = (s.check == true) end } cmd.connect(SEL_UPDATE) { |s, m, e| map = current_map s.check = map.['Edit on Creation'] if map } cmd = FXMenuCheck.new(, MENU_AUTOMATIC_CONNECTION) cmd.check = @@default_options['Automatic Connection'] cmd.connect(SEL_COMMAND) { |s, m, e| map = current_map if map map.['Automatic Connection'] = (s.check == true) end } cmd.connect(SEL_UPDATE) { |s, m, e| map = current_map s.check = map.['Automatic Connection'] if map } cmd = FXMenuCheck.new(, MENU_CREATE_ON_CONNECTION) cmd.check = @@default_options['Create on Connection'] cmd.connect(SEL_COMMAND) { |s, m, e| map = current_map map.['Create on Connection'] = s.check if map } cmd.connect(SEL_UPDATE) { |s, m, e| map = current_map s.check = map.['Create on Connection'] if map } FXMenuCascade.new(, MENU_OPTIONS, nil, ) ########################## # Display submenu ######################### = FXMenuPane.new(self) cmd = FXMenuCheck.new(, MENU_USE_ROOM_CURSOR) cmd.check = @@default_options['Use Room Cursor'] cmd.connect(SEL_COMMAND) { |s, m, e| map = current_map if map map.['Use Room Cursor'] = (s.check == true) map.draw end } cmd.connect(SEL_UPDATE) { |s, m, e| map = current_map s.check = map.['Use Room Cursor'] if map } cmd = FXMenuCheck.new(, MENU_PATHS_AS_CURVES) cmd.check = @@default_options['Paths as Curves'] cmd.connect(SEL_COMMAND) { |s, m, e| map = current_map if map map.['Paths as Curves'] = (s.check == true) map.draw end } cmd.connect(SEL_UPDATE) { |s, m, e| map = current_map s.check = map.['Paths as Curves'] if map } cmd = FXMenuCheck.new(, MENU_LOCATION_NUMBERS) cmd.check = @@default_options['Location Numbers'] cmd.connect(SEL_COMMAND) { |s, m, e| map = current_map if map map.['Location Numbers'] = (s.check == true) map.draw end } cmd.connect(SEL_UPDATE) { |s, m, e| map = current_map s.check = map.['Location Numbers'] if map } cmd = FXMenuCheck.new(, MENU_LOCATION_TASKS) cmd.check = @@default_options['Location Tasks'] cmd.connect(SEL_COMMAND) { |s, m, e| map = current_map if map map.['Location Tasks'] = (s.check == true) map.draw end } cmd.connect(SEL_UPDATE) { |s, m, e| map = current_map s.check = map.['Location Tasks'] if map } cmd = FXMenuCheck.new(, MENU_LOCATION_DESC) cmd.check = @@default_options['Location Description'] cmd.connect(SEL_COMMAND) { |s, m, e| map = current_map if map map.['Location Description'] = (s.check == true) map.draw end } cmd.connect(SEL_UPDATE) { |s, m, e| map = current_map s.check = map.['Location Description'] if map } cmd = FXMenuCheck.new(, MENU_BOXES) cmd.check = @@default_options['Grid Boxes'] cmd.connect(SEL_COMMAND) { |s, m, e| map = current_map if map map.['Grid Boxes'] = (s.check == true) map.draw end } cmd.connect(SEL_UPDATE) { |s, m, e| map = current_map s.check = map.['Grid Boxes'] if map } cmd = FXMenuCheck.new(, MENU_STRAIGHT_CONN) cmd.check = @@default_options['Grid Straight Connections'] cmd.connect(SEL_COMMAND) { |s, m, e| map = current_map if map map.['Grid Straight Connections'] = (s.check == true) map.draw end } cmd.connect(SEL_UPDATE) { |s, m, e| map = current_map s.check = map.['Grid Straight Connections'] if map } cmd = FXMenuCheck.new(, MENU_DIAGONAL_CONN) cmd.check = @@default_options['Grid Diagonal Connections'] cmd.connect(SEL_COMMAND) { |s, m, e| map = current_map if map map.['Grid Diagonal Connections'] = s.check map.draw end } cmd.connect(SEL_UPDATE) { |s, m, e| map = current_map s.check = map.['Grid Diagonal Connections'] if map } FXMenuCascade.new(, MENU_DISPLAY, nil, ) = FXMenuPane.new(self) cmd = FXMenuCommand.new(, MENU_COLORS) cmd.connect(SEL_COMMAND, method(:colors_cb)) # langmenu = FXMenuPane.new(self) # LANGUAGES.each { |k, v| # next unless File.exists?( "lib/IFMapper/locales/#{v}/Messages.rb" ) # cmd = FXMenuCheck.new(langmenu, k) # cmd.connect(SEL_COMMAND, method(:language_cb)) # } # FXMenuCascade.new(mapmenu, MENU_LANGUAGE, nil, langmenu) FXMenuSeparator.new() cmd = FXMenuCommand.new(, MENU_SAVE_PREFS) cmd.connect(SEL_COMMAND) { map = current_map map..write if map } FXMenuCascade.new(, MENU_PREFS, nil, ) FXMenuTitle.new(@menubar, MENU_MAP, nil, ) # Window menu = FXMenuPane.new(self) FXMenuCommand.new(, MENU_TILE_HORIZONTALLY, nil, @mdiclient, FXMDIClient::ID_MDI_TILEHORIZONTAL) FXMenuCommand.new(, MENU_TILE_VERTICALLY, nil, @mdiclient, FXMDIClient::ID_MDI_TILEVERTICAL) FXMenuCommand.new(, MENU_CASCADE, nil, @mdiclient, FXMDIClient::ID_MDI_CASCADE) FXMenuCommand.new(, MENU_CLOSE, nil, @mdiclient, FXMDIClient::ID_MDI_CLOSE) sep1 = FXMenuSeparator.new() sep1.setTarget(@mdiclient) sep1.setSelector(FXMDIClient::ID_MDI_ANY) FXMenuCommand.new(, nil, nil, @mdiclient, FXMDIClient::ID_MDI_1) FXMenuCommand.new(, nil, nil, @mdiclient, FXMDIClient::ID_MDI_2) FXMenuCommand.new(, nil, nil, @mdiclient, FXMDIClient::ID_MDI_3) FXMenuCommand.new(, nil, nil, @mdiclient, FXMDIClient::ID_MDI_4) FXMenuCommand.new(, MENU_OTHERS, nil, @mdiclient, FXMDIClient::ID_MDI_OVER_5) FXMenuTitle.new(@menubar, MENU_WINDOW, nil, ) # Help menu = FXMenuPane.new(self) cmd = FXMenuCommand.new(, MENU_HOTKEYS, nil) cmd.connect(SEL_COMMAND, method(:hotkeys)) cmd = FXMenuCommand.new(, MENU_INSTRUCTIONS, nil) cmd.connect(SEL_COMMAND, method(:docs)) FXMenuSeparator.new() cmd = FXMenuCommand.new(, MENU_ABOUT, nil) cmd.connect(SEL_COMMAND, method(:about_cb)) cmd = FXMenuCommand.new(, MENU_RESOURCE, nil) cmd.connect(SEL_COMMAND) { require 'IFMapper/FXMapFileDialog' file = FXMapFileDialog.new(self, "Resource a Ruby File", ['Ruby File (*.rb)']).filename if file != '' begin Kernel.load file rescue => e p e end end } FXMenuTitle.new(@menubar, MENU_HELP, nil, ) end |
#create_toolbar(toolbar) ⇒ Object
1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 |
# File 'lib/IFMapper/FXMapperWindow.rb', line 1445 def () # Construct these icons newdoc = load_icon("filenew") opendoc = load_icon("fileopen") savedoc = load_icon("filesave") saveasdoc = load_icon("filesaveas") # File manipulation cmd = FXButton.new(, ICON_NEW, newdoc, nil, 0, FRAME_THICK|FRAME_RAISED|LAYOUT_TOP|LAYOUT_LEFT) cmd.connect(SEL_COMMAND, method(:new_map_cb)) cmd = FXButton.new(, ICON_OPEN, opendoc, nil, 0, FRAME_THICK|FRAME_RAISED|LAYOUT_TOP|LAYOUT_LEFT) cmd.connect(SEL_COMMAND, method(:open_cb)) cmd = FXButton.new(, ICON_SAVE, savedoc, nil, 0, FRAME_THICK|FRAME_RAISED|LAYOUT_TOP|LAYOUT_LEFT) cmd.connect(SEL_COMMAND, method(:save_cb)) cmd.connect(SEL_UPDATE) { |sender, sel, ptr| map = current_map = map ? FXWindow::ID_ENABLE : FXWindow::ID_DISABLE sender.handle(self, MKUINT(, SEL_COMMAND), nil) } cmd = FXButton.new(, ICON_SAVE_AS, saveasdoc, nil, 0, FRAME_THICK|FRAME_RAISED|LAYOUT_TOP|LAYOUT_LEFT) cmd.connect(SEL_COMMAND, method(:save_as_cb)) cmd.connect(SEL_UPDATE) { |sender, sel, ptr| map = current_map = map ? FXWindow::ID_ENABLE : FXWindow::ID_DISABLE sender.handle(self, MKUINT(, SEL_COMMAND), nil) } # Print FXFrame.new(, LAYOUT_TOP|LAYOUT_LEFT|LAYOUT_FIX_WIDTH|LAYOUT_FIX_HEIGHT, 0, 0, 4, 20) cmd = FXButton.new(, ICON_PRINT, load_icon("printicon"), @mdiclient, FXGLViewer::ID_PRINT_IMAGE, BUTTON_AUTOGRAY|FRAME_THICK|FRAME_RAISED|LAYOUT_TOP|LAYOUT_LEFT) cmd.connect(SEL_COMMAND, method(:print_cb)) cmd.connect(SEL_UPDATE) { |sender, sel, ptr| map = current_map = map ? FXWindow::ID_ENABLE : FXWindow::ID_DISABLE sender.handle(self, MKUINT(, SEL_COMMAND), nil) } # Editing FXFrame.new(, LAYOUT_TOP|LAYOUT_LEFT|LAYOUT_FIX_WIDTH|LAYOUT_FIX_HEIGHT, 0, 0, 4, 20) cmd = FXButton.new(, ICON_CUT, load_icon("cut"), @mdiclient, FXGLViewer::ID_CUT_SEL, (BUTTON_AUTOGRAY|FRAME_THICK|FRAME_RAISED| LAYOUT_TOP|LAYOUT_LEFT)) cmd.connect(SEL_COMMAND, method(:cut_selected_cb)) cmd.connect(SEL_UPDATE) { |sender, sel, ptr| map = current_map = map ? FXWindow::ID_ENABLE : FXWindow::ID_DISABLE sender.handle(self, MKUINT(, SEL_COMMAND), nil) } cmd = FXButton.new(, ICON_COPY, load_icon("copy"), @mdiclient, FXGLViewer::ID_COPY_SEL, (BUTTON_AUTOGRAY|FRAME_THICK|FRAME_RAISED| LAYOUT_TOP|LAYOUT_LEFT)) cmd.connect(SEL_COMMAND, method(:copy_selected_cb)) cmd.connect(SEL_UPDATE) { |sender, sel, ptr| map = current_map = map ? FXWindow::ID_ENABLE : FXWindow::ID_DISABLE sender.handle(self, MKUINT(, SEL_COMMAND), nil) } cmd = FXButton.new(, ICON_PASTE, load_icon("paste"), @mdiclient, FXGLViewer::ID_PASTE_SEL, (BUTTON_AUTOGRAY|FRAME_THICK|FRAME_RAISED| LAYOUT_TOP|LAYOUT_LEFT)) cmd.connect(SEL_COMMAND, method(:paste_selected_cb)) cmd.connect(SEL_UPDATE) { |sender, sel, ptr| map = current_map = (map and @@copy_buffer) ? FXWindow::ID_ENABLE : FXWindow::ID_DISABLE sender.handle(self, MKUINT(, SEL_COMMAND), nil) } # Zooming FXFrame.new(, LAYOUT_TOP|LAYOUT_LEFT|LAYOUT_FIX_WIDTH|LAYOUT_FIX_HEIGHT, 0, 0, 4, 20) cmd = FXButton.new(, ICON_ZOOM_IN, load_icon("zoom"), @mdiclient, 0, FRAME_THICK|FRAME_RAISED|LAYOUT_TOP|LAYOUT_LEFT) cmd.connect(SEL_COMMAND) { zoom_in } cmd = FXButton.new(, ICON_ZOOM_OUT, load_icon("zoom"), @mdiclient, 0, FRAME_THICK|FRAME_RAISED|LAYOUT_TOP|LAYOUT_LEFT) cmd.connect(SEL_COMMAND) { zoom_out } # Section travel frame = FXHorizontalFrame.new(, LAYOUT_RIGHT|FRAME_THICK|FRAME_RAISED) cmd = FXButton.new(frame, ICON_PREV_SECTION, load_icon("prevpage"), @mdiclient, 0, FRAME_THICK|FRAME_RAISED|LAYOUT_TOP|LAYOUT_LEFT) cmd.connect(SEL_COMMAND) { previous_section } @section = FXTextField.new(frame, 5, nil, 0, TEXTFIELD_INTEGER|LAYOUT_FILL_ROW) @section.text = '1' @section.connect(SEL_COMMAND) { |s,m,e| v = s.text.to_i map = current_map if map map.section = v - 1 map.draw update_section end } @section.connect(SEL_UPDATE) { |s,m,e| map = current_map update_section if map } cmd = FXButton.new(frame, ICON_NEXT_SECTION, load_icon("nextpage"), @mdiclient, 0, FRAME_THICK|FRAME_RAISED|LAYOUT_TOP|LAYOUT_LEFT) cmd.connect(SEL_COMMAND) { next_section } end |
#create_widgets ⇒ Object
1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 |
# File 'lib/IFMapper/FXMapperWindow.rb', line 1634 def # Menubar @menubar = FXMenuBar.new(self, LAYOUT_SIDE_TOP|LAYOUT_FILL_X) FXHorizontalSeparator.new(self, LAYOUT_SIDE_TOP|SEPARATOR_GROOVE|LAYOUT_FILL_X) = FXToolBar.new(self, LAYOUT_SIDE_TOP|LAYOUT_FILL_X, 0, 0, 0, 0, 4, 4, 0, 0, 0, 0) # Status bar @statusbar = FXStatusBar.new(self, LAYOUT_SIDE_BOTTOM|LAYOUT_FILL_X| STATUSBAR_WITH_DRAGCORNER) create_mdiclient () self.connect(SEL_CLOSE, method(:close_cb)) show new_map end |
#current_map ⇒ Object
Returns current active map or nil if no maps
263 264 265 266 267 268 269 270 271 |
# File 'lib/IFMapper/FXMapperWindow.rb', line 263 def current_map window = @mdiclient.activeChild return nil unless window @maps.each { |m| return m if m.window == window } return nil end |
#cut_selected_cb(*o) ⇒ Object
713 714 715 716 717 |
# File 'lib/IFMapper/FXMapperWindow.rb', line 713 def cut_selected_cb(*o) map = current_map return unless map FXMapperWindow::cut_selected(map) end |
#delete_selected_cb(sender, sel, msg) ⇒ Object
Delete selected elements in map
365 366 367 368 369 |
# File 'lib/IFMapper/FXMapperWindow.rb', line 365 def delete_selected_cb(sender, sel, msg) map = current_map return unless map map.delete_selected end |
#docs(*opts) ⇒ Object
1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 |
# File 'lib/IFMapper/FXMapperWindow.rb', line 1421 def docs(*opts) browsers = [ 'firefox', 'opera', 'explorer' ] address = 'docs/' + language + '/start.html' status "#{MSG_OPENING_WEB_PAGE} #{address}..." ok = false browsers.each { |cmd| if RUBY_PLATFORM =~ /mswin/ ok = system("start #{cmd} #{address}") else ok = system("#{cmd} #{address} &") end break if ok } if not ok status ERR_COULD_NOT_OPEN_WEB_BROWSER end end |
#find_desc_in_map(s, m, e) ⇒ Object
Find task in map
913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 |
# File 'lib/IFMapper/FXMapperWindow.rb', line 913 def find_desc_in_map(s, m, e) map = current_map return unless map re = /#{s.text}/ matches = [] (0...map.sections.size).each { |p| map.sections[p].rooms.each { |r| next unless r.desc =~ re matches.push( [p, r] ) } } idx = @search.index @search.index = matches.size-1 if idx >= matches.size hilite_matches(map, matches, re, @search.index) end |
#find_desc_in_map_cb(s, m, e) ⇒ Object
Find description in map
933 934 935 936 937 938 939 940 941 942 943 944 945 946 |
# File 'lib/IFMapper/FXMapperWindow.rb', line 933 def find_desc_in_map_cb(s, m, e) map = current_map return unless map title = MSG_FIND_DESCRIPTION_IN_MAP if not @search require 'IFMapper/FXSearchDialogBox' @search = FXSearchDialogBox.new(self) end @search.proc = method(:find_desc_in_map) @search.title = title @search.text = '' @search.show end |
#find_in_map(s, m, e) ⇒ Object
Find location in map
768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 |
# File 'lib/IFMapper/FXMapperWindow.rb', line 768 def find_in_map(s, m, e) map = current_map return unless map re = /#{s.text}/ matches = [] (0...map.sections.size).each { |p| map.sections[p].rooms.each { |r| next unless r.name =~ re matches.push( [p, r] ) } } idx = @search.index @search.index = matches.size-1 if idx >= matches.size hilite_matches(map, matches, re, @search.index) end |
#find_in_map_cb(s, m, e) ⇒ Object
785 786 787 788 789 790 791 792 793 794 795 796 797 798 |
# File 'lib/IFMapper/FXMapperWindow.rb', line 785 def find_in_map_cb(s, m, e) map = current_map return unless map title = MSG_FIND_LOCATION_IN_MAP if not @search require 'IFMapper/FXSearchDialogBox' @search = FXSearchDialogBox.new(self) end @search.proc = method(:find_in_map) @search.title = title @search.text = '' @search.show end |
#find_in_section(s, m, e) ⇒ Object
Find location in section
803 804 805 806 807 808 809 810 811 812 813 814 |
# File 'lib/IFMapper/FXMapperWindow.rb', line 803 def find_in_section(s, m, e) map = current_map return unless map re = /#{s.text}/ matches = [] map.sections[map.section].rooms.each { |r| next unless r.name =~ re matches.push( [ map.section, r] ) } hilite_matches(map, matches, re) end |
#find_in_section_cb(s, m, e) ⇒ Object
Callback
819 820 821 822 823 824 825 826 827 828 829 830 831 832 |
# File 'lib/IFMapper/FXMapperWindow.rb', line 819 def find_in_section_cb(s, m, e) map = current_map return unless map title = MSG_FIND_LOCATION_IN_SECTION if not @search require 'IFMapper/FXSearchDialogBox' @search = FXSearchDialogBox.new(self) end @search.proc = method(:find_in_section) @search.title = title @search.text = '' @search.show end |
#find_object_in_map(s, m, e) ⇒ Object
Find object in map
837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 |
# File 'lib/IFMapper/FXMapperWindow.rb', line 837 def find_object_in_map(s, m, e) map = current_map return unless map re = /#{s.text}/ matches = [] (0...map.sections.size).each { |p| map.sections[p].rooms.each { |r| next unless r.objects =~ re matches.push( [p, r] ) } } idx = @search.index @search.index = matches.size-1 if idx >= matches.size hilite_matches(map, matches, re, @search.index) end |
#find_object_in_map_cb(s, m, e) ⇒ Object
Find object in map
877 878 879 880 881 882 883 884 885 886 887 888 889 890 |
# File 'lib/IFMapper/FXMapperWindow.rb', line 877 def find_object_in_map_cb(s, m, e) map = current_map return unless map title = MSG_FIND_OBJECT_IN_MAP if not @search require 'IFMapper/FXSearchDialogBox' @search = FXSearchDialogBox.new(self) end @search.proc = method(:find_object_in_map) @search.title = title @search.text = '' @search.show end |
#find_task_in_map(s, m, e) ⇒ Object
Find task in map
857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 |
# File 'lib/IFMapper/FXMapperWindow.rb', line 857 def find_task_in_map(s, m, e) map = current_map return unless map re = /#{s.text}/ matches = [] (0...map.sections.size).each { |p| map.sections[p].rooms.each { |r| next unless r.tasks =~ re matches.push( [p, r] ) } } idx = @search.index @search.index = matches.size-1 if idx >= matches.size hilite_matches(map, matches, re, @search.index) end |
#find_task_in_map_cb(s, m, e) ⇒ Object
Find task in map
895 896 897 898 899 900 901 902 903 904 905 906 907 908 |
# File 'lib/IFMapper/FXMapperWindow.rb', line 895 def find_task_in_map_cb(s, m, e) map = current_map return unless map title = MSG_FIND_TASK_IN_MAP if not @search require 'IFMapper/FXSearchDialogBox' @search = FXSearchDialogBox.new(self) end @search.proc = method(:find_task_in_map) @search.title = title @search.text = '' @search.show end |
#hilite_matches(map, matches, re, idx = 0) ⇒ Object
Hilite matches after a search
736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 |
# File 'lib/IFMapper/FXMapperWindow.rb', line 736 def hilite_matches(map, matches, re, idx = 0 ) if matches.size == 0 status "#{ERR_NO_MATCHES} '#{re}'." return end # sort matches by section matches.sort_by { |a| a[0] } # Jump to first section of match map.section = matches[idx][0] map.sections.each { |s| s.rooms.each { |r| r.selected = false } } matches.each { |p, r| next if p != map.section r.selected = true } num = matches.find_all { |p, r| p == matches[idx][0] } room = matches[idx][1] map.center_view_on_room( room ) update_section status "'#{room.name}' #{MSG_MATCHES}. #{matches.size} #{MSG_MATCHES_IN_MAP}, #{num.size} #{MSG_MATCHES_IN_SECTION}." map.draw end |
#hotkeys(*opts) ⇒ Object
1440 1441 1442 1443 |
# File 'lib/IFMapper/FXMapperWindow.rb', line 1440 def hotkeys(*opts) require 'IFMapper/FXAboutDialogBox' FXAboutDialogBox.new(self, BOX_HOTKEYS, MSG_HOTKEYS).show end |
#ifm_export_cb(sender, sel, msg) ⇒ Object
Export current map as an IFM file
400 401 402 403 404 405 406 407 408 409 410 |
# File 'lib/IFMapper/FXMapperWindow.rb', line 400 def ifm_export_cb(sender, sel, msg) map = current_map return unless map require 'IFMapper/FXMapFileDialog' d = FXMapFileDialog.new(self, MSG_SAVE_MAP_AS_IFM, [ FMT_IFM ]) map.export_ifm(d.filename) if d.filename != '' end |
#inform7_export_cb(sender, sel, msg) ⇒ Object
Export current map as an Inform source file
445 446 447 448 449 450 451 452 453 454 455 |
# File 'lib/IFMapper/FXMapperWindow.rb', line 445 def inform7_export_cb(sender, sel, msg) map = current_map return unless map require 'IFMapper/FXMapFileDialog' d = FXMapFileDialog.new(self, MSG_SAVE_MAP_AS_INFORM7, [ FMT_INFORM7, ]) map.export_inform7( d.filename ) if d.filename != '' end |
#inform_export_cb(sender, sel, msg) ⇒ Object
Export current map as an Inform source file
430 431 432 433 434 435 436 437 438 439 440 |
# File 'lib/IFMapper/FXMapperWindow.rb', line 430 def inform_export_cb(sender, sel, msg) map = current_map return unless map require 'IFMapper/FXMapFileDialog' d = FXMapFileDialog.new(self, MSG_SAVE_MAP_AS_INFORM6, [ FMT_INFORM6, ]) map.export_inform( d.filename ) if d.filename != '' end |
#itemlist(sender, sel, event) ⇒ Object
990 991 992 993 994 |
# File 'lib/IFMapper/FXMapperWindow.rb', line 990 def itemlist(sender, sel, event) map = current_map return unless map map.show_itemlist end |
#language ⇒ Object
1417 1418 1419 |
# File 'lib/IFMapper/FXMapperWindow.rb', line 1417 def language return @@default_options['Language'] end |
#language_cb(sender, msg, opts) ⇒ Object
Callback used to change language
302 303 304 305 306 307 |
# File 'lib/IFMapper/FXMapperWindow.rb', line 302 def language_cb(sender, msg, opts) @@default_options['Language'] = LANGUAGES[sender.text] require "IFMapper/locales/#{language}/Messages.rb" recreate end |
#load_icon(filename) ⇒ Object
Load the named PNG icon from a file
340 341 342 343 344 345 346 347 348 349 350 351 |
# File 'lib/IFMapper/FXMapperWindow.rb', line 340 def load_icon(filename) begin filename = File.join("icons", filename) + ".png" icon = nil File.open(filename, "rb") { |f| icon = FXPNGIcon.new(getApp(), f.read) } icon rescue raise RuntimeError, "#{ERR_NO_ICON} #{filename}" end end |
#map_properties ⇒ Object
Bring up the map property requester for current map
1618 1619 1620 1621 |
# File 'lib/IFMapper/FXMapperWindow.rb', line 1618 def map_properties map = current_map map.properties if map end |
#new_map ⇒ Object
Create a new map
312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 |
# File 'lib/IFMapper/FXMapperWindow.rb', line 312 def new_map mapname = "#{MSG_EMPTY_MAP} \##{@maps.size+1}" @maps.push( FXMap.new(mapname, @mdiclient, @@default_options.dup, @mdiicon, @mdimenu, MDI_NORMAL, 0, 0, 790, 500) ) map = @maps[-1] map.window.connect(SEL_PAINT) { map.draw } map.window.connect(SEL_CLOSE) { if map.close_cb @maps.delete(map) end if @maps[-1] @maps[-1].update_roomlist else FXMap::no_maps end } # Make it active @mdiclient.setActiveChild(map.window) map.update_roomlist return map end |
#new_map_cb(*args) ⇒ Object
Callback used to create new map
294 295 296 297 |
# File 'lib/IFMapper/FXMapperWindow.rb', line 294 def new_map_cb(*args) m = new_map m.window.create end |
#next_section ⇒ Object
Go to next section in current map
1578 1579 1580 1581 1582 |
# File 'lib/IFMapper/FXMapperWindow.rb', line 1578 def next_section map = current_map map.next_section if map update_section end |
#open_cb(sender, sel, ptr) ⇒ Object
Callback to Open File
169 170 171 172 173 174 175 |
# File 'lib/IFMapper/FXMapperWindow.rb', line 169 def open_cb(sender, sel, ptr) require 'IFMapper/FXMapFileDialog' file = FXMapFileDialog.new(self, MSG_LOAD_MAP).filename return if file == '' open_file( file ) end |
#open_file(file) ⇒ Object
177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 |
# File 'lib/IFMapper/FXMapperWindow.rb', line 177 def open_file(file) # First, make sure we don't have it loaded already... @maps.each { |m| if m.filename == file @mdiclient.setActiveChild(m.window) return end } # Then, check if we have a single and empty map. # If so, we can just use that one to load the file in. # If not, we need to create a new map make_new_map = false if @maps.size == 1 @maps[0].sections.each { |p| if p.rooms.size != 0 make_new_map = true break end } else make_new_map = true end if make_new_map map = new_map else map = @maps[0] end status "#{MSG_LOADING} '#{file}'..." tmp = nil if file =~ /\.ifm$/i tmp = open_ifm(file, map) elsif file =~ /\.inf$/i tmp = open_inform(file, map) elsif file =~ /\.t$/i or file =~ /\.t3m$/ tmp = open_tads(file, map) elsif file =~ /\.gmp$/ tmp = open_guemap(file, map) elsif file =~ /\.trizbort$/ tmp = open_trizbort(file, map) else tmp = open_map(file) end if not tmp.kind_of?(Map) and not tmp.kind_of?(FXMap) $stderr.puts tmp w = FXWarningBox.new( self, "#{tmp}") w.execute status "#{ERR_COULD_NOT_LOAD} '#{file}'." if make_new_map if map.close_cb @maps.delete(map) GC.start end end sleep 2 return end copy_map(map, tmp, file) end |
#open_guemap(file, map) ⇒ Object
118 119 120 121 122 123 124 125 126 |
# File 'lib/IFMapper/FXMapperWindow.rb', line 118 def open_guemap(file, map) require 'IFMapper/GUEReader' begin GUEReader.new(file, map) rescue => e return "#{e} #{e.backtrace}" end return map end |
#open_ifm(file, map) ⇒ Object
88 89 90 91 92 93 94 95 96 |
# File 'lib/IFMapper/FXMapperWindow.rb', line 88 def open_ifm(file, map) require 'IFMapper/IFMReader' begin IFMReader.new(file, map) rescue => e return "#{e} #{e.backtrace}" end return map end |
#open_inform(file, map) ⇒ Object
108 109 110 111 112 113 114 115 116 |
# File 'lib/IFMapper/FXMapperWindow.rb', line 108 def open_inform(file, map) require 'IFMapper/InformReader' begin InformReader.new(file, map) rescue => e return "#{e} #{e.backtrace}" end return map end |
#open_map(file) ⇒ Object
75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/IFMapper/FXMapperWindow.rb', line 75 def open_map(file) tmp = nil begin f = File.open(file, 'rb') tmp = Marshal.load(f) f.close tmp.filename = file rescue => e tmp = e end return tmp end |
#open_tads(file, map) ⇒ Object
98 99 100 101 102 103 104 105 106 |
# File 'lib/IFMapper/FXMapperWindow.rb', line 98 def open_tads(file, map) require 'IFMapper/TADSReader' begin TADSReader.new(file, map) rescue => e return "#{e} #{e.backtrace}" end return map end |
#open_trizbort(file, map) ⇒ Object
128 129 130 131 132 133 134 135 136 |
# File 'lib/IFMapper/FXMapperWindow.rb', line 128 def open_trizbort(file, map) require 'IFMapper/TrizbortReader' begin TrizbortReader.new(file, map) rescue => e return "#{e} #{e.backtrace}" end return map end |
#paste_selected_cb(*o) ⇒ Object
725 726 727 728 729 |
# File 'lib/IFMapper/FXMapperWindow.rb', line 725 def paste_selected_cb(*o) map = current_map return if not map or not @@copy_buffer FXMapperWindow::paste_selected(map) end |
#pdf_export_cb(sender, sel, msg) ⇒ Object
Export current map as Acrobat PDF
509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 |
# File 'lib/IFMapper/FXMapperWindow.rb', line 509 def pdf_export_cb(sender, sel, msg) map = current_map return unless map begin require 'IFMapper/PDFMapExporter' rescue LoadError => e w = FXWarningBox.new( self, "#{e}") w.execute return end # PRE: Let's ask for a page size and orientation for the PDF # and whether the user wants to include location numbers map.pdfpapersize = 0 map.pdflocationnos = 1 require 'IFMapper/FXPDFMapExporterOptionsDialogBox' cmd = FXPDFMapExporterOptionsDialogBox.new(self, MSG_SAVE_MAP_AS_PDF, map).execute return if cmd == 0 require 'IFMapper/FXMapFileDialog' d = FXMapFileDialog.new(self, MSG_SAVE_MAP_AS_PDF, [ FMT_PDF ]) if d.filename != '' map.pdf_export(d.filename) end end |
#previous_section ⇒ Object
Go to previous section in current map
1587 1588 1589 1590 1591 |
# File 'lib/IFMapper/FXMapperWindow.rb', line 1587 def previous_section map = current_map map.previous_section if map update_section end |
#print_cb(sender, sel, msg) ⇒ Object
Print current map graphically
544 545 546 547 548 549 550 551 552 553 554 555 |
# File 'lib/IFMapper/FXMapperWindow.rb', line 544 def print_cb(sender, sel, msg) map = current_map return unless map w = FXWarningBox.new( self, ERR_NO_PRINTING ) w.execute return require 'IFMapper/MapPrinting' printer = printer_dialog map.print( printer ) if printer end |
#print_locations_cb(sender, sel, msg) ⇒ Object
Print out all the locations in map
385 386 387 388 389 390 391 392 393 394 395 |
# File 'lib/IFMapper/FXMapperWindow.rb', line 385 def print_locations_cb(sender, sel, msg) map = current_map return unless map w = FXWarningBox.new( self, ERR_NO_PRINTING) w.execute return printer = printer_dialog MSG_PRINT_LOC map.print_locations( printer ) if printer end |
#printer_dialog(title = MSG_PRINT_MAP) ⇒ Object
Popup a printer dialog and return the settings or false if user cancels
374 375 376 377 378 379 380 |
# File 'lib/IFMapper/FXMapperWindow.rb', line 374 def printer_dialog(title = MSG_PRINT_MAP) map = current_map dlg = FXPrintDialog.new(self, title + " for #{map.name}") dlg.printer.flags |= PRINT_DEST_PAPER return dlg.printer if dlg.execute != 0 return false end |
#roomlist(sender, sel, event) ⇒ Object
984 985 986 987 988 |
# File 'lib/IFMapper/FXMapperWindow.rb', line 984 def roomlist(sender, sel, event) map = current_map return unless map map.show_roomlist end |
#save_as_cb(sender, sel, ptr) ⇒ Object
Callback for Save As
285 286 287 288 289 |
# File 'lib/IFMapper/FXMapperWindow.rb', line 285 def save_as_cb(sender, sel, ptr) map = current_map return unless map map.save_as end |
#save_cb(sender, sel, ptr) ⇒ Object
Callback for Save
276 277 278 279 280 |
# File 'lib/IFMapper/FXMapperWindow.rb', line 276 def save_cb(sender, sel, ptr) map = current_map return unless map map.save end |
#select_all_cb(sender, id, event) ⇒ Object
Select all
978 979 980 981 982 |
# File 'lib/IFMapper/FXMapperWindow.rb', line 978 def select_all_cb( sender, id, event ) map = current_map return if not map map.select_all end |
#select_none_cb(sender, id, event) ⇒ Object
Unselect all
968 969 970 971 972 973 |
# File 'lib/IFMapper/FXMapperWindow.rb', line 968 def select_none_cb( sender, id, event ) map = current_map return if not map map.clear_selection map.draw end |
#start_automap_cb(sender, sel, ptr) ⇒ Object
Start automapping from a transcript
141 142 143 144 145 |
# File 'lib/IFMapper/FXMapperWindow.rb', line 141 def start_automap_cb(sender, sel, ptr) map = current_map return if not map map.start_automap end |
#status(msg) ⇒ Object
Write a message to the status bar
256 257 258 |
# File 'lib/IFMapper/FXMapperWindow.rb', line 256 def status(msg) @statusbar.statusLine.text = msg end |
#stop_automap_cb(sender, sel, ptr) ⇒ Object
Stop automapping from a transcript
159 160 161 162 163 |
# File 'lib/IFMapper/FXMapperWindow.rb', line 159 def stop_automap_cb(sender, sel, ptr) map = current_map return if not map map.stop_automap end |
#svg_export_cb(sender, sel, msg) ⇒ Object
Export current map as Structured Vector Graphics (SVG)
477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 |
# File 'lib/IFMapper/FXMapperWindow.rb', line 477 def svg_export_cb(sender, sel, msg) map = current_map return unless map begin require 'IFMapper/SVGMapExporter' rescue LoadError => e w = FXWarningBox.new( self, "#{e}") w.execute return end require 'IFMapper/FXSVGMapExporterOptionsDialogBox' cmd = FXSVGMapExporterOptionsDialogBox.new(self, MSG_SAVE_MAP_AS_SVG, map).execute return if cmd == 0 require 'IFMapper/FXMapFileDialog' d = FXMapFileDialog.new(self, MSG_SAVE_MAP_AS_SVG, [ FMT_SVG ]) if d.filename != '' map.svg_export(d.filename) end end |
#tads_export_cb(sender, sel, msg) ⇒ Object
Export current map as a TADs source file
461 462 463 464 465 466 467 468 469 470 471 472 |
# File 'lib/IFMapper/FXMapperWindow.rb', line 461 def tads_export_cb(sender, sel, msg) map = current_map return unless map require 'IFMapper/TADSWriter' require 'IFMapper/FXMapFileDialog' d = FXMapFileDialog.new(self, MSG_SAVE_MAP_AS_TADS, [ FMT_TADS ]) map.export_tads( d.filename ) if d.filename != '' end |
#trizbort_export_cb(sender, sel, msg) ⇒ Object
Export current map as an IFM file
415 416 417 418 419 420 421 422 423 424 425 |
# File 'lib/IFMapper/FXMapperWindow.rb', line 415 def trizbort_export_cb(sender, sel, msg) map = current_map return unless map require 'IFMapper/FXMapFileDialog' d = FXMapFileDialog.new(self, MSG_SAVE_MAP_AS_TRIZBORT, [ FMT_TRIZBORT ]) map.export_trizbort(d.filename) if d.filename != '' end |
#update_map ⇒ Object
557 558 559 560 561 562 |
# File 'lib/IFMapper/FXMapperWindow.rb', line 557 def update_map map = current_map return unless map map.update_roomlist update_section end |
#update_section ⇒ Object
Update section # in toolbar widget
1569 1570 1571 1572 1573 |
# File 'lib/IFMapper/FXMapperWindow.rb', line 1569 def update_section map = current_map return unless map @section.text = (map.section + 1).to_s end |
#zoom_in ⇒ Object
Zoom in into current map
1596 1597 1598 1599 1600 1601 1602 |
# File 'lib/IFMapper/FXMapperWindow.rb', line 1596 def zoom_in map = current_map if map map.zoom_in map.draw end end |
#zoom_out ⇒ Object
Zoom out from current map
1607 1608 1609 1610 1611 1612 1613 |
# File 'lib/IFMapper/FXMapperWindow.rb', line 1607 def zoom_out map = current_map if map map.zoom_out map.draw end end |