Exemplo n.º 1
0
        }                                                                                         //was r+1,c

        public static void WriteStatsString(int r, int c, string s)
        {
            cstr cs = new cstr(Color.Gray, Color.Black, s);

            //cs.color = Color.Gray;
            //cs.bgcolor = Color.Black;
            //cs.s = s;
            WriteStatsString(r, c, cs);
        }
Exemplo n.º 2
0
        public static void WriteStatsString(int r, int c, string s, Color color)
        {
            cstr cs = new cstr(color, Color.Black, s);

            //cs.color = color;
            //cs.bgcolor = Color.Black;
            //cs.s = s;
            WriteStatsString(r, c, cs);
        }
Exemplo n.º 3
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)));
                 * }*/
            }
        }
Exemplo n.º 4
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;
                }
            }
        }
Exemplo n.º 5
0
        public static void WriteMapString(int r, int c, cstr s)
        {
            if (Global.COLS - c > s.s.Length)
            {
                //s.s = s.s.Substring(0); //don't move down to the next line
            }
            else
            {
                s.s = s.s.Substring(0, Global.COLS - c);
            }
            if (s.s.Length > 0)
            {
                r        += Global.MAP_OFFSET_ROWS;
                c        += 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, c + i].Equals(cch))
                    {
                        memory[r, c + i] = cch;
                        changed          = true;
                    }
                    ++i;
                }
                if (changed)
                {
                    Game.Console.SetCursorPosition(c, r);
                    Game.Console.Write(s.s);
                }
            }
        }
Exemplo n.º 6
0
        public static void WriteStatsString(int r, int c, cstr s)
        {
            if (12 - c > s.s.Length)
            {
                //s.s = s.s.Substring(0); //don't move down to the next line - 12 is the width of the stats area
            }
            else
            {
                s.s = s.s.Substring(0, 12 - c);
            }
            if (s.s.Length > 0)
            {
                //++r; //was ++r
                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;
                for (int ii = 0; ii < s.s.Length; ii++)
                {
                    cch.c = s.s.CharAt(ii);
                    if (!memory[r, c + i].Equals(cch))
                    {
                        memory[r, c + i] = cch;
                    }
                    ++i;
                }
                Game.Console.SetCursorPosition(c, r);
                Game.Console.Write(s.s);
            }
        }
Exemplo n.º 7
0
        public static void MapDrawWithStrings(colorchar[,] array, int row, int col, int height, int width)
        {
            cstr s = new cstr("", Color.Black, Color.Black);
            //s.s = "";
            //s.bgcolor = Color.Black;
            //s.color = Color.Black;
            int current_c = col;

            for (int i = row; i < row + height; ++i)
            {
                s.s       = "";
                current_c = col;
                for (int j = col; j < col + width; ++j)
                {
                    colorchar ch = array[i, j];
                    if (Screen.ResolveColor(ch.color) != s.color)
                    {
                        if (s.s.Length > 0)
                        {
                            Screen.WriteMapString(i, current_c, s);
                            s.s       = "";
                            s.s      += ch.c;
                            s.color   = ch.color;
                            current_c = j;
                        }
                        else
                        {
                            s.s    += ch.c;
                            s.color = ch.color;
                        }
                    }
                    else
                    {
                        s.s += ch.c;
                    }
                }
                Screen.WriteMapString(i, current_c, s);
            }
        }
Exemplo n.º 8
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;
				}
			}
		}
Exemplo n.º 9
0
 public colorstring(cstr[] cstrs)
 {
     if (cstrs != null && cstrs.Length > 0)
     {
         for (int i = 0; i < cstrs.Length; i++)
         {
             strings.Add(cstrs[i]);
         }
     }
 }
Exemplo n.º 10
0
		public static cstr StatsName(WeaponType type){
			cstr cs = new cstr("", Color.Gray, Color.Black);
			cs.bgcolor = Color.Black;
			cs.color = Color.Gray;
			switch(type){
			case WeaponType.SWORD:
				cs.s = "Sword";
				break;
			case WeaponType.FLAMEBRAND:
				cs.s = "+Sword+";
				cs.color = Color.Red;
				break;
			case WeaponType.MACE:
				cs.s = "Mace";
				break;
			case WeaponType.MACE_OF_FORCE:
				cs.s = "+Mace+";
				cs.color = Color.Cyan;
				break;
			case WeaponType.DAGGER:
				cs.s = "Dagger";
				break;
			case WeaponType.VENOMOUS_DAGGER:
				cs.s = "+Dagger+";
				cs.color = Color.Green;
				break;
			case WeaponType.STAFF:
				cs.s = "Staff";
				break;
			case WeaponType.STAFF_OF_MAGIC:
				cs.s = "+Staff+";
				cs.color = Color.Magenta;
				break;
			case WeaponType.BOW:
				cs.s = "Bow";
				break;
			case WeaponType.HOLY_LONGBOW:
				cs.s = "+Bow+";
				cs.color = Color.Yellow;
				break;
			default:
				cs.s = "no weapon";
				break;
			}
			return cs;
		}
Exemplo n.º 11
0
		public static void WriteStatsChar(int r,int c,colorchar ch){ WriteChar(r,c,ch); } //was r+1,c
		public static void WriteStatsString(int r,int c,string s){
            cstr cs = new cstr(Color.Gray, Color.Black, s);

            //cs.color = Color.Gray;
            //cs.bgcolor = Color.Black;
            //cs.s = s;
			WriteStatsString(r,c,cs);
		}
Exemplo n.º 12
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 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)));
         }*/
     }
 }
Exemplo n.º 13
0
		public static void WriteStatsString(int r,int c,cstr s){
			if(12 - c > s.s.Length){
				//s.s = s.s.Substring(0); //don't move down to the next line - 12 is the width of the stats area
			}
			else{
				s.s = s.s.Substring(0,12 - c);
			}
			if(s.s.Length > 0){
				//++r; //was ++r
				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;
                for (int ii = 0; ii < s.s.Length; ii++)
                {
                    cch.c = s.s.CharAt(ii);
					if(!memory[r,c+i].Equals(cch)){
						memory[r,c+i] = cch;
					}
					++i;
				}
				Game.Console.SetCursorPosition(c,r);
				Game.Console.Write(s.s);
			}
		}
Exemplo n.º 14
0
		public static cstr StatsName(MagicItemType type){
            cstr cs = new cstr("", Color.Gray, Color.Black);
			cs.bgcolor = Color.Black;
			cs.color = Color.DarkGreen;
			switch(type){
			case MagicItemType.RING_OF_PROTECTION:
				cs.s = "Ring (prot)";
				break;
			case MagicItemType.RING_OF_RESISTANCE:
				cs.s = "Ring (res)";
				break;
			case MagicItemType.PENDANT_OF_LIFE:
				cs.s = "Pendant";
				break;
			case MagicItemType.CLOAK_OF_DISAPPEARANCE:
				cs.s = "Cloak";
				break;
			default:
				cs.s = "No item";
				break;
			}
			return cs;
		}
Exemplo n.º 15
0
 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;
                 }
             }
         }
     }
 }
Exemplo n.º 16
0
 public void Add(cstr cs)
 {
     strings.Add(cs);
 }
Exemplo n.º 17
0
 public colorstring(cstr cs)
 {
     strings.Add(cs);
 }
