From 4c255b761c11019b05d369a41efa3d7ee41304f2 Mon Sep 17 00:00:00 2001 From: Moros Smith Date: Wed, 26 Jun 2024 02:23:45 -0400 Subject: [PATCH 01/50] switch default code to example1.cpp and remove unused api calls --- resources/{example.cpp => example1.cpp} | 2 +- resources/js/app.ts | 14 -------------- resources/js/components/EditorPanel.js | 2 +- routes/api.php | 7 ------- 4 files changed, 2 insertions(+), 23 deletions(-) rename resources/{example.cpp => example1.cpp} (98%) diff --git a/resources/example.cpp b/resources/example1.cpp similarity index 98% rename from resources/example.cpp rename to resources/example1.cpp index a8e29c3..7c46f72 100644 --- a/resources/example.cpp +++ b/resources/example1.cpp @@ -15,7 +15,7 @@ class Example : public olc::PixelGameEngine Example() { // Name your application - sAppName = "Example"; + sAppName = "Example 1"; } public: diff --git a/resources/js/app.ts b/resources/js/app.ts index 5194a94..82bf4a0 100644 --- a/resources/js/app.ts +++ b/resources/js/app.ts @@ -172,20 +172,6 @@ export default class PGEtinker } } - defaultCode() - { - axios.get("/api/default-code").then((response) => - { - this.editorPanel.setValue(response.data.code); - this.editorPanel.reveal({ - column: 1, - lineNumber: 1, - }); - - - }).catch((reason) => console.log(reason)); - } - download() { if(!this.playerPanel.getHtml().includes("Emscripten-Generated Code")) diff --git a/resources/js/components/EditorPanel.js b/resources/js/components/EditorPanel.js index 9e6969f..4dbf028 100644 --- a/resources/js/components/EditorPanel.js +++ b/resources/js/components/EditorPanel.js @@ -1,7 +1,7 @@ import { getUserConfiguration } from "../lib/monacoConfig"; import { configureMonacoWorkers, runCppWrapper } from "../lib/monacoWrapper"; import { getStorageValue } from "../lib/storage"; -import pgetinkerCppCode from '../../example.cpp?raw'; +import pgetinkerCppCode from '../../example1.cpp?raw'; import * as vscode from "vscode"; export default class EditorPanel diff --git a/routes/api.php b/routes/api.php index 2df5abc..9eac11e 100644 --- a/routes/api.php +++ b/routes/api.php @@ -20,13 +20,6 @@ ], 404); }); -Route::get("/default-code", function(Request $request) -{ - return [ - "code" => file_get_contents(base_path() . '/resources/example.cpp') - ]; -}); - Route::get("/news", function(Request $request) { $changeLog = new stdClass(); From b1c18ee1281f3fc58b2a23078ff591a7689d96a4 Mon Sep 17 00:00:00 2001 From: Moros Smith Date: Wed, 26 Jun 2024 02:24:05 -0400 Subject: [PATCH 02/50] stop using localStorage, use setStorageValue instead --- resources/js/components/EditorPanel.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/resources/js/components/EditorPanel.js b/resources/js/components/EditorPanel.js index 4dbf028..d9ec862 100644 --- a/resources/js/components/EditorPanel.js +++ b/resources/js/components/EditorPanel.js @@ -1,6 +1,6 @@ import { getUserConfiguration } from "../lib/monacoConfig"; import { configureMonacoWorkers, runCppWrapper } from "../lib/monacoWrapper"; -import { getStorageValue } from "../lib/storage"; +import { getStorageValue, setStorageValue } from "../lib/storage"; import pgetinkerCppCode from '../../example1.cpp?raw'; import * as vscode from "vscode"; @@ -132,7 +132,7 @@ export default class EditorPanel this.monacoWrapper.getEditor().onDidChangeModelContent(() => { - window.localStorage.setItem("pgetinkerCode", JSON.stringify(this.monacoWrapper.getEditor().getValue())); + setStorageValue("code", this.monacoWrapper.getEditor().getValue()); if(this.sharedFlag) { From 0a1cca705343ef7e6575627c303fb6e2fed8f35c Mon Sep 17 00:00:00 2001 From: Moros Smith Date: Wed, 26 Jun 2024 02:24:18 -0400 Subject: [PATCH 03/50] add examples 2 through 4 --- resources/example2.cpp | 76 ++++++++++++++++++++++++++++++++++++++++++ resources/example3.cpp | 76 ++++++++++++++++++++++++++++++++++++++++++ resources/example4.cpp | 76 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 228 insertions(+) create mode 100644 resources/example2.cpp create mode 100644 resources/example3.cpp create mode 100644 resources/example4.cpp diff --git a/resources/example2.cpp b/resources/example2.cpp new file mode 100644 index 0000000..228e18d --- /dev/null +++ b/resources/example2.cpp @@ -0,0 +1,76 @@ +#define OLC_PGE_APPLICATION +#include "olcPixelGameEngine.h" + +#if defined(__EMSCRIPTEN__) +#include +#define FILE_RESOLVE(url, file) emscripten_wget(url, file); emscripten_sleep(0) +#else +#define FILE_RESOLVE(url, file) +#endif + +// Override base class with your custom functionality +class Example : public olc::PixelGameEngine +{ +public: + Example() + { + // Name your application + sAppName = "Example 2"; + } + +public: + bool OnUserCreate() override + { + // Called once at the start, so create things here + + // built with emscripten, maps the url to the virtual filesystem and makes it + // available to the standard C/C++ file i/o functions without change! + // + // built with any other native toolchain, the macro does nothing and all file + // access is done just as it would in any other normal scenario. + FILE_RESOLVE("https://pit.pgetinker.com/MwpptUlwPhnc.png", "assets/gfx/broken.png"); + + renBroken.Load("assets/gfx/broken.png"); + + color = RandomColor(); + return true; + } + + bool OnUserUpdate(float fElapsedTime) override + { + // Called once per frame, draws random coloured pixels + if(GetMouse(0).bPressed) + color = RandomColor(); + + Clear(color); + DrawRect(0,0,ScreenWidth()-1, ScreenHeight()-1, olc::YELLOW); + DrawString(6, 6, "Hello, PGE", olc::BLACK); + DrawString(5, 5, "Hello, PGE", olc::WHITE); + DrawString(6, 26, "Mouse position SHOULD match\nclosely to the circle.\n\nYellow borders should ALWAYS\nbe visible\n\nLEFT MOUSE to change color.", olc::BLACK); + DrawString(5, 25, "Mouse position SHOULD match\nclosely to the circle.\n\nYellow borders should ALWAYS\nbe visible\n\nLEFT MOUSE to change color.", olc::WHITE); + + DrawSprite(5, 100, renBroken.Sprite()); + + DrawString(6, 221, GetMousePos().str(), olc::BLACK); + DrawString(5, 220, GetMousePos().str(), olc::WHITE); + FillCircle(GetMousePos(), 3, olc::RED); + Draw(GetMousePos(), olc::WHITE); + return true; + } + + olc::Pixel RandomColor() + { + return olc::Pixel(rand() % 128, rand() % 128, rand() % 128); + } + + olc::Pixel color; + olc::Renderable renBroken; +}; + +int main() +{ + Example demo; + if (demo.Construct(256, 240, 2, 2)) + demo.Start(); + return 0; +} \ No newline at end of file diff --git a/resources/example3.cpp b/resources/example3.cpp new file mode 100644 index 0000000..37ff71a --- /dev/null +++ b/resources/example3.cpp @@ -0,0 +1,76 @@ +#define OLC_PGE_APPLICATION +#include "olcPixelGameEngine.h" + +#if defined(__EMSCRIPTEN__) +#include +#define FILE_RESOLVE(url, file) emscripten_wget(url, file); emscripten_sleep(0) +#else +#define FILE_RESOLVE(url, file) +#endif + +// Override base class with your custom functionality +class Example : public olc::PixelGameEngine +{ +public: + Example() + { + // Name your application + sAppName = "Example 3"; + } + +public: + bool OnUserCreate() override + { + // Called once at the start, so create things here + + // built with emscripten, maps the url to the virtual filesystem and makes it + // available to the standard C/C++ file i/o functions without change! + // + // built with any other native toolchain, the macro does nothing and all file + // access is done just as it would in any other normal scenario. + FILE_RESOLVE("https://pit.pgetinker.com/MwpptUlwPhnc.png", "assets/gfx/broken.png"); + + renBroken.Load("assets/gfx/broken.png"); + + color = RandomColor(); + return true; + } + + bool OnUserUpdate(float fElapsedTime) override + { + // Called once per frame, draws random coloured pixels + if(GetMouse(0).bPressed) + color = RandomColor(); + + Clear(color); + DrawRect(0,0,ScreenWidth()-1, ScreenHeight()-1, olc::YELLOW); + DrawString(6, 6, "Hello, PGE", olc::BLACK); + DrawString(5, 5, "Hello, PGE", olc::WHITE); + DrawString(6, 26, "Mouse position SHOULD match\nclosely to the circle.\n\nYellow borders should ALWAYS\nbe visible\n\nLEFT MOUSE to change color.", olc::BLACK); + DrawString(5, 25, "Mouse position SHOULD match\nclosely to the circle.\n\nYellow borders should ALWAYS\nbe visible\n\nLEFT MOUSE to change color.", olc::WHITE); + + DrawSprite(5, 100, renBroken.Sprite()); + + DrawString(6, 221, GetMousePos().str(), olc::BLACK); + DrawString(5, 220, GetMousePos().str(), olc::WHITE); + FillCircle(GetMousePos(), 3, olc::RED); + Draw(GetMousePos(), olc::WHITE); + return true; + } + + olc::Pixel RandomColor() + { + return olc::Pixel(rand() % 128, rand() % 128, rand() % 128); + } + + olc::Pixel color; + olc::Renderable renBroken; +}; + +int main() +{ + Example demo; + if (demo.Construct(256, 240, 2, 2)) + demo.Start(); + return 0; +} \ No newline at end of file diff --git a/resources/example4.cpp b/resources/example4.cpp new file mode 100644 index 0000000..07b7221 --- /dev/null +++ b/resources/example4.cpp @@ -0,0 +1,76 @@ +#define OLC_PGE_APPLICATION +#include "olcPixelGameEngine.h" + +#if defined(__EMSCRIPTEN__) +#include +#define FILE_RESOLVE(url, file) emscripten_wget(url, file); emscripten_sleep(0) +#else +#define FILE_RESOLVE(url, file) +#endif + +// Override base class with your custom functionality +class Example : public olc::PixelGameEngine +{ +public: + Example() + { + // Name your application + sAppName = "Example 4"; + } + +public: + bool OnUserCreate() override + { + // Called once at the start, so create things here + + // built with emscripten, maps the url to the virtual filesystem and makes it + // available to the standard C/C++ file i/o functions without change! + // + // built with any other native toolchain, the macro does nothing and all file + // access is done just as it would in any other normal scenario. + FILE_RESOLVE("https://pit.pgetinker.com/MwpptUlwPhnc.png", "assets/gfx/broken.png"); + + renBroken.Load("assets/gfx/broken.png"); + + color = RandomColor(); + return true; + } + + bool OnUserUpdate(float fElapsedTime) override + { + // Called once per frame, draws random coloured pixels + if(GetMouse(0).bPressed) + color = RandomColor(); + + Clear(color); + DrawRect(0,0,ScreenWidth()-1, ScreenHeight()-1, olc::YELLOW); + DrawString(6, 6, "Hello, PGE", olc::BLACK); + DrawString(5, 5, "Hello, PGE", olc::WHITE); + DrawString(6, 26, "Mouse position SHOULD match\nclosely to the circle.\n\nYellow borders should ALWAYS\nbe visible\n\nLEFT MOUSE to change color.", olc::BLACK); + DrawString(5, 25, "Mouse position SHOULD match\nclosely to the circle.\n\nYellow borders should ALWAYS\nbe visible\n\nLEFT MOUSE to change color.", olc::WHITE); + + DrawSprite(5, 100, renBroken.Sprite()); + + DrawString(6, 221, GetMousePos().str(), olc::BLACK); + DrawString(5, 220, GetMousePos().str(), olc::WHITE); + FillCircle(GetMousePos(), 3, olc::RED); + Draw(GetMousePos(), olc::WHITE); + return true; + } + + olc::Pixel RandomColor() + { + return olc::Pixel(rand() % 128, rand() % 128, rand() % 128); + } + + olc::Pixel color; + olc::Renderable renBroken; +}; + +int main() +{ + Example demo; + if (demo.Construct(256, 240, 2, 2)) + demo.Start(); + return 0; +} \ No newline at end of file From 939fda89205cfe0a1100274661fcbcb0b0fd381b Mon Sep 17 00:00:00 2001 From: Moros Smith Date: Wed, 26 Jun 2024 02:25:28 -0400 Subject: [PATCH 04/50] select has label and value instead of simply just a value --- resources/js/lib/settingsDialog.js | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/resources/js/lib/settingsDialog.js b/resources/js/lib/settingsDialog.js index abc3e58..6d9c0f8 100644 --- a/resources/js/lib/settingsDialog.js +++ b/resources/js/lib/settingsDialog.js @@ -29,22 +29,22 @@ function select(label, description, valueCallback, options, initialValue) for(let i = 0; i < options.length; i++) { let option = document.createElement("option"); - option.value = options[i]; - option.innerHTML = options[i]; + option.value = options[i].value; + option.innerHTML = options[i].label; - if(options[i] == initialValue) + if(options[i].value == initialValue) { option.selected = true; } select.querySelector("select").append(option); } - + select.addEventListener("change", (event) => { valueCallback(event); }); - + return select; } @@ -158,7 +158,16 @@ export default function settingsDialog(state) state.UpdateTheme(); }, - ["dark", "light"], + [ + { + label: "Dark Theme", + value: "dark", + }, + { + label: "Light Theme", + value: "light", + } + ], getStorageValue("theme") )); From 15672ecfc49135b0fddc125ce8ee598e4f9572e0 Mon Sep 17 00:00:00 2001 From: Moros Smith Date: Wed, 26 Jun 2024 02:25:59 -0400 Subject: [PATCH 05/50] still not sure what changed, but it changed? --- resources/js/lib/settingsDialog.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/js/lib/settingsDialog.js b/resources/js/lib/settingsDialog.js index 6d9c0f8..f25c3f7 100644 --- a/resources/js/lib/settingsDialog.js +++ b/resources/js/lib/settingsDialog.js @@ -75,7 +75,7 @@ function toggle(label, description, valueCallback, initialValue) toggle.addEventListener("change", (event) => { event.preventDefault(); - valueCallback(event); + valueCallback(event); }); return toggle; From d878d1c685f94c153ce98dddfacf18045ca3aea1 Mon Sep 17 00:00:00 2001 From: Moros Smith Date: Wed, 26 Jun 2024 02:26:28 -0400 Subject: [PATCH 06/50] add button to form group in order to make consistent width, add description --- resources/js/lib/settingsDialog.js | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/resources/js/lib/settingsDialog.js b/resources/js/lib/settingsDialog.js index f25c3f7..c366f79 100644 --- a/resources/js/lib/settingsDialog.js +++ b/resources/js/lib/settingsDialog.js @@ -84,12 +84,22 @@ function toggle(label, description, valueCallback, initialValue) /** * * @param {string} label + * @param {string} description * @param {(event) => void} callback * @returns */ -function button(label, callback) +function button(label, description, callback) { fieldId++; + + let group = document.createElement("div"); + group.classList.toggle("form-group", true); + + group.innerHTML = ` +
${label}
+
${description}
+ `; + let button = document.createElement("button"); button.setAttribute("name", `button-${fieldId}`); @@ -100,7 +110,9 @@ function button(label, callback) callback(event); }); - return button; + group.append(button); + + return group; } export default function settingsDialog(state) From 0aadf4ae466a57ee4bc11faa212466d9d94371ad Mon Sep 17 00:00:00 2001 From: Moros Smith Date: Wed, 26 Jun 2024 02:26:45 -0400 Subject: [PATCH 07/50] add description to default layout button --- resources/js/lib/settingsDialog.js | 1 + 1 file changed, 1 insertion(+) diff --git a/resources/js/lib/settingsDialog.js b/resources/js/lib/settingsDialog.js index c366f79..c4417a5 100644 --- a/resources/js/lib/settingsDialog.js +++ b/resources/js/lib/settingsDialog.js @@ -147,6 +147,7 @@ export default function settingsDialog(state) dialog.querySelector(".content").append(button( "Restore Default Layout", + "If you're unhappy with the layout and want to just start over!", async(event) => { await state.switchToDefaultLayout(); From 985e04c66c1a7bdade6a67b7223c21dc0596ed84 Mon Sep 17 00:00:00 2001 From: Moros Smith Date: Wed, 26 Jun 2024 02:27:15 -0400 Subject: [PATCH 08/50] replace default code button with drop down --- resources/js/lib/settingsDialog.js | 62 +++++++++++++++++++++++++++--- 1 file changed, 56 insertions(+), 6 deletions(-) diff --git a/resources/js/lib/settingsDialog.js b/resources/js/lib/settingsDialog.js index c4417a5..1c6956f 100644 --- a/resources/js/lib/settingsDialog.js +++ b/resources/js/lib/settingsDialog.js @@ -1,6 +1,11 @@ import { createToast, ToastType } from './createToast'; import { getStorageValue, setStorageValue } from './storage'; +import exampleCode1 from '../../example1.cpp?raw'; +import exampleCode2 from '../../example2.cpp?raw'; +import exampleCode3 from '../../example3.cpp?raw'; +import exampleCode4 from '../../example4.cpp?raw'; + let fieldId = 0; /** @@ -136,15 +141,60 @@ export default function settingsDialog(state) `; - dialog.querySelector(".content").append(button( - "Load Default Code", + dialog.querySelector(".content").append(select( + "Load Example Code", + "Choose from the available examples!", (event) => { - state.defaultCode(); - createToast("Loaded default code.", ToastType.Info); - } + event.preventDefault(); + if(event.target.value !== "") + { + let code = null; + + if(event.target.value === "example1") + code = exampleCode1; + + if(event.target.value === "example2") + code = exampleCode2; + + if(event.target.value === "example3") + code = exampleCode3; + + if(event.target.value === "example4") + code = exampleCode4; + + if(code) + { + state.editorPanel.setValue(code); + state.editorPanel.reveal({ column: 1, lineNumber: 1 }); + createToast(`Set Code to ${event.target.selectedOptions[0].innerHTML}`, ToastType.Info); + } + } + }, + [ + { + label: "--Choose Example--", + value: "", + }, + { + label: "Example 1", + value: "example1", + }, + { + label: "Example 2", + value: "example2", + }, + { + label: "Example 3", + value: "example3", + }, + { + label: "Example 4", + value: "example4", + }, + ], )); - + dialog.querySelector(".content").append(button( "Restore Default Layout", "If you're unhappy with the layout and want to just start over!", From d918a42c39019975cd329083539b0eeafa504500 Mon Sep 17 00:00:00 2001 From: Moros Smith Date: Wed, 26 Jun 2024 02:27:29 -0400 Subject: [PATCH 09/50] fieldId should always refresh with each instance of the dialog --- resources/js/lib/settingsDialog.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/resources/js/lib/settingsDialog.js b/resources/js/lib/settingsDialog.js index 1c6956f..f779418 100644 --- a/resources/js/lib/settingsDialog.js +++ b/resources/js/lib/settingsDialog.js @@ -125,6 +125,8 @@ export default function settingsDialog(state) return new Promise((resolve) => { + fieldId = 0; + let dialog = document.createElement('div'); dialog.classList.toggle("dialog", "true"); From 3f29817023a03ea795d3f59c89bf2a0b9a69ba81 Mon Sep 17 00:00:00 2001 From: Moros Smith Date: Wed, 26 Jun 2024 02:28:03 -0400 Subject: [PATCH 10/50] update browser testing to account for updated UI elements --- tests/Browser/BrowserTest.php | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/tests/Browser/BrowserTest.php b/tests/Browser/BrowserTest.php index 6f71c83..c181e40 100644 --- a/tests/Browser/BrowserTest.php +++ b/tests/Browser/BrowserTest.php @@ -72,15 +72,22 @@ public function testLoadsDefaultCodeOnClick(): void $browser->assertMissing("#pgetinker-loading"); $browser->click("@settings-menu"); + $browser->waitFor(".settings-dialog"); - $browser->click('button[name="button-1"]'); + $browser->assertPresent('select[name="select-1"]'); + $browser->click('select[name="select-1"]'); + + $browser->waitFor('option[value="example1"]'); + $browser->click('option[value="example1"]'); + $browser->waitFor(".toastify"); $browser->waitUntilMissing(".toastify"); + $browser->click(".footer .ok"); $browser->waitUntilMissing(".dialog"); - + $browser->assertNotPresent(".dialog"); - $browser->assertSee("class Example : public olc::PixelGameEngine"); + $browser->assertSee('Example 1'); }); } @@ -93,11 +100,17 @@ public function testSelectsLightTheme(): void $browser->assertMissing("#pgetinker-loading"); $browser->click("@settings-menu"); - + $browser->waitFor(".settings-dialog"); + + $browser->assertPresent('select[name="select-3"]'); $browser->click('select[name="select-3"]'); + + $browser->waitFor('option[value="light"]'); $browser->click('option[value="light"]'); + $browser->waitFor(".toastify"); $browser->waitUntilMissing(".toastify"); + $browser->click(".footer .ok"); $browser->waitUntilMissing(".dialog"); From d377060a79d167558dc9376f92e751b00445ff75 Mon Sep 17 00:00:00 2001 From: Moros Smith Date: Wed, 26 Jun 2024 02:37:42 -0400 Subject: [PATCH 11/50] replace problematic macro in example codes --- resources/example1.cpp | 11 ++++++++--- resources/example2.cpp | 12 +++++++++--- resources/example3.cpp | 12 +++++++++--- resources/example4.cpp | 12 +++++++++--- 4 files changed, 35 insertions(+), 12 deletions(-) diff --git a/resources/example1.cpp b/resources/example1.cpp index 7c46f72..162d1ee 100644 --- a/resources/example1.cpp +++ b/resources/example1.cpp @@ -3,11 +3,16 @@ #if defined(__EMSCRIPTEN__) #include -#define FILE_RESOLVE(url, file) emscripten_wget(url, file); emscripten_sleep(0) -#else -#define FILE_RESOLVE(url, file) #endif +void FILE_RESOLVE(const char* url, const char* file) +{ + #if defined(__EMSCRIPTEN__) + emscripten_wget(url, file); + emscripten_sleep(0); + #endif +} + // Override base class with your custom functionality class Example : public olc::PixelGameEngine { diff --git a/resources/example2.cpp b/resources/example2.cpp index 228e18d..be8ac8e 100644 --- a/resources/example2.cpp +++ b/resources/example2.cpp @@ -3,11 +3,17 @@ #if defined(__EMSCRIPTEN__) #include -#define FILE_RESOLVE(url, file) emscripten_wget(url, file); emscripten_sleep(0) -#else -#define FILE_RESOLVE(url, file) #endif +void FILE_RESOLVE(const char* url, const char* file) +{ + #if defined(__EMSCRIPTEN__) + emscripten_wget(url, file); + emscripten_sleep(0); + #endif +} + + // Override base class with your custom functionality class Example : public olc::PixelGameEngine { diff --git a/resources/example3.cpp b/resources/example3.cpp index 37ff71a..a29e833 100644 --- a/resources/example3.cpp +++ b/resources/example3.cpp @@ -3,11 +3,17 @@ #if defined(__EMSCRIPTEN__) #include -#define FILE_RESOLVE(url, file) emscripten_wget(url, file); emscripten_sleep(0) -#else -#define FILE_RESOLVE(url, file) #endif +void FILE_RESOLVE(const char* url, const char* file) +{ + #if defined(__EMSCRIPTEN__) + emscripten_wget(url, file); + emscripten_sleep(0); + #endif +} + + // Override base class with your custom functionality class Example : public olc::PixelGameEngine { diff --git a/resources/example4.cpp b/resources/example4.cpp index 07b7221..15d9749 100644 --- a/resources/example4.cpp +++ b/resources/example4.cpp @@ -3,11 +3,17 @@ #if defined(__EMSCRIPTEN__) #include -#define FILE_RESOLVE(url, file) emscripten_wget(url, file); emscripten_sleep(0) -#else -#define FILE_RESOLVE(url, file) #endif +void FILE_RESOLVE(const char* url, const char* file) +{ + #if defined(__EMSCRIPTEN__) + emscripten_wget(url, file); + emscripten_sleep(0); + #endif +} + + // Override base class with your custom functionality class Example : public olc::PixelGameEngine { From 5ddd37615741de84b0647dece8ee5e4ee7d1a7cb Mon Sep 17 00:00:00 2001 From: Moros Smith Date: Wed, 26 Jun 2024 02:39:37 -0400 Subject: [PATCH 12/50] add 5 and 6 --- resources/example5.cpp | 82 ++++++++++++++++++++++++++++++ resources/example6.cpp | 82 ++++++++++++++++++++++++++++++ resources/js/lib/settingsDialog.js | 16 ++++++ 3 files changed, 180 insertions(+) create mode 100644 resources/example5.cpp create mode 100644 resources/example6.cpp diff --git a/resources/example5.cpp b/resources/example5.cpp new file mode 100644 index 0000000..401de4e --- /dev/null +++ b/resources/example5.cpp @@ -0,0 +1,82 @@ +#define OLC_PGE_APPLICATION +#include "olcPixelGameEngine.h" + +#if defined(__EMSCRIPTEN__) +#include +#endif + +void FILE_RESOLVE(const char* url, const char* file) +{ + #if defined(__EMSCRIPTEN__) + emscripten_wget(url, file); + emscripten_sleep(0); + #endif +} + + +// Override base class with your custom functionality +class Example : public olc::PixelGameEngine +{ +public: + Example() + { + // Name your application + sAppName = "Example 5"; + } + +public: + bool OnUserCreate() override + { + // Called once at the start, so create things here + + // built with emscripten, maps the url to the virtual filesystem and makes it + // available to the standard C/C++ file i/o functions without change! + // + // built with any other native toolchain, the macro does nothing and all file + // access is done just as it would in any other normal scenario. + FILE_RESOLVE("https://pit.pgetinker.com/MwpptUlwPhnc.png", "assets/gfx/broken.png"); + + renBroken.Load("assets/gfx/broken.png"); + + color = RandomColor(); + return true; + } + + bool OnUserUpdate(float fElapsedTime) override + { + // Called once per frame, draws random coloured pixels + if(GetMouse(0).bPressed) + color = RandomColor(); + + Clear(color); + DrawRect(0,0,ScreenWidth()-1, ScreenHeight()-1, olc::YELLOW); + DrawString(6, 6, "Hello, PGE", olc::BLACK); + DrawString(5, 5, "Hello, PGE", olc::WHITE); + DrawString(6, 26, "Mouse position SHOULD match\nclosely to the circle.\n\nYellow borders should ALWAYS\nbe visible\n\nLEFT MOUSE to change color.", olc::BLACK); + DrawString(5, 25, "Mouse position SHOULD match\nclosely to the circle.\n\nYellow borders should ALWAYS\nbe visible\n\nLEFT MOUSE to change color.", olc::WHITE); + + DrawSprite(5, 100, renBroken.Sprite()); + + DrawString(6, 221, GetMousePos().str(), olc::BLACK); + DrawString(5, 220, GetMousePos().str(), olc::WHITE); + FillCircle(GetMousePos(), 3, olc::RED); + Draw(GetMousePos(), olc::WHITE); + return true; + } + + olc::Pixel RandomColor() + { + return olc::Pixel(rand() % 128, rand() % 128, rand() % 128); + } + + olc::Pixel color; + olc::Renderable renBroken; +}; + +int main() +{ + Example demo; + if (demo.Construct(256, 240, 2, 2)) + demo.Start(); + return 0; +} \ No newline at end of file diff --git a/resources/example6.cpp b/resources/example6.cpp new file mode 100644 index 0000000..8defe58 --- /dev/null +++ b/resources/example6.cpp @@ -0,0 +1,82 @@ +#define OLC_PGE_APPLICATION +#include "olcPixelGameEngine.h" + +#if defined(__EMSCRIPTEN__) +#include +#endif + +void FILE_RESOLVE(const char* url, const char* file) +{ + #if defined(__EMSCRIPTEN__) + emscripten_wget(url, file); + emscripten_sleep(0); + #endif +} + + +// Override base class with your custom functionality +class Example : public olc::PixelGameEngine +{ +public: + Example() + { + // Name your application + sAppName = "Example 6"; + } + +public: + bool OnUserCreate() override + { + // Called once at the start, so create things here + + // built with emscripten, maps the url to the virtual filesystem and makes it + // available to the standard C/C++ file i/o functions without change! + // + // built with any other native toolchain, the macro does nothing and all file + // access is done just as it would in any other normal scenario. + FILE_RESOLVE("https://pit.pgetinker.com/MwpptUlwPhnc.png", "assets/gfx/broken.png"); + + renBroken.Load("assets/gfx/broken.png"); + + color = RandomColor(); + return true; + } + + bool OnUserUpdate(float fElapsedTime) override + { + // Called once per frame, draws random coloured pixels + if(GetMouse(0).bPressed) + color = RandomColor(); + + Clear(color); + DrawRect(0,0,ScreenWidth()-1, ScreenHeight()-1, olc::YELLOW); + DrawString(6, 6, "Hello, PGE", olc::BLACK); + DrawString(5, 5, "Hello, PGE", olc::WHITE); + DrawString(6, 26, "Mouse position SHOULD match\nclosely to the circle.\n\nYellow borders should ALWAYS\nbe visible\n\nLEFT MOUSE to change color.", olc::BLACK); + DrawString(5, 25, "Mouse position SHOULD match\nclosely to the circle.\n\nYellow borders should ALWAYS\nbe visible\n\nLEFT MOUSE to change color.", olc::WHITE); + + DrawSprite(5, 100, renBroken.Sprite()); + + DrawString(6, 221, GetMousePos().str(), olc::BLACK); + DrawString(5, 220, GetMousePos().str(), olc::WHITE); + FillCircle(GetMousePos(), 3, olc::RED); + Draw(GetMousePos(), olc::WHITE); + return true; + } + + olc::Pixel RandomColor() + { + return olc::Pixel(rand() % 128, rand() % 128, rand() % 128); + } + + olc::Pixel color; + olc::Renderable renBroken; +}; + +int main() +{ + Example demo; + if (demo.Construct(256, 240, 2, 2)) + demo.Start(); + return 0; +} \ No newline at end of file diff --git a/resources/js/lib/settingsDialog.js b/resources/js/lib/settingsDialog.js index f779418..08c0453 100644 --- a/resources/js/lib/settingsDialog.js +++ b/resources/js/lib/settingsDialog.js @@ -5,6 +5,8 @@ import exampleCode1 from '../../example1.cpp?raw'; import exampleCode2 from '../../example2.cpp?raw'; import exampleCode3 from '../../example3.cpp?raw'; import exampleCode4 from '../../example4.cpp?raw'; +import exampleCode5 from '../../example5.cpp?raw'; +import exampleCode6 from '../../example6.cpp?raw'; let fieldId = 0; @@ -165,6 +167,12 @@ export default function settingsDialog(state) if(event.target.value === "example4") code = exampleCode4; + if(event.target.value === "example5") + code = exampleCode5; + + if(event.target.value === "example6") + code = exampleCode6; + if(code) { state.editorPanel.setValue(code); @@ -194,6 +202,14 @@ export default function settingsDialog(state) label: "Example 4", value: "example4", }, + { + label: "Example 5", + value: "example5", + }, + { + label: "Example 6", + value: "example6", + }, ], )); From b68f1d80e89951b5c4682ae0e740cbdb042a4b16 Mon Sep 17 00:00:00 2001 From: Moros Smith Date: Wed, 26 Jun 2024 02:51:51 -0400 Subject: [PATCH 13/50] extend time allowed for share dialog to appear --- tests/Browser/BrowserTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Browser/BrowserTest.php b/tests/Browser/BrowserTest.php index c181e40..72f8835 100644 --- a/tests/Browser/BrowserTest.php +++ b/tests/Browser/BrowserTest.php @@ -143,7 +143,7 @@ public function testSharesOnClick(): void $browser->mouseover("@sharing-menu"); $browser->click("#share"); - $browser->waitFor(".share-dialog"); + $browser->waitFor(".share-dialog", 15); $shareUrl = $browser->value("#share-url"); $browser->visit($shareUrl); From 511b857021e4fa21b1df0114bd9aae709c597ff5 Mon Sep 17 00:00:00 2001 From: Moros Smith Date: Wed, 26 Jun 2024 02:55:00 -0400 Subject: [PATCH 14/50] update changelog --- CHANGELOG.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7946984..c8ae90f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,17 @@ All notable changes to this project will be documented in this file. Each batch It is a summary of changes that would be pertinent to the end user of the PGEtinker website. For a comprehensive history of changes made to the project, please refer to the repository's commit history. +## Unpublished + +- Changed default code to example1 +- Removed unused api endpoint for default code +- Removed unused funciton to retrieve default code +- Added Examples 1 through 6 codes +- Changed default code button to examples drop down +- Fixed fieldId should always refresh with each instance of the settings dialog +- Added button to a form group to make the width uniform on the settings dialog +- Changed select now has label and value rather than just label + ## 2024-06-25 - Fixed light theme persistence From 9c18ecc6039d8fe60891a1e0b14a3839225a81a6 Mon Sep 17 00:00:00 2001 From: Moros Smith Date: Wed, 26 Jun 2024 22:22:53 -0400 Subject: [PATCH 15/50] add examples menu to navbar styles --- resources/css/app/navbar.scss | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/resources/css/app/navbar.scss b/resources/css/app/navbar.scss index 4010926..3bfd1cc 100644 --- a/resources/css/app/navbar.scss +++ b/resources/css/app/navbar.scss @@ -108,11 +108,12 @@ } } -@media screen and (min-width: 761px) and (max-width: 900px) { +@media screen and (min-width: 761px) and (max-width: 1024px) { #header { nav { .menu { - &.left-menu { + &.left-menu, + &.right-menu { .item > a span { display: none; } @@ -130,6 +131,10 @@ width: 100%; } + #examples-menu { + display: none; + } + #settings-menu { order: 1; } From e739f9c6de8785e2276016a64219f3a23e6c6335 Mon Sep 17 00:00:00 2001 From: Moros Smith Date: Wed, 26 Jun 2024 22:23:42 -0400 Subject: [PATCH 16/50] switch to new examples code --- resources/js/components/EditorPanel.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/resources/js/components/EditorPanel.js b/resources/js/components/EditorPanel.js index d9ec862..efbab8f 100644 --- a/resources/js/components/EditorPanel.js +++ b/resources/js/components/EditorPanel.js @@ -1,7 +1,7 @@ +import examples from "../lib/exampleCodes"; import { getUserConfiguration } from "../lib/monacoConfig"; import { configureMonacoWorkers, runCppWrapper } from "../lib/monacoWrapper"; import { getStorageValue, setStorageValue } from "../lib/storage"; -import pgetinkerCppCode from '../../example1.cpp?raw'; import * as vscode from "vscode"; export default class EditorPanel @@ -89,7 +89,7 @@ export default class EditorPanel } else { - code = pgetinkerCppCode; + code = examples.code1.code; } /** From cc0c740edcca7c78fefe8d44d808382bd97acb60 Mon Sep 17 00:00:00 2001 From: Moros Smith Date: Wed, 26 Jun 2024 22:24:04 -0400 Subject: [PATCH 17/50] add setToExample function to quickly switch to an example code --- resources/js/components/EditorPanel.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/resources/js/components/EditorPanel.js b/resources/js/components/EditorPanel.js index efbab8f..8e48743 100644 --- a/resources/js/components/EditorPanel.js +++ b/resources/js/components/EditorPanel.js @@ -3,6 +3,7 @@ import { getUserConfiguration } from "../lib/monacoConfig"; import { configureMonacoWorkers, runCppWrapper } from "../lib/monacoWrapper"; import { getStorageValue, setStorageValue } from "../lib/storage"; import * as vscode from "vscode"; +import { createToast, ToastType } from '../lib/createToast'; export default class EditorPanel { @@ -49,6 +50,21 @@ export default class EditorPanel this.monacoWrapper.getEditor().setValue(value); } + setToExample(key) + { + const keys = Object.keys(examples); + for(let i = 0; i < keys.length; i++) + { + if(keys[i] === key) + { + this.state.editorPanel.setValue(examples[key].code); + this.state.editorPanel.reveal({ column: 1, lineNumber: 1 }); + createToast(`Set Code to ${examples[key].label}`, ToastType.Info); + return; + } + } + } + async onPreInit() { this.monacoWrapper = await runCppWrapper(); From 9d3e52c68652f4e3b258b86ee7437a05120538d7 Mon Sep 17 00:00:00 2001 From: Moros Smith Date: Wed, 26 Jun 2024 22:24:10 -0400 Subject: [PATCH 18/50] add example codes --- resources/js/lib/exampleCodes.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 resources/js/lib/exampleCodes.js diff --git a/resources/js/lib/exampleCodes.js b/resources/js/lib/exampleCodes.js new file mode 100644 index 0000000..878594d --- /dev/null +++ b/resources/js/lib/exampleCodes.js @@ -0,0 +1,17 @@ +import code1 from '../../example1.cpp?raw'; +import code2 from '../../example2.cpp?raw'; +import code3 from '../../example3.cpp?raw'; +import code4 from '../../example4.cpp?raw'; +import code5 from '../../example5.cpp?raw'; +import code6 from '../../example6.cpp?raw'; + +const examples = { + code1: { code: code1, label: "Example 1", }, + code2: { code: code2, label: "Example 2", }, + code3: { code: code3, label: "Example 3", }, + code4: { code: code4, label: "Example 4", }, + code5: { code: code5, label: "Example 5", }, + code6: { code: code6, label: "Example 6", }, +}; + +export default examples; From 027783c4edbf2cb649db8e74ac3467945c10eea7 Mon Sep 17 00:00:00 2001 From: Moros Smith Date: Wed, 26 Jun 2024 22:24:22 -0400 Subject: [PATCH 19/50] add example codes --- resources/example2.cpp | 1 - resources/example3.cpp | 1 - resources/example4.cpp | 1 - resources/example5.cpp | 1 - resources/example6.cpp | 1 - 5 files changed, 5 deletions(-) diff --git a/resources/example2.cpp b/resources/example2.cpp index be8ac8e..a4d1f4c 100644 --- a/resources/example2.cpp +++ b/resources/example2.cpp @@ -13,7 +13,6 @@ void FILE_RESOLVE(const char* url, const char* file) #endif } - // Override base class with your custom functionality class Example : public olc::PixelGameEngine { diff --git a/resources/example3.cpp b/resources/example3.cpp index a29e833..6f016b9 100644 --- a/resources/example3.cpp +++ b/resources/example3.cpp @@ -13,7 +13,6 @@ void FILE_RESOLVE(const char* url, const char* file) #endif } - // Override base class with your custom functionality class Example : public olc::PixelGameEngine { diff --git a/resources/example4.cpp b/resources/example4.cpp index 15d9749..51734b0 100644 --- a/resources/example4.cpp +++ b/resources/example4.cpp @@ -13,7 +13,6 @@ void FILE_RESOLVE(const char* url, const char* file) #endif } - // Override base class with your custom functionality class Example : public olc::PixelGameEngine { diff --git a/resources/example5.cpp b/resources/example5.cpp index 401de4e..61bc153 100644 --- a/resources/example5.cpp +++ b/resources/example5.cpp @@ -13,7 +13,6 @@ void FILE_RESOLVE(const char* url, const char* file) #endif } - // Override base class with your custom functionality class Example : public olc::PixelGameEngine { diff --git a/resources/example6.cpp b/resources/example6.cpp index 8defe58..04463ef 100644 --- a/resources/example6.cpp +++ b/resources/example6.cpp @@ -13,7 +13,6 @@ void FILE_RESOLVE(const char* url, const char* file) #endif } - // Override base class with your custom functionality class Example : public olc::PixelGameEngine { From 86e7d8376eb0e9e69ac09e8e2f9f4168a07a59fb Mon Sep 17 00:00:00 2001 From: Moros Smith Date: Wed, 26 Jun 2024 22:24:47 -0400 Subject: [PATCH 20/50] add examples menu/submenu --- resources/views/home.blade.php | 38 ++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/resources/views/home.blade.php b/resources/views/home.blade.php index 5758216..ac7350b 100644 --- a/resources/views/home.blade.php +++ b/resources/views/home.blade.php @@ -56,6 +56,44 @@ Settings +
  • + + + Examples + + +
  • From 5576f11142b70b72c6435d42a06feb35b4dae253 Mon Sep 17 00:00:00 2001 From: Moros Smith Date: Wed, 26 Jun 2024 22:24:57 -0400 Subject: [PATCH 21/50] add lightbulb icon --- resources/js/lib/lucide.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/resources/js/lib/lucide.js b/resources/js/lib/lucide.js index e3727fa..772a4af 100644 --- a/resources/js/lib/lucide.js +++ b/resources/js/lib/lucide.js @@ -17,7 +17,8 @@ import { SunMoon, UndoDot, Youtube, - Link, + Link, + Lightbulb, } from 'lucide'; createIcons({ @@ -31,6 +32,7 @@ createIcons({ Download, ExternalLink, Github, + Lightbulb, Link, Menu, Newspaper, From 3782d8c649c87bf0b348174b96dc26d95cb253f2 Mon Sep 17 00:00:00 2001 From: Moros Smith Date: Wed, 26 Jun 2024 22:25:13 -0400 Subject: [PATCH 22/50] remove example code stuff from settings dialog --- resources/js/lib/settingsDialog.js | 76 ------------------------------ 1 file changed, 76 deletions(-) diff --git a/resources/js/lib/settingsDialog.js b/resources/js/lib/settingsDialog.js index 08c0453..891aa0f 100644 --- a/resources/js/lib/settingsDialog.js +++ b/resources/js/lib/settingsDialog.js @@ -1,13 +1,6 @@ import { createToast, ToastType } from './createToast'; import { getStorageValue, setStorageValue } from './storage'; -import exampleCode1 from '../../example1.cpp?raw'; -import exampleCode2 from '../../example2.cpp?raw'; -import exampleCode3 from '../../example3.cpp?raw'; -import exampleCode4 from '../../example4.cpp?raw'; -import exampleCode5 from '../../example5.cpp?raw'; -import exampleCode6 from '../../example6.cpp?raw'; - let fieldId = 0; /** @@ -144,75 +137,6 @@ export default function settingsDialog(state) `; - - dialog.querySelector(".content").append(select( - "Load Example Code", - "Choose from the available examples!", - (event) => - { - event.preventDefault(); - if(event.target.value !== "") - { - let code = null; - - if(event.target.value === "example1") - code = exampleCode1; - - if(event.target.value === "example2") - code = exampleCode2; - - if(event.target.value === "example3") - code = exampleCode3; - - if(event.target.value === "example4") - code = exampleCode4; - - if(event.target.value === "example5") - code = exampleCode5; - - if(event.target.value === "example6") - code = exampleCode6; - - if(code) - { - state.editorPanel.setValue(code); - state.editorPanel.reveal({ column: 1, lineNumber: 1 }); - createToast(`Set Code to ${event.target.selectedOptions[0].innerHTML}`, ToastType.Info); - } - } - }, - [ - { - label: "--Choose Example--", - value: "", - }, - { - label: "Example 1", - value: "example1", - }, - { - label: "Example 2", - value: "example2", - }, - { - label: "Example 3", - value: "example3", - }, - { - label: "Example 4", - value: "example4", - }, - { - label: "Example 5", - value: "example5", - }, - { - label: "Example 6", - value: "example6", - }, - ], - )); - dialog.querySelector(".content").append(button( "Restore Default Layout", "If you're unhappy with the layout and want to just start over!", From 5c8d832f687ea13eaeccc987166d085f6c08bbd6 Mon Sep 17 00:00:00 2001 From: Moros Smith Date: Wed, 26 Jun 2024 22:25:52 -0400 Subject: [PATCH 23/50] dismiss dialog before calling settings dialog --- resources/js/lib/mobileMenuDialog.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/resources/js/lib/mobileMenuDialog.js b/resources/js/lib/mobileMenuDialog.js index 4fcc89b..5787679 100644 --- a/resources/js/lib/mobileMenuDialog.js +++ b/resources/js/lib/mobileMenuDialog.js @@ -112,11 +112,10 @@ export default function mobileMenuDialog(state) dialog.querySelector("#settings-menu").addEventListener("click", (event) => { event.preventDefault(); - settingsDialog(state).then(() => - { - dialog.remove(); - resolve() - }); + dialog.remove(); + resolve() + + settingsDialog(state); }); dialog.querySelector("#news-and-updates").addEventListener("click", (event) => From a9649a1e5771a54bdf144096df29a931423f5b51 Mon Sep 17 00:00:00 2001 From: Moros Smith Date: Wed, 26 Jun 2024 22:26:09 -0400 Subject: [PATCH 24/50] dismiss dialog before calling news dialog --- resources/js/lib/mobileMenuDialog.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/resources/js/lib/mobileMenuDialog.js b/resources/js/lib/mobileMenuDialog.js index 5787679..b2de0dc 100644 --- a/resources/js/lib/mobileMenuDialog.js +++ b/resources/js/lib/mobileMenuDialog.js @@ -121,11 +121,10 @@ export default function mobileMenuDialog(state) dialog.querySelector("#news-and-updates").addEventListener("click", (event) => { event.preventDefault(); - newsDialog().then(() => - { - dialog.remove(); - resolve() - }); + dialog.remove(); + resolve(); + + newsDialog(); }); dialog.querySelector("#supporters").addEventListener("click", (event) => From c3b6a5ab76772e1f4b8306d4b87817cca394f835 Mon Sep 17 00:00:00 2001 From: Moros Smith Date: Wed, 26 Jun 2024 22:26:22 -0400 Subject: [PATCH 25/50] dismiss dialog before calling supporters dialog --- resources/js/lib/mobileMenuDialog.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/resources/js/lib/mobileMenuDialog.js b/resources/js/lib/mobileMenuDialog.js index b2de0dc..f37b967 100644 --- a/resources/js/lib/mobileMenuDialog.js +++ b/resources/js/lib/mobileMenuDialog.js @@ -130,11 +130,10 @@ export default function mobileMenuDialog(state) dialog.querySelector("#supporters").addEventListener("click", (event) => { event.preventDefault(); - supportersDialog().then(() => - { - dialog.remove(); - resolve(); - }); + dialog.remove(); + resolve(); + + supportersDialog(); }); dialog.querySelector("#download").addEventListener("click", (event) => From e26b62bdbb4b23754a7417f77cd6e3bf5edaa2ea Mon Sep 17 00:00:00 2001 From: Moros Smith Date: Wed, 26 Jun 2024 22:26:44 -0400 Subject: [PATCH 26/50] dismiss dialog before calling share --- resources/js/lib/mobileMenuDialog.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/resources/js/lib/mobileMenuDialog.js b/resources/js/lib/mobileMenuDialog.js index f37b967..e6d6f64 100644 --- a/resources/js/lib/mobileMenuDialog.js +++ b/resources/js/lib/mobileMenuDialog.js @@ -147,9 +147,10 @@ export default function mobileMenuDialog(state) dialog.querySelector("#share").addEventListener("click", (event) => { event.preventDefault(); - state.share(); dialog.remove(); resolve(); + + state.share(); }); dialog.querySelector(".ok").addEventListener("click", (event) => From 8f09d064f2118c5aa45619c18d951245ca034931 Mon Sep 17 00:00:00 2001 From: Moros Smith Date: Wed, 26 Jun 2024 22:26:59 -0400 Subject: [PATCH 27/50] forgot a little event prevent default! --- resources/js/lib/mobileMenuDialog.js | 1 + 1 file changed, 1 insertion(+) diff --git a/resources/js/lib/mobileMenuDialog.js b/resources/js/lib/mobileMenuDialog.js index e6d6f64..6c6fb09 100644 --- a/resources/js/lib/mobileMenuDialog.js +++ b/resources/js/lib/mobileMenuDialog.js @@ -155,6 +155,7 @@ export default function mobileMenuDialog(state) dialog.querySelector(".ok").addEventListener("click", (event) => { + event.preventDefault(); dialog.remove(); resolve(); }); From 1d86812f37137fa081ca7c5256a1eb5b42775461 Mon Sep 17 00:00:00 2001 From: Moros Smith Date: Wed, 26 Jun 2024 22:27:14 -0400 Subject: [PATCH 28/50] a whole lot of unused code --- resources/js/lib/mobileMenuDialog.js | 48 ---------------------------- 1 file changed, 48 deletions(-) diff --git a/resources/js/lib/mobileMenuDialog.js b/resources/js/lib/mobileMenuDialog.js index 6c6fb09..7c6195b 100644 --- a/resources/js/lib/mobileMenuDialog.js +++ b/resources/js/lib/mobileMenuDialog.js @@ -163,51 +163,3 @@ export default function mobileMenuDialog(state) document.body.appendChild(dialog); }); } - - - // Default Code Button - // document.querySelector("#default-code")!.addEventListener("click", (event) => - // { - // event.preventDefault(); - - // axios.get("/api/default-code").then((response) => - // { - // this.editorPanel.setValue(response.data.code); - // this.editorPanel.reveal({ - // column: 1, - // lineNumber: 1, - // }); - // }).catch((reason) => console.log(reason)); - // }); - - // Toggle Theme Button - // document.querySelector("#toggle-theme")!.addEventListener("click", (event) => - // { - // event.preventDefault(); - - // if(this.theme === "dark") - // this.theme = "light"; - // else - // this.theme = "dark"; - - // this.UpdateTheme(); - // }); - - // Default Layout - // document.querySelector("#default-layout")!.addEventListener("click", async(event) => - // { - // event.preventDefault(); - // await this.editorPanel.onDestroy(); - - // this.layout.destroy(); - - // this.layoutConfig = defaultLandscapeLayout; - - // if(document.body.clientWidth <= 750) - // { - // console.log("chose portrait layout"); - // this.layoutConfig = defaultPortraitLayout; - // } - - // this.SetupLayout(); - // }); \ No newline at end of file From 1bd0640e38d7339aa8371be54356ff806620d82b Mon Sep 17 00:00:00 2001 From: Moros Smith Date: Wed, 26 Jun 2024 22:27:50 -0400 Subject: [PATCH 29/50] add examples to the mobile menu dialog --- resources/js/lib/examplesMenuDialog.js | 60 ++++++++++++++++++++++++++ resources/js/lib/mobileMenuDialog.js | 13 ++++++ 2 files changed, 73 insertions(+) create mode 100644 resources/js/lib/examplesMenuDialog.js diff --git a/resources/js/lib/examplesMenuDialog.js b/resources/js/lib/examplesMenuDialog.js new file mode 100644 index 0000000..75cb462 --- /dev/null +++ b/resources/js/lib/examplesMenuDialog.js @@ -0,0 +1,60 @@ + +export default function examplesMenuDialog(state) +{ + return new Promise((resolve) => + { + let dialog = document.createElement('div'); + + dialog.classList.toggle("dialog", "true"); + dialog.classList.toggle("examples-menu-dialog", "true"); + + dialog.innerHTML = ` + `; + + + dialog.querySelectorAll("#examples-menu a").forEach((item) => + { + item.addEventListener("click", () => + { + let selectedExample = item.getAttribute("data-example"); + if(selectedExample) + { + state.editorPanel.setToExample(selectedExample); + dialog.remove(); + resolve(); + } + }); + }); + + dialog.querySelector(".ok").addEventListener("click", (event) => + { + event.preventDefault(); + dialog.remove(); + resolve(); + }); + + document.body.appendChild(dialog); + }); +} diff --git a/resources/js/lib/mobileMenuDialog.js b/resources/js/lib/mobileMenuDialog.js index 7c6195b..2d75b5d 100644 --- a/resources/js/lib/mobileMenuDialog.js +++ b/resources/js/lib/mobileMenuDialog.js @@ -2,6 +2,7 @@ import settingsDialog from "./settingsDialog"; import newsDialog from "./newsDialog"; import supportersDialog from "./supportersDialog"; import version from "./version"; +import examplesMenuDialog from "./examplesMenuDialog"; export default function mobileMenuDialog(state) { @@ -23,6 +24,9 @@ export default function mobileMenuDialog(state)
  • Settings
  • +
  • + Load an Example +
  • Help @@ -118,6 +122,15 @@ export default function mobileMenuDialog(state) settingsDialog(state); }); + dialog.querySelector("#examples-menu").addEventListener("click", (event) => + { + event.preventDefault(); + dialog.remove(); + resolve(); + examplesMenuDialog(state); + }); + + dialog.querySelector("#news-and-updates").addEventListener("click", (event) => { event.preventDefault(); From 0c91c1014baaf58f3988e0a32b77a907371f2093 Mon Sep 17 00:00:00 2001 From: Moros Smith Date: Wed, 26 Jun 2024 22:28:06 -0400 Subject: [PATCH 30/50] load examples when they're clicked --- resources/js/app.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/resources/js/app.ts b/resources/js/app.ts index 82bf4a0..82c1010 100644 --- a/resources/js/app.ts +++ b/resources/js/app.ts @@ -84,6 +84,18 @@ export default class PGEtinker settingsDialog(this); }); + document.querySelectorAll("#examples-menu a").forEach((item) => + { + item.addEventListener("click", () => + { + let selectedExample = item.getAttribute("data-example"); + if(selectedExample) + { + this.editorPanel.setToExample(selectedExample); + } + }); + }); + // Download Button document.querySelector("#download")?.addEventListener("click", (event) => { From 7b11cde33e5c274f00cd6a3bdeb673e6bd8166b5 Mon Sep 17 00:00:00 2001 From: Moros Smith Date: Thu, 27 Jun 2024 03:15:23 -0400 Subject: [PATCH 31/50] change default code to example code and make appropriate changes --- tests/Browser/BrowserTest.php | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/tests/Browser/BrowserTest.php b/tests/Browser/BrowserTest.php index 72f8835..b04596f 100644 --- a/tests/Browser/BrowserTest.php +++ b/tests/Browser/BrowserTest.php @@ -63,7 +63,7 @@ public function testDismissesNewsAndUpdates(): void }); } - public function testLoadsDefaultCodeOnClick(): void + public function testLoadsExampleCodeOnClick(): void { $this->browse(function(Browser $browser) { @@ -71,22 +71,14 @@ public function testLoadsDefaultCodeOnClick(): void $browser->waitUntilMissing("#pgetinker-loading", 10); $browser->assertMissing("#pgetinker-loading"); - $browser->click("@settings-menu"); - $browser->waitFor(".settings-dialog"); + $browser->click("@examples-menu"); - $browser->assertPresent('select[name="select-1"]'); - $browser->click('select[name="select-1"]'); - - $browser->waitFor('option[value="example1"]'); - $browser->click('option[value="example1"]'); + $browser->waitFor("@examples-menu .submenu"); + $browser->click('a[data-example="code1"]'); $browser->waitFor(".toastify"); $browser->waitUntilMissing(".toastify"); - $browser->click(".footer .ok"); - $browser->waitUntilMissing(".dialog"); - - $browser->assertNotPresent(".dialog"); $browser->assertSee('Example 1'); }); } @@ -102,8 +94,8 @@ public function testSelectsLightTheme(): void $browser->click("@settings-menu"); $browser->waitFor(".settings-dialog"); - $browser->assertPresent('select[name="select-3"]'); - $browser->click('select[name="select-3"]'); + $browser->assertPresent('select[name="select-2"]'); + $browser->click('select[name="select-2"]'); $browser->waitFor('option[value="light"]'); $browser->click('option[value="light"]'); From 5d7eecfbda3ccfdf25af74f71b200fb289c12106 Mon Sep 17 00:00:00 2001 From: Moros Smith Date: Thu, 27 Jun 2024 03:26:01 -0400 Subject: [PATCH 32/50] dusk test config --- phpunit.dusk.xml | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 phpunit.dusk.xml diff --git a/phpunit.dusk.xml b/phpunit.dusk.xml new file mode 100644 index 0000000..24fbe45 --- /dev/null +++ b/phpunit.dusk.xml @@ -0,0 +1,15 @@ + + + + + ./tests/Browser + + + From a83ba81c3df65d8ea07eb6d7ee7899f683f83d66 Mon Sep 17 00:00:00 2001 From: Moros Smith Date: Thu, 27 Jun 2024 12:23:34 -0400 Subject: [PATCH 33/50] move miniaudio.c to .cpp to silence annoying log --- third_party/v0.02/include/{miniaudio.c => miniaudio.cpp} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename third_party/v0.02/include/{miniaudio.c => miniaudio.cpp} (100%) diff --git a/third_party/v0.02/include/miniaudio.c b/third_party/v0.02/include/miniaudio.cpp similarity index 100% rename from third_party/v0.02/include/miniaudio.c rename to third_party/v0.02/include/miniaudio.cpp From aa516e1a141f981f21c3edfd5bf80175b6b4b735 Mon Sep 17 00:00:00 2001 From: Moros Smith Date: Thu, 27 Jun 2024 12:23:44 -0400 Subject: [PATCH 34/50] update build scripts --- third_party/v0.01/build.sh | 22 ---------------------- third_party/v0.02/build.sh | 2 +- 2 files changed, 1 insertion(+), 23 deletions(-) diff --git a/third_party/v0.01/build.sh b/third_party/v0.01/build.sh index beb4695..0c128ae 100644 --- a/third_party/v0.01/build.sh +++ b/third_party/v0.01/build.sh @@ -63,25 +63,3 @@ if [ ! -e ./lib/olcSoundWaveEngine.o ] ; then echo Building olcSoundWaveEngine.o em++ -c -std=c++20 $INCLUDES ./include/olcSoundWaveEngine/olcSoundWaveEngine.cpp -o ./lib/olcSoundWaveEngine.o fi - -echo Building Monoaco\'s model -cat include/olcPixelGameEngine/olcPixelGameEngine.h > model.h - -cat include/olcPixelGameEngine/extensions/olcPGEX_Graphics2D.h >> model.h -cat include/olcPixelGameEngine/extensions/olcPGEX_Graphics3D.h >> model.h -cat include/olcPixelGameEngine/extensions/olcPGEX_Network.h >> model.h -cat include/olcPixelGameEngine/extensions/olcPGEX_PopUpMenu.h >> model.h -cat include/olcPixelGameEngine/extensions/olcPGEX_QuickGUI.h >> model.h -cat include/olcPixelGameEngine/extensions/olcPGEX_RayCastWorld.h >> model.h -cat include/olcPixelGameEngine/extensions/olcPGEX_Sound.h >> model.h -cat include/olcPixelGameEngine/extensions/olcPGEX_SplashScreen.h >> model.h -cat include/olcPixelGameEngine/extensions/olcPGEX_TransformedView.h >> model.h -cat include/olcPixelGameEngine/extensions/olcPGEX_Wireframe.h >> model.h -cat include/olcPixelGameEngine/utilities/olcUTIL_Animate2D.h >> model.h -cat include/olcPixelGameEngine/utilities/olcUTIL_Camera2D.h >> model.h -cat include/olcPixelGameEngine/utilities/olcUTIL_Container.h >> model.h -cat include/olcPixelGameEngine/utilities/olcUTIL_DataFile.h >> model.h -cat include/olcPixelGameEngine/utilities/olcUTIL_Geometry2D.h >> model.h -cat include/olcPixelGameEngine/utilities/olcUTIL_Palette.h >> model.h -cat include/olcPixelGameEngine/utilities/olcUTIL_QuadTree.h >> model.h -cat include/olcSoundWaveEngine/olcSoundWaveEngine.h >> model.h diff --git a/third_party/v0.02/build.sh b/third_party/v0.02/build.sh index 9bcc0f3..d6b0480 100644 --- a/third_party/v0.02/build.sh +++ b/third_party/v0.02/build.sh @@ -72,7 +72,7 @@ fi # build miniaudio if [ ! -e ./lib/miniaudio.o ] ; then echo Building miniaudio.o - em++ -c -std=c++20 $INCLUDES ./include/miniaudio.c -o ./lib/miniaudio.o + em++ -c -std=c++20 $INCLUDES ./include/miniaudio.cpp -o ./lib/miniaudio.o fi # build olcPGEX_MiniAudio From 530c70cd047f34e2d088c364a46cd4fe6ece1df3 Mon Sep 17 00:00:00 2001 From: Moros Smith Date: Fri, 28 Jun 2024 01:38:51 -0400 Subject: [PATCH 35/50] don't add metadata to the example code loader --- resources/js/lib/exampleCodes.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/resources/js/lib/exampleCodes.js b/resources/js/lib/exampleCodes.js index 878594d..7d275b2 100644 --- a/resources/js/lib/exampleCodes.js +++ b/resources/js/lib/exampleCodes.js @@ -6,12 +6,12 @@ import code5 from '../../example5.cpp?raw'; import code6 from '../../example6.cpp?raw'; const examples = { - code1: { code: code1, label: "Example 1", }, - code2: { code: code2, label: "Example 2", }, - code3: { code: code3, label: "Example 3", }, - code4: { code: code4, label: "Example 4", }, - code5: { code: code5, label: "Example 5", }, - code6: { code: code6, label: "Example 6", }, + code1, + code2, + code3, + code4, + code5, + code6, }; export default examples; From 01fb5868b54a421ef00ee60e8a0b18ac5d224928 Mon Sep 17 00:00:00 2001 From: Moros Smith Date: Fri, 28 Jun 2024 01:39:16 -0400 Subject: [PATCH 36/50] revamp setToExample to use codeId and codeName instead of using metadata from example loader --- resources/js/components/EditorPanel.js | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/resources/js/components/EditorPanel.js b/resources/js/components/EditorPanel.js index 8e48743..9437924 100644 --- a/resources/js/components/EditorPanel.js +++ b/resources/js/components/EditorPanel.js @@ -50,16 +50,22 @@ export default class EditorPanel this.monacoWrapper.getEditor().setValue(value); } - setToExample(key) + setToExample(codeId, codeName) { - const keys = Object.keys(examples); - for(let i = 0; i < keys.length; i++) + const codeIds = Object.keys(examples); + for(let i = 0; i < codeIds.length; i++) { - if(keys[i] === key) + if(codeIds[i] === codeId) { - this.state.editorPanel.setValue(examples[key].code); + this.state.editorPanel.setValue(examples[codeId]); this.state.editorPanel.reveal({ column: 1, lineNumber: 1 }); - createToast(`Set Code to ${examples[key].label}`, ToastType.Info); + + if(this.state.playerPanel.running) + { + document.querySelector("#start-stop").dispatchEvent(new Event("click")); + } + + createToast(`Set Code to ${codeName}`, ToastType.Info); return; } } From 8af2c6d2926604a34591950adaca36f5aa2f0a54 Mon Sep 17 00:00:00 2001 From: Moros Smith Date: Fri, 28 Jun 2024 01:39:48 -0400 Subject: [PATCH 37/50] use single template for example menu, easier to keep it all straight --- resources/views/home.blade.php | 43 +++-------------------- resources/views/shared/examples.blade.php | 39 ++++++++++++++++++++ 2 files changed, 44 insertions(+), 38 deletions(-) create mode 100644 resources/views/shared/examples.blade.php diff --git a/resources/views/home.blade.php b/resources/views/home.blade.php index ac7350b..0971654 100644 --- a/resources/views/home.blade.php +++ b/resources/views/home.blade.php @@ -56,44 +56,7 @@ Settings
  • -
  • - - - Examples - - -
  • + @include("shared.examples")
  • @@ -228,6 +191,10 @@ + + @include("shared.analytics") \ No newline at end of file diff --git a/resources/views/shared/examples.blade.php b/resources/views/shared/examples.blade.php new file mode 100644 index 0000000..3a24122 --- /dev/null +++ b/resources/views/shared/examples.blade.php @@ -0,0 +1,39 @@ +
  • + + + Examples + + +
  • + From 2b9a51b5bebca8aa8a77fe57edd7e5becc253f93 Mon Sep 17 00:00:00 2001 From: Moros Smith Date: Fri, 28 Jun 2024 01:40:06 -0400 Subject: [PATCH 38/50] use template in mobile example menu --- resources/js/lib/examplesMenuDialog.js | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/resources/js/lib/examplesMenuDialog.js b/resources/js/lib/examplesMenuDialog.js index 75cb462..746abdc 100644 --- a/resources/js/lib/examplesMenuDialog.js +++ b/resources/js/lib/examplesMenuDialog.js @@ -3,6 +3,9 @@ export default function examplesMenuDialog(state) { return new Promise((resolve) => { + // exmaples menu template + const examplesMenu = document.querySelector('#examples').content.cloneNode(true); + let dialog = document.createElement('div'); dialog.classList.toggle("dialog", "true"); @@ -13,19 +16,6 @@ export default function examplesMenuDialog(state)
    Choose an Example
    `; + dialog.querySelector('.menu').append(examplesMenu); dialog.querySelectorAll("#examples-menu a").forEach((item) => { item.addEventListener("click", () => { - let selectedExample = item.getAttribute("data-example"); - if(selectedExample) + let selectedId = item.getAttribute("data-code-id"); + let selectedName = item.innerText; + + if(selectedId) { - state.editorPanel.setToExample(selectedExample); + state.editorPanel.setToExample(selectedId, selectedName); dialog.remove(); resolve(); } From e4ed87c8f6e6af3dc7091ef4d6f31d1f93d115cf Mon Sep 17 00:00:00 2001 From: Moros Smith Date: Fri, 28 Jun 2024 01:40:56 -0400 Subject: [PATCH 39/50] use innerTExt for the code name, switch example to code-id --- resources/js/app.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/resources/js/app.ts b/resources/js/app.ts index 82c1010..3fed0dd 100644 --- a/resources/js/app.ts +++ b/resources/js/app.ts @@ -88,10 +88,12 @@ export default class PGEtinker { item.addEventListener("click", () => { - let selectedExample = item.getAttribute("data-example"); - if(selectedExample) + let selectedId = item.getAttribute("data-code-id"); + let selectedName = (item as HTMLAnchorElement).innerText; + + if(selectedId) { - this.editorPanel.setToExample(selectedExample); + this.editorPanel.setToExample(selectedId, selectedName); } }); }); From cfce24fc7fe1b2b078afc13311b448de8385694c Mon Sep 17 00:00:00 2001 From: Moros Smith Date: Fri, 28 Jun 2024 01:42:05 -0400 Subject: [PATCH 40/50] example1 is now the PGEtinker classic example --- resources/example1.cpp | 76 +++++++++++++++++++++++++++++++----------- 1 file changed, 57 insertions(+), 19 deletions(-) diff --git a/resources/example1.cpp b/resources/example1.cpp index 162d1ee..420f665 100644 --- a/resources/example1.cpp +++ b/resources/example1.cpp @@ -5,6 +5,12 @@ #include #endif +// EMSCRIPTEN ONLY! +// +// At runtime, this function attempts to load a file +// from the provided URL, and maps it to emscripten's +// filesystem. You can then use the file in any C/C++ +// filesystem function as if it were on the local disk. void FILE_RESOLVE(const char* url, const char* file) { #if defined(__EMSCRIPTEN__) @@ -20,62 +26,94 @@ class Example : public olc::PixelGameEngine Example() { // Name your application - sAppName = "Example 1"; + sAppName = "PGEtinker Classic Example"; } public: + + // OnUserCreate is Called once at the start and + // is where you do things like load files and + // initilize variables. bool OnUserCreate() override { - // Called once at the start, so create things here - - // built with emscripten, maps the url to the virtual filesystem and makes it - // available to the standard C/C++ file i/o functions without change! - // - // built with any other native toolchain, the macro does nothing and all file - // access is done just as it would in any other normal scenario. + // load "assets/gfx/broken.png" from a URL FILE_RESOLVE("https://pit.pgetinker.com/MwpptUlwPhnc.png", "assets/gfx/broken.png"); - renBroken.Load("assets/gfx/broken.png"); + renImageFromUrl.Load("assets/gfx/broken.png"); color = RandomColor(); return true; } + // OnUserUpdate is called once per frame and + // is where you draw things to the screen bool OnUserUpdate(float fElapsedTime) override { - // Called once per frame, draws random coloured pixels + // when you left click the mouse if(GetMouse(0).bPressed) + { + // change the color color = RandomColor(); - + + // print out the current mouse position (x, y) + std::cout << GetMousePos() << "\n"; + } + + // clear the screen to the provided color Clear(color); + + // Draw the yellow outline DrawRect(0,0,ScreenWidth()-1, ScreenHeight()-1, olc::YELLOW); - DrawString(6, 6, "Hello, PGE", olc::BLACK); - DrawString(5, 5, "Hello, PGE", olc::WHITE); - DrawString(6, 26, "Mouse position SHOULD match\nclosely to the circle.\n\nYellow borders should ALWAYS\nbe visible\n\nLEFT MOUSE to change color.", olc::BLACK); - DrawString(5, 25, "Mouse position SHOULD match\nclosely to the circle.\n\nYellow borders should ALWAYS\nbe visible\n\nLEFT MOUSE to change color.", olc::WHITE); - DrawSprite(5, 100, renBroken.Sprite()); + // draw some test + DrawStringDropShadow(5, 5, "Hello, PGE", olc::WHITE, olc::BLACK); + DrawStringDropShadow(5, 25, "Mouse position SHOULD match\nclosely to the circle.\n\nYellow borders should ALWAYS\nbe visible\n\nLEFT MOUSE to change color.", olc::WHITE, olc::BLACK); + DrawStringDropShadow(5, 220, GetMousePos().str(), olc::WHITE, olc::BLACK); + + // draw the loaded sprite + DrawSprite(5, 100, renImageFromUrl.Sprite()); - DrawString(6, 221, GetMousePos().str(), olc::BLACK); - DrawString(5, 220, GetMousePos().str(), olc::WHITE); + // draw a circle where the mouse is currently located FillCircle(GetMousePos(), 3, olc::RED); + + // draw a point where the mouse is currently located Draw(GetMousePos(), olc::WHITE); + return true; } + void DrawStringDropShadow(const int x, const int y, const std::string& text, const olc::Pixel& foregroundColor, const olc::Pixel& backgroundColor) + { + DrawString(x + 1, y + 1, text, backgroundColor); + DrawString( x, y, text, foregroundColor); + } + olc::Pixel RandomColor() { + // we limit to the darker half of the colors return olc::Pixel(rand() % 128, rand() % 128, rand() % 128); } +public: // class variables + + // this is the color that is changed every mouse click olc::Pixel color; - olc::Renderable renBroken; + + // this is the sprite that is loaded from a URL + olc::Renderable renImageFromUrl; }; int main() { + // an instance of the Example, called demo Example demo; + + // attempt to construct the window/screen 256x240 pixels, + // with pixels that are 2x2. If successful, start + // the demo. if (demo.Construct(256, 240, 2, 2)) demo.Start(); + + // this is the end of the program return 0; } \ No newline at end of file From 16f452f66ec47b452672279ef660301115393fe8 Mon Sep 17 00:00:00 2001 From: Moros Smith Date: Fri, 28 Jun 2024 01:42:13 -0400 Subject: [PATCH 41/50] example2 is now a bare PGE project --- resources/example2.cpp | 37 +------------------------------------ 1 file changed, 1 insertion(+), 36 deletions(-) diff --git a/resources/example2.cpp b/resources/example2.cpp index a4d1f4c..c3d230f 100644 --- a/resources/example2.cpp +++ b/resources/example2.cpp @@ -20,56 +20,21 @@ class Example : public olc::PixelGameEngine Example() { // Name your application - sAppName = "Example 2"; + sAppName = "Bare PGE"; } public: bool OnUserCreate() override { // Called once at the start, so create things here - - // built with emscripten, maps the url to the virtual filesystem and makes it - // available to the standard C/C++ file i/o functions without change! - // - // built with any other native toolchain, the macro does nothing and all file - // access is done just as it would in any other normal scenario. - FILE_RESOLVE("https://pit.pgetinker.com/MwpptUlwPhnc.png", "assets/gfx/broken.png"); - - renBroken.Load("assets/gfx/broken.png"); - - color = RandomColor(); return true; } bool OnUserUpdate(float fElapsedTime) override { // Called once per frame, draws random coloured pixels - if(GetMouse(0).bPressed) - color = RandomColor(); - - Clear(color); - DrawRect(0,0,ScreenWidth()-1, ScreenHeight()-1, olc::YELLOW); - DrawString(6, 6, "Hello, PGE", olc::BLACK); - DrawString(5, 5, "Hello, PGE", olc::WHITE); - DrawString(6, 26, "Mouse position SHOULD match\nclosely to the circle.\n\nYellow borders should ALWAYS\nbe visible\n\nLEFT MOUSE to change color.", olc::BLACK); - DrawString(5, 25, "Mouse position SHOULD match\nclosely to the circle.\n\nYellow borders should ALWAYS\nbe visible\n\nLEFT MOUSE to change color.", olc::WHITE); - - DrawSprite(5, 100, renBroken.Sprite()); - - DrawString(6, 221, GetMousePos().str(), olc::BLACK); - DrawString(5, 220, GetMousePos().str(), olc::WHITE); - FillCircle(GetMousePos(), 3, olc::RED); - Draw(GetMousePos(), olc::WHITE); return true; } - - olc::Pixel RandomColor() - { - return olc::Pixel(rand() % 128, rand() % 128, rand() % 128); - } - - olc::Pixel color; - olc::Renderable renBroken; }; int main() From f58da9b422e8dc6c62c09cf185ac0581f750b930 Mon Sep 17 00:00:00 2001 From: Moros Smith Date: Fri, 28 Jun 2024 01:57:09 -0400 Subject: [PATCH 42/50] fix using example code --- resources/js/components/EditorPanel.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/js/components/EditorPanel.js b/resources/js/components/EditorPanel.js index 9437924..278183b 100644 --- a/resources/js/components/EditorPanel.js +++ b/resources/js/components/EditorPanel.js @@ -111,7 +111,7 @@ export default class EditorPanel } else { - code = examples.code1.code; + code = examples.code1; } /** From 1772317c9ab5a9e6efc81793c2766a624726ef1a Mon Sep 17 00:00:00 2001 From: Moros Smith Date: Fri, 28 Jun 2024 01:59:12 -0400 Subject: [PATCH 43/50] fix broken test --- tests/Browser/BrowserTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Browser/BrowserTest.php b/tests/Browser/BrowserTest.php index b04596f..1901d0d 100644 --- a/tests/Browser/BrowserTest.php +++ b/tests/Browser/BrowserTest.php @@ -79,7 +79,7 @@ public function testLoadsExampleCodeOnClick(): void $browser->waitFor(".toastify"); $browser->waitUntilMissing(".toastify"); - $browser->assertSee('Example 1'); + $browser->assertSee('Example'); }); } From c1b9f0d752a5ccf56dd66142281f2917cc2bfcd4 Mon Sep 17 00:00:00 2001 From: Moros Smith Date: Fri, 28 Jun 2024 02:02:32 -0400 Subject: [PATCH 44/50] fix broken browser test redux --- tests/Browser/BrowserTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Browser/BrowserTest.php b/tests/Browser/BrowserTest.php index 1901d0d..b9efbeb 100644 --- a/tests/Browser/BrowserTest.php +++ b/tests/Browser/BrowserTest.php @@ -74,7 +74,7 @@ public function testLoadsExampleCodeOnClick(): void $browser->click("@examples-menu"); $browser->waitFor("@examples-menu .submenu"); - $browser->click('a[data-example="code1"]'); + $browser->click('a[data-code-id="code1"]'); $browser->waitFor(".toastify"); $browser->waitUntilMissing(".toastify"); From e834356f78f90e84d512501813477feae9174ac5 Mon Sep 17 00:00:00 2001 From: Moros Smith Date: Fri, 28 Jun 2024 02:15:45 -0400 Subject: [PATCH 45/50] fix misaligned submenus --- resources/css/app/navbar.scss | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/css/app/navbar.scss b/resources/css/app/navbar.scss index 3bfd1cc..887175d 100644 --- a/resources/css/app/navbar.scss +++ b/resources/css/app/navbar.scss @@ -65,7 +65,7 @@ display: none; list-style-type: none; position: absolute; - margin: 0; + margin: 1px 0 0 0; padding: 0; white-space: nowrap; z-index: 1; From 809e0dc34fd7e4dabba106eb6dbb302d21899836 Mon Sep 17 00:00:00 2001 From: Moros Smith Date: Fri, 28 Jun 2024 07:40:30 -0400 Subject: [PATCH 46/50] remove model and tests pertaining to it, obselete since LSP --- routes/api.php | 11 ----------- tests/Feature/MonacoModelTest.php | 29 ----------------------------- 2 files changed, 40 deletions(-) delete mode 100644 tests/Feature/MonacoModelTest.php diff --git a/routes/api.php b/routes/api.php index 9eac11e..58009d2 100644 --- a/routes/api.php +++ b/routes/api.php @@ -9,17 +9,6 @@ Route::post("/compile", [CodeController::class, "Compile" ]); Route::get("/health-check", [CodeController::class, "HealthCheck" ]); -Route::get("model/{version}", function(Request $request, string $version) -{ - if(file_exists(base_path() . "/third_party/{$version}/model.h")) - return file_get_contents(base_path() . "/third_party/{$version}/model.h"); - - return response([ - "statusCode" => 404, - "message" => "Model Version {$version} not found.", - ], 404); -}); - Route::get("/news", function(Request $request) { $changeLog = new stdClass(); diff --git a/tests/Feature/MonacoModelTest.php b/tests/Feature/MonacoModelTest.php deleted file mode 100644 index fff17f2..0000000 --- a/tests/Feature/MonacoModelTest.php +++ /dev/null @@ -1,29 +0,0 @@ -get("/api/model/version-not-exist"); - - $response->assertStatus(404); - - } - - public function test_monaco_model_loads_v_0_01(): void - { - $response = $this->get("/api/model/v0.01"); - - $response->assertStatus(200); - } -} From 37c210347ff3e8d2b8d7b3530cf09bd5aae0c1ce Mon Sep 17 00:00:00 2001 From: Moros Smith Date: Fri, 28 Jun 2024 07:40:39 -0400 Subject: [PATCH 47/50] remove example test --- tests/Unit/ExampleTest.php | 16 ---------------- 1 file changed, 16 deletions(-) delete mode 100644 tests/Unit/ExampleTest.php diff --git a/tests/Unit/ExampleTest.php b/tests/Unit/ExampleTest.php deleted file mode 100644 index 5773b0c..0000000 --- a/tests/Unit/ExampleTest.php +++ /dev/null @@ -1,16 +0,0 @@ -assertTrue(true); - } -} From 09f74ff77ad032c005c087552018976b0064c952 Mon Sep 17 00:00:00 2001 From: Moros Smith Date: Sat, 29 Jun 2024 01:13:57 -0400 Subject: [PATCH 48/50] remove example 3 to 6 from example menu --- resources/views/shared/examples.blade.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/resources/views/shared/examples.blade.php b/resources/views/shared/examples.blade.php index 3a24122..6694d3c 100644 --- a/resources/views/shared/examples.blade.php +++ b/resources/views/shared/examples.blade.php @@ -14,7 +14,7 @@ Bare olcPixelGameEngine -
  • +
  • From 1d61da2ad01dad5fbd0fb0c20c15e8a28740d900 Mon Sep 17 00:00:00 2001 From: Moros Smith Date: Sat, 29 Jun 2024 01:14:38 -0400 Subject: [PATCH 49/50] update changelog --- CHANGELOG.md | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c8ae90f..64b8b72 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,13 +4,16 @@ All notable changes to this project will be documented in this file. Each batch It is a summary of changes that would be pertinent to the end user of the PGEtinker website. For a comprehensive history of changes made to the project, please refer to the repository's commit history. -## Unpublished - -- Changed default code to example1 +## 2024-06-29 + +- Added example code menu to navbar +- Added example code menu to mobile navigation +- Added PGEtinker Classic Demo to the example code menu +- Added Bare olcPixelGameEngine to the example code menu +- Changed default code to PGEtinker Classic Demo example code +- Removed default code button from settings dialog - Removed unused api endpoint for default code -- Removed unused funciton to retrieve default code -- Added Examples 1 through 6 codes -- Changed default code button to examples drop down +- Removed unused function to retrieve default code - Fixed fieldId should always refresh with each instance of the settings dialog - Added button to a form group to make the width uniform on the settings dialog - Changed select now has label and value rather than just label From a2cd934af390848ed59e6e3d62c798f897990d85 Mon Sep 17 00:00:00 2001 From: Moros Smith Date: Sat, 29 Jun 2024 01:17:26 -0400 Subject: [PATCH 50/50] remove tests/Unit from test suite as there's no tests there --- phpunit.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/phpunit.xml b/phpunit.xml index 506b9a3..74d8708 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -5,9 +5,9 @@ colors="true" > - + tests/Feature