void event_choicewindraw(TEXTWIN textwin, int num, int method) { CHO_T *cho; VRAMHDL dst; RECT_T rct; POINT_T pt; POINT_T pfnt; TEXTCTRL textctrl; DISPWIN dispwin; BOOL fntgetsize; int pos; if ((num < 0) || (num >= textwin->cmdmax)) { return; } cho = textwin->cho + num; textctrl = &textwin->textctrl; textctrl_renewal(textctrl); dst = textwin->cmdvram; if (dst == NULL) { dst = textwin->textctrl.vram; } rct = cho->rct; fntgetsize = fontmng_getsize(textctrl->font, cho->str, &pfnt); if ((fntgetsize == SUCCESS) && (gamecore.sys.type & GAME_ENGSTYLE)) { // フォントの差を吸収 pos = pfnt.x - (rct.right - rct.left); if (pos > 0) { rct.right += pos; } #if 0 pos = pfnt.y - (rct.bottom - rct.top); if (pos > 0) { rct.bottom += pos; } #endif } if (gamecore.sys.version >= EXE_VER1) { if (method) { method = 3; } if (gamecore.sys.type & GAME_CMDWINNOBG) { dispwin = &gamecore.dispwin; if (dispwin->flag & DISPWIN_CLIPTEXT) { #ifndef SIZE_QVGA rct.left += dispwin->txtclip.left; rct.top += dispwin->txtclip.top; rct.right += dispwin->txtclip.left; rct.bottom += dispwin->txtclip.top; #else pt.x = dispwin->txtclip.left; pt.y = dispwin->txtclip.top; vramdraw_halfpoint(&pt); rct.left += pt.x; rct.top += pt.y; rct.right += pt.x; rct.bottom += pt.y; #endif } vram_zerofill(dst, &rct); } else if (textwin->chocolor[method+2] == 0) { vram_zerofill(dst, &rct); } else { vram_fill(dst, &rct, textwin->chocolor[method+2], 0xff); } if (textctrl->fonttype & TEXTCTRL_SHADOW) { pt.x = rct.left + 1; pt.y = rct.top + 1; vrammix_textex(dst, textctrl->font, cho->str, textwin->chocolor[method+1], &pt, &rct); } pt.x = rct.left; pt.y = rct.top; vrammix_textex(dst, textctrl->font, cho->str, textwin->chocolor[method+0], &pt, &rct); } else { vram_zerofill(dst, &rct); pt.x = rct.left; pt.y = rct.top; if ((fntgetsize == SUCCESS) && (!(gamecore.sys.type & GAME_DRS))) { pt.x += (rct.right - rct.left - pfnt.x) / 2; pt.y += (rct.bottom - rct.top - pfnt.y) / 2; } vrammix_textex(dst, textctrl->font, cho->str, textwin->chocolor[method], &pt, &rct); } vramdraw_setrect(dst, &rct); }
static BRESULT wndopenbase(MENUSYS *sys) { MENUHDL menu; RECT_T mrect; VRAMHDL vram; int items; int posx; UINT rootflg; int menutype; int height; POINT_T pt; wndclose(sys, 0); rootflg = 0; menu = sys->root; while(menu) { // メニュー内容を調べる。 if (!(menu->flag & (MENU_DISABLE | MENU_SEPARATOR))) { switch(menu->flag & MENUS_CTRLMASK) { case MENUS_POPUP: break; case MENUS_SYSTEM: rootflg |= MEXIST_SYS; break; case MENUS_MINIMIZE: rootflg |= MEXIST_MINIMIZE; break; case MENUS_CLOSE: rootflg |= MEXIST_CLOSE; break; default: rootflg |= MEXIST_ITEM; break; } } menu = menu->next; } mrect.left = MENU_FBORDER + MENU_BORDER; mrect.top = MENU_FBORDER + MENU_BORDER; mrect.right = menubase.width - (MENU_FBORDER + MENU_BORDER); mrect.bottom = (MENU_FBORDER + MENU_BORDER) + MENUSYS_CYCAPTION; height = ((MENU_FBORDER + MENU_BORDER) * 2) + MENUSYS_CYCAPTION; if (rootflg & MEXIST_ITEM) { height += (MENUSYS_BCAPTION * 3) + MENUSYS_CYSYS; mrect.left += MENUSYS_BCAPTION; mrect.top += MENUSYS_BCAPTION; mrect.right -= MENUSYS_BCAPTION; mrect.bottom += MENUSYS_BCAPTION; } vram = menuvram_create(menubase.width, height, menubase.bpp); sys->wnd[0].vram = vram; if (vram == NULL) { goto wopn0_err; } if (sys->style & MENUSTYLE_BOTTOM) { vram->posy = max(0, menuvram->height - height); } menuvram_caption(vram, &mrect, sys->icon, sys->title); menubase_setrect(vram, NULL); menu = sys->root; sys->wnd[0].menu = menu; sys->wnd[0].focus = -1; sys->depth++; items = 0; posx = MENU_FBORDER + MENU_BORDER + MENUSYS_BCAPTION; while(menu) { if (!(menu->flag & (MENU_DISABLE | MENU_SEPARATOR))) { menutype = menu->flag & MENUS_CTRLMASK; if (menutype == MENUS_POPUP) { } else if (menutype == MENUS_SYSTEM) { menu->rct.left = mrect.left + MENU_PXCAPTION; menu->rct.right = menu->rct.left; menu->rct.top = mrect.top + MENU_PYCAPTION; menu->rct.bottom = menu->rct.top; if (sys->icon) { menu->rct.right += MENUSYS_SZICON; menu->rct.bottom += MENUSYS_SZICON; } } else if (menutype == MENUS_MINIMIZE) { menu->rct.right = mrect.right - MENU_PXCAPTION; if (rootflg & MEXIST_CLOSE) { menu->rct.right -= MENUSYS_CXCLOSE + (MENU_LINE * 2); } menu->rct.left = menu->rct.right - MENUSYS_CXCLOSE; menu->rct.top = mrect.top + ((MENUSYS_CYCAPTION - MENUSYS_CYCLOSE) / 2); menu->rct.bottom = menu->rct.top + MENUSYS_CYCLOSE; menuvram_minimizebtn(vram, &menu->rct, 0); } else if (menutype == MENUS_CLOSE) { menu->rct.right = mrect.right - MENU_PXCAPTION; menu->rct.left = menu->rct.right - MENUSYS_CXCLOSE; menu->rct.top = mrect.top + ((MENUSYS_CYCAPTION - MENUSYS_CYCLOSE) / 2); menu->rct.bottom = menu->rct.top + MENUSYS_CYCLOSE; menuvram_closebtn(vram, &menu->rct, 0); } else { menu->rct.left = posx; menu->rct.top = mrect.bottom + MENUSYS_BCAPTION; menu->rct.bottom = menu->rct.top + MENUSYS_CYSYS; fontmng_getsize(menubase.font, menu->string, &pt); posx += MENUSYS_SXSYS + pt.x + MENUSYS_LXSYS; if (posx >= (menubase.width - (MENU_FBORDER + MENU_BORDER + MENUSYS_BCAPTION))) { break; } menu->rct.right = posx; bitemdraw(vram, menu, 0); } } items++; menu = menu->next; } sys->wnd[0].items = items; return(SUCCESS); wopn0_err: return(FAILURE); }
static BRESULT childopn(MENUSYS *sys, int depth, int pos) { MENUHDL menu; RECT_T parent; int dir; int width; int height; int items; MSYSWND wnd; int drawitems; POINT_T pt; menu = getitem(sys, depth, pos); if ((menu == NULL) || (menu->child == NULL)) { TRACEOUT(("child not found.")); goto copn_err; } wnd = sys->wnd + depth; if ((menu->flag & MENUS_CTRLMASK) == MENUS_POPUP) { parent.left = sys->popupx; parent.top = max(sys->popupy, wnd->vram->height); parent.right = parent.left; parent.bottom = parent.top; dir = 0; } else { parent.left = wnd->vram->posx + menu->rct.left; parent.top = wnd->vram->posy + menu->rct.top; parent.right = wnd->vram->posx + menu->rct.right; parent.bottom = wnd->vram->posy + menu->rct.bottom; dir = depth + 1; } if (depth >= (MENUSYS_MAX - 1)) { TRACEOUT(("menu max.")); goto copn_err; } wnd++; width = 0; height = (MENU_FBORDER + MENU_BORDER); items = 0; drawitems = 0; menu = menu->child; wnd->menu = menu; while(menu) { if (!(menu->flag & MENU_DISABLE)) { menu->rct.left = (MENU_FBORDER + MENU_BORDER); menu->rct.top = height; if (menu->flag & MENU_SEPARATOR) { if (height > (menubase.height - MENUSYS_CYSEP - (MENU_FBORDER + MENU_BORDER))) { break; } height += MENUSYS_CYSEP; menu->rct.bottom = height; } else { if (height > (menubase.height - MENUSYS_CYITEM - (MENU_FBORDER + MENU_BORDER))) { break; } height += MENUSYS_CYITEM; menu->rct.bottom = height; fontmng_getsize(menubase.font, menu->string, &pt); if (width < pt.x) { width = pt.x; } } } items++; menu = menu->next; } width += ((MENU_FBORDER + MENU_BORDER + MENUSYS_SXITEM) * 2) + MENUSYS_CXCHECK + MENUSYS_CXNEXT; if (width >= menubase.width) { width = menubase.width; } height += (MENU_FBORDER + MENU_BORDER); wnd->vram = menuvram_create(width, height, menubase.bpp); if (wnd->vram == NULL) { TRACEOUT(("sub menu vram couldn't create")); goto copn_err; } if (dir == 1) { if ((parent.top < height) || (parent.bottom < (menubase.height - height))) { parent.top = parent.bottom; } else { parent.top -= height; } } else if (dir >= 2) { if ((parent.left < width) || (parent.right < (menubase.width - width))) { parent.left = parent.right; } else { parent.left -= width; } if ((parent.top > (menubase.height - height)) && (parent.bottom >= height)) { parent.top = parent.bottom - height; } } wnd->vram->posx = min(parent.left, menubase.width - width); wnd->vram->posy = min(parent.top, menubase.height - height); wnd->items = items; wnd->focus = -1; sys->depth++; menu = wnd->menu; drawitems = items; while(drawitems--) { if (!(menu->flag & MENU_DISABLE)) { menu->rct.right = width - (MENU_FBORDER + MENU_BORDER); citemdraw(wnd->vram, menu, 0); } menu = menu->next; } menubase_setrect(wnd->vram, NULL); return(SUCCESS); copn_err: return(FAILURE); }
static BRESULT setmboxitem(MBOX *mb, const OEMCHAR *str, UINT type) { OEMCHAR *dst; int rem; int w; OEMCHAR work[4]; int width; POINT_T pt; int leng; if (mb == NULL) { goto smbi_err; } ZeroMemory(mb, sizeof(MBOX)); if (str == NULL) { goto smbi_set; } if ((type & 0xf) >= 6) { type &= ~0x0f; } mb->type = type; width = MENUMBOX_WIDTH - (MENUMBOX_SX + MENUMBOX_PXTEXT + MENUMBOX_LXTEXT); if (mb->type & 0xf0) { width -= MENUMBOX_CXICON; } dst = NULL; rem = 0; w = 0; while(1) { leng = milstr_charsize(str); if (leng == 0) { break; } if ((str[0] >= 0) && (str[0] < 0x20)) { if (str[0] == '\n') { dst = mb->string[mb->lines]; mb->lines++; if (mb->lines >= MENUMBOX_MAXLINE) { break; } rem = NELEMENTS(mb->string[0]) - 1; if (mb->width < w) { mb->width = w; } w = 0; } } else { CopyMemory(work, str, leng * sizeof(OEMCHAR)); work[leng] = '\0'; fontmng_getsize(menubase.font, work, &pt); if ((rem < leng) || ((w + pt.x) > width)) { dst = mb->string[mb->lines]; mb->lines++; if (mb->lines >= MENUMBOX_MAXLINE) { break; } rem = NELEMENTS(mb->string[0]) - 1; if (mb->width < w) { mb->width = w; } w = 0; } w += pt.x; CopyMemory(dst, str, leng * sizeof(OEMCHAR)); dst += leng; rem -= leng; } str += leng; } if (mb->width < w) { mb->width = w; } smbi_set: mb->width += (MENUMBOX_SX + MENUMBOX_PXTEXT + MENUMBOX_LXTEXT); fontmng_getsize(menubase.font, mstr_fontcheck, &pt); mb->fontsize = pt.y; mb->height = mb->lines * mb->fontsize; if (mb->type & 0xf0) { mb->width += MENUMBOX_CXICON; if (mb->height < MENUMBOX_CYICON) { mb->height = MENUMBOX_CYICON; } } mb->height += MENUMBOX_SY + MENUMBOX_SYBTN + MENUMBOX_CYBTN + MENUMBOX_LYBTN; width = b_res[mb->type & 0x0f][0]; width *= (MENUMBOX_CXBTN + MENUMBOX_PXBTN); width += (MENUMBOX_SXBTN * 2) - MENUMBOX_PXBTN; if (mb->width < width) { mb->width = width; } return(SUCCESS); smbi_err: return(FAILURE); }