Skip to content

Commit

Permalink
Merge pull request #2 from justinfrankel/master
Browse files Browse the repository at this point in the history
update from head
  • Loading branch information
zeppelinux authored Apr 28, 2020
2 parents 54ffa67 + e3c7243 commit 6091fe1
Show file tree
Hide file tree
Showing 20 changed files with 2,190 additions and 1,077 deletions.
4 changes: 2 additions & 2 deletions jmde/fx/reaninjam/Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
OGGDIR = ../../../sdks/libogg-1.2.0
VORBISDIR = ../../../sdks/libvorbis-1.3.1
OGGDIR = ../../../sdks/libogg-1.3.3
VORBISDIR = ../../../sdks/libvorbis-1.3.6

PLUGIN_CFLAGS = -DREANINJAM -DSWELL_PROVIDED_BY_APP -fPIC -I$(OGGDIR)/include -I$(VORBISDIR)/include -Wno-reorder

Expand Down
170 changes: 87 additions & 83 deletions jmde/fx/reaninjam/chat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#endif
#include "winclient.h"
#include "../../../WDL/wdlcstring.h"
#include "../../../WDL/wdlutf8.h"

#include "resource.h"

Expand Down Expand Up @@ -141,10 +142,13 @@ void chat_addline(const char *src, const char *text)
m_append_mutex.Leave();

}
#ifndef _WIN32
WDL_TypedQueue<char> g_chat_textappend;
#endif

