Browse Source

Merge pull request #181 from Hoikas/taskbar

Taskbar Stuff
Branan Purvine-Riley 13 years ago
parent
commit
c70bb776ba
  1. 54
      Sources/Plasma/Apps/plClient/plClient.cpp
  2. 4
      Sources/Plasma/Apps/plClient/plClient.h
  3. 41
      Sources/Plasma/Apps/plClient/winmain.cpp
  4. 7
      Sources/Plasma/FeatureLib/pfPython/cyMisc.cpp
  5. 9
      Sources/Plasma/FeatureLib/pfPython/cyMisc.h
  6. 4
      Sources/Plasma/FeatureLib/pfPython/cyMiscGlue.cpp
  7. 1
      Sources/Plasma/FeatureLib/pfSecurePreloader/pfSecurePreloader.cpp
  8. 2
      Sources/Plasma/NucleusLib/pnMessage/plClientMsg.h
  9. 3
      Sources/Plasma/PubUtilLib/plAgeLoader/plResPatcher.cpp
  10. 6
      Sources/Plasma/PubUtilLib/plNetClient/plNetLinkingMgr.cpp
  11. 1
      Sources/Plasma/PubUtilLib/plProgressMgr/plProgressMgr.cpp
  12. 1
      Sources/Plasma/PubUtilLib/plProgressMgr/plProgressMgr.h

54
Sources/Plasma/Apps/plClient/plClient.cpp

