[go: up one dir, main page]

Menu

[897c37]: / mlib / std / ansi.lpc  Maximize  Restore  History

Download this file

217 lines (189 with data), 3.8 kB

inherit "RO/Servers";
#include "ansi.h"
/* 30 June '95 Belgarion - mod to use above .h file */
/* 11 Dec 98 Jenna - Added "roomnames" */

#if 0
/*
 * try: CURSOR_RIGHT(n), CURSOR_LEFT(n), CURSOR_UP(n), and CURSOR_DOWN(n) -
 * defined in ansi.h :)
 */
#define FORWARD "p1C"
#define BACKWARD "p1D"
#define DOWN "1B"
#define UP "1A"
#endif

clearscreen()
{
	set_cursor(0,0);
	return ERASE_SCREEN;
}

/* this isn't in ansi.h ... */
set_cursor(int x, int y)
{
	return("["+x+";"+y+"H");
}

eraseline(int x, int y)
{
	return("");
	set_cursor(x,y);
	return("");
	return("");
}

bold(string str)
{
	return (BOLD_ON+str+BOLD_OFF);
}

reverse(string str)
{
	return(NEGATIVE_ON+str+NEGATIVE_OFF);
}

blink(string str)
{
	return(BLINK_ON+str+BLINK_OFF);
}

string
faint(string str)
{
	return(FAINT_ON+str+FAINT_OFF);
}

underscore(string str)
{
	return(UNDERLINE_ON+str+UNDERLINE_OFF);
}

/* also not in ansi.h */
scolor(int c, str)   /* Jenna Jan 99 - removed "string" str to avoid errors */
{
    if (c == 0) return str;
    if (str == 0) return "";
    if (c > 100)
    {
        c = c - 100;
	    return("["+c+";2m"+str+"");
    }
	return("["+c+";1m"+str+"");
}

fcolor(int c, string str)
{
    if (c == 0) return str;
	return("["+c+";2m"+str+"");
}

ocolor(int c, string str)
{
    if (c == 0) return str;
	return("["+c+";3m"+str+"");
}

rshout(string str)
{
	SHOUT->shout(scolor(41, str) + "\n");
}

cshout(int c, string str)
{
	SHOUT->shout(scolor(c, str) + "\n");
}

palette()
{
	int i;
	for (i = 21; i < 61; i++){
		write(scolor(i, "A"));
		say(scolor(i, "A"));
        if (i%10 == 0) 
        {
            write("\n");
            say("\n");
        }
}
}

fpalette()
{
	int i;
	for (i = 21; i < 61; i++){
		write(fcolor(i, "A"));
        if (i%10 == 0) 
        {
            write("\n");
        }
}
}

opalette()
{
	int i;
	for (i = 21; i < 61; i++){
		write(ocolor(i, "A"));
        if (i%10 == 0) 
        {
            write("\n");
        }
}
}

opalette()
{
	int i;
	for (i = 21; i < 61; i++){
		write(ocolor(i, "A"));
        if (i%10 == 0) 
        {
            write("\n");
        }
}
}



array colors =
[  
    "black", BLACK,
    "red", RED, 
    "green", GREEN, 
    "yellow", YELLOW, 
    "blue", BLUE, 
    "purple", PURPLE,
    "cyan", CYAN,
    "grey", GREY,
    "white", WHITE,
    "inverse red", INVERSE_RED,
    "inverse green", INVERSE_GREEN,
    "inverse yellow", INVERSE_YELLOW,
    "inverse blue", INVERSE_BLUE,
    "inverse purple", INVERSE_PURPLE,
    "inverse cyan", INVERSE_CYAN,
    "inverse grey", INVERSE_GREY,
    "faint red", FAINT_RED,
    "faint green", FAINT_GREEN,
    "faint yellow", FAINT_YELLOW,
    "faint blue", FAINT_BLUE,
    "faint purple", FAINT_PURPLE,
    "faint cyan", FAINT_CYAN,
    "faint grey", FAINT_GREY
    ];

int get_color(str)
{
    int x;

    if (!str) return 0;
    x = index(colors, str);
    if (x < 0 || x%2 == 1) return 0;
    return colors[x+1];
}

get_color_str(int i) {
        int x = index(colors, i);
        return (x > 0) ? colors[x - 1] : 0;
}

int
hilite(object ob, string str)
{
    int x;
    if (!ob->query_store("hilite_on")) return 0;
    x = ob->query_store("hilite_"+str);
    if (x < 2)
    {
        /* temp fix - so people have highlighting default */
        if (str == "tell") x = YELLOW;
        else if (str == "say") x= GREEN;
        else if (str == "shout") x= RED;
        else if (str == "exits") x= PURPLE;
        else if (str == "wiz") x= CYAN;
        else if (str == "combat") x= WHITE;
        else if (str == "rooms") x= WHITE;
	else if (str == "roomnames") x = WHITE;
	else if (str == "things") x = FAINT_YELLOW;
	else if (str == "people") x = FAINT_GREEN;
        ob->add_store("hilite_"+str, x);
    }
    return x;
}