Mariusz Pluciński : gameux: Add implementation of IGameStatistics::SetCategoryTitle.
Alexandre Julliard
julliard at winehq.org
Mon Sep 27 11:29:42 CDT 2010
Module: wine
Branch: master
Commit: 35692e40b113c950a8969ec1a438889332045d08
URL: http://source.winehq.org/git/wine.git/?a=commit;h=35692e40b113c950a8969ec1a438889332045d08
Author: Mariusz Pluciński <vshader at gmail.com>
Date: Sun Sep 26 15:17:41 2010 +0200
gameux: Add implementation of IGameStatistics::SetCategoryTitle.
---
dlls/gameux/gamestatistics.c | 47 ++++++++++++++++++++++++++++++++++-
dlls/gameux/tests/gamestatistics.c | 14 +++++-----
2 files changed, 52 insertions(+), 9 deletions(-)
diff --git a/dlls/gameux/gamestatistics.c b/dlls/gameux/gamestatistics.c
index 44cc04e..67bfc08 100644
--- a/dlls/gameux/gamestatistics.c
+++ b/dlls/gameux/gamestatistics.c
@@ -40,12 +40,36 @@ WINE_DEFAULT_DEBUG_CHANNEL(gameux);
#define MAX_CATEGORIES 10
#define MAX_STATS_PER_CATEGORY 10
/*******************************************************************************
+ * Game statistics helper components
+ */
+/*******************************************************************************
+ * struct GAMEUX_STATS
+ *
+ * set of structures for containing game's data
+ */
+struct GAMEUX_STATS_STAT
+{
+ WCHAR sName[MAX_NAME_LENGTH+1];
+ WCHAR sValue[MAX_VALUE_LENGTH+1];
+};
+struct GAMEUX_STATS_CATEGORY
+{
+ WCHAR sName[MAX_CATEGORY_LENGTH+1];
+ struct GAMEUX_STATS_STAT stats[MAX_STATS_PER_CATEGORY];
+};
+struct GAMEUX_STATS
+{
+ WCHAR sStatsFile[MAX_PATH];
+ struct GAMEUX_STATS_CATEGORY categories[MAX_CATEGORIES];
+};
+/*******************************************************************************
* IGameStatistics implementation
*/
typedef struct _GameStatisticsImpl
{
const struct IGameStatisticsVtbl *lpVtbl;
LONG ref;
+ struct GAMEUX_STATS stats;
} GameStatisticsImpl;
static inline GameStatisticsImpl *impl_from_IGameStatistics( IGameStatistics *iface )
@@ -177,8 +201,27 @@ static HRESULT WINAPI GameStatisticsImpl_SetCategoryTitle(
WORD categoryIndex,
LPCWSTR title)
{
- FIXME("stub\n");
- return E_NOTIMPL;
+ HRESULT hr = S_OK;
+ DWORD dwLength;
+ GameStatisticsImpl *This = impl_from_IGameStatistics(iface);
+
+ TRACE("(%p, %d, %s)\n", This, categoryIndex, debugstr_w(title));
+
+ if(!title || categoryIndex >= MAX_CATEGORIES)
+ return E_INVALIDARG;
+
+ dwLength = lstrlenW(title);
+
+ if(dwLength > MAX_CATEGORY_LENGTH)
+ {
+ hr = S_FALSE;
+ dwLength = MAX_CATEGORY_LENGTH;
+ }
+
+ lstrcpynW(This->stats.categories[categoryIndex].sName,
+ title, dwLength+1);
+
+ return hr;
}
static HRESULT WINAPI GameStatisticsImpl_GetCategoryTitle(
diff --git a/dlls/gameux/tests/gamestatistics.c b/dlls/gameux/tests/gamestatistics.c
index 30e1fcd..e62368a 100644
--- a/dlls/gameux/tests/gamestatistics.c
+++ b/dlls/gameux/tests/gamestatistics.c
@@ -271,10 +271,10 @@ static void test_gamestatisticsmgr( void )
/* write sample statistics */
hr = IGameStatistics_SetCategoryTitle(gs, wMaxCategories, NULL);
- todo_wine ok(hr==E_INVALIDARG, "setting category title invalid value: 0x%x\n", hr);
+ ok(hr==E_INVALIDARG, "setting category title invalid value: 0x%x\n", hr);
hr = IGameStatistics_SetCategoryTitle(gs, wMaxCategories, sCategory0);
- todo_wine ok(hr==E_INVALIDARG, "setting category title invalid value: 0x%x\n", hr);
+ ok(hr==E_INVALIDARG, "setting category title invalid value: 0x%x\n", hr);
/* check what happen if string is too long */
sTooLongString = CoTaskMemAlloc(sizeof(WCHAR)*(uMaxCategoryLength+2));
@@ -283,12 +283,12 @@ static void test_gamestatisticsmgr( void )
/* when string is too long, Windows returns S_FALSE, but saves string (stripped to expected number of characters) */
hr = IGameStatistics_SetCategoryTitle(gs, 0, sTooLongString);
- todo_wine ok(hr==S_FALSE, "setting category title invalid result: 0x%x\n", hr);
+ ok(hr==S_FALSE, "setting category title invalid result: 0x%x\n", hr);
CoTaskMemFree(sTooLongString);
- todo_wine ok(IGameStatistics_SetCategoryTitle(gs, 0, sCategory0)==S_OK, "setting category title failed: %s\n", wine_dbgstr_w(sCategory0));
- todo_wine ok(IGameStatistics_SetCategoryTitle(gs, 1, sCategory1)==S_OK, "setting category title failed: %s\n", wine_dbgstr_w(sCategory1));
- todo_wine ok(IGameStatistics_SetCategoryTitle(gs, 2, sCategory2)==S_OK, "setting category title failed: %s\n", wine_dbgstr_w(sCategory1));
+ ok(IGameStatistics_SetCategoryTitle(gs, 0, sCategory0)==S_OK, "setting category title failed: %s\n", wine_dbgstr_w(sCategory0));
+ ok(IGameStatistics_SetCategoryTitle(gs, 1, sCategory1)==S_OK, "setting category title failed: %s\n", wine_dbgstr_w(sCategory1));
+ ok(IGameStatistics_SetCategoryTitle(gs, 2, sCategory2)==S_OK, "setting category title failed: %s\n", wine_dbgstr_w(sCategory1));
/* check what happen if any string is NULL */
hr = IGameStatistics_SetStatistic(gs, 0, 0, NULL, sValue00);
@@ -333,7 +333,7 @@ static void test_gamestatisticsmgr( void )
todo_wine ok(_isFileExists(lpStatisticsFile) == TRUE, "statistics file %s does not exists\n", wine_dbgstr_w(lpStatisticsFile));
/* this value should not be stored in storage, we need it only to test is it not saved */
- todo_wine ok(IGameStatistics_SetCategoryTitle(gs, 0, sCategory0a)==S_OK, "setting category title failed: %s\n", wine_dbgstr_w(sCategory0a));
+ ok(IGameStatistics_SetCategoryTitle(gs, 0, sCategory0a)==S_OK, "setting category title failed: %s\n", wine_dbgstr_w(sCategory0a));
hr = IGameStatistics_Release(gs);
ok(SUCCEEDED(hr), "releasing IGameStatistics returned error: 0x%08x\n", hr);
More information about the wine-cvs
mailing list