2004-08-25 03:42:49 +00:00
|
|
|
#include "qcc.h"
|
|
|
|
#include "gui.h"
|
|
|
|
|
2005-02-28 07:16:19 +00:00
|
|
|
//common gui things
|
|
|
|
|
2013-06-23 02:17:02 +00:00
|
|
|
pbool fl_nondfltopts;
|
2005-02-28 07:16:19 +00:00
|
|
|
pbool fl_hexen2;
|
|
|
|
pbool fl_autohighlight;
|
|
|
|
pbool fl_compileonstart;
|
|
|
|
pbool fl_showall;
|
2005-03-01 15:36:23 +00:00
|
|
|
pbool fl_log;
|
2005-02-28 07:16:19 +00:00
|
|
|
|
|
|
|
char parameters[16384];
|
|
|
|
char progssrcname[256];
|
|
|
|
char progssrcdir[256];
|
2014-12-23 15:26:42 +00:00
|
|
|
char enginebinary[MAX_PATH];
|
|
|
|
char enginebasedir[MAX_PATH];
|
|
|
|
char enginecommandline[8192];
|
2005-02-28 07:16:19 +00:00
|
|
|
|
2009-06-13 11:57:52 +00:00
|
|
|
int qccpersisthunk = 1;
|
2013-08-11 17:18:44 +00:00
|
|
|
int Grep(char *filename, char *string)
|
|
|
|
{
|
|
|
|
int foundcount = 0;
|
|
|
|
char *last, *found, *linestart;
|
|
|
|
int line = 1;
|
|
|
|
int sz;
|
|
|
|
char *buf;
|
|
|
|
if (!filename)
|
|
|
|
return foundcount;
|
|
|
|
sz = QCC_FileSize(filename);
|
|
|
|
if (sz <= 0)
|
|
|
|
return foundcount;
|
|
|
|
buf = malloc(sz+1);
|
|
|
|
buf[sz] = 0;
|
2014-12-23 15:26:42 +00:00
|
|
|
QCC_ReadFile(filename, buf, sz, NULL);
|
2013-08-11 17:18:44 +00:00
|
|
|
|
|
|
|
linestart = last = found = buf;
|
|
|
|
while ((found = strstr(found, string)))
|
|
|
|
{
|
|
|
|
while (last < found)
|
|
|
|
{
|
|
|
|
if (*last++ == '\n')
|
|
|
|
{
|
|
|
|
line++;
|
|
|
|
linestart = last;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
while (*found && *found != '\n')
|
|
|
|
found++;
|
|
|
|
if (*found)
|
|
|
|
*found++ = '\0';
|
|
|
|
|
|
|
|
GUIprintf("%s:%i: %s\n", filename, line, linestart);
|
|
|
|
line++;
|
|
|
|
linestart = found;
|
|
|
|
foundcount++;
|
|
|
|
}
|
|
|
|
free(buf);
|
|
|
|
|
|
|
|
return foundcount;
|
|
|
|
}
|
2004-08-25 03:42:49 +00:00
|
|
|
void GoToDefinition(char *name)
|
|
|
|
{
|
|
|
|
QCC_def_t *def;
|
|
|
|
QCC_dfunction_t *fnc;
|
|
|
|
|
|
|
|
char *strip; //trim whitespace (for convieniance).
|
|
|
|
while (*name <= ' ' && *name)
|
|
|
|
name++;
|
|
|
|
for (strip = name + strlen(name)-1; *strip; strip++)
|
|
|
|
{
|
|
|
|
if (*strip <= ' ')
|
|
|
|
*strip = '\0';
|
|
|
|
else //got some part of a word
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!globalstable.numbuckets)
|
|
|
|
{
|
2005-02-28 07:16:19 +00:00
|
|
|
GUI_DialogPrint("Not found", "You need to compile first.");
|
2004-08-25 03:42:49 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-10-05 02:55:01 +00:00
|
|
|
def = QCC_PR_GetDef(NULL, name, NULL, false, 0, false);
|
2004-08-25 03:42:49 +00:00
|
|
|
|
|
|
|
if (def)
|
|
|
|
{
|
|
|
|
if (def->type->type == ev_function && def->constant)
|
|
|
|
{
|
|
|
|
fnc = &functions[((int *)qcc_pr_globals)[def->ofs]];
|
2004-11-04 04:19:10 +00:00
|
|
|
if (fnc->first_statement>=0 && fnc->s_file)
|
2004-08-25 03:42:49 +00:00
|
|
|
{
|
2014-04-12 03:31:59 +00:00
|
|
|
EditFile(fnc->s_file+strings, statements[fnc->first_statement].linenum);
|
2004-08-25 03:42:49 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2008-11-09 22:29:28 +00:00
|
|
|
if (!def->s_file)
|
|
|
|
GUI_DialogPrint("Not found", "Global definition of var was not specified.");
|
|
|
|
else
|
|
|
|
EditFile(def->s_file+strings, def->s_line-1);
|
2004-08-25 03:42:49 +00:00
|
|
|
}
|
|
|
|
else
|
2005-02-28 07:16:19 +00:00
|
|
|
GUI_DialogPrint("Not found", "Global instance of var was not found.");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//this function takes the windows specified commandline and strips out all the options menu items.
|
|
|
|
void GUI_ParseCommandLine(char *args)
|
|
|
|
{
|
|
|
|
int paramlen=0;
|
|
|
|
int l, p;
|
|
|
|
char *next;
|
|
|
|
while(*args)
|
|
|
|
{
|
|
|
|
while (*args <= ' ' && *args)
|
|
|
|
args++;
|
|
|
|
|
|
|
|
for (next = args; *next>' '; next++)
|
|
|
|
;
|
|
|
|
|
|
|
|
strncpy(parameters+paramlen, args, next-args);
|
|
|
|
parameters[paramlen+next-args] = '\0';
|
|
|
|
l = strlen(parameters+paramlen)+1;
|
|
|
|
|
|
|
|
if (!strnicmp(parameters+paramlen, "-O", 2) || !strnicmp(parameters+paramlen, "/O", 2))
|
|
|
|
{ //strip out all -O
|
2013-06-23 02:17:02 +00:00
|
|
|
fl_nondfltopts = true;
|
2005-02-28 07:16:19 +00:00
|
|
|
if (parameters[paramlen+2])
|
|
|
|
{
|
|
|
|
if (parameters[paramlen+2] >= '0' && parameters[paramlen+2] <= '3')
|
|
|
|
{
|
|
|
|
p = parameters[paramlen+2]-'0';
|
|
|
|
for (l = 0; optimisations[l].enabled; l++)
|
|
|
|
{
|
|
|
|
if (optimisations[l].optimisationlevel<=p)
|
|
|
|
optimisations[l].flags |= FLAG_SETINGUI;
|
|
|
|
else
|
|
|
|
optimisations[l].flags &= ~FLAG_SETINGUI;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (!strncmp(parameters+paramlen+2, "no-", 3))
|
|
|
|
{
|
|
|
|
if (parameters[paramlen+5])
|
|
|
|
{
|
|
|
|
for (p = 0; optimisations[p].enabled; p++)
|
|
|
|
if ((*optimisations[p].abbrev && !strcmp(parameters+paramlen+5, optimisations[p].abbrev)) || !strcmp(parameters+paramlen+5, optimisations[p].fullname))
|
|
|
|
{
|
|
|
|
optimisations[p].flags &= ~FLAG_SETINGUI;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!optimisations[p].enabled)
|
|
|
|
{
|
|
|
|
parameters[paramlen+next-args] = ' ';
|
|
|
|
paramlen += l;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
for (p = 0; optimisations[p].enabled; p++)
|
|
|
|
if ((*optimisations[p].abbrev && !strcmp(parameters+paramlen+2, optimisations[p].abbrev)) || !strcmp(parameters+paramlen+2, optimisations[p].fullname))
|
|
|
|
{
|
|
|
|
optimisations[p].flags |= FLAG_SETINGUI;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!optimisations[p].enabled)
|
|
|
|
{
|
|
|
|
parameters[paramlen+next-args] = ' ';
|
|
|
|
paramlen += l;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2014-03-01 11:38:53 +00:00
|
|
|
else if (!strnicmp(parameters+paramlen, "-F", 2) || !strnicmp(parameters+paramlen, "/F", 2) || !strnicmp(parameters+paramlen, "-K", 2) || !strnicmp(parameters+paramlen, "/K", 2))
|
|
|
|
{
|
|
|
|
if (parameters[paramlen+2])
|
|
|
|
{
|
|
|
|
if (!strncmp(parameters+paramlen+2, "no-", 3))
|
|
|
|
{
|
|
|
|
if (parameters[paramlen+5])
|
|
|
|
{
|
|
|
|
for (p = 0; compiler_flag[p].enabled; p++)
|
|
|
|
if ((*compiler_flag[p].abbrev && !strcmp(parameters+paramlen+5, compiler_flag[p].abbrev)) || !strcmp(parameters+paramlen+5, compiler_flag[p].fullname))
|
|
|
|
{
|
|
|
|
compiler_flag[p].flags &= ~FLAG_SETINGUI;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!compiler_flag[p].enabled)
|
|
|
|
{
|
|
|
|
parameters[paramlen+next-args] = ' ';
|
|
|
|
paramlen += l;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
for (p = 0; compiler_flag[p].enabled; p++)
|
|
|
|
if ((*compiler_flag[p].abbrev && !strcmp(parameters+paramlen+2, compiler_flag[p].abbrev)) || !strcmp(parameters+paramlen+2, compiler_flag[p].fullname))
|
|
|
|
{
|
|
|
|
compiler_flag[p].flags |= FLAG_SETINGUI;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!compiler_flag[p].enabled)
|
|
|
|
{
|
|
|
|
parameters[paramlen+next-args] = ' ';
|
|
|
|
paramlen += l;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-02-28 07:16:19 +00:00
|
|
|
/*
|
|
|
|
else if (!strnicmp(parameters+paramlen, "-Fno-kce", 8) || !strnicmp(parameters+paramlen, "/Fno-kce", 8)) //keywords stuph
|
|
|
|
{
|
|
|
|
fl_nokeywords_coexist = true;
|
|
|
|
}
|
|
|
|
else if (!strnicmp(parameters+paramlen, "-Fkce", 5) || !strnicmp(parameters+paramlen, "/Fkce", 5))
|
|
|
|
{
|
|
|
|
fl_nokeywords_coexist = false;
|
|
|
|
}
|
|
|
|
else if (!strnicmp(parameters+paramlen, "-Facc", 5) || !strnicmp(parameters+paramlen, "/Facc", 5))
|
|
|
|
{
|
|
|
|
fl_acc = true;
|
|
|
|
}
|
|
|
|
else if (!strnicmp(parameters+paramlen, "-autoproto", 10) || !strnicmp(parameters+paramlen, "/autoproto", 10))
|
|
|
|
{
|
|
|
|
fl_autoprototype = true;
|
|
|
|
}
|
|
|
|
*/
|
|
|
|
else if (!strnicmp(parameters+paramlen, "-showall", 8) || !strnicmp(parameters+paramlen, "/showall", 8))
|
|
|
|
{
|
|
|
|
fl_showall = true;
|
|
|
|
}
|
|
|
|
else if (!strnicmp(parameters+paramlen, "-ah", 3) || !strnicmp(parameters+paramlen, "/ah", 3))
|
|
|
|
{
|
|
|
|
fl_autohighlight = true;
|
|
|
|
}
|
|
|
|
else if (!strnicmp(parameters+paramlen, "-ac", 3) || !strnicmp(parameters+paramlen, "/ac", 3))
|
|
|
|
{
|
|
|
|
fl_compileonstart = true;
|
|
|
|
}
|
2005-03-01 15:36:23 +00:00
|
|
|
else if (!strnicmp(parameters+paramlen, "-log", 4) || !strnicmp(parameters+paramlen, "/log", 4))
|
|
|
|
{
|
|
|
|
fl_log = true;
|
|
|
|
}
|
2014-12-23 15:26:42 +00:00
|
|
|
else if (!strnicmp(parameters+paramlen, "-engine", 7) || !strnicmp(parameters+paramlen, "/engine", 7))
|
|
|
|
{
|
|
|
|
while (*next == ' ')
|
|
|
|
next++;
|
|
|
|
|
|
|
|
l = 0;
|
|
|
|
while (*next != ' ' && *next)
|
|
|
|
enginebinary[l++] = *next++;
|
|
|
|
enginebinary[l] = 0;
|
|
|
|
}
|
|
|
|
else if (!strnicmp(parameters+paramlen, "-basedir", 8) || !strnicmp(parameters+paramlen, "/basedir", 8))
|
|
|
|
{
|
|
|
|
while (*next == ' ')
|
|
|
|
next++;
|
|
|
|
|
|
|
|
l = 0;
|
|
|
|
while (*next != ' ' && *next)
|
|
|
|
enginebasedir[l++] = *next++;
|
|
|
|
enginebasedir[l] = 0;
|
|
|
|
}
|
|
|
|
//strcpy(enginecommandline, "-window +map start -nohome");
|
2006-01-02 23:01:54 +00:00
|
|
|
else if (!strnicmp(parameters+paramlen, "-srcfile", 8) || !strnicmp(parameters+paramlen, "/srcfile", 8))
|
|
|
|
{
|
|
|
|
while (*next == ' ')
|
|
|
|
next++;
|
|
|
|
|
|
|
|
l = 0;
|
|
|
|
while (*next != ' ' && *next)
|
|
|
|
progssrcname[l++] = *next++;
|
|
|
|
progssrcname[l] = 0;
|
|
|
|
}
|
2014-12-23 15:26:42 +00:00
|
|
|
else if (!strnicmp(parameters+paramlen, "-src ", 5) || !strnicmp(parameters+paramlen, "/src ", 5))
|
|
|
|
{
|
|
|
|
while (*next == ' ')
|
|
|
|
next++;
|
|
|
|
|
|
|
|
l = 0;
|
|
|
|
while (*next != ' ' && *next)
|
|
|
|
progssrcdir[l++] = *next++;
|
|
|
|
progssrcdir[l] = 0;
|
|
|
|
}
|
2005-02-28 07:16:19 +00:00
|
|
|
else if (!strnicmp(parameters+paramlen, "-T", 2) || !strnicmp(parameters+paramlen, "/T", 2)) //the target
|
|
|
|
{
|
|
|
|
if (!strnicmp(parameters+paramlen+2, "h2", 2))
|
|
|
|
{
|
|
|
|
fl_hexen2 = true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
fl_hexen2 = false;
|
|
|
|
parameters[paramlen+next-args] = ' ';
|
|
|
|
paramlen += l;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
parameters[paramlen+next-args] = ' ';
|
|
|
|
paramlen += l;
|
|
|
|
}
|
|
|
|
|
|
|
|
args=next;
|
|
|
|
}
|
|
|
|
if (paramlen)
|
|
|
|
parameters[paramlen-1] = '\0';
|
|
|
|
else
|
|
|
|
*parameters = '\0';
|
|
|
|
}
|
|
|
|
|
|
|
|
void GUI_SetDefaultOpts(void)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
for (i = 0; compiler_flag[i].enabled; i++) //enabled is a pointer
|
|
|
|
{
|
|
|
|
if (compiler_flag[i].flags & FLAG_ASDEFAULT)
|
|
|
|
compiler_flag[i].flags |= FLAG_SETINGUI;
|
|
|
|
else
|
|
|
|
compiler_flag[i].flags &= ~FLAG_SETINGUI;
|
|
|
|
}
|
|
|
|
for (i = 0; optimisations[i].enabled; i++) //enabled is a pointer
|
|
|
|
{
|
|
|
|
if (optimisations[i].flags & FLAG_ASDEFAULT)
|
|
|
|
optimisations[i].flags |= FLAG_SETINGUI;
|
|
|
|
else
|
|
|
|
optimisations[i].flags &= ~FLAG_SETINGUI;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void GUI_RevealOptions(void)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
for (i = 0; compiler_flag[i].enabled; i++) //enabled is a pointer
|
|
|
|
{
|
|
|
|
if (fl_showall && compiler_flag[i].flags & FLAG_HIDDENINGUI)
|
|
|
|
compiler_flag[i].flags &= ~FLAG_HIDDENINGUI;
|
|
|
|
}
|
|
|
|
for (i = 0; optimisations[i].enabled; i++) //enabled is a pointer
|
|
|
|
{
|
|
|
|
if (fl_showall && optimisations[i].flags & FLAG_HIDDENINGUI)
|
|
|
|
optimisations[i].flags &= ~FLAG_HIDDENINGUI;
|
|
|
|
|
|
|
|
if (optimisations[i].flags & FLAG_HIDDENINGUI) //hidden optimisations are disabled as default
|
|
|
|
optimisations[i].optimisationlevel = 4;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int GUI_BuildParms(char *args, char **argv)
|
|
|
|
{
|
|
|
|
static char param[2048];
|
|
|
|
int paramlen = 0;
|
|
|
|
int argc;
|
|
|
|
char *next;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
|
|
|
|
argc = 1;
|
|
|
|
argv[0] = "fteqcc";
|
|
|
|
|
|
|
|
while(*args)
|
|
|
|
{
|
|
|
|
while (*args <= ' '&& *args)
|
|
|
|
args++;
|
|
|
|
|
|
|
|
for (next = args; *next>' '; next++)
|
|
|
|
;
|
|
|
|
strncpy(param+paramlen, args, next-args);
|
|
|
|
param[paramlen+next-args] = '\0';
|
|
|
|
argv[argc++] = param+paramlen;
|
|
|
|
paramlen += strlen(param+paramlen)+1;
|
|
|
|
|
|
|
|
args=next;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (fl_hexen2)
|
|
|
|
{
|
|
|
|
strcpy(param+paramlen, "-Th2");
|
|
|
|
argv[argc++] = param+paramlen;
|
|
|
|
paramlen += strlen(param+paramlen)+1;
|
|
|
|
}
|
|
|
|
|
2013-06-23 02:17:02 +00:00
|
|
|
if (fl_nondfltopts)
|
2005-02-28 07:16:19 +00:00
|
|
|
{
|
2013-06-23 02:17:02 +00:00
|
|
|
for (i = 0; optimisations[i].enabled; i++) //enabled is a pointer
|
|
|
|
{
|
|
|
|
if (optimisations[i].flags & FLAG_SETINGUI)
|
|
|
|
sprintf(param+paramlen, "-O%s", optimisations[i].abbrev);
|
|
|
|
else
|
|
|
|
sprintf(param+paramlen, "-Ono-%s", optimisations[i].abbrev);
|
|
|
|
argv[argc++] = param+paramlen;
|
|
|
|
paramlen += strlen(param+paramlen)+1;
|
|
|
|
}
|
2005-02-28 07:16:19 +00:00
|
|
|
}
|
|
|
|
|
2005-03-22 23:47:49 +00:00
|
|
|
for (i = 0; compiler_flag[i].enabled; i++) //enabled is a pointer
|
|
|
|
{
|
|
|
|
if (compiler_flag[i].flags & FLAG_SETINGUI)
|
|
|
|
sprintf(param+paramlen, "-F%s", compiler_flag[i].abbrev);
|
|
|
|
else
|
|
|
|
sprintf(param+paramlen, "-Fno-%s", compiler_flag[i].abbrev);
|
|
|
|
argv[argc++] = param+paramlen;
|
|
|
|
paramlen += strlen(param+paramlen)+1;
|
|
|
|
}
|
|
|
|
|
2005-02-28 07:16:19 +00:00
|
|
|
|
|
|
|
/* while(*args)
|
|
|
|
{
|
|
|
|
while (*args <= ' '&& *args)
|
|
|
|
args++;
|
|
|
|
|
|
|
|
for (next = args; *next>' '; next++)
|
|
|
|
;
|
|
|
|
strncpy(param+paramlen, args, next-args);
|
|
|
|
param[paramlen+next-args] = '\0';
|
|
|
|
argv[argc++] = param+paramlen;
|
|
|
|
paramlen += strlen(param+paramlen)+1;
|
|
|
|
args=next;
|
|
|
|
}*/
|
|
|
|
|
|
|
|
if (*progssrcname)
|
|
|
|
{
|
|
|
|
argv[argc++] = "-srcfile";
|
|
|
|
argv[argc++] = progssrcname;
|
|
|
|
}
|
|
|
|
if (*progssrcdir)
|
|
|
|
{
|
|
|
|
argv[argc++] = "-src";
|
|
|
|
argv[argc++] = progssrcdir;
|
|
|
|
}
|
|
|
|
|
|
|
|
return argc;
|
2004-08-25 03:42:49 +00:00
|
|
|
}
|