Index: ActivityDoc.cpp =================================================================== RCS file: /cvs/mushclient/ActivityDoc.cpp,v retrieving revision 1.5 retrieving revision 1.6 diff -c -r1.5 -r1.6 *** ActivityDoc.cpp 17 Apr 2007 06:07:16 -0000 1.5 --- ActivityDoc.cpp 6 Jul 2009 05:58:56 -0000 1.6 *************** *** 103,109 **** --- 103,112 ---- // use default world file directory dlgFile.m_ofn.lpstrInitialDir = Make_Absolute_Path (App.m_strDefaultWorldFileDirectory); + ChangeToFileBrowsingDirectory (); int nResult = dlgFile.DoModal(); + ChangeToStartupDirectory (); + fileName.ReleaseBuffer(); if (nResult != IDOK) Index: AsciiArtDlg.cpp =================================================================== RCS file: /cvs/mushclient/AsciiArtDlg.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -c -r1.3 -r1.4 *** AsciiArtDlg.cpp 11 Jun 2007 10:42:08 -0000 1.3 --- AsciiArtDlg.cpp 6 Jul 2009 05:58:56 -0000 1.4 *************** *** 84,90 **** OFN_HIDEREADONLY|OFN_FILEMUSTEXIST, "Figlet font files (*.flf)|*.flf|All files (*.*)|*.*||"); dlg.m_ofn.lpstrTitle = "Select font file"; ! if (dlg.DoModal() != IDOK) return; m_ctlFont.SetWindowText (dlg.GetPathName()); } --- 84,95 ---- OFN_HIDEREADONLY|OFN_FILEMUSTEXIST, "Figlet font files (*.flf)|*.flf|All files (*.*)|*.*||"); dlg.m_ofn.lpstrTitle = "Select font file"; ! ! ChangeToFileBrowsingDirectory (); ! int nResult = dlg.DoModal(); ! ChangeToStartupDirectory (); ! ! if (nResult != IDOK) return; m_ctlFont.SetWindowText (dlg.GetPathName()); } Index: CHATSOCK.CPP =================================================================== RCS file: /cvs/mushclient/CHATSOCK.CPP,v retrieving revision 1.40 retrieving revision 1.41 diff -c -r1.40 -r1.41 *** CHATSOCK.CPP 13 Jun 2007 06:16:04 -0000 1.40 --- CHATSOCK.CPP 6 Jul 2009 05:58:56 -0000 1.41 *************** *** 1170,1178 **** if (!m_pDoc->m_strChatSaveDirectory.IsEmpty ()) filedlg.m_ofn.lpstrInitialDir = m_pDoc->m_strChatSaveDirectory; if (filedlg.DoModal () != IDOK) bWanted = false; // cancelled dialog ! m_strOurFileName = filedlg.GetPathName (); } else --- 1170,1180 ---- if (!m_pDoc->m_strChatSaveDirectory.IsEmpty ()) filedlg.m_ofn.lpstrInitialDir = m_pDoc->m_strChatSaveDirectory; + ChangeToFileBrowsingDirectory (); if (filedlg.DoModal () != IDOK) bWanted = false; // cancelled dialog ! ChangeToStartupDirectory (); ! m_strOurFileName = filedlg.GetPathName (); } else Index: GlobalPrefs.cpp =================================================================== RCS file: /cvs/mushclient/GlobalPrefs.cpp,v retrieving revision 1.39 retrieving revision 1.40 diff -c -r1.39 -r1.40 *** GlobalPrefs.cpp 22 Feb 2009 03:10:14 -0000 1.39 --- GlobalPrefs.cpp 6 Jul 2009 05:58:56 -0000 1.40 *************** *** 117,123 **** GetDlgItemText(IDC_DEFAULT_DIRECTORY_NAME, strStartingDirectory); dlg.m_ofn.lpstrInitialDir = strStartingDirectory; ! if (dlg.DoModal() == IDOK) { CListBox* pList = (CListBox*) GetDlgItem(IDC_WORLD_LIST); ASSERT_VALID(pList); --- 117,127 ---- GetDlgItemText(IDC_DEFAULT_DIRECTORY_NAME, strStartingDirectory); dlg.m_ofn.lpstrInitialDir = strStartingDirectory; ! ChangeToFileBrowsingDirectory (); ! int nResult = dlg.DoModal(); ! ChangeToStartupDirectory (); ! ! if (nResult == IDOK) { CListBox* pList = (CListBox*) GetDlgItem(IDC_WORLD_LIST); ASSERT_VALID(pList); *************** *** 902,908 **** else strcpy (filedlg.m_ofn.lpstrFile, suggested_name); ! if (filedlg.DoModal () != IDOK) return true; // cancelled dialog strPathName = filedlg.GetPathName (); --- 906,916 ---- else strcpy (filedlg.m_ofn.lpstrFile, suggested_name); ! ChangeToFileBrowsingDirectory (); ! int nResult = filedlg.DoModal(); ! ChangeToStartupDirectory (); ! ! if (nResult != IDOK) return true; // cancelled dialog strPathName = filedlg.GetPathName (); *************** *** 1477,1483 **** filedlg.m_ofn.lpstrTitle = "Tray icon"; ! if (filedlg.DoModal () != IDOK) return; // cancelled dialog m_strTrayIconFileName = filedlg.GetPathName (); --- 1485,1495 ---- filedlg.m_ofn.lpstrTitle = "Tray icon"; ! ChangeToFileBrowsingDirectory (); ! int nResult = filedlg.DoModal(); ! ChangeToStartupDirectory (); ! ! if (nResult != IDOK) return; // cancelled dialog m_strTrayIconFileName = filedlg.GetPathName (); *************** *** 1585,1591 **** GetDlgItemText(IDC_PLUGINS_DIRECTORY_NAME, strStartingDirectory); dlg.m_ofn.lpstrInitialDir = strStartingDirectory; ! if (dlg.DoModal() == IDOK) { CListBox* pList = (CListBox*) GetDlgItem(IDC_PLUGIN_LIST); ASSERT_VALID(pList); --- 1597,1607 ---- GetDlgItemText(IDC_PLUGINS_DIRECTORY_NAME, strStartingDirectory); dlg.m_ofn.lpstrInitialDir = strStartingDirectory; ! ChangeToFileBrowsingDirectory (); ! int nResult = dlg.DoModal(); ! ChangeToStartupDirectory (); ! ! if (nResult == IDOK) { CListBox* pList = (CListBox*) GetDlgItem(IDC_PLUGIN_LIST); ASSERT_VALID(pList); Index: ImportXMLdlg.cpp =================================================================== RCS file: /cvs/mushclient/ImportXMLdlg.cpp,v retrieving revision 1.12 retrieving revision 1.13 diff -c -r1.12 -r1.13 *** ImportXMLdlg.cpp 13 Jun 2007 06:16:04 -0000 1.12 --- ImportXMLdlg.cpp 6 Jul 2009 05:58:56 -0000 1.13 *************** *** 97,103 **** filedlg.m_ofn.lpstrTitle = "Import"; ! if (filedlg.DoModal () != IDOK) return; // cancelled dialog --- 97,107 ---- filedlg.m_ofn.lpstrTitle = "Import"; ! ChangeToFileBrowsingDirectory (); ! int nResult = filedlg.DoModal(); ! ChangeToStartupDirectory (); ! ! if (nResult != IDOK) return; // cancelled dialog Index: MUSHclient.cpp =================================================================== RCS file: /cvs/mushclient/MUSHclient.cpp,v retrieving revision 1.100 retrieving revision 1.102 diff -c -r1.100 -r1.102 *** MUSHclient.cpp 23 Jun 2009 23:39:23 -0000 1.100 --- MUSHclient.cpp 16 Jul 2009 01:48:53 -0000 1.102 *************** *** 78,83 **** --- 78,84 ---- // working directory at login time char working_dir [_MAX_PATH]; + char file_browsing_dir [_MAX_PATH]; bool bWinNT; bool bWin95; *************** *** 240,248 **** BOOL CMUSHclientApp::InitInstance() { - SetRegistryKey ("Gammon Software Solutions"); - - char fullfilename [MAX_PATH]; if (GetModuleFileName (NULL, fullfilename, sizeof (fullfilename))) --- 241,246 ---- *************** *** 264,269 **** --- 262,285 ---- if (working_dir [strlen (working_dir) - 1] != '\\') strcat (working_dir, "\\"); + // where we do file browsing from + strcpy (file_browsing_dir, working_dir); + + + // First free the string that was allocated by MFC in the startup + // of CWinApp. The string is allocated before InitInstance is + // called. + free((void*)m_pszProfileName); + + // Change the name of the .INI file--CWinApp destructor will free + // the memory. + + CString strIniFile (working_dir); + strIniFile += "MUSHclient.ini"; + + m_pszProfileName=_tcsdup(strIniFile); + + // in case of error dialogs, etc. m_strFixedPitchFont = "FixedSys"; m_iFixedPitchFontSize = 9; *************** *** 753,760 **** // Show first welcome ! BOOL firsttime = db_get_int ("control", "First time", ! GetProfileInt ("Miscellaneous", "First time", 1)); UINT version = 0; if (firsttime) --- 769,775 ---- // Show first welcome ! BOOL firsttime = db_get_int ("control", "First time", 1); UINT version = 0; if (firsttime) *************** *** 813,820 **** { ! version = db_get_int ("control", "Version", ! GetProfileInt ("Miscellaneous", "Version", 0)); if (version < THISVERSION) // THISVERSION is defined at start of this module { --- 828,834 ---- { ! version = db_get_int ("control", "Version", 0); if (version < THISVERSION) // THISVERSION is defined at start of this module { Index: MUSHclient.rc =================================================================== RCS file: /cvs/mushclient/MUSHclient.rc,v retrieving revision 1.234 retrieving revision 1.235 diff -c -r1.234 -r1.235 *** MUSHclient.rc 25 Mar 2009 20:46:12 -0000 1.234 --- MUSHclient.rc 6 Jul 2009 05:58:56 -0000 1.235 *************** *** 75,82 **** // VS_VERSION_INFO VERSIONINFO ! FILEVERSION 4,0,41,0 ! PRODUCTVERSION 4,0,41,0 FILEFLAGSMASK 0x3fL #ifdef _DEBUG FILEFLAGS 0x1L --- 75,82 ---- // VS_VERSION_INFO VERSIONINFO ! FILEVERSION 4,0,42,0 ! PRODUCTVERSION 4,0,42,0 FILEFLAGSMASK 0x3fL #ifdef _DEBUG FILEFLAGS 0x1L *************** *** 94,107 **** VALUE "Comments", "MUSHclient - a client program for playing MUD games\0" VALUE "CompanyName", "Gammon Software Solutions\0" VALUE "FileDescription", "MUSHclient\0" ! VALUE "FileVersion", "4.41\0" VALUE "InternalName", "MUSHCLIENT\0" VALUE "LegalCopyright", "Copyright © 2009 Gammon Software Solutions\0" VALUE "LegalTrademarks", "\0" VALUE "OriginalFilename", "MUSHCLIENT.EXE\0" VALUE "PrivateBuild", "\0" VALUE "ProductName", "MUSHclient\0" ! VALUE "ProductVersion", "4.41\0" VALUE "SpecialBuild", "\0" END END --- 94,107 ---- VALUE "Comments", "MUSHclient - a client program for playing MUD games\0" VALUE "CompanyName", "Gammon Software Solutions\0" VALUE "FileDescription", "MUSHclient\0" ! VALUE "FileVersion", "4.42\0" VALUE "InternalName", "MUSHCLIENT\0" VALUE "LegalCopyright", "Copyright © 2009 Gammon Software Solutions\0" VALUE "LegalTrademarks", "\0" VALUE "OriginalFilename", "MUSHCLIENT.EXE\0" VALUE "PrivateBuild", "\0" VALUE "ProductName", "MUSHclient\0" ! VALUE "ProductVersion", "4.42\0" VALUE "SpecialBuild", "\0" END END Index: Mapping.cpp =================================================================== RCS file: /cvs/mushclient/Mapping.cpp,v retrieving revision 1.15 retrieving revision 1.16 diff -c -r1.15 -r1.16 *** Mapping.cpp 12 Aug 2008 01:29:06 -0000 1.15 --- Mapping.cpp 6 Jul 2009 05:58:56 -0000 1.16 *************** *** 320,326 **** } else // not comment // if same as before, count them ! if (str == strLastDir) iCount++; else OUTPUT_PREVIOUS_ONE; --- 320,326 ---- } else // not comment // if same as before, count them ! if (str == strLastDir && iCount <= 98) iCount++; else OUTPUT_PREVIOUS_ONE; Index: NameGeneration.cpp =================================================================== RCS file: /cvs/mushclient/NameGeneration.cpp,v retrieving revision 1.6 retrieving revision 1.7 diff -c -r1.6 -r1.7 *** NameGeneration.cpp 22 Feb 2009 03:10:14 -0000 1.6 --- NameGeneration.cpp 6 Jul 2009 05:58:56 -0000 1.7 *************** *** 57,63 **** OFN_HIDEREADONLY|OFN_FILEMUSTEXIST, "Name files (*.txt;*.nam)|*.txt;*.nam|All files (*.*)|*.*||"); dlg.m_ofn.lpstrTitle = "Select names file"; ! if (dlg.DoModal() != IDOK) return; strFileName = dlg.GetPathName(); --- 57,67 ---- OFN_HIDEREADONLY|OFN_FILEMUSTEXIST, "Name files (*.txt;*.nam)|*.txt;*.nam|All files (*.*)|*.*||"); dlg.m_ofn.lpstrTitle = "Select names file"; ! ChangeToFileBrowsingDirectory (); ! int nResult = dlg.DoModal(); ! ChangeToStartupDirectory (); ! ! if (nResult != IDOK) return; strFileName = dlg.GetPathName(); Index: OtherTypes.h =================================================================== RCS file: /cvs/mushclient/OtherTypes.h,v retrieving revision 1.107 retrieving revision 1.109 diff -c -r1.107 -r1.109 *** OtherTypes.h 23 Jun 2009 23:39:23 -0000 1.107 --- OtherTypes.h 6 Jul 2009 21:35:01 -0000 1.109 *************** *** 1149,1154 **** --- 1149,1155 ---- #define MINIWINDOW_DRAW_UNDERNEATH 0x01 // draw underneath scrolling text #define MINIWINDOW_ABSOLUTE_LOCATION 0x02 // use m_iLeft, m_iTop to position #define MINIWINDOW_TRANSPARENT 0x04 // draw transparently, using m_iBackgroundColour + #define MINIWINDOW_IGNORE_MOUSE 0x08 // ignore mouse-down, mouse-over etc. class CMiniWindow { *************** *** 1340,1345 **** --- 1341,1357 ---- long HotspotTooltip(LPCTSTR HotspotId, LPCTSTR TooltipText); + + long LoadImageMemory(LPCTSTR ImageId, + unsigned char * Buffer, + const size_t Length, + const bool bAlpha); + + + long DrawImageAlpha(LPCTSTR ImageId, + long Left, long Top, long Right, long Bottom, + double Opacity, + long SrcLeft, long SrcTop); }; Index: PluginsDlg.cpp =================================================================== RCS file: /cvs/mushclient/PluginsDlg.cpp,v retrieving revision 1.23 retrieving revision 1.24 diff -c -r1.23 -r1.24 *** PluginsDlg.cpp 8 Jul 2008 03:49:51 -0000 1.23 --- PluginsDlg.cpp 6 Jul 2009 05:58:56 -0000 1.24 *************** *** 317,323 **** // use default world file directory filedlg.m_ofn.lpstrInitialDir = Make_Absolute_Path (App.m_strPluginsDirectory); ! if (filedlg.DoModal () != IDOK) return; // cancelled dialog CString strPath; --- 317,327 ---- // use default world file directory filedlg.m_ofn.lpstrInitialDir = Make_Absolute_Path (App.m_strPluginsDirectory); ! ChangeToFileBrowsingDirectory (); ! int nResult = filedlg.DoModal(); ! ChangeToStartupDirectory (); ! ! if (nResult != IDOK) return; // cancelled dialog CString strPath; Index: ProcessPreviousLine.cpp =================================================================== RCS file: /cvs/mushclient/ProcessPreviousLine.cpp,v retrieving revision 1.60 retrieving revision 1.61 diff -c -r1.60 -r1.61 *** ProcessPreviousLine.cpp 23 Jun 2009 23:39:23 -0000 1.60 --- ProcessPreviousLine.cpp 6 Jul 2009 05:58:56 -0000 1.61 *************** *** 222,232 **** COLORREF cText, cBack; ! // find actual RGB colour of style, inverting if necessary ! if (pStyle->iFlags & INVERSE) ! GetStyleRGB (pStyle, cBack, cText); ! else ! GetStyleRGB (pStyle, cText, cBack); StyledLine.AddStyle (CPaneStyle ((const char *) strLine.Mid (iCol, pStyle->iLength), --- 222,229 ---- COLORREF cText, cBack; ! // find actual RGB colour of style ! GetStyleRGB (pStyle, cText, cBack); StyledLine.AddStyle (CPaneStyle ((const char *) strLine.Mid (iCol, pStyle->iLength), *************** *** 974,986 **** } // end of doing each line ! if (trigger_item->iMatch & TRIGGER_MATCH_TEXT) if (get_foreground (trigger_item->iMatch) != ! iForeColour) continue; // wrong text colour if (trigger_item->iMatch & TRIGGER_MATCH_BACK) if (get_background (trigger_item->iMatch) != ! iBackColour) continue; // wrong background colour if (trigger_item->iMatch & TRIGGER_MATCH_HILITE) if ((get_style (trigger_item->iMatch) & HILITE) != --- 971,983 ---- } // end of doing each line ! if (trigger_item->iMatch & TRIGGER_MATCH_TEXT) if (get_foreground (trigger_item->iMatch) != ! (iFlags & INVERSE) ? iBackColour : iForeColour ) continue; // wrong text colour if (trigger_item->iMatch & TRIGGER_MATCH_BACK) if (get_background (trigger_item->iMatch) != ! (iFlags & INVERSE) ? iForeColour : iBackColour) continue; // wrong background colour if (trigger_item->iMatch & TRIGGER_MATCH_HILITE) if ((get_style (trigger_item->iMatch) & HILITE) != Index: RecallDlg.cpp =================================================================== RCS file: /cvs/mushclient/RecallDlg.cpp,v retrieving revision 1.4 retrieving revision 1.5 diff -c -r1.4 -r1.5 *** RecallDlg.cpp 11 Jun 2007 10:42:08 -0000 1.4 --- RecallDlg.cpp 6 Jul 2009 05:58:56 -0000 1.5 *************** *** 163,169 **** this); dlg.m_ofn.lpstrTitle = "File to save as"; ! if (dlg.DoModal() != IDOK) return FALSE; m_strFilename = dlg.GetPathName(); --- 163,173 ---- this); dlg.m_ofn.lpstrTitle = "File to save as"; ! ChangeToFileBrowsingDirectory (); ! int nResult = dlg.DoModal(); ! ChangeToStartupDirectory (); ! ! if (nResult != IDOK) return FALSE; m_strFilename = dlg.GetPathName(); Index: TextDocument.cpp =================================================================== RCS file: /cvs/mushclient/TextDocument.cpp,v retrieving revision 1.21 retrieving revision 1.22 diff -c -r1.21 -r1.22 *** TextDocument.cpp 30 Jun 2008 03:50:50 -0000 1.21 --- TextDocument.cpp 6 Jul 2009 05:58:56 -0000 1.22 *************** *** 341,347 **** --- 341,349 ---- dlgFile.m_ofn.lpstrTitle = title; dlgFile.m_ofn.lpstrFile = fileName.GetBuffer(_MAX_PATH); + ChangeToFileBrowsingDirectory (); int nResult = dlgFile.DoModal(); + ChangeToStartupDirectory (); fileName.ReleaseBuffer(); if (nResult != IDOK) Index: Utilities.cpp =================================================================== RCS file: /cvs/mushclient/Utilities.cpp,v retrieving revision 1.80 retrieving revision 1.82 diff -c -r1.80 -r1.82 *** Utilities.cpp 23 Jun 2009 23:39:23 -0000 1.80 --- Utilities.cpp 6 Jul 2009 21:35:01 -0000 1.82 *************** *** 3067,3073 **** png_set_sig_bytes(png_ptr, sizeof header); int png_transforms = PNG_TRANSFORM_STRIP_16 | // Strip 16-bit samples to 8 bits - PNG_TRANSFORM_STRIP_ALPHA | // Discard the alpha channel PNG_TRANSFORM_PACKING | // Expand 1, 2 and 4-bit samples to bytes PNG_TRANSFORM_BGR; // Flip RGB to BGR, RGBA to BGRA --- 3067,3072 ---- *************** *** 3087,3099 **** BITMAPINFO bmiB; ZeroMemory (&bmiB, sizeof bmiB); ! long bpl = BytesPerLine (info_ptr->width, 24); bmiB.bmiHeader.biSize = sizeof bmiB; bmiB.bmiHeader.biWidth = info_ptr->width; bmiB.bmiHeader.biHeight = info_ptr->height; bmiB.bmiHeader.biPlanes = 1; ! bmiB.bmiHeader.biBitCount = 24; bmiB.bmiHeader.biCompression = BI_RGB; bmiB.bmiHeader.biSizeImage = info_ptr->height * bpl; --- 3086,3103 ---- BITMAPINFO bmiB; ZeroMemory (&bmiB, sizeof bmiB); ! int bit_per_pixel = 24; ! ! if (png_ptr->color_type & PNG_COLOR_MASK_ALPHA) ! bit_per_pixel = 32; ! ! long bpl = BytesPerLine (info_ptr->width, bit_per_pixel); bmiB.bmiHeader.biSize = sizeof bmiB; bmiB.bmiHeader.biWidth = info_ptr->width; bmiB.bmiHeader.biHeight = info_ptr->height; bmiB.bmiHeader.biPlanes = 1; ! bmiB.bmiHeader.biBitCount = bit_per_pixel; bmiB.bmiHeader.biCompression = BI_RGB; bmiB.bmiHeader.biSizeImage = info_ptr->height * bpl; *************** *** 3120,3125 **** --- 3124,3273 ---- return eOK; } // end of LoadPng + typedef struct + { + unsigned char * BufferPos; + size_t LengthRemaining; + } tPngBufferInfo; + + void ReadDataFromInputStream(png_structp png_ptr, png_bytep outBytes, + png_size_t byteCountToRead) + { + if(png_ptr->io_ptr == NULL) + { + png_error(png_ptr, "No io_ptr structure"); + return; // oops + } + + // get our structure with buffer and length left in it + tPngBufferInfo * PngBufferInfo = (tPngBufferInfo*)png_ptr->io_ptr; + + if (byteCountToRead > PngBufferInfo->LengthRemaining) + { + png_error(png_ptr, "Insufficient data in buffer"); + return; + } + + // copy wanted bytes + memcpy (outBytes, PngBufferInfo->BufferPos, byteCountToRead); + PngBufferInfo->BufferPos += byteCountToRead; + PngBufferInfo->LengthRemaining -= byteCountToRead; + + } // end of ReadDataFromInputStream + + long LoadPngMemory (unsigned char * Buffer, const size_t Length, HBITMAP & hbmp, const bool bAlpha) // load a PNG file into a bitmap + { + + if (Length < 8) + return (eUnableToLoadImage); // too small for signature + + // check signature + if (png_sig_cmp (Buffer, 0, 8)) + return (eUnableToLoadImage); // bad signature + + // create PNG structure + png_structp png_ptr = png_create_read_struct + (PNG_LIBPNG_VER_STRING, NULL, + user_error_fn, user_warning_fn); + + if (!png_ptr) + return eUnableToLoadImage; + + // create info structure + png_infop info_ptr = png_create_info_struct(png_ptr); + if (!info_ptr) + { + png_destroy_read_struct(&png_ptr, + (png_infopp)NULL, (png_infopp)NULL); + return eUnableToLoadImage; + } + + // create end info structure + png_infop end_info = png_create_info_struct(png_ptr); + if (!end_info) + { + png_destroy_read_struct(&png_ptr, &info_ptr, + (png_infopp)NULL); + return eUnableToLoadImage; + } + + + // if png fails it will longjmp back to here, so we destroy the structure, + // and wrap up + if (setjmp(png_jmpbuf(png_ptr))) + { + png_destroy_read_struct(&png_ptr, &info_ptr, + &end_info); + return eUnableToLoadImage; + } + + + tPngBufferInfo PngBufferInfo; + PngBufferInfo.BufferPos = Buffer; + PngBufferInfo.LengthRemaining = Length; + + // initialize IO + png_set_read_fn(png_ptr, &PngBufferInfo, ReadDataFromInputStream); + + + int png_transforms = PNG_TRANSFORM_STRIP_16 | // Strip 16-bit samples to 8 bits + PNG_TRANSFORM_PACKING | // Expand 1, 2 and 4-bit samples to bytes + PNG_TRANSFORM_BGR; // Flip RGB to BGR, RGBA to BGRA + + + if (bAlpha) + png_transforms |= PNG_TRANSFORM_SWAP_ALPHA; + + // read the file + png_read_png(png_ptr, info_ptr, png_transforms, NULL); + + // note: png_read_end not needed with png_read_png (done already) + + // get the row pointers + png_bytep * row_pointers = png_get_rows(png_ptr, info_ptr); + + // make a bitmap + CDC B_DC; + B_DC.CreateCompatibleDC (NULL); + CBitmap B_bmp; + + BITMAPINFO bmiB; + ZeroMemory (&bmiB, sizeof bmiB); + + int bit_per_pixel = 24; + + if (png_ptr->color_type & PNG_COLOR_MASK_ALPHA) + bit_per_pixel = 32; + + long bpl = BytesPerLine (info_ptr->width, bit_per_pixel); + + bmiB.bmiHeader.biSize = sizeof bmiB; + bmiB.bmiHeader.biWidth = info_ptr->width; + bmiB.bmiHeader.biHeight = info_ptr->height; + bmiB.bmiHeader.biPlanes = 1; + bmiB.bmiHeader.biBitCount = bit_per_pixel; + bmiB.bmiHeader.biCompression = BI_RGB; + bmiB.bmiHeader.biSizeImage = info_ptr->height * bpl; + + unsigned char * pB = NULL; + + hbmp = CreateDIBSection(NULL, &bmiB, DIB_RGB_COLORS, (void**) &pB, NULL, 0); + + if (!hbmp) + return eUnableToLoadImage; + + long row; + unsigned char * p = pB; + + // have to reverse row order + for (row = 0; row < info_ptr->height; row++, p += bpl) + memcpy (p, row_pointers [info_ptr->height - row - 1], bpl); + + // done with data + png_destroy_read_struct(&png_ptr, &info_ptr, &end_info); + + return eOK; + } // end of LoadPngMemory #define LONGDOUBLE_TYPE long double *************** *** 3196,3199 **** --- 3344,3382 ---- *pResult = (double)(sign<0 ? -v1 : v1); return (int)(z - zBegin); } // end of myAtoF + + + #include + + // change to the current file browsing directory, browse for a file, put it back + + extern char file_browsing_dir [_MAX_PATH]; + + void ChangeToFileBrowsingDirectory () + { + + _chdir(file_browsing_dir); + + } // end of ChangeToFileBrowsingDirectory + + void ChangeToStartupDirectory () + { + + // first, remember the file_browsing directory + + _getdcwd (0, file_browsing_dir, sizeof (file_browsing_dir) - 1); + + // make sure directory name ends in a slash + + file_browsing_dir [sizeof (file_browsing_dir) - 2] = 0; + + if (file_browsing_dir [strlen (file_browsing_dir) - 1] != '\\') + strcat (file_browsing_dir, "\\"); + + + // now change back to startup directory + _chdir(working_dir); + + } // end of ChangeToStartupDirectory + Index: doc.cpp =================================================================== RCS file: /cvs/mushclient/doc.cpp,v retrieving revision 1.267 retrieving revision 1.269 diff -c -r1.267 -r1.269 *** doc.cpp 23 Jun 2009 23:39:23 -0000 1.267 --- doc.cpp 8 Jul 2009 04:10:49 -0000 1.269 *************** *** 581,586 **** --- 581,587 ---- DISP_FUNCTION(CMUSHclientDoc, "DatabaseReset", DatabaseReset, VT_I4, VTS_BSTR) DISP_FUNCTION(CMUSHclientDoc, "FlashIcon", FlashIcon, VT_EMPTY, VTS_NONE) DISP_FUNCTION(CMUSHclientDoc, "WindowHotspotTooltip", WindowHotspotTooltip, VT_I4, VTS_BSTR VTS_BSTR VTS_BSTR) + DISP_FUNCTION(CMUSHclientDoc, "WindowDrawImageAlpha", WindowDrawImageAlpha, VT_I4, VTS_BSTR VTS_BSTR VTS_I4 VTS_I4 VTS_I4 VTS_I4 VTS_R8 VTS_I4 VTS_I4) DISP_PROPERTY_PARAM(CMUSHclientDoc, "NormalColour", GetNormalColour, SetNormalColour, VT_I4, VTS_I2) DISP_PROPERTY_PARAM(CMUSHclientDoc, "BoldColour", GetBoldColour, SetBoldColour, VT_I4, VTS_I2) DISP_PROPERTY_PARAM(CMUSHclientDoc, "CustomColourText", GetCustomColourText, SetCustomColourText, VT_I4, VTS_I2) *************** *** 2665,2671 **** else strcpy (filedlg.m_ofn.lpstrFile, suggested_name); ! if (filedlg.DoModal () != IDOK) return; m_logfile_name = filedlg.GetPathName (); --- 2666,2676 ---- else strcpy (filedlg.m_ofn.lpstrFile, suggested_name); ! ChangeToFileBrowsingDirectory (); ! int nResult = filedlg.DoModal(); ! ChangeToStartupDirectory (); ! ! if (nResult != IDOK) return; m_logfile_name = filedlg.GetPathName (); *************** *** 3573,3579 **** filedlg.m_ofn.lpstrFile = filename.GetBuffer (_MAX_PATH); // needed!! (for Win32s) strcpy (filedlg.m_ofn.lpstrFile, ""); ! if (filedlg.DoModal () != IDOK) return; // cancelled dialog try --- 3578,3588 ---- filedlg.m_ofn.lpstrFile = filename.GetBuffer (_MAX_PATH); // needed!! (for Win32s) strcpy (filedlg.m_ofn.lpstrFile, ""); ! ChangeToFileBrowsingDirectory (); ! int nResult = filedlg.DoModal(); ! ChangeToStartupDirectory (); ! ! if (nResult != IDOK) return; // cancelled dialog try *************** *** 4669,4674 **** --- 4678,4699 ---- if (m_CurrentPlugin) return; + // check for selection change in command window + // I know, this is a crappy way of doing it, but the CEditView does + // not notify of selection changes. + + for(POSITION commandpos=GetFirstViewPosition();commandpos!=NULL;) + { + CView* pView = GetNextView(commandpos); + + if (pView->IsKindOf(RUNTIME_CLASS(CSendView))) + { + CSendView* pmyView = (CSendView*)pView; + + pmyView->CheckForSelectionChange (); + } // end of being a CSendView + } + // tell each plugin about the tick for (POSITION pos = m_PluginList.GetHeadPosition(); pos; ) { *************** *** 8003,8008 **** m_strSpecialFontName.Empty (); } - - - --- 8028,8030 ---- Index: doc.h =================================================================== RCS file: /cvs/mushclient/doc.h,v retrieving revision 1.284 retrieving revision 1.286 diff -c -r1.284 -r1.286 *** doc.h 23 Jun 2009 23:39:23 -0000 1.284 --- doc.h 6 Jul 2009 21:35:01 -0000 1.286 *************** *** 21,28 **** // New versions - things to change ! #define THISVERSION 441 // Step 1. ! const CString MUSHCLIENT_VERSION = "4.41"; // Step 2. // Step 3. Don't forget VERSION resource in Resources tab // Step 4. Remember: README.TXT --- 21,28 ---- // New versions - things to change ! #define THISVERSION 442 // Step 1. ! const CString MUSHCLIENT_VERSION = "4.42"; // Step 2. // Step 3. Don't forget VERSION resource in Resources tab // Step 4. Remember: README.TXT *************** *** 1240,1245 **** --- 1240,1246 ---- // for DirectSound LPDIRECTSOUNDBUFFER m_pDirectSoundSecondaryBuffer [MAX_SOUND_BUFFERS]; + long PlaySoundHelper(short Buffer, LPCTSTR FileName, BOOL Loop, double Volume, double Pan, LPCTSTR MemoryBuffer, size_t MemLen); WORD m_nextAcceleratorCommand; // next free command *************** *** 2012,2017 **** --- 2013,2024 ---- void DoFixMenus(CCmdUI* pCmdUI); + long WindowLoadImageMemory(LPCTSTR Name, + LPCTSTR ImageId, + unsigned char * Buffer, + const size_t Length, + const bool bAlpha); + // Overrides // ClassWizard generated virtual function overrides //{{AFX_VIRTUAL(CMUSHclientDoc) *************** *** 2555,2560 **** --- 2562,2568 ---- afx_msg long DatabaseReset(LPCTSTR Name); afx_msg void FlashIcon(); afx_msg long WindowHotspotTooltip(LPCTSTR Name, LPCTSTR HotspotId, LPCTSTR TooltipText); + afx_msg long WindowDrawImageAlpha(LPCTSTR Name, LPCTSTR ImageId, long Left, long Top, long Right, long Bottom, double Opacity, long SrcLeft, long SrcTop); afx_msg long GetNormalColour(short WhichColour); afx_msg void SetNormalColour(short WhichColour, long nNewValue); afx_msg long GetBoldColour(short WhichColour); Index: doc_construct.cpp =================================================================== RCS file: /cvs/mushclient/doc_construct.cpp,v retrieving revision 1.38 retrieving revision 1.39 diff -c -r1.38 -r1.39 *** doc_construct.cpp 22 Feb 2009 06:26:35 -0000 1.38 --- doc_construct.cpp 6 Jul 2009 05:58:56 -0000 1.39 *************** *** 651,657 **** // use default world file directory dlg.m_ofn.lpstrInitialDir = Make_Absolute_Path (App.m_strDefaultWorldFileDirectory); ! if (dlg.DoModal() != IDOK) break; CString strFileName = dlg.GetPathName(); --- 651,661 ---- // use default world file directory dlg.m_ofn.lpstrInitialDir = Make_Absolute_Path (App.m_strDefaultWorldFileDirectory); ! ChangeToFileBrowsingDirectory (); ! int nResult = dlg.DoModal(); ! ChangeToStartupDirectory (); ! ! if (nResult != IDOK) break; CString strFileName = dlg.GetPathName(); Index: evaluate.cpp =================================================================== RCS file: /cvs/mushclient/evaluate.cpp,v retrieving revision 1.79 retrieving revision 1.80 diff -c -r1.79 -r1.80 *** evaluate.cpp 6 Jan 2009 20:06:26 -0000 1.79 --- evaluate.cpp 6 Jul 2009 05:58:56 -0000 1.80 *************** *** 532,538 **** else strcpy (filedlg.m_ofn.lpstrFile, suggested_name); ! if (filedlg.DoModal () != IDOK) return TRUE; // cancelled dialog // since they can have any number of triggers, aliases and timers, ask them --- 532,542 ---- else strcpy (filedlg.m_ofn.lpstrFile, suggested_name); ! ChangeToFileBrowsingDirectory (); ! int nResult = filedlg.DoModal(); ! ChangeToStartupDirectory (); ! ! if (nResult!= IDOK) return TRUE; // cancelled dialog // since they can have any number of triggers, aliases and timers, ask them *************** *** 694,700 **** else strcpy (filedlg.m_ofn.lpstrFile, suggested_name); ! if (filedlg.DoModal () != IDOK) return TRUE; // cancelled dialog CPlugin * pSavedPlugin = m_CurrentPlugin; --- 698,708 ---- else strcpy (filedlg.m_ofn.lpstrFile, suggested_name); ! ChangeToFileBrowsingDirectory (); ! int nResult = filedlg.DoModal(); ! ChangeToStartupDirectory (); ! ! if (nResult != IDOK) return TRUE; // cancelled dialog CPlugin * pSavedPlugin = m_CurrentPlugin; Index: functionlist.cpp =================================================================== RCS file: /cvs/mushclient/functionlist.cpp,v retrieving revision 1.63 retrieving revision 1.64 diff -c -r1.63 -r1.64 *** functionlist.cpp 23 Jun 2009 23:39:23 -0000 1.63 --- functionlist.cpp 6 Jul 2009 05:58:56 -0000 1.64 *************** *** 381,386 **** --- 381,387 ---- "WindowDeleteHotspot", "WindowDragHandler", "WindowDrawImage", + "WindowDrawImageAlpha", "WindowFilter", "WindowFont", "WindowFontInfo", Index: globalregistryoptions.cpp =================================================================== RCS file: /cvs/mushclient/globalregistryoptions.cpp,v retrieving revision 1.21 retrieving revision 1.22 diff -c -r1.21 -r1.22 *** globalregistryoptions.cpp 22 Feb 2009 03:10:14 -0000 1.21 --- globalregistryoptions.cpp 16 Jul 2009 01:48:53 -0000 1.22 *************** *** 110,115 **** --- 110,117 ---- int CMUSHclientApp::PopulateDatabase (void) { + SetRegistryKey ("Gammon Software Solutions"); + int i; int db_rc = SQLITE_OK; Index: lua_methods.cpp =================================================================== RCS file: /cvs/mushclient/lua_methods.cpp,v retrieving revision 1.123 retrieving revision 1.125 diff -c -r1.123 -r1.125 *** lua_methods.cpp 23 Jun 2009 23:39:23 -0000 1.123 --- lua_methods.cpp 6 Jul 2009 21:35:01 -0000 1.125 *************** *** 4329,4334 **** --- 4329,4357 ---- } // end of L_PlaySound //---------------------------------------- + // world.PlaySoundMemory + //---------------------------------------- + static int L_PlaySoundMemory (lua_State *L) + { + CMUSHclientDoc * pDoc = doc (L); // must do this first + LPCTSTR sBuffer; + size_t iBufferLength; + sBuffer = luaL_checklstring (L, 2, &iBufferLength); + lua_pushnumber (L, pDoc->PlaySoundHelper ( + my_checknumber (L, 1), // Buffer + NULL, // Filename + optboolean (L, 3, 0), // Repeat + my_optnumber (L, 4, 0), // Volume + my_optnumber (L, 5, 0), // Pan + sBuffer, // MemoryBuffer + iBufferLength // MemLen + ) + ); + return 1; // number of result fields + } // end of L_PlaySoundMemory + + + //---------------------------------------- // world.PluginSupports //---------------------------------------- static int L_PluginSupports (lua_State *L) *************** *** 5496,5501 **** --- 5519,5544 ---- } // end of L_WindowDrawImage //---------------------------------------- + // world.WindowDrawImageAlpha + //---------------------------------------- + static int L_WindowDrawImageAlpha (lua_State *L) + { + CMUSHclientDoc *pDoc = doc (L); + lua_pushnumber (L, pDoc->WindowDrawImageAlpha ( + my_checkstring (L, 1), // Name + my_checkstring (L, 2), // ImageId + my_checknumber (L, 3), // Left + my_checknumber (L, 4), // Top + my_checknumber (L, 5), // Right + my_checknumber (L, 6), // Bottom + my_optnumber (L, 7, 1), // Opacity + my_optnumber (L, 8, 0), // SrcLeft + my_optnumber (L, 9, 0) // SrcTop + )); + return 1; // number of result fields + } // end of L_WindowDrawImageAlpha + + //---------------------------------------- // world.WindowFilter //---------------------------------------- static int L_WindowFilter (lua_State *L) *************** *** 5755,5760 **** --- 5798,5824 ---- } // end of L_WindowLoadImage //---------------------------------------- + // world.WindowLoadImageMemory + //---------------------------------------- + static int L_WindowLoadImageMemory (lua_State *L) + { + CMUSHclientDoc *pDoc = doc (L); + LPCTSTR sBuffer; + size_t iBufferLength; + sBuffer = luaL_checklstring (L, 3, &iBufferLength); + + lua_pushnumber (L, pDoc->WindowLoadImageMemory ( + my_checkstring (L, 1), // Name + my_checkstring (L, 2), // FontId + (unsigned char *) sBuffer, + iBufferLength, + optboolean (L, 4, 0) // swap alpha? + )); + + return 1; // number of result fields + } // end of L_WindowLoadImageMemory + + //---------------------------------------- // world.WindowMenu //---------------------------------------- static int L_WindowMenu (lua_State *L) *************** *** 6271,6276 **** --- 6335,6341 ---- {"Pause", L_Pause}, {"PickColour", L_PickColour}, {"PlaySound", L_PlaySound}, + {"PlaySoundMemory", L_PlaySoundMemory}, {"PluginSupports", L_PluginSupports}, {"PushCommand", L_PushCommand}, {"Queue", L_Queue}, *************** *** 6361,6366 **** --- 6426,6432 ---- {"WindowDeleteHotspot", L_WindowDeleteHotspot}, {"WindowDragHandler", L_WindowDragHandler}, {"WindowDrawImage", L_WindowDrawImage}, + {"WindowDrawImageAlpha", L_WindowDrawImageAlpha}, {"WindowFilter", L_WindowFilter}, {"WindowFont", L_WindowFont}, {"WindowFontInfo", L_WindowFontInfo}, *************** *** 6378,6383 **** --- 6444,6450 ---- {"WindowLine", L_WindowLine}, {"WindowList", L_WindowList}, {"WindowLoadImage", L_WindowLoadImage}, + {"WindowLoadImageMemory", L_WindowLoadImageMemory}, {"WindowMenu", L_WindowMenu}, {"WindowMergeImageAlpha", L_WindowMergeImageAlpha}, {"WindowPolygon", L_WindowPolygon}, Index: lua_utils.cpp =================================================================== RCS file: /cvs/mushclient/lua_utils.cpp,v retrieving revision 1.27 retrieving revision 1.28 diff -c -r1.27 -r1.28 *** lua_utils.cpp 6 Jan 2009 20:06:26 -0000 1.27 --- lua_utils.cpp 6 Jul 2009 05:58:56 -0000 1.28 *************** *** 614,620 **** if (sTitle) dlg.m_ofn.lpstrTitle = sTitle; ! if (dlg.DoModal() != IDOK) lua_pushnil (L); else lua_pushstring (L, dlg.GetPathName()); --- 614,624 ---- if (sTitle) dlg.m_ofn.lpstrTitle = sTitle; ! ChangeToFileBrowsingDirectory (); ! int nResult = dlg.DoModal(); ! ChangeToStartupDirectory (); ! ! if (nResult != IDOK) lua_pushnil (L); else lua_pushstring (L, dlg.GetPathName()); Index: mainfrm.cpp =================================================================== RCS file: /cvs/mushclient/mainfrm.cpp,v retrieving revision 1.68 retrieving revision 1.69 diff -c -r1.68 -r1.69 *** mainfrm.cpp 22 Feb 2009 03:10:14 -0000 1.68 --- mainfrm.cpp 6 Jul 2009 05:58:56 -0000 1.69 *************** *** 1687,1694 **** // use default world file directory dlgFile.m_ofn.lpstrInitialDir = Make_Absolute_Path (App.m_strDefaultWorldFileDirectory); ! int nResult = dlgFile.DoModal(); ! fileName.ReleaseBuffer(); if (nResult != IDOK) return; --- 1687,1697 ---- // use default world file directory dlgFile.m_ofn.lpstrInitialDir = Make_Absolute_Path (App.m_strDefaultWorldFileDirectory); ! ChangeToFileBrowsingDirectory (); ! int nResult = dlgFile.DoModal(); ! ChangeToStartupDirectory (); ! ! fileName.ReleaseBuffer(); if (nResult != IDOK) return; Index: methods.cpp =================================================================== RCS file: /cvs/mushclient/methods.cpp,v retrieving revision 1.263 retrieving revision 1.265 diff -c -r1.263 -r1.265 *** methods.cpp 23 Jun 2009 23:39:23 -0000 1.263 --- methods.cpp 6 Jul 2009 21:35:01 -0000 1.265 *************** *** 43,48 **** --- 43,50 ---- extern CString strKeypadNames [eKeypad_Max_Items]; extern char working_dir [_MAX_PATH]; + extern char file_browsing_dir [_MAX_PATH]; + extern set LuaFunctionsSet; *************** *** 4156,4161 **** --- 4158,4164 ---- { 81, "LibPNG header version string" }, { 82, "Preferences database pathname" }, { 83, "SQLite3 version" }, + { 84, "File browsing directory" }, *************** *** 4470,4475 **** --- 4473,4479 ---- case 81: SetUpVariantString (vaResult, PNG_HEADER_VERSION_STRING); break; case 82: SetUpVariantString (vaResult, App.m_PreferencesDatabaseName.c_str ()); break; case 83: SetUpVariantString (vaResult, sqlite3_libversion ()); break; + case 84: SetUpVariantString (vaResult, file_browsing_dir); break; case 101: SetUpVariantBool (vaResult, m_bNoEcho); break; case 102: SetUpVariantBool (vaResult, m_bDebugIncomingPackets); break; *************** *** 8615,8621 **** dlg.m_ofn.lpstrTitle = "Select file to send"; ! if (dlg.DoModal() != IDOK) return eFileNotFound; strName = dlg.GetPathName(); --- 8619,8629 ---- dlg.m_ofn.lpstrTitle = "Select file to send"; ! ChangeToFileBrowsingDirectory (); ! int nResult = dlg.DoModal(); ! ChangeToStartupDirectory (); ! ! if (nResult != IDOK) return eFileNotFound; strName = dlg.GetPathName(); *************** *** 11633,11639 **** --- 11641,11660 ---- long CMUSHclientDoc::ChangeDir(LPCTSTR Path) { if (_chdir(Path) == 0) + { + // find the new working directory + + _getdcwd (0, working_dir, sizeof (working_dir) - 1); + + // make sure directory name ends in a slash + + working_dir [sizeof (working_dir) - 2] = 0; + + if (working_dir [strlen (working_dir) - 1] != '\\') + strcat (working_dir, "\\"); + return true; // did it OK + } return false; } // end of ChangeDir *************** *** 11845,11851 **** } ! // start playing sound FileName in buffer Buffer // If not a fully-qualified path, prepend mushclient.exe directory followed by "sounds\" // Loop when finished if Loop is true // Play at volume 'Volume' (percent) - 0 is full volume, -100 is -100 db --- 11866,11873 ---- } ! // start playing sound FileName in buffer Buffer (or in memory in MemoryBuffer for length MemLen) ! // If not a fully-qualified path, prepend mushclient.exe directory followed by "sounds\" // Loop when finished if Loop is true // Play at volume 'Volume' (percent) - 0 is full volume, -100 is -100 db *************** *** 11859,11865 **** // test: /print (PlaySound (9, "/Program Files/Mushclient/sounds/battle/battle01.wav", true, 100)) ! long CMUSHclientDoc::PlaySound(short Buffer, LPCTSTR FileName, BOOL Loop, double Volume, double Pan) { int i; --- 11881,11887 ---- // test: /print (PlaySound (9, "/Program Files/Mushclient/sounds/battle/battle01.wav", true, 100)) ! long CMUSHclientDoc::PlaySoundHelper(short Buffer, LPCTSTR FileName, BOOL Loop, double Volume, double Pan, LPCTSTR MemoryBuffer, size_t MemLen) { int i; *************** *** 11902,11935 **** // ---------------------- if no filename, attempt to adjust existing sound --------------------- ! if (Buffer >= 1 && Buffer <= MAX_SOUND_BUFFERS && strlen (FileName) == 0) { ! Buffer--; // make zero-relative ! // can't if not there ! if (m_pDirectSoundSecondaryBuffer [Buffer] == NULL) ! return eBadParameter; ! // don't if not playing ! DWORD iStatus; ! if (FAILED (m_pDirectSoundSecondaryBuffer [Buffer]->GetStatus (&iStatus)) || ! (iStatus & DSBSTATUS_PLAYING) == 0) ! return eCannotPlaySound; ! ! // set requested panning ! m_pDirectSoundSecondaryBuffer [Buffer]->SetPan (iPan); ! // set requested volume ! m_pDirectSoundSecondaryBuffer [Buffer]->SetVolume (iVolume); ! // set requested looping ! m_pDirectSoundSecondaryBuffer [Buffer]->Play( 0, 0, Loop ? DSBPLAY_LOOPING : 0); ! return eOK; ! } ! // no file name AND no buffer number? can't do much ! if (strlen (FileName) < 2) // later I test the 1st and 2nd characters ! return eBadParameter; // ------------------- we have filename, get on with it ----------------------------- --- 11924,11961 ---- // ---------------------- if no filename, attempt to adjust existing sound --------------------- ! if (MemoryBuffer == NULL) { ! if (Buffer >= 1 && Buffer <= MAX_SOUND_BUFFERS && strlen (FileName) == 0) ! { ! Buffer--; // make zero-relative ! // can't if not there ! if (m_pDirectSoundSecondaryBuffer [Buffer] == NULL) ! return eBadParameter; ! // don't if not playing ! DWORD iStatus; ! if (FAILED (m_pDirectSoundSecondaryBuffer [Buffer]->GetStatus (&iStatus)) || ! (iStatus & DSBSTATUS_PLAYING) == 0) ! return eCannotPlaySound; ! ! // set requested panning ! m_pDirectSoundSecondaryBuffer [Buffer]->SetPan (iPan); ! // set requested volume ! m_pDirectSoundSecondaryBuffer [Buffer]->SetVolume (iVolume); ! // set requested looping ! m_pDirectSoundSecondaryBuffer [Buffer]->Play( 0, 0, Loop ? DSBPLAY_LOOPING : 0); ! return eOK; ! } ! // no file name AND no buffer number? can't do much ! if (strlen (FileName) < 2) // later I test the 1st and 2nd characters ! return eBadParameter; ! ! } // have a file name (not memory file) // ------------------- we have filename, get on with it ----------------------------- *************** *** 11956,11991 **** if (Buffer < 0 || Buffer >= MAX_SOUND_BUFFERS) return eBadParameter; // ------------------- we have a buffer now ------------------------------- ! // ---------- if not absolute path, use MUSHclient.exe / sounds / filename ! CString strName = FileName; ! strName.Replace ("/", "\\"); // convert forward to backslash ! // without a full pathname, assume in sounds directory under MUSHclient.exe ! if (!( ! isalpha ((unsigned char) strName [0]) && ! strName [1] == ':' // eg. c: blah ! ) && ! strName [0] != '\\') // eg. \mydir\blah or \\server\blah ! strName = ExtractDirectory (App.m_strMUSHclientFileName) + "sounds\\" + strName; - if (strName.GetLength () > 127) - return eBadParameter; - char sFilename [128]; - strcpy (sFilename, strName); // make not const // ---------- open multimedia file ---------------------------- HMMIO mmioWave ; MMCKINFO mmckinfoParent, mmckinfoSubchunk ; WAVEFORMATEX wfPCM ; // Open the wave data using the mm functions ! mmioWave = mmioOpen(sFilename, NULL, MMIO_READ) ; if ( !mmioWave ) return eFileNotFound; --- 11982,12040 ---- if (Buffer < 0 || Buffer >= MAX_SOUND_BUFFERS) return eBadParameter; + // ------------------- we have a buffer now ------------------------------- ! CString strName; ! if (MemoryBuffer == NULL) ! { ! // ---------- if not absolute path, use MUSHclient.exe / sounds / filename ! strName = FileName; ! ! strName.Replace ("/", "\\"); // convert forward to backslash ! ! // without a full pathname, assume in sounds directory under MUSHclient.exe ! if (!( ! isalpha ((unsigned char) strName [0]) && ! strName [1] == ':' // eg. c: blah ! ) && ! strName [0] != '\\') // eg. \mydir\blah or \\server\blah ! strName = ExtractDirectory (App.m_strMUSHclientFileName) + "sounds\\" + strName; ! ! if (strName.GetLength () > 127) ! return eBadParameter; ! ! } // have a file name (not memory file) // ---------- open multimedia file ---------------------------- HMMIO mmioWave ; MMCKINFO mmckinfoParent, mmckinfoSubchunk ; WAVEFORMATEX wfPCM ; + MMIOINFO mmioInfo; + memset(&mmioInfo, 0, sizeof(MMIOINFO)); // Open the wave data using the mm functions ! if (MemoryBuffer == NULL) ! { ! char sFilename [128]; ! strcpy (sFilename, strName); // make not const ! ! mmioWave = mmioOpen (sFilename, NULL, MMIO_READ); // open from disk ! } // have a file name (not memory file) ! else ! { // open from memory ! mmioInfo.pchBuffer = (char *) MemoryBuffer; ! mmioInfo.cchBuffer = MemLen; ! mmioInfo.fccIOProc = FOURCC_MEM; ! mmioWave = mmioOpen (NULL, &mmioInfo, MMIO_READ) ; ! } ! if ( !mmioWave ) return eFileNotFound; *************** *** 12132,12138 **** } return eOK; ! } // stop the sound in the numbered Buffer from playing // if Buffer is zero, stop all sounds --- 12181,12193 ---- } return eOK; ! } // end of CMUSHclientDoc::PlaySoundHelper ! ! long CMUSHclientDoc::PlaySound(short Buffer, LPCTSTR FileName, BOOL Loop, double Volume, double Pan) ! { ! return PlaySoundHelper (Buffer, FileName, Loop, Volume, Pan, NULL, 0); ! } // end of CMUSHclientDoc::PlaySound ! // stop the sound in the numbered Buffer from playing // if Buffer is zero, stop all sounds *************** *** 12872,12877 **** --- 12927,12948 ---- return it->second->LoadImage (ImageId, FileName); } // end of CMUSHclientDoc::WindowLoadImage + // load an image from memory + long CMUSHclientDoc::WindowLoadImageMemory(LPCTSTR Name, + LPCTSTR ImageId, + unsigned char * Buffer, + const size_t Length, + const bool bAlpha) + { + MiniWindowMapIterator it = m_MiniWindows.find (Name); + + if (it == m_MiniWindows.end ()) + return eNoSuchWindow; + + return it->second->LoadImageMemory (ImageId, Buffer, Length, bAlpha); + } // end of CMUSHclientDoc::WindowLoadImageMemory + + long CMUSHclientDoc::WindowWrite(LPCTSTR Name, LPCTSTR FileName) { MiniWindowMapIterator it = m_MiniWindows.find (Name); *************** *** 14513,14519 **** void CMUSHclientDoc::FlashIcon() { Frame.FlashWindow (TRUE); ! } long CMUSHclientDoc::WindowHotspotTooltip(LPCTSTR Name, LPCTSTR HotspotId, LPCTSTR TooltipText) --- 14584,14590 ---- void CMUSHclientDoc::FlashIcon() { Frame.FlashWindow (TRUE); ! } // end of CMUSHclientDoc::FlashIcon long CMUSHclientDoc::WindowHotspotTooltip(LPCTSTR Name, LPCTSTR HotspotId, LPCTSTR TooltipText) *************** *** 14525,14531 **** return eNoSuchWindow; return it->second->HotspotTooltip (HotspotId, TooltipText); ! } /* --- 14596,14614 ---- return eNoSuchWindow; return it->second->HotspotTooltip (HotspotId, TooltipText); ! } // end of CMUSHclientDoc::WindowHotspotTooltip ! ! long CMUSHclientDoc::WindowDrawImageAlpha(LPCTSTR Name, LPCTSTR ImageId, long Left, long Top, long Right, long Bottom, double Opacity, long SrcLeft, long SrcTop) ! { ! MiniWindowMapIterator it = m_MiniWindows.find (Name); ! ! if (it == m_MiniWindows.end ()) ! return eNoSuchWindow; ! ! return it->second->DrawImageAlpha (ImageId, Left, Top, Right, Bottom, Opacity, ! SrcLeft, SrcTop); ! ! } // end of CMUSHclientDoc::WindowDrawImageAlpha /* Index: miniwindow.cpp =================================================================== RCS file: /cvs/mushclient/miniwindow.cpp,v retrieving revision 1.38 retrieving revision 1.41 diff -c -r1.38 -r1.41 *** miniwindow.cpp 23 Jun 2009 23:39:23 -0000 1.38 --- miniwindow.cpp 16 Jul 2009 01:48:53 -0000 1.41 *************** *** 18,26 **** m_oldBitmap (NULL), m_iWidth (0), m_iHeight (0), m_iPosition (0), m_iFlags (0), ! m_iBackgroundColour (0), m_bShow (false), m_bTemporarilyHide (false), ! m_last_mouse_update (0) { dc.CreateCompatibleDC(NULL); dc.SetTextAlign (TA_LEFT | TA_TOP); --- 18,29 ---- m_oldBitmap (NULL), m_iWidth (0), m_iHeight (0), m_iPosition (0), m_iFlags (0), ! m_iBackgroundColour (0), m_bShow (false), ! m_rect (0, 0, 0, 0), m_bTemporarilyHide (false), ! m_last_mouseposition (0, 0), ! m_last_mouse_update (0), ! m_client_mouseposition (0, 0) { dc.CreateCompatibleDC(NULL); dc.SetTextAlign (TA_LEFT | TA_TOP); *************** *** 1007,1012 **** --- 1010,1046 ---- } // end of CMiniWindow::LoadImage + // loads an image from memory, ready for drawing into window + long CMiniWindow::LoadImageMemory(LPCTSTR ImageId, + unsigned char * Buffer, + const size_t Length, + const bool bAlpha) + { + ImageMapIterator it = m_Images.find (ImageId); + + if (it != m_Images.end ()) + { + delete it->second; // delete existing image + m_Images.erase (it); + } + + HBITMAP hbmp; + + long result = LoadPngMemory (Buffer, Length, hbmp, bAlpha); + + if (result != eOK) + return result; + + // make bitmap to add to images list + CBitmap * pImage = new CBitmap; + pImage->Attach (hbmp); + m_Images [ImageId] = pImage; + + return eOK; + + } // end of CMiniWindow::LoadImageMemory + + static void user_error_fn(png_structp png_ptr, png_const_charp error_msg) { *************** *** 1576,1590 **** long Flags) { ! if (strlen (MouseOver) > 0 && CheckLabel (MouseOver)) return eInvalidObjectLabel; ! if (strlen (CancelMouseOver) > 0 && CheckLabel (CancelMouseOver)) return eInvalidObjectLabel; ! if (strlen (MouseDown) > 0 && CheckLabel (MouseDown)) return eInvalidObjectLabel; ! if (strlen (CancelMouseDown) > 0 && CheckLabel (CancelMouseDown)) return eInvalidObjectLabel; ! if (strlen (MouseUp) > 0 && CheckLabel (MouseUp)) return eInvalidObjectLabel; // can't switch plugins here :) --- 1610,1624 ---- long Flags) { ! if (strlen (MouseOver) > 0 && CheckLabel (MouseOver, true)) return eInvalidObjectLabel; ! if (strlen (CancelMouseOver) > 0 && CheckLabel (CancelMouseOver, true)) return eInvalidObjectLabel; ! if (strlen (MouseDown) > 0 && CheckLabel (MouseDown, true)) return eInvalidObjectLabel; ! if (strlen (CancelMouseDown) > 0 && CheckLabel (CancelMouseDown, true)) return eInvalidObjectLabel; ! if (strlen (MouseUp) > 0 && CheckLabel (MouseUp, true)) return eInvalidObjectLabel; // can't switch plugins here :) *************** *** 3598,3606 **** long CMiniWindow::DragHandler(LPCTSTR HotspotId, string sPluginID, LPCTSTR MoveCallback, LPCTSTR ReleaseCallback, long Flags) { ! if (strlen (MoveCallback) > 0 && CheckLabel (MoveCallback)) return eInvalidObjectLabel; ! if (strlen (ReleaseCallback) > 0 && CheckLabel (ReleaseCallback)) return eInvalidObjectLabel; // can't switch plugins here :) --- 3632,3640 ---- long CMiniWindow::DragHandler(LPCTSTR HotspotId, string sPluginID, LPCTSTR MoveCallback, LPCTSTR ReleaseCallback, long Flags) { ! if (strlen (MoveCallback) > 0 && CheckLabel (MoveCallback, true)) return eInvalidObjectLabel; ! if (strlen (ReleaseCallback) > 0 && CheckLabel (ReleaseCallback, true)) return eInvalidObjectLabel; // can't switch plugins here :) *************** *** 3640,3642 **** --- 3674,3815 ---- return eOK; } // end of CMiniWindow::HotspotTooltip + + long CMiniWindow::DrawImageAlpha(LPCTSTR ImageId, + long Left, long Top, long Right, long Bottom, + double Opacity, + long SrcLeft, long SrcTop) + { + + // constrain to what we actually have + if (Left < 0) + Left = 0; + if (Top < 0) + Top = 0; + if (Right > m_iWidth) + Right = m_iWidth; + if (Bottom > m_iHeight) + Bottom = m_iHeight; + + if (Opacity < 0.0 || Opacity > 1.0) + return eBadParameter; + + // image to be merged + ImageMapIterator it = m_Images.find (ImageId); + + if (it == m_Images.end ()) + return eImageNotInstalled; + + CBitmap * bitmap = it->second; + + + BITMAP bi; + bitmap->GetBitmap(&bi); + + // can't do it unless we have alpha channel + if (bi.bmBitsPixel != 32) + return eImageNotInstalled; + + // calculate size of desired rectangle + long iWidth = FixRight (Right) - Left; + long iHeight = FixBottom (Bottom) - Top; + + // constrain to what we actually have + if (SrcLeft < 0) + SrcLeft = 0; + if (SrcTop < 0) + SrcTop = 0; + + if (iWidth <= 0 || iHeight <= 0) // sanity check + return eOK; + + // merge layer (from image id) + CDC A_DC; + A_DC.CreateCompatibleDC(&dc); + + BITMAPINFO bmi; + ZeroMemory (&bmi, sizeof bmi); + + bmi.bmiHeader.biSize = sizeof bmi; + bmi.bmiHeader.biWidth = iWidth; + bmi.bmiHeader.biHeight = iHeight; + bmi.bmiHeader.biPlanes = 1; + bmi.bmiHeader.biBitCount = 32; + bmi.bmiHeader.biCompression = BI_RGB; + bmi.bmiHeader.biSizeImage = iHeight * BytesPerLine (iWidth, 32); + + unsigned char * pA = NULL; + + HBITMAP hbmA = CreateDIBSection(NULL, &bmi, DIB_RGB_COLORS, (void**) &pA, NULL, 0); + + HBITMAP hOldAbmp = (HBITMAP) SelectObject(A_DC.m_hDC, hbmA); + + CDC bmDC; // for loading bitmaps into + bmDC.CreateCompatibleDC(&dc); + + //copy part from image to upper layer + CBitmap *pOldbmp = bmDC.SelectObject(bitmap); + A_DC.BitBlt (0, 0, iWidth, iHeight, &bmDC, SrcLeft, SrcTop, SRCCOPY); + bmDC.SelectObject(pOldbmp); + + + // base image (from miniwindow) + + CDC B_DC; + B_DC.CreateCompatibleDC(&dc); + CBitmap B_bmp; + + unsigned char * pB = NULL; + + HBITMAP hbmB = CreateDIBSection(NULL, &bmi, DIB_RGB_COLORS, (void**) &pB, NULL, 0); + + HBITMAP hOldBbmp = (HBITMAP) SelectObject(B_DC.m_hDC, hbmB); + + // copy base image from miniwindow to bitmap + B_DC.BitBlt (0, 0, iWidth, iHeight, &dc, Left, Top, SRCCOPY); + + + long count = bmi.bmiHeader.biSizeImage; + long perline = BytesPerLine (iWidth, 24); + + long i; + + // do the merge + + #define Blend_Mask(A,B,M) ((uint8) ((A * M + B * (255 - M)) / 255) ) + + if (Opacity < 1.0) + { + for (i = 0; i < count; i += 4) + { + pB [i] = Simple_Opacity (pB [i], Blend_Mask (pA [i], pB [i], pA [i + 3]), Opacity); + pB [i + 1] = Simple_Opacity (pB [i + 1], Blend_Mask (pA [i + 1], pB [i + 1], pA [i + 3]), Opacity); + pB [i + 2] = Simple_Opacity (pB [i + 2], Blend_Mask (pA [i + 2], pB [i + 2], pA [i + 3]), Opacity); + } + } + else + { + for (i = 0; i < count; i += 4) + { + pB [i] = Blend_Mask (pA [i], pB [i], pA [i + 3]); + pB [i + 1] = Blend_Mask (pA [i + 1], pB [i + 1], pA [i + 3]); + pB [i + 2] = Blend_Mask (pA [i + 2], pB [i + 2], pA [i + 3]); + } + } + + + // copy result back + + dc.BitBlt (Left, Top, iWidth, iHeight, &B_DC, 0, 0, SRCCOPY); + + + SelectObject(A_DC.m_hDC, hOldAbmp); + SelectObject(B_DC.m_hDC, hOldBbmp); + + DeleteObject (hbmA); + DeleteObject (hbmB); + + return eOK; + + + } // end of CMiniWindow::DrawImageAlpha Index: mushclient.clw =================================================================== RCS file: /cvs/mushclient/mushclient.clw,v retrieving revision 1.344 retrieving revision 1.345 diff -c -r1.344 -r1.345 *** mushclient.clw 8 Jul 2008 03:49:51 -0000 1.344 --- mushclient.clw 8 Jul 2009 04:10:49 -0000 1.345 *************** *** 2,8 **** [General Info] Version=1 ! LastClass=CMUSHclientDoc LastTemplate=CDialog NewFileInclude1=#include "stdafx.h" NewFileInclude2=#include "mushclient.h" --- 2,8 ---- [General Info] Version=1 ! LastClass=CMUSHView LastTemplate=CDialog NewFileInclude1=#include "stdafx.h" NewFileInclude2=#include "mushclient.h" Index: mushclient.cnt =================================================================== RCS file: /cvs/mushclient/mushclient.cnt,v retrieving revision 1.63 retrieving revision 1.64 diff -c -r1.63 -r1.64 *** mushclient.cnt 23 Jun 2009 23:39:23 -0000 1.63 --- mushclient.cnt 6 Jul 2009 05:58:57 -0000 1.64 *************** *** 527,532 **** --- 527,533 ---- 3 WindowDeleteHotspot=FNC_WindowDeleteHotspot 3 WindowDragHandler=FNC_WindowDragHandler 3 WindowDrawImage=FNC_WindowDrawImage + 3 WindowDrawImageAlpha=FNC_WindowDrawImageAlpha 3 WindowFilter=FNC_WindowFilter 3 WindowFont=FNC_WindowFont 3 WindowFontInfo=FNC_WindowFontInfo Index: mushclient.hlp =================================================================== RCS file: /cvs/mushclient/mushclient.hlp,v retrieving revision 1.108 retrieving revision 1.109 diff -c -r1.108 -r1.109 Binary files /tmp/cvsORFGAB and /tmp/cvsHs5LmY differ Index: mushclient.odl =================================================================== RCS file: /cvs/mushclient/mushclient.odl,v retrieving revision 1.147 diff -c -r1.147 mushclient.odl *** mushclient.odl 23 Jun 2009 23:40:20 -0000 1.147 --- mushclient.odl 16 Jul 2009 01:52:43 -0000 *************** *** 70,83 **** [id(44)] long SetCommand(BSTR Message); [id(45)] BSTR GetNotes(); [id(46)] void SetNotes(BSTR Message); ! [id(397), propget] long NormalColour(short WhichColour); ! [id(397), propput] void NormalColour(short WhichColour, long nNewValue); ! [id(398), propget] long BoldColour(short WhichColour); ! [id(398), propput] void BoldColour(short WhichColour, long nNewValue); ! [id(399), propget] long CustomColourText(short WhichColour); ! [id(399), propput] void CustomColourText(short WhichColour, long nNewValue); ! [id(400), propget] long CustomColourBackground(short WhichColour); ! [id(400), propput] void CustomColourBackground(short WhichColour, long nNewValue); [id(47)] void Redraw(); [id(48)] long ResetTimer(BSTR TimerName); [id(49)] void SetOutputFont(BSTR FontName, short PointSize); --- 70,83 ---- [id(44)] long SetCommand(BSTR Message); [id(45)] BSTR GetNotes(); [id(46)] void SetNotes(BSTR Message); ! [id(398), propget] long NormalColour(short WhichColour); ! [id(398), propput] void NormalColour(short WhichColour, long nNewValue); ! [id(399), propget] long BoldColour(short WhichColour); ! [id(399), propput] void BoldColour(short WhichColour, long nNewValue); ! [id(400), propget] long CustomColourText(short WhichColour); ! [id(400), propput] void CustomColourText(short WhichColour, long nNewValue); ! [id(401), propget] long CustomColourBackground(short WhichColour); ! [id(401), propput] void CustomColourBackground(short WhichColour, long nNewValue); [id(47)] void Redraw(); [id(48)] long ResetTimer(BSTR TimerName); [id(49)] void SetOutputFont(BSTR FontName, short PointSize); *************** *** 428,433 **** --- 428,434 ---- [id(394)] long DatabaseReset(BSTR Name); [id(395)] void FlashIcon(); [id(396)] long WindowHotspotTooltip(BSTR Name, BSTR HotspotId, BSTR TooltipText); + [id(397)] long WindowDrawImageAlpha(BSTR Name, BSTR ImageId, long Left, long Top, long Right, long Bottom, double Opacity, long SrcLeft, long SrcTop); //}}AFX_ODL_METHOD }; Index: mushview.cpp =================================================================== RCS file: /cvs/mushclient/mushview.cpp,v retrieving revision 1.123 retrieving revision 1.126 diff -c -r1.123 -r1.126 *** mushview.cpp 23 Jun 2009 23:40:20 -0000 1.123 --- mushview.cpp 16 Jul 2009 01:49:52 -0000 1.126 *************** *** 120,126 **** ON_COMMAND(ID_FIND_AGAIN_FORWARDS, OnFindAgainForwards) ON_UPDATE_COMMAND_UI(ID_FIND_AGAIN_FORWARDS, OnUpdateFindAgainForwards) ON_COMMAND(ID_DISPLAY_GOTOURL, OnDisplayGotourl) ! ON_UPDATE_COMMAND_UI(ID_EDIT_COPY, OnUpdateNeedSelection) ON_COMMAND(ID_DISPLAY_SENDMAILTO, OnDisplaySendmailto) ON_COMMAND(ID_EDIT_SELECT_ALL, OnEditSelectAll) ON_WM_LBUTTONDBLCLK() --- 120,126 ---- ON_COMMAND(ID_FIND_AGAIN_FORWARDS, OnFindAgainForwards) ON_UPDATE_COMMAND_UI(ID_FIND_AGAIN_FORWARDS, OnUpdateFindAgainForwards) ON_COMMAND(ID_DISPLAY_GOTOURL, OnDisplayGotourl) ! ON_UPDATE_COMMAND_UI(ID_DISPLAY_GOTOURL, OnUpdateNeedSelection) ON_COMMAND(ID_DISPLAY_SENDMAILTO, OnDisplaySendmailto) ON_COMMAND(ID_EDIT_SELECT_ALL, OnEditSelectAll) ON_WM_LBUTTONDBLCLK() *************** *** 144,159 **** ON_COMMAND(ID_EDIT_COPYASHTML, OnEditCopyashtml) ON_COMMAND(ID_DISPLAY_HIGHLIGHTPHRASE, OnDisplayHighlightphrase) ON_COMMAND(ID_DISPLAY_MULTILINETRIGGER, OnDisplayMultilinetrigger) ! ON_UPDATE_COMMAND_UI(ID_DISPLAY_GOTOURL, OnUpdateNeedSelection) ON_UPDATE_COMMAND_UI(ID_FILE_SAVESELECTION, OnUpdateNeedSelection) ON_UPDATE_COMMAND_UI(ID_DISPLAY_SENDMAILTO, OnUpdateNeedSelection) ON_COMMAND(ID_KEYS_TAB, OnKeysActivatecommandview) ON_COMMAND(ID_KEYS_ESCAPE, OnKeysActivatecommandview) ON_UPDATE_COMMAND_UI(ID_DISPLAY_TEXTATTRIBUTES, OnUpdateNeedSelection) ON_UPDATE_COMMAND_UI(ID_EDIT_COPYASHTML, OnUpdateNeedSelection) ! ON_COMMAND(ID_WINDOW_MAXIMIZE, OnWindowMaximize) ! ON_COMMAND(ID_WINDOW_RESTORE, OnWindowRestore) ! ON_WM_SYSCOMMAND() //}}AFX_MSG_MAP // macros --- 144,162 ---- ON_COMMAND(ID_EDIT_COPYASHTML, OnEditCopyashtml) ON_COMMAND(ID_DISPLAY_HIGHLIGHTPHRASE, OnDisplayHighlightphrase) ON_COMMAND(ID_DISPLAY_MULTILINETRIGGER, OnDisplayMultilinetrigger) ! ON_COMMAND(ID_WINDOW_MAXIMIZE, OnWindowMaximize) ! ON_COMMAND(ID_WINDOW_RESTORE, OnWindowRestore) ! ON_WM_SYSCOMMAND() ! ON_WM_RBUTTONUP() ! ON_WM_RBUTTONDOWN() ! ON_UPDATE_COMMAND_UI(ID_EDIT_COPY, OnUpdateNeedSelectionForCopy) ON_UPDATE_COMMAND_UI(ID_FILE_SAVESELECTION, OnUpdateNeedSelection) ON_UPDATE_COMMAND_UI(ID_DISPLAY_SENDMAILTO, OnUpdateNeedSelection) ON_COMMAND(ID_KEYS_TAB, OnKeysActivatecommandview) ON_COMMAND(ID_KEYS_ESCAPE, OnKeysActivatecommandview) ON_UPDATE_COMMAND_UI(ID_DISPLAY_TEXTATTRIBUTES, OnUpdateNeedSelection) ON_UPDATE_COMMAND_UI(ID_EDIT_COPYASHTML, OnUpdateNeedSelection) ! ON_WM_RBUTTONDBLCLK() //}}AFX_MSG_MAP // macros *************** *** 770,776 **** } // end of not absolute position ! if (iMode <= 3) // stretch pDestDC->StretchBlt(rect.left, rect.top, rect.right, rect.bottom, pSrcDC, 0, 0, iWidth, iHeight, SRCCOPY); else { // normal --- 773,779 ---- } // end of not absolute position ! if (iMode <= 3 && !bUseRect) // stretch (not for absolute rectangles) pDestDC->StretchBlt(rect.left, rect.top, rect.right, rect.bottom, pSrcDC, 0, 0, iWidth, iHeight, SRCCOPY); else { // normal *************** *** 1418,1423 **** --- 1421,1428 ---- m_selend_col = 0; m_bAtBufferEnd = true; // note we are at end + SelectionChanged (); + } void CMUSHView::OnTestPagedown() *************** *** 1717,1722 **** --- 1722,1729 ---- m_selend_col = m_pin_col; } + SelectionChanged (); + // auto-copy selection to clipboard if (pDoc->m_bCopySelectionToClipboard) if (pDoc->m_bAutoCopyInHTML) *************** *** 2133,2138 **** --- 2140,2146 ---- { // shift key not down, just start a new selection m_selend_line = m_pin_line = m_selstart_line = line; m_selend_col = m_pin_col = m_selstart_col = col; + SelectionChanged (); } // end of shift key not down Invalidate (); *************** *** 2151,2156 **** --- 2159,2186 ---- // CView::OnLButtonDown(nFlags, point); } + + void CMUSHView::OnRButtonDown(UINT nFlags, CPoint point) + { + CMUSHclientDoc* pDoc = GetDocument(); + ASSERT_VALID(pDoc); + + + // CView changes the viewport origin and mapping mode. + // It's necessary to convert the point from device coordinates + // to logical coordinates, such as are stored in the document. + CPoint mwpoint = point; + CClientDC dc(this); + OnPrepareDC(&dc); + dc.DPtoLP(&mwpoint); + + // if click in mini-window, don't continue + if (Mouse_Down_MiniWindow (pDoc, mwpoint, 0x20)) // RH mouse, single click + return; + + CView::OnRButtonDown(nFlags, point); + } + void CMUSHView::OnLButtonUp(UINT nFlags, CPoint point) { *************** *** 2174,2180 **** // if miniwindow handles it, don't continue ! if (Mouse_Up_MiniWindow (pDoc, point)) return; if (GetCapture() != this) --- 2204,2210 ---- // if miniwindow handles it, don't continue ! if (Mouse_Up_MiniWindow (pDoc, point, 0x10)) return; if (GetCapture() != this) *************** *** 2222,2227 **** --- 2252,2284 ---- // CView::OnLButtonUp(nFlags, point); } + + void CMUSHView::OnRButtonUp(UINT nFlags, CPoint point) + { + CMUSHclientDoc* pDoc = GetDocument(); + ASSERT_VALID(pDoc); + + + CClientDC dc(this); + + // CView changes the viewport origin and mapping mode. + // It's necessary to convert the point from device coordinates + // to logical coordinates, such as are stored in the document. + CPoint mwpoint = point; + OnPrepareDC(&dc); // set up mapping mode and viewport origin + dc.DPtoLP(&mwpoint); + + + // if miniwindow handles it, don't continue + if (Mouse_Up_MiniWindow (pDoc, mwpoint, 0x20)) + return; + + + CView::OnRButtonUp(nFlags, point); + } + + + void CMUSHView::OnMouseMove(UINT nFlags, CPoint point) { CMUSHclientDoc* pDoc = GetDocument(); *************** *** 2668,2679 **** --- 2725,2738 ---- { m_selstart_line = 0; m_selstart_col = 0; + SelectionChanged (); } if (m_selend_line < 0) { m_selend_line = 0; m_selend_col = 0; + SelectionChanged (); } if (m_pin_line < 0) *************** *** 2796,2814 **** CString strSelection; if (GetSelection (strSelection)) return; // error in producing selection putontoclipboard (strSelection, pDoc->m_bUTF_8); ! // put the focus back in the send window ! OnKeysActivatecommandview (); } ! void CMUSHView::OnUpdateNeedSelection(CCmdUI* pCmdUI) { CMUSHclientDoc* pDoc = GetDocument(); ASSERT_VALID(pDoc); --- 2855,2899 ---- CString strSelection; + // put the focus back in the send window + + OnKeysActivatecommandview (); + + // if no selection here, try a selection in the command window if (GetSelection (strSelection)) + { + m_bottomview->CEditView::OnEditCopy (); return; // error in producing selection + } putontoclipboard (strSelection, pDoc->m_bUTF_8); ! } ! void CMUSHView::OnUpdateNeedSelection(CCmdUI* pCmdUI) ! { ! CMUSHclientDoc* pDoc = GetDocument(); ! ASSERT_VALID(pDoc); + long startcol, + endcol; + + CLine * pStartLine, + * pEndLine; + + pStartLine = pDoc->m_LineList.GetAt (pDoc->GetLinePosition (m_selstart_line)); + pEndLine = pDoc->m_LineList.GetAt (pDoc->GetLinePosition (m_selend_line)); + + startcol = MIN (m_selstart_col, pStartLine->len); + endcol = MIN (m_selend_col, pEndLine->len); + + pCmdUI->Enable (m_selend_line > m_selstart_line || + (m_selend_line == m_selstart_line && + endcol > startcol)); } ! void CMUSHView::OnUpdateNeedSelectionForCopy(CCmdUI* pCmdUI) { CMUSHclientDoc* pDoc = GetDocument(); ASSERT_VALID(pDoc); *************** *** 2825,2837 **** startcol = MIN (m_selstart_col, pStartLine->len); endcol = MIN (m_selend_col, pEndLine->len); ! pCmdUI->Enable (m_selend_line > m_selstart_line || (m_selend_line == m_selstart_line && ! endcol > startcol)); } BOOL CMUSHView::OnEraseBkgnd(CDC* pDC) { CMUSHclientDoc* pDoc = GetDocument(); --- 2910,2926 ---- startcol = MIN (m_selstart_col, pStartLine->len); endcol = MIN (m_selend_col, pEndLine->len); ! if (m_selend_line > m_selstart_line || (m_selend_line == m_selstart_line && ! endcol > startcol)) ! pCmdUI->Enable (TRUE); ! else ! m_bottomview->CEditView::OnUpdateNeedSel (pCmdUI); } + BOOL CMUSHView::OnEraseBkgnd(CDC* pDC) { CMUSHclientDoc* pDoc = GetDocument(); *************** *** 3279,3289 **** --- 3368,3380 ---- point.Offset(5, 5); } + // new, for MXP - see if they clicked on a hyperlink CPoint menupoint = point; ScreenToClient (&point); + if (pDoc->m_bMXP && pDoc->m_FontHeight) { int line, *************** *** 3782,3788 **** this); dlg.m_ofn.lpstrTitle = "Saved selection"; ! if (dlg.DoModal() != IDOK) return; try --- 3873,3883 ---- this); dlg.m_ofn.lpstrTitle = "Saved selection"; ! ChangeToFileBrowsingDirectory (); ! int nResult = dlg.DoModal(); ! ChangeToStartupDirectory (); ! ! if (nResult != IDOK) return; try *************** *** 4276,4281 **** --- 4371,4378 ---- m_selend_line = pDoc->m_LineList.GetCount (); m_selend_col = pDoc->m_nWrapColumn; + SelectionChanged (); + Invalidate (); #if REDRAW_DEBUG *************** *** 4442,4448 **** CString strCurrentLine; m_selstart_col = m_selend_col = col; ! m_selstart_line = m_selstart_line = line; // SHIFT-double-click to select a paragraph if (nFlags & MK_SHIFT) --- 4539,4545 ---- CString strCurrentLine; m_selstart_col = m_selend_col = col; ! m_selstart_line = m_selend_line = line; // SHIFT-double-click to select a paragraph if (nFlags & MK_SHIFT) *************** *** 4526,4531 **** --- 4623,4630 ---- newrgn.DeleteObject (); oldrgn.DeleteObject (); + SelectionChanged (); + // if they want, send word to MUD if (!strCurrentLine.IsEmpty ()) if (pDoc->m_bDoubleClickSends) *************** *** 4558,4563 **** --- 4657,4684 ---- } + void CMUSHView::OnRButtonDblClk(UINT nFlags, CPoint point) + { + CMUSHclientDoc* pDoc = GetDocument(); + ASSERT_VALID(pDoc); + + + // CView changes the viewport origin and mapping mode. + // It's necessary to convert the point from device coordinates + // to logical coordinates, such as are stored in the document. + CPoint mwpoint = point; + CClientDC dc(this); + OnPrepareDC(&dc); + dc.DPtoLP(&mwpoint); + + // if click in mini-window, don't continue + if (Mouse_Down_MiniWindow (pDoc, mwpoint, 0x60)) // RH mouse - double click + return; + + CView::OnRButtonDblClk(nFlags, point); + } + + void CMUSHView::OnDisplayGotobookmark() { CMUSHclientDoc* pDoc = GetDocument(); *************** *** 4651,4656 **** --- 4772,4778 ---- if (pLine->flags & BOOKMARK) m_selend_col = pLine->len; + SelectionChanged (); // Get new selection region *************** *** 5523,5543 **** // select the found text, so it is highlighted ! m_selstart_line = iLine; ! m_selend_line = iLine + 1; ! m_selstart_col = 0; ! m_selend_col = 0; #if REDRAW_DEBUG ShowInvalidatedRgn (this, oldrgn); #endif ! Invalidate (); ! // freeze output, so they can study the found text at leisure ! EnsureSelectionVisible (); } // end of CMUSHView::SelectLine --- 5645,5667 ---- // select the found text, so it is highlighted ! m_selstart_line = iLine; ! m_selend_line = iLine + 1; ! m_selstart_col = 0; ! m_selend_col = 0; ! ! SelectionChanged (); #if REDRAW_DEBUG ShowInvalidatedRgn (this, oldrgn); #endif ! Invalidate (); ! // freeze output, so they can study the found text at leisure ! EnsureSelectionVisible (); } // end of CMUSHView::SelectLine *************** *** 6167,6174 **** if (!mw->GetShow ()) continue; ! // underneath ones can't be clicked on ! if (mw->GetFlags () & MINIWINDOW_DRAW_UNDERNEATH) continue; if (!mw->m_rect.PtInRect(point)) --- 6291,6298 ---- if (!mw->GetShow ()) continue; ! // underneath ones can't be clicked on - or if set to ignore the mouse ! if (mw->GetFlags () & (MINIWINDOW_DRAW_UNDERNEATH | MINIWINDOW_IGNORE_MOUSE)) continue; if (!mw->m_rect.PtInRect(point)) *************** *** 6392,6399 **** if (it != old_mw->m_Hotspots.end ()) Send_Mouse_Event_To_Plugin (old_mw->m_sCallbackPlugin, it->second->m_sCancelMouseOver, ! old_mw->m_sMouseOverHotspot, ! flags); // LH mouse? old_mw->m_sMouseOverHotspot.erase (); // no mouse-over right now m_sPreviousMiniWindow.erase (); // no longer have a previous mouse-over } // we had previous hotspot --- 6516,6522 ---- if (it != old_mw->m_Hotspots.end ()) Send_Mouse_Event_To_Plugin (old_mw->m_sCallbackPlugin, it->second->m_sCancelMouseOver, ! old_mw->m_sMouseOverHotspot); old_mw->m_sMouseOverHotspot.erase (); // no mouse-over right now m_sPreviousMiniWindow.erase (); // no longer have a previous mouse-over } // we had previous hotspot *************** *** 6416,6422 **** Send_Mouse_Event_To_Plugin (mw->m_sCallbackPlugin, pHotspot->m_sMouseDown, ! sHotspotId); } m_sPreviousMiniWindow = sMiniWindowId; // remember in case they move outside window --- 6539,6546 ---- Send_Mouse_Event_To_Plugin (mw->m_sCallbackPlugin, pHotspot->m_sMouseDown, ! sHotspotId, ! flags); // LH / RH mouse? } m_sPreviousMiniWindow = sMiniWindowId; // remember in case they move outside window *************** *** 6429,6435 **** } // end of CMUSHView::Mouse_Down_MiniWindow ! bool CMUSHView::Mouse_Up_MiniWindow (CMUSHclientDoc* pDoc, CPoint point) { // see if we clicked over one of our miniwindows --- 6553,6559 ---- } // end of CMUSHView::Mouse_Down_MiniWindow ! bool CMUSHView::Mouse_Up_MiniWindow (CMUSHclientDoc* pDoc, CPoint point, long flags) { // see if we clicked over one of our miniwindows *************** *** 6488,6493 **** --- 6612,6619 ---- // A mouse-up not in this miniwindow cancels a previous mouse-down if (sMiniWindowId != m_sPreviousMiniWindow && !m_sPreviousMiniWindow.empty ()) { + ReleaseCapture(); // Release the mouse capture established at + // the beginning of the mouse click. MiniWindowMapIterator it = pDoc->m_MiniWindows.find (m_sPreviousMiniWindow); *************** *** 6513,6520 **** } // previous window still exists m_sPreviousMiniWindow.erase (); // no longer have a previous window - ReleaseCapture(); // Release the mouse capture established at - // the beginning of the mouse click. bPreviouslyInMiniwindow = true; --- 6639,6644 ---- *************** *** 6526,6531 **** --- 6650,6657 ---- mw->m_last_mouseposition = CPoint (point.x - mw->m_rect.left, point.y - mw->m_rect.top); mw->m_last_mouse_update++; + ReleaseCapture(); // Release the mouse capture established at + // the beginning of the mouse click. // if mouse-up outside the current hotspot just cancel previous one // cancel previous mouse-down hotspot (in this miniwindow) *************** *** 6548,6561 **** { Send_Mouse_Event_To_Plugin (mw->m_sCallbackPlugin, pHotspot->m_sMouseUp, ! sHotspotId, 0x10); mw->m_sMouseDownHotspot.erase (); // no mouse-down right now } m_sPreviousMiniWindow.erase (); // no longer have a previous mouse-over - ReleaseCapture(); // Release the mouse capture established at - // the beginning of the mouse click. return true; // we are over mini-window - don't check for underlying text } --- 6674,6686 ---- { Send_Mouse_Event_To_Plugin (mw->m_sCallbackPlugin, pHotspot->m_sMouseUp, ! sHotspotId, ! flags); // LH / RH mouse? mw->m_sMouseDownHotspot.erase (); // no mouse-down right now } m_sPreviousMiniWindow.erase (); // no longer have a previous mouse-over return true; // we are over mini-window - don't check for underlying text } *************** *** 6946,6948 **** --- 7071,7088 ---- return pDoc->m_TextRectangle != CRect (0, 0, 0, 0); } // end of CMUSHView::HaveTextRectangle + + void CMUSHView::SelectionChanged (void) + { + + // no selection? do nothing + if (!(m_selend_line > m_selstart_line || + (m_selend_line == m_selstart_line && + m_selend_col > m_selstart_col))) + return; + + // something selected? cancel command window selection + m_bottomview->CancelSelection (); + + } // end of CMUSHView::::SelectionChanged + Index: mushview.h =================================================================== RCS file: /cvs/mushclient/mushview.h,v retrieving revision 1.41 retrieving revision 1.43 diff -c -r1.41 -r1.43 *** mushview.h 14 Feb 2009 04:52:56 -0000 1.41 --- mushview.h 16 Jul 2009 01:49:53 -0000 1.43 *************** *** 103,109 **** bool Mouse_Move_MiniWindow (CMUSHclientDoc* pDoc, CPoint point); bool Mouse_Down_MiniWindow (CMUSHclientDoc* pDoc, CPoint point, long flags); ! bool Mouse_Up_MiniWindow (CMUSHclientDoc* pDoc, CPoint point); bool Mouse_Tooltip_MiniWindow (CMUSHclientDoc* pDoc, CPoint point, NMHDR * pNMHDR); void Calculate_MiniWindow_Rectangles (CMUSHclientDoc* pDoc, const bool bUnderneath); --- 103,109 ---- bool Mouse_Move_MiniWindow (CMUSHclientDoc* pDoc, CPoint point); bool Mouse_Down_MiniWindow (CMUSHclientDoc* pDoc, CPoint point, long flags); ! bool Mouse_Up_MiniWindow (CMUSHclientDoc* pDoc, CPoint point, long flags); bool Mouse_Tooltip_MiniWindow (CMUSHclientDoc* pDoc, CPoint point, NMHDR * pNMHDR); void Calculate_MiniWindow_Rectangles (CMUSHclientDoc* pDoc, const bool bUnderneath); *************** *** 151,156 **** --- 151,157 ---- bool GetSelection(CFile & f); bool GetSelection(CString & s); void SendMacro (int whichone); + void SelectionChanged (void); // Overrides // ClassWizard generated virtual function overrides *************** *** 242,252 **** --- 243,257 ---- afx_msg void OnWindowMaximize(); afx_msg void OnWindowRestore(); afx_msg void OnSysCommand(UINT nID, LPARAM lParam); + afx_msg void OnRButtonUp(UINT nFlags, CPoint point); + afx_msg void OnRButtonDown(UINT nFlags, CPoint point); + afx_msg void OnRButtonDblClk(UINT nFlags, CPoint point); //}}AFX_MSG afx_msg BOOL OnMacroCommand(UINT nIDC); afx_msg BOOL OnKeypadCommand(UINT nIDC); afx_msg void OnMXPMenu(UINT nID); afx_msg void OnAcceleratorCommand(UINT nID); + afx_msg void OnUpdateNeedSelectionForCopy(CCmdUI* pCmdUI); DECLARE_MESSAGE_MAP() }; Index: mxpOpenAtomic.cpp =================================================================== RCS file: /cvs/mushclient/mxpOpenAtomic.cpp,v retrieving revision 1.13 retrieving revision 1.14 diff -c -r1.13 -r1.14 *** mxpOpenAtomic.cpp 12 Jun 2007 04:02:02 -0000 1.13 --- mxpOpenAtomic.cpp 6 Jul 2009 05:58:57 -0000 1.14 *************** *** 608,613 **** --- 608,614 ---- bIgnoreUnusedArgs = true; // don't worry about args for now :) StartNewLine (true, 0); + SetNewLineColour (0); break; // end of MXP_ACTION_BR // reset Index: plugins.cpp =================================================================== RCS file: /cvs/mushclient/plugins.cpp,v retrieving revision 1.47 retrieving revision 1.48 diff -c -r1.47 -r1.48 *** plugins.cpp 23 Jun 2009 23:40:20 -0000 1.47 --- plugins.cpp 6 Jul 2009 05:58:57 -0000 1.48 *************** *** 784,790 **** // use default plugins directory dlg.m_ofn.lpstrInitialDir = Make_Absolute_Path (App.m_strPluginsDirectory); ! if (dlg.DoModal() != IDOK) return; strFilename = dlg.GetPathName(); --- 784,794 ---- // use default plugins directory dlg.m_ofn.lpstrInitialDir = Make_Absolute_Path (App.m_strPluginsDirectory); ! ChangeToFileBrowsingDirectory (); ! int nResult = dlg.DoModal(); ! ChangeToStartupDirectory (); ! ! if (nResult != IDOK) return; strFilename = dlg.GetPathName(); Index: prefspropertypages.cpp =================================================================== RCS file: /cvs/mushclient/prefspropertypages.cpp,v retrieving revision 1.110 retrieving revision 1.111 diff -c -r1.110 -r1.111 *** prefspropertypages.cpp 14 Feb 2009 03:10:35 -0000 1.110 --- prefspropertypages.cpp 6 Jul 2009 05:58:57 -0000 1.111 *************** *** 1208,1214 **** // use default log file directory dlg.m_ofn.lpstrInitialDir = Make_Absolute_Path (App.m_strDefaultLogFileDirectory); ! if (dlg.DoModal() != IDOK) return; m_ctlLogFileName.SetWindowText (dlg.GetPathName()); --- 1208,1218 ---- // use default log file directory dlg.m_ofn.lpstrInitialDir = Make_Absolute_Path (App.m_strDefaultLogFileDirectory); ! ChangeToFileBrowsingDirectory (); ! int nResult = dlg.DoModal(); ! ChangeToStartupDirectory (); ! ! if (nResult != IDOK) return; m_ctlLogFileName.SetWindowText (dlg.GetPathName()); *************** *** 4709,4715 **** filedlg.m_ofn.lpstrFile = filename.GetBuffer (_MAX_PATH); // needed!! (for Win32s) strcpy (filedlg.m_ofn.lpstrFile, ""); ! if (filedlg.DoModal () != IDOK) return; // cancelled dialog try --- 4713,4723 ---- filedlg.m_ofn.lpstrFile = filename.GetBuffer (_MAX_PATH); // needed!! (for Win32s) strcpy (filedlg.m_ofn.lpstrFile, ""); ! ChangeToFileBrowsingDirectory (); ! int nResult = filedlg.DoModal(); ! ChangeToStartupDirectory (); ! ! if (nResult != IDOK) return; // cancelled dialog try *************** *** 4778,4784 **** else strcpy (filedlg.m_ofn.lpstrFile, suggested_name); ! if (filedlg.DoModal () != IDOK) return; // cancelled dialog try --- 4786,4796 ---- else strcpy (filedlg.m_ofn.lpstrFile, suggested_name); ! ChangeToFileBrowsingDirectory (); ! int nResult = filedlg.DoModal(); ! ChangeToStartupDirectory (); ! ! if (nResult != IDOK) return; // cancelled dialog try *************** *** 5634,5640 **** strcpy (filedlg.m_ofn.lpstrFile, m_strBeepSound); ! if (filedlg.DoModal () != IDOK) return; // cancelled dialog m_strBeepSound = filedlg.GetPathName (); --- 5646,5656 ---- strcpy (filedlg.m_ofn.lpstrFile, m_strBeepSound); ! ChangeToFileBrowsingDirectory (); ! int nResult = filedlg.DoModal(); ! ChangeToStartupDirectory (); ! ! if (nResult != IDOK) return; // cancelled dialog m_strBeepSound = filedlg.GetPathName (); *************** *** 6601,6607 **** dlg.m_ofn.lpstrTitle = "Script source file"; ! if (dlg.DoModal() != IDOK) return FALSE; m_strScriptFilename = dlg.GetPathName (); --- 6617,6627 ---- dlg.m_ofn.lpstrTitle = "Script source file"; ! ChangeToFileBrowsingDirectory (); ! int nResult = dlg.DoModal(); ! ChangeToStartupDirectory (); ! ! if (nResult != IDOK) return FALSE; m_strScriptFilename = dlg.GetPathName (); *************** *** 6837,6843 **** dlg.m_ofn.lpstrTitle = "Script editor"; ! if (dlg.DoModal() != IDOK) return; m_strScriptEditor = dlg.GetPathName (); --- 6857,6867 ---- dlg.m_ofn.lpstrTitle = "Script editor"; ! ChangeToFileBrowsingDirectory (); ! int nResult = dlg.DoModal(); ! ChangeToStartupDirectory (); ! ! if (nResult != IDOK) return; m_strScriptEditor = dlg.GetPathName (); *************** *** 7222,7228 **** OFN_HIDEREADONLY|OFN_FILEMUSTEXIST, "Text files (*.txt)|*.txt|All files (*.*)|*.*||"); dlg.m_ofn.lpstrTitle = "Select variables file"; ! if (dlg.DoModal() != IDOK) return; --- 7246,7257 ---- OFN_HIDEREADONLY|OFN_FILEMUSTEXIST, "Text files (*.txt)|*.txt|All files (*.*)|*.*||"); dlg.m_ofn.lpstrTitle = "Select variables file"; ! ! ChangeToFileBrowsingDirectory (); ! int nResult = dlg.DoModal(); ! ChangeToStartupDirectory (); ! ! if (nResult != IDOK) return; *************** *** 7345,7351 **** this); dlg.m_ofn.lpstrTitle = "File to save variables as"; ! if (dlg.DoModal() != IDOK) return; f = new CFile (dlg.GetPathName (), --- 7374,7384 ---- this); dlg.m_ofn.lpstrTitle = "File to save variables as"; ! ChangeToFileBrowsingDirectory (); ! int nResult = dlg.DoModal(); ! ChangeToStartupDirectory (); ! ! if (nResult != IDOK) return; f = new CFile (dlg.GetPathName (), *************** *** 8353,8359 **** if (m_sound_pathname == NOSOUNDLIT) strcpy (filedlg.m_ofn.lpstrFile, ""); ! if (filedlg.DoModal () != IDOK) return; // cancelled dialog m_sound_pathname = filedlg.GetPathName (); --- 8386,8396 ---- if (m_sound_pathname == NOSOUNDLIT) strcpy (filedlg.m_ofn.lpstrFile, ""); ! ChangeToFileBrowsingDirectory (); ! int nResult = filedlg.DoModal(); ! ChangeToStartupDirectory (); ! ! if (nResult != IDOK) return; // cancelled dialog m_sound_pathname = filedlg.GetPathName (); Index: sendvw.cpp =================================================================== RCS file: /cvs/mushclient/sendvw.cpp,v retrieving revision 1.92 retrieving revision 1.93 diff -c -r1.92 -r1.93 *** sendvw.cpp 22 Feb 2009 06:26:35 -0000 1.92 --- sendvw.cpp 8 Jul 2009 04:10:49 -0000 1.93 *************** *** 242,247 **** --- 242,249 ---- /* Handler to suppress default ALT key behaviour. */ ON_WM_SYSCOMMAND() + ON_COMMAND(ID_EDIT_COPY, OnEditCopy) + ON_UPDATE_COMMAND_UI(ID_EDIT_COPY, OnUpdateNeedSel) END_MESSAGE_MAP() *************** *** 2827,2832 **** --- 2829,2835 ---- } + // auto resizing of command window based on amount of content void CSendView::AdjustCommandWindowSize (void) { CMUSHclientDoc* pDoc = GetDocument(); *************** *** 2861,2863 **** --- 2864,2937 ---- } + // if we have a selection here, drop the selection in the output window + void CSendView::CheckForSelectionChange (void) + { + int nStartChar; + int nEndChar; + + GetEditCtrl().GetSel(nStartChar, nEndChar); + + // no selection? leave alone + if (nStartChar == nEndChar) + return; + + // no selection already? don't do anything else + if (!(m_topview->m_selend_line > m_topview->m_selstart_line || + (m_topview->m_selend_line == m_topview->m_selstart_line && + m_topview->m_selend_col > m_topview->m_selstart_col))) + return; + + // we have a selection, so cancel top view's selection + m_topview->m_selstart_line = 0; + m_topview->m_selstart_col = 0; + m_topview->m_selend_line = 0; + m_topview->m_selend_col = 0; + + m_topview->Invalidate (); + + } // end of CSendView::CheckForSelectionChange + + void CSendView::CancelSelection (void) + { + + int nStartChar; + int nEndChar; + + GetEditCtrl().GetSel(nStartChar, nEndChar); + + // no selection? leave alone + if (nStartChar == nEndChar) + return; + + // put cursor at end of previous selection + GetEditCtrl().SetSel (nEndChar, nEndChar); + + } // end of CSendView::CancelSelection + + + void CSendView::OnEditCopy() + { + + // if top view does NOT has a selection, copy from here + if (!(m_topview->m_selend_line > m_topview->m_selstart_line || + (m_topview->m_selend_line == m_topview->m_selstart_line && + m_topview->m_selend_col > m_topview->m_selstart_col))) + CEditView::OnEditCopy (); + else + m_topview->OnEditCopy (); // otherwise copy from there + + } + + void CSendView::OnUpdateNeedSel(CCmdUI* pCmdUI) + { + + // if top view does NOT has a selection, enable copy in the usual way + if (!(m_topview->m_selend_line > m_topview->m_selstart_line || + (m_topview->m_selend_line == m_topview->m_selstart_line && + m_topview->m_selend_col > m_topview->m_selstart_col))) + CEditView::OnUpdateNeedSel (pCmdUI); + else + pCmdUI->Enable(TRUE); // we have a selection in the top view, enable copying + + } Index: sendvw.h =================================================================== RCS file: /cvs/mushclient/sendvw.h,v retrieving revision 1.32 retrieving revision 1.33 diff -c -r1.32 -r1.33 *** sendvw.h 21 Feb 2009 19:47:05 -0000 1.32 --- sendvw.h 8 Jul 2009 04:10:49 -0000 1.33 *************** *** 78,85 **** void AddToCommandHistory (const CString & strCommand); void AdjustCommandWindowSize (void); ! ! // Overrides // ClassWizard generated virtual function overrides //{{AFX_VIRTUAL(CSendView) public: --- 78,87 ---- void AddToCommandHistory (const CString & strCommand); void AdjustCommandWindowSize (void); ! void CheckForSelectionChange (void); ! void CancelSelection (void); ! ! // Overrides // ClassWizard generated virtual function overrides //{{AFX_VIRTUAL(CSendView) public: *************** *** 199,204 **** --- 201,208 ---- afx_msg void OnAcceleratorCommand(UINT nID); afx_msg void OnInitMenu(CMenu* pMenu); afx_msg void OnInitMenuPopup(CMenu* pMenu, UINT nIndex, BOOL bSysMenu); + afx_msg void OnEditCopy(); + afx_msg void OnUpdateNeedSel(CCmdUI* pCmdUI); DECLARE_MESSAGE_MAP() }; Index: stdafx.h =================================================================== RCS file: /cvs/mushclient/stdafx.h,v retrieving revision 1.116 retrieving revision 1.118 diff -c -r1.116 -r1.118 *** stdafx.h 23 Jun 2009 23:40:20 -0000 1.116 --- stdafx.h 6 Jul 2009 21:35:01 -0000 1.118 *************** *** 904,906 **** --- 904,911 ---- long LoadPng (LPCTSTR FileName, HBITMAP & hbmp); // load a PNG file into a bitmap + long LoadPngMemory (unsigned char * Buffer, const size_t Length, HBITMAP & hbmp, const bool bAlpha); // load a PNG from memory into a bitmap + + void ChangeToFileBrowsingDirectory (); + void ChangeToStartupDirectory (); + Index: triggdlg.cpp =================================================================== RCS file: /cvs/mushclient/triggdlg.cpp,v retrieving revision 1.43 retrieving revision 1.44 diff -c -r1.43 -r1.44 *** triggdlg.cpp 25 Jul 2007 05:02:27 -0000 1.43 --- triggdlg.cpp 6 Jul 2009 05:58:57 -0000 1.44 *************** *** 463,469 **** if (m_sound_pathname == NOSOUNDLIT) strcpy (filedlg.m_ofn.lpstrFile, ""); ! if (filedlg.DoModal () != IDOK) return; // cancelled dialog m_sound_pathname = filedlg.GetPathName (); --- 463,473 ---- if (m_sound_pathname == NOSOUNDLIT) strcpy (filedlg.m_ofn.lpstrFile, ""); ! ChangeToFileBrowsingDirectory (); ! int nResult = filedlg.DoModal(); ! ChangeToStartupDirectory (); ! ! if (nResult != IDOK) return; // cancelled dialog m_sound_pathname = filedlg.GetPathName (); Index: install/mushclient.nsi =================================================================== RCS file: /cvs/mushclient/install/mushclient.nsi,v retrieving revision 1.67 retrieving revision 1.68 diff -c -r1.67 -r1.68 *** install/mushclient.nsi 21 Feb 2009 19:47:05 -0000 1.67 --- install/mushclient.nsi 16 Jul 2009 01:49:53 -0000 1.68 *************** *** 311,316 **** --- 311,318 ---- File "..\lua\getworld.lua" File "..\lua\checkplugin.lua" File "..\lua\re.lua" + File "..\lua\mw.lua" + File "..\lua\movewindow.lua" ; Set output path to the scripts subdirectory. SetOutPath $INSTDIR\scripts *************** *** 442,447 **** --- 444,451 ---- Delete "$INSTDIR\lua\getworld.lua" Delete "$INSTDIR\lua\checkplugin.lua" Delete "$INSTDIR\lua\re.lua" + Delete "$INSTDIR\lua\mw.lua" + Delete "$INSTDIR\lua\movewindow.lua" ; spell checker stuff Delete "$INSTDIR\spellchecker.lua" Index: install/readme.txt =================================================================== RCS file: /cvs/mushclient/install/readme.txt,v retrieving revision 1.190 retrieving revision 1.192 diff -c -r1.190 -r1.192 *** install/readme.txt 23 Jun 2009 23:40:20 -0000 1.190 --- install/readme.txt 16 Jul 2009 01:49:53 -0000 1.192 *************** *** 1,7 **** ! MUSHclient version 4.41 ======================= ! Wednesday, 24th June, 2009 Author: Nick Gammon Web support: http://www.gammon.com.au/forum/ --- 1,7 ---- ! MUSHclient version 4.42 ======================= ! Thursday, 16th July, 2009 Author: Nick Gammon Web support: http://www.gammon.com.au/forum/