summaryrefslogtreecommitdiff
path: root/game/client/econ/tool_items/custom_texture_cache.h
blob: c26b94e332e2954a243f2d61a91f1aaf1c9dcc26 (plain) (blame)
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
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose: 
//
// $NoKeywords: $
//=============================================================================//

#ifndef CUSTOM_TEXTURE_CACHE_H
#define CUSTOM_TEXTURE_CACHE_H
#ifdef _WIN32
#pragma once
#endif

#ifndef GC_CLIENTSYSTEM_H
	#include "gc_clientsystem.h"
#endif

class IGameSystem;
class ITexture;
class CEconItemView;

/// Given a UGC cloud ID of a custom image, return a VGUI texture handle
/// that can be used for drawing.  Returns 0 on failure
int GetCustomTextureGuiHandle( uint64 hCloudId );

//-----------------------------------------------------------------------------
// Purpose: Job to do the async work of uploading the file to the CDN (if
// necessary) and sending the tool request message
//-----------------------------------------------------------------------------
class CApplyCustomTextureJob : public GCSDK::CGCClientJob
{
public:

	CApplyCustomTextureJob( itemid_t nToolItemID, itemid_t nSubjectItemID, const void *pPNGData, int nPNGDataBytes );

protected:
	char	m_chRemoteStorageName[ MAX_PATH ];

	virtual bool BYieldingRunGCJob();
	virtual EResult YieldingRunJob();
	virtual EResult YieldingFindFileIncacheOrUploadFileToCDN();
	virtual EResult YieldingApplyTool();

	/// The file data, in PNG format
	CUtlBuffer m_bufPNGData;

	/// Item that we are applying the texture onto
	itemid_t m_nSubjectItemID;

	/// Tool that is being applied and will be consumed
	itemid_t m_nToolItemID;

	/// Cloud file ID
	uint64 m_hCloudID;

private:
	void CleanUp();
};

/// get interface to the game system responsible for managing the custom texture cache
IGameSystem *CustomTextureToolCacheGameSystem();

/// A few internal things that really shouldn't be public
namespace CustomTextureSystem
{

/// If we're auditioning (while selecting a file to apply on a model),
/// what texture should we display?
extern ITexture *g_pPreviewCustomTexture;

/// What is the econ item that is being auditioned and so should
/// use the preview texture
extern CEconItemView *g_pPreviewEconItem;

/// Do we need to update the bits in the rendering system?
extern bool g_pPreviewCustomTextureDirty;

extern const char k_rchCustomTextureFilterPreviewImageName[];
extern const char k_rchCustomTextureFilterPreviewTextureName[];

}

#endif // CUSTOM_TEXTURE_CACHE_H