void chatRun(HWND hwndDlg)
{
WDL_String tmp;
static WDL_FastString tmp;
m_append_mutex.Enter();
tmp.Set(m_append_text.Get());
m_append_text.Set("");
Expand All @@ -153,102 +157,102 @@ void chatRun(HWND hwndDlg)
if (!tmp.Get()[0]) return;

HWND m_hwnd=GetDlgItem(hwndDlg,IDC_CHATDISP);
const bool is_foc = GetFocus() == m_hwnd;
#ifdef _WIN32
SCROLLINFO si={sizeof(si),SIF_RANGE|SIF_POS|SIF_TRACKPOS,};
GetScrollInfo(m_hwnd,SB_VERT,&si);
if (is_foc) GetScrollInfo(m_hwnd,SB_VERT,&si);
#endif

int oldsel_s=0,oldsel_e=0;
SendMessage(m_hwnd,EM_GETSEL,(WPARAM)&oldsel_s,(LPARAM)&oldsel_e);

#ifdef _WIN32
// always feed in CRLF pairs to the richedit control to make sel positioning predictable (ugh)
{
int oldsels,oldsele;
SendMessage(m_hwnd,EM_GETSEL,(WPARAM)&oldsels,(LPARAM)&oldsele);
char txt[32768];
if(strlen(tmp.Get())>sizeof(txt)-1) return;

GetWindowText(m_hwnd,txt,sizeof(txt)-1);
txt[sizeof(txt)-1]=0;

while(strlen(txt)+strlen(tmp.Get())+4>sizeof(txt))
{
char *p=txt;
while(*p!=0 && *p!='\n') p++;
if(*p==0) return;
while (*p=='\n') p++;
strcpy(txt,p);
oldsels -= p-txt;
oldsele -= p-txt;
}
if (oldsels < 0) oldsels=0;
if (oldsele < 0) oldsele=0;

if(txt[0]) lstrcatn(txt,"\n",sizeof(txt));
lstrcatn(txt,tmp.Get(),sizeof(txt));

CHARFORMAT2 cf2;
cf2.cbSize=sizeof(cf2);
cf2.dwMask=CFM_LINK;
cf2.dwEffects=0;
SendMessage(m_hwnd,EM_SETCHARFORMAT,SCF_ALL,(LPARAM)&cf2);
SetWindowText(m_hwnd,txt);

GetWindowText(m_hwnd,txt,sizeof(txt)-1);
txt[sizeof(txt)-1]=0;

char *t=txt;
char lt=' ';
int sub=0;
while (*t)
for (int x=0;x<tmp.GetLength();x++)
{
if (lt == ' ' || lt == '\n' || lt == '\r')
{
int isurl=0;
if (!strnicmp(t,"http:",5)) isurl=5;
else if (!strnicmp(t,"ftp:",4)) isurl=4;
else if (!strnicmp(t,"www.",4)) isurl=4;
if (tmp.Get()[x] == '\n' && (!x || tmp.Get()[x-1] != '\r'))
tmp.Insert("\r",x++);
}
}
#endif

if (isurl && t[isurl] != ' ' && t[isurl] != '\n' && t[isurl] != '\r' && t[isurl])
{
int spos=t-txt-sub;
t+=isurl;
while (*t && *t != ' ' && *t != '\n' && *t != '\r') { t++; }
SendMessage(m_hwnd,EM_SETSEL,spos,(t-txt)-sub);
CHARFORMAT2 cf2;
cf2.cbSize=sizeof(cf2);
cf2.dwMask=CFM_LINK;
cf2.dwEffects=CFE_LINK;
SendMessage(m_hwnd,EM_SETCHARFORMAT,SCF_SELECTION,(LPARAM)&cf2);
}
}
if (*t == '\n') sub++;
if (*t) lt=*t++;
const int maxlen = 30000;
if (tmp.GetLength() > maxlen - 100) tmp.SetLen(maxlen - 100);
#ifdef _WIN32
int textl = GetWindowTextLengthW(m_hwnd);
#else
int textl = GetWindowTextLength(m_hwnd);
#endif
const int dropb = textl + tmp.GetLength() + 2 - maxlen;
if (dropb > 0)
{
#ifdef _WIN32
WCHAR txt[maxlen + 1024];
GetWindowTextW(m_hwnd,txt,sizeof(txt) / sizeof(WCHAR));
#else
char txt[maxlen + 1024];
GetWindowText(m_hwnd,txt,sizeof(txt));
#endif
int x, cr=0;
for (x = 0; x < dropb && txt[x]; x ++)
{
#ifdef _WIN32
if (txt[x] == '\r') cr++;
#endif
}
SendMessage(m_hwnd,EM_SETSEL,oldsels,oldsele);
for (; txt[x] && txt[x] != '\r' && txt[x] != '\n'; x++);
for (; txt[x] == '\r' || txt[x] == '\n'; x++)
{
#ifdef _WIN32
if (txt[x] == '\r') cr++;
#endif
}

textl -= x;
x -= cr;

#ifndef _WIN32
// selection range is in characters rather than bytes
x = WDL_utf8_bytepos_to_charpos(txt,x);
#endif
// remove x from start
if (oldsel_s >= x && oldsel_e >= x)
{
oldsel_s -= x;
oldsel_e -= x;
}
else
{
oldsel_s = oldsel_e = -1; // hmm not sure if this is best but oh well
}

SendMessage(m_hwnd,EM_SETSEL,0, x);
SendMessage(m_hwnd,EM_REPLACESEL,0, (LPARAM)"");
}

if (GetFocus() == m_hwnd)
if (textl)
{
SendMessage(m_hwnd, WM_VSCROLL, MAKEWPARAM(SB_THUMBPOSITION,si.nTrackPos),0);
#ifdef _WIN32
tmp.Insert("\r\n",0);
#else
tmp.Insert("\n",0);
#endif
}
else

SendMessage(m_hwnd,EM_SETSEL,textl, textl);
SendMessage(m_hwnd,EM_REPLACESEL,0, (LPARAM)tmp.Get());

SendMessage(m_hwnd,EM_SETSEL,oldsel_s,oldsel_e);

#ifdef _WIN32
if (!is_foc)
{
GetScrollInfo(m_hwnd,SB_VERT,&si);
SendMessage(m_hwnd, WM_VSCROLL, MAKEWPARAM(SB_THUMBPOSITION,si.nMax),0);
si.nTrackPos = si.nMax;
}
SendMessage(m_hwnd, WM_VSCROLL, MAKEWPARAM(SB_THUMBPOSITION,si.nTrackPos),0);
#else
static WDL_TypedQueue<char> bla;
int sz=bla.Available();
char *p=bla.Add(tmp.Get(),strlen(tmp.Get())+1);
if (sz) p[-1]='\n';

sz=bla.Available();
if (sz> 4096)
{
bla.Advance(sz-4096);
while (bla.Available() > 0 && bla.Get()[0] != '\n') bla.Advance(1);
bla.Advance(1);
bla.Compact();
}
if (bla.Available() > 0)
SetWindowText(m_hwnd,bla.Get());
else SetWindowText(m_hwnd,"");
SendMessage(m_hwnd,EM_SCROLL,SB_BOTTOM,0);
if (!is_foc) SendMessage(m_hwnd,EM_SCROLL,SB_BOTTOM,0);
#endif
}
54 changes: 32 additions & 22 deletions jmde/fx/reaninjam/locchn.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,17 @@ static WDL_DLGRET LocalChannelItemProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, L
case WM_DESTROY:
delete _this;
return 0;
case WM_NOTIFY:
#ifdef _WIN32
{
extern LRESULT (*handleCheckboxCustomDraw)(HWND, LPARAM, const unsigned short *list, int listsz, bool isdlg);
const unsigned short list[] = { IDC_TRANSMIT };
if (handleCheckboxCustomDraw)
return handleCheckboxCustomDraw(hwndDlg,lParam,list,1,true);
}
#endif
break;

