Code directory changes

This commit is contained in:
Vulpovile
2021-03-04 21:48:29 -08:00
parent 8bf27c6412
commit 12843a0890
87 changed files with 224 additions and 510 deletions

92
src/include/Application.h Normal file
View File

@@ -0,0 +1,92 @@
#pragma once
#include <G3DAll.h>
#include "PropertyWindow.h"
#include "TextButtonInstance.h"
#include "ImageButtonInstance.h"
#include "CameraController.h"
#include "IEBrowser.h"
#include "Mouse.h"
#include "Tool.h"
//#include "GuiRoot.h"
class TextButtonInstance;
class ImageButtonInstance;
class PartInstance;
class CameraController;
class Application { // : public GApp {
public:
Application(HWND parentWindow);
void Boop();
virtual ~Application() {}
virtual void exitApplication();
virtual void onInit();
virtual void onLogic();
virtual void onNetwork();
virtual void onSimulation(RealTime rdt, SimTime sdt, SimTime idt);
virtual void onGraphics(RenderDevice* rd);
virtual void onUserInput(UserInput* ui);
virtual void onCleanup();
void clearInstances();
void navigateToolbox(std::string);
PartInstance* makePart();
void drawButtons(RenderDevice* rd);
void drawOutline(Vector3 from, Vector3 to, RenderDevice* rd, LightingParameters lighting, Vector3 size, Vector3 pos, CoordinateFrame c);
void makeFlag(Vector3 &vec, RenderDevice* &rd);
std::vector<Instance*> getSelection();
void deleteInstance();
void run();
void QuitApp();
void resizeWithParent(HWND parentWindow);
void onCreate(HWND parentWindow);
void onKeyPressed(int key);
void onKeyUp(int key);
void onMouseLeftPressed(HWND hwnd,int x, int y);
void onMouseLeftUp(RenderDevice* renderDevice, int x, int y);
void onMouseRightPressed(int x, int y);
void onMouseRightUp(int x, int y);
void onMouseMoved(int x, int y);
void onMouseWheel(int x, int y, short delta);
void setFocus(bool isFocused);
int getMode();
CameraController cameraController;
UserInput* userInput;
PropertyWindow* _propWindow;
void generateShadowMap(const CoordinateFrame& lightViewMatrix) const;
RenderDevice* getRenderDevice();
void selectInstance(Instance* selectedInstance,PropertyWindow* propWindow);
void setMode(int mode);
Tool * tool;
void changeTool(Tool *);
Mouse mouse;
private:
bool mouseMoveState;
RenderDevice* renderDevice;
//void initGUI();
HWND _hWndMain;
SkyRef sky;
bool quit;
bool mouseOnScreen;
bool rightButtonHolding;
void main();
GWindow* _window;
HWND _hwndToolbox;
HWND _buttonTest;
HWND _hwndRenderer;
DataModelInstance* _dataModel;
G3D::TextureRef shadowMap;
std::string _title;
bool _dragging;
int _mode;
GAppSettings _settings;
double lightProjX, lightProjY, lightProjNear, lightProjFar;
IEBrowser* webBrowser;
protected:
Stopwatch m_graphicsWatch;
Stopwatch m_logicWatch;
Stopwatch m_networkWatch;
Stopwatch m_userInputWatch;
Stopwatch m_simulationWatch;
Stopwatch m_waitWatch;
};

23
src/include/ArrowTool.h Normal file
View File

@@ -0,0 +1,23 @@
#pragma once
#include "tool.h"
class ArrowTool :
public Tool
{
public:
ArrowTool(void); //OnSelect?
~ArrowTool(void); //OnDeselect?
virtual void onButton1MouseDown(Mouse);
virtual void onButton1MouseUp(Mouse);
virtual void onMouseMoved(Mouse mouse);
virtual void onSelect(Mouse mouse);
virtual void onKeyDown(int key);
virtual void onKeyUp(int key);
private:
bool lctrlDown;
bool rctrlDown;
int mouseDownStartx;
int mouseDownStarty;
bool dragging;
bool mouseDown;
};

11
src/include/AudioPlayer.h Normal file
View File

@@ -0,0 +1,11 @@
#include <G3DAll.h>
#pragma once
class AudioPlayer
{
public:
AudioPlayer(void);
~AudioPlayer(void);
static void playSound(std::string);
static void init();
};

View File

@@ -0,0 +1,26 @@
#pragma once
#include "instance.h"
#include "ButtonListener.h"
class ButtonListener;
class Instance;
class BaseButtonInstance : public Instance
{
public:
BaseButtonInstance(void);
virtual ~BaseButtonInstance(void);
virtual void render(RenderDevice* rd);
virtual void drawObj(RenderDevice* rd, Vector2 mousePos, bool mouseDown);
virtual bool mouseInButton(float, float, RenderDevice* rd);
virtual void onMouseClick();
void setButtonListener(ButtonListener*);
bool floatBottom;
bool floatRight;
bool floatCenter;
volatile bool disabled;
bool selected;
protected:
bool mouseInArea(float, float, float, float, float, float);
class ButtonListener* listener;
};

View File

@@ -0,0 +1,8 @@
#pragma once
#include <Mshtmhst.h>
class BrowserCallHandler : IDocHostUIHandler
{
public:
BrowserCallHandler(void);
~BrowserCallHandler(void);
};

View File

@@ -0,0 +1,22 @@
#pragma once
//#include "Application.h"
#include "BaseButtonInstance.h"
class BaseButtonInstance;
class ButtonListener
{
public:
ButtonListener();
~ButtonListener(void);
virtual void onButton1MouseClick(BaseButtonInstance*);
bool doDelete;
//virtual void onMouseOver(); //TODO
//virtual void onMouseOut(); //TODO
//virtual void onButton1MouseDown(); //TODO
//virtual void onButton1MouseUp(); //TODO
//virtual void onButton2MouseClick(); //TODO
//virtual void onButton2MouseDown(); //TODO
//virtual void onButton2MouseUp(); //TODO
//What to do now...
};

View File

@@ -0,0 +1,7 @@
#pragma once
#include "ButtonListener.h"
class CameraButtonListener : public ButtonListener {
public:
void onButton1MouseClick(BaseButtonInstance*);
};

View File

@@ -0,0 +1,47 @@
#pragma once
#include <G3DAll.h>
#include "Instance.h"
#include "Globals.h"
#include <string>
#define CAM_ZOOM_MIN 0.1f
#define CAM_ZOOM_MAX 100.f
class Application;
class CameraController {
public:
CameraController();
G3D::CoordinateFrame getCoordinateFrame();
void setFrame(const CoordinateFrame& cf);
void lookAt(const Vector3& position);
void refreshZoom(const CoordinateFrame& frame);
void pan(CoordinateFrame* frame,float spdX,float spdY);
void panLock(CoordinateFrame* frame,float spdX,float spdY);
void update(Application* app);
void centerCamera(Instance* selection);
void panLeft();
void panRight();
void tiltUp();
void tiltDown();
void Zoom(short delta);
bool onMouseWheel(int x, int y, short delta);
GCamera* getCamera();
private:
Vector3 translation;
Vector3 focusPosition;
float yaw;
float pitch;
float moveRate;
float zoom;
bool forwards;
bool backwards;
bool left;
bool right;
bool rightButtonHolding;
POINT oldDesktopMouse;
GCamera g3dCamera;
std::string cameraSound;
};

View File

@@ -0,0 +1,57 @@
#pragma once
#include "WorkspaceInstance.h"
#include "LevelInstance.h"
#include "PartInstance.h"
#include "rapidxml/rapidxml.hpp"
#include "GuiRootInstance.h"
class GuiRootInstance;
class DataModelInstance :
public Instance
{
public:
DataModelInstance(void);
~DataModelInstance(void);
void setMessage(std::string);
void setMessageBrickCount();
void clearMessage();
bool debugGetOpen();
bool getOpen();
bool load(const char* filename,bool clearObjects);
bool readXMLFileStream(std::ifstream* file);
void drawMessage(RenderDevice*);
WorkspaceInstance* getWorkspace();
LevelInstance * getLevel();
std::string message;
std::string _loadedFileName;
bool showMessage;
G3D::GFontRef font;
GuiRootInstance* getGuiRoot();
//float mousex;
//float mousey;
//Vector2 getMousePos();
//void setMousePos(int x,int y);
//void setMousePos(Vector2 pos);
//bool mouseButton1Down;
PartInstance* makePart();
void clearLevel();
void toggleRun();
bool isRunning();
#if _DEBUG
void modXMLLevel(float modY);
#endif
private:
bool isBrickCount;
bool scanXMLObject(rapidxml::xml_node<>* node);
rapidxml::xml_node<>* getNode(rapidxml::xml_node<> * node,const char* name );
float getFloatValue(rapidxml::xml_node<> * node,const char* name);
bool _successfulLoad;
std::string _errMsg;
bool _legacyLoad;
float _modY;
WorkspaceInstance* workspace;
LevelInstance * level;
GuiRootInstance* guiRoot;
bool running;
};

View File

@@ -0,0 +1,6 @@
#include "ButtonListener.h"
class DeleteListener : public ButtonListener {
public:
void onButton1MouseClick(BaseButtonInstance*);
};

23
src/include/Enum.h Normal file
View File

@@ -0,0 +1,23 @@
#pragma once
namespace Enum
{
namespace SurfaceType
{
enum Value {
Smooth, Snaps, Inlets, Glue, Weld, Spawn, Hinge, Motor, Bumps
};
}
namespace Shape
{
enum Value {
Ball = 0, Block = 1, Cylinder = 2
};
}
namespace Controller
{
enum Value {
Player = 7, KeyboardRight = 1, KeyboardLeft = 2, Joypad1 = 3, Joypad2 = 4, Chase = 5, Flee = 6, None = 0
};
}
}

16
src/include/Enums.h Normal file
View File

@@ -0,0 +1,16 @@
#ifdef UENUMS
#ifndef ENUM_H
#define ENUM_H
static enum BinType {GameTool, Grab, Clone, Hammer};
static enum ControllerType {None, KeyboardRight, KeyboardLeft, Joypad1, Joypad2, Chase, Flee};
//static enum JointType {UNK0, WeldJoint, SnapJoint, UNK3, Rotate, RotateP, RotateV, GlueJoint, UNK8, UNK9, None};
static enum ActionType {Nothing, Pause, Lose, Draw, Win};
static enum AffectType {NoChange, Increase, Decrease};
static enum InputType {NoInput, LeftTread, RightTread, Steer, Throtle, UpDown, Action1, Action2, Action3, Action4, Action5, Constant, Sin};
//static enum SurfaceConstraint {None, Hinge, SteppingMotor, Motor};
static enum SurfaceType{Smooth, Snaps, Inlets, Glue, Weld, Spawn, Hinge, Motor, Bumps};
static enum SoundType {NoSound, Boing, Bomb, Break, Click, Clock, Slingshot, Page, Ping, Snap, Splat, Step, StepOn, Swoosh, Victory};
static enum PartType {Ball, Block, Cylinder};
static enum KeywordFilterType {Include, Exclude};
#endif
#endif

View File

@@ -0,0 +1,6 @@
#pragma once
#include <string>
void OnError(int err, std::string msg = "");
void MessageBoxStr(std::string msg);
void MessageBoxStream(std::stringstream msg);

View File

@@ -0,0 +1,7 @@
#pragma once
#include "ButtonListener.h"
class GUDButtonListener : public ButtonListener {
public:
void onButton1MouseClick(BaseButtonInstance*);
};

39
src/include/Globals.h Normal file
View File

@@ -0,0 +1,39 @@
#pragma once
#include "DataModelInstance.h"
class Application;
class Globals
{
public:
Globals(void);
~Globals(void);
static DataModelInstance* dataModel;
static bool showMouse;
static POINT mousepoint;
static bool useMousePoint;
static const int gen;
static const int major;
static const int minor;
static const int patch;
static G3D::TextureRef surface;
static int surfaceId;
static const std::string g_PlaceholderName;
static COLORREF g_acrCustClr[16]; //Will be dynamic later
};
extern std::vector<Instance*> postRenderStack;
extern std::vector<Instance*> g_selectedInstances;
extern bool running;
extern DataModelInstance* g_dataModel;
extern Application* g_usableApp;
extern GFontRef g_fntdominant;
extern GFontRef g_fntlighttrek;
extern COLORREF g_acrCustClr[16]; //Will be dynamic later
extern std::string cameraSound;
extern std::string clickSound;
extern std::string dingSound;
const std::string g_PlaceholderName = "Dygysphere";

View File

@@ -0,0 +1,16 @@
#pragma once
#include "PartInstance.h"
class GroupInstance :
public PVInstance
{
public:
GroupInstance(void);
~GroupInstance(void);
GroupInstance(const GroupInstance &oinst);
virtual std::vector<PROPGRIDITEM> getProperties();
virtual void PropUpdate(LPPROPGRIDITEM &pItem);
std::vector<Instance *> unGroup();
PartInstance * primaryPart;
void render(RenderDevice * r);
};

View File

@@ -0,0 +1,24 @@
#pragma once
#include "Instance.h"
class ImageButtonInstance;
class TextButtonInstance;
class GuiRootInstance : public Instance
{
public:
GuiRootInstance();
GuiRootInstance::~GuiRootInstance();
TextButtonInstance* makeTextButton();
void drawButtons(RenderDevice* rd);
ImageButtonInstance* makeImageButton(G3D::TextureRef newImage, G3D::TextureRef overImage, G3D::TextureRef downImage, G3D::TextureRef disableImage);
void renderGUI(G3D::RenderDevice* rd, double fps);
void setDebugMessage(std::string msg, G3D::RealTime msgTime);
void update();
bool mouseInGUI(G3D::RenderDevice* renderDevice,int x,int y);
void onMouseLeftUp(G3D::RenderDevice* renderDevice, int x,int y);
private:
std::string _message;
G3D::RealTime _messageTime;
};

28
src/include/IEBrowser.h Normal file
View File

@@ -0,0 +1,28 @@
//#include "WindowFunctions.h"
#pragma once
#include "Globals.h"
#pragma once
#include <mshtml.h>
#include <exdisp.h>
#include <Mshtmhst.h>
#include "IEDispatcher.h"
#include "AudioPlayer.h"
class IEBrowser {
public:
IEBrowser(HWND attachHWnd);
~IEBrowser(void);
bool navigateSyncURL(wchar_t* url);
HRESULT doExternal(std::wstring funcName,
DISPID dispIdMember,
REFIID riid,
LCID lcid,
WORD wFlags,
DISPPARAMS FAR* pDispParams,
VARIANT FAR* pVarResult,
EXCEPINFO FAR* pExcepInfo,
unsigned int FAR* puArgErr);
private:
IWebBrowser2* webBrowser;
HWND hwnd;
};

View File

@@ -0,0 +1,29 @@
#pragma once
#include "oaidl.h"
//DEFINE_GUID(CLSID_G3d, 0xB323F8E0L, 0x2E68, 0x11D0, 0x90, 0xEA, 0x00, 0xAA, 0x00, 0x60, 0xF8, 0x6F);
class IEDispatcher : public IDispatch
{
/*
EXTERN_C const IID IID_IDispatch;
#if defined(__cplusplus) && !defined(CINTERFACE)
MIDL_INTERFACE("B323F8E0-2E68-11D0-90EA-00AA0060F86F")
IEDispatcher : public IDispatch
{
*/
public:
IEDispatcher(void);
~IEDispatcher(void);
HRESULT STDMETHODCALLTYPE IEDispatcher::QueryInterface(const IID &riid, void **ppvObject);
ULONG STDMETHODCALLTYPE IEDispatcher::AddRef();
ULONG STDMETHODCALLTYPE IEDispatcher::Release();
HRESULT STDMETHODCALLTYPE IEDispatcher::GetTypeInfoCount(UINT *pctinfo);
HRESULT STDMETHODCALLTYPE IEDispatcher::GetTypeInfo(UINT, LCID, ITypeInfo **);
HRESULT STDMETHODCALLTYPE IEDispatcher::GetIDsOfNames(const IID &, LPOLESTR *, UINT, LCID, DISPID *);
HRESULT STDMETHODCALLTYPE IEDispatcher::Invoke(DISPID, const IID &, LCID, WORD, DISPPARAMS *, VARIANT *, EXCEPINFO *, UINT *);
};
//#endif

View File

@@ -0,0 +1,27 @@
#pragma once
#include "BaseButtonInstance.h"
class BaseButtonInstance;
class ImageButtonInstance : public BaseButtonInstance
{
public:
//ImageButtonInstance(G3D::TextureRef);
//ImageButtonInstance(G3D::TextureRef,G3D::TextureRef);
//ImageButtonInstance(G3D::TextureRef,G3D::TextureRef,G3D::TextureRef);
ImageButtonInstance(G3D::TextureRef,G3D::TextureRef,G3D::TextureRef,G3D::TextureRef);
~ImageButtonInstance(void);
void drawObj(RenderDevice*, Vector2, bool);
Vector2 size;
Vector2 position;
G3D::TextureRef image;
int openGLID;
G3D::TextureRef image_ovr;
int openGLID_ovr;
G3D::TextureRef image_dn;
int openGLID_dn;
G3D::TextureRef image_ds;
int openGLID_ds;
bool mouseInButton(float, float, RenderDevice*);
};

37
src/include/Instance.h Normal file
View File

@@ -0,0 +1,37 @@
#pragma once
#include <G3DAll.h>
#include "propertyGrid.h"
#include "map"
class Instance
{
public:
bool canDelete;
Instance(void);
Instance(const Instance&);
virtual ~Instance(void);
std::string name;
virtual void render(RenderDevice*);
virtual void update();
std::vector<Instance*> children; // All children.
std::string getClassName();
Instance* findFirstChild(std::string);
std::vector<Instance* > getChildren();
std::vector<Instance* > getAllChildren();
virtual void setParent(Instance*);
void setName(std::string newName);
void addChild(Instance*);
void removeChild(Instance*);
void clearChildren();
Instance* getParent();
virtual Instance* clone() const { return new Instance(*this); }
virtual std::vector<PROPGRIDITEM> getProperties();
virtual void PropUpdate(LPPROPGRIDITEM &pItem);
int listicon;
protected:
std::string className;
Instance* parent; // Another pointer.
PROPGRIDITEM createPGI(LPSTR catalog, LPSTR propName, LPSTR propDesc, LPARAM curVal, INT type, TCHAR choices[] = NULL);
private:
static const std::map<std::string, Instance> g_logLevelsDescriptions;
};

View File

@@ -0,0 +1,16 @@
#pragma once
#include "instance.h"
class LevelInstance :
public Instance
{
public:
LevelInstance(void);
~LevelInstance(void);
float timer;
int score;
virtual std::vector<PROPGRIDITEM> getProperties();
std::string winMessage;
std::string loseMessage;
virtual void PropUpdate(LPPROPGRIDITEM &pItem);
};

View File

@@ -0,0 +1,8 @@
#pragma once
#include "buttonlistener.h"
class MenuButtonListener :
public ButtonListener
{
public:
void onButton1MouseClick(BaseButtonInstance*);
};

View File

@@ -0,0 +1,11 @@
#pragma once
#include "ButtonListener.h"
#define CURSOR 0
#define ARROWS 1
#define RESIZE 2
class ModeSelectionListener : public ButtonListener {
public:
void onButton1MouseClick(BaseButtonInstance*);
};

32
src/include/Mouse.h Normal file
View File

@@ -0,0 +1,32 @@
#pragma once
#include "PartInstance.h"
#pragma once
#include "WorkspaceInstance.h"
struct MousePoint{
Vector3 position;
PartInstance * target;
MousePoint(Vector3 pos, PartInstance * targ)
{
position = pos;
target = targ;
}
};
#pragma once
class Mouse
{
public:
Mouse();
~Mouse(void);
int x, y;
int oldx, oldy;
PartInstance * getTarget();
MousePoint getPositionAndPart(std::vector<Instance *> ignore = std::vector<Instance *>());
Vector3 getPosition(std::vector<Instance *> ignore = std::vector<Instance *>());
bool isMouseOnScreen();
bool isMouseDown();
void setMouseDown(bool mouseDown);
private:
bool mouseDown;
};

34
src/include/PVInstance.h Normal file
View File

@@ -0,0 +1,34 @@
#pragma once
#include "instance.h"
#include "enum.h"
class PVInstance :
public Instance
{
public:
PVInstance(void);
~PVInstance(void);
PVInstance(const PVInstance &oinst);
virtual void postRender(RenderDevice* rd);
virtual std::vector<PROPGRIDITEM> getProperties();
virtual void PropUpdate(LPPROPGRIDITEM &pItem);
bool nameShown;
bool controllerFlagShown;
Enum::Controller::Value controller;
protected:
static G3D::Color3 getControllerColor(int controller)
{
switch(controller)
{
case Enum::Controller::KeyboardLeft:
return Color3::red();
case Enum::Controller::KeyboardRight:
return Color3::blue();
case Enum::Controller::Chase:
return Color3::black();
case Enum::Controller::Flee:
return Color3::yellow();
}
return Color3::gray();
}
};

View File

@@ -0,0 +1,85 @@
#pragma once
#include "PVInstance.h"
#include "Enum.h"
#define _USE_MATH_DEFINES
#include <cmath>
#define NEW_BOX_RENDER
class PartInstance : public PVInstance
{
public:
PartInstance(void);
PartInstance(const PartInstance &oinst);
Instance* clone() const { return new PartInstance(*this); }
virtual void PartInstance::postRender(RenderDevice* rd);
~PartInstance(void);
virtual void render(RenderDevice*);
Enum::SurfaceType::Value top;
Enum::SurfaceType::Value front;
Enum::SurfaceType::Value right;
Enum::SurfaceType::Value back;
Enum::SurfaceType::Value left;
Enum::SurfaceType::Value bottom;
Enum::Shape::Value shape;
CoordinateFrame cFrame;
Color3 color;
Vector3 getPosition();
Vector3 getVelocity();
Vector3 getRotVelocity();
void setParent(Instance* parent);
void setPosition(Vector3);
void setVelocity(Vector3);
bool collides(PartInstance * part);
void setRotVelocity(Vector3);
CoordinateFrame getCFrame();
void setCFrame(CoordinateFrame);
Box getBox();
Sphere getSphere();
Box getScaledBox();
CoordinateFrame getCFrameRenderBased();
Vector3 getSize();
void setSize(Vector3);
void setShape(Enum::Shape::Value shape);
bool canCollide;
bool anchored;
bool collides(Box);
virtual std::vector<PROPGRIDITEM> getProperties();
virtual void PropUpdate(LPPROPGRIDITEM &pItem);
#ifdef NEW_BOX_RENDER
void addVertex(Vector3 vertexPos,Color3 color);
void addNormals(Vector3 normal);
void addSingularNormal(Vector3 normal);
void addTriangle(Vector3 vertexPos,Vector3 vertexPos2, Vector3 vertexPos3);
void addQuad(Vector3 v1,Vector3 v2, Vector3 v3, Vector3 v4);
void genSmoothNormals(int);
void addSmoothTriangle(Vector3 vertexPos,Vector3 vertexPos2, Vector3 vertexPos3);
void makeSmoothFace(int vertex1, int vertex2, int vertex3);
void addPlus(Vector3 v1);
void addPlus2(Vector3 v1);
void debugPrintVertexIDs(RenderDevice* rd, GFontRef font, Matrix3 camRot);
void makeFace(int vertex1, int vertex2, int vertex3);
void fromArrays(float verts[], float norms[], float ind[], unsigned int countVN, unsigned int countInd);
bool isUniqueVertex(Vector3 pos);
#endif
private:
Vector3 position;
Vector3 size;
Vector3 velocity;
Vector3 rotVelocity;
float _bevelSize;
int _parseVert;
int _debugTimer;
std::vector<Vector3> _debugUniqueVertices;
#ifdef NEW_BOX_RENDER
std::vector<GLfloat> _vertices;
std::vector<GLfloat> _normals;
#else
GLfloat _vertices[96];
#endif
std::vector<GLushort> _indices;
bool changed;
Box itemBox;
GLuint glList;
};

View File

@@ -0,0 +1,17 @@
#pragma once
#include "Instance.h"
class PropertyWindow {
public:
PropertyWindow(int x, int y, int sx, int sy, HMODULE hThisInstance);
bool onCreate(int x, int y, int sx, int sy, HMODULE hThisInstance);
void UpdateSelected(Instance *);
void ClearProperties();
void onResize();
void refreshExplorer(Instance* selectedInstance);
HWND _hwndProp;
private:
HWND _propGrid;
HWND _explorerComboBox;
void _resize();
};

View File

@@ -0,0 +1,7 @@
#pragma once
#include "ButtonListener.h"
class RotateButtonListener : public ButtonListener {
public:
void onButton1MouseClick(BaseButtonInstance*);
};

View File

@@ -0,0 +1,6 @@
#pragma once
#include <string>
std::string Convert (float number);
std::string ExePath();
std::string GetFileInPath(std::string file);

View File

@@ -0,0 +1,35 @@
#pragma once
#include "BaseButtonInstance.h"
class TextButtonInstance : public BaseButtonInstance
{
public:
TextButtonInstance(void);
~TextButtonInstance(void);
void setAllColorsSame();
Vector2 boxBegin;
Vector2 boxEnd;
Vector2 fontLocationRelativeTo;
Color4 textColor;
Color4 textOutlineColor;
Color4 boxColor;
Color4 boxOutlineColor;
Color4 textColorOvr;
Color4 textOutlineColorOvr;
Color4 boxColorOvr;
Color4 boxOutlineColorOvr;
Color4 textColorDn;
Color4 textOutlineColorDn;
Color4 boxColorDn;
Color4 boxOutlineColorDn;
Color4 textColorDis;
Color4 textOutlineColorDis;
Color4 boxColorDis;
Color4 boxOutlineColorDis;
bool centeredWithinBox;
std::string title;
G3D::GFontRef font;
bool visible;
int textSize;
void drawObj(RenderDevice*, Vector2, bool);
bool mouseInButton(float, float, RenderDevice*);
};

View File