Exemplo n.º 18
0
 public static void WriteString(int r,int c,cstr s)
 {
     if(Global.SCREEN_W - c > s.s.Length){
         //s.s = s.s.Substring(0,; //don't move down to the next line
     }
     else{
         s.s = s.s.Substring(0,Global.SCREEN_W - c);
     }
     if(s.s.Length > 0){
         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 start_col = -1;
         int end_col = -1;
         int i = 0;
         bool changed = false;
         foreach(char ch in s.s){
             cch.c = ch;
             if(!memory[r,c+i].Equals(cch)){
                 memory[r,c+i] = cch;
                 if(start_col == -1){
                     start_col = c+i;
                 }
                 end_col = c+i;
                 changed = true;
             }
             ++i;
         }
         if(changed){
             if(GLMode){
                 if(!NoGLUpdate){
                     UpdateGLBuffer(r,start_col,r,end_col);
                 }
             }
             else{
                 Console.SetCursorPosition(c,r);
                 Console.Write(s.s);
             }
         }
         if(MouseUI.AutomaticButtonsFromStrings && GLMode){
             int idx = 0;
             int brace = -1;
             int start = -1;
             int end = -1;
             bool last_char_was_separator = false;
             while(true){
                 if(brace == -1){
                     if(s.s[idx] == '['){
                         brace = 0;
                         start = idx;
                     }
                 }
                 else{
                     if(brace == 0){
                         if(s.s[idx] == ']'){
                             brace = 1;
                             end = idx;
                         }
                     }
                     else{
                         if(s.s[idx] == ' ' || s.s[idx] == '-' || s.s[idx] == ','){
                             if(last_char_was_separator){
                                 ConsoleKey key = ConsoleKey.A;
                                 bool shifted = false;
                                 switch(s.s[start+1]){
                                 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)s.s[start+1] - (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 == s.s.Length){
                     if(brace == 1){
                         ConsoleKey key = ConsoleKey.A;
                         bool shifted = false;
                         switch(s.s[start+1]){
                         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)s.s[start+1] - (int)'a'));
                             break;
                         }
                         MouseUI.CreateButton(key,shifted,r,c+start,1,end-start+1);
                     }
                     break;
                 }
             }
         }
     }
 }
Exemplo n.º 19
0
 public static void WriteStatsString(int r,int c,cstr s)
 {
     if(12 - c > s.s.Length){
         //s.s = s.s.Substring(0); //don't move down to the next line - 12 is the width of the stats area
     }
     else{
         s.s = s.s.Substring(0,12 - c);
     }
     if(s.s.Length > 0){
         //++r;
         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 start_col = -1;
         int end_col = -1;
         int i = 0;
         bool changed = false;
         foreach(char ch in s.s){
             cch.c = ch;
             if(!memory[r,c+i].Equals(cch)){
                 memory[r,c+i] = cch;
                 if(start_col == -1){
                     start_col = c+i;
                 }
                 end_col = c+i;
                 changed = true;
             }
             ++i;
         }
         if(changed){
             if(GLMode){
                 if(!NoGLUpdate){
                     UpdateGLBuffer(r,start_col,r,end_col);
                 }
             }
             else{
                 Console.SetCursorPosition(c,r);
                 Console.Write(s.s);
             }
         }
         if(MouseUI.AutomaticButtonsFromStrings && GLMode){
             int idx = s.s.IndexOf('['); //for now I'm only checking for a single brace here.
             if(idx != -1 && idx+1 < s.s.Length){
                 ConsoleKey key = ConsoleKey.A;
                 bool shifted = false;
                 switch(s.s[idx+1]){
                 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)s.s[idx+1] - (int)'a'));
                     break;
                 }
                 MouseUI.CreateStatsButton(key,shifted,r,1);
             }
         }
     }
 }
Exemplo n.º 20
0
		public static void WriteMapString(int r,int c,cstr s){
			if(Global.COLS - c > s.s.Length){
				//s.s = s.s.Substring(0); //don't move down to the next line
			}
			else{
				s.s = s.s.Substring(0,Global.COLS - c);
			}
			if(s.s.Length > 0){
				r += Global.MAP_OFFSET_ROWS;
				c += 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,c+i].Equals(cch)){
						memory[r,c+i] = cch;
						changed = true;
					}
					++i;
				}
				if(changed){
					Game.Console.SetCursorPosition(c,r);
					Game.Console.Write(s.s);
				}
			}
		}
