84 Commits
0.0.14 ... cb3

Author SHA1 Message Date
andreja6
1cae1135b9 Merge pull request #15 from andreja6/sound
Added sound and sound effects
2018-04-27 09:19:54 -07:00
andreja6
f78ca49ec0 Added try/catch 2018-04-27 09:18:48 -07:00
andreja6
e9c7607a4b Added init check 2018-04-27 00:04:04 -07:00
andreja6
6d49e266dd Made AudioPlayer's play and init method static 2018-04-26 21:41:07 -07:00
andreja6
78cdb01ef1 changed how bitrate is set 2018-04-26 21:28:22 -07:00
andreja6
1ed434c858 removed useless arial fonts 2018-04-26 20:11:36 -07:00
andreja6
f4acbaacdc Added camera click 2018-04-26 20:07:19 -07:00
andreja6
e777f3ccc4 Added sound system
Added delete sound
2018-04-26 20:01:37 -07:00
andreja6
9e61c9e4d2 Fixed bad operator 2018-04-26 13:36:57 -07:00
andreja6
3fb730ceba Merge pull request #14 from andreja6/raycasting-part-selection
Added delete functionality
2018-04-26 13:35:15 -07:00
andreja6
811ac871a3 Added delete functionality 2018-04-26 11:57:04 -07:00
andreja6
54ed0299c0 Merge pull request #13 from andreja6/bevels
Bevels
2018-04-26 11:18:28 -07:00
andreja6
09fcd72e43 Changed shade mode 2018-04-26 11:17:54 -07:00
andreja6
0371836dc8 Attempted to make bevel code 2018-04-26 11:15:41 -07:00
andreja6
74e423e9f8 Added code to unlock mouse on message box 2018-04-25 21:32:28 -07:00
andreja6
9868937c08 Merge branch 'master' of https://github.com/andreja6/G3D-Fun 2018-04-25 14:39:04 -07:00
andreja6
5c500859a3 Removed dialog test on 'U' 2018-04-25 14:38:55 -07:00
andreja6
1274a8deca Merge pull request #12 from andreja6/buttons
Added button listeners, added some buttons, Made window use HWND rather than SDL
2018-04-25 14:36:03 -07:00
andreja6
4bbd82b715 Merge pull request #11 from andreja6/window
Now uses HWND rather than an SDL Window
2018-04-25 14:35:21 -07:00
andreja6
827e610b8c Added selected in button class
Basically active, it will probably be renamed
2018-04-25 14:34:27 -07:00
andreja6
10f3a25c54 Changed how selection boxes are rendered 2018-04-25 14:17:33 -07:00
andreja6
e650d4afbc Removed useless images 2018-04-25 05:58:33 -07:00
andreja6
d738a804e6 Changed some images, Added camera button listeners 2018-04-24 22:00:46 -07:00
andreja6
1f7c5b28f8 Test of forward button 2018-04-24 20:24:34 -07:00
andreja6
a9d533e447 YAY 2018-04-24 19:35:53 -07:00
andreja6
a9f91c8a9e Changed how window works
Controls now work
2018-04-24 19:17:49 -07:00
andreja6
04f1ac813e Controller still broken but window size works 2018-04-24 19:02:48 -07:00
andreja6
2b2672b9fd Now resizes with hwnd
but controls are dead asgassdsad
2018-04-24 18:23:07 -07:00
andreja6
d0bba08f3a Controlls dont work 2018-04-24 18:11:29 -07:00
andreja6
3f222b75d8 Tried adding dialog and main window 2018-04-24 18:01:26 -07:00
andreja6
560245e005 Im not sure what changed 2018-04-24 17:20:04 -07:00
andreja6
cbd680a6ac Changed the way blocks are rendered 2018-04-24 17:13:04 -07:00
andreja6
f6b301a836 Added click listener to TextButton 2018-04-24 12:44:24 -07:00
andreja6
d1a1ebd016 Added mouse click functions to image button
Added destructor for images
Deleting listener now on exit
2018-04-24 12:39:53 -07:00
andreja6
9ffe37c21a Fixed issue with disabled images 2018-04-24 00:59:03 -07:00
andreja6
30aa99ff0b Changed how the scale disabled icon looks 2018-04-24 00:35:57 -07:00
andreja6
3ee0075f1d Added scale tool image 2018-04-24 00:34:34 -07:00
andreja6
05da8e2270 Added "disabled" bool to button
Changed null check
2018-04-23 23:40:58 -07:00
andreja6
68ac692314 Added final GUI components 2018-04-23 23:25:06 -07:00
andreja6
a4176510b9 Changed class organization 2018-04-23 22:05:41 -07:00
andreja6
55e890bdc1 Made BaseButton class
Buttons now children of BaseButton
Buttons now render over and down modes
Text buttons now exist
Buttons render differently
2018-04-23 22:02:12 -07:00
andreja6
98d3358fd5 Added resize, cursor, and arrows mode
Added selection box rendering
Added arrow rendering
added resize rendering
2018-04-23 20:09:01 -07:00
andreja6
68edb442d3 Mouse now stays where you left it 2018-04-23 17:53:41 -07:00
andreja6
20e8c63d5c Changed how the camera works
Added arrow key controlled camera
Removed WASD camera movement
FPS is now locked to 30 Frames P/S
Mouse wheel now moves the camera
2018-04-23 17:51:03 -07:00
andreja6
5d8e4bc040 Merge pull request #10 from andreja6/HWND
Hwnd
2018-04-23 14:09:23 -07:00
andreja6
71cf1e39f3 Delete stdafx.h 2018-04-23 21:09:05 +00:00
andreja6
21be7a4c73 Delete Work.cpp 2018-04-23 21:08:08 +00:00
andreja6
e7df4b26f0 Merge pull request #8 from andreja6/dialogui
Added test dialog
2018-04-23 14:04:41 -07:00
andreja6
11788fa37c Changed the way controllerflags are rendered, they work now 2018-04-23 11:35:02 -07:00
andreja6
e29ad28a06 Test of hover text 2018-04-22 23:32:36 -07:00
andreja6
9d30c2aed7 Tried doing stuff with fonts 2018-04-22 22:52:50 -07:00
andreja6
c62df67db2 Changed default DataModel name to "undefined" 2018-04-22 21:09:43 -07:00
andreja6
c9e997c794 Added mouse cursors 2018-04-22 20:44:29 -07:00
andreja6
8a6d7d0d8d added new line 2018-04-22 19:57:12 -07:00
andreja6
6cea4397f2 Changed window to SDL, can now access bare HWND component 2018-04-22 19:51:14 -07:00
andreja6
f0fffa71d4 Tried something 2018-04-22 15:05:45 -07:00
andreja6
49c117d5d7 Removed MFC 2018-04-22 12:32:37 -07:00
andreja6
19913cb665 Added base class for button listening
Fixed a few memory leaks
2018-04-20 18:55:55 -07:00
andreja6
810488e20c Added test dialog 2018-04-20 06:59:37 -07:00
andreja6
a91bc4c5b5 Reverted to old sln 2018-04-19 22:26:57 -07:00
andreja6
45e28f96dc Merge branch 'master' of https://github.com/andreja6/G3D-Fun 2018-04-19 21:57:29 -07:00
andreja6
b521f1c86f Fixed solution 2018-04-19 21:57:26 -07:00
andreja6
1d4082bdd0 Merge pull request #7 from andreja6/guiinstance
Fixed names
2018-04-19 21:45:04 -07:00
andreja6
df6cee3e11 Fixed names 2018-04-19 21:44:30 -07:00
andreja6
15e1868fc2 Merge pull request #6 from andreja6/guiinstance
Merge Guiinstance
2018-04-19 21:42:11 -07:00
andreja6
113115b6df Changed the way releases compile 2018-04-19 21:41:03 -07:00
andreja6
2445d076a1 Reset Solution 2018-04-19 21:36:31 -07:00
andreja6
8fc8549a6c Added deprication notice to debug mode 2018-04-19 20:42:11 -07:00
andreja6
bb3aac25c5 put drawButton in its class, and not in main loop 2018-04-19 20:30:30 -07:00
andreja6
09fa95d4a0 Added dialog 2018-04-19 19:40:15 -07:00
andreja6
acd87e351b Made test work on offset 2018-04-19 18:17:19 -07:00
andreja6
8d53e8ff0f Removed useless debug comments and code 2018-04-19 18:07:48 -07:00
andreja6
b900e918b4 Converted most menu buttons to TextButton, No longer hard coded
Removed useless values
MUCH faster now!
2018-04-19 18:03:12 -07:00
andreja6
067a744cda Changed className TextButtonInstance to TextButton to match naming convention 2018-04-19 17:19:02 -07:00
andreja6
3e4c128347 Added bare bones TextButton rendering
(Yes, it took that many lines of code)
2018-04-19 17:18:26 -07:00
andreja6
acbe509c05 Fixed errors
Changed bit depth
2018-04-19 00:15:16 -07:00
andreja6
1bb0c6eb6f Removed broken image 2018-04-18 23:56:10 -07:00
andreja6
8889494848 Removed unneded font 2018-04-18 23:55:21 -07:00
andreja6
8a780d6f0b Added some images 2018-04-18 23:53:32 -07:00
andreja6
0a2b508290 Added down state
-Added mouse down state
-Commented out useless function
-Added temporary default value to ovr_id
-Added temporary images go_dn and go_dn_id
-Removed debug spacing increase and decrease key press code (causes crashes by design and was useless)
2018-04-18 22:50:31 -07:00
andreja6
33e3aeb16e Commented out useless function 2018-04-18 20:42:15 -07:00
andreja6
4526fa68df Added mouseover testing, will be moved to instances 2018-04-18 20:39:36 -07:00
andreja6
acfd499cfb GO BUTTON TEXTURE!
YES!
2018-04-18 19:56:48 -07:00
andreja6
b12c753179 Added visible and float booleans 2018-04-13 20:09:20 -07:00
56 changed files with 2397 additions and 812 deletions