@@ -0,0 +1,87 @@
#pragma once
#include <G3DAll.h>
#include <map>
class TextureHandler
{
public:
TextureHandler(void);
~TextureHandler(void);
static int getTextureVolatile(std::string str)
{
if(!volTex[str].isNull())
{
volExp[str] = G3D::System::time();
return volTex[str]->openGLID();
}
else
{
G3D::TextureRef tex = G3D::Texture::fromFile(str);
volExp[str] = G3D::System::time();
volTex[str] = tex;
return tex->openGLID();
}
}
static int getTexturePermanent(std::string str)
{
if(!permTex[str].isNull())
{
return permTex[str]->openGLID();
}
else
{
G3D::TextureRef tex = G3D::Texture::fromFile(str);
permTex[str] = tex;
return tex->openGLID();
}
}
static void flushVolatile()
{
std::map<std::string, G3D::RealTime>::iterator it;
for (it=volExp.begin(); it!=volExp.end(); ++it)
{
if(it->second < G3D::System::time() - 3)
{
volTex[it->first]->~Texture();
volTex.erase(it->first);
volExp.erase(it->first);
//it->second->~ReferenceCountedPointer();
}
}
}
static void dispose()
{
std::map<std::string, G3D::TextureRef>::iterator it;
for (it=volTex.begin(); it!=volTex.end(); ++it)
{
it->second->~Texture();
//it->second->~ReferenceCountedPointer();
}
for (it=permTex.begin(); it!=permTex.end(); ++it)
{
it->second->~Texture();
//it->second->~ReferenceCountedPointer();
}
permTex.clear();
volTex.clear();
}
static void remove(std::string str)
{
if(!volTex[str].isNull())
{
volTex[str]->~Texture();
//volTex[str]->~ReferenceCountedPointer();
volTex.erase(str);
}
if(!permTex[str].isNull())
{
permTex[str]->~Texture();
//permTex[str]->~ReferenceCountedPointer();
permTex.erase(str);
}
}
private:
static std::map<std::string, G3D::TextureRef> volTex;
static std::map<std::string, G3D::RealTime> volExp;
static std::map<std::string, G3D::TextureRef> permTex;
};

View File

@@ -0,0 +1,29 @@
#pragma once
#include "imagebuttoninstance.h"
class ToggleImageButtonInstance : public ImageButtonInstance
{
public:
//ImageButtonInstance(G3D::TextureRef);
//ImageButtonInstance(G3D::TextureRef,G3D::TextureRef);
//ImageButtonInstance(G3D::TextureRef,G3D::TextureRef,G3D::TextureRef);
ToggleImageButtonInstance(G3D::TextureRef newImage,G3D::TextureRef overImage = NULL,
G3D::TextureRef downImage = NULL,
G3D::TextureRef disableImage = NULL,
G3D::TextureRef newImage2 = NULL,
G3D::TextureRef overImage2 = NULL,
G3D::TextureRef downImage2 = NULL,
G3D::TextureRef disableImage2 = NULL);
~ToggleImageButtonInstance(void);
void drawObj(RenderDevice*, Vector2, bool);
bool checked;
G3D::TextureRef image2;
int openGLID2;
G3D::TextureRef image_ovr2;
int openGLID2_ovr;
G3D::TextureRef image_dn2;
int openGLID2_dn;
G3D::TextureRef image_ds2;
int openGLID2_ds;
};

34
src/include/Tool.h Normal file
View File

@@ -0,0 +1,34 @@
#pragma once
#include "TextureHandler.h"
#pragma once
#include <G3DAll.h>
#pragma once
#include "Mouse.h"
#pragma once
#include "Globals.h"
#pragma once
#include "StringFunctions.h"
#pragma once
class Tool
{
public:
Tool(void);
~Tool(void);
virtual void onButton1MouseDown(Mouse); //yes
virtual void onButton2MouseDown(Mouse); //yes
virtual void onButton3MouseDown(Mouse); //no
virtual void onButton1MouseUp(Mouse);//yes
virtual void onButton2MouseUp(Mouse);//yes
virtual void onButton3MouseUp(Mouse); //no
virtual void onMouseMoved(Mouse);//yes
virtual void onSelect(Mouse);//yes
virtual void onDeselect(Mouse);//yes
virtual void onMouseScroll(Mouse);//Kinda
virtual void onKeyDown(int);//yes
virtual void onKeyUp(int);//yes
virtual int getCursorId();//yes
protected:
virtual void setCursor(std::string);
private:
std::string cursorString;
};

View File

@@ -0,0 +1,13 @@
#pragma once
#include "buttonlistener.h"
#pragma once
#include <G3DAll.h>
class ToolbarListener : public ButtonListener
{
public:
void onButton1MouseClick(BaseButtonInstance* button);
void addButtonRef(BaseButtonInstance* button);
private:
std::vector<BaseButtonInstance*> btns;
};

View File

@@ -0,0 +1,4 @@
#pragma once
#include <windows.h>
bool createWindowClass(const char* name,WNDPROC proc,HMODULE hInstance);

View File

@@ -0,0 +1,12 @@
#pragma once
#include "GroupInstance.h"
#include "PartInstance.h"
class WorkspaceInstance :
public GroupInstance
{
public:
WorkspaceInstance(void);
~WorkspaceInstance(void);
std::vector<PartInstance *> partObjects;
};

198
src/include/ax.h Normal file
View File

@@ -0,0 +1,198 @@
// AX.H
#pragma once
#include "Globals.h"
#include <mshtmhst.h>
#include <string>
#pragma once
#include "IEBrowser.h"
// messages
#define AX_QUERYINTERFACE (WM_USER + 1)
#define AX_INPLACE (WM_USER + 2)
#define AX_GETAXINTERFACE (WM_USER + 3)
#define AX_CONNECTOBJECT (WM_USER + 4)
#define AX_DISCONNECTOBJECT (WM_USER + 5)
#define AX_SETDATAADVISE (WM_USER + 6)
#define AX_DOVERB (WM_USER + 7)
// Registration function
ATOM AXRegister();
// Class AXClientSide
class AXClientSite :
public IOleClientSite,
public IDispatch,
public IAdviseSink,
public IOleInPlaceSite,
public IOleInPlaceFrame,
public IDocHostUIHandler
{
protected:
int refNum;
public:
HWND Window;
HWND Parent;
HMENU Menu;
bool InPlace;
bool ExternalPlace;
bool CalledCanInPlace;
class AX* ax;
// MyClientSite Methods
AXClientSite();
virtual ~AXClientSite();
STDMETHODIMP_(void) OnDataChange2(FORMATETC*);
// IUnknown methods
STDMETHODIMP QueryInterface(REFIID iid,void**ppvObject);
STDMETHODIMP_(ULONG) AddRef();
STDMETHODIMP_(ULONG) Release();
// IOleClientSite methods
STDMETHODIMP SaveObject();
STDMETHODIMP GetMoniker(DWORD dwA,DWORD dwW,IMoniker**pm);
STDMETHODIMP GetContainer(IOleContainer**pc);
STDMETHODIMP ShowObject();
STDMETHODIMP OnShowWindow(BOOL f);
STDMETHODIMP RequestNewObjectLayout();
// IDDocHandler methods
STDMETHODIMP ShowContextMenu(
/* [in] */ DWORD dwID,
/* [in] */ POINT *ppt,
/* [in] */ IUnknown *pcmdtReserved,
/* [in] */ IDispatch *pdispReserved);
STDMETHODIMP GetHostInfo(
/* [out][in] */ DOCHOSTUIINFO *pInfo);
STDMETHODIMP ShowUI(
/* [in] */ DWORD dwID,
/* [in] */ IOleInPlaceActiveObject *pActiveObject,
/* [in] */ IOleCommandTarget *pCommandTarget,
/* [in] */ IOleInPlaceFrame *pFrame,
/* [in] */ IOleInPlaceUIWindow *pDoc);
STDMETHODIMP HideUI( void);
STDMETHODIMP UpdateUI( void);
STDMETHODIMP OnDocWindowActivate(
/* [in] */ BOOL fActivate);
STDMETHODIMP OnFrameWindowActivate(
/* [in] */ BOOL fActivate);
STDMETHODIMP ResizeBorder(
/* [in] */ LPCRECT prcBorder,
/* [in] */ IOleInPlaceUIWindow *pUIWindow,
/* [in] */ BOOL fRameWindow);
STDMETHODIMP TranslateAccelerator(
/* [in] */ LPMSG lpMsg,
/* [in] */ const GUID *pguidCmdGroup,
/* [in] */ DWORD nCmdID);
STDMETHODIMP GetOptionKeyPath(
/* [out] */ LPOLESTR *pchKey,
/* [in] */ DWORD dw);
STDMETHODIMP GetDropTarget(
/* [in] */ IDropTarget *pDropTarget,
/* [out] */ IDropTarget **ppDropTarget);
STDMETHODIMP GetExternal(
/* [out] */ IDispatch **ppDispatch);
STDMETHODIMP TranslateUrl(
/* [in] */ DWORD dwTranslate,
/* [in] */ OLECHAR *pchURLIn,
/* [out] */ OLECHAR **ppchURLOut);
STDMETHODIMP FilterDataObject(
/* [in] */ IDataObject *pDO,
/* [out] */ IDataObject **ppDORet);
// IAdviseSink methods
STDMETHODIMP_(void) OnDataChange(FORMATETC *pFormatEtc,STGMEDIUM *pStgmed);
STDMETHODIMP_(void) OnViewChange(DWORD dwAspect,LONG lIndex);
STDMETHODIMP_(void) OnRename(IMoniker * pmk);
STDMETHODIMP_(void) OnSave();
STDMETHODIMP_(void) OnClose();
// IOleInPlaceSite methods
STDMETHODIMP GetWindow(HWND *p);
STDMETHODIMP ContextSensitiveHelp(BOOL);
STDMETHODIMP CanInPlaceActivate();
STDMETHODIMP OnInPlaceActivate();
STDMETHODIMP OnUIActivate();
STDMETHODIMP GetWindowContext(IOleInPlaceFrame** ppFrame,IOleInPlaceUIWindow **ppDoc,LPRECT r1,LPRECT r2,LPOLEINPLACEFRAMEINFO o);
STDMETHODIMP Scroll(SIZE s);
STDMETHODIMP OnUIDeactivate(int);
STDMETHODIMP OnInPlaceDeactivate();
STDMETHODIMP DiscardUndoState();
STDMETHODIMP DeactivateAndUndo();
STDMETHODIMP OnPosRectChange(LPCRECT);
// IOleInPlaceFrame methods
STDMETHODIMP GetBorder(LPRECT l);
STDMETHODIMP RequestBorderSpace(LPCBORDERWIDTHS);
STDMETHODIMP SetBorderSpace(LPCBORDERWIDTHS w);
STDMETHODIMP SetActiveObject(IOleInPlaceActiveObject*pV,LPCOLESTR s);
STDMETHODIMP InsertMenus(HMENU h,LPOLEMENUGROUPWIDTHS x);
STDMETHODIMP SetMenu(HMENU h,HOLEMENU hO,HWND hw);
STDMETHODIMP RemoveMenus(HMENU h);
STDMETHODIMP SetStatusText(LPCOLESTR t);
STDMETHODIMP EnableModeless(BOOL f);
STDMETHODIMP TranslateAccelerator(LPMSG,WORD);
std::wstring m_lastExternalName;
// IDispatch Methods
HRESULT _stdcall GetTypeInfoCount(unsigned int * pctinfo);
HRESULT _stdcall GetTypeInfo(unsigned int iTInfo,LCID lcid,ITypeInfo FAR* FAR* ppTInfo);
HRESULT _stdcall GetIDsOfNames(REFIID riid,OLECHAR FAR* FAR*,unsigned int cNames,LCID lcid,DISPID FAR* );
HRESULT _stdcall Invoke(DISPID dispIdMember,REFIID riid,LCID lcid,WORD wFlags,DISPPARAMS FAR* pDispParams,VARIANT FAR* pVarResult,EXCEPINFO FAR* pExcepInfo,unsigned int FAR* puArgErr);
};
// Class AX
class AX
{
public:
AX(char* clsid);
CLSID GetCLSID();
~AX();
void Init(char* clsid);
void Clean();
AXClientSite Site;
IID* iid;
IOleObject* OleObject;
IStorage* Storage;
IViewObject* View;
IDataObject* Data;
IUnknown* Unk;
IOleInPlaceActiveObject* Pao;
//AX_CONNECTSTRUCT* tcs;
bool AddMenu;
DWORD AdviseToken;
DWORD DAdviseToken[100];
private:
CLSID clsid;
};

392
src/include/propertyGrid.h Normal file
View File

@@ -0,0 +1,392 @@
//////////////////////////////////////////////////////////////////////////////
///
/// @file propertyGrid.h
///
/// @brief A property grid control in Win32 SDK C.
///
/// @author David MacDermot
///
/// @par Comments:
/// This source is distributed in the hope that it will be useful,
/// but WITHOUT ANY WARRANTY; without even the implied warranty of
/// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
///
/// @date 2-27-16
///
/// @todo
///
/// @bug
///
//////////////////////////////////////////////////////////////////////////////
//DWM 1.8: Added Message PG_FLATCHECKS and associated macroes
#ifndef PROPERTYGRID_H
#define PROPERTYGRID_H
/****************************************************************************/
// Public Messages
// List box message subset handled by the property grid.
// LB_ADDSTRING - PropGrid_AddItem()
// LB_DELETESTRING - PropGrid_DeleteItem()
// LB_GETCOUNT - PropGrid_GetCount()
// LB_GETCURSEL - PropGrid_GetCurSel()
// LB_GETHORIZONTALEXTENT - PropGrid_GetHorizontalExtent()
// LB_GETITEMDATA - PropGrid_GetItemData()
// LB_GETITEMHEIGHT - PropGrid_GetItemHeight()
// LB_GETITEMRECT - PropGrid_GetItemRect()
// LB_GETSEL - PropGrid_GetSel()
// LB_RESETCONTENT - PropGrid_ResetContent()
// LB_SETCURSEL - PropGrid_SetCurSel()
// LB_SETHORIZONTALEXTENT - PropGrid_SetHorizontalExtent()
// LB_SETITEMDATA - PropGrid_SetItemData()
// LB_SETITEMHEIGHT - PropGrid_SetItemHeight()
/// @name Property grid specific messages.
/// @{
#define PG_EXPANDCATALOGS WM_USER + 0x01 ///<PropGrid_ExpandCatalogs()
#define PG_COLLAPSECATALOGS WM_USER + 0x02 ///<PropGrid_CollapseCatalogs()
#define PG_SHOWTOOLTIPS WM_USER + 0x03 ///<PropGrid_ShowToolTips()
#define PG_SHOWPROPERTYDESC WM_USER + 0x04 ///<PropGrid_ShowPropertyDescriptions()
#define PG_FLATCHECKS WM_USER + 0x05 ///<PropGrid_SetFlatStyleChecks()
/// @}
/****************************************************************************/
// Property item types
#define PIT_EDIT 0 ///< Property item type: Edit
#define PIT_COMBO 1 ///< Property item type: Dropdownlist
#define PIT_EDITCOMBO 2 ///< Property item type: Dropdown(editable)
#define PIT_STATIC 3 ///< Property item type: Not editable text
#define PIT_COLOR 4 ///< Property item type: Color
#define PIT_FONT 5 ///< Property item type: Font
#define PIT_FILE 6 ///< Property item type: File select dialog
#define PIT_FOLDER 7 ///< Property item type: Folder select dialog
#define PIT_CHECK 8 ///< Property item type: BOOL
#define PIT_IP 9 ///< Property item type: IP Address
#define PIT_DATE 10 ///< Property item type: Date
#define PIT_TIME 11 ///< Property item type: Time
#define PIT_DATETIME 12 ///< Property item type: Date & Time
#define PIT_CATALOG 99 ///< Property item type: Catalog
/****************************************************************************/
// Public structures and notifications
/// @var PROPGRIDFDITEM
/// @brief A property grid file dialog item object
/// @var LPPROPGRIDFDITEM
/// @brief Pointer to a property grid file dialog item
/// @struct tagPROPGRIDFDITEM
/// @brief This is additional data associated with a property grid file dialog item
typedef struct tagPROPGRIDFDITEM {
LPTSTR lpszDlgTitle; ///< Dialog title
LPTSTR lpszFilePath; ///< Initial path
LPTSTR lpszFilter; ///< Double null terminated filter string
LPTSTR lpszDefExt; ///< Default extension
} PROPGRIDFDITEM, *LPPROPGRIDFDITEM;
/// @var PROPGRIDFONTITEM
/// @brief A property grid font item object
/// @var LPPROPGRIDFONTITEM
/// @brief Pointer to a property grid font item
/// @struct tagPROPGRIDFONTITEM
/// @brief This is additional data associated with a property grid font item
typedef struct tagPROPGRIDFONTITEM {
LOGFONT logFont; ///< Logical font struct
COLORREF crFont; ///< Text color
} PROPGRIDFONTITEM, *LPPROPGRIDFONTITEM;
/// @var PROPGRIDITEM
/// @brief A property grid item object
/// @var LPPROPGRIDITEM
/// @brief Pointer to a property grid item
/// @struct tagPROPGRIDITEM
/// @brief This is the data associated with a property grid item
typedef struct tagPROPGRIDITEM {
LPTSTR lpszCatalog; ///< Catalog (group) name
LPTSTR lpszPropName; ///< Property (item) name
LPTSTR lpszzCmbItems; ///< Double null terminated list of strings
LPTSTR lpszPropDesc; ///< Property (item) description
LPARAM lpCurValue; ///< Property (item) value
INT iItemType; ///< Property (item) type identifier
} PROPGRIDITEM, *LPPROPGRIDITEM;
/// @var NMPROPGRID
/// @brief A property grid notification message data object
/// @var LPNMPROPGRID
/// @brief Pointer to property grid notification message data
/// @struct tagNMPROPGRID
/// @brief This is the data associated with a property grid notification
typedef struct tagNMPROPGRID {
NMHDR hdr; ///< Notification message header
INT iIndex; ///< Index of a property grid item
} NMPROPGRID, *LPNMPROPGRID;
#define PGN_PROPERTYCHANGE WM_USER + 0x2A ///<property grid Property changed notification message
/****************************************************************************/
/// @name Macroes
/// @{
/// @def PropGrid_AddItem(hwndCtl,lpItem)
///
/// @brief Add an item to a property grid. Items are appended to their respective
/// catalogs.
///
/// @param hwndCtl The handle of a property grid.
/// @param lpItem Pointer to a property grid item.
///
/// @returns The zero-based index of the item in the list box. If an error occurs,
/// the return value is LB_ERR. If there is insufficient space to store
/// the new string, the return value is LB_ERRSPACE.
#define PropGrid_AddItem(hwndCtl,lpItem) ((int)(DWORD)SendMessage((hwndCtl),LB_ADDSTRING,0,(LPARAM)(lpItem)))
/// @def PropGrid_DeleteItem(hwndCtl,index)
///
/// @brief Deletes the item at the specified location in a property grid.
///
/// @param hwndCtl The handle of a property grid.
/// @param index The zero-based index of the item to delete.
///
/// @returns A count of the items remaining in the grid. The return value is
/// LB_ERR if the index parameter specifies an index greater than the
/// number of items in the list.
#define PropGrid_DeleteItem(hwndCtl,index) ((int)(DWORD)SendMessage((hwndCtl),LB_DELETESTRING,(WPARAM)(int)(index),0))
/// @def PropGrid_Enable(hwndCtl,fEnable)
///
/// @brief Enables or disables a property grid control.
///
/// @param hwndCtl The handle of a property grid.
/// @param fEnable TRUE to enable the control, or FALSE to disable it.
///
/// @returns No return value.
#define PropGrid_Enable(hwndCtl,fEnable) EnableWindow((hwndCtl),(fEnable))
/// @def PropGrid_GetCount(hwndCtl)
///
/// @brief Gets the number of items in a property grid.
///
/// @param hwndCtl The handle of a property grid.
///
/// @returns The number of items.
#define PropGrid_GetCount(hwndCtl) ((int)(DWORD)SendMessage((hwndCtl),LB_GETCOUNT,0,0))
/// @def PropGrid_GetCurSel(hwndCtl)
///
/// @brief Gets the index of the currently selected item in a property grid.
///
/// @param hwndCtl The handle of a property grid.
///
/// @returns The zero-based index of the selected item. If there is no selection,
/// the return value is LB_ERR.
#define PropGrid_GetCurSel(hwndCtl) ((int)(DWORD)SendMessage((hwndCtl),LB_GETCURSEL,0,0))
/// @def PropGrid_GetHorizontalExtent(hwndCtl)
///
/// @brief Gets the width that a property grid can be scrolled horizontally
/// (the scrollable width).
///
/// @param hwndCtl The handle of a property grid.
///
/// @returns The scrollable width, in pixels, of the property grid.
#define PropGrid_GetHorizontalExtent(hwndCtl) ((int)(DWORD)SendMessage((hwndCtl),LB_GETHORIZONTALEXTENT,0,0))
/// @def PropGrid_GetItemData(hwndCtl,index)
///
/// @brief Gets the PROPGRIDITEM associated with the specified property grid item.
///
/// @param hwndCtl The handle of a property grid.
/// @param index The zero-based index of the item.
///
/// @returns A pointer to a PROPGRIDITEM object.
#define PropGrid_GetItemData(hwndCtl,index) ((LPPROPGRIDITEM)(DWORD_PTR)SendMessage((hwndCtl),LB_GETITEMDATA,(WPARAM)(int)(index),0))
/// @def PropGrid_GetItemHeight(hwndCtl)
///
/// @brief Retrieves the height of all items in a property grid.
///
/// @param hwndCtl The handle of a property grid.
///
/// @returns The height, in pixels, of the items, or LB_ERR if an error occurs.
#define PropGrid_GetItemHeight(hwndCtl) ((int)(DWORD)SendMessage((hwndCtl),LB_GETITEMHEIGHT,(WPARAM)0,0))
/// @def PropGrid_GetItemRect(hwndCtl,index,lprc)
///
/// @brief Gets the dimensions of the rectangle that bounds a property grid item
/// as it is currently displayed in the property grid.
///
/// @param hwndCtl The handle of a property grid.
/// @param index The zero-based index of the item in the property grid.
/// @param lprc A pointer to a RECT structure that receives the client
/// coordinates for the item in the property grid.
///
/// @returns If an error occurs, the return value is LB_ERR.
#define PropGrid_GetItemRect(hwndCtl,index,lprc) ((int)(DWORD)SendMessage((hwndCtl),LB_GETITEMRECT,(WPARAM)(int)(index),(LPARAM)(RECT*)(lprc)))
/// @def PropGrid_GetSel(hwndCtl,index)
///
/// @brief Gets the selection state of an item.
///
/// @param hwndCtl The handle of a property grid.
/// @param index The zero-based index of the item.
///
/// @returns If the item is selected, the return value is greater than zero;
/// otherwise, it is zero. If an error occurs, the return value is LB_ERR.
#define PropGrid_GetSel(hwndCtl,index) ((int)(DWORD)SendMessage((hwndCtl),LB_GETSEL,(WPARAM)(int)(index),0))
/// @def PropGrid_ResetContent(hwndCtl)
///
/// @brief Removes all items from a property grid.
///
/// @param hwndCtl The handle of a property grid.
///
/// @returns The return value is not meaningful.
#define PropGrid_ResetContent(hwndCtl) ((BOOL)(DWORD)SendMessage((hwndCtl),LB_RESETCONTENT,0,0))
/// @def PropGrid_SetCurSel(hwndCtl,index)
///
/// @brief Sets the currently selected item in a property grid.
///
/// @param hwndCtl The handle of a property grid.
/// @param index The zero-based index of the item to select, or <20>1 to clear the selection.
///
/// @returns If an error occurs, the return value is LB_ERR. If the index
/// parameter is <20>1, the return value is LB_ERR even though no error occurred.
#define PropGrid_SetCurSel(hwndCtl,index) ((int)(DWORD)SendMessage((hwndCtl),LB_SETCURSEL,(WPARAM)(int)(index),0))
/// @def PropGrid_SetHorizontalExtent(hwndCtl,cxExtent)
///
/// @brief Set the width by which a property grid can be scrolled horizontally
/// (the scrollable width). If the width of the property grid is smaller
/// than this value, the horizontal scroll bar horizontally scrolls items
/// in the property grid. If the width of the property grid is equal to or
/// greater than this value, the horizontal scroll bar is hidden.
///
/// @param hwndCtl The handle of a property grid.
/// @param cxExtent The number of pixels by which the list box can be scrolled.
///
/// @returns No return value.
#define PropGrid_SetHorizontalExtent(hwndCtl,cxExtent) ((void)SendMessage((hwndCtl),LB_SETHORIZONTALEXTENT,(WPARAM)(int)(cxExtent),0))
/// @def PropGrid_SetItemData(hwndCtl,index,data)
///
/// @brief Sets the PROPGRIDITEM associated with the specified property grid item.
///
/// @param hwndCtl The handle of a property grid.
/// @param index The zero-based index of the item.
/// @param data The item data to set.
///
/// @returns If an error occurs, the return value is LB_ERR.
#define PropGrid_SetItemData(hwndCtl,index,data) ((int)(DWORD)SendMessage((hwndCtl),LB_SETITEMDATA,(WPARAM)(int)(index),(LPARAM)(data)))
/// @def PropGrid_SetItemHeight(hwndCtl,cy)
///
/// @brief Sets the height of all items in a property grid.
///
/// @param hwndCtl The handle of a property grid.
/// @param cy The height of the items, in pixels.
///
/// @returns If the height is invalid, the return value is LB_ERR.
#define PropGrid_SetItemHeight(hwndCtl,cy) ((int)(DWORD)SendMessage((hwndCtl),LB_SETITEMHEIGHT,(WPARAM)0,MAKELPARAM((cy),0)))
/// @def PropGrid_ExpandCatalogs(hwndCtl, lpszzCatalogs)
///
/// @brief Expand certain specified catalogs in a property grid.
///
/// @param hwndCtl The handle of a property grid.
/// @param lpszzCatalogs The list of catalog names each terminated by a null (\\0).
///
/// @returns No return value.
#define PropGrid_ExpandCatalogs(hwndCtl, lpszzCatalogs) ((void)SendMessage((hwndCtl),PG_EXPANDCATALOGS,(WPARAM)0,(LPARAM)(lpszzCatalogs)))
/// @def PropGrid_ExpandAllCatalogs(hwndCtl)
///
/// @brief Expand all catalogs in a property grid.
///
/// @param hwndCtl The handle of a property grid.
///
/// @returns No return value.
#define PropGrid_ExpandAllCatalogs(hwndCtl) ((void)SendMessage((hwndCtl),PG_EXPANDCATALOGS,(WPARAM)0,(LPARAM)NULL))
/// @def PropGrid_CollapseCatalogs(hwndCtl, lpszzCatalogs)
///
/// @brief Collapse certain specified catalogs in a property grid.
///
/// @param hwndCtl The handle of a property grid.
/// @param lpszzCatalogs The catalog names each terminated by a null (\\0).
///
/// @returns No return value.
#define PropGrid_CollapseCatalogs(hwndCtl, lpszzCatalogs) ((void)SendMessage((hwndCtl),PG_COLLAPSECATALOGS,(WPARAM)0,(LPARAM)(lpszzCatalogs)))
/// @def PropGrid_CollapseAllCatalogs(hwndCtl)
///
/// @brief Collapse all catalogs in a property grid.
///
/// @param hwndCtl The handle of a property grid.
///
/// @returns No return value.
#define PropGrid_CollapseAllCatalogs(hwndCtl) ((void)SendMessage((hwndCtl),PG_COLLAPSECATALOGS,(WPARAM)0,(LPARAM)NULL))
/// @def PropGrid_ShowToolTips(hwndCtl,fShow)
///
/// @brief Show or hide tooltips in the property grid.
///
/// @param hwndCtl The handle of a property grid.
/// @param fShow TRUE for tooltips; FALSE do not show tooltips.
///
/// @returns No return value.
#define PropGrid_ShowToolTips(hwndCtl,fShow) ((void)SendMessage((hwndCtl),PG_SHOWTOOLTIPS,(WPARAM)(fShow),(LPARAM)0L))
/// @def PropGrid_ShowPropertyDescriptions(hwndCtl,fShow)
///
/// @brief Show or hide the property discription pane in the property grid.
///
/// @param hwndCtl The handle of a property grid.
/// @param fShow TRUE for descriptions; FALSE do not show discription pane.
///
/// @returns No return value.
#define PropGrid_ShowPropertyDescriptions(hwndCtl,fShow) ((void)SendMessage((hwndCtl),PG_SHOWPROPERTYDESC,(WPARAM)(fShow),(LPARAM)0L))
/// @def PropGrid_SetFlatStyleChecks(hwndCtl, fFlat)
///
/// @brief Sets the appearance of the checkboxes.
///
/// @param hwndCtl The handle of a property grid.
/// @param fFlat TRUE for flat checkboxes, or FALSE for standard checkboxes.
///
/// @returns No return value.
#define PropGrid_SetFlatStyleChecks(hwndCtl, fFlat) \
((void)SendMessage((hwndCtl),PG_FLATCHECKS,(WPARAM)(BOOL) (fFlat),(LPARAM)0L))
/// @def PropGrid_ItemInit(pgi)
///
/// @brief Initialize an item struct.
///
/// @param pgi The PROPGRIDITEM struct.
///
/// @returns No return value.
#define PropGrid_ItemInit(pgi) \
(pgi.lpszCatalog = NULL, pgi.lpszPropName = NULL, \
pgi.lpszzCmbItems = NULL, pgi.lpszPropDesc = NULL, \
pgi.lpCurValue = 0, pgi.iItemType = 0)
/// @}
/****************************************************************************/
// Exported function prototypes
ATOM InitPropertyGrid(HINSTANCE hInstance);
HWND New_PropertyGrid(HWND hParent, DWORD dwID);
#endif //PROPERTYGRID_H