Exemplo n.º 21
0
		public static cstr StatsName(ArmorType type){
            cstr cs = new cstr("", Color.Gray, Color.Black);
			cs.bgcolor = Color.Black;
			cs.color = Color.Gray;
			switch(type){
			case ArmorType.LEATHER:
				cs.s = "Leather";
				break;
			case ArmorType.ELVEN_LEATHER:
				cs.s = "+Leather+";
				cs.color = Color.DarkCyan;
				break;
			case ArmorType.CHAINMAIL:
				cs.s = "Chainmail";
				break;
			case ArmorType.CHAINMAIL_OF_ARCANA:
				cs.s = "+Chainmail+";
				cs.color = Color.Magenta;
				break;
			case ArmorType.FULL_PLATE:
				cs.s = "Full plate";
				break;
			case ArmorType.FULL_PLATE_OF_RESISTANCE:
				cs.s = "+Full plate+";
				cs.color = Color.Blue;
				break;
			default:
				cs.s = "no armor";
				break;
			}
			return cs;
		}
Exemplo n.º 22
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)));
				}*/
			}
		}
Exemplo n.º 23
0
		public static cstr EquipmentScreenName(WeaponType type){
            cstr cs = new cstr("", Color.Gray, Color.Black);
			cs.bgcolor = Color.Black;
			cs.color = Color.Gray;
			switch(type){
			case WeaponType.SWORD:
				cs.s = "Sword";
				break;
			case WeaponType.FLAMEBRAND:
				cs.s = "Flamebrand";
				cs.color = Color.Red;
				break;
			case WeaponType.MACE:
				cs.s = "Mace";
				break;
			case WeaponType.MACE_OF_FORCE:
				cs.s = "Mace of force";
				cs.color = Color.Cyan;
				break;
			case WeaponType.DAGGER:
				cs.s = "Dagger";
				break;
			case WeaponType.VENOMOUS_DAGGER:
				cs.s = "Venomous dagger";
				cs.color = Color.Green;
				break;
			case WeaponType.STAFF:
				cs.s = "Staff";
				break;
			case WeaponType.STAFF_OF_MAGIC:
				cs.s = "Staff of magic";
				cs.color = Color.Magenta;
				break;
			case WeaponType.BOW:
				cs.s = "Bow";
				break;
			case WeaponType.HOLY_LONGBOW:
				cs.s = "Holy longbow";
				cs.color = Color.Yellow;
				break;
			default:
				cs.s = "no weapon";
				break;
			}
			return cs;
		}
Exemplo n.º 24
0
		public static void WriteStatsString(int r,int c,string s,Color color){
            cstr cs = new cstr(color, Color.Black, s);
            //cs.color = color;
            //cs.bgcolor = Color.Black;
            //cs.s = s;
			WriteStatsString(r,c,cs);
		}
