/* * 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 bool buy_stat(Stat choice, short[] stats, int[] points_spent, ref int points_left) { /* Must be a valid stat, and have a "base" of below 18 to be adjusted */ if (!(choice >= Stat.Max || choice < 0) && (stats[(int)choice] < 18)) { /* Get the cost of buying the extra point (beyond what * it has already cost to get this far). */ int stat_cost = birth_stat_costs[stats[(int)choice] + 1]; if (stat_cost <= points_left) { stats[(int)choice]++; points_spent[(int)choice] += stat_cost; points_left -= stat_cost; /* Tell the UI the new points situation. */ Game_Event.signal_birthpoints(points_spent, points_left); /* Recalculate everything that's changed because * the stat has changed, and inform the UI. */ recalculate_stats(stats, points_left); return(true); } } /* Didn't adjust stat. */ return(false); }
/* ------------------------------------------------------------------------ * 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); }
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 signal_flag(Event_Type type, bool flag) { Game_Event data = new Game_Event(); data.flag = flag; dispatch(type, data); }
public static void signal_string(Event_Type type, string s) { Game_Event data = new Game_Event(); data.text = s; dispatch(type, data); }
public static void init_display() { Game_Event.add_handler(Game_Event.Event_Type.ENTER_INIT, ui_enter_init, null); Game_Event.add_handler(Game_Event.Event_Type.LEAVE_INIT, ui_leave_init, null); Game_Event.add_handler(Game_Event.Event_Type.ENTER_GAME, ui_enter_game, null); Game_Event.add_handler(Game_Event.Event_Type.LEAVE_GAME, ui_leave_game, null); UIBirth.ui_init_birthstate_handlers(); }
public static void signal_point(Event_Type type, int x, int y) { Game_Event data = new Game_Event(); data.point = new Loc(x, y); //data.point.x = x; //data.point.y = y; Game_Event.dispatch(type, data); }
/* * Hack -- main Angband initialization entry point * * Verify some files, display the "news.txt" file, create * the high score file, initialize all internal arrays, and * load the basic "user pref files". * * Be very careful to keep track of the order in which things * are initialized, in particular, the only thing *known* to * be available when this function is called is the "z-term.c" * package, and that may not be fully initialized until the * end of this function, when the default "user pref files" * are loaded and "Term_xtra(TERM_XTRA_REACT,0)" is called. * * Note that this function attempts to verify the "news" file, * and the game aborts (cleanly) on failure, since without the * "news" file, it is likely that the "lib" folder has not been * correctly located. Otherwise, the news file is displayed for * the user. * * Note that this function attempts to verify (or create) the * "high score" file, and the game aborts (cleanly) on failure, * since one of the most common "extraction" failures involves * failing to extract all sub-directories (even empty ones), such * as by failing to use the "-d" option of "pkunzip", or failing * to use the "save empty directories" option with "Compact Pro". * This error will often be caught by the "high score" creation * code below, since the "lib/apex" directory, being empty in the * standard distributions, is most likely to be "lost", making it * impossible to create the high score file. * * Note that various things are initialized by this function, * including everything that was once done by "init_some_arrays". * * This initialization involves the parsing of special files * in the "lib/edit" directories. * * Note that the "template" files are initialized first, since they * often contain errors. This means that macros and message recall * and things like that are not available until after they are done. * * We load the default "user pref files" here in case any "color" * changes are needed before character creation. * * Note that the "graf-xxx.prf" file must be loaded separately, * if needed, in the first (?) pass through "TERM_XTRA_REACT". */ public static bool init_angband() { Game_Event.signal(Game_Event.Event_Type.ENTER_INIT); /*** Initialize some arrays ***/ Init.arrays(); /*** Load default user pref files ***/ /* Initialize feature info */ Game_Event.signal_string(Game_Event.Event_Type.INITSTATUS, "Loading basic user pref file..."); /* Process that file */ Prefs.process_pref_file("pref.prf", false, false); /* Done */ Game_Event.signal_string(Game_Event.Event_Type.INITSTATUS, "Initialization complete"); /* Sneakily init command list */ Command.Init(); //#ifdef ALLOW_BORG /* apw */ // /* Allow the screensaver to do its work */ // if (screensaver) // { // event_signal(EVENT_LEAVE_INIT); // return !file_exists(savefile); // } //#endif /* ALLOW_BORG */ /* Ask for a "command" until we get one we like. */ while (true) { Game_Command command_req = new Game_Command(); if (Game_Command.get(cmd_context.CMD_INIT, ref command_req, true) == null) { continue; } else if (command_req.command == Command_Code.QUAFF) { Utilities.quit(); } else if (command_req.command == Command_Code.NEWGAME) { Game_Event.signal(Game_Event.Event_Type.LEAVE_INIT); return(true); } else if (command_req.command == Command_Code.LOADFILE) { Game_Event.signal(Game_Event.Event_Type.LEAVE_INIT); return(false); } } }
//stats is size 6 public static void signal_birthpoints(int[] stats, int remaining) { Game_Event data = new Game_Event(); data.birthstats = new birthstats_info(); data.birthstats.stats = stats; data.birthstats.remaining = remaining; dispatch(Event_Type.BIRTHPOINTS, data); }
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); } }
static void dispatch(Event_Type type, Game_Event data) { event_handler_entry t = event_handlers[(int)type]; /* * Send the word out to all interested event handlers. */ while (t != null) { /* Call the handler with the relevant data */ t.fn(type, data, t.user); t = t.next; } }
/* * 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++; } } }
static void reset_stats(short[] stats, int[] points_spent, ref int points_left) { /* Calculate and signal initial stats and points totals. */ points_left = MAX_BIRTH_POINTS; for (int i = 0; i < (int)Stat.Max; i++) { /* Initial stats are all 10 and costs are zero */ stats[i] = 10; points_spent[i] = 0; } /* Use the new "birth stat" values to work out the "other" * stat values (i.e. after modifiers) and tell the UI things have * changed. */ recalculate_stats(stats, points_left); Game_Event.signal_birthpoints(points_spent, points_left); }
static void point_based_start() { string prompt = "[up/down to move, left/right to modify, 'r' to reset, 'Enter' to accept]"; /* Clear */ Term.clear(); /* Display the player */ Files.display_player_xtra_info(); Files.display_player_stat_info(); Utilities.prt(prompt, Term.instance.hgt - 1, Term.instance.wid / 2 - prompt.Length / 2); /* Register handlers for various events - cheat a bit because we redraw * the lot at once rather than each bit at a time. */ Game_Event.add_handler(Game_Event.Event_Type.BIRTHPOINTS, point_based_points, null); Game_Event.add_handler(Game_Event.Event_Type.STATS, point_based_stats, null); Game_Event.add_handler(Game_Event.Event_Type.GOLD, point_based_misc, null); }
const int MAX_BIRTH_POINTS = 24; /* 3 * (1+1+1+1+1+1+2) */ static void recalculate_stats(short[] stats, int points_left) { /* Process stats */ for (int i = 0; i < (int)Stat.Max; i++) { /* Variable stat maxes */ if (Option.birth_maximize.value) { /* Reset stats */ Player.Player.instance.stat_cur[i] = Player.Player.instance.stat_max[i] = Player.Player.instance.stat_birth[i] = stats[i]; } /* Fixed stat maxes */ else { int bonus = 0; /* Obtain a "bonus" for "race" and "class" */ if (Player.Player.instance.Race != null || Player.Player.instance.Class != null) { bonus = Player.Player.instance.Race.r_adj[i] + Player.Player.instance.Class.c_adj[i]; } /* Apply the racial/class bonuses */ Player.Player.instance.stat_cur[i] = Player.Player.instance.stat_max[i] = Player.Player.instance.stat_birth[i] = modify_stat_value(stats[i], bonus); } } /* Gold is inversely proportional to cost */ Player.Player.instance.au_birth = STARTING_GOLD + (50 * points_left); /* Update bonuses, hp, etc. */ get_bonuses(); /* Tell the UI about all this stuff that's changed. */ Game_Event.signal(Game_Event.Event_Type.GOLD); Game_Event.signal(Game_Event.Event_Type.AC); Game_Event.signal(Game_Event.Event_Type.HP); Game_Event.signal(Game_Event.Event_Type.STATS); }
/* 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); }
/* * 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++; } } }
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); }
static bool sell_stat(Stat choice, short[] stats, int[] points_spent, ref int points_left) { /* Must be a valid stat, and we can't "sell" stats below the base of 10. */ if (!(choice >= Stat.Max || choice < 0) && (stats[(int)choice] > 10)) { int stat_cost = birth_stat_costs[stats[(int)choice]]; stats[(int)choice]--; points_spent[(int)choice] -= stat_cost; points_left += stat_cost; /* Tell the UI the new points situation. */ Game_Event.signal_birthpoints(points_spent, points_left); /* Recalculate everything that's changed because * the stat has changed, and inform the UI. */ recalculate_stats(stats, points_left); return(true); } /* Didn't adjust stat. */ return(false); }
/* * 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(); }
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 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(); } }
/* 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_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); }
/* * Create a new character. * * Note that we may be called with "junk" leftover in the various * fields, so we must be sure to clear them first. */ public static void player_birth(bool quickstart_allowed) { Game_Command blank = new Game_Command(Command_Code.NULL, null, null, false, 0); Game_Command cmd = blank; short[] stats = new short[(int)Stat.Max]; int[] points_spent = new int[(int)Stat.Max]; int points_left = 0; string buf; int success; bool rolled_stats = false; /* * The last character displayed, to allow the user to flick between two. * We rely on prev.age being zero to determine whether there is a stored * character or not, so initialise it here. */ Birther prev = new Birther(); /* * If quickstart is allowed, we store the old character in this, * to allow for it to be reloaded if we step back that far in the * birth process. */ Birther quickstart_prev = new Birther(); /* * If there's a quickstart character, store it for later use. * If not, default to whatever the first of the choices is. */ if (quickstart_allowed) { quickstart_prev.save_roller_data(); } else { Player.Player.instance.psex = 0; /* XXX default race/class */ Player.Player.instance.Class = Misc.classes; Player.Player.instance.Race = Misc.races; Player.Player.instance.generate(null, null, null); } /* Handle incrementing name suffix */ buf = Utilities.find_roman_suffix_start(Player_Other.instance.full_name); if (buf != null) { /* Try to increment the roman suffix */ success = Utilities.int_to_roman((Utilities.roman_to_int(buf) + 1), buf); if (success == 0) { Utilities.msg("Sorry, could not deal with suffix"); } } /* We're ready to start the interactive birth process. */ Game_Event.signal_flag(Game_Event.Event_Type.ENTER_BIRTH, quickstart_allowed); /* * Loop around until the UI tells us we have an acceptable character. * Note that it is possible to quit from inside this loop. */ while (cmd.command != Command_Code.ACCEPT_CHARACTER) { /* Grab a command from the queue - we're happy to wait for it. */ if (Game_Command.get(cmd_context.CMD_BIRTH, ref cmd, true) == null) { continue; } if (cmd.command == Command_Code.BIRTH_RESET) { Player.Player.instance.generate(null, null, null); reset_stats(stats, points_spent, ref points_left); do_birth_reset(quickstart_allowed, quickstart_prev); rolled_stats = false; } else if (cmd.command == Command_Code.CHOOSE_SEX) { Player.Player.instance.psex = (byte)cmd.arg[0].value; Player.Player.instance.generate(null, null, null); } else if (cmd.command == Command_Code.CHOOSE_RACE) { Player.Player.instance.generate(null, Player_Race.player_id2race(cmd.arg[0].value), null); reset_stats(stats, points_spent, ref points_left); generate_stats(stats, points_spent, ref points_left); rolled_stats = false; } else if (cmd.command == Command_Code.CHOOSE_CLASS) { Player.Player.instance.generate(null, null, Player_Class.player_id2class(cmd.arg[0].value)); reset_stats(stats, points_spent, ref points_left); generate_stats(stats, points_spent, ref points_left); rolled_stats = false; } else if (cmd.command == Command_Code.FINALIZE_OPTIONS) { /* Reset score options from cheat options */ for (int i = Option.CHEAT; i < Option.CHEAT + Option.N_OPTS_CHEAT; i++) { Player_Other.instance.opt[Option.SCORE + (i - Option.CHEAT)] = Player_Other.instance.opt[i]; } } else if (cmd.command == Command_Code.BUY_STAT) { /* .choice is the stat to buy */ if (!rolled_stats) { buy_stat((Stat)cmd.arg[0].value, stats, points_spent, ref points_left); } } else if (cmd.command == Command_Code.SELL_STAT) { /* .choice is the stat to sell */ if (!rolled_stats) { sell_stat((Stat)cmd.arg[0].value, stats, points_spent, ref points_left); } } else if (cmd.command == Command_Code.RESET_STATS) { /* .choice is whether to regen stats */ reset_stats(stats, points_spent, ref points_left); if (cmd.arg[0].value == 1) { generate_stats(stats, points_spent, ref points_left); } rolled_stats = false; } else if (cmd.command == Command_Code.ROLL_STATS) { throw new NotImplementedException(); //int i; //save_roller_data(&prev); ///* Get a new character */ //get_stats(stats); ///* Update stats with bonuses, etc. */ //get_bonuses(); ///* There's no real need to do this here, but it's tradition. */ //get_ahw(Player.Player.instance); //Player.Player.instance.history = get_history(Player.Player.instance.race.history, &Player.Player.instance.sc); //Player.Player.instance.sc_birth = Player.Player.instance.sc; //event_signal(EVENT_GOLD); //event_signal(EVENT_AC); //event_signal(EVENT_HP); //event_signal(EVENT_STATS); ///* Give the UI some dummy info about the points situation. */ //points_left = 0; //for (i = 0; i < A_MAX; i++) //{ // points_spent[i] = 0; //} //event_signal_birthpoints(points_spent, points_left); ///* Lock out buying and selling of stats based on rolled stats. */ //rolled_stats = true; } else if (cmd.command == Command_Code.PREV_STATS) { throw new NotImplementedException(); ///* Only switch to the stored "previous" // character if we've actually got one to load. */ //if (prev.age) //{ // load_roller_data(&prev, &prev); // get_bonuses(); //} //event_signal(EVENT_GOLD); //event_signal(EVENT_AC); //event_signal(EVENT_HP); //event_signal(EVENT_STATS); } else if (cmd.command == Command_Code.NAME_CHOICE) { /* Set player name */ Player_Other.instance.full_name = cmd.arg[0].text; //string_free((void *) cmd.arg[0].string); /* Don't change savefile name. If the UI wants it changed, they can do it. XXX (Good idea?) */ Files.process_player_name(false); } /* Various not-specific-to-birth commands. */ else if (cmd.command == Command_Code.HELP) { throw new NotImplementedException(); //char buf[80]; //strnfmt(buf, sizeof(buf), "birth.txt"); //screen_save(); //show_file(buf, null, 0, 0); //screen_load(); } else if (cmd.command == Command_Code.QUIT) { Utilities.quit(); } } roll_hp(); Squelch.birth_init(); /* Clear old messages, add new starting message */ History.clear(); History.add("Began the quest to destroy Morgoth.", History.PLAYER_BIRTH, null); /* Reset message prompt (i.e. no extraneous -more-s) */ Term.msg_flag = true; /* Note player birth in the message recall */ Message.add(" ", Message_Type.MSG_GENERIC); Message.add(" ", Message_Type.MSG_GENERIC); Message.add("====================", Message_Type.MSG_GENERIC); Message.add(" ", Message_Type.MSG_GENERIC); Message.add(" ", Message_Type.MSG_GENERIC); /* Give the player some money */ get_money(); /* Outfit the player, if they can sell the stuff */ if (!Option.birth_no_selling.value) { player_outfit(Player.Player.instance); } /* Initialise the stores */ Store.reset(); /* Now we're really done.. */ Game_Event.signal(Game_Event.Event_Type.LEAVE_BIRTH); }
static void ui_leave_birthscreen(Game_Event.Event_Type type, Game_Event data, object user) { free_birth_menus(); }
public static void ui_init_birthstate_handlers() { Game_Event.add_handler(Game_Event.Event_Type.ENTER_BIRTH, ui_enter_birthscreen, null); Game_Event.add_handler(Game_Event.Event_Type.LEAVE_BIRTH, ui_leave_birthscreen, null); }
/* * 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); }
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; }
static void point_based_stop() { Game_Event.remove_handler(Game_Event.Event_Type.BIRTHPOINTS, point_based_points, null); Game_Event.remove_handler(Game_Event.Event_Type.STATS, point_based_stats, null); Game_Event.remove_handler(Game_Event.Event_Type.GOLD, point_based_misc, null); }
/* ------------------------------------------------------------------------ * 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, ' '); } } }