-
Notifications
You must be signed in to change notification settings - Fork 97
/
MACROS.C
144 lines (134 loc) · 2.39 KB
/
MACROS.C
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
//
// Choose which type of netplay
//
#include <dos.h>
#include <conio.h>
#include <string.h>
#include "main.h"
//
// Line input routine -- totally crude!
//
int EditLine(item_t *item,char *string,int maxlen)
{
char c;
int len;
textbackground(0);
textcolor(15);
Clear(item);
Pos(item);
cprintf("%s",string);
while(1)
{
c = getch();
switch(c)
{
case 8: // BACKSPACE
case 0x4b: // LEFT ARROW
len = strlen(string);
if (!len)
{
sound(2500);
delay(3);
nosound();
continue;
}
string[len-1] = 0;
Clear(item);
Pos(item);
cprintf("%s",string);
case 77: // RIGHT ARROW
sound(2500);
delay(3);
nosound();
break;
case KEY_ENTER:
case KEY_ESC:
return c;
default:
if (c < 0x20 || c > 0x7a)
{
sound(2500);
delay(3);
nosound();
continue;
}
len = strlen(string);
if (len+1 == maxlen)
{
sound(2500);
delay(3);
nosound();
continue;
}
string[len] = c;
string[len+1] = 0;
Pos(item);
cprintf("%s",string);
break;
}
}
}
enum {MAC_MACRO0,MAC_MACRO1,MAC_MACRO2,MAC_MACRO3,MAC_MACRO4,MAC_MACRO5,
MAC_MACRO6,MAC_MACRO7,MAC_MACRO8,MAC_MACRO9,MAC_MAX};
item_t macrositems[]=
{
{MAC_MACRO0, 22,7,40, -1,-1},
{MAC_MACRO1, 22,8,40, -1,-1},
{MAC_MACRO2, 22,9,40, -1,-1},
{MAC_MACRO3, 22,10,40, -1,-1},
{MAC_MACRO4, 22,11,40, -1,-1},
{MAC_MACRO5, 22,12,40, -1,-1},
{MAC_MACRO6, 22,13,40, -1,-1},
{MAC_MACRO7, 22,14,40, -1,-1},
{MAC_MACRO8, 22,15,40, -1,-1},
{MAC_MACRO9, 22,16,40, -1,-1}
};
menu_t macrosmenu=
{
¯ositems[0],
MAC_MACRO0,
MAC_MAX,
0x7f
};
void MacroConfig(void)
{
short key;
short field;
int i;
char string[40];
SaveScreen();
DrawPup(¯os);
textcolor(15);
textbackground(1);
for (i = 0;i < MAC_MAX; i++)
{
Clear(¯ositems[i]);
Pos(¯ositems[i]);
cprintf("%s",&chatmacros[i][0]);
}
gotoxy(1,25);
while(1)
{
SetupMenu(¯osmenu);
field = GetMenuInput();
key = menukey;
switch(key)
{
case KEY_ENTER:
strcpy(string,chatmacros[field]);
key = EditLine(¯ositems[field],string,40);
if (key == KEY_ENTER)
strcpy(chatmacros[field],string);
textbackground(1);
textcolor(15);
Clear(¯ositems[field]);
Pos(¯ositems[field]);
cprintf("%s",chatmacros[field]);
gotoxy(1,25);
continue;
case KEY_ESC:
RestoreScreen();
return;
}
}
};