Exemplo n.º 25
0
        public void DisplayStats(bool cyan_letters)
        {
            Game.Console.CursorVisible = false;
            Screen.WriteStatsString(2, 0, "HP: ");
            if (curhp < 50)
            {
                if (curhp < 20)
                {
                    Screen.WriteStatsString(2, 4, new cstr(Color.DarkRed, curhp.ToString() + "  "));
                }
                else
                {
                    Screen.WriteStatsString(2, 4, new cstr(Color.Red, curhp.ToString() + "  "));
                }
            }
            else
            {
                Screen.WriteStatsString(2, 4, curhp.ToString() + "  ");
            }
            Screen.WriteStatsString(3, 0, "Depth: " + M.current_level + "  ");
            Screen.WriteStatsString(4, 0, "AC: " + ArmorClass() + "  ");
            int magic_item_lines = magic_items.Count;
            cstr cs = Weapon.StatsName(weapons[0]);
            cs.s = cs.s.PadRight(12);
            Screen.WriteStatsString(5, 0, cs);
            cs = Armor.StatsName(armors[0]);
            cs.s = cs.s.PadRight(12);
            Screen.WriteStatsString(6, 0, cs);
            int line = 7;
            foreach (MagicItemType m in magic_items)
            {
                cs = MagicItem.StatsName(m);
                cs.s = cs.s.PadRight(12);
                Screen.WriteStatsString(line, 0, cs);
                ++line;
            }
            if (!Global.Option(OptionType.HIDE_COMMANDS))
            {
                /*[i]nventory
                [e]quipment
                [c]haracter
                [t]orch off
                Use [f]eat
                Cast [z]
                [s]hoot			here is the full list, to be completed when there's enough room.
                [a]pply item
                [g]et item
                [d]rop item     missing only drop, now. I don't think it really needs a spot.
                [r]est
                [w]alk
                E[x]plore
                [o]perate
                [tab] Look
                */
                for (int i = 7 + magic_item_lines; i < 11; ++i)
                {
                    Screen.WriteStatsString(i, 0, "".PadRight(12));
                }
                string[] commandhints = new string[]{"[i]nventory ","[e]quipment ","[c]haracter ","SPECIAL",
					"Use [f]eat  ","Cast [z]    ","[s]hoot     ","[Tab] Look  ","[a]pply item","[g]et item  ",
					"[r]est      ","[w]alk      ","E[x]plore   ","[o]perate   "};
                if (light_radius > 0)
                {
                    commandhints[3] = "[t]orch off ";
                }
                else
                {
                    commandhints[3] = "[t]orch on  ";
                }
                Color lettercolor = cyan_letters ? Color.Cyan : Color.DarkCyan;
                Color wordcolor = cyan_letters ? Color.Gray : Color.DarkGray;
                for (int i = 0; i < commandhints.Length; ++i)
                {
                    int open = commandhints[i].LastIndexOf("[");
                    cstr front = new cstr(commandhints[i].Substring(0, open + 1), wordcolor);
                    int close = commandhints[i].LastIndexOf("]");
                    cstr middle = new cstr(commandhints[i].Substring(open + 1, (close)), lettercolor); // was close - open
                    cstr end = new cstr(commandhints[i].Substring(close), wordcolor);
                    Screen.WriteString(11 + i, 0, new colorstring(new cstr[] { front, middle, end }));
                }
            }
            else
            {
                for (int i = 7 + magic_item_lines; i < Global.SCREEN_H; ++i)
                {
                    Screen.WriteStatsString(i, 0, "".PadRight(12));
                }
            }
            Screen.ResetColors();
        }
Exemplo n.º 26
0
		public static void MapDrawWithStrings(colorchar[,] array,int row,int col,int height,int width){
			cstr s = new cstr("", Color.Black, Color.Black);
            //s.s = "";
            //s.bgcolor = Color.Black;
            //s.color = Color.Black;
			int current_c = col;
			for(int i=row;i<row+height;++i){
				s.s = "";
				current_c = col;
				for(int j=col;j<col+width;++j){
					colorchar ch = array[i,j];
					if(Screen.ResolveColor(ch.color) != s.color){
						if(s.s.Length > 0){
							Screen.WriteMapString(i,current_c,s);
							s.s = "";
							s.s += ch.c;
							s.color = ch.color;
							current_c = j;
						}
						else{
							s.s += ch.c;
							s.color = ch.color;
						}
					}
					else{
						s.s += ch.c;
					}
				}
				Screen.WriteMapString(i,current_c,s);
			}
		}
Exemplo n.º 27
0
		public static cstr EquipmentScreenName(ArmorType type){
            cstr cs = new cstr("", Color.Gray, Color.Black);
			cs.bgcolor = Color.Black;
			cs.color = Color.Gray;
			switch(type){
			case ArmorType.LEATHER:
				cs.s = "Leather";
				break;
			case ArmorType.ELVEN_LEATHER:
				cs.s = "Elven leather";
				cs.color = Color.DarkCyan;
				break;
			case ArmorType.CHAINMAIL:
				cs.s = "Chainmail";
				break;
			case ArmorType.CHAINMAIL_OF_ARCANA:
				cs.s = "Chainmail of arcana";
				cs.color = Color.Magenta;
				break;
			case ArmorType.FULL_PLATE:
				cs.s = "Full plate";
				break;
			case ArmorType.FULL_PLATE_OF_RESISTANCE:
				cs.s = "Full plate of resistance";
				cs.color = Color.Blue;
				break;
			default:
				cs.s = "no armor";
				break;
			}
			return cs;
		}