Added console-links support.

Shift click IPs/words/links on the console to enter them as arguments.
Fixed some utf-8 issues.
Fixed issue with csaddon.dat not loading in release builds.
Fixed berkelium inputs, should have a full range of keys now, though there's still no 'back' support.
Bad name rejection made more paranoid.

git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4124 fc73d0e0-1445-4013-8a0c-d673dee63da5
This commit is contained in:
Spoike 2012-10-13 00:56:31 +00:00
parent fc2ab857f5
commit 5d9ba4b548
20 changed files with 866 additions and 179 deletions

View file

@ -23,40 +23,105 @@ class MyDelegate : public Berkelium::WindowDelegate
private:
decctx *ctx;
virtual void onCrashedWorker(Berkelium::Window *win)
{
int i;
Con_Printf("Berkelium worker crashed\n");
/*black it out*/
for (i = 0; i < ctx->width*ctx->height; i++)
{
ctx->buffer[i] = 0xff000000;
}
ctx->repainted = true;
}
virtual void onCrashed(Berkelium::Window *win)
{
int i;
Con_Printf("Berkelium window crashed\n");
/*black it out*/
for (i = 0; i < ctx->width*ctx->height; i++)
{
ctx->buffer[i] = 0xff000000;
}
ctx->repainted = true;
}
virtual void onUnresponsive(Berkelium::Window *win)
{
Con_Printf("Berkelium window unresponsive\n");
}
virtual void onResponsive(Berkelium::Window *win)
{
Con_Printf("Berkelium window responsive again, yay\n");
}
virtual void onPaint(Berkelium::Window *wini, const unsigned char *bitmap_in, const Berkelium::Rect &bitmap_rect, size_t num_copy_rects, const Berkelium::Rect *copy_rects, int dx, int dy, const Berkelium::Rect& scroll_rect)
{
int i;
// handle paint events...
if (dx || dy)
{
int y;
int t = scroll_rect.top();
int l = scroll_rect.left();
int y, m;
int dt = scroll_rect.top();
int dl = scroll_rect.left();
int w = scroll_rect.width();
int h = scroll_rect.height();
if (dy > 0)
{
//if we're moving downwards, we need to write the bottom before the top (so we don't overwrite the data before its copied)
for (y = t+h-1; y >= t; y--)
{
if (y < 0 || y >= ctx->height)
continue;
if (y+dy < 0 || y+dy >= ctx->height)
continue;
memmove(ctx->buffer + ((l+dx) + (y+dy)*ctx->width), ctx->buffer + (l + y*ctx->width), w*4);
}
}
else
{
//moving upwards requires we write the top row first
for (y = t; y < t+h; y++)
{
if (y < 0 || y >= ctx->height)
continue;
if (y+dy < 0 || y+dy >= ctx->height)
continue;
int st = dt - dy;
int sl = dl - dx;
memmove(ctx->buffer + ((l+dx) + (y+dy)*ctx->width), ctx->buffer + (l + y*ctx->width), w*4);
/*bound the output rect*/
if (dt < 0)
{
st -= dt;
h += dt;
dt = 0;
}
if (dl < 0)
{
sl -= dl;
w += dl;
dl = 0;
}
/*bound the source rect*/
if (st < 0)
{
dt -= st;
h += st;
st = 0;
}
if (sl < 0)
{
dl -= sl;
w += sl;
sl = 0;
}
/*bound the width*/
m = (dl>sl)?dl:sl;
if (m + w > ctx->width)
w = ctx->width - m;
m = (dt>st)?dt:st;
if (m + h > ctx->height)
h = ctx->height - m;
if (w > 0 && h > 0)
{
if (dy > 0)
{
//if we're moving downwards, we need to write the bottom before the top (so we don't overwrite the data before its copied)
for (y = h; y >= 0; y--)
{
memmove(ctx->buffer + (dl + (dt+y)*ctx->width), ctx->buffer + (sl + (st+y)*ctx->width), w*4);
}
}
else
{
//moving upwards requires we write the top row first
for (y = 0; y < h; y++)
{
memmove(ctx->buffer + (dl + (dt+y)*ctx->width), ctx->buffer + (sl + (st+y)*ctx->width), w*4);
}
}
}
}
@ -65,22 +130,37 @@ private:
unsigned int *out = ctx->buffer;
const unsigned int *in = (const unsigned int*)bitmap_in;
int x, y;
int t = copy_rects[i].top() - bitmap_rect.top();
int l = copy_rects[i].left() - bitmap_rect.left();
int t = copy_rects[i].top();
int l = copy_rects[i].left();
int r = copy_rects[i].width() + l;
int b = copy_rects[i].height() + t;
unsigned int instride = bitmap_rect.width() - (r - l);
unsigned int outstride = ctx->width - (r - l);
int w, h;
out += copy_rects[i].left();
out += copy_rects[i].top() * ctx->width;
//Clip the rect to the display. This should generally happen anyway, but resizes can be lagged a bit with the whole multi-process/thread thing.
//don't need to clip to the bitmap rect, that should be correct.
if (l < 0)
l = 0;
if (t < 0)
t = 0;
if (r > ctx->width)
r = ctx->width;
if (b > ctx->height)
b = ctx->height;
w = r - l;
h = b - t;
in += l;
in += t * bitmap_rect.width();
unsigned int instride = bitmap_rect.width() - (w);
unsigned int outstride = ctx->width - (w);
for (y = t; y < b; y++)
out += l;
out += t * ctx->width;
in += (l-bitmap_rect.left());
in += (t-bitmap_rect.top()) * bitmap_rect.width();
for (y = 0; y < h; y++)
{
for (x = l; x < r; x++)
for (x = 0; x < w; x++)
{
*out++ = *in++;
}
@ -182,16 +262,47 @@ static void Dec_Key (void *vctx, int code, int unicode, int isup)
wchar_t wchr = unicode;
if (code >= 178 && code < 178+6)
ctx->wnd->mouseButton(code - 178, !isup);
{
code = code - 178;
//swap mouse2+3
if (code == 1)
code = 2;
else if (code == 2)
code = 1;
ctx->wnd->mouseButton(code, !isup);
}
else if (code == 188 || code == 189)
ctx->wnd->mouseWheel(0, (code==189)?-30:30);
{
if (!isup)
ctx->wnd->mouseWheel(0, (code==189)?-30:30);
}
else
{
if (code)
{
int mods = 0;
if (code == 127)
code = 0x08;
else if (code == 140) //del
code = 0x2e;
else if (code == 143) //home
code = 0x24;
else if (code == 144) //end
code = 0x23;
else if (code == 141) //pgdn
code = 0x22;
else if (code == 142) //pgup
code = 0x21;
else if (code == 139) //ins
code = 0x2d;
else if (code == 132) //up
code = 0x26;
else if (code == 133) //down
code = 0x28;
else if (code == 134) //left
code = 0x25;
else if (code == 135) //right
code = 0x27;
ctx->wnd->keyEvent(!isup, mods, code, 0);
}
if (unicode && !isup)
@ -214,6 +325,10 @@ static void Dec_ChangeStream(void *vctx, char *newstream)
ctx->wnd->refresh();
else if (!strcmp(newstream+4, "transparent"))
ctx->wnd->setTransparent(true);
else if (!strcmp(newstream+4, "focus"))
ctx->wnd->focus();
else if (!strcmp(newstream+4, "unfocus"))
ctx->wnd->unfocus();
else if (!strcmp(newstream+4, "opaque"))
ctx->wnd->setTransparent(true);
else if (!strcmp(newstream+4, "stop"))