View File

@@ -0,0 +1,52 @@
Use of this software is granted under one of the following two licenses,
to be chosen freely by the user.
1. Boost Software License - Version 1.0 - August 17th, 2003
===============================================================================
Copyright (c) 2006, 2007 Marcin Kalicinski
Permission is hereby granted, free of charge, to any person or organization
obtaining a copy of the software and accompanying documentation covered by
this license (the "Software") to use, reproduce, display, distribute,
execute, and transmit the Software, and to prepare derivative works of the
Software, and to permit third-parties to whom the Software is furnished to
do so, all subject to the following:
The copyright notices in the Software and this entire statement, including
the above license grant, this restriction and the following disclaimer,
must be included in all copies of the Software, in whole or in part, and
all derivative works of the Software, unless such copies or derivative
works are solely in the form of machine-executable object code generated by
a source language processor.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
2. The MIT License
===============================================================================
Copyright (c) 2006, 2007 Marcin Kalicinski
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
IN THE SOFTWARE.

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,174 @@
#ifndef RAPIDXML_ITERATORS_HPP_INCLUDED
#define RAPIDXML_ITERATORS_HPP_INCLUDED
// Copyright (C) 2006, 2009 Marcin Kalicinski
// Version 1.13
// Revision $DateTime: 2009/05/13 01:46:17 $
//! \file rapidxml_iterators.hpp This file contains rapidxml iterators
#include "rapidxml.hpp"
namespace rapidxml
{
//! Iterator of child nodes of xml_node
template<class Ch>
class node_iterator
{
public:
typedef typename xml_node<Ch> value_type;
typedef typename xml_node<Ch> &reference;
typedef typename xml_node<Ch> *pointer;
typedef std::ptrdiff_t difference_type;
typedef std::bidirectional_iterator_tag iterator_category;
node_iterator()
: m_node(0)
{
}
node_iterator(xml_node<Ch> *node)
: m_node(node->first_node())
{
}
reference operator *() const
{
assert(m_node);
return *m_node;
}
pointer operator->() const
{
assert(m_node);
return m_node;
}
node_iterator& operator++()
{
assert(m_node);
m_node = m_node->next_sibling();
return *this;
}
node_iterator operator++(int)
{
node_iterator tmp = *this;
++this;
return tmp;
}
node_iterator& operator--()
{
assert(m_node && m_node->previous_sibling());
m_node = m_node->previous_sibling();
return *this;
}
node_iterator operator--(int)
{
node_iterator tmp = *this;
++this;
return tmp;
}
bool operator ==(const node_iterator<Ch> &rhs)
{
return m_node == rhs.m_node;
}
bool operator !=(const node_iterator<Ch> &rhs)
{
return m_node != rhs.m_node;
}
private:
xml_node<Ch> *m_node;
};
//! Iterator of child attributes of xml_node
template<class Ch>
class attribute_iterator
{
public:
typedef typename xml_attribute<Ch> value_type;
typedef typename xml_attribute<Ch> &reference;
typedef typename xml_attribute<Ch> *pointer;
typedef std::ptrdiff_t difference_type;
typedef std::bidirectional_iterator_tag iterator_category;
attribute_iterator()
: m_attribute(0)
{
}
attribute_iterator(xml_node<Ch> *node)
: m_attribute(node->first_attribute())
{
}
reference operator *() const
{
assert(m_attribute);
return *m_attribute;
}
pointer operator->() const
{
assert(m_attribute);
return m_attribute;
}
attribute_iterator& operator++()
{
assert(m_attribute);
m_attribute = m_attribute->next_attribute();
return *this;
}
attribute_iterator operator++(int)
{
attribute_iterator tmp = *this;
++this;
return tmp;
}
attribute_iterator& operator--()
{
assert(m_attribute && m_attribute->previous_attribute());
m_attribute = m_attribute->previous_attribute();
return *this;
}
attribute_iterator operator--(int)
{
attribute_iterator tmp = *this;
++this;
return tmp;
}
bool operator ==(const attribute_iterator<Ch> &rhs)
{
return m_attribute == rhs.m_attribute;
}
bool operator !=(const attribute_iterator<Ch> &rhs)
{
return m_attribute != rhs.m_attribute;
}
private:
xml_attribute<Ch> *m_attribute;
};
}
#endif

View File

@@ -0,0 +1,421 @@
#ifndef RAPIDXML_PRINT_HPP_INCLUDED
#define RAPIDXML_PRINT_HPP_INCLUDED
// Copyright (C) 2006, 2009 Marcin Kalicinski
// Version 1.13
// Revision $DateTime: 2009/05/13 01:46:17 $
//! \file rapidxml_print.hpp This file contains rapidxml printer implementation
#include "rapidxml.hpp"
// Only include streams if not disabled
#ifndef RAPIDXML_NO_STREAMS
#include <ostream>
#include <iterator>
#endif
namespace rapidxml
{
///////////////////////////////////////////////////////////////////////
// Printing flags
const int print_no_indenting = 0x1; //!< Printer flag instructing the printer to suppress indenting of XML. See print() function.
///////////////////////////////////////////////////////////////////////
// Internal
//! \cond internal
namespace internal
{
///////////////////////////////////////////////////////////////////////////
// Internal character operations
// Copy characters from given range to given output iterator
template<class OutIt, class Ch>
inline OutIt copy_chars(const Ch *begin, const Ch *end, OutIt out)
{
while (begin != end)
*out++ = *begin++;
return out;
}
// Copy characters from given range to given output iterator and expand
// characters into references (&lt; &gt; &apos; &quot; &amp;)
template<class OutIt, class Ch>
inline OutIt copy_and_expand_chars(const Ch *begin, const Ch *end, Ch noexpand, OutIt out)
{
while (begin != end)
{
if (*begin == noexpand)
{
*out++ = *begin; // No expansion, copy character
}
else
{
switch (*begin)
{
case Ch('<'):
*out++ = Ch('&'); *out++ = Ch('l'); *out++ = Ch('t'); *out++ = Ch(';');
break;
case Ch('>'):
*out++ = Ch('&'); *out++ = Ch('g'); *out++ = Ch('t'); *out++ = Ch(';');
break;
case Ch('\''):
*out++ = Ch('&'); *out++ = Ch('a'); *out++ = Ch('p'); *out++ = Ch('o'); *out++ = Ch('s'); *out++ = Ch(';');
break;
case Ch('"'):
*out++ = Ch('&'); *out++ = Ch('q'); *out++ = Ch('u'); *out++ = Ch('o'); *out++ = Ch('t'); *out++ = Ch(';');
break;
case Ch('&'):
*out++ = Ch('&'); *out++ = Ch('a'); *out++ = Ch('m'); *out++ = Ch('p'); *out++ = Ch(';');
break;
default:
*out++ = *begin; // No expansion, copy character
}
}
++begin; // Step to next character
}
return out;
}
// Fill given output iterator with repetitions of the same character
template<class OutIt, class Ch>
inline OutIt fill_chars(OutIt out, int n, Ch ch)
{
for (int i = 0; i < n; ++i)
*out++ = ch;
return out;
}
// Find character
template<class Ch, Ch ch>
inline bool find_char(const Ch *begin, const Ch *end)
{
while (begin != end)
if (*begin++ == ch)
return true;
return false;
}
///////////////////////////////////////////////////////////////////////////
// Internal printing operations
// Print node
template<class OutIt, class Ch>
inline OutIt print_node(OutIt out, const xml_node<Ch> *node, int flags, int indent)
{
// Print proper node type
switch (node->type())
{
// Document
case node_document:
out = print_children(out, node, flags, indent);
break;
// Element
case node_element:
out = print_element_node(out, node, flags, indent);
break;
// Data
case node_data:
out = print_data_node(out, node, flags, indent);
break;
// CDATA
case node_cdata:
out = print_cdata_node(out, node, flags, indent);
break;
// Declaration
case node_declaration:
out = print_declaration_node(out, node, flags, indent);
break;
// Comment
case node_comment:
out = print_comment_node(out, node, flags, indent);
break;
// Doctype
case node_doctype:
out = print_doctype_node(out, node, flags, indent);
break;
// Pi
case node_pi:
out = print_pi_node(out, node, flags, indent);
break;
// Unknown
default:
assert(0);
break;
}
// If indenting not disabled, add line break after node
if (!(flags & print_no_indenting))
*out = Ch('\n'), ++out;
// Return modified iterator
return out;
}
// Print children of the node
template<class OutIt, class Ch>
inline OutIt print_children(OutIt out, const xml_node<Ch> *node, int flags, int indent)
{
for (xml_node<Ch> *child = node->first_node(); child; child = child->next_sibling())
out = print_node(out, child, flags, indent);
return out;
}
// Print attributes of the node
template<class OutIt, class Ch>
inline OutIt print_attributes(OutIt out, const xml_node<Ch> *node, int flags)
{
for (xml_attribute<Ch> *attribute = node->first_attribute(); attribute; attribute = attribute->next_attribute())
{
if (attribute->name() && attribute->value())
{
// Print attribute name
*out = Ch(' '), ++out;
out = copy_chars(attribute->name(), attribute->name() + attribute->name_size(), out);
*out = Ch('='), ++out;
// Print attribute value using appropriate quote type
if (find_char<Ch, Ch('"')>(attribute->value(), attribute->value() + attribute->value_size()))
{
*out = Ch('\''), ++out;
out = copy_and_expand_chars(attribute->value(), attribute->value() + attribute->value_size(), Ch('"'), out);
*out = Ch('\''), ++out;
}
else
{
*out = Ch('"'), ++out;
out = copy_and_expand_chars(attribute->value(), attribute->value() + attribute->value_size(), Ch('\''), out);
*out = Ch('"'), ++out;
}
}
}
return out;
}
// Print data node
template<class OutIt, class Ch>
inline OutIt print_data_node(OutIt out, const xml_node<Ch> *node, int flags, int indent)
{
assert(node->type() == node_data);
if (!(flags & print_no_indenting))
out = fill_chars(out, indent, Ch('\t'));
out = copy_and_expand_chars(node->value(), node->value() + node->value_size(), Ch(0), out);
return out;
}
// Print data node
template<class OutIt, class Ch>
inline OutIt print_cdata_node(OutIt out, const xml_node<Ch> *node, int flags, int indent)
{
assert(node->type() == node_cdata);
if (!(flags & print_no_indenting))
out = fill_chars(out, indent, Ch('\t'));
*out = Ch('<'); ++out;
*out = Ch('!'); ++out;
*out = Ch('['); ++out;
*out = Ch('C'); ++out;
*out = Ch('D'); ++out;
*out = Ch('A'); ++out;
*out = Ch('T'); ++out;
*out = Ch('A'); ++out;
*out = Ch('['); ++out;
out = copy_chars(node->value(), node->value() + node->value_size(), out);
*out = Ch(']'); ++out;
*out = Ch(']'); ++out;
*out = Ch('>'); ++out;
return out;
}
// Print element node
template<class OutIt, class Ch>
inline OutIt print_element_node(OutIt out, const xml_node<Ch> *node, int flags, int indent)
{
assert(node->type() == node_element);
// Print element name and attributes, if any
if (!(flags & print_no_indenting))
out = fill_chars(out, indent, Ch('\t'));
*out = Ch('<'), ++out;
out = copy_chars(node->name(), node->name() + node->name_size(), out);
out = print_attributes(out, node, flags);
// If node is childless
if (node->value_size() == 0 && !node->first_node())
{
// Print childless node tag ending
*out = Ch('/'), ++out;
*out = Ch('>'), ++out;
}
else
{
// Print normal node tag ending
*out = Ch('>'), ++out;
// Test if node contains a single data node only (and no other nodes)
xml_node<Ch> *child = node->first_node();
if (!child)
{
// If node has no children, only print its value without indenting
out = copy_and_expand_chars(node->value(), node->value() + node->value_size(), Ch(0), out);
}
else if (child->next_sibling() == 0 && child->type() == node_data)
{
// If node has a sole data child, only print its value without indenting
out = copy_and_expand_chars(child->value(), child->value() + child->value_size(), Ch(0), out);
}
else
{
// Print all children with full indenting
if (!(flags & print_no_indenting))
*out = Ch('\n'), ++out;
out = print_children(out, node, flags, indent + 1);
if (!(flags & print_no_indenting))
out = fill_chars(out, indent, Ch('\t'));
}
// Print node end
*out = Ch('<'), ++out;
*out = Ch('/'), ++out;
out = copy_chars(node->name(), node->name() + node->name_size(), out);
*out = Ch('>'), ++out;
}
return out;
}
// Print declaration node
template<class OutIt, class Ch>
inline OutIt print_declaration_node(OutIt out, const xml_node<Ch> *node, int flags, int indent)
{
// Print declaration start
if (!(flags & print_no_indenting))
out = fill_chars(out, indent, Ch('\t'));
*out = Ch('<'), ++out;
*out = Ch('?'), ++out;
*out = Ch('x'), ++out;
*out = Ch('m'), ++out;
*out = Ch('l'), ++out;
// Print attributes
out = print_attributes(out, node, flags);
// Print declaration end
*out = Ch('?'), ++out;
*out = Ch('>'), ++out;
return out;
}
// Print comment node
template<class OutIt, class Ch>
inline OutIt print_comment_node(OutIt out, const xml_node<Ch> *node, int flags, int indent)
{
assert(node->type() == node_comment);
if (!(flags & print_no_indenting))
out = fill_chars(out, indent, Ch('\t'));
*out = Ch('<'), ++out;
*out = Ch('!'), ++out;
*out = Ch('-'), ++out;
*out = Ch('-'), ++out;
out = copy_chars(node->value(), node->value() + node->value_size(), out);
*out = Ch('-'), ++out;
*out = Ch('-'), ++out;
*out = Ch('>'), ++out;
return out;
}
// Print doctype node
template<class OutIt, class Ch>
inline OutIt print_doctype_node(OutIt out, const xml_node<Ch> *node, int flags, int indent)
{
assert(node->type() == node_doctype);
if (!(flags & print_no_indenting))
out = fill_chars(out, indent, Ch('\t'));
*out = Ch('<'), ++out;
*out = Ch('!'), ++out;
*out = Ch('D'), ++out;
*out = Ch('O'), ++out;
*out = Ch('C'), ++out;
*out = Ch('T'), ++out;
*out = Ch('Y'), ++out;
*out = Ch('P'), ++out;
*out = Ch('E'), ++out;
*out = Ch(' '), ++out;
out = copy_chars(node->value(), node->value() + node->value_size(), out);
*out = Ch('>'), ++out;
return out;
}
// Print pi node
template<class OutIt, class Ch>
inline OutIt print_pi_node(OutIt out, const xml_node<Ch> *node, int flags, int indent)
{
assert(node->type() == node_pi);
if (!(flags & print_no_indenting))
out = fill_chars(out, indent, Ch('\t'));
*out = Ch('<'), ++out;
*out = Ch('?'), ++out;
out = copy_chars(node->name(), node->name() + node->name_size(), out);
*out = Ch(' '), ++out;
out = copy_chars(node->value(), node->value() + node->value_size(), out);
*out = Ch('?'), ++out;
*out = Ch('>'), ++out;
return out;
}
}
//! \endcond
///////////////////////////////////////////////////////////////////////////
// Printing
//! Prints XML to given output iterator.
//! \param out Output iterator to print to.
//! \param node Node to be printed. Pass xml_document to print entire document.
//! \param flags Flags controlling how XML is printed.
//! \return Output iterator pointing to position immediately after last character of printed text.
template<class OutIt, class Ch>
inline OutIt print(OutIt out, const xml_node<Ch> &node, int flags = 0)
{
return internal::print_node(out, &node, flags, 0);
}
#ifndef RAPIDXML_NO_STREAMS
//! Prints XML to given output stream.
//! \param out Output stream to print to.
//! \param node Node to be printed. Pass xml_document to print entire document.
//! \param flags Flags controlling how XML is printed.
//! \return Output stream.
template<class Ch>
inline std::basic_ostream<Ch> &print(std::basic_ostream<Ch> &out, const xml_node<Ch> &node, int flags = 0)
{
print(std::ostream_iterator<Ch>(out), node, flags);
return out;
}
//! Prints formatted XML to given output stream. Uses default printing flags. Use print() function to customize printing process.
//! \param out Output stream to print to.
//! \param node Node to be printed.
//! \return Output stream.
template<class Ch>
inline std::basic_ostream<Ch> &operator <<(std::basic_ostream<Ch> &out, const xml_node<Ch> &node)
{
return print(out, node);
}
#endif
}
#endif

View File

@@ -0,0 +1,122 @@
#ifndef RAPIDXML_UTILS_HPP_INCLUDED
#define RAPIDXML_UTILS_HPP_INCLUDED
// Copyright (C) 2006, 2009 Marcin Kalicinski
// Version 1.13
// Revision $DateTime: 2009/05/13 01:46:17 $
//! \file rapidxml_utils.hpp This file contains high-level rapidxml utilities that can be useful
//! in certain simple scenarios. They should probably not be used if maximizing performance is the main objective.
#include "rapidxml.hpp"
#include <vector>
#include <string>
#include <fstream>
#include <stdexcept>
namespace rapidxml
{
//! Represents data loaded from a file
template<class Ch = char>
class file
{
public:
//! Loads file into the memory. Data will be automatically destroyed by the destructor.
//! \param filename Filename to load.
file(const char *filename)
{
using namespace std;
// Open stream
basic_ifstream<Ch> stream(filename, ios::binary);
if (!stream)
throw runtime_error(string("cannot open file ") + filename);
stream.unsetf(ios::skipws);
// Determine stream size
stream.seekg(0, ios::end);
size_t size = stream.tellg();
stream.seekg(0);
// Load data and add terminating 0
m_data.resize(size + 1);
stream.read(&m_data.front(), static_cast<streamsize>(size));
m_data[size] = 0;
}
//! Loads file into the memory. Data will be automatically destroyed by the destructor
//! \param stream Stream to load from
file(std::basic_istream<Ch> &stream)
{
using namespace std;
// Load data and add terminating 0
stream.unsetf(ios::skipws);
m_data.assign(istreambuf_iterator<Ch>(stream), istreambuf_iterator<Ch>());
if (stream.fail() || stream.bad())
throw runtime_error("error reading stream");
m_data.push_back(0);
}
//! Gets file data.
//! \return Pointer to data of file.
Ch *data()
{
return &m_data.front();
}
//! Gets file data.
//! \return Pointer to data of file.
const Ch *data() const
{
return &m_data.front();
}
//! Gets file data size.
//! \return Size of file data, in characters.
std::size_t size() const
{
return m_data.size();
}
private:
std::vector<Ch> m_data; // File data
};
//! Counts children of node. Time complexity is O(n).
//! \return Number of children of node
template<class Ch>
inline std::size_t count_children(xml_node<Ch> *node)
{
xml_node<Ch> *child = node->first_node();
std::size_t count = 0;
while (child)
{
++count;
child = child->next_sibling();
}
return count;
}
//! Counts attributes of node. Time complexity is O(n).
//! \return Number of attributes of node
template<class Ch>
inline std::size_t count_attributes(xml_node<Ch> *node)
{
xml_attribute<Ch> *attr = node->first_attribute();
std::size_t count = 0;
while (attr)
{
++count;
attr = attr->next_attribute();
}
return count;
}
}
#endif

7
src/include/resource.h Normal file
View File

@@ -0,0 +1,7 @@
#define IDC_PROPERTYGRID 2000
#define IDC_STATIC 2
#define IDE_EDIT 105
#define IDI_ICON1 102
#define IDB_BITMAP1 103
#define IDD_DIALOG1 104

View File

@@ -0,0 +1,5 @@
#pragma once
#include <windows.h>
#define GetHoldKeyState(nVirtKey) (GetKeyState(nVirtKey)>>1)
#define GetKPBool(nVirtKey) (GetKeyState(nVirtKey) & 0x8000)

1013
src/source/Application.cpp Normal file

File diff suppressed because it is too large Load Diff

82
src/source/ArrowTool.cpp Normal file
View File

@@ -0,0 +1,82 @@
#include "ArrowTool.h"
#include "Application.h"
ArrowTool::ArrowTool(void)
{
lctrlDown = false;
rctrlDown = false;
dragging = false;
mouseDown = false;
}
ArrowTool::~ArrowTool(void)
{
}
void ArrowTool::onButton1MouseDown(Mouse mouse)
{
mouseDownStartx = mouse.x;
mouseDownStarty = mouse.y;
mouseDown = true;
if(!lctrlDown && !rctrlDown)
g_selectedInstances.clear();
PartInstance * target = mouse.getTarget();
if(target != NULL && std::find(g_selectedInstances.begin(), g_selectedInstances.end(), target) == g_selectedInstances.end())
g_selectedInstances.push_back(target);
if(g_selectedInstances.size() == 0)
g_selectedInstances.push_back(g_dataModel);
g_usableApp->_propWindow->UpdateSelected(g_selectedInstances[0]);
}
void ArrowTool::onButton1MouseUp(Mouse mouse)
{
if(dragging)
this->setCursor(GetFileInPath("/content/images/ArrowCursor.png"));
mouseDown = false;
dragging = false;
}
void ArrowTool::onMouseMoved(Mouse mouse)
{
if(mouseDown)
{
if(!dragging)
{
if(abs(mouse.x-mouseDownStartx) > 5 || abs(mouse.y-mouseDownStarty) > 5)
{
this->setCursor(GetFileInPath("/content/images/GrabRotateCursor.png"));
dragging = true;
}
else return;
}
for(size_t i = 0; i < g_selectedInstances.size(); i++) //This will later decide primary and move all parts according to primary
{
if(PartInstance * part = dynamic_cast<PartInstance *>(g_selectedInstances[i]))
{
part->setPosition(mouse.getPosition(g_selectedInstances));
}
}
return;
}
PartInstance * target = mouse.getTarget();
if(target == NULL)
this->setCursor(GetFileInPath("/content/images/ArrowCursor.png"));
else this->setCursor(GetFileInPath("/content/images/DragCursor.png"));
}
void ArrowTool::onSelect(Mouse mouse)
{
this->setCursor(GetFileInPath("/content/images/ArrowCursor.png"));
}
void ArrowTool::onKeyDown(int key)
{
if(key == VK_CONTROL)
{
lctrlDown = true;
}
}
void ArrowTool::onKeyUp(int key)
{
if(key == VK_CONTROL)
lctrlDown = false;
}

112
src/source/AudioPlayer.cpp Normal file
View File

