bool GetWorkAreaFromPPCShell(LPRECT prect, SIPINFO *pssi) { PFNSHSipInfo pfnSHSipInfo; HMODULE hMod; // if (IsAPIReady(SH_SHELL,0))//WAIT_OBJECT_0 != WaitForAPIReady(SH_SHELL, 0)) // return false; hMod = GetModuleHandle(TEXT("aygshell.dll")); if (!hMod) return false; pfnSHSipInfo = (PFNSHSipInfo) GetProcAddress(hMod, TEXT("SHSipInfo")); if (!pfnSHSipInfo) return false; if ((*pfnSHSipInfo)(SPI_GETSIPINFO, 0, (PVOID) pssi, 0)) { murmur("GetWorkAreaFromPPCShell() rcVisibleDesktop = (%d, %d - %d, %d)\n", pssi->rcVisibleDesktop.left, pssi->rcVisibleDesktop.top, pssi->rcVisibleDesktop.right, pssi->rcVisibleDesktop.bottom); murmur("GetWorkAreaFromPPCShell() fdwFlags & SIPF_ON = %d\n", pssi->fdwFlags & SIPF_ON); if(!(pssi->fdwFlags & SIPF_ON)) pssi->rcVisibleDesktop.bottom-= pssi->rcVisibleDesktop.top; *prect = pssi->rcVisibleDesktop; return true; } return false; }
unsigned hash_value(value_t *v) { switch (v->type) { case SU_NIL: return (unsigned)SU_NIL; case SU_BOOLEAN: return (unsigned)v->obj.b + (unsigned)SU_BOOLEAN; case SU_NUMBER: return murmur(&v->obj.num, sizeof(double), (unsigned)SU_NUMBER); case SU_STRING: return v->obj.str->hash; default: return murmur(&v->obj.ptr, sizeof(void*), (unsigned)v->type); } }
void UIShowCandWindow() { murmur("UIShowCandWindow"); if (IsWindow(uiCand.hWnd)) { _ShowCandiPage(); } }
gc_t *string_from_cache(su_state *s, const char *str, unsigned size) { value_t v; string_cache_t entry; string_cache_t *entries; unsigned hash = murmur(str, size, 0); unsigned index = (unsigned)bit_count((int)hash) - 8; int i; if (index < 16) { entries = s->string_cache[index]; for (i = 0; i < STRING_CACHE_SIZE; i++) { if (entries[i].hash == hash && !memcmp(entries[i].str->str, str, size)) return &entries[i].str->gc; } } v.type = SU_STRING; v.obj.ptr = su_allocate(s, NULL, sizeof(string_t) + size); v.obj.str->size = size; memcpy(v.obj.str->str, str, size); v.obj.str->str[size] = '\0'; v.obj.str->hash = hash; if (index < 16) { entry.hash = hash; entry.str = v.obj.str; entries[s->string_cache_head[index]] = entry; s->string_cache_head[index] = (s->string_cache_head[index] + 1) % STRING_CACHE_SIZE; } gc_insert_object(s, v.obj.gc_object, SU_STRING); return v.obj.gc_object; }
void UIHideCandWindow() { murmur("UIHideCandWindow"); if (IsWindow(uiCand.hWnd)) { _HideCandiPage(); } }
int su_getglobal(su_state *s, const char *name) { int size = strlen(name); value_t v = get_global(s, name, murmur(name, size, 0), size); if (v.type == SU_INV) return 0; push_value(s, &v); return 1; }
//set Status window module list void UISetStatusModStrMenuAll(int modAmount, const char* modNames[]) { UIClearStatusMenuModString(); for(int i = 0; i < modAmount; i++){ murmur("\t set module %i name:%s",i , modNames[i]); UISetStatusModStrMenuEach(modNames[i]); } }
//static bool m_docked=true; void UIShowStatusWindow() { if (IsWindow(uiStatus.hWnd)) { murmur("\tShow status window. isDocked:%d", UIGetIsStatusDocked()); if(UIGetIsStatusDocked()) { murmur("\tAdd deskband..."); UIShowDeskBand(true);// bandadded=true; } else murmur("\tStatus is not doced"); _ShowStatusPage(); //show } }
void su_string_push(su_state *s) { value_t v; assert(s->string_builder); v.type = SU_STRING; s->string_builder->hash = murmur(s->string_builder->str, s->string_builder->size, 0); v.obj.gc_object = string_build_from_cache(s); push_value(s, &v); s->string_builder = NULL; }
OVBuffer* AVBuffer::update(int cursorPos, int markFrom=-1, int markTo=-1) { murmur("OVBuffer* AVBuffer::update(cursorPos=%d, markFrom=%d, markTo=%d ",cursorPos,markFrom,markTo); dsvr->setBufString(bufstr.c_str(),cursorPos,markFrom,markTo); dsvr->setMarkFrom(markFrom); dsvr->setMarkTo(markTo); //dsvr->showBuf(true); return this; }
// // AdjustCandWnd() // void AdjustCandWnd(HWND hCandWnd, LPUIPRIV lpUIPriv, LPINPUTCONTEXT lpIMC) { //LPUIPRIV lpUIPriv; POINT ptNew; GetWorkArea(&g_sImeUIG.rcWorkArea); if (GetCaretPos(&ptNew)){ ClientToScreen(lpIMC->hWnd, &ptNew); murmur("AdjustCandWnd() ptNew.x = %d, ptNew.y = %d, rcWorkArea.bottom = %d, nCandHi=%d\n", ptNew.x, ptNew.y, g_sImeUIG.rcWorkArea.bottom, lpUIPriv->nCandHi); if( ( g_sImeUIG.rcWorkArea.bottom - ptNew.y < 2*lpUIPriv->nCandHi ) && ( g_sImeUIG.rcWorkArea.bottom - ptNew.y >0 ) && ptNew.y < g_sImeUIG.rcWorkArea.bottom ){ ptNew.y -= lpUIPriv->nCandHi; } else ptNew.y = g_sImeUIG.rcWorkArea.bottom - lpUIPriv->nCandHi; } else ptNew.y = g_sImeUIG.rcWorkArea.bottom - lpUIPriv->nCandHi; ptNew.x = 0; murmur("AdjustCandWnd() ptNew.x = %d, ptNew.y = %d\n", ptNew.x, ptNew.y); InvalidateRect(hCandWnd, NULL, FALSE); lpUIPriv->rcCandText.right = g_sImeUIG.rcWorkArea.right -g_sImeUIG.nCandCharWi *2; if (ptNew.x != lpUIPriv->ptCand.x || ptNew.y != lpUIPriv->ptCand.y || g_sImeUIG.rcWorkArea.right != lpUIPriv->nCandWi ) { lpUIPriv->ptCand = ptNew; lpUIPriv->nCandWi = g_sImeUIG.rcWorkArea.right; SetWindowPos(hCandWnd, NULL, ptNew.x, ptNew.y, g_sImeUIG.rcWorkArea.right, g_sImeUIG.nCandLineHi, SWP_NOACTIVATE|SWP_NOZORDER); } return; }
void UIHideStatusWindow() { if (IsWindow(uiStatus.hWnd)) { murmur("\tHide status window..."); //ShowWindow(uiStatus.hWnd, SW_HIDE); if(UIGetIsStatusDocked()) { murmur("\tRemove deskband..."); UIShowDeskBand(false);// bandadded = false; } _HideStatusPage(); } }
OVBuffer* AVBuffer::send() { vector<OVOutputFilter*>::iterator of; for(of = ovof_vector->begin(); of != ovof_vector->end(); of++) { if(!strcmp((*of)->identifier(), "OVOFFullWidthCharacter")){ murmur("Fullshape output filter"); if(dsvr->getisFullShapeFlag() ) bufstr = (*of)->process(bufstr.c_str(), srv); } else if (dsvr->getisChineseFlag()&& strcmp(bufstr.c_str()," ") ) { murmur("Pass filter %s", (*of)->identifier()); bufstr = (*of)->process(bufstr.c_str(), srv); } } dsvr->sendBuf(bufstr.c_str()); clear(); //dsvr->showBuf(false); return this; }
void GetWorkArea(LPRECT lprcWorkArea) { SIPINFO sSipInfo; memset(&sSipInfo, 0, sizeof(SIPINFO)); sSipInfo.cbSize = sizeof(SIPINFO); sSipInfo.dwImDataSize = 0; sSipInfo.pvImData = NULL; if (!GetWorkAreaFromPPCShell(lprcWorkArea, &sSipInfo)) { if (SipGetInfo(&sSipInfo)) { *lprcWorkArea = sSipInfo.rcVisibleDesktop; } else { SystemParametersInfo(SPI_GETWORKAREA, 0, lprcWorkArea, 0); } } murmur("rcWorkArea.top=%d; psi->rcWorkArea.bottom=%d\n",lprcWorkArea->top, lprcWorkArea->bottom); murmur("rcWorkArea.right=%d; psi->rcWorkArea.left=%d\n",lprcWorkArea->right, lprcWorkArea->left); }
void UISetMarkFrom(int i) { // murmur("-----> UISetMarkFrom, status window"); CompSelStart = i; murmur( "---> UISetMarkFrom Start %d", CompSelStart); /* HDC tmpdc = GetDC(NULL); TCHAR debug_info[100]; _stprintf(debug_info, _T("mf=%d"), i); TextOut( tmpdc, 0, 0, debug_info, lstrlen(debug_info)); ReleaseDC( NULL, tmpdc ); */ }
void UISetMarkTo(int i) { // murmur("-----> UISetMarkTo, status window"); /* HDC tmpdc = GetDC(NULL); TCHAR debug_info[100]; _stprintf(debug_info, _T("mt=%d"), i); TextOut( tmpdc, 40, 0, debug_info, lstrlen(debug_info)); ReleaseDC( NULL, tmpdc ); */ CompSelEnd = i; murmur( "---> UISetMarkFrom End %d", CompSelEnd); }
util_frames_t util_frames_outbox(util_frames_t frames, uint8_t *data, uint8_t *meta) { if(!frames) return LOG("bad args"); if(frames->err) return LOG("frame state error"); if(!data) return util_frames_ready(frames); // just a ready check uint8_t size = PAYLOAD(frames); uint8_t *out = lob_raw(frames->outbox); uint32_t len = lob_len(frames->outbox); // clear/init uint32_t hash = frames->outbase; // first get the last sent hash if(len) { // safely only hash the packet size correctly uint32_t at, i; for(i = at = 0;at < len && i < frames->out;i++,at += size) { hash ^= murmur4((out+at), ((at - len) < size) ? (at - len) : size); hash += i; } } // if flushing, or nothing to send, just send meta frame w/ hashes if(frames->flush || !len || (frames->out * size) > len) { memset(data,0,size+4); memcpy(data,&(frames->inlast),4); memcpy(data+4,&(hash),4); if(meta) memcpy(data+10,meta,size-10); murmur(data,size,data+size); // LOG("sending meta frame inlast %lu cur %lu",frames->inlast,hash); return frames; } // send next frame memset(data,0,size+4); uint32_t at = frames->out * size; if((at + size) > len) { size = len - at; data[PAYLOAD(frames)-1] = size; } memcpy(data,out+at,size); hash ^= murmur4(data,size); hash += frames->out; memcpy(data+PAYLOAD(frames),&(hash),4); LOG("sending data frame %u %lu",frames->out,hash); return frames; }
int UIGetStatusPos(LPPOINT lp_pt) { if (IsWindow(uiStatus.hWnd)) { LPRECT lp_rect; lp_rect = new RECT; GetWindowRect(uiStatus.hWnd,lp_rect); lp_pt->x = lp_rect->left; lp_pt->y = lp_rect->top; murmur("status window at (%i, %i).", lp_pt->x, lp_pt->y); return 1; } else return -1; }
void UICreateStatusWindow(HWND hUIWnd, int xPos, int yPos) { murmur("\tUICreateStatusWindow, hUIWnd=%x, %i, %i",hUIWnd, xPos, yPos); RECT rec; if (!IsWindow(uiStatus.hWnd)) { uiStatus.hWnd = _CreateStatusPage(); //設定C# Status 內 m_AppHWnd _SetStatusAppHWnd(hUIWnd); //設定 module menu (init: current module) SendMessage(hUIWnd, WM_IME_NOTIFY, IMN_PRIVATE, 9); // set all module names. //SendMessage(hUIWnd, WM_IME_NOTIFY, IMN_PRIVATE, 3); //UISetStatusModStr(); //設定中英 //_SetStatusChiEng(); //設定繁簡 _SetStatusSimpifiedOrTraditional(isTraditional); //設定 hIMEWnd (?) hIMEWnd = hUIWnd; //存到 hIMEWnd 之後會拿來判斷 //移動到螢幕右下方 if((xPos==0)||(yPos==0)) { SystemParametersInfo(SPI_GETWORKAREA, 0, &rec, 0); UIMoveStatusWindow(hUIWnd, rec.right - 200, rec.bottom - 50); } else UIMoveStatusWindow(hUIWnd, xPos, yPos); } //設定C# Status 內 m_AppHWnd _SetStatusAppHWnd(hUIWnd); }
int OVCINList::load(const char *loadpath, const char *extension) { int loaded=0; BOOL fFinished; HANDLE hList; WIN32_FIND_DATA FileData; string pathString(loadpath); pathString += "\\*"; pathString += extension; const char* findpath = pathString.c_str(); hList = FindFirstFile(findpath, &FileData); if(hList == INVALID_HANDLE_VALUE) { murmur("No files found in %s\n", pathString.c_str()); } else { fFinished = FALSE; while (!fFinished) { if(strstr(FileData.cFileName, extension)) { if (preparse(loadpath, FileData.cFileName)) loaded++; } if (!FindNextFile(hList, &FileData)) { if (GetLastError() == ERROR_NO_MORE_FILES) { fFinished = TRUE; } } } } FindClose(hList); return loaded; // murmur("OVCINList::load called, index=%d", index); }
static const char* nick_color(const char *nick) { return nick_colors[murmur(nick, strlen(nick)) % (sizeof(nick_colors) / sizeof(*nick_colors))]; }
void clubmaster_driver(int cn,int ret,int lastact) { struct clubmaster_driver_data *dat; int co,in,n,rank,cc,val; struct msg *msg,*next; char *ptr,tmp[80],name[80]; dat=set_data(cn,DRD_CLUBMASTERDRIVER,sizeof(struct clubmaster_driver_data)); if (!dat) return; // oops... if (ch[cn].arg) { clubmaster_driver_parse(cn,dat); ch[cn].arg=NULL; } // loop through our messages for (msg=ch[cn].msg; msg; msg=next) { next=msg->next; // did we see someone? if (msg->type==NT_CHAR) { co=msg->dat1; // dont talk to someone we cant see, and dont talk to ourself if (!char_see_char(cn,co) || cn==co) { remove_message(cn,msg); continue; } // dont talk to someone far away if (char_dist(cn,co)>10) { remove_message(cn,msg); continue; } // dont talk to the same person twice if (mem_check_driver(cn,co,7)) { remove_message(cn,msg); continue; } if (!get_char_club(cn) && !get_char_clan(cn)) quiet_say(cn,"Hello %s! Would you like to found a °c4club°c0?",ch[co].name); mem_add_driver(cn,co,7); } // talk back if (msg->type==NT_TEXT) { analyse_text_driver(cn,msg->dat1,(char*)msg->dat2,msg->dat3); if ((msg->dat1==1 || msg->dat1==2) && (co=msg->dat3)!=cn) { // talk, and not our talk if ((ptr=strcasestr((char*)msg->dat2,"found:"))) { if (!(ch[co].flags&CF_PAID)) { quiet_say(cn,"I'm sorry, %s, but only paying players may found clubs.",ch[co].name); } else if (!get_char_clan(co) && !get_char_club(co)) { if (ch[co].gold>=10000*100) { ptr+=6; while (isspace(*ptr)) ptr++; for (n=0; n<79; n++) { if (!(isalpha(*ptr) || *ptr==' ')) break; name[n]=*ptr++; } name[n]=0; if ((n=create_club(name))) { take_money(co,10000*100); ch[co].clan=n+CLUBOFFSET; ch[co].clan_serial=club[n].serial; ch[co].clan_rank=2; quiet_say(cn,"Congratulations, %s, you are now the leader of the club %s.",ch[co].name,club[n].name); dlog(co,0,"created club %d %s",n,club[n].name); } else quiet_say(cn,"Something's wrong with the name."); } else quiet_say(cn,"You cannot pay the fee of 10,000 gold."); } else quiet_say(cn,"You are already a member of a clan or club. You cannot found a new one."); } if ((ptr=strcasestr((char*)msg->dat2,"accept:"))) { if (!get_char_club(co) || ch[co].clan_rank<1) { quiet_say(cn,"You are not a club leader, %s.",ch[co].name); } else { ptr+=7; while (isspace(*ptr)) ptr++; for (n=0; n<79; n++) { if (!*ptr || *ptr=='"') break; dat->accept[n]=*ptr++; } dat->accept[n]=0; strcpy(dat->join,ch[co].name); dat->accept_clan=get_char_club(co); dat->accept_cn=co; quiet_say(cn,"To join %s's club %s, say: 'join: %s'",dat->join,dat->accept,dat->join); } } if ((ptr=strcasestr((char*)msg->dat2,"join:"))) { if (get_char_clan(co) || get_char_club(co)) { quiet_say(cn,"You are already a clan or club member, %s.",ch[co].name); } else { ptr+=5; while (isspace(*ptr)) ptr++; for (n=0; n<79; n++) { if (!*ptr || *ptr=='"') break; tmp[n]=*ptr++; } tmp[n]=0; if (strcasecmp(dat->accept,ch[co].name)) { quiet_say(cn,"You have not been invited, %s.",ch[co].name); } else if (strcasecmp(dat->join,tmp)) { quiet_say(cn,"%s has not invited you, %s.",tmp,ch[co].name); } else { //add_member(co,dat->accept_clan,dat->join); ch[co].clan=dat->accept_clan+CLUBOFFSET; ch[co].clan_serial=club[dat->accept_clan].serial; ch[co].clan_rank=0; quiet_say(cn,"%s, you are now a member of %s's club.",ch[co].name,dat->join); dat->accept[0]=0; dat->accept_clan=0; dat->join[0]=0; } } } if ((ptr=strcasestr((char*)msg->dat2,"leave!"))) { if (!get_char_club(co)) { quiet_say(cn,"You are not a club member, %s.",ch[co].name); } else { remove_member(co,co); quiet_say(cn,"You are no longer a member of any club, %s",ch[co].name); } } if ((ptr=strcasestr((char*)msg->dat2,"rank:"))) { if (!get_char_club(co) || ch[co].clan_rank<2) { quiet_say(cn,"You are not a club founder, %s.",ch[co].name); } else { ptr+=6; while (isspace(*ptr)) ptr++; for (n=0; n<79; n++) { if (!*ptr || *ptr=='"' || isspace(*ptr)) break; tmp[n]=*ptr++; } tmp[n]=0; rank=atoi(ptr); if (rank<0 || rank>1) { quiet_say(cn,"You must use a rank between 0 and 1."); remove_message(cn,msg); continue; } for (cc=getfirst_char(); cc; cc=getnext_char(cc)) { if (!strcasecmp(tmp,ch[cc].name) && (ch[cc].flags&CF_PLAYER)) break; } if (cc) { if (!(ch[cc].flags&CF_PAID) && rank>0) { quiet_say(cn,"%s is not a paying player, you cannot set the rank higher than 0.",ch[cc].name); } else if (ch[cc].clan_rank==2) { quiet_say(cn,"%s is the club's founder, cannot change rank.",ch[cc].name); } else if (get_char_club(cc)==get_char_club(co)) { ch[cc].clan_rank=rank; quiet_say(cn,"Set %s's rank to %d.",ch[cc].name,rank); } else quiet_say(cn,"You cannot change the rank of those not belonging to your club."); } else { int uID; uID=lookup_name(tmp,NULL); if (uID==0) continue; if (uID==-1) { quiet_say(cn,"Sorry, no player by the name %s found.",tmp); } else { task_set_clan_rank(uID,ch[co].ID,get_char_club(co)+CLUBOFFSET,rank,ch[co].name); quiet_say(cn,"Update scheduled (%s,%d).",tmp,rank); } } } } if ((ptr=strcasestr((char*)msg->dat2,"fire:"))) { if (!get_char_club(co) || ch[co].clan_rank<1) { quiet_say(cn,"You are not a club leader, %s.",ch[co].name); } else { ptr+=6; while (isspace(*ptr)) ptr++; for (n=0; n<79; n++) { if (!*ptr || *ptr=='"' || isspace(*ptr)) break; tmp[n]=*ptr++; } tmp[n]=0; for (cc=getfirst_char(); cc; cc=getnext_char(cc)) { if (!strcasecmp(tmp,ch[cc].name) && (ch[cc].flags&CF_PLAYER)) break; } if (cc) { if (get_char_club(cc)==get_char_club(co)) { if (ch[cc].clan_rank<2) { remove_member(cc,co); quiet_say(cn,"Fired: %s.",ch[cc].name); } else quiet_say(cn,"You cannot fire the founder of the club."); } else quiet_say(cn,"You cannot fire those not belonging to your club."); } else { int uID; uID=lookup_name(tmp,NULL); if (uID==0) continue; if (uID==-1) { quiet_say(cn,"Sorry, no player by the name %s found.",tmp); } else { task_fire_from_clan(uID,ch[co].ID,get_char_club(co)+CLUBOFFSET,ch[co].name); quiet_say(cn,"Update scheduled (%s).",tmp); } } } } if ((ptr=strcasestr((char*)msg->dat2,"deposit:"))) { if (!(n=get_char_club(co))) { quiet_say(cn,"You are not a club member, %s.",ch[co].name); } else { val=atoi(ptr+8)*100; if (val>0 && ch[co].gold>=val) { club[n].money+=val; take_money(co,val); quiet_say(cn,"You have deposited %dG, for a total of %dG, %s.",val/100,club[n].money/100,ch[co].name); dlog(co,0,"Deposited %dG into club %d, for a new total of %dG",val/100,n,club[n].money/100); db_update_club(n); } else quiet_say(cn,"You do not have that much gold, %s.",ch[co].name); } } if ((ptr=strcasestr((char*)msg->dat2,"withdraw:"))) { if (!(n=get_char_club(co)) || ch[co].clan_rank<2) { quiet_say(cn,"You are not a club founder, %s.",ch[co].name); } else { val=atoi(ptr+9)*100; if (val>0 && club[n].money>=val) { club[n].money-=val; give_money(co,val,"club withdrawal"); quiet_say(cn,"You have withdrawn %dG, money left in club %dG, %s.",val/100,club[n].money/100,ch[co].name); dlog(co,0,"Withdrew %dG from club %d, for a new total of %dG",val/100,n,club[n].money/100); db_update_club(n); } else quiet_say(cn,"The club does not have that much gold, %s.",ch[co].name); } } } } // got an item? if (msg->type==NT_GIVE) { co=msg->dat1; if ((in=ch[cn].citem)) { // we still have it // try to give it back if (give_char_item(cn,co)) return; // didnt work, let it vanish, then destroy_item(ch[cn].citem); ch[cn].citem=0; } } remove_message(cn,msg); } // do something. whenever possible, call do_idle with as high a tick count // as reasonable when doing nothing. if (secure_move_driver(cn,ch[cn].tmpx,ch[cn].tmpy,dat->dir,ret,lastact)) return; if (ticker>dat->last_talk+TICKS*60 && !RANDOM(25)) { switch(RANDOM(8)) { case 0: murmur(cn,"My back itches."); break; case 1: whisper(cn,"There's something stuck between your teeth."); break; case 2: murmur(cn,"Oh yeah, those were the days."); break; case 3: murmur(cn,"Now where did I put it?"); break; case 4: murmur(cn,"Oh my, life is hard but unfair."); break; case 5: murmur(cn,"Beware of the fire snails!"); break; case 6: murmur(cn,"I love the clicking of coins."); break; case 7: murmur(cn,"Gold and Silver, Silver and Gold."); break; default: break; } dat->last_talk=ticker; } if (ticker>dat->memcleartimer) { mem_erase_driver(cn,7); dat->memcleartimer=ticker+TICKS*60*60*12; } do_idle(cn,TICKS*2); }
void UICreateStatusWindow(HWND hUIWnd, int xPos, int yPos, bool isDocked) { if (!IsWindow(uiStatus.hWnd)) { murmur("\tUICreateStatusWindow, hUIWnd=%x @(%i, %i), isDocked:%d",hUIWnd, xPos, yPos, isDocked); RECT rec; uiStatus.pt.x = (xPos>0)?xPos : 0; uiStatus.pt.y = (yPos>0)?yPos : 0; uiStatus.hWnd = _CreateStatusPage(); murmur("\tStatusWindow created. hWnd=%x",uiStatus.hWnd); //設定C# Status 內 m_AppHWnd //_SetStatusAppHWnd(hUIWnd); //設定 module menu (init: current module) SendMessage(hUIWnd, WM_IME_NOTIFY, IMN_PRIVATE, 9); // set all module names. //SendMessage(hUIWnd, WM_IME_NOTIFY, IMN_PRIVATE, 3); //UISetStatusModStr(); //設定中英 //_SetStatusChiEng(); //設定繁簡 //_SetStatusSimpifiedOrTraditional(isTraditional); //設定 hIMEWnd (?) hIMEWnd = hUIWnd; //存到 hIMEWnd 之後會拿來判斷 //移動到螢幕右下方 if(isDocked) { murmur("\tDocked the status window.."); UISetIsStatusDocked(true); } else { UISetIsStatusDocked(false); if((xPos==0)||(yPos==0)) { murmur("\tMove the status window to default location."); SystemParametersInfo(SPI_GETWORKAREA, 0, &rec, 0); UIMoveStatusWindow(hUIWnd, rec.right - 200, rec.bottom - 50); } else { murmur("\tMove the status window to saved location, isDocked:%d.", UIGetIsStatusDocked()); UIMoveStatusWindow(hUIWnd, xPos, yPos); } } } else murmur("Status window is already created."); //設定C# Status 內 m_AppHWnd _SetStatusAppHWnd(hUIWnd); }
void AdjustCandWnd(HWND hCandWnd, POINT ptNew) { LPUIPRIV lpUIPriv; int nAvailTextHi; DWORD dwPageSize; // Available page size RECT rect; BOOL bSipOverlapped=FALSE; int nSipTop; lpUIPriv = (LPUIPRIV)GetWindowLong(hCandWnd, IMMGWL_PRIVATE); if (!lpUIPriv->lpCandList) { return; } ptNew.x = ptNew.x < 0 ? 0 : ptNew.x; ptNew.y = ptNew.y < 0 ? 0 : ptNew.y; nAvailTextHi = g_sImeUIG.rcWorkArea.bottom - ptNew.y - lpUIPriv->nFracHi - g_sImeUIG.cyBorder * 2; nAvailTextHi = nAvailTextHi < 0 ? 0 : nAvailTextHi; rect.left = ptNew.x; rect.top = ptNew.y; rect.right = ptNew.x + g_sImeUIG.nCandLineWi; rect.bottom = ptNew.y + g_sImeUIG.nCandLineHi*lpUIPriv->dwPageSize + lpUIPriv->nFracHi + g_sImeUIG.cyBorder * 2; bSipOverlapped = CheckRectForSIP(&rect, nSipTop); dwPageSize = (DWORD)nAvailTextHi / g_sImeUIG.nCandLineHi; if ((dwPageSize >= lpUIPriv->dwPageSize) && !bSipOverlapped) { dwPageSize = lpUIPriv->dwPageSize; } else if ((dwPageSize >= MIN_PAGESIZE) && !bSipOverlapped) { dwPageSize = MIN_PAGESIZE; } else { #if 1 // Use new way to calculate candidate window position. // We will calculate the space above composition window and // try to meet MIN_PAGESIZE. // If there is still not enough space, candidate window will // locate above the composition window. nAvailTextHi = ptNew.y - lpUIPriv->nCompHi - g_sImeUIG.rcWorkArea.top - lpUIPriv->nFracHi - g_sImeUIG.cyBorder; nAvailTextHi = nAvailTextHi < 0 ? 0 : nAvailTextHi; dwPageSize = (DWORD)nAvailTextHi / g_sImeUIG.nCandLineHi; if (dwPageSize >= lpUIPriv->dwPageSize ) { dwPageSize = lpUIPriv->dwPageSize; } else if (dwPageSize < MIN_PAGESIZE) { dwPageSize = MIN_PAGESIZE; } else { } ptNew.y = lpUIPriv->ptComp.y - g_sImeUIG.nCandDy[dwPageSize] - lpUIPriv->nFracHi - g_sImeUIG.cyBorder; // if there is no enough space at the above and the below of the composition window, murmur("AdjustCandWnd() bSipOverlapped = %d, ptNew.y = %d, g_sImeUIG.rcWorkArea.top = %d\n", bSipOverlapped, ptNew.y, g_sImeUIG.rcWorkArea.top); if (ptNew.y < g_sImeUIG.rcWorkArea.top) { ptNew.y = nSipTop - lpUIPriv->nCandHi; dwPageSize = lpUIPriv->dwPageSize; if ((lpUIPriv->ptComp.x + lpUIPriv->nCompWi + lpUIPriv->nCandWi) < g_sImeUIG.rcWorkArea.right) ptNew.x = lpUIPriv->ptComp.x + lpUIPriv->nCompWi; else if (lpUIPriv->ptComp.x > lpUIPriv->nCandWi) ptNew.x = lpUIPriv->ptComp.x - lpUIPriv->nCandWi; } #else // Still keep the old way for reference and backup (in case). int nyCand; nyCand = lpUIPriv->ptComp.y - g_sImeUIG.nCandDy[lpUIPriv->dwPageSize] - lpUIPriv->nFracHi - g_sImeUIG.cyBorder; if (nyCand >= g_sImeUIG.rcWorkArea.top) { ptNew.y = nyCand; dwPageSize = lpUIPriv->dwPageSize; } else { dwPageSize = MIN_PAGESIZE; } #endif } lpUIPriv->lpCandList->dwPageSize = dwPageSize; CalcCandSize(hCandWnd); SetWindowPos(hCandWnd, NULL, 0, 0, lpUIPriv->nCandWi, lpUIPriv->nCandHi, SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOZORDER); SetWindowPos(lpUIPriv->hScrBar, NULL, lpUIPriv->rcCandText.right, lpUIPriv->rcCandText.top, g_sImeUIG.cxVScroll, (lpUIPriv->rcCandText.bottom - lpUIPriv->rcCandText.top), SWP_NOACTIVATE|SWP_NOZORDER); InvalidateRect(hCandWnd, NULL, FALSE); if (ptNew.x + lpUIPriv->nCandWi > g_sImeUIG.rcWorkArea.right) { ptNew.x = g_sImeUIG.rcWorkArea.right - lpUIPriv->nCandWi; } if (ptNew.x != lpUIPriv->ptCand.x || ptNew.y != lpUIPriv->ptCand.y) { lpUIPriv->ptCand = ptNew; SetWindowPos(hCandWnd, NULL, ptNew.x, ptNew.y, 0, 0, SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOZORDER); } return; }
int OVIMRomanNewContext::keyEvent( OVKeyCode* k, OVBuffer* b, OVCandidate* i, OVService* s) { if(!candi.isEmpty()) { if(k->code()==ovkEsc) return closeCandidateWindow(i); if (k->code()==ovkLeft || k->code()==ovkUp) { if(pagenumber > 0) pagenumber--; else pagenumber = pagetotal; return showcandi(i); } if (k->code()==ovkRight || k->code()==ovkDown) { if(pagenumber == pagetotal) pagenumber = 0; else pagenumber++; return showcandi(i); } if(k->code()==ovkTab){ if(!candi.item(temp+pagenumber*10)) return 0; b->clear() ->append(keyseq.buf) ->append(candi.item(temp+pagenumber*10) + keyseq.len) ->update(); if(temp++ > 8) temp = 0; if(temp+pagenumber*10 > candi.count()) temp = 0; return 1; } if(is_selkey(k->code())) { murmur("SelectKey Pressed: %c",k->code()); int n = (k->code() - '1' + 10) % 10; if(n+pagenumber*10 >= candi.count()) return 0; const char* correctedWord = candi.item(n+pagenumber*10); b->clear()->append(correctedWord)->append(" ")->send(); if (i->onScreen()) i->hide(); keyseq.clear(); return closeCandidateWindow(i); } if (k->code()==ovkSpace || k->code()==ovkReturn || is_punc(k->code())) { if (!(strlen(keyseq.buf))) return 0; // empty buffer, do nothing b->append(" ")->send(); keyseq.clear(); return closeCandidateWindow(i); } if(!b->isEmpty() && isprint(k->code())) { b->append(" ")->send(); keyseq.clear(); keyseq.add(k->code()); b->clear()->append(keyseq.buf)->update(); return closeCandidateWindow(i); } } if(k->code() == ovkEsc) { b->clear()->update(); clear(); return 1; } if (k->code() == ovkReturn) { if(!(strlen(keyseq.buf))) return 0; if (keyseq.buf) { if(!(strlen(keyseq.buf))) return 0; keyseq.clear(); //keyseq.add(k->code()); b->append(keyseq.buf)->send(); keyseq.clear(); return 1; } } if (k->code()==ovkSpace || is_punc(k->code())) { if (!(strlen(keyseq.buf))) return 0; // empty buffer, do nothing if(keyseq.buf) { pagenumber = 0; if(!isEnglish(keyseq.buf) && spellCheckerByHunspell(keyseq.buf)) { showcandi(i); return 1; } if (!(strlen(keyseq.buf))) return 0; keyseq.clear(); keyseq.add(k->code()); b->append(keyseq.buf)->send(); keyseq.clear(); return closeCandidateWindow(i); } else { b->send(); return 0; } } if (k->code()==ovkDelete || k->code()==ovkBackspace) { if(!strlen(keyseq.buf)) { closeCandidateWindow(i); return 0;} keyseq.remove(); if(keyseq.len && i->onScreen()) { pagenumber = 0; if(!isEnglish(keyseq.buf) && spellCheckerByHunspell(keyseq.buf)) { showcandi(i); return 1; } else { closeCandidateWindow(i); } } else { closeCandidateWindow(i); } b->clear()->append(keyseq.buf)->update(); return 1; } if(k->code()==ovkTab){ if(keyseq.buf) { pagenumber = 0; if(!isEnglish(keyseq.buf) && spellCheckerByHunspell(keyseq.buf)) { showcandi(i); return 1; } else { closeCandidateWindow(i); } } else { return 0; } } if (!isprint(k->code()) || k->isFunctionKey()) { closeCandidateWindow(i); return 0; } if(strlen(keyseq.buf) >= ebMaxKeySeq) return 1; if (isprint(k->code())){ char s[2]; sprintf(s, "%c", k->code()); keyseq.add(k->code()); if(keyseq.buf && i->onScreen()) { pagenumber = 0; temp = 0; if(!isEnglish(keyseq.buf) && spellCheckerByHunspell(keyseq.buf)) { showcandi(i); return 1; } else { closeCandidateWindow(i); } } b->clear()->append(keyseq.buf)->update(); return 1; } return 0; }
bool OVCINList::preparse(const char *loadpath, const char *filename) { // check if a file of the same short name has been alread loaded for (size_t i=0; i<list.size(); i++) { OVCINInfo &x=list[i]; if (x.shortfilename==filename) { murmur("OVCINList: file %s not loaded, short name '%s' already exists", loadpath, filename); return false; } } string longname = string(loadpath) + pathsep + string(filename); FILE *in=fopen(longname.c_str(), "r"); if (!in) { murmur("OVCINList: opening %s failed", longname.c_str()); return false; } OVCINInfo info; info.shortfilename=filename; info.longfilename=longname; int line=0; const size_t bs=2049; char buf[bs]; bzero(buf, bs); string k, v; while (!feof(in)) { fgets(buf, bs-1, in); if (buf[0]=='#') continue; // ignore comment CLSplitString(buf, k, v); const char *key=k.c_str(); if (!strcasecmp(key, "%ename")) info.ename=v; else if (!strcasecmp(key, "%cname")) info.cname=v; else if (!strcasecmp(key, "%tcname")) info.tcname=v; else if (!strcasecmp(key, "%scname")) info.scname=v; line++; if (line >= CL_PREPARSELIMIT) break; } fclose(in); // some fallbacks.. if (!info.ename.length()) info.ename=filename; if (!info.cname.length()) info.cname=info.ename; if (!info.tcname.length()) info.tcname=info.cname; if (!info.scname.length()) info.scname=info.cname; list.push_back(info); murmur("Loaded: longfilename=%s, shortfilename=%s, ename=%s, cname=%s, tcname=%s, scname=%s", info.longfilename.c_str(), info.shortfilename.c_str(), info.ename.c_str(), info.cname.c_str(), info.tcname.c_str(), info.scname.c_str()); return 1; }
void merchant_driver(int cn,int ret,int lastact) { struct merchant_driver_data *dat; int co,in,n; struct msg *msg,*next; dat=set_data(cn,DRD_MERCHANTDRIVER,sizeof(struct merchant_driver_data)); if (!dat) return; // oops... if (ch[cn].arg) { dat->open=6; dat->close=23; merchant_driver_parse(cn,dat); ch[cn].arg=NULL; } if (!ch[cn].store) { if (dat->pricemulti) create_store(cn,dat->ignore,dat->pricemulti); else create_store(cn,dat->ignore,400); if (dat->special) { for (n=0; n<5; n++) add_special_store(cn); } } // loop through our messages for (msg=ch[cn].msg; msg; msg=next) { next=msg->next; // did we see someone? if (msg->type==NT_CHAR) { co=msg->dat1; // dont talk to someone we cant see, and dont talk to ourself if (!char_see_char(cn,co) || cn==co) { remove_message(cn,msg); continue; } // dont talk to someone far away if (char_dist(cn,co)>10) { remove_message(cn,msg); continue; } // dont talk to the same person twice if (mem_check_driver(cn,co,7)) { remove_message(cn,msg); continue; } quiet_say(cn,"Hello %s! If you'd like to trade, say: '°c4%s, trade°c0!",ch[co].name,ch[cn].name); mem_add_driver(cn,co,7); } // talk back if (msg->type==NT_TEXT) { analyse_text_driver(cn,msg->dat1,(char*)msg->dat2,msg->dat3); if ((msg->dat1==1 || msg->dat1==2) && (co=msg->dat3)!=cn) { // talk, and not our talk if (strcasestr((char*)msg->dat2,ch[cn].name) && strcasestr((char*)msg->dat2,"trade")) { /*if (abuser(ch[co].ID)) { switch(RANDOM(3)) { case 0: murmur(cn,"I hate cheaters."); break; case 1: emote(cn,"clenches his fists and stares at %s.",ch[co].name); break; case 2: murmur(cn,"I wish the cheaters would leave me alone."); break; } }*/ ch[co].merchant=cn; } } } // got an item? if (msg->type==NT_GIVE) { co=msg->dat1; if ((in=ch[cn].citem)) { // we still have it // let it vanish destroy_item(ch[cn].citem); ch[cn].citem=0; } } remove_message(cn,msg); } // do something. whenever possible, call do_idle with as high a tick count // as reasonable when doing nothing. if (dat->dayx) { // we have day / night positions if (!opening_time(dat->open,dat->close)) { // we're closed if (dat->doorx && !is_closed(dat->doorx,dat->doory)) { // door is still open if (!is_room_empty(dat->storefx,dat->storefy,dat->storetx,dat->storety)) { // store is not empty quiet_say(cn,"We're closing, please leave now!"); do_idle(cn,TICKS); return; } else { if (use_item_at(cn,dat->doorx,dat->doory,0)) return; do_idle(cn,TICKS); return; } } if (secure_move_driver(cn,dat->nightx,dat->nighty,dat->nightdir,ret,lastact)) return; } else { // we're open if (dat->doorx && is_closed(dat->doorx,dat->doory)) { // door is still closed if (use_item_at(cn,dat->doorx,dat->doory,0)) return; do_idle(cn,TICKS); return; } if (secure_move_driver(cn,dat->dayx,dat->dayy,dat->daydir,ret,lastact)) return; } } else { // just one position if (secure_move_driver(cn,ch[cn].tmpx,ch[cn].tmpy,dat->dir,ret,lastact)) return; } if (ticker>dat->last_talk+TICKS*60 && !RANDOM(25)) { switch(RANDOM(11)) { case 0: murmur(cn,"My back itches."); break; case 1: whisper(cn,"There's something stuck between your teeth."); break; case 2: murmur(cn,"Oh yeah, those were the days."); break; case 3: murmur(cn,"Now where did I put it?"); break; case 4: murmur(cn,"Oh my, life is hard but unfair."); break; case 5: murmur(cn,"Beware of the fire snails!"); break; case 6: murmur(cn,"Ishtar! Oh, what has become of us!"); break; case 7: murmur(cn,"The demons will get you."); break; case 8: emote(cn,"scratches %s back",hisname(cn)); break; case 9: if (map[ch[cn].x+ch[cn].y*MAXMAP].flags&MF_INDOORS) emote(cn,"stares at the ceiling"); else emote(cn,"stares at the sky"); break; case 10: emote(cn,"twiddles %s thumbs",hisname(cn)); break; default: break; } dat->last_talk=ticker; } if (dat->special && ticker>dat->lastadd+TICKS*60*60*12) { add_special_store(cn); dat->lastadd=ticker; } if (ticker>dat->memcleartimer) { mem_erase_driver(cn,7); dat->memcleartimer=ticker+TICKS*60*60*12; } do_idle(cn,TICKS*2); }
OVBuffer* AVBuffer::update() //set + show { murmur("OVBuffer* AVBuffer::update() "); return update(-1, -1, -1); }
bool UIShowDeskBand(bool t) { CLSID CLSID_OVDeskBand ={0x6d5d9154, 0xb557, 0x4509, {0x82, 0x9e, 0x94, 0xb8, 0xbf, 0x96, 0x2e, 0x5b}}; static HRESULT bandID=0; bool ret=false; int i =0; murmur("hIMEWND:%x, AncestorWND:%x, TopWindow:%x, ForegroundWindow:%x, ShellWindow:%x " ,hIMEWnd, GetAncestor(hIMEWnd,GA_ROOTOWNER), GetTopWindow(NULL), GetForegroundWindow(), GetShellWindow()); //CLSID CLSIDDeskBand = {0x46b3d3ef, 0x71a, 0x4b7e, {0x8a, 0xa2, 0xe5, 0x60, 0x81, 0xd, 0xab, 0x35}}; // only for vista /* ITrayDeskBand * spTrayDeskBand=0; if(SUCCEEDED(CoCreateInstance(CLSID_TrayDeskBand, NULL, CLSCTX_LOCAL_SERVER, IID_ITrayDeskBand, (void**)&spTrayDeskBand))) { if(t) spTrayDeskBand->ShowDeskBand(CLSID_OVDeskBand); else spTrayDeskBand->HideDeskBand(CLSID_OVDeskBand); } */ CComPtr <IUnknown> spBandService; if(!spBandSite) { if(SUCCEEDED(spBandService.CoCreateInstance(CLSID_TrayBandSiteService, NULL))) { //HWND aWnd = GetAncestor(hIMEWnd, GA_ROOTOWNER); //if(aWnd) BringWindowToTop(aWnd); murmur("Create IBandsite interface succeed"); spBandService->QueryInterface(&spBandSite); } else { murmur("Create IBandsite interface failed"); spBand = NULL; spBandSite = NULL; //WaitForSingleObject(NULL, 3000); //SendMessage(hIMEWnd, WM_IME_NOTIFY, IMN_OPENSTATUSWINDOW, 0); } } if(spBandSite && !spBand ) { if(SUCCEEDED(CoCreateInstance(CLSID_OVDeskBand, NULL, CLSCTX_INPROC, IID_IUnknown, (void**)&spBand))) { // CComPtr<IObjectWithSite> spSite; // if(SUCCEEDED(spBand->QueryInterface(&spSite)) ) // { // spSite->SetSite(spBandSite); // } // else spBand = NULL; } else spBand = NULL; } //if(SUCCEEDED(spBandService.CoCreateInstance(CLSID_TrayBandSiteService, NULL)) // && SUCCEEDED(spBandService->QueryInterface(&spBandSite)) ) if( spBand && spBandSite) { if(t) { if(!((int)bandID >0)) { bandID = spBandSite->AddBand(spBand); murmur("\tBandID:%d",bandID); if( (int)bandID >0 ) { murmur("Create deskband succeeded."); //spBand = NULL; //spBandSite = NULL; ret = true; } else { murmur("Create deskband failed."); spBand->ShowDW(0); spBand = NULL; spBandSite = NULL; bandID =0; } } else { murmur("\tBandID:%d",bandID); murmur("Deskband created."); } } else if((int)bandID >0) { //HWND aWnd = GetAncestor(hIMEWnd, GA_ROOTOWNER); //if(aWnd) BringWindowToTop(aWnd); if(SUCCEEDED( spBandSite->RemoveBand(bandID))) { murmur("\tBandID:%d",bandID); murmur("Remove deskband succeeded."); spBand = NULL; spBandSite = NULL; bandID =0; //CoUninitialize(); ret = true; } else { murmur("Remove deskband failed."); //spBand->CloseDW(0); //spBand=NULL; //spBandSite = NULL; //bandID =0; //HANDLE hEvent = CreateEvent(NULL,FALSE,FALSE,_T("OVE")); //WaitForSingleObject(hEvent, 500); //SendMessage(hIMEWnd, WM_IME_NOTIFY, IMN_CLOSESTATUSWINDOW, 0); } } else { murmur("Deskband was not created."); //spBand->CloseDW(0); spBand=NULL; spBandSite = NULL; } } //} //while(!ret && i++<3); murmur("::hIMEWND:%x, AncestorWND:%x, TopWindow:%x, ForegroundWindow:%x, ShellWindow:%x " ,hIMEWnd, GetAncestor(hIMEWnd,GA_ROOTOWNER), GetTopWindow(NULL), GetForegroundWindow(), GetShellWindow()); return ret; }