113
AudioPlayer.cpp Normal file
View File

@@ -0,0 +1,113 @@
#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());
exit(1);
}
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");
}
}

11
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();
};

51
BaseButtonInstance.cpp Normal file
View File

@@ -0,0 +1,51 @@
#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;
}

23
BaseButtonInstance.h Normal file
View File

@@ -0,0 +1,23 @@
#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;
};

15
ButtonListener.cpp Normal file
View File

@@ -0,0 +1,15 @@
#include "ButtonListener.h"
ButtonListener::ButtonListener(void)
{
}
ButtonListener::~ButtonListener(void)
{
}
void ButtonListener::onButton1MouseClick(BaseButtonInstance* button)
{
}

18
ButtonListener.h Normal file
View File

@@ -0,0 +1,18 @@
#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...
};

Binary file not shown.

View File

@@ -52,33 +52,15 @@ END
// Dialog // Dialog
// //
IDD_TOOLBOX DIALOGEX 0, 0, 368, 77 IDD_TOOLBOX DIALOGEX 0, 0, 398, 64
STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD
FONT 8, "MS Shell Dlg", 0, 0, 0x0 FONT 8, "MS Shell Dlg", 0, 0, 0x0
BEGIN BEGIN
CONTROL "",IDC_AXBROWSER1,"{A8F8E829-06DA-11D2-8D70-00A0C98B28E2}",WS_TABSTOP,7,7,354,63 CONTROL "",IDC_TOOLBOX_BROWSER,
"{A8F8E829-06DA-11D2-8D70-00A0C98B28E2}",WS_TABSTOP,0,0,398,64
END END
/////////////////////////////////////////////////////////////////////////////
//
// DESIGNINFO
//
#ifdef APSTUDIO_INVOKED
GUIDELINES DESIGNINFO
BEGIN
IDD_TOOLBOX, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 361
TOPMARGIN, 7
BOTTOMMARGIN, 70
END
END
#endif // APSTUDIO_INVOKED
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// //
// Dialog Info // Dialog Info
@@ -86,12 +68,12 @@ END
IDD_TOOLBOX DLGINIT IDD_TOOLBOX DLGINIT
BEGIN BEGIN
IDC_AXBROWSER1, 0x376, 76, 0 IDC_TOOLBOX_BROWSER, 0x376, 76, 0
0x0000, 0x0000, 0xb293, 0x0000, 0x0048, 0x0000, 0x0003, 0x0008, 0xf20b, 0x0000, 0x0000, 0xb293, 0x0000, 0x0048, 0x0000, 0x0003, 0x0008, 0xf20b,
0x4757, 0x0020, 0x0000, 0x005f, 0x0065, 0x0078, 0x0074, 0x0065, 0x006e, 0x4757, 0x0020, 0x0000, 0x005f, 0x0065, 0x0078, 0x0074, 0x0065, 0x006e,
0x0074, 0x0078, 0x36e1, 0x0000, 0x0003, 0x0008, 0xf20a, 0x4757, 0xffe0, 0x0074, 0x0078, 0x3db4, 0x0000, 0x0003, 0x0008, 0xf20a, 0x4757, 0xffe0,
0xffff, 0x005f, 0x0065, 0x0078, 0x0074, 0x0065, 0x006e, 0x0074, 0x0079, 0xffff, 0x005f, 0x0065, 0x0078, 0x0074, 0x0065, 0x006e, 0x0074, 0x0079,
0x0a8b, 0x0000, 0x0ac0, 0x0000,
0 0
END END
@@ -141,6 +123,15 @@ 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
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////

