Compare commits
1 Commits
DataModelR
...
0.0.12
| Author | SHA1 | Date | |
|---|---|---|---|
| 88f99db867 |
112
AudioPlayer.cpp
@@ -1,112 +0,0 @@
|
|||||||
#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");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
#include <G3DAll.h>
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
class AudioPlayer
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
AudioPlayer(void);
|
|
||||||
~AudioPlayer(void);
|
|
||||||
static void playSound(std::string);
|
|
||||||
static void init();
|
|
||||||
};
|
|
||||||
@@ -1,51 +0,0 @@
|
|||||||
#include "BaseButtonInstance.h"
|
|
||||||
|
|
||||||
bool floatBottom = false;
|
|
||||||
bool floatRight = false;
|
|
||||||
bool floatCenter = false;
|
|
||||||
bool disabled = false;
|
|
||||||
bool selected = false;
|
|
||||||
ButtonListener* listener = NULL;
|
|
||||||
|
|
||||||
BaseButtonInstance::BaseButtonInstance(void)
|
|
||||||
{
|
|
||||||
listener = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
BaseButtonInstance::~BaseButtonInstance(void)
|
|
||||||
{
|
|
||||||
delete listener;
|
|
||||||
}
|
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
@@ -1,23 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
#include "instance.h"
|
|
||||||
#pragma once
|
|
||||||
#include "ButtonListener.h"
|
|
||||||
class ButtonListener;
|
|
||||||
class BaseButtonInstance : public Instance
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
BaseButtonInstance(void);
|
|
||||||
virtual ~BaseButtonInstance(void);
|
|
||||||
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;
|
|
||||||
bool disabled;
|
|
||||||
bool selected;
|
|
||||||
protected:
|
|
||||||
bool mouseInArea(float, float, float, float, float, float);
|
|
||||||
class ButtonListener* listener;
|
|
||||||
};
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
#include "ButtonListener.h"
|
|
||||||
|
|
||||||
|
|
||||||
ButtonListener::ButtonListener(void)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
ButtonListener::~ButtonListener(void)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void ButtonListener::onButton1MouseClick(BaseButtonInstance* button)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
#include "BaseButtonInstance.h"
|
|
||||||
class BaseButtonInstance;
|
|
||||||
class ButtonListener
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
ButtonListener(void);
|
|
||||||
~ButtonListener(void);
|
|
||||||
virtual void onButton1MouseClick(BaseButtonInstance*);
|
|
||||||
//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...
|
|
||||||
};
|
|
||||||
@@ -1,27 +0,0 @@
|
|||||||
#include "DataModelInstance.h"
|
|
||||||
|
|
||||||
|
|
||||||
WorkspaceInstance* workspace;
|
|
||||||
Instance* guiRoot;
|
|
||||||
|
|
||||||
DataModelInstance::DataModelInstance(void)
|
|
||||||
{
|
|
||||||
workspace = new WorkspaceInstance();
|
|
||||||
guiRoot = new Instance();
|
|
||||||
children.push_back(workspace);
|
|
||||||
className = "dataModel";
|
|
||||||
}
|
|
||||||
|
|
||||||
DataModelInstance::~DataModelInstance(void)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
WorkspaceInstance* DataModelInstance::getWorkspace()
|
|
||||||
{
|
|
||||||
return workspace;
|
|
||||||
}
|
|
||||||
|
|
||||||
Instance* DataModelInstance::getGuiRoot()
|
|
||||||
{
|
|
||||||
return guiRoot;
|
|
||||||
}
|
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
#include "instance.h"
|
|
||||||
#include "WorkspaceInstance.h"
|
|
||||||
|
|
||||||
class DataModelInstance :
|
|
||||||
public Instance
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
DataModelInstance(void);
|
|
||||||
~DataModelInstance(void);
|
|
||||||
WorkspaceInstance* getWorkspace();
|
|
||||||
Instance* getGuiRoot();
|
|
||||||
};
|
|
||||||
BIN
Dialogs.aps
40
Dialogs.rc
@@ -46,37 +46,6 @@ END
|
|||||||
|
|
||||||
#endif // APSTUDIO_INVOKED
|
#endif // APSTUDIO_INVOKED
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
|
||||||
//
|
|
||||||
// Dialog
|
|
||||||
//
|
|
||||||
|
|
||||||
IDD_TOOLBOX DIALOGEX 0, 0, 398, 64
|
|
||||||
STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD
|
|
||||||
FONT 8, "MS Shell Dlg", 0, 0, 0x0
|
|
||||||
BEGIN
|
|
||||||
CONTROL "",IDC_TOOLBOX_BROWSER,
|
|
||||||
"{A8F8E829-06DA-11D2-8D70-00A0C98B28E2}",WS_TABSTOP,0,0,398,64
|
|
||||||
END
|
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
|
||||||
//
|
|
||||||
// Dialog Info
|
|
||||||
//
|
|
||||||
|
|
||||||
IDD_TOOLBOX DLGINIT
|
|
||||||
BEGIN
|
|
||||||
IDC_TOOLBOX_BROWSER, 0x376, 76, 0
|
|
||||||
0x0000, 0x0000, 0xb293, 0x0000, 0x0048, 0x0000, 0x0003, 0x0008, 0xf20b,
|
|
||||||
0x4757, 0x0020, 0x0000, 0x005f, 0x0065, 0x0078, 0x0074, 0x0065, 0x006e,
|
|
||||||
0x0074, 0x0078, 0x3db4, 0x0000, 0x0003, 0x0008, 0xf20a, 0x4757, 0xffe0,
|
|
||||||
0xffff, 0x005f, 0x0065, 0x0078, 0x0074, 0x0065, 0x006e, 0x0074, 0x0079,
|
|
||||||
0x0ac0, 0x0000,
|
|
||||||
0
|
|
||||||
END
|
|
||||||
|
|
||||||
#endif // English (U.S.) resources
|
#endif // English (U.S.) resources
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
@@ -123,15 +92,6 @@ BEGIN
|
|||||||
END
|
END
|
||||||
#endif // APSTUDIO_INVOKED
|
#endif // APSTUDIO_INVOKED
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
|
||||||
//
|
|
||||||
// Icon
|
|
||||||
//
|
|
||||||
|
|
||||||
// Icon with lowest ID value placed first to ensure application icon
|
|
||||||
// remains consistent on all systems.
|
|
||||||
IDI_ICON1 ICON "icon1.ico"
|
|
||||||
#endif // English (Canada) resources
|
#endif // English (Canada) resources
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|||||||
BIN
G3DTest.suo
Normal file
@@ -51,7 +51,7 @@
|
|||||||
InlineFunctionExpansion="1"
|
InlineFunctionExpansion="1"
|
||||||
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS"
|
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS"
|
||||||
StringPooling="true"
|
StringPooling="true"
|
||||||
RuntimeLibrary="2"
|
RuntimeLibrary="0"
|
||||||
EnableFunctionLevelLinking="true"
|
EnableFunctionLevelLinking="true"
|
||||||
PrecompiledHeaderFile=".\Release/G3DTest.pch"
|
PrecompiledHeaderFile=".\Release/G3DTest.pch"
|
||||||
AssemblerListingLocation=".\Release/"
|
AssemblerListingLocation=".\Release/"
|
||||||
@@ -73,7 +73,7 @@
|
|||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCLinkerTool"
|
Name="VCLinkerTool"
|
||||||
OutputFile="./G3DTest.exe"
|
OutputFile=".\Release/G3DTest.exe"
|
||||||
LinkIncremental="1"
|
LinkIncremental="1"
|
||||||
SuppressStartupBanner="true"
|
SuppressStartupBanner="true"
|
||||||
ProgramDatabaseFile=".\Release/G3DTest.pdb"
|
ProgramDatabaseFile=".\Release/G3DTest.pdb"
|
||||||
@@ -167,7 +167,7 @@
|
|||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCLinkerTool"
|
Name="VCLinkerTool"
|
||||||
OutputFile="./G3DTest-Debug.exe"
|
OutputFile=".\Debug/G3DTest.exe"
|
||||||
LinkIncremental="2"
|
LinkIncremental="2"
|
||||||
SuppressStartupBanner="true"
|
SuppressStartupBanner="true"
|
||||||
GenerateDebugInformation="true"
|
GenerateDebugInformation="true"
|
||||||
@@ -230,18 +230,14 @@
|
|||||||
Name="Source Files"
|
Name="Source Files"
|
||||||
Filter="cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
|
Filter="cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
|
||||||
>
|
>
|
||||||
<File
|
|
||||||
RelativePath=".\AudioPlayer.cpp"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath=".\ButtonListener.cpp"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
<File
|
||||||
RelativePath=".\Dialogs.rc"
|
RelativePath=".\Dialogs.rc"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\Instance.cpp"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath="main.cpp"
|
RelativePath="main.cpp"
|
||||||
>
|
>
|
||||||
@@ -262,102 +258,34 @@
|
|||||||
/>
|
/>
|
||||||
</FileConfiguration>
|
</FileConfiguration>
|
||||||
</File>
|
</File>
|
||||||
<Filter
|
<File
|
||||||
Name="Instances"
|
RelativePath=".\PhysicalInstance.cpp"
|
||||||
>
|
>
|
||||||
<File
|
</File>
|
||||||
RelativePath=".\BaseButtonInstance.cpp"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath=".\DataModelInstance.cpp"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath=".\ImageButtonInstance.cpp"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath=".\Instance.cpp"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath=".\PhysicalInstance.cpp"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath=".\TextButtonInstance.cpp"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath=".\WorkspaceInstance.cpp"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
</Filter>
|
|
||||||
</Filter>
|
</Filter>
|
||||||
<Filter
|
<Filter
|
||||||
Name="Header Files"
|
Name="Header Files"
|
||||||
Filter="h;hpp;hxx;hm;inl"
|
Filter="h;hpp;hxx;hm;inl"
|
||||||
>
|
>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\AudioPlayer.h"
|
RelativePath=".\Instance.h"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\ButtonListener.h"
|
RelativePath=".\PhysicalInstance.h"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\resource.h"
|
RelativePath=".\resource.h"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
<Filter
|
|
||||||
Name="Instances"
|
|
||||||
>
|
|
||||||
<File
|
|
||||||
RelativePath=".\BaseButtonInstance.h"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath=".\DataModelInstance.h"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath=".\ImageButtonInstance.h"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath=".\Instance.h"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath=".\PhysicalInstance.h"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath=".\TextButtonInstance.h"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath=".\WorkspaceInstance.h"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
</Filter>
|
|
||||||
</Filter>
|
</Filter>
|
||||||
<Filter
|
<Filter
|
||||||
Name="Resource Files"
|
Name="Resource Files"
|
||||||
Filter="ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
|
Filter="ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
|
||||||
>
|
>
|
||||||
<File
|
|
||||||
RelativePath=".\icon1.ico"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
</Filter>
|
</Filter>
|
||||||
</Files>
|
</Files>
|
||||||
<Globals>
|
<Globals>
|
||||||
<Global
|
|
||||||
Name="RESOURCE_FILE"
|
|
||||||
Value="Dialogs.rc"
|
|
||||||
/>
|
|
||||||
</Globals>
|
</Globals>
|
||||||
</VisualStudioProject>
|
</VisualStudioProject>
|
||||||
|
|||||||
@@ -1,144 +0,0 @@
|
|||||||
#include "ImageButtonInstance.h"
|
|
||||||
G3D::TextureRef image = NULL;
|
|
||||||
int openGLID = 0;
|
|
||||||
G3D::TextureRef image_ovr = NULL;
|
|
||||||
int openGLID_ovr = 0;
|
|
||||||
G3D::TextureRef image_dn = NULL;
|
|
||||||
int openGLID_dn = 0;
|
|
||||||
G3D::TextureRef image_ds = NULL;
|
|
||||||
int openGLID_ds = 0;
|
|
||||||
Vector2 size;
|
|
||||||
Vector2 position;
|
|
||||||
ImageButtonInstance::ImageButtonInstance(G3D::TextureRef newImage, G3D::TextureRef overImage = NULL, G3D::TextureRef downImage = NULL, G3D::TextureRef disableImage = NULL)
|
|
||||||
{
|
|
||||||
|
|
||||||
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())
|
|
||||||
{
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
rd->pushState();
|
|
||||||
rd->beforePrimitive();
|
|
||||||
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 );
|
|
||||||
rd->afterPrimitive();
|
|
||||||
rd->popState();
|
|
||||||
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());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,24 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
#include "BaseButtonInstance.h"
|
|
||||||
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*);
|
|
||||||
};
|
|
||||||
92
Instance.cpp
@@ -1,105 +1,21 @@
|
|||||||
#define WINVER 0x0400
|
|
||||||
#include <G3DAll.h>
|
#include <G3DAll.h>
|
||||||
#include "Instance.h"
|
#include "Instance.h"
|
||||||
|
|
||||||
std::string name;
|
std::string name;
|
||||||
Instance* parent = NULL;
|
Instance* parent;
|
||||||
std::vector<Instance* > children;
|
static std::string className = "Instance";
|
||||||
static std::string className = "BaseInstance";
|
|
||||||
|
|
||||||
Instance::Instance(void)
|
Instance::Instance(void)
|
||||||
{
|
{
|
||||||
parent = NULL;
|
|
||||||
name = "Default Game Instance";
|
name = "Default Game Instance";
|
||||||
className = "BaseInstance";
|
className = "Part";
|
||||||
}
|
|
||||||
|
|
||||||
void Instance::render(RenderDevice* rd)
|
|
||||||
{
|
|
||||||
for(size_t i = 0; i < children.size(); i++)
|
|
||||||
{
|
|
||||||
children.at(i)->render(rd);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Instance::~Instance(void)
|
Instance::~Instance(void)
|
||||||
{
|
{
|
||||||
for(size_t i = 0; i < children.size(); i++)
|
name = "Default Game Instance";
|
||||||
{
|
|
||||||
delete children.at(i);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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::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)
|
|
||||||
{
|
|
||||||
Instance* child = NULL;
|
|
||||||
for(size_t i = 0; i < children.size(); i++)
|
|
||||||
{
|
|
||||||
if(children.at(i)->name == name)
|
|
||||||
{
|
|
||||||
child = children.at(i);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return child;
|
|
||||||
}
|
|
||||||
|
|||||||
16
Instance.h
@@ -1,23 +1,11 @@
|
|||||||
#include <G3DAll.h>
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
class Instance
|
class Instance
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Instance(void);
|
Instance(void);
|
||||||
virtual ~Instance(void);
|
~Instance(void);
|
||||||
std::string name;
|
std::string name;
|
||||||
virtual void render(RenderDevice*);
|
|
||||||
std::vector<Instance*> children; // All children.
|
|
||||||
std::string getClassName();
|
|
||||||
Instance* findFirstChild(std::string);
|
|
||||||
std::vector<Instance* > getChildren();
|
|
||||||
std::vector<Instance* > getAllChildren();
|
|
||||||
void setParent(Instance*);
|
|
||||||
void addChild(Instance*);
|
|
||||||
void removeChild(Instance*);
|
|
||||||
Instance* getParent();
|
|
||||||
protected:
|
|
||||||
std::string className;
|
|
||||||
Instance* parent; // Another pointer.
|
Instance* parent; // Another pointer.
|
||||||
|
std::string className;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,15 +1,13 @@
|
|||||||
|
#include <G3DAll.h>
|
||||||
#include "PhysicalInstance.h"
|
#include "PhysicalInstance.h"
|
||||||
|
|
||||||
bool canCollide = true;
|
bool canCollide = true;
|
||||||
bool anchored = false;
|
bool anchored = false;
|
||||||
Vector3 size;
|
Vector3 size;
|
||||||
Vector3 position;
|
Vector3 position;
|
||||||
Vector3 velocity;
|
Vector3 velocity;
|
||||||
Vector3 rotVelocity;
|
Vector3 rotVelocity;
|
||||||
CoordinateFrame cFrame;
|
|
||||||
Color3 color;
|
Color3 color;
|
||||||
bool changed = true;
|
|
||||||
Box itemBox = Box();
|
|
||||||
|
|
||||||
|
|
||||||
PhysicalInstance::PhysicalInstance(void)
|
PhysicalInstance::PhysicalInstance(void)
|
||||||
{
|
{
|
||||||
@@ -19,97 +17,13 @@ PhysicalInstance::PhysicalInstance(void)
|
|||||||
anchored = true;
|
anchored = true;
|
||||||
size = Vector3(2,1,4);
|
size = Vector3(2,1,4);
|
||||||
position = Vector3(0,0,0);
|
position = Vector3(0,0,0);
|
||||||
cFrame = CoordinateFrame(position);
|
|
||||||
color = Color3::gray();
|
color = Color3::gray();
|
||||||
velocity = Vector3(0,0,0);
|
velocity = Vector3(0,0,0);
|
||||||
rotVelocity = Vector3(0,0,0);
|
rotVelocity = Vector3(0,0,0);
|
||||||
}
|
}
|
||||||
void PhysicalInstance::setSize(Vector3 newSize)
|
|
||||||
{
|
|
||||||
int minsize = 1;
|
|
||||||
int maxsize = 512;
|
|
||||||
changed = true;
|
|
||||||
int sizex = (int)newSize.x;
|
|
||||||
if(sizex <= 0)
|
|
||||||
sizex = 1;
|
|
||||||
if(sizex > 512)
|
|
||||||
sizex = 512;
|
|
||||||
|
|
||||||
int sizey = (int)newSize.y;
|
|
||||||
if(sizey <= 0)
|
|
||||||
sizey = 1;
|
|
||||||
if(sizey > 512)
|
|
||||||
sizey = 512;
|
|
||||||
|
|
||||||
int sizez = (int)newSize.z;
|
|
||||||
if(sizez <= 0)
|
|
||||||
sizez = 1;
|
|
||||||
if(sizez > 512)
|
|
||||||
sizez = 512;
|
|
||||||
|
|
||||||
size = Vector3(sizex, sizey, sizez);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
Vector3 PhysicalInstance::getSize()
|
|
||||||
{
|
|
||||||
return size;
|
|
||||||
}
|
|
||||||
Vector3 PhysicalInstance::getPosition()
|
|
||||||
{
|
|
||||||
return position;
|
|
||||||
}
|
|
||||||
void PhysicalInstance::setPosition(Vector3 pos)
|
|
||||||
{
|
|
||||||
position = pos;
|
|
||||||
cFrame = CoordinateFrame(pos);
|
|
||||||
changed = true;
|
|
||||||
}
|
|
||||||
CoordinateFrame PhysicalInstance::getCFrame()
|
|
||||||
{
|
|
||||||
return cFrame;
|
|
||||||
}
|
|
||||||
void PhysicalInstance::setCFrame(CoordinateFrame coordinateFrame)
|
|
||||||
{
|
|
||||||
cFrame = coordinateFrame;
|
|
||||||
position = coordinateFrame.translation;
|
|
||||||
changed = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
CoordinateFrame PhysicalInstance::getCFrameRenderBased()
|
|
||||||
{
|
|
||||||
return CoordinateFrame(getCFrame().rotation,Vector3(getCFrame().translation.x/2, getCFrame().translation.y/2, getCFrame().translation.z/2));
|
|
||||||
}
|
|
||||||
|
|
||||||
Box PhysicalInstance::getBox()
|
|
||||||
{
|
|
||||||
if(changed)
|
|
||||||
{
|
|
||||||
Box box = Box(Vector3(0+size.x/4, 0+size.y/4, 0+size.z/4) ,Vector3(0-size.x/4,0-size.y/4,0-size.z/4));
|
|
||||||
CoordinateFrame c = getCFrameRenderBased();
|
|
||||||
itemBox = c.toWorldSpace(box);
|
|
||||||
}
|
|
||||||
return itemBox;
|
|
||||||
}
|
|
||||||
|
|
||||||
void PhysicalInstance::render(RenderDevice* rd)
|
|
||||||
{
|
|
||||||
Draw::box(getBox(), rd, color, Color4::clear());
|
|
||||||
if(!children.empty())
|
|
||||||
{
|
|
||||||
for(size_t i = 0; i < children.size(); i++)
|
|
||||||
{
|
|
||||||
children.at(i)->render(rd);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
PhysicalInstance::~PhysicalInstance(void)
|
PhysicalInstance::~PhysicalInstance(void)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -7,20 +7,9 @@ class PhysicalInstance :
|
|||||||
public:
|
public:
|
||||||
PhysicalInstance(void);
|
PhysicalInstance(void);
|
||||||
~PhysicalInstance(void);
|
~PhysicalInstance(void);
|
||||||
virtual void render(RenderDevice*);
|
Vector3 size;
|
||||||
|
Vector3 position;
|
||||||
Vector3 velocity;
|
Vector3 velocity;
|
||||||
Vector3 rotvelocity;
|
Vector3 rotvelocity;
|
||||||
CoordinateFrame cFrame;
|
|
||||||
Color3 color;
|
Color3 color;
|
||||||
Vector3 getPosition();
|
|
||||||
void setPosition(Vector3);
|
|
||||||
CoordinateFrame getCFrame();
|
|
||||||
void setCFrame(CoordinateFrame);
|
|
||||||
Box getBox();
|
|
||||||
CoordinateFrame getCFrameRenderBased();
|
|
||||||
Vector3 getSize();
|
|
||||||
void setSize(Vector3);
|
|
||||||
private:
|
|
||||||
Vector3 position;
|
|
||||||
Vector3 size;
|
|
||||||
};
|
};
|
||||||
|
|||||||
14
README.md
@@ -1,14 +0,0 @@
|
|||||||
# G3D-Fun
|
|
||||||
|
|
||||||
Despite its name, this is actually a recreation of ROBLOX as it was in 2005. Early development. Uses roughly time-accurate development tools.
|
|
||||||
|
|
||||||
# COMPILE WITH
|
|
||||||
|
|
||||||
Graphics3D 6.10 (Released July 21, 2006)
|
|
||||||
SDL 1.2.7 (1.2.9 could work as well)
|
|
||||||
Visual Studio 2005 Professional or Visual Studio 2005 Express with Platform SDK
|
|
||||||
|
|
||||||
# NOTE
|
|
||||||
|
|
||||||
Please know that there currently is no documentation and minimal commenting. As such, it may be confusing to follow the code.
|
|
||||||
Code for this project is written quickly at random intervals, where each individual thinks of a solution to a problem and adds it.
|
|
||||||
@@ -1,121 +0,0 @@
|
|||||||
#include "TextButtonInstance.h"
|
|
||||||
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;
|
|
||||||
bool centeredWithinBox;
|
|
||||||
std::string title;
|
|
||||||
G3D::GFontRef* font;
|
|
||||||
int textSize;
|
|
||||||
|
|
||||||
bool visible;
|
|
||||||
|
|
||||||
TextButtonInstance::TextButtonInstance(void)
|
|
||||||
{
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
TextButtonInstance::~TextButtonInstance(void)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void TextButtonInstance::drawObj(RenderDevice* rd, Vector2 mousePos, bool mouseDown)
|
|
||||||
{
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
Vector2 RelativeTo = Vector2(point1.x + fontLocationRelativeTo.x, point1.y + fontLocationRelativeTo.y);
|
|
||||||
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(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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void doNullCheck()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
@@ -1,31 +0,0 @@
|
|||||||
#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;
|
|
||||||
bool centeredWithinBox;
|
|
||||||
std::string title;
|
|
||||||
G3D::GFontRef font;
|
|
||||||
bool visible;
|
|
||||||
int textSize;
|
|
||||||
void drawObj(RenderDevice*, Vector2, bool);
|
|
||||||
bool mouseInButton(float, float, RenderDevice*);
|
|
||||||
};
|
|
||||||
@@ -1,14 +0,0 @@
|
|||||||
#include "WorkspaceInstance.h"
|
|
||||||
float timer = 60.0F;
|
|
||||||
int score = 0;
|
|
||||||
|
|
||||||
WorkspaceInstance::WorkspaceInstance(void)
|
|
||||||
{
|
|
||||||
className = "Workspace";
|
|
||||||
timer = 60.0F;
|
|
||||||
score = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
WorkspaceInstance::~WorkspaceInstance(void)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
#include "instance.h"
|
|
||||||
|
|
||||||
class WorkspaceInstance :
|
|
||||||
public Instance
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
float timer;
|
|
||||||
int score;
|
|
||||||
WorkspaceInstance(void);
|
|
||||||
~WorkspaceInstance(void);
|
|
||||||
};
|
|
||||||
75
building.md
@@ -1,75 +0,0 @@
|
|||||||
# Building Setup
|
|
||||||
|
|
||||||
##### G3D is super delicate, meaning that you have to go about building in a special way
|
|
||||||
|
|
||||||
#### Skip to steps 7-13 if you have already built this program
|
|
||||||
|
|
||||||
1. Install Visual Studio 2005. Google where to find it. Make note of which version you downloaded.
|
|
||||||
|
|
||||||
2. Download and install G3D from [this link here](https://sourceforge.net/projects/g3d/files/g3d-cpp/6.10/g3d-6_10_win32.exe/download).
|
|
||||||
|
|
||||||
3. Make sure G3D is included under your build directories by going under Tools -> Options -> Projects and Solutions -> VC++ Directories and check and see if:
|
|
||||||
|
|
||||||
* `g3d-6_10\bin` is under executable files
|
|
||||||
|
|
||||||
* `g3d-6_10\include` is under include files
|
|
||||||
|
|
||||||
* `g3d-6_10\bin` is under executable files
|
|
||||||
|
|
||||||
* `g3d-6_10\win32-vc8-lib` is under library files
|
|
||||||
|
|
||||||
* Ex: `C:\libraries\g3d-6_10\bin`
|
|
||||||
|
|
||||||
4. Download SDL version 1.2.7 from [this link](http://www.libsdl.org/release/SDL-devel-1.2.7-VC6.zip)
|
|
||||||
|
|
||||||
5. Extract the file to a folder on your computer. Keep note of this folder.
|
|
||||||
|
|
||||||
6. Include the extracted files by going to Tools -> Options -> Projects and Solutions -> VC++ Directories and adding the following links:
|
|
||||||
|
|
||||||
* Include files - extractpath\`include`
|
|
||||||
|
|
||||||
* Library files - extractpath\`lib`
|
|
||||||
|
|
||||||
* Ex: `C:\libraries\SDL-1.2.7\bin`
|
|
||||||
|
|
||||||
#### Steps 7-11 are optional if you are using Visual Studio Professional. Check the Error stuff section if it doesn't work, most reference steps from here.
|
|
||||||
|
|
||||||
7. Download and install the [platform SDK](https://www.microsoft.com/en-us/download/details.aspx?id=6510).
|
|
||||||
|
|
||||||
8. Put the platform SDK into your directories (Tools -> Options -> Projects and Solutions -> VC++ Directories) by replacing all mentions of $(VCInstallDir)PlatformSDK with the actual path.
|
|
||||||
Ex: `$(VCInstallDir)PlatformSDK\include` -> `C:\Program Files\Microsoft Platform SDK\Include`
|
|
||||||
|
|
||||||
9. Right click Source files -> Dialogs.rc -> View Code
|
|
||||||
|
|
||||||
10. Edit line 10 to say
|
|
||||||
```cpp
|
|
||||||
#include "WinResrc.h"
|
|
||||||
#define IDC_STATIC -1
|
|
||||||
```
|
|
||||||
|
|
||||||
instead of
|
|
||||||
|
|
||||||
```cpp
|
|
||||||
#include "afxres.h"
|
|
||||||
```
|
|
||||||
|
|
||||||
11. Right click the project -> Properties -> Configuration Properties -> Linker -> Input, and add `AdvAPI32.lib` under Additional Dependencies.
|
|
||||||
|
|
||||||
### Continue back here if you're skipping steps 7-11
|
|
||||||
|
|
||||||
12. Right click the project -> Properties -> Configuration Properties -> Linker -> General, and make sure Additional Library Directories is blank.
|
|
||||||
|
|
||||||
13. Try building using Build -> Build G3DTest.
|
|
||||||
|
|
||||||
|
|
||||||
## Error stuff
|
|
||||||
|
|
||||||
```c:\libraries\g3d-6_10\include\G3D/platform.h(235) : fatal error C1083: Cannot open include file: 'windows.h': No such file or directory``` > Download and install platform SDK (lines 7-8)
|
|
||||||
|
|
||||||
```G3D-debug.lib(RegistryUtil.obj) : error LNK2019: unresolved external symbol __imp__RegCloseKey@4 referenced in function "public: static bool __cdecl G3D::RegistryUtil::keyExists(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (?keyExists@RegistryUtil@G3D@@SA_NABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z)``` > Add AdvAPI32.lib under Additional Dependencies (step 11)
|
|
||||||
|
|
||||||
```.\Dialogs.rc(10) : fatal error RC1015: cannot open include file 'afxres.h'.``` > Perform steps 9-10
|
|
||||||
|
|
||||||
Enjoy!
|
|
||||||
|
|
||||||
please report unfriendliness of this page
|
|
||||||
|
Before Width: | Height: | Size: 576 B |
|
Before Width: | Height: | Size: 637 B |
BIN
content/font/adventure.fnt
Normal file
BIN
content/font/anglo-small.fnt
Normal file
BIN
content/font/anglo.fnt
Normal file
BIN
content/font/arial-small.fnt
Normal file
BIN
content/font/arial.fnt
Normal file
BIN
content/font/arialblack-small.fnt
Normal file
BIN
content/font/arialblack.fnt
Normal file
BIN
content/font/arialround.fnt
Normal file
BIN
content/font/ariaround-small.fnt
Normal file
BIN
content/font/bahaus-small.fnt
Normal file
BIN
content/font/bahaus.fnt
Normal file
BIN
content/font/baskerville-small.fnt
Normal file
BIN
content/font/baskerville.fnt
Normal file
BIN
content/font/britannic-small.fnt
Normal file
BIN
content/font/britannic.fnt
Normal file
BIN
content/font/broadway-small.fnt
Normal file
BIN
content/font/broadway.fnt
Normal file
BIN
content/font/bubble-small.fnt
Normal file
BIN
content/font/bubble.fnt
Normal file
BIN
content/font/burton-small.fnt
Normal file
BIN
content/font/burton.fnt
Normal file
BIN
content/font/century-small.fnt
Normal file
BIN
content/font/century.fnt
Normal file
BIN
content/font/colonna-small.fnt
Normal file
BIN
content/font/colonna.fnt
Normal file
BIN
content/font/cooper-small.fnt
Normal file
BIN
content/font/cooper.fnt
Normal file
BIN
content/font/courier-small.fnt
Normal file
BIN
content/font/curly-small.fnt
Normal file
BIN
content/font/curly.fnt
Normal file
BIN
content/font/desmonda-small.fnt
Normal file
BIN
content/font/desmonda.fnt
Normal file
BIN
content/font/diner-small.fnt
Normal file
BIN
content/font/diner.fnt
Normal file
BIN
content/font/elephant-small.fnt
Normal file
BIN
content/font/elephant.fnt
Normal file
BIN
content/font/emperor-small.fnt
Normal file
BIN
content/font/emperor.fnt
Normal file
BIN
content/font/eurostyle-small.fnt
Normal file
BIN
content/font/eurostyle.fnt
Normal file
BIN
content/font/federation.fnt
Normal file
BIN
content/font/gradl-small.fnt
Normal file
BIN
content/font/gradl.fnt
Normal file
BIN
content/font/led.fnt
Normal file
BIN
content/font/leditalic.fnt
Normal file
BIN
content/font/news.fnt
Normal file
BIN
content/font/note-small.fnt
Normal file
BIN
content/font/note.fnt
Normal file
BIN
content/font/onyx-small.fnt
Normal file
BIN
content/font/onyx.fnt
Normal file
BIN
content/font/pricedown.fnt
Normal file
BIN
content/font/sansserif.fnt
Normal file
BIN
content/font/saxon-small.fnt
Normal file
BIN
content/font/saxon.fnt
Normal file
BIN
content/font/shadowed-small.fnt
Normal file
BIN
content/font/shadowed.fnt
Normal file
BIN
content/font/stencil-small.fnt
Normal file
BIN
content/font/stencil.fnt
Normal file
BIN
content/font/terminal.fnt
Normal file
BIN
content/font/times-small.fnt
Normal file
BIN
content/font/times.fnt
Normal file
BIN
content/font/venusrising-small.fnt
Normal file
BIN
content/font/venusrising.fnt
Normal file
BIN
content/font/videophreak-small.fnt
Normal file
BIN
content/font/videophreak.fnt
Normal file
BIN
content/font/widelatin-small.fnt
Normal file
BIN
content/font/widelatin.fnt
Normal file
|
Before Width: | Height: | Size: 4.2 KiB After Width: | Height: | Size: 4.2 KiB |
|
Before Width: | Height: | Size: 1.2 KiB |
|
Before Width: | Height: | Size: 955 B |
|
Before Width: | Height: | Size: 971 B |
|
Before Width: | Height: | Size: 1.5 KiB |
|
Before Width: | Height: | Size: 1.2 KiB |
|
Before Width: | Height: | Size: 1.2 KiB |