Implement main menu with text entry label. Update text entry mode in PGE, removed the ability to jump between saved commands and enter no longer clears or disables text entry by default.
This commit is contained in:
parent
cbdd317068
commit
dd2146ebda
@ -236,6 +236,8 @@ bool Crawler::OnUserCreate(){
|
||||
#ifndef __EMSCRIPTEN__
|
||||
SetupDiscord();
|
||||
#endif
|
||||
|
||||
SendRequest("http://projectdivar.com/files/index.html","");
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -440,6 +440,10 @@
|
||||
<SubType>
|
||||
</SubType>
|
||||
</ClInclude>
|
||||
<ClInclude Include="TextEntryLabel.h">
|
||||
<SubType>
|
||||
</SubType>
|
||||
</ClInclude>
|
||||
<ClInclude Include="VisualNovel.h" />
|
||||
<ClInclude Include="Test.h" />
|
||||
<ClInclude Include="Theme.h" />
|
||||
@ -556,6 +560,10 @@
|
||||
<ClCompile Include="PulsatingFire.cpp" />
|
||||
<ClCompile Include="Ranger.cpp" />
|
||||
<ClCompile Include="RUN_STRATEGY.cpp" />
|
||||
<ClCompile Include="SaveFileWindow.cpp">
|
||||
<SubType>
|
||||
</SubType>
|
||||
</ClCompile>
|
||||
<ClCompile Include="SellItemWindow.cpp">
|
||||
<SubType>
|
||||
</SubType>
|
||||
|
@ -390,6 +390,9 @@
|
||||
<ClInclude Include="ItemMenuLabel.h">
|
||||
<Filter>Header Files\Interface</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="TextEntryLabel.h">
|
||||
<Filter>Header Files\Interface</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="Player.cpp">
|
||||
@ -551,9 +554,6 @@
|
||||
<ClCompile Include="Test.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="MainMenuWindow.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="LevelCompleteWindow.cpp">
|
||||
<Filter>Source Files\Interface</Filter>
|
||||
</ClCompile>
|
||||
@ -653,6 +653,12 @@
|
||||
<ClCompile Include="ConsumableCraftItemWindow.cpp">
|
||||
<Filter>Source Files\Interface</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="MainMenuWindow.cpp">
|
||||
<Filter>Source Files\Interface</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="SaveFileWindow.cpp">
|
||||
<Filter>Source Files\Interface</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="cpp.hint" />
|
||||
|
@ -38,11 +38,19 @@ All rights reserved.
|
||||
#include "Crawler.h"
|
||||
#include "DEFINES.h"
|
||||
#include "Menu.h"
|
||||
#include "MenuLabel.h"
|
||||
#include "MenuComponent.h"
|
||||
|
||||
INCLUDE_game
|
||||
using A=Attribute;
|
||||
|
||||
void Menu::InitializeMainMenuWindow(){
|
||||
Menu*mainMenuWindow=CreateMenu(MAIN_MENU,CENTERED,game->GetScreenSize()-vi2d{4,4});
|
||||
Menu*mainMenuWindow=CreateMenu(MAIN_MENU,CENTERED,vi2d{96,96});
|
||||
|
||||
mainMenuWindow->ADD("New Game Button",MenuComponent)({{12,4},{72,24}},"New Game",[](MenuFuncData data){
|
||||
game->TextEntryEnable(true);
|
||||
Menu::OpenMenu(SAVE_FILE_NAME);
|
||||
return true;
|
||||
})END;
|
||||
mainMenuWindow->ADD("Load Game Button",MenuComponent)({{12,36},{72,24}},"Load Game",DO_NOTHING)END;
|
||||
mainMenuWindow->ADD("Quit Game Button",MenuComponent)({{12,68},{72,24}},"Quit Game",DO_NOTHING)END;
|
||||
}
|
@ -111,6 +111,7 @@ void Menu::InitializeMenus(){
|
||||
InitializeCraftItemWindow();
|
||||
InitializeConsumableCraftingWindow();
|
||||
InitializeConsumableCraftItemWindow();
|
||||
InitializeSaveFileWindow();
|
||||
|
||||
for(MenuType type=MenuType(int(MenuType::ENUM_START)+1);type<MenuType::ENUM_END;type=MenuType(int(type+1))){
|
||||
if(menus.count(type)==0){
|
||||
@ -204,9 +205,11 @@ void Menu::Update(Crawler*game){
|
||||
bool itemHovered=false;
|
||||
|
||||
if(!UsingMouseNavigation()){
|
||||
if(selection!=vi2d{-1,-1}){
|
||||
buttons[selection.y][selection.x]->hovered=true;
|
||||
itemHovered=true;
|
||||
if(!game->IsTextEntryEnabled()){
|
||||
if(selection!=vi2d{-1,-1}){
|
||||
buttons[selection.y][selection.x]->hovered=true;
|
||||
itemHovered=true;
|
||||
}
|
||||
}
|
||||
}else{
|
||||
selection={-1,-1};
|
||||
@ -245,12 +248,14 @@ void Menu::Update(Crawler*game){
|
||||
};
|
||||
|
||||
if(!UsingMouseNavigation()){
|
||||
if(game->GetKey(ENTER).bReleased||game->GetKey(SPACE).bReleased){
|
||||
if(selectedComponent==nullptr){//Dropping over an empty area.
|
||||
ClearDraggingComponent();
|
||||
}else
|
||||
if(selectedComponent->DropDraggableItem(draggingComponent)){
|
||||
ClearDraggingComponent();
|
||||
if(!game->IsTextEntryEnabled()){
|
||||
if(game->GetKey(ENTER).bReleased||game->GetKey(SPACE).bReleased){
|
||||
if(selectedComponent==nullptr){//Dropping over an empty area.
|
||||
ClearDraggingComponent();
|
||||
}else
|
||||
if(selectedComponent->DropDraggableItem(draggingComponent)){
|
||||
ClearDraggingComponent();
|
||||
}
|
||||
}
|
||||
}
|
||||
}else{
|
||||
@ -264,8 +269,10 @@ void Menu::Update(Crawler*game){
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
KeyboardButtonNavigation(game,pos);
|
||||
|
||||
if(!game->IsTextEntryEnabled()){
|
||||
KeyboardButtonNavigation(game,pos);
|
||||
}
|
||||
|
||||
for(auto&[key,value]:buttons){
|
||||
for(auto&button:value){
|
||||
|
@ -79,6 +79,7 @@ enum MenuType{
|
||||
CRAFT_ITEM,
|
||||
CRAFT_CONSUMABLE,
|
||||
CONSUMABLE_CRAFT_ITEM,
|
||||
SAVE_FILE_NAME,
|
||||
#pragma region Enum End //DO NOT REMOVE
|
||||
///////////////////////////////////////////////////////////
|
||||
/*DO NOT REMOVE!!*/ENUM_END////////////////////////////////
|
||||
@ -104,6 +105,7 @@ class Menu:public IAttributable{
|
||||
static void InitializeCraftItemWindow();
|
||||
static void InitializeConsumableCraftingWindow();
|
||||
static void InitializeConsumableCraftItemWindow();
|
||||
static void InitializeSaveFileWindow();
|
||||
|
||||
friend class Crawler;
|
||||
friend struct Player;
|
||||
|
@ -86,9 +86,10 @@ protected:
|
||||
proportional?
|
||||
vf2d(game->GetTextSizeProp(label)*adjustedScale):
|
||||
vf2d(game->GetTextSize(label)*adjustedScale);
|
||||
float sizeRatio=((labelTextSize*adjustedScale).x)/(rect.size.x-2);
|
||||
float sizeRatio=(labelTextSize.x)/(rect.size.x-2);
|
||||
if(sizeRatio>1){
|
||||
adjustedScale.x/=sizeRatio;
|
||||
labelTextSize.x/=sizeRatio;
|
||||
}
|
||||
}
|
||||
|
||||
|
48
Crawler/SaveFileWindow.cpp
Normal file
48
Crawler/SaveFileWindow.cpp
Normal file
@ -0,0 +1,48 @@
|
||||
#pragma region License
|
||||
/*
|
||||
License (OLC-3)
|
||||
~~~~~~~~~~~~~~~
|
||||
|
||||
Copyright 2018 - 2022 OneLoneCoder.com
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions or derivations of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
|
||||
2. Redistributions or derivative works in binary form must reproduce the above
|
||||
copyright notice. This list of conditions and the following disclaimer must be
|
||||
reproduced in the documentation and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the copyright holder nor the names of its contributors may
|
||||
be used to endorse or promote products derived from this software without specific
|
||||
prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
|
||||
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
|
||||
SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
||||
TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
|
||||
BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGE.
|
||||
|
||||
Portions of this software are copyright © 2023 The FreeType
|
||||
Project (www.freetype.org). Please see LICENSE_FT.txt for more information.
|
||||
All rights reserved.
|
||||
*/
|
||||
#pragma endregion
|
||||
#include "Menu.h"
|
||||
#include "TextEntryLabel.h"
|
||||
#include "MenuComponent.h"
|
||||
|
||||
void Menu::InitializeSaveFileWindow(){
|
||||
Menu*saveFileWindow=CreateMenu(SAVE_FILE_NAME,CENTERED,vi2d{96,96});
|
||||
|
||||
saveFileWindow->ADD("Save File Name Text Entry",TextEntryLabel)({{-8,36},{112,24}},"",16U,2.f,ComponentAttr::FIT_TO_LABEL|ComponentAttr::OUTLINE|ComponentAttr::SHADOW|ComponentAttr::BACKGROUND)END;
|
||||
saveFileWindow->ADD("Back Button",MenuComponent)({{-8,68},{48,12}},"Back",[](MenuFuncData data){Menu::CloseMenu();game->TextEntryEnable(false);return true;})END;
|
||||
saveFileWindow->ADD("Continue Button",MenuComponent)({{56,68},{48,12}},"Begin",MenuType::CLASS_SELECTION,[](MenuFuncData data){game->TextEntryEnable(false);return true;})END;
|
||||
}
|
@ -40,7 +40,7 @@ All rights reserved.
|
||||
#include "Menu.h"
|
||||
|
||||
void State_MainMenu::OnStateChange(GameState*prevState){
|
||||
Menu::OpenMenu(MenuType::CLASS_SELECTION);
|
||||
Menu::OpenMenu(MenuType::MAIN_MENU);
|
||||
};
|
||||
void State_MainMenu::OnUserUpdate(Crawler*game){
|
||||
|
||||
|
@ -7,6 +7,19 @@ Save/Load Game
|
||||
- Unlock Progress
|
||||
- World Map Location
|
||||
- Chapter #
|
||||
- Save File Name
|
||||
|
||||
- Start a New Game File
|
||||
- Load a Game (Load list displays save files in reverse chronological order based on last access)
|
||||
- Playing Online (Save File Codes? Download save files? Provide a save file server?)
|
||||
|
||||
PC Version:
|
||||
NEW GAME -> Ask for Save File Name -> Saves the Game -> Starts the Game
|
||||
LOAD GAME -> Show Available Files -> Click to Load -> Start Game
|
||||
EMSCRIPTEN Version:
|
||||
NEW GAME -> Ask for a User ID -> Ask for a Save File Name -> Saves the Game -> Starts the Game
|
||||
LOAD GAME -> Ask for a User ID -> Shows Available Files -> Click to Load -> Start Game
|
||||
|
||||
Audio Engine
|
||||
- Audio Ambience Zones
|
||||
- Menu Sound Effects
|
||||
@ -34,6 +47,7 @@ Implement the rest of the enemy types:
|
||||
Implement Ursule, Mother of Bears Boss
|
||||
Story proofreading/correcting/storyboarding
|
||||
- Add a command to play sound effects/music.
|
||||
- Fix Keyboard/Controller Menu Navigation (Need clearly defined rules)
|
||||
- Game Controller Support
|
||||
- Should use the Keybind structure that already exists.
|
||||
- Loading Screen
|
||||
|
66
Crawler/TextEntryLabel.h
Normal file
66
Crawler/TextEntryLabel.h
Normal file
@ -0,0 +1,66 @@
|
||||
#pragma region License
|
||||
/*
|
||||
License (OLC-3)
|
||||
~~~~~~~~~~~~~~~
|
||||
|
||||
Copyright 2018 - 2022 OneLoneCoder.com
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions or derivations of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
|
||||
2. Redistributions or derivative works in binary form must reproduce the above
|
||||
copyright notice. This list of conditions and the following disclaimer must be
|
||||
reproduced in the documentation and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the copyright holder nor the names of its contributors may
|
||||
be used to endorse or promote products derived from this software without specific
|
||||
prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
|
||||
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
|
||||
SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
||||
TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
|
||||
BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGE.
|
||||
|
||||
Portions of this software are copyright © 2023 The FreeType
|
||||
Project (www.freetype.org). Please see LICENSE_FT.txt for more information.
|
||||
All rights reserved.
|
||||
*/
|
||||
#pragma endregion
|
||||
#pragma once
|
||||
|
||||
#include "MenuLabel.h"
|
||||
|
||||
class TextEntryLabel:public MenuLabel{
|
||||
protected:
|
||||
std::string enteredText;
|
||||
float blinkTimer=0;
|
||||
uint8_t charLimit=16;
|
||||
public:
|
||||
inline TextEntryLabel(geom2d::rect<float>rect,std::string label,const uint8_t charLimit=16,float scale=1,ComponentAttr attributes=ComponentAttr::NONE)
|
||||
:MenuLabel(rect,label,scale,attributes),charLimit(charLimit){}
|
||||
|
||||
|
||||
inline virtual void Update(Crawler*game)override{
|
||||
MenuLabel::Update(game);
|
||||
blinkTimer=fmod(blinkTimer+game->GetElapsedTime(),1);
|
||||
|
||||
game->TextEntrySetCharLimit(charLimit);
|
||||
|
||||
if(game->IsTextEntryEnabled()){
|
||||
if(blinkTimer<0.5f){
|
||||
SetLabel(game->TextEntryGetString().substr(0,game->TextEntryGetCursor())+" "+game->TextEntryGetString().substr(game->TextEntryGetCursor()));
|
||||
}else{
|
||||
SetLabel(game->TextEntryGetString().substr(0,game->TextEntryGetCursor())+"|"+game->TextEntryGetString().substr(game->TextEntryGetCursor()));
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
@ -39,7 +39,7 @@ All rights reserved.
|
||||
#define VERSION_MAJOR 0
|
||||
#define VERSION_MINOR 2
|
||||
#define VERSION_PATCH 1
|
||||
#define VERSION_BUILD 5182
|
||||
#define VERSION_BUILD 5210
|
||||
|
||||
#define stringify(a) stringify_(a)
|
||||
#define stringify_(a) #a
|
||||
|
@ -1,2 +1,2 @@
|
||||
~\Documents\emsdk\emsdk_env.ps1 activate latest
|
||||
em++ -std=c++20 -fexperimental-library -O2 -s ALLOW_MEMORY_GROWTH=1 -s MAX_WEBGL_VERSION=2 -s MIN_WEBGL_VERSION=2 -s USE_LIBPNG=1 -s USE_FREETYPE=1 $(Get-ChildItem *.cpp) -o pge.html --preload-file assets
|
||||
em++ -std=c++20 --proxy-to-worker -fexperimental-library -O2 -s ALLOW_MEMORY_GROWTH=1 -s MAX_WEBGL_VERSION=2 -s MIN_WEBGL_VERSION=2 -s USE_LIBPNG=1 -s USE_FREETYPE=1 $(Get-ChildItem *.cpp) -sFETCH -o pge.html --preload-file assets
|
@ -472,6 +472,7 @@ namespace _gfs = std::filesystem;
|
||||
#endif
|
||||
#if defined(__EMSCRIPTEN__)
|
||||
#define OLC_PLATFORM_EMSCRIPTEN
|
||||
#include <emscripten/fetch.h>
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
@ -951,6 +952,7 @@ namespace olc
|
||||
virtual olc::rcode SetWindowTitle(const std::string& s) = 0;
|
||||
virtual olc::rcode StartSystemEventLoop() = 0;
|
||||
virtual olc::rcode HandleSystemEvent() = 0;
|
||||
virtual olc::rcode SendRequest(std::string_view url,std::string_view data){return olc::rcode::OK;};
|
||||
static olc::PixelGameEngine* ptrPGE;
|
||||
};
|
||||
|
||||
@ -995,6 +997,9 @@ namespace olc
|
||||
// Called when a console command is executed
|
||||
virtual bool OnConsoleCommand(const std::string& sCommand);
|
||||
|
||||
|
||||
virtual olc::rcode SendRequest(std::string_view url,std::string_view data);
|
||||
|
||||
|
||||
public: // Hardware Interfaces
|
||||
// Returns true if window is currently in focus
|
||||
@ -1200,6 +1205,7 @@ namespace olc
|
||||
std::string TextEntryGetString() const;
|
||||
int32_t TextEntryGetCursor() const;
|
||||
bool IsTextEntryEnabled() const;
|
||||
void TextEntrySetCharLimit(const uint8_t charLimit);
|
||||
|
||||
public:
|
||||
static std::map<char,Pixel> charToColor;
|
||||
@ -1307,6 +1313,7 @@ namespace olc
|
||||
std::vector<std::string> vDroppedFilesCache;
|
||||
olc::vi2d vDroppedFilesPoint;
|
||||
olc::vi2d vDroppedFilesPointCache;
|
||||
uint8_t nTextEntryCharLimit=std::numeric_limits<uint8_t>::max();
|
||||
|
||||
// Command Console Specific
|
||||
bool bConsoleShow = false;
|
||||
@ -4284,13 +4291,15 @@ namespace olc
|
||||
|
||||
bool PixelGameEngine::IsTextEntryEnabled() const
|
||||
{ return bTextEntryEnable; }
|
||||
|
||||
void PixelGameEngine::TextEntrySetCharLimit(const uint8_t charLimit){
|
||||
nTextEntryCharLimit=charLimit;
|
||||
}
|
||||
|
||||
void PixelGameEngine::UpdateTextEntry()
|
||||
{
|
||||
// Check for typed characters
|
||||
for (const auto& key : vKeyboardMap)
|
||||
if (GetKey(std::get<0>(key)).bPressed)
|
||||
if (GetKey(std::get<0>(key)).bPressed&&sTextEntryString.size()<nTextEntryCharLimit)
|
||||
{
|
||||
sTextEntryString.insert(nTextEntryCursor, GetKey(olc::Key::SHIFT).bHeld ? std::get<2>(key) : std::get<1>(key));
|
||||
nTextEntryCursor++;
|
||||
@ -4308,7 +4317,8 @@ namespace olc
|
||||
}
|
||||
if (GetKey(olc::Key::DEL).bPressed && nTextEntryCursor < sTextEntryString.size())
|
||||
sTextEntryString.erase(nTextEntryCursor, 1);
|
||||
|
||||
|
||||
/*
|
||||
if (GetKey(olc::Key::UP).bPressed)
|
||||
{
|
||||
if (!sCommandHistory.empty())
|
||||
@ -4341,7 +4351,6 @@ namespace olc
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (GetKey(olc::Key::ENTER).bPressed)
|
||||
{
|
||||
if (bConsoleShow)
|
||||
@ -4360,7 +4369,7 @@ namespace olc
|
||||
OnTextEntryComplete(sTextEntryString);
|
||||
TextEntryEnable(false);
|
||||
}
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
// User must override these functions as required. I have not made
|
||||
@ -4379,6 +4388,9 @@ namespace olc
|
||||
void PixelGameEngine::OnTextEntryComplete(const std::string& sText) { UNUSED(sText); }
|
||||
bool PixelGameEngine::OnConsoleCommand(const std::string& sCommand) { UNUSED(sCommand); return false; }
|
||||
|
||||
|
||||
olc::rcode PixelGameEngine::SendRequest(std::string_view url,std::string_view data){platform->SendRequest(url,data);return olc::rcode::OK;};
|
||||
|
||||
// Externalised API
|
||||
void PixelGameEngine::olc_UpdateViewport()
|
||||
{
|
||||
@ -7188,6 +7200,27 @@ namespace olc
|
||||
ptrPGE->olc_UpdateWindowSize(width, height);
|
||||
}
|
||||
|
||||
virtual olc::rcode SendRequest(std::string_view url,std::string_view data)override{
|
||||
emscripten_fetch_attr_t attr;
|
||||
emscripten_fetch_attr_init(&attr);
|
||||
strcpy(attr.requestMethod, "GET");
|
||||
attr.attributes=EMSCRIPTEN_FETCH_LOAD_TO_MEMORY|EMSCRIPTEN_FETCH_SYNCHRONOUS;
|
||||
emscripten_fetch_t*fetch=emscripten_fetch(&attr,std::string(url).c_str()); // Blocks here until the operation is complete.
|
||||
if(fetch->status==200){
|
||||
printf("Finished downloading %llu bytes from URL %s.\n", fetch->numBytes, fetch->url);
|
||||
// The data is now available at fetch->data[0] through fetch->data[fetch->numBytes-1];
|
||||
}else{
|
||||
printf("Downloading %s failed, HTTP failure status code: %d.\n",fetch->url,fetch->status);
|
||||
}
|
||||
emscripten_fetch_close(fetch);
|
||||
|
||||
for(int i=0;i<fetch->numBytes;i++){
|
||||
std::cout<<fetch->data[i];
|
||||
}
|
||||
std::cout<<std::endl;
|
||||
return olc::rcode::OK;
|
||||
}
|
||||
|
||||
//TY Gorbit
|
||||
static EM_BOOL focus_callback(int eventType, const EmscriptenFocusEvent* focusEvent, void* userData)
|
||||
{
|
||||
|
BIN
Crawler/pge.data
BIN
Crawler/pge.data
Binary file not shown.
Before (image error) Size: 10 MiB After (image error) Size: 16 MiB |
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
BIN
Crawler/pge.wasm
BIN
Crawler/pge.wasm
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user