Binary file not shown.

View File

@@ -51,7 +51,7 @@
InlineFunctionExpansion="1" InlineFunctionExpansion="1"
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS" PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS"
StringPooling="true" StringPooling="true"
RuntimeLibrary="0" RuntimeLibrary="2"
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=".\Release/G3DTest.exe" OutputFile="./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=".\Debug/G3DTest.exe" OutputFile="./G3DTest-Debug.exe"
LinkIncremental="2" LinkIncremental="2"
SuppressStartupBanner="true" SuppressStartupBanner="true"
GenerateDebugInformation="true" GenerateDebugInformation="true"
@@ -230,10 +230,26 @@
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=".\BaseButtonInstance.cpp"
>
</File>
<File
RelativePath=".\ButtonListener.cpp"
>
</File>
<File <File
RelativePath=".\Dialogs.rc" RelativePath=".\Dialogs.rc"
> >
</File> </File>
<File
RelativePath=".\ImageButtonInstance.cpp"
>
</File>
<File <File
RelativePath=".\Instance.cpp" RelativePath=".\Instance.cpp"
> >
@@ -271,6 +287,22 @@
Name="Header Files" Name="Header Files"
Filter="h;hpp;hxx;hm;inl" Filter="h;hpp;hxx;hm;inl"
> >
<File
RelativePath=".\AudioPlayer.h"
>
</File>
<File
RelativePath=".\BaseButtonInstance.h"
>
</File>
<File
RelativePath=".\ButtonListener.h"
>
</File>
<File
RelativePath=".\ImageButtonInstance.h"
>
</File>
<File <File
RelativePath=".\Instance.h" RelativePath=".\Instance.h"
> >
@@ -292,6 +324,10 @@
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>

