diff --git a/constraint.cpp b/constraint.cpp
index 8fb0c5a..e6cdadc 100644
--- a/constraint.cpp
+++ b/constraint.cpp
@@ -103,6 +103,16 @@ void Constraint::ConstrainCoincident(hEntity ptA, hEntity ptB) {
}
void Constraint::MenuConstrain(int id) {
+ if(SK.constraint.n > 30) {
+ if((!SS.license.licensed) && SS.license.trialDaysRemaining <= 0) {
+ Error("The 90-day trial of SolveSpace has expired, and the light "
+ "version does not support more than 30 constraints in a "
+ "single file.\r\n\r\n"
+ "Choose Help -> Website / Manual to purchase a license.");
+ return;
+ }
+ }
+
Constraint c;
ZERO(&c);
c.group = SS.GW.activeGroup;
diff --git a/group.cpp b/group.cpp
index 7535d4b..f8705d6 100644
--- a/group.cpp
+++ b/group.cpp
@@ -17,14 +17,6 @@ void Group::AddParam(IdList *param, hParam hp, double v) {
}
void Group::MenuGroup(int id) {
- if(!SS.license.licensed && SK.group.n >= 7) {
- Error("The free version of this software does not support more "
- "than six groups.\r\n\r\n"
- "To remove this restriction, please choose Help -> "
- "Website / Manual, and purchase a license.");
- return;
- }
-
Group g;
ZERO(&g);
g.visible = true;
diff --git a/solvespace.cpp b/solvespace.cpp
index a1a1d82..43ff666 100644
--- a/solvespace.cpp
+++ b/solvespace.cpp
@@ -12,6 +12,23 @@ void SolveSpace::CheckLicenseFromRegistry(void) {
license.licensed =
LicenseValid(license.line1, license.line2, license.users, license.key);
+
+ // Now see if we've recorded a previous first use time in the registry. If
+ // yes then we use that, otherwise we record the current time.
+ SQWORD now = GetUnixTime();
+ DWORD timeLow = CnfThawDWORD(0, "FirstUseLow");
+ DWORD timeHigh = CnfThawDWORD(0, "FirstUseHigh");
+ if(timeHigh == 0 && timeLow == 0) {
+ CnfFreezeDWORD((DWORD)((now ) & 0xffffffff), "FirstUseLow");
+ CnfFreezeDWORD((DWORD)((now >> 32) & 0xffffffff), "FirstUseHigh");
+ license.firstUse = now;
+ } else {
+ license.firstUse = (((SQWORD)timeHigh) << 32) | ((SQWORD)timeLow);
+ }
+
+ const int SECONDS_IN_DAY = 60*60*24;
+ license.trialDaysRemaining = 90 -
+ (int)(((now - license.firstUse))/SECONDS_IN_DAY);
}
void SolveSpace::Init(char *cmdLine) {
@@ -257,6 +274,7 @@ void SolveSpace::AddToRecentList(char *file) {
}
bool SolveSpace::GetFilenameAndSave(bool saveAs) {
+
char newFile[MAX_PATH];
strcpy(newFile, saveFile);
if(saveAs || strlen(newFile)==0) {
diff --git a/solvespace.h b/solvespace.h
index cc05b14..98c97d8 100644
--- a/solvespace.h
+++ b/solvespace.h
@@ -44,6 +44,7 @@ inline double WRAP_SYMMETRIC(double v, double n) {
#define isforname(c) (isalnum(c) || (c) == '_' || (c) == '-' || (c) == '#')
typedef unsigned __int64 QWORD;
+typedef signed __int64 SQWORD;
typedef signed long SDWORD;
typedef signed short SWORD;
@@ -118,6 +119,7 @@ void InvalidateGraphics(void);
void PaintGraphics(void);
void GetGraphicsWindowSize(int *w, int *h);
SDWORD GetMilliseconds(void);
+SQWORD GetUnixTime(void);
void dbp(char *str, ...);
#define DBPTRI(tri) \
@@ -636,11 +638,13 @@ public:
};
Crc crc;
struct {
- bool licensed;
- char line1[512];
- char line2[512];
- char users[512];
- DWORD key;
+ bool licensed;
+ char line1[512];
+ char line2[512];
+ char users[512];
+ DWORD key;
+ SQWORD firstUse;
+ int trialDaysRemaining;
} license;
static void MenuHelp(int id);
void CleanEol(char *s);
diff --git a/textscreens.cpp b/textscreens.cpp
index 3a37f5d..a46bfe3 100644
--- a/textscreens.cpp
+++ b/textscreens.cpp
@@ -157,7 +157,13 @@ void TextWindow::ShowListOfGroups(void) {
Printf(false, "%Fg %s", SS.license.users);
} else {
Printf(false, "%Fx*** NO LICENSE FILE IS PRESENT ***");
- Printf(false, "%Fx eval / non-commercial use only");
+ if(SS.license.trialDaysRemaining > 0) {
+ Printf(false, "%Fx running as full demo, %d day%s remaining",
+ SS.license.trialDaysRemaining,
+ SS.license.trialDaysRemaining == 1 ? "" : "s");
+ } else {
+ Printf(false, "%Fx demo expired, now running in light mode");
+ }
Printf(false, "%Fx buy at %Fl%f%Llhttp://www.solvespace.com/%E",
&ScreenGoToWebsite);
}
diff --git a/win32/w32main.cpp b/win32/w32main.cpp
index ac99a75..6ad5c3e 100644
--- a/win32/w32main.cpp
+++ b/win32/w32main.cpp
@@ -7,6 +7,7 @@
#include
#include
#include
+#include
#include "solvespace.h"
@@ -598,6 +599,13 @@ SDWORD GetMilliseconds(void)
return (SDWORD)d;
}
+SQWORD GetUnixTime(void)
+{
+ __time64_t ret;
+ _time64(&ret);
+ return ret;
+}
+
void InvalidateText(void)
{
InvalidateRect(TextWnd, NULL, FALSE);