Exemple #1
0
        public static void WriteMapString(int r, int c, colorstring cs)
        {
            if (cs.Length() > 0)
            {
                r += Global.MAP_OFFSET_ROWS;
                c += Global.MAP_OFFSET_COLS;
                int cpos = c;
                foreach (cstr s1 in cs.strings)
                {
                    cstr s = new cstr(s1.s, s1.color, s1.bgcolor);
                    if (cpos - Global.MAP_OFFSET_COLS + s.s.Length > Global.COLS)
                    {
                        s.s = s.s.Substring(0, Global.COLS - (cpos - Global.MAP_OFFSET_COLS));
                    }
                    s.color   = ResolveColor(s.color);
                    s.bgcolor = ResolveColor(s.bgcolor);
                    colorchar cch = new colorchar(' ', s.color, s.bgcolor);

/*					cch.color = s.color;
 *                                      cch.bgcolor = s.bgcolor;*/
                    ConsoleColor co = GetColor(s.color);
                    if (ForegroundColor != co)
                    {
                        ForegroundColor = co;
                    }
                    co = GetColor(s.bgcolor);
                    if (BackgroundColor != co)
                    {
                        BackgroundColor = co;
                    }
                    int  i       = 0;
                    bool changed = false;
                    for (int ii = 0; ii < s.s.Length; ii++)
                    {
                        cch.c = s.s.CharAt(ii);
                        if (!memory[r, cpos + i].Equals(cch))
                        {
                            memory[r, cpos + i] = cch;
                            changed             = true;
                        }
                        ++i;
                    }
                    if (changed)
                    {
                        Game.Console.SetCursorPosition(cpos, r);
                        Game.Console.Write(s.s);
                    }
                    cpos += s.s.Length;
                }

                /*if(cpos-Global.MAP_OFFSET_COLS < Global.COLS){
                 *      WriteString(r,cpos,"".PadRight(Global.COLS-(cpos-Global.MAP_OFFSET_COLS)));
                 * }*/
            }
        }