@@ -0,0 +1,112 @@
#include "AudioPlayer.h"
#include "SDL.h"
#include "SDL_audio.h"
#include <stdlib.h>
#include <malloc.h>
#include <string.h>
#define NUM_SOUNDS 10
static SDL_AudioSpec fmt;
static bool initiated = false;
AudioPlayer::AudioPlayer(void)
{
}
AudioPlayer::~AudioPlayer(void)
{
SDL_CloseAudio();
}
void AudioPlayer::init()
{
initiated = true;
extern void mixaudio(void *unused, Uint8 *stream, int len);
fmt.freq = 22050;
fmt.format = AUDIO_S16;
fmt.channels = 2;
fmt.samples = 1024; /* A good value for games */
fmt.callback = mixaudio;
fmt.userdata = NULL;
/* Open the audio device and start playing sound! */
if ( SDL_OpenAudio(&fmt, NULL) < 0 ) {
fprintf(stderr, "Unable to open audio: %s\n", SDL_GetError());
}
SDL_PauseAudio(0);
}
static struct sample {
Uint8 *data;
Uint32 dpos;
Uint32 dlen;
} sounds[NUM_SOUNDS];
void mixaudio(void *unused, Uint8 *stream, int len)
{
int i;
Uint32 amount;
for ( i=0; i<NUM_SOUNDS; ++i ) {
amount = (sounds[i].dlen-sounds[i].dpos);
if ( amount > (Uint32)len ) {
amount = len;
}
SDL_MixAudio(stream, &sounds[i].data[sounds[i].dpos], amount, SDL_MIX_MAXVOLUME);
sounds[i].dpos += amount;
}
}
void AudioPlayer::playSound(std::string fileString)
{
if(initiated)
{
char *file = new char[fileString.length() + 1];
strcpy(file, fileString.c_str());
int index;
SDL_AudioSpec wave;
Uint8 *data;
Uint32 dlen;
SDL_AudioCVT cvt;
/* Look for an empty (or finished) sound slot */
for ( index=0; index<NUM_SOUNDS; ++index ) {
if ( sounds[index].dpos == sounds[index].dlen ) {
break;
}
}
if ( index == NUM_SOUNDS )
return;
/* Load the sound file and convert it to 16-bit stereo at 22kHz */
if ( SDL_LoadWAV(file, &wave, &data, &dlen) == NULL ) {
fprintf(stderr, "Couldn't load %s: %s\n", file, SDL_GetError());
return;
}
SDL_BuildAudioCVT(&cvt, wave.format, wave.channels, wave.freq,
AUDIO_S16, 2, fmt.freq);
cvt.buf = (Uint8*)malloc(dlen*cvt.len_mult);
memcpy(cvt.buf, data, dlen);
cvt.len = dlen;
SDL_ConvertAudio(&cvt);
SDL_FreeWAV(data);
/* Put the sound data in the slot (it starts playing immediately) */
if ( sounds[index].data ) {
free(sounds[index].data);
}
SDL_LockAudio();
sounds[index].data = cvt.buf;
sounds[index].dlen = cvt.len_cvt;
sounds[index].dpos = 0;
SDL_UnlockAudio();
delete [] file;
}
else
{
OutputDebugString("Audio player not initialized, sound will not play\r\n");
}
}

View File

@@ -0,0 +1,62 @@
#include "BaseButtonInstance.h"
#include "Globals.h"
#include "Application.h"
ButtonListener* listener = NULL;
BaseButtonInstance::BaseButtonInstance(void)
{
Instance::Instance();
listener = NULL;
}
void BaseButtonInstance::render(RenderDevice* rd)
{
DataModelInstance* dataModel = g_dataModel;
Vector2 pos = Vector2(g_usableApp->mouse.x,g_usableApp->mouse.y);
drawObj(rd, pos, g_usableApp->mouse.isMouseDown());
Instance::render(rd);
}
BaseButtonInstance::~BaseButtonInstance(void)
{
if(listener != NULL && listener->doDelete)
{
delete listener;
listener = NULL;
}
}
void BaseButtonInstance::setButtonListener(ButtonListener* buttonListener)
{
listener = buttonListener;
}
void BaseButtonInstance::drawObj(RenderDevice* rd, Vector2 mousePos, bool mouseDown){}
bool BaseButtonInstance::mouseInButton(float mousex, float mousey, RenderDevice* rd){return false;}
void BaseButtonInstance::onMouseClick()
{
if(listener != NULL)
{
listener->onButton1MouseClick(this);
}
}
bool BaseButtonInstance::mouseInArea(float point1x, float point1y, float point2x, float point2y, float mousex, float mousey)
{
if(mousex >= point1x && mousey >= point1y)
{
if(mousex < point2x && mousey < point2y)
{
return true;
}
}
return false;
}

View File

@@ -0,0 +1,9 @@
#include "BrowserCallHandler.h"
BrowserCallHandler::BrowserCallHandler(void)
{
}
BrowserCallHandler::~BrowserCallHandler(void)
{
}

View File

@@ -0,0 +1,17 @@
#include "BaseButtonInstance.h"
#include "ButtonListener.h"
ButtonListener::ButtonListener()
{
doDelete = true;
}
ButtonListener::~ButtonListener(void)
{
}
void ButtonListener::onButton1MouseClick(BaseButtonInstance* button)
{
}

View File

@@ -0,0 +1,24 @@
#include "CameraButtonListener.h"
#include "Globals.h"
#include "AudioPlayer.h"
#include "Application.h"
void CameraButtonListener::onButton1MouseClick(BaseButtonInstance* button)
{
AudioPlayer::playSound(cameraSound);
CoordinateFrame frame = g_usableApp->cameraController.getCamera()->getCoordinateFrame();
if(button->name == "CenterCam" && g_selectedInstances.size() > 0)
g_usableApp->cameraController.centerCamera(g_selectedInstances.at(0));
else if(button->name == "ZoomIn")
g_usableApp->cameraController.Zoom(1);
else if(button->name == "ZoomOut")
g_usableApp->cameraController.Zoom(-1);
else if(button->name == "PanRight")
g_usableApp->cameraController.panRight();
else if(button->name == "PanLeft")
g_usableApp->cameraController.panLeft();
else if(button->name == "TiltUp")
g_usableApp->cameraController.tiltUp();
else if(button->name == "TiltDown")
g_usableApp->cameraController.tiltDown();
}

View File

@@ -0,0 +1,264 @@
#include "CameraController.h"
#include "win32Defines.h"
#include <iostream>
#include "PartInstance.h"
#include "Application.h"
#include "AudioPlayer.h"
CameraController::CameraController() :
yaw(0),
pitch(0),
moveRate(1.0f),
forwards(false),
backwards(false),
left(false),
right(false),
zoom(14.f),
rightButtonHolding(false),
focusPosition(Vector3(0,0,0)) {}
GCamera* CameraController::getCamera()
{
return &g3dCamera;
}
void CameraController::lookAt(const Vector3& position) {
const Vector3 look = (position - g3dCamera.getCoordinateFrame().translation);
yaw = aTan2(look.x, -look.z);
pitch = -aTan2(look.y, distance(look.x, look.z));
CoordinateFrame frame = g3dCamera.getCoordinateFrame().translation;
frame.rotation = Matrix3::fromEulerAnglesZYX(0, -yaw, -pitch);
g3dCamera.setCoordinateFrame(frame);
}
void CameraController::setFrame(const CoordinateFrame& cf) {
Vector3 look = cf.getLookVector();
g3dCamera.setCoordinateFrame(cf);
lookAt(cf.translation + look);
focusPosition=cf.translation+cf.lookVector()*zoom;
}
CoordinateFrame CameraController::getCoordinateFrame() {
CoordinateFrame cf;
cf.translation=translation;
cf.rotation = Matrix3::fromEulerAnglesZYX(0, -yaw, -pitch);
return cf;
}
void CameraController::refreshZoom(const CoordinateFrame& frame)
{
CoordinateFrame zoomFrame = focusPosition-frame.lookVector()*zoom;
zoomFrame.lookAt(focusPosition);
setFrame(zoomFrame);
}
void CameraController::pan(CoordinateFrame* frame,float spdX, float spdY)
{
yaw+=spdX;
pitch+=spdY;
if (pitch>1.4f) pitch=1.4f;
if (pitch<-1.4f) pitch=-1.4f;
frame->translation = Vector3(sin(-yaw)*zoom*cos(pitch),sin(pitch)*zoom,cos(-yaw)*zoom*cos(pitch))+focusPosition;
frame->lookAt(focusPosition);
}
void CameraController::panLock(CoordinateFrame* frame,float spdX, float spdY)
{
int sign = 0;
yaw = toDegrees(yaw);
if((((yaw - fmod(yaw, 45)) / 45) * 45) < 0)
{
sign = 1;
}
yaw = fabs(yaw);
yaw = ((yaw - fmod(yaw, 45)) / 45) * 45;
yaw = toRadians(yaw);
if(sign==1)
{
yaw = yaw * -1;
}
yaw+=spdX;
pitch+=spdY;
if (pitch>1.4f) pitch=1.4f;
if (pitch<-1.4f) pitch=-1.4f;
frame->translation = Vector3(sin(-yaw)*zoom*cos(pitch),sin(pitch)*zoom,cos(-yaw)*zoom*cos(pitch))+focusPosition;
frame->lookAt(focusPosition);
}
bool CameraController::onMouseWheel(int x, int y, short delta)
{
Zoom(delta);
return true;
}
void CameraController::Zoom(short delta)
{
CoordinateFrame frame = g3dCamera.getCoordinateFrame();
if (delta>0) { // Mouse wheel up
CoordinateFrame zoomFrame = frame+frame.lookVector()*(zoom/5);
zoom=(zoomFrame.translation-focusPosition).magnitude();
if (zoom>CAM_ZOOM_MIN)
{
setFrame(zoomFrame);
}
else
{
zoom=CAM_ZOOM_MIN;
refreshZoom(frame);
}
}
else {
CoordinateFrame zoomFrame = frame-frame.lookVector()*(zoom/5);
zoom=(zoomFrame.translation-focusPosition).magnitude();
if (zoom<CAM_ZOOM_MAX)
{
setFrame(zoomFrame);
}
else
{
zoom=CAM_ZOOM_MAX;
refreshZoom(frame);
}
}
}
void CameraController::panLeft()
{
CoordinateFrame frame = g3dCamera.getCoordinateFrame();
panLock(&frame,toRadians(-45),0);
setFrame(frame);
}
void CameraController::panRight()
{
CoordinateFrame frame = g3dCamera.getCoordinateFrame();
panLock(&frame,toRadians(45),0);
setFrame(frame);
}
void CameraController::tiltUp()
{
CoordinateFrame frame = CoordinateFrame(g3dCamera.getCoordinateFrame().rotation, g3dCamera.getCoordinateFrame().translation);
pan(&frame,0,toRadians(25));
setFrame(frame);
}
void CameraController::tiltDown()
{
CoordinateFrame frame = CoordinateFrame(g3dCamera.getCoordinateFrame().rotation, g3dCamera.getCoordinateFrame().translation);
pan(&frame,0,toRadians(-25));
setFrame(frame);
}
void CameraController::centerCamera(Instance* selection)
{
CoordinateFrame frame = CoordinateFrame(g3dCamera.getCoordinateFrame().translation);
if(selection == NULL)
{
lookAt(Vector3(0,0,0));
focusPosition=Vector3(0,0,0);
}
else if(PartInstance* part = dynamic_cast<PartInstance*>(selection))
{
Vector3 partPos = (part)->getPosition();
lookAt(partPos);
focusPosition=partPos;
zoom=((partPos-frame.translation).magnitude());
}
else
{
lookAt(Vector3(0,0,0));
focusPosition=Vector3(0,0,0);
}
}
void CameraController::update(Application* app)
{
float offsetSize = 0.05F;
Vector3 cameraPos = g3dCamera.getCoordinateFrame().translation;
CoordinateFrame frame = g3dCamera.getCoordinateFrame();
bool moving=false;
if(GetHoldKeyState('U')) {
forwards = true;
moving=true;
}
if(GetHoldKeyState('J')) {
backwards = true;
moving=true;
}
if(GetHoldKeyState('H')) {
left = true;
moving=true;
}
if(GetHoldKeyState('K')) {
right = true;
moving=true;
}
if(forwards) {
forwards = false;
frame.translation += frame.lookVector()*moveRate;
}
else if(backwards) {
backwards = false;
frame.translation -= frame.lookVector()*moveRate;
}
if(left) {
left = false;
frame.translation += frame.leftVector()*moveRate;
}
else if(right) {
right = false;
frame.translation += frame.rightVector()*moveRate;
}
if (moving)
{
zoom=7;
focusPosition=frame.translation+frame.lookVector()*zoom;
}
if(rightButtonHolding) {
Globals::useMousePoint = true;
Globals::mousepoint = oldDesktopMouse;
POINT mouse;
GetCursorPos(&mouse);
pan(&frame,(mouse.x-oldDesktopMouse.x)/100.f,(mouse.y-oldDesktopMouse.y)/100.f);
SetCursorPos(oldDesktopMouse.x,oldDesktopMouse.y);
}
else
{
Globals::useMousePoint = false;
}
if(GetHoldKeyState(VK_RSHIFT) || GetHoldKeyState(VK_LSHIFT)) {
moveRate = 2;
}
else {
moveRate = 1;
}
if(GetHoldKeyState(VK_RBUTTON))
{
if (rightButtonHolding==false)
{
GetCursorPos(&oldDesktopMouse);
rightButtonHolding = true;
}
}
else
{
rightButtonHolding = false;
}
g3dCamera.setCoordinateFrame(frame);
}

View File

@@ -0,0 +1,613 @@
#include <string>
#include "GuiRootInstance.h"
#include "DataModelInstance.h"
#include <fstream>
#include <iostream>
#include <sstream>
#include <commdlg.h>
#include "ErrorFunctions.h"
using namespace std;
using namespace rapidxml;
DataModelInstance::DataModelInstance(void)
{
Instance::Instance();
workspace = new WorkspaceInstance();
guiRoot = new GuiRootInstance();
level = new LevelInstance();
//children.push_back(workspace);
//children.push_back(level);
className = "dataModel";
//mousex = 0;
//mousey = 0;
//mouseButton1Down = false;
showMessage = false;
canDelete = false;
_modY=0;
workspace->setParent(this);
level->setParent(this);
_loadedFileName="..//skooter.rbxm";
listicon = 5;
running = false;
}
void DataModelInstance::toggleRun()
{
running = !running;
}
bool DataModelInstance::isRunning()
{
return running;
}
DataModelInstance::~DataModelInstance(void)
{
}
#ifdef _DEBUG
void DataModelInstance::modXMLLevel(float modY)
{
_modY += modY;
clearLevel();
debugGetOpen();
}
#endif
void DataModelInstance::clearLevel()
{
workspace->clearChildren();
}
PartInstance* DataModelInstance::makePart()
{
PartInstance* part = new PartInstance();
return part;
}
rapidxml::xml_node<>* DataModelInstance::getNode(xml_node<> * node,const char* name)
{
xml_node<> * tempNode = node->first_node(name);
if (!tempNode)
{
_errMsg = "Expected <";
_errMsg += name;
_errMsg+="> tag.";
_successfulLoad=false;
return 0;
}
return tempNode;
}
float DataModelInstance::getFloatValue(xml_node<> * node,const char* name)
{
xml_node<> * tempNode = node->first_node(name);
if (!tempNode)
{
_errMsg = "Expected <";
_errMsg += name;
_errMsg+="> tag.";
_successfulLoad=false;
return 0;
}
float newFloat;
stringstream converter;
converter << tempNode->value();
converter >> newFloat;
return newFloat;
}
Color3 bcToRGB(short bc)
{
switch(bc)
{
case 1: return Color3(0.94901967048645F,0.95294123888016F,0.95294123888016F);
case 2: return Color3(0.63137257099152F,0.64705884456635F,0.63529413938522F);
case 3: return Color3(0.9764706492424F,0.91372555494308F,0.60000002384186F);
case 5: return Color3(0.84313732385635F,0.77254909276962F,0.60392159223557F);
case 6: return Color3(0.7607843875885F,0.85490202903748F,0.72156864404678F);
case 9: return Color3(0.90980398654938F,0.7294117808342F,0.78431379795074F);
case 11: return Color3(0.50196081399918F,0.73333334922791F,0.85882359743118F);
case 12: return Color3(0.79607850313187F,0.51764708757401F,0.258823543787F);
case 18: return Color3(0.80000007152557F,0.55686277151108F,0.41176474094391F);
case 21: return Color3(0.76862752437592F,0.15686275064945F,0.10980392992496F);
case 22: return Color3(0.76862752437592F,0.43921571969986F,0.62745100259781F);
case 23: return Color3(0.050980396568775F,0.41176474094391F,0.6745098233223F);
case 24: return Color3(0.96078437566757F,0.80392163991928F,0.18823531270027F);
case 25: return Color3(0.38431376218796F,0.27843138575554F,0.19607844948769F);
case 26: return Color3(0.10588236153126F,0.16470588743687F,0.20784315466881F);
case 27: return Color3(0.42745101451874F,0.43137258291245F,0.42352944612503F);
case 28: return Color3(0.15686275064945F,0.49803924560547F,0.27843138575554F);
case 29: return Color3(0.63137257099152F,0.76862752437592F,0.54901963472366F);
case 36: return Color3(0.95294123888016F,0.8117647767067F,0.60784316062927F);
case 37: return Color3(0.29411765933037F,0.59215688705444F,0.29411765933037F);
case 38: return Color3(0.62745100259781F,0.37254902720451F,0.20784315466881F);
case 39: return Color3(0.75686281919479F,0.79215693473816F,0.8705883026123F);
case 40: return Color3(0.92549026012421F,0.92549026012421F,0.92549026012421F);
case 41: return Color3(0.80392163991928F,0.32941177487373F,0.29411765933037F);
case 42: return Color3(0.75686281919479F,0.87450987100601F,0.94117653369904F);
case 43: return Color3(0.48235297203064F,0.71372550725937F,0.90980398654938F);
case 44: return Color3(0.96862751245499F,0.94509810209274F,0.55294120311737F);
case 45: return Color3(0.70588237047195F,0.82352948188782F,0.89411771297455F);
case 47: return Color3(0.85098046064377F,0.52156865596771F,0.42352944612503F);
case 48: return Color3(0.51764708757401F,0.71372550725937F,0.55294120311737F);
case 49: return Color3(0.97254908084869F,0.94509810209274F,0.51764708757401F);
case 50: return Color3(0.92549026012421F,0.90980398654938F,0.8705883026123F);
case 100: return Color3(0.93333339691162F,0.76862752437592F,0.71372550725937F);
case 101: return Color3(0.85490202903748F,0.52549022436142F,0.47843140363693F);
case 102: return Color3(0.43137258291245F,0.60000002384186F,0.79215693473816F);
case 103: return Color3(0.78039222955704F,0.75686281919479F,0.71764707565308F);
case 104: return Color3(0.41960787773132F,0.19607844948769F,0.48627454042435F);
case 105: return Color3(0.88627457618713F,0.60784316062927F,0.25098040699959F);
case 106: return Color3(0.85490202903748F,0.52156865596771F,0.2549019753933F);
case 107: return Color3(0,0.56078433990479F,0.61176472902298F);
case 108: return Color3(0.4078431725502F,0.36078432202339F,0.26274511218071F);
case 110: return Color3(0.26274511218071F,0.32941177487373F,0.57647061347961F);
case 111: return Color3(0.74901962280273F,0.71764707565308F,0.69411766529083F);
case 112: return Color3(0.4078431725502F,0.45490199327469F,0.6745098233223F);
case 113: return Color3(0.89411771297455F,0.678431391716F,0.78431379795074F);
case 115: return Color3(0.78039222955704F,0.82352948188782F,0.23529413342476F);
case 116: return Color3(0.33333334326744F,0.64705884456635F,0.68627452850342F);
case 118: return Color3(0.71764707565308F,0.84313732385635F,0.83529418706894F);
case 119: return Color3(0.64313727617264F,0.74117648601532F,0.27843138575554F);
case 120: return Color3(0.85098046064377F,0.89411771297455F,0.65490198135376F);
case 121: return Color3(0.90588241815567F,0.6745098233223F,0.34509804844856F);
case 123: return Color3(0.82745105028152F,0.43529415130615F,0.29803922772408F);
case 124: return Color3(0.57254904508591F,0.22352942824364F,0.47058826684952F);
case 125: return Color3(0.91764712333679F,0.72156864404678F,0.57254904508591F);
case 126: return Color3(0.64705884456635F,0.64705884456635F,0.79607850313187F);
case 127: return Color3(0.86274516582489F,0.73725491762161F,0.50588238239288F);
case 128: return Color3(0.68235296010971F,0.47843140363693F,0.34901961684227F);
case 131: return Color3(0.61176472902298F,0.63921570777893F,0.65882354974747F);
case 133: return Color3(0.83529418706894F,0.45098042488098F,0.23921570181847F);
case 134: return Color3(0.84705889225006F,0.8666667342186F,0.33725491166115F);
case 135: return Color3(0.45490199327469F,0.52549022436142F,0.61568629741669F);
case 136: return Color3(0.52941179275513F,0.48627454042435F,0.56470590829849F);
case 137: return Color3(0.87843143939972F,0.59607845544815F,0.39215689897537F);
case 138: return Color3(0.58431375026703F,0.54117649793625F,0.45098042488098F);
case 140: return Color3(0.12549020349979F,0.22745099663734F,0.33725491166115F);
case 141: return Color3(0.15294118225574F,0.27450981736183F,0.17647059261799F);
case 143: return Color3(0.8117647767067F,0.88627457618713F,0.96862751245499F);
case 145: return Color3(0.47450983524323F,0.53333336114883F,0.63137257099152F);
case 146: return Color3(0.58431375026703F,0.55686277151108F,0.63921570777893F);
case 147: return Color3(0.57647061347961F,0.52941179275513F,0.40392160415649F);
case 148: return Color3(0.34117648005486F,0.34509804844856F,0.34117648005486F);
case 149: return Color3(0.086274512112141F,0.11372549831867F,0.19607844948769F);
case 150: return Color3(0.67058825492859F,0.678431391716F,0.6745098233223F);
case 151: return Color3(0.47058826684952F,0.56470590829849F,0.50980395078659F);
case 153: return Color3(0.58431375026703F,0.47450983524323F,0.46666669845581F);
case 154: return Color3(0.48235297203064F,0.1803921610117F,0.1843137294054F);
case 157: return Color3(1,0.96470594406128F,0.48235297203064F);
case 158: return Color3(0.88235300779343F,0.64313727617264F,0.7607843875885F);
case 168: return Color3(0.4588235616684F,0.42352944612503F,0.38431376218796F);
case 176: return Color3(0.59215688705444F,0.41176474094391F,0.35686275362968F);
case 178: return Color3(0.70588237047195F,0.51764708757401F,0.33333334326744F);
case 179: return Color3(0.53725492954254F,0.52941179275513F,0.53333336114883F);
case 180: return Color3(0.84313732385635F,0.66274511814117F,0.29411765933037F);
case 190: return Color3(0.9764706492424F,0.83921575546265F,0.1803921610117F);
case 191: return Color3(0.90980398654938F,0.67058825492859F,0.17647059261799F);
case 192: return Color3(0.41176474094391F,0.25098040699959F,0.15686275064945F);
case 193: return Color3(0.8117647767067F,0.37647062540054F,0.14117647707462F);
case 195: return Color3(0.27450981736183F,0.40392160415649F,0.64313727617264F);
case 196: return Color3(0.13725490868092F,0.27843138575554F,0.54509806632996F);
case 198: return Color3(0.55686277151108F,0.258823543787F,0.52156865596771F);
case 199: return Color3(0.38823533058167F,0.37254902720451F,0.38431376218796F);
case 200: return Color3(0.50980395078659F,0.54117649793625F,0.3647058904171F);
case 208: return Color3(0.89803928136826F,0.89411771297455F,0.87450987100601F);
case 209: return Color3(0.69019609689713F,0.55686277151108F,0.26666668057442F);
case 210: return Color3(0.43921571969986F,0.58431375026703F,0.47058826684952F);
case 211: return Color3(0.47450983524323F,0.70980393886566F,0.70980393886566F);
case 212: return Color3(0.6235294342041F,0.76470595598221F,0.91372555494308F);
case 213: return Color3(0.42352944612503F,0.50588238239288F,0.71764707565308F);
case 216: return Color3(0.56078433990479F,0.29803922772408F,0.16470588743687F);
case 217: return Color3(0.48627454042435F,0.36078432202339F,0.27450981736183F);
case 218: return Color3(0.58823531866074F,0.43921571969986F,0.6235294342041F);
case 219: return Color3(0.41960787773132F,0.38431376218796F,0.60784316062927F);
case 220: return Color3(0.65490198135376F,0.66274511814117F,0.80784320831299F);
case 221: return Color3(0.80392163991928F,0.38431376218796F,0.59607845544815F);
case 222: return Color3(0.89411771297455F,0.678431391716F,0.78431379795074F);
case 223: return Color3(0.86274516582489F,0.56470590829849F,0.58431375026703F);
case 224: return Color3(0.94117653369904F,0.83529418706894F,0.62745100259781F);
case 225: return Color3(0.9215686917305F,0.72156864404678F,0.49803924560547F);
case 226: return Color3(0.99215692281723F,0.91764712333679F,0.55294120311737F);
case 232: return Color3(0.49019610881805F,0.73333334922791F,0.8666667342186F);
case 268: return Color3(0.2039215862751F,0.16862745583057F,0.4588235616684F);
case 1001: return Color3(0.97254908084869F,0.97254908084869F,0.97254908084869F);
case 1002: return Color3(0.80392163991928F,0.80392163991928F,0.80392163991928F);
case 1003: return Color3(0.066666670143604F,0.066666670143604F,0.066666670143604F);
case 1004: return Color3(1,0,0);
case 1005: return Color3(1,0.68627452850342F,0);
case 1006: return Color3(0.70588237047195F,0.50196081399918F,1);
case 1007: return Color3(0.63921570777893F,0.29411765933037F,0.29411765933037F);
case 1008: return Color3(0.75686281919479F,0.74509805440903F,0.258823543787F);
case 1009: return Color3(1,1,0);
case 1010: return Color3(0,0,1);
case 1011: return Color3(0,0.12549020349979F,0.37647062540054F);
case 1012: return Color3(0.1294117718935F,0.32941177487373F,0.72549021244049F);
case 1013: return Color3(0.015686275437474F,0.68627452850342F,0.92549026012421F);
case 1014: return Color3(0.66666668653488F,0.33333334326744F,0);
case 1015: return Color3(0.66666668653488F,0,0.66666668653488F);
case 1016: return Color3(1,0.40000003576279F,0.80000007152557F);
case 1017: return Color3(1,0.68627452850342F,0);
case 1018: return Color3(0.070588238537312F,0.93333339691162F,0.83137261867523F);
case 1019: return Color3(0,1,1);
case 1020: return Color3(0,1,0);
case 1021: return Color3(0.22745099663734F,0.49019610881805F,0.082352943718433F);
case 1022: return Color3(0.49803924560547F,0.55686277151108F,0.39215689897537F);
case 1023: return Color3(0.54901963472366F,0.35686275362968F,0.6235294342041F);
case 1024: return Color3(0.68627452850342F,0.8666667342186F,1);
case 1025: return Color3(1,0.78823536634445F,0.78823536634445F);
case 1026: return Color3(0.69411766529083F,0.65490198135376F,1);
case 1027: return Color3(0.6235294342041F,0.95294123888016F,0.91372555494308F);
case 1028: return Color3(0.80000007152557F,1,0.80000007152557F);
case 1029: return Color3(1,1,0.80000007152557F);
case 1030: return Color3(1,0.80000007152557F,0.60000002384186F);
case 1031: return Color3(0.38431376218796F,0.14509804546833F,0.81960791349411F);
case 1032: return Color3(1,0,0.74901962280273F);
default: return Color3::gray();
}
}
bool DataModelInstance::scanXMLObject(xml_node<> * scanNode)
{
xml_node<> * watchFirstNode = scanNode->first_node();
for (xml_node<> *node = scanNode->first_node();node; node = node->next_sibling())
{
if (strncmp(node->name(),"Item",4)==0)
{
xml_attribute<> *classAttr = node->first_attribute("class");
std::string className = classAttr->value();
if (className=="Part") {
xml_node<> *propNode = node->first_node();
xml_node<> *cFrameNode=0;
xml_node<> *sizeNode=0;
xml_node<> *shapeNode=0;
xml_node<> *colorNode=0;
xml_node<> *brickColorNode=0;
xml_node<> *nameNode=0;
for (xml_node<> *partPropNode = propNode->first_node();partPropNode; partPropNode = partPropNode->next_sibling())
{
for (xml_attribute<> *attr = partPropNode->first_attribute();attr; attr = attr->next_attribute())
{
std::string xmlName = attr->name();
std::string xmlValue = attr->value();
if (xmlValue=="CFrame" | xmlValue=="CoordinateFrame")
{
cFrameNode = partPropNode;
}
if (xmlValue=="Name")
{
nameNode = partPropNode;
}
if (xmlValue=="shape")
{
shapeNode = partPropNode;
_legacyLoad=false;
}
if (xmlValue=="Color")
{
colorNode=partPropNode;
}
if (xmlValue=="BrickColor")
{
brickColorNode=partPropNode;
}
if (xmlValue=="size")
{
sizeNode = partPropNode;
_legacyLoad=false;
}
if (xmlValue=="Part")
{
for (xml_node<> *featureNode = partPropNode->first_node();featureNode; featureNode = featureNode->next_sibling())
{
for (xml_attribute<> *attr = featureNode->first_attribute();attr; attr = attr->next_attribute())
{
std::string xmlName = attr->name();
std::string xmlValue = attr->value();
if (xmlValue=="shape")
{
shapeNode = featureNode;
_legacyLoad=true;
}
if (xmlValue=="size")
{
sizeNode=featureNode;
_legacyLoad=true;
}
}
}
}
}
}
if (!cFrameNode) {
_errMsg="CFrame is missing in Part";
return false;
}
if (!sizeNode) {
_errMsg="Size is missing in Part";
return false;
}
float R=1;
float G=1;
float B=1;
if (colorNode)
{
R = getFloatValue(colorNode,"R");
G = getFloatValue(colorNode,"G");
B = getFloatValue(colorNode,"B");
}
Enum::Shape::Value partshape = Enum::Shape::Block;
std::string pshape = shapeNode->value();
if (shapeNode)
{
if(pshape == "0" || pshape == "Ball"){
partshape = Enum::Shape::Ball;
}
if(pshape == "1" || pshape == "Block"){
partshape = Enum::Shape::Block;
}
if(pshape == "2" || pshape == "Cylinder"){
partshape = Enum::Shape::Cylinder;
}
}
std::string newName = nameNode->value();
float X = getFloatValue(cFrameNode,"X");
float Y = getFloatValue(cFrameNode,"Y");
float Z = getFloatValue(cFrameNode,"Z");
float R00 = getFloatValue(cFrameNode,"R00");
float R01 = getFloatValue(cFrameNode,"R01");
float R02 = getFloatValue(cFrameNode,"R02");
float R10 = getFloatValue(cFrameNode,"R10");
float R11 = getFloatValue(cFrameNode,"R11");
float R12 = getFloatValue(cFrameNode,"R12");
float R20 = getFloatValue(cFrameNode,"R20");
float R21 = getFloatValue(cFrameNode,"R21");
float R22 = getFloatValue(cFrameNode,"R22");
float sizeX = getFloatValue(sizeNode,"X");
float sizeY = getFloatValue(sizeNode,"Y");
float sizeZ = getFloatValue(sizeNode,"Z");
//sizeX=1;
//sizeY=1;
//sizeZ=1;
if (_successfulLoad) {
PartInstance* test = makePart();
test->setParent(getWorkspace());
test->color = Color3(R,G,B);
test->shape = partshape;
if(brickColorNode)
{
test->color = bcToRGB(atoi(brickColorNode->value()));
}
test->setSize(Vector3(sizeX,sizeY+_modY,sizeZ));
test->setName(newName);
CoordinateFrame cf;
if (_legacyLoad)
{
cf = CoordinateFrame(Vector3(-X,Y,Z))*CoordinateFrame(Vector3(-sizeX/2,(sizeY+_modY)/2,sizeZ/2)*Matrix3(R00,R01,R02,R10,R11,R12,R20,R21,R22));
cf.rotation = Matrix3(R00,R01,R02,R10,R11,R12,R20,R21,R22);
}
else
{
cf.translation = Vector3(X,Y,Z);
cf.rotation = Matrix3(R00,R01,R02,R10,R11,R12,R20,R21,R22);
}
test->setCFrame(cf);
}
else
{
return false;
}
}
}
/*
for (xml_attribute<> *attr = node->first_attribute();attr; attr = attr->next_attribute())
{
std::string xmlName = attr->name();
std::string xmlValue = attr->value();
}
*/
scanXMLObject(node);
}
return true;
}
bool DataModelInstance::load(const char* filename, bool clearObjects)
{
ifstream levelFile(filename,ios::binary);
if (levelFile)
{
if (clearObjects)
clearLevel();
readXMLFileStream(&levelFile);
std::string sfilename = std::string(filename);
std::size_t begin = sfilename.rfind('\\') + 1;
std::size_t end = sfilename.find(".rbx");
std::string hname = sfilename.substr(begin);
std::string tname = hname.substr(0, hname.length() - 5);
name = tname;
return true;
}
else
{
std::stringstream msg;
msg << "Failed to load file:" << std::endl << filename << std::endl << strerror(errno);
MessageBoxStr(msg.str());
return false;
}
}
bool DataModelInstance::readXMLFileStream(std::ifstream* file)
{
file->seekg(0,file->end);
int length = file->tellg();
if (length<0)
{
MessageBoxStr("File is empty");
file->close();
return false;
}
file->seekg(0,file->beg);
char * buffer = new char[length+1];
buffer[length]=0;
file->read(buffer,length);
file->close();
if (!file)
{
stringstream msg;
msg << "Something went wrong." << endl << strerror(errno);
MessageBoxStr(msg.str());
return false;
}
_successfulLoad = true;
xml_document<> doc;
doc.parse<0>(buffer);
xml_node<> *mainNode = doc.first_node();
_legacyLoad=false;
//std::string xmlName = mainNode->name();
//node = node->first_node();
//xmlName = node->name();
scanXMLObject(mainNode);
delete[] buffer;
return true;
}
bool DataModelInstance::debugGetOpen()
{
ifstream levelFile(_loadedFileName.c_str(),ios::binary);
if (levelFile)
readXMLFileStream(&levelFile);
else
getOpen();
return true;
}
bool DataModelInstance::getOpen()
{
_modY=0;
OPENFILENAME of;
ZeroMemory( &of , sizeof( of));
of.lStructSize = sizeof(OPENFILENAME);
of.lpstrFilter = "Roblox Files\0*.rbxm;*.rbxl\0\0";
char szFile[512];
of.lpstrFile = szFile ;
of.lpstrFile[0]='\0';
of.nMaxFile=500;
of.lpstrTitle="Hello";
of.Flags = OFN_FILEMUSTEXIST;
ShowCursor(TRUE);
BOOL file = GetOpenFileName(&of);
if (file)
{
_loadedFileName = of.lpstrFile;
load(of.lpstrFile,true);
}
return true;
}
void DataModelInstance::setMessage(std::string msg)
{
message = msg;
isBrickCount = false;
showMessage = true;
}
void DataModelInstance::clearMessage()
{
showMessage = false;
isBrickCount = false;
message = "";
}
void DataModelInstance::setMessageBrickCount()
{
isBrickCount = true;
showMessage = true;
}
void DataModelInstance::drawMessage(RenderDevice* rd)
{
if(isBrickCount)
{
int brickCount = 0;
int instCount = 0;
std::vector<Instance*> inst = getAllChildren();
for(size_t i = 0; i < inst.size(); i++)
{
if(PartInstance* moveTo = dynamic_cast<PartInstance*>(inst.at(i)))
{
brickCount++;
}
else
{
instCount++;
}
}
char brkc[12];
sprintf_s(brkc, "%d", brickCount);
char instc[12];
sprintf_s(instc, "%d", instCount);
message = "Bricks: ";
message += brkc;
message += " Snaps: ";
message += instc;
}
if(showMessage && !font.isNull())
{
int x = rd->getWidth()/2;
int y = rd->getHeight()/2;
int width = rd->getWidth()/2 + 100;
int height = width / 3;
Draw::box(Box(Vector3(x-(width/2), y-(height/2), 0), Vector3(x+(width/2), y+(height/2), 0)), rd, Color4::fromARGB(0x55B2B2B2), Color3::fromARGB(0xB2B2B2));
font->draw2D(rd, message, Vector2(x,y), height/8, Color3::white(), Color4::clear(), GFont::XALIGN_CENTER, GFont::YALIGN_CENTER);
}
}
WorkspaceInstance* DataModelInstance::getWorkspace()
{
return workspace;
}
/*Vector2 DataModelInstance::getMousePos()
{
return Vector2(mousex,mousey);
}
void DataModelInstance::setMousePos(int x,int y)
{
mousex=x;
mousey=y;
}
void DataModelInstance::setMousePos(Vector2 pos)
{
mousex=pos.x;
mousey=pos.y;
}*/
GuiRootInstance* DataModelInstance::getGuiRoot()
{
return guiRoot;
}
LevelInstance* DataModelInstance::getLevel()
{
return level;
}