@ -168,6 +168,10 @@ static plDispatchBase* gDisp = nil;
static plTimerCallbackManager* gTimerMgr = nil; static plTimerCallbackManager* gTimerMgr = nil;
static plAudioSystem* gAudio = nil; static plAudioSystem* gAudio = nil;
#ifdef HS_BUILD_FOR_WIN32
extern ITaskbarList3* gTaskbarList;
#endif
hsBool plClient::fDelayMS = false; hsBool plClient::fDelayMS = false;
plClient* plClient::fInstance=nil; plClient* plClient::fInstance=nil;
@ -768,6 +772,11 @@ hsBool plClient::MsgReceive(plMessage* msg)
} }
break; break;
case plClientMsg::kFlashWindow:
{
FlashWindow();
}
break;
} }
return true; return true;
} }
@ -864,8 +873,8 @@ hsBool plClient::MsgReceive(plMessage* msg)
// plResPatcherMsg // plResPatcherMsg
//============================================================================ //============================================================================
if (plResPatcherMsg * resMsg = plResPatcherMsg::ConvertNoRef(msg)) { if (plResPatcherMsg * resMsg = plResPatcherMsg::ConvertNoRef(msg)) {
plgDispatch::Dispatch()->UnRegisterForExactType(plResPatcherMsg::Index(), GetKey()); IHandlePatcherMsg(resMsg);
IOnAsyncInitComplete(); return true;
} }
return hsKeyedObject::MsgReceive(msg); return hsKeyedObject::MsgReceive(msg);
@ -1291,6 +1300,24 @@ void plClient::IProgressMgrCallbackProc(plOperationProgress * progress)
if(!fInstance) if(!fInstance)
return; return;
// Increments the taskbar progress [Windows 7+]
#ifdef HS_BUILD_FOR_WIN32
if (gTaskbarList)
{
HWND hwnd = fInstance->GetWindowHandle(); // lazy
if (progress->IsAborting())
// We'll assume this is fatal
gTaskbarList->SetProgressState(hwnd, TBPF_ERROR);
else if (progress->IsLastUpdate())
gTaskbarList->SetProgressState(hwnd, TBPF_NOPROGRESS);
else if (progress->GetMax() == 0.f)
gTaskbarList->SetProgressState(hwnd, TBPF_INDETERMINATE);
else
// This will set TBPF_NORMAL for us
gTaskbarList->SetProgressValue(hwnd, (ULONGLONG)progress->GetProgress(), (ULONGLONG)progress->GetMax());
}
#endif
fInstance->fMessagePumpProc(); fInstance->fMessagePumpProc();
// HACK HACK HACK HACK! // HACK HACK HACK HACK!
@ -2415,6 +2442,17 @@ void plClient::WindowActivate(bool active)
fWindowActive = active; fWindowActive = active;
} }
void plClient::FlashWindow()
{
#ifdef HS_BUILD_FOR_WIN32
FLASHWINFO info;
info.cbSize = sizeof(info);
info.dwFlags = FLASHW_TIMERNOFG | FLASHW_ALL;
info.hwnd = fWindowHndl;
info.uCount = -1;
FlashWindowEx(&info);
#endif
}
//============================================================================ //============================================================================
void plClient::IOnAsyncInitComplete () { void plClient::IOnAsyncInitComplete () {
@ -2531,6 +2569,18 @@ void plClient::IHandlePreloaderMsg (plPreloaderMsg * msg) {
IPatchGlobalAgeFiles(); IPatchGlobalAgeFiles();
} }
//============================================================================
void plClient::IHandlePatcherMsg (plResPatcherMsg * msg) {
plgDispatch::Dispatch()->UnRegisterForExactType(plResPatcherMsg::Index(), GetKey());
if (!msg->Success()) {
plNetClientApp::GetInstance()->QueueDisableNet(true, msg->GetError());
return;
}
IOnAsyncInitComplete();
}
//============================================================================ //============================================================================
void plClient::IHandleNetCommAuthMsg (plNetCommAuthMsg * msg) { void plClient::IHandleNetCommAuthMsg (plNetCommAuthMsg * msg) {

4
Sources/Plasma/Apps/plClient/plClient.h

@ -82,7 +82,7 @@ class plBinkPlayer;
class plPreloaderMsg; class plPreloaderMsg;
class plNetCommAuthMsg; class plNetCommAuthMsg;
class plAgeLoaded2Msg; class plAgeLoaded2Msg;
class plResPatcherMsg;
typedef void (*plMessagePumpProc)( void ); typedef void (*plMessagePumpProc)( void );
@ -179,6 +179,7 @@ protected:
void ICompleteInit (); void ICompleteInit ();
void IOnAsyncInitComplete (); void IOnAsyncInitComplete ();
void IHandlePatcherMsg (plResPatcherMsg * msg);
void IHandlePreloaderMsg (plPreloaderMsg * msg); void IHandlePreloaderMsg (plPreloaderMsg * msg);
void IHandleNetCommAuthMsg (plNetCommAuthMsg * msg); void IHandleNetCommAuthMsg (plNetCommAuthMsg * msg);
bool IHandleAgeLoaded2Msg (plAgeLoaded2Msg * msg); bool IHandleAgeLoaded2Msg (plAgeLoaded2Msg * msg);
@ -289,6 +290,7 @@ public:
virtual void WindowActivate(bool active); virtual void WindowActivate(bool active);
virtual hsBool WindowActive() const { return fWindowActive; } virtual hsBool WindowActive() const { return fWindowActive; }
void FlashWindow();
void SetMessagePumpProc( plMessagePumpProc proc ) { fMessagePumpProc = proc; } void SetMessagePumpProc( plMessagePumpProc proc ) { fMessagePumpProc = proc; }
void ResetDisplayDevice(int Width, int Height, int ColorDepth, hsBool Windowed, int NumAASamples, int MaxAnisotropicSamples, hsBool VSync = false); void ResetDisplayDevice(int Width, int Height, int ColorDepth, hsBool Windowed, int NumAASamples, int MaxAnisotropicSamples, hsBool VSync = false);
void ResizeDisplayDevice(int Width, int Height, hsBool Windowed); void ResizeDisplayDevice(int Width, int Height, hsBool Windowed);

41
Sources/Plasma/Apps/plClient/winmain.cpp

@ -92,6 +92,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
// Globals // Globals
// //
hsBool gHasMouse = false; hsBool gHasMouse = false;
ITaskbarList3* gTaskbarList = nil; // NT 6.1+ taskbar stuff
extern hsBool gDataServerLocal; extern hsBool gDataServerLocal;
@ -121,6 +122,7 @@ bool gPendingActivateFlag = false;
static bool s_loginDlgRunning = false; static bool s_loginDlgRunning = false;
static CEvent s_statusEvent(kEventManualReset); static CEvent s_statusEvent(kEventManualReset);
static UINT s_WmTaskbarList = RegisterWindowMessage("TaskbarButtonCreated");
FILE *errFP = nil; FILE *errFP = nil;
HINSTANCE gHInst = NULL; // Instance of this app HINSTANCE gHInst = NULL; // Instance of this app
@ -402,12 +404,12 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
gClient->GetInputManager()->HandleWin32ControlEvent(message, wParam, lParam, hWnd); gClient->GetInputManager()->HandleWin32ControlEvent(message, wParam, lParam, hWnd);
} }
} }
break; return TRUE;
#if 0 #if 0
case WM_KILLFOCUS: case WM_KILLFOCUS:
SetForegroundWindow(hWnd); SetForegroundWindow(hWnd);
break; return TRUE;
#endif #endif
case WM_SYSKEYUP: case WM_SYSKEYUP:
@ -419,7 +421,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
} }
//DefWindowProc(hWnd, message, wParam, lParam); //DefWindowProc(hWnd, message, wParam, lParam);
} }
break; return TRUE;
case WM_SYSCOMMAND: case WM_SYSCOMMAND:
switch (wParam) { switch (wParam) {
@ -435,9 +437,9 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
if (plNetClientMgr * mgr = plNetClientMgr::GetInstance()) if (plNetClientMgr * mgr = plNetClientMgr::GetInstance())
mgr->QueueDisableNet(false, nil); mgr->QueueDisableNet(false, nil);
DestroyWindow(gClient->GetWindowHandle()); DestroyWindow(gClient->GetWindowHandle());
break; return TRUE;
} }
break; return TRUE;
case WM_ACTIVATE: case WM_ACTIVATE:
{ {
@ -478,7 +480,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
gPendingActivateFlag = active; gPendingActivateFlag = active;
} }
} }
break; return TRUE;
// Let go of the mouse if the window is being moved. // Let go of the mouse if the window is being moved.
case WM_ENTERSIZEMOVE: case WM_ENTERSIZEMOVE:
@ -486,7 +488,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
gDragging = true; gDragging = true;
if( gClient ) if( gClient )
gClient->WindowActivate(false); gClient->WindowActivate(false);
break; return TRUE;
// Redo the mouse capture if the window gets moved // Redo the mouse capture if the window gets moved
case WM_EXITSIZEMOVE: case WM_EXITSIZEMOVE:
@ -494,7 +496,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
gDragging = false; gDragging = false;
if( gClient ) if( gClient )
gClient->WindowActivate(true); gClient->WindowActivate(true);
break; return TRUE;
// Redo the mouse capture if the window gets moved (special case for Colin // Redo the mouse capture if the window gets moved (special case for Colin
// and his cool program that bumps windows out from under the taskbar) // and his cool program that bumps windows out from under the taskbar)
@ -506,7 +508,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
} }
else else
DebugMsgF("Got WM_MOVE, but ignoring"); DebugMsgF("Got WM_MOVE, but ignoring");
break; return TRUE;
/// Resize the window /// Resize the window
// (we do WM_SIZING here instead of WM_SIZE because, for some reason, WM_SIZE is // (we do WM_SIZING here instead of WM_SIZE because, for some reason, WM_SIZE is
@ -521,7 +523,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
::GetClientRect(hWnd, &r); ::GetClientRect(hWnd, &r);
gClient->GetPipeline()->Resize(r.right - r.left, r.bottom - r.top); gClient->GetPipeline()->Resize(r.right - r.left, r.bottom - r.top);
} }
break; return TRUE;
case WM_SIZE: case WM_SIZE:
// Let go of the mouse if the window is being minimized // Let go of the mouse if the window is being minimized
@ -538,7 +540,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
if (gClient) if (gClient)
gClient->WindowActivate(true); gClient->WindowActivate(true);
} }
break; return TRUE;
case WM_CLOSE: case WM_CLOSE:
gClient->SetDone(TRUE); gClient->SetDone(TRUE);
@ -554,9 +556,22 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
return TRUE; return TRUE;
case WM_CREATE: case WM_CREATE:
// Create renderer // Create renderer
break; return TRUE;
} }
return DefWindowProc(hWnd, message, wParam, lParam);
// Messages we registered for manually (no const value)
if (message == s_WmTaskbarList)
{
// Grab the Windows 7 taskbar list stuff
if (gTaskbarList)
gTaskbarList->Release();
HRESULT result = CoCreateInstance(CLSID_TaskbarList, NULL, CLSCTX_ALL, IID_ITaskbarList3, (void**)&gTaskbarList);
if (FAILED(result))
gTaskbarList = nil;
return TRUE;
}
else
return DefWindowProc(hWnd, message, wParam, lParam);
} }
void PumpMessageQueueProc( void ) void PumpMessageQueueProc( void )

