Team Fortress 2 Source Code as on 22/4/2020
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

134 lines
5.3 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================//
  7. #ifndef ISYSTEM_H
  8. #define ISYSTEM_H
  9. #ifdef _WIN32
  10. #pragma once
  11. #endif
  12. #include "tier1/interface.h"
  13. #include <vgui/VGUI.h>
  14. #include <vgui/KeyCode.h>
  15. #ifdef PlaySound
  16. #undef PlaySound
  17. #endif
  18. class KeyValues;
  19. namespace vgui
  20. {
  21. //-----------------------------------------------------------------------------
  22. // Purpose: Wraps contextless windows system functions
  23. //-----------------------------------------------------------------------------
  24. class ISystem : public IBaseInterface
  25. {
  26. public:
  27. // call when done with ISystem to clean up any memory allocation
  28. virtual void Shutdown() = 0;
  29. // called every frame
  30. virtual void RunFrame() = 0;
  31. // use this with the "open" command to launch web browsers/explorer windows, eg. ShellExecute("open", "www.valvesoftware.com")
  32. virtual void ShellExecute(const char *command, const char *file) = 0;
  33. // returns the time at the start of the frame, in seconds
  34. virtual double GetFrameTime() = 0;
  35. // returns the current time, in seconds
  36. virtual double GetCurrentTime() = 0;
  37. // returns the current time, in milliseconds
  38. virtual long GetTimeMillis() = 0;
  39. // clipboard access
  40. virtual int GetClipboardTextCount() = 0;
  41. virtual void SetClipboardText(const char *text, int textLen) = 0;
  42. virtual void SetClipboardText(const wchar_t *text, int textLen) = 0;
  43. virtual int GetClipboardText(int offset, char *buf, int bufLen) = 0;
  44. virtual int GetClipboardText(int offset, wchar_t *buf, int bufLen) = 0;
  45. // windows registry
  46. virtual bool SetRegistryString(const char *key, const char *value) = 0;
  47. virtual bool GetRegistryString(const char *key, char *value, int valueLen) = 0;
  48. virtual bool SetRegistryInteger(const char *key, int value) = 0;
  49. virtual bool GetRegistryInteger(const char *key, int &value) = 0;
  50. // user config
  51. virtual KeyValues *GetUserConfigFileData(const char *dialogName, int dialogID) = 0;
  52. // sets the name of the config file to save/restore from. Settings are loaded immediately.
  53. virtual void SetUserConfigFile(const char *fileName, const char *pathName) = 0;
  54. // saves all the current settings to the user config file
  55. virtual void SaveUserConfigFile() = 0;
  56. // sets the watch on global computer use
  57. // returns true if supported
  58. virtual bool SetWatchForComputerUse(bool state) = 0;
  59. // returns the time, in seconds, since the last computer use.
  60. virtual double GetTimeSinceLastUse() = 0;
  61. // Get a string containing the available drives
  62. // If the function succeeds, the return value is the length, in characters,
  63. // of the strings copied to the buffer,
  64. // not including the terminating null character.
  65. virtual int GetAvailableDrives(char *buf, int bufLen) = 0;
  66. // exe command line options accessors
  67. // returns whether or not the parameter was on the command line
  68. virtual bool CommandLineParamExists(const char *paramName) = 0;
  69. // returns the full command line, including the exe name
  70. virtual const char *GetFullCommandLine() = 0;
  71. // Convert a windows virtual key code to a VGUI key code.
  72. virtual KeyCode KeyCode_VirtualKeyToVGUI( int keyCode ) = 0;
  73. // returns the current local time and date
  74. // fills in every field that a pointer is given to it for
  75. virtual bool GetCurrentTimeAndDate(int *year, int *month, int *dayOfWeek, int *day, int *hour, int *minute, int *second) = 0;
  76. // returns the amount of available disk space, in bytes, on the drive
  77. // path can be any path, drive letter is stripped out
  78. virtual double GetFreeDiskSpace(const char *path) = 0;
  79. // shortcut (.lnk) modification functions
  80. virtual bool CreateShortcut(const char *linkFileName, const char *targetPath, const char *arguments, const char *workingDirectory, const char *iconFile) = 0;
  81. virtual bool GetShortcutTarget(const char *linkFileName, char *targetPath, char *arguments, int destBufferSizes) = 0;
  82. virtual bool ModifyShortcutTarget(const char *linkFileName, const char *targetPath, const char *arguments, const char *workingDirectory) = 0;
  83. // gets the string following a command line param
  84. //!! move this function up on changing interface version number
  85. virtual bool GetCommandLineParamValue(const char *paramName, char *value, int valueBufferSize) = 0;
  86. // recursively deletes a registry key and all it's subkeys
  87. //!! move this function next to other registry function on changing interface version number
  88. virtual bool DeleteRegistryKey(const char *keyName) = 0;
  89. virtual const char *GetDesktopFolderPath() = 0;
  90. // use this with the "open" command to launch web browsers/explorer windows, eg. ShellExecute("open", "www.valvesoftware.com")
  91. virtual void ShellExecuteEx( const char *command, const char *file, const char *pParams ) = 0;
  92. // Copy a portion of the application client area to the clipboard
  93. // (x1,y1) specifies the top-left corner of the client rect to copy
  94. // (x2,y2) specifies the bottom-right corner of the client rect to copy
  95. // Requires: x2 > x1 && y2 > y1
  96. // Dimensions of the copied rectangle are (x2 - x1) x (y2 - y1)
  97. // Pixel at (x1,y1) is copied, pixels at column x2 and row y2 are *not* copied
  98. virtual void SetClipboardImage( void *pWnd, int x1, int y1, int x2, int y2 ) = 0;
  99. };
  100. }
  101. #define VGUI_SYSTEM_INTERFACE_VERSION "VGUI_System010"
  102. #endif // ISYSTEM_H