case WM_CTLCOLOREDIT:
case WM_CTLCOLORLISTBOX:
case WM_CTLCOLORBTN:
Expand All @@ -89,7 +100,7 @@ static WDL_DLGRET LocalChannelItemProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, L
if (_this)
{
_this->wndsizer.init(hwndDlg);
_this->wndsizer.init_item(IDC_VU,0.0f,0.0f,1.0f,0.0f);
_this->wndsizer.init_item(IDC_VU,0.0f,0.0f,0.0f,0.0f);
_this->wndsizer.init_item(IDC_VOL,0.0f,0.0f,0.8f,0.0f);
_this->wndsizer.init_item(IDC_PAN,0.8f,0.0f,1.0f,0.0f);
_this->wndsizer.init_item(IDC_MUTE,1.0f,0.0f,1.0f,0.0f);
Expand All @@ -102,12 +113,6 @@ static WDL_DLGRET LocalChannelItemProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, L
int sch;
bool bc;

extern void (*RemoveXPStyle)(HWND hwnd, int rem);
if (RemoveXPStyle)
{
RemoveXPStyle(GetDlgItem(hwndDlg,IDC_TRANSMIT),1);
}

int f=0;
char *buf=g_client->GetLocalChannelInfo(m_idx,&sch,NULL,&bc,NULL,&f);
float vol=0.0,pan=0.0 ;
Expand All @@ -121,6 +126,9 @@ static WDL_DLGRET LocalChannelItemProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, L
SendDlgItemMessage(hwndDlg,IDC_MUTE,BM_SETIMAGE,IMAGE_ICON|0x8000,(LPARAM)GetIconThemePointer(ismute?"track_mute_on":"track_mute_off"));
SendDlgItemMessage(hwndDlg,IDC_SOLO,BM_SETIMAGE,IMAGE_ICON|0x8000,(LPARAM)GetIconThemePointer(issolo?"track_solo_on":"track_solo_off"));

SendDlgItemMessage(hwndDlg,IDC_MUTE,WM_USER+0x300,0xbeef,(LPARAM)"Local channel mute");
SendDlgItemMessage(hwndDlg,IDC_SOLO,WM_USER+0x300,0xbeef,(LPARAM)"Local channel solo");

SendDlgItemMessage(hwndDlg,IDC_ASYNCXMIT,CB_ADDSTRING,0,(LPARAM)"Normal NINJAM");
SendDlgItemMessage(hwndDlg,IDC_ASYNCXMIT,CB_ADDSTRING,0,(LPARAM)"Voice Chat");
SendDlgItemMessage(hwndDlg,IDC_ASYNCXMIT,CB_ADDSTRING,0,(LPARAM)"Session Mode");
Expand All @@ -136,12 +144,14 @@ static WDL_DLGRET LocalChannelItemProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, L
//SendDlgItemMessage(hwndDlg,IDC_VOL,TBM_SETRANGE,FALSE,MAKELONG(0,100));
SendDlgItemMessage(hwndDlg,IDC_VOL,TBM_SETTIC,FALSE,-1);
SendDlgItemMessage(hwndDlg,IDC_VOL,TBM_SETPOS,TRUE,(LPARAM)DB2SLIDER(VAL2DB(vol)));
SendDlgItemMessage(hwndDlg,IDC_VOL,WM_USER+9999,1,(LPARAM)"Local channel volume");

SendDlgItemMessage(hwndDlg,IDC_PAN,TBM_SETRANGE,FALSE,MAKELONG(0,100));
SendDlgItemMessage(hwndDlg,IDC_PAN,TBM_SETTIC,FALSE,50);
int t=(int)(pan*50.0) + 50;
if (t < 0) t=0; else if (t > 100)t=100;
SendDlgItemMessage(hwndDlg,IDC_PAN,TBM_SETPOS,TRUE,t);
SendDlgItemMessage(hwndDlg,IDC_PAN,WM_USER+9999,1,(LPARAM)"Local channel pan");

{
char tmp[512];
Expand Down Expand Up @@ -372,8 +382,9 @@ static WDL_DLGRET LocalChannelItemProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, L
return 0;
case WM_LCUSER_VUUPDATE:
{
int ival=(int) floor(VAL2DB(g_client->GetLocalChannelPeak(m_idx,0))*10.0);
int ival2=(int) floor(VAL2DB(g_client->GetLocalChannelPeak(m_idx,1))*10.0);
float pk1 = g_client->GetLocalChannelPeak(m_idx,0), pk2 = g_client->GetLocalChannelPeak(m_idx,1);
int ival=(int) floor(VAL2DB(pk1)*10.0);
int ival2=(int) floor(VAL2DB(pk2)*10.0);
SendDlgItemMessage(hwndDlg,IDC_VU,WM_USER+1010,ival,ival2);
}
return 0;
Expand Down Expand Up @@ -452,6 +463,8 @@ static WDL_DLGRET LocalChannelListProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, L

SetWindowPos(hwndDlg,0,0,0,w,h,SWP_NOMOVE|SWP_NOZORDER|SWP_NOACTIVATE);
SendMessage(GetParent(hwndDlg),WM_LCUSER_RESIZE,0,uMsg == WM_COMMAND);
if (uMsg == WM_COMMAND)
SetFocus(GetDlgItem(hwnd,IDC_NAME));
}
}
break;
Expand Down Expand Up @@ -527,20 +540,18 @@ static WDL_DLGRET LocalChannelListProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, L
return 0;
}