View File

@@ -0,0 +1,8 @@
#include "DeleteListener.h"
#include "Globals.h"
#include "Application.h"
void DeleteListener::onButton1MouseClick(BaseButtonInstance* button)
{
g_usableApp->deleteInstance();
}

View File

@@ -0,0 +1,29 @@
#include <sstream>
#include "ErrorFunctions.h"
#include "Globals.h"
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_PlaceholderName+" has to quit. We're sorry!" + msg;
std::string title = g_PlaceholderName+"Crash";
//clearInstances();
MessageBox(NULL, emsg.c_str(), title.c_str(), MB_OK);
exit(err);
}
void MessageBoxStr(std::string msg)
{
std::string title = g_PlaceholderName;
MessageBox(NULL, msg.c_str(), title.c_str(), MB_OK);
}
void MessageBoxStream(std::stringstream msg)
{
std::string strMsg = msg.str();
std::string title = g_PlaceholderName;
MessageBox(NULL, strMsg.c_str(), title.c_str(), MB_OK);
}

View File

@@ -0,0 +1,85 @@
#include <G3DAll.h>
#include "Application.h"
#include "Globals.h"
#include "AudioPlayer.h"
#include "GUDButtonListener.h"
void GUDButtonListener::onButton1MouseClick(BaseButtonInstance* button)
{
bool cont = false;
for(size_t i = 0; i < g_selectedInstances.size(); i++)
if(g_selectedInstances.at(i)->canDelete)
{
cont = true;
break;
}
if(cont)
{
AudioPlayer::playSound(dingSound);
if(button->name == "Duplicate")
{
std::vector<Instance*> newinst;
for(size_t i = 0; i < g_selectedInstances.size(); i++)
{
if(g_selectedInstances.at(i)->canDelete)
{
Instance* tempinst = g_selectedInstances.at(i);
Instance* clonedInstance = g_selectedInstances.at(i)->clone();
newinst.push_back(tempinst);
}
/*tempinst->setPosition(Vector3(tempPos.x, tempPos.y + tempSize.y, tempPos.z));
g_usableApp->cameraController.centerCamera(g_selectedInstances.at(0));*/
}
g_selectedInstances = newinst;
if(g_selectedInstances.size() > 0)
g_usableApp->_propWindow->UpdateSelected(newinst.at(0));
}
else if(button->name == "Group")
{
GroupInstance * inst = new GroupInstance();
for(size_t i = 0; i < g_selectedInstances.size(); i++)
{
if(g_selectedInstances.at(i)->canDelete)
{
g_selectedInstances.at(i)->setParent(inst);
if(PartInstance* part = dynamic_cast<PartInstance*>(g_selectedInstances.at(i)))
{
inst->primaryPart = part;
}
}
/*tempinst->setPosition(Vector3(tempPos.x, tempPos.y + tempSize.y, tempPos.z));
g_usableApp->cameraController.centerCamera(g_selectedInstances.at(0));*/
}
inst->setParent(g_dataModel->getWorkspace());
g_selectedInstances.clear();
g_selectedInstances.push_back(inst);
if(g_selectedInstances.size() > 0)
g_usableApp->_propWindow->UpdateSelected(g_selectedInstances.at(0));
}
else if(button->name == "UnGroup")
{
std::vector<Instance*> newinst;
for(size_t i = 0; i < g_selectedInstances.size(); i++)
{
if(g_selectedInstances.at(i)->canDelete)
{
if(GroupInstance* model = dynamic_cast<GroupInstance*>(g_selectedInstances.at(i)))
{
newinst = model->unGroup();
model->setParent(NULL);
delete model;
model = NULL;
}
}
/*tempinst->setPosition(Vector3(tempPos.x, tempPos.y + tempSize.y, tempPos.z));
g_usableApp->cameraController.centerCamera(g_selectedInstances.at(0));*/
}
g_selectedInstances.clear();
g_selectedInstances = newinst;
if(g_selectedInstances.size() > 0)
g_usableApp->_propWindow->UpdateSelected(newinst.at(0));
}
}
}

33
src/source/Globals.cpp Normal file
View File

@@ -0,0 +1,33 @@
#include "Globals.h"
#include "Application.h"
int const Globals::gen = 0;
int const Globals::major = 0;
int const Globals::minor = 4;
int const Globals::patch = 2;
int Globals::surfaceId = 2;
bool Globals::showMouse = true;
bool Globals::useMousePoint = false;
std::vector<Instance*> postRenderStack = std::vector<Instance*>();
std::vector<Instance*> g_selectedInstances = std::vector<Instance*>();
DataModelInstance* g_dataModel = NULL;
bool running = false;
G3D::TextureRef Globals::surface;
POINT Globals::mousepoint;
GFontRef g_fntdominant = NULL;
GFontRef g_fntlighttrek = NULL;
Globals::Globals(void){}
Globals::~Globals(void){}
std::string cameraSound="";
std::string clickSound="";
std::string dingSound="";
Application *g_usableApp = NULL;
COLORREF g_acrCustClr[16] = {RGB(255,255,255),RGB(255,255,255),RGB(255,255,255),RGB(255,255,255),RGB(255,255,255),RGB(255,255,255),RGB(255,255,255),RGB(255,255,255),RGB(255,255,255),RGB(255,255,255),RGB(255,255,255),RGB(255,255,255),RGB(255,255,255),RGB(255,255,255),RGB(255,255,255),RGB(255,255,255)};

View File

@@ -0,0 +1,77 @@
#include "GroupInstance.h"
GroupInstance::GroupInstance(void)
{
PVInstance::PVInstance();
name = "Model";
className = "GroupInstance";
listicon = 12;
primaryPart = NULL;
}
GroupInstance::GroupInstance(const GroupInstance &oinst)
{
PVInstance::PVInstance(oinst);
name = "Model";
className = "GroupInstance";
listicon = 12;
primaryPart = NULL;
}
GroupInstance::~GroupInstance(void)
{
}
std::vector<PROPGRIDITEM> GroupInstance::getProperties()
{
std::vector<PROPGRIDITEM> properties = PVInstance::getProperties();
return properties;
}
void GroupInstance::PropUpdate(LPPROPGRIDITEM &pItem)
{
PVInstance::PropUpdate(pItem);
}
std::vector<Instance *> GroupInstance::unGroup()
{
std::vector<Instance *> child;
while(children.size() > 0)
{
child.push_back(children[0]);
children[0]->setParent(parent);
}
return child;
}
void GroupInstance::render(RenderDevice * rd)
{
Instance::render(rd);
if(primaryPart != NULL && controllerFlagShown && getControllerColor(controller) != Color3::gray())
{
rd->disableLighting();
Vector3 vec = Vector3(0,0,0);
Vector3 up = Vector3(0,8,0);
rd->setColor(getControllerColor(controller));
rd->setObjectToWorldMatrix(primaryPart->cFrame);
rd->beforePrimitive();
glBegin(GL_LINES);
glVertex3f(vec.x, vec.y, vec.z);
glVertex3f(up.x, up.y, up.z);
glEnd();
glBegin( GL_TRIANGLES );
glVertex3f(up.x, up.y-2, up.z);
glVertex3f(up.x, up.y-1, up.z-2);
glVertex3f(up.x, up.y, up.z);
glVertex3f(up.x, up.y, up.z);
glVertex3f(up.x, up.y-1, up.z-2);
glVertex3f(up.x, up.y-2, up.z);
glEnd();
rd->afterPrimitive();
rd->setColor(Color3::white());
rd->enableLighting();
}
}

View File