144
ImageButtonInstance.cpp Normal file
View File

@@ -0,0 +1,144 @@
#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());
}
}

24
ImageButtonInstance.h Normal file
View File

@@ -0,0 +1,24 @@
#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*);
};

View File

@@ -1,14 +1,15 @@
#define WINVER 0x0400
#include <G3DAll.h> #include <G3DAll.h>
#include "Instance.h" #include "Instance.h"
std::string name; std::string name;
Instance* parent; Instance* parent;
static std::string className = "Instance"; static std::string className = "DataModel";
Instance::Instance(void) Instance::Instance(void)
{ {
name = "Default Game Instance"; name = "Default Game Instance";
className = "Part"; className = "DataModel";
} }
Instance::~Instance(void) Instance::~Instance(void)

View File

@@ -5,7 +5,7 @@ class Instance
{ {
public: public:
Instance(void); Instance(void);
~Instance(void); virtual ~Instance(void);
std::string name; std::string name;
Instance* parent; // Another pointer. Instance* parent; // Another pointer.
std::string className; std::string className;

View File

@@ -6,6 +6,7 @@ Vector3 size;
Vector3 position; Vector3 position;
Vector3 velocity; Vector3 velocity;
Vector3 rotVelocity; Vector3 rotVelocity;
CoordinateFrame cFrame;
Color3 color; Color3 color;
PhysicalInstance::PhysicalInstance(void) PhysicalInstance::PhysicalInstance(void)
@@ -16,13 +17,36 @@ 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);
} }
Vector3 PhysicalInstance::getPosition()
{
return position;
}
void PhysicalInstance::setPosition(Vector3 pos)
{
position = pos;
cFrame = CoordinateFrame(pos);
}
CoordinateFrame PhysicalInstance::getCFrame()
{
return cFrame;
}
void PhysicalInstance::setCFrame(CoordinateFrame coordinateFrame)
{
cFrame = coordinateFrame;
position = coordinateFrame.translation;
}
PhysicalInstance::~PhysicalInstance(void) PhysicalInstance::~PhysicalInstance(void)
{ {
} }