7
Sources/Plasma/FeatureLib/pfPython/cyMisc.cpp

@ -721,6 +721,13 @@ void cyMisc::ExcludeRegionSetNow(pyKey& sender, pyKey& exKey, uint16_t state)
plgDispatch::MsgSend( msg ); // whoosh... off it goes plgDispatch::MsgSend( msg ); // whoosh... off it goes
} }
void cyMisc::FlashWindow()
{
plKey clientKey = hsgResMgr::ResMgr()->FindKey(kClient_KEY);
plClientMsg* pMsg = new plClientMsg(plClientMsg::kFlashWindow);
pMsg->Send(clientKey); // whoosh... off it goes
}
#include "hsTimer.h" #include "hsTimer.h"
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// //

9
Sources/Plasma/FeatureLib/pfPython/cyMisc.h

@ -244,6 +244,15 @@ public:
// //
static hsBool WasLocallyNotified(pyKey &selfkey); static hsBool WasLocallyNotified(pyKey &selfkey);
/////////////////////////////////////////////////////////////////////////////
//
// Function : FlashWindow
// PARAMETERS :
//
// PURPOSE : Flashes the client window if it is not focused
//
static void FlashWindow();
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// //
// Function : GetClientName // Function : GetClientName

4
Sources/Plasma/FeatureLib/pfPython/cyMiscGlue.cpp

