/* ------------------------------------------------------------------------ * Initialising * ------------------------------------------------------------------------ */ static void ui_enter_init(Game_Event.Event_Type type, Game_Event data, object user) { show_splashscreen(type, data, user); /* Set up our splashscreen handlers */ Game_Event.add_handler(Game_Event.Event_Type.INITSTATUS, splashscreen_note, null); }
/* * Called when we enter the birth mode - so we set up handlers, command hooks, * etc, here. */ static void ui_enter_birthscreen(Game_Event.Event_Type type, Game_Event data, object user) { ///* Set the ugly static global that tells us if quickstart's available. */ quickstart_allowed = data.flag; setup_menus(); }
static void show_splashscreen(Game_Event.Event_Type type, Game_Event data, object user) { //ang_file *fp; //char buf[1024]; /*** Verify the "news" file ***/ string buf = Misc.path_build(Misc.ANGBAND_DIR_FILE, "news.txt"); if (!File.Exists(buf)) { //char why[1024]; /* Crash and burn */ string why = "Cannot access the '" + buf + "' file!"; throw new NotImplementedException(); //<-- Uncomment below and remove this //init_angband_aux(why); } /*** Display the "news" file ***/ Term.clear(); /* Open the News file */ buf = Misc.path_build(Misc.ANGBAND_DIR_FILE, "news.txt"); //Didn't we just do this? FileStream fp = File.OpenRead(buf); StreamReader sr = new StreamReader(fp); Misc.text_out_hook = Utilities.text_out_to_screen; /* Dump */ //if (fp) //{ /* Dump the file to the screen */ while (!sr.EndOfStream) { buf = sr.ReadLine(); //We are skipping the version stuff, we will do that later I gues... //No big deal if we skip it, right? //string version_marker = strstr(buf, "$VERSION"); //if (version_marker) //{ // ptrdiff_t pos = version_marker - buf; // strnfmt(version_marker, sizeof(buf) - pos, "%-8s", buildver); //} Utilities.text_out_e("{0}", buf); Utilities.text_out("\n"); } fp.Close(); //} /* Flush it */ Term.fresh(); }
public static void hp_colour_change(Game_Event.Event_Type type, Game_Event data, object user) { /* * hack: redraw player, since the player's color * now indicates approximate health. Note that * using this command when graphics mode is on * causes the character to be a black square. */ if ((Option.hp_changes_color.value) && (Misc.arg_graphics == Misc.GRAPHICS_NONE)) { Cave.cave_light_spot(Cave.cave, Misc.p_ptr.py, Misc.p_ptr.px); } }
/* * Print the status line. */ public static void update_statusline(Game_Event.Event_Type type, Game_Event data, object user) { int row = Term.instance.hgt - 1; int col = 13; int i; /* Clear the remainder of the line */ Utilities.prt("", row, col); /* Display those which need redrawing */ for (i = 0; i < status_handlers.Length; i++) { col += status_handlers[i](row, col); } }
/* * This prints the sidebar, using a clever method which means that it will only * print as much as can be displayed on <24-line screens. * * Each row is given a priority; the least important higher numbers and the most * important lower numbers. As the screen gets smaller, the rows start to * disappear in the order of lowest to highest importance. */ public static void update_sidebar(Game_Event.Event_Type type, Game_Event data, object user) { int x, y, row; int max_priority; int i; Term.get_size(out x, out y); /* Keep the top and bottom lines clear. */ max_priority = y - 2; /* Display list entries */ for (i = 0, row = 1; i < side_handlers.Length; i++) { side_handler_t hnd = side_handlers[i]; int priority = hnd.priority; bool from_bottom = false; /* Negative means print from bottom */ if (priority < 0) { priority = -priority; from_bottom = true; } /* If this is high enough priority, display it */ if (priority <= max_priority) { if (hnd.type == type && hnd.hook != null) { if (from_bottom) { hnd.hook(Term.instance.hgt - (side_handlers.Length - i), 0); } else { hnd.hook(row, 0); } } /* Increment for next time */ row++; } } }
/* This is called whenever the points totals are changed (in birth.c), so * that we can update our display of how many points have been spent and * are available. */ static void point_based_points(Game_Event.Event_Type type, Game_Event data, object user) { int sum = 0; int[] stats = data.birthstats.stats; /* Display the costs header */ Utilities.put_str("Cost", COSTS_ROW - 1, COSTS_COL); /* Display the costs */ for (int i = 0; i < (int)Stat.Max; i++) { /* Display cost */ Utilities.put_str(stats[i].ToString("D4"), COSTS_ROW + i, COSTS_COL); sum += stats[i]; } Utilities.put_str("Total Cost: " + sum.ToString("D2") + "/" + (data.birthstats.remaining + sum).ToString("D2"), COSTS_ROW + (int)Stat.Max, TOTAL_COL); }
static void ui_leave_game(Game_Event.Event_Type type, Game_Event data, object user) { /* Because of the "flexible" sidebar, all these things trigger * the same function. */ Game_Event.remove_handler_set(player_events, Sidebar.update_sidebar, null); /* The flexible statusbar has similar requirements, so is * also trigger by a large set of events. */ Game_Event.remove_handler_set(statusline_events, Statusline.update_statusline, null); /* Player HP can optionally change the colour of the '@' now. */ Game_Event.remove_handler(Game_Event.Event_Type.HP, Sidebar.hp_colour_change, null); /* Simplest way to keep the map up to date - will do for now */ Game_Event.remove_handler(Game_Event.Event_Type.MAP, Map.update_maps, Misc.angband_term[0]); //#if 0 // event_remove_handler(EVENT_MAP, trace_map_updates, angband_term[0]); //#endif /* Check if the panel should shift when the player's moved */ Game_Event.remove_handler(Game_Event.Event_Type.PLAYERMOVED, Floor.check_panel, null); Game_Event.remove_handler(Game_Event.Event_Type.SEEFLOOR, Floor.see_floor_items, null); }
public flag_event_trigger(uint f, Game_Event.Event_Type e) { flag = f; evt =e; }
public static void see_floor_items(Game_Event.Event_Type type, Game_Event data, object user) { int py = Misc.p_ptr.py; int px = Misc.p_ptr.px; int floor_num = 0; int[] floor_list = new int[Misc.MAX_FLOOR_STACK + 1]; bool blind = ((Misc.p_ptr.timed[(int)Timed_Effect.BLIND] != 0) || (Cave.no_light())); string p = "see"; int can_pickup = 0; int i; /* Scan all marked objects in the grid */ floor_num = Object.Object.scan_floor(floor_list, floor_list.Length, py, px, 0x03); if (floor_num == 0) { return; } for (i = 0; i < floor_num; i++) { can_pickup += Object.Object.byid((short)floor_list[i]).inven_carry_okay()?1:0; } /* One object */ if (floor_num == 1) { /* Get the object */ Object.Object o_ptr = Object.Object.byid((short)floor_list[0]); //char o_name[80]; string o_name = null; if (can_pickup == 0) { p = "have no room for"; } else if (blind) { p = "feel"; } /* Describe the object. Less detail if blind. */ if (blind) { o_name = o_ptr.object_desc(Object.Object.Detail.PREFIX | Object.Object.Detail.BASE); } else { o_name = o_ptr.object_desc(Object.Object.Detail.PREFIX | Object.Object.Detail.FULL); } /* Message */ Utilities.message_flush(); Utilities.msg("You {0} {1}.", p, o_name); } else { ui_event e; if (can_pickup == 0) { p = "have no room for the following objects"; } else if (blind) { p = "feel something on the floor"; } throw new NotImplementedException(); /* Display objects on the floor */ //screen_save(); //show_floor(floor_list, floor_num, (OLIST_WEIGHT)); //prt(format("You %s: ", p), 0, 0); ///* Wait for it. Use key as next command. */ //e = inkey_ex(); //Term_event_push(&e); ///* Restore screen */ //screen_load(); } }
/* ------------------------------------------------------------------------ * Temporary (hopefully) hackish solutions. * ------------------------------------------------------------------------ */ public static void check_panel(Game_Event.Event_Type type, Game_Event data, object user) { Xtra2.verify_panel(); }
public side_handler_t(hook_func a, int b, Game_Event.Event_Type c) { hook = a; priority = b; type = c; }
/* This is called whenever any of the other miscellaneous stat-dependent things * changed. We are hooked into changes in the amount of gold in this case, * but redisplay everything because it's easier. */ static void point_based_misc(Game_Event.Event_Type type, Game_Event data, object user) { Files.display_player_xtra_info(); }
static void ui_leave_birthscreen(Game_Event.Event_Type type, Game_Event data, object user) { free_birth_menus(); }
static void ui_leave_init(Game_Event.Event_Type type, Game_Event data, object user) { /* Remove our splashscreen handlers */ Game_Event.remove_handler(Game_Event.Event_Type.INITSTATUS, splashscreen_note, null); }
public Game_Event.Event_Type type; /* PR_* flag this corresponds to */ #endregion Fields #region Constructors public side_handler_t(hook_func a, int b, Game_Event.Event_Type c) { hook = a; priority = b; type = c; }
/* ------------------------------------------------------------------------ * Map redraw. * ------------------------------------------------------------------------ */ //#if 0 //static void trace_map_updates(game_event_type type, game_event_data *data, void *user) //{ // if (data.point.x == -1 && data.point.y == -1) // { // printf("Redraw whole map\n"); // } // else // { // printf("Redraw (%i, %i)\n", data.point.x, data.point.y); // } //} //#endif public static void update_maps(Game_Event.Event_Type type, Game_Event data, object user) { Term t = user as Term; /* This signals a whole-map redraw. */ if (data.point.x == -1 && data.point.y == -1) { Cave.prt_map(); } /* Single point to be redrawn */ else { Grid_Data g = new Grid_Data(); ConsoleColor a = ConsoleColor.White, ta = ConsoleColor.White; char c = ' ', tc = ' '; int ky, kx; int vy, vx; /* Location relative to panel */ ky = data.point.y - t.offset_y; kx = data.point.x - t.offset_x; if (t == Misc.angband_term[0]) { /* Verify location */ if ((ky < 0) || (ky >= Misc.SCREEN_HGT)) { return; } /* Verify location */ if ((kx < 0) || (kx >= Misc.SCREEN_WID)) { return; } /* Location in window */ vy = ky + Misc.ROW_MAP; vx = kx + Misc.COL_MAP; if (Term.tile_width > 1) { vx += (Term.tile_width - 1) * kx; } if (Term.tile_height > 1) { vy += (Term.tile_height - 1) * ky; } } else { if (Term.tile_width > 1) { kx += (Term.tile_width - 1) * kx; } if (Term.tile_height > 1) { ky += (Term.tile_height - 1) * ky; } /* Verify location */ if ((ky < 0) || (ky >= t.hgt)) { return; } if ((kx < 0) || (kx >= t.wid)) { return; } /* Location in window */ vy = ky; vx = kx; } /* Redraw the grid spot */ Cave.map_info(data.point.y, data.point.x, ref g); Cave.grid_data_as_text(ref g, ref a, ref c, ref ta, ref tc); t.queue_char(vx, vy, a, c, ta, tc); //#if 0 // /* Plot 'spot' updates in light green to make them visible */ // Term_queue_char(t, vx, vy, TERM_L_GREEN, c, ta, tc); //#endif if ((Term.tile_width > 1) || (Term.tile_height > 1)) { t.big_queue_char(vx, vy, a, c, ConsoleColor.White, ' '); } } }
/* * Hack -- take notes on line 23 */ static void splashscreen_note(Game_Event.Event_Type type, Game_Event data, object user) { Term.erase(0, 23, 255); Term.putstr(20, 23, -1, ConsoleColor.White, "[" + data.text + "]"); Term.fresh(); }