Harmonic Flow Framework (libhffwk)
Cross platform C++ 2D Game Engine Framework
Environment.cpp
1 /*
2  Harmonic Flow Framework
3  Copyright (C) 2011-2018 Andreas Widen <andreas@harmonicflow.org>
4 
5  This software is provided 'as-is', without any express or implied
6  warranty. In no event will the authors be held liable for any damages
7  arising from the use of this software.
8 
9  Permission is granted to anyone to use this software for any purpose,
10  including commercial applications, and to alter it and redistribute it
11  freely, subject to the following restrictions:
12 
13  1. The origin of this software must not be misrepresented; you must not
14  claim that you wrote the original software. If you use this software
15  in a product, an acknowledgment in the product documentation would be
16  appreciated but is not required.
17  2. Altered source versions must be plainly marked as such, and must not be
18  misrepresented as being the original software.
19  3. This notice may not be removed or altered from any source distribution.
20 */
21 #include <assert.h>
22 
23 #include "Environment.h"
24 #include "Game.h"
25 #include "Graphics.h"
26 #include "SoundPlayer.h"
27 
29 #include "pref/Preferences.h"
30 #include "storage/Storage.h"
31 #include "actor/ActorManager.h"
32 #include "platform/Camera.h"
33 #include "platform/ImageHelper.h"
34 
35 #include "HFDataTypes.h"
36 
37 #if defined(HF_PLATFORM_WINDOWS_D3D9)
38 #include "platform/windows/WinEnvironment.h"
39 #elif defined(HF_PLATFORM_WINDOWS_OPENGL)
40 #include "platform/sdl/SDLOpenGLEnvironment.h"
41 #elif defined(HF_PLATFORM_OSX)
42 #include "platform/sdl/SDLOpenGLEnvironment.h"
43 #elif defined(HF_PLATFORM_LINUX)
44 #include "platform/sdl/SDLOpenGLEnvironment.h"
45 #elif defined(HF_PLATFORM_IOS)
46 #include "platform/sdl/SDLOpenGLEnvironment.h"
47 #elif defined(HF_PLATFORM_ANDROID)
48 #include "platform/sdl/SDLOpenGLEnvironment.h"
49 #else
50 #error "Environment (panic) -> unknown platform"
51 #endif
52 
53 using namespace HFCore;
54 
55 #include "debug/CrtDbgNew.h"
56 
57 #if defined(HF_PLATFORM_WINDOWS_D3D9)
58 static WinEnvironment sEnvObj;
59 #elif defined(HF_PLATFORM_WINDOWS_OPENGL)
60 static SDLOpenGLEnvironment sEnvObj;
61 #elif defined(HF_PLATFORM_OSX)
62 static SDLOpenGLEnvironment sEnvObj;
63 #elif defined(HF_PLATFORM_LINUX)
64 static SDLOpenGLEnvironment sEnvObj;
65 #elif defined(HF_PLATFORM_IOS)
66 static SDLOpenGLEnvironment sEnvObj;
67 #elif defined(HF_PLATFORM_ANDROID)
68 static SDLOpenGLEnvironment sEnvObj;
69 #else
70 #error "Environment (panic) -> unknown platform"
71 #endif
72 
73 Environment *Environment::gInstance = &sEnvObj;
74 
76 {
78  mGame = NULL;
79  mWindowTitle = "";
80  mPublisherName = "";
81  mPrefFileName = "";
82  mPakDataFile = "";
83  mWindowIconPath = "";
84  mAudioDeviceID = 0;
85 }
86 
88 {
90 }
91 
93 {
94  assert(gInstance != NULL);
95  return gInstance;
96 }
97 
99 {
101 }
102 
103 void *Environment::TiXmlFileOpen(const int8_hf *pFilePathUtf8)
104 {
105  HF_FileHandle hFile;
106  Storage::Result openResult = HFCORE_STORAGE->FileOpen(pFilePathUtf8,
109 
110  void *retVal = NULL;
111  if (openResult == Storage::STORAGE_OK)
112  {
113  retVal = (void *)(long long)hFile;
114  }
115 
116  return retVal;
117 }
118 
119 int32_hf Environment::TiXmlFileRead(void *pContext, void *pBuffer, int32_hf readSizeBytes)
120 {
121  int32_hf readOk = 0;
122  HF_FileHandle hFile = (HF_FileHandle)(long long)pContext;
123  Storage::Result result = HFCORE_STORAGE->FileRead(hFile, pBuffer, readSizeBytes);
124  if (result == Storage::STORAGE_OK)
125  {
126  readOk = 1;
127  }
128 
129  return readOk;
130 }
131 
133 {
134  HF_FileHandle hFile = (HF_FileHandle)(long long)pContext;
135  int32_hf size = HFCORE_STORAGE->FileGetSize(hFile);
136  return size;
137 }
138 
139 void Environment::TiXmlFileClose(void *pContext)
140 {
141  HF_FileHandle hFile = (HF_FileHandle)(long long)pContext;
142  HFCORE_STORAGE->FileClose(hFile);
143 }
144 
146 {
147  if (mGame != NULL)
148  {
149  mGame->handleMouseAdded(mouseId);
150  }
151 }
152 
154 {
155  if (mGame != NULL)
156  {
157  mGame->handleMouseRemoved(mouseId);
158  }
159 }
160 
162 {
163  if (mGame != NULL)
164  {
165  mGame->handleTouchAdded(touchId);
166  }
167 }
168 
170 {
171  if (mGame != NULL)
172  {
173  mGame->handleTouchRemoved(touchId);
174  }
175 }
176 
178 {
179  if (mGame != NULL)
180  {
181  mGame->handleGamePadAdded(gamePadId);
182  }
183 }
184 
186 {
187  if (mGame != NULL)
188  {
189  mGame->handleGamePadRemoved(gamePadId);
190  }
191 }
192 
194  const UString &windowTitle,
195  const UString &publisherName,
196  const UString &prefFileName,
197  const UString &pakDataFile,
198  const UString &pakDataFilePassword,
199  const UString &windowIconPath,
200  uint8_hf *cryptoKey,
201  const UString &androidActivityClass)
202 {
203  mGame = game;
204  mWindowTitle = windowTitle;
205  mPublisherName = publisherName;
206  mPrefFileName = prefFileName;
207  mPakDataFile = pakDataFile;
208  mPakDataFilePassword = pakDataFilePassword;
209  mWindowIconPath = windowIconPath;
210  mAndroidActivityClass = androidActivityClass;
211 }
212 
214 {
215  mGame = NULL;
216 }
217 
219 {
220  static uint32_hf lastClickTicks;
221  uint32_hf currentClickTicks;
222  // The first time this function is called, lastClickTicks has not been initialised yet.
223  if (! lastClickTicks)
224  {
225  lastClickTicks = HFCORE_ENV->getTicks();
226  return false;
227  }
228  else
229  {
230  currentClickTicks = HFCORE_ENV->getTicks();
231  // If the period between the two clicks is smaller or equal to a
232  // pre-defined number, we report a DoubleClick event.
233  if ((currentClickTicks - lastClickTicks) <= DOUBLE_CLICK_MAX_DELAY)
234  {
235  // Update lastClickTicks and signal a DoubleClick.
236  lastClickTicks = currentClickTicks;
237  return true;
238  }
239  else
240  {
241  // Update lastClickTicks and signal a SingleClick.
242  lastClickTicks = currentClickTicks;
243  return false;
244  }
245  }
246 }
247 
249 {
250  return mWindowTitle;
251 }
252 
254 {
255  return mPublisherName;
256 }
257 
259 {
260  return mPrefFileName;
261 }
262 
264 {
265  return mPakDataFile;
266 }
267 
269 {
270  return mWindowIconPath;
271 }
272 
274 {
275  return mAndroidActivityClass;
276 }
277 
279 {
280  return mGame;
281 }
282 
284 {
285  return mActorManager;
286 }
287 
289 {
290  int32_hf pid = HFCORE_PREF->getCurrentProfileID();
291  UString name = "MusicVol";
292  int32_hf childID = HFCORE_PREF->getChildIDByName(pid, name);
293 
294  UString value = HFCORE_PREF->getChildValue(pid, childID);
295  int32_hf prefMusicVol = atoi(value.toUtf8());
296 
297  return prefMusicVol;
298 }
299 
301 {
302  int32_hf pid = HFCORE_PREF->getCurrentProfileID();
303  UString name = "SoundVol";
304  int32_hf childID = HFCORE_PREF->getChildIDByName(pid, name);
305 
306  UString value = HFCORE_PREF->getChildValue(pid, childID);
307  int32_hf prefSoundVol = atoi(value.toUtf8());
308 
309  return prefSoundVol;
310 }
311 
313 {
314  int32_hf pid = HFCORE_PREF->getCurrentProfileID();
315  UString name = "Fullscreen";
316  int32_hf childID = HFCORE_PREF->getChildIDByName(pid, name);
317 
318  UString value = HFCORE_PREF->getChildValue(pid, childID);
319  int32_hf prefFullscreen = atoi(value.toUtf8());
320 
321  bool fullscreen = (prefFullscreen == 1) ? true : false;
322  return fullscreen;
323 }
324 
326 {
327  int32_hf pid = HFCORE_PREF->getCurrentProfileID();
328  UString name = "CustomCursor";
329  int32_hf childID = HFCORE_PREF->getChildIDByName(pid, name);
330 
331  UString value = HFCORE_PREF->getChildValue(pid, childID);
332  int32_hf prefCustomCursor = atoi(value.toUtf8());
333 
334  bool customcursor = (prefCustomCursor == 1) ? true : false;
335  return customcursor;
336 }
337 
339 {
340  int32_hf pid = HFCORE_PREF->getCurrentProfileID();
341  UString name = "Language";
342  int32_hf childID = HFCORE_PREF->getChildIDByName(pid, name);
343 
344  UString value = HFCORE_PREF->getChildValue(pid, childID);
345 
346  return value;
347 }
348 
350  int32_hf inDataSize,
351  int8_hf **outData,
352  int32_hf *outDataSize,
353  int32_hf compLevel)
354 {
355  assert(inData != NULL);
356  assert(inDataSize > 0);
357  assert(compLevel >= -1 && compLevel <= 9);
358 
359  // default output:
360  *outData = NULL;
361  *outDataSize = 0;
362 
363  int32_hf ret;
364  z_stream z_strm;
365  int32_hf bufSize = inDataSize;
366 
367  // create output buffer:
368  int8_hf *out = new int8_hf[bufSize];
369  memset(out, 0, bufSize * sizeof(int8_hf));
370  if (!out)
371  return false;
372 
373  // init z stream:
374  z_strm.zalloc = Z_NULL;
375  z_strm.zfree = Z_NULL;
376  z_strm.opaque = Z_NULL;
377  z_strm.next_in = (Bytef *)inData;
378  z_strm.avail_in = inDataSize;
379  z_strm.next_out = (Bytef *)out;
380  z_strm.avail_out = bufSize;
381 
382  ret = deflateInit(&z_strm, compLevel);
383  if (ret != Z_OK)
384  {
385  HF_SAFE_DELETE_ARR(out);
386  return false;
387  }
388 
389  do
390  {
391  // compress:
392  ret = deflate(&z_strm, Z_FINISH);
393  assert(ret != Z_STREAM_ERROR);
394 
395  }
396  while (ret == Z_OK);
397 
398  // clean-up:
399  int32_hf outSize = z_strm.total_out;
400  deflateEnd(&z_strm);
401 
402  // make sure we reached end of zstream:
403  if (ret != Z_STREAM_END)
404  {
405  HF_SAFE_DELETE_ARR(out);
406  return false;
407  }
408 
409  *outData = out;
410  *outDataSize = outSize;
411  return true;
412 }
413 
415  int32_hf inDataSize,
416  int8_hf **outData,
417  int32_hf *outDataSize)
418 {
419  assert(inData != NULL);
420  assert(inDataSize > 0);
421 
422  // default output:
423  *outData = NULL;
424  *outDataSize = 0;
425 
426  int32_hf ret;
427  z_stream z_strm;
428  int32_hf bufSize = inDataSize * 2;
429 
430  // create output buffer:
431  int8_hf *out = new int8_hf[bufSize];
432  memset(out, 0, bufSize * sizeof(int8_hf));
433  if (!out)
434  return false;
435 
436  // init z stream:
437  z_strm.zalloc = Z_NULL;
438  z_strm.zfree = Z_NULL;
439  z_strm.opaque = Z_NULL;
440  z_strm.next_in = (Bytef *)inData;
441  z_strm.avail_in = inDataSize;
442  z_strm.next_out = (Bytef *)out;
443  z_strm.avail_out = bufSize;
444 
445  ret = inflateInit(&z_strm);
446  if (ret != Z_OK)
447  {
448  HF_SAFE_DELETE_ARR(out);
449  return false;
450  }
451 
452  do
453  {
454  ret = inflate(&z_strm, Z_SYNC_FLUSH);
455 
456  switch (ret)
457  {
458  case Z_NEED_DICT:
459  case Z_STREAM_ERROR:
460  ret = Z_DATA_ERROR;
461  case Z_DATA_ERROR:
462  case Z_MEM_ERROR:
463  inflateEnd(&z_strm);
464  HF_SAFE_DELETE_ARR(out);
465  return false;
466  }
467 
468  if (ret != Z_STREAM_END)
469  {
470  // need to allocate more memory. Start with double size:
471  int8_hf *tmpbuff = new int8_hf[bufSize];
472  memset(tmpbuff, 0, bufSize * sizeof(int8_hf));
473  if (!tmpbuff)
474  {
475  inflateEnd(&z_strm);
476  HF_SAFE_DELETE_ARR(out);
477  HF_SAFE_DELETE_ARR(tmpbuff);
478  return false;
479  }
480  memcpy(tmpbuff, out, bufSize);
481 
482  HF_SAFE_DELETE_ARR(out);
483  out = new int8_hf[bufSize * 2];
484  memset(out, 0, (bufSize * 2) * sizeof(int8_hf));
485  memcpy(out, tmpbuff, bufSize);
486 
487  HF_SAFE_DELETE_ARR(tmpbuff);
488 
489  if (!out)
490  {
491  inflateEnd(&z_strm);
492  HF_SAFE_DELETE_ARR(out);
493  return false;
494  }
495 
496  // pos to start from next:
497  z_strm.next_out = (Bytef *)(out + bufSize);
498  z_strm.avail_out = bufSize;
499  bufSize *= 2;
500  }
501  }
502  while (ret != Z_STREAM_END);
503 
504  // make sure all input was processed:
505  if (z_strm.avail_in != 0)
506  {
507  inflateEnd(&z_strm);
508  HF_SAFE_DELETE_ARR(out);
509  return false;
510  }
511 
512  // clean-up:
513  int32_hf outSize = z_strm.total_out;
514  inflateEnd(&z_strm);
515 
516  *outData = out;
517  *outDataSize = outSize;
518  return true;
519 }
520 
522  int8_hf **outData,
523  int32_hf *outDataSize)
524 {
525  // default output:
526  *outData = NULL;
527  *outDataSize = 0;
528 
529  // open the input file:
530  int32_hf size = 0;
531  int8_hf *inData = HFCORE_STORAGE->GetFileContents(fileName, &size);
532  if (inData == NULL)
533  {
534  return false;
535  }
536 
537  // decompress:
538  if (!zlibDeCompress(inData, size, outData, outDataSize))
539  {
540  // delete the input data buffer:
541  HF_SAFE_DELETE_ARR(inData);
542  return false;
543  }
544 
545  // delete the input data buffer:
546  HF_SAFE_DELETE_ARR(inData);
547 
548  return true;
549 }
550 
552  const int8_hf *outFileName)
553 {
554  // open the input file:
555  int32_hf size = 0;
556  int8_hf *inData = HFCORE_STORAGE->GetFileContents(inFileName, &size);
557  if (inData == NULL)
558  {
559  return false;
560  }
561 
562  // compress:
563  int8_hf *compressedData;
564  int32_hf compressedDataSize;
565  if (!zlibCompress(inData, size, &compressedData, &compressedDataSize))
566  {
567  // delete the input data buffer:
568  HF_SAFE_DELETE_ARR(inData);
569  HF_SAFE_DELETE_ARR(compressedData);
570  return false;
571  }
572 
573  // delete the input data buffer:
574  HF_SAFE_DELETE_ARR(inData);
575 
576  // open the input file for writing:
577  PFILE *file = p_fopen(outFileName, "wb");
578  if (file == NULL)
579  {
580  return false;
581  }
582 
583  // write out compressed data:
584  int32_hf written = (int32_hf)p_fwrite(compressedData,
585  1,
586  compressedDataSize,
587  file);
588  if (written != compressedDataSize)
589  {
590  return false;
591  }
592 
593  // close:
594  p_fclose(file);
595 
596  // delete compressed data:
597  HF_SAFE_DELETE_ARR(compressedData);
598 
599  return true;
600 }
601 
602 bool Environment::saveFile(const int8_hf *fileName,
603  const int8_hf *inData,
604  int32_hf inDataSize)
605 {
606  // open the output file for writing:
607  PFILE *file = p_fopen(fileName, "wb");
608  if (file == NULL)
609  {
610  return false;
611  }
612 
613  // write out compressed data:
614  int32_hf written = (int32_hf)p_fwrite(inData,
615  1,
616  inDataSize,
617  file);
618  if (written != inDataSize)
619  {
620  return false;
621  }
622 
623  // close:
624  p_fclose(file);
625 
626  return true;
627 }
628 
630 {
631  return mAudioDeviceID;
632 }
633 
635 {
637 
638  switch (rate)
639  {
640  case 11025:
641  audioRate = HF_AUDIORATE_11025;
642  break;
643  case 22050:
644  audioRate = HF_AUDIORATE_22050;
645  break;
646  case 44100:
647  audioRate = HF_AUDIORATE_44100;
648  break;
649  default:
650  audioRate = HF_AUDIORATE_INVALID;
651  break;
652  }
653 
654  return audioRate;
655 }
656 
658 {
660 
661  switch (channels)
662  {
663  case 1:
664  audioChannels = HF_AUDIOCHANNELS_1;
665  break;
666  case 2:
667  audioChannels = HF_AUDIOCHANNELS_2;
668  break;
669  case 4:
670  audioChannels = HF_AUDIOCHANNELS_4;
671  break;
672  case 6:
673  audioChannels = HF_AUDIOCHANNELS_6;
674  break;
675  default:
676  audioChannels = HF_AUDIOCHANNELS_INVALID;
677  break;
678  }
679 
680  return audioChannels;
681 }
682 
684 {
685  HF_AudioBufferSize audioBufferSize = HF_AUDIOBUFFER_INVALID;
686 
687  switch (buffer)
688  {
689  case 1024:
690  audioBufferSize = HF_AUDIOBUFFER_1024;
691  break;
692  case 2048:
693  audioBufferSize = HF_AUDIOBUFFER_2048;
694  break;
695  case 4096:
696  audioBufferSize = HF_AUDIOBUFFER_4096;
697  break;
698  default:
699  audioBufferSize = HF_AUDIOBUFFER_INVALID;
700  break;
701  }
702 
703  return audioBufferSize;
704 }
705 
707 {
708  int32_hf audioRate = -1;
709 
710  switch (rate)
711  {
712  case HF_AUDIORATE_11025:
713  audioRate = 11025;
714  break;
715  case HF_AUDIORATE_22050:
716  audioRate = 22050;
717  break;
718  case HF_AUDIORATE_44100:
719  audioRate = 44100;
720  break;
721  default:
722  audioRate = -1;
723  break;
724  }
725 
726  return audioRate;
727 }
728 
730 {
731  int32_hf audioChannels = -1;
732 
733  switch (channels)
734  {
735  case HF_AUDIOCHANNELS_1:
736  audioChannels = 1;
737  break;
738  case HF_AUDIOCHANNELS_2:
739  audioChannels = 2;
740  break;
741  case HF_AUDIOCHANNELS_4:
742  audioChannels = 4;
743  break;
744  case HF_AUDIOCHANNELS_6:
745  audioChannels = 6;
746  break;
747  default:
748  audioChannels = -1;
749  break;
750  }
751 
752  return audioChannels;
753 }
754 
756 {
757  int32_hf audioBufferSize = -1;
758 
759  switch (bufferSize)
760  {
761  case HF_AUDIOBUFFER_1024:
762  audioBufferSize = 1024;
763  break;
764  case HF_AUDIOBUFFER_2048:
765  audioBufferSize = 2048;
766  break;
767  case HF_AUDIOBUFFER_4096:
768  audioBufferSize = 4096;
769  break;
770  default:
771  audioBufferSize = -1;
772  break;
773  }
774 
775  return audioBufferSize;
776 }
unsigned int uint32_hf
A type definition for unsigned int.
Definition: HFDataTypes.h:354
UString getWindowIconPath()
Get Window icon path.
virtual ~Environment()
Destructor.
Definition: Environment.cpp:87
virtual HF_AudioRate getAudioRateEnumForInt(int32_hf rate)
Get HF_AudioRate enum for rate value.
Interface for all rendering related things.
virtual void init(Game *game, const UString &windowTitle, const UString &publisherName, const UString &prefFileName, const UString &pakDataFile, const UString &pakDataFilePassword, const UString &windowIconPath, uint8_hf *cryptoKey, const UString &androidActivityClass)
Initializes Environment and all platform interfaces.
virtual UString getPrefLanguage()
Get Preferences language for current profile.
virtual void handleGamePadAdded(int32_hf gamePadId)
Called by the framework when a new GamePad object becomes available.
Definition: Game.h:202
Interface for unicode string class UString.
Definition: UString.h:35
Interface useful for controlling the Camera.
Interface for handling Actor&#39;s.
Definition: ActorManager.h:69
virtual bool getPrefFullscreen()
Get Preferences Fullscreen mode for current profile.
void InitTinyXML()
Initiate TinyXML = Set IO callback hooks.
Definition: Environment.cpp:98
#define HF_SAFE_DELETE(p)
Check if not NULL, delete and set to NULL.
Definition: HFDataTypes.h:49
Storage. Must exist.
Definition: Storage.h:57
HFCore::PFILE * p_fopen(const int8_hf *fileName, const int8_hf *access)
Open a file (within pak file or outside of it).
int int32_hf
A type definition for int.
Definition: HFDataTypes.h:349
Interface for Image loading / writing related helper methods.
Audio channels: 1 (mono).
Definition: HFDataTypes.h:613
Environment()
Constructor.
Definition: Environment.cpp:75
void fireGamePadAdded(int32_hf gamePadId)
Called automatically when a GamePad is added. It then calls callback method Game::handleGamePadAdded(...
static bool savezlibCompressedFile(const int8_hf *inFileName, const int8_hf *outFileName)
Compress inFileName and store compressed as outFileName.
HF_AudioRate
Audio rate / frequency enum.
Definition: HFDataTypes.h:599
Interface for handling Actor&#39;s.
UString mPrefFileName
Preferences file name.
Definition: Environment.h:2300
void fireTouchAdded(int32_hf touchId)
Called automatically when a Touch is added. It then calls callback method Game::handleTouchAdded().
virtual int32_hf getAudioBufferSizeIntForEnum(HF_AudioBufferSize bufferSize)
Get int value for bufferSize enum.
int32_hf p_fclose(HFCore::PFILE *file)
Closes and deletes a HFCore::PFILE.
Audio rate / frequency: 44100.
Definition: HFDataTypes.h:604
static bool zlibDeCompress(const int8_hf *inData, int32_hf inDataSize, int8_hf **outData, int32_hf *outDataSize)
Decompress inData using zlib.
virtual void destroy()
Destroy the singleton Environment instance and do cleanup.
Audio rate / frequency: 22050.
Definition: HFDataTypes.h:603
virtual HF_AudioChannels getAudioChannelsEnumForInt(int32_hf channels)
Get HF_AudioChannels enum for channels value.
Framework data types, defines, typedef&#39;s, enum and structs.
virtual HF_AudioBufferSize getAudioBufferSizeEnumForInt(int32_hf buffer)
Get HF_AudioBufferSize enum for buffer value.
Audio buffer size: 2048 bytes.
Definition: HFDataTypes.h:626
virtual int32_hf getPrefSoundVol()
Get Preferences Sound volume for current profile.
Audio channels: 6 (Surround 5.1).
Definition: HFDataTypes.h:616
static void * TiXmlFileOpen(const int8_hf *pFilePathUtf8)
TinyXML IO hook for FileOpen.
#define HF_SAFE_DELETE_ARR(p)
Check if not NULL, delete array and set to NULL.
Definition: HFDataTypes.h:56
UString getPakDataFileName()
Get PakInterface PAK data file name.
UString getPublisherName()
Get Publisher Name.
HF_AudioBufferSize
Audio buffer size enum.
Definition: HFDataTypes.h:622
bool mouseDoubleClickDetected()
Determines whether we&#39;ve a Mouse double click.
virtual void handleGamePadRemoved(int32_hf gamePadId)
Called by the framework when an existing GamePad object becomes unavailable.
Definition: Game.h:209
Interface used by the framework to drive the main loop.
Interface for Storage and File IO stuff.
UString getPrefFileName()
Get Preferences file name.
void fireTouchRemoved(int32_hf touchId)
Called automatically when a Touch is removed. It then calls callback method Game::handleTouchRemoved(...
UString mPakDataFile
PakInterface PAK file name.
Definition: Environment.h:2305
static bool loadzlibCompressedFile(const int8_hf *fileName, int8_hf **outData, int32_hf *outDataSize)
Load a zlib compressed file and return raw data.
size_t p_fwrite(const void *ptr, int32_hf size, int32_hf count, HFCore::PFILE *file)
Write block of data to HFCore::PFILE stream.
UString mPakDataFilePassword
PakInterface PAK file password.
Definition: Environment.h:2310
static Environment * instance()
Environment singleton instance.
Definition: Environment.cpp:92
static int32_hf TiXmlFileSize(void *pContext)
TinyXML IO hook for FileSize.
virtual bool getPrefCustomCursor()
Get Preferences custom cursor mode for current profile.
virtual void handleTouchRemoved(int32_hf touchId)
Called by the framework when an existing Touch object becomes unavailable.
Definition: Game.h:195
void fireMouseRemoved(int32_hf mouseId)
Called automatically when a Mouse is removed. It then calls callback method Game::handleMouseRemoved(...
HF_AudioDeviceID mAudioDeviceID
Default audio device id opened during Environment::init().
Definition: Environment.h:2331
#define NULL
Convenient define for 0.
Definition: HFDataTypes.h:42
Singleton interface for platform specific things.
Definition: Environment.h:151
Audio rate / frequency: 11025.
Definition: HFDataTypes.h:602
ActorManager * mActorManager
ActorManager interface instance.
Definition: Environment.h:2325
Audio channels: 2 (stereo).
Definition: HFDataTypes.h:614
const int8_hf * toUtf8() const
Get the utf8 encoded string.
Definition: UString.cpp:574
HF_AudioChannels
Audio channels enum.
Definition: HFDataTypes.h:610
virtual int32_hf getAudioRateIntForEnum(HF_AudioRate rate)
Get int value for rate enum.
char int8_hf
A type definition for char.
Definition: HFDataTypes.h:329
Game * mGame
Singleton Game instance.
Definition: Environment.h:2285
UString mPublisherName
Publisher name.
Definition: Environment.h:2295
static int32_hf TiXmlFileRead(void *pContext, void *pBuffer, int32_hf readSizeBytes)
TinyXML IO hook for FileRead.
int32_hf HF_FileHandle
A type definition for int32_hf used as File IO handle.
Definition: HFDataTypes.h:381
Audio buffer size invalid.
Definition: HFDataTypes.h:624
Audio channels invalid.
Definition: HFDataTypes.h:612
virtual void handleMouseAdded(int32_hf mouseId)
Called by the framework when a new Mouse object becomes available.
Definition: Game.h:174
#define DOUBLE_CLICK_MAX_DELAY
HFCore::Mouse double click delay in milliseconds.
Definition: Environment.h:63
void fireMouseAdded(int32_hf mouseId)
Called automatically when a Mouse is added. It then calls callback method Game::handleMouseAdded().
static bool zlibCompress(const int8_hf *inData, int32_hf inDataSize, int8_hf **outData, int32_hf *outDataSize, int32_hf compLevel=Z_DEFAULT_COMPRESSION)
Compress inData using zlib.
Storage mode: Read.
Definition: Storage.h:53
Interface for Preferences base class.
static bool saveFile(const int8_hf *fileName, const int8_hf *inData, int32_hf inDataSize)
Store and save inData in a new file with fileName.
Audio buffer size: 4096 bytes.
Definition: HFDataTypes.h:627
UString mWindowTitle
Window title.
Definition: Environment.h:2290
#define HFCORE_PREF
Get HFCore::Preferences instance shortcut macro.
Definition: Environment.h:88
Result
Storage result enum.
Definition: Storage.h:42
Audio rate invalid.
Definition: HFDataTypes.h:601
Interface for ResourceManager which handles all Resource loading etc.
Game * getGameInstance()
Get singleton Game instance.
Definition: Actor.h:34
virtual void handleTouchAdded(int32_hf touchId)
Called by the framework when a new Touch object becomes available.
Definition: Game.h:188
Interface for playing Sound&#39;s and Music streams.
Singleton interface for platform specific things.
void fireGamePadRemoved(int32_hf gamePadId)
Called automatically when a GamePad is removed. It then calls callback method Game::handleGamePadRemo...
virtual int32_hf getAudioChannelsIntForEnum(HF_AudioChannels channels)
Get int value for channels enum.
Struct holding PakRecord, pointer to actual FILE and position.
Definition: PakInterface.h:146
virtual HF_AudioDeviceID getAudioDeviceID()
Get audio device id for the default device opened during Environment::init().
#define HFCORE_ENV
Get HFCore::Environment instance shortcut macro.
Definition: Environment.h:68
virtual ActorManager * getActorManager()
Get pointer to ActorManager interface.
Audio buffer size: 1024 bytes.
Definition: HFDataTypes.h:625
UString mAndroidActivityClass
Android java activity class path.
Definition: Environment.h:2320
Interface used by the framework to drive the main loop.
Definition: Game.h:67
UString getAndroidActivityClass()
Get Android java activity class path.
unsigned char uint8_hf
A type definition for unsigned char.
Definition: HFDataTypes.h:334
virtual void handleMouseRemoved(int32_hf mouseId)
Called by the framework when an existing Mouse object becomes unavailable.
Definition: Game.h:181
static void TiXmlFileClose(void *pContext)
TinyXML IO hook for FileClose.
#define HFCORE_STORAGE
Get HFCore::Storage instance shortcut macro.
Definition: Environment.h:93
Audio channels: 4 (quad).
Definition: HFDataTypes.h:615
UString mWindowIconPath
Window icon path.
Definition: Environment.h:2315
virtual int32_hf getPrefMusicVol()
Get Preferences SoundPlayer music volume for current profile.
uint32_hf HF_AudioDeviceID
A type definition for uint32_hf used as Audio device id.
Definition: HFDataTypes.h:386
UString getWindowTitle()
Get Window title name.