/***************************** control.c ******************************/ #include "sdi.h" #include "sdi_color.h" /* * Copyright 1987 by Mark Weiser. * Permission to reproduce and use in any manner whatsoever on Suns is granted * so long as this copyright and other identifying marks of authorship * in the code and the game remain intact and visible. Use of this code * in other products is reserved to me--I'm working on Mac and IBM versions. */ /* * The main code for setting up the control panel lives here. * Other panel-related code is in control_procs.c, helpers.c, and main.c. */ static short interceptor_pic_array[] = { #include "interceptor_picture.h" }; static short laser_pic_array[] = { #include "laser_picture.h" }; static short rock_pic_array[] = { #include "rock_picture.h" }; static short foe_pic_array[] = { #include "foe_picture.h" }; static short cursor_pic_array[] = { #include "cursor.h" }; static short dyna_pic_array[] = { #include "dyna_picture.h" }; static short silly_pic_array[] = { #include "silly_picture.h" }; static Xv_Window interceptor_pic, laser_pic, rock_pic, foe_pic, cursor_pic, dyna_pic, silly_pic; extern Panel_setting save_file_notify_proc(), name_notify_proc(); Panel_item cycle_time_item, timeout_item; /* * Build and place all the items in the control panel. */ init_control(panel) Panel panel; { extern Panel_item rock_item; interceptor_pic = (Xv_Window)xv_create(XV_NULL, SERVER_IMAGE, XV_HEIGHT, 16, XV_WIDTH, 16, SERVER_IMAGE_BITS, interceptor_pic_array, NULL); init_text(); laser_pic = (Xv_Window)xv_create(XV_NULL, SERVER_IMAGE, XV_HEIGHT, 16, XV_WIDTH, 16, SERVER_IMAGE_BITS, laser_pic_array, NULL); rock_pic = (Xv_Window)xv_create(XV_NULL, SERVER_IMAGE, XV_HEIGHT, 16, XV_WIDTH, 16, SERVER_IMAGE_BITS, rock_pic_array, NULL); foe_pic = (Xv_Window)xv_create(XV_NULL, SERVER_IMAGE, XV_HEIGHT, 16, XV_WIDTH, 16, SERVER_IMAGE_BITS, foe_pic_array, NULL); cursor_pic = (Xv_Window)xv_create(XV_NULL, SERVER_IMAGE, XV_HEIGHT, 16, XV_WIDTH, 16, SERVER_IMAGE_BITS, cursor_pic_array, NULL); dyna_pic = (Xv_Window)xv_create(XV_NULL, SERVER_IMAGE, XV_HEIGHT, 16, XV_WIDTH, 16, SERVER_IMAGE_BITS, dyna_pic_array, NULL); silly_pic = (Xv_Window)xv_create(XV_NULL, SERVER_IMAGE, XV_HEIGHT, 16, XV_WIDTH, 16, SERVER_IMAGE_BITS, silly_pic_array, NULL); next_round_item = xv_create(panel, PANEL_BUTTON, PANEL_LABEL_STRING, "Next Round", PANEL_NOTIFY_PROC, next_round_proc, XV_SHOW, FALSE, 0); (void) xv_create(panel, PANEL_BUTTON, PANEL_LABEL_STRING, "Quit", PANEL_NOTIFY_PROC, quit_proc, 0); (void) xv_create(panel, PANEL_BUTTON, PANEL_LABEL_STRING, "New Game", PANEL_NOTIFY_PROC, new_game_proc, 0); suspend_item = xv_create(panel, PANEL_BUTTON, PANEL_LABEL_STRING, "Suspend", PANEL_NOTIFY_PROC, suspend_proc, 0); resume_item = xv_create(panel, PANEL_BUTTON, PANEL_LABEL_STRING, "Resume", PANEL_NOTIFY_PROC, resume_proc, XV_SHOW, FALSE, XV_X, xv_get(suspend_item, XV_X), XV_Y, xv_get(suspend_item ,XV_Y), 0); level_item = xv_create(panel, PANEL_TEXT, PANEL_LABEL_STRING, "Level:", PANEL_VALUE, "0", (char *)PANEL_EVENT_PROC, (char *)no_events, PANEL_VALUE_DISPLAY_LENGTH, 2, 0); score_item = xv_create(panel, PANEL_TEXT, PANEL_LABEL_STRING, "Score:", PANEL_VALUE, "0", PANEL_VALUE_DISPLAY_LENGTH, 8, (char *)PANEL_EVENT_PROC, (char *)no_events, 0); OPENPANELCOLORS interceptor_item = xv_create(panel, PANEL_GAUGE, ATTR_LIST, panel_common, #ifdef STRINGLABELS PANEL_LABEL_STRING, "Interceptors: ", #else PANEL_LABEL_IMAGE, interceptor_pic, PANEL_ITEM_COLOR, BLACK, #endif 0); rock_item = xv_create(panel, PANEL_GAUGE, ATTR_LIST, panel_common, #ifdef STRINGLABELS PANEL_LABEL_STRING, "Rocks: ", #else PANEL_LABEL_IMAGE, rock_pic, PANEL_ITEM_COLOR, BROWN, #endif 0); laser_item = xv_create(panel, PANEL_GAUGE, ATTR_LIST, panel_common, #ifdef STRINGLABELS PANEL_LABEL_STRING, "X-ray lasers: ", #else PANEL_LABEL_IMAGE, laser_pic, PANEL_ITEM_COLOR, ORANGE, #endif 0); #define FOE_WIDTH 270 foe_item = xv_create(panel, PANEL_GAUGE, ATTR_LIST, panel_common, #ifdef STRINGLABELS PANEL_LABEL_STRING, "Foe in flight:", #else PANEL_LABEL_IMAGE, foe_pic, PANEL_ITEM_COLOR, ORANGERED, #endif PANEL_SLIDER_WIDTH, FOE_WIDTH, 0); CLOSEPANELCOLORS total_foe_item = xv_create(panel, PANEL_TEXT, PANEL_LABEL_STRING, "Total foe killed:", PANEL_VALUE, "0", PANEL_VALUE_DISPLAY_LENGTH, 24, (char *)PANEL_EVENT_PROC, (char *)no_events, 0); if (time_to_play) { timeout_item = xv_create(panel, PANEL_GAUGE, ATTR_LIST, panel_common, PANEL_LABEL_STRING, "Seconds remaining:", PANEL_MIN_VALUE, 0, PANEL_MAX_VALUE, time_to_play, PANEL_VALUE, time_to_play, PANEL_SLIDER_WIDTH, 500, 0); continuous = 1; start_timeout(timeout_item); } (void) xv_create(panel, PANEL_BUTTON, PANEL_LABEL_STRING, "Options", PANEL_NOTIFY_PROC, misc_options_proc, 0); (void) xv_create(panel, PANEL_BUTTON, PANEL_LABEL_STRING, "Things To Read", PANEL_NOTIFY_PROC, text_options_proc, 0); (void) xv_create(panel, PANEL_BUTTON, PANEL_LABEL_STRING, "Icon Options", PANEL_NOTIFY_PROC, icon_option_proc, 0); skill_item = xv_create(panel, PANEL_CYCLE, PANEL_LABEL_STRING, " Skill:", PANEL_CHOICE_STRINGS, "Novice", "Occasional", "Expert", 0, PANEL_NOTIFY_PROC, new_game_proc, PANEL_VALUE, starting_skill, 0); (void) xv_create(panel, PANEL_BUTTON, PANEL_LABEL_STRING, "Instructions", PANEL_NOTIFY_PROC, instructions_proc, 0); (void) xv_create(panel, PANEL_TOGGLE, PANEL_CHOICE_STRINGS, "Realistic", 0, PANEL_NOTIFY_PROC, realistic_proc, XV_SHOW, TRUE, 0); if (gamemaster) { (void) xv_create(panel, PANEL_TOGGLE, PANEL_CHOICE_STRINGS, "", 0, PANEL_NOTIFY_PROC, master_proc, XV_SHOW, TRUE, 0); } } void misc_options_proc() { char *s; Panel panel, make_popup_panel(); void options_done(); if ((panel = make_popup_panel(" SDI Options", options_done)) == NULL) { return; } (void) xv_create(panel, PANEL_CYCLE, PANEL_LABEL_STRING, "Cursor:", PANEL_CHOICE_IMAGES, cursor_pic, dyna_pic, silly_pic, 0, PANEL_NOTIFY_PROC, cursor_notify_proc, PANEL_VALUE, cursor_type, 0); (void) xv_create(panel, PANEL_TOGGLE, PANEL_CHOICE_STRINGS, "Non-stop", 0, PANEL_NOTIFY_PROC, non_stop_notify_proc, PANEL_VALUE, continuous, 0); (void) xv_create(panel, PANEL_BUTTON, PANEL_LABEL_STRING, "Melt", PANEL_NOTIFY_PROC, end_proc, 0); if (user_name[0] == '\0') { s = (char *)get_name(); if (s[0] != '\0') strcpy(user_name, s); } user_name_item = xv_create(panel, PANEL_TEXT, PANEL_LABEL_STRING, "Name: ", PANEL_VALUE_DISPLAY_LENGTH, 16, PANEL_VALUE_STORED_LENGTH, 63, PANEL_VALUE, user_name, 0); window_fit_width(panel); (void) xv_create(panel, PANEL_BUTTON, PANEL_LABEL_STRING, "Save", PANEL_NOTIFY_PROC, save_proc, 0); (void) xv_create(panel, PANEL_BUTTON, PANEL_LABEL_STRING, "Restore", PANEL_NOTIFY_PROC, restore_proc, 0); save_file_item = xv_create(panel, PANEL_TEXT, PANEL_LABEL_STRING, "Save file:", PANEL_VALUE_DISPLAY_LENGTH, 16, PANEL_VALUE_STORED_LENGTH, 63, PANEL_VALUE, save_file_name, 0); cycle_item = xv_create(panel, PANEL_SLIDER, PANEL_LABEL_STRING, "Cycle time (ms): ", PANEL_NOTIFY_LEVEL, PANEL_ALL, PANEL_SLIDER_WIDTH, 100, PANEL_MIN_VALUE, 5, PANEL_MAX_VALUE, 999, PANEL_SHOW_RANGE, FALSE, PANEL_SHOW_VALUE, TRUE, PANEL_VALUE, blast_delay/1000, XV_SHOW, TRUE, PANEL_NOTIFY_PROC, cycle_time_proc, 0); ballistic_time_item = xv_create(panel, PANEL_SLIDER, PANEL_LABEL_STRING, "Ballistic time: ", PANEL_SLIDER_WIDTH, 50, PANEL_MIN_VALUE, 0, PANEL_MAX_VALUE, 10, PANEL_SHOW_RANGE, FALSE, PANEL_SHOW_VALUE, TRUE, PANEL_VALUE, ballistic_delay, XV_SHOW, TRUE, PANEL_NOTIFY_PROC, ballistic_time_proc, 0); round_item = xv_create(panel, PANEL_SLIDER, PANEL_LABEL_STRING, "Max round duration: ", PANEL_SLIDER_WIDTH, 50, PANEL_MIN_VALUE, 1, PANEL_MAX_VALUE, 90, PANEL_SHOW_RANGE, FALSE, PANEL_SHOW_VALUE, TRUE, PANEL_VALUE, round_duration/1000000, XV_SHOW, TRUE, PANEL_NOTIFY_PROC, round_time_proc, 0); launch_interval_item = xv_create(panel, PANEL_SLIDER, PANEL_LABEL_STRING, "mean launch interval: ", PANEL_SLIDER_WIDTH, 50, PANEL_MIN_VALUE, 100, PANEL_MAX_VALUE, 5000, PANEL_SHOW_RANGE, FALSE, PANEL_SHOW_VALUE, TRUE, PANEL_VALUE, missile_delay/1000, XV_SHOW, TRUE, PANEL_NOTIFY_PROC, missile_delay_proc, 0); user_name[0] = '\0'; save_file_name[0] = '\0'; display_popup_panel(panel); } void options_done() { strcpy(user_name, xv_get(user_name_item, PANEL_VALUE)); strcpy(save_file_name, xv_get(save_file_item, PANEL_VALUE)); }