Exemple #2
0
        public static void WriteString(int r, int c, colorstring cs)
        {
            if (cs.Length() > 0)
            {
                int pos = c;
                foreach (cstr s1 in cs.strings)
                {
                    cstr s = new cstr(s1.s, s1.color, s1.bgcolor);
                    if (s.s.Length + pos > Global.SCREEN_W)
                    {
                        s.s = s.s.Substring(0, Global.SCREEN_W - pos);
                    }
                    s.color   = ResolveColor(s.color);
                    s.bgcolor = ResolveColor(s.bgcolor);
                    colorchar cch = new colorchar(' ', s.color, s.bgcolor);

                    /*cch.color = s.color;
                     * cch.bgcolor = s.bgcolor;*/
                    ConsoleColor co = GetColor(s.color);
                    if (ForegroundColor != co)
                    {
                        ForegroundColor = co;
                    }
                    co = GetColor(s.bgcolor);
                    if (BackgroundColor != co)
                    {
                        BackgroundColor = co;
                    }
                    int  i       = 0;
                    bool changed = false;
                    for (int ii = 0; ii < s.s.Length; ii++)
                    {
                        cch.c = s.s.CharAt(ii);
                        if (!memory[r, pos + i].Equals(cch))
                        {
                            memory[r, pos + i] = cch;
                            changed            = true;
                        }
                        ++i;
                    }
                    if (changed)
                    {
                        Game.Console.SetCursorPosition(pos, r);
                        Game.Console.Write(s.s);
                    }
                    pos += s.s.Length;
                }
            }
        }
		public static void WriteMapString(int r,int c,colorstring cs){
			if(cs.Length() > 0){
				r += Global.MAP_OFFSET_ROWS;
				c += Global.MAP_OFFSET_COLS;
				int cpos = c;
				foreach(cstr s1 in cs.strings){
					cstr s = new cstr(s1.s,s1.color,s1.bgcolor);
					if(cpos-Global.MAP_OFFSET_COLS + s.s.Length > Global.COLS){
						s.s = s.s.Substring(0,Global.COLS-(cpos-Global.MAP_OFFSET_COLS));
					}
					s.color = ResolveColor(s.color);
					s.bgcolor = ResolveColor(s.bgcolor);
                    colorchar cch = new colorchar(' ', s.color, s.bgcolor);
/*					cch.color = s.color;
					cch.bgcolor = s.bgcolor;*/
					ConsoleColor co = GetColor(s.color);
					if(ForegroundColor != co){
						ForegroundColor = co;
					}
					co = GetColor(s.bgcolor);
					if(BackgroundColor != co){
						BackgroundColor = co;
					}
					int i = 0;
                    bool changed = false;
                    for (int ii = 0; ii < s.s.Length; ii++)
                    {
                        cch.c = s.s.CharAt(ii);
						if(!memory[r,cpos+i].Equals(cch)){
							memory[r,cpos+i] = cch;
							changed = true;
						}
						++i;
					}
					if(changed){
						Game.Console.SetCursorPosition(cpos,r);
						Game.Console.Write(s.s);
					}
					cpos += s.s.Length;
				}
				/*if(cpos-Global.MAP_OFFSET_COLS < Global.COLS){
					WriteString(r,cpos,"".PadRight(Global.COLS-(cpos-Global.MAP_OFFSET_COLS)));
				}*/
			}
		}
		public static void WriteString(int r,int c,colorstring cs){
			if(cs.Length() > 0){
				int pos = c;
				foreach(cstr s1 in cs.strings){
					cstr s = new cstr(s1.s,s1.color,s1.bgcolor);
					if(s.s.Length + pos > Global.SCREEN_W){
						s.s = s.s.Substring(0,Global.SCREEN_W - pos);
					}
					s.color = ResolveColor(s.color);
					s.bgcolor = ResolveColor(s.bgcolor);
                    colorchar cch = new colorchar(' ', s.color, s.bgcolor);
					/*cch.color = s.color;
					cch.bgcolor = s.bgcolor;*/
					ConsoleColor co = GetColor(s.color);
					if(ForegroundColor != co){
						ForegroundColor = co;
					}
					co = GetColor(s.bgcolor);
					if(BackgroundColor != co){
						BackgroundColor = co;
					}
					int i = 0;
                    bool changed = false;
                    for (int ii = 0; ii < s.s.Length; ii++)
                    {
                        cch.c = s.s.CharAt(ii);
						if(!memory[r,pos+i].Equals(cch)){
							memory[r,pos+i] = cch;
							changed = true;
						}
						++i;
					}
					if(changed){
						Game.Console.SetCursorPosition(pos,r);
						Game.Console.Write(s.s);
					}
					pos += s.s.Length;
				}
			}
		}
 public colorstring EquipmentScreenName()
 {
     colorstring result = new colorstring(NameWithEnchantment().Capitalize() + " ",EnchantmentColor());
     for(int i=0;i<(int)EquipmentStatus.NUM_STATUS;++i){
         if(status[(EquipmentStatus)i]){
             result.strings.Add(new cstr("*",StatusColor((EquipmentStatus)i)));
             if(result.Length() >= 25){
                 break;
             }
         }
     }
     return result;
 }
 public static void WriteString(int r,int c,colorstring cs)
 {
     if(cs.Length() > 0){
         int pos = c;
         int start_col = -1;
         int end_col = -1;
         foreach(cstr s1 in cs.strings){
             cstr s = new cstr(s1.s,s1.color,s1.bgcolor);
             if(s.s.Length + pos > Global.SCREEN_W){
                 s.s = s.s.Substring(0,Global.SCREEN_W - pos);
             }
             s.color = Colors.ResolveColor(s.color);
             s.bgcolor = Colors.ResolveColor(s.bgcolor);
             colorchar cch;
             cch.color = s.color;
             cch.bgcolor = s.bgcolor;
             if(!GLMode){
                 ConsoleColor co = Colors.GetColor(s.color);
                 if(ForegroundColor != co){
                     ForegroundColor = co;
                 }
                 co = Colors.GetColor(s.bgcolor);
                 if(BackgroundColor != co){
                     BackgroundColor = co;
                 }
             }
             int i = 0;
             bool changed = false;
             foreach(char ch in s.s){
                 cch.c = ch;
                 if(!memory[r,pos+i].Equals(cch)){
                     memory[r,pos+i] = cch;
                     if(start_col == -1){
                         start_col = pos+i;
                     }
                     end_col = pos+i;
                     changed = true;
                 }
                 ++i;
             }
             if(changed && !GLMode){
                 Console.SetCursorPosition(pos,r);
                 Console.Write(s.s);
             }
             pos += s.s.Length;
         }
         if(GLMode && !NoGLUpdate && start_col != -1){
             UpdateGLBuffer(r,start_col,r,end_col);
         }
         if(MouseUI.AutomaticButtonsFromStrings && GLMode){
             int idx = 0;
             int brace = -1;
             int start = -1;
             int end = -1;
             bool last_char_was_separator = false;
             while(true){
                 char ch = cs[idx].c;
                 if(brace == -1){
                     if(ch == '['){
                         brace = 0;
                         start = idx;
                     }
                 }
                 else{
                     if(brace == 0){
                         if(ch == ']'){
                             brace = 1;
                             end = idx;
                         }
                     }
                     else{
                         if(ch == ' ' || ch == '-' || ch == ','){
                             if(last_char_was_separator){
                                 ConsoleKey key = ConsoleKey.A;
                                 bool shifted = false;
                                 switch(cs[start+1].c){
                                 case 'E':
                                     key = ConsoleKey.Enter;
                                     break;
                                 case 'T':
                                     key = ConsoleKey.Tab;
                                     break;
                                 case 'P': //"Press any key"
                                     break;
                                 case '?':
                                     key = ConsoleKey.Oem2;
                                     shifted = true;
                                     break;
                                 case '=':
                                     key = ConsoleKey.OemPlus;
                                     break;
                                 default: //all others should be lowercase letters
                                     key = (ConsoleKey)(ConsoleKey.A + ((int)cs[start+1].c - (int)'a'));
                                     break;
                                 }
                                 MouseUI.CreateButton(key,shifted,r,c+start,1,end-start+1);
                                 brace = -1;
                                 start = -1;
                                 end = -1;
                             }
                             last_char_was_separator = !last_char_was_separator;
                         }
                         else{
                             last_char_was_separator = false;
                             end = idx;
                         }
                     }
                 }
                 ++idx;
                 if(idx == cs.Length()){
                     if(brace == 1){
                         ConsoleKey key = ConsoleKey.A;
                         bool shifted = false;
                         switch(cs[start+1].c){
                         case 'E':
                             key = ConsoleKey.Enter;
                             break;
                         case 'T':
                             key = ConsoleKey.Tab;
                             break;
                         case 'P': //"Press any key"
                             break;
                         case '?':
                             key = ConsoleKey.Oem2;
                             shifted = true;
                             break;
                         case '=':
                             key = ConsoleKey.OemPlus;
                             break;
                         default: //all others should be lowercase letters
                             key = (ConsoleKey)(ConsoleKey.A + ((int)cs[start+1].c - (int)'a'));
                             break;
                         }
                         MouseUI.CreateButton(key,shifted,r,c+start,1,end-start+1);
                     }
                     break;
                 }
             }
         }
     }
 }
 public static void WriteMapString(int r,int c,colorstring cs)
 {
     if(cs.Length() > 0){
         r += Global.MAP_OFFSET_ROWS;
         c += Global.MAP_OFFSET_COLS;
         int start_col = -1;
         int end_col = -1;
         int cpos = c;
         foreach(cstr s1 in cs.strings){
             cstr s = new cstr(s1.s,s1.color,s1.bgcolor);
             if(cpos-Global.MAP_OFFSET_COLS + s.s.Length > Global.COLS){
                 s.s = s.s.Substring(0,Global.COLS-(cpos-Global.MAP_OFFSET_COLS));
             }
             s.color = Colors.ResolveColor(s.color);
             s.bgcolor = Colors.ResolveColor(s.bgcolor);
             colorchar cch;
             cch.color = s.color;
             cch.bgcolor = s.bgcolor;
             if(!GLMode){
                 ConsoleColor co = Colors.GetColor(s.color);
                 if(ForegroundColor != co){
                     ForegroundColor = co;
                 }
                 co = Colors.GetColor(s.bgcolor);
                 if(BackgroundColor != co){
                     BackgroundColor = co;
                 }
             }
             int i = 0;
             bool changed = false;
             foreach(char ch in s.s){
                 cch.c = ch;
                 if(!memory[r,cpos+i].Equals(cch)){
                     memory[r,cpos+i] = cch;
                     if(start_col == -1){
                         start_col = cpos+i;
                     }
                     end_col = cpos+i;
                     changed = true;
                 }
                 ++i;
             }
             if(changed && !GLMode){
                 Console.SetCursorPosition(cpos,r);
                 Console.Write(s.s);
             }
             cpos += s.s.Length;
         }
         if(GLMode && !NoGLUpdate && start_col != -1){
             UpdateGLBuffer(r,start_col,r,end_col);
         }
         if(MouseUI.AutomaticButtonsFromStrings && GLMode){
             int idx = -1;
             int len = cs.Length();
             for(int i=0;i<len;++i){
                 if(cs[i].c == '['){
                     idx = i;
                     break;
                 }
             }
             if(idx != -1 && idx+1 < cs.Length()){
                 ConsoleKey key = ConsoleKey.A;
                 bool shifted = false;
                 switch(cs[idx+1].c){
                 case 'E':
                     key = ConsoleKey.Enter;
                     break;
                 case 'T':
                     key = ConsoleKey.Tab;
                     break;
                 case 'P': //"Press any key"
                     break;
                 case '?':
                     key = ConsoleKey.Oem2;
                     shifted = true;
                     break;
                 case '=':
                     key = ConsoleKey.OemPlus;
                     break;
                 default: //all others should be lowercase letters
                     key = (ConsoleKey)(ConsoleKey.A + ((int)cs[idx+1].c - (int)'a'));
                     break;
                 }
                 MouseUI.CreateMapButton(key,shifted,r-Global.MAP_OFFSET_ROWS,1);
             }
         }
         /*if(cpos-Global.MAP_OFFSET_COLS < Global.COLS){
             WriteString(r,cpos,"".PadRight(Global.COLS-(cpos-Global.MAP_OFFSET_COLS)));
         }*/
     }
 }