HWND g_local_channel_wnd;
WDL_DLGRET LocalOuterChannelListProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
static int m_wh, m_ww,m_nScrollPos,m_nScrollPos_w;
static int m_h, m_maxpos_h, m_w,m_maxpos_w;
static HWND m_child;
switch (uMsg)
{

case WM_INITDIALOG:
m_nScrollPos=m_nScrollPos_w=0;
m_maxpos_h=m_h=m_maxpos_w=m_w=0;
m_child=NULL;
g_local_channel_wnd=NULL;
case WM_RCUSER_UPDATE:
case WM_LCUSER_RESIZE:
{
Expand All @@ -553,21 +564,20 @@ WDL_DLGRET LocalOuterChannelListProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPA

SetWindowPos(hwndDlg,NULL,r.left,r.top,m_ww,m_wh,SWP_NOZORDER|SWP_NOACTIVATE);

m_wh -= GetSystemMetrics(SM_CYHSCROLL);

if (uMsg == WM_INITDIALOG)
{
InitializeCoolSB(hwndDlg);
m_child=CreateDialog(g_hInst,MAKEINTRESOURCE(IDD_LOCALLIST),hwndDlg,LocalChannelListProc);
ShowWindow(m_child,SW_SHOWNA);
g_local_channel_wnd=CreateDialog(g_hInst,MAKEINTRESOURCE(IDD_LOCALLIST),hwndDlg,LocalChannelListProc);
ShowWindow(g_local_channel_wnd,SW_SHOWNA);
ShowWindow(hwndDlg,SW_SHOWNA);
}
}

{
SendMessage(m_child,WM_RCUSER_UPDATE,0,0);
SendMessage(g_local_channel_wnd,WM_RCUSER_UPDATE,0,0);
RECT r;
GetWindowRect(m_child,&r);
GetWindowRect(g_local_channel_wnd,&r);
if (r.bottom < r.top) SWAP(r.bottom,r.top,int);
m_h=r.bottom-r.top;
m_w=r.right-r.left;
Expand Down Expand Up @@ -614,9 +624,9 @@ WDL_DLGRET LocalOuterChannelListProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPA
}
{
RECT r,r2;
GetClientRect(m_child,&r);
GetClientRect(g_local_channel_wnd,&r);
GetClientRect(hwndDlg,&r2);
SetWindowPos(m_child,0,0,0,r2.right,r.bottom,SWP_NOMOVE|SWP_NOZORDER|SWP_NOACTIVATE);
SetWindowPos(g_local_channel_wnd,0,0,0,r2.right,r.bottom,SWP_NOMOVE|SWP_NOZORDER|SWP_NOACTIVATE);
}
if (uMsg == WM_LCUSER_RESIZE && lParam == 1)
{
Expand All @@ -640,7 +650,7 @@ WDL_DLGRET LocalOuterChannelListProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPA
case WM_LCUSER_REPOP_CH:
case WM_LCUSER_ADDCHILD:
case WM_LCUSER_VUUPDATE:
SendMessage(m_child,uMsg,wParam,lParam);
SendMessage(g_local_channel_wnd,uMsg,wParam,lParam);
break;
case WM_VSCROLL:
{
Expand Down Expand Up @@ -732,7 +742,7 @@ WDL_DLGRET LocalOuterChannelListProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPA
case WM_DRAWITEM:
return SendMessage(GetMainHwnd(),uMsg,wParam,lParam);;
case WM_DESTROY:
m_child=NULL;
g_local_channel_wnd=NULL;
UninitializeCoolSB(hwndDlg);
return 0;
}
Expand Down
Loading

0 comments on commit 6091fe1

Please sign in to comment.