/* * PlayMusicRsc: Play MIDI file associated with given resource number as * background music. */ void PlayMusicRsc(ID rsc) { debug(("PlayMusicRsc %d\n", rsc)); /* If we're already playing same music file, keep jammin' */ if (playing_music) { if (rsc != 0 && bg_music != 0 && !stricmp(LookupNameRsc(rsc), LookupNameRsc(bg_music))) { debug(("Already playing that music.\n" )); return; } } MusicAbort(); bg_music = rsc; if (!config.play_music || !has_midi || rsc == 0) return; playing_music = True; music_pos = 0; #ifndef M59_MSS /* If sound is already going, wait for it to end */ if (playing_midi) return; #endif NewMusic(SOUND_MUSIC, rsc); }
/* * DisplayDescription: Display given object's description. * Caller must ensure that obj is not deleted while dialog is up. * flags gives info on what user can do with dialog. * hDescParent global is used as parent for this dialog. * extra_string and url are used only in player descriptions. */ void DisplayDescription(object_node *obj, BYTE flags, char *description, char *extra_string, char *url) { DescDialogStruct info; int template_id; if (hDescDialog != NULL) { debug(("Attempted to create multiple description dialogs\n")); return; } ZeroMemory(&info,sizeof(info)); info.obj = obj; info.flags = flags; info.name = LookupNameRsc(obj->name_res); info.description = description; info.fixed_string = extra_string; info.url = url; // Different dialog for players template_id = (obj->flags & OF_PLAYER) ? IDD_DESCPLAYER : IDD_DESC; DialogBoxParam(hInst, MAKEINTRESOURCE(template_id), hDescParent, DescDialogProc, (LPARAM) &info); TooltipReset(); SetDescParams(NULL, DESC_NONE); }
/* * GroupDialogProc: Dialog procedure for group dialog. */ BOOL CALLBACK GroupDialogProc(HWND hDlg, UINT message, UINT wParam, LONG lParam) { int i, index; HWND hList, hCombo; list_type l; switch (message) { case WM_INITDIALOG: // Add groups to list box hCombo = GetDlgItem(hDlg, IDC_GROUPS); SetWindowFont(hCombo, GetFont(FONT_LIST), FALSE); for (i=0; i < num_groups; i++) index = ComboBox_AddString(hCombo, groups[i]); // Add logged on users to list box hList = GetDlgItem(hDlg, IDC_LOGGEDON); SetWindowFont(hList, GetFont(FONT_LIST), FALSE); for (l = *(cinfo->current_users); l != NULL; l = l->next) { object_node *obj = (object_node *) (l->data); ListBox_AddString(hList, LookupNameRsc(obj->name_res)); } PostMessage(hDlg, BK_CREATED, 0, 0); SetWindowFont(GetDlgItem(hDlg, IDC_GROUPMEMBERS), GetFont(FONT_LIST), FALSE); SetWindowFont(GetDlgItem(hDlg, IDC_ADDNAME), GetFont(FONT_EDIT), FALSE); SetWindowFont(GetDlgItem(hDlg, IDC_NEWGROUP), GetFont(FONT_EDIT), FALSE); SetWindowFont(GetDlgItem(hDlg, IDC_GROUPTELL), GetFont(FONT_EDIT), FALSE); Edit_LimitText(GetDlgItem(hDlg, IDC_NEWGROUP), MAX_GROUPNAME); Edit_LimitText(GetDlgItem(hDlg, IDC_ADDNAME), MAX_CHARNAME); Edit_LimitText(GetDlgItem(hDlg, IDC_GROUPTELL), MAXSAY); if (num_groups >= MAX_NUMGROUPS) EnableWindow(GetDlgItem(hDlg, IDC_NEWGROUP), FALSE); hGroupDialog = hDlg; CenterWindow(hDlg, GetParent(hDlg)); return TRUE; case BK_CREATED: hCombo = GetDlgItem(hDlg, IDC_GROUPS); ComboBox_SetCurSel(hCombo, 0); // Need this for some reason to simulate WM_COMMAND GroupCommand(hDlg, IDC_GROUPS, hCombo, CBN_SELCHANGE); return TRUE; HANDLE_MSG(hDlg, WM_COMMAND, GroupCommand); case WM_DRAWITEM: // windowsx.h macro always returns FALSE return GroupListDrawItem(hDlg, (const DRAWITEMSTRUCT *)(lParam)); case WM_DESTROY: hGroupDialog = NULL; return TRUE; } return FALSE; }
/* * StatsListChangeStat: Redisplay current statistic, whose value has changed. * Requires that s is a list type stat in the current group. */ void StatsListChangeStat(Statistic *s) { int index, top; if (s->num < 0 || s->num > ListBox_GetCount(hList)) { debug(("StatListChangeList got illegal stat #%d\n", (int) s->num)); return; } top = ListBox_GetTopIndex(hList); index = StatListFindItem(s->num); if (index == -1) { debug(("StatListChangeList got illegal stat #%d\n", (int) s->num)); return; } WindowBeginUpdate(hList); ListBox_DeleteString(hList, index); index = ListBox_AddString(hList, LookupNameRsc(s->name_res)); ListBox_SetItemData(hList, index, s); ListBox_SetTopIndex(hList, top); WindowEndUpdate(hList); }
/* * MenuRemoveSpell: Remove given spell from main menu. */ void MenuRemoveSpell(spell *sp) { int index = -1, i; HMENU submenu = NULL; if (spell_menu == NULL) return; for (i=0; i < num_schools; i++) { submenu = submenus[i]; if (submenu) { index = MenuFindItemByName(submenu, LookupNameRsc(sp->obj.name_res)); if (index != -1) break; } } if (index == -1) { debug(("MenuRemoveSpell failed to find spell %d in menu\n", sp->obj.id)); return; } RemoveMenu(submenu, index, MF_BYPOSITION); MenuRenumberSpells(); }
/* * StatsListDrawStat: Draw info about stat in stat list box. * selected is True iff the item is currently selected. */ void StatsListDrawStat(const DRAWITEMSTRUCT *lpdis, Bool selected, Bool bShowSpellIcon ) { HFONT hOldFont; Statistic *s; char str[MAXRSCSTRING + 10]; RECT r; int lastItem = ListBox_GetCount(lpdis->hwndItem) - 1; RECT rcWnd; GetClientRect(lpdis->hwndItem,&rcWnd); if (lpdis->rcItem.bottom > rcWnd.bottom) return; hOldFont = (HFONT) SelectObject(lpdis->hDC, GetFont(FONT_STATS)); s = (Statistic *) ListBox_GetItemData(hList, lpdis->itemID); if (s == NULL) return; sprintf(str, "%s %d%%", LookupNameRsc(s->name_res), s->list.value); SetBkMode(lpdis->hDC, TRANSPARENT); memcpy(&r, &lpdis->rcItem, sizeof(RECT)); r.left += ENCHANT_SIZE + 2; // Draw text with drop shadow SetTextColor(lpdis->hDC, GetColor(COLOR_STATSBGD)); //DrawText(lpdis->hDC, str, strlen(str), &r, DT_CENTER); DrawText( lpdis->hDC, str, strlen(str), &r, DT_LEFT ); OffsetRect(&r, 1, 1); SetTextColor(lpdis->hDC, selected ? GetColor(COLOR_HIGHLITE) : GetColor(COLOR_STATSFGD)); //DrawText(lpdis->hDC, str, strlen(str), &r, DT_CENTER); DrawText( lpdis->hDC, str, strlen(str), &r, DT_LEFT ); SelectObject(lpdis->hDC, hOldFont); switch (StatsGetCurrentGroup()) { AREA areaIcon; case STATS_SPELLS: case STATS_SKILLS: areaIcon.x = lpdis->rcItem.left; areaIcon.y = lpdis->rcItem.top; areaIcon.cx = ENCHANT_SIZE; //xxx areaIcon.cy = ENCHANT_SIZE; DrawObjectIcon(lpdis->hDC, s->list.icon, 0, True, &areaIcon, NULL, 0, 0, True); break; } if (lastItem == (int)lpdis->itemID) { RECT rcWnd; GetClientRect(lpdis->hwndItem,&rcWnd); rcWnd.top = lpdis->rcItem.bottom; if (rcWnd.top < rcWnd.bottom) InvalidateRect(lpdis->hwndItem,&rcWnd,TRUE); } }
/* * AliasSave: Save aliases to INI file. */ void AliasSave(void) { int i, len; char temp[10], text[MAX_ALIASLEN + 1]; char fullSection[255]; char destName[128]; char *srcName; player_info *playerInfo; destName[0] = '\0'; playerInfo = GetPlayerInfo(); srcName = LookupNameRsc(cinfo->player->name_res); len = strlen(srcName); for (i = 0; i < len; i++) { itoa(srcName[i], temp, 10); strcat(destName, temp); } strcpy(fullSection, alias_section); strcat(fullSection, destName); // Save the hotkey aliases. for (i=0; i < NUM_ALIASES; i++) { // Save function key aliases sprintf(temp, "F%d", i + 1); if (aliases[i].cr) strcpy(text, aliases[i].text); else sprintf(text, "%s~", aliases[i].text); WritePrivateProfileString(fullSection, temp, text, cinfo->ini_file); } strcpy(fullSection, command_section); strcat(fullSection, destName); // Save the command aliases. if (_nVerbAliases) { WritePrivateProfileSection(command_section, "\0\0\0", cinfo->ini_file); for (i = 0; i < _nVerbAliases; i++) { if (_apVerbAliases[i].verb[0]) { WritePrivateProfileString(command_section, _apVerbAliases[i].verb, _apVerbAliases[i].text, cinfo->ini_file); } } } }
void InterfaceNewRoom(void) { char buf[MAXRSCSTRING]; EnchantmentsNewRoom(); // Set main window title to show room name sprintf(buf, GetString(hInst, IDS_WINDOWTITLE), LookupNameRsc(cinfo->player->room_name_res)); SetWindowText(cinfo->hMain, buf); }
/* * MenuAddSpell: Add given spell to Spells submenu. */ void MenuAddSpell(spell *sp) { int num, index, len; char item_name[MAXRSCSTRING + 1], *name; HMENU submenu; int school = sp->school; if ((school < 0) || (school >= num_schools)) { debug(("MenuAddSpell got spell with bad school number %d\n", school)); return; } submenu = submenus[school]; if (NULL == submenu) { submenus[school] = CreatePopupMenu(); AppendMenu(spell_menu, MF_STRING | MF_POPUP | MF_BYPOSITION, (UINT) submenus[school], LookupNameRsc(schoolID[school])); submenu = submenus[school]; } num = GetMenuItemCount(submenu); name = LookupNameRsc(sp->obj.name_res); // Add in sorted order for (index = 0; index < num; index++) { len = GetMenuString(submenu, index, item_name, MAXRSCSTRING, MF_BYPOSITION); if (len == 0) continue; if (stricmp(item_name, name) >= 0) break; } // Check for adding to end if (index == num) index = -1; // Use ID_SPELL + (school * # per school)+ (# of spells) as menu id InsertMenu(submenu, index, MF_STRING | MF_BYPOSITION, ID_SPELL + num + sp->school * MAX_SPELLS_PER_SCHOOL, name); }
/* * FindSpellByName: Return the spell whose name best matches name. * Return SPELL_NOMATCH if no spell matches, or SPELL_AMBIGUOUS if more than one * spell matches equally well. */ spell *FindSpellByName(char *name) { list_type l; spell *sp, *best_spell = NULL; int match, max_match; Bool tied; // True if a different spell matches as well as best_spell char *ptr, *spell_name; max_match = 0; tied = False; for (l = spells; l != NULL; l = l->next) { sp = (spell *) (l->data); spell_name = LookupNameRsc(sp->obj.name_res); ptr = name; match = 0; while (*ptr != 0 && *spell_name != 0) { if (toupper(*ptr) != toupper(*spell_name)) { match = 0; break; } match++; ptr++; spell_name++; } // Check for exact match, or extra characters in search string if (*spell_name == 0) if (*ptr == 0) return sp; else continue; if (match > max_match) { max_match = match; best_spell = sp; tied = False; } else if (match == max_match) tied = True; } if (max_match == 0) return SPELL_NOMATCH; if (tied) return SPELL_AMBIGUOUS; return best_spell; }
/* * NewMusic: Start playing new music. type gives type of sound (MIDI, * music). rsc gives resource id of file. */ void NewMusic(WPARAM type, ID rsc) { char *filename, fname[MAX_PATH + FILENAME_MAX]; // NULL rsc => abort midi in progress if( !rsc ) { if( ( type == SOUND_MIDI ) && ( playing_midi ) ) { #ifdef M59_MSS AIL_end_sample( hseqImmediate ); #else mciSendCommand(midi_element, MCI_CLOSE, 0, 0); #endif playing_midi = False; } else if( ( type == SOUND_MUSIC ) && ( playing_music ) ) { #ifdef M59_MSS AIL_end_sample( hseqBackground ); #else mciSendCommand(midi_element, MCI_CLOSE, 0, 0); #endif playing_music = False; return; } return; } if( (filename = LookupNameRsc(rsc)) == NULL ) return; sprintf(fname, "%s\\%.*s", music_dir, FILENAME_MAX, filename); switch (type) { case SOUND_MIDI: PlayMidiFile(hMain, fname); #ifndef M59_MSS debug(("NewMusic MIDI, element = %d\n", midi_element)); #endif break; case SOUND_MUSIC: PlayMusicFile(hMain, fname); #ifndef M59_MSS debug(("NewMusic music, element = %d\n", midi_element)); #endif break; } }
/* * StatsListCreate: Create stats list box, and fill it with the given stats. */ void StatsListCreate(list_type stats) { list_type l; hList = CreateWindow("listbox", NULL, WS_CHILD | LBS_HASSTRINGS | LBS_SORT | LBS_OWNERDRAWFIXED | LBS_NOTIFY | LBS_NOINTEGRALHEIGHT, 0, 0, 0, 0, hStats, (HMENU) IDC_STATLIST, hInst, NULL); lpfnDefStatListProc = SubclassWindow(hList, StatsListProc); SetWindowFont(hList, GetFont(FONT_STATS), FALSE); for (l = stats; l != NULL; l = l->next) { int index; Statistic *s = (Statistic *) (l->data); index = ListBox_AddString(hList, LookupNameRsc(s->name_res)); ListBox_SetItemData(hList, index, s); } }
/* * SpellsGotSchools: Display spell school names in menu. This * must be done before the spells themselves arrive, since the spells * are added to the schools' submenus. */ void SpellsGotSchools(BYTE num, ID *schools) { int i; num_schools = num; submenus = (HMENU *) SafeMalloc(num_schools * sizeof(HMENU)); // Add spell schools to spell submenu for (i=0; i < num; i++) { schoolID[i] = schools[i]; submenus[i] = NULL; #if 0 submenus[i] = CreatePopupMenu(); InsertMenu(spell_menu, i, MF_STRING | MF_POPUP | MF_BYPOSITION, (UINT) submenus[i], LookupNameRsc(schools[i])); #endif } SafeFree(schools); }
/* * CharSpellsInit: Initialize spells tab page. spells is a list of Spell structures. */ void CharSpellsInit(HWND hDlg) { list_type l; int index; hPoints = GetDlgItem(hDlg, IDC_POINTSLEFT); SendMessage(hPoints, GRPH_COLORSET, GRAPHCOLOR_BAR, GetColor(COLOR_BAR2)); SendMessage(hPoints, GRPH_COLORSET, GRAPHCOLOR_BKGND, GetColor(COLOR_BAR3)); SendMessage(hPoints, GRPH_RANGESET, 0, SPELL_POINTS_INITIAL); // Set spell list contents hList1 = GetDlgItem(hDlg, IDC_SPELLIST1); hList2 = GetDlgItem(hDlg, IDC_SPELLIST2); for (l = spells; l != NULL; l = l->next) { Spell *s = (Spell *) (l->data); index = ListBox_AddString(hList1, LookupNameRsc(s->name_res)); ListBox_SetItemData(hList1, index, s); } ListBox_SetCurSel(hList1, 0); FORWARD_WM_COMMAND(hDlg, IDC_SPELLIST1, hList1, LBN_SELCHANGE, CharSpellsDialogProc); }
/* * CharSpellsCommand: Handle WM_COMMAND messages. */ void CharSpellsCommand(HWND hwnd, int id, HWND hwndCtl, UINT codeNotify) { int index1, index2; Spell *s; char temp[MAXAMOUNT + 1]; UserDidSomething(); switch (id) { case IDC_ADDSPELL: index1 = ListBox_GetCurSel(hList1); if (index1 == LB_ERR) break; s = (Spell *) ListBox_GetItemData(hList1, index1); // See if enough points to get spell if (s->cost > spell_points) break; spell_points -= s->cost; SendMessage(hPoints, GRPH_POSSET, 0, spell_points); index2 = ListBox_AddString(hList2, LookupNameRsc(s->name_res)); ListBox_SetItemData(hList2, index2, s); s->chosen = True; ListBox_DeleteString(hList1, index1); ListBox_SetCurSel(hList1, min(index1, ListBox_GetCount(hList1) - 1)); FORWARD_WM_COMMAND(hwnd, IDC_SPELLIST1, hList1, LBN_SELCHANGE, CharSpellsDialogProc); break; case IDC_REMOVESPELL: index2 = ListBox_GetCurSel(hList2); if (index2 == LB_ERR) break; s = (Spell *) ListBox_GetItemData(hList2, index2); spell_points += s->cost; SendMessage(hPoints, GRPH_POSSET, 0, spell_points); index1 = ListBox_AddString(hList1, LookupNameRsc(s->name_res)); ListBox_SetItemData(hList1, index1, s); s->chosen = False; ListBox_DeleteString(hList2, index2); ListBox_SetCurSel(hList2, min(index2, ListBox_GetCount(hList2) - 1)); FORWARD_WM_COMMAND(hwnd, IDC_SPELLIST2, hList2, LBN_SELCHANGE, CharSpellsDialogProc); MaybeEnableAddButton(hwnd); break; case IDC_SPELLIST1: if (codeNotify != LBN_SELCHANGE) break; index1 = ListBox_GetCurSel(hList1); if (index1 == LB_ERR) break; s = (Spell *) ListBox_GetItemData(hList1, index1); SetDlgItemText(hwnd, IDC_SPELLINFO, LookupNameRsc(s->desc_res)); sprintf(temp, "%d", s->cost); SetDlgItemText(hwnd, IDC_COST2, temp); MaybeEnableAddButton(hwnd); break; case IDC_SPELLIST2: if (codeNotify != LBN_SELCHANGE) break; index2 = ListBox_GetCurSel(hList2); if (index2 == LB_ERR) break; s = (Spell *) ListBox_GetItemData(hList2, index2); SetDlgItemText(hwnd, IDC_SPELLINFO, LookupNameRsc(s->desc_res)); sprintf(temp, "%d", s->cost); SetDlgItemText(hwnd, IDC_COST2, temp); break; default: CharTabPageCommand(hwnd, id, hwndCtl, codeNotify); return; } }
Bool WINAPI EventUserAction(int action, void *action_data) { int x, y; list_type objects; char buf[MAX_ADMIN]; object_node *obj; ID id; switch (action) { case A_QEDITOR: debug(("A_QEDITOR\n")); if (GetQEditorDlg() || GetGChannelDlg()) break; ShowQEditorDlg(); break; case A_GCHANNEL: debug(("A_GCHANNEL\n")); if (GetQEditorDlg() || GetGChannelDlg()) break; ShowGChannelDlg(); break; case A_LOOKMOUSE: /* user 'looks' on main window */ if (!GetQEditorDlg() && !GetGChannelDlg()) return True; if (!MouseToRoom(&x, &y)) return True; objects = GetObjects3D(x, y, 0, 0, 0); if (objects == NULL) return True; /* Get details of object */ obj = (object_node *) (objects->data); if (!obj) { debug(("clicked, but nothing\n")); return True; } strcpy(buf, LookupNameRsc(obj->name_res)); if (GetGChannelDlg() && (obj->flags & OF_PLAYER)) { debug(("gchannel needs to hear we clicked on '%s' (flags = 0x08X)\n", buf, obj->flags)); SendMessage(GetGChannelDlg(), DMDLGM_CLICKEDUSER, 0, (LPARAM)buf); return False; } if (GetQEditorDlg()) { debug(("qeditor needs to hear we clicked on '%s'\n", buf)); SendMessage(GetQEditorDlg(), DMDLGM_CLICKEDUSER, 0, (LPARAM)buf); return False; } break; case A_LOOKINVENTORY: /* user 'looks' on inventory window */ if (!GetQEditorDlg() /* && !GetGChannelDlg() */) return True; id = (ID)action_data; if (id == INVALID_ID) return True; break; default: return True; } return False; }
/* * DescDialogProc: Dialog procedure for dialog containing an * item's long description. */ BOOL CALLBACK DescDialogProc(HWND hDlg, UINT message, UINT wParam, LONG lParam) { DescDialogStruct *info; static HWND hwndBitmap; static Bool changed; // True when player has changed description HWND hEdit, hwndOK, hURL, hFixed; HDC hdc; HFONT hFont; RECT dlg_rect, edit_rect, fixed_rect; AREA area; char *desc, *str, url[MAX_URL + 1], *pPageBreak; DRAWITEMSTRUCT *lpdis; char descriptionBuffer[MAX_PAGE_DESCRIPTION_TEXT+1]; int height; info = (DescDialogStruct *) GetWindowLong(hDlg, DWL_USER); switch (message) { case WM_INITDIALOG: info = (DescDialogStruct *) lParam; /* Store structure in dialog box's extra bytes */ SetWindowLong(hDlg, DWL_USER, (long) info); hwndBitmap = GetDlgItem(hDlg, IDC_DESCBITMAP); hFixed = GetDlgItem(hDlg, IDC_DESCFIXED); hEdit = GetDlgItem(hDlg, IDC_DESCBOX); hwndOK = GetDlgItem(hDlg, IDOK); // Item Name. height = SetFontToFitText(info,GetDlgItem(hDlg, IDC_DESCNAME), (int)FONT_TITLES, info->name); SetDlgItemText(hDlg, IDC_DESCNAME, info->name); hdc = GetDC(hDlg); SetTextColor(hdc,GetPlayerNameColor(info->obj,info->name)); ReleaseDC(hDlg,hdc); // Item Description. hFont = GetFont(FONT_EDIT); SetWindowFont(hFixed, hFont, FALSE); SetWindowFont(hEdit, hFont, FALSE); str = info->description; if (str) { pPageBreak = strchr(str,PAGE_BREAK_CHAR); while (pPageBreak) { info->numPages++; str = pPageBreak+1; pPageBreak = strchr(str,PAGE_BREAK_CHAR); } info->numPages++; GetPageText(descriptionBuffer,info); Edit_SetText(hEdit, descriptionBuffer); } // Show fixed string, if appropriate if (info->fixed_string != NULL) { SetDlgItemText(hDlg, IDC_DESCFIXED, info->fixed_string); SetWindowFont(GetDlgItem(hDlg, IDC_DESCFIXED), GetFont(FONT_EDIT), FALSE); } // Can this player edit this object's description? if (info->flags & DF_EDITABLE) Edit_SetReadOnly(hEdit, FALSE); Edit_LimitText(hEdit, MAX_DESCRIPTION); if (!(info->flags & (DF_EDITABLE | DF_INSCRIBED)) && !str) { GetWindowRect(hFixed, &fixed_rect); GetWindowRect(hEdit, &edit_rect); UnionRect(&fixed_rect, &fixed_rect, &edit_rect); ScreenToClient(hDlg, (LPPOINT)(&fixed_rect)); ScreenToClient(hDlg, (LPPOINT)(&fixed_rect)+1); MoveWindow(hFixed, fixed_rect.left, fixed_rect.top, fixed_rect.right - fixed_rect.left, fixed_rect.bottom - fixed_rect.top, FALSE); ShowWindow(hEdit, SW_HIDE); } // Resize and move dialog controls GetWindowRect(hDlg, &dlg_rect); if (GetWindowLong(hEdit, GWL_STYLE) & WS_VISIBLE) { ShowWindow(hEdit, SW_HIDE); ResizeEditToFitText(hFixed, hFont); ResizeDialog(hDlg, &dlg_rect, desc_controls); ShowWindow(hEdit, SW_SHOW); } else { ResizeEditToFitText(hFixed, hFont); ResizeDialog(hDlg, &dlg_rect, desc_controls); } if (GetWindowLong(hEdit, GWL_STYLE) & WS_VISIBLE) { GetWindowRect(hFixed, &fixed_rect); GetWindowRect(hEdit, &edit_rect); height = fixed_rect.bottom-edit_rect.top; ScreenToClient(hDlg, (LPPOINT)(&edit_rect)); ScreenToClient(hDlg, (LPPOINT)(&edit_rect)+1); ShowWindow(hFixed, SW_HIDE); OffsetRect(&edit_rect, 0, height); MoveWindow(hEdit, edit_rect.left, edit_rect.top, edit_rect.right - edit_rect.left, edit_rect.bottom - edit_rect.top, FALSE); GetWindowRect(hDlg, &dlg_rect); ResizeEditToFitText(hEdit, hFont); ResizeDialog(hDlg, &dlg_rect, desc_controls); ShowWindow(hFixed, SW_SHOW); } CenterWindow(hDlg, GetParent(hDlg)); // Show URL, if appropriate if (info->url != NULL) { hURL = GetDlgItem(hDlg, IDC_URL); SetWindowText(hURL, info->url); SetWindowFont(hURL, GetFont(FONT_EDIT), FALSE); if (info->flags & DF_EDITABLE) Edit_SetReadOnly(hURL, FALSE); Edit_LimitText(hURL, MAX_URL); } // Show appropriate buttons if (!(desc_flags & DESC_GET)) DestroyWindow(GetDlgItem(hDlg, IDC_GET)); if (!(desc_flags & DESC_DROP)) DestroyWindow(GetDlgItem(hDlg, IDC_DROP)); if (!(desc_flags & DESC_USE)) DestroyWindow(GetDlgItem(hDlg, IDC_USE)); if (!(desc_flags & DESC_UNUSE)) DestroyWindow(GetDlgItem(hDlg, IDC_UNUSE)); if (!(desc_flags & DESC_INSIDE)) DestroyWindow(GetDlgItem(hDlg, IDC_INSIDE)); if (!(desc_flags & DESC_ACTIVATE)) DestroyWindow(GetDlgItem(hDlg, IDC_ACTIVATE)); if (!(desc_flags & DESC_APPLY)) DestroyWindow(GetDlgItem(hDlg, IDC_APPLY)); SetLookPageButtons(hDlg, info); #if 0 if (info->numPages < 2) { HWND hwnd = GetDlgItem(hDlg,IDC_NEXT); if (hwnd) DestroyWindow(GetDlgItem(hDlg, IDC_NEXT)); hwnd = GetDlgItem(hDlg,IDC_PREV); if (hwnd) DestroyWindow(GetDlgItem(hDlg, IDC_PREV)); } else { HWND hwnd = GetDlgItem(hDlg,IDC_PREV); if (hwnd) EnableWindow(hwnd,FALSE); } #endif SetFocus(hwndOK); hDescDialog = hDlg; changed = False; return FALSE; case WM_PAINT: InvalidateRect(hwndBitmap, NULL, TRUE); UpdateWindow(hwndBitmap); /* fall through */ case BK_ANIMATE: /* Draw object's bitmap */ hdc = GetDC(hwndBitmap); GetClientRect(hwndBitmap, &dlg_rect); RectToArea(&dlg_rect, &area); DrawStretchedObjectGroup(hdc, info->obj, info->obj->animate->group, &area, GetSysColorBrush(COLOR_3DFACE)); ReleaseDC(hwndBitmap, hdc); break; HANDLE_MSG(hDlg, WM_CTLCOLOREDIT, DialogCtlColor); HANDLE_MSG(hDlg, WM_CTLCOLORLISTBOX, DialogCtlColor); HANDLE_MSG(hDlg, WM_CTLCOLORSTATIC, DialogCtlColor); HANDLE_MSG(hDlg, WM_CTLCOLORDLG, DialogCtlColor); case WM_DESTROY: hDescDialog = NULL; return TRUE; case WM_DRAWITEM: // Draw player name in color that reflects murderer status lpdis = (DRAWITEMSTRUCT *) lParam; switch (lpdis->itemAction) { case ODA_SELECT: case ODA_DRAWENTIRE: SelectPalette(lpdis->hDC, hPal, FALSE); hFont = info->hFontTitle; SelectObject(lpdis->hDC, hFont); SetBkMode(lpdis->hDC, TRANSPARENT); str = LookupNameRsc(info->obj->name_res); SetTextColor(lpdis->hDC, NAME_COLOR_NORMAL_BG); DrawText(lpdis->hDC, str, strlen(str), &lpdis->rcItem, DT_LEFT | DT_VCENTER | DT_NOPREFIX); OffsetRect(&lpdis->rcItem, -1, -1); SetTextColor(lpdis->hDC, GetPlayerNameColor(info->obj, info->name)); DrawText(lpdis->hDC, str, strlen(str), &lpdis->rcItem, DT_LEFT | DT_VCENTER | DT_NOPREFIX); break; } return TRUE; case WM_COMMAND: switch(GET_WM_COMMAND_ID(wParam, lParam)) { case IDC_PREV: if (info->currentPage > 0) info->currentPage--; GetPageText(descriptionBuffer,info); SetLookPageButtons(hDlg, info); Edit_SetText(GetDlgItem(hDlg, IDC_DESCBOX), descriptionBuffer); #if 0 EnableWindow(GetDlgItem(hDlg,IDC_PREV),info->currentPage > 0); EnableWindow(GetDlgItem(hDlg,IDC_NEXT),info->currentPage < info->numPages-1); #endif return TRUE; case IDC_NEXT: if (info->currentPage < info->numPages-1) info->currentPage++; GetPageText(descriptionBuffer,info); Edit_SetText(GetDlgItem(hDlg, IDC_DESCBOX), descriptionBuffer); SetLookPageButtons(hDlg, info); #if 0 EnableWindow(GetDlgItem(hDlg,IDC_PREV),info->currentPage > 0); EnableWindow(GetDlgItem(hDlg,IDC_NEXT),info->currentPage < info->numPages-1); #endif return TRUE; case IDC_GET: RequestPickup(info->obj->id); EndDialog(hDlg, 0); return TRUE; case IDC_DROP: // Drop all of number items info->obj->temp_amount = info->obj->amount; RequestDrop(info->obj); EndDialog(hDlg, 0); return TRUE; case IDC_USE: // If player isn't holding the object (i.e. there's a Get button), pick object up first if (IsWindowVisible(GetDlgItem(hDlg, IDC_GET))) RequestPickup(info->obj->id); RequestUse(info->obj->id); EndDialog(hDlg, 0); return TRUE; case IDC_UNUSE: RequestUnuse(info->obj->id); EndDialog(hDlg, 0); return TRUE; case IDC_INSIDE: RequestObjectContents(info->obj->id); EndDialog(hDlg, 0); return TRUE; case IDC_ACTIVATE: RequestActivate(info->obj->id); EndDialog(hDlg, 0); return TRUE; case IDC_APPLY: StartApply(info->obj->id); EndDialog(hDlg, 0); return TRUE; case IDC_DESCBOX: if (GET_WM_COMMAND_CMD(wParam, lParam) != EN_CHANGE) break; changed = True; return TRUE; case IDC_URLBUTTON: hURL = GetDlgItem(hDlg, IDC_URL); Edit_GetText(hURL, url, MAX_URL); WebLaunchBrowser(url); return TRUE; case IDOK: // Send new description if changed if (changed) { desc = (char *) SafeMalloc(MAX_DESCRIPTION + 1); GetDlgItemText(hDlg, IDC_DESCBOX, desc, MAX_DESCRIPTION); RequestChangeDescription(info->obj->id, desc); SafeFree(desc); } // Send new URL if changed if (info->url != NULL) { GetDlgItemText(hDlg, IDC_URL, url, MAX_URL); if (strcmp(url, info->url)) RequestChangeURL(player.id, url); } // FALLTHRU case IDCANCEL: SetWindowFont(GetDlgItem(hDlg,IDC_DESCNAME), GetFont(FONT_TITLES), FALSE); if (info->hFontTitle && info->hFontTitle != GetFont(FONT_TITLES)) DeleteObject(info->hFontTitle); info->hFontTitle = NULL; EndDialog(hDlg, IDOK == GET_WM_COMMAND_ID(wParam, lParam)); return TRUE; } break; } return FALSE; }
BOOL CALLBACK SendOfferDialogProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) { static HWND hwndSend, hwndReceive; /* Subwindows */ switch (message) { case WM_INITDIALOG: hSendOfferDlg = hDlg; CenterWindow(hDlg, hMain); hwndSend = GetDlgItem(hDlg, IDC_OFFERSEND); hwndReceive = GetDlgItem(hDlg, IDC_OFFERRECEIVE); SendMessage(hDlg, BK_SETDLGFONTS, 0, 0); // Set up owner drawn boxes SetWindowLong(hwndSend, GWL_USERDATA, OD_DRAWOBJ); SetWindowLong(hwndReceive, GWL_USERDATA, OD_DRAWOBJ); SendInfo = (SendOfferDialogStruct *) lParam; /* Display offered items in list */ ItemListSetContents(hwndSend, SendInfo->items, TRUE); // boolean is to list quantities /* Subclass list boxes */ lpfnDefListProc = SubclassWindow(hwndSend, OfferListProc); SubclassWindow(hwndReceive, OfferListProc); /* Display receiver's name */ Edit_SetText(GetDlgItem(hDlg, IDC_OFFEREDIT), LookupNameRsc(SendInfo->receiver_name)); /* Gray out "Accept" button until counteroffer arrives */ ShowWindow(hwndReceive, SW_HIDE); EnableWindow(GetDlgItem(hDlg, IDOK), FALSE); return TRUE; case WM_ACTIVATE: if (wParam == 0) hCurrentDlg = NULL; else hCurrentDlg = hDlg; return TRUE; case BK_SETDLGFONTS: SetWindowFont(GetDlgItem(hDlg, IDC_OFFEREDIT), GetFont(FONT_LIST), TRUE); return TRUE; case BK_SETDLGCOLORS: InvalidateRect(hDlg, NULL, TRUE); return TRUE; case WM_COMPAREITEM: return ItemListCompareItem(hDlg, (const COMPAREITEMSTRUCT *) lParam); case WM_MEASUREITEM: ItemListMeasureItem(hDlg, (MEASUREITEMSTRUCT *) lParam); return TRUE; case WM_DRAWITEM: return ItemListDrawItemNoSelect(hDlg, (const DRAWITEMSTRUCT *)(lParam)); HANDLE_MSG(hDlg, WM_CTLCOLOREDIT, DialogCtlColor); HANDLE_MSG(hDlg, WM_CTLCOLORLISTBOX, DialogCtlColor); HANDLE_MSG(hDlg, WM_CTLCOLORSTATIC, DialogCtlColor); HANDLE_MSG(hDlg, WM_CTLCOLORDLG, DialogCtlColor); HANDLE_MSG(hDlg, WM_INITMENUPOPUP, InitMenuPopupHandler); case BK_COUNTEROFFER: /* Update receive list */ receive_items = (list_type) lParam; ItemListSetContents(hwndReceive, receive_items, True); /* Enable Accept button */ ShowWindow(hwndReceive, SW_NORMAL); EnableWindow(GetDlgItem(hDlg, IDOK), TRUE); SetWindowText(GetDlgItem(hDlg, IDC_MESSAGE), GetString(hInst, IDS_GOTOFFER)); return TRUE; case WM_CLOSE: SendCancelOffer(); /* fall through */ case BK_OFFERDONE: SendOfferEndDialog(hDlg); break; case WM_COMMAND: switch(GET_WM_COMMAND_ID(wParam, lParam)) { case IDC_OFFERSEND: case IDC_OFFERRECEIVE: /* Double click ==> look at item */ if (GET_WM_COMMAND_CMD(wParam, lParam) == LBN_DBLCLK) { RequestLook(ItemListGetId(GET_WM_COMMAND_HWND(wParam, lParam))); SetDescParams(hDlg, DESC_NONE); } return TRUE; case IDCANCEL: SendCancelOffer(); SendOfferEndDialog(hDlg); return TRUE; case IDOK: SendAcceptOffer(); SendOfferEndDialog(hDlg); return TRUE; } break; } return FALSE; }
/* * AliasInit: Read aliases from INI file and set them up. */ void AliasInit(void) { int i, len; char temp[10]; char fullSection[255]; char destName[128]; char *srcName; WORD command; player_info *playerInfo; destName[0] = '\0'; playerInfo = GetPlayerInfo(); // This was incorrectly being called before the player's resource was known, // giving an unknown resource dialog box every time the game was entered. // Unfortunately, players' aliases were then written to disk under with // the default "<Unknown>" player name encoded in the INI preferences file. // In order not to lose everyone's saved aliases, we have to emulate that // old behavior. if (cinfo->player->name_res == 0) srcName = "<Unknown>"; else srcName = LookupNameRsc(cinfo->player->name_res); len = strlen(srcName); for (i = 0; i < len; i++) { itoa(srcName[i], temp, 10); strcat(destName, temp); } strcpy(fullSection, alias_section); strcat(fullSection, destName); // Hot-Key Aliases for (i = 0; i < NUM_ALIASES; i++) { // Read function key aliases sprintf(temp, "F%d", i + 1); //GetPrivateProfileString(alias_section, temp, aliases[i].text, GetPrivateProfileString(fullSection, temp, aliases[i].text, aliases[i].text, MAX_ALIASLEN, cinfo->ini_file); // Check for CR len = strlen(aliases[i].text); if (len > 0 && aliases[i].text[len - 1] == '~') { command = A_TEXTINSERT; aliases[i].text[len - 1] = 0; aliases[i].cr = False; } else { command = A_TEXTCOMMAND; aliases[i].cr = True; } if (gbClassicKeys) AliasSetKey(interface_key_table, aliases[i].key, KEY_NONE, command, aliases[i].text); else AliasSetKey(gCustomKeys, aliases[i].key, KEY_NONE, command, aliases[i].text); AliasSetKey(inventory_key_table, aliases[i].key, KEY_NONE, command, aliases[i].text); } }
BOOL CALLBACK PostNewsDialogProc(HWND hDlg, UINT message, UINT wParam, LONG lParam) { static HWND hEdit, hSubject; static PostNewsDialogStruct *info; char *buf, subject[MAX_SUBJECT]; int len; MINMAXINFO *lpmmi; switch (message) { case WM_INITDIALOG: CenterWindow(hDlg, cinfo->hMain); info = (PostNewsDialogStruct *) lParam; hEdit = GetDlgItem(hDlg, IDC_NEWSEDIT); hSubject = GetDlgItem(hDlg, IDC_SUBJECT); Edit_LimitText(hEdit, MAXARTICLE); SetWindowFont(hEdit, GetFont(FONT_MAIL), TRUE); Edit_LimitText(hSubject, MAX_SUBJECT - 1); SetWindowFont(hSubject, GetFont(FONT_MAIL), TRUE); /* Store dialog rectangle in case of resize */ GetWindowRect(hDlg, &dlg_rect); /* Set default subject if appropriate */ if (info->subject != NULL) { MakeReplySubject(info->subject, MAX_SUBJECT); Edit_SetText(hSubject, info->subject); SetFocus(hEdit); } else SetFocus(hSubject); /* Display group name */ SetWindowText(GetDlgItem(hDlg, IDC_GROUPNAME), LookupNameRsc(info->group_name_rsc)); EnableWindow(GetDlgItem(hDlg, IDOK), FALSE); hPostNewsDialog = hDlg; return FALSE; HANDLE_MSG(hDlg, WM_CTLCOLOREDIT, MailCtlColor); HANDLE_MSG(hDlg, WM_CTLCOLORLISTBOX, MailCtlColor); HANDLE_MSG(hDlg, WM_CTLCOLORSTATIC, MailCtlColor); HANDLE_MSG(hDlg, WM_CTLCOLORDLG, MailCtlColor); case WM_SIZE: ResizeDialog(hDlg, &dlg_rect, newssend_controls); return TRUE; case WM_GETMINMAXINFO: lpmmi = (MINMAXINFO *) lParam; lpmmi->ptMinTrackSize.x = 200; lpmmi->ptMinTrackSize.y = 300; return 0; case WM_DESTROY: hPostNewsDialog = NULL; if (exiting) PostMessage(cinfo->hMain, BK_MODULEUNLOAD, 0, MODULE_ID); return TRUE; case WM_COMMAND: UserDidSomething(); switch(GET_WM_COMMAND_ID(wParam, lParam)) { case IDC_NEWSEDIT: if (GET_WM_COMMAND_CMD(wParam, lParam) != EN_CHANGE) return TRUE; /* Only allow user to post when article is nonempty */ if (Edit_GetTextLength(hEdit) > 0) EnableWindow(GetDlgItem(hDlg, IDOK), TRUE); else EnableWindow(GetDlgItem(hDlg, IDOK), FALSE); return TRUE; case IDOK: /* Get title and article; post article */ Edit_GetText(hSubject, subject, MAX_SUBJECT); len = Edit_GetTextLength(hEdit); buf = (char *) SafeMalloc(len + 1); Edit_GetText(hEdit, buf, len + 1); SendArticle(info->newsgroup, subject, buf); SafeFree(buf); EndDialog(hDlg, IDOK); return TRUE; case IDCANCEL: EndDialog(hDlg, IDCANCEL); return TRUE; } } return FALSE; }
/* * DisplayNumericStat: Display the given numeric type stat from the current group on the * main window. */ void DisplayNumericStat(Statistic *s) { RECT r; HDC hdc; HFONT hOldFont; char *name, *str; AREA stats_area; AREA a; // ajw - Avoid drawing if Inventory is selected as the "group". if( StatsGetCurrentGroup() == STATS_INVENTORY ) return; StatsGetArea(&stats_area); r.left = 0; r.right = stats_area.cx / 2; r.top = s->y; r.bottom = r.top + s->cy; /* If stat is out of stats area, abort */ if (r.bottom > stats_area.cy || s->num <= top_stat) return; hdc = GetDC(hStats); // DrawWindowBackground(hdc, &r, stats_area.x + r.left, stats_area.y + r.top); DrawWindowBackgroundColor( pinventory_bkgnd(), hdc, &r, stats_area.x + r.left, stats_area.y + r.top, -1 ); hOldFont = (HFONT) SelectObject(hdc, GetFont(FONT_STATS)); SetBkMode(hdc, TRANSPARENT); name = LookupNameRsc(s->name_res); // Draw with drop shadow SetTextColor(hdc, GetColor(COLOR_STATSBGD)); DrawText(hdc, name, strlen(name), &r, DT_LEFT); OffsetRect(&r, 1, 1); SetTextColor(hdc, GetColor(COLOR_STATSFGD)); DrawText(hdc, name, strlen(name), &r, DT_LEFT); switch (s->numeric.tag) { case STAT_RES: r.left = stats_area.cx / 2; r.right = stats_area.cx; DrawWindowBackgroundColor( pinventory_bkgnd(), hdc, &r, stats_area.x + r.left, stats_area.y + r.top, -1 ); str = LookupNameRsc(s->numeric.value); DrawText(hdc, str, strlen(str), &r, DT_RIGHT); break; case STAT_INT: // Draw background around stat bar a.x = stats_area.cx / 2; a.cx = stats_bar_width; a.y = s->y + (s->cy - STATS_BAR_HEIGHT) / 2; a.cy = STATS_BAR_HEIGHT; InterfaceDrawBarBorder( pinventory_bkgnd(), hdc, &a ); break; } SelectObject(hdc, hOldFont); ReleaseDC(hStats, hdc); InvalidateRect( s->hControl, NULL, FALSE ); }
BOOL CALLBACK RcvOfferDialogProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) { static HWND hwndSend, hwndReceive; switch (message) { case WM_INITDIALOG: CenterWindow(hDlg, hMain); hwndSend = GetDlgItem(hDlg, IDC_OFFERSEND); hwndReceive = GetDlgItem(hDlg, IDC_OFFERRECEIVE); SendMessage(hDlg, BK_SETDLGFONTS, 0, 0); // Set up owner drawn boxes SetWindowLong(hwndSend, GWL_USERDATA, OD_DRAWOBJ); SetWindowLong(hwndReceive, GWL_USERDATA, OD_DRAWOBJ); RcvInfo = (RcvOfferDialogStruct *) lParam; /* Display offered items in list */ ItemListSetContents(hwndReceive, RcvInfo->items, True); /* Subclass list boxes */ lpfnDefListProc = (WNDPROC) GetWindowLong(hwndSend, GWL_WNDPROC); SubclassWindow(hwndSend, OfferListProc); SubclassWindow(hwndReceive, OfferListProc); /* Display receiver's name */ Edit_SetText(GetDlgItem(hDlg, IDC_OFFEREDIT), LookupNameRsc(RcvInfo->sender_name)); ShowWindow(hDlg, SW_HIDE); hRcvOfferDlg = hDlg; return TRUE; case WM_ACTIVATE: if (wParam == 0) hCurrentDlg = NULL; else hCurrentDlg = hDlg; return TRUE; case BK_SETDLGFONTS: SetWindowFont(GetDlgItem(hDlg, IDC_OFFEREDIT), GetFont(FONT_LIST), TRUE); return TRUE; case BK_SETDLGCOLORS: InvalidateRect(hDlg, NULL, TRUE); return TRUE; case WM_COMPAREITEM: return ItemListCompareItem(hDlg, (const COMPAREITEMSTRUCT *) lParam); case WM_MEASUREITEM: ItemListMeasureItem(hDlg, (MEASUREITEMSTRUCT *) lParam); return TRUE; case WM_DRAWITEM: return ItemListDrawItemNoSelect(hDlg, (const DRAWITEMSTRUCT *)(lParam)); HANDLE_MSG(hDlg, WM_CTLCOLOREDIT, DialogCtlColor); HANDLE_MSG(hDlg, WM_CTLCOLORLISTBOX, DialogCtlColor); HANDLE_MSG(hDlg, WM_CTLCOLORSTATIC, DialogCtlColor); HANDLE_MSG(hDlg, WM_CTLCOLORDLG, DialogCtlColor); HANDLE_MSG(hDlg, WM_INITMENUPOPUP, InitMenuPopupHandler); case WM_CLOSE: SendCancelOffer(); /* fall through */ case BK_OFFERDONE: RcvOfferEndDialog(hDlg); return TRUE; case BK_COUNTEROFFERED: /* Display items we counteroffered */ send_items = (list_type) lParam; ItemListSetContents(hwndSend, send_items, True); return TRUE; case WM_COMMAND: switch(GET_WM_COMMAND_ID(wParam, lParam)) { case IDC_OFFERSEND: case IDC_OFFERRECEIVE: /* Double click ==> look at item */ if (GET_WM_COMMAND_CMD(wParam, lParam) == LBN_DBLCLK) { RequestLook(ItemListGetId(GET_WM_COMMAND_HWND(wParam, lParam))); SetDescParams(hDlg, DESC_NONE); } return TRUE; case IDC_SETITEMS: /* Close any other look dialogs that are up */ AbortLookList(); /* Get list of items from inventory & tell server */ send_items = UserInventoryList(hDlg, GetString(hInst, IDS_OFFERITEMS)); /* fall through */ case IDOK: /* Send counteroffer */ RequestCounteroffer(send_items); send_items = ObjectListDestroy(send_items); EnableWindow(GetDlgItem(hDlg, IDOK), FALSE); EnableWindow(GetDlgItem(hDlg, IDC_SETITEMS), FALSE); SetWindowText(GetDlgItem(hDlg, IDC_MESSAGE), GetString(hInst, IDS_WAITRESPONSE)); return TRUE; case IDCANCEL: SendCancelOffer(); RcvOfferEndDialog(hDlg); return TRUE; } break; } return FALSE; }