@@ -0,0 +1,536 @@
#include <iomanip>
#include <sstream>
#include "G3DAll.h"
#include "BaseButtonInstance.h"
#include "TextButtonInstance.h"
#include "ImageButtonInstance.h"
#include "ToggleImageButtonInstance.h"
#include "GuiRootInstance.h"
#include "Globals.h"
#include "StringFunctions.h"
#include "GUDButtonListener.h"
#include "ModeSelectionListener.h"
#include "MenuButtonListener.h"
#include "RotateButtonListener.h"
#include "CameraButtonListener.h"
#include "DeleteListener.h"
#include "ToolbarListener.h"
#include "ImageButtonInstance.h"
ImageButtonInstance* GuiRootInstance::makeImageButton(G3D::TextureRef newImage = NULL, G3D::TextureRef overImage = NULL, G3D::TextureRef downImage = NULL, G3D::TextureRef disableImage = NULL)
{
ImageButtonInstance* part = new ImageButtonInstance(newImage,overImage, downImage, disableImage);
// instances.push_back(part);
// instances_2D.push_back(part);
return part;
}
TextButtonInstance* GuiRootInstance::makeTextButton()
{
TextButtonInstance* part = new TextButtonInstance();
return part;
}
ToolbarListener * toolbar;
GuiRootInstance::GuiRootInstance() : _message(""), _messageTime(0)
{
toolbar = new ToolbarListener();
toolbar->doDelete = false;
g_fntdominant = GFont::fromFile(GetFileInPath("/content/font/dominant.fnt"));
g_fntlighttrek = GFont::fromFile(GetFileInPath("/content/font/lighttrek.fnt"));
//Bottom Left
TextButtonInstance* button = makeTextButton();
button->boxBegin = Vector2(0, -24);
button->boxEnd = Vector2(80, 0);
button->floatBottom = true;
button->setParent(this);
button->font = g_fntlighttrek;
button->textColor = Color3(0,255,255);
button->textOutlineColor = Color4::clear();
button->title = "Hopper";
button->fontLocationRelativeTo = Vector2(10, 3);
button->setAllColorsSame();
button->boxOutlineColorOvr = Color3(0,255,255);
button->boxColorDn = Color4(button->boxColor.r,button->boxColor.g,button->boxColor.b, 0.2F);
button->setButtonListener(toolbar);
toolbar->addButtonRef(button);
button = makeTextButton();
button->boxBegin = Vector2(0, -48);
button->boxEnd = Vector2(80, -24);
button->floatBottom = true;
button->setParent(this);
button->font = g_fntlighttrek;
button->textColor = Color3(0,255,255);
button->textOutlineColor = Color4::clear();
button->title = "Controller";
button->fontLocationRelativeTo = Vector2(10, 3);
button->setAllColorsSame();
button->boxOutlineColorOvr = Color3(0,255,255);
button->boxColorDn = Color4(button->boxColor.r,button->boxColor.g,button->boxColor.b, 0.2F);
button->setButtonListener(toolbar);
toolbar->addButtonRef(button);
button = makeTextButton();
button->boxBegin = Vector2(0, -72);
button->boxEnd = Vector2(80, -48);
button->floatBottom = true;
button->setParent(this);
button->font = g_fntlighttrek;
button->textColor = Color3(0,255,255);
button->textOutlineColor = Color4::clear();
button->title = "Color";
button->fontLocationRelativeTo = Vector2(10, 3);
button->setAllColorsSame();
button->boxOutlineColorOvr = Color3(0,255,255);
button->boxColorDn = Color4(button->boxColor.r,button->boxColor.g,button->boxColor.b, 0.2F);
button->setButtonListener(toolbar);
toolbar->addButtonRef(button);
button = makeTextButton();
button->boxBegin = Vector2(0, -96);
button->boxEnd = Vector2(80, -72);
button->floatBottom = true;
button->setParent(this);
button->font = g_fntlighttrek;
button->textColor = Color3(0,255,255);
button->textOutlineColor = Color4::clear();
button->title = "Surface";
button->fontLocationRelativeTo = Vector2(10, 3);
button->setAllColorsSame();
button->boxOutlineColorOvr = Color3(0,255,255);
button->boxColorDn = Color4(button->boxColor.r,button->boxColor.g,button->boxColor.b, 0.2F);
button->setButtonListener(toolbar);
toolbar->addButtonRef(button);
button = makeTextButton();
button->boxBegin = Vector2(0, -120);
button->boxEnd = Vector2(80, -96);
button->floatBottom = true;
button->setParent(this);
button->font = g_fntlighttrek;
button->textColor = Color3(0,255,255);
button->title = "Model";
button->selected = true;
button->fontLocationRelativeTo = Vector2(10, 3);
button->setAllColorsSame();
button->boxOutlineColorOvr = Color3(0,255,255);
button->boxColorDn = Color4(button->boxColor.r,button->boxColor.g,button->boxColor.b, 0.2F);
button->setButtonListener(toolbar);
toolbar->addButtonRef(button);
//Top bar
button = makeTextButton();
button->boxBegin = Vector2(0, 0);
button->boxEnd = Vector2(125, 25);
button->setParent(this);
button->font = g_fntlighttrek;
button->textColor = Color3::white();
button->boxColor = Color4::clear();
button->textOutlineColor = Color4(0.5F,0.5F,0.5F,0.5F);
button->title = "File";
button->textSize = 16;
button->fontLocationRelativeTo = Vector2(10, 0);
button->setAllColorsSame();
button->boxColorOvr = Color4(0.6F,0.6F,0.6F,0.4F);
button = makeTextButton();
button->boxBegin = Vector2(125, 0);
button->boxEnd = Vector2(250, 25);
button->setParent(this);
button->font = g_fntlighttrek;
button->textColor = Color3::white();
button->boxColor = Color4::clear();
button->textOutlineColor = Color4(0.5F,0.5F,0.5F,0.5F);
button->title = "Edit";
button->textSize = 16;
button->fontLocationRelativeTo = Vector2(10, 0);
button->setAllColorsSame();
button->boxColorOvr = Color4(0.6F,0.6F,0.6F,0.4F);
button = makeTextButton();
button->boxBegin = Vector2(250, 0);
button->boxEnd = Vector2(375, 25);
button->setParent(this);
button->font = g_fntlighttrek;
button->textColor = Color3::white();
button->boxColor = Color4::clear();
button->textOutlineColor = Color4(0.5F,0.5F,0.5F,0.5F);
button->title = "View";
button->textSize = 16;
button->fontLocationRelativeTo = Vector2(10, 0);
button->setAllColorsSame();
button->boxColorOvr = Color4(0.6F,0.6F,0.6F,0.4F);
button = makeTextButton();
button->boxBegin = Vector2(375, 0);
button->boxEnd = Vector2(500, 25);
button->setParent(this);
button->font = g_fntlighttrek;
button->textColor = Color3::white();
button->boxColor = Color4::clear();
button->textOutlineColor = Color4(0.5F,0.5F,0.5F,0.5F);
button->title = "Insert";
button->textSize = 16;
button->fontLocationRelativeTo = Vector2(10, 0);
button->setAllColorsSame();
button->boxColorOvr = Color4(0.6F,0.6F,0.6F,0.4F);
button = makeTextButton();
button->boxBegin = Vector2(500, 0);
button->boxEnd = Vector2(625, 25);
button->setParent(this);
button->font = g_fntlighttrek;
button->textColor = Color3::white();
button->boxColor = Color4::clear();
button->textOutlineColor = Color4(0.5F,0.5F,0.5F,0.5F);
button->title = "Format";
button->textSize = 16;
button->fontLocationRelativeTo = Vector2(10, 0);
button->setAllColorsSame();
button->boxColorOvr = Color4(0.6F,0.6F,0.6F,0.4F);
//Menu
button = makeTextButton();
button->boxBegin = Vector2(0,215);
button->boxEnd = Vector2(80,235);
button->textOutlineColor = Color4(0.5F,0.5F,0.5F,0.5F);
button->textColor = Color3::white();
button->boxColor = Color4::clear();
button->textSize = 12;
button->title = "Group";
button->name = "Group";
button->setAllColorsSame();
button->textColorDis = Color3(0.8F,0.8F,0.8F);
button->font = g_fntlighttrek;
button->fontLocationRelativeTo = Vector2(10, 0);
button->setParent(this);
button->setButtonListener(new GUDButtonListener());
button = makeTextButton();
button->boxBegin = Vector2(0,240);
button->boxEnd = Vector2(80,260);
button->textOutlineColor = Color4(0.5F,0.5F,0.5F,0.5F);
button->textColor = Color3::white();
button->boxColor = Color4::clear();
button->textSize = 12;
button->title = "UnGroup";
button->name = "UnGroup";
button->setAllColorsSame();
button->textColorDis = Color3(0.8F,0.8F,0.8F);
button->font = g_fntlighttrek;
button->fontLocationRelativeTo = Vector2(10, 0);
button->setParent(this);
button->setButtonListener(new GUDButtonListener());
button = makeTextButton();
button->boxBegin = Vector2(0,265);
button->boxEnd = Vector2(80,285);
button->textOutlineColor = Color4(0.5F,0.5F,0.5F,0.5F);
button->textColor = Color3::white();
button->boxColor = Color4::clear();
button->textSize = 12;
button->title = "Duplicate";
button->setAllColorsSame();
button->textColorDis = Color3(0.8F,0.8F,0.8F);
button->font = g_fntlighttrek;
button->fontLocationRelativeTo = Vector2(10, 0);
button->setParent(this);
button->name = "Duplicate";
button->setButtonListener(new GUDButtonListener());
ImageButtonInstance* instance = new ToggleImageButtonInstance(
Texture::fromFile(GetFileInPath("/content/images/Run.png")),
Texture::fromFile(GetFileInPath("/content/images/Run_ovr.png")),
Texture::fromFile(GetFileInPath("/content/images/Run_dn.png")),
NULL,
Texture::fromFile(GetFileInPath("/content/images/Stop.png")),
Texture::fromFile(GetFileInPath("/content/images/Stop_ovr.png")),
Texture::fromFile(GetFileInPath("/content/images/Stop_dn.png"))
);
instance->setButtonListener(new MenuButtonListener());
instance->name = "go";
instance->size = Vector2(65,65);
instance->position = Vector2(6.5, 25);
instance->setParent(this);
instance = makeImageButton(
Texture::fromFile(GetFileInPath("/content/images/ArrowTool.png")),
Texture::fromFile(GetFileInPath("/content/images/ArrowTool_ovr.png")),
Texture::fromFile(GetFileInPath("/content/images/ArrowTool_dn.png")),
Texture::fromFile(GetFileInPath("/content/images/ArrowTool_ds.png")));
instance->size = Vector2(50,50);
instance->position = Vector2(15, 90);
instance->setParent(this);
instance->name = "Cursor";
instance->setButtonListener(new ModeSelectionListener());
instance = makeImageButton(Texture::fromFile(GetFileInPath("/content/images/ScaleTool.png")),Texture::fromFile(GetFileInPath("/content/images/ScaleTool_ovr.png")),Texture::fromFile(GetFileInPath("/content/images/ScaleTool_dn.png")),Texture::fromFile(GetFileInPath("/content/images/ScaleTool_ds.png")));
instance->size = Vector2(40,40);
instance->position = Vector2(0, 140);
instance->setParent(this);
instance->name = "Resize";
instance->setButtonListener(new ModeSelectionListener());
instance = makeImageButton(
Texture::fromFile(GetFileInPath("/content/images/MoveTool.png")),
Texture::fromFile(GetFileInPath("/content/images/MoveTool_ovr.png")),
Texture::fromFile(GetFileInPath("/content/images/MoveTool_dn.png")),
Texture::fromFile(GetFileInPath("/content/images/MoveTool_ds.png")));
instance->size = Vector2(40,40);
instance->position = Vector2(40, 140);
instance->setParent(this);
instance->name = "Arrows";
instance->setButtonListener(new ModeSelectionListener());
instance = makeImageButton(
Texture::fromFile(GetFileInPath("/content/images/SelectionRotate.png")),
Texture::fromFile(GetFileInPath("/content/images/SelectionRotate_ovr.png")),
NULL,
Texture::fromFile(GetFileInPath("/content/images/SelectionRotate_ds.png")));
instance->size = Vector2(30,30);
instance->position = Vector2(10, 175);
instance->setParent(this);
instance->name = "Rotate";
instance->setButtonListener(new RotateButtonListener());
instance = makeImageButton(
Texture::fromFile(GetFileInPath("/content/images/SelectionTilt.png")),
Texture::fromFile(GetFileInPath("/content/images/SelectionTilt_ovr.png")),
NULL,
Texture::fromFile(GetFileInPath("/content/images/SelectionTilt_ds.png")));
instance->size = Vector2(30,30);
instance->position = Vector2(40, 175);
instance->setParent(this);
instance->name = "Tilt";
instance->setButtonListener(new RotateButtonListener());
instance = makeImageButton(
Texture::fromFile(GetFileInPath("/content/images/Delete.png")),
Texture::fromFile(GetFileInPath("/content/images/Delete_ovr.png")),
Texture::fromFile(GetFileInPath("/content/images/Delete_dn.png")),
Texture::fromFile(GetFileInPath("/content/images/Delete_ds.png")));
instance->size = Vector2(40,46);
instance->position = Vector2(20, 284);
instance->setParent(this);
instance->name = "Delete";
instance->setButtonListener(new DeleteListener());
instance = makeImageButton(
Texture::fromFile(GetFileInPath("/content/images/CameraZoomIn.png")),
Texture::fromFile(GetFileInPath("/content/images/CameraZoomIn_ovr.png")),
Texture::fromFile(GetFileInPath("/content/images/CameraZoomIn_dn.png")));
instance->size = Vector2(34,25);
instance->floatBottom = true;
instance->floatRight = true;
instance->position = Vector2(-77, -90);
instance->setParent(this);
instance->name = "ZoomIn";
instance->setButtonListener(new CameraButtonListener());
instance = makeImageButton(
Texture::fromFile(GetFileInPath("/content/images/CameraZoomOut.png")),
Texture::fromFile(GetFileInPath("/content/images/CameraZoomOut_ovr.png")),
Texture::fromFile(GetFileInPath("/content/images/CameraZoomOut_dn.png")));
instance->size = Vector2(34,26);
instance->floatBottom = true;
instance->floatRight = true;
instance->position = Vector2(-77, -31);
instance->setParent(this);
instance->name = "ZoomOut";
instance->setButtonListener(new CameraButtonListener());
instance = makeImageButton(
Texture::fromFile(GetFileInPath("/content/images/CameraPanLeft.png")),
Texture::fromFile(GetFileInPath("/content/images/CameraPanLeft_ovr.png")),
Texture::fromFile(GetFileInPath("/content/images/CameraPanLeft_dn.png")));
instance->size = Vector2(34,34);
instance->floatBottom = true;
instance->floatRight = true;
instance->position = Vector2(-110, -50);
instance->setParent(this);
instance->name = "PanLeft";
instance->setButtonListener(new CameraButtonListener());
instance = makeImageButton(
Texture::fromFile(GetFileInPath("/content/images/CameraPanRight.png")),
Texture::fromFile(GetFileInPath("/content/images/CameraPanRight_ovr.png")),
Texture::fromFile(GetFileInPath("/content/images/CameraPanRight_dn.png")));
instance->size = Vector2(34,34);
instance->floatBottom = true;
instance->floatRight = true;
instance->position = Vector2(-45, -50);
instance->setParent(this);
instance->name = "PanRight";
instance->setButtonListener(new CameraButtonListener());
instance = makeImageButton(
Texture::fromFile(GetFileInPath("/content/images/CameraCenter.png")),
Texture::fromFile(GetFileInPath("/content/images/CameraCenter_ovr.png")),
Texture::fromFile(GetFileInPath("/content/images/CameraCenter_dn.png")));
instance->size = Vector2(34,20);
instance->floatBottom = true;
instance->floatRight = true;
instance->position = Vector2(-77, -60);
instance->setParent(this);
instance->name = "CenterCam";
instance->setButtonListener(new CameraButtonListener());
instance = makeImageButton(
Texture::fromFile(GetFileInPath("/content/images/CameraTiltUp.png")),
Texture::fromFile(GetFileInPath("/content/images/CameraTiltUp_ovr.png")),
Texture::fromFile(GetFileInPath("/content/images/CameraTiltUp_dn.png")));
instance->size = Vector2(24,24);
instance->floatBottom = true;
instance->floatRight = true;
instance->position = Vector2(-105, -75);
instance->setParent(this);
instance->name = "TiltUp";
instance->setButtonListener(new CameraButtonListener());
instance = makeImageButton(
Texture::fromFile(GetFileInPath("/content/images/CameraTiltDown.png")),
Texture::fromFile(GetFileInPath("/content/images/CameraTiltDown_ovr.png")),
Texture::fromFile(GetFileInPath("/content/images/CameraTiltDown_dn.png")));
instance->size = Vector2(24,24);
instance->floatBottom = true;
instance->floatRight = true;
instance->position = Vector2(-40, -75);
instance->setParent(this);
instance->name = "TiltDown";
instance->setButtonListener(new CameraButtonListener());
}
void GuiRootInstance::drawButtons(RenderDevice* rd)
{
rd->pushState();
rd->beforePrimitive();
//this->render(rd);
rd->afterPrimitive();
rd->popState();
}
void GuiRootInstance::setDebugMessage(std::string msg, G3D::RealTime msgTime)
{
_messageTime = msgTime;
_message = msg;
}
//void GuiRootInstance::render(G3D::RenderDevice* renderDevice) {}
void GuiRootInstance::renderGUI(G3D::RenderDevice* rd, double fps)
{
//TODO--Move these to their own instance
std::stringstream stream;
stream << std::fixed << std::setprecision(1) << g_dataModel->getLevel()->timer;
g_fntdominant->draw2D(rd, "Timer: " + stream.str(), Vector2(rd->getWidth() - 120, 25), 20, Color3::fromARGB(0x81C518), Color3::black());
g_fntdominant->draw2D(rd, "Score: " + Convert(g_dataModel->getLevel()->score), Vector2(rd->getWidth() - 120, 50), 20, Color3::fromARGB(0x81C518), Color3::black());
//FPS
#ifdef _DEBUG
stream.str("");
stream.clear();
stream << std::fixed << std::setprecision(3) << fps;
g_fntdominant->draw2D(rd, "FPS: " + stream.str(), Vector2(120, 25), 10, Color3::fromARGB(0xFFFF00), Color3::black());
#endif
//GUI Boxes
Draw::box(G3D::Box(Vector3(0,25,0),Vector3(80,355,0)),rd,Color4(0.6F,0.6F,0.6F,0.4F), Color4(0,0,0,0));
Draw::box(G3D::Box(Vector3(rd->getWidth() - 120,rd->getHeight() - 120,0),Vector3(rd->getWidth(),rd->getHeight(),0)),rd,Color4(0.6F,0.6F,0.6F,0.4F), Color4(0,0,0,0));
//Camera menu title
g_fntlighttrek->draw2D(rd, "CameraMenu", Vector2(rd->getWidth()-(g_fntlighttrek->get2DStringBounds("CameraMenu", 14).x+1),rd->getHeight() - 120), 14, Color3::white(), Color4(0.5F,0.5F,0.5F,0.5F));
//Tools menu
Draw::box(G3D::Box(Vector3(5, 210,0),Vector3(75, 210,0)),rd,Color4(0.6F,0.6F,0.6F,0.4F), Color4(0.6F,0.6F,0.6F,0.4F));
g_fntlighttrek->draw2D(rd,"MENU", Vector2(10,332), 14, Color3::white(), Color4(0.5F,0.5F,0.5F,0.5F));
//drawButtons(rd);
if(System::time() - 3 < _messageTime)
{
g_fntdominant->draw2D(rd, _message, Vector2((rd->getWidth()/2)-(g_fntdominant->get2DStringBounds(_message, 20).x/2),(rd->getHeight()/2)-(g_fntdominant->get2DStringBounds(_message, 20).y/2)), 20, Color3::yellow(), Color3::black());
}
g_dataModel->drawMessage(rd);
render(rd);
}
bool GuiRootInstance::mouseInGUI(G3D::RenderDevice* renderDevice,int x,int y)
{
std::vector<Instance*> instances_2D = g_dataModel->getGuiRoot()->getAllChildren();
for(size_t i = 0; i < instances_2D.size(); i++)
{
if(BaseButtonInstance* button = dynamic_cast<BaseButtonInstance*>(instances_2D.at(i)))
{
if(button->mouseInButton(x,y, renderDevice))
{
return true;
}
}
}
return false;
}
void GuiRootInstance::update()
{
Instance * obj6 = this->findFirstChild("Delete");
Instance * obj = this->findFirstChild("Duplicate");
Instance * obj2 = this->findFirstChild("Group");
Instance * obj3 = this->findFirstChild("UnGroup");
Instance * obj4 = this->findFirstChild("Rotate");
Instance * obj5 = this->findFirstChild("Tilt");
if(obj != NULL && obj2 != NULL && obj3 != NULL && obj4 !=NULL && obj5 != NULL && obj6 != NULL)
{
BaseButtonInstance* button = (BaseButtonInstance*)obj;
BaseButtonInstance* button2 = (BaseButtonInstance*)obj2;
BaseButtonInstance* button3 = (BaseButtonInstance*)obj3;
BaseButtonInstance* button4 = (BaseButtonInstance*)obj4;
BaseButtonInstance* button5 = (BaseButtonInstance*)obj5;
BaseButtonInstance* button6 = (BaseButtonInstance*)obj6;
button->disabled = true;
button2->disabled = true;
button3->disabled = true;
button4->disabled = true;
button5->disabled = true;
button6->disabled = true;
for(size_t i = 0; i < g_selectedInstances.size(); i++)
if(g_selectedInstances.at(i)->canDelete)
{
button->disabled = false;
button2->disabled = false;
button3->disabled = false;
button4->disabled = false;
button5->disabled = false;
button6->disabled = false;
break;
}
}
}
GuiRootInstance::~GuiRootInstance()
{
delete toolbar;
}
void GuiRootInstance::onMouseLeftUp(G3D::RenderDevice* renderDevice, int x,int y)
{
std::vector<Instance*> instances_2D = this->getAllChildren();
for(size_t i = 0; i < instances_2D.size(); i++)
{
if(BaseButtonInstance* button = dynamic_cast<BaseButtonInstance*>(instances_2D[i]))
{
if(button->mouseInButton(x, y, renderDevice))
{
button->onMouseClick();
}
}
}
}

130
src/source/IEBrowser.cpp Normal file
View File

@@ -0,0 +1,130 @@
#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN
#endif
#include <windows.h>
#include <Commdlg.h>
#include "IEBrowser.h"
#include "Globals.h"
#pragma once
#include "ax.h"
HRESULT IEBrowser::doExternal(std::wstring funcName,
DISPID dispIdMember,
REFIID riid,
LCID lcid,
WORD wFlags,
DISPPARAMS FAR* pDispParams,
VARIANT FAR* pVarResult,
EXCEPINFO FAR* pExcepInfo,
unsigned int FAR* puArgErr)
{
if (funcName==L"Insert")
{
MessageBoxW(NULL, pDispParams->rgvarg->bstrVal,L"Add insert here...",MB_OK);
return S_OK;
}
else if (funcName==L"ToggleHopperBin")
{
pVarResult->vt = VT_INT;
pVarResult->intVal = 5;
//MessageBox(NULL, "BOOP", "Boopity boop",MB_OK);
}
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;
for(size_t i = 0; i < g_selectedInstances.size(); i++)
{
if(PVInstance* part = dynamic_cast<PVInstance*>(g_selectedInstances.at(i)))
{
ding = true;
part->controller = cont;
}
}
if(ding)
AudioPlayer::playSound(dingSound);
return S_OK;
}
else if(funcName==L"SetColor")
{
return S_OK;
}
else if(funcName==L"ChooseColor")
{
CHOOSECOLOR color;
DWORD rgbCurrent; //Will be dynamic later
ZeroMemory(&color, sizeof(CHOOSECOLOR));
color.lStructSize = sizeof(color);
color.hwndOwner = hwnd;
color.lpCustColors = (LPDWORD) g_acrCustClr;
color.rgbResult = rgbCurrent;
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;
}
else
{
DWORD error = CommDlgExtendedError();
std::cout << error;
pVarResult->vt = VT_NULL;
}
return S_OK;
}
return E_NOTIMPL;
}
IEBrowser::IEBrowser(HWND attachHWnd) {
MSG messages;
while (PeekMessage (&messages, NULL, 0, 0,PM_REMOVE))
{
if (IsDialogMessage(hwnd, &messages) == 0)
{
TranslateMessage(&messages);
DispatchMessage(&messages);
}
}
hwnd = attachHWnd;
webBrowser = 0;
SendMessage(hwnd,AX_INPLACE,1,0);
SendMessage(hwnd,AX_QUERYINTERFACE,(WPARAM)&IID_IWebBrowser2,(LPARAM)&webBrowser);
}
IEBrowser::~IEBrowser(void) {
if (webBrowser)
{
webBrowser->Release();
}
}
bool IEBrowser::navigateSyncURL(wchar_t* url)
{
//MSG messages;
if (webBrowser)
{
webBrowser->Navigate(url,0,0,0,0);
}
else
{
MessageBox(NULL,"Cannot read IWebBrowser2...",(g_PlaceholderName+" Crash").c_str(),MB_OK);
}
return false;
}

View File

@@ -0,0 +1,39 @@
#include "IEDispatcher.h"
IEDispatcher::IEDispatcher(void)
{
}
IEDispatcher::~IEDispatcher(void)
{
}
HRESULT STDMETHODCALLTYPE IEDispatcher::QueryInterface(const IID &riid, void **ppvObject)
{
return NULL;
}
ULONG STDMETHODCALLTYPE IEDispatcher::AddRef()
{
return NULL;
}
ULONG STDMETHODCALLTYPE IEDispatcher::Release()
{
return NULL;
}
HRESULT STDMETHODCALLTYPE IEDispatcher::GetTypeInfoCount(UINT *pctinfo)
{
return NULL;
}
HRESULT STDMETHODCALLTYPE IEDispatcher::GetTypeInfo(UINT, LCID, ITypeInfo **)
{
return NULL;
}
HRESULT STDMETHODCALLTYPE IEDispatcher::GetIDsOfNames(const IID &, LPOLESTR *, UINT, LCID, DISPID *)
{
return NULL;
}
HRESULT STDMETHODCALLTYPE IEDispatcher::Invoke(DISPID, const IID &, LCID, WORD, DISPPARAMS *, VARIANT *, EXCEPINFO *, UINT *)
{
return NULL;
}

View File

@@ -0,0 +1,133 @@
#include "ImageButtonInstance.h"
ImageButtonInstance::ImageButtonInstance(G3D::TextureRef newImage, G3D::TextureRef overImage = NULL, G3D::TextureRef downImage = NULL, G3D::TextureRef disableImage = NULL)
{
BaseButtonInstance::BaseButtonInstance();
image = newImage;
openGLID = image->getOpenGLID();
image_ovr = overImage;
if(!image_ovr.isNull())
openGLID_ovr = image_ovr->getOpenGLID();
image_dn = downImage;
if(!image_dn.isNull())
openGLID_dn = image_dn->getOpenGLID();
image_ds = disableImage;
if(!image_ds.isNull())
openGLID_ds = image_ds->getOpenGLID();
Vector2 size = Vector2(0,0);
Vector2 position = Vector2(0,0);
floatCenter = false;
floatBottom = false;
floatRight = false;
disabled = false;
className = "ImageButton";
}
ImageButtonInstance::~ImageButtonInstance(void)
{
//Delete everything on destruction
image.~ReferenceCountedPointer();
delete image.getPointer();
image_ovr.~ReferenceCountedPointer();
delete image_ovr.getPointer();
image_ds.~ReferenceCountedPointer();
delete image_ds.getPointer();
image_dn.~ReferenceCountedPointer();
delete image_dn.getPointer();
image = NULL;
image_ovr = NULL;
image_ds = NULL;
image_dn = NULL;
delete listener;
listener = NULL;
selected = false;
}
bool ImageButtonInstance::mouseInButton(float mousex, float mousey, RenderDevice* rd)
{
Vector2 positionRelative = position;
if(floatRight && floatBottom)
{
positionRelative = Vector2(rd->getWidth() + position.x, rd->getHeight() + position.y);
}
else if(floatBottom)
{
positionRelative = Vector2(position.x, rd->getHeight() + position.y);
}
else if(floatRight)
{
positionRelative = Vector2(rd->getWidth() + position.x, position.y);
}
if(mousex >= positionRelative.x && mousey >= positionRelative.y)
{
if(mousex < positionRelative.x + size.x && mousey < positionRelative.y + size.y)
{
return true;
}
}
return false;
}
void ImageButtonInstance::drawObj(RenderDevice* rd, Vector2 mousePos, bool mouseDown)
{
bool drawDisabledBox = false;
Vector2 positionRelative = position;
if(floatRight && floatBottom)
{
positionRelative = Vector2(rd->getWidth() + position.x, rd->getHeight() + position.y);
}
else if(floatBottom)
{
positionRelative = Vector2(position.x, rd->getHeight() + position.y);
}
else if(floatRight)
{
positionRelative = Vector2(rd->getWidth() + position.x, position.y);
}
int renderimage = openGLID;
if(selected == true && !image_dn.isNull() && !disabled)
{
renderimage = openGLID_dn;
}
else if(disabled)
{
if(!image_ds.isNull())
renderimage = openGLID_ds;
else
drawDisabledBox = true;
}
else if(mouseInArea(positionRelative.x, positionRelative.y, positionRelative.x + size.x, positionRelative.y + size.y, mousePos.x, mousePos.y))
{
if(mouseDown && !image_dn.isNull())
{
renderimage = openGLID_dn;
}
else if(!image_ovr.isNull())
{
renderimage = openGLID_ovr;
}
}
glEnable( GL_TEXTURE_2D );
glEnable(GL_BLEND);// you enable blending function
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glBindTexture( GL_TEXTURE_2D, renderimage);
glBegin( GL_QUADS );
glTexCoord2d(0.0,0.0);
glVertex2f( positionRelative.x, positionRelative.y );
glTexCoord2d( 1.0,0.0 );
glVertex2f( positionRelative.x + size.x, positionRelative.y );
glTexCoord2d( 1.0,1.0 );
glVertex2f( positionRelative.x + size.x, positionRelative.y + size.y );
glTexCoord2d( 0.0,1.0 );
glVertex2f( positionRelative.x, positionRelative.y + size.y );
glEnd();
glDisable( GL_TEXTURE_2D );
if(drawDisabledBox)
{
Draw::box(Box(Vector3(positionRelative.x, positionRelative.y, 0), Vector3(positionRelative.x+size.x, positionRelative.y+size.y, 0)), rd, Color4(0.7F,0.7F,0.7F,0.3F), Color4::clear());
}
}

169
src/source/Instance.cpp Normal file
View File

@@ -0,0 +1,169 @@
#define WINVER 0x0400
#include <G3DAll.h>
#include "Instance.h"
Instance::Instance(void)
{
parent = NULL;
name = "Default Game Instance";
className = "BaseInstance";
listicon = 1;
canDelete = true;
}
Instance::Instance(const Instance &oinst)
{
name = oinst.name;
className = oinst.className;
canDelete = oinst.canDelete;
listicon = oinst.listicon;
//setParent(oinst.parent);
}
void Instance::render(RenderDevice* rd)
{
for(size_t i = 0; i < children.size(); i++)
{
children[i]->render(rd);
}
}
void Instance::update()
{
}
PROPGRIDITEM Instance::createPGI(LPSTR catalog, LPSTR propName, LPSTR propDesc, LPARAM curVal, INT type, TCHAR choices[])
{
PROPGRIDITEM pItem;
PropGrid_ItemInit(pItem);
pItem.lpszCatalog=catalog;
pItem.lpszPropName=propName;
pItem.lpszPropDesc=propDesc;
pItem.lpCurValue=curVal;
pItem.iItemType=type;
if(choices != NULL)
pItem.lpszzCmbItems = choices;
return pItem;
}
void Instance::PropUpdate(LPPROPGRIDITEM &item)
{
if(strcmp(item->lpszPropName, "Name") == 0)
{
name = (LPSTR)item->lpCurValue;
}
}
std::vector<PROPGRIDITEM> Instance::getProperties()
{
std::vector<PROPGRIDITEM> properties;
properties.push_back(createPGI(
"Properties",
"Name",
"The name of this instance",
(LPARAM)name.c_str(),
PIT_EDIT
));
return properties;
}
Instance::~Instance(void)
{
for(size_t i = 0; i < children.size(); i++)
{
delete children.at(i);
}
}
void Instance::setName(std::string newName)
{
name = newName;
}
std::string Instance::getClassName()
{
return className;
}
std::vector<Instance* > Instance::getChildren()
{
return children;
}
std::vector<Instance* > Instance::getAllChildren()
{
if(!children.empty())
{
std::vector<Instance* > totalchildren = children;
for(size_t i = 0; i < children.size(); i++)
{
std::vector<Instance* > subchildren = children.at(i)->getAllChildren();
if(!subchildren.empty())
totalchildren.insert(totalchildren.end(), subchildren.begin(), subchildren.end());
}
return totalchildren;
}
return children;
}
void Instance::setParent(Instance* newParent)
{
if(parent != NULL)
{
parent->removeChild(this);
}
parent = newParent;
if(newParent != NULL)
{
newParent->addChild(this);
}
}
Instance* Instance::getParent()
{
return parent;
}
void Instance::addChild(Instance* newChild)
{
children.push_back(newChild);
}
void Instance::clearChildren()
{
children.clear();
}
void Instance::removeChild(Instance* oldChild)
{
for(size_t i = 0; i < children.size(); i++)
{
if(children.at(i) == oldChild)
{
children.erase(children.begin() + i);
}
}
}
Instance* Instance::findFirstChild(std::string name)
{
for(size_t i = 0; i < children.size(); i++)
{
if(children.at(i)->name.compare(name) == 0)
{
return children.at(i);
}
}
return NULL;
}

View File

@@ -0,0 +1,73 @@
#include "LevelInstance.h"
LevelInstance::LevelInstance(void)
{
Instance::Instance();
name = "Level";
winMessage = "You Won!";
loseMessage = "You Lost. Try Again";
timer = 60.0F;
score = 0;
canDelete = false;
}
LevelInstance::~LevelInstance(void)
{
}
char timerTxt[12];
char scoreTxt[12];
std::vector<PROPGRIDITEM> LevelInstance::getProperties()
{
std::vector<PROPGRIDITEM> properties = Instance::getProperties();
properties.push_back(createPGI("Messages",
"WinMessage",
"The message that shows when the player wins.",
(LPARAM)winMessage.c_str(),
PIT_EDIT));
properties.push_back(createPGI("Messages",
"LoseMessage",
"The message that shows when the player loses.",
(LPARAM)loseMessage.c_str(),
PIT_EDIT));
sprintf_s(timerTxt, "%g", timer);
sprintf_s(scoreTxt, "%d", score);
properties.push_back(createPGI("Gameplay",
"InitialTimerValue",
"The ammount of time in seconds the player has to complete this level.\r\n\r\nPut 0 if time is limitless.",
(LPARAM)timerTxt,
PIT_EDIT));
properties.push_back(createPGI("Gameplay",
"InitialScoreValue",
"The ammount of points the player starts with.",
(LPARAM)scoreTxt,
PIT_EDIT));
return properties;
}
void LevelInstance::PropUpdate(LPPROPGRIDITEM &pItem)
{
if(strcmp(pItem->lpszPropName, "InitialTimerValue") == 0)
{
timer = atoi((LPSTR)pItem->lpCurValue);
}
if(strcmp(pItem->lpszPropName, "InitialScoreValue") == 0)
{
score = atof((LPSTR)pItem->lpCurValue);
}
if(strcmp(pItem->lpszPropName, "LoseMessage") == 0)
{
loseMessage = (LPSTR)pItem->lpCurValue;
}
if(strcmp(pItem->lpszPropName, "WinMessage") == 0)
{
winMessage = (LPSTR)pItem->lpCurValue;
}
else
Instance::PropUpdate(pItem);
}