Exemple #8
0
        public static void AddWithWrap(this List <colorstring> l, colorstring cs, int wrap_width, int indent = 0)
        {
            colorstring last      = l.LastOrDefault();
            colorstring remainder = null;

            if (last == null)
            {
                remainder = cs;
            }
            else
            {
                if (last.Length() + cs.Length() <= wrap_width)
                {
                    foreach (cstr s in cs.strings)
                    {
                        last.strings.Add(s);
                    }
                }
                else
                {
                    int split_idx = cs.LastSpaceBeforeWrap(wrap_width - last.Length());
                    if (split_idx == -1)
                    {
                        remainder = cs;
                    }
                    else
                    {
                        var split = cs.SplitAt(split_idx, true);
                        foreach (cstr s in split[0].strings)
                        {
                            last.strings.Add(s);
                        }
                        remainder = split[1];
                    }
                }
            }
            while (remainder?.Length() > 0)
            {
                if (indent + remainder.Length() <= wrap_width)
                {
                    l.Add(new colorstring("".PadRight(indent)) + remainder);
                    break;
                }
                else
                {
                    colorstring next = new colorstring("".PadRight(indent));
                    l.Add(next);
                    int  split_idx    = remainder.LastSpaceBeforeWrap(wrap_width - indent);
                    bool remove_space = true;
                    if (split_idx == -1)                     // if there's nowhere better, just cut it off at the end of the line.
                    {
                        split_idx    = wrap_width - indent;
                        remove_space = false;
                    }
                    var split = remainder.SplitAt(split_idx, remove_space);
                    foreach (cstr s in split[0].strings)
                    {
                        next.strings.Add(s);
                    }
                    remainder = split[1];
                }
            }
        }