| #charset "us-ascii" | |
| /* | |
| ** T3Checks helps you keep track of what capabilities a given | |
| ** interpreter has or doesn't have. For example: is the interpreter | |
| ** capable of HTML mode? Can the interpreter handle graphics? | |
| ** All results are stored in the sysInfoObj object. | |
| ** | |
| ** Version: 1.0 (6 Jan 2003) | |
| ** | |
| ** Copyright (c) 2003, Stephen Granade. All rights reserved. | |
| ** | |
| */ | |
| #include <tadsio.h> | |
| #include <tadsgen.h> | |
| // To use: in your main() function, call sysInfoObject.getSysInfo(). | |
| // The object is transient because we don't want its state saved in | |
| // a game file, nor do we want it restored. This way, if the player | |
| // plays our game on one machine, then moves the saved game file to | |
| // another, the information won't be wrong. | |
| transient sysInfoObject: object | |
| isHTMLRuntime = nil | |
| canDoGraphics = nil | |
| canDoSoundFX = nil | |
| canDoMusic = nil | |
| versionNumber = '' | |
| // graphicsOn() returns true if user has the "graphics" option selected | |
| // and the runtime is capable of displaying graphics | |
| graphicsOn() { | |
| return (canDoGraphics && systemInfo(SysInfoPrefImages)); | |
| } | |
| // soundsOn() is like graphicsOn(), only for sound effects | |
| soundsOn() { | |
| return (canDoSoundFX && systemInfo(SysInfoPrefSounds)); | |
| } | |
| // And a similar function for music | |
| musicOn() { | |
| return (canDoMusic && systemInfo(SysInfoPrefMusic)); | |
| } | |
| getSysInfo() { | |
| isHTMLRuntime = (systemInfo(SysInfoInterpClass) == SysInfoIClassHTML); | |
| canDoGraphics = (systemInfo(SysInfoJpeg) == 1) || | |
| (systemInfo(SysInfoPng) == 1);// True if we can do PNG or JPEG | |
| canDoSoundFX = (systemInfo(SysInfoMpeg) == 1) || | |
| (systemInfo(SysInfoWav) == 1); | |
| canDoMusic = (systemInfo(SysInfoMidi) == 1); | |
| // Check our version number | |
| versionNumber = systemInfo(SysInfoVersion); | |
| } | |
| // Compare two version numbers (e.g. '2.2.6'), starting with the major | |
| // number, then minor, then final. Returns -1 if the first number is | |
| // less than the second, 0 if they are equal, or 1 if the first is | |
| // greater | |
| compareVersionNumbers(one, two) { | |
| local firstStr, secondStr, i, j, firstLoc, secondLoc; | |
| firstStr = one; | |
| secondStr = two; | |
| do { | |
| firstLoc = find(firstStr, '.'); | |
| secondLoc = find(secondStr, '.'); | |
| if (firstLoc) { | |
| i = toInteger(substr(firstStr, 1, firstLoc - 1)); | |
| firstStr = substr(firstStr, firstLoc + 1, | |
| length(firstStr) - firstLoc); | |
| } | |
| else i = toInteger(firstStr); | |
| if (secondLoc) { | |
| j = toInteger(substr(secondStr, 1, secondLoc - 1)); | |
| secondStr = substr(secondStr, secondLoc + 1, | |
| length(secondStr) - secondLoc); | |
| } | |
| else j = toInteger(secondStr); | |
| if (i < j) return -1; | |
| if (i > j) return 1; | |
| } while (firstLoc && secondLoc); | |
| if (firstLoc) return 1; // This handles e.g. '2.5.1' vs '2.5' | |
| if (secondLoc) return -1; // while this handles '2.5' vs '2.5.1' | |
| return 0; | |
| } | |
| ; | |
| // Make an ID for this module | |
| ModuleID | |
| name = 'T3Checks' | |
| byline = 'by Stephen Granade' | |
| htmlByline = 'by <a href="mailto:stephen@granades.com">Stephen Granade</a>' | |
| version = '1.0' | |
| ; | |
Xet Storage Details
- Size:
- 3.06 kB
- Xet hash:
- 4ded607a7d9996f2a13db28355cbded0535e498f56384c92d575c46b8078025f
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.