View File

@@ -0,0 +1,11 @@
#include "MenuButtonListener.h"
#include "toggleimagebuttoninstance.h"
#include "Globals.h"
void MenuButtonListener::onButton1MouseClick(BaseButtonInstance* button)
{
if(button->name == "go")
{
g_dataModel->toggleRun();
((ToggleImageButtonInstance*)button)->checked = g_dataModel->isRunning();
}
}

View File

@@ -0,0 +1,29 @@
#include "Globals.h"
#include "Instance.h"
#include "ModeSelectionListener.h"
#include "Application.h"
#include "ArrowTool.h"
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();
for(size_t i = 0; i < instances_2D.size(); i++)
{
if(instances_2D.at(i)->name == "Cursor" || instances_2D.at(i)->name == "Resize" || instances_2D.at(i)->name == "Arrows")
{
BaseButtonInstance* button = (BaseButtonInstance*)instances_2D.at(i);
button->selected = false;
}
}
button->selected = true;
if(button->name == "Cursor")
g_usableApp->changeTool(new ArrowTool());
else if(button->name == "Resize")
g_usableApp->setMode(RESIZE);
else if(button->name == "Arrows")
g_usableApp->setMode(ARROWS);
}

116
src/source/Mouse.cpp Normal file
View File

@@ -0,0 +1,116 @@
#include "Mouse.h"
#include "Application.h"
#include "Globals.h"
#include <algorithm>
Mouse::Mouse(){
x = y = 0;
}
Mouse::~Mouse(){}
PartInstance * selectedInstance = NULL;
Ray testRay;
float nearest=std::numeric_limits<float>::infinity();
void eprt(PartInstance * instance)
{
float time = testRay.intersectionTime(instance->getBox());
if (time != inf())
{
if (nearest>time)
{
nearest=time;
selectedInstance = instance;
//This is where dead code below was
}
}
}
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;
}
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);
}
MousePoint Mouse::getPositionAndPart(std::vector<Instance *> ignore)
{
testRay = g_usableApp->cameraController.getCamera()->worldRay(x, y, g_usableApp->getRenderDevice()->getViewport());
PartInstance * currPart = NULL;
Vector3 pos = testRay.closestPoint(Vector3(0,0,0));
nearest=std::numeric_limits<float>::infinity();
for(size_t i = 0; i < g_dataModel->getWorkspace()->partObjects.size(); i++)
{
PartInstance * p = g_dataModel->getWorkspace()->partObjects[i];
if(std::find(ignore.begin(), ignore.end(), p) != ignore.end())
continue;
float newdistance = testRay.intersectionTime(p->getBox()); //testRay.distance(inter);
if(G3D::isFinite(newdistance))
{
if(nearest > abs(newdistance))
{
nearest = newdistance;
pos = testRay.origin+(testRay.direction*nearest);
currPart = p;
}
}
}
return MousePoint(pos, currPart);
}
Vector3 Mouse::getPosition(std::vector<Instance *> ignore)
{
return getPositionAndPart(ignore).position;
}
bool Mouse::isMouseOnScreen()
{
//hm
return true;
}
bool Mouse::isMouseDown()
{
return mouseDown;
}
void Mouse::setMouseDown(bool bval)
{
mouseDown = bval;
}
//bool found = false;
/*for(size_t i = 0; i < g_selectedInstances.size(); i++)
{
if(g_selectedInstances.at(i) == test)
{
found = true;
//ShowWindow(_propWindow->_hwndProp, SW_SHOW);
//SetActiveWindow(_propWindow->_hwndProp);
//SetForegroundWindow(_propWindow->_hwndProp);
break;
}
}
if(!found)
{
selectedInstance = test;
//if(!GetHoldKeyState(VK_RCONTROL) && !GetHoldKeyState(VK_LCONTROL))
//g_selectedInstances.clear();
//if(std::find(g_selectedInstances.begin(), g_selectedInstances.end(),test)==g_selectedInstances.end())
//g_selectedInstances.push_back(test);
}
//selectInstance(test, _propWindow);
//_message = "Dragging = true.";
//_messageTime = System::time();
//_dragging = true;*/

107
src/source/PVInstance.cpp Normal file
View File

@@ -0,0 +1,107 @@
#include "PVInstance.h"
PVInstance::PVInstance(void)
{
Instance::Instance();
nameShown = false;
controllerFlagShown = true;
className = "PVInstance";
listicon = 0;
controller = (Enum::Controller::Value)0;
}
PVInstance::PVInstance(const PVInstance &oinst)
{
Instance::Instance(oinst);
}
PVInstance::~PVInstance(void)
{
}
void PVInstance::postRender(RenderDevice* rd)
{
}
static TCHAR* enumStr(int controller)
{
switch(controller)
{
case Enum::Controller::None:
return "None";
case Enum::Controller::KeyboardLeft:
return "KeyboardLeft";
case Enum::Controller::KeyboardRight:
return "KeyboardRight";
case Enum::Controller::Joypad1:
return "Joypad1";
case Enum::Controller::Joypad2:
return "Joypad2";
case Enum::Controller::Chase:
return "Joypad1";
case Enum::Controller::Flee:
return "Joypad2";
}
}
static Enum::Controller::Value strEnum(TCHAR * tval)
{
if(strcmp(tval, "KeyboardLeft") == 0)
return Enum::Controller::KeyboardLeft;
if(strcmp(tval, "KeyboardRight") == 0)
return Enum::Controller::KeyboardRight;
if(strcmp(tval, "Joypad1") == 0)
return Enum::Controller::Joypad1;
if(strcmp(tval, "Joypad2") == 0)
return Enum::Controller::Joypad2;
if(strcmp(tval, "Chase") == 0)
return Enum::Controller::Chase;
if(strcmp(tval, "Flee") == 0)
return Enum::Controller::Flee;
return Enum::Controller::None;
}
std::vector<PROPGRIDITEM> PVInstance::getProperties()
{
std::vector<PROPGRIDITEM> properties = Instance::getProperties();
properties.push_back(createPGI(
"Item",
"NameShown",
"This chooses whether the item name is shown",
nameShown,
PIT_CHECK));
properties.push_back(createPGI(
"Item",
"ControllerFlagShown",
"This chooses whether the item's ControllerFlag is shown",
controllerFlagShown,
PIT_CHECK));
properties.push_back(createPGI(
"Behaviour",
"Controller",
"This chooses what type of controller is used",
(LPARAM)enumStr(controller),
PIT_COMBO,
TEXT("None\0KeyboardRight\0KeyboardLeft\0Joypad1\0Joypad2\0Chase\0Flee")
));
return properties;
}
void PVInstance::PropUpdate(LPPROPGRIDITEM &pItem)
{
if(strcmp(pItem->lpszPropName, "NameShown") == 0)
{
nameShown = (bool)pItem->lpCurValue;
}
if(strcmp(pItem->lpszPropName, "ControllerFlagShown") == 0)
{
controllerFlagShown = (bool)pItem->lpCurValue;
}
if(strcmp(pItem->lpszPropName, "Controller") == 0)
{
controller = strEnum((TCHAR *)pItem->lpCurValue);
}
else Instance::PropUpdate(pItem);
}

1124
src/source/PartInstance.cpp Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,372 @@
#define _WINSOCKAPI_
#include <windows.h>
#include "WindowFunctions.h"
#include "resource.h"
#include "PropertyWindow.h"
#include "Globals.h"
#include "strsafe.h"
#include "Application.h"
/*typedef struct typPRGP {
Instance* instance; // Declare member types
Property &prop;
} PRGP;*/
std::vector<PROPGRIDITEM> prop;
std::vector<Instance*> children;
Instance * selectedInstance;
Instance * parent = NULL;
const int CX_BITMAP = 16;
const int CY_BITMAP = 16;
HBITMAP CreateBitmapMask(HBITMAP hbmColour, COLORREF crTransparent)
{
HDC hdcMem, hdcMem2;
HBITMAP hbmMask;
BITMAP bm;
// Create monochrome (1 bit) mask bitmap.
GetObject(hbmColour, sizeof(BITMAP), &bm);
hbmMask = CreateBitmap(bm.bmWidth, bm.bmHeight, 1, 1, NULL);
// Get some HDCs that are compatible with the display driver
hdcMem = CreateCompatibleDC(0);
hdcMem2 = CreateCompatibleDC(0);
SelectObject(hdcMem, hbmColour);
SelectObject(hdcMem2, hbmMask);
// Set the background colour of the colour image to the colour
// you want to be transparent.
SetBkColor(hdcMem, crTransparent);
// Copy the bits from the colour image to the B+W mask... everything
// with the background colour ends up white while everythig else ends up
// black...Just what we wanted.
BitBlt(hdcMem2, 0, 0, bm.bmWidth, bm.bmHeight, hdcMem, 0, 0, SRCCOPY);
// Take our new mask and use it to turn the transparent colour in our
// original colour image to black so the transparency effect will
// work right.
BitBlt(hdcMem, 0, 0, bm.bmWidth, bm.bmHeight, hdcMem2, 0, 0, SRCINVERT);
// Clean up.
DeleteDC(hdcMem);
DeleteDC(hdcMem2);
return hbmMask;
}
LRESULT CALLBACK PropProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
TCHAR achTemp[256];
PropertyWindow *propWind = (PropertyWindow *)GetWindowLongPtr(hwnd, GWL_USERDATA);
if (propWind==NULL)
{
return DefWindowProc(hwnd, msg, wParam, lParam);
}
switch(msg)
{
case WM_CLOSE:
{
ShowWindow(hwnd, SW_HIDE);
}
break;
case WM_DRAWITEM:
{
std::cout << "Drawing?" << "\r\n";
COLORREF clrBackground;
COLORREF clrForeground;
TEXTMETRIC tm;
int x;
int y;
HRESULT hr;
size_t cch;
LPDRAWITEMSTRUCT lpdis = (LPDRAWITEMSTRUCT) lParam;
if (lpdis->itemID == -1) // Empty item)
break;
// Get the food icon from the item data.
HBITMAP hbmIcon = LoadBitmap(GetModuleHandle(NULL), MAKEINTRESOURCE(IDB_BITMAP1));
HBITMAP hbmMask = CreateBitmapMask(hbmIcon, RGB(255, 0, 220));
// The colors depend on whether the item is selected.
clrForeground = SetTextColor(lpdis->hDC,
GetSysColor(lpdis->itemState & ODS_SELECTED ?
COLOR_HIGHLIGHTTEXT : COLOR_WINDOWTEXT));
clrBackground = SetBkColor(lpdis->hDC,
GetSysColor(lpdis->itemState & ODS_SELECTED ?
COLOR_HIGHLIGHT : COLOR_WINDOW));
// Calculate the vertical and horizontal position.
GetTextMetrics(lpdis->hDC, &tm);
y = (lpdis->rcItem.bottom + lpdis->rcItem.top - tm.tmHeight) / 2;
x = LOWORD(GetDialogBaseUnits()) / 4;
// Get and display the text for the list item.
int mul = 0;
SendMessage(lpdis->hwndItem, CB_GETLBTEXT, lpdis->itemID, (LPARAM) achTemp);
if(lpdis->itemID >= 0)
{
mul = children[lpdis->itemID]->listicon;
}
//else mul = children[lpdis->itemID-1]->listicon;
//mul = children[lpdis->itemID]->listicon;
hr = StringCchLength(achTemp, 256, &cch);
if (FAILED(hr))
{
// TODO: Write error handler.
}
ExtTextOut(lpdis->hDC, CX_BITMAP + 2 * x, y,
ETO_CLIPPED | ETO_OPAQUE, &lpdis->rcItem,
achTemp, (UINT)cch, NULL);
// Restore the previous colors.
SetTextColor(lpdis->hDC, clrForeground);
SetBkColor(lpdis->hDC, clrBackground);
// Draw the food icon for the item.
HDC hdc = CreateCompatibleDC(lpdis->hDC);
if (hdc == NULL)
break;
SelectObject(hdc, hbmMask);
BitBlt(lpdis->hDC, x, lpdis->rcItem.top,
CX_BITMAP, CY_BITMAP, hdc, mul*16, 0, SRCAND);
SelectObject(hdc, hbmIcon);
BitBlt(lpdis->hDC, x, lpdis->rcItem.top,
CX_BITMAP, CY_BITMAP, hdc, mul*16, 0, SRCPAINT);
DeleteDC(hdc);
// If the item has the focus, draw the focus rectangle.
if (lpdis->itemState & ODS_FOCUS)
DrawFocusRect(lpdis->hDC, &lpdis->rcItem);
}
break;
case WM_MEASUREITEM:
{
LPMEASUREITEMSTRUCT lpmis = (LPMEASUREITEMSTRUCT) lParam;
if (lpmis->itemHeight < 18)
lpmis->itemHeight = 18;
}
break;
case WM_SIZE:
{
propWind->onResize();
}
break;
case WM_COMMAND:
{
if(HIWORD(wParam) == CBN_SELCHANGE)
{
int ItemIndex = SendMessage((HWND) lParam, (UINT) CB_GETCURSEL, (WPARAM) 0, (LPARAM) 0);
CHAR ListItem[256];
SendMessage((HWND) lParam, (UINT) CB_GETLBTEXT, (WPARAM) ItemIndex, (LPARAM) ListItem);
propWind->ClearProperties();
g_usableApp->selectInstance(children.at(ItemIndex),propWind);
}
}
break;
case WM_NOTIFY:
{
switch(((LPNMHDR)lParam)->code)
{
case PGN_PROPERTYCHANGE:
{
if (IDC_PROPERTYGRID==wParam) {
LPNMHDR pnm = (LPNMHDR)lParam;
LPNMPROPGRID lpnmp = (LPNMPROPGRID)pnm;
LPPROPGRIDITEM item = PropGrid_GetItemData(pnm->hwndFrom,lpnmp->iIndex);
selectedInstance->PropUpdate(item);
//propWind->UpdateSelected(selectedInstance);
}
}
break;
}
//MessageBox(NULL,"Test","Test",0);
}
break;
default:
return DefWindowProc(hwnd, msg, wParam, lParam);
}
return 0;
}
void PropertyWindow::refreshExplorer(Instance* selectedInstance)
{
SendMessage(_explorerComboBox,CB_RESETCONTENT,0,0);
parent = NULL;
children.clear();
//g_selectedInstances.clear();
//for (unsigned int i=0;i<g_selectedInstances.size();i++) {
children.push_back(selectedInstance);
SendMessage(_explorerComboBox, CB_ADDSTRING, 0, (LPARAM)selectedInstance->name.c_str());
if(selectedInstance->getParent() != NULL)
{
std::string title = ".. (";
title += selectedInstance->getParent()->name;
title += ")";
SendMessage(_explorerComboBox,CB_ADDSTRING, 0,(LPARAM)title.c_str());
parent = selectedInstance->getParent();
children.push_back(selectedInstance->getParent());
}
//children = g_selectedInstances[i]->getChildren();
std::vector<Instance*> selectedChildren = selectedInstance->getChildren();
for(size_t z = 0; z < selectedChildren.size(); z++)
{
children.push_back(selectedChildren.at(z));
SendMessage(_explorerComboBox,CB_ADDSTRING, 0,(LPARAM)selectedChildren.at(z)->name.c_str());
}
//g_usableApp->selectInstance(selectedInstance, this);
SendMessage(_explorerComboBox,CB_SETCURSEL,0,(LPARAM)0);
//}
}
bool PropertyWindow::onCreate(int x, int y, int sx, int sy, HMODULE hThisInstance) {
if (!createWindowClass("propHWND",PropProc,hThisInstance))
return false;
_hwndProp = CreateWindowEx(
WS_EX_TOOLWINDOW,
"propHWND",
"PropertyGrid",
WS_VISIBLE | WS_POPUPWINDOW | WS_THICKFRAME | WS_CAPTION,
CW_USEDEFAULT,
CW_USEDEFAULT,
300,
660,
NULL, // parent
NULL, // menu
hThisInstance,
NULL
);
_explorerComboBox = CreateWindowEx(
NULL,
"COMBOBOX",
"Combo",
WS_VISIBLE | WS_CHILD | CBS_DROPDOWNLIST | CBS_OWNERDRAWFIXED | CBS_HASSTRINGS ,
0,
0,
0,
0,
_hwndProp, // parent
NULL, // menu
hThisInstance,
NULL
);
SendMessage(_explorerComboBox, WM_SETFONT, (WPARAM)GetStockObject(DEFAULT_GUI_FONT), 0);
_propGrid = New_PropertyGrid(_hwndProp,IDC_PROPERTYGRID);
/*PROPGRIDITEM pItem;
PropGrid_ItemInit(pItem);
pItem.lpszCatalog="Test";
pItem.lpszPropName="Offset";
pItem.lpszzCmbItems="What";
pItem.lpszPropDesc="Description";
pItem.lpCurValue=(LPARAM)"0, 0, 0";
pItem.iItemType=PIT_EDIT;
PROPGRIDITEM pItem2;
PropGrid_ItemInit(pItem2);
pItem2.lpszCatalog="Test";
pItem2.lpszPropName="s";
pItem2.lpszzCmbItems="itemlist\0itemlist2\0itemlist3";
pItem2.lpszPropDesc="";
pItem2.lpCurValue=0;
pItem2.iItemType=PIT_COMBO;
/*PROPGRIDITEM FauxExplorerItem;
PropGrid_ItemInit(FauxExplorerItem);
FauxExplorerItem.lpszCatalog="Test";
FauxExplorerItem.lpszPropName = "Editable Combo Field";
FauxExplorerItem.lpszzCmbItems = "Test1\0Test2\0Test3";
FauxExplorerItem.lpszPropDesc = "Press F4 to view drop down.";
FauxExplorerItem.iItemType = PIT_EDITCOMBO;
FauxExplorerItem.lpCurValue = 1;
PropGrid_AddItem(_propGrid, &FauxExplorerItem);*/
PropGrid_Enable(_propGrid,true);
ShowWindow(_propGrid,SW_SHOW);
// PropGrid_AddItem(_propGrid,&pItem);
// PropGrid_AddItem(_propGrid,&pItem2);
PropGrid_SetItemHeight(_propGrid,20);
PropGrid_ShowToolTips(_propGrid,TRUE);
PropGrid_ShowPropertyDescriptions(_propGrid,TRUE);
PropGrid_ExpandAllCatalogs(_propGrid);
SetWindowLongPtr(_hwndProp,GWL_USERDATA,(LONG)this);
//refreshExplorer();
_resize();
return true;
}
PropertyWindow::PropertyWindow(int x, int y, int sx, int sy, HMODULE hThisInstance) {
onCreate(x, y, sx, sy, hThisInstance);
}
void PropertyWindow::onResize()
{
_resize();
}
void PropertyWindow::_resize()
{
RECT rect;
GetClientRect(_hwndProp,&rect);
SetWindowPos(_propGrid, NULL, 0, 20, rect.right, rect.bottom-20, SWP_NOZORDER | SWP_NOACTIVATE);
SetWindowPos(_explorerComboBox, NULL, 0, 0, rect.right, 400, SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE);
}
void PropertyWindow::UpdateSelected(Instance * instance)
{
PropGrid_ResetContent(_propGrid);
prop = instance->getProperties();
if (selectedInstance != instance)
{
selectedInstance = instance;
for(size_t i = 0; i < prop.size(); i++)
{
::PROPGRIDITEM item = prop.at(i);
PropGrid_AddItem(_propGrid, &item);
//PRGP propgp;
//propgp.instance = instance;
//propgp.prop = prop.at(i);
}
PropGrid_ExpandAllCatalogs(_propGrid);
//SetWindowLongPtr(_propGrid,GWL_USERDATA,(LONG)this);
refreshExplorer(instance);
_resize();
}
}
void PropertyWindow::ClearProperties()
{
PropGrid_ResetContent(_propGrid);
}

View File

@@ -0,0 +1,21 @@
#include "BaseButtonInstance.h"
#include "RotateButtonListener.h"
#include "Globals.h"
#include "AudioPlayer.h"
void RotateButtonListener::onButton1MouseClick(BaseButtonInstance* button)
{
if(g_selectedInstances.size() > 0)
{
Instance* selectedInstance = g_selectedInstances.at(0);
AudioPlayer::playSound(clickSound);
if(PartInstance* part = dynamic_cast<PartInstance*>(selectedInstance))
{
if(button->name == "Tilt")
part->setCFrame(part->getCFrame()*Matrix3::fromEulerAnglesXYZ(0,0,toRadians(90)));
else if(button->name == "Rotate")
part->setCFrame(part->getCFrame()*Matrix3::fromEulerAnglesXYZ(0,toRadians(90),0));
}
}
}

View File

@@ -0,0 +1,34 @@
#include <G3DAll.h>
#include <sstream>
#include "ErrorFunctions.h"
#include "StringFunctions.h"
#include <windows.h>
std::string Convert (float number)
{
std::ostringstream buff;
buff<<number;
return buff.str();
}
std::string ExePath() {
char buffer[MAX_PATH];
GetModuleFileName( NULL, buffer, MAX_PATH );
std::string::size_type pos = std::string( buffer ).find_last_of( "\\/" );
return std::string( buffer ).substr( 0, pos);
}
std::string GetFileInPath(std::string file)
{
std::string name = ExePath() + file;
struct stat buf;
if (stat(name.c_str(), &buf) != -1)
{
return name;
}
else
OnError(202, " \r\nFile not found: " + name);
return NULL;
}

View File

@@ -0,0 +1,117 @@
#include "TextButtonInstance.h"
TextButtonInstance::TextButtonInstance(void)
{
BaseButtonInstance::BaseButtonInstance();
boxBegin = Vector2(0,0);
boxEnd = Vector2(0,0);
fontLocationRelativeTo = Vector2(0,0);
centeredWithinBox = false;
title = "TextBox";
textColor = Color4(1, 1, 1, 1);
textOutlineColor = Color4(0, 0, 0, 0);
boxColor = Color4(0.6F,0.6F,0.6F,0.4F);
boxOutlineColor = Color4(0, 0, 0, 0);
setAllColorsSame();
textSize = 12;
floatBottom = false;
floatRight = false;
floatCenter = false;
visible = true;
className = "TextButton";
disabled = false;
selected = false;
}
bool TextButtonInstance::mouseInButton(float mousex, float mousey, RenderDevice* rd)
{
Vector3 point1;
Vector3 point2;
if(floatBottom)
{
point1 = Vector3(boxBegin.x, rd->getHeight() + boxBegin.y,0);
point2 = Vector3(boxEnd.x, rd->getHeight() + boxEnd.y,0);
}
else
{
point1 = Vector3(boxBegin.x, boxBegin.y,0);
point2 = Vector3(boxEnd.x, boxEnd.y,0);
}
if(mousex >= point1.x && mousey >= point1.y)
{
if(mousex < point2.x && mousey < point2.y)
{
return true;
}
}
return false;
}
void TextButtonInstance::setAllColorsSame()
{
textColorOvr = textColor;
textOutlineColorOvr = textOutlineColor;
boxColorOvr = boxColor;
boxOutlineColorOvr = boxOutlineColor;
textColorDn = textColor;
textOutlineColorDn = textOutlineColor;
boxColorDn = boxColor;
boxOutlineColorDn = boxOutlineColor;
textColorDis = textColor;
textOutlineColorDis = textOutlineColor;
boxColorDis = boxColor;
boxOutlineColorDis = boxOutlineColor;
}
TextButtonInstance::~TextButtonInstance(void)
{
}
void TextButtonInstance::drawObj(RenderDevice* rd, Vector2 mousePos, bool mouseDown)
{
Vector3 point1;
Vector3 point2;
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glDisableClientState(GL_COLOR_ARRAY);
if(floatBottom)
{
point1 = Vector3(boxBegin.x, rd->getHeight() + boxBegin.y,0);
point2 = Vector3(boxEnd.x, rd->getHeight() + boxEnd.y,0);
}
else
{
point1 = Vector3(boxBegin.x, boxBegin.y,0);
point2 = Vector3(boxEnd.x, boxEnd.y,0);
}
Vector2 RelativeTo = Vector2(point1.x + fontLocationRelativeTo.x, point1.y + fontLocationRelativeTo.y);
if(disabled)
{
Draw::box(Box(point1, point2), rd, boxColorDis, boxOutlineColorDis);
font->draw2D(rd, title, RelativeTo, textSize, textColorDis, textOutlineColorDis);
}
else if(mouseInArea(point1.x, point1.y, point2.x, point2.y, mousePos.x, mousePos.y) && mouseDown)
{
Draw::box(Box(point1, point2), rd, boxColorDn, boxOutlineColorDn);
font->draw2D(rd, title, RelativeTo, textSize, textColorDn, textOutlineColorDn);
}
else if(selected || mouseInArea(point1.x, point1.y, point2.x, point2.y, mousePos.x, mousePos.y))
{
Draw::box(Box(point1, point2), rd, boxColorOvr, boxOutlineColorOvr);
font->draw2D(rd, title, RelativeTo, textSize, textColorOvr, textOutlineColorOvr);
}
else
{
Draw::box(Box(point1, point2), rd, boxColor, boxOutlineColor);
font->draw2D(rd, title, RelativeTo, textSize, textColor, textOutlineColor);
}
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
glEnableClientState(GL_COLOR_ARRAY);
}
void doNullCheck()
{
}

View File

@@ -0,0 +1,12 @@
#include "TextureHandler.h"
TextureHandler::TextureHandler(void)
{
}
TextureHandler::~TextureHandler(void)
{
}
std::map<std::string, G3D::TextureRef> TextureHandler::volTex = std::map<std::string, G3D::TextureRef>();
std::map<std::string, G3D::RealTime> TextureHandler::volExp = std::map<std::string, G3D::RealTime>();
std::map<std::string, G3D::TextureRef> TextureHandler::permTex = std::map<std::string, G3D::TextureRef>();

