2
.gitignore
vendored
2
.gitignore
vendored
@@ -58,3 +58,5 @@ desktop.ini
|
||||
#Redist
|
||||
!Installer/Redist/*
|
||||
UpgradeLog.htm
|
||||
click_output.JPEG
|
||||
click_output.PNG
|
||||
|
||||
@@ -505,6 +505,10 @@
|
||||
RelativePath=".\src\source\DataModel\SelectionService.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\ThumbnailGeneratorInstance.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\source\DataModelV2\WorkspaceInstance.cpp"
|
||||
>
|
||||
@@ -666,6 +670,14 @@
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Helpers"
|
||||
>
|
||||
<File
|
||||
RelativePath=".\src\source\base64.cpp"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Header Files"
|
||||
@@ -866,6 +878,10 @@
|
||||
RelativePath=".\src\include\DataModelV2\SelectionService.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\include\DataModelV2\ThumbnailGeneratorInstance.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\include\DataModelV2\WorkspaceInstance.h"
|
||||
>
|
||||
@@ -919,6 +935,14 @@
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Helpers"
|
||||
>
|
||||
<File
|
||||
RelativePath=".\src\include\base64.h"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Resource Files"
|
||||
|
||||
50
ThumbnailGeneratorInstance.cpp
Normal file
50
ThumbnailGeneratorInstance.cpp
Normal file
@@ -0,0 +1,50 @@
|
||||
#include "DataModelV2/ThumbnailGeneratorInstance.h"
|
||||
#include "Application.h"
|
||||
#include "Globals.h"
|
||||
#include "base64.h"
|
||||
#include <fstream>
|
||||
|
||||
ThumbnailGeneratorInstance::ThumbnailGeneratorInstance(void)
|
||||
{
|
||||
Instance::Instance();
|
||||
name = "ThumbnailGenerator";
|
||||
className = "ThumbnailGenerator";
|
||||
canDelete = false;
|
||||
}
|
||||
|
||||
ThumbnailGeneratorInstance::~ThumbnailGeneratorInstance(void) {}
|
||||
|
||||
/*
|
||||
* TODO:
|
||||
* Move functions like toggleSky into their own "Lighting" instance
|
||||
* Make this headless, and allow for resolutions greater than the screen resolution
|
||||
*/
|
||||
std::string ThumbnailGeneratorInstance::click(std::string fileType, int cx, int cy, bool hideSky)
|
||||
{
|
||||
RenderDevice* rd = g_usableApp->getRenderDevice();
|
||||
GuiRootInstance* guiRoot = g_dataModel->getGuiRoot();
|
||||
const G3D::GImage::Format format = G3D::GImage::stringToFormat(fileType);
|
||||
int prevWidth = rd->width();
|
||||
int prevHeight = rd->height();
|
||||
G3D::GImage imgBuffer(cx, cy, 4);
|
||||
G3D::BinaryOutput binOut;
|
||||
|
||||
guiRoot->hideGui(true);
|
||||
g_usableApp->resize3DView(cx, cy);
|
||||
|
||||
if(hideSky)
|
||||
g_usableApp->toggleSky();
|
||||
|
||||
g_usableApp->onGraphics(rd);
|
||||
rd->screenshotPic(imgBuffer, true, hideSky);
|
||||
imgBuffer.encode(format, binOut);
|
||||
|
||||
// Convert to Base64 string
|
||||
std::string base64ImgStr = base64_encode(reinterpret_cast<const unsigned char*>(binOut.getCArray()), binOut.length(), false);
|
||||
|
||||
guiRoot->hideGui(false);
|
||||
g_usableApp->resize3DView(prevWidth, prevHeight);
|
||||
|
||||
return base64ImgStr;
|
||||
}
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
#include "IEBrowser.h"
|
||||
#include "Mouse.h"
|
||||
#include "Tool/Tool.h"
|
||||
//#include "GuiRoot.h"
|
||||
|
||||
class TextButtonInstance;
|
||||
class ImageButtonInstance;
|
||||
@@ -48,14 +47,18 @@ class Application { // : public GApp {
|
||||
void setFocus(bool isFocused);
|
||||
int getMode();
|
||||
void unSetMode();
|
||||
|
||||
void toggleSky();
|
||||
CameraController cameraController;
|
||||
UserInput* userInput;
|
||||
PropertyWindow* _propWindow;
|
||||
void generateShadowMap(const CoordinateFrame& lightViewMatrix) const;
|
||||
void generateShadowMap(const CoordinateFrame& lightViewMatrix) const;
|
||||
RenderDevice* getRenderDevice();
|
||||
void selectInstance(Instance* selectedInstance,PropertyWindow* propWindow);
|
||||
void setMode(int mode);
|
||||
|
||||
SkyRef getSky();
|
||||
void resize3DView(int w, int h);
|
||||
|
||||
Tool * tool;
|
||||
void changeTool(Tool *);
|
||||
Mouse mouse;
|
||||
@@ -82,6 +85,7 @@ class Application { // : public GApp {
|
||||
GAppSettings _settings;
|
||||
double lightProjX, lightProjY, lightProjNear, lightProjFar;
|
||||
IEBrowser* webBrowser;
|
||||
bool _hideSky;
|
||||
protected:
|
||||
Stopwatch m_graphicsWatch;
|
||||
Stopwatch m_logicWatch;
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#include "WorkspaceInstance.h"
|
||||
#include "LevelInstance.h"
|
||||
#include "PartInstance.h"
|
||||
#include "ThumbnailGeneratorInstance.h"
|
||||
#include "SelectionService.h"
|
||||
#include "rapidxml/rapidxml.hpp"
|
||||
#include "GuiRootInstance.h"
|
||||
@@ -23,9 +24,12 @@ public:
|
||||
bool load(const char* filename,bool clearObjects);
|
||||
bool readXMLFileStream(std::ifstream* file);
|
||||
void drawMessage(RenderDevice*);
|
||||
WorkspaceInstance* getWorkspace();
|
||||
LevelInstance * getLevel();
|
||||
XplicitNgine * getEngine();
|
||||
|
||||
WorkspaceInstance* getWorkspace();
|
||||
LevelInstance* getLevel();
|
||||
XplicitNgine* getEngine();
|
||||
ThumbnailGeneratorInstance* getThumbnailGenerator();
|
||||
|
||||
std::string message;
|
||||
std::string _loadedFileName;
|
||||
bool showMessage;
|
||||
@@ -50,9 +54,10 @@ private:
|
||||
bool _legacyLoad;
|
||||
float _modY;
|
||||
WorkspaceInstance* workspace;
|
||||
LevelInstance * level;
|
||||
LevelInstance* level;
|
||||
GuiRootInstance* guiRoot;
|
||||
SelectionService* selectionService;
|
||||
ThumbnailGeneratorInstance * thumbnailGenerator;
|
||||
bool running;
|
||||
XplicitNgine * xplicitNgine;
|
||||
};
|
||||
|
||||
@@ -18,7 +18,9 @@ public:
|
||||
void update();
|
||||
bool mouseInGUI(G3D::RenderDevice* renderDevice,int x,int y);
|
||||
void onMouseLeftUp(G3D::RenderDevice* renderDevice, int x,int y);
|
||||
void hideGui(bool doHide);
|
||||
private:
|
||||
std::string _message;
|
||||
G3D::RealTime _messageTime;
|
||||
bool _hideGui;
|
||||
};
|
||||
14
src/include/DataModelV2/ThumbnailGeneratorInstance.h
Normal file
14
src/include/DataModelV2/ThumbnailGeneratorInstance.h
Normal file
@@ -0,0 +1,14 @@
|
||||
#pragma once
|
||||
#include "instance.h"
|
||||
|
||||
class ThumbnailGeneratorInstance :
|
||||
public Instance
|
||||
{
|
||||
public:
|
||||
// Constructor / Destructor
|
||||
ThumbnailGeneratorInstance(void);
|
||||
~ThumbnailGeneratorInstance(void);
|
||||
|
||||
// Functions
|
||||
std::string click(std::string fileType, int cx, int cy, bool hideSky);
|
||||
};
|
||||
@@ -29,6 +29,8 @@ extern bool running;
|
||||
extern DataModelInstance* g_dataModel;
|
||||
extern XplicitNgine* g_xplicitNgine;
|
||||
extern Application* g_usableApp;
|
||||
extern SkyRef g_sky;
|
||||
extern RenderDevice g_renderDevice;
|
||||
|
||||
extern GFontRef g_fntdominant;
|
||||
extern GFontRef g_fntlighttrek;
|
||||
|
||||
35
src/include/base64.h
Normal file
35
src/include/base64.h
Normal file
@@ -0,0 +1,35 @@
|
||||
//
|
||||
// base64 encoding and decoding with C++.
|
||||
// Version: 2.rc.08 (release candidate)
|
||||
//
|
||||
|
||||
#ifndef BASE64_H_C0CE2A47_D10E_42C9_A27C_C883944E704A
|
||||
#define BASE64_H_C0CE2A47_D10E_42C9_A27C_C883944E704A
|
||||
|
||||
#include <string>
|
||||
|
||||
#if __cplusplus >= 201703L
|
||||
#include <string_view>
|
||||
#endif // __cplusplus >= 201703L
|
||||
|
||||
std::string base64_encode (std::string const& s, bool url = false);
|
||||
std::string base64_encode_pem (std::string const& s);
|
||||
std::string base64_encode_mime(std::string const& s);
|
||||
|
||||
std::string base64_decode(std::string const& s, bool remove_linebreaks = false);
|
||||
std::string base64_encode(unsigned char const*, size_t len, bool url = false);
|
||||
|
||||
#if __cplusplus >= 201703L
|
||||
//
|
||||
// Interface with std::string_view rather than const std::string&
|
||||
// Requires C++17
|
||||
// Provided by Yannic Bonenberger (https://github.com/Yannic)
|
||||
//
|
||||
std::string base64_encode (std::string_view s, bool url = false);
|
||||
std::string base64_encode_pem (std::string_view s);
|
||||
std::string base64_encode_mime(std::string_view s);
|
||||
|
||||
std::string base64_decode(std::string_view s, bool remove_linebreaks = false);
|
||||
#endif // __cplusplus >= 201703L
|
||||
|
||||
#endif /* BASE64_H_C0CE2A47_D10E_42C9_A27C_C883944E704A */
|
||||
@@ -33,10 +33,7 @@
|
||||
#include "Listener/RotateButtonListener.h"
|
||||
#include "Faces.h"
|
||||
#define LEGACY_LOAD_G3DFUN_LEVEL
|
||||
//Ray testRay;
|
||||
//static int cursorid = 0;
|
||||
//static int cursorOvrid = 0;
|
||||
//static int currentcursorid = 0;
|
||||
|
||||
static bool mouseMovedBeginMotion = false;
|
||||
static POINT oldGlobalMouse;
|
||||
Vector2 oldMouse = Vector2(0,0);
|
||||
@@ -74,6 +71,7 @@ Application::Application(HWND parentWindow) : _propWindow(NULL) { //: GApp(setti
|
||||
CreateDirectory(tempPath.c_str(), NULL);
|
||||
|
||||
_hWndMain = parentWindow;
|
||||
_hideSky = false;
|
||||
|
||||
HMODULE hThisInstance = GetModuleHandle(NULL);
|
||||
|
||||
@@ -110,6 +108,10 @@ Application::Application(HWND parentWindow) : _propWindow(NULL) { //: GApp(setti
|
||||
_settings.writeLicenseFile = false;
|
||||
_settings.logFilename = tempPath + "/g3dlog.txt";
|
||||
_settings.window.center = true;
|
||||
|
||||
// Needs to be enabled if "B3DCCService" (still need to finalize that name)
|
||||
//_settings.window.fsaaSamples = 8;
|
||||
|
||||
Win32Window* window = Win32Window::create(_settings.window,_hwndRenderer);
|
||||
ShowWindow(_hwndRenderer, SW_SHOW);
|
||||
ShowWindow(_hWndMain, SW_SHOW);
|
||||
@@ -288,16 +290,6 @@ void Application::onInit() {
|
||||
|
||||
_dataModel->getSelectionService()->clearSelection();
|
||||
_dataModel->getSelectionService()->addSelected(_dataModel);
|
||||
|
||||
|
||||
|
||||
//setDesiredFrameRate(60);
|
||||
|
||||
|
||||
|
||||
|
||||
//GApplet::onInit();
|
||||
|
||||
}
|
||||
|
||||
void Application::onCleanup() {
|
||||
@@ -313,12 +305,6 @@ void Application::onNetwork() {
|
||||
// Poll net messages here
|
||||
}
|
||||
|
||||
|
||||
//double getVectorDistance(Vector3 vector1, Vector3 vector2)
|
||||
//{
|
||||
// return pow(pow((double)vector1.x - (double)vector2.x, 2) + pow((double)vector1.y - (double)vector2.y, 2) + pow((double)vector1.z - (double)vector2.z, 2), 0.5);
|
||||
//}
|
||||
|
||||
void Application::onSimulation(RealTime rdt, SimTime sdt, SimTime idt) {
|
||||
|
||||
if(_dataModel->isRunning())
|
||||
@@ -425,7 +411,7 @@ int Application::getMode()
|
||||
void Application::drawOutline(Vector3 from, Vector3 to, RenderDevice* rd, LightingParameters lighting, Vector3 size, Vector3 pos, CoordinateFrame c)
|
||||
{
|
||||
rd->disableLighting();
|
||||
Color3 outline = Color3::cyan();//Color3(0.098F,0.6F,1.0F);
|
||||
Color3 outline = Color3::cyan();
|
||||
float offsetSize = 0.05F;
|
||||
//X
|
||||
Draw::box(c.toWorldSpace(Box(Vector3(from.x - offsetSize, from.y + offsetSize, from.z + offsetSize), Vector3(to.x + offsetSize, from.y - offsetSize, from.z - offsetSize))), rd, outline, Color4::clear());
|
||||
@@ -500,8 +486,6 @@ void Application::drawOutline(Vector3 from, Vector3 to, RenderDevice* rd, Lighti
|
||||
|
||||
void Application::exitApplication()
|
||||
{
|
||||
//endApplet = true;
|
||||
//endProgram = true;
|
||||
}
|
||||
|
||||
|
||||
@@ -515,27 +499,18 @@ void Application::onGraphics(RenderDevice* rd) {
|
||||
if (GetCursorPos(&mousepos))
|
||||
{
|
||||
POINT pointm = mousepos;
|
||||
if (ScreenToClient(_hWndMain, &mousepos))
|
||||
{
|
||||
//mouseOnScreen = true;
|
||||
//POINT pointm;
|
||||
///GetCursorPos(&pointm);
|
||||
if(_hwndRenderer != WindowFromPoint(pointm)) //OLD: mousepos.x < 1 || mousepos.y < 1 || mousepos.x >= rd->getViewport().width()-1 || mousepos.y >= rd->getViewport().height()-1
|
||||
if (ScreenToClient(_hWndMain, &mousepos))
|
||||
{
|
||||
mouseOnScreen = false;
|
||||
//ShowCursor(true);
|
||||
//_window->setMouseVisible(true);
|
||||
//rd->window()->setInputCaptureCount(0);
|
||||
if(_hwndRenderer != WindowFromPoint(pointm))
|
||||
{
|
||||
mouseOnScreen = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
mouseOnScreen = true;
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
mouseOnScreen = true;
|
||||
//SetCursor(NULL);
|
||||
//_window->setMouseVisible(false);
|
||||
//rd->window()->setInputCaptureCount(1);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if(Globals::useMousePoint)
|
||||
@@ -548,13 +523,15 @@ void Application::onGraphics(RenderDevice* rd) {
|
||||
lighting.ambient = Color3(0.6F,0.6F,0.6F);
|
||||
renderDevice->setProjectionAndCameraMatrix(*cameraController.getCamera());
|
||||
|
||||
// Cyan background
|
||||
//renderDevice->setColorClearValue(Color3(0.0f, 0.5f, 1.0f));
|
||||
|
||||
renderDevice->clear(sky.isNull(), true, true);
|
||||
if (sky.notNull()) {
|
||||
sky->render(renderDevice, lighting);
|
||||
}
|
||||
// TODO: stick this into its own rendering thing
|
||||
if(!_hideSky) {
|
||||
renderDevice->clear(sky.isNull(), true, true);
|
||||
if (sky.notNull()) sky->render(renderDevice, lighting);
|
||||
} else {
|
||||
rd->setColorClearValue(Color4(0.0f, 0.0f, 0.0f, 0.0f));
|
||||
renderDevice->clear(true, true, true);
|
||||
toggleSky();
|
||||
}
|
||||
|
||||
// Setup lighting
|
||||
renderDevice->enableLighting();
|
||||
@@ -565,41 +542,18 @@ void Application::onGraphics(RenderDevice* rd) {
|
||||
renderDevice->setLight(0, GLight::directional(lighting.lightDirection, lighting.lightColor, true, true));
|
||||
renderDevice->setAmbientLightColor(lighting.ambient);
|
||||
|
||||
//renderDevice->setBlendFunc(RenderDevice::BLEND_ONE, RenderDevice::BLEND_ONE);
|
||||
|
||||
|
||||
|
||||
//renderDevice->setShininess(70);
|
||||
//renderDevice->setSpecularCoefficient(Color3(0.1F, 0.1F, 0.1F));
|
||||
|
||||
//float lightAmbient[] = { 0.5F, 0.5F, 0.5F, 1.0F };
|
||||
//float lightDiffuse[] = { 0.6F, 0.6F, 0.6F, 1.0F };
|
||||
//float lightSpecular[] = { 0.8F, 0.8F, 0.8F, 1.0F };
|
||||
|
||||
//glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, lightAmbient);
|
||||
//glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, lightDiffuse);
|
||||
//glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, lightSpecular);
|
||||
//glMateriali(GL_FRONT_AND_BACK, GL_SHININESS, 70);
|
||||
|
||||
|
||||
rd->beforePrimitive();
|
||||
CoordinateFrame forDraw = rd->getObjectToWorldMatrix();
|
||||
glEnableClientState(GL_VERTEX_ARRAY);
|
||||
glEnableClientState(GL_COLOR_ARRAY);
|
||||
glEnableClientState(GL_NORMAL_ARRAY);
|
||||
//if(_dataModel->getWorkspace() != NULL)
|
||||
|
||||
_dataModel->getWorkspace()->render(rd);
|
||||
//else throw std::exception("Workspace not found");
|
||||
glDisableClientState(GL_VERTEX_ARRAY);
|
||||
glDisableClientState(GL_COLOR_ARRAY);
|
||||
glDisableClientState(GL_NORMAL_ARRAY);
|
||||
rd->setObjectToWorldMatrix(forDraw);
|
||||
rd->afterPrimitive();
|
||||
|
||||
|
||||
//Draw::box(G3D::Box(mouse.getPosition()-Vector3(2,0.5F,1),mouse.getPosition()+Vector3(2,0.5F,1)), rd, Color3::cyan(), Color4::clear());
|
||||
|
||||
for(size_t i = 0; i < _dataModel->getSelectionService()->getSelection().size(); i++)
|
||||
{
|
||||
if(PartInstance* part = dynamic_cast<PartInstance*>(g_dataModel->getSelectionService()->getSelection()[i]))
|
||||
@@ -609,18 +563,6 @@ void Application::onGraphics(RenderDevice* rd) {
|
||||
drawOutline(Vector3(0+size.x/2, 0+size.y/2, 0+size.z/2) ,Vector3(0-size.x/2,0-size.y/2,0-size.z/2), rd, lighting, Vector3(size.x/2, size.y/2, size.z/2), Vector3(pos.x, pos.y, pos.z), part->getCFrame());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//Vector3 gamepoint = Vector3(0, 5, 0);
|
||||
//Vector3 camerapoint = rd->getCameraToWorldMatrix().translation;
|
||||
//float distance = pow(pow((double)gamepoint.x - (double)camerapoint.x, 2) + pow((double)gamepoint.y - (double)camerapoint.y, 2) + pow((double)gamepoint.z - (double)camerapoint.z, 2), 0.5);
|
||||
//if(distance < 50 && distance > -50)
|
||||
|
||||
//{
|
||||
// if(distance < 0)
|
||||
// distance = distance*-1;
|
||||
// fntdominant->draw3D(rd, "Testing", CoordinateFrame(rd->getCameraToWorldMatrix().rotation, gamepoint), 0.04*distance, Color3::yellow(), Color3::black(), G3D::GFont::XALIGN_CENTER, G3D::GFont::YALIGN_CENTER);
|
||||
//}
|
||||
|
||||
renderDevice->disableLighting();
|
||||
|
||||
@@ -629,51 +571,6 @@ void Application::onGraphics(RenderDevice* rd) {
|
||||
}
|
||||
renderDevice->push2D();
|
||||
_dataModel->getGuiRoot()->renderGUI(renderDevice, m_graphicsWatch.FPS());
|
||||
/*rd->pushState();
|
||||
rd->beforePrimitive();
|
||||
|
||||
if(Globals::showMouse && mouseOnScreen)
|
||||
{
|
||||
glEnable( GL_TEXTURE_2D );
|
||||
glEnable(GL_BLEND);// you enable blending function
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
/*
|
||||
std::vector<Instance*> instances = _dataModel->getWorkspace()->getAllChildren();
|
||||
currentcursorid = cursorid;
|
||||
for(size_t i = 0; i < instances.size(); i++)
|
||||
{
|
||||
if(PartInstance* test = dynamic_cast<PartInstance*>(instances.at(i)))
|
||||
{
|
||||
float time = cameraController.getCamera()->worldRay(_dataModel->mousex, _dataModel->mousey, renderDevice->getViewport()).intersectionTime(test->getBox());
|
||||
//float time = testRay.intersectionTime(test->getBox());
|
||||
if (time != inf())
|
||||
{
|
||||
currentcursorid = cursorOvrid;
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
*/
|
||||
/*glBindTexture( GL_TEXTURE_2D, tool->getCursorId());
|
||||
|
||||
|
||||
glBegin( GL_QUADS );
|
||||
glTexCoord2d(0.0,0.0);
|
||||
glVertex2f(mousepos.x-64, mousepos.y-64);
|
||||
glTexCoord2d( 1.0,0.0 );
|
||||
glVertex2f(mousepos.x+64, mousepos.y-64);
|
||||
glTexCoord2d(1.0,1.0 );
|
||||
glVertex2f(mousepos.x+64, mousepos.y+64 );
|
||||
glTexCoord2d( 0.0,1.0 );
|
||||
glVertex2f( mousepos.x-64, mousepos.y+64 );
|
||||
glEnd();
|
||||
|
||||
glDisable( GL_TEXTURE_2D );*/
|
||||
//}
|
||||
|
||||
/*rd->afterPrimitive();
|
||||
rd->popState();*/
|
||||
renderDevice->pop2D();
|
||||
}
|
||||
|
||||
@@ -732,7 +629,6 @@ void Application::onMouseMoved(int x,int y)
|
||||
mouse.oldy = mouse.y;
|
||||
mouse.x = x;
|
||||
mouse.y = y;
|
||||
//tool->onMouseMoved(mouse);
|
||||
mouseMoveState = true;
|
||||
|
||||
}
|
||||
@@ -748,26 +644,9 @@ void Application::onMouseWheel(int x,int y,short delta)
|
||||
|
||||
void Application::run() {
|
||||
g_usableApp = this;
|
||||
//setDebugMode(false);
|
||||
//debugController.setActive(false);
|
||||
/*
|
||||
if (!createWindowClass("ToolWindowClass",ToolProc,GetModuleHandle(0)))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
HWND propertyHWnd = CreateWindowEx(
|
||||
WS_EX_TOOLWINDOW,"ToolWindowClass", "ToolWindow",
|
||||
WS_SYSMENU | WS_VISIBLE | WS_CHILD,
|
||||
0, 0, 800, 64,
|
||||
hWndMain, NULL, GetModuleHandle(0), NULL);
|
||||
|
||||
ShowWindow(propertyHWnd,SW_SHOW);
|
||||
*/
|
||||
UpdateWindow(_hWndMain);
|
||||
|
||||
// Load objects here=
|
||||
|
||||
Globals::surface = Texture::fromFile(GetFileInPath("/content/images/surfacebr.png"));
|
||||
Globals::surfaceId = Globals::surface->getOpenGLID();
|
||||
cameraSound = GetFileInPath("/content/sounds/SWITCH3.wav");
|
||||
@@ -783,12 +662,7 @@ void Application::run() {
|
||||
RealTime lastWaitTime=0;
|
||||
|
||||
MSG messages;
|
||||
//RECT cRect;
|
||||
//GetClientRect(_hWndMain,&cRect);
|
||||
//renderDevice->notifyResize(cRect.right,cRect.bottom);
|
||||
//Rect2D viewportRect = Rect2D::xywh(0,0,cRect.right,cRect.bottom);
|
||||
//renderDevice->setViewport(viewportRect);
|
||||
//window()->setInputCaptureCount(1);
|
||||
|
||||
resizeWithParent(_hWndMain);
|
||||
glEnable(GL_CULL_FACE);
|
||||
while (!quit)
|
||||
@@ -800,21 +674,15 @@ void Application::run() {
|
||||
|
||||
m_userInputWatch.tick();
|
||||
onUserInput(userInput);
|
||||
//m_moduleManager->onUserInput(_userInput);
|
||||
m_userInputWatch.tock();
|
||||
|
||||
m_simulationWatch.tick();
|
||||
//debugController.doSimulation(clamp(timeStep, 0.0, 0.1));
|
||||
//g3dCamera.setCoordinateFrame
|
||||
//(debugController.getCoordinateFrame());
|
||||
|
||||
double rate = simTimeRate;
|
||||
RealTime rdt = timeStep;
|
||||
SimTime sdt = timeStep * rate;
|
||||
SimTime idt = desiredFrameDuration * rate;
|
||||
|
||||
|
||||
|
||||
onSimulation(rdt,sdt,idt);
|
||||
m_simulationWatch.tock();
|
||||
|
||||
@@ -863,6 +731,24 @@ void Application::resizeWithParent(HWND parentWindow)
|
||||
|
||||
}
|
||||
|
||||
// These should be moved into a "Lighting" class
|
||||
G3D::SkyRef Application::getSky()
|
||||
{
|
||||
return sky;
|
||||
}
|
||||
|
||||
void Application::toggleSky()
|
||||
{
|
||||
_hideSky = !_hideSky;
|
||||
}
|
||||
|
||||
void Application::resize3DView(int w, int h)
|
||||
{
|
||||
Rect2D newViewport = Rect2D::xywh(0, 0, w, h);
|
||||
renderDevice->notifyResize(w, h);
|
||||
renderDevice->setViewport(newViewport);
|
||||
}
|
||||
|
||||
void Application::QuitApp()
|
||||
{
|
||||
PostQuitMessage(0);
|
||||
@@ -871,7 +757,4 @@ void Application::QuitApp()
|
||||
|
||||
void Application::onCreate(HWND parentWindow)
|
||||
{
|
||||
//SetWindowLongPtr(hwndRenderer,GWL_USERDATA,(LONG)this);
|
||||
//SetWindowLongPtr(hwndToolbox,GWL_USERDATA,(LONG)this);
|
||||
//SetWindowLongPtr(hwndMain,GWL_USERDATA,(LONG)&app);
|
||||
}
|
||||
@@ -2,6 +2,7 @@
|
||||
#include "DataModelV2/GuiRootInstance.h"
|
||||
#include "DataModelV2/ToggleImageButtonInstance.h"
|
||||
#include "DataModelV2/DataModelInstance.h"
|
||||
#include "DataModelV2/ThumbnailGeneratorInstance.h"
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
@@ -20,14 +21,11 @@ DataModelInstance::DataModelInstance(void)
|
||||
workspace = new WorkspaceInstance();
|
||||
guiRoot = new GuiRootInstance();
|
||||
level = new LevelInstance();
|
||||
thumbnailGenerator = new ThumbnailGeneratorInstance();
|
||||
|
||||
selectionService = new SelectionService();
|
||||
selectionService->setPropertyWindow(g_usableApp->_propWindow);
|
||||
//children.push_back(workspace);
|
||||
//children.push_back(level);
|
||||
className = "dataModel";
|
||||
//mousex = 0;
|
||||
//mousey = 0;
|
||||
//mouseButton1Down = false;
|
||||
showMessage = false;
|
||||
canDelete = false;
|
||||
_modY=0;
|
||||
@@ -652,3 +650,8 @@ LevelInstance* DataModelInstance::getLevel()
|
||||
{
|
||||
return level;
|
||||
}
|
||||
|
||||
ThumbnailGeneratorInstance* DataModelInstance::getThumbnailGenerator()
|
||||
{
|
||||
return thumbnailGenerator;
|
||||
}
|
||||
|
||||
@@ -43,6 +43,7 @@ GuiRootInstance::GuiRootInstance() : _message(""), _messageTime(0)
|
||||
{
|
||||
g_fntdominant = GFont::fromFile(GetFileInPath("/content/font/dominant.fnt"));
|
||||
g_fntlighttrek = GFont::fromFile(GetFileInPath("/content/font/lighttrek.fnt"));
|
||||
_hideGui = false;
|
||||
|
||||
//Bottom Left
|
||||
TextButtonInstance* button = makeTextButton();
|
||||
@@ -434,6 +435,7 @@ void GuiRootInstance::setDebugMessage(std::string msg, G3D::RealTime msgTime)
|
||||
|
||||
void GuiRootInstance::renderGUI(G3D::RenderDevice* rd, double fps)
|
||||
{
|
||||
if(_hideGui) return;
|
||||
//TODO--Move these to their own instance
|
||||
|
||||
std::stringstream stream;
|
||||
@@ -539,3 +541,7 @@ void GuiRootInstance::onMouseLeftUp(G3D::RenderDevice* renderDevice, int x,int y
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void GuiRootInstance::hideGui(bool doHide) {
|
||||
_hideGui = doHide;
|
||||
}
|
||||
@@ -5,6 +5,7 @@ LevelInstance::LevelInstance(void)
|
||||
{
|
||||
Instance::Instance();
|
||||
name = "Level";
|
||||
className = "LevelService";
|
||||
winMessage = "You Won!";
|
||||
loseMessage = "You Lost. Try Again";
|
||||
timer = 60.0F;
|
||||
|
||||
@@ -6,11 +6,8 @@
|
||||
|
||||
void OnError(int err, std::string msg)
|
||||
{
|
||||
//g_usableApp->window()->setInputCaptureCount(0);
|
||||
//g_usableApp->window()->setMouseVisible(true);
|
||||
std::string emsg = "An unexpected error has occured and "+g_appName+" has to quit. We're sorry!" + msg;
|
||||
std::string title = g_appName+" Crash";
|
||||
//clearInstances();
|
||||
MessageBox(NULL, emsg.c_str(), title.c_str(), MB_OK);
|
||||
exit(err);
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
#include "Application.h"
|
||||
|
||||
int Globals::surfaceId = 2;
|
||||
//bool Globals::showMouse = true;
|
||||
bool Globals::useMousePoint = false;
|
||||
std::vector<Instance*> postRenderStack = std::vector<Instance*>();
|
||||
|
||||
|
||||
@@ -54,9 +54,6 @@ HRESULT IEBrowser::doExternal(std::wstring funcName,
|
||||
else if (funcName==L"SetController")
|
||||
{
|
||||
bool ding = false;
|
||||
//int len = SysStringLen(pDispParams->rgvarg->bstrVal)+1;
|
||||
//char * args = new char[len];
|
||||
//WideCharToMultiByte(CP_ACP, 0, pDispParams->rgvarg->bstrVal, len, args, len, NULL, (LPBOOL)TRUE);
|
||||
if(pDispParams->rgvarg->intVal < 0 || pDispParams->rgvarg->intVal > 7)
|
||||
return S_OK;
|
||||
Enum::Controller::Value cont = (Enum::Controller::Value)pDispParams->rgvarg->intVal;
|
||||
@@ -78,20 +75,9 @@ HRESULT IEBrowser::doExternal(std::wstring funcName,
|
||||
return E_NOTIMPL;
|
||||
int j = pDispParams->rgvarg->intVal;
|
||||
int i = (pDispParams->rgvarg+1)->intVal;
|
||||
//printf("Got values %d and %d", i, j);
|
||||
if(i > 5 || i < 0)
|
||||
return E_NOTIMPL;
|
||||
g_usableApp->changeTool(new SurfaceTool(i, j));
|
||||
/*VARIANT val1;
|
||||
VARIANT val2;
|
||||
unsigned int puArgErr;
|
||||
HRESULT res = DispGetParam(pDispParams,1,VT_VARIANT,&val1, &puArgErr);
|
||||
if(res != S_OK)
|
||||
return res;
|
||||
//res = DispGetParam(pDispParams,1,VT_UI4,&val2, &puArgErr);
|
||||
//if(res != S_OK)
|
||||
//return res;
|
||||
*/
|
||||
return S_OK;
|
||||
}
|
||||
else if(funcName==L"SetColor")
|
||||
@@ -112,11 +98,6 @@ HRESULT IEBrowser::doExternal(std::wstring funcName,
|
||||
color.Flags = CC_FULLOPEN | CC_RGBINIT;
|
||||
if(ChooseColorA((LPCHOOSECOLOR)&color))
|
||||
{
|
||||
//DWORD dwR = GetRValue(color.rgbResult);
|
||||
//DWORD dwG = GetGValue(color.rgbResult);
|
||||
//DWORD dwB = GetBValue(color.rgbResult);
|
||||
//wchar_t * str = L"Test";
|
||||
//swprintf_s(str, 16, L"#%02X%02X%02X", dwR, dwG, dwB);
|
||||
pVarResult->vt = VT_UI4;
|
||||
pVarResult->ulVal = color.rgbResult;
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ void MenuButtonListener::onButton1MouseClick(BaseButtonInstance* button)
|
||||
AppendMenu(mainmenu, MF_STRING, 101, "Open...");
|
||||
AppendMenu(mainmenu, MF_STRING, 102, "Close");
|
||||
AppendMenu(mainmenu, MF_SEPARATOR, 0, NULL);
|
||||
|
||||
POINT p;
|
||||
GetCursorPos(&p);
|
||||
int menuClick = TrackPopupMenu(mainmenu, TPM_LEFTBUTTON | TPM_RETURNCMD, p.x, p.y, 0, Globals::mainHwnd, 0);
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
|
||||
void ModeSelectionListener::onButton1MouseClick(BaseButtonInstance* button)
|
||||
{
|
||||
//CoordinateFrame frame = g_usableApp->g3dCamera.getCoordinateFrame();
|
||||
int mode = g_usableApp->getMode();
|
||||
|
||||
std::vector<Instance*> instances_2D = g_dataModel->getGuiRoot()->getAllChildren();
|
||||
|
||||
@@ -20,7 +20,6 @@ void eprt(PartInstance * instance)
|
||||
{
|
||||
nearest=time;
|
||||
selectedInstance = instance;
|
||||
//This is where dead code below was
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -30,7 +29,6 @@ PartInstance * Mouse::getTarget()
|
||||
selectedInstance = NULL;
|
||||
testRay = g_usableApp->cameraController.getCamera()->worldRay(x, y, g_usableApp->getRenderDevice()->getViewport());
|
||||
nearest=std::numeric_limits<float>::infinity();
|
||||
//Vector3 camPos = g_usableApp->cameraController.getCamera()->getCoordinateFrame().translation;
|
||||
for_each (g_dataModel->getWorkspace()->partObjects.begin(), g_dataModel->getWorkspace()->partObjects.end(), eprt);
|
||||
return selectedInstance;
|
||||
}
|
||||
|
||||
@@ -73,7 +73,6 @@ LRESULT CALLBACK PropProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||
break;
|
||||
case WM_DRAWITEM:
|
||||
{
|
||||
std::cout << "Drawing?" << "\r\n";
|
||||
COLORREF clrBackground;
|
||||
COLORREF clrForeground;
|
||||
TEXTMETRIC tm;
|
||||
|
||||
@@ -105,7 +105,6 @@ void ArrowTool::onMouseMoved(Mouse mouse)
|
||||
return;
|
||||
}
|
||||
PartInstance * target = mouse.getTarget();
|
||||
//if(target == NULL)
|
||||
}
|
||||
void ArrowTool::onSelect(Mouse mouse)
|
||||
{
|
||||
|
||||
@@ -2,8 +2,7 @@
|
||||
|
||||
Tool::Tool(void)
|
||||
{
|
||||
//cursorString = GetFileInPath("/content/images/ArrowFarCursor.png");
|
||||
//cursorId = cursorRef->openGLID();
|
||||
|
||||
}
|
||||
|
||||
Tool::~Tool(void)
|
||||
@@ -21,12 +20,4 @@ void Tool::onSelect(Mouse mouse){}
|
||||
void Tool::onDeselect(Mouse mouse){}
|
||||
void Tool::onMouseScroll(Mouse mouse){}
|
||||
void Tool::onKeyDown(int key){}
|
||||
void Tool::onKeyUp(int key){}
|
||||
/*void Tool::setCursor(std::string str)
|
||||
{
|
||||
//cursorString = str;
|
||||
}*/
|
||||
/*int Tool::getCursorId()
|
||||
{
|
||||
return TextureHandler::getTexturePermanent(cursorString);
|
||||
}*/
|
||||
void Tool::onKeyUp(int key){}
|
||||
@@ -1,14 +1,6 @@
|
||||
#include "XplicitNgine/XplicitNgine.h"
|
||||
#include "Globals.h"
|
||||
|
||||
//#define SIDE (0.5f)
|
||||
//#define MASS (1.0)
|
||||
|
||||
// constraints
|
||||
//#define MAX_BODIES 65535
|
||||
//#define OBJ_DENSITY (5.0)
|
||||
//#define MAX_CONTACT_PER_BODY 4
|
||||
|
||||
XplicitNgine::XplicitNgine()
|
||||
{
|
||||
|
||||
@@ -23,7 +15,6 @@ XplicitNgine::XplicitNgine()
|
||||
dWorldSetAutoDisableSteps(physWorld, 20);
|
||||
|
||||
this->name = "PhysicsService";
|
||||
//dGeomID ground_geom = dCreatePlane(physSpace, 0, 1, 0, 0);
|
||||
}
|
||||
|
||||
XplicitNgine::~XplicitNgine()
|
||||
@@ -58,7 +49,6 @@ void collisionCallback(void *data, dGeomID o1, dGeomID o2)
|
||||
contact[i].surface.mode = dContactBounce | dContactSlip1 | dContactSlip2 | dContactSoftERP | dContactSoftCFM | dContactApprox1;
|
||||
|
||||
// Define contact surface properties
|
||||
|
||||
contact[i].surface.bounce = 0.5; //Elasticity
|
||||
contact[i].surface.mu = 0.4F; //Friction
|
||||
contact[i].surface.slip1 = 0.0;
|
||||
@@ -121,9 +111,6 @@ void XplicitNgine::deleteBody(PartInstance* partInstance)
|
||||
|
||||
void XplicitNgine::createBody(PartInstance* partInstance)
|
||||
{
|
||||
// calculate collisions
|
||||
//dSpaceCollide (physSpace,0,&collisionCallback);
|
||||
|
||||
if(partInstance->physBody == NULL)
|
||||
{
|
||||
|
||||
@@ -131,6 +118,7 @@ void XplicitNgine::createBody(PartInstance* partInstance)
|
||||
Vector3 partPosition = partInstance->getPosition();
|
||||
Vector3 velocity = partInstance->getVelocity();
|
||||
Vector3 rotVelocity = partInstance->getRotVelocity();
|
||||
|
||||
// init body
|
||||
partInstance->physBody = dBodyCreate(physWorld);
|
||||
dBodySetData(partInstance->physBody, partInstance);
|
||||
@@ -146,11 +134,6 @@ void XplicitNgine::createBody(PartInstance* partInstance)
|
||||
|
||||
dVector3 result;
|
||||
dGeomBoxGetLengths(partInstance->physGeom[0], result);
|
||||
//printf("[XplicitNgine] Part Geom Size: %.1f, %.1f, %.1f\n",
|
||||
// result[0],
|
||||
// result[1],
|
||||
// result[2]
|
||||
//);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -161,11 +144,7 @@ void XplicitNgine::createBody(PartInstance* partInstance)
|
||||
mass.setBox(sqrt(partSize.x*2), sqrt(partSize.y*2), sqrt(partSize.z*2), 0.7F);
|
||||
dBodySetMass(partInstance->physBody, &mass);
|
||||
|
||||
// Debug output
|
||||
|
||||
|
||||
// Create rigid body
|
||||
//printf("[XplicitNgine] Created Geom for PartInstance\n");
|
||||
dBodySetPosition(partInstance->physBody,
|
||||
partPosition.x,
|
||||
partPosition.y,
|
||||
@@ -187,8 +166,6 @@ void XplicitNgine::createBody(PartInstance* partInstance)
|
||||
dGeomSetRotation(partInstance->physGeom[0], rotation);
|
||||
dBodySetRotation(partInstance->physBody, rotation);
|
||||
|
||||
//printf("[XplicitNgine] Created Body for PartInstance\n");
|
||||
|
||||
if(!partInstance->isAnchored() && !partInstance->isDragging())
|
||||
dGeomSetBody(partInstance->physGeom[0], partInstance->physBody);
|
||||
|
||||
@@ -203,10 +180,7 @@ void XplicitNgine::createBody(PartInstance* partInstance)
|
||||
|
||||
const dReal* physPosition = dBodyGetPosition(partInstance->physBody);
|
||||
|
||||
// TODO: Rotation code
|
||||
// Probably should be done AFTER we get physics KINDA working!!!
|
||||
const dReal* physRotation = dGeomGetRotation(partInstance->physGeom[0]);
|
||||
//partInstance->setPosition(Vector3(physPosition[0], physPosition[1], physPosition[2]));
|
||||
partInstance->setCFrameNoSync(CoordinateFrame(
|
||||
Matrix3(physRotation[0],physRotation[1],physRotation[2],
|
||||
physRotation[4],physRotation[5],physRotation[6],
|
||||
@@ -214,9 +188,6 @@ void XplicitNgine::createBody(PartInstance* partInstance)
|
||||
Vector3(physPosition[0], physPosition[1], physPosition[2])));
|
||||
}
|
||||
}
|
||||
//STEP SHOULD NOT BE HERE!
|
||||
//dWorldQuickStep(physWorld, stepSize);
|
||||
//dJointGroupEmpty(contactgroup);
|
||||
}
|
||||
|
||||
void XplicitNgine::step(float stepSize)
|
||||
@@ -224,8 +195,6 @@ void XplicitNgine::step(float stepSize)
|
||||
dJointGroupEmpty(contactgroup);
|
||||
dSpaceCollide (physSpace,0,&collisionCallback);
|
||||
dWorldQuickStep(physWorld, stepSize);
|
||||
//dWorldStepFast1(physWorld, stepSize*2, 100);
|
||||
//dWorldStep(physWorld, stepSize);
|
||||
}
|
||||
|
||||
void XplicitNgine::updateBody(PartInstance *partInstance)
|
||||
|
||||
282
src/source/base64.cpp
Normal file
282
src/source/base64.cpp
Normal file
@@ -0,0 +1,282 @@
|
||||
/*
|
||||
base64.cpp and base64.h
|
||||
|
||||
base64 encoding and decoding with C++.
|
||||
More information at
|
||||
https://renenyffenegger.ch/notes/development/Base64/Encoding-and-decoding-base-64-with-cpp
|
||||
|
||||
Version: 2.rc.08 (release candidate)
|
||||
|
||||
Copyright (C) 2004-2017, 2020, 2021 René Nyffenegger
|
||||
|
||||
This source code is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the author be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this source code must not be misrepresented; you must not
|
||||
claim that you wrote the original source code. If you use this source code
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original source code.
|
||||
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
|
||||
René Nyffenegger rene.nyffenegger@adp-gmbh.ch
|
||||
|
||||
*/
|
||||
|
||||
#include "base64.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <stdexcept>
|
||||
|
||||
//
|
||||
// Depending on the url parameter in base64_chars, one of
|
||||
// two sets of base64 characters needs to be chosen.
|
||||
// They differ in their last two characters.
|
||||
//
|
||||
static const char* base64_chars[2] = {
|
||||
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
|
||||
"abcdefghijklmnopqrstuvwxyz"
|
||||
"0123456789"
|
||||
"+/",
|
||||
|
||||
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
|
||||
"abcdefghijklmnopqrstuvwxyz"
|
||||
"0123456789"
|
||||
"-_"};
|
||||
|
||||
static unsigned int pos_of_char(const unsigned char chr) {
|
||||
//
|
||||
// Return the position of chr within base64_encode()
|
||||
//
|
||||
|
||||
if (chr >= 'A' && chr <= 'Z') return chr - 'A';
|
||||
else if (chr >= 'a' && chr <= 'z') return chr - 'a' + ('Z' - 'A') + 1;
|
||||
else if (chr >= '0' && chr <= '9') return chr - '0' + ('Z' - 'A') + ('z' - 'a') + 2;
|
||||
else if (chr == '+' || chr == '-') return 62; // Be liberal with input and accept both url ('-') and non-url ('+') base 64 characters (
|
||||
else if (chr == '/' || chr == '_') return 63; // Ditto for '/' and '_'
|
||||
else
|
||||
//
|
||||
// 2020-10-23: Throw std::exception rather than const char*
|
||||
//(Pablo Martin-Gomez, https://github.com/Bouska)
|
||||
//
|
||||
throw std::runtime_error("Input is not valid base64-encoded data.");
|
||||
}
|
||||
|
||||
static std::string insert_linebreaks(std::string str, size_t distance) {
|
||||
//
|
||||
// Provided by https://github.com/JomaCorpFX, adapted by me.
|
||||
//
|
||||
if (!str.length()) {
|
||||
return "";
|
||||
}
|
||||
|
||||
size_t pos = distance;
|
||||
|
||||
while (pos < str.size()) {
|
||||
str.insert(pos, "\n");
|
||||
pos += distance + 1;
|
||||
}
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
template <typename String, unsigned int line_length>
|
||||
static std::string encode_with_line_breaks(String s) {
|
||||
return insert_linebreaks(base64_encode(s, false), line_length);
|
||||
}
|
||||
|
||||
template <typename String>
|
||||
static std::string encode_pem(String s) {
|
||||
return encode_with_line_breaks<String, 64>(s);
|
||||
}
|
||||
|
||||
template <typename String>
|
||||
static std::string encode_mime(String s) {
|
||||
return encode_with_line_breaks<String, 76>(s);
|
||||
}
|
||||
|
||||
template <typename String>
|
||||
static std::string encode(String s, bool url) {
|
||||
return base64_encode(reinterpret_cast<const unsigned char*>(s.data()), s.length(), url);
|
||||
}
|
||||
|
||||
std::string base64_encode(unsigned char const* bytes_to_encode, size_t in_len, bool url) {
|
||||
|
||||
size_t len_encoded = (in_len +2) / 3 * 4;
|
||||
|
||||
unsigned char trailing_char = url ? '.' : '=';
|
||||
|
||||
//
|
||||
// Choose set of base64 characters. They differ
|
||||
// for the last two positions, depending on the url
|
||||
// parameter.
|
||||
// A bool (as is the parameter url) is guaranteed
|
||||
// to evaluate to either 0 or 1 in C++ therefore,
|
||||
// the correct character set is chosen by subscripting
|
||||
// base64_chars with url.
|
||||
//
|
||||
const char* base64_chars_ = base64_chars[url];
|
||||
|
||||
std::string ret;
|
||||
ret.reserve(len_encoded);
|
||||
|
||||
unsigned int pos = 0;
|
||||
|
||||
while (pos < in_len) {
|
||||
ret.push_back(base64_chars_[(bytes_to_encode[pos + 0] & 0xfc) >> 2]);
|
||||
|
||||
if (pos+1 < in_len) {
|
||||
ret.push_back(base64_chars_[((bytes_to_encode[pos + 0] & 0x03) << 4) + ((bytes_to_encode[pos + 1] & 0xf0) >> 4)]);
|
||||
|
||||
if (pos+2 < in_len) {
|
||||
ret.push_back(base64_chars_[((bytes_to_encode[pos + 1] & 0x0f) << 2) + ((bytes_to_encode[pos + 2] & 0xc0) >> 6)]);
|
||||
ret.push_back(base64_chars_[ bytes_to_encode[pos + 2] & 0x3f]);
|
||||
}
|
||||
else {
|
||||
ret.push_back(base64_chars_[(bytes_to_encode[pos + 1] & 0x0f) << 2]);
|
||||
ret.push_back(trailing_char);
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
ret.push_back(base64_chars_[(bytes_to_encode[pos + 0] & 0x03) << 4]);
|
||||
ret.push_back(trailing_char);
|
||||
ret.push_back(trailing_char);
|
||||
}
|
||||
|
||||
pos += 3;
|
||||
}
|
||||
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
template <typename String>
|
||||
static std::string decode(String encoded_string, bool remove_linebreaks) {
|
||||
//
|
||||
// decode(…) is templated so that it can be used with String = const std::string&
|
||||
// or std::string_view (requires at least C++17)
|
||||
//
|
||||
|
||||
if (encoded_string.empty()) return std::string();
|
||||
|
||||
if (remove_linebreaks) {
|
||||
|
||||
std::string copy(encoded_string);
|
||||
|
||||
copy.erase(std::remove(copy.begin(), copy.end(), '\n'), copy.end());
|
||||
|
||||
return base64_decode(copy, false);
|
||||
}
|
||||
|
||||
size_t length_of_string = encoded_string.length();
|
||||
size_t pos = 0;
|
||||
|
||||
//
|
||||
// The approximate length (bytes) of the decoded string might be one or
|
||||
// two bytes smaller, depending on the amount of trailing equal signs
|
||||
// in the encoded string. This approximation is needed to reserve
|
||||
// enough space in the string to be returned.
|
||||
//
|
||||
size_t approx_length_of_decoded_string = length_of_string / 4 * 3;
|
||||
std::string ret;
|
||||
ret.reserve(approx_length_of_decoded_string);
|
||||
|
||||
while (pos < length_of_string) {
|
||||
//
|
||||
// Iterate over encoded input string in chunks. The size of all
|
||||
// chunks except the last one is 4 bytes.
|
||||
//
|
||||
// The last chunk might be padded with equal signs or dots
|
||||
// in order to make it 4 bytes in size as well, but this
|
||||
// is not required as per RFC 2045.
|
||||
//
|
||||
// All chunks except the last one produce three output bytes.
|
||||
//
|
||||
// The last chunk produces at least one and up to three bytes.
|
||||
//
|
||||
|
||||
size_t pos_of_char_1 = pos_of_char(encoded_string[pos+1] );
|
||||
|
||||
//
|
||||
// Emit the first output byte that is produced in each chunk:
|
||||
//
|
||||
ret.push_back(static_cast<std::string::value_type>( ( (pos_of_char(encoded_string[pos+0]) ) << 2 ) + ( (pos_of_char_1 & 0x30 ) >> 4)));
|
||||
|
||||
if ( ( pos + 2 < length_of_string ) && // Check for data that is not padded with equal signs (which is allowed by RFC 2045)
|
||||
encoded_string[pos+2] != '=' &&
|
||||
encoded_string[pos+2] != '.' // accept URL-safe base 64 strings, too, so check for '.' also.
|
||||
)
|
||||
{
|
||||
//
|
||||
// Emit a chunk's second byte (which might not be produced in the last chunk).
|
||||
//
|
||||
unsigned int pos_of_char_2 = pos_of_char(encoded_string[pos+2] );
|
||||
ret.push_back(static_cast<std::string::value_type>( (( pos_of_char_1 & 0x0f) << 4) + (( pos_of_char_2 & 0x3c) >> 2)));
|
||||
|
||||
if ( ( pos + 3 < length_of_string ) &&
|
||||
encoded_string[pos+3] != '=' &&
|
||||
encoded_string[pos+3] != '.'
|
||||
)
|
||||
{
|
||||
//
|
||||
// Emit a chunk's third byte (which might not be produced in the last chunk).
|
||||
//
|
||||
ret.push_back(static_cast<std::string::value_type>( ( (pos_of_char_2 & 0x03 ) << 6 ) + pos_of_char(encoded_string[pos+3]) ));
|
||||
}
|
||||
}
|
||||
|
||||
pos += 4;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
std::string base64_decode(std::string const& s, bool remove_linebreaks) {
|
||||
return decode(s, remove_linebreaks);
|
||||
}
|
||||
|
||||
std::string base64_encode(std::string const& s, bool url) {
|
||||
return encode(s, url);
|
||||
}
|
||||
|
||||
std::string base64_encode_pem (std::string const& s) {
|
||||
return encode_pem(s);
|
||||
}
|
||||
|
||||
std::string base64_encode_mime(std::string const& s) {
|
||||
return encode_mime(s);
|
||||
}
|
||||
|
||||
#if __cplusplus >= 201703L
|
||||
//
|
||||
// Interface with std::string_view rather than const std::string&
|
||||
// Requires C++17
|
||||
// Provided by Yannic Bonenberger (https://github.com/Yannic)
|
||||
//
|
||||
|
||||
std::string base64_encode(std::string_view s, bool url) {
|
||||
return encode(s, url);
|
||||
}
|
||||
|
||||
std::string base64_encode_pem(std::string_view s) {
|
||||
return encode_pem(s);
|
||||
}
|
||||
|
||||
std::string base64_encode_mime(std::string_view s) {
|
||||
return encode_mime(s);
|
||||
}
|
||||
|
||||
std::string base64_decode(std::string_view s, bool remove_linebreaks) {
|
||||
return decode(s, remove_linebreaks);
|
||||
}
|
||||
|
||||
#endif // __cplusplus >= 201703L
|
||||
@@ -63,12 +63,7 @@ LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||
|
||||
LRESULT CALLBACK ToolboxProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
//Application *app = (Application *)GetWindowLongPtr(hwnd, GWL_USERDATA);
|
||||
MessageBox(NULL, (LPCSTR)wParam, (LPCSTR)lParam, 1);
|
||||
//if (app==NULL)
|
||||
//{
|
||||
//return DefWindowProc(hwnd, msg, wParam, lParam);
|
||||
//}
|
||||
switch(msg)
|
||||
{
|
||||
case WM_SIZE:
|
||||
@@ -152,24 +147,11 @@ int main(int argc, char** argv) {
|
||||
try{
|
||||
#endif
|
||||
hresult = OleInitialize(NULL);
|
||||
|
||||
/* IInternetSecurityManager *pSecurityMgr;
|
||||
IInternetZoneManager *pZoneMgr;
|
||||
LPCWSTR site1 = SysAllocString(L"http://www.androdome.com");
|
||||
|
||||
hr = CoCreateInstance(CLSID_InternetSecurityManager, NULL, CLSCTX_INPROC_SERVER, IID_IInternetSecurityManager, (void**)&pSecurityMgr);
|
||||
|
||||
pSecurityMgr->SetZoneMapping((DWORD)2, site1, (DWORD)0); // 2 = Trusted Site, site1 is the URL to add, and 0 is to create the entry.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
if (!AXRegister())
|
||||
return 0;
|
||||
|
||||
|
||||
INITCOMMONCONTROLSEX icc;
|
||||
// WNDCLASSEX wcx;
|
||||
|
||||
/* Initialize common controls. Also needed for MANIFEST's */
|
||||
|
||||
@@ -179,10 +161,6 @@ int main(int argc, char** argv) {
|
||||
InitCommonControlsEx(&icc);
|
||||
|
||||
AudioPlayer::init();
|
||||
/* GAppSettings settings;
|
||||
settings.window.resizable = true;
|
||||
settings.writeLicenseFile = false;
|
||||
settings.window.center = true; */
|
||||
HMODULE hThisInstance = GetModuleHandle(NULL);
|
||||
|
||||
if (!createWindowClass("mainHWND",WndProc,hThisInstance))
|
||||
|
||||
Reference in New Issue
Block a user