Migrate more strings
FossilOrigin-Name: 5ef6284dcf38a9367998d964d81cf7cf8340d76c87d58efaa350c9d930ccb416
This commit is contained in:
parent
2a2c5ee6ee
commit
570b9e3bb3
5 changed files with 76 additions and 68 deletions
|
@ -166,7 +166,7 @@ trydisconnect()
|
|||
|
||||
string ctext;
|
||||
void
|
||||
toserver(char *text)
|
||||
toserver(const char *text)
|
||||
{
|
||||
conoutf(@"%s:\f %s", player1->name, text);
|
||||
strn0cpy(ctext, text, 80);
|
||||
|
|
|
@ -511,33 +511,44 @@ resetcomplete()
|
|||
}
|
||||
|
||||
void
|
||||
complete(char *s)
|
||||
complete(OFString *s_)
|
||||
{
|
||||
@autoreleasepool {
|
||||
std::unique_ptr<char> copy(strdup(s_.UTF8String));
|
||||
char *s = copy.get();
|
||||
|
||||
if (*s != '/') {
|
||||
string t;
|
||||
strcpy_s(t, s);
|
||||
strcpy_s(s, "/");
|
||||
strcat_s(s, t);
|
||||
}
|
||||
|
||||
if (!s[1])
|
||||
return;
|
||||
|
||||
if (!completesize) {
|
||||
completesize = (int)strlen(s) - 1;
|
||||
completesize = strlen(s) - 1;
|
||||
completeidx = 0;
|
||||
}
|
||||
|
||||
__block int idx = 0;
|
||||
[idents enumerateKeysAndObjectsUsingBlock:^(
|
||||
OFString *name, Ident *ident, bool *stop) {
|
||||
if (strncmp(ident.name.UTF8String, s + 1, completesize) == 0 &&
|
||||
if (strncmp(ident.name.UTF8String, s + 1,
|
||||
completesize) == 0 &&
|
||||
idx++ == completeidx) {
|
||||
strcpy_s(s, "/");
|
||||
strcat_s(s, ident.name.UTF8String);
|
||||
}
|
||||
}];
|
||||
|
||||
completeidx++;
|
||||
|
||||
if (completeidx >= idx)
|
||||
completeidx = 0;
|
||||
}
|
||||
}
|
||||
|
||||
bool
|
||||
execfile(OFString *cfgfile)
|
||||
|
|
|
@ -18,7 +18,7 @@ const int WORDWRAP = 80;
|
|||
int conskip = 0;
|
||||
|
||||
bool saycommandon = false;
|
||||
string commandbuf;
|
||||
static OFMutableString *commandbuf;
|
||||
|
||||
void
|
||||
setconskip(int n)
|
||||
|
@ -128,18 +128,21 @@ bindkey(OFString *key, OFString *action)
|
|||
COMMANDN(bind, bindkey, ARG_2STR)
|
||||
|
||||
void
|
||||
saycommand(char *init) // turns input to the command line on or off
|
||||
saycommand(const char *init) // turns input to the command line on or off
|
||||
{
|
||||
saycommandon = (init != NULL);
|
||||
if (saycommandon)
|
||||
SDL_StartTextInput();
|
||||
else
|
||||
SDL_StopTextInput();
|
||||
|
||||
if (!editmode)
|
||||
Cube.sharedInstance.repeatsKeys = saycommandon;
|
||||
|
||||
if (!init)
|
||||
init = "";
|
||||
strcpy_s(commandbuf, init);
|
||||
|
||||
commandbuf = [[OFMutableString alloc] initWithUTF8String:init];
|
||||
}
|
||||
COMMAND(saycommand, ARG_VARI)
|
||||
|
||||
|
@ -155,12 +158,13 @@ COMMAND(mapmsg, ARG_1STR)
|
|||
void
|
||||
pasteconsole()
|
||||
{
|
||||
char *cb = SDL_GetClipboardText();
|
||||
strcat_s(commandbuf, cb);
|
||||
@autoreleasepool {
|
||||
[commandbuf appendString:@(SDL_GetClipboardText())];
|
||||
}
|
||||
}
|
||||
|
||||
static OFMutableArray<OFString *> *vhistory;
|
||||
int histpos = 0;
|
||||
static int histpos = 0;
|
||||
|
||||
void
|
||||
history(int n)
|
||||
|
@ -189,31 +193,24 @@ keypress(int code, bool isdown, int cooked)
|
|||
|
||||
case SDLK_BACKSPACE:
|
||||
case SDLK_LEFT: {
|
||||
for (int i = 0; commandbuf[i]; i++)
|
||||
if (!commandbuf[i + 1])
|
||||
commandbuf[i] = 0;
|
||||
[commandbuf
|
||||
deleteCharactersInRange:
|
||||
OFMakeRange(commandbuf.length - 1, 1)];
|
||||
|
||||
resetcomplete();
|
||||
break;
|
||||
}
|
||||
|
||||
case SDLK_UP:
|
||||
if (histpos) {
|
||||
@autoreleasepool {
|
||||
strcpy_s(commandbuf,
|
||||
vhistory[--histpos]
|
||||
.UTF8String);
|
||||
}
|
||||
}
|
||||
if (histpos)
|
||||
commandbuf =
|
||||
[vhistory[--histpos] mutableCopy];
|
||||
break;
|
||||
|
||||
case SDLK_DOWN:
|
||||
if (histpos < vhistory.count) {
|
||||
@autoreleasepool {
|
||||
strcpy_s(commandbuf,
|
||||
vhistory[histpos++]
|
||||
.UTF8String);
|
||||
}
|
||||
}
|
||||
if (histpos < vhistory.count)
|
||||
commandbuf =
|
||||
[vhistory[histpos++] mutableCopy];
|
||||
break;
|
||||
|
||||
case SDLK_TAB:
|
||||
|
@ -225,22 +222,17 @@ keypress(int code, bool isdown, int cooked)
|
|||
(KMOD_LCTRL | KMOD_RCTRL)) {
|
||||
pasteconsole();
|
||||
return;
|
||||
};
|
||||
}
|
||||
|
||||
default:
|
||||
resetcomplete();
|
||||
if (cooked) {
|
||||
char add[] = {(char)cooked, 0};
|
||||
strcat_s(commandbuf, add);
|
||||
}
|
||||
if (cooked)
|
||||
[commandbuf appendFormat:@"%c", cooked];
|
||||
}
|
||||
} else {
|
||||
if (code == SDLK_RETURN) {
|
||||
if (commandbuf[0]) {
|
||||
if (commandbuf.length > 0) {
|
||||
@autoreleasepool {
|
||||
OFString *cmdbuf =
|
||||
@(commandbuf);
|
||||
|
||||
if (vhistory == nil)
|
||||
vhistory =
|
||||
[[OFMutableArray
|
||||
|
@ -248,17 +240,22 @@ keypress(int code, bool isdown, int cooked)
|
|||
|
||||
if (vhistory.count == 0 ||
|
||||
![vhistory.lastObject
|
||||
isEqual:cmdbuf]) {
|
||||
isEqual:commandbuf]) {
|
||||
// cap this?
|
||||
[vhistory
|
||||
addObject:cmdbuf];
|
||||
addObject:
|
||||
[commandbuf
|
||||
copy]];
|
||||
}
|
||||
}
|
||||
histpos = vhistory.count;
|
||||
if (commandbuf[0] == '/')
|
||||
execute(commandbuf, true);
|
||||
else
|
||||
toserver(commandbuf);
|
||||
if ([commandbuf hasPrefix:@"/"]) {
|
||||
std::unique_ptr<char> copy(
|
||||
strdup(
|
||||
commandbuf.UTF8String));
|
||||
execute(copy.get(), true);
|
||||
} else
|
||||
toserver(commandbuf.UTF8String);
|
||||
}
|
||||
saycommand(NULL);
|
||||
} else if (code == SDLK_ESCAPE) {
|
||||
|
@ -281,7 +278,7 @@ keypress(int code, bool isdown, int cooked)
|
|||
}
|
||||
}
|
||||
|
||||
char *
|
||||
OFString *
|
||||
getcurcommand()
|
||||
{
|
||||
return saycommandon ? commandbuf : NULL;
|
||||
|
|
|
@ -11,7 +11,7 @@ extern int execute(char *p, bool down = true);
|
|||
extern void exec(OFString *cfgfile);
|
||||
extern bool execfile(OFString *cfgfile);
|
||||
extern void resetcomplete();
|
||||
extern void complete(char *s);
|
||||
extern void complete(OFString *s);
|
||||
extern void alias(OFString *name, OFString *action);
|
||||
extern OFString *getalias(OFString *name);
|
||||
extern void writecfg();
|
||||
|
@ -20,7 +20,7 @@ extern void writecfg();
|
|||
extern void keypress(int code, bool isdown, int cooked);
|
||||
extern void renderconsole();
|
||||
extern void conoutf(OFConstantString *format, ...);
|
||||
extern char *getcurcommand();
|
||||
extern OFString *getcurcommand();
|
||||
extern void writebinds(OFStream *stream);
|
||||
|
||||
// init
|
||||
|
@ -71,7 +71,7 @@ extern void setarraypointers();
|
|||
extern void localservertoclient(uchar *buf, int len);
|
||||
extern void connects(OFString *servername);
|
||||
extern void disconnect(int onlyclean = 0, int async = 0);
|
||||
extern void toserver(char *text);
|
||||
extern void toserver(const char *text);
|
||||
extern void addmsg(int rel, int num, int type, ...);
|
||||
extern bool multiplayer();
|
||||
extern bool allowedittoggle();
|
||||
|
|
|
@ -366,11 +366,11 @@ gl_drawhud(int w, int h, int curfps, int nquads, int curvert, bool underwater)
|
|||
glEnable(GL_TEXTURE_2D);
|
||||
|
||||
@autoreleasepool {
|
||||
char *command = getcurcommand();
|
||||
OFString *command = getcurcommand();
|
||||
char *player = playerincrosshair();
|
||||
|
||||
if (command)
|
||||
draw_textf(@"> %s_", 20, 1570, 2, command);
|
||||
draw_textf(@"> %@_", 20, 1570, 2, command);
|
||||
else if (closeent[0])
|
||||
draw_text(@(closeent), 20, 1570, 2);
|
||||
else if (player)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue