/* data_panel array element initializer, for ansi compliance */ static void P_I(ConsoleColor col, string lab, string format, Type_Union val1, Type_Union val2, Data_Panel[] panel, ref int i) { panel[i].color = col; panel[i].label = lab; panel[i].fmt = format; panel[i].value[0] = val1; panel[i].value[1] = val2; i++; }
//size = panel.Length static int get_panel(int oid, ref Data_Panel[] panel) { int size = panel.Length; int ret = panel.Length; Type_Union END = new Type_Union(); Player.Player p_ptr = Player.Player.instance; Player_Other op_ptr = Player_Other.instance; switch(oid) { case 1: { int i = 0; Misc.assert(size >= (uint)boundaries[1].page_rows); ret = boundaries[1].page_rows; P_I(ConsoleColor.Cyan, "Name", "{0}", new Type_Union(op_ptr.full_name), END, panel, ref i); P_I(ConsoleColor.Cyan, "Sex", "{0}", new Type_Union(p_ptr.Sex.Title), END, panel, ref i); P_I(ConsoleColor.Cyan, "Race", "{0}", new Type_Union(p_ptr.Race.Name), END, panel, ref i); P_I(ConsoleColor.Cyan, "Class", "{0}", new Type_Union(p_ptr.Class.Name), END, panel, ref i); P_I(ConsoleColor.Cyan, "Title", "{0}", new Type_Union(show_title()), END, panel, ref i); P_I(ConsoleColor.Cyan, "HP", "{0}/{1}", new Type_Union(p_ptr.chp), new Type_Union(p_ptr.mhp), panel, ref i); P_I(ConsoleColor.Cyan, "SP", "{0}/{1}", new Type_Union(p_ptr.csp), new Type_Union(p_ptr.msp), panel, ref i); P_I(ConsoleColor.Cyan, "Level", "{0}", new Type_Union(p_ptr.lev), END, panel, ref i); Misc.assert(i == boundaries[1].page_rows); return ret; } case 2: { int i = 0; Misc.assert(ret >= boundaries[2].page_rows); ret = boundaries[2].page_rows; P_I(max_color(p_ptr.lev, p_ptr.max_lev), "Level", "{0}", new Type_Union(p_ptr.lev), END, panel, ref i); P_I(max_color(p_ptr.exp, p_ptr.max_exp), "Cur Exp", "{0}", new Type_Union(p_ptr.exp), END, panel, ref i); P_I(ConsoleColor.Green, "Max Exp", "{0}", new Type_Union(p_ptr.max_exp), END, panel, ref i); P_I(ConsoleColor.Green, "Adv Exp", "{0}", new Type_Union(show_adv_exp()), END, panel, ref i); P_I(ConsoleColor.Green, "MaxDepth", "{0}", new Type_Union(show_depth()), END, panel, ref i); P_I(ConsoleColor.Green, "Game Turns", "{0}", new Type_Union(Misc.turn), END, panel, ref i); P_I(ConsoleColor.Green, "Standard Turns", "{0}", new Type_Union((int)(p_ptr.total_energy / 100)), END, panel, ref i); P_I(ConsoleColor.Green, "Resting Turns", "{0}", new Type_Union((int)(p_ptr.resting_turn)), END, panel, ref i); P_I(ConsoleColor.Green, "Gold", "{0}", new Type_Union(p_ptr.au), END, panel, ref i); Misc.assert(i == boundaries[2].page_rows); return ret; } case 3: { int i = 0; Misc.assert(ret >= boundaries[3].page_rows); ret = boundaries[3].page_rows; P_I(ConsoleColor.Cyan, "Armor", "[{0},%+y]", new Type_Union(p_ptr.state.dis_ac), new Type_Union(p_ptr.state.dis_to_a) , panel, ref i); P_I(ConsoleColor.Cyan, "Fight", "(%+y,%+y)", new Type_Union(p_ptr.state.dis_to_h), new Type_Union(p_ptr.state.dis_to_d) , panel, ref i); P_I(ConsoleColor.Cyan, "Melee", "{0}", new Type_Union(show_melee_weapon(p_ptr.inventory[Misc.INVEN_WIELD])), END , panel, ref i); P_I(ConsoleColor.Cyan, "Shoot", "{0}", new Type_Union(show_missile_weapon(p_ptr.inventory[Misc.INVEN_BOW])), END , panel, ref i ); P_I(ConsoleColor.Cyan, "Blows", "{0}.%y/turn", new Type_Union(p_ptr.state.num_blows / 100), new Type_Union((p_ptr.state.num_blows / 10) % 10) , panel, ref i); P_I(ConsoleColor.Cyan, "Shots", "{0}/turn", new Type_Union(p_ptr.state.num_shots), END, panel, ref i ); P_I(ConsoleColor.Cyan, "Infra", "{0} ft", new Type_Union(p_ptr.state.see_infra * 10), END , panel, ref i ); P_I(ConsoleColor.Cyan, "Speed", "{0}", new Type_Union(show_speed()), END, panel, ref i ); P_I(ConsoleColor.Cyan, "Burden","%.1y lbs", new Type_Union(p_ptr.total_weight/10.0f), END, panel, ref i ); Misc.assert(i == boundaries[3].page_rows); return ret; } case 4: { temp_skills[] skills = { new temp_skills( "Saving Throw", Skill.SAVE, 6 ), new temp_skills( "Stealth", Skill.STEALTH, 1 ), new temp_skills( "Fighting", Skill.TO_HIT_MELEE, 12 ), new temp_skills( "Shooting", Skill.TO_HIT_BOW, 12 ), new temp_skills( "Disarming", Skill.DISARM, 8 ), new temp_skills( "Magic Device", Skill.DEVICE, 6 ), new temp_skills( "Perception", Skill.SEARCH_FREQUENCY, 6 ), new temp_skills( "Searching", Skill.SEARCH, 6 ) }; int i; Misc.assert(skills.Length == boundaries[4].page_rows); ret = skills.Length; if (ret > size) ret = size; for (i = 0; i < ret; i++) { short skill = p_ptr.state.skills[(int)skills[i].skill]; panel[i].color = ConsoleColor.Cyan; panel[i].label = skills[i].name; if (skills[i].skill == Skill.SAVE || skills[i].skill == Skill.SEARCH) { if (skill < 0) skill = 0; if (skill > 100) skill = 100; panel[i].fmt = "{0}%"; panel[i].value[0] = new Type_Union(skill); panel[i].color = colour_table[skill / 10]; } else if (skills[i].skill == Skill.DEVICE) { panel[i].fmt = "{0}"; panel[i].value[0] = new Type_Union(skill); panel[i].color = colour_table[skill / 13]; } else if (skills[i].skill == Skill.SEARCH_FREQUENCY) { if (skill <= 0) skill = 1; if (skill >= 50) { panel[i].fmt = "1 in 1"; panel[i].color = colour_table[10]; } else { /* convert to % chance of searching */ skill = (short)(50 - skill); panel[i].fmt = "1 in {0}"; panel[i].value[0] = new Type_Union(skill); panel[i].color = colour_table[(100 - skill*2) / 10]; } } else if (skills[i].skill == Skill.DISARM) { /* assume disarming a dungeon trap */ skill -= 5; if (skill > 100) skill = 100; if (skill < 2) skill = 2; panel[i].fmt = "{0}%"; panel[i].value[0] = new Type_Union(skill); panel[i].color = colour_table[skill / 10]; } else { panel[i].fmt = "{0}"; //last argument for likert was "panel[i].color"... ConsoleColor c = ConsoleColor.DarkMagenta; //Random color... panel[i].value[0] = new Type_Union(likert(skill, skills[i].div, ref c)); } } return ret; } case 5: { int i = 0; Misc.assert(ret >= boundaries[5].page_rows); ret = boundaries[5].page_rows; P_I(ConsoleColor.Cyan, "Age", "{0}", new Type_Union(p_ptr.age), END , panel, ref i ); P_I(ConsoleColor.Cyan, "Height", "{0}", new Type_Union(p_ptr.ht), END , panel, ref i ); P_I(ConsoleColor.Cyan, "Weight", "{0}", new Type_Union(p_ptr.wt), END , panel, ref i ); P_I(ConsoleColor.Cyan, "Social", "{0}", new Type_Union(show_status()), END , panel, ref i ); P_I(ConsoleColor.Cyan, "Maximize", "{0}", new Type_Union(Option.birth_maximize.value ? 'Y' : 'N'), END, panel, ref i ); //#if 0 // /* Preserve mode deleted */ // P_I(ConsoleColor.Cyan, "Preserve", "{0}", c2u(birth_preserve ? 'Y' : 'N'), END); //#endif Misc.assert(i == boundaries[5].page_rows); return ret; } } /* hopefully not reached */ return 0; }
//size = panel.Length static int get_panel(int oid, ref Data_Panel[] panel) { int size = panel.Length; int ret = panel.Length; Type_Union END = new Type_Union(); Player.Player p_ptr = Player.Player.instance; Player_Other op_ptr = Player_Other.instance; switch (oid) { case 1: { int i = 0; Misc.assert(size >= (uint)boundaries[1].page_rows); ret = boundaries[1].page_rows; P_I(ConsoleColor.Cyan, "Name", "{0}", new Type_Union(op_ptr.full_name), END, panel, ref i); P_I(ConsoleColor.Cyan, "Sex", "{0}", new Type_Union(p_ptr.Sex.Title), END, panel, ref i); P_I(ConsoleColor.Cyan, "Race", "{0}", new Type_Union(p_ptr.Race.Name), END, panel, ref i); P_I(ConsoleColor.Cyan, "Class", "{0}", new Type_Union(p_ptr.Class.Name), END, panel, ref i); P_I(ConsoleColor.Cyan, "Title", "{0}", new Type_Union(show_title()), END, panel, ref i); P_I(ConsoleColor.Cyan, "HP", "{0}/{1}", new Type_Union(p_ptr.chp), new Type_Union(p_ptr.mhp), panel, ref i); P_I(ConsoleColor.Cyan, "SP", "{0}/{1}", new Type_Union(p_ptr.csp), new Type_Union(p_ptr.msp), panel, ref i); P_I(ConsoleColor.Cyan, "Level", "{0}", new Type_Union(p_ptr.lev), END, panel, ref i); Misc.assert(i == boundaries[1].page_rows); return(ret); } case 2: { int i = 0; Misc.assert(ret >= boundaries[2].page_rows); ret = boundaries[2].page_rows; P_I(max_color(p_ptr.lev, p_ptr.max_lev), "Level", "{0}", new Type_Union(p_ptr.lev), END, panel, ref i); P_I(max_color(p_ptr.exp, p_ptr.max_exp), "Cur Exp", "{0}", new Type_Union(p_ptr.exp), END, panel, ref i); P_I(ConsoleColor.Green, "Max Exp", "{0}", new Type_Union(p_ptr.max_exp), END, panel, ref i); P_I(ConsoleColor.Green, "Adv Exp", "{0}", new Type_Union(show_adv_exp()), END, panel, ref i); P_I(ConsoleColor.Green, "MaxDepth", "{0}", new Type_Union(show_depth()), END, panel, ref i); P_I(ConsoleColor.Green, "Game Turns", "{0}", new Type_Union(Misc.turn), END, panel, ref i); P_I(ConsoleColor.Green, "Standard Turns", "{0}", new Type_Union((int)(p_ptr.total_energy / 100)), END, panel, ref i); P_I(ConsoleColor.Green, "Resting Turns", "{0}", new Type_Union((int)(p_ptr.resting_turn)), END, panel, ref i); P_I(ConsoleColor.Green, "Gold", "{0}", new Type_Union(p_ptr.au), END, panel, ref i); Misc.assert(i == boundaries[2].page_rows); return(ret); } case 3: { int i = 0; Misc.assert(ret >= boundaries[3].page_rows); ret = boundaries[3].page_rows; P_I(ConsoleColor.Cyan, "Armor", "[{0},%+y]", new Type_Union(p_ptr.state.dis_ac), new Type_Union(p_ptr.state.dis_to_a), panel, ref i); P_I(ConsoleColor.Cyan, "Fight", "(%+y,%+y)", new Type_Union(p_ptr.state.dis_to_h), new Type_Union(p_ptr.state.dis_to_d), panel, ref i); P_I(ConsoleColor.Cyan, "Melee", "{0}", new Type_Union(show_melee_weapon(p_ptr.inventory[Misc.INVEN_WIELD])), END, panel, ref i); P_I(ConsoleColor.Cyan, "Shoot", "{0}", new Type_Union(show_missile_weapon(p_ptr.inventory[Misc.INVEN_BOW])), END, panel, ref i); P_I(ConsoleColor.Cyan, "Blows", "{0}.%y/turn", new Type_Union(p_ptr.state.num_blows / 100), new Type_Union((p_ptr.state.num_blows / 10) % 10), panel, ref i); P_I(ConsoleColor.Cyan, "Shots", "{0}/turn", new Type_Union(p_ptr.state.num_shots), END, panel, ref i); P_I(ConsoleColor.Cyan, "Infra", "{0} ft", new Type_Union(p_ptr.state.see_infra * 10), END, panel, ref i); P_I(ConsoleColor.Cyan, "Speed", "{0}", new Type_Union(show_speed()), END, panel, ref i); P_I(ConsoleColor.Cyan, "Burden", "%.1y lbs", new Type_Union(p_ptr.total_weight / 10.0f), END, panel, ref i); Misc.assert(i == boundaries[3].page_rows); return(ret); } case 4: { temp_skills[] skills = { new temp_skills("Saving Throw", Skill.SAVE, 6), new temp_skills("Stealth", Skill.STEALTH, 1), new temp_skills("Fighting", Skill.TO_HIT_MELEE, 12), new temp_skills("Shooting", Skill.TO_HIT_BOW, 12), new temp_skills("Disarming", Skill.DISARM, 8), new temp_skills("Magic Device", Skill.DEVICE, 6), new temp_skills("Perception", Skill.SEARCH_FREQUENCY, 6), new temp_skills("Searching", Skill.SEARCH, 6) }; int i; Misc.assert(skills.Length == boundaries[4].page_rows); ret = skills.Length; if (ret > size) { ret = size; } for (i = 0; i < ret; i++) { short skill = p_ptr.state.skills[(int)skills[i].skill]; panel[i].color = ConsoleColor.Cyan; panel[i].label = skills[i].name; if (skills[i].skill == Skill.SAVE || skills[i].skill == Skill.SEARCH) { if (skill < 0) { skill = 0; } if (skill > 100) { skill = 100; } panel[i].fmt = "{0}%"; panel[i].value[0] = new Type_Union(skill); panel[i].color = colour_table[skill / 10]; } else if (skills[i].skill == Skill.DEVICE) { panel[i].fmt = "{0}"; panel[i].value[0] = new Type_Union(skill); panel[i].color = colour_table[skill / 13]; } else if (skills[i].skill == Skill.SEARCH_FREQUENCY) { if (skill <= 0) { skill = 1; } if (skill >= 50) { panel[i].fmt = "1 in 1"; panel[i].color = colour_table[10]; } else { /* convert to % chance of searching */ skill = (short)(50 - skill); panel[i].fmt = "1 in {0}"; panel[i].value[0] = new Type_Union(skill); panel[i].color = colour_table[(100 - skill * 2) / 10]; } } else if (skills[i].skill == Skill.DISARM) { /* assume disarming a dungeon trap */ skill -= 5; if (skill > 100) { skill = 100; } if (skill < 2) { skill = 2; } panel[i].fmt = "{0}%"; panel[i].value[0] = new Type_Union(skill); panel[i].color = colour_table[skill / 10]; } else { panel[i].fmt = "{0}"; //last argument for likert was "panel[i].color"... ConsoleColor c = ConsoleColor.DarkMagenta; //Random color... panel[i].value[0] = new Type_Union(likert(skill, skills[i].div, ref c)); } } return(ret); } case 5: { int i = 0; Misc.assert(ret >= boundaries[5].page_rows); ret = boundaries[5].page_rows; P_I(ConsoleColor.Cyan, "Age", "{0}", new Type_Union(p_ptr.age), END, panel, ref i); P_I(ConsoleColor.Cyan, "Height", "{0}", new Type_Union(p_ptr.ht), END, panel, ref i); P_I(ConsoleColor.Cyan, "Weight", "{0}", new Type_Union(p_ptr.wt), END, panel, ref i); P_I(ConsoleColor.Cyan, "Social", "{0}", new Type_Union(show_status()), END, panel, ref i); P_I(ConsoleColor.Cyan, "Maximize", "{0}", new Type_Union(Option.birth_maximize.value ? 'Y' : 'N'), END, panel, ref i); //#if 0 // /* Preserve mode deleted */ // P_I(ConsoleColor.Cyan, "Preserve", "{0}", c2u(birth_preserve ? 'Y' : 'N'), END); //#endif Misc.assert(i == boundaries[5].page_rows); return(ret); } } /* hopefully not reached */ return(0); }