View File

@@ -0,0 +1,139 @@
#include "ToggleImageButtonInstance.h"
ToggleImageButtonInstance::ToggleImageButtonInstance(G3D::TextureRef newImage,
G3D::TextureRef overImage,
G3D::TextureRef downImage,
G3D::TextureRef disableImage,
G3D::TextureRef newImage2,
G3D::TextureRef overImage2,
G3D::TextureRef downImage2,
G3D::TextureRef disableImage2) : ImageButtonInstance(newImage, overImage, downImage, disableImage)
{
image2 = newImage2;
openGLID2 = image2->getOpenGLID();
image_ovr2 = overImage2;
if(!image_ovr2.isNull())
openGLID2_ovr = image_ovr2->getOpenGLID();
image_dn2 = downImage2;
if(!image_dn2.isNull())
openGLID2_dn = image_dn2->getOpenGLID();
image_ds2 = disableImage2;
if(!image_ds2.isNull())
openGLID2_ds = image_ds2->getOpenGLID();
checked = false;
className = "ToggleImageButton";
}
ToggleImageButtonInstance::~ToggleImageButtonInstance(void)
{
//Delete everything on destruction
image2.~ReferenceCountedPointer();
delete image2.getPointer();
image_ovr2.~ReferenceCountedPointer();
delete image_ovr2.getPointer();
image_ds2.~ReferenceCountedPointer();
delete image_ds2.getPointer();
image_dn2.~ReferenceCountedPointer();
delete image_dn2.getPointer();
image = NULL;
image_ovr = NULL;
image_ds = NULL;
image_dn = NULL;
delete listener;
listener = NULL;
selected = false;
}
void ToggleImageButtonInstance::drawObj(RenderDevice* rd, Vector2 mousePos, bool mouseDown)
{
bool drawDisabledBox = false;
Vector2 positionRelative = position;
if(floatRight && floatBottom)
{
positionRelative = Vector2(rd->getWidth() + position.x, rd->getHeight() + position.y);
}
else if(floatBottom)
{
positionRelative = Vector2(position.x, rd->getHeight() + position.y);
}
else if(floatRight)
{
positionRelative = Vector2(rd->getWidth() + position.x, position.y);
}
int renderimage = openGLID;
if(checked)
{
renderimage = openGLID2;
if(selected == true && !image_dn2.isNull() && !disabled)
{
renderimage = openGLID2_dn;
}
else if(disabled)
{
if(!image_ds2.isNull())
renderimage = openGLID2_ds;
else
drawDisabledBox = true;
}
else if(mouseInArea(positionRelative.x, positionRelative.y, positionRelative.x + size.x, positionRelative.y + size.y, mousePos.x, mousePos.y))
{
if(mouseDown && !image_dn2.isNull())
{
renderimage = openGLID2_dn;
}
else if(!image_ovr2.isNull())
{
renderimage = openGLID2_ovr;
}
}
}
else
{
if(selected == true && !image_dn.isNull() && !disabled)
{
renderimage = openGLID_dn;
}
else if(disabled)
{
if(!image_ds.isNull())
renderimage = openGLID_ds;
else
drawDisabledBox = true;
}
else if(mouseInArea(positionRelative.x, positionRelative.y, positionRelative.x + size.x, positionRelative.y + size.y, mousePos.x, mousePos.y))
{
if(mouseDown && !image_dn.isNull())
{
renderimage = openGLID_dn;
}
else if(!image_ovr.isNull())
{
renderimage = openGLID_ovr;
}
}
}
glEnable( GL_TEXTURE_2D );
glEnable(GL_BLEND);// you enable blending function
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glBindTexture( GL_TEXTURE_2D, renderimage);
glBegin( GL_QUADS );
glTexCoord2d(0.0,0.0);
glVertex2f( positionRelative.x, positionRelative.y );
glTexCoord2d( 1.0,0.0 );
glVertex2f( positionRelative.x + size.x, positionRelative.y );
glTexCoord2d( 1.0,1.0 );
glVertex2f( positionRelative.x + size.x, positionRelative.y + size.y );
glTexCoord2d( 0.0,1.0 );
glVertex2f( positionRelative.x, positionRelative.y + size.y );
glEnd();
glDisable( GL_TEXTURE_2D );
if(drawDisabledBox)
{
Draw::box(Box(Vector3(positionRelative.x, positionRelative.y, 0), Vector3(positionRelative.x+size.x, positionRelative.y+size.y, 0)), rd, Color4(0.7F,0.7F,0.7F,0.3F), Color4::clear());
}
}

32
src/source/Tool.cpp Normal file
View File

@@ -0,0 +1,32 @@
#include "Tool.h"
Tool::Tool(void)
{
cursorString = GetFileInPath("/content/images/ArrowFarCursor.png");
//cursorId = cursorRef->openGLID();
}
Tool::~Tool(void)
{
}
void Tool::onButton1MouseDown(Mouse mouse){}
void Tool::onButton2MouseDown(Mouse mouse){}
void Tool::onButton3MouseDown(Mouse mouse){}
void Tool::onButton1MouseUp(Mouse mouse){}
void Tool::onButton2MouseUp(Mouse mouse){}
void Tool::onButton3MouseUp(Mouse mouse){}
void Tool::onMouseMoved(Mouse mouse){}
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);
}

View File

@@ -0,0 +1,23 @@
#include "ToolbarListener.h"
#include "Globals.h"
#include "StringFunctions.h"
#include "Application.h"
void ToolbarListener::onButton1MouseClick(BaseButtonInstance* btn)
{
if(TextButtonInstance* button = dynamic_cast<TextButtonInstance*>(btn))
{
for(size_t i = 0; i < btns.size(); i++)
btns[i]->selected = false;
button->selected = true;
if(button->title == "Model") g_usableApp->navigateToolbox("http://androdome.com/res/ClientToolbox.php");
else if(button->title == "Surface") g_usableApp->navigateToolbox(GetFileInPath("/content/page/surface.html"));
else if(button->title == "Color") g_usableApp->navigateToolbox(GetFileInPath("/content/page/color.html"));
else if(button->title == "Controller") g_usableApp->navigateToolbox(GetFileInPath("/content/page/controller.html"));
else if(button->title == "Hopper") g_usableApp->navigateToolbox(GetFileInPath("/content/page/hopper.html"));
}
}
void ToolbarListener::addButtonRef(BaseButtonInstance* button)
{
btns.push_back(button);
}

View File

@@ -0,0 +1,32 @@
#include "WindowFunctions.h"
#include <sstream>
#include <string>
using namespace std;
bool createWindowClass(const char* name,WNDPROC proc,HMODULE hInstance)
{
WNDCLASSEX wc;
wc.cbSize = sizeof(WNDCLASSEX);
wc.style = 0;
wc.lpfnWndProc = proc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = hInstance;
wc.hIcon = LoadIcon(NULL, IDI_APPLICATION);
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
wc.hbrBackground = (HBRUSH)(COLOR_WINDOW);
wc.lpszMenuName = NULL;
wc.lpszClassName = name;
wc.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
if (!RegisterClassEx (&wc))
{
stringstream errMsg;
errMsg<<"Failed to register " << name;
MessageBox(NULL, errMsg.str().c_str(),"Dynamica Crash", MB_OK);
return false;
}
return true;
}

View File

@@ -0,0 +1,14 @@
#include "WorkspaceInstance.h"
WorkspaceInstance::WorkspaceInstance(void)
{
GroupInstance::GroupInstance();
name = "Workspace";
className = "Workspace";
canDelete = false;
}
WorkspaceInstance::~WorkspaceInstance(void)
{
}

723
src/source/ax.cpp Normal file
View File

@@ -0,0 +1,723 @@
// AX.CPP
#include "ax.h"
#include "AudioPlayer.h"
#include "Enum.h"
#pragma warning (disable: 4311)
#pragma warning (disable: 4312)
#pragma warning (disable: 4244)
#pragma warning (disable: 4800)
// AXClientSite class
// ------- Implement member functions
AXClientSite :: AXClientSite()
{
refNum = 0;
CalledCanInPlace = 0;
InPlace = 0;
}
AXClientSite :: ~AXClientSite()
{
}
STDMETHODIMP AXClientSite :: ShowContextMenu(DWORD dwID, POINT *ppt, IUnknown *pcmdtReserved, IDispatch *pdispReserved)
{
return E_NOTIMPL;
}
STDMETHODIMP AXClientSite :: GetHostInfo(DOCHOSTUIINFO *pInfo)
{
return E_NOTIMPL;
}
STDMETHODIMP AXClientSite :: ShowUI( DWORD dwID, IOleInPlaceActiveObject *pActiveObject, IOleCommandTarget *pCommandTarget, IOleInPlaceFrame *pFrame, IOleInPlaceUIWindow *pDoc)
{
return E_NOTIMPL;
}
STDMETHODIMP AXClientSite :: HideUI( void)
{
return E_NOTIMPL;
}
STDMETHODIMP AXClientSite :: UpdateUI( void)
{
return E_NOTIMPL;
}
STDMETHODIMP AXClientSite :: OnDocWindowActivate(BOOL fActivate)
{
return E_NOTIMPL;
}
STDMETHODIMP AXClientSite :: OnFrameWindowActivate(BOOL fActivate)
{
return E_NOTIMPL;
}
STDMETHODIMP AXClientSite :: ResizeBorder( LPCRECT prcBorder, IOleInPlaceUIWindow *pUIWindow, BOOL fRameWindow)
{
return E_NOTIMPL;
}
STDMETHODIMP AXClientSite :: TranslateAccelerator( LPMSG lpMsg, const GUID *pguidCmdGroup, DWORD nCmdID)
{
return E_NOTIMPL;
}
STDMETHODIMP AXClientSite :: GetOptionKeyPath( LPOLESTR *pchKey, DWORD dw)
{
return E_NOTIMPL;
}
STDMETHODIMP AXClientSite :: GetDropTarget( IDropTarget *pDropTarget, IDropTarget **ppDropTarget)
{
return E_NOTIMPL;
}
STDMETHODIMP AXClientSite :: GetExternal(IDispatch **ppDispatch)
{
//IDispatch* disp = ax->GetExternalDispatch();
*ppDispatch = this;
/* if (disp!=NULL)
{
*ppDispatch = this;
return S_OK;
} */
return S_OK;
}
STDMETHODIMP AXClientSite ::TranslateUrl( DWORD dwTranslate, OLECHAR *pchURLIn, OLECHAR **ppchURLOut)
{
return E_NOTIMPL;
}
STDMETHODIMP AXClientSite :: FilterDataObject( IDataObject *pDO, IDataObject **ppDORet)
{
return E_NOTIMPL;
}
// IUnknown methods
STDMETHODIMP AXClientSite :: QueryInterface(REFIID iid,void**ppvObject)
{
*ppvObject = 0;
// if (iid == IID_IOleInPlaceSite)
// *ppvObject = (IOleInPlaceSite*)this;
if (iid == IID_IOleClientSite)
*ppvObject = (IOleClientSite*)this;
if (iid == IID_IUnknown)
*ppvObject = this;
if (iid == IID_IAdviseSink)
*ppvObject = (IAdviseSink*)this;
if (iid == IID_IDispatch)
*ppvObject = (IDispatch*)this;
//if (ExternalPlace == false)
{
if (iid == IID_IOleInPlaceSite)
*ppvObject = (IOleInPlaceSite*)this;
if (iid == IID_IOleInPlaceFrame)
*ppvObject = (IOleInPlaceFrame*)this;
if (iid == IID_IOleInPlaceUIWindow)
*ppvObject = (IOleInPlaceUIWindow*)this;
if (iid == IID_IDocHostUIHandler)
*ppvObject = (IDocHostUIHandler*)this;
}
//* Log Call
if (*ppvObject)
{
AddRef();
return S_OK;
}
return E_NOINTERFACE;
}
STDMETHODIMP_(ULONG) AXClientSite :: AddRef()
{
refNum++;
return refNum;
}
STDMETHODIMP_(ULONG) AXClientSite :: Release()
{
refNum--;
return refNum;
}
// IOleClientSite methods
STDMETHODIMP AXClientSite :: SaveObject()
{
return S_OK;
}
STDMETHODIMP AXClientSite :: GetMoniker(DWORD dwA,DWORD dwW,IMoniker**pm)
{
*pm = 0;
return E_NOTIMPL;
}
STDMETHODIMP AXClientSite :: GetContainer(IOleContainer**pc)
{
*pc = 0;
return E_FAIL;
}
STDMETHODIMP AXClientSite :: ShowObject()
{
return S_OK;
}
STDMETHODIMP AXClientSite :: OnShowWindow(BOOL f)
{
InvalidateRect(Window, 0, TRUE);
InvalidateRect(Parent, 0, TRUE);
return S_OK;
}
STDMETHODIMP AXClientSite :: RequestNewObjectLayout()
{
return S_OK;
}
STDMETHODIMP_(void) AXClientSite :: OnViewChange(DWORD dwAspect,LONG lIndex)
{
}
STDMETHODIMP_(void) AXClientSite :: OnRename(IMoniker * pmk)
{
}
STDMETHODIMP_(void) AXClientSite :: OnSave()
{
}
STDMETHODIMP_(void) AXClientSite :: OnClose()
{
}
// IOleInPlaceSite methods
STDMETHODIMP AXClientSite :: GetWindow(HWND *p)
{
*p = Window;
return S_OK;
}
STDMETHODIMP AXClientSite :: ContextSensitiveHelp(BOOL)
{
return E_NOTIMPL;
}
STDMETHODIMP AXClientSite :: CanInPlaceActivate()
{
if (InPlace)
{
CalledCanInPlace = true;
return S_OK;
}
return S_FALSE;
}
STDMETHODIMP AXClientSite :: OnInPlaceActivate()
{
return S_OK;
}
STDMETHODIMP AXClientSite :: OnUIActivate()
{
return S_OK;
}
STDMETHODIMP AXClientSite :: GetWindowContext(IOleInPlaceFrame** ppFrame,IOleInPlaceUIWindow **ppDoc,LPRECT r1,LPRECT r2,LPOLEINPLACEFRAMEINFO o)
{
*ppFrame = (IOleInPlaceFrame*)this;
AddRef();
*ppDoc = NULL;
GetClientRect(Window,r1);
GetClientRect(Window,r2);
o->cb = sizeof(OLEINPLACEFRAMEINFO);
o->fMDIApp = false;
o->hwndFrame = Parent;
o->haccel = 0;
o->cAccelEntries = 0;
return S_OK;
}
STDMETHODIMP AXClientSite :: Scroll(SIZE s)
{
return E_NOTIMPL;
}
STDMETHODIMP AXClientSite :: OnUIDeactivate(int)
{
return S_OK;
}
STDMETHODIMP AXClientSite :: OnInPlaceDeactivate()
{
return S_OK;
}
STDMETHODIMP AXClientSite :: DiscardUndoState()
{
return S_OK;
}
STDMETHODIMP AXClientSite :: DeactivateAndUndo()
{
return S_OK;
}
STDMETHODIMP AXClientSite :: OnPosRectChange(LPCRECT)
{
return S_OK;
}
// IOleInPlaceFrame methods
STDMETHODIMP AXClientSite :: GetBorder(LPRECT l)
{
GetClientRect(Window,l);
return S_OK;
}
STDMETHODIMP AXClientSite :: RequestBorderSpace(LPCBORDERWIDTHS b)
{
//return S_OK;
return E_NOTIMPL;
}
STDMETHODIMP AXClientSite :: SetBorderSpace(LPCBORDERWIDTHS b)
{
return S_OK;
}
STDMETHODIMP AXClientSite :: SetActiveObject(IOleInPlaceActiveObject*pV,LPCOLESTR s)
{
ax->Pao = pV;
return S_OK;
}
STDMETHODIMP AXClientSite :: SetStatusText(LPCOLESTR t)
{
return E_NOTIMPL;
}
STDMETHODIMP AXClientSite :: EnableModeless(BOOL f)
{
return E_NOTIMPL;
}
STDMETHODIMP AXClientSite :: TranslateAccelerator(LPMSG,WORD)
{
return E_NOTIMPL;
}
// IDispatch Methods
HRESULT _stdcall AXClientSite :: GetTypeInfoCount(
unsigned int * pctinfo) {return E_NOTIMPL;}
HRESULT _stdcall AXClientSite :: GetTypeInfo(
unsigned int iTInfo,
LCID lcid,
ITypeInfo FAR* FAR* ppTInfo)
{
return E_NOTIMPL;
}
HRESULT _stdcall AXClientSite :: GetIDsOfNames(
REFIID riid,
OLECHAR FAR* FAR* ext_function_name,
unsigned int cNames,
LCID lcid,
DISPID FAR* )
{
m_lastExternalName = *ext_function_name;
return S_OK;
}
// Other Methods
void AX :: Init(char* cls)
{
wchar_t x[1000] = {0};
MultiByteToWideChar(CP_ACP,0,cls,-1,x,1000);
CLSIDFromString(x,&clsid);
iid = (IID*)&IID_IOleObject;
OleObject = 0;
Storage = 0;
View = 0;
Data = 0;
Unk = 0;
Pao = 0;
AdviseToken = 0;
memset(DAdviseToken,0,sizeof(DAdviseToken));
Site.ax = this;
}
AX :: AX(char* cls)
{
Init(cls);
}
void AX :: Clean()
{
if (Site.InPlace == true)
{
Site.InPlace = false;
IOleInPlaceObject* iib = 0;
if (OleObject)
OleObject->QueryInterface(IID_IOleInPlaceObject,(void**)&iib);
if (iib)
{
iib->UIDeactivate();
iib->InPlaceDeactivate();
iib->Release();
}
}
if (AdviseToken && OleObject)
{
OleObject->Unadvise(AdviseToken);
AdviseToken = 0;
}
if (Data)
{
for(int i = 0 ; i < 100 ; i++)
if (DAdviseToken[i])
Data->DUnadvise(DAdviseToken[i]);
memset(DAdviseToken,0,sizeof(DAdviseToken));
}
if (Pao) Pao->Release();
if (Unk) Unk->Release();
if (Data) Data->Release();
if (View) View->Release();
if (Storage) Storage->Release();
if (OleObject) OleObject->Release();
Unk = 0;
Data = 0;
View = 0;
Storage = 0;
OleObject = 0;
}
AX :: ~AX()
{
Clean();
}
CLSID AX :: GetCLSID()
{
return clsid;
}
HRESULT _stdcall AXClientSite :: InsertMenus(HMENU h,LPOLEMENUGROUPWIDTHS x)
{
/* AX * t = (AX*)ax;
if (t->AddMenu)
{
x->width[0] = 0;
x->width[2] = 0;
x->width[4] = 0;
//InsertMenu(h,0,MF_BYPOSITION | MF_POPUP,(int)Menu,"test");
return S_OK;
}
*/
return E_NOTIMPL;
}
HRESULT _stdcall AXClientSite :: SetMenu(HMENU h,HOLEMENU hO,HWND hw)
{
AX * t = (AX*)ax;
/* if (t->AddMenu)
{
if (!h && !hO)
{
//::SetMenu(Window,Menu);
//DrawMenuBar(Window);
::SetMenu(Parent,Menu);
DrawMenuBar(Parent);
return S_OK;
}
//::SetMenu(Window,h);
//DrawMenuBar(Window);
//HMENU hm = GetMenu(Parent);
//AppendMenu(hm,MF_POPUP | MF_MENUBREAK,(int)h,0);
//::SetMenu(Parent,hm);
::SetMenu(Parent,h);
DrawMenuBar(Parent);
//hOleWindow = hw;
//OleSetMenuDescriptor(hO,Window,hw,0,0);
OleSetMenuDescriptor(hO,Parent,hw,0,0);
return S_OK;
}
*/
return E_NOTIMPL;
}
HRESULT _stdcall AXClientSite :: RemoveMenus(HMENU h)
{
AX * t = (AX*)ax;
if (t->AddMenu)
{
if (!h)
return S_OK;
int c = GetMenuItemCount(h);
for (int i = c ; i >= 0 ; i--)
{
HMENU hh = GetSubMenu(h,i);
if (hh == Menu)
RemoveMenu(h,i,MF_BYPOSITION);
}
if (h == Menu)
DestroyMenu(h);
//DrawMenuBar(Window);
DrawMenuBar(Parent);
return S_OK;
}
return E_NOTIMPL;
}
HRESULT _stdcall AXClientSite :: Invoke(
DISPID dispIdMember,
REFIID riid,
LCID lcid,
WORD wFlags,
DISPPARAMS FAR* pDispParams,
VARIANT FAR* pVarResult,
EXCEPINFO FAR* pExcepInfo,
unsigned int FAR* puArgErr)
{
IEBrowser * browser = (IEBrowser *)GetWindowLongPtr(Window,GWL_USERDATA+1);
return browser->doExternal(m_lastExternalName,dispIdMember, riid, lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
//return S_OK;
}
void _stdcall AXClientSite :: OnDataChange(FORMATETC *pFormatEtc,STGMEDIUM *pStgmed)
{
// Notify our app that a change is being requested
return;
}
// Window Procedure for AX control
LRESULT CALLBACK AXWndProc(HWND hh,UINT mm,WPARAM ww,LPARAM ll)
{
if (mm == WM_CREATE)
{
char tit[1000] = {0};
HRESULT hr;
GetWindowTextA(hh,tit,1000);
AX* ax;
ax = new AX(tit);
SetWindowLong(hh,GWL_USERDATA,(LONG)ax);
ax->Site.Window = hh;
ax->Site.Parent = GetParent(hh);
hr = StgCreateDocfile(0,STGM_READWRITE | STGM_SHARE_EXCLUSIVE | STGM_DIRECT | STGM_CREATE,0,&ax->Storage);
ax->Site.Window = hh;
REFIID rid = *ax->iid;
hr = OleCreate(ax->GetCLSID(),rid,OLERENDER_DRAW,0,&ax->Site,ax->Storage,(void**)&ax->OleObject);
if (!ax->OleObject)
{
delete ax;
SetWindowLong(hh,GWL_USERDATA,0);
return -1;
}
hr = OleSetContainedObject(ax->OleObject, TRUE);
hr = ax->OleObject->Advise(&ax->Site,&ax->AdviseToken);
hr = ax->OleObject->QueryInterface(IID_IViewObject,(void**)&ax->View);
hr = ax->OleObject->QueryInterface(IID_IDataObject,(void**)&ax->Data);
if (ax->View)
hr = ax->View->SetAdvise(DVASPECT_CONTENT,0,&ax->Site);
return 0;
}
if (mm == WM_DESTROY)
{
AX* ax = (AX*)GetWindowLong(hh,GWL_USERDATA);
if (!ax)
return 0;
ax->Clean();
return true;
}
if (mm == AX_SETDATAADVISE)
{
AX* ax = (AX*)GetWindowLong(hh,GWL_USERDATA);
if (!ax)
return 0;
// 1.Enum available FORMATETC structures
// 2.Set Data Advise specified to index ww
if (!ax->Data)
return 0;
IEnumFORMATETC* ief = 0;
int i = 0;
FORMATETC fe;
ax->Data->EnumFormatEtc((LPARAM)ll,&ief);
if (!ief)
return 0;
for(;;)
{
HRESULT hr = ief->Next(1,&fe,0);
if (hr != S_OK)
break;
if (ww == i)
break;
i++;
}
ief->Release();
if (ww == -1)
return i;
if (ax->Data)
ax->Data->DAdvise(&fe,0,&ax->Site,&ax->DAdviseToken[ww]);
return true;
}
if (mm == AX_GETAXINTERFACE)
{
AX* ax = (AX*)GetWindowLong(hh,GWL_USERDATA);
return (LONG)ax;
}
if (mm == AX_QUERYINTERFACE)
{
char* p = (char*)ww;
AX* ax = (AX*)GetWindowLong(hh,GWL_USERDATA);
if (!ax)
return 0;
return ax->OleObject->QueryInterface((REFIID)*p,(void**)ll);
}
if (mm == WM_LBUTTONDBLCLK)
{
PostMessage(hh,AX_INPLACE,1,0);
return 0;
}
if (mm == AX_INPLACE)
{
AX* ax = (AX*)GetWindowLong(hh,GWL_USERDATA);
if (!ax)
return 0;
if (!ax->OleObject)
return 0;
RECT rect;
HRESULT hr;
::GetClientRect(hh,&rect);
if (ax->Site.InPlace == false && ww == 1) // Activate In Place
{
ax->Site.InPlace = true;
ax->Site.ExternalPlace = ll;
hr = ax->OleObject->DoVerb(OLEIVERB_INPLACEACTIVATE,0,&ax->Site,0,hh,&rect);
InvalidateRect(hh,0,true);
return 1;
}
if (ax->Site.InPlace == true && ww == 0) // Deactivate
{
ax->Site.InPlace = false;
IOleInPlaceObject* iib;
ax->OleObject->QueryInterface(IID_IOleInPlaceObject,(void**)&iib);
if (iib)
{
iib->UIDeactivate();
iib->InPlaceDeactivate();
iib->Release();
InvalidateRect(hh,0,true);
return 1;
}
}
return 0;
}
if (mm == WM_SIZE)
{
AX* ax = (AX*)GetWindowLong(hh,GWL_USERDATA);
if (!ax)
return 0;
if (!ax->OleObject)
return 0;
DefWindowProc(hh,mm,ww,ll);
if (ax->Site.InPlace == true)
{
SendMessage(hh,AX_INPLACE,0,0);
InvalidateRect(hh,0,true);
SendMessage(hh,AX_INPLACE,1,0);
}
IOleInPlaceObject* pl;
ax->OleObject->QueryInterface(IID_IOleInPlaceObject,(void**)&pl);
if (!pl)
return 0;
RECT r;
GetClientRect(ax->Site.Window,&r);
pl->SetObjectRects(&r,&r);
pl->Release();
return 0;
}
return DefWindowProc(hh,mm,ww,ll);
}
// Registration function
ATOM AXRegister()
{
WNDCLASSEXA wC = {0};
wC.cbSize = sizeof(wC);
wC.style = CS_GLOBALCLASS | CS_DBLCLKS;
wC.lpfnWndProc = AXWndProc;
wC.cbWndExtra = 4;
wC.hInstance = GetModuleHandle(0);
wC.lpszClassName = "AX";
return RegisterClassExA(&wC);
}

4439
src/source/propertyGrid.cpp Normal file

File diff suppressed because it is too large Load Diff