Example #1
0
        public static int DisplayCharacterInfo(bool readkey)
        {
            //todo remove old version in Actor
            MouseUI.PushButtonMap();
            UI.DisplayStats();
            UI.draw_bottom_commands = false;
            UI.darken_status_bar = true;

            const Color c = Color.Green;
            const Color text = Color.Gray;
            List<colorstring> top = new List<colorstring>{new colorstring("".PadRight(COLS,'-'),text)};
            List<colorstring> name = new List<colorstring>{(new cstr("Name",c) + new cstr(": " + Actor.player_name,text)).PadRight(COLS/2) + (new cstr("Turns played",c) + new cstr(": " + Q.turn/100,text))};
            List<colorstring> skills = null;
            List<colorstring> feats = null;
            List<colorstring> spells = null;
            List<colorstring> trinkets = null;
            List<colorstring> divider = new List<colorstring>{new colorstring("Active abilities",c,":",text)};
            List<colorstring> actives = new List<colorstring>();

            List<List<colorstring>> potential_skills = new List<List<colorstring>>();
            for(int indent=7;indent>=1;--indent){
                List<colorstring> list = new List<colorstring>{new colorstring("Skills",c,":",text)};
                potential_skills.Add(list);
                for(SkillType sk = SkillType.COMBAT;sk < SkillType.NUM_SKILLS;++sk){
                    int skill_base = player.skills[sk];
                    int skill_mod = player.BonusSkill(sk);
                    colorstring skill_string = new colorstring(" " + Skill.Name(sk) + "(",text,skill_base.ToString(),Color.White);
                    if(skill_mod > 0){
                        skill_string.Add($"+{skill_mod}",Color.Yellow);
                    }
                    else{
                        if(skill_mod < 0){
                            skill_string.strings.Add(new cstr(skill_mod.ToString(),Color.Blue));
                        }
                    }
                    skill_string.strings.Add(new cstr(")",text));
                    list.AddWithWrap(skill_string,Global.COLS,indent);
                }
            }
            skills = potential_skills.WhereLeast(x=>x.Count)[0]; //Take the first result (i.e. highest indent) from the lowest count.

            List<List<colorstring>> potential_feats = new List<List<colorstring>>();
            for(int indent=6;indent>=1;--indent){
                List<colorstring> list = new List<colorstring>{new colorstring("Feats",c,":",text)};
                potential_feats.Add(list);
                for(int i=0;i<Actor.feats_in_order.Count;++i){
                    string comma = (i == Actor.feats_in_order.Count - 1)? "" : ",";
                    colorstring feat_string = new colorstring(" " + Feat.Name(Actor.feats_in_order[i]) + comma);
                    list.AddWithWrap(feat_string,Global.COLS,indent);
                }
            }
            feats = potential_feats.WhereLeast(x=>x.Count)[0]; //Take the first result (i.e. highest indent) from the lowest count.

            List<List<colorstring>> potential_spells = new List<List<colorstring>>();
            for(int indent=7;indent>=1;--indent){
                List<colorstring> list = new List<colorstring>{new colorstring("Spells",c,":",text)};
                potential_spells.Add(list);
                for(int i=0;i<Actor.spells_in_order.Count;++i){
                    string comma = (i == Actor.spells_in_order.Count - 1)? "" : ",";
                    colorstring spell_string = new colorstring(" " + Spell.Name(Actor.spells_in_order[i]) + comma);
                    list.AddWithWrap(spell_string,Global.COLS,indent);
                }
            }
            spells = potential_spells.WhereLeast(x=>x.Count)[0]; //Take the first result (i.e. highest indent) from the lowest count.

            List<string> magic_equipment_names = new List<string>();
            foreach(Weapon w in player.weapons){
                if(w.IsEnchanted()){
                    magic_equipment_names.Add(w.NameWithEnchantment());
                }
            }
            foreach(Armor a in player.armors){
                if(a.IsEnchanted()){
                    magic_equipment_names.Add(a.NameWithEnchantment());
                }
            }
            foreach(MagicTrinketType trinket in player.magic_trinkets){
                magic_equipment_names.Add(MagicTrinket.Name(trinket));
            }

            List<List<colorstring>> potential_trinkets = new List<List<colorstring>>();
            for(int indent=18;indent>=1;--indent){ //todo keep this value?
                List<colorstring> list = new List<colorstring>{new colorstring("Magical equipment",c,":",text)};
                potential_trinkets.Add(list);
                for(int i=0;i<magic_equipment_names.Count;++i){
                    string comma = (i == magic_equipment_names.Count - 1)? "" : ",";
                    colorstring equip_string = new colorstring(" " + magic_equipment_names[i].Capitalize() + comma);
                    list.AddWithWrap(equip_string,Global.COLS,indent);
                }
            }
            trinkets = potential_trinkets.WhereLeast(x=>x.Count)[0]; //Take the first result (i.e. highest indent) from the lowest count.

            List<FeatType> active_feats = new List<FeatType>();

            foreach(FeatType f in Actor.feats_in_order){
                if(Feat.IsActivated(f)){
                    active_feats.Add(f);
                }
            }

            for(int i=0;i<active_feats.Count;++i){
                actives.Add(new colorstring("  [",text,((char)(i+'a')).ToString(),Color.Cyan,"] " + Feat.Name(active_feats[i]),text));
            }

            //eventually activated trinkets or temporary effects will go here.

            const int total_height = Global.SCREEN_H - Global.MAP_OFFSET_ROWS;
            List<List<colorstring>> all = new List<List<colorstring>>{top,name,skills,feats,spells,trinkets,divider,actives};
            List<List<colorstring>> some = new List<List<colorstring>>{name,skills,feats,spells};
            List<List<colorstring>> top_titles = new List<List<colorstring>>{name,skills,feats,spells,trinkets};
            int rows_left = total_height - 1; // -1 for the bottom border
            foreach(var list in all){
                rows_left -= list.Count;
            }

            //Here's how the extra rows are distributed:
            if(rows_left >= 1){
                trinkets.Add(new colorstring(""));
                --rows_left;
            }

            if(rows_left >= 1){
                actives.Add(new colorstring(""));
                --rows_left;
            }

            List<List<colorstring>> cramped = new List<List<colorstring>>();
            foreach(var list in some){
                if(list.Count == 1){
                    cramped.Add(list); //a list is considered cramped if its title (in green) is right next to another title.
                }
            }
            if(rows_left >= cramped.Count){
                foreach(var list in cramped){
                    list.Add(new colorstring(""));
                    --rows_left;
                }
            }

            List<List<colorstring>> no_blank_line = new List<List<colorstring>>();
            foreach(var list in some){
                if(list.Last().Length() > 0){
                    no_blank_line.Add(list); //this time, we try to put a space between each list and the next title.
                }
            }
            if(rows_left >= no_blank_line.Count){
                foreach(var list in no_blank_line){
                    list.Add(new colorstring(""));
                    --rows_left;
                }
            }

            /*if(rows_left >= 1){
                divider.Add(new colorstring(""));
                --rows_left;
            }*/

            int top_text_height = 0;
            foreach(var list in top_titles){
                top_text_height += list.Count;
            }
            if(rows_left >= 1 && top_text_height < 14){
                top.Add(new colorstring(""));
                --rows_left;
            }

            for(int i=0;i<rows_left;++i){
                actives.Add(new colorstring(""));
            }

            int row = 0;
            foreach(var list in all){
                foreach(colorstring cs in list){
                    Screen.WriteMapString(row,0,cs.PadRight(COLS));
                    ++row;
                }
            }
            Screen.WriteMapString(row,0,"".PadRight(COLS,'-'),text);
            Screen.ResetColors();
            B.DisplayNow("Character information: ");
            Screen.CursorVisible = true;

            int result = -1;
            if(readkey){
                result = player.GetSelection("Character information: ",active_feats.Count,false,true,false); //todo, currently only feats.
            }
            MouseUI.PopButtonMap();
            UI.draw_bottom_commands = true;
            UI.darken_status_bar = false;
            return result;
        }
Example #2
0
 public List<colorstring> ShortStatusList()
 {
     List<colorstring> result = new List<colorstring>();
     List<EquipmentStatus> list = new List<EquipmentStatus>();
     for(int i=0;i<(int)EquipmentStatus.NUM_STATUS;++i){
         EquipmentStatus st = (EquipmentStatus)i;
         if(status[st]){
             list.Add(st);
         }
     }
     for(int i=0;i<list.Count;++i){
         EquipmentStatus st = list[i];
         string comma = (i == list.Count - 1)? "" : ",";
         colorstring statusString = new colorstring(" " + StatusName(st) + comma,StatusColor(st));
         result.AddWithWrap(statusString,Global.COLS - 2,1);
     }
     if(result.Count > 2){ //hard cap at 2 lines
         result.RemoveRange(2,result.Count - 2);
     }
     for(int i=0;i<result.Count;++i){
         result[i] = result[i].PadOuter(Global.COLS);
     }
     return result;
 }