View File

@@ -8,8 +8,14 @@ public:
PhysicalInstance(void); PhysicalInstance(void);
~PhysicalInstance(void); ~PhysicalInstance(void);
Vector3 size; 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);
private:
Vector3 position;
}; };

View File

@@ -16,9 +16,10 @@ Color4 boxColorDn;
Color4 boxOutlineColorDn; Color4 boxOutlineColorDn;
bool centeredWithinBox; bool centeredWithinBox;
std::string title; std::string title;
G3D::GFontRef font; G3D::GFontRef* font;
int textSize; int textSize;
bool visible;
TextButtonInstance::TextButtonInstance(void) TextButtonInstance::TextButtonInstance(void)
{ {
@@ -31,10 +32,90 @@ TextButtonInstance::TextButtonInstance(void)
textOutlineColor = Color4(0, 0, 0, 0); textOutlineColor = Color4(0, 0, 0, 0);
boxColor = Color4(0.6F,0.6F,0.6F,0.4F); boxColor = Color4(0.6F,0.6F,0.6F,0.4F);
boxOutlineColor = Color4(0, 0, 0, 0); boxOutlineColor = Color4(0, 0, 0, 0);
setAllColorsSame();
textSize = 12; 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) 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()
{
}

View File

@@ -1,12 +1,11 @@
#pragma once #pragma once
#include "instance.h" #include "BaseButtonInstance.h"
class TextButtonInstance : public BaseButtonInstance
class TextButtonInstance :
public Instance
{ {
public: public:
TextButtonInstance(void); TextButtonInstance(void);
~TextButtonInstance(void); ~TextButtonInstance(void);
void setAllColorsSame();
Vector2 boxBegin; Vector2 boxBegin;
Vector2 boxEnd; Vector2 boxEnd;
Vector2 fontLocationRelativeTo; Vector2 fontLocationRelativeTo;
@@ -25,4 +24,8 @@ public:
bool centeredWithinBox; bool centeredWithinBox;
std::string title; std::string title;
G3D::GFontRef font; G3D::GFontRef font;
bool visible;
int textSize;
void drawObj(RenderDevice*, Vector2, bool);
bool mouseInButton(float, float, RenderDevice*);
}; };

BIN
content/cursor.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 576 B

BIN
content/cursor2.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 637 B

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
content/font/comics.fnt Normal file

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 955 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 971 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.7 KiB

BIN
content/sounds/SWITCH3.wav Normal file

Binary file not shown.

BIN
content/sounds/pageturn.wav Normal file

Binary file not shown.

View File

Before

Width:  |  Height:  |  Size: 4.2 KiB

After

Width:  |  Height:  |  Size: 4.2 KiB

1596
main.cpp

File diff suppressed because it is too large Load Diff

View File

@@ -2,18 +2,18 @@
// Microsoft Visual C++ generated include file. // Microsoft Visual C++ generated include file.
// Used by Dialogs.rc // Used by Dialogs.rc
// //
#define IDD_TOOLBOX 101
#define IDD_ABOUT_DIALOG 102 #define IDD_ABOUT_DIALOG 102
#define IDC_AXBROWSER1 1001 #define IDD_TOOLBOX 103
#define IDC_BUTTON1 1002 #define IDI_ICON1 106
#define IDC_TOOLBOX_BROWSER 1001
// Next default values for new objects // Next default values for new objects
// //
#ifdef APSTUDIO_INVOKED #ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS #ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 106 #define _APS_NEXT_RESOURCE_VALUE 107
#define _APS_NEXT_COMMAND_VALUE 40004 #define _APS_NEXT_COMMAND_VALUE 40004
#define _APS_NEXT_CONTROL_VALUE 1003 #define _APS_NEXT_CONTROL_VALUE 1002
#define _APS_NEXT_SYMED_VALUE 101 #define _APS_NEXT_SYMED_VALUE 101
#endif #endif
#endif #endif