Constant STORY "GMenuDemo 4"; Constant HEADLINE "^GWindows Demonstration Program 7^"; Constant DEMO 7; Constant PURPOSE "This program shows how a minor change to the layout code affects the program. This program is identical to GMenuDemo 3, except for the placement of the status bar."; ! GWindows Demo program. ! ! This demo shows the difference between two very similar layouts ! This is identical to GMenuDemo 3 except for the placement of the status bar ! GWindows switches Constant GW_ECHO_OVERRIDE; ! Force override commands to be printed ! Include Gwindows Definitions include "gwindefs"; include "parser"; include "verblib"; ! Include GWindows base classes include "gwincls"; ! Include GWindows hooks include "gwindows"; include "grammar"; ! Include GWindows predefined widgets include "gstatus"; include "gmenu"; ! Class for menu items ! 'menu_cmd' items execute a command based on their name, so if the option ! menu_cmd "TAKE BALL"; ! was selected, the game would act as if the player had typed >TAKE BALL ! himself ! ! 'menu_word' items insert their name into the current input line. class menu_cmd with select [; cmd_override=self; ]; class menu_word with select [; StreamWord(self); ]; ! 'item_word' is a menuword whose name is taken from an item in the area. class item_word(12) class menu_word with short_name [; print (name) self.number; rtrue;], number 0; ! The menu's data. It consists of items which override player input, and ! items which append to player input object main_menu; menu_cmd -> "LOOK"; menu_cmd -> "QUIT"; menu_cmd -> "SAVE"; menu_cmd -> "RESTART"; menu_cmd -> "RESTORE"; menu_cmd -> "SCORE"; menu_word -> "EXAMINE "; menu_word -> "TAKE "; menu_word -> "DROP "; ! The location menu. It uses 'update' to refresh its contents each turn. object loc_menu with update [ o x; for(o=child(self):o:o=x) { x=sibling(o); item_word.destroy(o); } objectloop(o in location) { x=item_word.create(); if (x) { x.number=o; move x to loc_menu; } } rtrue; ]; [ InitGWindows; Active_UI=top; Main_GWindow=mainwin; ]; ! The layout becomes slightly more complex. 'mainarea' is essentially ! the top-level windowpair from demo1, but we now divide the top-level ! window into mainarea and the menu. ! ! The major difference from GMenuDemo 1 is that we now use a GPopupMenu WindowPair top; WindowPair -> mainarea; Textbuffer -> -> mainwin; GMenu -> -> menuwin with split 33, split_dir winmethod_Left; GStatusWin -> statuswin with split 1, split_dir winmethod_Above, has abssplit; object r1 "Test room" with description "This is a primitive room. Its only purpose is to give the user somewhere to be while viewing this GWindows Demonstration", has light; object -> foo "foo" with name 'foo'; object -> bar "bar" with name 'bar'; [ Initialise; location=r1; print "^^^Welcome to GWindows demo program ", DEMO, ". ", (string) PURPOSE, "^^"; ]; [ dmenusub; if (menuwin.current_menu==main_menu) menuwin.activate(loc_menu); else menuwin.activate(main_menu); ]; verb 'menu' * -> dmenu;