@ -48,6 +48,8 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include <Python.h> #include <Python.h>
PYTHON_BASIC_GLOBAL_METHOD_DEFINITION(PtFlashWindow, cyMisc::FlashWindow, "Flashes the client window if it is not focused");
PYTHON_GLOBAL_METHOD_DEFINITION_NOARGS(PtGetAgeName, "DEPRECIATED - use ptDniInfoSource instead") PYTHON_GLOBAL_METHOD_DEFINITION_NOARGS(PtGetAgeName, "DEPRECIATED - use ptDniInfoSource instead")
{ {
return PyString_FromString(cyMisc::GetAgeName()); return PyString_FromString(cyMisc::GetAgeName());
@ -514,6 +516,8 @@ PYTHON_GLOBAL_METHOD_DEFINITION(PtDumpLogs, args, "Params: folder\nDumps all cur
void cyMisc::AddPlasmaMethods(std::vector<PyMethodDef> &methods) void cyMisc::AddPlasmaMethods(std::vector<PyMethodDef> &methods)
{ {
PYTHON_GLOBAL_METHOD_NOARGS(methods, PtFlashWindow);
PYTHON_GLOBAL_METHOD_NOARGS(methods, PtGetAgeName); PYTHON_GLOBAL_METHOD_NOARGS(methods, PtGetAgeName);
PYTHON_GLOBAL_METHOD_NOARGS(methods, PtGetAgeInfo); PYTHON_GLOBAL_METHOD_NOARGS(methods, PtGetAgeInfo);
PYTHON_GLOBAL_METHOD_NOARGS(methods, PtGetAgeTime); PYTHON_GLOBAL_METHOD_NOARGS(methods, PtGetAgeTime);

1
Sources/Plasma/FeatureLib/pfSecurePreloader/pfSecurePreloader.cpp

@ -300,6 +300,7 @@ void pfSecurePreloader::Start()
void pfSecurePreloader::Terminate() void pfSecurePreloader::Terminate()
{ {
FATAL("pfSecurePreloader failure"); FATAL("pfSecurePreloader failure");
fProgress->SetAborting();
plPreloaderMsg* msg = new plPreloaderMsg; plPreloaderMsg* msg = new plPreloaderMsg;
msg->fSuccess = false; msg->fSuccess = false;

2
Sources/Plasma/NucleusLib/pnMessage/plClientMsg.h

@ -94,6 +94,8 @@ public:
kEnableRenderScene, kEnableRenderScene,
kResetGraphicsDevice, kResetGraphicsDevice,
kSetGraphicsDefaults, kSetGraphicsDefaults,
kFlashWindow,
}; };
// graphics settings fields // graphics settings fields

3
Sources/Plasma/PubUtilLib/plAgeLoader/plResPatcher.cpp

@ -278,7 +278,10 @@ void plResPatcher::Finish(bool success)
if (success) if (success)
PatcherLog(kHeader, "--- Patch Completed Successfully ---"); PatcherLog(kHeader, "--- Patch Completed Successfully ---");
else else
{
PatcherLog(kHeader, "--- Patch Killed by Error ---"); PatcherLog(kHeader, "--- Patch Killed by Error ---");
fProgress->SetAborting();
}
plResPatcherMsg* pMsg = new plResPatcherMsg(success, sLastError); plResPatcherMsg* pMsg = new plResPatcherMsg(success, sLastError);
pMsg->Send(); // whoosh... off it goes pMsg->Send(); // whoosh... off it goes

6
Sources/Plasma/PubUtilLib/plNetClient/plNetLinkingMgr.cpp

@ -165,11 +165,9 @@ void plNetLinkingMgr::NCAgeJoinerCallback (
// Tell the user we failed to link. // Tell the user we failed to link.
// In the future, we might want to try graceful recovery (link back to Relto?) // In the future, we might want to try graceful recovery (link back to Relto?)
if (!params->success) { if (!params->success) {
plNetClientMgr::StaticErrorMsg(params->msg); plNetClientApp::GetInstance()->ErrorMsg(params->msg);
hsMessageBox(params->msg, "Linking Error", hsMessageBoxNormal, hsMessageBoxIconError);
#ifdef PLASMA_EXTERNAL_RELEASE #ifdef PLASMA_EXTERNAL_RELEASE
plClientMsg* clientMsg = new plClientMsg(plClientMsg::kQuit); plNetClientApp::GetInstance()->QueueDisableNet(true, params->msg);
clientMsg->Send(hsgResMgr::ResMgr()->FindKey(kClient_KEY));
#endif #endif
return; return;
} }

1
Sources/Plasma/PubUtilLib/plProgressMgr/plProgressMgr.cpp

@ -389,7 +389,6 @@ void plOperationProgress::SetAborting()
hsSetBits(fFlags, kAborting); hsSetBits(fFlags, kAborting);
plProgressMgr::GetInstance()->IUpdateCallbackProc(this); plProgressMgr::GetInstance()->IUpdateCallbackProc(this);
fMax = fValue = 0.f; fMax = fValue = 0.f;
hsClearBits(fFlags, kAborting);
} }
void plOperationProgress::SetRetry() void plOperationProgress::SetRetry()

1
Sources/Plasma/PubUtilLib/plProgressMgr/plProgressMgr.h

@ -153,6 +153,7 @@ class plOperationProgress
// progress bars above this one know to adjust their totals to not include any amount // progress bars above this one know to adjust their totals to not include any amount
// that wasn't completed, and will set this progress bar to zero // that wasn't completed, and will set this progress bar to zero
void SetAborting(); void SetAborting();
bool IsAborting() { return hsCheckBits(fFlags, kAborting); }
// If you're reusing an existing progress bar to retry a failed operation, call this. // If you're reusing an existing progress bar to retry a failed operation, call this.
// It will set the retry flag, and reset the progress bar so the next update will // It will set the retry flag, and reset the progress bar so the next update will
// count as the first. If you set retry in RegisterOperation, don't use this too. // count as the first. If you set retry in RegisterOperation, don't use this too.

Loading…
Cancel
Save