From 3b83e527f8dfcaacb07dc0e84d9d499a52f76a7c Mon Sep 17 00:00:00 2001 From: Lannuked Date: Tue, 4 Oct 2022 23:36:59 -0400 Subject: [PATCH 1/5] Fix Hopper selection crash, add some placeholder enums, add a compaitiblity shim --- .gitignore | 3 ++- Blocks3D.vcproj | 8 ++++++++ content/page/hopper.html | 2 +- src/include/ToolEnum.h | 11 +++++++++++ src/include/VS2005CompatShim.h | 26 ++++++++++++++++++++++++++ src/source/IEBrowser.cpp | 25 +++++++++++++++++++++---- 6 files changed, 69 insertions(+), 6 deletions(-) create mode 100644 src/include/ToolEnum.h create mode 100644 src/include/VS2005CompatShim.h diff --git a/.gitignore b/.gitignore index 36a1686..1902ebe 100644 --- a/.gitignore +++ b/.gitignore @@ -53,4 +53,5 @@ desktop.ini *.db #Redist -!Installer/Redist/* \ No newline at end of file +!Installer/Redist/* +UpgradeLog.htm diff --git a/Blocks3D.vcproj b/Blocks3D.vcproj index 5554683..9203292 100644 --- a/Blocks3D.vcproj +++ b/Blocks3D.vcproj @@ -733,6 +733,14 @@ RelativePath=".\src\include\TextureHandler.h" > + + + + diff --git a/content/page/hopper.html b/content/page/hopper.html index b3478a8..a2fa956 100644 --- a/content/page/hopper.html +++ b/content/page/hopper.html @@ -22,7 +22,7 @@ } - + diff --git a/src/include/ToolEnum.h b/src/include/ToolEnum.h new file mode 100644 index 0000000..0790963 --- /dev/null +++ b/src/include/ToolEnum.h @@ -0,0 +1,11 @@ +#pragma once + +namespace Enum +{ + namespace Hopper + { + enum Value { + GameTool = 0, Grab = 1, Clone = 2, Hammer = 3, Slingshot = 4, Rocket = 5, Laser = 6 + }; + } +} \ No newline at end of file diff --git a/src/include/VS2005CompatShim.h b/src/include/VS2005CompatShim.h new file mode 100644 index 0000000..3115e08 --- /dev/null +++ b/src/include/VS2005CompatShim.h @@ -0,0 +1,26 @@ +#ifndef COMPAT_SHIM +#define COMPAT_SHIM +#include +#include + +template +std::string toString(const T &value) +{ + std::ostringstream os; + os << value; + return os.str(); +} + +namespace std +{ + std::string to_string( int value ) {return toString(value);} + std::string to_string( long value ) {return toString(value);} + std::string to_string( long long value ) {return toString(value);} + std::string to_string( unsigned value ) {return toString(value);} + std::string to_string( unsigned long value ) {return toString(value);} + std::string to_string( unsigned long long value ) {return toString(value);} + std::string to_string( float value ) {return toString(value);} + std::string to_string( double value ) {return toString(value);} + std::string to_string( long double value ) {return toString(value);} +} +#endif \ No newline at end of file diff --git a/src/source/IEBrowser.cpp b/src/source/IEBrowser.cpp index 6d72313..f88f173 100644 --- a/src/source/IEBrowser.cpp +++ b/src/source/IEBrowser.cpp @@ -2,7 +2,6 @@ #define WIN32_LEAN_AND_MEAN #endif - #include #include #include "IEBrowser.h" @@ -11,6 +10,9 @@ #include "ax.h" #include "Tool/SurfaceTool.h" #include "Application.h" +#include "Enum.h" +#include "ToolEnum.h" +#include "VS2005CompatShim.h" HRESULT IEBrowser::doExternal(std::wstring funcName, DISPID dispIdMember, @@ -30,9 +32,24 @@ HRESULT IEBrowser::doExternal(std::wstring funcName, } else if (funcName==L"ToggleHopperBin") { - pVarResult->vt = VT_INT; - pVarResult->intVal = 5; - //MessageBox(NULL, "BOOP", "Boopity boop",MB_OK); + MessageBox(NULL, "BOOP", "Boopity boop",MB_OK); + + /*To-do Make enums in ToolEnum work with this properly, + commented code is not fully tested.*/ + /*MessageBox(NULL, + std::to_string(pDispParams->rgvarg->intVal).c_str(), + "Is it working?", + MB_OK); + Enum::Hopper::Value cont = (Enum::Hopper::Value)pDispParams->rgvarg->intVal; + + switch (cont) + { + case GameTool + case Grab + + break; + }*/ + return S_OK; } else if (funcName==L"SetController") { From 791fa55767307743939ce159dbafc42949d90d1b Mon Sep 17 00:00:00 2001 From: Lannuked Date: Wed, 5 Oct 2022 02:33:06 -0400 Subject: [PATCH 2/5] PR update --- Dialogs.rc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dialogs.rc b/Dialogs.rc index d11bbe9..11bf464 100644 --- a/Dialogs.rc +++ b/Dialogs.rc @@ -10,7 +10,7 @@ #define APP_GENER 0 #define APP_MAJOR 0 #define APP_MINOR 106 -#define APP_PATCH 3 +#define APP_PATCH 4 #define APP_VER_STRING APP_GENER.APP_MAJOR.APP_MINOR.APP_PATCH #define VER_PREFIX( N ) v##N From 48e65358f4794d52121a4dceb993df7db3d10115 Mon Sep 17 00:00:00 2001 From: NT_x86 Date: Wed, 5 Oct 2022 13:13:54 +0300 Subject: [PATCH 3/5] Implement initial level service functionality --- src/include/DataModelV2/LevelInstance.h | 5 + src/include/Enum.h | 12 ++ src/source/Application.cpp | 3 + src/source/DataModelV2/LevelInstance.cpp | 147 +++++++++++++++++++++++ 4 files changed, 167 insertions(+) diff --git a/src/include/DataModelV2/LevelInstance.h b/src/include/DataModelV2/LevelInstance.h index f29ca78..e83bcfe 100644 --- a/src/include/DataModelV2/LevelInstance.h +++ b/src/include/DataModelV2/LevelInstance.h @@ -7,10 +7,15 @@ class LevelInstance : public: LevelInstance(void); ~LevelInstance(void); + bool HighScoreIsGood; + Enum::ActionType::Value TimerUpAction; + Enum::AffectType::Value TimerAffectsScore; + bool RunOnOpen; float timer; int score; virtual std::vector getProperties(); std::string winMessage; std::string loseMessage; virtual void PropUpdate(LPPROPGRIDITEM &pItem); + void Step(SimTime sdt); }; diff --git a/src/include/Enum.h b/src/include/Enum.h index 1b1209b..8d9fbe6 100644 --- a/src/include/Enum.h +++ b/src/include/Enum.h @@ -20,4 +20,16 @@ namespace Enum Player = 7, KeyboardRight = 1, KeyboardLeft = 2, Joypad1 = 3, Joypad2 = 4, Chase = 5, Flee = 6, None = 0 }; } + namespace ActionType + { + enum Value { + Nothing = 0, Pause = 1, Lose = 2, Draw = 3, Win = 4 + }; + } + namespace AffectType + { + enum Value { + NoChange = 0, Increase = 1, Decrease = 2 + }; + } } \ No newline at end of file diff --git a/src/source/Application.cpp b/src/source/Application.cpp index f0f2f24..df8abd6 100644 --- a/src/source/Application.cpp +++ b/src/source/Application.cpp @@ -323,6 +323,9 @@ void Application::onSimulation(RealTime rdt, SimTime sdt, SimTime idt) { if(_dataModel->isRunning()) { + LevelInstance* Level = _dataModel->getLevel(); + Level->Step(sdt); + // XplicitNgine Start std::vector toDelete; for(size_t i = 0; i < _dataModel->getWorkspace()->partObjects.size(); i++) diff --git a/src/source/DataModelV2/LevelInstance.cpp b/src/source/DataModelV2/LevelInstance.cpp index 1be61d9..ed8acc4 100644 --- a/src/source/DataModelV2/LevelInstance.cpp +++ b/src/source/DataModelV2/LevelInstance.cpp @@ -1,3 +1,4 @@ +#include "DataModelV2/DataModelInstance.h" #include "DataModelV2/LevelInstance.h" LevelInstance::LevelInstance(void) @@ -16,6 +17,61 @@ LevelInstance::~LevelInstance(void) } +static TCHAR* strActionType(int option) +{ + switch(option) + { + case Enum::ActionType::Nothing: + return "Nothing"; + case Enum::ActionType::Pause: + return "Pause"; + case Enum::ActionType::Lose: + return "Lose"; + case Enum::ActionType::Draw: + return "Draw"; + case Enum::ActionType::Win: + return "Win"; + } + return "Nothing"; +} + +static Enum::ActionType::Value EnumActionType(TCHAR* option) +{ + if(strcmp("Nothing", option) == 0) + return Enum::ActionType::Nothing; + if(strcmp("Pause", option) == 0) + return Enum::ActionType::Pause; + if(strcmp("Lose", option) == 0) + return Enum::ActionType::Lose; + if(strcmp("Draw", option) == 0) + return Enum::ActionType::Draw; + return Enum::ActionType::Win; +} + +static TCHAR* strAffectType(int option) +{ + switch(option) + { + case Enum::AffectType::NoChange: + return "NoChange"; + case Enum::AffectType::Increase: + return "Increase"; + case Enum::AffectType::Decrease: + return "Decrease"; + } + return "NoChange"; +} + +static Enum::AffectType::Value EnumAffectType(TCHAR* option) +{ + if(strcmp("NoChange", option) == 0) + return Enum::AffectType::NoChange; + if(strcmp("Increase", option) == 0) + return Enum::AffectType::Increase; + return Enum::AffectType::Decrease; +} + + char timerTxt[12]; char scoreTxt[12]; std::vector LevelInstance::getProperties() @@ -29,12 +85,28 @@ std::vector LevelInstance::getProperties() "The message that shows when the player wins.", (LPARAM)winMessage.c_str(), PIT_EDIT)); + properties.push_back(createPGI("Messages", "LoseMessage", "The message that shows when the player loses.", (LPARAM)loseMessage.c_str(), PIT_EDIT)); + properties.push_back(createPGI( + "Gameplay", + "HighScoreIsGood", + "Some temporary string here", + (LPARAM)HighScoreIsGood, + PIT_CHECK + )); + + properties.push_back(createPGI( + "Gameplay", + "RunOnOpen", + "Some temporary string here", + (LPARAM)RunOnOpen, + PIT_CHECK + )); sprintf_s(timerTxt, "%g", timer); sprintf_s(scoreTxt, "%d", score); @@ -43,11 +115,28 @@ std::vector LevelInstance::getProperties() "The amount of time in seconds the player has to complete this level.\r\n\r\nPut 0 if time is limitless.", (LPARAM)timerTxt, PIT_EDIT)); + properties.push_back(createPGI("Gameplay", "InitialScoreValue", "The amount of points the player starts with.", (LPARAM)scoreTxt, PIT_EDIT)); + + properties.push_back(createPGI("Gameplay", + "TimerUpAction", + "Some temporary string here", + (LPARAM)strActionType(TimerUpAction), + PIT_COMBO, + TEXT("Nothing\0Pause\0Lose\0Draw\0Win\0") + )); + + properties.push_back(createPGI("Gameplay", + "TimerAffectsScore", + "Some temporary string here", + (LPARAM)strAffectType(TimerAffectsScore), + PIT_COMBO, + TEXT("NoChange\0Increase\0Decrease\0") + )); return properties; } void LevelInstance::PropUpdate(LPPROPGRIDITEM &pItem) @@ -68,6 +157,64 @@ void LevelInstance::PropUpdate(LPPROPGRIDITEM &pItem) { winMessage = (LPSTR)pItem->lpCurValue; } + else if(strcmp(pItem->lpszPropName, "TimerUpAction") == 0) + { + TimerUpAction = EnumActionType((TCHAR*)pItem->lpCurValue); + } + else if(strcmp(pItem->lpszPropName, "TimerAffectsScore") == 0) + { + TimerAffectsScore = EnumAffectType((TCHAR*)pItem->lpCurValue); + } + else if(strcmp(pItem->lpszPropName, "HighScoreIsGood") == 0) + { + HighScoreIsGood = pItem->lpCurValue == TRUE; + } + else if(strcmp(pItem->lpszPropName, "RunOnOpen") == 0) + { + RunOnOpen = pItem->lpCurValue == TRUE; + } else Instance::PropUpdate(pItem); } + +void LevelInstance::Step(SimTime sdt) +{ + switch(TimerAffectsScore) + { + case Enum::AffectType::NoChange: + break; + case Enum::AffectType::Increase: + score += 1; + break; + case Enum::AffectType::Decrease: + if (score > 0) + score -= 1; + break; + } + if (timer >= 0.1f){ + timer -= sdt; + } + else{ + timer = 0.0f; + DataModelInstance* DataModel = (DataModelInstance*)getParent(); + switch(TimerUpAction) + { + case Enum::ActionType::Nothing: + break; + case Enum::ActionType::Pause: + DataModel->toggleRun(); + break; + case Enum::ActionType::Lose: + DataModel->setMessage(loseMessage); + DataModel->toggleRun(); + break; + case Enum::ActionType::Draw: + DataModel->toggleRun(); + break; + case Enum::ActionType::Win: + DataModel->setMessage(winMessage); + DataModel->toggleRun(); + break; + } + } +} \ No newline at end of file From 932de58185dc1d649dbc37c19ceb41ceaafffcd7 Mon Sep 17 00:00:00 2001 From: NT_x86 Date: Wed, 5 Oct 2022 13:19:05 +0300 Subject: [PATCH 4/5] Add unsaved comments --- src/source/DataModelV2/LevelInstance.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/source/DataModelV2/LevelInstance.cpp b/src/source/DataModelV2/LevelInstance.cpp index ed8acc4..4867c5d 100644 --- a/src/source/DataModelV2/LevelInstance.cpp +++ b/src/source/DataModelV2/LevelInstance.cpp @@ -191,12 +191,12 @@ void LevelInstance::Step(SimTime sdt) score -= 1; break; } - if (timer >= 0.1f){ + if (timer >= 0.1f){ //Due to timing used this could cause the number go into negatives for one step timer -= sdt; } else{ timer = 0.0f; - DataModelInstance* DataModel = (DataModelInstance*)getParent(); + DataModelInstance* DataModel = (DataModelInstance*)getParent(); //If level parent gets changed to something other than Datamodel it could cause nasty data corruption bugs switch(TimerUpAction) { case Enum::ActionType::Nothing: From 27ac18b503c2d8077e7317fa8aea5b116e46e292 Mon Sep 17 00:00:00 2001 From: NT_x86 Date: Wed, 5 Oct 2022 17:25:35 +0300 Subject: [PATCH 5/5] Separate each condition as separate functions --- src/include/DataModelV2/LevelInstance.h | 4 +++ src/source/DataModelV2/LevelInstance.cpp | 37 +++++++++++++++++++----- 2 files changed, 34 insertions(+), 7 deletions(-) diff --git a/src/include/DataModelV2/LevelInstance.h b/src/include/DataModelV2/LevelInstance.h index e83bcfe..b7c0251 100644 --- a/src/include/DataModelV2/LevelInstance.h +++ b/src/include/DataModelV2/LevelInstance.h @@ -17,5 +17,9 @@ public: std::string winMessage; std::string loseMessage; virtual void PropUpdate(LPPROPGRIDITEM &pItem); + void winCondition(); + void loseCondition(); + void pauseCondition(); + void drawCondition(); void Step(SimTime sdt); }; diff --git a/src/source/DataModelV2/LevelInstance.cpp b/src/source/DataModelV2/LevelInstance.cpp index 4867c5d..4b33578 100644 --- a/src/source/DataModelV2/LevelInstance.cpp +++ b/src/source/DataModelV2/LevelInstance.cpp @@ -177,6 +177,32 @@ void LevelInstance::PropUpdate(LPPROPGRIDITEM &pItem) Instance::PropUpdate(pItem); } +void LevelInstance::winCondition() +{ + DataModelInstance* DataModel = (DataModelInstance*)getParent(); //If level parent gets changed to something other than Datamodel it could cause nasty data corruption bugs + DataModel->setMessage(winMessage); + DataModel->toggleRun(); +} + +void LevelInstance::loseCondition() +{ + DataModelInstance* DataModel = (DataModelInstance*)getParent(); + DataModel->setMessage(loseMessage); + DataModel->toggleRun(); +} + +void LevelInstance::pauseCondition() +{ + DataModelInstance* DataModel = (DataModelInstance*)getParent(); + DataModel->toggleRun(); +} + +void LevelInstance::drawCondition() +{ + DataModelInstance* DataModel = (DataModelInstance*)getParent(); + DataModel->toggleRun(); +} + void LevelInstance::Step(SimTime sdt) { switch(TimerAffectsScore) @@ -196,24 +222,21 @@ void LevelInstance::Step(SimTime sdt) } else{ timer = 0.0f; - DataModelInstance* DataModel = (DataModelInstance*)getParent(); //If level parent gets changed to something other than Datamodel it could cause nasty data corruption bugs switch(TimerUpAction) { case Enum::ActionType::Nothing: break; case Enum::ActionType::Pause: - DataModel->toggleRun(); + pauseCondition(); break; case Enum::ActionType::Lose: - DataModel->setMessage(loseMessage); - DataModel->toggleRun(); + loseCondition(); break; case Enum::ActionType::Draw: - DataModel->toggleRun(); + drawCondition(); break; case Enum::ActionType::Win: - DataModel->setMessage(winMessage); - DataModel->toggleRun(); + winCondition(); break; } }