Skip to content

Commit

Permalink
Merge branch 'master' of github.com:scummvm/scummvm
Browse files Browse the repository at this point in the history
  • Loading branch information
Travis Howell committed Jun 29, 2011
2 parents 50f28f2 + 3385fd3 commit 0be5ba9
Show file tree
Hide file tree
Showing 13 changed files with 648 additions and 506 deletions.
122 changes: 121 additions & 1 deletion backends/taskbar/win32/win32-taskbar.cpp
Expand Up @@ -66,7 +66,7 @@
// System.Title property key, values taken from http://msdn.microsoft.com/en-us/library/bb787584.aspx
const PROPERTYKEY PKEY_Title = { /* fmtid = */ { 0xF29F85E0, 0x4FF9, 0x1068, { 0xAB, 0x91, 0x08, 0x00, 0x2B, 0x27, 0xB3, 0xD9 } }, /* propID = */ 2 };

Win32TaskbarManager::Win32TaskbarManager() : _taskbar(NULL) {
Win32TaskbarManager::Win32TaskbarManager() : _taskbar(NULL), _count(0), _icon(NULL) {
// Do nothing if not running on Windows 7 or later
if (!isWin7OrLater())
return;
Expand Down Expand Up @@ -96,6 +96,9 @@ Win32TaskbarManager::~Win32TaskbarManager() {
_taskbar->Release();
_taskbar = NULL;

if (_icon)
DestroyIcon(_icon);

CoUninitialize();
}

Expand Down Expand Up @@ -144,6 +147,123 @@ void Win32TaskbarManager::setProgressState(TaskbarProgressState state) {
_taskbar->SetProgressState(getHwnd(), (TBPFLAG)state);
}

void Win32TaskbarManager::setCount(int count) {
if (_taskbar == NULL)
return;

if (count == 0) {
_taskbar->SetOverlayIcon(getHwnd(), NULL, L"");
return;
}

// FIXME: This isn't really nice and could use a cleanup.
// The only good thing is that it doesn't use GDI+
// and thus does not have a dependancy on it,
// with the downside of being a lot more ugly.
// Maybe replace it by a Graphic::Surface, use
// ScummVM font drawing and extract the contents at
// the end?

if (_count != count || _icon == NULL) {
// Cleanup previous icon
_count = count;
if (_icon)
DestroyIcon(_icon);

Common::String countString = (count < 100 ? Common::String::format("%d", count) : "9+");

// Create transparent background
BITMAPV5HEADER bi;
ZeroMemory(&bi, sizeof(BITMAPV5HEADER));
bi.bV5Size = sizeof(BITMAPV5HEADER);
bi.bV5Width = 16;
bi.bV5Height = 16;
bi.bV5Planes = 1;
bi.bV5BitCount = 32;
bi.bV5Compression = BI_RGB;
// Set 32 BPP alpha format
bi.bV5RedMask = 0x00FF0000;
bi.bV5GreenMask = 0x0000FF00;
bi.bV5BlueMask = 0x000000FF;
bi.bV5AlphaMask = 0xFF000000;

// Get DC
HDC hdc;
hdc = GetDC(NULL);
HDC hMemDC = CreateCompatibleDC(hdc);
ReleaseDC(NULL, hdc);

// Create a bitmap mask
HBITMAP hBitmapMask = CreateBitmap(16, 16, 1, 1, NULL);

// Create the DIB section with an alpha channel
void *lpBits;
HBITMAP hBitmap = CreateDIBSection(hdc, (BITMAPINFO *)&bi, DIB_RGB_COLORS, (void **)&lpBits, NULL, 0);
HBITMAP hOldBitmap = (HBITMAP)SelectObject(hMemDC, hBitmap);

// Load the icon background
HICON hIconBackground = LoadIcon(GetModuleHandle(NULL), MAKEINTRESOURCE(1002 /* IDI_COUNT */));
DrawIconEx(hMemDC, 0, 0, hIconBackground, 16, 16, 0, 0, DI_NORMAL);
DeleteObject(hIconBackground);

// Draw the count
LOGFONT lFont;
memset(&lFont, 0, sizeof(LOGFONT));
lFont.lfHeight = 10;
lFont.lfWeight = FW_BOLD;
lFont.lfItalic = 1;
strcpy(lFont.lfFaceName, "Arial");

HFONT hFont = CreateFontIndirect(&lFont);
SelectObject(hMemDC, hFont);

RECT rect;
SetRect(&rect, 4, 4, 12, 12);
SetTextColor(hMemDC, RGB(48, 48, 48));
SetBkMode(hMemDC, TRANSPARENT);
DrawText(hMemDC, countString.c_str(), -1, &rect, DT_NOCLIP|DT_CENTER);

// Set the text alpha to fully opaque (we consider the data inside the text rect)
DWORD *lpdwPixel = (DWORD *)lpBits;
for (int x = 3; x < 12; x++) {
for(int y = 3; y < 12; y++) {
unsigned char *p = (unsigned char *)(lpdwPixel + x * 16 + y);

if (p[0] != 0 && p[1] != 0 && p[2] != 0)
p[3] = 255;
}
}

// Cleanup DC
DeleteObject(hFont);
SelectObject(hMemDC, hOldBitmap);
DeleteDC(hMemDC);

// Prepare our new icon
ICONINFO ii;
ii.fIcon = FALSE;
ii.xHotspot = 0;
ii.yHotspot = 0;
ii.hbmMask = hBitmapMask;
ii.hbmColor = hBitmap;

_icon = CreateIconIndirect(&ii);

DeleteObject(hBitmap);
DeleteObject(hBitmapMask);

if (!_icon) {
warning("[Win32TaskbarManager::setCount] Cannot create icon for count");
return;
}
}

// Sets the overlay icon
LPWSTR desc = ansiToUnicode(Common::String::format("Found games: %d", count).c_str());
_taskbar->SetOverlayIcon(getHwnd(), _icon, desc);
delete[] desc;
}

void Win32TaskbarManager::addRecent(const Common::String &name, const Common::String &description) {
//warning("[Win32TaskbarManager::addRecent] Adding recent list entry: %s (%s)", name.c_str(), description.c_str());

Expand Down
5 changes: 5 additions & 0 deletions backends/taskbar/win32/win32-taskbar.h
Expand Up @@ -41,11 +41,16 @@ class Win32TaskbarManager : public Common::TaskbarManager {
virtual void setOverlayIcon(const Common::String &name, const Common::String &description);
virtual void setProgressValue(int completed, int total);
virtual void setProgressState(TaskbarProgressState state);
virtual void setCount(int count);
virtual void addRecent(const Common::String &name, const Common::String &description);

private:
ITaskbarList3 *_taskbar;

// Count handling
HICON _icon;
int _count;

/**
* Get the path to an icon for the game
*
Expand Down
2 changes: 1 addition & 1 deletion configure
Expand Up @@ -1854,7 +1854,7 @@ case $_host_os in
mingw*)
DEFINES="$DEFINES -DWIN32"
DEFINES="$DEFINES -D__USE_MINGW_ANSI_STDIO=0"
LIBS="$LIBS -lmingw32 -lwinmm"
LIBS="$LIBS -lmingw32 -lwinmm -lgdi32"
OBJS="$OBJS scummvmwinres.o"
add_line_to_config_mk 'WIN32 = 1'
;;
Expand Down
4 changes: 3 additions & 1 deletion dists/scummvm.rc
Expand Up @@ -5,9 +5,11 @@
#endif

#define FILE 256
#define IDI_ICON 1001
#define IDI_ICON 1001
#define IDI_COUNT 1002

IDI_ICON ICON DISCARDABLE "icons/scummvm.ico"
IDI_COUNT ICON DISCARDABLE "icons/count.ico"

scummmodern.zip FILE "gui/themes/scummmodern.zip"
#ifdef USE_TRANSLATION
Expand Down
16 changes: 15 additions & 1 deletion engines/lastexpress/data/snd.cpp
Expand Up @@ -103,7 +103,8 @@ void SimpleSound::play(Audio::AudioStream *as) {
//////////////////////////////////////////////////////////////////////////
// StreamedSound
//////////////////////////////////////////////////////////////////////////
StreamedSound::StreamedSound() {}
StreamedSound::StreamedSound() : _loaded(false) {}

StreamedSound::~StreamedSound() {}

bool StreamedSound::load(Common::SeekableReadStream *stream) {
Expand All @@ -120,9 +121,18 @@ bool StreamedSound::load(Common::SeekableReadStream *stream) {
// Start playing the decoded audio stream
play(as);

_loaded = true;

return true;
}

bool StreamedSound::isFinished() {
if (!_loaded)
return false;

return !g_system->getMixer()->isSoundHandleActive(_handle);
}

//////////////////////////////////////////////////////////////////////////
// StreamedSound
//////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -172,4 +182,8 @@ void AppendableSound::finish() {
_finished = true;
}

bool AppendableSound::isFinished() {
return _as->endOfStream();
}

} // End of namespace LastExpress
8 changes: 8 additions & 0 deletions engines/lastexpress/data/snd.h
Expand Up @@ -55,6 +55,7 @@ class SimpleSound {
virtual ~SimpleSound();

void stop() const;
virtual bool isFinished() = 0;

protected:
void loadHeader(Common::SeekableReadStream *in);
Expand All @@ -76,6 +77,11 @@ class StreamedSound : public SimpleSound {
~StreamedSound();

bool load(Common::SeekableReadStream *stream);

virtual bool isFinished();

private:
bool _loaded;
};

class AppendableSound : public SimpleSound {
Expand All @@ -87,6 +93,8 @@ class AppendableSound : public SimpleSound {
void queueBuffer(Common::SeekableReadStream *bufferIn);
void finish();

virtual bool isFinished();

private:
Audio::QueuingAudioStream *_as;
bool _finished;
Expand Down
21 changes: 21 additions & 0 deletions engines/lastexpress/shared.h
Expand Up @@ -89,6 +89,27 @@ enum SoundState {
kSoundState2 = 2
};

enum SoundStatus {
kSoundStatus_20 = 0x20,
kSoundStatus_40 = 0x40,
kSoundStatus_180 = 0x180,
kSoundStatusRemoved = 0x200,
kSoundStatus_400 = 0x400,

kSoundStatus_8000 = 0x8000,
kSoundStatus_20000 = 0x20000,
kSoundStatus_100000 = 0x100000,
kSoundStatus_20000000 = 0x20000000,
kSoundStatus_40000000 = 0x40000000,

kSoundStatusClear0 = 0x10,
kSoundStatusFilterVariant = 0x1F,
kSoundStatusClear2 = 0x80,
kSoundStatusClear3 = 0x200,
kSoundStatusClear4 = 0x800,
kSoundStatusClearAll = 0xFFFFFFE0
};

//////////////////////////////////////////////////////////////////////////
// Time values
//////////////////////////////////////////////////////////////////////////
Expand Down

0 comments on commit 0be5ba9

Please sign in to comment.