Class: FXMapperWindow
- Inherits:
-
FXMainWindow
- Object
- FXMainWindow
- FXMapperWindow
- Defined in:
- lib/IFMapper/FXMapperWindow.rb
Constant Summary collapse
- 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 Scalable 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.
1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 |
# File 'lib/IFMapper/FXMapperWindow.rb', line 1665 def initialize(app) super(app, eval("\"#{TITLE}\""), nil, nil, DECOR_ALL, 0, 0, 800, 600) @colors = nil = 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
607 608 609 |
# File 'lib/IFMapper/FXMapperWindow.rb', line 607 def self.copy_buffer return @@copy_buffer end |
.copy_selected(map) ⇒ Object
Copy selected elements
614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 |
# File 'lib/IFMapper/FXMapperWindow.rb', line 614 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
643 644 645 646 647 |
# File 'lib/IFMapper/FXMapperWindow.rb', line 643 def self.cut_selected(map) return map. if map. FXMapperWindow::copy_selected(map) map.cut_selected end |
.default_options ⇒ Object
65 66 67 |
# File 'lib/IFMapper/FXMapperWindow.rb', line 65 def self. return end |
.paste_selected(map) ⇒ Object
Paste selected elements
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 712 713 714 715 716 717 718 719 720 |
# File 'lib/IFMapper/FXMapperWindow.rb', line 652 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
1005 1006 1007 1008 1009 |
# File 'lib/IFMapper/FXMapperWindow.rb', line 1005 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
158 159 160 161 162 |
# File 'lib/IFMapper/FXMapperWindow.rb', line 158 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.
1632 1633 1634 1635 1636 |
# File 'lib/IFMapper/FXMapperWindow.rb', line 1632 def autosave @maps.each { |m| m.save } end |
#close_cb(*args) ⇒ Object
1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 |
# File 'lib/IFMapper/FXMapperWindow.rb', line 1682 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
961 962 963 964 965 966 967 968 969 970 971 972 |
# File 'lib/IFMapper/FXMapperWindow.rb', line 961 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
364 365 366 367 368 |
# File 'lib/IFMapper/FXMapperWindow.rb', line 364 def complex_connection_cb(sender, sel, msg) map = current_map return unless map map.complex_connection end |
#copy_map(map, tmp, file) ⇒ Object
250 251 252 253 254 255 256 257 258 259 |
# File 'lib/IFMapper/FXMapperWindow.rb', line 250 def copy_map(map, tmp, file) map.copy(tmp) map..replace( .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
728 729 730 731 732 |
# File 'lib/IFMapper/FXMapperWindow.rb', line 728 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
575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 |
# File 'lib/IFMapper/FXMapperWindow.rb', line 575 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(, , @mdiclient, FXMDIClient::ID_MDI_MENUWINDOW, LAYOUT_LEFT) FXMDIDeleteButton.new(, @mdiclient, FXMDIClient::ID_MDI_MENUCLOSE, FRAME_RAISED|LAYOUT_RIGHT) FXMDIRestoreButton.new(, @mdiclient, FXMDIClient::ID_MDI_MENURESTORE, FRAME_RAISED|LAYOUT_RIGHT) FXMDIMinimizeButton.new(, @mdiclient, FXMDIClient::ID_MDI_MENUMINIMIZE, FRAME_RAISED|LAYOUT_RIGHT) # Icon for MDI Child @mdiicon = load_icon("winapp") # Make MDI Window Menu = FXMDIMenu.new(self, @mdiclient) end |
#create_menus ⇒ Object
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 1416 1417 1418 1419 1420 1421 1422 1423 1424 |
# File 'lib/IFMapper/FXMapperWindow.rb', line 1012 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(, 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(filemenu, MENU_PRINT, nil, submenu) cmd = FXMenuCommand.new(, MENU_QUIT, nil) cmd.connect( SEL_COMMAND, method(:close_cb) ) # Edit Menu = FXMenuPane.new(self) FXMenuTitle.new(, 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 = ['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 = ['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 = ['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 = ['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 = ['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 = ['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 = ['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 = ['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 = ['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 = ['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 = ['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(, 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(, 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(, MENU_HELP, nil, ) end |
#create_toolbar(toolbar) ⇒ Object
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 1565 1566 1567 1568 1569 |
# File 'lib/IFMapper/FXMapperWindow.rb', line 1450 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
1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 |
# File 'lib/IFMapper/FXMapperWindow.rb', line 1639 def # 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 = 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
271 272 273 274 275 276 277 278 279 |
# File 'lib/IFMapper/FXMapperWindow.rb', line 271 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
722 723 724 725 726 |
# File 'lib/IFMapper/FXMapperWindow.rb', line 722 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
373 374 375 376 377 |
# File 'lib/IFMapper/FXMapperWindow.rb', line 373 def delete_selected_cb(sender, sel, msg) map = current_map return unless map map.delete_selected end |
#docs(*opts) ⇒ Object
1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 |
# File 'lib/IFMapper/FXMapperWindow.rb', line 1430 def docs(*opts) address = 'docs/' + language + '/start.html' status "#{MSG_OPENING_WEB_PAGE} #{address}..." if RUBY_PLATFORM =~ /mswin|mingw|cygwin/ system("rundll32 url.dll,FileProtocolHandler \"#{address}\"") elsif RUBY_PLATFORM =~ /darwin/ system("open \"#{address}\"") elsif RUBY_PLATFORM =~ /linux|bsd/ system("xdg-open \"#{address}\"") else status ERR_COULD_NOT_OPEN_WEB_BROWSER end end |
#find_desc_in_map(s, m, e) ⇒ Object
Find task in map
922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 |
# File 'lib/IFMapper/FXMapperWindow.rb', line 922 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
942 943 944 945 946 947 948 949 950 951 952 953 954 955 |
# File 'lib/IFMapper/FXMapperWindow.rb', line 942 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
777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 |
# File 'lib/IFMapper/FXMapperWindow.rb', line 777 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
794 795 796 797 798 799 800 801 802 803 804 805 806 807 |
# File 'lib/IFMapper/FXMapperWindow.rb', line 794 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
812 813 814 815 816 817 818 819 820 821 822 823 |
# File 'lib/IFMapper/FXMapperWindow.rb', line 812 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
828 829 830 831 832 833 834 835 836 837 838 839 840 841 |
# File 'lib/IFMapper/FXMapperWindow.rb', line 828 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
846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 |
# File 'lib/IFMapper/FXMapperWindow.rb', line 846 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
886 887 888 889 890 891 892 893 894 895 896 897 898 899 |
# File 'lib/IFMapper/FXMapperWindow.rb', line 886 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
866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 |
# File 'lib/IFMapper/FXMapperWindow.rb', line 866 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
904 905 906 907 908 909 910 911 912 913 914 915 916 917 |
# File 'lib/IFMapper/FXMapperWindow.rb', line 904 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
745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 |
# File 'lib/IFMapper/FXMapperWindow.rb', line 745 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
1445 1446 1447 1448 |
# File 'lib/IFMapper/FXMapperWindow.rb', line 1445 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
408 409 410 411 412 413 414 415 416 417 418 |
# File 'lib/IFMapper/FXMapperWindow.rb', line 408 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
453 454 455 456 457 458 459 460 461 462 463 |
# File 'lib/IFMapper/FXMapperWindow.rb', line 453 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
438 439 440 441 442 443 444 445 446 447 448 |
# File 'lib/IFMapper/FXMapperWindow.rb', line 438 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
999 1000 1001 1002 1003 |
# File 'lib/IFMapper/FXMapperWindow.rb', line 999 def itemlist(sender, sel, event) map = current_map return unless map map.show_itemlist end |
#language ⇒ Object
1426 1427 1428 |
# File 'lib/IFMapper/FXMapperWindow.rb', line 1426 def language return ['Language'] end |
#language_cb(sender, msg, opts) ⇒ Object
Callback used to change language
310 311 312 313 314 315 |
# File 'lib/IFMapper/FXMapperWindow.rb', line 310 def language_cb(sender, msg, opts) ['Language'] = LANGUAGES[sender.text] require "IFMapper/locales/#{language}/Messages.rb" recreate end |
#load_icon(filename) ⇒ Object
Load the named PNG icon from a file
348 349 350 351 352 353 354 355 356 357 358 359 |
# File 'lib/IFMapper/FXMapperWindow.rb', line 348 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
1623 1624 1625 1626 |
# File 'lib/IFMapper/FXMapperWindow.rb', line 1623 def map_properties map = current_map map.properties if map end |
#new_map ⇒ Object
Create a new map
320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 |
# File 'lib/IFMapper/FXMapperWindow.rb', line 320 def new_map mapname = "#{MSG_EMPTY_MAP} \##{@maps.size+1}" @maps.push( FXMap.new(mapname, @mdiclient, .dup, @mdiicon, , 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
302 303 304 305 |
# File 'lib/IFMapper/FXMapperWindow.rb', line 302 def new_map_cb(*args) m = new_map m.window.create end |
#next_section ⇒ Object
Go to next section in current map
1583 1584 1585 1586 1587 |
# File 'lib/IFMapper/FXMapperWindow.rb', line 1583 def next_section map = current_map map.next_section if map update_section end |
#open_cb(sender, sel, ptr) ⇒ Object
Callback to Open File
177 178 179 180 181 182 183 |
# File 'lib/IFMapper/FXMapperWindow.rb', line 177 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
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 241 242 243 244 245 246 247 248 |
# File 'lib/IFMapper/FXMapperWindow.rb', line 185 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
126 127 128 129 130 131 132 133 134 |
# File 'lib/IFMapper/FXMapperWindow.rb', line 126 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
96 97 98 99 100 101 102 103 104 |
# File 'lib/IFMapper/FXMapperWindow.rb', line 96 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
116 117 118 119 120 121 122 123 124 |
# File 'lib/IFMapper/FXMapperWindow.rb', line 116 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
83 84 85 86 87 88 89 90 91 92 93 94 |
# File 'lib/IFMapper/FXMapperWindow.rb', line 83 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
106 107 108 109 110 111 112 113 114 |
# File 'lib/IFMapper/FXMapperWindow.rb', line 106 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
136 137 138 139 140 141 142 143 144 |
# File 'lib/IFMapper/FXMapperWindow.rb', line 136 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
734 735 736 737 738 |
# File 'lib/IFMapper/FXMapperWindow.rb', line 734 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
517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 |
# File 'lib/IFMapper/FXMapperWindow.rb', line 517 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
1592 1593 1594 1595 1596 |
# File 'lib/IFMapper/FXMapperWindow.rb', line 1592 def previous_section map = current_map map.previous_section if map update_section end |
#print_cb(sender, sel, msg) ⇒ Object
Print current map graphically
552 553 554 555 556 557 558 559 560 561 562 563 |
# File 'lib/IFMapper/FXMapperWindow.rb', line 552 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
393 394 395 396 397 398 399 400 401 402 403 |
# File 'lib/IFMapper/FXMapperWindow.rb', line 393 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
382 383 384 385 386 387 388 |
# File 'lib/IFMapper/FXMapperWindow.rb', line 382 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
993 994 995 996 997 |
# File 'lib/IFMapper/FXMapperWindow.rb', line 993 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
293 294 295 296 297 |
# File 'lib/IFMapper/FXMapperWindow.rb', line 293 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
284 285 286 287 288 |
# File 'lib/IFMapper/FXMapperWindow.rb', line 284 def save_cb(sender, sel, ptr) map = current_map return unless map map.save end |
#select_all_cb(sender, id, event) ⇒ Object
Select all
987 988 989 990 991 |
# File 'lib/IFMapper/FXMapperWindow.rb', line 987 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
977 978 979 980 981 982 |
# File 'lib/IFMapper/FXMapperWindow.rb', line 977 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
149 150 151 152 153 |
# File 'lib/IFMapper/FXMapperWindow.rb', line 149 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
264 265 266 |
# File 'lib/IFMapper/FXMapperWindow.rb', line 264 def status(msg) .statusLine.text = msg end |
#stop_automap_cb(sender, sel, ptr) ⇒ Object
Stop automapping from a transcript
167 168 169 170 171 |
# File 'lib/IFMapper/FXMapperWindow.rb', line 167 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 Scalable Vector Graphics (SVG)
485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 |
# File 'lib/IFMapper/FXMapperWindow.rb', line 485 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
469 470 471 472 473 474 475 476 477 478 479 480 |
# File 'lib/IFMapper/FXMapperWindow.rb', line 469 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
423 424 425 426 427 428 429 430 431 432 433 |
# File 'lib/IFMapper/FXMapperWindow.rb', line 423 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
565 566 567 568 569 570 |
# File 'lib/IFMapper/FXMapperWindow.rb', line 565 def update_map map = current_map return unless map map.update_roomlist update_section end |
#update_section ⇒ Object
Update section # in toolbar widget
1574 1575 1576 1577 1578 |
# File 'lib/IFMapper/FXMapperWindow.rb', line 1574 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
1601 1602 1603 1604 1605 1606 1607 |
# File 'lib/IFMapper/FXMapperWindow.rb', line 1601 def zoom_in map = current_map if map map.zoom_in map.draw end end |
#zoom_out ⇒ Object
Zoom out from current map
1612 1613 1614 1615 1616 1617 1618 |
# File 'lib/IFMapper/FXMapperWindow.rb', line 1612 def zoom_out map = current_map if map map.zoom_out map.draw end end |