forked from BoyC/GW2TacO
-
Notifications
You must be signed in to change notification settings - Fork 0
/
OverlayApplication.cpp
119 lines (94 loc) · 3.5 KB
/
OverlayApplication.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
#include "OverlayApplication.h"
COverlayApp::COverlayApp()
{
}
TBOOL COverlayApp::Initialize( const CCoreWindowParameters &WindowParams )
{
FORCEDDEBUGLOG( "COverlayApp::Initialize()" );
if ( !CWBApplication::Initialize( WindowParams ) ) return false;
FORCEDDEBUGLOG( "CWBApplication::Initialize() returned with true." );
CCoreBlendState *GuiBlendState = Device->CreateBlendState();
if ( !GuiBlendState )
{
LOG( LOG_ERROR, _T( "[gui] Error creating UI Blend State" ) );
return false;
}
FORCEDDEBUGLOG( "GUI Blendstate instance created" );
GuiBlendState->SetBlendEnable( 0, true );
GuiBlendState->SetSrcBlend( 0, COREBLEND_SRCALPHA );
GuiBlendState->SetDestBlend( 0, COREBLEND_INVSRCALPHA );
GuiBlendState->SetSrcBlendAlpha( 0, COREBLEND_ONE );
GuiBlendState->SetDestBlendAlpha( 0, COREBLEND_INVSRCALPHA );
DrawAPI->SetUIBlendState( GuiBlendState );
holePunchBlendState = DrawAPI->GetDevice()->CreateBlendState();
holePunchBlendState->SetBlendEnable( 0, true );
holePunchBlendState->SetIndependentBlend( true );
holePunchBlendState->SetSrcBlend( 0, COREBLEND_ZERO );
holePunchBlendState->SetDestBlend( 0, COREBLEND_ZERO );
holePunchBlendState->SetSrcBlendAlpha( 0, COREBLEND_ZERO );
holePunchBlendState->SetDestBlendAlpha( 0, COREBLEND_ZERO );
FORCEDDEBUGLOG( "GUI Blendstate set, app init fully done" );
//CCoreSamplerState *GuiSampler = Device->CreateSamplerState();
//GuiSampler->SetFilter(COREFILTER_COMPARISON_MIN_MAG_MIP_POINT);
//DrawAPI->SetUISamplerState(GuiSampler);
//LPCSTR shader =
// "Texture2D GuiTexture:register(t0);"
// "SamplerState Sampler:register(s0);"
// "cbuffer resdata : register(b0)"
// "{ "
// " float4 resolution; "
// "}"
// "struct VSIN { float4 Position : POSITIONT; float2 UV : TEXCOORD0; float4 Color : COLOR0; };"
// "struct VSOUT { float4 Position : SV_POSITION; float2 UV : TEXCOORD0; float4 Color : COLOR0; };"
// "VSOUT vsmain(VSIN x) { VSOUT k; k.Position=float4(x.Position.x/resolution.x*2-1,-x.Position.y/resolution.y*2+1,0,1); k.UV=x.UV; k.Color=x.Color; return k; }"
// "float4 psmain(VSOUT x) : SV_TARGET0 { float4 col=x.Color*GuiTexture.Sample(Sampler,x.UV); return float4(col.xyz*col.a,col.a); }";
//auto PxShader = Device->CreatePixelShader(shader, strlen(shader), "psmain", "ps_4_0");
//DrawAPI->SetPixelShader(PxShader);
return true;
}
COverlayApp::~COverlayApp()
{
SAFEDELETE( holePunchBlendState );
}
void COverlayApp::TakeScreenshot()
{
}
TBOOL COverlayApp::DeviceOK()
{
if ( !Device ) return false;
return Device->DeviceOk();
}
void FetchMarkerPackOnline( CString& ourl );
LRESULT COverlayApp::WindowProc( UINT uMsg, WPARAM wParam, LPARAM lParam )
{
switch ( uMsg )
{
case WM_COPYDATA:
PCOPYDATASTRUCT pcpy = (PCOPYDATASTRUCT)lParam;
if ( pcpy )
{
CString incoming( (TS8*)( pcpy->lpData ), pcpy->cbData );
FetchMarkerPackOnline( incoming );
}
break;
}
if ( uMsg > 0x60ff )
{
int z = 0;
}
//switch (uMsg)
//{
// case WM_WINDOWPOSCHANGED:
// {
// HWND gw2Window = FindWindow( NULL, "Guild Wars 2" );
// if ( gw2Window )
// {
// HWND wnd = ::GetNextWindow( (HWND)GetHandle(), GW_HWNDNEXT );
// if ( wnd != gw2Window )
// ::SetWindowPos( gw2Window, (HWND)GetHandle(), 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE );
// //::SetWindowPos( (HWND)GetHandle(), gw2Window, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOSENDCHANGING );
// }
// }
//}
return CWBApplication::WindowProc( uMsg, wParam, lParam );
}